@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.
- 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 +175 -0
- package/dist/components/docs.cjs.map +1 -0
- package/dist/components/docs.d.cts +81 -0
- package/dist/components/docs.d.cts.map +1 -0
- package/dist/components/docs.d.mts +81 -0
- package/dist/components/docs.d.mts.map +1 -0
- package/dist/components/docs.mjs +171 -0
- package/dist/components/docs.mjs.map +1 -0
- package/dist/components/index.cjs +5 -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/automd.cjs +59 -0
- package/dist/helpers/automd.cjs.map +1 -0
- package/dist/helpers/automd.mjs +58 -0
- package/dist/helpers/automd.mjs.map +1 -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 +284 -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 +276 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/types/command.d.cts +14 -4
- package/dist/types/command.d.cts.map +1 -0
- package/dist/types/command.d.mts +14 -4
- package/dist/types/command.d.mts.map +1 -0
- package/dist/types/config.d.cts +74 -10
- package/dist/types/config.d.cts.map +1 -0
- package/dist/types/config.d.mts +74 -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/dist/types/runtime.cjs +0 -0
- package/dist/types/runtime.d.cts +24 -0
- package/dist/types/runtime.d.cts.map +1 -0
- package/dist/types/runtime.d.mts +24 -0
- package/dist/types/runtime.d.mts.map +1 -0
- package/dist/types/runtime.mjs +1 -0
- package/package.json +223 -91
- 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/powerlines.mjs
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { getCommandsPersistencePath, readCommandsPersistence, writeCommandsPersistence } from "./helpers/persistence.mjs";
|
|
2
|
-
import { findCommandName, findCommandsRoot, reflectCommandTree, resolveCommandPath } from "./helpers/resolve-command.mjs";
|
|
3
|
-
import { updatePackageJsonBinary } from "./helpers/update-package-json.mjs";
|
|
4
|
-
import { getAppDescription, getAppName, getAppTitle } from "./helpers/utilities.mjs";
|
|
5
|
-
import tsdown from "@powerlines/plugin-tsdown";
|
|
6
|
-
import { chmodX } from "@stryke/fs/chmod-x";
|
|
7
|
-
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
8
|
-
import { appendPath } from "@stryke/path/append";
|
|
9
|
-
import { findFileName, findFilePath } from "@stryke/path/file-path-fns";
|
|
10
|
-
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
11
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
12
|
-
import { replacePath } from "@stryke/path/replace";
|
|
13
|
-
import { resolveParentPath } from "@stryke/path/resolve-parent-path";
|
|
14
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
15
|
-
import { isFunction } from "@stryke/type-checks/is-function";
|
|
16
|
-
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
17
|
-
import { defu } from "defu";
|
|
18
|
-
|
|
19
|
-
//#region src/powerlines.ts
|
|
20
|
-
const MAX_DEPTH = 50;
|
|
21
|
-
/**
|
|
22
|
-
* The core Powerlines plugin to build Shell Shock projects.
|
|
23
|
-
*/
|
|
24
|
-
const shellShock = (options = {}) => {
|
|
25
|
-
return [
|
|
26
|
-
tsdown(),
|
|
27
|
-
{
|
|
28
|
-
name: "shell-shock:config",
|
|
29
|
-
async config() {
|
|
30
|
-
this.trace("Resolving the Shell Shock configuration.");
|
|
31
|
-
return defu(options, {
|
|
32
|
-
entry: !this.config.entry || Array.isArray(this.config.entry) && this.config.entry.length === 0 ? [joinPaths(this.config.sourceRoot, "**/*")] : void 0,
|
|
33
|
-
build: {
|
|
34
|
-
target: "node22",
|
|
35
|
-
platform: "node"
|
|
36
|
-
},
|
|
37
|
-
type: "application",
|
|
38
|
-
framework: "shell-shock"
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
configResolved: {
|
|
42
|
-
order: "pre",
|
|
43
|
-
async handler() {
|
|
44
|
-
this.trace("Shell Shock configuration has been resolved.");
|
|
45
|
-
await updatePackageJsonBinary(this);
|
|
46
|
-
this.config.name = getAppName(this);
|
|
47
|
-
this.config.title = getAppTitle(this);
|
|
48
|
-
this.config.description = getAppDescription(this);
|
|
49
|
-
if (this.config.defaultOptions === false) this.options = [];
|
|
50
|
-
else if (Array.isArray(this.config.defaultOptions)) this.options = getUniqueBy(this.config.defaultOptions, (item) => item.name);
|
|
51
|
-
else if (isFunction(this.config.defaultOptions)) this.options = getUniqueBy(this.config.defaultOptions(this, {
|
|
52
|
-
id: null,
|
|
53
|
-
name: this.config.name,
|
|
54
|
-
title: this.config.title,
|
|
55
|
-
description: this.config.description,
|
|
56
|
-
path: [],
|
|
57
|
-
isVirtual: false
|
|
58
|
-
}), (item) => item.name);
|
|
59
|
-
this.inputs ??= [];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: "shell-shock:inputs",
|
|
65
|
-
async configResolved() {
|
|
66
|
-
this.trace("Finding command entry points.");
|
|
67
|
-
this.commandsPath = findCommandsRoot(this);
|
|
68
|
-
this.inputs = this.entry.filter((entry) => findFileName(entry.file, { withExtension: false }) === "command").reduce((ret, entry) => {
|
|
69
|
-
const file = appendPath(appendPath(entry.file, this.config.projectRoot), this.workspaceConfig.workspaceRoot);
|
|
70
|
-
if (!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.`);
|
|
71
|
-
const path = resolveCommandPath(this, file);
|
|
72
|
-
const id = path.replaceAll("/", "-");
|
|
73
|
-
if (!ret.some((existing) => existing.id === id)) {
|
|
74
|
-
const name = findCommandName(file);
|
|
75
|
-
ret.push({
|
|
76
|
-
id,
|
|
77
|
-
path: path.split("/").filter(Boolean),
|
|
78
|
-
name,
|
|
79
|
-
title: titleCase(name),
|
|
80
|
-
isVirtual: false,
|
|
81
|
-
entry: {
|
|
82
|
-
...entry,
|
|
83
|
-
file,
|
|
84
|
-
input: {
|
|
85
|
-
file: entry.file,
|
|
86
|
-
name: entry.name
|
|
87
|
-
},
|
|
88
|
-
output: name
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return ret;
|
|
93
|
-
}, this.inputs);
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
name: "shell-shock:virtual-inputs",
|
|
98
|
-
configResolved: {
|
|
99
|
-
order: "post",
|
|
100
|
-
async handler() {
|
|
101
|
-
if (this.inputs.length === 0) this.warn("No commands were found in the project. Please ensure at least one command exists.");
|
|
102
|
-
else {
|
|
103
|
-
this.info(`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")}`);
|
|
104
|
-
this.trace("Finding and adding virtual command inputs for each command previously found.");
|
|
105
|
-
this.inputs = this.inputs.reduce((ret, command) => {
|
|
106
|
-
let depth = 0;
|
|
107
|
-
let parentPath = resolveParentPath(findFilePath(command.entry.file));
|
|
108
|
-
while (parentPath !== this.commandsPath) {
|
|
109
|
-
if (depth++ > MAX_DEPTH) throw new Error(`Maximum command virtual parent depth of ${MAX_DEPTH} exceeded while processing command: ${command.name}`);
|
|
110
|
-
if (!ret.some((existing) => findFilePath(existing.entry.file) === parentPath)) {
|
|
111
|
-
const file = joinPaths(parentPath, "command.ts");
|
|
112
|
-
const path = resolveCommandPath(this, file);
|
|
113
|
-
const id = path.replaceAll("/", "-");
|
|
114
|
-
if (!ret.some((existing) => existing.id === id)) {
|
|
115
|
-
const name = findCommandName(file);
|
|
116
|
-
ret.push({
|
|
117
|
-
id,
|
|
118
|
-
path: path.split("/").filter(Boolean),
|
|
119
|
-
name,
|
|
120
|
-
title: titleCase(name),
|
|
121
|
-
isVirtual: true,
|
|
122
|
-
entry: {
|
|
123
|
-
file,
|
|
124
|
-
input: { file }
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
parentPath = resolveParentPath(parentPath);
|
|
130
|
-
}
|
|
131
|
-
return ret;
|
|
132
|
-
}, this.inputs).sort((a, b) => a.path.length - b.path.length);
|
|
133
|
-
this.trace(`Final command input list: \n${this.inputs.map((command) => ` - ${command.id}: ${replacePath(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: "shell-shock:reflect-commands",
|
|
140
|
-
async prepare() {
|
|
141
|
-
this.entry = [];
|
|
142
|
-
this.commands = {};
|
|
143
|
-
if (this.config.command !== "prepare" && this.config.skipCache !== true && this.persistedMeta?.checksum === this.meta.checksum && this.fs.existsSync(getCommandsPersistencePath(this))) {
|
|
144
|
-
this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
|
|
145
|
-
await readCommandsPersistence(this);
|
|
146
|
-
} else {
|
|
147
|
-
for (const input of this.inputs.filter((input$1) => input$1.path.length === 1)) this.commands[input.name] = await reflectCommandTree(this, input);
|
|
148
|
-
await writeCommandsPersistence(this);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: "shell-shock:chmod+x",
|
|
154
|
-
async buildEnd() {
|
|
155
|
-
if (!isSetObject(this.packageJson.bin)) {
|
|
156
|
-
this.warn("No binaries were found in package.json. Please ensure the binaries are correctly configured.");
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
this.debug("Adding executable permissions to binaries.");
|
|
160
|
-
for (const executablePath of Object.values(this.packageJson.bin)) if (this.fs.existsSync(appendPath(executablePath, this.config.output.buildPath))) await chmodX(appendPath(executablePath, this.config.output.buildPath));
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
];
|
|
164
|
-
};
|
|
165
|
-
var powerlines_default = shellShock;
|
|
166
|
-
|
|
167
|
-
//#endregion
|
|
168
|
-
export { powerlines_default as default, shellShock };
|