dotcom-tool-kit 3.5.0 → 4.0.0-beta.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.
Files changed (77) hide show
  1. package/bin/run +11 -1
  2. package/lib/config/hash.d.ts +6 -0
  3. package/lib/config/hash.d.ts.map +1 -0
  4. package/lib/config/hash.js +43 -0
  5. package/lib/config/validate-plugins.d.ts +4 -0
  6. package/lib/config/validate-plugins.d.ts.map +1 -0
  7. package/lib/config/validate-plugins.js +9 -0
  8. package/lib/config.d.ts +2 -54
  9. package/lib/config.d.ts.map +1 -1
  10. package/lib/config.js +62 -113
  11. package/lib/fetch.d.ts +2 -0
  12. package/lib/fetch.d.ts.map +1 -0
  13. package/lib/fetch.js +19 -0
  14. package/lib/help.d.ts +1 -1
  15. package/lib/help.d.ts.map +1 -1
  16. package/lib/help.js +72 -39
  17. package/lib/index.d.ts +3 -4
  18. package/lib/index.d.ts.map +1 -1
  19. package/lib/index.js +12 -99
  20. package/lib/init.d.ts +4 -0
  21. package/lib/init.d.ts.map +1 -0
  22. package/lib/init.js +16 -0
  23. package/lib/install.d.ts +6 -1
  24. package/lib/install.d.ts.map +1 -1
  25. package/lib/install.js +69 -13
  26. package/lib/messages.d.ts +14 -13
  27. package/lib/messages.d.ts.map +1 -1
  28. package/lib/messages.js +38 -27
  29. package/lib/plugin/entry-point.d.ts +7 -0
  30. package/lib/plugin/entry-point.d.ts.map +1 -0
  31. package/lib/plugin/entry-point.js +46 -0
  32. package/lib/plugin/is-descendent.d.ts +3 -0
  33. package/lib/plugin/is-descendent.d.ts.map +1 -0
  34. package/lib/plugin/is-descendent.js +15 -0
  35. package/lib/plugin/merge-commands.d.ts +5 -0
  36. package/lib/plugin/merge-commands.d.ts.map +1 -0
  37. package/lib/plugin/merge-commands.js +59 -0
  38. package/lib/plugin/merge-hooks.d.ts +4 -0
  39. package/lib/plugin/merge-hooks.d.ts.map +1 -0
  40. package/lib/plugin/merge-hooks.js +29 -0
  41. package/lib/plugin/merge-inits.d.ts +4 -0
  42. package/lib/plugin/merge-inits.d.ts.map +1 -0
  43. package/lib/plugin/merge-inits.js +13 -0
  44. package/lib/plugin/merge-plugin-options.d.ts +4 -0
  45. package/lib/plugin/merge-plugin-options.d.ts.map +1 -0
  46. package/lib/plugin/merge-plugin-options.js +46 -0
  47. package/lib/plugin/merge-task-options.d.ts +4 -0
  48. package/lib/plugin/merge-task-options.d.ts.map +1 -0
  49. package/lib/plugin/merge-task-options.js +43 -0
  50. package/lib/plugin/merge-tasks.d.ts +4 -0
  51. package/lib/plugin/merge-tasks.d.ts.map +1 -0
  52. package/lib/plugin/merge-tasks.js +27 -0
  53. package/lib/plugin/options.d.ts +7 -0
  54. package/lib/plugin/options.d.ts.map +1 -0
  55. package/lib/plugin/options.js +170 -0
  56. package/lib/plugin/reduce-installations.d.ts +7 -0
  57. package/lib/plugin/reduce-installations.d.ts.map +1 -0
  58. package/lib/plugin/reduce-installations.js +59 -0
  59. package/lib/plugin.d.ts +4 -3
  60. package/lib/plugin.d.ts.map +1 -1
  61. package/lib/plugin.js +56 -217
  62. package/lib/rc-file.d.ts +4 -9
  63. package/lib/rc-file.d.ts.map +1 -1
  64. package/lib/rc-file.js +80 -20
  65. package/lib/tasks.d.ts +3 -0
  66. package/lib/tasks.d.ts.map +1 -0
  67. package/lib/tasks.js +92 -0
  68. package/package.json +28 -22
  69. package/lib/conflict.d.ts +0 -9
  70. package/lib/conflict.d.ts.map +0 -1
  71. package/lib/conflict.js +0 -27
  72. package/lib/hook.d.ts +0 -7
  73. package/lib/hook.d.ts.map +0 -1
  74. package/lib/hook.js +0 -2
  75. package/lib/postInstall.d.ts +0 -7
  76. package/lib/postInstall.d.ts.map +0 -1
  77. package/lib/postInstall.js +0 -53
package/lib/conflict.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withoutConflicts = exports.findConflicts = exports.isConflict = void 0;
4
- function isConflict(thing) {
5
- return Boolean(thing.conflicting);
6
- }
7
- exports.isConflict = isConflict;
8
- function findConflicts(items) {
9
- const conflicts = [];
10
- for (const item of items) {
11
- if (isConflict(item)) {
12
- conflicts.push(item);
13
- }
14
- }
15
- return conflicts;
16
- }
17
- exports.findConflicts = findConflicts;
18
- function withoutConflicts(items) {
19
- const nonConflicts = [];
20
- for (const item of items) {
21
- if (!isConflict(item)) {
22
- nonConflicts.push(item);
23
- }
24
- }
25
- return nonConflicts;
26
- }
27
- exports.withoutConflicts = withoutConflicts;
package/lib/hook.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { Plugin } from '@dotcom-tool-kit/types';
2
- export interface HookTask {
3
- id: string;
4
- plugin: Plugin;
5
- tasks: string[];
6
- }
7
- //# sourceMappingURL=hook.d.ts.map
package/lib/hook.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../src/hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB"}
package/lib/hook.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- import type { Logger } from 'winston';
2
- /**
3
- * This step adds the tags only filter to rest of the jobs in the workflow if there is a job that contains the semverRegex.
4
- * CircleCI will only run the jobs if the rest of the jobs have the tags filter.
5
- */
6
- export declare function postInstall(logger: Logger): Promise<void>;
7
- //# sourceMappingURL=postInstall.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postInstall.d.ts","sourceRoot":"","sources":["../src/postInstall.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC;;;GAGG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuC/D"}
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.postInstall = void 0;
4
- const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
- const fs_1 = require("fs");
7
- const npm_1 = require("@dotcom-tool-kit/types/lib/npm");
8
- const YAML = tslib_1.__importStar(require("yaml"));
9
- const merge_1 = tslib_1.__importDefault(require("lodash/merge"));
10
- const circleci_1 = require("@dotcom-tool-kit/types/lib/circleci");
11
- /**
12
- * This step adds the tags only filter to rest of the jobs in the workflow if there is a job that contains the semverRegex.
13
- * CircleCI will only run the jobs if the rest of the jobs have the tags filter.
14
- */
15
- async function postInstall(logger) {
16
- const circleConfigPath = path_1.default.resolve(process.cwd(), '.circleci/config.yml');
17
- try {
18
- const rawCircleConfig = await fs_1.promises.readFile(circleConfigPath, 'utf8');
19
- if (rawCircleConfig &&
20
- rawCircleConfig.includes(npm_1.semVerRegex.source) &&
21
- rawCircleConfig.startsWith(circleci_1.automatedComment)) {
22
- logger.verbose('running postInstall step');
23
- const yml = YAML.parseDocument(rawCircleConfig);
24
- const workflows = yml.get('workflows');
25
- const toolkitWorkflow = workflows.get('tool-kit');
26
- const jobs = toolkitWorkflow.get('jobs');
27
- jobs?.items.forEach((jobItem, index) => {
28
- const tagsFilterConfig = { filters: { tags: { only: `${npm_1.semVerRegex}` } } };
29
- if (jobItem.type === 'PLAIN') {
30
- // eg. - checkout
31
- const node = YAML.createNode({ [jobItem.value]: tagsFilterConfig });
32
- jobs.items[index] = node;
33
- }
34
- else {
35
- const job = jobItem.items[0];
36
- const existingFilter = job.value.items.filter((item) => item.key.value === 'filters')[0];
37
- const merged = existingFilter ? (0, merge_1.default)(existingFilter.toJSON(), tagsFilterConfig) : tagsFilterConfig;
38
- const node = YAML.createNode(merged['filters']);
39
- job.value.set('filters', node);
40
- }
41
- });
42
- logger.info(`writing postInstall results to file ${circleConfigPath}`);
43
- await fs_1.promises.writeFile(circleConfigPath, yml.toString());
44
- }
45
- }
46
- catch (error) {
47
- // Not an error if config file doesn't exist
48
- if (error.code !== 'ENOENT') {
49
- throw error;
50
- }
51
- }
52
- }
53
- exports.postInstall = postInstall;