@shell-shock/core 0.2.1 → 0.3.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.
- package/README.md +1 -1
- package/dist/api.cjs +15 -3
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +9 -1
- package/dist/api.d.cts.map +1 -0
- package/dist/api.d.mts +9 -1
- package/dist/api.d.mts.map +1 -0
- package/dist/api.mjs +14 -3
- package/dist/api.mjs.map +1 -0
- package/dist/components/docs.cjs +105 -0
- package/dist/components/docs.cjs.map +1 -0
- package/dist/components/docs.d.cts +56 -0
- package/dist/components/docs.d.cts.map +1 -0
- package/dist/components/docs.d.mts +56 -0
- package/dist/components/docs.d.mts.map +1 -0
- package/dist/components/docs.mjs +102 -0
- package/dist/components/docs.mjs.map +1 -0
- package/dist/components/index.cjs +4 -6
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/config.cjs +2 -1
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +2 -1
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +2 -1
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +2 -1
- package/dist/config.mjs.map +1 -0
- package/dist/contexts/command.cjs +21 -0
- package/dist/contexts/command.cjs.map +1 -0
- package/dist/contexts/command.d.cts +18 -0
- package/dist/contexts/command.d.cts.map +1 -0
- package/dist/contexts/command.d.mts +18 -0
- package/dist/contexts/command.d.mts.map +1 -0
- package/dist/contexts/command.mjs +19 -0
- package/dist/contexts/command.mjs.map +1 -0
- package/dist/contexts/index.cjs +4 -0
- package/dist/contexts/index.d.cts +2 -0
- package/dist/contexts/index.d.mts +2 -0
- package/dist/contexts/index.mjs +3 -0
- package/dist/helpers/docs-helpers.cjs +17 -0
- package/dist/helpers/docs-helpers.cjs.map +1 -0
- package/dist/helpers/docs-helpers.mjs +16 -0
- package/dist/helpers/docs-helpers.mjs.map +1 -0
- package/dist/helpers/persistence.cjs +2 -1
- package/dist/helpers/persistence.cjs.map +1 -0
- package/dist/helpers/persistence.mjs +2 -1
- package/dist/helpers/persistence.mjs.map +1 -0
- package/dist/helpers/resolve-command.cjs +118 -33
- package/dist/helpers/resolve-command.cjs.map +1 -0
- package/dist/helpers/resolve-command.mjs +116 -32
- package/dist/helpers/resolve-command.mjs.map +1 -0
- package/dist/helpers/update-package-json.cjs +18 -10
- package/dist/helpers/update-package-json.cjs.map +1 -0
- package/dist/helpers/update-package-json.mjs +17 -10
- package/dist/helpers/update-package-json.mjs.map +1 -0
- package/dist/helpers/utilities.cjs +30 -30
- package/dist/helpers/utilities.cjs.map +1 -0
- package/dist/helpers/utilities.mjs +29 -28
- package/dist/helpers/utilities.mjs.map +1 -0
- package/dist/helpers/validations.cjs +97 -0
- package/dist/helpers/validations.cjs.map +1 -0
- package/dist/helpers/validations.mjs +97 -0
- package/dist/helpers/validations.mjs.map +1 -0
- package/dist/index.cjs +5 -13
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -17
- package/dist/index.d.mts +6 -17
- package/dist/index.mjs +4 -13
- package/dist/index.mjs.map +1 -0
- package/dist/plugin-utils/context-helpers.cjs +86 -0
- package/dist/plugin-utils/context-helpers.cjs.map +1 -0
- package/dist/plugin-utils/context-helpers.d.cts +58 -0
- package/dist/plugin-utils/context-helpers.d.cts.map +1 -0
- package/dist/plugin-utils/context-helpers.d.mts +58 -0
- package/dist/plugin-utils/context-helpers.d.mts.map +1 -0
- package/dist/plugin-utils/context-helpers.mjs +79 -0
- package/dist/plugin-utils/context-helpers.mjs.map +1 -0
- package/dist/plugin-utils/get-command-tree.cjs +4 -2
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -0
- package/dist/plugin-utils/get-command-tree.d.cts +2 -1
- package/dist/plugin-utils/get-command-tree.d.cts.map +1 -0
- package/dist/plugin-utils/get-command-tree.d.mts +2 -1
- package/dist/plugin-utils/get-command-tree.d.mts.map +1 -0
- package/dist/plugin-utils/get-command-tree.mjs +5 -2
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -0
- package/dist/plugin-utils/index.cjs +14 -1
- package/dist/plugin-utils/index.d.cts +4 -1
- package/dist/plugin-utils/index.d.mts +4 -1
- package/dist/plugin-utils/index.mjs +4 -1
- package/dist/plugin-utils/reflect.cjs +25 -0
- package/dist/plugin-utils/reflect.cjs.map +1 -0
- package/dist/plugin-utils/reflect.d.cts +14 -0
- package/dist/plugin-utils/reflect.d.cts.map +1 -0
- package/dist/plugin-utils/reflect.d.mts +14 -0
- package/dist/plugin-utils/reflect.d.mts.map +1 -0
- package/dist/plugin-utils/reflect.mjs +24 -0
- package/dist/plugin-utils/reflect.mjs.map +1 -0
- package/dist/plugin-utils/traverse-command-tree.cjs +33 -0
- package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -0
- package/dist/plugin-utils/traverse-command-tree.d.cts +23 -0
- package/dist/plugin-utils/traverse-command-tree.d.cts.map +1 -0
- package/dist/plugin-utils/traverse-command-tree.d.mts +23 -0
- package/dist/plugin-utils/traverse-command-tree.d.mts.map +1 -0
- package/dist/plugin-utils/traverse-command-tree.mjs +31 -0
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -0
- package/dist/plugin.cjs +267 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +13 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +13 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +261 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/types/command.d.cts +13 -4
- package/dist/types/command.d.cts.map +1 -0
- package/dist/types/command.d.mts +13 -4
- package/dist/types/command.d.mts.map +1 -0
- package/dist/types/config.d.cts +73 -10
- package/dist/types/config.d.cts.map +1 -0
- package/dist/types/config.d.mts +73 -10
- package/dist/types/config.d.mts.map +1 -0
- package/dist/types/context.d.cts +7 -4
- package/dist/types/context.d.cts.map +1 -0
- package/dist/types/context.d.mts +7 -4
- package/dist/types/context.d.mts.map +1 -0
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.mts +4 -4
- package/dist/types/internal.cjs +0 -0
- package/dist/types/internal.d.cts +24 -0
- package/dist/types/internal.d.cts.map +1 -0
- package/dist/types/internal.d.mts +24 -0
- package/dist/types/internal.d.mts.map +1 -0
- package/dist/types/internal.mjs +1 -0
- package/dist/types/options.d.cts +2 -1
- package/dist/types/options.d.cts.map +1 -0
- package/dist/types/options.d.mts +2 -1
- package/dist/types/options.d.mts.map +1 -0
- package/package.json +207 -92
- package/dist/components/utils-builtin.cjs +0 -453
- package/dist/components/utils-builtin.d.cts +0 -27
- package/dist/components/utils-builtin.d.mts +0 -27
- package/dist/components/utils-builtin.mjs +0 -447
- package/dist/powerlines.cjs +0 -172
- package/dist/powerlines.d.cts +0 -12
- package/dist/powerlines.d.mts +0 -12
- package/dist/powerlines.mjs +0 -168
package/dist/plugin.cjs
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_plugin_utils_context_helpers = require('./plugin-utils/context-helpers.cjs');
|
|
4
|
+
const require_components_docs = require('./components/docs.cjs');
|
|
5
|
+
const require_persistence = require('./helpers/persistence.cjs');
|
|
6
|
+
const require_utilities = require('./helpers/utilities.cjs');
|
|
7
|
+
const require_resolve_command = require('./helpers/resolve-command.cjs');
|
|
8
|
+
const require_update_package_json = require('./helpers/update-package-json.cjs');
|
|
9
|
+
const require_validations = require('./helpers/validations.cjs');
|
|
10
|
+
const require_plugin_utils_get_command_tree = require('./plugin-utils/get-command-tree.cjs');
|
|
11
|
+
const require_plugin_utils_traverse_command_tree = require('./plugin-utils/traverse-command-tree.cjs');
|
|
12
|
+
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
13
|
+
let __alloy_js_core_components = require("@alloy-js/core/components");
|
|
14
|
+
let __powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
15
|
+
let __powerlines_plugin_nodejs = require("@powerlines/plugin-nodejs");
|
|
16
|
+
__powerlines_plugin_nodejs = require_rolldown_runtime.__toESM(__powerlines_plugin_nodejs);
|
|
17
|
+
let __powerlines_plugin_tsdown = require("@powerlines/plugin-tsdown");
|
|
18
|
+
__powerlines_plugin_tsdown = require_rolldown_runtime.__toESM(__powerlines_plugin_tsdown);
|
|
19
|
+
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
20
|
+
let __stryke_fs_chmod_x = require("@stryke/fs/chmod-x");
|
|
21
|
+
let __stryke_path_append = require("@stryke/path/append");
|
|
22
|
+
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
23
|
+
let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
|
|
24
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
25
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
26
|
+
let __stryke_path_resolve_parent_path = require("@stryke/path/resolve-parent-path");
|
|
27
|
+
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
28
|
+
let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
29
|
+
let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
30
|
+
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
31
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
32
|
+
let defu = require("defu");
|
|
33
|
+
let powerlines_lib_entry = require("powerlines/lib/entry");
|
|
34
|
+
|
|
35
|
+
//#region src/plugin.tsx
|
|
36
|
+
const MAX_DEPTH = 50;
|
|
37
|
+
/**
|
|
38
|
+
* The core Powerlines plugin to build Shell Shock projects.
|
|
39
|
+
*/
|
|
40
|
+
const plugin = (options = {}) => {
|
|
41
|
+
return [
|
|
42
|
+
(0, __powerlines_plugin_tsdown.default)(),
|
|
43
|
+
{
|
|
44
|
+
name: "shell-shock:config",
|
|
45
|
+
async config() {
|
|
46
|
+
this.debug("Resolving the Shell Shock configuration.");
|
|
47
|
+
await require_update_package_json.updatePackageJsonBinary(this);
|
|
48
|
+
const result = (0, defu.defu)({ output: { buildPath: (0, __stryke_path_join_paths.joinPaths)(this.config.projectRoot, "dist") } }, options, {
|
|
49
|
+
name: require_plugin_utils_context_helpers.getAppName(this),
|
|
50
|
+
title: require_plugin_utils_context_helpers.getAppTitle(this),
|
|
51
|
+
description: require_plugin_utils_context_helpers.getAppDescription(this),
|
|
52
|
+
envPrefix: (0, __stryke_string_format_constant_case.constantCase)(require_plugin_utils_context_helpers.getAppName(this)),
|
|
53
|
+
env: { prefix: [] },
|
|
54
|
+
automd: { generators: {} },
|
|
55
|
+
isCaseSensitive: false,
|
|
56
|
+
output: {
|
|
57
|
+
format: "esm",
|
|
58
|
+
dts: true
|
|
59
|
+
},
|
|
60
|
+
entry: !this.config.entry || Array.isArray(this.config.entry) && this.config.entry.length === 0 ? [(0, __stryke_path_join_paths.joinPaths)(this.config.sourceRoot, "**/*.ts"), (0, __stryke_path_join_paths.joinPaths)(this.config.sourceRoot, "**/*.tsx")] : void 0,
|
|
61
|
+
build: {
|
|
62
|
+
dts: false,
|
|
63
|
+
platform: "node",
|
|
64
|
+
nodeProtocol: true,
|
|
65
|
+
unbundle: false
|
|
66
|
+
},
|
|
67
|
+
type: "application",
|
|
68
|
+
framework: "shell-shock"
|
|
69
|
+
});
|
|
70
|
+
if (!result.env.prefix.includes(result.envPrefix)) result.env.prefix.push(result.envPrefix);
|
|
71
|
+
return result;
|
|
72
|
+
},
|
|
73
|
+
configResolved: {
|
|
74
|
+
order: "pre",
|
|
75
|
+
async handler() {
|
|
76
|
+
this.debug("Shell Shock configuration has been resolved.");
|
|
77
|
+
this.config.bin = ((0, __stryke_type_checks_is_set_string.isSetString)(this.packageJson.bin) ? { [(0, __stryke_string_format_kebab_case.kebabCase)(this.config.name)]: this.packageJson.bin } : this.packageJson.bin) ?? { [(0, __stryke_string_format_kebab_case.kebabCase)(this.config.name)]: require_update_package_json.formatBinaryPath(this.config.output.format) };
|
|
78
|
+
this.inputs ??= [];
|
|
79
|
+
this.options = Object.values(require_utilities.getDefaultOptions(this, {
|
|
80
|
+
id: null,
|
|
81
|
+
name: this.config.name,
|
|
82
|
+
title: this.config.title,
|
|
83
|
+
description: this.config.description,
|
|
84
|
+
path: {
|
|
85
|
+
value: null,
|
|
86
|
+
segments: []
|
|
87
|
+
},
|
|
88
|
+
isVirtual: false
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
...(0, __powerlines_plugin_nodejs.default)(),
|
|
94
|
+
{
|
|
95
|
+
name: "shell-shock:inputs",
|
|
96
|
+
async configResolved() {
|
|
97
|
+
this.debug("Finding command entry point files.");
|
|
98
|
+
this.commandsPath = require_resolve_command.findCommandsRoot(this);
|
|
99
|
+
const entries = await (0, powerlines_lib_entry.resolveEntries)(this, (0, __stryke_convert_to_array.toArray)(this.config.entry || []));
|
|
100
|
+
this.debug(`Found ${entries.length} entry points specified in the configuration options.`);
|
|
101
|
+
this.inputs = entries.reduce((ret, entry) => {
|
|
102
|
+
if (!(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.`);
|
|
103
|
+
const id = require_resolve_command.resolveCommandId(this, entry.file);
|
|
104
|
+
if (!ret.some((existing) => existing.id === id)) {
|
|
105
|
+
const path = require_resolve_command.resolveCommandPath(this, entry.file);
|
|
106
|
+
const name = require_resolve_command.resolveCommandName(entry.file);
|
|
107
|
+
ret.push({
|
|
108
|
+
id,
|
|
109
|
+
path: {
|
|
110
|
+
value: path,
|
|
111
|
+
segments: path.split("/").filter(Boolean)
|
|
112
|
+
},
|
|
113
|
+
name,
|
|
114
|
+
isVirtual: false,
|
|
115
|
+
entry: {
|
|
116
|
+
...entry,
|
|
117
|
+
file: entry.file,
|
|
118
|
+
input: {
|
|
119
|
+
file: entry.file,
|
|
120
|
+
name: entry.name
|
|
121
|
+
},
|
|
122
|
+
output: name
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return ret;
|
|
127
|
+
}, this.inputs);
|
|
128
|
+
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")}`);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "shell-shock:virtual-inputs",
|
|
133
|
+
configResolved: {
|
|
134
|
+
order: "post",
|
|
135
|
+
async handler() {
|
|
136
|
+
if (this.inputs.length === 0) this.warn("No commands were found in the project. Please ensure at least one command exists.");
|
|
137
|
+
else {
|
|
138
|
+
this.debug(`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")}`);
|
|
139
|
+
this.debug("Finding and adding virtual command inputs for each command previously found.");
|
|
140
|
+
this.inputs = this.inputs.reduce((ret, command) => {
|
|
141
|
+
let depth = 0;
|
|
142
|
+
let parentPath = (0, __stryke_path_resolve_parent_path.resolveParentPath)((0, __stryke_path_file_path_fns.findFilePath)(command.entry.file));
|
|
143
|
+
while (parentPath !== this.commandsPath) {
|
|
144
|
+
if (depth++ > MAX_DEPTH) throw new Error(`Maximum command virtual parent depth of ${MAX_DEPTH} exceeded while processing command: ${command.name}`);
|
|
145
|
+
if (!ret.some((existing) => (0, __stryke_path_file_path_fns.findFilePath)(existing.entry.file) === parentPath)) {
|
|
146
|
+
const file = (0, __stryke_path_join_paths.joinPaths)(parentPath, "command.ts");
|
|
147
|
+
const id = require_resolve_command.resolveCommandId(this, file);
|
|
148
|
+
if (!ret.some((existing) => existing.id === id)) {
|
|
149
|
+
const name = require_resolve_command.resolveCommandName(file);
|
|
150
|
+
const path = require_resolve_command.resolveCommandPath(this, file);
|
|
151
|
+
ret.push({
|
|
152
|
+
id,
|
|
153
|
+
path: {
|
|
154
|
+
value: path,
|
|
155
|
+
segments: path.split("/").filter(Boolean)
|
|
156
|
+
},
|
|
157
|
+
name,
|
|
158
|
+
isVirtual: true,
|
|
159
|
+
entry: { file }
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
parentPath = (0, __stryke_path_resolve_parent_path.resolveParentPath)(parentPath);
|
|
164
|
+
}
|
|
165
|
+
return ret;
|
|
166
|
+
}, this.inputs).sort((a, b) => a.path.segments.length - b.path.segments.length);
|
|
167
|
+
this.debug(`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")}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: "shell-shock:reflect-commands",
|
|
174
|
+
prepare: {
|
|
175
|
+
order: "post",
|
|
176
|
+
async handler() {
|
|
177
|
+
this.debug("Initializing the CLI application's command tree.");
|
|
178
|
+
this.commands = {};
|
|
179
|
+
if (this.config.command !== "prepare" && this.config.skipCache !== true && this.persistedMeta?.checksum === this.meta.checksum && this.fs.existsSync(require_persistence.getCommandsPersistencePath(this))) {
|
|
180
|
+
this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
|
|
181
|
+
await require_persistence.readCommandsPersistence(this);
|
|
182
|
+
} else {
|
|
183
|
+
for (const input of this.inputs.filter((input$1) => input$1.path.segments.filter((segment) => !require_plugin_utils_context_helpers.isVariableCommandPath(segment)).length === 1)) this.commands[input.name] = await require_resolve_command.reflectCommandTree(this, input);
|
|
184
|
+
this.debug("Post-processing commands to ensure proper reflection.");
|
|
185
|
+
this.options = this.options.map((option) => ({
|
|
186
|
+
...option,
|
|
187
|
+
name: (0, __stryke_string_format_camel_case.camelCase)(option.name),
|
|
188
|
+
alias: option.alias ?? [],
|
|
189
|
+
optional: option.optional ?? false
|
|
190
|
+
}));
|
|
191
|
+
await require_plugin_utils_traverse_command_tree.traverseCommands(this, (command) => {
|
|
192
|
+
command.options = Object.fromEntries(Object.entries(command.options).map(([name, option]) => [(0, __stryke_string_format_camel_case.camelCase)(name), {
|
|
193
|
+
...option,
|
|
194
|
+
name: (0, __stryke_string_format_camel_case.camelCase)(name),
|
|
195
|
+
alias: option.alias ?? [],
|
|
196
|
+
optional: option.optional ?? false
|
|
197
|
+
}]));
|
|
198
|
+
});
|
|
199
|
+
await require_persistence.writeCommandsPersistence(this);
|
|
200
|
+
}
|
|
201
|
+
this.debug("Validating the CLI applications command tree.");
|
|
202
|
+
let isValid = true;
|
|
203
|
+
await require_plugin_utils_traverse_command_tree.traverseCommands(this, (command) => {
|
|
204
|
+
const failures = require_validations.validateCommand(command);
|
|
205
|
+
if (failures.length > 0) {
|
|
206
|
+
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`);
|
|
207
|
+
isValid = false;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
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.`);
|
|
211
|
+
this.info(`\nCreating an application with the following command tree: \n${require_utilities.formatCommandTree(this)}\n`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: "shell-shock:chmod+x",
|
|
217
|
+
configResolved() {
|
|
218
|
+
this.config.build.outputOptions ??= {};
|
|
219
|
+
this.config.build.outputOptions.banner = (chunk) => {
|
|
220
|
+
if (chunk.isEntry && (0, __stryke_path_join_paths.joinPaths)(this.entryPath, "bin.ts") === chunk.facadeModuleId) {
|
|
221
|
+
this.debug(`Adding hashbang to binary executable output file: ${chunk.fileName}`);
|
|
222
|
+
return `#!/usr/bin/env ${this.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node\n`;
|
|
223
|
+
}
|
|
224
|
+
return "";
|
|
225
|
+
};
|
|
226
|
+
},
|
|
227
|
+
async buildEnd() {
|
|
228
|
+
if (!(0, __stryke_type_checks_is_set_object.isSetObject)(this.config.bin)) this.warn(`No binaries were found for the ${this.config.name} application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`);
|
|
229
|
+
else await Promise.all(Object.values(this.config.bin).map(async (bin) => {
|
|
230
|
+
const path = (0, __stryke_path_append.appendPath)(bin, (0, __stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot));
|
|
231
|
+
if (this.fs.existsSync(path)) {
|
|
232
|
+
this.debug(`Adding executable permissions (chmod+x) to binary executable output file: ${path}`);
|
|
233
|
+
await (0, __stryke_fs_chmod_x.chmodX)(path);
|
|
234
|
+
} else this.warn(`Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`);
|
|
235
|
+
}));
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "shell-shock:docs",
|
|
240
|
+
async docs() {
|
|
241
|
+
this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
|
|
242
|
+
const commands = this.inputs.map((input) => require_plugin_utils_get_command_tree.getCommandTree(this, input.path.segments)).filter(Boolean);
|
|
243
|
+
return (0, __powerlines_plugin_alloy_render.render)(this, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core_components.For, {
|
|
244
|
+
get each() {
|
|
245
|
+
return Object.values(commands);
|
|
246
|
+
},
|
|
247
|
+
doubleHardline: true,
|
|
248
|
+
children: (child) => (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core_components.Show, {
|
|
249
|
+
get when() {
|
|
250
|
+
return !child.isVirtual;
|
|
251
|
+
},
|
|
252
|
+
get children() {
|
|
253
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_docs.CommandDocsFile, { command: child });
|
|
254
|
+
}
|
|
255
|
+
})
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
];
|
|
260
|
+
};
|
|
261
|
+
var plugin_default = plugin;
|
|
262
|
+
|
|
263
|
+
//#endregion
|
|
264
|
+
exports.default = plugin_default;
|
|
265
|
+
exports.plugin = plugin;
|
|
266
|
+
exports.shellShock = plugin;
|
|
267
|
+
//# sourceMappingURL=plugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["For","Show","render","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","isVariableCommandPath","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","projectRoot","title","description","envPrefix","env","prefix","automd","generators","isCaseSensitive","format","dts","entry","Array","isArray","length","sourceRoot","undefined","build","platform","nodeProtocol","unbundle","type","framework","includes","push","configResolved","order","handler","bin","packageJson","inputs","Object","values","id","path","value","segments","isVirtual","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","input","map","command","join","warn","cmd","depth","parentPath","sort","a","b","prepare","commands","skipCache","persistedMeta","checksum","meta","fs","existsSync","segment","option","alias","optional","fromEntries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","docs","_$createComponent","each","doubleHardline","children","child","when","shellShock"],"sources":["../src/plugin.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveEntries } from \"powerlines/lib/entry\";\nimport type { RenderedChunk } from \"rolldown\";\nimport type { OutputOptions } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n isVariableCommandPath\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n buildPath: joinPaths(this.config.projectRoot, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n automd: {\n generators: {}\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n entry:\n !this.config.entry ||\n (Array.isArray(this.config.entry) &&\n this.config.entry.length === 0)\n ? [\n joinPaths(this.config.sourceRoot, \"**/*.ts\"),\n joinPaths(this.config.sourceRoot, \"**/*.tsx\")\n ]\n : undefined,\n build: {\n dts: false,\n platform: \"node\",\n nodeProtocol: true,\n unbundle: false\n },\n type: \"application\",\n framework: \"shell-shock\"\n }\n );\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\n }\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n title: this.config.title,\n description: this.config.description,\n path: {\n value: null,\n segments: []\n },\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n\n const entries = await resolveEntries(\n this,\n toArray(this.config.entry || [])\n );\n this.debug(\n `Found ${\n entries.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = entries.reduce((ret, entry) => {\n if (!isParentPath(entry.file, this.commandsPath)) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const path = resolveCommandPath(this, entry.file);\n const name = resolveCommandName(entry.file);\n\n ret.push({\n id,\n path: {\n value: path,\n segments: path.split(\"/\").filter(Boolean)\n },\n name,\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Maximum command virtual parent depth of ${\n MAX_DEPTH\n } exceeded while processing command: ${command.name}`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n const path = resolveCommandPath(this, file);\n\n ret.push({\n id,\n path: {\n value: path,\n segments: path.split(\"/\").filter(Boolean)\n },\n name,\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.path.segments.length - b.path.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:reflect-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n this.commands = {};\n\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping reflection initialization as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await reflectCommandTree(this, input);\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.build.outputOptions ??= {} as OutputOptions;\n (this.config.build.outputOptions as OutputOptions).banner = (\n chunk: RenderedChunk\n ) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${chunk.fileName}`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n )\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\n );\n }\n })\n );\n }\n }\n },\n {\n name: \"shell-shock:docs\",\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.path.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAMwC,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;2CACG;EACR;GACEC,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMf,oDAAwB,KAAK;IAEnC,MAAMgB,wBACJ,EACEC,QAAQ,EACNC,mDAAqB,KAAKJ,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KACEC,MAAMR,gDAAW,KAAK;KACtBe,OAAOd,iDAAY,KAAK;KACxBe,aAAajB,uDAAkB,KAAK;KACpCkB,kEAAwBjB,gDAAW,KAAK,CAAC;KACzCkB,KAAK,EACHC,QAAQ,EAAA,EACT;KACDC,QAAQ,EACNC,YAAY,EAAC,EACd;KACDC,iBAAiB;KACjBV,QAAQ;MACNW,QAAQ;MACRC,KAAK;MACN;KACDC,OACE,CAAC,KAAKhB,OAAOgB,SACZC,MAA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/CC,2DACElJ,iCAAI;MAAA,IAACmJ,OAAI;AAAA,cAAE,CAACD,MAAM7D;;MAAS,IAAA4D,WAAA;AAAA,+DACzB9H,yCAAe,EAACgF,SAAS+C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe1G"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Context } from "./types/context.cjs";
|
|
2
|
+
import { Options } from "./types/config.cjs";
|
|
3
|
+
import { Plugin } from "powerlines";
|
|
4
|
+
|
|
5
|
+
//#region src/plugin.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The core Powerlines plugin to build Shell Shock projects.
|
|
9
|
+
*/
|
|
10
|
+
declare const plugin: <TContext extends Context = Context>(options?: Options) => Plugin<TContext>[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { plugin as default, plugin, plugin as shellShock };
|
|
13
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AA4EA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAuajC,MAvaiC,CAua1B,QAva0B,CAAA,EAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Context } from "./types/context.mjs";
|
|
2
|
+
import { Options } from "./types/config.mjs";
|
|
3
|
+
import { Plugin } from "powerlines";
|
|
4
|
+
|
|
5
|
+
//#region src/plugin.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The core Powerlines plugin to build Shell Shock projects.
|
|
9
|
+
*/
|
|
10
|
+
declare const plugin: <TContext extends Context = Context>(options?: Options) => Plugin<TContext>[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { plugin as default, plugin, plugin as shellShock };
|
|
13
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AA4EA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAuajC,MAvaiC,CAua1B,QAva0B,CAAA,EAAA"}
|
package/dist/plugin.mjs
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { getAppDescription, getAppName, getAppTitle, isVariableCommandPath } from "./plugin-utils/context-helpers.mjs";
|
|
2
|
+
import { CommandDocsFile } from "./components/docs.mjs";
|
|
3
|
+
import { getCommandsPersistencePath, readCommandsPersistence, writeCommandsPersistence } from "./helpers/persistence.mjs";
|
|
4
|
+
import { formatCommandTree, getDefaultOptions } from "./helpers/utilities.mjs";
|
|
5
|
+
import { findCommandsRoot, reflectCommandTree, resolveCommandId, resolveCommandName, resolveCommandPath } from "./helpers/resolve-command.mjs";
|
|
6
|
+
import { formatBinaryPath, updatePackageJsonBinary } from "./helpers/update-package-json.mjs";
|
|
7
|
+
import { validateCommand } from "./helpers/validations.mjs";
|
|
8
|
+
import { getCommandTree } from "./plugin-utils/get-command-tree.mjs";
|
|
9
|
+
import { traverseCommands } from "./plugin-utils/traverse-command-tree.mjs";
|
|
10
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
11
|
+
import { For, Show } from "@alloy-js/core/components";
|
|
12
|
+
import { render } from "@powerlines/plugin-alloy/render";
|
|
13
|
+
import nodejs from "@powerlines/plugin-nodejs";
|
|
14
|
+
import tsdown from "@powerlines/plugin-tsdown";
|
|
15
|
+
import { toArray } from "@stryke/convert/to-array";
|
|
16
|
+
import { chmodX } from "@stryke/fs/chmod-x";
|
|
17
|
+
import { appendPath } from "@stryke/path/append";
|
|
18
|
+
import { findFilePath } from "@stryke/path/file-path-fns";
|
|
19
|
+
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
20
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
21
|
+
import { replacePath } from "@stryke/path/replace";
|
|
22
|
+
import { resolveParentPath } from "@stryke/path/resolve-parent-path";
|
|
23
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
24
|
+
import { constantCase } from "@stryke/string-format/constant-case";
|
|
25
|
+
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
26
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
27
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
28
|
+
import { defu } from "defu";
|
|
29
|
+
import { resolveEntries } from "powerlines/lib/entry";
|
|
30
|
+
|
|
31
|
+
//#region src/plugin.tsx
|
|
32
|
+
const MAX_DEPTH = 50;
|
|
33
|
+
/**
|
|
34
|
+
* The core Powerlines plugin to build Shell Shock projects.
|
|
35
|
+
*/
|
|
36
|
+
const plugin = (options = {}) => {
|
|
37
|
+
return [
|
|
38
|
+
tsdown(),
|
|
39
|
+
{
|
|
40
|
+
name: "shell-shock:config",
|
|
41
|
+
async config() {
|
|
42
|
+
this.debug("Resolving the Shell Shock configuration.");
|
|
43
|
+
await updatePackageJsonBinary(this);
|
|
44
|
+
const result = defu({ output: { buildPath: joinPaths(this.config.projectRoot, "dist") } }, options, {
|
|
45
|
+
name: getAppName(this),
|
|
46
|
+
title: getAppTitle(this),
|
|
47
|
+
description: getAppDescription(this),
|
|
48
|
+
envPrefix: constantCase(getAppName(this)),
|
|
49
|
+
env: { prefix: [] },
|
|
50
|
+
automd: { generators: {} },
|
|
51
|
+
isCaseSensitive: false,
|
|
52
|
+
output: {
|
|
53
|
+
format: "esm",
|
|
54
|
+
dts: true
|
|
55
|
+
},
|
|
56
|
+
entry: !this.config.entry || Array.isArray(this.config.entry) && this.config.entry.length === 0 ? [joinPaths(this.config.sourceRoot, "**/*.ts"), joinPaths(this.config.sourceRoot, "**/*.tsx")] : void 0,
|
|
57
|
+
build: {
|
|
58
|
+
dts: false,
|
|
59
|
+
platform: "node",
|
|
60
|
+
nodeProtocol: true,
|
|
61
|
+
unbundle: false
|
|
62
|
+
},
|
|
63
|
+
type: "application",
|
|
64
|
+
framework: "shell-shock"
|
|
65
|
+
});
|
|
66
|
+
if (!result.env.prefix.includes(result.envPrefix)) result.env.prefix.push(result.envPrefix);
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
configResolved: {
|
|
70
|
+
order: "pre",
|
|
71
|
+
async handler() {
|
|
72
|
+
this.debug("Shell Shock configuration has been resolved.");
|
|
73
|
+
this.config.bin = (isSetString(this.packageJson.bin) ? { [kebabCase(this.config.name)]: this.packageJson.bin } : this.packageJson.bin) ?? { [kebabCase(this.config.name)]: formatBinaryPath(this.config.output.format) };
|
|
74
|
+
this.inputs ??= [];
|
|
75
|
+
this.options = Object.values(getDefaultOptions(this, {
|
|
76
|
+
id: null,
|
|
77
|
+
name: this.config.name,
|
|
78
|
+
title: this.config.title,
|
|
79
|
+
description: this.config.description,
|
|
80
|
+
path: {
|
|
81
|
+
value: null,
|
|
82
|
+
segments: []
|
|
83
|
+
},
|
|
84
|
+
isVirtual: false
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
...nodejs(),
|
|
90
|
+
{
|
|
91
|
+
name: "shell-shock:inputs",
|
|
92
|
+
async configResolved() {
|
|
93
|
+
this.debug("Finding command entry point files.");
|
|
94
|
+
this.commandsPath = findCommandsRoot(this);
|
|
95
|
+
const entries = await resolveEntries(this, toArray(this.config.entry || []));
|
|
96
|
+
this.debug(`Found ${entries.length} entry points specified in the configuration options.`);
|
|
97
|
+
this.inputs = entries.reduce((ret, entry) => {
|
|
98
|
+
if (!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.`);
|
|
99
|
+
const id = resolveCommandId(this, entry.file);
|
|
100
|
+
if (!ret.some((existing) => existing.id === id)) {
|
|
101
|
+
const path = resolveCommandPath(this, entry.file);
|
|
102
|
+
const name = resolveCommandName(entry.file);
|
|
103
|
+
ret.push({
|
|
104
|
+
id,
|
|
105
|
+
path: {
|
|
106
|
+
value: path,
|
|
107
|
+
segments: path.split("/").filter(Boolean)
|
|
108
|
+
},
|
|
109
|
+
name,
|
|
110
|
+
isVirtual: false,
|
|
111
|
+
entry: {
|
|
112
|
+
...entry,
|
|
113
|
+
file: entry.file,
|
|
114
|
+
input: {
|
|
115
|
+
file: entry.file,
|
|
116
|
+
name: entry.name
|
|
117
|
+
},
|
|
118
|
+
output: name
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return ret;
|
|
123
|
+
}, this.inputs);
|
|
124
|
+
this.debug(`Shell Shock will process ${this.inputs.length} command entry files: \n${this.inputs.map((command) => ` - ${command.id}: ${replacePath(command.entry.file, this.commandsPath)}`).join("\n")}`);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: "shell-shock:virtual-inputs",
|
|
129
|
+
configResolved: {
|
|
130
|
+
order: "post",
|
|
131
|
+
async handler() {
|
|
132
|
+
if (this.inputs.length === 0) this.warn("No commands were found in the project. Please ensure at least one command exists.");
|
|
133
|
+
else {
|
|
134
|
+
this.debug(`Shell Shock will create an application with the following commands: \n${this.inputs.filter((cmd) => !cmd.isVirtual).map((command) => ` - ${command.id}: ${replacePath(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
|
|
135
|
+
this.debug("Finding and adding virtual command inputs for each command previously found.");
|
|
136
|
+
this.inputs = this.inputs.reduce((ret, command) => {
|
|
137
|
+
let depth = 0;
|
|
138
|
+
let parentPath = resolveParentPath(findFilePath(command.entry.file));
|
|
139
|
+
while (parentPath !== this.commandsPath) {
|
|
140
|
+
if (depth++ > MAX_DEPTH) throw new Error(`Maximum command virtual parent depth of ${MAX_DEPTH} exceeded while processing command: ${command.name}`);
|
|
141
|
+
if (!ret.some((existing) => findFilePath(existing.entry.file) === parentPath)) {
|
|
142
|
+
const file = joinPaths(parentPath, "command.ts");
|
|
143
|
+
const id = resolveCommandId(this, file);
|
|
144
|
+
if (!ret.some((existing) => existing.id === id)) {
|
|
145
|
+
const name = resolveCommandName(file);
|
|
146
|
+
const path = resolveCommandPath(this, file);
|
|
147
|
+
ret.push({
|
|
148
|
+
id,
|
|
149
|
+
path: {
|
|
150
|
+
value: path,
|
|
151
|
+
segments: path.split("/").filter(Boolean)
|
|
152
|
+
},
|
|
153
|
+
name,
|
|
154
|
+
isVirtual: true,
|
|
155
|
+
entry: { file }
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
parentPath = resolveParentPath(parentPath);
|
|
160
|
+
}
|
|
161
|
+
return ret;
|
|
162
|
+
}, this.inputs).sort((a, b) => a.path.segments.length - b.path.segments.length);
|
|
163
|
+
this.debug(`Final command input list: \n${this.inputs.map((command) => ` - ${command.id}: ${replacePath(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
name: "shell-shock:reflect-commands",
|
|
170
|
+
prepare: {
|
|
171
|
+
order: "post",
|
|
172
|
+
async handler() {
|
|
173
|
+
this.debug("Initializing the CLI application's command tree.");
|
|
174
|
+
this.commands = {};
|
|
175
|
+
if (this.config.command !== "prepare" && this.config.skipCache !== true && this.persistedMeta?.checksum === this.meta.checksum && this.fs.existsSync(getCommandsPersistencePath(this))) {
|
|
176
|
+
this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
|
|
177
|
+
await readCommandsPersistence(this);
|
|
178
|
+
} else {
|
|
179
|
+
for (const input of this.inputs.filter((input$1) => input$1.path.segments.filter((segment) => !isVariableCommandPath(segment)).length === 1)) this.commands[input.name] = await reflectCommandTree(this, input);
|
|
180
|
+
this.debug("Post-processing commands to ensure proper reflection.");
|
|
181
|
+
this.options = this.options.map((option) => ({
|
|
182
|
+
...option,
|
|
183
|
+
name: camelCase(option.name),
|
|
184
|
+
alias: option.alias ?? [],
|
|
185
|
+
optional: option.optional ?? false
|
|
186
|
+
}));
|
|
187
|
+
await traverseCommands(this, (command) => {
|
|
188
|
+
command.options = Object.fromEntries(Object.entries(command.options).map(([name, option]) => [camelCase(name), {
|
|
189
|
+
...option,
|
|
190
|
+
name: camelCase(name),
|
|
191
|
+
alias: option.alias ?? [],
|
|
192
|
+
optional: option.optional ?? false
|
|
193
|
+
}]));
|
|
194
|
+
});
|
|
195
|
+
await writeCommandsPersistence(this);
|
|
196
|
+
}
|
|
197
|
+
this.debug("Validating the CLI applications command tree.");
|
|
198
|
+
let isValid = true;
|
|
199
|
+
await traverseCommands(this, (command) => {
|
|
200
|
+
const failures = validateCommand(command);
|
|
201
|
+
if (failures.length > 0) {
|
|
202
|
+
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`);
|
|
203
|
+
isValid = false;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
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.`);
|
|
207
|
+
this.info(`\nCreating an application with the following command tree: \n${formatCommandTree(this)}\n`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "shell-shock:chmod+x",
|
|
213
|
+
configResolved() {
|
|
214
|
+
this.config.build.outputOptions ??= {};
|
|
215
|
+
this.config.build.outputOptions.banner = (chunk) => {
|
|
216
|
+
if (chunk.isEntry && joinPaths(this.entryPath, "bin.ts") === chunk.facadeModuleId) {
|
|
217
|
+
this.debug(`Adding hashbang to binary executable output file: ${chunk.fileName}`);
|
|
218
|
+
return `#!/usr/bin/env ${this.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node\n`;
|
|
219
|
+
}
|
|
220
|
+
return "";
|
|
221
|
+
};
|
|
222
|
+
},
|
|
223
|
+
async buildEnd() {
|
|
224
|
+
if (!isSetObject(this.config.bin)) this.warn(`No binaries were found for the ${this.config.name} application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`);
|
|
225
|
+
else await Promise.all(Object.values(this.config.bin).map(async (bin) => {
|
|
226
|
+
const path = appendPath(bin, joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot));
|
|
227
|
+
if (this.fs.existsSync(path)) {
|
|
228
|
+
this.debug(`Adding executable permissions (chmod+x) to binary executable output file: ${path}`);
|
|
229
|
+
await chmodX(path);
|
|
230
|
+
} else this.warn(`Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`);
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: "shell-shock:docs",
|
|
236
|
+
async docs() {
|
|
237
|
+
this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
|
|
238
|
+
const commands = this.inputs.map((input) => getCommandTree(this, input.path.segments)).filter(Boolean);
|
|
239
|
+
return render(this, createComponent(For, {
|
|
240
|
+
get each() {
|
|
241
|
+
return Object.values(commands);
|
|
242
|
+
},
|
|
243
|
+
doubleHardline: true,
|
|
244
|
+
children: (child) => createComponent(Show, {
|
|
245
|
+
get when() {
|
|
246
|
+
return !child.isVirtual;
|
|
247
|
+
},
|
|
248
|
+
get children() {
|
|
249
|
+
return createComponent(CommandDocsFile, { command: child });
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
];
|
|
256
|
+
};
|
|
257
|
+
var plugin_default = plugin;
|
|
258
|
+
|
|
259
|
+
//#endregion
|
|
260
|
+
export { plugin_default as default, plugin, plugin as shellShock };
|
|
261
|
+
//# sourceMappingURL=plugin.mjs.map
|