@decohere/devkit 0.0.1-dev.125 → 0.0.1-dev.5

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.
Files changed (121) hide show
  1. package/package.json +3 -12
  2. package/src/cli/action.ts +77 -0
  3. package/src/cli/command.ts +173 -0
  4. package/src/cli/index.ts +30 -0
  5. package/src/cli/module.type.ts +48 -0
  6. package/src/cli/options.ts +81 -0
  7. package/src/diagnostics/trace.ts +92 -0
  8. package/src/interop/docker/docker.ts +57 -0
  9. package/src/interop/errors/interop.error.ts +1 -0
  10. package/src/interop/git/git.ts +98 -0
  11. package/{types/src/interop/git/git.types.d.ts → src/interop/git/git.types.ts} +9 -6
  12. package/{es6/src/interop/index.js → src/interop/index.ts} +1 -0
  13. package/src/interop/node/node.ts +38 -0
  14. package/src/interop/npm/npm.ts +168 -0
  15. package/src/interop/npm/npm.types.ts +28 -0
  16. package/src/interop/pnpm/pnpm.ts +22 -0
  17. package/{types/src/interop/pnpm/pnpm.types.d.ts → src/interop/pnpm/pnpm.types.ts} +1 -1
  18. package/src/interop/shell/shell.argv.ts +31 -0
  19. package/src/interop/shell/shell.ts +100 -0
  20. package/src/interop/shell/shell.types.ts +9 -0
  21. package/src/interop/types/detect-package-manager.ts +45 -0
  22. package/src/interop/types/package-manager.ts +7 -0
  23. package/src/interop/yarn/yarn.ts +28 -0
  24. package/{types/src/interop/yarn/yarn.types.d.ts → src/interop/yarn/yarn.types.ts} +1 -1
  25. package/src/io/find-directories.ts +13 -0
  26. package/src/io/find-file.ts +37 -0
  27. package/src/io/watch.ts +290 -0
  28. package/tests/cli/command.model.spec.ts +91 -0
  29. package/tests/diagnostics/trace.spec.ts +319 -0
  30. package/tests/interop/detect-package-manager.spec.ts +70 -0
  31. package/tests/interop/npm.spec.ts +129 -0
  32. package/tests/interop/pnpm.spec.ts +30 -0
  33. package/tests/interop/shell.spec.ts +47 -0
  34. package/tests/interop/yarn.spec.ts +18 -0
  35. package/tests/io/find-file.spec.ts +188 -0
  36. package/tests/io/watch.real-fs.spec.ts +76 -0
  37. package/tests/io/watch.spec.ts +291 -0
  38. package/LICENSE +0 -15
  39. package/commonjs/src/cli/action.js +0 -65
  40. package/commonjs/src/cli/command.js +0 -127
  41. package/commonjs/src/cli/index.js +0 -61
  42. package/commonjs/src/cli/module.type.js +0 -18
  43. package/commonjs/src/cli/options.js +0 -115
  44. package/commonjs/src/diagnostics/index.js +0 -22
  45. package/commonjs/src/diagnostics/trace.js +0 -79
  46. package/commonjs/src/interop/docker/docker.js +0 -54
  47. package/commonjs/src/interop/errors/interop.error.js +0 -12
  48. package/commonjs/src/interop/git/git.js +0 -134
  49. package/commonjs/src/interop/git/git.types.js +0 -4
  50. package/commonjs/src/interop/index.js +0 -97
  51. package/commonjs/src/interop/node/index.js +0 -18
  52. package/commonjs/src/interop/node/node.js +0 -45
  53. package/commonjs/src/interop/npm/npm.js +0 -231
  54. package/commonjs/src/interop/npm/npm.types.js +0 -16
  55. package/commonjs/src/interop/pnpm/pnpm.js +0 -34
  56. package/commonjs/src/interop/pnpm/pnpm.types.js +0 -4
  57. package/commonjs/src/interop/shell/shell.argv.js +0 -45
  58. package/commonjs/src/interop/shell/shell.js +0 -105
  59. package/commonjs/src/interop/shell/shell.types.js +0 -4
  60. package/commonjs/src/interop/types/detect-package-manager.js +0 -71
  61. package/commonjs/src/interop/types/package-manager.js +0 -4
  62. package/commonjs/src/interop/yarn/yarn.js +0 -34
  63. package/commonjs/src/interop/yarn/yarn.types.js +0 -4
  64. package/commonjs/src/io/find-directories.js +0 -21
  65. package/commonjs/src/io/find-file.js +0 -45
  66. package/commonjs/src/io/index.js +0 -20
  67. package/commonjs/src/io/watch.js +0 -261
  68. package/es6/src/cli/action.js +0 -47
  69. package/es6/src/cli/command.js +0 -106
  70. package/es6/src/cli/index.js +0 -4
  71. package/es6/src/cli/module.type.js +0 -11
  72. package/es6/src/cli/options.js +0 -76
  73. package/es6/src/diagnostics/trace.js +0 -61
  74. package/es6/src/interop/docker/docker.js +0 -44
  75. package/es6/src/interop/errors/interop.error.js +0 -2
  76. package/es6/src/interop/git/git.js +0 -124
  77. package/es6/src/interop/git/git.types.js +0 -1
  78. package/es6/src/interop/node/node.js +0 -35
  79. package/es6/src/interop/npm/npm.js +0 -180
  80. package/es6/src/interop/npm/npm.types.js +0 -6
  81. package/es6/src/interop/pnpm/pnpm.js +0 -24
  82. package/es6/src/interop/pnpm/pnpm.types.js +0 -1
  83. package/es6/src/interop/shell/shell.argv.js +0 -35
  84. package/es6/src/interop/shell/shell.js +0 -95
  85. package/es6/src/interop/shell/shell.types.js +0 -1
  86. package/es6/src/interop/types/detect-package-manager.js +0 -50
  87. package/es6/src/interop/types/package-manager.js +0 -1
  88. package/es6/src/interop/yarn/yarn.js +0 -24
  89. package/es6/src/interop/yarn/yarn.types.js +0 -1
  90. package/es6/src/io/find-directories.js +0 -11
  91. package/es6/src/io/find-file.js +0 -27
  92. package/es6/src/io/watch.js +0 -238
  93. package/types/src/cli/action.d.ts +0 -36
  94. package/types/src/cli/command.d.ts +0 -34
  95. package/types/src/cli/index.d.ts +0 -7
  96. package/types/src/cli/module.type.d.ts +0 -36
  97. package/types/src/cli/options.d.ts +0 -28
  98. package/types/src/diagnostics/index.d.ts +0 -1
  99. package/types/src/diagnostics/trace.d.ts +0 -10
  100. package/types/src/interop/docker/docker.d.ts +0 -19
  101. package/types/src/interop/errors/interop.error.d.ts +0 -2
  102. package/types/src/interop/git/git.d.ts +0 -16
  103. package/types/src/interop/index.d.ts +0 -14
  104. package/types/src/interop/node/index.d.ts +0 -1
  105. package/types/src/interop/node/node.d.ts +0 -5
  106. package/types/src/interop/npm/npm.d.ts +0 -29
  107. package/types/src/interop/npm/npm.types.d.ts +0 -24
  108. package/types/src/interop/pnpm/pnpm.d.ts +0 -9
  109. package/types/src/interop/shell/shell.argv.d.ts +0 -5
  110. package/types/src/interop/shell/shell.d.ts +0 -6
  111. package/types/src/interop/shell/shell.types.d.ts +0 -9
  112. package/types/src/interop/types/detect-package-manager.d.ts +0 -4
  113. package/types/src/interop/types/package-manager.d.ts +0 -10
  114. package/types/src/interop/yarn/yarn.d.ts +0 -9
  115. package/types/src/io/find-directories.d.ts +0 -2
  116. package/types/src/io/find-file.d.ts +0 -9
  117. package/types/src/io/index.d.ts +0 -3
  118. package/types/src/io/watch.d.ts +0 -16
  119. /package/{es6/src/diagnostics/index.js → src/diagnostics/index.ts} +0 -0
  120. /package/{es6/src/interop/node/index.js → src/interop/node/index.ts} +0 -0
  121. /package/{es6/src/io/index.js → src/io/index.ts} +0 -0
@@ -0,0 +1,291 @@
1
+ import path from "node:path";
2
+ import { fs, vol } from "memfs";
3
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
4
+ import { watch } from "../../src/io/watch.js";
5
+
6
+ vi.mock("fs");
7
+ vi.mock("node:fs");
8
+ vi.mock("fs/promises");
9
+ vi.mock("node:fs/promises");
10
+
11
+ describe("io.watch", () => {
12
+ beforeEach(() => {
13
+ vol.reset();
14
+ });
15
+
16
+ afterEach(() => {
17
+ vol.reset();
18
+ });
19
+
20
+ it("emits change for nested subdirectory files", async () => {
21
+ const rootPath = "/workspace/project/src";
22
+ const nestedDirectoryPath = path.join(rootPath, "nested", "deeper");
23
+ const nestedFilePath = path.join(nestedDirectoryPath, "index.ts");
24
+ const expectedRelativePath = path.posix.join("nested", "deeper", "index.ts");
25
+
26
+ fs.mkdirSync(nestedDirectoryPath, { recursive: true });
27
+ fs.writeFileSync(nestedFilePath, "export const v = 1;", { encoding: "utf8" });
28
+
29
+ await new Promise<void>((resolve, reject) => {
30
+ const watcher = watch(rootPath);
31
+
32
+ watcher.on("change", (file) => {
33
+ if (file.relativePath !== expectedRelativePath) {
34
+ return;
35
+ }
36
+
37
+ expect(file.fullPath).toBe(nestedFilePath);
38
+ watcher.close();
39
+ resolve();
40
+ });
41
+
42
+ setTimeout(() => {
43
+ fs.writeFileSync(nestedFilePath, "export const v = 2;", { encoding: "utf8" });
44
+ }, 30);
45
+
46
+ setTimeout(() => {
47
+ watcher.close();
48
+ reject(new Error("expected change event was not emitted for nested file"));
49
+ }, 800);
50
+ });
51
+ });
52
+
53
+ it("does not emit initial add events when ignoreInitial is true", async () => {
54
+ const rootPath = "/workspace/project/src";
55
+ const existingFilePath = path.join(rootPath, "index.ts");
56
+
57
+ fs.mkdirSync(rootPath, { recursive: true });
58
+ fs.writeFileSync(existingFilePath, "export const v = 1;", { encoding: "utf8" });
59
+
60
+ await new Promise<void>((resolve, reject) => {
61
+ const watcher = watch(rootPath, { ignoreInitial: true });
62
+
63
+ watcher.on("add", () => {
64
+ watcher.close();
65
+ reject(new Error("unexpected initial add event"));
66
+ });
67
+
68
+ setTimeout(() => {
69
+ watcher.close();
70
+ resolve();
71
+ }, 100);
72
+ });
73
+ });
74
+
75
+ it("emits add for a new file when ignoreInitial is true", async () => {
76
+ const rootPath = "/workspace/project/src";
77
+ const addedFilePath = path.join(rootPath, "new-file.ts");
78
+
79
+ fs.mkdirSync(rootPath, { recursive: true });
80
+ fs.writeFileSync(path.join(rootPath, "existing.ts"), "export const x = 1;", {
81
+ encoding: "utf8",
82
+ });
83
+
84
+ await new Promise<void>((resolve, reject) => {
85
+ const watcher = watch(rootPath, { ignoreInitial: true });
86
+
87
+ watcher.on("add", (file) => {
88
+ if (file.relativePath !== "new-file.ts") {
89
+ return;
90
+ }
91
+
92
+ expect(file.fullPath).toBe(addedFilePath);
93
+ watcher.close();
94
+ resolve();
95
+ });
96
+
97
+ watcher.ready.then(() => {
98
+ fs.writeFileSync(addedFilePath, "export const y = 2;", { encoding: "utf8" });
99
+ });
100
+
101
+ setTimeout(() => {
102
+ watcher.close();
103
+ reject(new Error("expected add event was not emitted for new file"));
104
+ }, 800);
105
+ });
106
+ });
107
+
108
+ it("emits unlink when a watched file is deleted", async () => {
109
+ const rootPath = "/workspace/project/src";
110
+ const removedFilePath = path.join(rootPath, "index.ts");
111
+
112
+ fs.mkdirSync(rootPath, { recursive: true });
113
+ fs.writeFileSync(removedFilePath, "export const v = 1;", { encoding: "utf8" });
114
+
115
+ await new Promise<void>((resolve, reject) => {
116
+ const watcher = watch(rootPath, { ignoreInitial: true });
117
+
118
+ watcher.on("unlink", (file) => {
119
+ if (file.relativePath !== "index.ts") {
120
+ return;
121
+ }
122
+
123
+ expect(file.fullPath).toBe(removedFilePath);
124
+ watcher.close();
125
+ resolve();
126
+ });
127
+
128
+ watcher.ready.then(() => {
129
+ fs.unlinkSync(removedFilePath);
130
+ });
131
+
132
+ setTimeout(() => {
133
+ watcher.close();
134
+ reject(new Error("expected unlink event was not emitted for removed file"));
135
+ }, 800);
136
+ });
137
+ });
138
+
139
+ it("applies include patterns to emitted events", async () => {
140
+ const rootPath = "/workspace/project/src";
141
+ const ignoredFilePath = path.join(rootPath, "ignored.js");
142
+ const includedFilePath = path.join(rootPath, "included.ts");
143
+
144
+ fs.mkdirSync(rootPath, { recursive: true });
145
+
146
+ await new Promise<void>((resolve, reject) => {
147
+ const watcher = watch(rootPath, { ignoreInitial: true, include: ["**/*.ts"] });
148
+
149
+ watcher.on("add", (file) => {
150
+ if (file.relativePath === "ignored.js") {
151
+ watcher.close();
152
+ reject(new Error("include filter emitted ignored.js unexpectedly"));
153
+ return;
154
+ }
155
+
156
+ if (file.relativePath !== "included.ts") {
157
+ return;
158
+ }
159
+
160
+ expect(file.fullPath).toBe(includedFilePath);
161
+ watcher.close();
162
+ resolve();
163
+ });
164
+
165
+ watcher.ready.then(() => {
166
+ fs.writeFileSync(ignoredFilePath, "export const ignored = true;", {
167
+ encoding: "utf8",
168
+ });
169
+ fs.writeFileSync(includedFilePath, "export const included = true;", {
170
+ encoding: "utf8",
171
+ });
172
+ });
173
+
174
+ setTimeout(() => {
175
+ watcher.close();
176
+ reject(new Error("include filter did not emit included.ts"));
177
+ }, 800);
178
+ });
179
+ });
180
+
181
+ it("applies ignore patterns to emitted events", async () => {
182
+ const rootPath = "/workspace/project/src";
183
+ const ignoredFilePath = path.join(rootPath, "index.spec.ts");
184
+ const includedFilePath = path.join(rootPath, "index.ts");
185
+
186
+ fs.mkdirSync(rootPath, { recursive: true });
187
+
188
+ await new Promise<void>((resolve, reject) => {
189
+ const watcher = watch(rootPath, {
190
+ ignoreInitial: true,
191
+ ignore: ["**/*.spec.ts"],
192
+ });
193
+
194
+ watcher.on("add", (file) => {
195
+ if (file.relativePath === "index.spec.ts") {
196
+ watcher.close();
197
+ reject(new Error("ignore filter emitted index.spec.ts unexpectedly"));
198
+ return;
199
+ }
200
+
201
+ if (file.relativePath !== "index.ts") {
202
+ return;
203
+ }
204
+
205
+ expect(file.fullPath).toBe(includedFilePath);
206
+ watcher.close();
207
+ resolve();
208
+ });
209
+
210
+ watcher.ready.then(() => {
211
+ fs.writeFileSync(ignoredFilePath, "export const ignored = true;", {
212
+ encoding: "utf8",
213
+ });
214
+ fs.writeFileSync(includedFilePath, "export const included = true;", {
215
+ encoding: "utf8",
216
+ });
217
+ });
218
+
219
+ setTimeout(() => {
220
+ watcher.close();
221
+ reject(new Error("ignore filter did not emit index.ts"));
222
+ }, 800);
223
+ });
224
+ });
225
+
226
+ it("emits ready after watcher initialization", async () => {
227
+ const rootPath = "/workspace/project/src";
228
+ fs.mkdirSync(rootPath, { recursive: true });
229
+ fs.writeFileSync(path.join(rootPath, "index.ts"), "export const v = 1;", {
230
+ encoding: "utf8",
231
+ });
232
+
233
+ await new Promise<void>((resolve, reject) => {
234
+ const watcher = watch(rootPath, { ignoreInitial: true });
235
+
236
+ watcher.on("ready", () => {
237
+ watcher.close();
238
+ resolve();
239
+ });
240
+
241
+ setTimeout(() => {
242
+ watcher.close();
243
+ reject(new Error("watcher did not emit ready event"));
244
+ }, 200);
245
+ });
246
+ });
247
+
248
+ it("resolves watcher.ready after initialization", async () => {
249
+ const rootPath = "/workspace/project/src";
250
+ fs.mkdirSync(rootPath, { recursive: true });
251
+ const watcher = watch(rootPath, { ignoreInitial: true });
252
+
253
+ await expect(watcher.ready).resolves.toBeUndefined();
254
+ watcher.close();
255
+ });
256
+
257
+ it("emits change only once for a single write", async () => {
258
+ const rootPath = "/workspace/project/src";
259
+ const filePath = path.join(rootPath, "index.ts");
260
+
261
+ fs.mkdirSync(rootPath, { recursive: true });
262
+ fs.writeFileSync(filePath, "export const v = 1;", { encoding: "utf8" });
263
+
264
+ await new Promise<void>((resolve, reject) => {
265
+ const watcher = watch(rootPath, { ignoreInitial: true });
266
+ let changeCount = 0;
267
+
268
+ watcher.on("change", (file) => {
269
+ if (file.relativePath !== "index.ts") {
270
+ return;
271
+ }
272
+
273
+ changeCount += 1;
274
+ });
275
+
276
+ watcher.ready.then(() => {
277
+ fs.writeFileSync(filePath, "export const v = 2;", { encoding: "utf8" });
278
+ });
279
+
280
+ setTimeout(() => {
281
+ watcher.close();
282
+ try {
283
+ expect(changeCount).toBeLessThanOrEqual(1);
284
+ resolve();
285
+ } catch (error) {
286
+ reject(error);
287
+ }
288
+ }, 300);
289
+ });
290
+ });
291
+ });
package/LICENSE DELETED
@@ -1,15 +0,0 @@
1
- ISC License
2
-
3
- Copyright (c) 2025-2026 Typesmiths
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get ActionMap () {
13
- return ActionMap;
14
- },
15
- get ActionResponse () {
16
- return ActionResponse;
17
- }
18
- });
19
- const ActionMap = Symbol("ActionMap");
20
- class ActionResponse {
21
- static Success(name, data) {
22
- return new ActionResponse({
23
- name,
24
- data,
25
- succeeded: true
26
- });
27
- }
28
- static Skipped(name) {
29
- return new ActionResponse({
30
- name,
31
- skipped: true
32
- });
33
- }
34
- static Blocking(name) {
35
- return new ActionResponse({
36
- name,
37
- succeeded: true,
38
- blocking: true
39
- });
40
- }
41
- static Error(name, messageOrData, data) {
42
- if (Array.isArray(messageOrData)) {
43
- const message = messageOrData.filter((r)=>!r.succeeded).map((r)=>r.error ?? "Unknown error").join("\n");
44
- return new ActionResponse({
45
- name,
46
- message,
47
- data: messageOrData
48
- });
49
- }
50
- return new ActionResponse({
51
- name,
52
- message: messageOrData,
53
- data
54
- });
55
- }
56
- constructor(data){
57
- Object.assign(this, data);
58
- }
59
- name;
60
- succeeded = false;
61
- skipped = false;
62
- blocking = false;
63
- message;
64
- data;
65
- }
@@ -1,127 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get CommandError () {
13
- return CommandError;
14
- },
15
- get CommandResponse () {
16
- return CommandResponse;
17
- },
18
- get DecohereCommand () {
19
- return DecohereCommand;
20
- }
21
- });
22
- const _commander = require("commander");
23
- const CommandResponse = {
24
- success (_ctx, responses) {
25
- return responses;
26
- },
27
- help () {
28
- return {};
29
- },
30
- fromAction (name, response) {
31
- return {
32
- [name]: response
33
- };
34
- }
35
- };
36
- class CommandError extends Error {
37
- }
38
- class DecohereCommand extends _commander.Command {
39
- get actions() {
40
- return [];
41
- }
42
- constructor(name, handler){
43
- super();
44
- if (typeof name === "string" || typeof name === "function") {
45
- this.name(this.parseCommandName(name));
46
- } else {
47
- this.name(this.parseCommandName(this.constructor));
48
- if (name) {
49
- this.registerSubcommand(name, handler);
50
- }
51
- }
52
- if (handler && !this.commands.length) {
53
- this.action(handler);
54
- }
55
- this.exitOverride();
56
- }
57
- /**
58
- * Whether the command, with these options, runs until it is stopped (`flux serve`,
59
- * `forge build --watch`). The CLI then listens for SIGINT and SIGTERM from the moment it
60
- * starts, so a stop during start-up still shuts down cleanly; other commands keep Node's
61
- * default, where Ctrl+C ends them at once.
62
- */ runsUntilStopped(_options) {
63
- return false;
64
- }
65
- async run(actions, options) {
66
- const responses = await this.runActions(actions, options);
67
- this.throwOnErrors(responses);
68
- return CommandResponse.success(options, responses);
69
- }
70
- registerSubcommand(commands, onAction) {
71
- if (typeof commands === "function") {
72
- const instance = new commands(commands, onAction);
73
- this.addCommand(instance);
74
- if (onAction && !instance.commands.length) {
75
- instance.action(onAction);
76
- }
77
- return;
78
- }
79
- for (const [key, command] of Object.entries(commands)){
80
- const instance = command instanceof DecohereCommand ? command : new command(key, onAction);
81
- this.addCommand(instance);
82
- if (onAction && !instance.commands.length) {
83
- instance.action(onAction);
84
- }
85
- }
86
- }
87
- async runActions(actions, options) {
88
- const selectedActions = this.getSelectedActions(actions);
89
- const responses = {};
90
- for (const [actionKey, action] of selectedActions){
91
- responses[actionKey] = await action.run(options);
92
- }
93
- return responses;
94
- }
95
- getSelectedActions(actions) {
96
- if (!this.actions.length) {
97
- return [];
98
- }
99
- const actionEntries = Object.entries(actions);
100
- return this.actions.map((ActionClass)=>{
101
- const selectedAction = actionEntries.find(([, action])=>action instanceof ActionClass);
102
- if (!selectedAction) {
103
- throw new CommandError(`${this.name()} command missing action instance for ${ActionClass.name}`);
104
- }
105
- return selectedAction;
106
- });
107
- }
108
- throwOnErrors(responses) {
109
- const failures = Object.entries(responses).filter(([, response])=>{
110
- if (!response) {
111
- return false;
112
- }
113
- return !response.succeeded && !response.skipped;
114
- });
115
- if (!failures.length) {
116
- return;
117
- }
118
- throw new CommandError(`${this.name()} command failed. ${failures.map(([actionName, response])=>`${actionName}: ${response?.message ?? "Unknown error"}`).join("\n")}`);
119
- }
120
- parseCommandName(stringLike) {
121
- const command = typeof stringLike === "string" ? stringLike : stringLike.name?.toLowerCase().replace("command", "") ?? "";
122
- if (command === "") {
123
- throw new CommandError(`Could not parse command name from ${stringLike.toString()}`);
124
- }
125
- return command;
126
- }
127
- }
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get ActionMap () {
13
- return _action.ActionMap;
14
- },
15
- get ActionResponse () {
16
- return _action.ActionResponse;
17
- },
18
- get CommandError () {
19
- return _command.CommandError;
20
- },
21
- get CommandResponse () {
22
- return _command.CommandResponse;
23
- },
24
- get ConfigFileOption () {
25
- return _options.ConfigFileOption;
26
- },
27
- get ConfigurationOption () {
28
- return _options.ConfigurationOption;
29
- },
30
- get DecohereCommand () {
31
- return _command.DecohereCommand;
32
- },
33
- get DryRunOption () {
34
- return _options.DryRunOption;
35
- },
36
- get EnvFileIfExistsOption () {
37
- return _options.EnvFileIfExistsOption;
38
- },
39
- get EnvFileOption () {
40
- return _options.EnvFileOption;
41
- },
42
- get LogLevelOption () {
43
- return _options.LogLevelOption;
44
- },
45
- get ModuleManifest () {
46
- return _moduletype.ModuleManifest;
47
- },
48
- get NoBuildOptions () {
49
- return _options.NoBuildOptions;
50
- },
51
- get NoCleanOptions () {
52
- return _options.NoCleanOptions;
53
- },
54
- get ProjectOption () {
55
- return _options.ProjectOption;
56
- }
57
- });
58
- const _action = require("./action.js");
59
- const _command = require("./command.js");
60
- const _moduletype = require("./module.type.js");
61
- const _options = require("./options.js");
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "ModuleManifest", {
6
- enumerable: true,
7
- get: function() {
8
- return ModuleManifest;
9
- }
10
- });
11
- class ModuleManifest {
12
- /** Sub-command classes this module contributes. */ commands = {};
13
- /** Action classes this module contributes. */ actions = {};
14
- /** Register infrastructure services into the DI container. */ registerServices(_builder) {}
15
- /** Lazily create a workspace instance. Return null if this module does not use a workspace. */ createWorkspace(_options) {
16
- return Promise.resolve(null);
17
- }
18
- }
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: Object.getOwnPropertyDescriptor(all, name).get
9
- });
10
- }
11
- _export(exports, {
12
- get ConfigFileOption () {
13
- return ConfigFileOption;
14
- },
15
- get ConfigurationOption () {
16
- return ConfigurationOption;
17
- },
18
- get DryRunOption () {
19
- return DryRunOption;
20
- },
21
- get EnvFileIfExistsOption () {
22
- return EnvFileIfExistsOption;
23
- },
24
- get EnvFileOption () {
25
- return EnvFileOption;
26
- },
27
- get LogLevelOption () {
28
- return LogLevelOption;
29
- },
30
- get NoBuildOptions () {
31
- return NoBuildOptions;
32
- },
33
- get NoCleanOptions () {
34
- return NoCleanOptions;
35
- },
36
- get ProjectOption () {
37
- return ProjectOption;
38
- }
39
- });
40
- const _commander = require("commander");
41
- function parseOptionalBoolean(input) {
42
- if (typeof input === "boolean") {
43
- return input;
44
- }
45
- const value = input.trim().toLowerCase();
46
- if ([
47
- "true",
48
- "1",
49
- "yes",
50
- "on"
51
- ].includes(value)) {
52
- return true;
53
- }
54
- if ([
55
- "false",
56
- "0",
57
- "no",
58
- "off"
59
- ].includes(value)) {
60
- return false;
61
- }
62
- throw new Error(`Invalid boolean value: "${input}". Use true/false.`);
63
- }
64
- class ConfigurationOption extends _commander.Option {
65
- constructor(defaultValue){
66
- super("--configuration <configuration>", "Configuration name");
67
- this.default(defaultValue);
68
- }
69
- }
70
- class ConfigFileOption extends _commander.Option {
71
- constructor(defaultValue = ".decohere.js"){
72
- super("--config-file <file>", "Path to Decohere config file");
73
- this.default(defaultValue);
74
- }
75
- }
76
- class LogLevelOption extends _commander.Option {
77
- constructor(){
78
- super("--log-level <level>", "Log level (trace, debug, info, warn, error)");
79
- }
80
- }
81
- class EnvFileOption extends _commander.Option {
82
- constructor(){
83
- super("--env-file <file>", "Load environment variables from this file before running");
84
- }
85
- }
86
- class EnvFileIfExistsOption extends _commander.Option {
87
- constructor(){
88
- super("--env-file-if-exists <file>", "Like --env-file, but skip it when the file is missing");
89
- }
90
- }
91
- class NoCleanOptions extends _commander.Option {
92
- constructor(defaultValue){
93
- super("--no-clean", "Will not clean the project directories");
94
- this.default(defaultValue);
95
- }
96
- }
97
- class NoBuildOptions extends _commander.Option {
98
- constructor(defaultValue){
99
- super("--no-build", "Will not run the build step");
100
- this.default(defaultValue);
101
- }
102
- }
103
- class DryRunOption extends _commander.Option {
104
- constructor(description, defaultValue = false){
105
- super("--dry-run [dryRun]", description);
106
- this.default(defaultValue);
107
- this.preset(true);
108
- this.argParser(parseOptionalBoolean);
109
- }
110
- }
111
- class ProjectOption extends _commander.Option {
112
- constructor(){
113
- super("--project <project>", "Project name to target");
114
- }
115
- }