dotcom-tool-kit 1.0.0-beta.3 → 1.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +26 -18
- package/lib/help.js +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +27 -2
- package/lib/install.d.ts.map +1 -1
- package/lib/install.js +17 -5
- package/lib/messages.d.ts.map +1 -1
- package/lib/messages.js +7 -5
- package/lib/plugin.js +14 -14
- package/lib/rc-file.js +1 -1
- package/package.json +7 -4
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAoB,MAAM,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAmC,MAAM,YAAY,CAAA;AAYtE,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACjC,KAAK,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAA;KAAE,CAAA;IACxD,SAAS,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAA;IAC1D,OAAO,EAA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E,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA"}
|
package/lib/config.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadConfig = exports.validateConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
5
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
6
6
|
const plugin_1 = require("./plugin");
|
|
7
7
|
const conflict_1 = require("./conflict");
|
|
8
8
|
const error_1 = require("@dotcom-tool-kit/error");
|
|
@@ -21,38 +21,46 @@ async function asyncFilter(items, predicate) {
|
|
|
21
21
|
return results.filter(({ keep }) => keep).map(({ item }) => item);
|
|
22
22
|
}
|
|
23
23
|
async function validateConfig(config, { checkInstall = true } = {}) {
|
|
24
|
-
const hookTaskConflicts = conflict_1.findConflicts(Object.values(config.hookTasks));
|
|
25
|
-
const hookConflicts = conflict_1.findConflicts(Object.values(config.hooks));
|
|
26
|
-
const taskConflicts = conflict_1.findConflicts(Object.values(config.tasks));
|
|
27
|
-
const optionConflicts = conflict_1.findConflicts(Object.values(config.options));
|
|
24
|
+
const hookTaskConflicts = (0, conflict_1.findConflicts)(Object.values(config.hookTasks));
|
|
25
|
+
const hookConflicts = (0, conflict_1.findConflicts)(Object.values(config.hooks));
|
|
26
|
+
const taskConflicts = (0, conflict_1.findConflicts)(Object.values(config.tasks));
|
|
27
|
+
const optionConflicts = (0, conflict_1.findConflicts)(Object.values(config.options));
|
|
28
|
+
const definedHookTaskConflicts = hookTaskConflicts.filter((conflict) => {
|
|
29
|
+
return conflict.conflicting[0].id in config.hooks;
|
|
30
|
+
});
|
|
28
31
|
let shouldThrow = false;
|
|
29
32
|
const error = new error_1.ToolKitError('There are problems with your Tool Kit configuration.');
|
|
30
33
|
error.details = '';
|
|
31
34
|
if (hookConflicts.length > 0 ||
|
|
32
|
-
|
|
35
|
+
definedHookTaskConflicts.length > 0 ||
|
|
33
36
|
taskConflicts.length > 0 ||
|
|
34
37
|
optionConflicts.length > 0) {
|
|
35
38
|
shouldThrow = true;
|
|
36
39
|
if (hookConflicts.length) {
|
|
37
|
-
error.details += messages_1.formatHookConflicts(hookConflicts);
|
|
40
|
+
error.details += (0, messages_1.formatHookConflicts)(hookConflicts);
|
|
38
41
|
}
|
|
39
|
-
if (
|
|
40
|
-
error.details += messages_1.formatHookTaskConflicts(
|
|
42
|
+
if (definedHookTaskConflicts.length) {
|
|
43
|
+
error.details += (0, messages_1.formatHookTaskConflicts)(definedHookTaskConflicts);
|
|
41
44
|
}
|
|
42
45
|
if (taskConflicts.length) {
|
|
43
|
-
error.details += messages_1.formatTaskConflicts(taskConflicts);
|
|
46
|
+
error.details += (0, messages_1.formatTaskConflicts)(taskConflicts);
|
|
44
47
|
}
|
|
45
48
|
if (optionConflicts.length) {
|
|
46
|
-
error.details += messages_1.formatOptionConflicts(optionConflicts);
|
|
49
|
+
error.details += (0, messages_1.formatOptionConflicts)(optionConflicts);
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
|
-
const configuredHookTasks = conflict_1.withoutConflicts(Object.values(config.hookTasks));
|
|
50
|
-
const definedHooks = conflict_1.withoutConflicts(Object.values(config.hooks));
|
|
52
|
+
const configuredHookTasks = (0, conflict_1.withoutConflicts)(Object.values(config.hookTasks));
|
|
53
|
+
const definedHooks = (0, conflict_1.withoutConflicts)(Object.values(config.hooks));
|
|
51
54
|
const definedHookIds = new Set(Object.keys(config.hooks));
|
|
52
|
-
const undefinedHookTasks = configuredHookTasks.filter((
|
|
55
|
+
const undefinedHookTasks = configuredHookTasks.filter((hookTask) => {
|
|
56
|
+
// we only care about undefined hooks that were configured by the app, not default config from plugins
|
|
57
|
+
const fromApp = hookTask.plugin.root === process.cwd();
|
|
58
|
+
const hookDefined = definedHookIds.has(hookTask.id);
|
|
59
|
+
return fromApp && !hookDefined;
|
|
60
|
+
});
|
|
53
61
|
if (undefinedHookTasks.length > 0) {
|
|
54
62
|
shouldThrow = true;
|
|
55
|
-
error.details += messages_1.formatUndefinedHookTasks(undefinedHookTasks, Array.from(definedHookIds));
|
|
63
|
+
error.details += (0, messages_1.formatUndefinedHookTasks)(undefinedHookTasks, Array.from(definedHookIds));
|
|
56
64
|
}
|
|
57
65
|
const missingTasks = configuredHookTasks
|
|
58
66
|
.map((hook) => ({
|
|
@@ -62,7 +70,7 @@ async function validateConfig(config, { checkInstall = true } = {}) {
|
|
|
62
70
|
.filter(({ tasks }) => tasks.length > 0);
|
|
63
71
|
if (missingTasks.length > 0) {
|
|
64
72
|
shouldThrow = true;
|
|
65
|
-
error.details += messages_1.formatMissingTasks(missingTasks, Object.keys(config.tasks));
|
|
73
|
+
error.details += (0, messages_1.formatMissingTasks)(missingTasks, Object.keys(config.tasks));
|
|
66
74
|
}
|
|
67
75
|
if (checkInstall) {
|
|
68
76
|
const uninstalledHooks = await asyncFilter(definedHooks, async (Hook) => {
|
|
@@ -71,7 +79,7 @@ async function validateConfig(config, { checkInstall = true } = {}) {
|
|
|
71
79
|
});
|
|
72
80
|
if (uninstalledHooks.length > 0) {
|
|
73
81
|
shouldThrow = true;
|
|
74
|
-
error.details += messages_1.formatUninstalledHooks(uninstalledHooks);
|
|
82
|
+
error.details += (0, messages_1.formatUninstalledHooks)(uninstalledHooks);
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
85
|
if (shouldThrow) {
|
|
@@ -82,7 +90,7 @@ async function validateConfig(config, { checkInstall = true } = {}) {
|
|
|
82
90
|
exports.validateConfig = validateConfig;
|
|
83
91
|
async function loadConfig({ validate = true, checkInstall = true } = {}) {
|
|
84
92
|
// start loading config and child plugins, starting from the consumer app directory
|
|
85
|
-
const config = await plugin_1.loadPluginConfig({
|
|
93
|
+
const config = await (0, plugin_1.loadPluginConfig)({
|
|
86
94
|
id: 'app root',
|
|
87
95
|
root: process.cwd()
|
|
88
96
|
}, createConfig());
|
package/lib/help.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const config_1 = require("./config");
|
|
4
4
|
const messages_1 = require("./messages");
|
|
5
5
|
async function showHelp(hooks) {
|
|
6
|
-
const config = await config_1.loadConfig(
|
|
6
|
+
const config = await (0, config_1.loadConfig)();
|
|
7
7
|
if (hooks.length === 0) {
|
|
8
8
|
hooks = Object.keys(config.hooks).sort();
|
|
9
9
|
}
|
|
@@ -16,7 +16,7 @@ Tool Kit is modern, maintainable & modular developer tooling for FT.com projects
|
|
|
16
16
|
${messages_1.styles.URL('https://github.com/financial-times/dotcom-tool-kit')}
|
|
17
17
|
|
|
18
18
|
${messages_1.styles.ruler()}
|
|
19
|
-
${messages_1.styles.dim(hooks.length === 0
|
|
19
|
+
${Object.keys(config.hooks).length === 0 ? `there are no hooks available. you'll need to install plugins that define hooks to be able to run Tool Kit tasks.` : messages_1.styles.dim(hooks.length === 0
|
|
20
20
|
? 'available hooks'
|
|
21
21
|
: `help for ${hooks.length - missingHooks.length} ${hooks.length - missingHooks.length > 1 ? 'hooks' : 'hook'}`)}:
|
|
22
22
|
`);
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,wBAAsB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsE7D;AAED,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const config_1 = require("./config");
|
|
|
9
9
|
const messages_1 = require("./messages");
|
|
10
10
|
async function runTasks(hooks) {
|
|
11
11
|
var _a;
|
|
12
|
-
const config = await config_1.loadConfig();
|
|
12
|
+
const config = await (0, config_1.loadConfig)();
|
|
13
13
|
const availableHooks = Object.keys(config.hooks)
|
|
14
14
|
.sort()
|
|
15
15
|
.map((id) => `- ${id}`)
|
|
@@ -24,6 +24,7 @@ ${availableHooks}`;
|
|
|
24
24
|
throw error;
|
|
25
25
|
}
|
|
26
26
|
for (const hook of hooks) {
|
|
27
|
+
const errors = [];
|
|
27
28
|
if (!config.hookTasks[hook]) {
|
|
28
29
|
console.warn(messages_1.styles.warning(`no task configured for ${hook}: skipping assignment...}`));
|
|
29
30
|
continue;
|
|
@@ -36,7 +37,31 @@ ${availableHooks}`;
|
|
|
36
37
|
// but typescript doesn't, so cast it to any.
|
|
37
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
39
|
const task = new Task(options);
|
|
39
|
-
|
|
40
|
+
try {
|
|
41
|
+
await task.run();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// allow subsequent hook tasks to run on error
|
|
45
|
+
errors.push({
|
|
46
|
+
hook,
|
|
47
|
+
task: id,
|
|
48
|
+
error
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (errors.length > 0) {
|
|
53
|
+
const error = new error_1.ToolKitError(`error running tasks for ${messages_1.styles.hook(hook)}`);
|
|
54
|
+
error.details = errors
|
|
55
|
+
.map(({ hook, task, error }) => `${messages_1.styles.heading(`${messages_1.styles.task(task)}:`)}
|
|
56
|
+
|
|
57
|
+
${error.message}${error instanceof error_1.ToolKitError
|
|
58
|
+
? `
|
|
59
|
+
|
|
60
|
+
${error.details}`
|
|
61
|
+
: ''}`)
|
|
62
|
+
.join(`\n${messages_1.styles.dim(messages_1.styles.ruler())}\n`);
|
|
63
|
+
error.exitCode = errors.length + 1;
|
|
64
|
+
throw error;
|
|
40
65
|
}
|
|
41
66
|
}
|
|
42
67
|
}
|
package/lib/install.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAGA,wBAA8B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CA6B1D"}
|
package/lib/install.js
CHANGED
|
@@ -2,16 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_1 = require("./config");
|
|
4
4
|
const error_1 = require("@dotcom-tool-kit/error");
|
|
5
|
-
const isRejected = (result) => result.status === 'rejected';
|
|
6
5
|
async function installHooks() {
|
|
7
|
-
const config = await config_1.loadConfig({ checkInstall: false });
|
|
8
|
-
const
|
|
6
|
+
const config = await (0, config_1.loadConfig)({ checkInstall: false });
|
|
7
|
+
const tasks = Object.values(config.hooks).map((Hook) => async () => {
|
|
9
8
|
const hook = new Hook();
|
|
10
9
|
if (!(await hook.check())) {
|
|
11
10
|
await hook.install();
|
|
12
11
|
}
|
|
13
|
-
})
|
|
14
|
-
const errors =
|
|
12
|
+
});
|
|
13
|
+
const errors = [];
|
|
14
|
+
for (const task of tasks) {
|
|
15
|
+
try {
|
|
16
|
+
await task();
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
if (err instanceof Error) {
|
|
20
|
+
errors.push(err);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
15
27
|
if (errors.length) {
|
|
16
28
|
const error = new error_1.ToolKitError('could not automatically install hooks:');
|
|
17
29
|
error.details = errors.map((error) => error.message).join('\n\n');
|
package/lib/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,aAA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A;AAED,OAAO,EAAE,CAAC,IAAI,MAAM,EAAE,CAAA;AAStB,eAAO,MAAM,mBAAmB,cAAe,SAAS,SAAS,CAAC,EAAE,KAAG,MAKE,CAAA;AASzE,eAAO,MAAM,mBAAmB,cAAe,SAAS,SAAS,CAAC,EAAE,KAAG,MAKE,CAAA;AAazE,eAAO,MAAM,uBAAuB,cAAe,SAAS,QAAQ,CAAC,EAAE,KAAG,MAQzE,CAAA;AAOD,eAAO,MAAM,qBAAqB,cAAe,SAAS,aAAa,CAAC,EAAE,KAAG,MAU5E,CAAA;AAMD,eAAO,MAAM,wBAAwB,mBACnB,QAAQ,EAAE,gBACZ,MAAM,EAAE,KACrB,MAWF,CAAA;AAED,eAAO,MAAM,sBAAsB,qBACf,SAAS,EAAE,KAC5B,MAKF,CAAA;AAED,aAAK,OAAO,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAOlD,eAAO,MAAM,kBAAkB,iBACf,OAAO,EAAE,SAChB,MAAM,EAAE,KACd,MAOF,CAAA"}
|
package/lib/messages.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatMissingTasks = exports.formatUninstalledHooks = exports.formatUndefinedHookTasks = exports.formatOptionConflicts = exports.formatHookTaskConflicts = exports.formatHookConflicts = exports.formatTaskConflicts = exports.styles = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
5
|
+
const ansi_colors_1 = (0, tslib_1.__importDefault)(require("ansi-colors"));
|
|
6
6
|
// consistent styling use cases for terminal colours
|
|
7
7
|
// don't use ansi-colors directly, define a style please
|
|
8
8
|
const s = {
|
|
@@ -58,13 +58,15 @@ You must resolve this conflict by providing options in your app's Tool Kit confi
|
|
|
58
58
|
exports.formatOptionConflicts = formatOptionConflicts;
|
|
59
59
|
const formatPlugin = (plugin) => plugin.id === 'app root' ? s.app('your app') : `plugin ${s.plugin(plugin.id)}`;
|
|
60
60
|
// TODO text similarity "did you mean...?"
|
|
61
|
-
const formatUndefinedHookTasks = (undefinedHooks, definedHooks) => `
|
|
61
|
+
const formatUndefinedHookTasks = (undefinedHooks, definedHooks) => `Hooks must be defined by a plugin before you can configure a task to run for them. In your Tool Kit configuration you've configured hooks that aren't defined:
|
|
62
62
|
|
|
63
|
-
${undefinedHooks.map((hook) => `- ${s.hook(hook.id)}
|
|
63
|
+
${undefinedHooks.map((hook) => `- ${s.hook(hook.id)}`).join('\n')}
|
|
64
64
|
|
|
65
|
-
They could be misspelt, or defined by a Tool Kit plugin that isn't
|
|
65
|
+
They could be misspelt, or defined by a Tool Kit plugin that isn't installed in this app.
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
${definedHooks.length > 0
|
|
68
|
+
? `Hooks that are defined and available for tasks are: ${definedHooks.map(s.hook).join(', ')}`
|
|
69
|
+
: `There are no hooks defined by this app's plugins. You probably need to install some plugins to define hooks.`}.
|
|
68
70
|
`;
|
|
69
71
|
exports.formatUndefinedHookTasks = formatUndefinedHookTasks;
|
|
70
72
|
const formatUninstalledHooks = (uninstalledHooks) => `These hooks aren't installed into your app:
|
package/lib/plugin.js
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadPlugins = exports.loadPlugin = exports.loadPluginConfig = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const import_from_1 = tslib_1.__importDefault(require("import-from"));
|
|
6
|
-
const resolve_from_1 = tslib_1.__importDefault(require("resolve-from"));
|
|
7
|
-
const lodash_mergewith_1 = tslib_1.__importDefault(require("lodash.mergewith"));
|
|
5
|
+
const import_from_1 = (0, tslib_1.__importDefault)(require("import-from"));
|
|
6
|
+
const resolve_from_1 = (0, tslib_1.__importDefault)(require("resolve-from"));
|
|
7
|
+
const lodash_mergewith_1 = (0, tslib_1.__importDefault)(require("lodash.mergewith"));
|
|
8
8
|
const conflict_1 = require("./conflict");
|
|
9
9
|
const rc_file_1 = require("./rc-file");
|
|
10
10
|
async function loadPluginConfig(plugin, config) {
|
|
11
|
-
const { plugins = [], hooks = {}, options = {} } = await rc_file_1.loadToolKitRC(plugin.root);
|
|
11
|
+
const { plugins = [], hooks = {}, options = {} } = await (0, rc_file_1.loadToolKitRC)(plugin.root);
|
|
12
12
|
// load any plugins requested by this plugin
|
|
13
13
|
await loadPlugins(plugins, config, plugin);
|
|
14
14
|
// load plugin hook tasks. do this after loading child plugins, so
|
|
15
15
|
// parent hooks get assigned after child hooks and can override them
|
|
16
|
-
lodash_mergewith_1.default(config.hookTasks, hooks,
|
|
16
|
+
(0, lodash_mergewith_1.default)(config.hookTasks, hooks,
|
|
17
17
|
// handle conflicts between hooks from different plugins
|
|
18
18
|
(existingHookTask, configHookTask, id) => {
|
|
19
19
|
const newHookTask = {
|
|
@@ -30,7 +30,7 @@ async function loadPluginConfig(plugin, config) {
|
|
|
30
30
|
// return a conflict either listing this hook and the siblings,
|
|
31
31
|
// or merging in a previously-generated hook
|
|
32
32
|
if (existingFromSibling) {
|
|
33
|
-
const conflicting = conflict_1.isConflict(existingHookTask) ? existingHookTask.conflicting : [existingHookTask];
|
|
33
|
+
const conflicting = (0, conflict_1.isConflict)(existingHookTask) ? existingHookTask.conflicting : [existingHookTask];
|
|
34
34
|
const conflict = {
|
|
35
35
|
plugin,
|
|
36
36
|
conflicting: conflicting.concat(newHookTask)
|
|
@@ -43,7 +43,7 @@ async function loadPluginConfig(plugin, config) {
|
|
|
43
43
|
});
|
|
44
44
|
// merge options from this plugin's config with any options we've collected already
|
|
45
45
|
// TODO this is almost the exact same code as for hooks, refactor
|
|
46
|
-
lodash_mergewith_1.default(config.options, options, (existingOptions, configOptions, id) => {
|
|
46
|
+
(0, lodash_mergewith_1.default)(config.options, options, (existingOptions, configOptions, id) => {
|
|
47
47
|
const pluginOptions = {
|
|
48
48
|
options: configOptions,
|
|
49
49
|
plugin,
|
|
@@ -58,7 +58,7 @@ async function loadPluginConfig(plugin, config) {
|
|
|
58
58
|
// return a conflict either listing these options and the sibling's,
|
|
59
59
|
// or merging in previously-generated options
|
|
60
60
|
if (existingFromSibling) {
|
|
61
|
-
const conflicting = conflict_1.isConflict(existingOptions) ? existingOptions.conflicting : [existingOptions];
|
|
61
|
+
const conflicting = (0, conflict_1.isConflict)(existingOptions) ? existingOptions.conflicting : [existingOptions];
|
|
62
62
|
const conflict = {
|
|
63
63
|
plugin,
|
|
64
64
|
conflicting: conflicting.concat(pluginOptions)
|
|
@@ -79,8 +79,8 @@ async function loadPlugin(id, config, parent) {
|
|
|
79
79
|
}
|
|
80
80
|
const root = parent ? parent.root : process.cwd();
|
|
81
81
|
// load plugin relative to the parent plugin
|
|
82
|
-
const pluginRoot = resolve_from_1.default(root, id);
|
|
83
|
-
const basePlugin = import_from_1.default(root, id);
|
|
82
|
+
const pluginRoot = (0, resolve_from_1.default)(root, id);
|
|
83
|
+
const basePlugin = (0, import_from_1.default)(root, id);
|
|
84
84
|
const plugin = {
|
|
85
85
|
...basePlugin,
|
|
86
86
|
id,
|
|
@@ -89,13 +89,13 @@ async function loadPlugin(id, config, parent) {
|
|
|
89
89
|
};
|
|
90
90
|
config.plugins[id] = plugin;
|
|
91
91
|
// add plugin tasks to our task registry, handling any conflicts
|
|
92
|
-
lodash_mergewith_1.default(config.tasks, Object.fromEntries((plugin.tasks || []).map((task) => [task.name, task])), (existingTask, newTask, taskId) => {
|
|
92
|
+
(0, lodash_mergewith_1.default)(config.tasks, Object.fromEntries((plugin.tasks || []).map((task) => [task.name, task])), (existingTask, newTask, taskId) => {
|
|
93
93
|
newTask.plugin = plugin;
|
|
94
94
|
newTask.id = taskId;
|
|
95
95
|
if (!existingTask) {
|
|
96
96
|
return newTask;
|
|
97
97
|
}
|
|
98
|
-
const conflicting = conflict_1.isConflict(existingTask) ? existingTask.conflicting : [existingTask];
|
|
98
|
+
const conflicting = (0, conflict_1.isConflict)(existingTask) ? existingTask.conflicting : [existingTask];
|
|
99
99
|
return {
|
|
100
100
|
plugin,
|
|
101
101
|
conflicting: conflicting.concat(newTask)
|
|
@@ -103,13 +103,13 @@ async function loadPlugin(id, config, parent) {
|
|
|
103
103
|
});
|
|
104
104
|
// add hooks to the registry, handling any conflicts
|
|
105
105
|
// TODO refactor with command conflict handler
|
|
106
|
-
lodash_mergewith_1.default(config.hooks, plugin.hooks, (existingHook, newHook, hookId) => {
|
|
106
|
+
(0, lodash_mergewith_1.default)(config.hooks, plugin.hooks, (existingHook, newHook, hookId) => {
|
|
107
107
|
newHook.id = hookId;
|
|
108
108
|
newHook.plugin = plugin;
|
|
109
109
|
if (!existingHook) {
|
|
110
110
|
return newHook;
|
|
111
111
|
}
|
|
112
|
-
const conflicting = conflict_1.isConflict(existingHook) ? existingHook.conflicting : [existingHook];
|
|
112
|
+
const conflicting = (0, conflict_1.isConflict)(existingHook) ? existingHook.conflicting : [existingHook];
|
|
113
113
|
return {
|
|
114
114
|
plugin,
|
|
115
115
|
conflicting: conflicting.concat(newHook)
|
package/lib/rc-file.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadToolKitRC = void 0;
|
|
4
4
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
5
|
-
const explorer = cosmiconfig_1.cosmiconfig('toolkit', { ignoreEmptySearchPlaces: false });
|
|
5
|
+
const explorer = (0, cosmiconfig_1.cosmiconfig)('toolkit', { ignoreEmptySearchPlaces: false });
|
|
6
6
|
async function loadToolKitRC(root) {
|
|
7
7
|
const result = await explorer.search(root);
|
|
8
8
|
if (!result || !result.config)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dotcom-tool-kit",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.30",
|
|
4
4
|
"description": "modern, maintainable, modular developer tooling for FT.com projects",
|
|
5
5
|
"author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"ts-node": "^8.10.2"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@dotcom-tool-kit/error": "^1.0.0-beta.
|
|
34
|
-
"@dotcom-tool-kit/wait-for-ok": "^1.0.0-beta.
|
|
33
|
+
"@dotcom-tool-kit/error": "^1.0.0-beta.30",
|
|
34
|
+
"@dotcom-tool-kit/wait-for-ok": "^1.0.0-beta.30",
|
|
35
35
|
"ansi-colors": "^4.1.1",
|
|
36
36
|
"cosmiconfig": "^7.0.0",
|
|
37
37
|
"import-from": "^3.0.0",
|
|
@@ -47,5 +47,8 @@
|
|
|
47
47
|
"/bin",
|
|
48
48
|
"/lib",
|
|
49
49
|
"/npm-shrinkwrap.json"
|
|
50
|
-
]
|
|
50
|
+
],
|
|
51
|
+
"volta": {
|
|
52
|
+
"extends": "../../package.json"
|
|
53
|
+
}
|
|
51
54
|
}
|