silgi 0.42.5 → 0.43.1
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/_virtual/rolldown_runtime.mjs +11 -0
- package/dist/build.d.mts +3 -11
- package/dist/build.mjs +4 -48
- package/dist/cli/build/build.mjs +17 -0
- package/dist/cli/build/dev.d.mts +9 -0
- package/dist/cli/build/dev.mjs +59 -0
- package/dist/cli/build/prepare.d.mts +6 -0
- package/dist/cli/build/prepare.mjs +15 -0
- package/dist/cli/commands/commands.mjs +90 -0
- package/dist/cli/commands/env.mjs +53 -0
- package/dist/cli/commands/init.mjs +84 -0
- package/dist/cli/commands/install.mjs +52 -0
- package/dist/cli/commands/prepare.mjs +65 -0
- package/dist/cli/commands/reset.mjs +46 -0
- package/dist/cli/commands/run.mjs +105 -0
- package/dist/cli/commands/watch.mjs +48 -0
- package/dist/cli/config/defaults.mjs +117 -0
- package/dist/cli/config/index.d.mts +3 -11
- package/dist/cli/config/index.mjs +4 -17
- package/dist/cli/config/loader.d.mts +6 -0
- package/dist/cli/config/loader.mjs +71 -0
- package/dist/cli/config/resolvers/compatibility.mjs +71 -0
- package/dist/cli/config/resolvers/imports.mjs +35 -0
- package/dist/cli/config/resolvers/paths.mjs +98 -0
- package/dist/cli/config/resolvers/storage.mjs +23 -0
- package/dist/cli/config/resolvers/url.mjs +9 -0
- package/dist/cli/config/types.d.mts +14 -0
- package/dist/cli/config/types.mjs +147 -0
- package/dist/cli/core/apiful.mjs +36 -0
- package/dist/cli/core/app.mjs +105 -0
- package/dist/cli/core/devServer.mjs +10 -0
- package/dist/cli/core/env.mjs +68 -0
- package/dist/cli/core/installPackage.mjs +60 -0
- package/dist/cli/core/runtimeConfig.mjs +70 -0
- package/dist/cli/core/scan.mjs +35 -0
- package/dist/cli/core/silgi.mjs +111 -0
- package/dist/cli/core/templates.mjs +38 -0
- package/dist/cli/framework/emptyFramework.mjs +7 -0
- package/dist/cli/framework/h3.mjs +55 -0
- package/dist/cli/framework/index.mjs +15 -0
- package/dist/cli/framework/nitro.mjs +24 -0
- package/dist/cli/framework/nuxt.mjs +10 -0
- package/dist/cli/index.d.mts +1 -1
- package/dist/cli/index.mjs +24 -27
- package/dist/cli/module/exportScan.mjs +180 -0
- package/dist/cli/module/install.mjs +49 -0
- package/dist/cli/module/scan.mjs +195 -0
- package/dist/cli/scan/prepareCommands.mjs +40 -0
- package/dist/cli/scan/prepareConfigs.mjs +33 -0
- package/dist/cli/scan/prepareCoreFile.mjs +118 -0
- package/dist/cli/scan/prepareScanFile.mjs +59 -0
- package/dist/cli/scan/prepareSchema.mjs +140 -0
- package/dist/cli/scan/scanExportFile.mjs +347 -0
- package/dist/cli/scan/writeCoreFile.mjs +22 -0
- package/dist/cli/scan/writeTypesAndFiles.mjs +72 -0
- package/dist/cli/utils/cancel.mjs +14 -0
- package/dist/cli/utils/common.mjs +15 -0
- package/dist/cli/utils/compatibility.mjs +33 -0
- package/dist/cli/utils/debug.mjs +11 -0
- package/dist/cli/utils/ignore.mjs +56 -0
- package/dist/cli/utils/readScanFile.mjs +58 -0
- package/dist/cli/utils/storage.mjs +23 -0
- package/dist/core/context.d.mts +30 -0
- package/dist/core/context.mjs +32 -0
- package/dist/core/createSilgi.d.mts +6 -0
- package/dist/core/createSilgi.mjs +152 -0
- package/dist/core/error.d.mts +65 -0
- package/dist/core/error.mjs +106 -0
- package/dist/core/event.d.mts +26 -0
- package/dist/core/event.mjs +44 -0
- package/dist/core/index.d.mts +24 -316
- package/dist/core/index.mjs +27 -1345
- package/dist/core/orchestrate.mjs +113 -0
- package/dist/core/response.d.mts +20 -0
- package/dist/core/response.mjs +105 -0
- package/dist/core/silgi.d.mts +19 -0
- package/dist/core/silgi.mjs +141 -0
- package/dist/core/silgiApp.d.mts +9 -0
- package/dist/core/silgiApp.mjs +23 -0
- package/dist/core/storage.d.mts +7 -0
- package/dist/core/storage.mjs +15 -0
- package/dist/core/unctx.d.mts +21 -0
- package/dist/core/unctx.mjs +35 -0
- package/dist/core/utils/event-stream.d.mts +53 -0
- package/dist/core/utils/event-stream.mjs +38 -0
- package/dist/core/utils/event.d.mts +8 -0
- package/dist/core/utils/event.mjs +12 -0
- package/dist/core/utils/internal/event-stream.d.mts +45 -0
- package/dist/core/utils/internal/event-stream.mjs +137 -0
- package/dist/core/utils/internal/obj.mjs +9 -0
- package/dist/core/utils/internal/object.mjs +29 -0
- package/dist/core/utils/internal/query.mjs +73 -0
- package/dist/core/utils/internal/req.mjs +35 -0
- package/dist/core/utils/merge.d.mts +14 -0
- package/dist/core/utils/merge.mjs +27 -0
- package/dist/{shared/silgi.DTwQEdSr.d.mts → core/utils/middleware.d.mts} +11 -13
- package/dist/core/utils/middleware.mjs +12 -0
- package/dist/core/utils/request.mjs +35 -0
- package/dist/core/utils/resolver.d.mts +7 -0
- package/dist/core/utils/resolver.mjs +29 -0
- package/dist/core/utils/runtime.d.mts +7 -0
- package/dist/core/utils/runtime.mjs +20 -0
- package/dist/core/utils/sanitize.mjs +22 -0
- package/dist/core/utils/schema.d.mts +34 -0
- package/dist/core/utils/schema.mjs +33 -0
- package/dist/core/utils/service.d.mts +13 -0
- package/dist/core/utils/service.mjs +19 -0
- package/dist/core/utils/shared.d.mts +6 -0
- package/dist/core/utils/shared.mjs +7 -0
- package/dist/core/utils/storage.d.mts +24 -0
- package/dist/core/utils/storage.mjs +54 -0
- package/dist/index.d.mts +21 -6
- package/dist/index.mjs +22 -16
- package/dist/kit/add/add-commands.d.mts +6 -0
- package/dist/kit/add/add-commands.mjs +12 -0
- package/dist/kit/add/add-core-file.d.mts +9 -0
- package/dist/kit/add/add-core-file.mjs +11 -0
- package/dist/kit/add/add-imports.d.mts +14 -0
- package/dist/kit/add/add-imports.mjs +56 -0
- package/dist/kit/add/add-npm.d.mts +14 -0
- package/dist/kit/add/add-npm.mjs +23 -0
- package/dist/kit/define.d.mts +28 -0
- package/dist/kit/define.mjs +25 -0
- package/dist/kit/errors.d.mts +6 -0
- package/dist/kit/errors.mjs +11 -0
- package/dist/kit/esm.d.mts +11 -0
- package/dist/kit/esm.mjs +21 -0
- package/dist/kit/fs.d.mts +7 -0
- package/dist/kit/fs.mjs +23 -0
- package/dist/kit/function-utils.d.mts +27 -0
- package/dist/kit/function-utils.mjs +75 -0
- package/dist/kit/gen.d.mts +5 -0
- package/dist/kit/gen.mjs +26 -0
- package/dist/kit/hash.d.mts +4 -0
- package/dist/kit/hash.mjs +10 -0
- package/dist/kit/index.d.mts +22 -321
- package/dist/kit/index.mjs +23 -1039
- package/dist/kit/isFramework.d.mts +6 -0
- package/dist/kit/isFramework.mjs +21 -0
- package/dist/kit/logger.d.mts +6 -0
- package/dist/kit/logger.mjs +10 -0
- package/dist/kit/migration.d.mts +113 -0
- package/dist/kit/migration.mjs +301 -0
- package/dist/kit/module.d.mts +14 -0
- package/dist/kit/module.mjs +53 -0
- package/dist/kit/path.d.mts +7 -0
- package/dist/kit/path.mjs +26 -0
- package/dist/kit/preset.d.mts +8 -0
- package/dist/kit/preset.mjs +11 -0
- package/dist/kit/resolve.d.mts +37 -0
- package/dist/kit/resolve.mjs +82 -0
- package/dist/kit/template.d.mts +14 -0
- package/dist/kit/template.mjs +59 -0
- package/dist/kit/useRequest.d.mts +19 -0
- package/dist/kit/useRequest.mjs +63 -0
- package/dist/kit/utils.d.mts +34 -0
- package/dist/kit/utils.mjs +90 -0
- package/dist/package.mjs +176 -0
- package/dist/presets/_all.gen.d.mts +5 -2
- package/dist/presets/_all.gen.mjs +16 -13
- package/dist/presets/_resolve.d.mts +10 -6
- package/dist/presets/_resolve.mjs +51 -65
- package/dist/presets/_types.gen.d.mts +8 -5
- package/dist/presets/_types.gen.mjs +5 -1
- package/dist/presets/h3/preset.d.mts +5 -2
- package/dist/presets/h3/preset.mjs +33 -38
- package/dist/presets/hono/preset.d.mts +5 -2
- package/dist/presets/hono/preset.mjs +28 -35
- package/dist/presets/index.d.mts +3 -2
- package/dist/presets/index.mjs +3 -1
- package/dist/presets/nitro/preset.d.mts +5 -2
- package/dist/presets/nitro/preset.mjs +35 -42
- package/dist/presets/npmpackage/preset.d.mts +5 -2
- package/dist/presets/npmpackage/preset.mjs +27 -32
- package/dist/presets/nuxt/preset.d.mts +5 -2
- package/dist/presets/nuxt/preset.mjs +39 -44
- package/dist/runtime/index.d.mts +4 -3
- package/dist/runtime/index.mjs +5 -3
- package/dist/runtime/internal/config.d.mts +11 -7
- package/dist/runtime/internal/config.mjs +79 -90
- package/dist/runtime/internal/debug.d.mts +6 -3
- package/dist/runtime/internal/debug.mjs +9 -4
- package/dist/runtime/internal/defu.d.mts +4 -1
- package/dist/runtime/internal/defu.mjs +7 -2
- package/dist/runtime/internal/index.d.mts +7 -6
- package/dist/runtime/internal/index.mjs +8 -20
- package/dist/runtime/internal/nitro.d.mts +6 -3
- package/dist/runtime/internal/nitro.mjs +29 -37
- package/dist/runtime/internal/nuxt.d.mts +12 -8
- package/dist/runtime/internal/nuxt.mjs +12 -7
- package/dist/runtime/internal/ofetch.d.mts +8 -4
- package/dist/runtime/internal/ofetch.mjs +33 -34
- package/dist/runtime/internal/plugin.d.mts +7 -3
- package/dist/runtime/internal/plugin.mjs +7 -3
- package/dist/types/cliConfig.d.mts +288 -0
- package/dist/types/cliConfig.mjs +0 -0
- package/dist/types/cliHooks.d.mts +154 -0
- package/dist/types/cliHooks.mjs +0 -0
- package/dist/types/compatibility.d.mts +13 -0
- package/dist/types/compatibility.mjs +0 -0
- package/dist/types/config.d.mts +46 -0
- package/dist/types/config.mjs +0 -0
- package/dist/types/dotenv.d.mts +29 -0
- package/dist/types/dotenv.mjs +0 -0
- package/dist/types/event.d.mts +63 -0
- package/dist/types/event.mjs +0 -0
- package/dist/types/global.d.mts +24 -0
- package/dist/types/global.mjs +0 -0
- package/dist/types/helper.d.mts +25 -0
- package/dist/types/helper.mjs +0 -0
- package/dist/types/hooks.d.mts +37 -0
- package/dist/types/hooks.mjs +0 -0
- package/dist/types/index.d.mts +26 -1306
- package/dist/types/index.mjs +0 -1
- package/dist/types/kits.d.mts +32 -0
- package/dist/types/kits.mjs +0 -0
- package/dist/types/middleware.d.mts +31 -0
- package/dist/types/middleware.mjs +0 -0
- package/dist/types/module.d.mts +102 -0
- package/dist/types/module.mjs +0 -0
- package/dist/types/preset.d.mts +20 -0
- package/dist/types/preset.mjs +0 -0
- package/dist/types/route.d.mts +59 -0
- package/dist/types/route.mjs +0 -0
- package/dist/types/runtime/index.d.mts +5 -0
- package/dist/types/runtime/index.mjs +0 -0
- package/dist/types/runtime/nuxt.d.mts +13 -0
- package/dist/types/runtime/nuxt.mjs +0 -0
- package/dist/types/runtime/ofetch.d.mts +14 -0
- package/dist/types/runtime/ofetch.mjs +0 -0
- package/dist/types/runtime/plugin.d.mts +8 -0
- package/dist/types/runtime/plugin.mjs +0 -0
- package/dist/types/runtime/silgi.d.mts +11 -0
- package/dist/types/runtime/silgi.mjs +0 -0
- package/dist/types/schema.d.mts +86 -0
- package/dist/types/schema.mjs +0 -0
- package/dist/types/service.d.mts +102 -0
- package/dist/types/service.mjs +0 -0
- package/dist/types/shared.d.mts +19 -0
- package/dist/types/shared.mjs +0 -0
- package/dist/types/silgi.d.mts +71 -0
- package/dist/types/silgi.mjs +0 -0
- package/dist/types/silgiCLI.d.mts +118 -0
- package/dist/types/silgiCLI.mjs +0 -0
- package/dist/types/standard-schema.d.mts +61 -0
- package/dist/types/standard-schema.mjs +0 -0
- package/dist/types/storage.d.mts +30 -0
- package/dist/types/storage.mjs +0 -0
- package/package.json +22 -37
- package/dist/_chunks/silgiApp.mjs +0 -25
- package/dist/cli/build.mjs +0 -2190
- package/dist/cli/common.mjs +0 -13
- package/dist/cli/compatibility.mjs +0 -30
- package/dist/cli/dev.mjs +0 -67
- package/dist/cli/init.mjs +0 -112
- package/dist/cli/install.mjs +0 -151
- package/dist/cli/loader.mjs +0 -618
- package/dist/cli/prepare.mjs +0 -188
- package/dist/cli/reset.mjs +0 -55
- package/dist/cli/run.mjs +0 -159
- package/dist/cli/types.mjs +0 -232
- package/dist/cli/watch.mjs +0 -91
- package/dist/presets/next/preset.d.mts +0 -3
- package/dist/presets/next/preset.mjs +0 -38
- package/dist/runtime/internal/next.d.mts +0 -9
- package/dist/runtime/internal/next.mjs +0 -22
package/dist/build.d.mts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
declare function watchDev(): Promise<{
|
|
5
|
-
watcher: FSWatcher | undefined;
|
|
6
|
-
close: () => Promise<void>;
|
|
7
|
-
}>;
|
|
8
|
-
|
|
9
|
-
declare function prepareBuild(config?: SilgiCLIConfig): Promise<SilgiCLI>;
|
|
10
|
-
|
|
11
|
-
export { prepareBuild, watchDev };
|
|
1
|
+
import { watchDev$1 as watchDev } from "./cli/build/dev.mjs";
|
|
2
|
+
import { prepareBuild$1 as prepareBuild } from "./cli/build/prepare.mjs";
|
|
3
|
+
export { prepareBuild, watchDev };
|
package/dist/build.mjs
CHANGED
|
@@ -1,48 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import 'perfect-debounce';
|
|
6
|
-
import './_chunks/silgiApp.mjs';
|
|
7
|
-
import 'unctx';
|
|
8
|
-
import 'silgi';
|
|
9
|
-
import './cli/build.mjs';
|
|
10
|
-
import 'hookable';
|
|
11
|
-
import 'silgi/kit';
|
|
12
|
-
import 'silgi/runtime';
|
|
13
|
-
import 'silgi/runtime/meta';
|
|
14
|
-
import 'unimport';
|
|
15
|
-
import '@clack/prompts';
|
|
16
|
-
import 'node:fs';
|
|
17
|
-
import 'dotenv';
|
|
18
|
-
import 'knitwork';
|
|
19
|
-
import 'node:path';
|
|
20
|
-
import 'mlly';
|
|
21
|
-
import 'dev-jiti';
|
|
22
|
-
import './cli/compatibility.mjs';
|
|
23
|
-
import 'semver/functions/satisfies.js';
|
|
24
|
-
import 'silgi/meta';
|
|
25
|
-
import 'node:url';
|
|
26
|
-
import 'defu';
|
|
27
|
-
import 'exsolve';
|
|
28
|
-
import 'ufo';
|
|
29
|
-
import 'node:fs/promises';
|
|
30
|
-
import 'micromatch';
|
|
31
|
-
import 'oxc-parser';
|
|
32
|
-
import 'tinyglobby';
|
|
33
|
-
import 'ignore';
|
|
34
|
-
import 'scule';
|
|
35
|
-
import 'klona';
|
|
36
|
-
import 'unstorage';
|
|
37
|
-
import './cli/loader.mjs';
|
|
38
|
-
import 'c12';
|
|
39
|
-
import 'compatx';
|
|
40
|
-
import 'klona/full';
|
|
41
|
-
import 'std-env';
|
|
42
|
-
import 'consola/utils';
|
|
43
|
-
import 'escape-string-regexp';
|
|
44
|
-
import 'pkg-types';
|
|
45
|
-
import 'apiful/openapi';
|
|
46
|
-
import 'pathe/utils';
|
|
47
|
-
import 'untyped';
|
|
48
|
-
import './cli/types.mjs';
|
|
1
|
+
import { prepareBuild } from "./cli/build/prepare.mjs";
|
|
2
|
+
import { watchDev } from "./cli/build/dev.mjs";
|
|
3
|
+
|
|
4
|
+
export { prepareBuild, watchDev };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { generateApiFul } from "../core/apiful.mjs";
|
|
2
|
+
import { generateApp } from "../core/app.mjs";
|
|
3
|
+
import { prepareCommands } from "../scan/prepareCommands.mjs";
|
|
4
|
+
import { writeCoreFile } from "../scan/writeCoreFile.mjs";
|
|
5
|
+
import { writeTypesAndFiles } from "../scan/writeTypesAndFiles.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/cli/build/build.ts
|
|
8
|
+
async function build(silgi) {
|
|
9
|
+
await generateApiFul(silgi);
|
|
10
|
+
await prepareCommands(silgi);
|
|
11
|
+
await writeCoreFile(silgi);
|
|
12
|
+
await writeTypesAndFiles(silgi);
|
|
13
|
+
await generateApp(silgi);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { build };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { silgiCLIIClose, useSilgiCLI } from "../../core/silgiApp.mjs";
|
|
2
|
+
import { reloadScan } from "../core/devServer.mjs";
|
|
3
|
+
import { prepareBuild } from "./prepare.mjs";
|
|
4
|
+
import { watch } from "chokidar";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { basename } from "pathe";
|
|
7
|
+
import { debounce } from "perfect-debounce";
|
|
8
|
+
|
|
9
|
+
//#region src/cli/build/dev.ts
|
|
10
|
+
async function watchDev() {
|
|
11
|
+
const silgi = useSilgiCLI();
|
|
12
|
+
let watcher;
|
|
13
|
+
async function load() {
|
|
14
|
+
await prepareBuild({
|
|
15
|
+
commandType: "prepare",
|
|
16
|
+
activeEnvironment: silgi.options.activeEnvironment || ".env",
|
|
17
|
+
dev: true
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const reload = debounce(load);
|
|
21
|
+
const watchReloadEvents = new Set([
|
|
22
|
+
"add",
|
|
23
|
+
"addDir",
|
|
24
|
+
"unlink",
|
|
25
|
+
"unlinkDir",
|
|
26
|
+
"change"
|
|
27
|
+
]);
|
|
28
|
+
if (silgi.options.devServer.watch.length > 0) {
|
|
29
|
+
silgi.options.devServer.watch = [...new Set(silgi.options.devServer.watch)];
|
|
30
|
+
watcher = watch(silgi.options.devServer.watch, silgi.options.watchOptions);
|
|
31
|
+
watcher.on("all", async (event, path, stats) => {
|
|
32
|
+
if (!watchReloadEvents.has(event)) return;
|
|
33
|
+
const startTime = performance.now();
|
|
34
|
+
silgi.errors = [];
|
|
35
|
+
try {
|
|
36
|
+
await reloadScan(path, stats);
|
|
37
|
+
await reload();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
consola.withTag("silgi").error(error);
|
|
40
|
+
}
|
|
41
|
+
silgi.errors = [];
|
|
42
|
+
const endTime = performance.now();
|
|
43
|
+
const elapsedTime = Math.round(endTime - startTime);
|
|
44
|
+
silgi.logger.success(`${basename(path)} - ${elapsedTime}ms`);
|
|
45
|
+
}).on("error", (error) => {
|
|
46
|
+
consola.withTag("silgi").error(error);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async function close() {
|
|
50
|
+
await silgiCLIIClose();
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
watcher,
|
|
54
|
+
close
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { watchDev };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createSilgiCLI } from "../core/silgi.mjs";
|
|
2
|
+
import { build } from "./build.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/cli/build/prepare.ts
|
|
5
|
+
async function prepareBuild(config) {
|
|
6
|
+
const silgi = await createSilgiCLI({
|
|
7
|
+
commandType: config?.commandType || "prepare",
|
|
8
|
+
...config
|
|
9
|
+
});
|
|
10
|
+
await build(silgi);
|
|
11
|
+
return silgi;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { prepareBuild };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { silgiCLIIClose } from "../../core/silgiApp.mjs";
|
|
2
|
+
import { prepareEnv } from "./env.mjs";
|
|
3
|
+
import { loadOptions } from "../config/loader.mjs";
|
|
4
|
+
import { cancelOnCancel } from "../utils/cancel.mjs";
|
|
5
|
+
import { commonArgs } from "../utils/common.mjs";
|
|
6
|
+
import prepare_default from "./prepare.mjs";
|
|
7
|
+
import { consola as consola$1 } from "consola";
|
|
8
|
+
import { useSilgiCLI } from "silgi";
|
|
9
|
+
import * as p from "@clack/prompts";
|
|
10
|
+
import { createJiti } from "dev-jiti";
|
|
11
|
+
import { version } from "silgi/meta";
|
|
12
|
+
import { defineCommand, runCommand } from "citty";
|
|
13
|
+
import { execSync } from "node:child_process";
|
|
14
|
+
|
|
15
|
+
//#region src/cli/commands/commands.ts
|
|
16
|
+
const command = defineCommand({
|
|
17
|
+
meta: {
|
|
18
|
+
name: "run",
|
|
19
|
+
description: "Run a command from the CLI",
|
|
20
|
+
version
|
|
21
|
+
},
|
|
22
|
+
args: {
|
|
23
|
+
...commonArgs,
|
|
24
|
+
preset: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
27
|
+
},
|
|
28
|
+
tag: { type: "string" },
|
|
29
|
+
prepare: {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
description: "Run in silgi development mode",
|
|
32
|
+
default: true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
async run({ args }) {
|
|
36
|
+
if (args.prepare) await runCommand(prepare_default, { rawArgs: ["--commandType", "commands"] });
|
|
37
|
+
const silgi = useSilgiCLI();
|
|
38
|
+
if (!silgi) throw new Error("Silgi is not initialized");
|
|
39
|
+
const commands = silgi.options.commands;
|
|
40
|
+
const tags = args.tag?.split(",").map((t) => t.trim());
|
|
41
|
+
const silgiConfig = await loadOptions({});
|
|
42
|
+
await prepareEnv(silgiConfig);
|
|
43
|
+
let selectedCommands = [];
|
|
44
|
+
if (tags?.length) selectedCommands = commands.filter((cmd) => cmd.tags?.some((tag) => tags.includes(tag))).filter((cmd) => cmd.when !== false);
|
|
45
|
+
else selectedCommands = commands.filter((cmd) => cmd.when !== false);
|
|
46
|
+
if (!selectedCommands.length) return;
|
|
47
|
+
const multiSelect = await p.groupMultiselect({
|
|
48
|
+
message: "Select commands to run",
|
|
49
|
+
required: true,
|
|
50
|
+
options: { ...selectedCommands.sort((a, b) => (a.order || Infinity) - (b.order || Infinity)).reduce((acc, cmd) => {
|
|
51
|
+
const groupKey = cmd.group || "";
|
|
52
|
+
if (!acc[groupKey]) acc[groupKey] = [];
|
|
53
|
+
acc[groupKey].push({
|
|
54
|
+
label: cmd.name,
|
|
55
|
+
value: cmd,
|
|
56
|
+
hint: cmd.description
|
|
57
|
+
});
|
|
58
|
+
return acc;
|
|
59
|
+
}, {}) }
|
|
60
|
+
});
|
|
61
|
+
cancelOnCancel({ value: multiSelect });
|
|
62
|
+
selectedCommands = multiSelect;
|
|
63
|
+
const spinner = p.spinner({ indicator: "dots" });
|
|
64
|
+
for (const cmd of selectedCommands) {
|
|
65
|
+
const data = cmd.getContents({ app: silgi });
|
|
66
|
+
spinner.start(`[${cmd.group}] ${cmd.name}...`);
|
|
67
|
+
if (cmd.type === "command") execSync(data, { stdio: "inherit" });
|
|
68
|
+
if (cmd.type === "function") {
|
|
69
|
+
const jiti = createJiti(import.meta.url, { alias: silgiConfig.alias });
|
|
70
|
+
let cleanHandler = cmd.getContents({ app: silgi }).replace(/\n/g, "");
|
|
71
|
+
cleanHandler = `import { silgiCLICtx } from 'silgi'
|
|
72
|
+
${cleanHandler}
|
|
73
|
+
`;
|
|
74
|
+
await jiti.evalModule(cleanHandler, {
|
|
75
|
+
filename: import.meta.url,
|
|
76
|
+
async: true,
|
|
77
|
+
conditions: silgiConfig.conditions,
|
|
78
|
+
forceTranspile: true
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
spinner.stop();
|
|
82
|
+
consola$1.success(`[${cmd.group}] ${cmd.name} done`);
|
|
83
|
+
}
|
|
84
|
+
await silgiCLIIClose();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
var commands_default = command;
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
export { commands_default as default };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { setupDotenv } from "../core/env.mjs";
|
|
2
|
+
import * as p from "@clack/prompts";
|
|
3
|
+
|
|
4
|
+
//#region src/cli/commands/env.ts
|
|
5
|
+
let initialized = false;
|
|
6
|
+
async function prepareEnv(silgiConfig) {
|
|
7
|
+
if (initialized) return;
|
|
8
|
+
initialized = true;
|
|
9
|
+
const customEnvironments = silgiConfig.environments;
|
|
10
|
+
const environment = silgiConfig.activeEnvironment ? silgiConfig.activeEnvironment : await p.select({
|
|
11
|
+
message: "Select an environment",
|
|
12
|
+
options: customEnvironments?.length > 0 ? customEnvironments.map((env) => ({
|
|
13
|
+
label: env.fileName,
|
|
14
|
+
value: env.fileName
|
|
15
|
+
})) : [
|
|
16
|
+
{
|
|
17
|
+
label: "Development (.env)",
|
|
18
|
+
value: ".env"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "Docker (.env.docker)",
|
|
22
|
+
value: "docker"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "Staging (.env.staging)",
|
|
26
|
+
value: "staging"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: "Testing (.env.testing)",
|
|
30
|
+
value: "testing"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "Production (.env.prod)",
|
|
34
|
+
value: "prod"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
const findEnv = customEnvironments?.find((env) => env.fileName === environment);
|
|
39
|
+
if (findEnv) await setupDotenv({
|
|
40
|
+
cwd: findEnv.cwd || silgiConfig.rootDir,
|
|
41
|
+
interpolate: findEnv.interpolate,
|
|
42
|
+
fileName: findEnv.fileName,
|
|
43
|
+
env: findEnv.env
|
|
44
|
+
});
|
|
45
|
+
else await setupDotenv({
|
|
46
|
+
cwd: silgiConfig.rootDir,
|
|
47
|
+
interpolate: true,
|
|
48
|
+
fileName: environment === ".env" ? ".env" : `.env.${environment}`
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { prepareEnv };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { cancelOnCancel } from "../utils/cancel.mjs";
|
|
2
|
+
import prepare_default from "./prepare.mjs";
|
|
3
|
+
import consola from "consola";
|
|
4
|
+
import { dirname } from "pathe";
|
|
5
|
+
import * as p from "@clack/prompts";
|
|
6
|
+
import { writeFileSync } from "node:fs";
|
|
7
|
+
import fsp from "node:fs/promises";
|
|
8
|
+
import { defineCommand, runCommand } from "citty";
|
|
9
|
+
|
|
10
|
+
//#region src/cli/commands/init.ts
|
|
11
|
+
const command = defineCommand({
|
|
12
|
+
meta: {
|
|
13
|
+
name: "Silgi Init",
|
|
14
|
+
description: "Initialize silgi config",
|
|
15
|
+
version: "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
args: {},
|
|
18
|
+
async run() {
|
|
19
|
+
p.intro("Initializing silgi config");
|
|
20
|
+
const framework = await p.select({
|
|
21
|
+
message: "Choose a framework",
|
|
22
|
+
options: [
|
|
23
|
+
{
|
|
24
|
+
label: "Nitro",
|
|
25
|
+
value: "nitro"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: "Nuxt",
|
|
29
|
+
value: "nuxt"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: "H3",
|
|
33
|
+
value: "h3"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: "NPM Package",
|
|
37
|
+
value: "npm-package"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
initialValue: "h3"
|
|
41
|
+
});
|
|
42
|
+
cancelOnCancel({ value: framework });
|
|
43
|
+
const context = [
|
|
44
|
+
`import { defineSilgiConfig } from 'silgi/config'`,
|
|
45
|
+
"",
|
|
46
|
+
"export default defineSilgiConfig({",
|
|
47
|
+
` preset: '${framework}',`,
|
|
48
|
+
` compatibilityDate: '${new Date().toISOString().split("T")[0]}',`,
|
|
49
|
+
"",
|
|
50
|
+
"})",
|
|
51
|
+
""
|
|
52
|
+
];
|
|
53
|
+
if (framework === "nitro" || framework === "nuxt") {
|
|
54
|
+
const plugin = [
|
|
55
|
+
`import { buildSilgi } from '../silgi/core'`,
|
|
56
|
+
"",
|
|
57
|
+
"export default defineNitroPlugin(async (nitro) => {",
|
|
58
|
+
"",
|
|
59
|
+
" await buildSilgi({",
|
|
60
|
+
" framework: {",
|
|
61
|
+
" nitro,",
|
|
62
|
+
" },",
|
|
63
|
+
" options: {",
|
|
64
|
+
" putStorage: useStorage(),",
|
|
65
|
+
" runtimeConfig: useRuntimeConfig(),",
|
|
66
|
+
" },",
|
|
67
|
+
" })",
|
|
68
|
+
"})",
|
|
69
|
+
""
|
|
70
|
+
];
|
|
71
|
+
const file = "server/plugins/silgi.ts";
|
|
72
|
+
await fsp.mkdir(dirname(file), { recursive: true });
|
|
73
|
+
writeFileSync(file, plugin.join("\n"));
|
|
74
|
+
consola.success("Silgi plugin created, see server/plugins/silgi.ts");
|
|
75
|
+
runCommand(prepare_default, { rawArgs: ["--env", ".env"] });
|
|
76
|
+
}
|
|
77
|
+
writeFileSync("silgi.config.ts", context.join("\n"));
|
|
78
|
+
consola.success("Silgi config created, see silgi.config.ts");
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
var init_default = command;
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
export { init_default as default };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { commonArgs } from "../utils/common.mjs";
|
|
2
|
+
import prepare_default from "./prepare.mjs";
|
|
3
|
+
import { installPackages } from "../core/installPackage.mjs";
|
|
4
|
+
import { consola as consola$1 } from "consola";
|
|
5
|
+
import { version } from "silgi/meta";
|
|
6
|
+
import { defineCommand, runCommand } from "citty";
|
|
7
|
+
import { execSync } from "node:child_process";
|
|
8
|
+
|
|
9
|
+
//#region src/cli/commands/install.ts
|
|
10
|
+
const command = defineCommand({
|
|
11
|
+
meta: {
|
|
12
|
+
name: "install",
|
|
13
|
+
description: "Install dependencies from the install.json file.",
|
|
14
|
+
version
|
|
15
|
+
},
|
|
16
|
+
args: {
|
|
17
|
+
...commonArgs,
|
|
18
|
+
preset: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
async run() {
|
|
24
|
+
await runCommand(prepare_default, { rawArgs: ["--commandType", "install"] }).catch(() => {});
|
|
25
|
+
const packages = await installPackages();
|
|
26
|
+
const commandArgs = process.argv.slice(process.argv.indexOf("install") + 1);
|
|
27
|
+
const extraArgs = commandArgs.length ? ` ${commandArgs.join(" ")}` : "";
|
|
28
|
+
if (Object.keys(packages).length === 0) {
|
|
29
|
+
consola$1.info("Empty command list, maybe forgot pnpm silgi prepare?");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const cleanPackageName = (name, version$1) => {
|
|
33
|
+
const cleanVersion = version$1.replace(/^(>=|<=|>|<)/, "^");
|
|
34
|
+
return `${name}@${cleanVersion}`;
|
|
35
|
+
};
|
|
36
|
+
const deps = Object.entries(packages.dependencies || {}).map(([name, version$1]) => cleanPackageName(name, version$1)).join(" ");
|
|
37
|
+
const devDeps = Object.entries(packages.devDependencies || {}).map(([name, version$1]) => cleanPackageName(name, version$1)).join(" ");
|
|
38
|
+
if (deps) {
|
|
39
|
+
consola$1.info("Installing dependencies...");
|
|
40
|
+
execSync(`ni ${deps}${extraArgs}`, { stdio: "inherit" });
|
|
41
|
+
}
|
|
42
|
+
if (devDeps) {
|
|
43
|
+
consola$1.info("Installing dev dependencies...");
|
|
44
|
+
execSync(`ni ${devDeps}${extraArgs} -D`, { stdio: "inherit" });
|
|
45
|
+
}
|
|
46
|
+
consola$1.success("All dependencies installed successfully.");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
var install_default = command;
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { install_default as default };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createSilgiCLI } from "../core/silgi.mjs";
|
|
2
|
+
import { build } from "../build/build.mjs";
|
|
3
|
+
import { commonArgs } from "../utils/common.mjs";
|
|
4
|
+
import commands_default from "./commands.mjs";
|
|
5
|
+
import { resolve } from "pathe";
|
|
6
|
+
import { readPackageJSON } from "pkg-types";
|
|
7
|
+
import { version } from "silgi/meta";
|
|
8
|
+
import { defineCommand, runCommand } from "citty";
|
|
9
|
+
|
|
10
|
+
//#region src/cli/commands/prepare.ts
|
|
11
|
+
const command = defineCommand({
|
|
12
|
+
meta: {
|
|
13
|
+
name: "prepare",
|
|
14
|
+
description: "Generate types for the project",
|
|
15
|
+
version
|
|
16
|
+
},
|
|
17
|
+
args: {
|
|
18
|
+
...commonArgs,
|
|
19
|
+
preset: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
22
|
+
},
|
|
23
|
+
stub: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
description: "Run in silgi development mode"
|
|
26
|
+
},
|
|
27
|
+
dev: {
|
|
28
|
+
type: "boolean",
|
|
29
|
+
description: "Run in silgi development mode"
|
|
30
|
+
},
|
|
31
|
+
env: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "The environment to use"
|
|
34
|
+
},
|
|
35
|
+
commandType: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "The command type to run"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
async run({ args }) {
|
|
41
|
+
const rootDir = resolve(args.dir || args._dir || ".");
|
|
42
|
+
const packageJson = await readPackageJSON(rootDir);
|
|
43
|
+
const packageName = packageJson.name || "";
|
|
44
|
+
const silgi = await createSilgiCLI({
|
|
45
|
+
rootDir,
|
|
46
|
+
dev: args.dev || args.stub,
|
|
47
|
+
stub: args.stub,
|
|
48
|
+
preset: args.preset,
|
|
49
|
+
commandType: args.commandType || "prepare",
|
|
50
|
+
activeEnvironment: args.env,
|
|
51
|
+
package: { name: packageName }
|
|
52
|
+
});
|
|
53
|
+
await build(silgi);
|
|
54
|
+
if (args.commandType !== "commands") await runCommand(commands_default, { rawArgs: [
|
|
55
|
+
"--tag",
|
|
56
|
+
"init",
|
|
57
|
+
"--prepare",
|
|
58
|
+
"false"
|
|
59
|
+
] });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var prepare_default = command;
|
|
63
|
+
|
|
64
|
+
//#endregion
|
|
65
|
+
export { prepare_default as default };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { loadOptions } from "../config/loader.mjs";
|
|
2
|
+
import { commonArgs } from "../utils/common.mjs";
|
|
3
|
+
import consola from "consola";
|
|
4
|
+
import { join, resolve } from "pathe";
|
|
5
|
+
import { version } from "silgi/meta";
|
|
6
|
+
import fsp from "node:fs/promises";
|
|
7
|
+
import { defineCommand } from "citty";
|
|
8
|
+
|
|
9
|
+
//#region src/cli/commands/reset.ts
|
|
10
|
+
const command = defineCommand({
|
|
11
|
+
meta: {
|
|
12
|
+
name: "prepare",
|
|
13
|
+
description: "Generate types for the project",
|
|
14
|
+
version
|
|
15
|
+
},
|
|
16
|
+
args: { ...commonArgs },
|
|
17
|
+
async run({ args }) {
|
|
18
|
+
const rootDir = resolve(args.dir || args._dir || ".");
|
|
19
|
+
const options = await loadOptions({ rootDir }, {});
|
|
20
|
+
const serverDir = options.silgi.serverDir;
|
|
21
|
+
const vfs = join(serverDir, "vfs");
|
|
22
|
+
const configs = join(serverDir, "configs.ts");
|
|
23
|
+
const core = join(serverDir, "core.ts");
|
|
24
|
+
const scan = join(serverDir, "scan.ts");
|
|
25
|
+
const meta = join(serverDir, "meta.ts");
|
|
26
|
+
const silgiDir = options.build.dir;
|
|
27
|
+
for (const file of [
|
|
28
|
+
vfs,
|
|
29
|
+
configs,
|
|
30
|
+
core,
|
|
31
|
+
scan,
|
|
32
|
+
silgiDir,
|
|
33
|
+
meta
|
|
34
|
+
]) try {
|
|
35
|
+
await fsp.rm(file, {
|
|
36
|
+
force: true,
|
|
37
|
+
recursive: true
|
|
38
|
+
});
|
|
39
|
+
consola.success(`Removed ${file.replace(rootDir, "")}`);
|
|
40
|
+
} catch {}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
var reset_default = command;
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { reset_default as default };
|