@shell-shock/core 0.17.5 → 0.17.7

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 (74) hide show
  1. package/README.md +1 -1
  2. package/dist/components/command-validation-logic.cjs +214 -152
  3. package/dist/components/command-validation-logic.mjs +213 -152
  4. package/dist/components/command-validation-logic.mjs.map +1 -1
  5. package/dist/components/docs.cjs +113 -9
  6. package/dist/components/docs.mjs +109 -9
  7. package/dist/components/docs.mjs.map +1 -1
  8. package/dist/components/exec-builtin.cjs +36 -1
  9. package/dist/components/exec-builtin.d.cts.map +1 -1
  10. package/dist/components/exec-builtin.d.mts.map +1 -1
  11. package/dist/components/exec-builtin.mjs +35 -1
  12. package/dist/components/exec-builtin.mjs.map +1 -1
  13. package/dist/components/helpers.cjs +51 -2
  14. package/dist/components/helpers.mjs +50 -2
  15. package/dist/components/helpers.mjs.map +1 -1
  16. package/dist/components/index.cjs +17 -1
  17. package/dist/components/index.mjs +9 -9
  18. package/dist/components/options-parser-logic.cjs +411 -174
  19. package/dist/components/options-parser-logic.d.cts.map +1 -1
  20. package/dist/components/options-parser-logic.d.mts.map +1 -1
  21. package/dist/components/options-parser-logic.mjs +405 -174
  22. package/dist/components/options-parser-logic.mjs.map +1 -1
  23. package/dist/components/state-builtin.cjs +61 -5
  24. package/dist/components/state-builtin.mjs +60 -5
  25. package/dist/components/state-builtin.mjs.map +1 -1
  26. package/dist/components/usage.cjs +46 -3
  27. package/dist/components/usage.mjs +45 -3
  28. package/dist/components/usage.mjs.map +1 -1
  29. package/dist/components/utils-builtin.cjs +68 -3
  30. package/dist/components/utils-builtin.mjs +67 -3
  31. package/dist/components/utils-builtin.mjs.map +1 -1
  32. package/dist/helpers/automd.cjs +28 -13
  33. package/dist/helpers/automd.mjs +28 -13
  34. package/dist/helpers/automd.mjs.map +1 -1
  35. package/dist/index.cjs +11 -0
  36. package/dist/index.d.cts +2 -2
  37. package/dist/index.d.mts +2 -2
  38. package/dist/index.mjs +2 -2
  39. package/dist/plugin-utils/compute-bin.cjs +50 -0
  40. package/dist/plugin-utils/compute-bin.d.cts +13 -0
  41. package/dist/plugin-utils/compute-bin.d.cts.map +1 -0
  42. package/dist/plugin-utils/compute-bin.d.mts +13 -0
  43. package/dist/plugin-utils/compute-bin.d.mts.map +1 -0
  44. package/dist/plugin-utils/compute-bin.mjs +50 -0
  45. package/dist/plugin-utils/compute-bin.mjs.map +1 -0
  46. package/dist/plugin-utils/get-command-tree.cjs +50 -0
  47. package/dist/plugin-utils/get-command-tree.d.cts +15 -1
  48. package/dist/plugin-utils/get-command-tree.d.cts.map +1 -1
  49. package/dist/plugin-utils/get-command-tree.d.mts +15 -1
  50. package/dist/plugin-utils/get-command-tree.d.mts.map +1 -1
  51. package/dist/plugin-utils/get-command-tree.mjs +49 -1
  52. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  53. package/dist/plugin-utils/index.cjs +4 -0
  54. package/dist/plugin-utils/index.d.cts +3 -2
  55. package/dist/plugin-utils/index.d.mts +3 -2
  56. package/dist/plugin-utils/index.mjs +3 -2
  57. package/dist/plugin.cjs +170 -52
  58. package/dist/plugin.mjs +170 -52
  59. package/dist/plugin.mjs.map +1 -1
  60. package/dist/resolver/deepkit.cjs +1 -1
  61. package/dist/resolver/deepkit.mjs +1 -1
  62. package/dist/resolver/deepkit.mjs.map +1 -1
  63. package/dist/types/command.cjs +120 -10
  64. package/dist/types/command.d.cts +95 -8
  65. package/dist/types/command.d.cts.map +1 -1
  66. package/dist/types/command.d.mts +95 -8
  67. package/dist/types/command.d.mts.map +1 -1
  68. package/dist/types/command.mjs +109 -10
  69. package/dist/types/command.mjs.map +1 -1
  70. package/dist/types/index.cjs +12 -1
  71. package/dist/types/index.d.cts +2 -2
  72. package/dist/types/index.d.mts +2 -2
  73. package/dist/types/index.mjs +2 -2
  74. package/package.json +10 -10
package/dist/plugin.cjs CHANGED
@@ -40,17 +40,21 @@ let defu = require("defu");
40
40
  let powerlines_utils = require("powerlines/utils");
41
41
 
42
42
  //#region src/plugin.tsx
43
+ function __assignType(fn, args) {
44
+ fn.__type = args;
45
+ return fn;
46
+ }
43
47
  const MAX_DEPTH = 50;
44
48
  /**
45
49
  * The core Powerlines plugin to build Shell Shock projects.
46
50
  */
47
- const plugin = (options = {}) => {
51
+ const plugin = __assignType((options = {}) => {
48
52
  return [
49
- (0, _powerlines_plugin_tsdown.default)(),
50
- (0, _powerlines_plugin_automd.default)(),
53
+ (_powerlines_plugin_tsdown.default.Ω = [["Context", "\"w!"]], (0, _powerlines_plugin_tsdown.default)()),
54
+ (_powerlines_plugin_automd.default.Ω = [["Context", "\"w!"]], (0, _powerlines_plugin_automd.default)()),
51
55
  {
52
56
  name: "shell-shock:config",
53
- async config() {
57
+ config: __assignType(async function config() {
54
58
  this.debug("Resolving the Shell Shock configuration.");
55
59
  await require_update_package_json.updatePackageJsonBinary(this);
56
60
  return (0, defu.defu)({ output: { path: (0, _stryke_path_join_paths.joinPaths)(this.config.root, "dist") } }, options, {
@@ -76,7 +80,7 @@ const plugin = (options = {}) => {
76
80
  unbundle: false
77
81
  }
78
82
  });
79
- },
83
+ }, ["config", "P\"/!"]),
80
84
  configResolved: {
81
85
  order: "pre",
82
86
  async handler() {
@@ -105,19 +109,23 @@ const plugin = (options = {}) => {
105
109
  alias: [],
106
110
  isVirtual: false
107
111
  }));
108
- this.options = this.options.map((option) => ({
112
+ this.options = this.options.map(__assignType((option) => ({
109
113
  ...option,
110
114
  name: (0, _stryke_string_format_camel_case.camelCase)(option.name),
111
115
  alias: option.alias ?? [],
112
116
  optional: option.optional ?? false
113
- }));
117
+ }), [
118
+ "option",
119
+ "",
120
+ "P\"2!\"/\""
121
+ ]));
114
122
  }
115
123
  }
116
124
  },
117
- ...(0, _powerlines_plugin_nodejs.default)((0, defu.defu)(options ?? {}, { env: {
125
+ ...(_powerlines_plugin_nodejs.default.Ω = [["Context", "\"w!"]], (0, _powerlines_plugin_nodejs.default)((0, defu.defu)(options ?? {}, { env: {
118
126
  types: "@shell-shock/core/types/env#ShellShockEnv",
119
127
  validate: false
120
- } })),
128
+ } }))),
121
129
  {
122
130
  name: "shell-shock:inputs",
123
131
  async configResolved() {
@@ -127,17 +135,34 @@ const plugin = (options = {}) => {
127
135
  this.debug(`Resolved commands root path: ${this.commandsPath}`);
128
136
  const inputs = await (0, powerlines_utils.resolveInputs)(this, this.config.input);
129
137
  this.debug(`Found ${inputs.length} entry points specified in the configuration options.`);
130
- this.inputs = inputs.reduce((ret, entry) => {
138
+ this.inputs = inputs.reduce(__assignType((ret, entry) => {
131
139
  if (entry.file !== this.commandsPath && !(0, _stryke_path_is_parent_path.isParentPath)(entry.file, this.commandsPath)) throw new Error(`Command entry point "${entry.file}" is not located within the commands root "${this.commandsPath}". Please ensure that all command entry points are located within the current project.`);
132
140
  const id = require_paths.resolveCommandId(this, entry.file);
133
- if (!ret.some((existing) => existing.id === id)) {
141
+ if (!ret.some(__assignType((existing) => existing.id === id, [
142
+ "existing",
143
+ "",
144
+ "P\"2!\"/\""
145
+ ]))) {
134
146
  const name = require_paths.resolveCommandName(entry.file);
135
147
  let segments = require_paths.resolveCommandPath(this, entry.file).split("/").filter(Boolean);
136
- segments = segments.map((segment, index) => {
137
- const found = segments.findIndex((existing) => existing === segment);
138
- if (found !== -1 && found !== index) segment += `_${segments.filter((segment) => require_context_helpers.isDynamicPathSegment(segment) && require_context_helpers.getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === segment).length}`;
148
+ segments = segments.map(__assignType((segment, index) => {
149
+ const found = segments.findIndex(__assignType((existing) => existing === segment, [
150
+ "existing",
151
+ "",
152
+ "P\"2!\"/\""
153
+ ]));
154
+ if (found !== -1 && found !== index) segment += `_${segments.filter(__assignType((segment) => require_context_helpers.isDynamicPathSegment(segment) && require_context_helpers.getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === segment, [
155
+ "segment",
156
+ "",
157
+ "P\"2!\"/\""
158
+ ])).length}`;
139
159
  return segment;
140
- });
160
+ }, [
161
+ "segment",
162
+ "index",
163
+ "",
164
+ "P\"2!\"2\"\"/#"
165
+ ]));
141
166
  ret.push({
142
167
  id,
143
168
  path: segments.join("/"),
@@ -159,17 +184,26 @@ const plugin = (options = {}) => {
159
184
  });
160
185
  }
161
186
  return ret;
162
- }, this.inputs);
163
- this.debug(`Shell Shock will process ${this.inputs.length} command entry files: \n${this.inputs.map((command) => ` - ${command.id}: ${(0, _stryke_path_replace.replacePath)(command.entry.file, this.commandsPath)}`).join("\n")}`);
187
+ }, [
188
+ "ret",
189
+ "entry",
190
+ "",
191
+ "P\"2!\"2\"\"/#"
192
+ ]), this.inputs);
193
+ this.debug(`Shell Shock will process ${this.inputs.length} command entry files: \n${this.inputs.map(__assignType((command) => ` - ${command.id}: ${(0, _stryke_path_replace.replacePath)(command.entry.file, this.commandsPath)}`, [
194
+ "command",
195
+ "",
196
+ "P\"2!\"/\""
197
+ ])).join("\n")}`);
164
198
  },
165
- async prepare() {
199
+ prepare: __assignType(async function prepare() {
166
200
  this.debug("Rendering base built-in modules for the Shell Shock application.");
167
201
  return (0, _powerlines_plugin_alloy_render.render)(this, [
168
202
  (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_state_builtin.StateBuiltin, {}),
169
203
  (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_utils_builtin.UtilsBuiltin, {}),
170
204
  (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_exec_builtin.ExecBuiltin, {})
171
205
  ]);
172
- }
206
+ }, ["prepare", "P\"/!"])
173
207
  },
174
208
  {
175
209
  name: "shell-shock:virtual-inputs",
@@ -179,22 +213,43 @@ const plugin = (options = {}) => {
179
213
  if (this.inputs.length === 0) this.warn("No commands were found in the project. Please ensure at least one command exists.");
180
214
  else {
181
215
  this.debug("Finding and adding virtual command inputs for each command previously found.");
182
- this.inputs = this.inputs.reduce((ret, command) => {
216
+ this.inputs = this.inputs.reduce(__assignType((ret, command) => {
183
217
  let depth = 0;
184
218
  let parentPath = (0, _stryke_path_resolve_parent_path.resolveParentPath)((0, _stryke_path_file_path_fns.findFilePath)(command.entry.file));
185
219
  if ((0, _stryke_path_is_parent_path.isParentPath)(parentPath, this.commandsPath)) while (parentPath !== this.commandsPath) {
186
220
  if (depth++ > MAX_DEPTH) throw new Error(`Unable to process virtual commands for ${command.name} \n\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`);
187
- if (!ret.some((existing) => (0, _stryke_path_file_path_fns.findFilePath)(existing.entry.file) === parentPath)) {
221
+ if (!ret.some(__assignType((existing) => (0, _stryke_path_file_path_fns.findFilePath)(existing.entry.file) === parentPath, [
222
+ "existing",
223
+ "",
224
+ "P\"2!\"/\""
225
+ ]))) {
188
226
  const file = (0, _stryke_path_join_paths.joinPaths)(parentPath, "command.ts");
189
227
  const id = require_paths.resolveCommandId(this, file);
190
- if (!ret.some((existing) => existing.id === id)) {
228
+ if (!ret.some(__assignType((existing) => existing.id === id, [
229
+ "existing",
230
+ "",
231
+ "P\"2!\"/\""
232
+ ]))) {
191
233
  const name = require_paths.resolveCommandName(file);
192
234
  let segments = require_paths.resolveCommandPath(this, file).split("/").filter(Boolean);
193
- segments = segments.map((segment, index) => {
194
- const found = segments.findIndex((existing) => existing === segment);
195
- if (found !== -1 && found !== index) segment += `_${segments.filter((segment) => require_context_helpers.isDynamicPathSegment(segment) && require_context_helpers.getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === segment).length}`;
235
+ segments = segments.map(__assignType((segment, index) => {
236
+ const found = segments.findIndex(__assignType((existing) => existing === segment, [
237
+ "existing",
238
+ "",
239
+ "P\"2!\"/\""
240
+ ]));
241
+ if (found !== -1 && found !== index) segment += `_${segments.filter(__assignType((segment) => require_context_helpers.isDynamicPathSegment(segment) && require_context_helpers.getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === segment, [
242
+ "segment",
243
+ "",
244
+ "P\"2!\"/\""
245
+ ])).length}`;
196
246
  return segment;
197
- });
247
+ }, [
248
+ "segment",
249
+ "index",
250
+ "",
251
+ "P\"2!\"2\"\"/#"
252
+ ]));
198
253
  ret.push({
199
254
  id,
200
255
  path: segments.join("/"),
@@ -211,8 +266,22 @@ const plugin = (options = {}) => {
211
266
  parentPath = (0, _stryke_path_resolve_parent_path.resolveParentPath)(parentPath);
212
267
  }
213
268
  return ret;
214
- }, this.inputs).sort((a, b) => a.segments.length - b.segments.length);
215
- this.debug(`Final command input list: \n${this.inputs.map((command) => ` - ${command.id}${command.isVirtual ? " (virtual)" : ""}: ${command.source === "file" ? (0, _stryke_path_replace.replacePath)(command.entry.file, this.commandsPath) : `added by ${command.source}`}`).join("\n")}`);
269
+ }, [
270
+ "ret",
271
+ "command",
272
+ "",
273
+ "P\"2!\"2\"\"/#"
274
+ ]), this.inputs).sort(__assignType((a, b) => a.segments.length - b.segments.length, [
275
+ "a",
276
+ "b",
277
+ "",
278
+ "P\"2!\"2\"\"/#"
279
+ ]));
280
+ this.debug(`Final command input list: \n${this.inputs.map(__assignType((command) => ` - ${command.id}${command.isVirtual ? " (virtual)" : ""}: ${command.source === "file" ? (0, _stryke_path_replace.replacePath)(command.entry.file, this.commandsPath) : `added by ${command.source}`}`, [
281
+ "command",
282
+ "",
283
+ "P\"2!\"/\""
284
+ ])).join("\n")}`);
216
285
  }
217
286
  }
218
287
  }
@@ -228,30 +297,54 @@ const plugin = (options = {}) => {
228
297
  this.debug(`Skipping command resolution as the meta checksum has not changed.`);
229
298
  await require_persistence.readCommandsPersistence(this);
230
299
  } else {
231
- for (const input of this.inputs.filter((input) => input.segments.filter((segment) => !require_context_helpers.isDynamicPathSegment(segment) && !require_context_helpers.isPathSegmentGroup(segment)).length === 1)) this.commands[input.name] = await require_resolve.resolve({
300
+ for (const input of this.inputs.filter(__assignType((input) => input.segments.filter(__assignType((segment) => !require_context_helpers.isDynamicPathSegment(segment) && !require_context_helpers.isPathSegmentGroup(segment), [
301
+ "segment",
302
+ "",
303
+ "P\"2!\"/\""
304
+ ])).length === 1, [
305
+ "input",
306
+ "",
307
+ "P\"2!\"/\""
308
+ ]))) this.commands[input.name] = await require_resolve.resolve({
232
309
  context: this,
233
310
  command: input
234
311
  });
235
312
  this.debug("Post-processing commands to ensure proper reflection.");
236
- await require_traverse_command_tree.traverseCommands(this, (command) => {
237
- command.options = Object.fromEntries(Object.entries(command.options).map(([name, option]) => [(0, _stryke_string_format_camel_case.camelCase)(name), {
313
+ await require_traverse_command_tree.traverseCommands(this, __assignType((command) => {
314
+ command.options = Object.fromEntries(Object.entries(command.options).map(__assignType(([name, option]) => [(0, _stryke_string_format_camel_case.camelCase)(name), {
238
315
  ...option,
239
316
  name: (0, _stryke_string_format_camel_case.camelCase)(name),
240
317
  alias: option.alias ?? [],
241
318
  optional: option.optional ?? false
242
- }]));
243
- });
319
+ }], [
320
+ "param0",
321
+ "",
322
+ "P\"2!\"/\""
323
+ ])));
324
+ }, [
325
+ "command",
326
+ "",
327
+ "P\"2!\"/\""
328
+ ]));
244
329
  await require_persistence.writeCommandsPersistence(this);
245
330
  }
246
331
  this.debug("Validating the CLI applications command tree.");
247
332
  let isValid = true;
248
- await require_traverse_command_tree.traverseCommands(this, (command) => {
333
+ await require_traverse_command_tree.traverseCommands(this, __assignType((command) => {
249
334
  const failures = require_validations.validateCommand(command);
250
335
  if (failures.length > 0) {
251
- this.error(`Found ${failures.length} issue${failures.length > 1 ? "s" : ""} with the ${command.title} command: \n${failures.map((failure) => ` - ${failure.code}: ${failure.details}`).join("\n")}\n`);
336
+ this.error(`Found ${failures.length} issue${failures.length > 1 ? "s" : ""} with the ${command.title} command: \n${failures.map(__assignType((failure) => ` - ${failure.code}: ${failure.details}`, [
337
+ "failure",
338
+ "",
339
+ "P\"2!\"/\""
340
+ ])).join("\n")}\n`);
252
341
  isValid = false;
253
342
  }
254
- });
343
+ }, [
344
+ "command",
345
+ "",
346
+ "P\"2!\"/\""
347
+ ]));
255
348
  if (!isValid) throw new Error(`One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`);
256
349
  this.info(`\nCreating an application with the following command tree: \n${require_utilities.formatCommandTree(this)}\n`);
257
350
  }
@@ -261,8 +354,8 @@ const plugin = (options = {}) => {
261
354
  name: "shell-shock:chmod+x",
262
355
  configResolved() {
263
356
  this.config.tsdown.hooks ??= {};
264
- this.config.tsdown.hooks["build:done"] = async (_) => {
265
- await Promise.all(Object.values(this.config.bin).map(async (bin) => {
357
+ this.config.tsdown.hooks["build:done"] = __assignType(async (_) => {
358
+ await Promise.all(Object.values(this.config.bin).map(__assignType(async (bin) => {
266
359
  const path = (0, _stryke_path_append.appendPath)(bin, (0, _stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.root));
267
360
  if (this.fs.existsSync(path)) {
268
361
  this.debug(`Adding hashbang to binary executable output file: ${path}`);
@@ -271,40 +364,65 @@ const plugin = (options = {}) => {
271
364
  this.debug(`Adding executable permissions (chmod+x) to binary executable output file: ${path}`);
272
365
  await (0, _stryke_fs_chmod_x.chmodX)(path);
273
366
  } else this.warn(`Expected binary output file not found at path: ${path}. Skipping adding hashbang and executable permissions (chmod+x).`);
274
- }));
275
- };
367
+ }, [
368
+ "bin",
369
+ "",
370
+ "P\"2!\"/\""
371
+ ])));
372
+ }, [
373
+ "chunks",
374
+ "_",
375
+ "",
376
+ "PP!P!F4!MK2\"\"/#"
377
+ ]);
276
378
  }
277
379
  },
278
380
  {
279
381
  name: "shell-shock:docs",
280
- configResolved() {
382
+ configResolved: __assignType(function configResolved() {
281
383
  this.config.automd ??= {};
282
384
  this.config.automd.generators = {
283
385
  ...this.config.automd.generators ?? {},
284
386
  commands: require_automd.commands(this)
285
387
  };
286
- },
388
+ }, ["configResolved", "P\"/!"]),
287
389
  async docs() {
288
390
  this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
289
- const commands = this.inputs.map((input) => require_get_command_tree.getCommandTree(this, input.segments)).filter(Boolean);
391
+ const commands = this.inputs.map(__assignType((input) => require_get_command_tree.getCommandTree(this, input.segments), [
392
+ "input",
393
+ "",
394
+ "P\"2!\"/\""
395
+ ])).filter(Boolean);
290
396
  return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core_components.For, {
291
397
  get each() {
292
398
  return Object.values(commands);
293
399
  },
294
400
  doubleHardline: true,
295
- children: (child) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core_components.Show, {
296
- get when() {
297
- return !child.isVirtual;
298
- },
299
- get children() {
300
- return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_docs.CommandDocsFile, { command: child });
301
- }
302
- })
401
+ get children() {
402
+ return __assignType((child) => (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core_components.Show, {
403
+ get when() {
404
+ return !child.isVirtual;
405
+ },
406
+ get children() {
407
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_docs.CommandDocsFile, { command: child });
408
+ }
409
+ }), [
410
+ "child",
411
+ "",
412
+ "P\"2!\"/\""
413
+ ]);
414
+ }
303
415
  }));
304
416
  }
305
417
  }
306
418
  ];
307
- };
419
+ }, [
420
+ "Options",
421
+ "options",
422
+ () => ({}),
423
+ "",
424
+ "P\"w!2\">#!F/$"
425
+ ]);
308
426
 
309
427
  //#endregion
310
428
  exports.default = plugin;