@dotcom-tool-kit/base 4.0.0-beta.0 → 4.0.0-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/CHANGELOG.md +220 -0
- package/lib/base.js +2 -4
- package/lib/hook.d.ts +12 -4
- package/lib/hook.d.ts.map +1 -1
- package/lib/hook.js +14 -1
- package/lib/init.d.ts +4 -1
- package/lib/init.d.ts.map +1 -1
- package/lib/init.js +1 -0
- package/lib/task.d.ts +15 -5
- package/lib/task.d.ts.map +1 -1
- package/lib/task.js +10 -1
- package/lib/type-utils.d.ts +2 -0
- package/lib/type-utils.d.ts.map +1 -0
- package/lib/type-utils.js +2 -0
- package/package.json +16 -11
- package/src/hook.ts +24 -3
- package/src/init.ts +5 -1
- package/src/task.ts +20 -5
- package/src/type-utils.ts +1 -0
- package/tsconfig.json +3 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
### Dependencies
|
|
4
|
+
|
|
5
|
+
* The following workspace dependencies were updated
|
|
6
|
+
* devDependencies
|
|
7
|
+
* @dotcom-tool-kit/config bumped from ^1.0.3 to ^1.0.4
|
|
8
|
+
|
|
9
|
+
### Dependencies
|
|
10
|
+
|
|
11
|
+
* The following workspace dependencies were updated
|
|
12
|
+
* dependencies
|
|
13
|
+
* @dotcom-tool-kit/validated bumped from ^1.0.1 to ^1.0.2
|
|
14
|
+
* devDependencies
|
|
15
|
+
* @dotcom-tool-kit/config bumped from ^1.0.4 to ^1.0.5
|
|
16
|
+
* @dotcom-tool-kit/logger bumped from ^4.0.1 to ^4.1.0
|
|
17
|
+
|
|
18
|
+
### Dependencies
|
|
19
|
+
|
|
20
|
+
* The following workspace dependencies were updated
|
|
21
|
+
* devDependencies
|
|
22
|
+
* @dotcom-tool-kit/config bumped from ^1.0.5 to ^1.0.6
|
|
23
|
+
|
|
24
|
+
### Dependencies
|
|
25
|
+
|
|
26
|
+
* The following workspace dependencies were updated
|
|
27
|
+
* devDependencies
|
|
28
|
+
* @dotcom-tool-kit/config bumped from ^1.0.6 to ^1.0.7
|
|
29
|
+
|
|
30
|
+
### Dependencies
|
|
31
|
+
|
|
32
|
+
* The following workspace dependencies were updated
|
|
33
|
+
* devDependencies
|
|
34
|
+
* @dotcom-tool-kit/config bumped from ^1.0.8 to ^1.0.9
|
|
35
|
+
|
|
36
|
+
### Dependencies
|
|
37
|
+
|
|
38
|
+
* The following workspace dependencies were updated
|
|
39
|
+
* devDependencies
|
|
40
|
+
* @dotcom-tool-kit/config bumped from ^1.0.9 to ^1.0.10
|
|
41
|
+
|
|
42
|
+
### Dependencies
|
|
43
|
+
|
|
44
|
+
* The following workspace dependencies were updated
|
|
45
|
+
* devDependencies
|
|
46
|
+
* @dotcom-tool-kit/config bumped from ^1.0.10 to ^1.0.11
|
|
47
|
+
|
|
48
|
+
### Dependencies
|
|
49
|
+
|
|
50
|
+
* The following workspace dependencies were updated
|
|
51
|
+
* devDependencies
|
|
52
|
+
* @dotcom-tool-kit/config bumped from ^1.0.11 to ^1.0.12
|
|
53
|
+
|
|
54
|
+
### Dependencies
|
|
55
|
+
|
|
56
|
+
* The following workspace dependencies were updated
|
|
57
|
+
* dependencies
|
|
58
|
+
* @dotcom-tool-kit/conflict bumped from ^1.0.0 to ^1.0.1
|
|
59
|
+
* devDependencies
|
|
60
|
+
* @dotcom-tool-kit/config bumped from ^1.0.12 to ^1.1.0
|
|
61
|
+
* @dotcom-tool-kit/plugin bumped from ^1.0.0 to ^1.1.0
|
|
62
|
+
|
|
63
|
+
### Dependencies
|
|
64
|
+
|
|
65
|
+
* The following workspace dependencies were updated
|
|
66
|
+
* dependencies
|
|
67
|
+
* @dotcom-tool-kit/logger bumped from ^4.1.1 to ^4.2.0
|
|
68
|
+
|
|
69
|
+
## [2.0.1](https://github.com/Financial-Times/dotcom-tool-kit/compare/base-v2.0.0...base-v2.0.1) (2026-01-09)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### Bug Fixes
|
|
73
|
+
|
|
74
|
+
* it's not a conflict if there's only one child installation lol ([afa7863](https://github.com/Financial-Times/dotcom-tool-kit/commit/afa7863554744a65887507e9fea52b203fbb8cbb))
|
|
75
|
+
|
|
76
|
+
## [2.0.0](https://github.com/Financial-Times/dotcom-tool-kit/compare/base-v1.3.1...base-v2.0.0) (2025-10-28)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### ⚠ BREAKING CHANGES
|
|
80
|
+
|
|
81
|
+
* declare Node engines in all libraries
|
|
82
|
+
|
|
83
|
+
### Features
|
|
84
|
+
|
|
85
|
+
* declare Node engines in all libraries ([648d4d0](https://github.com/Financial-Times/dotcom-tool-kit/commit/648d4d0267d329655056ad38614b6659c80f5409))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### Dependencies
|
|
89
|
+
|
|
90
|
+
* The following workspace dependencies were updated
|
|
91
|
+
* dependencies
|
|
92
|
+
* @dotcom-tool-kit/conflict bumped from ^1.0.1 to ^2.0.0
|
|
93
|
+
* @dotcom-tool-kit/logger bumped from ^4.2.2 to ^5.0.0
|
|
94
|
+
* @dotcom-tool-kit/validated bumped from ^1.0.3 to ^2.0.0
|
|
95
|
+
* devDependencies
|
|
96
|
+
* @dotcom-tool-kit/config bumped from ^1.1.1 to ^2.0.0
|
|
97
|
+
* @dotcom-tool-kit/plugin bumped from ^1.1.0 to ^2.0.0
|
|
98
|
+
|
|
99
|
+
## [1.3.1](https://github.com/Financial-Times/dotcom-tool-kit/compare/base-v1.3.0...base-v1.3.1) (2025-10-09)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### Bug Fixes
|
|
103
|
+
|
|
104
|
+
* bump semver from 7.7.2 to 7.7.3 ([f37e915](https://github.com/Financial-Times/dotcom-tool-kit/commit/f37e915f184786c24dfe6095d3a54267c0738e5b))
|
|
105
|
+
|
|
106
|
+
## [1.3.0](https://github.com/Financial-Times/dotcom-tool-kit/compare/base-v1.2.3...base-v1.3.0) (2025-08-12)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
### Features
|
|
110
|
+
|
|
111
|
+
* add a Task.stop method and stop parallel tasks on error ([9d33d02](https://github.com/Financial-Times/dotcom-tool-kit/commit/9d33d02e734c04886d7e491e47bdac9f839ed509))
|
|
112
|
+
|
|
113
|
+
## [1.2.3](https://github.com/Financial-Times/dotcom-tool-kit/compare/base-v1.2.2...base-v1.2.3) (2025-05-20)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
### Bug Fixes
|
|
117
|
+
|
|
118
|
+
* bump semver from 7.7.1 to 7.7.2 ([9f82a24](https://github.com/Financial-Times/dotcom-tool-kit/commit/9f82a24fca533d05ec0fad171ca2b72dc3d0fb96))
|
|
119
|
+
* bump winston from 3.14.2 to 3.17.0 ([c0bc4c7](https://github.com/Financial-Times/dotcom-tool-kit/commit/c0bc4c71af06ac26323c826f24896e735591ac1a))
|
|
120
|
+
* bump zod from 3.24.3 to 3.24.4 ([2059a64](https://github.com/Financial-Times/dotcom-tool-kit/commit/2059a64ff9ab1b246f5b4e6b5b66f465be596b9e))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
### Dependencies
|
|
124
|
+
|
|
125
|
+
* The following workspace dependencies were updated
|
|
126
|
+
* dependencies
|
|
127
|
+
* @dotcom-tool-kit/logger bumped from ^4.2.1 to ^4.2.2
|
|
128
|
+
|
|
129
|
+
## [1.2.2](https://github.com/Financial-Times/dotcom-tool-kit/compare/base-v1.2.1...base-v1.2.2) (2025-05-06)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
### Bug Fixes
|
|
133
|
+
|
|
134
|
+
* bump zod from 3.24.2 to 3.24.3 ([21ecd2c](https://github.com/Financial-Times/dotcom-tool-kit/commit/21ecd2ccaf42f11a78e0b6f06f5ef2352aa91703))
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
### Dependencies
|
|
138
|
+
|
|
139
|
+
* The following workspace dependencies were updated
|
|
140
|
+
* dependencies
|
|
141
|
+
* @dotcom-tool-kit/logger bumped from ^4.2.0 to ^4.2.1
|
|
142
|
+
* @dotcom-tool-kit/validated bumped from ^1.0.2 to ^1.0.3
|
|
143
|
+
* devDependencies
|
|
144
|
+
* @dotcom-tool-kit/config bumped from ^1.1.0 to ^1.1.1
|
|
145
|
+
|
|
146
|
+
## [1.2.0](https://github.com/Financial-Times/dotcom-tool-kit/compare/base-v1.1.10...base-v1.2.0) (2025-03-03)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### Features
|
|
150
|
+
|
|
151
|
+
* **base:** pass cwd into init method ([b6cc028](https://github.com/Financial-Times/dotcom-tool-kit/commit/b6cc028129138869866f88860d544f5056668080))
|
|
152
|
+
|
|
153
|
+
## [1.1.5](https://github.com/Financial-Times/dotcom-tool-kit/compare/base-v1.1.4...base-v1.1.5) (2025-01-14)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
### Bug Fixes
|
|
157
|
+
|
|
158
|
+
* **base:** move logger dependency to prod ([c1c8a57](https://github.com/Financial-Times/dotcom-tool-kit/commit/c1c8a57e2e459e13b37efd519a80ff60835bde72))
|
|
159
|
+
* **cli:** try to always log ToolKitError details if present ([0d4f2b4](https://github.com/Financial-Times/dotcom-tool-kit/commit/0d4f2b4cf7de12a290b19c13ad7be27b41197896))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### Dependencies
|
|
163
|
+
|
|
164
|
+
* The following workspace dependencies were updated
|
|
165
|
+
* dependencies
|
|
166
|
+
* @dotcom-tool-kit/logger bumped from ^4.1.0 to ^4.1.1
|
|
167
|
+
* devDependencies
|
|
168
|
+
* @dotcom-tool-kit/config bumped from ^1.0.7 to ^1.0.8
|
|
169
|
+
|
|
170
|
+
## [1.1.0](https://github.com/Financial-Times/dotcom-tool-kit/compare/base-v1.0.0...base-v1.1.0) (2024-12-09)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
### Features
|
|
174
|
+
|
|
175
|
+
* pass config into taskruncontext ([435ffbc](https://github.com/Financial-Times/dotcom-tool-kit/commit/435ffbc74a81bdd159d4ea01943c6614ed1d3471))
|
|
176
|
+
* pass current command into task run context ([e4cf21c](https://github.com/Financial-Times/dotcom-tool-kit/commit/e4cf21c8c4e502b02918736b8b127097dba27572))
|
|
177
|
+
* pass task cwd through via TaskRunContext ([b12fe30](https://github.com/Financial-Times/dotcom-tool-kit/commit/b12fe30916e99e157e131a99fca6c59960b89f3a))
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
### Bug Fixes
|
|
181
|
+
|
|
182
|
+
* freeze the config before passing it into tasks ([a0283b9](https://github.com/Financial-Times/dotcom-tool-kit/commit/a0283b9b5a48314a26ce04ce4c176ab5f4aacc07))
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
### Dependencies
|
|
186
|
+
|
|
187
|
+
* The following workspace dependencies were updated
|
|
188
|
+
* dependencies
|
|
189
|
+
* @dotcom-tool-kit/validated bumped from ^1.0.0 to ^1.0.1
|
|
190
|
+
* devDependencies
|
|
191
|
+
* @dotcom-tool-kit/config bumped from ^1.0.2 to ^1.0.3
|
|
192
|
+
* @dotcom-tool-kit/logger bumped from ^4.0.0 to ^4.0.1
|
|
193
|
+
|
|
194
|
+
## 1.0.0 (2024-09-10)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
### ⚠ BREAKING CHANGES
|
|
198
|
+
|
|
199
|
+
* pass task files in as part of a run context object
|
|
200
|
+
* rename Task#options to pluginOptions
|
|
201
|
+
* move base classes into their own package
|
|
202
|
+
|
|
203
|
+
### Features
|
|
204
|
+
|
|
205
|
+
* allow tasks to receive a task options object and parse task schema when initialising ([1dce6bd](https://github.com/Financial-Times/dotcom-tool-kit/commit/1dce6bd5e8436bf521e94eb812aa847ca7dd1e4d))
|
|
206
|
+
* move base classes into their own package ([be1681b](https://github.com/Financial-Times/dotcom-tool-kit/commit/be1681b033609a9e332ab072681b6de8d05befb2))
|
|
207
|
+
* split remaining bits of types into config and plugins packages ([6cde9b9](https://github.com/Financial-Times/dotcom-tool-kit/commit/6cde9b90d4cd02383ae1b18ca38e0843e6c3d3ab))
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
### Code Refactoring
|
|
211
|
+
|
|
212
|
+
* pass task files in as part of a run context object ([5aa7327](https://github.com/Financial-Times/dotcom-tool-kit/commit/5aa7327018c0a87c8c9feef36ef9e3735a4f5e6d))
|
|
213
|
+
* rename Task#options to pluginOptions ([e73dcae](https://github.com/Financial-Times/dotcom-tool-kit/commit/e73dcae5ff48693545aa20e5c572269c3adf486b))
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
### Dependencies
|
|
217
|
+
|
|
218
|
+
* The following workspace dependencies were updated
|
|
219
|
+
* devDependencies
|
|
220
|
+
* @dotcom-tool-kit/logger bumped from ^3.3.0 to ^4.0.0
|
package/lib/base.js
CHANGED
|
@@ -12,9 +12,8 @@ const packageJsonPath = path_1.default.resolve(__dirname, '../package.json');
|
|
|
12
12
|
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
|
|
13
13
|
const version = packageJson.version;
|
|
14
14
|
class Base {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
15
|
+
static version = version;
|
|
16
|
+
version = version;
|
|
18
17
|
static get [symbols_1.typeSymbol]() {
|
|
19
18
|
return symbols_1.baseSymbol;
|
|
20
19
|
}
|
|
@@ -49,4 +48,3 @@ class Base {
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
exports.Base = Base;
|
|
52
|
-
Base.version = version;
|
package/lib/hook.d.ts
CHANGED
|
@@ -4,28 +4,36 @@ import { typeSymbol } from './symbols';
|
|
|
4
4
|
import type { z } from 'zod';
|
|
5
5
|
import type { Plugin } from '@dotcom-tool-kit/plugin';
|
|
6
6
|
import { Conflict } from '@dotcom-tool-kit/conflict';
|
|
7
|
+
import type { Default } from './type-utils';
|
|
7
8
|
export interface HookInstallation<Options = Record<string, unknown>> {
|
|
8
9
|
options: Options;
|
|
9
10
|
plugin: Plugin;
|
|
10
11
|
forHook: string;
|
|
11
12
|
hookConstructor: HookConstructor;
|
|
12
13
|
}
|
|
13
|
-
export declare abstract class Hook<Options extends
|
|
14
|
+
export declare abstract class Hook<Options extends {
|
|
15
|
+
hook?: z.ZodTypeAny;
|
|
16
|
+
plugin?: z.ZodTypeAny;
|
|
17
|
+
} = Record<never, never>, State = unknown> extends Base {
|
|
14
18
|
id: string;
|
|
15
|
-
options: z.output<Options
|
|
19
|
+
options: z.output<Default<Options['hook'], z.ZodObject<Record<string, never>>>>;
|
|
20
|
+
pluginOptions: z.output<Default<Options['plugin'], z.ZodObject<Record<string, never>>>>;
|
|
16
21
|
logger: Logger;
|
|
17
22
|
installGroup?: string;
|
|
18
23
|
static get [typeSymbol](): symbol;
|
|
19
24
|
get [typeSymbol](): symbol;
|
|
20
25
|
static mergeChildInstallations(plugin: Plugin, childInstallations: (HookInstallation | Conflict<HookInstallation>)[]): (HookInstallation | Conflict<HookInstallation>)[];
|
|
21
26
|
static overrideChildInstallations(plugin: Plugin, parentInstallation: HookInstallation, _childInstallations: (HookInstallation | Conflict<HookInstallation>)[]): (HookInstallation | Conflict<HookInstallation>)[];
|
|
22
|
-
constructor(logger: Logger, id: string, options: z.output<Options
|
|
27
|
+
constructor(logger: Logger, id: string, options: z.output<Default<Options['hook'], z.ZodObject<Record<string, never>>>>, pluginOptions: z.output<Default<Options['plugin'], z.ZodObject<Record<string, never>>>>);
|
|
23
28
|
abstract isInstalled(): Promise<boolean>;
|
|
24
29
|
abstract install(state?: State): Promise<State>;
|
|
25
30
|
commitInstall(_state: State): Promise<void>;
|
|
26
31
|
}
|
|
27
32
|
export type HookConstructor = {
|
|
28
|
-
new
|
|
33
|
+
new <O extends {
|
|
34
|
+
plugin: z.ZodTypeAny;
|
|
35
|
+
hook: z.ZodTypeAny;
|
|
36
|
+
}>(logger: Logger, id: string, options: z.infer<O['hook']>, pluginOptions: z.infer<O['plugin']>): Hook<O, unknown>;
|
|
29
37
|
};
|
|
30
38
|
export type HookClass = HookConstructor & typeof Hook;
|
|
31
39
|
//# sourceMappingURL=hook.d.ts.map
|
package/lib/hook.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../src/hook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAc,UAAU,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAc,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../src/hook.ts"],"names":[],"mappings":"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"}
|
package/lib/hook.js
CHANGED
|
@@ -5,6 +5,15 @@ const base_1 = require("./base");
|
|
|
5
5
|
const symbols_1 = require("./symbols");
|
|
6
6
|
const conflict_1 = require("@dotcom-tool-kit/conflict");
|
|
7
7
|
class Hook extends base_1.Base {
|
|
8
|
+
id;
|
|
9
|
+
options;
|
|
10
|
+
pluginOptions;
|
|
11
|
+
logger;
|
|
12
|
+
// This field is used to collect hooks that share state when running their
|
|
13
|
+
// install methods. All hooks in the same group will run their install method
|
|
14
|
+
// one after the other, and then their commitInstall method will be run with
|
|
15
|
+
// the collected state.
|
|
16
|
+
installGroup;
|
|
8
17
|
static get [symbols_1.typeSymbol]() {
|
|
9
18
|
return symbols_1.hookSymbol;
|
|
10
19
|
}
|
|
@@ -12,6 +21,9 @@ class Hook extends base_1.Base {
|
|
|
12
21
|
return symbols_1.hookSymbol;
|
|
13
22
|
}
|
|
14
23
|
static mergeChildInstallations(plugin, childInstallations) {
|
|
24
|
+
if (childInstallations.length === 1) {
|
|
25
|
+
return childInstallations;
|
|
26
|
+
}
|
|
15
27
|
return [
|
|
16
28
|
{
|
|
17
29
|
plugin,
|
|
@@ -22,10 +34,11 @@ class Hook extends base_1.Base {
|
|
|
22
34
|
static overrideChildInstallations(plugin, parentInstallation, _childInstallations) {
|
|
23
35
|
return [parentInstallation];
|
|
24
36
|
}
|
|
25
|
-
constructor(logger, id, options) {
|
|
37
|
+
constructor(logger, id, options, pluginOptions) {
|
|
26
38
|
super();
|
|
27
39
|
this.id = id;
|
|
28
40
|
this.options = options;
|
|
41
|
+
this.pluginOptions = pluginOptions;
|
|
29
42
|
this.logger = logger.child({ hook: this.constructor.name });
|
|
30
43
|
}
|
|
31
44
|
async commitInstall(_state) {
|
package/lib/init.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { Logger } from 'winston';
|
|
2
2
|
import { typeSymbol } from './symbols';
|
|
3
3
|
import { Base } from './base';
|
|
4
|
+
export type InitContext = {
|
|
5
|
+
cwd: string;
|
|
6
|
+
};
|
|
4
7
|
export declare abstract class Init extends Base {
|
|
5
8
|
logger: Logger;
|
|
6
9
|
constructor(logger: Logger);
|
|
7
10
|
static get [typeSymbol](): symbol;
|
|
8
11
|
get [typeSymbol](): symbol;
|
|
9
|
-
abstract init(): Promise<void>;
|
|
12
|
+
abstract init(context: InitContext): Promise<void>;
|
|
10
13
|
}
|
|
11
14
|
export type InitConstructor = {
|
|
12
15
|
new (logger: Logger): Init;
|
package/lib/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAc,UAAU,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,8BAAsB,IAAK,SAAQ,IAAI;IACrC,MAAM,EAAE,MAAM,CAAA;gBAEF,MAAM,EAAE,MAAM;IAK1B,MAAM,KAAK,CAAC,UAAU,CAAC,IAAI,MAAM,CAEhC;IAED,IAAI,CAAC,UAAU,CAAC,IAAI,MAAM,CAEzB;IAED,QAAQ,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAc,UAAU,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7B,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,8BAAsB,IAAK,SAAQ,IAAI;IACrC,MAAM,EAAE,MAAM,CAAA;gBAEF,MAAM,EAAE,MAAM;IAK1B,MAAM,KAAK,CAAC,UAAU,CAAC,IAAI,MAAM,CAEhC;IAED,IAAI,CAAC,UAAU,CAAC,IAAI,MAAM,CAEzB;IAED,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CACnD;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,eAAe,GAAG,OAAO,IAAI,CAAA"}
|
package/lib/init.js
CHANGED
package/lib/task.d.ts
CHANGED
|
@@ -2,7 +2,16 @@ import type { z } from 'zod';
|
|
|
2
2
|
import { Base } from './base';
|
|
3
3
|
import { typeSymbol } from './symbols';
|
|
4
4
|
import type { Logger } from 'winston';
|
|
5
|
-
type
|
|
5
|
+
import type { ValidConfig } from '@dotcom-tool-kit/config';
|
|
6
|
+
import { Plugin } from '@dotcom-tool-kit/plugin';
|
|
7
|
+
import type { Default } from './type-utils';
|
|
8
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
9
|
+
export type TaskRunContext = {
|
|
10
|
+
files?: string[];
|
|
11
|
+
command: string;
|
|
12
|
+
cwd: string;
|
|
13
|
+
config: ReadonlyDeep<ValidConfig>;
|
|
14
|
+
};
|
|
6
15
|
export declare abstract class Task<Options extends {
|
|
7
16
|
plugin?: z.ZodTypeAny;
|
|
8
17
|
task?: z.ZodTypeAny;
|
|
@@ -10,18 +19,19 @@ export declare abstract class Task<Options extends {
|
|
|
10
19
|
id: string;
|
|
11
20
|
pluginOptions: z.output<Default<Options['plugin'], z.ZodObject<Record<string, never>>>>;
|
|
12
21
|
options: z.output<Default<Options['task'], z.ZodObject<Record<string, never>>>>;
|
|
22
|
+
plugin: Plugin;
|
|
13
23
|
static get [typeSymbol](): symbol;
|
|
14
24
|
get [typeSymbol](): symbol;
|
|
15
25
|
logger: Logger;
|
|
16
|
-
constructor(logger: Logger, id: string, pluginOptions: z.output<Default<Options['plugin'], z.ZodObject<Record<string, never>>>>, options: z.output<Default<Options['task'], z.ZodObject<Record<string, never
|
|
17
|
-
abstract run(
|
|
26
|
+
constructor(logger: Logger, id: string, pluginOptions: z.output<Default<Options['plugin'], z.ZodObject<Record<string, never>>>>, options: z.output<Default<Options['task'], z.ZodObject<Record<string, never>>>>, plugin: Plugin);
|
|
27
|
+
abstract run(runContext: TaskRunContext): Promise<void>;
|
|
28
|
+
stop(): Promise<void>;
|
|
18
29
|
}
|
|
19
30
|
export type TaskConstructor = {
|
|
20
31
|
new <O extends {
|
|
21
32
|
plugin: z.ZodTypeAny;
|
|
22
33
|
task: z.ZodTypeAny;
|
|
23
|
-
}>(logger: Logger, id: string, pluginOptions: Partial<z.infer<O['plugin']>>, options: Partial<z.infer<O['task']
|
|
34
|
+
}>(logger: Logger, id: string, pluginOptions: Partial<z.infer<O['plugin']>>, options: Partial<z.infer<O['task']>>, plugin: Plugin): Task<O>;
|
|
24
35
|
};
|
|
25
36
|
export type TaskClass = TaskConstructor & typeof Task;
|
|
26
|
-
export {};
|
|
27
37
|
//# sourceMappingURL=task.d.ts.map
|
package/lib/task.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../src/task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAc,UAAU,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../src/task.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAc,UAAU,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,CAAA;CAClC,CAAA;AAED,8BAAsB,IAAI,CACxB,OAAO,SAAS;IACd,MAAM,CAAC,EAAE,CAAC,CAAC,UAAU,CAAA;IACrB,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAA;CACpB,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CACxB,SAAQ,IAAI;IAaH,EAAE,EAAE,MAAM;IACV,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACvF,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/E,MAAM,EAAE,MAAM;IAfvB,MAAM,KAAK,CAAC,UAAU,CAAC,IAAI,MAAM,CAEhC;IAED,IAAI,CAAC,UAAU,CAAC,IAAI,MAAM,CAEzB;IAED,MAAM,EAAE,MAAM,CAAA;gBAGZ,MAAM,EAAE,MAAM,EACP,EAAE,EAAE,MAAM,EACV,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EACvF,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAC/E,MAAM,EAAE,MAAM;IAMvB,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAC5B;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,SAAS;QAAE,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC;QAAC,IAAI,EAAE,CAAC,CAAC,UAAU,CAAA;KAAE,EACzD,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5C,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EACpC,MAAM,EAAE,MAAM,GACb,IAAI,CAAC,CAAC,CAAC,CAAA;CACX,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,eAAe,GAAG,OAAO,IAAI,CAAA"}
|
package/lib/task.js
CHANGED
|
@@ -4,18 +4,27 @@ exports.Task = void 0;
|
|
|
4
4
|
const base_1 = require("./base");
|
|
5
5
|
const symbols_1 = require("./symbols");
|
|
6
6
|
class Task extends base_1.Base {
|
|
7
|
+
id;
|
|
8
|
+
pluginOptions;
|
|
9
|
+
options;
|
|
10
|
+
plugin;
|
|
7
11
|
static get [symbols_1.typeSymbol]() {
|
|
8
12
|
return symbols_1.taskSymbol;
|
|
9
13
|
}
|
|
10
14
|
get [symbols_1.typeSymbol]() {
|
|
11
15
|
return symbols_1.taskSymbol;
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
logger;
|
|
18
|
+
constructor(logger, id, pluginOptions, options, plugin) {
|
|
14
19
|
super();
|
|
15
20
|
this.id = id;
|
|
16
21
|
this.pluginOptions = pluginOptions;
|
|
17
22
|
this.options = options;
|
|
23
|
+
this.plugin = plugin;
|
|
18
24
|
this.logger = logger.child({ task: id });
|
|
19
25
|
}
|
|
26
|
+
// not abstract for default behaviour of doing nothing
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
28
|
+
async stop() { }
|
|
20
29
|
}
|
|
21
30
|
exports.Task = Task;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,CAAC,GAAG,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcom-tool-kit/base",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib",
|
|
6
6
|
"scripts": {
|
|
@@ -10,18 +10,23 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dotcom-tool-kit/conflict": "2.0.0
|
|
14
|
-
"@dotcom-tool-kit/
|
|
15
|
-
"
|
|
16
|
-
"
|
|
13
|
+
"@dotcom-tool-kit/conflict": "^2.0.0",
|
|
14
|
+
"@dotcom-tool-kit/logger": "^5.0.0",
|
|
15
|
+
"@dotcom-tool-kit/validated": "^2.0.0",
|
|
16
|
+
"semver": "^7.7.3",
|
|
17
|
+
"winston": "^3.17.0"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
|
-
"@dotcom-tool-kit/
|
|
20
|
-
"@dotcom-tool-kit/plugin": "2.0.0
|
|
21
|
-
"
|
|
22
|
-
"
|
|
20
|
+
"@dotcom-tool-kit/config": "^2.0.0",
|
|
21
|
+
"@dotcom-tool-kit/plugin": "^2.0.0",
|
|
22
|
+
"type-fest": "^4.41.0",
|
|
23
|
+
"winston": "^3.17.0",
|
|
24
|
+
"zod": "^3.24.4"
|
|
23
25
|
},
|
|
24
26
|
"peerDependencies": {
|
|
25
|
-
"zod": "^3.
|
|
27
|
+
"zod": "^3.24.4"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=20.x"
|
|
26
31
|
}
|
|
27
|
-
}
|
|
32
|
+
}
|
package/src/hook.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { hookSymbol, typeSymbol } from './symbols'
|
|
|
4
4
|
import type { z } from 'zod'
|
|
5
5
|
import type { Plugin } from '@dotcom-tool-kit/plugin'
|
|
6
6
|
import { Conflict, isConflict } from '@dotcom-tool-kit/conflict'
|
|
7
|
+
import type { Default } from './type-utils'
|
|
7
8
|
|
|
8
9
|
export interface HookInstallation<Options = Record<string, unknown>> {
|
|
9
10
|
options: Options
|
|
@@ -12,7 +13,13 @@ export interface HookInstallation<Options = Record<string, unknown>> {
|
|
|
12
13
|
hookConstructor: HookConstructor
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export abstract class Hook<
|
|
16
|
+
export abstract class Hook<
|
|
17
|
+
Options extends {
|
|
18
|
+
hook?: z.ZodTypeAny
|
|
19
|
+
plugin?: z.ZodTypeAny
|
|
20
|
+
} = Record<never, never>,
|
|
21
|
+
State = unknown
|
|
22
|
+
> extends Base {
|
|
16
23
|
logger: Logger
|
|
17
24
|
// This field is used to collect hooks that share state when running their
|
|
18
25
|
// install methods. All hooks in the same group will run their install method
|
|
@@ -32,6 +39,10 @@ export abstract class Hook<Options extends z.ZodTypeAny = z.ZodTypeAny, State =
|
|
|
32
39
|
plugin: Plugin,
|
|
33
40
|
childInstallations: (HookInstallation | Conflict<HookInstallation>)[]
|
|
34
41
|
): (HookInstallation | Conflict<HookInstallation>)[] {
|
|
42
|
+
if (childInstallations.length === 1) {
|
|
43
|
+
return childInstallations
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
return [
|
|
36
47
|
{
|
|
37
48
|
plugin,
|
|
@@ -50,7 +61,12 @@ export abstract class Hook<Options extends z.ZodTypeAny = z.ZodTypeAny, State =
|
|
|
50
61
|
return [parentInstallation]
|
|
51
62
|
}
|
|
52
63
|
|
|
53
|
-
constructor(
|
|
64
|
+
constructor(
|
|
65
|
+
logger: Logger,
|
|
66
|
+
public id: string,
|
|
67
|
+
public options: z.output<Default<Options['hook'], z.ZodObject<Record<string, never>>>>,
|
|
68
|
+
public pluginOptions: z.output<Default<Options['plugin'], z.ZodObject<Record<string, never>>>>
|
|
69
|
+
) {
|
|
54
70
|
super()
|
|
55
71
|
this.logger = logger.child({ hook: this.constructor.name })
|
|
56
72
|
}
|
|
@@ -63,7 +79,12 @@ export abstract class Hook<Options extends z.ZodTypeAny = z.ZodTypeAny, State =
|
|
|
63
79
|
}
|
|
64
80
|
|
|
65
81
|
export type HookConstructor = {
|
|
66
|
-
new
|
|
82
|
+
new <O extends { plugin: z.ZodTypeAny; hook: z.ZodTypeAny }>(
|
|
83
|
+
logger: Logger,
|
|
84
|
+
id: string,
|
|
85
|
+
options: z.infer<O['hook']>,
|
|
86
|
+
pluginOptions: z.infer<O['plugin']>
|
|
87
|
+
): Hook<O, unknown>
|
|
67
88
|
}
|
|
68
89
|
|
|
69
90
|
export type HookClass = HookConstructor & typeof Hook
|
package/src/init.ts
CHANGED
|
@@ -2,6 +2,10 @@ import type { Logger } from 'winston'
|
|
|
2
2
|
import { initSymbol, typeSymbol } from './symbols'
|
|
3
3
|
import { Base } from './base'
|
|
4
4
|
|
|
5
|
+
export type InitContext = {
|
|
6
|
+
cwd: string
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
export abstract class Init extends Base {
|
|
6
10
|
logger: Logger
|
|
7
11
|
|
|
@@ -18,7 +22,7 @@ export abstract class Init extends Base {
|
|
|
18
22
|
return initSymbol
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
abstract init(): Promise<void>
|
|
25
|
+
abstract init(context: InitContext): Promise<void>
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
export type InitConstructor = {
|
package/src/task.ts
CHANGED
|
@@ -2,8 +2,17 @@ import type { z } from 'zod'
|
|
|
2
2
|
import { Base } from './base'
|
|
3
3
|
import { taskSymbol, typeSymbol } from './symbols'
|
|
4
4
|
import type { Logger } from 'winston'
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import type { ValidConfig } from '@dotcom-tool-kit/config'
|
|
6
|
+
import { Plugin } from '@dotcom-tool-kit/plugin'
|
|
7
|
+
import type { Default } from './type-utils'
|
|
8
|
+
import type { ReadonlyDeep } from 'type-fest'
|
|
9
|
+
|
|
10
|
+
export type TaskRunContext = {
|
|
11
|
+
files?: string[]
|
|
12
|
+
command: string
|
|
13
|
+
cwd: string
|
|
14
|
+
config: ReadonlyDeep<ValidConfig>
|
|
15
|
+
}
|
|
7
16
|
|
|
8
17
|
export abstract class Task<
|
|
9
18
|
Options extends {
|
|
@@ -25,13 +34,18 @@ export abstract class Task<
|
|
|
25
34
|
logger: Logger,
|
|
26
35
|
public id: string,
|
|
27
36
|
public pluginOptions: z.output<Default<Options['plugin'], z.ZodObject<Record<string, never>>>>,
|
|
28
|
-
public options: z.output<Default<Options['task'], z.ZodObject<Record<string, never
|
|
37
|
+
public options: z.output<Default<Options['task'], z.ZodObject<Record<string, never>>>>,
|
|
38
|
+
public plugin: Plugin
|
|
29
39
|
) {
|
|
30
40
|
super()
|
|
31
41
|
this.logger = logger.child({ task: id })
|
|
32
42
|
}
|
|
33
43
|
|
|
34
|
-
abstract run(
|
|
44
|
+
abstract run(runContext: TaskRunContext): Promise<void>
|
|
45
|
+
|
|
46
|
+
// not abstract for default behaviour of doing nothing
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
48
|
+
async stop(): Promise<void> {}
|
|
35
49
|
}
|
|
36
50
|
|
|
37
51
|
export type TaskConstructor = {
|
|
@@ -39,7 +53,8 @@ export type TaskConstructor = {
|
|
|
39
53
|
logger: Logger,
|
|
40
54
|
id: string,
|
|
41
55
|
pluginOptions: Partial<z.infer<O['plugin']>>,
|
|
42
|
-
options: Partial<z.infer<O['task']
|
|
56
|
+
options: Partial<z.infer<O['task']>>,
|
|
57
|
+
plugin: Plugin
|
|
43
58
|
): Task<O>
|
|
44
59
|
}
|
|
45
60
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Default<T, D> = T extends undefined ? D : T
|