dotcom-tool-kit 4.0.0-beta.5 → 4.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAuDrC,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA+DlG"}
1
+ {"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../src/tasks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAuDrC,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ElG"}
package/lib/tasks.js CHANGED
@@ -27,14 +27,14 @@ const loadTasks = async (logger, tasks, config) => {
27
27
  };
28
28
  if (parsedOptions.success) {
29
29
  const task = new Task(logger, taskId, (0, options_1.getOptions)(entryPoint.plugin.id) ?? {}, parsedOptions.data);
30
- return (0, validated_1.valid)([taskId, task]);
30
+ return (0, validated_1.valid)(task);
31
31
  }
32
32
  else {
33
33
  return (0, validated_1.invalid)([(0, messages_1.formatInvalidOption)([logger_1.styles.task(taskId), parsedOptions.error])]);
34
34
  }
35
35
  });
36
36
  }));
37
- return (0, validated_1.reduceValidated)(taskResults).map(Object.fromEntries);
37
+ return (0, validated_1.reduceValidated)(taskResults);
38
38
  };
39
39
  async function runTasks(logger, commands, files) {
40
40
  const config = await (0, config_1.loadConfig)(logger);
@@ -48,24 +48,30 @@ async function runTasks(logger, commands, files) {
48
48
  if ((0, fetch_1.shouldDisableNativeFetch)()) {
49
49
  process.execArgv.push('--no-experimental-fetch');
50
50
  }
51
- const commandTasks = commands.flatMap((command) => config.commandTasks[command]?.tasks ?? []);
52
- const tasks = (await loadTasks(logger, commandTasks, config)).unwrap('tasks are invalid');
53
- for (const command of commands) {
51
+ const commandTasks = (0, validated_1.reduceValidated)(await Promise.all(commands.map(async (command) => {
52
+ const tasks = config.commandTasks[command]?.tasks ?? [];
53
+ const validatedTaskInstances = await loadTasks(logger, tasks, config);
54
+ return validatedTaskInstances.map((taskInstances) => ({ command, tasks: taskInstances }));
55
+ }))).unwrap('tasks are invalid!');
56
+ for (const { command, tasks } of commandTasks) {
54
57
  const errors = [];
55
- if (!config.commandTasks[command]) {
58
+ if (tasks.length === 0) {
56
59
  logger.warn(`no task configured for ${command}: skipping assignment...`);
57
- continue;
58
60
  }
59
- for (const { task: taskId } of config.commandTasks[command].tasks) {
61
+ for (const task of tasks) {
60
62
  try {
61
- logger.info(logger_1.styles.taskHeader(`running ${logger_1.styles.task(taskId)} task`));
62
- await tasks[taskId].run(files);
63
+ logger.info(logger_1.styles.taskHeader(`running ${logger_1.styles.task(task.id)} task`));
64
+ await task.run({ files });
63
65
  }
64
66
  catch (error) {
67
+ // if there's an exit code, that's a request from the task to exit early
68
+ if (error instanceof error_1.ToolKitError && error.exitCode) {
69
+ throw error;
70
+ }
71
+ // if not, we allow subsequent hook tasks to run on error
65
72
  // TODO use validated for this
66
- // allow subsequent command tasks to run on error
67
73
  errors.push({
68
- task: taskId,
74
+ task: task.id,
69
75
  error: error
70
76
  });
71
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotcom-tool-kit",
3
- "version": "4.0.0-beta.5",
3
+ "version": "4.0.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",
@@ -30,15 +30,15 @@
30
30
  "zod": "^3.22.4"
31
31
  },
32
32
  "dependencies": {
33
- "@dotcom-tool-kit/base": "4.0.0-beta.0",
34
- "@dotcom-tool-kit/config": "2.0.0-beta.0",
35
- "@dotcom-tool-kit/conflict": "2.0.0-beta.0",
36
- "@dotcom-tool-kit/error": "4.0.0-beta.0",
37
- "@dotcom-tool-kit/logger": "4.0.0-beta.0",
38
- "@dotcom-tool-kit/options": "4.0.0-beta.0",
39
- "@dotcom-tool-kit/plugin": "2.0.0-beta.0",
40
- "@dotcom-tool-kit/validated": "2.0.0-beta.0",
41
- "@dotcom-tool-kit/wait-for-ok": "4.0.0-beta.0",
33
+ "@dotcom-tool-kit/base": "^1.0.0",
34
+ "@dotcom-tool-kit/config": "^1.0.0",
35
+ "@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.0",
39
+ "@dotcom-tool-kit/plugin": "^1.0.0",
40
+ "@dotcom-tool-kit/validated": "^1.0.0",
41
+ "@dotcom-tool-kit/wait-for-ok": "^4.0.0",
42
42
  "endent": "^2.1.0",
43
43
  "lodash": "^4.17.21",
44
44
  "minimist": "^1.2.5",