dotcom-tool-kit 2.3.2 → 2.3.4

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":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,MAAM,EACN,YAAY,EAIZ,SAAS,EACV,MAAM,wBAAwB,CAAA;AAG/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAiB,SAAS,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAmBvE,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,CAgDvE;AAoBD,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,CAyD5B;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAsI9F"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,MAAM,EACN,YAAY,EAIZ,SAAS,EACV,MAAM,wBAAwB,CAAA;AAG/B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAiB,SAAS,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAmBvE,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,CAgDvE;AAoBD,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,CA4D5B;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAsI9F"}
package/lib/plugin.js CHANGED
@@ -80,11 +80,12 @@ async function loadPlugin(id, config, logger, parent) {
80
80
  if (id in config.plugins) {
81
81
  return config.plugins[id];
82
82
  }
83
+ const isAppRoot = id === 'app root';
83
84
  // load plugin relative to the parent plugin
84
85
  const root = parent ? parent.root : process.cwd();
85
86
  let pluginRoot;
86
87
  try {
87
- pluginRoot = id === 'app root' ? root : (0, resolve_from_1.default)(root, id);
88
+ pluginRoot = isAppRoot ? root : (0, resolve_from_1.default)(root, id);
88
89
  }
89
90
  catch (e) {
90
91
  return { valid: false, reasons: [`could not find path for name ${logger_1.styles.filepath(id)}`] };
@@ -99,9 +100,11 @@ async function loadPlugin(id, config, logger, parent) {
99
100
  };
100
101
  config.plugins[id] = plugin;
101
102
  // start loading rc file in the background
102
- const rcFilePromise = (0, rc_file_1.loadToolKitRC)(pluginRoot);
103
+ const rcFilePromise = (0, rc_file_1.loadToolKitRC)(logger, pluginRoot, isAppRoot);
103
104
  // start loading module in the background
104
- const pluginModulePromise = id === 'app root' ? Promise.resolve({ valid: true, value: undefined }) : importPlugin(pluginRoot);
105
+ const pluginModulePromise = isAppRoot
106
+ ? Promise.resolve({ valid: true, value: undefined })
107
+ : importPlugin(pluginRoot);
105
108
  plugin.value.rcFile = await rcFilePromise;
106
109
  // start loading child plugins in the background
107
110
  const childrenPromise = Promise.all(plugin.value.rcFile.plugins.map((child) => loadPlugin(child, config, logger, plugin.value)));
package/lib/rc-file.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { RCFile } from '@dotcom-tool-kit/types/src';
2
+ import type { Logger } from 'winston';
2
3
  export declare const explorer: {
3
4
  readonly search: (searchFrom?: string | undefined) => Promise<import("cosmiconfig/dist/types").CosmiconfigResult>;
4
5
  readonly load: (filepath: string) => Promise<import("cosmiconfig/dist/types").CosmiconfigResult>;
@@ -6,5 +7,5 @@ export declare const explorer: {
6
7
  readonly clearSearchCache: () => void;
7
8
  readonly clearCaches: () => void;
8
9
  };
9
- export declare function loadToolKitRC(root: string): Promise<RCFile>;
10
+ export declare function loadToolKitRC(logger: Logger, root: string, isAppRoot: boolean): Promise<RCFile>;
10
11
  //# sourceMappingURL=rc-file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rc-file.d.ts","sourceRoot":"","sources":["../src/rc-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAEnD,eAAO,MAAM,QAAQ;;;;;;CAA6D,CAAA;AAMlF,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASjE"}
1
+ {"version":3,"file":"rc-file.d.ts","sourceRoot":"","sources":["../src/rc-file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAGnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,eAAO,MAAM,QAAQ;;;;;;CAA6D,CAAA;AAQlF,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CA0BrG"}
package/lib/rc-file.js CHANGED
@@ -1,17 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadToolKitRC = exports.explorer = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const logger_1 = require("@dotcom-tool-kit/logger");
4
6
  const cosmiconfig_1 = require("cosmiconfig");
7
+ const path = (0, tslib_1.__importStar)(require("path"));
5
8
  exports.explorer = (0, cosmiconfig_1.cosmiconfig)('toolkit', { ignoreEmptySearchPlaces: false });
6
- async function loadToolKitRC(root) {
9
+ const emptyConfig = { plugins: [], hooks: {}, options: {} };
10
+ let rootConfig;
11
+ async function loadToolKitRC(logger, root, isAppRoot) {
7
12
  var _a, _b, _c;
8
- const result = (await exports.explorer.search(root));
9
- if (!result || !result.config)
10
- return { plugins: [], hooks: {}, options: {} };
13
+ const result = await exports.explorer.search(root);
14
+ if (!(result === null || result === void 0 ? void 0 : result.config)) {
15
+ return emptyConfig;
16
+ }
17
+ if (isAppRoot) {
18
+ rootConfig = result.filepath;
19
+ }
20
+ else if (result.filepath === rootConfig) {
21
+ // Make sure that custom plugins which don't have a config file won't cause
22
+ // the resolver to use the root config instead and start an infinite loop
23
+ // of config resolution.
24
+ logger.warn(`plugin at ${logger_1.styles.filepath(path.dirname(root))} has no config file. please add an empty ${logger_1.styles.filepath('.toolkitrc')} file to avoid potential config resolution issues.`);
25
+ return emptyConfig;
26
+ }
27
+ const config = result.config;
11
28
  return {
12
- plugins: (_a = result.config.plugins) !== null && _a !== void 0 ? _a : [],
13
- hooks: (_b = result.config.hooks) !== null && _b !== void 0 ? _b : {},
14
- options: (_c = result.config.options) !== null && _c !== void 0 ? _c : {}
29
+ plugins: (_a = config.plugins) !== null && _a !== void 0 ? _a : [],
30
+ hooks: (_b = config.hooks) !== null && _b !== void 0 ? _b : {},
31
+ options: (_c = config.options) !== null && _c !== void 0 ? _c : {}
15
32
  };
16
33
  }
17
34
  exports.loadToolKitRC = loadToolKitRC;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotcom-tool-kit",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
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,17 +23,17 @@
23
23
  "@jest/globals": "^27.4.6",
24
24
  "@types/lodash.merge": "^4.6.6",
25
25
  "@types/node": "^12.20.24",
26
- "@dotcom-tool-kit/backend-app": "^2.0.8",
27
- "@dotcom-tool-kit/heroku": "^2.0.7",
28
- "@dotcom-tool-kit/webpack": "^2.1.5",
29
- "@dotcom-tool-kit/babel": "^2.0.6",
30
- "@dotcom-tool-kit/circleci": "^2.1.4",
31
- "@dotcom-tool-kit/npm": "^2.0.7",
32
- "@dotcom-tool-kit/circleci-heroku": "^2.0.8",
33
- "@dotcom-tool-kit/frontend-app": "^2.1.6",
34
- "@dotcom-tool-kit/eslint": "^2.1.5",
35
- "@dotcom-tool-kit/mocha": "^2.1.3",
36
- "@dotcom-tool-kit/n-test": "^2.1.1",
26
+ "@dotcom-tool-kit/backend-app": "^2.0.10",
27
+ "@dotcom-tool-kit/heroku": "^2.0.9",
28
+ "@dotcom-tool-kit/webpack": "^2.1.6",
29
+ "@dotcom-tool-kit/babel": "^2.0.7",
30
+ "@dotcom-tool-kit/circleci": "^2.1.5",
31
+ "@dotcom-tool-kit/npm": "^2.0.8",
32
+ "@dotcom-tool-kit/circleci-heroku": "^2.0.10",
33
+ "@dotcom-tool-kit/frontend-app": "^2.1.8",
34
+ "@dotcom-tool-kit/eslint": "^2.2.0",
35
+ "@dotcom-tool-kit/mocha": "^2.1.4",
36
+ "@dotcom-tool-kit/n-test": "^2.1.2",
37
37
  "chai": "^4.3.4",
38
38
  "globby": "^10.0.2",
39
39
  "ts-node": "^8.10.2",
@@ -42,8 +42,8 @@
42
42
  "dependencies": {
43
43
  "@dotcom-tool-kit/error": "^2.0.0",
44
44
  "@dotcom-tool-kit/logger": "^2.1.1",
45
- "@dotcom-tool-kit/options": "^2.0.6",
46
- "@dotcom-tool-kit/types": "^2.5.1",
45
+ "@dotcom-tool-kit/options": "^2.0.7",
46
+ "@dotcom-tool-kit/types": "^2.6.0",
47
47
  "@dotcom-tool-kit/wait-for-ok": "^2.0.0",
48
48
  "cosmiconfig": "^7.0.0",
49
49
  "lodash.merge": "^4.6.2",