@shell-shock/core 0.2.1 → 0.4.0

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 (158) hide show
  1. package/README.md +1 -1
  2. package/dist/api.cjs +15 -3
  3. package/dist/api.cjs.map +1 -0
  4. package/dist/api.d.cts +9 -1
  5. package/dist/api.d.cts.map +1 -0
  6. package/dist/api.d.mts +9 -1
  7. package/dist/api.d.mts.map +1 -0
  8. package/dist/api.mjs +14 -3
  9. package/dist/api.mjs.map +1 -0
  10. package/dist/components/docs.cjs +175 -0
  11. package/dist/components/docs.cjs.map +1 -0
  12. package/dist/components/docs.d.cts +81 -0
  13. package/dist/components/docs.d.cts.map +1 -0
  14. package/dist/components/docs.d.mts +81 -0
  15. package/dist/components/docs.d.mts.map +1 -0
  16. package/dist/components/docs.mjs +171 -0
  17. package/dist/components/docs.mjs.map +1 -0
  18. package/dist/components/index.cjs +5 -6
  19. package/dist/components/index.d.cts +2 -2
  20. package/dist/components/index.d.mts +2 -2
  21. package/dist/components/index.mjs +2 -2
  22. package/dist/config.cjs +2 -1
  23. package/dist/config.cjs.map +1 -0
  24. package/dist/config.d.cts +2 -1
  25. package/dist/config.d.cts.map +1 -0
  26. package/dist/config.d.mts +2 -1
  27. package/dist/config.d.mts.map +1 -0
  28. package/dist/config.mjs +2 -1
  29. package/dist/config.mjs.map +1 -0
  30. package/dist/contexts/command.cjs +21 -0
  31. package/dist/contexts/command.cjs.map +1 -0
  32. package/dist/contexts/command.d.cts +18 -0
  33. package/dist/contexts/command.d.cts.map +1 -0
  34. package/dist/contexts/command.d.mts +18 -0
  35. package/dist/contexts/command.d.mts.map +1 -0
  36. package/dist/contexts/command.mjs +19 -0
  37. package/dist/contexts/command.mjs.map +1 -0
  38. package/dist/contexts/index.cjs +4 -0
  39. package/dist/contexts/index.d.cts +2 -0
  40. package/dist/contexts/index.d.mts +2 -0
  41. package/dist/contexts/index.mjs +3 -0
  42. package/dist/helpers/automd.cjs +59 -0
  43. package/dist/helpers/automd.cjs.map +1 -0
  44. package/dist/helpers/automd.mjs +58 -0
  45. package/dist/helpers/automd.mjs.map +1 -0
  46. package/dist/helpers/docs-helpers.cjs +17 -0
  47. package/dist/helpers/docs-helpers.cjs.map +1 -0
  48. package/dist/helpers/docs-helpers.mjs +16 -0
  49. package/dist/helpers/docs-helpers.mjs.map +1 -0
  50. package/dist/helpers/persistence.cjs +2 -1
  51. package/dist/helpers/persistence.cjs.map +1 -0
  52. package/dist/helpers/persistence.mjs +2 -1
  53. package/dist/helpers/persistence.mjs.map +1 -0
  54. package/dist/helpers/resolve-command.cjs +118 -33
  55. package/dist/helpers/resolve-command.cjs.map +1 -0
  56. package/dist/helpers/resolve-command.mjs +116 -32
  57. package/dist/helpers/resolve-command.mjs.map +1 -0
  58. package/dist/helpers/update-package-json.cjs +18 -10
  59. package/dist/helpers/update-package-json.cjs.map +1 -0
  60. package/dist/helpers/update-package-json.mjs +17 -10
  61. package/dist/helpers/update-package-json.mjs.map +1 -0
  62. package/dist/helpers/utilities.cjs +30 -30
  63. package/dist/helpers/utilities.cjs.map +1 -0
  64. package/dist/helpers/utilities.mjs +29 -28
  65. package/dist/helpers/utilities.mjs.map +1 -0
  66. package/dist/helpers/validations.cjs +97 -0
  67. package/dist/helpers/validations.cjs.map +1 -0
  68. package/dist/helpers/validations.mjs +97 -0
  69. package/dist/helpers/validations.mjs.map +1 -0
  70. package/dist/index.cjs +5 -13
  71. package/dist/index.cjs.map +1 -0
  72. package/dist/index.d.cts +6 -17
  73. package/dist/index.d.mts +6 -17
  74. package/dist/index.mjs +4 -13
  75. package/dist/index.mjs.map +1 -0
  76. package/dist/plugin-utils/context-helpers.cjs +86 -0
  77. package/dist/plugin-utils/context-helpers.cjs.map +1 -0
  78. package/dist/plugin-utils/context-helpers.d.cts +58 -0
  79. package/dist/plugin-utils/context-helpers.d.cts.map +1 -0
  80. package/dist/plugin-utils/context-helpers.d.mts +58 -0
  81. package/dist/plugin-utils/context-helpers.d.mts.map +1 -0
  82. package/dist/plugin-utils/context-helpers.mjs +79 -0
  83. package/dist/plugin-utils/context-helpers.mjs.map +1 -0
  84. package/dist/plugin-utils/get-command-tree.cjs +4 -2
  85. package/dist/plugin-utils/get-command-tree.cjs.map +1 -0
  86. package/dist/plugin-utils/get-command-tree.d.cts +2 -1
  87. package/dist/plugin-utils/get-command-tree.d.cts.map +1 -0
  88. package/dist/plugin-utils/get-command-tree.d.mts +2 -1
  89. package/dist/plugin-utils/get-command-tree.d.mts.map +1 -0
  90. package/dist/plugin-utils/get-command-tree.mjs +5 -2
  91. package/dist/plugin-utils/get-command-tree.mjs.map +1 -0
  92. package/dist/plugin-utils/index.cjs +14 -1
  93. package/dist/plugin-utils/index.d.cts +4 -1
  94. package/dist/plugin-utils/index.d.mts +4 -1
  95. package/dist/plugin-utils/index.mjs +4 -1
  96. package/dist/plugin-utils/reflect.cjs +25 -0
  97. package/dist/plugin-utils/reflect.cjs.map +1 -0
  98. package/dist/plugin-utils/reflect.d.cts +14 -0
  99. package/dist/plugin-utils/reflect.d.cts.map +1 -0
  100. package/dist/plugin-utils/reflect.d.mts +14 -0
  101. package/dist/plugin-utils/reflect.d.mts.map +1 -0
  102. package/dist/plugin-utils/reflect.mjs +24 -0
  103. package/dist/plugin-utils/reflect.mjs.map +1 -0
  104. package/dist/plugin-utils/traverse-command-tree.cjs +33 -0
  105. package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -0
  106. package/dist/plugin-utils/traverse-command-tree.d.cts +23 -0
  107. package/dist/plugin-utils/traverse-command-tree.d.cts.map +1 -0
  108. package/dist/plugin-utils/traverse-command-tree.d.mts +23 -0
  109. package/dist/plugin-utils/traverse-command-tree.d.mts.map +1 -0
  110. package/dist/plugin-utils/traverse-command-tree.mjs +31 -0
  111. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -0
  112. package/dist/plugin.cjs +284 -0
  113. package/dist/plugin.cjs.map +1 -0
  114. package/dist/plugin.d.cts +13 -0
  115. package/dist/plugin.d.cts.map +1 -0
  116. package/dist/plugin.d.mts +13 -0
  117. package/dist/plugin.d.mts.map +1 -0
  118. package/dist/plugin.mjs +276 -0
  119. package/dist/plugin.mjs.map +1 -0
  120. package/dist/types/command.d.cts +14 -4
  121. package/dist/types/command.d.cts.map +1 -0
  122. package/dist/types/command.d.mts +14 -4
  123. package/dist/types/command.d.mts.map +1 -0
  124. package/dist/types/config.d.cts +74 -10
  125. package/dist/types/config.d.cts.map +1 -0
  126. package/dist/types/config.d.mts +74 -10
  127. package/dist/types/config.d.mts.map +1 -0
  128. package/dist/types/context.d.cts +7 -4
  129. package/dist/types/context.d.cts.map +1 -0
  130. package/dist/types/context.d.mts +7 -4
  131. package/dist/types/context.d.mts.map +1 -0
  132. package/dist/types/index.d.cts +4 -4
  133. package/dist/types/index.d.mts +4 -4
  134. package/dist/types/internal.cjs +0 -0
  135. package/dist/types/internal.d.cts +24 -0
  136. package/dist/types/internal.d.cts.map +1 -0
  137. package/dist/types/internal.d.mts +24 -0
  138. package/dist/types/internal.d.mts.map +1 -0
  139. package/dist/types/internal.mjs +1 -0
  140. package/dist/types/options.d.cts +2 -1
  141. package/dist/types/options.d.cts.map +1 -0
  142. package/dist/types/options.d.mts +2 -1
  143. package/dist/types/options.d.mts.map +1 -0
  144. package/dist/types/runtime.cjs +0 -0
  145. package/dist/types/runtime.d.cts +24 -0
  146. package/dist/types/runtime.d.cts.map +1 -0
  147. package/dist/types/runtime.d.mts +24 -0
  148. package/dist/types/runtime.d.mts.map +1 -0
  149. package/dist/types/runtime.mjs +1 -0
  150. package/package.json +223 -91
  151. package/dist/components/utils-builtin.cjs +0 -453
  152. package/dist/components/utils-builtin.d.cts +0 -27
  153. package/dist/components/utils-builtin.d.mts +0 -27
  154. package/dist/components/utils-builtin.mjs +0 -447
  155. package/dist/powerlines.cjs +0 -172
  156. package/dist/powerlines.d.cts +0 -12
  157. package/dist/powerlines.d.mts +0 -12
  158. package/dist/powerlines.mjs +0 -168
@@ -1,447 +0,0 @@
1
- import defu$1 from "defu";
2
- import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
3
- import { Show, code, splitProps } from "@alloy-js/core";
4
- import { FunctionDeclaration, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
5
- import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
6
- import { TSDoc, TSDocLink, TSDocParam, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
7
-
8
- //#region src/components/utils-builtin.tsx
9
- /**
10
- * Generates utilities for detecting terminal color support.
11
- */
12
- function EnvSupportUtilities() {
13
- return [
14
- createComponent(VarDeclaration, {
15
- "export": true,
16
- "const": true,
17
- name: "isTTY",
18
- doc: "Detect if stdout.TTY is available",
19
- initializer: code`Boolean(process.stdout && process.stdout.isTTY);`
20
- }),
21
- createIntrinsic("hbr", {}),
22
- createIntrinsic("hbr", {}),
23
- createComponent(VarDeclaration, {
24
- "export": true,
25
- "const": true,
26
- name: "isMinimal",
27
- doc: "Detect if the current environment is minimal (CI, non-TTY, etc.)",
28
- initializer: code` env.MINIMAL || isCI || isTest || !isTTY; `
29
- }),
30
- createIntrinsic("hbr", {}),
31
- createIntrinsic("hbr", {}),
32
- createComponent(VarDeclaration, {
33
- "export": true,
34
- "const": true,
35
- name: "isInteractive",
36
- doc: "Detect if the current environment is interactive",
37
- initializer: code` !isMinimal && process.stdin?.isTTY && env.TERM !== "dumb"; `
38
- })
39
- ];
40
- }
41
- /**
42
- * Generates utilities for detecting terminal color support.
43
- */
44
- function ColorSupportUtilities() {
45
- return [
46
- createComponent(InterfaceDeclaration, {
47
- "export": true,
48
- name: "GetColorSupportLevelOptions",
49
- doc: "Options for the getColorSupportLevel function",
50
- get children() {
51
- return createComponent(InterfaceMember, {
52
- name: "ignoreFlags",
53
- type: "boolean",
54
- doc: "Indicates if the function should skip checking command-line flags for color support"
55
- });
56
- }
57
- }),
58
- createIntrinsic("hbr", {}),
59
- createIntrinsic("hbr", {}),
60
- createComponent(TSDoc, {
61
- heading: "Checks if a specific flag is present in the command line arguments.",
62
- get children() {
63
- return [
64
- createComponent(TSDocLink, { children: "https://github.com/sindresorhus/has-flag/blob/main/index.js" }),
65
- createComponent(TSDocParam, {
66
- name: "flag",
67
- children: "The flag to check for, e.g., \"color\", \"no-color\"."
68
- }),
69
- createComponent(TSDocParam, {
70
- name: "argv",
71
- children: "The command line arguments to check against. Defaults to global Deno args or process args."
72
- }),
73
- createComponent(TSDocReturns, { children: "True if the flag is present, false otherwise." })
74
- ];
75
- }
76
- }),
77
- createComponent(FunctionDeclaration, {
78
- "export": true,
79
- name: "getColorSupportLevel",
80
- parameters: [{
81
- name: "stream",
82
- type: "NodeJS.WriteStream & { fd: 1 | 2; }"
83
- }, {
84
- name: "options",
85
- type: "GetColorSupportLevelOptions",
86
- default: "{}"
87
- }],
88
- children: code`const { ignoreFlags = false } = options;
89
-
90
- let forceColor: number | undefined;
91
- if (env.FORCE_COLOR !== undefined) {
92
- forceColor = !env.FORCE_COLOR
93
- ? 0
94
- : typeof env.FORCE_COLOR === "boolean"
95
- ? 1
96
- : typeof env.FORCE_COLOR === "number" &&
97
- [0, 1, 2, 3].includes(Math.min(env.FORCE_COLOR as number, 3))
98
- ? Math.min(env.FORCE_COLOR as number, 3)
99
- : undefined;
100
- }
101
-
102
- if (ignoreFlags !== true && forceColor === undefined) {
103
- forceColor = hasFlag("no-color") ||
104
- hasFlag("no-colors") ||
105
- hasFlag("color=false") ||
106
- hasFlag("color=never")
107
- ? 0
108
- : hasFlag("color") ||
109
- hasFlag("colors") ||
110
- hasFlag("color=true") ||
111
- hasFlag("color=always")
112
- ? 1
113
- : 0;
114
- }
115
-
116
- if (forceColor === 0) {
117
- return 0;
118
- }
119
-
120
- if (ignoreFlags !== true) {
121
- if (hasFlag("color=16m") ||
122
- hasFlag("color=full") ||
123
- hasFlag("color=truecolor")) {
124
- return 3;
125
- }
126
-
127
- if (hasFlag("color=256")) {
128
- return 2;
129
- }
130
- }
131
-
132
- const level = Boolean(env.TF_BUILD) || Boolean(env.AGENT_NAME)
133
- ? 1
134
- : stream &&
135
- !(isTTY || (stream && stream.isTTY)) &&
136
- forceColor === undefined
137
- ? 0
138
- : env.TERM === "dumb"
139
- ? forceColor || 0
140
- : isWindows
141
- ? Number(os.release().split(".")[0]) >= 10 &&
142
- Number(os.release().split(".")[2]) >= 10_586
143
- ? Number(os.release().split(".")[2]) >= 14_931
144
- ? 3
145
- : 2
146
- : 1
147
- : isCI
148
- ? Boolean(env.GITHUB_ACTIONS) ||
149
- Boolean(env.GITEA_ACTIONS) ||
150
- Boolean(env.CIRCLECI)
151
- ? 3
152
- : Boolean(env.TRAVIS) ||
153
- Boolean(env.APPVEYOR) ||
154
- Boolean(env.GITLAB_CI) ||
155
- Boolean(env.BUILDKITE) ||
156
- Boolean(env.DRONE) ||
157
- env.CI_NAME === "codeship"
158
- ? 1
159
- : forceColor || 0
160
- : Boolean(env.TEAMCITY_VERSION)
161
- ? /^(?:9\.0*[1-9]\d*\.|\d{2,}\.)/.test(String(env.TEAMCITY_VERSION) || "")
162
- ? 1
163
- : 0
164
- : String(env.COLORTERM) === "truecolor" ||
165
- env.TERM === "xterm-kitty"
166
- ? 3
167
- : Boolean(env.TERM_PROGRAM)
168
- ? env.TERM_PROGRAM === "iTerm.app"
169
- ? Number.parseInt(
170
- (env.TERM_PROGRAM_VERSION || "").split(".")[0] as string,
171
- 10
172
- ) >= 3
173
- ? 3
174
- : 2
175
- : env.TERM_PROGRAM === "Apple_Terminal"
176
- ? 2
177
- : 0
178
- : /-256(?:color)?$/i.test(env.TERM || "")
179
- ? 2
180
- : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(
181
- env.TERM || ""
182
- )
183
- ? 1
184
- : Boolean(env.COLORTERM);
185
-
186
- return typeof level === "boolean" || level === 0
187
- ? false
188
- : {
189
- level,
190
- hasBasic: true,
191
- has256: level >= 2,
192
- has16m: level >= 3,
193
- };
194
-
195
- `
196
- }),
197
- createIntrinsic("hbr", {}),
198
- createIntrinsic("hbr", {}),
199
- createComponent(VarDeclaration, {
200
- "export": true,
201
- "const": true,
202
- name: "colorSupportLevels",
203
- doc: "Detect the terminal color support level in the current environment",
204
- initializer: code` {
205
- stdout: getColorSupportLevel(process.stdout),
206
- stderr: getColorSupportLevel(process.stderr),
207
- }; `
208
- }),
209
- createIntrinsic("hbr", {}),
210
- createIntrinsic("hbr", {}),
211
- createComponent(VarDeclaration, {
212
- "export": true,
213
- "const": true,
214
- name: "isColorSupported",
215
- doc: "Detect if terminal color is supported in the current environment",
216
- initializer: code` Boolean(colorSupportLevels.stdout); `
217
- }),
218
- createIntrinsic("hbr", {}),
219
- createIntrinsic("hbr", {}),
220
- createComponent(VarDeclaration, {
221
- "export": true,
222
- "const": true,
223
- name: "isUnicodeSupported",
224
- doc: "Detect if Unicode characters are supported in the current environment",
225
- initializer: code` !isWindows
226
- ? env.TERM !== "linux"
227
- : Boolean(env.WT_SESSION) ||
228
- Boolean(env.TERMINUS_SUBLIME) ||
229
- env.ConEmuTask === "{cmd::Cmder}" ||
230
- env.TERM_PROGRAM === "Terminus-Sublime" ||
231
- env.TERM_PROGRAM === "vscode" ||
232
- env.TERM === "xterm-256color" ||
233
- env.TERM === "alacritty" ||
234
- env.TERM === "rxvt-unicode" ||
235
- env.TERM === "rxvt-unicode-256color" ||
236
- env.TERMINAL_EMULATOR === "JetBrains-JediTerm"; `
237
- })
238
- ];
239
- }
240
- /**
241
- * Generates utilities for detecting terminal color support.
242
- */
243
- function HyperlinkSupportUtilities() {
244
- return [
245
- createComponent(FunctionDeclaration, {
246
- name: "parseVersion",
247
- parameters: [{
248
- name: "version",
249
- type: "string",
250
- default: "\"\""
251
- }],
252
- children: code`if (/^\d{3,4}$/.test(version)) {
253
- const match = /(\d{1,2})(\d{2})/.exec(version) ?? [];
254
-
255
- return {
256
- major: 0,
257
- minor: Number.parseInt(match[1]!, 10),
258
- patch: Number.parseInt(match[2]!, 10)
259
- };
260
- }
261
-
262
- const versionParts = (version ?? "")
263
- .split(".")
264
- .map(n => Number.parseInt(n, 10));
265
-
266
- return {
267
- major: versionParts[0],
268
- minor: versionParts[1],
269
- patch: versionParts[2]
270
- }; `
271
- }),
272
- createComponent(TSDoc, {
273
- heading: "Check if the current environment/terminal supports hyperlinks in the terminal.",
274
- get children() {
275
- return createComponent(TSDocReturns, { children: "True if the current environment/terminal supports hyperlinks." });
276
- }
277
- }),
278
- createComponent(FunctionDeclaration, {
279
- "export": true,
280
- name: "isHyperlinkSupported",
281
- returnType: "boolean",
282
- children: code`if (Boolean(env.FORCE_HYPERLINK)) {
283
- return true;
284
- }
285
-
286
- if (Boolean(env.NETLIFY)) {
287
- return true;
288
- } else if (isColorSupported || isTTY) {
289
- return false;
290
- } else if (Boolean(env.WT_SESSION)) {
291
- return true;
292
- } else if (isWindows || isMinimal || Boolean(env.TEAMCITY_VERSION)) {
293
- return false;
294
- } else if (Boolean(env.TERM_PROGRAM)) {
295
- const version = parseVersion(env.TERM_PROGRAM_VERSION);
296
-
297
- switch (String(env.TERM_PROGRAM)) {
298
- case "iTerm.app": {
299
- if (version.major === 3) {
300
- return version.minor !== undefined && version.minor >= 1;
301
- }
302
-
303
- return version.major !== undefined && version.major > 3;
304
- }
305
- case "WezTerm": {
306
- return version.major !== undefined && version.major >= 20_200_620;
307
- }
308
-
309
- case "vscode": {
310
- if (Boolean(env.CURSOR_TRACE_ID)) {
311
- return true;
312
- }
313
-
314
- return (
315
- version.minor !== undefined &&
316
- version.major !== undefined &&
317
- (version.major > 1 || (version.major === 1 && version.minor >= 72))
318
- );
319
- }
320
-
321
- case "ghostty": {
322
- return true;
323
- }
324
- }
325
- }
326
-
327
- if (Boolean(env.VTE_VERSION)) {
328
- if (env.VTE_VERSION === "0.50.0") {
329
- return false;
330
- }
331
-
332
- const version = parseVersion(env.VTE_VERSION);
333
- return (
334
- (version.major !== undefined && version.major > 0) ||
335
- (version.minor !== undefined && version.minor >= 50)
336
- );
337
- }
338
-
339
- if (String(env.TERM) === "alacritty") {
340
- return true;
341
- }
342
-
343
- return false; `
344
- })
345
- ];
346
- }
347
- /**
348
- * Generates utilities for detecting terminal color support.
349
- */
350
- function ArgsUtilities() {
351
- return [createComponent(TSDoc, {
352
- heading: "Checks if a specific flag is present in the command line arguments.",
353
- get children() {
354
- return [
355
- createComponent(TSDocLink, { children: "https://github.com/sindresorhus/has-flag/blob/main/index.js" }),
356
- createComponent(TSDocParam, {
357
- name: "flag",
358
- children: "The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\"."
359
- }),
360
- createComponent(TSDocParam, {
361
- name: "argv",
362
- children: "The command line arguments to check against. Defaults to global Deno args or process args."
363
- }),
364
- createComponent(TSDocReturns, { children: "True if the flag is present, false otherwise." })
365
- ];
366
- }
367
- }), createComponent(FunctionDeclaration, {
368
- "export": true,
369
- name: "hasFlag",
370
- parameters: [{
371
- name: "flag",
372
- type: "string | string[]"
373
- }, {
374
- name: "argv",
375
- type: "string[]",
376
- optional: true,
377
- default: "globalThis.Deno ? globalThis.Deno.args : process.argv"
378
- }],
379
- get children() {
380
- return [
381
- createComponent(VarDeclaration, {
382
- "const": true,
383
- name: "position",
384
- type: "number",
385
- initializer: code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {
386
- const pos = argv.findIndex(arg => (f.startsWith("-") ? "" : (f.length === 1 ? "-" : "--") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? "-" : "--") + f + "=")?.toLowerCase());
387
- return pos !== -1 ? pos : ret;
388
- }, -1);`
389
- }),
390
- createIntrinsic("hbr", {}),
391
- code`return position !== -1 && argv.indexOf("--") === -1 || position < argv.indexOf("--");`
392
- ];
393
- }
394
- })];
395
- }
396
- /**
397
- * A built-in utilities module for Shell Shock.
398
- */
399
- function UtilsBuiltin(props) {
400
- const [{ children }, rest] = splitProps(props, ["children"]);
401
- return createComponent(BuiltinFile, mergeProps({
402
- id: "utils",
403
- description: "A collection of helper utilities that ease command-line application development."
404
- }, rest, {
405
- get imports() {
406
- return defu$1(rest.imports ?? {}, {
407
- "node:os": ["os"],
408
- "node:process": ["process"]
409
- });
410
- },
411
- get builtinImports() {
412
- return defu$1(rest.builtinImports ?? {}, { env: [
413
- "env",
414
- "isCI",
415
- "isTest",
416
- "isWindows"
417
- ] });
418
- },
419
- get children() {
420
- return [
421
- createIntrinsic("hbr", {}),
422
- createIntrinsic("hbr", {}),
423
- createComponent(ArgsUtilities, {}),
424
- createIntrinsic("hbr", {}),
425
- createIntrinsic("hbr", {}),
426
- createComponent(EnvSupportUtilities, {}),
427
- createIntrinsic("hbr", {}),
428
- createIntrinsic("hbr", {}),
429
- createComponent(HyperlinkSupportUtilities, {}),
430
- createIntrinsic("hbr", {}),
431
- createIntrinsic("hbr", {}),
432
- createComponent(ColorSupportUtilities, {}),
433
- createIntrinsic("hbr", {}),
434
- createIntrinsic("hbr", {}),
435
- createComponent(Show, {
436
- get when() {
437
- return Boolean(children);
438
- },
439
- children
440
- })
441
- ];
442
- }
443
- }));
444
- }
445
-
446
- //#endregion
447
- export { ArgsUtilities, ColorSupportUtilities, EnvSupportUtilities, HyperlinkSupportUtilities, UtilsBuiltin };
@@ -1,172 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
- const require_persistence = require('./helpers/persistence.cjs');
4
- const require_resolve_command = require('./helpers/resolve-command.cjs');
5
- const require_update_package_json = require('./helpers/update-package-json.cjs');
6
- const require_utilities = require('./helpers/utilities.cjs');
7
- let __powerlines_plugin_tsdown = require("@powerlines/plugin-tsdown");
8
- __powerlines_plugin_tsdown = require_rolldown_runtime.__toESM(__powerlines_plugin_tsdown);
9
- let __stryke_fs_chmod_x = require("@stryke/fs/chmod-x");
10
- let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
11
- let __stryke_path_append = require("@stryke/path/append");
12
- let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
13
- let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
14
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
15
- let __stryke_path_replace = require("@stryke/path/replace");
16
- let __stryke_path_resolve_parent_path = require("@stryke/path/resolve-parent-path");
17
- let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
18
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
19
- let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
20
- let defu = require("defu");
21
-
22
- //#region src/powerlines.ts
23
- const MAX_DEPTH = 50;
24
- /**
25
- * The core Powerlines plugin to build Shell Shock projects.
26
- */
27
- const shellShock = (options = {}) => {
28
- return [
29
- (0, __powerlines_plugin_tsdown.default)(),
30
- {
31
- name: "shell-shock:config",
32
- async config() {
33
- this.trace("Resolving the Shell Shock configuration.");
34
- return (0, defu.defu)(options, {
35
- entry: !this.config.entry || Array.isArray(this.config.entry) && this.config.entry.length === 0 ? [(0, __stryke_path_join_paths.joinPaths)(this.config.sourceRoot, "**/*")] : void 0,
36
- build: {
37
- target: "node22",
38
- platform: "node"
39
- },
40
- type: "application",
41
- framework: "shell-shock"
42
- });
43
- },
44
- configResolved: {
45
- order: "pre",
46
- async handler() {
47
- this.trace("Shell Shock configuration has been resolved.");
48
- await require_update_package_json.updatePackageJsonBinary(this);
49
- this.config.name = require_utilities.getAppName(this);
50
- this.config.title = require_utilities.getAppTitle(this);
51
- this.config.description = require_utilities.getAppDescription(this);
52
- if (this.config.defaultOptions === false) this.options = [];
53
- else if (Array.isArray(this.config.defaultOptions)) this.options = (0, __stryke_helpers_get_unique.getUniqueBy)(this.config.defaultOptions, (item) => item.name);
54
- else if ((0, __stryke_type_checks_is_function.isFunction)(this.config.defaultOptions)) this.options = (0, __stryke_helpers_get_unique.getUniqueBy)(this.config.defaultOptions(this, {
55
- id: null,
56
- name: this.config.name,
57
- title: this.config.title,
58
- description: this.config.description,
59
- path: [],
60
- isVirtual: false
61
- }), (item) => item.name);
62
- this.inputs ??= [];
63
- }
64
- }
65
- },
66
- {
67
- name: "shell-shock:inputs",
68
- async configResolved() {
69
- this.trace("Finding command entry points.");
70
- this.commandsPath = require_resolve_command.findCommandsRoot(this);
71
- this.inputs = this.entry.filter((entry) => (0, __stryke_path_file_path_fns.findFileName)(entry.file, { withExtension: false }) === "command").reduce((ret, entry) => {
72
- const file = (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)(entry.file, this.config.projectRoot), this.workspaceConfig.workspaceRoot);
73
- if (!(0, __stryke_path_is_parent_path.isParentPath)(file, this.commandsPath)) throw new Error(`Command entry point "${file}" is not located within the commands root "${this.commandsPath}". Please ensure that all command entry points are located within the current project.`);
74
- const path = require_resolve_command.resolveCommandPath(this, file);
75
- const id = path.replaceAll("/", "-");
76
- if (!ret.some((existing) => existing.id === id)) {
77
- const name = require_resolve_command.findCommandName(file);
78
- ret.push({
79
- id,
80
- path: path.split("/").filter(Boolean),
81
- name,
82
- title: (0, __stryke_string_format_title_case.titleCase)(name),
83
- isVirtual: false,
84
- entry: {
85
- ...entry,
86
- file,
87
- input: {
88
- file: entry.file,
89
- name: entry.name
90
- },
91
- output: name
92
- }
93
- });
94
- }
95
- return ret;
96
- }, this.inputs);
97
- }
98
- },
99
- {
100
- name: "shell-shock:virtual-inputs",
101
- configResolved: {
102
- order: "post",
103
- async handler() {
104
- if (this.inputs.length === 0) this.warn("No commands were found in the project. Please ensure at least one command exists.");
105
- else {
106
- this.info(`Shell Shock will create an application with the following commands: \n${this.inputs.filter((cmd) => !cmd.isVirtual).map((command) => ` - ${command.id}: ${(0, __stryke_path_replace.replacePath)(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
107
- this.trace("Finding and adding virtual command inputs for each command previously found.");
108
- this.inputs = this.inputs.reduce((ret, command) => {
109
- let depth = 0;
110
- let parentPath = (0, __stryke_path_resolve_parent_path.resolveParentPath)((0, __stryke_path_file_path_fns.findFilePath)(command.entry.file));
111
- while (parentPath !== this.commandsPath) {
112
- if (depth++ > MAX_DEPTH) throw new Error(`Maximum command virtual parent depth of ${MAX_DEPTH} exceeded while processing command: ${command.name}`);
113
- if (!ret.some((existing) => (0, __stryke_path_file_path_fns.findFilePath)(existing.entry.file) === parentPath)) {
114
- const file = (0, __stryke_path_join_paths.joinPaths)(parentPath, "command.ts");
115
- const path = require_resolve_command.resolveCommandPath(this, file);
116
- const id = path.replaceAll("/", "-");
117
- if (!ret.some((existing) => existing.id === id)) {
118
- const name = require_resolve_command.findCommandName(file);
119
- ret.push({
120
- id,
121
- path: path.split("/").filter(Boolean),
122
- name,
123
- title: (0, __stryke_string_format_title_case.titleCase)(name),
124
- isVirtual: true,
125
- entry: {
126
- file,
127
- input: { file }
128
- }
129
- });
130
- }
131
- }
132
- parentPath = (0, __stryke_path_resolve_parent_path.resolveParentPath)(parentPath);
133
- }
134
- return ret;
135
- }, this.inputs).sort((a, b) => a.path.length - b.path.length);
136
- this.trace(`Final command input list: \n${this.inputs.map((command) => ` - ${command.id}: ${(0, __stryke_path_replace.replacePath)(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
137
- }
138
- }
139
- }
140
- },
141
- {
142
- name: "shell-shock:reflect-commands",
143
- async prepare() {
144
- this.entry = [];
145
- this.commands = {};
146
- if (this.config.command !== "prepare" && this.config.skipCache !== true && this.persistedMeta?.checksum === this.meta.checksum && this.fs.existsSync(require_persistence.getCommandsPersistencePath(this))) {
147
- this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
148
- await require_persistence.readCommandsPersistence(this);
149
- } else {
150
- for (const input of this.inputs.filter((input$1) => input$1.path.length === 1)) this.commands[input.name] = await require_resolve_command.reflectCommandTree(this, input);
151
- await require_persistence.writeCommandsPersistence(this);
152
- }
153
- }
154
- },
155
- {
156
- name: "shell-shock:chmod+x",
157
- async buildEnd() {
158
- if (!(0, __stryke_type_checks_is_set_object.isSetObject)(this.packageJson.bin)) {
159
- this.warn("No binaries were found in package.json. Please ensure the binaries are correctly configured.");
160
- return;
161
- }
162
- this.debug("Adding executable permissions to binaries.");
163
- for (const executablePath of Object.values(this.packageJson.bin)) if (this.fs.existsSync((0, __stryke_path_append.appendPath)(executablePath, this.config.output.buildPath))) await (0, __stryke_fs_chmod_x.chmodX)((0, __stryke_path_append.appendPath)(executablePath, this.config.output.buildPath));
164
- }
165
- }
166
- ];
167
- };
168
- var powerlines_default = shellShock;
169
-
170
- //#endregion
171
- exports.default = powerlines_default;
172
- exports.shellShock = shellShock;
@@ -1,12 +0,0 @@
1
- import { Context } from "./types/context.cjs";
2
- import { Options } from "./types/config.cjs";
3
- import { Plugin } from "powerlines";
4
-
5
- //#region src/powerlines.d.ts
6
-
7
- /**
8
- * The core Powerlines plugin to build Shell Shock projects.
9
- */
10
- declare const shellShock: <TContext extends Context = Context>(options?: Options) => Plugin<TContext>[];
11
- //#endregion
12
- export { shellShock as default, shellShock };
@@ -1,12 +0,0 @@
1
- import { Context } from "./types/context.mjs";
2
- import { Options } from "./types/config.mjs";
3
- import { Plugin } from "powerlines";
4
-
5
- //#region src/powerlines.d.ts
6
-
7
- /**
8
- * The core Powerlines plugin to build Shell Shock projects.
9
- */
10
- declare const shellShock: <TContext extends Context = Context>(options?: Options) => Plugin<TContext>[];
11
- //#endregion
12
- export { shellShock as default, shellShock };