@shell-shock/core 0.9.7 → 0.11.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/dist/api.cjs +1 -2
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.mjs +1 -2
- package/dist/api.mjs.map +1 -1
- package/dist/components/docs.cjs +4 -4
- package/dist/components/docs.cjs.map +1 -1
- package/dist/components/docs.d.cts +5 -5
- package/dist/components/docs.d.mts +5 -5
- package/dist/components/helpers.d.cts +6 -6
- package/dist/components/helpers.d.mts +6 -6
- package/dist/components/helpers.d.mts.map +1 -1
- package/dist/components/index.cjs +1 -0
- 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/components/options-parser-logic.cjs +31 -31
- package/dist/components/options-parser-logic.cjs.map +1 -1
- package/dist/components/options-parser-logic.d.cts +9 -9
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +9 -9
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs +26 -26
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/usage.cjs +5 -5
- package/dist/components/usage.cjs.map +1 -1
- package/dist/components/usage.d.cts +2 -2
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.mjs +4 -4
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +204 -0
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.d.cts +13 -9
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +13 -9
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +208 -5
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/contexts/options.cjs +2 -2
- package/dist/contexts/options.cjs.map +1 -1
- package/dist/contexts/options.d.cts +1 -1
- package/dist/contexts/options.d.cts.map +1 -1
- package/dist/contexts/options.d.mts +1 -1
- package/dist/contexts/options.d.mts.map +1 -1
- package/dist/contexts/options.mjs +4 -4
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +2 -2
- package/dist/helpers/automd.cjs.map +1 -1
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +1 -1
- package/dist/helpers/docs-helpers.cjs.map +1 -1
- package/dist/helpers/docs-helpers.mjs +1 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +125 -0
- package/dist/helpers/paths.cjs.map +1 -0
- package/dist/helpers/paths.mjs +121 -0
- package/dist/helpers/paths.mjs.map +1 -0
- package/dist/helpers/persistence.cjs +68 -116
- package/dist/helpers/persistence.cjs.map +1 -1
- package/dist/helpers/persistence.mjs +68 -116
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +5 -5
- package/dist/helpers/update-package-json.cjs.map +1 -1
- package/dist/helpers/update-package-json.mjs +1 -1
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +1 -1
- package/dist/helpers/utilities.mjs +1 -1
- package/dist/helpers/validations.cjs +2 -3
- package/dist/helpers/validations.cjs.map +1 -1
- package/dist/helpers/validations.mjs +2 -2
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +14 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.mts +2 -4
- package/dist/index.mjs +3 -5
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +72 -0
- package/dist/plugin-utils/deepkit.cjs.map +1 -0
- package/dist/plugin-utils/deepkit.d.cts +24 -0
- package/dist/plugin-utils/deepkit.d.cts.map +1 -0
- package/dist/plugin-utils/deepkit.d.mts +24 -0
- package/dist/plugin-utils/deepkit.d.mts.map +1 -0
- package/dist/plugin-utils/deepkit.mjs +70 -0
- package/dist/plugin-utils/deepkit.mjs.map +1 -0
- package/dist/plugin-utils/get-command-tree.cjs +2 -2
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/index.cjs +27 -18
- package/dist/plugin-utils/index.d.cts +3 -1
- package/dist/plugin-utils/index.d.mts +3 -1
- package/dist/plugin-utils/index.mjs +3 -1
- package/dist/plugin-utils/reflect.cjs +4 -5
- package/dist/plugin-utils/reflect.cjs.map +1 -1
- package/dist/plugin-utils/reflect.mjs +4 -4
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +89 -0
- package/dist/plugin-utils/type-checks.cjs.map +1 -0
- package/dist/plugin-utils/type-checks.d.cts +42 -0
- package/dist/plugin-utils/type-checks.d.cts.map +1 -0
- package/dist/plugin-utils/type-checks.d.mts +42 -0
- package/dist/plugin-utils/type-checks.d.mts.map +1 -0
- package/dist/plugin-utils/type-checks.mjs +84 -0
- package/dist/plugin-utils/type-checks.mjs.map +1 -0
- package/dist/plugin.cjs +48 -45
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +30 -26
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +129 -0
- package/dist/resolver/deepkit.cjs.map +1 -0
- package/dist/resolver/deepkit.mjs +128 -0
- package/dist/resolver/deepkit.mjs.map +1 -0
- package/dist/resolver/helpers.cjs +173 -0
- package/dist/resolver/helpers.cjs.map +1 -0
- package/dist/resolver/helpers.mjs +168 -0
- package/dist/resolver/helpers.mjs.map +1 -0
- package/dist/resolver/module.cjs +144 -0
- package/dist/resolver/module.cjs.map +1 -0
- package/dist/resolver/module.mjs +143 -0
- package/dist/resolver/module.mjs.map +1 -0
- package/dist/resolver/resolve.cjs +209 -0
- package/dist/resolver/resolve.cjs.map +1 -0
- package/dist/resolver/resolve.mjs +208 -0
- package/dist/resolver/resolve.mjs.map +1 -0
- package/dist/types/command.cjs +131 -99
- package/dist/types/command.cjs.map +1 -1
- package/dist/types/command.d.cts +49 -75
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +49 -75
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs +119 -91
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +1 -2
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts +2 -2
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +2 -2
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +1 -2
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +1 -1
- package/dist/types/context.cjs.map +1 -1
- package/dist/types/context.d.cts +3 -3
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +3 -3
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/context.mjs +1 -1
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/index.cjs +13 -9
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +2 -2
- package/package.json +34 -79
- package/dist/helpers/resolve-command.cjs +0 -410
- package/dist/helpers/resolve-command.cjs.map +0 -1
- package/dist/helpers/resolve-command.mjs +0 -405
- package/dist/helpers/resolve-command.mjs.map +0 -1
|
@@ -1,139 +1,80 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
3
|
-
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
4
|
-
let __stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
5
3
|
|
|
6
4
|
//#region src/helpers/persistence.ts
|
|
7
|
-
const __ΩRecord = [
|
|
8
|
-
"K",
|
|
9
|
-
"T",
|
|
10
|
-
"Record",
|
|
11
|
-
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
12
|
-
];
|
|
13
5
|
function __assignType(fn, args) {
|
|
14
6
|
fn.__type = args;
|
|
15
7
|
return fn;
|
|
16
8
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
const serialize = __assignType((node, parent = null) => {
|
|
28
|
-
const serializedNode = {
|
|
29
|
-
...node,
|
|
30
|
-
options: Object.entries(node.options).reduce(__assignType((ret, [key, option]) => {
|
|
31
|
-
ret[key] = { ...(0, __stryke_helpers_omit.omit)(option, ["reflection"]) };
|
|
32
|
-
return ret;
|
|
33
|
-
}, [
|
|
34
|
-
"ret",
|
|
35
|
-
"param1",
|
|
36
|
-
"",
|
|
37
|
-
"P\"2!\"2\"\"/#"
|
|
38
|
-
]), {}),
|
|
39
|
-
arguments: node.arguments.map(__assignType((arg) => ({ ...(0, __stryke_helpers_omit.omit)(arg, ["reflection"]) }), [
|
|
40
|
-
"arg",
|
|
41
|
-
"",
|
|
42
|
-
"P\"2!\"/\""
|
|
43
|
-
])),
|
|
44
|
-
parent,
|
|
45
|
-
children: {},
|
|
46
|
-
reflection: node.reflection ? (0, __powerlines_deepkit_vendor_type.serializeType)(node.reflection.type) : void 0
|
|
47
|
-
};
|
|
48
|
-
for (const [key, child] of Object.entries(node.children || {})) serializedNode.children[key] = serialize(child, node.id);
|
|
49
|
-
return serializedNode;
|
|
50
|
-
}, [
|
|
51
|
-
"CommandTree",
|
|
52
|
-
"node",
|
|
53
|
-
"parent",
|
|
54
|
-
() => null,
|
|
55
|
-
"SerializedCommandTree",
|
|
56
|
-
"",
|
|
57
|
-
"P\"w!2\"P&,J2#>$\"w%/&"
|
|
58
|
-
]);
|
|
59
|
-
const result = {};
|
|
60
|
-
for (const [key, child] of Object.entries(commands)) result[key] = serialize(child, null);
|
|
61
|
-
return result;
|
|
9
|
+
function serialize(command) {
|
|
10
|
+
return {
|
|
11
|
+
...command,
|
|
12
|
+
parent: command.parent?.name ? command.parent.name : null,
|
|
13
|
+
children: Object.fromEntries(Object.entries(command.children || {}).map(__assignType(([name, child]) => [name, serialize(child)], [
|
|
14
|
+
"param0",
|
|
15
|
+
"",
|
|
16
|
+
"P\"2!\"/\""
|
|
17
|
+
])))
|
|
18
|
+
};
|
|
62
19
|
}
|
|
63
|
-
|
|
64
|
-
() => __ΩRecord,
|
|
20
|
+
serialize.__type = [
|
|
65
21
|
"CommandTree",
|
|
66
|
-
"
|
|
67
|
-
() => __ΩRecord,
|
|
22
|
+
"command",
|
|
68
23
|
"SerializedCommandTree",
|
|
69
|
-
"
|
|
70
|
-
"P
|
|
24
|
+
"serialize",
|
|
25
|
+
"P\"w!2\"\"w#/$"
|
|
71
26
|
];
|
|
72
|
-
function
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (optionsType.kind === __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral) optionsReflection = (0, __powerlines_deepkit_vendor_type.resolveClassType)(optionsType);
|
|
81
|
-
}
|
|
82
|
-
const deserializedNode = {
|
|
83
|
-
...node,
|
|
84
|
-
options: optionsReflection ? Object.entries(node.options).reduce(__assignType((ret, [key, option]) => {
|
|
85
|
-
ret[key] = {
|
|
86
|
-
...option,
|
|
87
|
-
reflection: optionsReflection.getProperty(option.name)
|
|
88
|
-
};
|
|
89
|
-
return ret;
|
|
90
|
-
}, [
|
|
91
|
-
"ret",
|
|
92
|
-
"param1",
|
|
93
|
-
"",
|
|
94
|
-
"P\"2!\"2\"\"/#"
|
|
95
|
-
]), {}) : {},
|
|
96
|
-
arguments: node.arguments.map(__assignType((arg, i) => ({
|
|
97
|
-
...arg,
|
|
98
|
-
reflection: reflection.getParameters().length > i + 1 ? reflection.getParameters()[i + 1] : reflection.getParameterOrUndefined(arg.name)
|
|
99
|
-
}), [
|
|
100
|
-
"arg",
|
|
101
|
-
"i",
|
|
102
|
-
"",
|
|
103
|
-
"P\"2!\"2\"\"/#"
|
|
104
|
-
])),
|
|
105
|
-
parent,
|
|
106
|
-
children: {},
|
|
107
|
-
reflection
|
|
108
|
-
};
|
|
109
|
-
for (const [key, child] of Object.entries(node.children || {})) deserializedNode.children[key] = deserialize(child, deserializedNode);
|
|
110
|
-
return deserializedNode;
|
|
111
|
-
}, [
|
|
112
|
-
"SerializedCommandTree",
|
|
113
|
-
"node",
|
|
114
|
-
"CommandTree",
|
|
115
|
-
"parent",
|
|
116
|
-
() => null,
|
|
27
|
+
function deserialize(command, parent = null) {
|
|
28
|
+
const result = {
|
|
29
|
+
...command,
|
|
30
|
+
parent: parent ?? null,
|
|
31
|
+
children: {}
|
|
32
|
+
};
|
|
33
|
+
result.children = Object.fromEntries(Object.entries(command.children || {}).map(__assignType(([name, child]) => [name, deserialize(child, result)], [
|
|
34
|
+
"param0",
|
|
117
35
|
"",
|
|
118
|
-
"P\"
|
|
119
|
-
]);
|
|
120
|
-
const result = {};
|
|
121
|
-
for (const [key, child] of Object.entries(serializedCommands)) result[key] = deserialize(child, null);
|
|
36
|
+
"P\"2!\"/\""
|
|
37
|
+
])));
|
|
122
38
|
return result;
|
|
123
39
|
}
|
|
124
|
-
|
|
125
|
-
() => __ΩRecord,
|
|
40
|
+
deserialize.__type = [
|
|
126
41
|
"SerializedCommandTree",
|
|
127
|
-
"
|
|
128
|
-
() => __ΩRecord,
|
|
42
|
+
"command",
|
|
129
43
|
"CommandTree",
|
|
130
|
-
"
|
|
131
|
-
|
|
44
|
+
"parent",
|
|
45
|
+
() => null,
|
|
46
|
+
"deserialize",
|
|
47
|
+
"P\"w!2\"P\"w#,J2$>%\"w#/&"
|
|
132
48
|
];
|
|
49
|
+
/**
|
|
50
|
+
* Gets the file path for persisting CLI command reflections.
|
|
51
|
+
*
|
|
52
|
+
* @param context - The Shell Shock context.
|
|
53
|
+
* @returns The file path for persisting CLI command reflections.
|
|
54
|
+
*/
|
|
55
|
+
function getCommandsPersistencePath(context) {
|
|
56
|
+
return (0, __stryke_path_join_paths.joinPaths)(context.dataPath, "reflections", "commands.json");
|
|
57
|
+
}
|
|
58
|
+
getCommandsPersistencePath.__type = [
|
|
59
|
+
"Context",
|
|
60
|
+
"context",
|
|
61
|
+
"getCommandsPersistencePath",
|
|
62
|
+
"P\"w!2\"&/#"
|
|
63
|
+
];
|
|
64
|
+
/**
|
|
65
|
+
* Reads the persisted CLI command reflections from the file system and populates the context's commands.
|
|
66
|
+
*
|
|
67
|
+
* @param context - The Shell Shock context.
|
|
68
|
+
* @throws Will throw an error if the reflections file is empty or cannot be read.
|
|
69
|
+
*/
|
|
133
70
|
async function readCommandsPersistence(context) {
|
|
134
71
|
const reflections = await context.fs.read(getCommandsPersistencePath(context));
|
|
135
72
|
if (!reflections || !reflections.length) throw new Error(`CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`);
|
|
136
|
-
context.commands =
|
|
73
|
+
context.commands = Object.fromEntries(Object.entries(JSON.parse(reflections) ?? {}).map(__assignType(([name, command]) => [name, deserialize(command)], [
|
|
74
|
+
"param0",
|
|
75
|
+
"",
|
|
76
|
+
"P\"2!\"/\""
|
|
77
|
+
])));
|
|
137
78
|
}
|
|
138
79
|
readCommandsPersistence.__type = [
|
|
139
80
|
"Context",
|
|
@@ -141,9 +82,20 @@ readCommandsPersistence.__type = [
|
|
|
141
82
|
"readCommandsPersistence",
|
|
142
83
|
"P\"w!2\"\"/#"
|
|
143
84
|
];
|
|
85
|
+
/**
|
|
86
|
+
* Writes the current CLI command reflections from the context to the file system for persistence.
|
|
87
|
+
*
|
|
88
|
+
* @param context - The Shell Shock context.
|
|
89
|
+
* @returns A promise that resolves when the reflections have been successfully written to the file system.
|
|
90
|
+
* @throws Will throw an error if there is an issue writing the reflections to the file system.
|
|
91
|
+
*/
|
|
144
92
|
async function writeCommandsPersistence(context) {
|
|
145
93
|
const filePath = getCommandsPersistencePath(context);
|
|
146
|
-
await context.fs.write(filePath, JSON.stringify(
|
|
94
|
+
await context.fs.write(filePath, JSON.stringify(Object.fromEntries(Object.entries(context.commands).map(__assignType(([name, command]) => [name, serialize(command)], [
|
|
95
|
+
"param0",
|
|
96
|
+
"",
|
|
97
|
+
"P\"2!\"/\""
|
|
98
|
+
]))), null, context.config.mode === "production" ? 0 : 2));
|
|
147
99
|
}
|
|
148
100
|
writeCommandsPersistence.__type = [
|
|
149
101
|
"Context",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.cjs","names":[],"sources":["../../src/helpers/persistence.ts"],"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
|
|
1
|
+
{"version":3,"file":"persistence.cjs","names":[],"sources":["../../src/helpers/persistence.ts"],"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 { joinPaths } from \"@stryke/path/join-paths\";\nimport type { CommandTree, SerializedCommandTree } from \"../types\";\nimport type { Context } from \"../types/context\";\n\nfunction serialize(command: CommandTree): SerializedCommandTree {\n return {\n ...command,\n parent: command.parent?.name ? command.parent.name : null,\n children: Object.fromEntries(\n Object.entries(command.children || {}).map(([name, child]) => [\n name,\n serialize(child)\n ])\n )\n };\n}\n\nfunction deserialize(\n command: SerializedCommandTree,\n parent: CommandTree | null = null\n): CommandTree {\n const result: CommandTree = {\n ...command,\n parent: parent ?? null,\n children: {}\n };\n\n result.children = Object.fromEntries(\n Object.entries(command.children || {}).map(([name, child]) => [\n name,\n deserialize(child, result)\n ])\n );\n\n return result;\n}\n\n/**\n * Gets the file path for persisting CLI command reflections.\n *\n * @param context - The Shell Shock context.\n * @returns The file path for persisting CLI command reflections.\n */\nexport function getCommandsPersistencePath(context: Context): string {\n return joinPaths(context.dataPath, \"reflections\", \"commands.json\");\n}\n\n/**\n * Reads the persisted CLI command reflections from the file system and populates the context's commands.\n *\n * @param context - The Shell Shock context.\n * @throws Will throw an error if the reflections file is empty or cannot be read.\n */\nexport async function readCommandsPersistence(context: Context) {\n const reflections = await context.fs.read(\n getCommandsPersistencePath(context)\n );\n if (!reflections || !reflections.length) {\n throw new Error(\n `CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`\n );\n }\n\n context.commands = Object.fromEntries(\n Object.entries(\n (JSON.parse(reflections) ?? {}) as Record<string, SerializedCommandTree>\n ).map(([name, command]) => [name, deserialize(command)])\n );\n}\n\n/**\n * Writes the current CLI command reflections from the context to the file system for persistence.\n *\n * @param context - The Shell Shock context.\n * @returns A promise that resolves when the reflections have been successfully written to the file system.\n * @throws Will throw an error if there is an issue writing the reflections to the file system.\n */\nexport async function writeCommandsPersistence(context: Context) {\n const filePath = getCommandsPersistencePath(context);\n\n await context.fs.write(\n filePath,\n JSON.stringify(\n Object.fromEntries(\n Object.entries(context.commands).map(([name, command]) => [\n name,\n serialize(command)\n ])\n ),\n null,\n context.config.mode === \"production\" ? 0 : 2\n )\n );\n}\n"],"mappings":";;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AAoBX,SAAS,UAAU,SAAS;AACxB,QAAK;EACD,GAAG;EACH,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,OAAO,OAAO;EACrD,UAAU,OAAO,YAAO,OAAA,QAAA,QAAA,YAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,WAAA,CACpB,MACA,UAAA,MAAA,CACH,EAAE;GAAC;GAAU;GAAC;GAAA,CAAA,CAAA,CAAA;EAClB;;AAEL,UAAG,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACH,SAAA,YAAA,SAAA,SAAA,MAAA;;EAEQ,GAAG;EACH,QAAQ,UAAU;EAClB,UAAU,EAAC;EACd;AACD,QAAO,WAAW,OAAO,YAAC,OAAA,QAAA,QAAA,YAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,WAAA,CACtB,MACA,YAAY,OAAM,OAAA,CACrB,EAAE;EAAC;EAAO;EAAA;EAAA,CAAA,CAAA,CAAA;AACZ,QAAA;;AAEH,YAAY,SAAS;CAAC;CAAgB;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;;;;;;;AAOtC,SAAe,2BAAA,SAAA;AACf,gDAAA,QAAA,UAAA,eAAA,gBAAA;;AAEA,2BAAE,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOF,eAAsB,wBAAwB,SAAS;CACvD,MAAA,cAAA,MAAA,QAAA,GAAA,KAAA,2BAAA,QAAA,CAAA;yCAEE,OAAA,IAAA,MAAA,+BAAA,2BAAA,QAAA,CAAA,WAAA;AAED,SAAA,WAAA,OAAA,YAAA,OAAA,QAAA,KAAA,MAAA,YAAA,IAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,aAAA,CAAA,MAAA,YAAA,QAAA,CAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;;AAED,wBAAwB,SAAS;CAAC;CAAW;CAAW;CAAyB;CAAA;;;;;;;;AAQjF,eAAsB,yBAAyB,SAAS;CACpD,MAAC,WAAA,2BAAA,QAAA;AACH,OAAA,QAAA,GAAA,MAAA,UAAA,KAAA,UAAA,OAAA,YAAA,OAAA,QAAA,QAAA,SAAA,CAAA,IAAA,cAAA,CAAA,MAAA,aAAA,OAEM,UAAU,QAAQ,CACrB,EAAE;EAAC;EAAU;EAAA;EAAA,CAAA,CAAA,CAAA,EAAA,MAAA,QAAA,OAAA,SAAA,eAAA,IAAA,EAAA,CAAA;;AAElB,yBAAyB,SAAS;CAAC;CAAW;CAAW;CAAE;CAAA"}
|
|
@@ -1,138 +1,79 @@
|
|
|
1
1
|
import { joinPaths } from "@stryke/path/join-paths";
|
|
2
|
-
import { ReflectionFunction, ReflectionKind, deserializeType, resolveClassType, serializeType } from "@powerlines/deepkit/vendor/type";
|
|
3
|
-
import { omit } from "@stryke/helpers/omit";
|
|
4
2
|
|
|
5
3
|
//#region src/helpers/persistence.ts
|
|
6
|
-
const __ΩRecord = [
|
|
7
|
-
"K",
|
|
8
|
-
"T",
|
|
9
|
-
"Record",
|
|
10
|
-
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
11
|
-
];
|
|
12
4
|
function __assignType(fn, args) {
|
|
13
5
|
fn.__type = args;
|
|
14
6
|
return fn;
|
|
15
7
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
]
|
|
25
|
-
|
|
26
|
-
const serialize = __assignType((node, parent = null) => {
|
|
27
|
-
const serializedNode = {
|
|
28
|
-
...node,
|
|
29
|
-
options: Object.entries(node.options).reduce(__assignType((ret, [key, option]) => {
|
|
30
|
-
ret[key] = { ...omit(option, ["reflection"]) };
|
|
31
|
-
return ret;
|
|
32
|
-
}, [
|
|
33
|
-
"ret",
|
|
34
|
-
"param1",
|
|
35
|
-
"",
|
|
36
|
-
"P\"2!\"2\"\"/#"
|
|
37
|
-
]), {}),
|
|
38
|
-
arguments: node.arguments.map(__assignType((arg) => ({ ...omit(arg, ["reflection"]) }), [
|
|
39
|
-
"arg",
|
|
40
|
-
"",
|
|
41
|
-
"P\"2!\"/\""
|
|
42
|
-
])),
|
|
43
|
-
parent,
|
|
44
|
-
children: {},
|
|
45
|
-
reflection: node.reflection ? serializeType(node.reflection.type) : void 0
|
|
46
|
-
};
|
|
47
|
-
for (const [key, child] of Object.entries(node.children || {})) serializedNode.children[key] = serialize(child, node.id);
|
|
48
|
-
return serializedNode;
|
|
49
|
-
}, [
|
|
50
|
-
"CommandTree",
|
|
51
|
-
"node",
|
|
52
|
-
"parent",
|
|
53
|
-
() => null,
|
|
54
|
-
"SerializedCommandTree",
|
|
55
|
-
"",
|
|
56
|
-
"P\"w!2\"P&,J2#>$\"w%/&"
|
|
57
|
-
]);
|
|
58
|
-
const result = {};
|
|
59
|
-
for (const [key, child] of Object.entries(commands)) result[key] = serialize(child, null);
|
|
60
|
-
return result;
|
|
8
|
+
function serialize(command) {
|
|
9
|
+
return {
|
|
10
|
+
...command,
|
|
11
|
+
parent: command.parent?.name ? command.parent.name : null,
|
|
12
|
+
children: Object.fromEntries(Object.entries(command.children || {}).map(__assignType(([name, child]) => [name, serialize(child)], [
|
|
13
|
+
"param0",
|
|
14
|
+
"",
|
|
15
|
+
"P\"2!\"/\""
|
|
16
|
+
])))
|
|
17
|
+
};
|
|
61
18
|
}
|
|
62
|
-
|
|
63
|
-
() => __ΩRecord,
|
|
19
|
+
serialize.__type = [
|
|
64
20
|
"CommandTree",
|
|
65
|
-
"
|
|
66
|
-
() => __ΩRecord,
|
|
21
|
+
"command",
|
|
67
22
|
"SerializedCommandTree",
|
|
68
|
-
"
|
|
69
|
-
"P
|
|
23
|
+
"serialize",
|
|
24
|
+
"P\"w!2\"\"w#/$"
|
|
70
25
|
];
|
|
71
|
-
function
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (optionsType.kind === ReflectionKind.objectLiteral) optionsReflection = resolveClassType(optionsType);
|
|
80
|
-
}
|
|
81
|
-
const deserializedNode = {
|
|
82
|
-
...node,
|
|
83
|
-
options: optionsReflection ? Object.entries(node.options).reduce(__assignType((ret, [key, option]) => {
|
|
84
|
-
ret[key] = {
|
|
85
|
-
...option,
|
|
86
|
-
reflection: optionsReflection.getProperty(option.name)
|
|
87
|
-
};
|
|
88
|
-
return ret;
|
|
89
|
-
}, [
|
|
90
|
-
"ret",
|
|
91
|
-
"param1",
|
|
92
|
-
"",
|
|
93
|
-
"P\"2!\"2\"\"/#"
|
|
94
|
-
]), {}) : {},
|
|
95
|
-
arguments: node.arguments.map(__assignType((arg, i) => ({
|
|
96
|
-
...arg,
|
|
97
|
-
reflection: reflection.getParameters().length > i + 1 ? reflection.getParameters()[i + 1] : reflection.getParameterOrUndefined(arg.name)
|
|
98
|
-
}), [
|
|
99
|
-
"arg",
|
|
100
|
-
"i",
|
|
101
|
-
"",
|
|
102
|
-
"P\"2!\"2\"\"/#"
|
|
103
|
-
])),
|
|
104
|
-
parent,
|
|
105
|
-
children: {},
|
|
106
|
-
reflection
|
|
107
|
-
};
|
|
108
|
-
for (const [key, child] of Object.entries(node.children || {})) deserializedNode.children[key] = deserialize(child, deserializedNode);
|
|
109
|
-
return deserializedNode;
|
|
110
|
-
}, [
|
|
111
|
-
"SerializedCommandTree",
|
|
112
|
-
"node",
|
|
113
|
-
"CommandTree",
|
|
114
|
-
"parent",
|
|
115
|
-
() => null,
|
|
26
|
+
function deserialize(command, parent = null) {
|
|
27
|
+
const result = {
|
|
28
|
+
...command,
|
|
29
|
+
parent: parent ?? null,
|
|
30
|
+
children: {}
|
|
31
|
+
};
|
|
32
|
+
result.children = Object.fromEntries(Object.entries(command.children || {}).map(__assignType(([name, child]) => [name, deserialize(child, result)], [
|
|
33
|
+
"param0",
|
|
116
34
|
"",
|
|
117
|
-
"P\"
|
|
118
|
-
]);
|
|
119
|
-
const result = {};
|
|
120
|
-
for (const [key, child] of Object.entries(serializedCommands)) result[key] = deserialize(child, null);
|
|
35
|
+
"P\"2!\"/\""
|
|
36
|
+
])));
|
|
121
37
|
return result;
|
|
122
38
|
}
|
|
123
|
-
|
|
124
|
-
() => __ΩRecord,
|
|
39
|
+
deserialize.__type = [
|
|
125
40
|
"SerializedCommandTree",
|
|
126
|
-
"
|
|
127
|
-
() => __ΩRecord,
|
|
41
|
+
"command",
|
|
128
42
|
"CommandTree",
|
|
129
|
-
"
|
|
130
|
-
|
|
43
|
+
"parent",
|
|
44
|
+
() => null,
|
|
45
|
+
"deserialize",
|
|
46
|
+
"P\"w!2\"P\"w#,J2$>%\"w#/&"
|
|
131
47
|
];
|
|
48
|
+
/**
|
|
49
|
+
* Gets the file path for persisting CLI command reflections.
|
|
50
|
+
*
|
|
51
|
+
* @param context - The Shell Shock context.
|
|
52
|
+
* @returns The file path for persisting CLI command reflections.
|
|
53
|
+
*/
|
|
54
|
+
function getCommandsPersistencePath(context) {
|
|
55
|
+
return joinPaths(context.dataPath, "reflections", "commands.json");
|
|
56
|
+
}
|
|
57
|
+
getCommandsPersistencePath.__type = [
|
|
58
|
+
"Context",
|
|
59
|
+
"context",
|
|
60
|
+
"getCommandsPersistencePath",
|
|
61
|
+
"P\"w!2\"&/#"
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* Reads the persisted CLI command reflections from the file system and populates the context's commands.
|
|
65
|
+
*
|
|
66
|
+
* @param context - The Shell Shock context.
|
|
67
|
+
* @throws Will throw an error if the reflections file is empty or cannot be read.
|
|
68
|
+
*/
|
|
132
69
|
async function readCommandsPersistence(context) {
|
|
133
70
|
const reflections = await context.fs.read(getCommandsPersistencePath(context));
|
|
134
71
|
if (!reflections || !reflections.length) throw new Error(`CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`);
|
|
135
|
-
context.commands =
|
|
72
|
+
context.commands = Object.fromEntries(Object.entries(JSON.parse(reflections) ?? {}).map(__assignType(([name, command]) => [name, deserialize(command)], [
|
|
73
|
+
"param0",
|
|
74
|
+
"",
|
|
75
|
+
"P\"2!\"/\""
|
|
76
|
+
])));
|
|
136
77
|
}
|
|
137
78
|
readCommandsPersistence.__type = [
|
|
138
79
|
"Context",
|
|
@@ -140,9 +81,20 @@ readCommandsPersistence.__type = [
|
|
|
140
81
|
"readCommandsPersistence",
|
|
141
82
|
"P\"w!2\"\"/#"
|
|
142
83
|
];
|
|
84
|
+
/**
|
|
85
|
+
* Writes the current CLI command reflections from the context to the file system for persistence.
|
|
86
|
+
*
|
|
87
|
+
* @param context - The Shell Shock context.
|
|
88
|
+
* @returns A promise that resolves when the reflections have been successfully written to the file system.
|
|
89
|
+
* @throws Will throw an error if there is an issue writing the reflections to the file system.
|
|
90
|
+
*/
|
|
143
91
|
async function writeCommandsPersistence(context) {
|
|
144
92
|
const filePath = getCommandsPersistencePath(context);
|
|
145
|
-
await context.fs.write(filePath, JSON.stringify(
|
|
93
|
+
await context.fs.write(filePath, JSON.stringify(Object.fromEntries(Object.entries(context.commands).map(__assignType(([name, command]) => [name, serialize(command)], [
|
|
94
|
+
"param0",
|
|
95
|
+
"",
|
|
96
|
+
"P\"2!\"/\""
|
|
97
|
+
]))), null, context.config.mode === "production" ? 0 : 2));
|
|
146
98
|
}
|
|
147
99
|
writeCommandsPersistence.__type = [
|
|
148
100
|
"Context",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.ts"],"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
|
|
1
|
+
{"version":3,"file":"persistence.mjs","names":[],"sources":["../../src/helpers/persistence.ts"],"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 { joinPaths } from \"@stryke/path/join-paths\";\nimport type { CommandTree, SerializedCommandTree } from \"../types\";\nimport type { Context } from \"../types/context\";\n\nfunction serialize(command: CommandTree): SerializedCommandTree {\n return {\n ...command,\n parent: command.parent?.name ? command.parent.name : null,\n children: Object.fromEntries(\n Object.entries(command.children || {}).map(([name, child]) => [\n name,\n serialize(child)\n ])\n )\n };\n}\n\nfunction deserialize(\n command: SerializedCommandTree,\n parent: CommandTree | null = null\n): CommandTree {\n const result: CommandTree = {\n ...command,\n parent: parent ?? null,\n children: {}\n };\n\n result.children = Object.fromEntries(\n Object.entries(command.children || {}).map(([name, child]) => [\n name,\n deserialize(child, result)\n ])\n );\n\n return result;\n}\n\n/**\n * Gets the file path for persisting CLI command reflections.\n *\n * @param context - The Shell Shock context.\n * @returns The file path for persisting CLI command reflections.\n */\nexport function getCommandsPersistencePath(context: Context): string {\n return joinPaths(context.dataPath, \"reflections\", \"commands.json\");\n}\n\n/**\n * Reads the persisted CLI command reflections from the file system and populates the context's commands.\n *\n * @param context - The Shell Shock context.\n * @throws Will throw an error if the reflections file is empty or cannot be read.\n */\nexport async function readCommandsPersistence(context: Context) {\n const reflections = await context.fs.read(\n getCommandsPersistencePath(context)\n );\n if (!reflections || !reflections.length) {\n throw new Error(\n `CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`\n );\n }\n\n context.commands = Object.fromEntries(\n Object.entries(\n (JSON.parse(reflections) ?? {}) as Record<string, SerializedCommandTree>\n ).map(([name, command]) => [name, deserialize(command)])\n );\n}\n\n/**\n * Writes the current CLI command reflections from the context to the file system for persistence.\n *\n * @param context - The Shell Shock context.\n * @returns A promise that resolves when the reflections have been successfully written to the file system.\n * @throws Will throw an error if there is an issue writing the reflections to the file system.\n */\nexport async function writeCommandsPersistence(context: Context) {\n const filePath = getCommandsPersistencePath(context);\n\n await context.fs.write(\n filePath,\n JSON.stringify(\n Object.fromEntries(\n Object.entries(context.commands).map(([name, command]) => [\n name,\n serialize(command)\n ])\n ),\n null,\n context.config.mode === \"production\" ? 0 : 2\n )\n );\n}\n"],"mappings":";;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AAoBX,SAAS,UAAU,SAAS;AACxB,QAAK;EACD,GAAG;EACH,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,OAAO,OAAO;EACrD,UAAU,OAAO,YAAO,OAAA,QAAA,QAAA,YAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,WAAA,CACpB,MACA,UAAA,MAAA,CACH,EAAE;GAAC;GAAU;GAAC;GAAA,CAAA,CAAA,CAAA;EAClB;;AAEL,UAAG,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACH,SAAA,YAAA,SAAA,SAAA,MAAA;;EAEQ,GAAG;EACH,QAAQ,UAAU;EAClB,UAAU,EAAC;EACd;AACD,QAAO,WAAW,OAAO,YAAC,OAAA,QAAA,QAAA,YAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,WAAA,CACtB,MACA,YAAY,OAAM,OAAA,CACrB,EAAE;EAAC;EAAO;EAAA;EAAA,CAAA,CAAA,CAAA;AACZ,QAAA;;AAEH,YAAY,SAAS;CAAC;CAAgB;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;;;;;;;AAOtC,SAAe,2BAAA,SAAA;AACf,QAAA,UAAA,QAAA,UAAA,eAAA,gBAAA;;AAEA,2BAAE,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOF,eAAsB,wBAAwB,SAAS;CACvD,MAAA,cAAA,MAAA,QAAA,GAAA,KAAA,2BAAA,QAAA,CAAA;yCAEE,OAAA,IAAA,MAAA,+BAAA,2BAAA,QAAA,CAAA,WAAA;AAED,SAAA,WAAA,OAAA,YAAA,OAAA,QAAA,KAAA,MAAA,YAAA,IAAA,EAAA,CAAA,CAAA,IAAA,cAAA,CAAA,MAAA,aAAA,CAAA,MAAA,YAAA,QAAA,CAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;;AAED,wBAAwB,SAAS;CAAC;CAAW;CAAW;CAAyB;CAAA;;;;;;;;AAQjF,eAAsB,yBAAyB,SAAS;CACpD,MAAC,WAAA,2BAAA,QAAA;AACH,OAAA,QAAA,GAAA,MAAA,UAAA,KAAA,UAAA,OAAA,YAAA,OAAA,QAAA,QAAA,SAAA,CAAA,IAAA,cAAA,CAAA,MAAA,aAAA,OAEM,UAAU,QAAQ,CACrB,EAAE;EAAC;EAAU;EAAA;EAAA,CAAA,CAAA,CAAA,EAAA,MAAA,QAAA,OAAA,SAAA,eAAA,IAAA,EAAA,CAAA;;AAElB,yBAAyB,SAAS;CAAC;CAAW;CAAW;CAAE;CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const
|
|
2
|
+
const require_context_helpers = require('../plugin-utils/context-helpers.cjs');
|
|
3
3
|
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
4
4
|
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
5
5
|
let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
@@ -21,7 +21,7 @@ formatBinaryPath.__type = [
|
|
|
21
21
|
"PP&&F-J2!&/\""
|
|
22
22
|
];
|
|
23
23
|
async function updatePackageJsonBinary(context) {
|
|
24
|
-
const packageJsonPath = (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.
|
|
24
|
+
const packageJsonPath = (0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.root, "package.json");
|
|
25
25
|
if (context.config.bin && Array.isArray(context.config.bin) && context.config.bin.length > 0) {
|
|
26
26
|
context.packageJson.bin = Object.fromEntries((0, __stryke_helpers_get_unique.getUnique)((0, __stryke_convert_to_array.toArray)(context.config.bin)).map(__assignType((bin) => [bin, formatBinaryPath(context.config.output.format)], [
|
|
27
27
|
"bin",
|
|
@@ -31,9 +31,9 @@ async function updatePackageJsonBinary(context) {
|
|
|
31
31
|
await context.fs.write(packageJsonPath, __stryke_json_storm_json.StormJSON.stringify(context.packageJson));
|
|
32
32
|
} else {
|
|
33
33
|
if (Array.isArray(context.config.output.format) && context.config.output.format.length > 1) {
|
|
34
|
-
context.packageJson.bin = { [(0, __stryke_string_format_kebab_case.kebabCase)(
|
|
34
|
+
context.packageJson.bin = { [(0, __stryke_string_format_kebab_case.kebabCase)(require_context_helpers.getAppName(context))]: formatBinaryPath((0, __stryke_convert_to_array.toArray)(context.config.output.format)[0]) };
|
|
35
35
|
context.packageJson.bin = (0, __stryke_convert_to_array.toArray)(context.config.output.format).reduce(__assignType((ret, format) => {
|
|
36
|
-
ret[`${(0, __stryke_string_format_kebab_case.kebabCase)(
|
|
36
|
+
ret[`${(0, __stryke_string_format_kebab_case.kebabCase)(require_context_helpers.getAppName(context))}-${format}`] = formatBinaryPath(format);
|
|
37
37
|
return ret;
|
|
38
38
|
}, [
|
|
39
39
|
"ret",
|
|
@@ -41,7 +41,7 @@ async function updatePackageJsonBinary(context) {
|
|
|
41
41
|
"",
|
|
42
42
|
"P\"2!\"2\"\"/#"
|
|
43
43
|
]), context.packageJson.bin);
|
|
44
|
-
} else context.packageJson.bin = { [(0, __stryke_string_format_kebab_case.kebabCase)(
|
|
44
|
+
} else context.packageJson.bin = { [(0, __stryke_string_format_kebab_case.kebabCase)(require_context_helpers.getAppName(context))]: formatBinaryPath(context.config.output.format) };
|
|
45
45
|
await context.fs.write(packageJsonPath, __stryke_json_storm_json.StormJSON.stringify(context.packageJson));
|
|
46
46
|
}
|
|
47
47
|
if (!(0, __stryke_type_checks_is_set_object.isSetObject)(context.packageJson.bin)) throw new Error("Unable to determine the CLI binary name. Please specify the `bin` option in your Shell Shock configuration or ensure that the `name` field is set in your package.json.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-package-json.cjs","names":[],"sources":["../../src/helpers/update-package-json.ts"],"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 { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getAppName } from \"../plugin-utils/context-helpers\";\nimport type { UnresolvedContext } from \"../types/context\";\n\nexport function formatBinaryPath(\n format: string | string[] | undefined\n): string {\n return `./dist/bin.${\n format === \"cjs\" || (Array.isArray(format) && format.includes(\"cjs\"))\n ? \"cjs\"\n : \"mjs\"\n }`;\n}\n\nexport async function updatePackageJsonBinary(\n context: UnresolvedContext\n): Promise<void> {\n const packageJsonPath = joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.
|
|
1
|
+
{"version":3,"file":"update-package-json.cjs","names":[],"sources":["../../src/helpers/update-package-json.ts"],"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 { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getAppName } from \"../plugin-utils/context-helpers\";\nimport type { UnresolvedContext } from \"../types/context\";\n\nexport function formatBinaryPath(\n format: string | string[] | undefined\n): string {\n return `./dist/bin.${\n format === \"cjs\" || (Array.isArray(format) && format.includes(\"cjs\"))\n ? \"cjs\"\n : \"mjs\"\n }`;\n}\n\nexport async function updatePackageJsonBinary(\n context: UnresolvedContext\n): Promise<void> {\n const packageJsonPath = joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n \"package.json\"\n );\n if (\n context.config.bin &&\n Array.isArray(context.config.bin) &&\n context.config.bin.length > 0\n ) {\n context.packageJson.bin = Object.fromEntries(\n getUnique(toArray(context.config.bin)).map(bin => [\n bin,\n formatBinaryPath(context.config.output.format)\n ])\n );\n\n await context.fs.write(\n packageJsonPath,\n StormJSON.stringify(context.packageJson)\n );\n } else {\n if (\n Array.isArray(context.config.output.format) &&\n context.config.output.format.length > 1\n ) {\n context.packageJson.bin = {\n [kebabCase(getAppName(context))]: formatBinaryPath(\n toArray(context.config.output.format)[0]\n )\n };\n context.packageJson.bin = toArray(context.config.output.format).reduce(\n (ret, format) => {\n ret[`${kebabCase(getAppName(context))}-${format}`] =\n formatBinaryPath(format);\n\n return ret;\n },\n context.packageJson.bin\n );\n } else {\n context.packageJson.bin = {\n [kebabCase(getAppName(context))]: formatBinaryPath(\n context.config.output.format\n )\n };\n }\n\n await context.fs.write(\n packageJsonPath,\n StormJSON.stringify(context.packageJson)\n );\n }\n\n if (!isSetObject(context.packageJson.bin)) {\n throw new Error(\n \"Unable to determine the CLI binary name. Please specify the `bin` option in your Shell Shock configuration or ensure that the `name` field is set in your package.json.\"\n );\n }\n\n context.config.bin = Object.keys(context.packageJson.bin);\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA0BX,SAAgB,iBAAiB,QAAK;AAClC,QAAM,cAAA,WAAA,SAAA,MAAA,QAAA,OAAA,IAAA,OAAA,SAAA,MAAA,GACA,QACA;;AAEV,iBAAY,SAAA;CAAA;CAAA;CAAA;CAAA;AACZ,eAAI,wBAAA,SAAA;CACJ,MAAA,0DAAA,QAAA,gBAAA,eAAA,QAAA,OAAA,MAAA,eAAA;2BAEQ,MAAM,QAAQ,QAAQ,OAAO,IAAI,IACjC,QAAQ,OAAO,IAAI,SAAA,GAAA;AACnB,UAAQ,YAAC,MAAA,OAAA,8FAAA,QAAA,OAAA,IAAA,CAAA,CAAA,IAAA,cAAA,QAAA,CACL,KACA,iBAAiB,QAAQ,OAAI,OAAA,OAAA,CAChC,EAAE;GAAC;GAAO;GAAI;GAAA,CAAA,CAAA,CAAA;AACf,QAAM,QAAG,GAAA,MAAA,iBAAA,mCAAA,UAAA,QAAA,YAAA,CAAA;QAEZ;AACG,MAAI,MAAM,QAAM,QAAA,OAAA,OAAA,OAAA,IACZ,QAAQ,OAAO,OAAO,OAAK,SAAA,GAAA;AAC3B,WAAQ,YAAY,MAAA,oDAC5B,mCAAA,QAAA,CAAA,GAAA,wDAAA,QAAA,OAAA,OAAA,OAAA,CAAA,GAAA,EACS;AACD,WAAQ,YAAY,6CAAc,QAAQ,OAAE,OAAA,OAAA,CAAA,OAAA,cAAA,KAAA,WAAA;AAC7C,QAAA,oDAAA,mCAAA,QAAA,CAAA,CAAA,GAAA,YACS,iBAAiB,OAAO;AACrC,WAAA;MACF;IAAA;IAAA;IAAA;IAAA;IAAA,CAAA,EAAA,QAAA,YAAA,IAAA;QAGO,SAAQ,YAAC,MAAA,oDACM,mCAAW,QAAO,CAAA,GAAA,iBAAA,QAAA,OAAA,OAAA,OAAA,EACxC;AAEE,QAAA,QAAA,GAAA,MAAA,iBAAA,mCAAA,UAAA,QAAA,YAAA,CAAA;;AAEH,KAAI,qDAAa,QAAQ,YAAY,IAAG,CACtC,OAAA,IAAA,MAAA,0KAAA;AAEF,SAAQ,OAAO,MAAM,OAAO,KAAK,QAAQ,YAAY,IAAC;;AAE1D,wBAAQ,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
|
@@ -20,7 +20,7 @@ formatBinaryPath.__type = [
|
|
|
20
20
|
"PP&&F-J2!&/\""
|
|
21
21
|
];
|
|
22
22
|
async function updatePackageJsonBinary(context) {
|
|
23
|
-
const packageJsonPath = joinPaths(context.workspaceConfig.workspaceRoot, context.config.
|
|
23
|
+
const packageJsonPath = joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, "package.json");
|
|
24
24
|
if (context.config.bin && Array.isArray(context.config.bin) && context.config.bin.length > 0) {
|
|
25
25
|
context.packageJson.bin = Object.fromEntries(getUnique(toArray(context.config.bin)).map(__assignType((bin) => [bin, formatBinaryPath(context.config.output.format)], [
|
|
26
26
|
"bin",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-package-json.mjs","names":[],"sources":["../../src/helpers/update-package-json.ts"],"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 { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getAppName } from \"../plugin-utils/context-helpers\";\nimport type { UnresolvedContext } from \"../types/context\";\n\nexport function formatBinaryPath(\n format: string | string[] | undefined\n): string {\n return `./dist/bin.${\n format === \"cjs\" || (Array.isArray(format) && format.includes(\"cjs\"))\n ? \"cjs\"\n : \"mjs\"\n }`;\n}\n\nexport async function updatePackageJsonBinary(\n context: UnresolvedContext\n): Promise<void> {\n const packageJsonPath = joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.
|
|
1
|
+
{"version":3,"file":"update-package-json.mjs","names":[],"sources":["../../src/helpers/update-package-json.ts"],"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 { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { StormJSON } from \"@stryke/json/storm-json\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getAppName } from \"../plugin-utils/context-helpers\";\nimport type { UnresolvedContext } from \"../types/context\";\n\nexport function formatBinaryPath(\n format: string | string[] | undefined\n): string {\n return `./dist/bin.${\n format === \"cjs\" || (Array.isArray(format) && format.includes(\"cjs\"))\n ? \"cjs\"\n : \"mjs\"\n }`;\n}\n\nexport async function updatePackageJsonBinary(\n context: UnresolvedContext\n): Promise<void> {\n const packageJsonPath = joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n \"package.json\"\n );\n if (\n context.config.bin &&\n Array.isArray(context.config.bin) &&\n context.config.bin.length > 0\n ) {\n context.packageJson.bin = Object.fromEntries(\n getUnique(toArray(context.config.bin)).map(bin => [\n bin,\n formatBinaryPath(context.config.output.format)\n ])\n );\n\n await context.fs.write(\n packageJsonPath,\n StormJSON.stringify(context.packageJson)\n );\n } else {\n if (\n Array.isArray(context.config.output.format) &&\n context.config.output.format.length > 1\n ) {\n context.packageJson.bin = {\n [kebabCase(getAppName(context))]: formatBinaryPath(\n toArray(context.config.output.format)[0]\n )\n };\n context.packageJson.bin = toArray(context.config.output.format).reduce(\n (ret, format) => {\n ret[`${kebabCase(getAppName(context))}-${format}`] =\n formatBinaryPath(format);\n\n return ret;\n },\n context.packageJson.bin\n );\n } else {\n context.packageJson.bin = {\n [kebabCase(getAppName(context))]: formatBinaryPath(\n context.config.output.format\n )\n };\n }\n\n await context.fs.write(\n packageJsonPath,\n StormJSON.stringify(context.packageJson)\n );\n }\n\n if (!isSetObject(context.packageJson.bin)) {\n throw new Error(\n \"Unable to determine the CLI binary name. Please specify the `bin` option in your Shell Shock configuration or ensure that the `name` field is set in your package.json.\"\n );\n }\n\n context.config.bin = Object.keys(context.packageJson.bin);\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA0BX,SAAgB,iBAAiB,QAAK;AAClC,QAAM,cAAA,WAAA,SAAA,MAAA,QAAA,OAAA,IAAA,OAAA,SAAA,MAAA,GACA,QACA;;AAEV,iBAAY,SAAA;CAAA;CAAA;CAAA;CAAA;AACZ,eAAI,wBAAA,SAAA;CACJ,MAAA,kBAAA,UAAA,QAAA,gBAAA,eAAA,QAAA,OAAA,MAAA,eAAA;2BAEQ,MAAM,QAAQ,QAAQ,OAAO,IAAI,IACjC,QAAQ,OAAO,IAAI,SAAA,GAAA;AACnB,UAAQ,YAAC,MAAA,OAAA,YAAA,UAAA,QAAA,QAAA,OAAA,IAAA,CAAA,CAAA,IAAA,cAAA,QAAA,CACL,KACA,iBAAiB,QAAQ,OAAI,OAAA,OAAA,CAChC,EAAE;GAAC;GAAO;GAAI;GAAA,CAAA,CAAA,CAAA;AACf,QAAM,QAAG,GAAA,MAAA,iBAAA,UAAA,UAAA,QAAA,YAAA,CAAA;QAEZ;AACG,MAAI,MAAM,QAAM,QAAA,OAAA,OAAA,OAAA,IACZ,QAAQ,OAAO,OAAO,OAAK,SAAA,GAAA;AAC3B,WAAQ,YAAY,MAAA,GAC5B,UAAA,WAAA,QAAA,CAAA,GAAA,iBAAA,QAAA,QAAA,OAAA,OAAA,OAAA,CAAA,GAAA,EACS;AACD,WAAQ,YAAY,MAAM,QAAQ,QAAQ,OAAE,OAAA,OAAA,CAAA,OAAA,cAAA,KAAA,WAAA;AAC7C,QAAA,GAAA,UAAA,WAAA,QAAA,CAAA,CAAA,GAAA,YACS,iBAAiB,OAAO;AACrC,WAAA;MACF;IAAA;IAAA;IAAA;IAAA;IAAA,CAAA,EAAA,QAAA,YAAA,IAAA;QAGO,SAAQ,YAAC,MAAA,GACJ,UAAU,WAAW,QAAO,CAAA,GAAA,iBAAA,QAAA,OAAA,OAAA,OAAA,EACxC;AAEE,QAAA,QAAA,GAAA,MAAA,iBAAA,UAAA,UAAA,QAAA,YAAA,CAAA;;AAEH,KAAI,CAAC,YAAY,QAAQ,YAAY,IAAG,CACtC,OAAA,IAAA,MAAA,0KAAA;AAEF,SAAQ,OAAO,MAAM,OAAO,KAAK,QAAQ,YAAY,IAAC;;AAE1D,wBAAQ,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|