@dotcom-tool-kit/package-json-hook 5.1.7 → 5.2.1
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/package-json-helper.d.ts +2 -2
- package/lib/package-json-helper.d.ts.map +1 -1
- package/lib/package-json-helper.js +3 -0
- package/lib/schema.d.ts +12 -0
- package/lib/schema.d.ts.map +1 -0
- package/lib/schema.js +47 -0
- package/package.json +7 -8
- package/readme.md +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
2
|
import { Hook, HookInstallation } from '@dotcom-tool-kit/base';
|
|
3
3
|
import type { Plugin } from '@dotcom-tool-kit/plugin';
|
|
4
|
-
import { PackageJsonSchema } from '@dotcom-tool-kit/schemas/lib/hooks/package-json';
|
|
5
4
|
import { Conflict } from '@dotcom-tool-kit/conflict';
|
|
5
|
+
import { PackageJsonSchema } from './schema';
|
|
6
6
|
interface PackageJsonContents {
|
|
7
7
|
[field: string]: PackageJsonContents | string;
|
|
8
8
|
}
|
|
@@ -14,6 +14,7 @@ interface PackageJsonStateValue {
|
|
|
14
14
|
interface PackageJsonState {
|
|
15
15
|
[path: string]: PackageJsonStateValue;
|
|
16
16
|
}
|
|
17
|
+
export { PackageJsonSchema as schema };
|
|
17
18
|
export default class PackageJson extends Hook<{
|
|
18
19
|
hook: typeof PackageJsonSchema;
|
|
19
20
|
}, PackageJsonState> {
|
|
@@ -27,5 +28,4 @@ export default class PackageJson extends Hook<{
|
|
|
27
28
|
install(state?: PackageJsonState): Promise<PackageJsonState>;
|
|
28
29
|
commitInstall(state: PackageJsonState): Promise<void>;
|
|
29
30
|
}
|
|
30
|
-
export {};
|
|
31
31
|
//# sourceMappingURL=package-json-helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-json-helper.d.ts","sourceRoot":"","sources":["../src/package-json-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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GACpD,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CACjE,EAAE,GACF,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,EAAE;IAexF,MAAM,CAAC,0BAA0B,CAC/B,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC,EACxE,kBAAkB,EAAE,CAChB,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC,GACpD,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CACjE,EAAE,GACF,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC,EAAE;IAsBlF,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAW9C,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAmC/B,OAAO,CAAC,KAAK,GAAE,gBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgChE,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAe5D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const base_1 = require("@dotcom-tool-kit/base");
|
|
5
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
@@ -10,6 +11,8 @@ const update_1 = tslib_1.__importDefault(require("lodash/update"));
|
|
|
10
11
|
const merge_1 = tslib_1.__importDefault(require("lodash/merge"));
|
|
11
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
13
|
const conflict_1 = require("@dotcom-tool-kit/conflict");
|
|
14
|
+
const schema_1 = require("./schema");
|
|
15
|
+
Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return schema_1.PackageJsonSchema; } });
|
|
13
16
|
function installationsOverlap(installation, other) {
|
|
14
17
|
for (const [field, object] of Object.entries(installation.options)) {
|
|
15
18
|
for (const key of Object.keys(object)) {
|
package/lib/schema.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const PackageJsonSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString]>, z.ZodObject<{
|
|
3
|
+
commands: z.ZodUnion<[z.ZodArray<z.ZodString, "many">, z.ZodString]>;
|
|
4
|
+
trailingString: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
commands: string | string[];
|
|
7
|
+
trailingString: string;
|
|
8
|
+
}, {
|
|
9
|
+
commands: string | string[];
|
|
10
|
+
trailingString: string;
|
|
11
|
+
}>]>>>;
|
|
12
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAGxB,eAAO,MAAM,iBAAiB;;;;;;;;;MA4C5B,CAAA"}
|
package/lib/schema.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PackageJsonSchema = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const z = tslib_1.__importStar(require("zod"));
|
|
6
|
+
const CommandListSchema = z.union([z.array(z.string()), z.string()]);
|
|
7
|
+
exports.PackageJsonSchema = z.record(z.record(z.union([
|
|
8
|
+
CommandListSchema,
|
|
9
|
+
z.object({
|
|
10
|
+
commands: CommandListSchema,
|
|
11
|
+
trailingString: z.string()
|
|
12
|
+
})
|
|
13
|
+
])))
|
|
14
|
+
.describe(`This hook accepts a nested object with a structure that matches the generated output in \`package.json\`. The values are used as Tool Kit command names to run. You can provide a single command or an array; multiple commands are concatenated in order.
|
|
15
|
+
|
|
16
|
+
For more complex use cases, you can provide an object instead of a command. The object must contain keys \`commands\` (as above), and \`trailingString\` (which will be appended to the resulting \`dotcom-tool-kit\` CLI invocation). This is useful for tasks that accept a list of files after a trailing \`--\`.
|
|
17
|
+
|
|
18
|
+
Options provided in your repository's \`.toolkitrc.yml\` for this hook are merged with any Tool Kit plugin that also provides options for the hook.
|
|
19
|
+
|
|
20
|
+
For example, configuring this hook with the following options:
|
|
21
|
+
|
|
22
|
+
~~~yml
|
|
23
|
+
options:
|
|
24
|
+
hooks:
|
|
25
|
+
- PackageJson:
|
|
26
|
+
scripts:
|
|
27
|
+
start: 'run:local'
|
|
28
|
+
customScript:
|
|
29
|
+
commands:
|
|
30
|
+
- custom:one
|
|
31
|
+
- custom:two
|
|
32
|
+
trailingString: '--'
|
|
33
|
+
~~~
|
|
34
|
+
|
|
35
|
+
will result in the following output in \`package.json\`:
|
|
36
|
+
|
|
37
|
+
~~~json
|
|
38
|
+
{
|
|
39
|
+
"scripts": {
|
|
40
|
+
"start": "dotcom-tool-kit run:local",
|
|
41
|
+
"customScript": "dotcom-tool-kit custom:one custom:two --"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
~~~
|
|
45
|
+
|
|
46
|
+
<!-- hide autogenerated schema docs -->
|
|
47
|
+
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcom-tool-kit/package-json-hook",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib",
|
|
6
6
|
"scripts": {
|
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
"author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dotcom-tool-kit/base": "^1.
|
|
14
|
-
"@dotcom-tool-kit/conflict": "^1.0.
|
|
15
|
-
"@dotcom-tool-kit/plugin": "^1.
|
|
13
|
+
"@dotcom-tool-kit/base": "^1.2.0",
|
|
14
|
+
"@dotcom-tool-kit/conflict": "^1.0.1",
|
|
15
|
+
"@dotcom-tool-kit/plugin": "^1.1.0",
|
|
16
16
|
"@financial-times/package-json": "^3.0.0",
|
|
17
17
|
"lodash": "^4.17.21",
|
|
18
|
-
"tslib": "^2.3.1"
|
|
18
|
+
"tslib": "^2.3.1",
|
|
19
|
+
"zod": "^3.22.4"
|
|
19
20
|
},
|
|
20
21
|
"repository": {
|
|
21
22
|
"type": "git",
|
|
@@ -28,11 +29,9 @@
|
|
|
28
29
|
"zod": "^3.22.4"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@dotcom-tool-kit/schemas": "^1.9.0",
|
|
32
32
|
"@jest/globals": "^27.4.6",
|
|
33
33
|
"@types/lodash": "^4.14.185",
|
|
34
|
-
"winston": "^3.5.1"
|
|
35
|
-
"zod": "^3.22.4"
|
|
34
|
+
"winston": "^3.5.1"
|
|
36
35
|
},
|
|
37
36
|
"files": [
|
|
38
37
|
"/lib",
|
package/readme.md
CHANGED
|
@@ -15,7 +15,7 @@ Install `@dotcom-tool-kit/package-json-hook` as a `devDependency` in your app:
|
|
|
15
15
|
npm install --save-dev @dotcom-tool-kit/package-json-hook
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
Add the plugin to your [Tool Kit configuration](https://github.com/financial-times/dotcom-tool-kit/blob/main/readme.md#
|
|
18
|
+
Add the plugin to your [Tool Kit configuration](https://github.com/financial-times/dotcom-tool-kit/blob/main/readme.md#configuring-tool-kit):
|
|
19
19
|
|
|
20
20
|
```yaml
|
|
21
21
|
plugins:
|