silgi 0.8.46 → 0.8.48

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.
@@ -1,4 +1,4 @@
1
- const version = "0.8.46";
1
+ const version = "0.8.48";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.2.0",
4
4
  "@fastify/deepmerge": "^2.0.2",
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,72 @@ const run = defineCommand({
145
149
  fileName: environment === "prod" ? ".env" : `.env.${environment}`
146
150
  });
147
151
  }
148
- const commandName = await p.select({
149
- message: "Select a command to run",
150
- options: Object.keys(cliJson).map((key) => ({
151
- label: key,
152
- value: key
153
- }))
154
- });
155
- const scripts = cliJson[commandName];
156
- const scriptName = await p.select({
157
- message: "Select a script to run",
158
- options: Object.keys(scripts).map((key) => ({
159
- label: key,
160
- value: key
161
- }))
162
- });
163
- const script = scripts[scriptName];
164
- if (script.type === "command") {
165
- execSync(script.handler, { stdio: "inherit" });
166
- }
167
- if (script.type === "function") {
168
- const jiti = createJiti(import.meta.url, {
169
- alias: silgiConfig.alias
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).filter((key) => {
175
+ const scripts2 = cliJson[key];
176
+ const scriptValues = Object.values(scripts2);
177
+ return !scriptValues.some((script) => script.tags?.length);
178
+ }).map((key) => ({
179
+ label: key,
180
+ value: key
181
+ }))
170
182
  });
171
- const cleanHandler = script.handler.replace(/\n/g, "");
172
- await jiti.evalModule(cleanHandler, {
173
- filename: import.meta.url,
174
- async: true,
175
- conditions: silgiConfig.conditions,
176
- forceTranspile: true
183
+ if (!commandName)
184
+ return;
185
+ const scripts = cliJson[commandName];
186
+ const scriptName = await p.select({
187
+ message: "Select a script to run",
188
+ options: Object.keys(scripts).filter((key) => !scripts[key].tags?.length).map((key) => ({
189
+ label: key,
190
+ value: key
191
+ }))
177
192
  });
193
+ if (!scriptName)
194
+ return;
195
+ selectedCommands = [{
196
+ command: commandName,
197
+ script: scriptName,
198
+ handler: scripts[scriptName]
199
+ }];
200
+ }
201
+ for (const cmd of selectedCommands) {
202
+ consola.info(`Running ${cmd.command}:${cmd.script}...`);
203
+ if (cmd.handler.type === "command") {
204
+ execSync(cmd.handler.handler, { stdio: "inherit" });
205
+ }
206
+ if (cmd.handler.type === "function") {
207
+ const jiti = createJiti(import.meta.url, {
208
+ alias: silgiConfig.alias
209
+ });
210
+ const cleanHandler = cmd.handler.handler.replace(/\n/g, "");
211
+ await jiti.evalModule(cleanHandler, {
212
+ filename: import.meta.url,
213
+ async: true,
214
+ conditions: silgiConfig.conditions,
215
+ forceTranspile: true
216
+ });
217
+ }
178
218
  }
179
219
  }
180
220
  });
@@ -1,4 +1,4 @@
1
- const version = "0.8.46";
1
+ const version = "0.8.48";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.2.0",
4
4
  "@fastify/deepmerge": "^2.0.2",
@@ -1,4 +1,4 @@
1
- const version = "0.8.46";
1
+ const version = "0.8.48";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.2.0",
4
4
  "@fastify/deepmerge": "^2.0.2",
@@ -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
  }
@@ -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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.8.46",
4
+ "version": "0.8.48",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {