silgi 0.8.45 → 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.45";
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");
@@ -123,9 +127,11 @@ const run = defineCommand({
123
127
  label: env.fileName,
124
128
  value: env.fileName
125
129
  })) : [
126
- { label: "Development (.env)", value: "dev" },
127
- { label: "Production (.env.prod)", value: "prod" },
128
- { label: "Docker (.env.docker)", value: "docker" }
130
+ { label: "Development (.env.dev)", value: "dev" },
131
+ { label: "Docker (.env.docker)", value: "docker" },
132
+ { label: "Staging (.env.staging)", value: "staging" },
133
+ { label: "Testing (.env.testing)", value: "testing" },
134
+ { label: "Production (.env)", value: ".env" }
129
135
  ]
130
136
  });
131
137
  const findEnv = customEnvironments?.find((env) => env.fileName === environment);
@@ -140,39 +146,67 @@ const run = defineCommand({
140
146
  await setupDotenv({
141
147
  cwd: silgiConfig.rootDir,
142
148
  interpolate: true,
143
- fileName: `.env.${environment}`
149
+ fileName: environment === "prod" ? ".env" : `.env.${environment}`
144
150
  });
145
151
  }
146
- const commandName = await p.select({
147
- message: "Select a command to run",
148
- options: Object.keys(cliJson).map((key) => ({
149
- label: key,
150
- value: key
151
- }))
152
- });
153
- const scripts = cliJson[commandName];
154
- const scriptName = await p.select({
155
- message: "Select a script to run",
156
- options: Object.keys(scripts).map((key) => ({
157
- label: key,
158
- value: key
159
- }))
160
- });
161
- const script = scripts[scriptName];
162
- if (script.type === "command") {
163
- execSync(script.handler, { stdio: "inherit" });
164
- }
165
- if (script.type === "function") {
166
- const jiti = createJiti(import.meta.url, {
167
- 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
+ }))
168
178
  });
169
- const cleanHandler = script.handler.replace(/\n/g, "");
170
- await jiti.evalModule(cleanHandler, {
171
- filename: import.meta.url,
172
- async: true,
173
- conditions: silgiConfig.conditions,
174
- 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
+ }))
175
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
+ }
176
210
  }
177
211
  }
178
212
  });
@@ -1,4 +1,4 @@
1
- const version = "0.8.45";
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.45";
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,10 +1,10 @@
1
1
  import _h3 from "./h3/preset.mjs";
2
2
  import _nitro from "./nitro/preset.mjs";
3
- import _npmPackage from "./npmPackage/preset.mjs";
3
+ import _npmpackage from "./npmpackage/preset.mjs";
4
4
  import _nuxt from "./nuxt/preset.mjs";
5
5
  export default [
6
6
  ..._h3,
7
7
  ..._nitro,
8
- ..._npmPackage,
8
+ ..._npmpackage,
9
9
  ..._nuxt
10
10
  ];
@@ -10,13 +10,13 @@ type ExtractPathParams<T extends string> = T extends `${infer _Start}:${infer Pa
10
10
  [K in Param]: string;
11
11
  } : object;
12
12
  export type RouterParams<R extends AllPaths | (string & {})> = ExtractPathParams<R>;
13
- type SilgiFetchOptions<T, P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]> = {
13
+ type SilgiFetchOptions<P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]> = {
14
14
  method?: M;
15
15
  params?: ExtractPathParams<P>;
16
16
  body?: SilgiRouterTypes[BasePath][M]['input'];
17
17
  } & Omit<FetchOptions, 'method' | 'body' | 'params'>;
18
- export type SilgiFetchClient = <T, P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(url: BasePath, options?: SilgiFetchOptions<T, P, BasePath, M>) => Promise<FetchResponse<SilgiRouterTypes[BasePath][M]['output']>>;
18
+ export type SilgiFetchClient = <P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(url: BasePath, options?: SilgiFetchOptions<P, BasePath, M>) => Promise<FetchResponse<SilgiRouterTypes[BasePath][M]['output']>>;
19
19
  export declare function silgiFetchRequestInterceptor(ctx: FetchContext): void;
20
20
  export declare function createSilgiFetch(options: FetchOptions | ((options: FetchOptions) => FetchOptions), localFetch?: typeof globalThis.$fetch): SilgiFetchClient;
21
- export declare function silgi$fetch<T, P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(url: P, opts?: SilgiFetchOptions<T, P, BasePath, M>): Promise<FetchResponse<SilgiRouterTypes[BasePath][M]['output']>>;
21
+ export declare function silgi$fetch<P extends AllPaths | (string & {}), BasePath extends keyof SilgiRouterTypes = TrimAfterFourSlashes<P> extends keyof SilgiRouterTypes ? TrimAfterFourSlashes<P> : never, M extends keyof SilgiRouterTypes[BasePath] = keyof SilgiRouterTypes[BasePath]>(url: P, opts?: SilgiFetchOptions<P, BasePath, M>): Promise<FetchResponse<SilgiRouterTypes[BasePath][M]['output']>>;
22
22
  export {};
@@ -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.45",
4
+ "version": "0.8.47",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {