@dotcom-tool-kit/package-json-hook 1.0.0 → 1.0.2-beta.11
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 +3 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +7 -17
- package/package.json +7 -7
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare abstract class PackageJsonHook {
|
|
3
|
-
|
|
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
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!this._packageJson) {
|
|
10
|
-
const filepath = path_1.default.resolve(process.cwd(), 'package.json');
|
|
11
|
-
this._packageJson = (0, 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(
|
|
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.
|
|
17
|
+
stage: this.key,
|
|
28
18
|
command
|
|
29
19
|
});
|
|
30
20
|
this.packageJson.writeChanges();
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcom-tool-kit/package-json-hook",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2-beta.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "cd ../../ ; npx jest --silent --projects
|
|
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
|
-
"@
|
|
13
|
+
"@dotcom-tool-kit/hook": "^1.0.2-beta.11"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "https://github.com/financial-times/dotcom-tool-kit.git",
|
|
18
|
-
"directory": "
|
|
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/
|
|
21
|
+
"homepage": "https://github.com/financial-times/dotcom-tool-kit/tree/main/lib/package-json-hook",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@jest/globals": "^
|
|
24
|
-
"
|
|
23
|
+
"@jest/globals": "^27.4.6",
|
|
24
|
+
"winston": "^3.5.1"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
27
|
"/lib",
|