Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove stringformat #1206

Merged
merged 1 commit into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
"semver": "6.3.0",
"semver-extra": "3.0.0",
"serialize-error": "4.1.0",
"stringformat": "0.0.5",
"targz": "1.0.1",
"try-require": "^1.2.1",
"yargs": "13.3.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

const format = require('stringformat');

const strings = require('../../../resources');

module.exports = (options, cb) => {
Expand All @@ -11,7 +9,7 @@ module.exports = (options, cb) => {

const err = isOk
? null
: format(strings.errors.cli.TEMPLATE_DEP_MISSING, template, componentPath);
: strings.errors.cli.TEMPLATE_DEP_MISSING(template, componentPath);

cb(err, compilerDep);
};
4 changes: 1 addition & 3 deletions src/cli/domain/handle-dependencies/install-compiler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

const format = require('stringformat');

const cleanRequire = require('../../../utils/clean-require');
const isTemplateValid = require('../../../utils/is-template-valid');
const npm = require('../../../utils/npm-utils');
Expand All @@ -10,7 +8,7 @@ const strings = require('../../../resources/index');
module.exports = (options, cb) => {
const { compilerPath, componentPath, dependency, logger } = options;

logger.warn(format(strings.messages.cli.INSTALLING_DEPS, dependency), true);
logger.warn(strings.messages.cli.INSTALLING_DEPS(dependency), true);

const npmOptions = {
dependency,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const format = require('stringformat');
const path = require('path');
const _ = require('lodash');

Expand All @@ -17,10 +16,7 @@ module.exports = (options, callback) => {
return callback(null);
}

logger.warn(
format(strings.messages.cli.INSTALLING_DEPS, missing.join(', ')),
true
);
logger.warn(strings.messages.cli.INSTALLING_DEPS(missing.join(', ')), true);

const npmOptions = {
dependencies: missing,
Expand Down
10 changes: 2 additions & 8 deletions src/cli/domain/handle-dependencies/link-missing-dependencies.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const format = require('stringformat');
const _ = require('lodash');
const path = require('path');
const fs = require('fs-extra');
Expand All @@ -18,10 +17,7 @@ module.exports = (options, callback) => {
}

logger.warn(
format(
strings.messages.cli.LINKING_DEPENDENCIES,
missingDependencies.join(', ')
),
strings.messages.cli.LINKING_DEPENDENCIES(missingDependencies.join(', ')),
true
);

Expand All @@ -39,9 +35,7 @@ module.exports = (options, callback) => {
fs.ensureSymlinkSync(pathToComponentModule, pathToModule, symLinkType);
} catch (err) {
symLinkError = true;
logger.err(
format(strings.errors.cli.DEPENDENCY_LINK_FAIL, moduleName, err)
);
logger.err(strings.errors.cli.DEPENDENCY_LINK_FAIL(moduleName, err));
}
});
return !symLinkError
Expand Down
7 changes: 2 additions & 5 deletions src/cli/domain/handle-dependencies/require-template.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const format = require('stringformat');
const path = require('path');

const cleanRequire = require('../../../utils/clean-require');
Expand Down Expand Up @@ -35,13 +34,11 @@ module.exports = function(template, options) {
);

if (!ocTemplate) {
throw new Error(format(strings.errors.cli.TEMPLATE_NOT_FOUND, template));
throw new Error(strings.errors.cli.TEMPLATE_NOT_FOUND(template));
}

if (!isTemplateValid(ocTemplate, requireOptions)) {
throw new Error(
format(strings.errors.cli.TEMPLATE_TYPE_NOT_VALID, template)
);
throw new Error(strings.errors.cli.TEMPLATE_TYPE_NOT_VALID(template));
}

return ocTemplate;
Expand Down
3 changes: 1 addition & 2 deletions src/cli/facade/clean.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const format = require('stringformat');
const read = require('read');

const strings = require('../../resources/index');
Expand Down Expand Up @@ -44,7 +43,7 @@ module.exports = function(dependencies) {

fetchList(opts.dirPath, (err, list) => {
if (err) {
logger.err(format(strings.errors.generic, err));
logger.err(strings.errors.generic(err));
return callback(err);
}

Expand Down
25 changes: 8 additions & 17 deletions src/cli/facade/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const async = require('async');
const colors = require('colors/safe');
const format = require('stringformat');
const getPort = require('getport');
const livereload = require('livereload');
const path = require('path');
Expand Down Expand Up @@ -36,9 +35,9 @@ module.exports = function(dependencies) {
const watchForChanges = function({ components, refreshLiveReload }, cb) {
watch(components, componentsDir, (err, changedFile, componentDir) => {
if (err) {
logger.err(format(strings.errors.generic, err));
logger.err(strings.errors.generic(err));
} else {
logger.warn(format(cliMessages.CHANGES_DETECTED, changedFile));
logger.warn(cliMessages.CHANGES_DETECTED(changedFile));
if (!hotReloading) {
logger.warn(cliMessages.HOT_RELOADING_DISABLED);
} else if (!componentDir) {
Expand Down Expand Up @@ -81,11 +80,7 @@ module.exports = function(dependencies) {
? error.message
: error;
logger.err(
format(
cliErrors.PACKAGING_FAIL,
componentsDirs[i],
errorDescription
)
cliErrors.PACKAGING_FAIL(componentsDirs[i], errorDescription)
);
logger.warn(cliMessages.RETRYING_10_SECONDS);
setTimeout(() => {
Expand All @@ -109,8 +104,7 @@ module.exports = function(dependencies) {
registry.on('request', data => {
if (data.errorCode === 'PLUGIN_MISSING_FROM_REGISTRY') {
logger.err(
format(
cliErrors.PLUGIN_MISSING_FROM_REGISTRY,
cliErrors.PLUGIN_MISSING_FROM_REGISTRY(
data.errorDetails,
colors.blue(strings.commands.cli.MOCK_PLUGIN)
)
Expand All @@ -122,7 +116,7 @@ module.exports = function(dependencies) {
logger.warn(cliMessages.SCANNING_COMPONENTS, true);
local.getComponentsByDir(componentsDir, (err, components) => {
if (_.isEmpty(components)) {
err = format(cliErrors.DEV_FAIL, cliErrors.COMPONENTS_NOT_FOUND);
err = cliErrors.DEV_FAIL(cliErrors.COMPONENTS_NOT_FOUND);
callback(err);
return logger.err(err);
}
Expand Down Expand Up @@ -181,19 +175,16 @@ module.exports = function(dependencies) {

registerPlugins(registry);

logger.warn(format(cliMessages.REGISTRY_STARTING, baseUrl));
logger.warn(cliMessages.REGISTRY_STARTING(baseUrl));
if (liveReload.port) {
logger.warn(
format(
cliMessages.REGISTRY_LIVERELOAD_STARTING,
liveReload.port
)
cliMessages.REGISTRY_LIVERELOAD_STARTING(liveReload.port)
);
}
registry.start(err => {
if (err) {
if (err.code === 'EADDRINUSE') {
err = format(cliErrors.PORT_IS_BUSY, port);
err = cliErrors.PORT_IS_BUSY(port);
}

logger.err(err);
Expand Down
5 changes: 2 additions & 3 deletions src/cli/facade/init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

const format = require('stringformat');
const path = require('path');
const _ = require('lodash');

Expand Down Expand Up @@ -35,9 +34,9 @@ module.exports = function(dependencies) {
}

if (err === 'template type not valid') {
err = format(errors.TEMPLATE_TYPE_NOT_VALID, templateType);
err = errors.TEMPLATE_TYPE_NOT_VALID(templateType);
}
logger.err(format(errors.INIT_FAIL, err));
logger.err(errors.INIT_FAIL(err));
} else {
logger.log(messages.initSuccess(componentName, componentPath));
}
Expand Down
8 changes: 1 addition & 7 deletions src/cli/facade/mock.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

const format = require('stringformat');

const strings = require('../../resources/index');
const wrapCliCallback = require('../wrap-cli-callback');

Expand All @@ -14,11 +12,7 @@ module.exports = function(dependencies) {

local.mock(opts, (err, res) => {
logger.ok(
format(
strings.messages.cli.MOCKED_PLUGIN,
opts.targetName,
opts.targetValue
)
strings.messages.cli.MOCKED_PLUGIN(opts.targetName, opts.targetValue)
);
callback(err, res);
});
Expand Down
17 changes: 6 additions & 11 deletions src/cli/facade/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const strings = require('../../resources/index');
const wrapCliCallback = require('../wrap-cli-callback');
const format = require('stringformat');
const path = require('path');
const handleDependencies = require('../domain/handle-dependencies');

Expand All @@ -18,7 +17,7 @@ module.exports = function(dependencies) {

callback = wrapCliCallback(callback);

logger.warn(format(strings.messages.cli.PACKAGING, packageDir));
logger.warn(strings.messages.cli.PACKAGING(packageDir));
handleDependencies(
{
components: [path.resolve(componentPath)],
Expand All @@ -36,27 +35,23 @@ module.exports = function(dependencies) {
};
local.package(packageOptions, (err, component) => {
if (err) {
logger.err(format(strings.errors.cli.PACKAGE_CREATION_FAIL, err));
logger.err(strings.errors.cli.PACKAGE_CREATION_FAIL(err));
return callback(err);
}

logger.ok(format(strings.messages.cli.PACKAGED, packageDir));
logger.ok(strings.messages.cli.PACKAGED(packageDir));

if (opts.compress) {
logger.warn(
format(strings.messages.cli.COMPRESSING, compressedPackagePath)
strings.messages.cli.COMPRESSING(compressedPackagePath)
);

local.compress(packageDir, compressedPackagePath, err => {
if (err) {
logger.err(
format(strings.errors.cli.PACKAGE_CREATION_FAIL, err)
);
logger.err(strings.errors.cli.PACKAGE_CREATION_FAIL(err));
return callback(err);
}
logger.ok(
format(strings.messages.cli.COMPRESSED, compressedPackagePath)
);
logger.ok(strings.messages.cli.COMPRESSED(compressedPackagePath));
callback(null, component);
});
} else {
Expand Down
Loading