silgi 0.24.16 → 0.24.17
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/cli/build/prepare.mjs +43 -0
- package/dist/{chunks → cli/commands}/dev.mjs +4 -43
- package/dist/cli/commands/env.mjs +40 -0
- package/dist/{chunks → cli/commands}/install.mjs +3 -37
- package/dist/cli/commands/prepare.mjs +66 -0
- package/dist/{chunks/prepare.mjs → cli/commands/run.mjs} +9 -82
- package/dist/cli/config/defaults.mjs +129 -0
- package/dist/cli/config/index.mjs +2 -16
- package/dist/cli/config/loader.mjs +97 -0
- package/dist/cli/config/resolvers/compatibility.mjs +90 -0
- package/dist/cli/config/resolvers/imports.mjs +96 -0
- package/dist/cli/config/resolvers/paths.mjs +167 -0
- package/dist/cli/config/resolvers/storage.mjs +25 -0
- package/dist/cli/config/resolvers/url.mjs +7 -0
- package/dist/cli/config/types.mjs +191 -0
- package/dist/cli/core/app.mjs +92 -0
- package/dist/cli/core/devServer.mjs +8 -0
- package/dist/cli/core/env.mjs +76 -0
- package/dist/cli/core/installPackage.mjs +31 -0
- package/dist/cli/core/prepare.mjs +7 -0
- package/dist/cli/core/runtimeConfig.mjs +14 -0
- package/dist/cli/core/scan.mjs +39 -0
- package/dist/cli/core/silgi.mjs +125 -0
- package/dist/cli/core/templates.mjs +31 -0
- package/dist/cli/framework/emptyFramework.mjs +9 -0
- package/dist/cli/framework/h3.mjs +89 -0
- package/dist/cli/framework/index.mjs +8 -0
- package/dist/cli/framework/nitro.mjs +106 -0
- package/dist/cli/framework/nuxt.mjs +9 -0
- package/dist/cli/index.mjs +6 -9
- package/dist/cli/module/exportScan.mjs +130 -0
- package/dist/cli/module/install.mjs +59 -0
- package/dist/cli/module/scan.mjs +227 -0
- package/dist/cli/scan/commands.mjs +47 -0
- package/dist/cli/scan/prepareConfigs.mjs +46 -0
- package/dist/cli/scan/prepareCoreFile.mjs +166 -0
- package/dist/cli/scan/prepareFramework.mjs +73 -0
- package/dist/cli/scan/prepareSchema.mjs +177 -0
- package/dist/cli/scan/prepareServerFiles.mjs +119 -0
- package/dist/cli/scan/scanExportFile.mjs +155 -0
- package/dist/cli/scan/writeCoreFile.mjs +34 -0
- package/dist/cli/scan/writeScanFiles.mjs +30 -0
- package/dist/cli/scan/writeTypesAndFiles.mjs +109 -0
- package/dist/cli/utils/build-uri-map.mjs +39 -0
- package/dist/cli/utils/common.mjs +13 -0
- package/dist/{shared/silgi.DWfN_DdY.mjs → cli/utils/compatibility.mjs} +1 -1
- package/dist/cli/utils/generateRouterDTS.mjs +80 -0
- package/dist/cli/utils/ignore.mjs +46 -0
- package/dist/cli/utils/parser.mjs +168 -0
- package/dist/cli/utils/readScanFile.mjs +79 -0
- package/dist/cli/utils/storage.mjs +25 -0
- package/dist/core/createSilgi.mjs +76 -0
- package/dist/core/error.mjs +227 -0
- package/dist/core/index.mjs +8 -0
- package/dist/core/routeRules.mjs +288 -0
- package/dist/core/silgi.mjs +128 -0
- package/dist/core/silgiApp.mjs +25 -0
- package/dist/core/storage.mjs +15 -0
- package/dist/core/unctx.mjs +27 -0
- package/dist/core/uris/uri.mjs +33 -0
- package/dist/core/uris/utils.mjs +130 -0
- package/dist/core/utils/event.mjs +15 -0
- package/dist/core/utils/merge.mjs +29 -0
- package/dist/core/utils/runtime.mjs +22 -0
- package/dist/core/utils/schema.mjs +5 -0
- package/dist/core/utils/service.mjs +5 -0
- package/dist/core/utils/shared.mjs +5 -0
- package/dist/core/utils/storage.mjs +72 -0
- package/dist/index.mjs +20 -793
- package/dist/kit/errors.mjs +11 -0
- package/dist/kit/esm.mjs +14 -0
- package/dist/kit/fs.mjs +30 -0
- package/dist/kit/gen.mjs +44 -0
- package/dist/kit/hash.mjs +8 -0
- package/dist/kit/index.mjs +15 -528
- package/dist/kit/isFramework.mjs +25 -0
- package/dist/kit/logger.mjs +7 -0
- package/dist/kit/module.mjs +73 -0
- package/dist/kit/parseServices.mjs +57 -0
- package/dist/kit/path.mjs +34 -0
- package/dist/kit/preset.mjs +6 -0
- package/dist/kit/resolve.mjs +80 -0
- package/dist/kit/template.mjs +49 -0
- package/dist/kit/useRequest.mjs +91 -0
- package/dist/kit/utils.mjs +43 -0
- package/dist/package.json.mjs +5 -0
- package/package.json +1 -1
- package/dist/shared/silgi.BIBmUBIR.mjs +0 -772
- package/dist/shared/silgi.CvG35CGc.mjs +0 -2682
- /package/dist/{chunks → cli/commands}/init.mjs +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { genObjectFromRawEntries, genObjectFromRaw, genObjectFromValues } from 'knitwork';
|
|
2
|
+
import { join } from 'pathe';
|
|
3
|
+
import { writeFile } from 'silgi/kit';
|
|
4
|
+
|
|
5
|
+
async function prepareBuild(silgi) {
|
|
6
|
+
try {
|
|
7
|
+
if (!silgi?.routeRules?.exportRules) {
|
|
8
|
+
throw new Error("Invalid silgi configuration: routeRules or exportRules is undefined");
|
|
9
|
+
}
|
|
10
|
+
const exportedRules = silgi.routeRules.exportRules();
|
|
11
|
+
if (!exportedRules || typeof exportedRules !== "object") {
|
|
12
|
+
throw new Error("No valid route rules to export");
|
|
13
|
+
}
|
|
14
|
+
const content = `/* eslint-disable */
|
|
15
|
+
// @ts-nocheck
|
|
16
|
+
// This file is auto-generated at build time by Silgi
|
|
17
|
+
// Contains route rules with preserved functions
|
|
18
|
+
// DO NOT MODIFY THIS FILE DIRECTLY
|
|
19
|
+
|
|
20
|
+
export const routeRules = ${genObjectFromRawEntries(
|
|
21
|
+
Object.entries(exportedRules).map(([key, value]) => {
|
|
22
|
+
if (typeof value === "function") {
|
|
23
|
+
return [key, genObjectFromRaw(value)];
|
|
24
|
+
}
|
|
25
|
+
return [key, genObjectFromValues(value)];
|
|
26
|
+
})
|
|
27
|
+
)}
|
|
28
|
+
`;
|
|
29
|
+
const serverDir = silgi.options.silgi.serverDir;
|
|
30
|
+
if (!serverDir) {
|
|
31
|
+
throw new Error("Server directory not defined in configuration");
|
|
32
|
+
}
|
|
33
|
+
const file = join(serverDir, "rules.ts");
|
|
34
|
+
if (!silgi.errors.length) {
|
|
35
|
+
await writeFile(file, content);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error("\u274C Failed to prepare build:", error instanceof Error ? error.message : String(error));
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { prepareBuild };
|
|
@@ -5,49 +5,10 @@ import consola from 'consola';
|
|
|
5
5
|
import { join } from 'pathe';
|
|
6
6
|
import { useSilgiCLI } from 'silgi';
|
|
7
7
|
import { version } from 'silgi/meta';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import '
|
|
11
|
-
import '
|
|
12
|
-
import 'node:fs';
|
|
13
|
-
import 'node:fs/promises';
|
|
14
|
-
import 'hookable';
|
|
15
|
-
import 'silgi/runtime/meta';
|
|
16
|
-
import 'unimport';
|
|
17
|
-
import 'ufo';
|
|
18
|
-
import '@clack/prompts';
|
|
19
|
-
import 'dotenv';
|
|
20
|
-
import 'mlly';
|
|
21
|
-
import 'dev-jiti';
|
|
22
|
-
import '../shared/silgi.DWfN_DdY.mjs';
|
|
23
|
-
import 'semver/functions/satisfies.js';
|
|
24
|
-
import 'node:url';
|
|
25
|
-
import 'defu';
|
|
26
|
-
import 'exsolve';
|
|
27
|
-
import 'untyped';
|
|
28
|
-
import 'globby';
|
|
29
|
-
import 'ignore';
|
|
30
|
-
import '@oxc-parser/wasm';
|
|
31
|
-
import 'klona';
|
|
32
|
-
import 'silgi/runtime';
|
|
33
|
-
import 'unstorage';
|
|
34
|
-
import '../shared/silgi.BIBmUBIR.mjs';
|
|
35
|
-
import 'c12';
|
|
36
|
-
import 'compatx';
|
|
37
|
-
import 'klona/full';
|
|
38
|
-
import 'std-env';
|
|
39
|
-
import 'consola/utils';
|
|
40
|
-
import 'escape-string-regexp';
|
|
41
|
-
import 'pkg-types';
|
|
42
|
-
import 'pathe/utils';
|
|
43
|
-
import 'unctx';
|
|
44
|
-
import 'node:child_process';
|
|
45
|
-
import 'picocolors';
|
|
46
|
-
|
|
47
|
-
async function reloadScan(path, _stats) {
|
|
48
|
-
const silgi = useSilgiCLI();
|
|
49
|
-
await silgi.callHook("reload:scan", path, _stats);
|
|
50
|
-
}
|
|
8
|
+
import { silgiCLIIClose } from '../../core/silgiApp.mjs';
|
|
9
|
+
import { reloadScan } from '../core/devServer.mjs';
|
|
10
|
+
import { commonArgs } from '../utils/common.mjs';
|
|
11
|
+
import prepare from './prepare.mjs';
|
|
51
12
|
|
|
52
13
|
const dev = defineCommand({
|
|
53
14
|
meta: {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as p from '@clack/prompts';
|
|
2
|
+
import { setupDotenv } from '../core/env.mjs';
|
|
3
|
+
|
|
4
|
+
let initialized = false;
|
|
5
|
+
async function prepareEnv(silgiConfig) {
|
|
6
|
+
if (initialized)
|
|
7
|
+
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
|
+
{ label: "Development (.env.dev)", value: "dev" },
|
|
17
|
+
{ label: "Docker (.env.docker)", value: "docker" },
|
|
18
|
+
{ label: "Staging (.env.staging)", value: "staging" },
|
|
19
|
+
{ label: "Testing (.env.testing)", value: "testing" },
|
|
20
|
+
{ label: "Production (.env)", value: ".env" }
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
const findEnv = customEnvironments?.find((env) => env.fileName === environment);
|
|
24
|
+
if (findEnv) {
|
|
25
|
+
await setupDotenv({
|
|
26
|
+
cwd: findEnv.cwd || silgiConfig.rootDir,
|
|
27
|
+
interpolate: findEnv.interpolate,
|
|
28
|
+
fileName: findEnv.fileName,
|
|
29
|
+
env: findEnv.env
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
await setupDotenv({
|
|
33
|
+
cwd: silgiConfig.rootDir,
|
|
34
|
+
interpolate: true,
|
|
35
|
+
fileName: environment === ".env" ? ".env" : `.env.${environment}`
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { prepareEnv };
|
|
@@ -4,43 +4,9 @@ import { defineCommand, runCommand } from 'citty';
|
|
|
4
4
|
import { consola } from 'consola';
|
|
5
5
|
import { resolve } from 'pathe';
|
|
6
6
|
import { version } from 'silgi/meta';
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import '../
|
|
10
|
-
import 'knitwork';
|
|
11
|
-
import 'silgi/kit';
|
|
12
|
-
import 'node:fs/promises';
|
|
13
|
-
import 'hookable';
|
|
14
|
-
import 'silgi';
|
|
15
|
-
import 'silgi/runtime/meta';
|
|
16
|
-
import 'unimport';
|
|
17
|
-
import 'ufo';
|
|
18
|
-
import '@clack/prompts';
|
|
19
|
-
import 'dotenv';
|
|
20
|
-
import 'mlly';
|
|
21
|
-
import 'dev-jiti';
|
|
22
|
-
import '../shared/silgi.DWfN_DdY.mjs';
|
|
23
|
-
import 'semver/functions/satisfies.js';
|
|
24
|
-
import 'node:url';
|
|
25
|
-
import 'defu';
|
|
26
|
-
import 'exsolve';
|
|
27
|
-
import 'untyped';
|
|
28
|
-
import 'globby';
|
|
29
|
-
import 'ignore';
|
|
30
|
-
import '@oxc-parser/wasm';
|
|
31
|
-
import 'klona';
|
|
32
|
-
import 'silgi/runtime';
|
|
33
|
-
import 'unstorage';
|
|
34
|
-
import 'pathe/utils';
|
|
35
|
-
import 'unctx';
|
|
36
|
-
import 'picocolors';
|
|
37
|
-
import 'c12';
|
|
38
|
-
import 'compatx';
|
|
39
|
-
import 'klona/full';
|
|
40
|
-
import 'std-env';
|
|
41
|
-
import 'consola/utils';
|
|
42
|
-
import 'escape-string-regexp';
|
|
43
|
-
import 'pkg-types';
|
|
7
|
+
import { commonArgs } from '../utils/common.mjs';
|
|
8
|
+
import prepare from './prepare.mjs';
|
|
9
|
+
import { loadOptions } from '../config/loader.mjs';
|
|
44
10
|
|
|
45
11
|
const install = defineCommand({
|
|
46
12
|
meta: {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { defineCommand, runCommand } from 'citty';
|
|
2
|
+
import { resolve } from 'pathe';
|
|
3
|
+
import { version } from 'silgi/meta';
|
|
4
|
+
import { prepareBuild } from '../build/prepare.mjs';
|
|
5
|
+
import { prepare as prepare$1 } from '../core/prepare.mjs';
|
|
6
|
+
import { createSilgiCLI } from '../core/silgi.mjs';
|
|
7
|
+
import { writeCoreFile } from '../scan/writeCoreFile.mjs';
|
|
8
|
+
import { writeTypesAndFiles } from '../scan/writeTypesAndFiles.mjs';
|
|
9
|
+
import { commonArgs } from '../utils/common.mjs';
|
|
10
|
+
import run from './run.mjs';
|
|
11
|
+
|
|
12
|
+
const prepare = defineCommand({
|
|
13
|
+
meta: {
|
|
14
|
+
name: "prepare",
|
|
15
|
+
description: "Generate types for the project",
|
|
16
|
+
version: version
|
|
17
|
+
},
|
|
18
|
+
args: {
|
|
19
|
+
...commonArgs,
|
|
20
|
+
preset: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
23
|
+
},
|
|
24
|
+
stub: {
|
|
25
|
+
type: "boolean",
|
|
26
|
+
description: "Run in silgi development mode"
|
|
27
|
+
},
|
|
28
|
+
dev: {
|
|
29
|
+
type: "boolean",
|
|
30
|
+
description: "Run in silgi development mode"
|
|
31
|
+
},
|
|
32
|
+
env: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "The environment to use"
|
|
35
|
+
},
|
|
36
|
+
commands: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "The commands to run"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
async run({ args }) {
|
|
42
|
+
const rootDir = resolve(args.dir || args._dir || ".");
|
|
43
|
+
const silgi = await createSilgiCLI({
|
|
44
|
+
rootDir,
|
|
45
|
+
dev: args.dev || args.stub,
|
|
46
|
+
stub: args.stub,
|
|
47
|
+
preset: args.preset,
|
|
48
|
+
commandType: "prepare",
|
|
49
|
+
activeEnvironment: args.env
|
|
50
|
+
});
|
|
51
|
+
await prepare$1();
|
|
52
|
+
await writeTypesAndFiles(silgi);
|
|
53
|
+
await writeCoreFile(silgi);
|
|
54
|
+
await prepareBuild(silgi);
|
|
55
|
+
if (!args.commands) {
|
|
56
|
+
await runCommand(run, {
|
|
57
|
+
rawArgs: ["--tag", "init", "--active", "false"]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
silgi
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export { prepare as default };
|
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
import { defineCommand, runCommand } from 'citty';
|
|
2
|
-
import { resolve } from 'pathe';
|
|
3
|
-
import { version } from 'silgi/meta';
|
|
4
|
-
import { p as prepareEnv, s as silgiCLIIClose, c as createSilgiCLI, a as prepare$2, w as writeTypesAndFiles, b as writeCoreFile, d as prepareBuild } from '../shared/silgi.CvG35CGc.mjs';
|
|
5
1
|
import { execSync } from 'node:child_process';
|
|
6
2
|
import { readFileSync } from 'node:fs';
|
|
7
3
|
import * as p from '@clack/prompts';
|
|
4
|
+
import { defineCommand, runCommand } from 'citty';
|
|
8
5
|
import { consola } from 'consola';
|
|
9
6
|
import { createJiti } from 'dev-jiti';
|
|
7
|
+
import { resolve } from 'pathe';
|
|
10
8
|
import color from 'picocolors';
|
|
11
9
|
import { useSilgiCLI } from 'silgi';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
_dir: {
|
|
20
|
-
type: "positional",
|
|
21
|
-
default: ".",
|
|
22
|
-
description: "project root directory (prefer using `--dir`)"
|
|
23
|
-
}
|
|
24
|
-
};
|
|
10
|
+
import { version } from 'silgi/meta';
|
|
11
|
+
import { silgiCLIIClose } from '../../core/silgiApp.mjs';
|
|
12
|
+
import { commonArgs } from '../utils/common.mjs';
|
|
13
|
+
import { prepareEnv } from './env.mjs';
|
|
14
|
+
import prepare from './prepare.mjs';
|
|
15
|
+
import { loadOptions } from '../config/loader.mjs';
|
|
25
16
|
|
|
26
17
|
const run = defineCommand({
|
|
27
18
|
meta: {
|
|
@@ -181,68 +172,4 @@ const run = defineCommand({
|
|
|
181
172
|
}
|
|
182
173
|
});
|
|
183
174
|
|
|
184
|
-
|
|
185
|
-
__proto__: null,
|
|
186
|
-
default: run
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
const prepare = defineCommand({
|
|
190
|
-
meta: {
|
|
191
|
-
name: "prepare",
|
|
192
|
-
description: "Generate types for the project",
|
|
193
|
-
version: version
|
|
194
|
-
},
|
|
195
|
-
args: {
|
|
196
|
-
...commonArgs,
|
|
197
|
-
preset: {
|
|
198
|
-
type: "string",
|
|
199
|
-
description: "The build preset to use (you can also use `SILGI_PRESET` environment variable)."
|
|
200
|
-
},
|
|
201
|
-
stub: {
|
|
202
|
-
type: "boolean",
|
|
203
|
-
description: "Run in silgi development mode"
|
|
204
|
-
},
|
|
205
|
-
dev: {
|
|
206
|
-
type: "boolean",
|
|
207
|
-
description: "Run in silgi development mode"
|
|
208
|
-
},
|
|
209
|
-
env: {
|
|
210
|
-
type: "string",
|
|
211
|
-
description: "The environment to use"
|
|
212
|
-
},
|
|
213
|
-
commands: {
|
|
214
|
-
type: "string",
|
|
215
|
-
description: "The commands to run"
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
async run({ args }) {
|
|
219
|
-
const rootDir = resolve(args.dir || args._dir || ".");
|
|
220
|
-
const silgi = await createSilgiCLI({
|
|
221
|
-
rootDir,
|
|
222
|
-
dev: args.dev || args.stub,
|
|
223
|
-
stub: args.stub,
|
|
224
|
-
preset: args.preset,
|
|
225
|
-
commandType: "prepare",
|
|
226
|
-
activeEnvironment: args.env
|
|
227
|
-
});
|
|
228
|
-
await prepare$2();
|
|
229
|
-
await writeTypesAndFiles(silgi);
|
|
230
|
-
await writeCoreFile(silgi);
|
|
231
|
-
await prepareBuild(silgi);
|
|
232
|
-
if (!args.commands) {
|
|
233
|
-
await runCommand(run, {
|
|
234
|
-
rawArgs: ["--tag", "init", "--active", "false"]
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
silgi
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
const prepare$1 = {
|
|
244
|
-
__proto__: null,
|
|
245
|
-
default: prepare
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
export { prepare$1 as a, commonArgs as c, prepare as p, run$1 as r };
|
|
175
|
+
export { run as default };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { isDebug, isTest } from 'std-env';
|
|
2
|
+
|
|
3
|
+
const SilgiCLIDefaults = {
|
|
4
|
+
// General
|
|
5
|
+
debug: isDebug,
|
|
6
|
+
// timing: isDebug,
|
|
7
|
+
logLevel: isTest ? 1 : 3,
|
|
8
|
+
// runtimeConfig: { app: {}, silgi: {} },
|
|
9
|
+
appConfig: {},
|
|
10
|
+
appConfigFiles: [],
|
|
11
|
+
commandType: "prepare",
|
|
12
|
+
runtimeConfig: {
|
|
13
|
+
silgi: {
|
|
14
|
+
version: "0.0.1"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
serviceParseModules: [],
|
|
18
|
+
storages: [],
|
|
19
|
+
devServer: {
|
|
20
|
+
watch: []
|
|
21
|
+
},
|
|
22
|
+
// Dirs
|
|
23
|
+
scanDirs: [],
|
|
24
|
+
build: {
|
|
25
|
+
dir: ".silgi",
|
|
26
|
+
typesDir: "{{ build.dir }}/types",
|
|
27
|
+
templates: []
|
|
28
|
+
},
|
|
29
|
+
output: {
|
|
30
|
+
dir: "{{ rootDir }}/.output",
|
|
31
|
+
serverDir: "{{ output.dir }}/server",
|
|
32
|
+
publicDir: "{{ output.dir }}/public"
|
|
33
|
+
},
|
|
34
|
+
serverDir: "{{ rootDir }}/server",
|
|
35
|
+
clientDir: "{{ rootDir }}/client",
|
|
36
|
+
silgi: {
|
|
37
|
+
serverDir: "{{ serverDir }}/silgi",
|
|
38
|
+
clientDir: "{{ clientDir }}/silgi",
|
|
39
|
+
publicDir: "{{ silgi.serverDir }}/public",
|
|
40
|
+
utilsDir: "{{ silgi.serverDir }}/utils",
|
|
41
|
+
vfsDir: "{{ silgi.serverDir }}/vfs",
|
|
42
|
+
typesDir: "{{ silgi.serverDir }}/types"
|
|
43
|
+
},
|
|
44
|
+
// Modules
|
|
45
|
+
_modules: [],
|
|
46
|
+
modules: [],
|
|
47
|
+
routeRules: {},
|
|
48
|
+
// Features
|
|
49
|
+
// experimental: {},
|
|
50
|
+
future: {},
|
|
51
|
+
storage: {},
|
|
52
|
+
devStorage: {},
|
|
53
|
+
stub: false,
|
|
54
|
+
// bundledStorage: [],
|
|
55
|
+
// publicAssets: [],
|
|
56
|
+
// serverAssets: [],
|
|
57
|
+
plugins: [],
|
|
58
|
+
// tasks: {},
|
|
59
|
+
// scheduledTasks: {},
|
|
60
|
+
imports: {
|
|
61
|
+
exclude: [],
|
|
62
|
+
dirs: [],
|
|
63
|
+
presets: [],
|
|
64
|
+
virtualImports: ["#silgiImports"]
|
|
65
|
+
},
|
|
66
|
+
// virtual: {},
|
|
67
|
+
// compressPublicAssets: false,
|
|
68
|
+
ignore: [],
|
|
69
|
+
// Dev
|
|
70
|
+
dev: false,
|
|
71
|
+
// devServer: { watch: [] },
|
|
72
|
+
watchOptions: {
|
|
73
|
+
ignoreInitial: true,
|
|
74
|
+
ignored: [
|
|
75
|
+
"**/node_modules/**",
|
|
76
|
+
"**/.git/**",
|
|
77
|
+
"**/.silgi/**",
|
|
78
|
+
"**/.output/**",
|
|
79
|
+
"**/.vscode/**",
|
|
80
|
+
"**/.idea/**",
|
|
81
|
+
"**/.nuxt/**",
|
|
82
|
+
"**/.next/**",
|
|
83
|
+
"**/.gitignore",
|
|
84
|
+
"**/.gitattributes",
|
|
85
|
+
"**/assets/**",
|
|
86
|
+
"**/dist/**",
|
|
87
|
+
"**/build/**",
|
|
88
|
+
"**/coverage/**",
|
|
89
|
+
"**/test/**",
|
|
90
|
+
"**/tests/**",
|
|
91
|
+
"**/tmp/**"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
// devProxy: {},
|
|
95
|
+
// Logging
|
|
96
|
+
// logging: {
|
|
97
|
+
// compressedSizes: true,
|
|
98
|
+
// buildSuccess: true,
|
|
99
|
+
// },
|
|
100
|
+
// Routing
|
|
101
|
+
// baseURL: process.env.NITRO_APP_BASE_URL || '/',
|
|
102
|
+
// handlers: [],
|
|
103
|
+
// devHandlers: [],
|
|
104
|
+
// errorHandler: undefined,
|
|
105
|
+
// Advanced
|
|
106
|
+
typescript: {
|
|
107
|
+
strict: false,
|
|
108
|
+
generateTsConfig: true,
|
|
109
|
+
// generateRuntimeConfigTypes: true,
|
|
110
|
+
tsconfigPath: ".silgi/types/silgi.tsconfig.json",
|
|
111
|
+
tsConfig: {},
|
|
112
|
+
customConditions: [],
|
|
113
|
+
generateRuntimeConfigTypes: true,
|
|
114
|
+
removeFileExtension: false
|
|
115
|
+
},
|
|
116
|
+
conditions: [],
|
|
117
|
+
nodeModulesDirs: [],
|
|
118
|
+
// hooks: {},
|
|
119
|
+
commands: {},
|
|
120
|
+
// Framework
|
|
121
|
+
framework: {
|
|
122
|
+
name: "h3",
|
|
123
|
+
version: ""
|
|
124
|
+
},
|
|
125
|
+
extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".vue"],
|
|
126
|
+
ignoreOptions: void 0
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export { SilgiCLIDefaults };
|
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
import 'compatx';
|
|
4
|
-
import 'klona/full';
|
|
5
|
-
import 'std-env';
|
|
6
|
-
import 'consola';
|
|
7
|
-
import 'consola/utils';
|
|
8
|
-
import 'pathe';
|
|
9
|
-
import 'escape-string-regexp';
|
|
10
|
-
import 'mlly';
|
|
11
|
-
import 'node:fs';
|
|
12
|
-
import 'pkg-types';
|
|
13
|
-
import 'silgi/kit';
|
|
14
|
-
import 'silgi/runtime/meta';
|
|
15
|
-
import 'ufo';
|
|
16
|
-
import 'defu';
|
|
1
|
+
export { loadOptions } from './loader.mjs';
|
|
2
|
+
export { silgiGenerateType } from './types.mjs';
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { watchConfig, loadConfig } from 'c12';
|
|
2
|
+
import { resolveCompatibilityDates } from 'compatx';
|
|
3
|
+
import { klona } from 'klona/full';
|
|
4
|
+
import { SilgiCLIDefaults } from './defaults.mjs';
|
|
5
|
+
import { resolveCompatibilityOptions, fallbackCompatibilityDate } from './resolvers/compatibility.mjs';
|
|
6
|
+
import { resolveImportsOptions } from './resolvers/imports.mjs';
|
|
7
|
+
import { resolvePathOptions } from './resolvers/paths.mjs';
|
|
8
|
+
import { resolveStorageOptions } from './resolvers/storage.mjs';
|
|
9
|
+
import { resolveURLOptions } from './resolvers/url.mjs';
|
|
10
|
+
|
|
11
|
+
const configResolvers = [
|
|
12
|
+
resolveCompatibilityOptions,
|
|
13
|
+
resolvePathOptions,
|
|
14
|
+
resolveImportsOptions,
|
|
15
|
+
// resolveRouteRulesOptions,
|
|
16
|
+
// resolveDatabaseOptions,
|
|
17
|
+
// resolveFetchOptions,
|
|
18
|
+
// resolveExportConditionsOptions,
|
|
19
|
+
// resolveRuntimeConfigOptions,
|
|
20
|
+
// resolveOpenAPIOptions,
|
|
21
|
+
resolveURLOptions,
|
|
22
|
+
// resolveAssetsOptions,
|
|
23
|
+
resolveStorageOptions
|
|
24
|
+
// resolveErrorOptions,
|
|
25
|
+
];
|
|
26
|
+
async function loadOptions(configOverrides = {}, opts = {}) {
|
|
27
|
+
const options = await _loadUserConfig(configOverrides, opts);
|
|
28
|
+
for (const resolver of configResolvers) {
|
|
29
|
+
await resolver(options);
|
|
30
|
+
}
|
|
31
|
+
return options;
|
|
32
|
+
}
|
|
33
|
+
async function _loadUserConfig(configOverrides = {}, opts = {}) {
|
|
34
|
+
const presetOverride = configOverrides.preset || process.env.SILGI_PRESET;
|
|
35
|
+
if (configOverrides.dev) ;
|
|
36
|
+
configOverrides = klona(configOverrides);
|
|
37
|
+
globalThis.defineSilgiConfig = globalThis.defineSilgiConfig || ((c) => c);
|
|
38
|
+
let compatibilityDate = configOverrides.compatibilityDate || opts.compatibilityDate || (process.env.SILGI_COMPATIBILITY_DATE || process.env.SERVER_COMPATIBILITY_DATE || process.env.COMPATIBILITY_DATE);
|
|
39
|
+
const { resolvePreset } = await import('silgi/presets');
|
|
40
|
+
const loadedConfig = await (opts.watch ? watchConfig : loadConfig)({
|
|
41
|
+
name: "silgi",
|
|
42
|
+
cwd: configOverrides.rootDir,
|
|
43
|
+
dotenv: configOverrides.dev,
|
|
44
|
+
extend: { extendKey: ["extends", "preset"] },
|
|
45
|
+
overrides: {
|
|
46
|
+
...configOverrides,
|
|
47
|
+
preset: presetOverride
|
|
48
|
+
},
|
|
49
|
+
async defaultConfig({ configs }) {
|
|
50
|
+
const getConf = (key) => configs.main?.[key] ?? configs.rc?.[key] ?? configs.packageJson?.[key];
|
|
51
|
+
if (!compatibilityDate) {
|
|
52
|
+
compatibilityDate = getConf("compatibilityDate");
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
// typescript: {
|
|
56
|
+
// generateRuntimeConfigTypes:
|
|
57
|
+
// !framework?.name || framework.name === 'nitro',
|
|
58
|
+
// },
|
|
59
|
+
preset: presetOverride || (await resolvePreset("", {
|
|
60
|
+
static: getConf("static"),
|
|
61
|
+
compatibilityDate: compatibilityDate || fallbackCompatibilityDate
|
|
62
|
+
}))?._meta?.name
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
defaults: SilgiCLIDefaults,
|
|
66
|
+
jitiOptions: {
|
|
67
|
+
alias: {
|
|
68
|
+
"silgi/config": "silgi/config"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
async resolve(id) {
|
|
72
|
+
const preset = await resolvePreset(id, {
|
|
73
|
+
static: configOverrides.static,
|
|
74
|
+
compatibilityDate: compatibilityDate || fallbackCompatibilityDate
|
|
75
|
+
});
|
|
76
|
+
if (preset) {
|
|
77
|
+
return {
|
|
78
|
+
config: klona(preset)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
...opts.c12
|
|
83
|
+
});
|
|
84
|
+
delete globalThis.defineSilgiConfig;
|
|
85
|
+
const options = klona(loadedConfig.config);
|
|
86
|
+
options._config = configOverrides;
|
|
87
|
+
options._c12 = loadedConfig;
|
|
88
|
+
const _presetName = (loadedConfig.layers || []).find((l) => l.config?._meta?.name)?.config?._meta?.name || presetOverride;
|
|
89
|
+
options.preset = _presetName;
|
|
90
|
+
options.compatibilityDate = resolveCompatibilityDates(
|
|
91
|
+
compatibilityDate,
|
|
92
|
+
options.compatibilityDate
|
|
93
|
+
);
|
|
94
|
+
return options;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { loadOptions };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { resolveCompatibilityDatesFromEnv, formatDate } from 'compatx';
|
|
2
|
+
import consola from 'consola';
|
|
3
|
+
import { colors } from 'consola/utils';
|
|
4
|
+
import { relative } from 'pathe';
|
|
5
|
+
|
|
6
|
+
const fallbackCompatibilityDate = "2025-02-04";
|
|
7
|
+
async function resolveCompatibilityOptions(options) {
|
|
8
|
+
options.compatibilityDate = resolveCompatibilityDatesFromEnv(
|
|
9
|
+
options.compatibilityDate
|
|
10
|
+
);
|
|
11
|
+
if (!options.compatibilityDate.default) {
|
|
12
|
+
options.compatibilityDate.default = await _resolveDefault(options);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
let _fallbackInfoShown = false;
|
|
16
|
+
let _promptedUserToUpdate = false;
|
|
17
|
+
async function _resolveDefault(options) {
|
|
18
|
+
const _todayDate = formatDate(/* @__PURE__ */ new Date());
|
|
19
|
+
const consola$1 = consola.withTag("silgi");
|
|
20
|
+
consola$1.warn(`No valid compatibility date is specified.`);
|
|
21
|
+
const onFallback = () => {
|
|
22
|
+
if (!_fallbackInfoShown) {
|
|
23
|
+
consola$1.info(
|
|
24
|
+
[
|
|
25
|
+
`Using \`${fallbackCompatibilityDate}\` as fallback.`,
|
|
26
|
+
` Please specify compatibility date to avoid unwanted behavior changes:`,
|
|
27
|
+
` - Add \`compatibilityDate: '${_todayDate}'\` to the config file.`,
|
|
28
|
+
` - Or set \`COMPATIBILITY_DATE=${_todayDate}\` environment variable.`,
|
|
29
|
+
``
|
|
30
|
+
].join("\n")
|
|
31
|
+
);
|
|
32
|
+
_fallbackInfoShown = true;
|
|
33
|
+
}
|
|
34
|
+
return fallbackCompatibilityDate;
|
|
35
|
+
};
|
|
36
|
+
const shallUpdate = !_promptedUserToUpdate && await consola$1.prompt(
|
|
37
|
+
`Do you want to auto update config file to set ${colors.cyan(`compatibilityDate: '${_todayDate}'`)}?`,
|
|
38
|
+
{
|
|
39
|
+
type: "confirm",
|
|
40
|
+
default: true
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
_promptedUserToUpdate = true;
|
|
44
|
+
if (!shallUpdate) {
|
|
45
|
+
return onFallback();
|
|
46
|
+
}
|
|
47
|
+
const { updateConfig } = await import('c12/update');
|
|
48
|
+
const updateResult = await updateConfig({
|
|
49
|
+
configFile: "silgi.config",
|
|
50
|
+
cwd: options.rootDir,
|
|
51
|
+
async onCreate({ configFile }) {
|
|
52
|
+
const shallCreate = await consola$1.prompt(
|
|
53
|
+
`Do you want to initialize a new config in ${colors.cyan(relative(".", configFile))}?`,
|
|
54
|
+
{
|
|
55
|
+
type: "confirm",
|
|
56
|
+
default: true
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
if (shallCreate !== true) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return _getDefaultNitroConfig();
|
|
63
|
+
},
|
|
64
|
+
async onUpdate(config) {
|
|
65
|
+
config.compatibilityDate = _todayDate;
|
|
66
|
+
}
|
|
67
|
+
}).catch((error) => {
|
|
68
|
+
consola$1.error(`Failed to update config: ${error.message}`);
|
|
69
|
+
return null;
|
|
70
|
+
});
|
|
71
|
+
if (updateResult?.configFile) {
|
|
72
|
+
consola$1.success(
|
|
73
|
+
`Compatibility date set to \`${_todayDate}\` in \`${relative(".", updateResult.configFile)}\``
|
|
74
|
+
);
|
|
75
|
+
return _todayDate;
|
|
76
|
+
}
|
|
77
|
+
return onFallback();
|
|
78
|
+
}
|
|
79
|
+
function _getDefaultNitroConfig() {
|
|
80
|
+
return (
|
|
81
|
+
/* js */
|
|
82
|
+
`
|
|
83
|
+
import { defineSilgiConfig } from 'silgi/config'
|
|
84
|
+
|
|
85
|
+
export default defineSilgiConfig({})
|
|
86
|
+
`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { fallbackCompatibilityDate, resolveCompatibilityOptions };
|