silgi 0.8.46 → 0.8.47
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/run.mjs +61 -29
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/run.mjs
CHANGED
|
@@ -104,9 +104,13 @@ const run = defineCommand({
|
|
|
104
104
|
preset: {
|
|
105
105
|
type: "string",
|
|
106
106
|
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
107
|
+
},
|
|
108
|
+
tag: {
|
|
109
|
+
type: "string"
|
|
107
110
|
}
|
|
108
111
|
},
|
|
109
|
-
async run() {
|
|
112
|
+
async run({ args }) {
|
|
113
|
+
const tags = args.tag?.split(",").map((t) => t.trim());
|
|
110
114
|
p.intro(color.bold(`Silgi CLI ${color.green(`v${version}`)}`));
|
|
111
115
|
const silgiConfig = await loadOptions({});
|
|
112
116
|
const getCli = resolve(silgiConfig.build.dir, "cli.json");
|
|
@@ -145,36 +149,64 @@ const run = defineCommand({
|
|
|
145
149
|
fileName: environment === "prod" ? ".env" : `.env.${environment}`
|
|
146
150
|
});
|
|
147
151
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
152
|
+
let selectedCommands = [];
|
|
153
|
+
if (tags) {
|
|
154
|
+
for (const commandName of Object.keys(cliJson)) {
|
|
155
|
+
const scripts = cliJson[commandName];
|
|
156
|
+
for (const scriptName of Object.keys(scripts)) {
|
|
157
|
+
const script = scripts[scriptName];
|
|
158
|
+
if (script.tags && script.tags.some((tag) => tags.includes(tag))) {
|
|
159
|
+
selectedCommands.push({
|
|
160
|
+
command: commandName,
|
|
161
|
+
script: scriptName,
|
|
162
|
+
handler: script
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (selectedCommands.length === 0) {
|
|
168
|
+
consola.warn(`No commands found with tags: ${tags.join(", ")}`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
const commandName = await p.select({
|
|
173
|
+
message: "Select a command to run",
|
|
174
|
+
options: Object.keys(cliJson).map((key) => ({
|
|
175
|
+
label: key,
|
|
176
|
+
value: key
|
|
177
|
+
}))
|
|
170
178
|
});
|
|
171
|
-
const
|
|
172
|
-
await
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
const scripts = cliJson[commandName];
|
|
180
|
+
const scriptName = await p.select({
|
|
181
|
+
message: "Select a script to run",
|
|
182
|
+
options: Object.keys(scripts).map((key) => ({
|
|
183
|
+
label: key,
|
|
184
|
+
value: key
|
|
185
|
+
}))
|
|
177
186
|
});
|
|
187
|
+
selectedCommands = [{
|
|
188
|
+
command: commandName,
|
|
189
|
+
script: scriptName,
|
|
190
|
+
handler: scripts[scriptName]
|
|
191
|
+
}];
|
|
192
|
+
}
|
|
193
|
+
for (const cmd of selectedCommands) {
|
|
194
|
+
consola.info(`Running ${cmd.command}:${cmd.script}...`);
|
|
195
|
+
if (cmd.handler.type === "command") {
|
|
196
|
+
execSync(cmd.handler.handler, { stdio: "inherit" });
|
|
197
|
+
}
|
|
198
|
+
if (cmd.handler.type === "function") {
|
|
199
|
+
const jiti = createJiti(import.meta.url, {
|
|
200
|
+
alias: silgiConfig.alias
|
|
201
|
+
});
|
|
202
|
+
const cleanHandler = cmd.handler.handler.replace(/\n/g, "");
|
|
203
|
+
await jiti.evalModule(cleanHandler, {
|
|
204
|
+
filename: import.meta.url,
|
|
205
|
+
async: true,
|
|
206
|
+
conditions: silgiConfig.conditions,
|
|
207
|
+
forceTranspile: true
|
|
208
|
+
});
|
|
209
|
+
}
|
|
178
210
|
}
|
|
179
211
|
}
|
|
180
212
|
});
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -355,6 +355,7 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
355
355
|
type: 'function' | 'command';
|
|
356
356
|
handler: string;
|
|
357
357
|
description?: string;
|
|
358
|
+
tags?: string[];
|
|
358
359
|
}>>) => HookResult;
|
|
359
360
|
'prepare:installPackages': (packages: Record<'dependencies' | 'devDependencies', Record<string, string>>) => HookResult;
|
|
360
361
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -355,6 +355,7 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
355
355
|
type: 'function' | 'command';
|
|
356
356
|
handler: string;
|
|
357
357
|
description?: string;
|
|
358
|
+
tags?: string[];
|
|
358
359
|
}>>) => HookResult;
|
|
359
360
|
'prepare:installPackages': (packages: Record<'dependencies' | 'devDependencies', Record<string, string>>) => HookResult;
|
|
360
361
|
}
|