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.
@@ -1,4 +1,4 @@
1
- const version = "0.8.46";
1
+ const version = "0.8.47";
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,64 @@ 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).map((key) => ({
175
+ label: key,
176
+ value: key
177
+ }))
170
178
  });
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
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
  });
@@ -1,4 +1,4 @@
1
- const version = "0.8.46";
1
+ const version = "0.8.47";
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.47";
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.47",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {