silgi 0.19.28 → 0.19.30
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/_chunks/index.mjs +1 -1
- package/dist/cli/common.mjs +17 -5
- package/dist/cli/prepare.mjs +71 -29
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +8 -7
- package/dist/types/index.d.ts +8 -7
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/common.mjs
CHANGED
|
@@ -157,13 +157,21 @@ async function h3Framework(silgi, skip = false) {
|
|
|
157
157
|
silgi.hook("prepare:schema.ts", (data) => {
|
|
158
158
|
data.importItems.nitropack = {
|
|
159
159
|
import: [
|
|
160
|
-
{
|
|
160
|
+
{
|
|
161
|
+
name: "NitroApp",
|
|
162
|
+
type: true,
|
|
163
|
+
key: "NitroApp"
|
|
164
|
+
}
|
|
161
165
|
],
|
|
162
166
|
from: "nitropack/types"
|
|
163
167
|
};
|
|
164
168
|
data.importItems.h3 = {
|
|
165
169
|
import: [
|
|
166
|
-
{
|
|
170
|
+
{
|
|
171
|
+
name: "H3Event",
|
|
172
|
+
type: true,
|
|
173
|
+
key: "H3Event"
|
|
174
|
+
}
|
|
167
175
|
],
|
|
168
176
|
from: "h3"
|
|
169
177
|
};
|
|
@@ -177,7 +185,11 @@ async function h3Framework(silgi, skip = false) {
|
|
|
177
185
|
silgi.hook("prepare:createDTSFramework", (data) => {
|
|
178
186
|
data.importItems["silgi/types"] = {
|
|
179
187
|
import: [
|
|
180
|
-
{
|
|
188
|
+
{
|
|
189
|
+
name: "SilgiRuntimeContext",
|
|
190
|
+
type: true,
|
|
191
|
+
key: "SilgiRuntimeContext"
|
|
192
|
+
}
|
|
181
193
|
],
|
|
182
194
|
from: "silgi/types"
|
|
183
195
|
};
|
|
@@ -724,8 +736,8 @@ async function commands(silgi) {
|
|
|
724
736
|
write: true,
|
|
725
737
|
getContents: () => JSON.stringify(commands2, null, 2)
|
|
726
738
|
});
|
|
739
|
+
silgi.commands = commands2;
|
|
727
740
|
silgi.hook("prepare:schema.ts", async (object) => {
|
|
728
|
-
console.log("prepare:schema.ts");
|
|
729
741
|
const allTags = Object.values(commands2).reduce((acc, commandGroup) => {
|
|
730
742
|
Object.values(commandGroup).forEach((command) => {
|
|
731
743
|
if (command.tags) {
|
|
@@ -1586,7 +1598,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1586
1598
|
options,
|
|
1587
1599
|
hooks,
|
|
1588
1600
|
errors: [],
|
|
1589
|
-
|
|
1601
|
+
commands: {},
|
|
1590
1602
|
_requiredModules: {},
|
|
1591
1603
|
logger: consola.withTag("silgi"),
|
|
1592
1604
|
close: () => silgi.hooks.callHook("close", silgi),
|
package/dist/cli/prepare.mjs
CHANGED
|
@@ -122,14 +122,18 @@ const run = defineCommand({
|
|
|
122
122
|
const data = args.active ? await runCommand(prepare, {
|
|
123
123
|
rawArgs: ["--commands", "run"]
|
|
124
124
|
}) : void 0;
|
|
125
|
-
if (data?.result?.silgi) {
|
|
126
|
-
|
|
125
|
+
if (!data?.result?.silgi) {
|
|
126
|
+
consola.error("Silgi not found");
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const silgi = data.result.silgi;
|
|
130
|
+
if (silgi) {
|
|
127
131
|
if (silgiCLICtx.tryUse()) {
|
|
128
132
|
silgiCLICtx.unset();
|
|
129
|
-
silgiCLICtx.set(
|
|
133
|
+
silgiCLICtx.set(silgi);
|
|
130
134
|
} else {
|
|
131
|
-
silgiCLICtx.set(
|
|
132
|
-
|
|
135
|
+
silgiCLICtx.set(silgi);
|
|
136
|
+
silgi.hook("close", () => silgiCLICtx.unset());
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
139
|
const tags = args.tag?.split(",").map((t) => t.trim());
|
|
@@ -162,34 +166,72 @@ const run = defineCommand({
|
|
|
162
166
|
consola.warn("No commands found in cli.json");
|
|
163
167
|
return;
|
|
164
168
|
}
|
|
169
|
+
const allTags = Object.values(silgi.commands).reduce((acc, commandGroup) => {
|
|
170
|
+
Object.values(commandGroup).forEach((command) => {
|
|
171
|
+
if (command.tags) {
|
|
172
|
+
command.tags.forEach((tag) => acc.add(tag));
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
return acc;
|
|
176
|
+
}, /* @__PURE__ */ new Set());
|
|
165
177
|
const commandName = await p.select({
|
|
166
178
|
message: "Select a command to run",
|
|
167
|
-
options:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
179
|
+
options: [
|
|
180
|
+
...allTags.size ? [{
|
|
181
|
+
value: "command-tags",
|
|
182
|
+
label: "Command Tags",
|
|
183
|
+
hint: "It executes all commands that are related to the tags you select."
|
|
184
|
+
}] : [],
|
|
185
|
+
...Object.keys(cliJson).filter((key) => {
|
|
186
|
+
const scripts = cliJson[key];
|
|
187
|
+
const scriptValues = Object.values(scripts);
|
|
188
|
+
return scriptValues;
|
|
189
|
+
}).map((key) => ({
|
|
190
|
+
label: key,
|
|
191
|
+
value: key
|
|
192
|
+
}))
|
|
193
|
+
]
|
|
175
194
|
});
|
|
176
195
|
if (!commandName)
|
|
177
196
|
return;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
197
|
+
if (commandName === "command-tags") {
|
|
198
|
+
const tags2 = Array.from(allTags);
|
|
199
|
+
const selectedTags = await p.select({
|
|
200
|
+
message: "Select tags to run",
|
|
201
|
+
options: tags2.map((tag) => ({
|
|
202
|
+
label: tag,
|
|
203
|
+
value: tag
|
|
204
|
+
}))
|
|
205
|
+
});
|
|
206
|
+
if (!selectedTags)
|
|
207
|
+
return;
|
|
208
|
+
selectedCommands = Object.keys(cliJson).map(
|
|
209
|
+
(commandName2) => {
|
|
210
|
+
const scripts = cliJson[commandName2];
|
|
211
|
+
return Object.keys(scripts).map((scriptName) => ({
|
|
212
|
+
command: commandName2,
|
|
213
|
+
script: scriptName,
|
|
214
|
+
handler: scripts[scriptName]
|
|
215
|
+
})).filter((script) => script.handler.tags?.includes(selectedTags));
|
|
216
|
+
}
|
|
217
|
+
).flat();
|
|
218
|
+
} else {
|
|
219
|
+
const scripts = cliJson[commandName];
|
|
220
|
+
const scriptName = await p.select({
|
|
221
|
+
message: "Select a script to run",
|
|
222
|
+
options: Object.keys(scripts).filter((key) => !scripts[key].tags?.length).map((key) => ({
|
|
223
|
+
label: key,
|
|
224
|
+
value: key
|
|
225
|
+
}))
|
|
226
|
+
});
|
|
227
|
+
if (!scriptName)
|
|
228
|
+
return;
|
|
229
|
+
selectedCommands = [{
|
|
230
|
+
command: commandName,
|
|
231
|
+
script: scriptName,
|
|
232
|
+
handler: scripts[scriptName]
|
|
233
|
+
}];
|
|
234
|
+
}
|
|
193
235
|
}
|
|
194
236
|
for (const cmd of selectedCommands) {
|
|
195
237
|
consola.info(`Running ${cmd.command}:${cmd.script}...`);
|
|
@@ -204,7 +246,7 @@ const run = defineCommand({
|
|
|
204
246
|
alias: silgiConfig.alias
|
|
205
247
|
});
|
|
206
248
|
let cleanHandler = cmd.handler.handler.replace(/\n/g, "");
|
|
207
|
-
global.__silgi_temp_obj =
|
|
249
|
+
global.__silgi_temp_obj = silgi;
|
|
208
250
|
cleanHandler = `import { silgiCLICtx } from 'silgi/core'
|
|
209
251
|
|
|
210
252
|
// Access from global scope
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -76,6 +76,13 @@ interface SilgiCLI {
|
|
|
76
76
|
}>;
|
|
77
77
|
options: SilgiCLIOptions;
|
|
78
78
|
_requiredModules: Record<string, boolean>;
|
|
79
|
+
commands: Record<string, Record<string, {
|
|
80
|
+
type: 'function' | 'command';
|
|
81
|
+
handler: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
tags?: (keyof SilgiCommands)[];
|
|
84
|
+
enabled?: boolean;
|
|
85
|
+
}>>;
|
|
79
86
|
}
|
|
80
87
|
type SilgiCLIDynamicConfig = Pick<SilgiCLIConfig, 'routeRules'>;
|
|
81
88
|
interface SilgiFrameworkInfo {
|
|
@@ -277,13 +284,7 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
277
284
|
*/
|
|
278
285
|
'app:templatesGenerated': (app: SilgiCLI, templates: ResolvedSilgiTemplate[], options?: GenerateAppOptions) => HookResult;
|
|
279
286
|
'scanFiles:done': (app: SilgiCLI) => HookResult;
|
|
280
|
-
'prepare:commands': (commands:
|
|
281
|
-
type: 'function' | 'command';
|
|
282
|
-
handler: string;
|
|
283
|
-
description?: string;
|
|
284
|
-
tags?: keyof SilgiCommands[];
|
|
285
|
-
enabled?: boolean;
|
|
286
|
-
}>>) => HookResult;
|
|
287
|
+
'prepare:commands': (commands: SilgiCLI['commands']) => HookResult;
|
|
287
288
|
'prepare:installPackages': (packages: Record<'dependencies' | 'devDependencies', Record<string, string>>) => HookResult;
|
|
288
289
|
}
|
|
289
290
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -76,6 +76,13 @@ interface SilgiCLI {
|
|
|
76
76
|
}>;
|
|
77
77
|
options: SilgiCLIOptions;
|
|
78
78
|
_requiredModules: Record<string, boolean>;
|
|
79
|
+
commands: Record<string, Record<string, {
|
|
80
|
+
type: 'function' | 'command';
|
|
81
|
+
handler: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
tags?: (keyof SilgiCommands)[];
|
|
84
|
+
enabled?: boolean;
|
|
85
|
+
}>>;
|
|
79
86
|
}
|
|
80
87
|
type SilgiCLIDynamicConfig = Pick<SilgiCLIConfig, 'routeRules'>;
|
|
81
88
|
interface SilgiFrameworkInfo {
|
|
@@ -277,13 +284,7 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
277
284
|
*/
|
|
278
285
|
'app:templatesGenerated': (app: SilgiCLI, templates: ResolvedSilgiTemplate[], options?: GenerateAppOptions) => HookResult;
|
|
279
286
|
'scanFiles:done': (app: SilgiCLI) => HookResult;
|
|
280
|
-
'prepare:commands': (commands:
|
|
281
|
-
type: 'function' | 'command';
|
|
282
|
-
handler: string;
|
|
283
|
-
description?: string;
|
|
284
|
-
tags?: keyof SilgiCommands[];
|
|
285
|
-
enabled?: boolean;
|
|
286
|
-
}>>) => HookResult;
|
|
287
|
+
'prepare:commands': (commands: SilgiCLI['commands']) => HookResult;
|
|
287
288
|
'prepare:installPackages': (packages: Record<'dependencies' | 'devDependencies', Record<string, string>>) => HookResult;
|
|
288
289
|
}
|
|
289
290
|
|