silgi 0.8.0 → 0.8.2
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/prepare.mjs +2 -5
- package/dist/cli/run.mjs +18 -7
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/presets/h3/preset.mjs +0 -3
- package/dist/presets/nitro/preset.mjs +0 -3
- package/dist/presets/npmpackage/preset.mjs +1 -4
- package/dist/presets/nuxt/preset.mjs +0 -3
- package/dist/types/index.d.mts +10 -2
- package/dist/types/index.d.ts +10 -2
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -1537,17 +1537,14 @@ async function compileTemplate(template, ctx) {
|
|
|
1537
1537
|
|
|
1538
1538
|
async function commands(silgi) {
|
|
1539
1539
|
const commands2 = {
|
|
1540
|
-
|
|
1541
|
-
dev: 'echo "module dev"',
|
|
1542
|
-
build: 'echo "module build"'
|
|
1543
|
-
}
|
|
1540
|
+
...silgi.options.commands
|
|
1544
1541
|
};
|
|
1545
1542
|
await silgi.callHook("prepare:commands", commands2);
|
|
1546
1543
|
addTemplate({
|
|
1547
1544
|
filename: "cli.json",
|
|
1548
1545
|
where: ".silgi",
|
|
1549
1546
|
write: true,
|
|
1550
|
-
getContents: () => JSON.stringify(commands2, null, 2)
|
|
1547
|
+
getContents: () => Object.keys(commands2).length > 1 ? JSON.stringify(commands2, null, 2) : "{}"
|
|
1551
1548
|
});
|
|
1552
1549
|
}
|
|
1553
1550
|
|
package/dist/cli/run.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
2
3
|
import * as p from '@clack/prompts';
|
|
3
4
|
import { defineCommand } from 'citty';
|
|
5
|
+
import { consola } from 'consola';
|
|
4
6
|
import { resolve } from 'pathe';
|
|
5
7
|
import color from 'picocolors';
|
|
6
8
|
import { version } from 'silgi/meta';
|
|
@@ -10,11 +12,9 @@ import 'c12';
|
|
|
10
12
|
import 'compatx';
|
|
11
13
|
import 'klona/full';
|
|
12
14
|
import 'std-env';
|
|
13
|
-
import 'consola';
|
|
14
15
|
import 'consola/utils';
|
|
15
16
|
import 'escape-string-regexp';
|
|
16
17
|
import 'mlly';
|
|
17
|
-
import 'node:fs';
|
|
18
18
|
import 'pkg-types';
|
|
19
19
|
import 'silgi/kit';
|
|
20
20
|
import 'silgi/runtime/meta';
|
|
@@ -37,16 +37,21 @@ const run = defineCommand({
|
|
|
37
37
|
p.intro(color.bold(`Silgi CLI ${color.green(`v${version}`)}`));
|
|
38
38
|
const silgiConfig = await loadOptions({});
|
|
39
39
|
const getCli = resolve(silgiConfig.build.dir, "cli.json");
|
|
40
|
-
const cli =
|
|
41
|
-
const
|
|
40
|
+
const cli = readFileSync(getCli, "utf-8");
|
|
41
|
+
const cliJson = JSON.parse(cli);
|
|
42
|
+
if (Object.keys(cliJson).length === 0) {
|
|
43
|
+
consola.info("Empty command list, maybe forgot pnpm silgi prepare?");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
42
46
|
const commandName = await p.select({
|
|
43
47
|
message: "Select a command to run",
|
|
44
|
-
options: Object.keys(
|
|
48
|
+
options: Object.keys(cliJson).map((key) => ({
|
|
45
49
|
label: key,
|
|
46
50
|
value: key
|
|
47
51
|
}))
|
|
48
52
|
});
|
|
49
|
-
const scripts =
|
|
53
|
+
const scripts = cliJson[commandName];
|
|
54
|
+
console.log("scripts", scripts);
|
|
50
55
|
const scriptName = await p.select({
|
|
51
56
|
message: "Select a script to run",
|
|
52
57
|
options: Object.keys(scripts).map((key) => ({
|
|
@@ -55,7 +60,13 @@ const run = defineCommand({
|
|
|
55
60
|
}))
|
|
56
61
|
});
|
|
57
62
|
const script = scripts[scriptName];
|
|
58
|
-
|
|
63
|
+
if (script.type === "command") {
|
|
64
|
+
execSync(script.handler, { stdio: "inherit" });
|
|
65
|
+
}
|
|
66
|
+
if (script.type === "function") {
|
|
67
|
+
const fn = eval(`(${script.handler})`);
|
|
68
|
+
fn();
|
|
69
|
+
}
|
|
59
70
|
}
|
|
60
71
|
});
|
|
61
72
|
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED
package/dist/types/index.d.mts
CHANGED
|
@@ -351,7 +351,11 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
351
351
|
*/
|
|
352
352
|
'app:templatesGenerated': (app: SilgiCLI, templates: ResolvedSilgiTemplate[], options?: GenerateAppOptions) => HookResult;
|
|
353
353
|
'scanFiles:done': (app: SilgiCLI) => HookResult;
|
|
354
|
-
'prepare:commands': (commands: Record<string, Record<string,
|
|
354
|
+
'prepare:commands': (commands: Record<string, Record<string, {
|
|
355
|
+
type: 'function' | 'command';
|
|
356
|
+
handler: string;
|
|
357
|
+
description?: string;
|
|
358
|
+
}>>) => HookResult;
|
|
355
359
|
}
|
|
356
360
|
|
|
357
361
|
/**
|
|
@@ -726,7 +730,11 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
726
730
|
* ```
|
|
727
731
|
*/
|
|
728
732
|
ignoreOptions: Options;
|
|
729
|
-
commands: Record<string, string
|
|
733
|
+
commands: Record<string, Record<string, {
|
|
734
|
+
type: 'function' | 'command';
|
|
735
|
+
handler: string;
|
|
736
|
+
description?: string;
|
|
737
|
+
}>>;
|
|
730
738
|
}
|
|
731
739
|
/**
|
|
732
740
|
* Silgi input config (silgi.config)
|
package/dist/types/index.d.ts
CHANGED
|
@@ -351,7 +351,11 @@ interface SilgiCLIHooks extends SilgiHooks {
|
|
|
351
351
|
*/
|
|
352
352
|
'app:templatesGenerated': (app: SilgiCLI, templates: ResolvedSilgiTemplate[], options?: GenerateAppOptions) => HookResult;
|
|
353
353
|
'scanFiles:done': (app: SilgiCLI) => HookResult;
|
|
354
|
-
'prepare:commands': (commands: Record<string, Record<string,
|
|
354
|
+
'prepare:commands': (commands: Record<string, Record<string, {
|
|
355
|
+
type: 'function' | 'command';
|
|
356
|
+
handler: string;
|
|
357
|
+
description?: string;
|
|
358
|
+
}>>) => HookResult;
|
|
355
359
|
}
|
|
356
360
|
|
|
357
361
|
/**
|
|
@@ -726,7 +730,11 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
726
730
|
* ```
|
|
727
731
|
*/
|
|
728
732
|
ignoreOptions: Options;
|
|
729
|
-
commands: Record<string, string
|
|
733
|
+
commands: Record<string, Record<string, {
|
|
734
|
+
type: 'function' | 'command';
|
|
735
|
+
handler: string;
|
|
736
|
+
description?: string;
|
|
737
|
+
}>>;
|
|
730
738
|
}
|
|
731
739
|
/**
|
|
732
740
|
* Silgi input config (silgi.config)
|