@dotcom-tool-kit/package-json-hook 1.0.0-beta.9 → 1.0.2-beta.2

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/index.d.ts CHANGED
@@ -1,10 +1,6 @@
1
- import type { PackageJson } from '@financial-times/package-json';
2
- export declare abstract class PackageJsonHook {
3
- _packageJson?: PackageJson;
4
- abstract script: string;
5
- abstract hook: string;
6
- get packageJson(): PackageJson;
7
- check(): Promise<boolean>;
1
+ import { PackageJsonHelper } from '@dotcom-tool-kit/hook';
2
+ export declare abstract class PackageJsonHook extends PackageJsonHelper {
3
+ field: string;
8
4
  install(): Promise<void>;
9
5
  }
10
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAOhE,8BAAsB,eAAe;IACnC,YAAY,CAAC,EAAE,WAAW,CAAA;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,IAAI,WAAW,IAAI,WAAW,CAO7B;IAEK,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAKzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAa/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAMzD,8BAAsB,eAAgB,SAAQ,iBAAiB;IAC7D,KAAK,SAAY;IAEX,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAa/B"}
package/lib/index.js CHANGED
@@ -1,30 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PackageJsonHook = void 0;
4
- const tslib_1 = require("tslib");
5
- const package_json_1 = tslib_1.__importDefault(require("@financial-times/package-json"));
6
- const path_1 = tslib_1.__importDefault(require("path"));
7
- class PackageJsonHook {
8
- get packageJson() {
9
- if (!this._packageJson) {
10
- const filepath = path_1.default.resolve(process.cwd(), 'package.json');
11
- this._packageJson = package_json_1.default({ filepath });
12
- }
13
- return this._packageJson;
14
- }
15
- async check() {
16
- var _a;
17
- const scripts = this.packageJson.getField('scripts');
18
- return scripts && ((_a = scripts[this.script]) === null || _a === void 0 ? void 0 : _a.includes(this.hook));
4
+ const hook_1 = require("@dotcom-tool-kit/hook");
5
+ class PackageJsonHook extends hook_1.PackageJsonHelper {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.field = 'scripts';
19
9
  }
20
10
  async install() {
21
11
  let command = `dotcom-tool-kit ${this.hook}`;
22
- const existingCommand = this.packageJson.getField('scripts')[this.script];
12
+ const existingCommand = this.packageJson.getField(this.field)[this.key];
23
13
  if (existingCommand && existingCommand.startsWith('dotcom-tool-kit ')) {
24
14
  command = command.concat(existingCommand.replace('dotcom-tool-kit', ''));
25
15
  }
26
16
  this.packageJson.requireScript({
27
- stage: this.script,
17
+ stage: this.key,
28
18
  command
29
19
  });
30
20
  this.packageJson.writeChanges();
package/package.json CHANGED
@@ -1,29 +1,33 @@
1
1
  {
2
2
  "name": "@dotcom-tool-kit/package-json-hook",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.2-beta.2",
4
4
  "description": "",
5
5
  "main": "lib",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "cd ../../ ; npx jest --silent --projects lib/package-json-hook"
8
8
  },
9
9
  "keywords": [],
10
10
  "author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
- "@financial-times/package-json": "^3.0.0"
13
+ "@dotcom-tool-kit/hook": "^1.0.2-beta.2"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
17
17
  "url": "https://github.com/financial-times/dotcom-tool-kit.git",
18
- "directory": "packages/package-json-hook"
18
+ "directory": "lib/package-json-hook"
19
19
  },
20
20
  "bugs": "https://github.com/financial-times/dotcom-tool-kit/issues",
21
- "homepage": "https://github.com/financial-times/dotcom-tool-kit/tree/main/packages/package-json-hook",
21
+ "homepage": "https://github.com/financial-times/dotcom-tool-kit/tree/main/lib/package-json-hook",
22
22
  "devDependencies": {
23
- "@types/financial-times__package-json": "file:../../types/financial-times__package-json"
23
+ "@jest/globals": "^27.4.6",
24
+ "winston": "^3.5.1"
24
25
  },
25
26
  "files": [
26
27
  "/lib",
27
28
  ".toolkitrc.yml"
28
- ]
29
+ ],
30
+ "volta": {
31
+ "extends": "../../package.json"
32
+ }
29
33
  }