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.
- package/dist/_chunks/index.mjs +1 -1
- package/dist/cli/run.mjs +67 -33
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/presets/_all.gen.mjs +2 -2
- package/dist/runtime/internal/ofetch.d.ts +3 -3
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
- /package/dist/presets/{npmPackage → npmpackage}/preset.d.ts +0 -0
- /package/dist/presets/{npmPackage → npmpackage}/preset.mjs +0 -0
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");
|
|
@@ -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: "
|
|
128
|
-
{ label: "
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
|
|
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
|
|
170
|
-
await
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
});
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _h3 from "./h3/preset.mjs";
|
|
2
2
|
import _nitro from "./nitro/preset.mjs";
|
|
3
|
-
import
|
|
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
|
-
...
|
|
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<
|
|
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 = <
|
|
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<
|
|
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 {};
|
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
|
}
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|