dotcom-tool-kit 4.0.5 → 4.1.0

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/bin/run CHANGED
@@ -9,7 +9,8 @@ const argv = require('minimist')(process.argv.slice(2), {
9
9
  '--': true
10
10
  })
11
11
 
12
- const { rootLogger, styles } = require('@dotcom-tool-kit/logger')
12
+ const { rootLogger } = require('@dotcom-tool-kit/logger')
13
+ const { formatError } = require('../lib/messages')
13
14
 
14
15
  async function main() {
15
16
  try {
@@ -41,15 +42,7 @@ async function main() {
41
42
  }
42
43
  }
43
44
  } catch (error) {
44
- if (error.details) {
45
- rootLogger.error('', { skipformat: true })
46
- rootLogger.error(error.message)
47
- rootLogger.error(styles.ruler() + '\n', { skipformat: true })
48
- rootLogger.error(error.details, { skipformat: true })
49
- } else {
50
- rootLogger.error(error.stack)
51
- }
52
-
45
+ rootLogger.error(formatError(error), { skipFormat: true })
53
46
  process.exitCode = error.exitCode || 1
54
47
  }
55
48
  }
package/lib/config.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import type { Logger } from 'winston';
2
2
  import { RawConfig, ValidConfig, ValidPluginsConfig } from '@dotcom-tool-kit/config';
3
- export declare const createConfig: () => RawConfig;
3
+ export declare const createConfig: (root: string) => RawConfig;
4
4
  export declare function validateConfig(config: ValidPluginsConfig): ValidConfig;
5
- export declare function loadConfig(logger: Logger, options?: {
5
+ export declare function loadConfig(logger: Logger, options: {
6
6
  validate?: true;
7
+ root: string;
7
8
  }): Promise<ValidConfig>;
8
- export declare function loadConfig(logger: Logger, options?: {
9
+ export declare function loadConfig(logger: Logger, options: {
9
10
  validate?: false;
11
+ root: string;
10
12
  }): Promise<RawConfig>;
11
13
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAA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"__esModule", { value: true });
3
3
  exports.loadConfig = exports.validateConfig = exports.createConfig = void 0;
4
- const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
4
  const plugin_1 = require("./plugin");
7
5
  const conflict_1 = require("@dotcom-tool-kit/conflict");
8
6
  const error_1 = require("@dotcom-tool-kit/error");
9
7
  const messages_1 = require("./messages");
10
8
  const validate_plugins_1 = require("./config/validate-plugins");
11
9
  const options_1 = require("./plugin/options");
12
- const coreRoot = path_1.default.resolve(__dirname, '../');
13
- const createConfig = () => ({
14
- root: coreRoot,
10
+ const logger_1 = require("@dotcom-tool-kit/logger");
11
+ const createConfig = (root) => ({
12
+ root,
15
13
  plugins: {},
16
14
  resolutionTrackers: {
17
15
  resolvedPluginOptions: new Set(),
@@ -64,14 +62,14 @@ function validateConfig(config) {
64
62
  }
65
63
  }
66
64
  const unusedPluginOptions = Object.entries(config.pluginOptions)
67
- .filter(([, option]) => option && !(0, conflict_1.isConflict)(option) && !option.forPlugin && option.plugin.root === process.cwd())
65
+ .filter(([, option]) => option && !(0, conflict_1.isConflict)(option) && !option.forPlugin && option.plugin.root === config.root)
68
66
  .map(([id]) => id);
69
67
  if (unusedPluginOptions.length > 0) {
70
68
  shouldThrow = true;
71
69
  error.details += (0, messages_1.formatUnusedPluginOptions)(unusedPluginOptions, Object.keys(config.plugins));
72
70
  }
73
71
  const unusedTaskOptions = Object.entries(config.taskOptions)
74
- .filter(([, option]) => option && !(0, conflict_1.isConflict)(option) && !option.task && option.plugin.root === process.cwd())
72
+ .filter(([, option]) => option && !(0, conflict_1.isConflict)(option) && !option.task && option.plugin.root === config.root)
75
73
  .map(([id]) => id);
76
74
  if (unusedTaskOptions.length > 0) {
77
75
  shouldThrow = true;
@@ -94,8 +92,8 @@ function validateConfig(config) {
94
92
  return validConfig;
95
93
  }
96
94
  exports.validateConfig = validateConfig;
97
- async function loadConfig(logger, { validate = true } = {}) {
98
- const config = (0, exports.createConfig)();
95
+ async function loadConfig(logger, { validate = true, root }) {
96
+ const config = (0, exports.createConfig)(root);
99
97
  // start loading config and child plugins, starting from the consumer app directory
100
98
  const rootPlugin = await (0, plugin_1.loadPlugin)('app root', config, logger);
101
99
  const validRootPlugin = rootPlugin.unwrap('root plugin was not valid!');
@@ -107,7 +105,7 @@ async function loadConfig(logger, { validate = true } = {}) {
107
105
  (0, plugin_1.resolvePluginOptions)(validRootPlugin, validPluginConfig);
108
106
  const invalidOptions = (0, options_1.validatePluginOptions)(logger, validPluginConfig);
109
107
  if (invalidOptions.length > 0 && validate) {
110
- const error = new error_1.ToolKitError('There are problems with your plugin options.');
108
+ const error = new error_1.ToolKitError(`There are options in your ${logger_1.styles.filepath('.toolkitrc.yml')} that aren't what Tool Kit expected.`);
111
109
  error.details = (0, messages_1.formatInvalidPluginOptions)(invalidOptions);
112
110
  throw error;
113
111
  }
package/lib/fetch.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export declare const shouldDisableNativeFetch: () => boolean;
1
+ import { RootOptions } from '@dotcom-tool-kit/schemas/src/plugins/dotcom-tool-kit';
2
+ export declare const shouldDisableNativeFetch: (options: RootOptions) => boolean;
2
3
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,wBAAwB,QAAO,OAY3C,CAAA"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sDAAsD,CAAA;AAIlF,eAAO,MAAM,wBAAwB,YAAa,WAAW,KAAG,OAK/D,CAAA"}
package/lib/fetch.js CHANGED
@@ -1,19 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shouldDisableNativeFetch = void 0;
4
- const options_1 = require("@dotcom-tool-kit/options");
5
4
  // function that plugins can check if they need to implement their own logic to
6
5
  // disable Node 18's native fetch
7
- const shouldDisableNativeFetch = () => {
6
+ const shouldDisableNativeFetch = (options) => {
8
7
  // disable Node 18's native fetch if the Node runtime supports it (older
9
8
  // runtimes don't support the flag, implying they also don't use native
10
9
  // fetch) and the user hasn't opted out of the behaviour
11
- return (
12
- /* eslint-disable-next-line @typescript-eslint/no-non-null-assertion --
13
- * the root plugin has default options and it always exists so is always
14
- * defined
15
- **/
16
- !(0, options_1.getOptions)('app root').allowNativeFetch &&
17
- process.allowedNodeEnvironmentFlags.has('--no-experimental-fetch'));
10
+ return !options.allowNativeFetch && process.allowedNodeEnvironmentFlags.has('--no-experimental-fetch');
18
11
  };
19
12
  exports.shouldDisableNativeFetch = shouldDisableNativeFetch;
package/lib/help.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AA4ErC,wBAA8B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4CxF"}
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AA4ErC,wBAA8B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsCxF"}
package/lib/help.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const config_1 = require("./config");
5
- const options_1 = require("@dotcom-tool-kit/options");
6
5
  const logger_1 = require("@dotcom-tool-kit/logger");
7
6
  const yaml_1 = tslib_1.__importDefault(require("yaml"));
8
7
  const endent_1 = tslib_1.__importDefault(require("endent"));
@@ -51,16 +50,11 @@ const formatHooks = (config) => logger_1.styles.box((0, endent_1.default) `
51
50
  .join('\n')}
52
51
  `, { title: logger_1.styles.title('🎣 installed hooks') });
53
52
  async function showHelp(logger, commands) {
54
- const config = await (0, config_1.loadConfig)(logger);
53
+ const config = await (0, config_1.loadConfig)(logger, { root: process.cwd() });
55
54
  const printAllCommands = commands.length === 0;
56
55
  if (printAllCommands) {
57
56
  commands = Object.keys(config.commandTasks).sort();
58
57
  }
59
- for (const pluginOptions of Object.values(config.pluginOptions)) {
60
- if (pluginOptions.forPlugin) {
61
- (0, options_1.setOptions)(pluginOptions.forPlugin.id, pluginOptions.options);
62
- }
63
- }
64
58
  logger.info(toolKitIntro);
65
59
  const definedCommands = commands.filter((command) => config.commandTasks[command]);
66
60
  const missingCommands = commands.filter((command) => !config.commandTasks[command]);
package/lib/index.js CHANGED
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "runTasks", { enumerable: true, get: function ()
10
10
  var fetch_1 = require("./fetch");
11
11
  Object.defineProperty(exports, "shouldDisableNativeFetch", { enumerable: true, get: function () { return fetch_1.shouldDisableNativeFetch; } });
12
12
  async function listPlugins(logger) {
13
- const config = await (0, config_1.loadConfig)(logger, { validate: false });
13
+ const config = await (0, config_1.loadConfig)(logger, { validate: false, root: process.cwd() });
14
14
  const rootPlugin = config.plugins['app root'];
15
15
  if (rootPlugin?.valid) {
16
16
  logger.info((0, messages_1.formatPluginTree)(rootPlugin.value).join('\n'));
@@ -18,7 +18,7 @@ async function listPlugins(logger) {
18
18
  }
19
19
  exports.listPlugins = listPlugins;
20
20
  async function printConfig(logger) {
21
- const config = await (0, config_1.loadConfig)(logger, { validate: false });
21
+ const config = await (0, config_1.loadConfig)(logger, { validate: false, root: process.cwd() });
22
22
  logger.info(util_1.default.inspect(config, { depth: null, colors: true }));
23
23
  }
24
24
  exports.printConfig = printConfig;
package/lib/install.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import type { z } from 'zod';
2
1
  import type { Logger } from 'winston';
3
2
  import type { ValidConfig } from '@dotcom-tool-kit/config';
4
3
  import { Hook } from '@dotcom-tool-kit/base';
5
4
  import { Validated } from '@dotcom-tool-kit/validated';
6
- export declare const loadHookInstallations: (logger: Logger, config: ValidConfig) => Promise<Validated<Hook<z.ZodType, unknown>[]>>;
5
+ export declare const loadHookInstallations: (logger: Logger, config: ValidConfig) => Promise<Validated<Hook[]>>;
7
6
  export declare function checkInstall(logger: Logger, config: ValidConfig): Promise<void>;
8
7
  export default function installHooks(logger: Logger): Promise<ValidConfig>;
9
8
  //# sourceMappingURL=install.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAK5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAa,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAmC,MAAM,4BAA4B,CAAA;AAyCvF,eAAO,MAAM,qBAAqB,WACxB,MAAM,UACN,WAAW,KAClB,QAAQ,UAAU,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAqC/C,CAAA;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBrF;AAED,wBAA8B,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAyD/E"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,IAAI,EAAa,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,SAAS,EAAmC,MAAM,4BAA4B,CAAA;AAyCvF,eAAO,MAAM,qBAAqB,WACxB,MAAM,UACN,WAAW,KAClB,QAAQ,UAAU,IAAI,EAAE,CAAC,CAwC3B,CAAA;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBrF;AAED,wBAA8B,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmD/E"}
package/lib/install.js CHANGED
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
5
5
  const path = tslib_1.__importStar(require("path"));
6
6
  const error_1 = require("@dotcom-tool-kit/error");
7
7
  const logger_1 = require("@dotcom-tool-kit/logger");
8
- const options_1 = require("@dotcom-tool-kit/options");
9
8
  const groupBy_1 = tslib_1.__importDefault(require("lodash/groupBy"));
10
9
  const config_1 = require("./config");
11
10
  const hash_1 = require("./config/hash");
@@ -52,7 +51,10 @@ const loadHookInstallations = async (logger, config) => {
52
51
  return (0, validated_1.valid)((0, conflict_1.withoutConflicts)(installations));
53
52
  });
54
53
  return installationsWithoutConflicts.map((installations) => {
55
- return installations.map(({ hookConstructor, forHook, options }) => new hookConstructor(logger, forHook, options));
54
+ return installations.map(({ hookConstructor, forHook, options }) => {
55
+ const hookPlugin = config.hooks[forHook].plugin;
56
+ return new hookConstructor(logger, forHook, options, config.pluginOptions[hookPlugin.id]?.options);
57
+ });
56
58
  });
57
59
  };
58
60
  exports.loadHookInstallations = loadHookInstallations;
@@ -73,12 +75,7 @@ async function checkInstall(logger, config) {
73
75
  }
74
76
  exports.checkInstall = checkInstall;
75
77
  async function installHooks(logger) {
76
- const config = await (0, config_1.loadConfig)(logger);
77
- for (const pluginOptions of Object.values(config.pluginOptions)) {
78
- if (pluginOptions.forPlugin) {
79
- (0, options_1.setOptions)(pluginOptions.forPlugin.id, pluginOptions.options);
80
- }
81
- }
78
+ const config = await (0, config_1.loadConfig)(logger, { root: process.cwd() });
82
79
  await (0, init_1.runInit)(logger, config);
83
80
  const errors = [];
84
81
  const hooks = (await (0, exports.loadHookInstallations)(logger, config)).unwrap('hooks were found to be invalid when installing');
package/lib/messages.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare const formatInvalidPluginOptions: (invalidOptions: InvalidOption[
13
13
  export declare const formatUnusedPluginOptions: (unusedOptions: string[], definedPlugins: string[]) => string;
14
14
  export declare const formatUnusedTaskOptions: (unusedOptions: string[], definedTasks: string[]) => string;
15
15
  export declare const formatUnusedHookOptions: (unusedOptions: string[], definedHooks: string[]) => string;
16
- export declare const formatUninstalledHooks: (uninstalledHooks: Hook<z.ZodTypeAny, unknown>[]) => string;
16
+ export declare const formatUninstalledHooks: (uninstalledHooks: Hook[]) => string;
17
17
  type Missing = {
18
18
  command: CommandTask;
19
19
  tasks: OptionsForTask[];
@@ -21,5 +21,6 @@ type Missing = {
21
21
  export declare const formatMissingTasks: (missingTasks: Missing[], tasks: string[]) => string;
22
22
  export declare function formatPluginTree(plugin: Plugin): string[];
23
23
  export declare const indentReasons: (reasons: string) => string;
24
+ export declare function formatError(error: Error): string;
24
25
  export {};
25
26
  //# sourceMappingURL=messages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,cAAc,EACf,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAOzD,eAAO,MAAM,mBAAmB,cAAe,CAAC,MAAM,EAAE,SAAS,UAAU,CAAC,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AED,KAAK,OAAO,GAAG;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,cAAc,EAAE,CAAA;CAAE,CAAA;AAOhE,eAAO,MAAM,kBAAkB,iBACf,OAAO,EAAE,SAChB,MAAM,EAAE,KACd,MAOF,CAAA;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAezD;AAED,eAAO,MAAM,aAAa,YAAa,MAAM,KAAG,MAAwC,CAAA;AAExF,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,UA4BvC"}
package/lib/messages.js CHANGED
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.indentReasons = exports.formatPluginTree = exports.formatMissingTasks = exports.formatUninstalledHooks = exports.formatUnusedHookOptions = exports.formatUnusedTaskOptions = exports.formatUnusedPluginOptions = exports.formatInvalidPluginOptions = exports.formatInvalidOption = exports.formatTaskOptionConflicts = exports.formatPluginOptionConflicts = exports.formatCommandTaskConflicts = exports.formatHookConflicts = exports.formatTaskConflicts = void 0;
3
+ exports.formatError = exports.indentReasons = exports.formatPluginTree = exports.formatMissingTasks = exports.formatUninstalledHooks = exports.formatUnusedHookOptions = exports.formatUnusedTaskOptions = exports.formatUnusedPluginOptions = exports.formatInvalidPluginOptions = exports.formatInvalidOption = exports.formatTaskOptionConflicts = exports.formatPluginOptionConflicts = exports.formatCommandTaskConflicts = exports.formatHookConflicts = exports.formatTaskConflicts = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const logger_1 = require("@dotcom-tool-kit/logger");
5
6
  const zod_validation_error_1 = require("zod-validation-error");
7
+ const pluralize_1 = tslib_1.__importDefault(require("pluralize"));
8
+ const error_1 = require("@dotcom-tool-kit/error");
6
9
  const formatTaskConflict = ([key, conflict]) => `- ${logger_1.styles.task(key ?? 'unknown task')} ${logger_1.styles.dim('from plugins')} ${conflict.conflicting
7
10
  .map((entryPoint) => logger_1.styles.plugin(entryPoint.plugin.id ?? 'unknown plugin'))
8
11
  .join(logger_1.styles.dim(', '))}`;
@@ -51,14 +54,12 @@ You must resolve this conflict by providing options in your app's Tool Kit confi
51
54
  `;
52
55
  exports.formatTaskOptionConflicts = formatTaskOptionConflicts;
53
56
  const formatPlugin = (plugin) => plugin.id === 'app root' ? logger_1.styles.app('your app') : `plugin ${logger_1.styles.plugin(plugin.id)}`;
54
- const formatInvalidOption = ([id, error]) => (0, zod_validation_error_1.fromZodError)(error, { prefix: `- ${id} has the issue(s)` }).message;
57
+ const formatInvalidOption = ([id, error]) => (0, zod_validation_error_1.fromZodError)(error, { prefix: `${logger_1.styles.warning((0, pluralize_1.default)('issue', error.issues.length, true))} in ${logger_1.styles.plugin(id)}`, prefixSeparator: ':\n- ', issueSeparator: '\n- ' }).message;
55
58
  exports.formatInvalidOption = formatInvalidOption;
56
- const formatInvalidPluginOptions = (invalidOptions) => `Options are defined in your Tool Kit configuration that are the wrong types:
57
-
59
+ const formatInvalidPluginOptions = (invalidOptions) => `Please update the options so that they are the expected types.
58
60
  ${invalidOptions.map(([plugin, error]) => (0, exports.formatInvalidOption)([logger_1.styles.plugin(plugin), error])).join('\n')}
59
61
 
60
- Please update the options so that they are the expected types. You can refer to the README for the plugin for examples and descriptions of the options used.
61
- `;
62
+ You can refer to the README for the plugin for examples and descriptions of the options used.`;
62
63
  exports.formatInvalidPluginOptions = formatInvalidPluginOptions;
63
64
  const formatUnusedPluginOptions = (unusedOptions, definedPlugins) => `Options are defined in your Tool Kit configuration for plugins that don't exist:
64
65
 
@@ -131,3 +132,26 @@ function formatPluginTree(plugin) {
131
132
  exports.formatPluginTree = formatPluginTree;
132
133
  const indentReasons = (reasons) => reasons.replace(/\n/g, '\n ');
133
134
  exports.indentReasons = indentReasons;
135
+ function formatError(error) {
136
+ let output = `${logger_1.styles.error(error.name)}: ${error.message}\n`;
137
+ if (error instanceof AggregateError) {
138
+ output += error.errors
139
+ .map(formatError)
140
+ .map((message, messageIndex) => {
141
+ const lines = message.split('\n');
142
+ // TODO:KB:20241125 refactor the tree formatter from this and formatPluginTree into a shared function
143
+ return lines.map((line, lineIndex) => (messageIndex === error.errors.length - 1 ? (lineIndex === 0 ? '╰─' : ' ') : lineIndex === 0 ? '├─' : '│ ') + line).join('\n');
144
+ })
145
+ .join('\n');
146
+ }
147
+ else if (error instanceof error_1.ToolKitError) {
148
+ if (error.details) {
149
+ output += logger_1.styles.info(error.details);
150
+ }
151
+ }
152
+ else if (error.stack) {
153
+ output += error.stack.split('\n').slice(1).join('\n');
154
+ }
155
+ return output + '\n';
156
+ }
157
+ exports.formatError = formatError;
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/plugin/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAI/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAKrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,eAAO,MAAM,qBAAqB,WAAY,MAAM,UAAU,kBAAkB,KAAG,aAAa,EAoD/F,CAAA;AAED,eAAO,MAAM,oBAAoB,WAAY,MAAM,UAAU,kBAAkB,KAAG,IAgHjF,CAAA"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/plugin/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,EAA4B,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAI/E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAKrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,eAAO,MAAM,qBAAqB,WAAY,MAAM,UAAU,kBAAkB,KAAG,aAAa,EAwD/F,CAAA;AAED,eAAO,MAAM,oBAAoB,WAAY,MAAM,UAAU,kBAAkB,KAAG,IAgHjF,CAAA"}
@@ -25,7 +25,7 @@ const validatePluginOptions = (logger, config) => {
25
25
  id,
26
26
  new zod_1.ZodError([
27
27
  {
28
- message: `options for ${logger_1.styles.plugin(id)} have moved to the ${logger_1.styles.task(movedToTask)} task`,
28
+ message: `options for the ${logger_1.styles.plugin(id)} plugin have moved to ${logger_1.styles.code(`options.tasks.${logger_1.styles.task(movedToTask)}`)}`,
29
29
  code: zod_1.ZodIssueCode.custom,
30
30
  path: []
31
31
  }
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ export declare const resolve: NodeJS.RequireResolve;
3
+ //# sourceMappingURL=require-resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-resolve.d.ts","sourceRoot":"","sources":["../../src/plugin/require-resolve.ts"],"names":[],"mappings":";AAAA,eAAO,MAAM,OAAO,uBAAkB,CAAA"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolve = void 0;
4
+ exports.resolve = require.resolve;
@@ -0,0 +1,2 @@
1
+ export declare function resolveRoot(id: string, root: string): string;
2
+ //# sourceMappingURL=resolve-root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-root.d.ts","sourceRoot":"","sources":["../../src/plugin/resolve-root.ts"],"names":[],"mappings":"AAKA,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAoB5D"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveRoot = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
+ const require_resolve_1 = require("./require-resolve");
7
+ const error_1 = require("@dotcom-tool-kit/error");
8
+ const logger_1 = require("@dotcom-tool-kit/logger");
9
+ function resolveRoot(id, root) {
10
+ const isRelative = id.startsWith('./');
11
+ // resolve the .toolkitrc.yml of a plugin as many plugins don't have valid
12
+ // entrypoints now that we're intending their tasks/hooks to be loaded via
13
+ // entrypoints defined in config
14
+ const pluginPath = path_1.default.join(id, '.toolkitrc.yml');
15
+ try {
16
+ const resolvedPath = (0, require_resolve_1.resolve)(isRelative ? './' + pluginPath : pluginPath, { paths: [root] });
17
+ return path_1.default.dirname(resolvedPath);
18
+ }
19
+ catch (error) {
20
+ if (error instanceof Error && 'code' in error && error.code === 'MODULE_NOT_FOUND') {
21
+ const error = new error_1.ToolKitError(`Couldn't resolve plugin ${logger_1.styles.plugin(id)} from directory ${logger_1.styles.filepath(root)}`);
22
+ error.details = `If this is a built-in Tool Kit plugin, check it's installed as a dependency. If it's a custom plugin, check it has a ${logger_1.styles.filepath('.toolkitrc.yml')}, and that the path is the correct relative path to the plugin from the ${logger_1.styles.filepath('.toolkitrc.yml')} it's being included from.`;
23
+ throw error;
24
+ }
25
+ throw error;
26
+ }
27
+ }
28
+ exports.resolveRoot = resolveRoot;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAmC,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAEvF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAoBrC,wBAAsB,UAAU,CAC9B,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAqD5B;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAiBrF;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAqB9F"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAmC,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACvF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAWrC,wBAAsB,UAAU,CAC9B,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAqD5B;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAiBrF;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAqB9F"}
package/lib/plugin.js CHANGED
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolvePlugin = exports.resolvePluginOptions = exports.loadPlugin = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const logger_1 = require("@dotcom-tool-kit/logger");
6
5
  const plugin_1 = require("@dotcom-tool-kit/plugin");
7
6
  const validated_1 = require("@dotcom-tool-kit/validated");
8
- const path = tslib_1.__importStar(require("path"));
9
7
  const rc_file_1 = require("./rc-file");
10
8
  const messages_1 = require("./messages");
11
9
  const merge_tasks_1 = require("./plugin/merge-tasks");
@@ -14,15 +12,7 @@ const merge_commands_1 = require("./plugin/merge-commands");
14
12
  const merge_plugin_options_1 = require("./plugin/merge-plugin-options");
15
13
  const merge_inits_1 = require("./plugin/merge-inits");
16
14
  const merge_task_options_1 = require("./plugin/merge-task-options");
17
- function resolveRoot(id, root) {
18
- const isPath = id.startsWith('.') || id.startsWith('/');
19
- // resolve the package.json of a plugin as many plugins don't have valid
20
- // entrypoints now that we're intending their tasks/hooks to be loaded via
21
- // entrypoints defined in config
22
- const modulePath = isPath ? id : path.join(id, 'package.json');
23
- const resolvedPath = require.resolve(modulePath, { paths: [root] });
24
- return path.dirname(resolvedPath);
25
- }
15
+ const resolve_root_1 = require("./plugin/resolve-root");
26
16
  async function loadPlugin(id, config, logger, parent) {
27
17
  // don't load duplicate plugins
28
18
  if (id in config.plugins) {
@@ -30,8 +20,8 @@ async function loadPlugin(id, config, logger, parent) {
30
20
  }
31
21
  const isAppRoot = id === 'app root';
32
22
  // load plugin relative to the parent plugin
33
- const root = parent ? parent.root : process.cwd();
34
- const pluginRoot = isAppRoot ? root : resolveRoot(id, root);
23
+ const root = parent ? parent.root : config.root;
24
+ const pluginRoot = isAppRoot ? root : (0, resolve_root_1.resolveRoot)(id, root);
35
25
  if (!pluginRoot) {
36
26
  return (0, validated_1.invalid)([`could not find path for name ${logger_1.styles.filepath(id)}`]);
37
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAuDrC,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAwEjI;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAIlG"}
1
+ {"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAuDrC,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,EAAE,EAClB,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,IAAI,CAAC,CA8Df;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAIlG"}
package/lib/tasks.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runTasks = exports.runTasksFromConfig = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const base_1 = require("@dotcom-tool-kit/base");
5
6
  const validated_1 = require("@dotcom-tool-kit/validated");
6
7
  const entry_point_1 = require("./plugin/entry-point");
7
- const options_1 = require("@dotcom-tool-kit/options");
8
8
  const config_1 = require("./config");
9
9
  const error_1 = require("@dotcom-tool-kit/error");
10
10
  const install_1 = require("./install");
@@ -13,6 +13,7 @@ const fetch_1 = require("./fetch");
13
13
  const init_1 = require("./init");
14
14
  const messages_1 = require("./messages");
15
15
  const schemas_1 = require("@dotcom-tool-kit/schemas");
16
+ const pluralize_1 = tslib_1.__importDefault(require("pluralize"));
16
17
  const loadTasks = async (logger, tasks, config) => {
17
18
  const taskResults = await Promise.all(tasks.map(async ({ task: taskId, options }) => {
18
19
  const entryPoint = config.tasks[taskId];
@@ -26,7 +27,7 @@ const loadTasks = async (logger, tasks, config) => {
26
27
  data: mergedOptions
27
28
  };
28
29
  if (parsedOptions.success) {
29
- const task = new Task(logger, taskId, (0, options_1.getOptions)(entryPoint.plugin.id) ?? {}, parsedOptions.data);
30
+ const task = new Task(logger, taskId, config.pluginOptions[entryPoint.plugin.id]?.options ?? {}, parsedOptions.data);
30
31
  return (0, validated_1.valid)(task);
31
32
  }
32
33
  else {
@@ -37,14 +38,10 @@ const loadTasks = async (logger, tasks, config) => {
37
38
  return (0, validated_1.reduceValidated)(taskResults);
38
39
  };
39
40
  async function runTasksFromConfig(logger, config, commands, files) {
40
- for (const pluginOptions of Object.values(config.pluginOptions)) {
41
- if (pluginOptions.forPlugin) {
42
- (0, options_1.setOptions)(pluginOptions.forPlugin.id, pluginOptions.options);
43
- }
44
- }
45
41
  await (0, init_1.runInit)(logger, config);
46
42
  await (0, install_1.checkInstall)(logger, config);
47
- if ((0, fetch_1.shouldDisableNativeFetch)()) {
43
+ if ((0, fetch_1.shouldDisableNativeFetch)(config.pluginOptions['app root'].options) &&
44
+ !process.execArgv.includes('--no-experimental-fetch')) {
48
45
  process.execArgv.push('--no-experimental-fetch');
49
46
  }
50
47
  const commandTasks = (0, validated_1.reduceValidated)(await Promise.all(commands.map(async (command) => {
@@ -52,6 +49,9 @@ async function runTasksFromConfig(logger, config, commands, files) {
52
49
  const validatedTaskInstances = await loadTasks(logger, tasks, config);
53
50
  return validatedTaskInstances.map((taskInstances) => ({ command, tasks: taskInstances }));
54
51
  }))).unwrap('tasks are invalid!');
52
+ // at this point we no longer need to update the config, so freeze it before
53
+ // passing it into task run contexts so that plugins can't do crimes
54
+ Object.freeze(config);
55
55
  for (const { command, tasks } of commandTasks) {
56
56
  const errors = [];
57
57
  if (tasks.length === 0) {
@@ -60,7 +60,7 @@ async function runTasksFromConfig(logger, config, commands, files) {
60
60
  for (const task of tasks) {
61
61
  try {
62
62
  logger.info(logger_1.styles.taskHeader(`running ${logger_1.styles.task(task.id)} task`));
63
- await task.run({ files });
63
+ await task.run({ files, command, cwd: config.root, config });
64
64
  }
65
65
  catch (error) {
66
66
  // if there's an exit code, that's a request from the task to exit early
@@ -76,24 +76,16 @@ async function runTasksFromConfig(logger, config, commands, files) {
76
76
  }
77
77
  }
78
78
  if (errors.length > 0) {
79
- const error = new error_1.ToolKitError(`error running tasks for ${logger_1.styles.hook(command)}`);
80
- error.details = errors
81
- .map(({ task, error }) => `${logger_1.styles.heading(`${logger_1.styles.task(task)}:`)}
82
-
83
- ${error.message}${error instanceof error_1.ToolKitError
84
- ? `
85
-
86
- ${error.details}`
87
- : ''}`)
88
- .join(`${logger_1.styles.dim(logger_1.styles.ruler())}\n`);
89
- error.exitCode = errors.length + 1;
90
- throw error;
79
+ throw new AggregateError(errors.map(({ task, error }) => {
80
+ error.name = `${logger_1.styles.task(task)} → ${error.name}`;
81
+ return error;
82
+ }), `${(0, pluralize_1.default)('error', errors.length, true)} running tasks for ${logger_1.styles.command(command)}`);
91
83
  }
92
84
  }
93
85
  }
94
86
  exports.runTasksFromConfig = runTasksFromConfig;
95
87
  async function runTasks(logger, commands, files) {
96
- const config = await (0, config_1.loadConfig)(logger);
88
+ const config = await (0, config_1.loadConfig)(logger, { root: process.cwd() });
97
89
  return runTasksFromConfig(logger, config, commands, files);
98
90
  }
99
91
  exports.runTasks = runTasks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotcom-tool-kit",
3
- "version": "4.0.5",
3
+ "version": "4.1.0",
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",
@@ -23,6 +23,7 @@
23
23
  "@jest/globals": "^27.4.6",
24
24
  "@types/lodash": "^4.14.185",
25
25
  "@types/node": "^16.18.23",
26
+ "@types/pluralize": "^0.0.33",
26
27
  "chai": "^4.3.4",
27
28
  "globby": "^10.0.2",
28
29
  "ts-node": "^8.10.2",
@@ -30,19 +31,19 @@
30
31
  "zod": "^3.22.4"
31
32
  },
32
33
  "dependencies": {
33
- "@dotcom-tool-kit/base": "^1.0.0",
34
- "@dotcom-tool-kit/config": "^1.0.2",
34
+ "@dotcom-tool-kit/base": "^1.1.0",
35
+ "@dotcom-tool-kit/config": "^1.0.3",
35
36
  "@dotcom-tool-kit/conflict": "^1.0.0",
36
- "@dotcom-tool-kit/error": "^4.0.0",
37
- "@dotcom-tool-kit/logger": "^4.0.0",
38
- "@dotcom-tool-kit/options": "^4.0.2",
37
+ "@dotcom-tool-kit/error": "^4.0.1",
38
+ "@dotcom-tool-kit/logger": "^4.0.1",
39
39
  "@dotcom-tool-kit/plugin": "^1.0.0",
40
40
  "@dotcom-tool-kit/state": "^4.0.0",
41
- "@dotcom-tool-kit/validated": "^1.0.0",
41
+ "@dotcom-tool-kit/validated": "^1.0.1",
42
42
  "@dotcom-tool-kit/wait-for-ok": "^4.0.0",
43
43
  "endent": "^2.1.0",
44
44
  "lodash": "^4.17.21",
45
45
  "minimist": "^1.2.5",
46
+ "pluralize": "^8.0.0",
46
47
  "tslib": "^2.3.1",
47
48
  "yaml": "^2.4.1",
48
49
  "zod-validation-error": "^2.1.0"