silgi 0.27.4 → 0.27.6
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/silgiApp.mjs +287 -1
- package/dist/build.d.mts +3 -16
- package/dist/build.mjs +8 -32
- package/dist/cli/build.mjs +861 -0
- package/dist/cli/config/index.mjs +2 -1
- package/dist/cli/dev.mjs +12 -12
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/init.mjs +14 -14
- package/dist/cli/install.mjs +14 -14
- package/dist/cli/loader.mjs +598 -0
- package/dist/cli/prepare.mjs +1575 -18
- package/dist/cli/types.mjs +6 -597
- package/dist/core/index.mjs +2 -2
- package/dist/index.mjs +1 -2
- package/dist/runtime/internal/config.mjs +3 -3
- package/package.json +1 -1
- package/dist/_chunks/routeRules.mjs +0 -288
- package/dist/cli/writeTypesAndFiles.mjs +0 -2413
package/dist/cli/types.mjs
CHANGED
|
@@ -1,600 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { resolveCompatibilityDatesFromEnv, formatDate, resolveCompatibilityDates } from 'compatx';
|
|
3
|
-
import { klona } from 'klona/full';
|
|
4
|
-
import { isDebug, isTest } from 'std-env';
|
|
5
|
-
import consola from 'consola';
|
|
6
|
-
import { colors } from 'consola/utils';
|
|
7
|
-
import { relative, join, resolve, dirname, isAbsolute } from 'pathe';
|
|
8
|
-
import escapeRE from 'escape-string-regexp';
|
|
9
|
-
import { resolveModuleExportNames } from 'mlly';
|
|
10
|
-
import { existsSync, promises, lstatSync } from 'node:fs';
|
|
11
|
-
import { findWorkspaceDir, readPackageJSON } from 'pkg-types';
|
|
12
|
-
import { resolveSilgiPath, relativeWithDot, resolveSilgiModule } from 'silgi/kit';
|
|
13
|
-
import { runtimeDir, pkgDir } from 'silgi/runtime/meta';
|
|
14
|
-
import { withLeadingSlash, withTrailingSlash } from 'ufo';
|
|
1
|
+
import { promises, lstatSync } from 'node:fs';
|
|
15
2
|
import { defu } from 'defu';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// timing: isDebug,
|
|
21
|
-
logLevel: isTest ? 1 : 3,
|
|
22
|
-
// runtimeConfig: { app: {}, silgi: {} },
|
|
23
|
-
appConfig: {},
|
|
24
|
-
appConfigFiles: [],
|
|
25
|
-
commandType: "prepare",
|
|
26
|
-
runtimeConfig: {
|
|
27
|
-
silgi: {
|
|
28
|
-
version: "0.0.1"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
serviceParseModules: [],
|
|
32
|
-
storages: [],
|
|
33
|
-
devServer: {
|
|
34
|
-
watch: []
|
|
35
|
-
},
|
|
36
|
-
// Dirs
|
|
37
|
-
scanDirs: [],
|
|
38
|
-
build: {
|
|
39
|
-
dir: ".silgi",
|
|
40
|
-
typesDir: "{{ build.dir }}/types",
|
|
41
|
-
templates: []
|
|
42
|
-
},
|
|
43
|
-
output: {
|
|
44
|
-
dir: "{{ rootDir }}/.output",
|
|
45
|
-
serverDir: "{{ output.dir }}/server",
|
|
46
|
-
publicDir: "{{ output.dir }}/public"
|
|
47
|
-
},
|
|
48
|
-
serverDir: "{{ rootDir }}/server",
|
|
49
|
-
clientDir: "{{ rootDir }}/client",
|
|
50
|
-
silgi: {
|
|
51
|
-
serverDir: "{{ serverDir }}/silgi",
|
|
52
|
-
clientDir: "{{ clientDir }}/silgi",
|
|
53
|
-
publicDir: "{{ silgi.serverDir }}/public",
|
|
54
|
-
utilsDir: "{{ silgi.serverDir }}/utils",
|
|
55
|
-
vfsDir: "{{ silgi.serverDir }}/vfs",
|
|
56
|
-
typesDir: "{{ silgi.serverDir }}/types"
|
|
57
|
-
},
|
|
58
|
-
// Codegen
|
|
59
|
-
codegen: {
|
|
60
|
-
env: {
|
|
61
|
-
safeList: [
|
|
62
|
-
["silgi", "version"]
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
// Modules
|
|
67
|
-
_modules: [],
|
|
68
|
-
modules: [],
|
|
69
|
-
routeRules: {},
|
|
70
|
-
// Features
|
|
71
|
-
// experimental: {},
|
|
72
|
-
future: {},
|
|
73
|
-
storage: {},
|
|
74
|
-
devStorage: {},
|
|
75
|
-
stub: false,
|
|
76
|
-
// bundledStorage: [],
|
|
77
|
-
// publicAssets: [],
|
|
78
|
-
// serverAssets: [],
|
|
79
|
-
plugins: [],
|
|
80
|
-
// tasks: {},
|
|
81
|
-
// scheduledTasks: {},
|
|
82
|
-
imports: {
|
|
83
|
-
exclude: [],
|
|
84
|
-
dirs: [],
|
|
85
|
-
presets: [],
|
|
86
|
-
virtualImports: ["#silgiImports"]
|
|
87
|
-
},
|
|
88
|
-
// virtual: {},
|
|
89
|
-
// compressPublicAssets: false,
|
|
90
|
-
ignore: [],
|
|
91
|
-
// Dev
|
|
92
|
-
dev: false,
|
|
93
|
-
// devServer: { watch: [] },
|
|
94
|
-
watchOptions: {
|
|
95
|
-
ignoreInitial: true,
|
|
96
|
-
ignored: [
|
|
97
|
-
"**/node_modules/**",
|
|
98
|
-
"**/.git/**",
|
|
99
|
-
"**/.silgi/**",
|
|
100
|
-
"**/.output/**",
|
|
101
|
-
"**/.vscode/**",
|
|
102
|
-
"**/.idea/**",
|
|
103
|
-
"**/.nuxt/**",
|
|
104
|
-
"**/.next/**",
|
|
105
|
-
"**/.gitignore",
|
|
106
|
-
"**/.gitattributes",
|
|
107
|
-
"**/assets/**",
|
|
108
|
-
"**/dist/**",
|
|
109
|
-
"**/build/**",
|
|
110
|
-
"**/coverage/**",
|
|
111
|
-
"**/test/**",
|
|
112
|
-
"**/tests/**",
|
|
113
|
-
"**/tmp/**"
|
|
114
|
-
]
|
|
115
|
-
},
|
|
116
|
-
// devProxy: {},
|
|
117
|
-
// Logging
|
|
118
|
-
// logging: {
|
|
119
|
-
// compressedSizes: true,
|
|
120
|
-
// buildSuccess: true,
|
|
121
|
-
// },
|
|
122
|
-
// Routing
|
|
123
|
-
// baseURL: process.env.NITRO_APP_BASE_URL || '/',
|
|
124
|
-
// handlers: [],
|
|
125
|
-
// devHandlers: [],
|
|
126
|
-
// errorHandler: undefined,
|
|
127
|
-
// Advanced
|
|
128
|
-
typescript: {
|
|
129
|
-
strict: false,
|
|
130
|
-
generateTsConfig: true,
|
|
131
|
-
// generateRuntimeConfigTypes: true,
|
|
132
|
-
tsconfigPath: ".silgi/types/silgi.tsconfig.json",
|
|
133
|
-
tsConfig: {},
|
|
134
|
-
customConditions: [],
|
|
135
|
-
generateRuntimeConfigTypes: true,
|
|
136
|
-
removeFileExtension: false
|
|
137
|
-
},
|
|
138
|
-
conditions: [],
|
|
139
|
-
nodeModulesDirs: [],
|
|
140
|
-
// hooks: {},
|
|
141
|
-
commands: {},
|
|
142
|
-
// Framework
|
|
143
|
-
framework: {
|
|
144
|
-
name: "h3",
|
|
145
|
-
version: ""
|
|
146
|
-
},
|
|
147
|
-
extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".vue"],
|
|
148
|
-
ignoreOptions: void 0,
|
|
149
|
-
// 3. party
|
|
150
|
-
apiFul: {}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const fallbackCompatibilityDate = "2025-02-04";
|
|
154
|
-
async function resolveCompatibilityOptions(options) {
|
|
155
|
-
options.compatibilityDate = resolveCompatibilityDatesFromEnv(
|
|
156
|
-
options.compatibilityDate
|
|
157
|
-
);
|
|
158
|
-
if (!options.compatibilityDate.default) {
|
|
159
|
-
options.compatibilityDate.default = await _resolveDefault(options);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
let _fallbackInfoShown = false;
|
|
163
|
-
let _promptedUserToUpdate = false;
|
|
164
|
-
async function _resolveDefault(options) {
|
|
165
|
-
const _todayDate = formatDate(/* @__PURE__ */ new Date());
|
|
166
|
-
const consola$1 = consola.withTag("silgi");
|
|
167
|
-
consola$1.warn(`No valid compatibility date is specified.`);
|
|
168
|
-
const onFallback = () => {
|
|
169
|
-
if (!_fallbackInfoShown) {
|
|
170
|
-
consola$1.info(
|
|
171
|
-
[
|
|
172
|
-
`Using \`${fallbackCompatibilityDate}\` as fallback.`,
|
|
173
|
-
` Please specify compatibility date to avoid unwanted behavior changes:`,
|
|
174
|
-
` - Add \`compatibilityDate: '${_todayDate}'\` to the config file.`,
|
|
175
|
-
` - Or set \`COMPATIBILITY_DATE=${_todayDate}\` environment variable.`,
|
|
176
|
-
``
|
|
177
|
-
].join("\n")
|
|
178
|
-
);
|
|
179
|
-
_fallbackInfoShown = true;
|
|
180
|
-
}
|
|
181
|
-
return fallbackCompatibilityDate;
|
|
182
|
-
};
|
|
183
|
-
const shallUpdate = !_promptedUserToUpdate && await consola$1.prompt(
|
|
184
|
-
`Do you want to auto update config file to set ${colors.cyan(`compatibilityDate: '${_todayDate}'`)}?`,
|
|
185
|
-
{
|
|
186
|
-
type: "confirm",
|
|
187
|
-
default: true
|
|
188
|
-
}
|
|
189
|
-
);
|
|
190
|
-
_promptedUserToUpdate = true;
|
|
191
|
-
if (!shallUpdate) {
|
|
192
|
-
return onFallback();
|
|
193
|
-
}
|
|
194
|
-
const { updateConfig } = await import('c12/update');
|
|
195
|
-
const updateResult = await updateConfig({
|
|
196
|
-
configFile: "silgi.config",
|
|
197
|
-
cwd: options.rootDir,
|
|
198
|
-
async onCreate({ configFile }) {
|
|
199
|
-
const shallCreate = await consola$1.prompt(
|
|
200
|
-
`Do you want to initialize a new config in ${colors.cyan(relative(".", configFile))}?`,
|
|
201
|
-
{
|
|
202
|
-
type: "confirm",
|
|
203
|
-
default: true
|
|
204
|
-
}
|
|
205
|
-
);
|
|
206
|
-
if (shallCreate !== true) {
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
return _getDefaultNitroConfig();
|
|
210
|
-
},
|
|
211
|
-
async onUpdate(config) {
|
|
212
|
-
config.compatibilityDate = _todayDate;
|
|
213
|
-
}
|
|
214
|
-
}).catch((error) => {
|
|
215
|
-
consola$1.error(`Failed to update config: ${error.message}`);
|
|
216
|
-
return null;
|
|
217
|
-
});
|
|
218
|
-
if (updateResult?.configFile) {
|
|
219
|
-
consola$1.success(
|
|
220
|
-
`Compatibility date set to \`${_todayDate}\` in \`${relative(".", updateResult.configFile)}\``
|
|
221
|
-
);
|
|
222
|
-
return _todayDate;
|
|
223
|
-
}
|
|
224
|
-
return onFallback();
|
|
225
|
-
}
|
|
226
|
-
function _getDefaultNitroConfig() {
|
|
227
|
-
return (
|
|
228
|
-
/* js */
|
|
229
|
-
`
|
|
230
|
-
import { defineSilgiConfig } from 'silgi/config'
|
|
231
|
-
|
|
232
|
-
export default defineSilgiConfig({})
|
|
233
|
-
`
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
async function resolveImportsOptions(options) {
|
|
238
|
-
if (options.imports === false) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
options.imports.presets ??= [];
|
|
242
|
-
options.imports.presets.push(...getSilgiImportsPreset());
|
|
243
|
-
if (options.preset === "h3") {
|
|
244
|
-
const h3Exports = await resolveModuleExportNames("h3", {
|
|
245
|
-
url: import.meta.url
|
|
246
|
-
});
|
|
247
|
-
options.imports.presets ??= [];
|
|
248
|
-
options.imports.presets.push({
|
|
249
|
-
from: "h3",
|
|
250
|
-
imports: h3Exports.filter((n) => !/^[A-Z]/.test(n) && n !== "use")
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
options.imports.dirs ??= [];
|
|
254
|
-
options.imports.dirs.push(
|
|
255
|
-
...options.scanDirs.map((dir) => join(dir, "utils/**/*"))
|
|
256
|
-
);
|
|
257
|
-
if (Array.isArray(options.imports.exclude) && options.imports.exclude.length === 0) {
|
|
258
|
-
options.imports.exclude.push(/[/\\]\.git[/\\]/);
|
|
259
|
-
options.imports.exclude.push(options.build.dir);
|
|
260
|
-
const scanDirsInNodeModules = options.scanDirs.map((dir) => dir.match(/(?<=\/)node_modules\/(.+)$/)?.[1]).filter(Boolean);
|
|
261
|
-
options.imports.exclude.push(
|
|
262
|
-
scanDirsInNodeModules.length > 0 ? new RegExp(
|
|
263
|
-
`node_modules\\/(?!${scanDirsInNodeModules.map((dir) => escapeRE(dir)).join("|")})`
|
|
264
|
-
) : /[/\\]node_modules[/\\]/
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
function getSilgiImportsPreset() {
|
|
269
|
-
return [
|
|
270
|
-
// TODO: buraya bizim importlarimiz gelecek.
|
|
271
|
-
{
|
|
272
|
-
from: "silgi",
|
|
273
|
-
imports: [
|
|
274
|
-
"createShared",
|
|
275
|
-
"useSilgi",
|
|
276
|
-
"createService",
|
|
277
|
-
"createSchema"
|
|
278
|
-
]
|
|
279
|
-
},
|
|
280
|
-
// {
|
|
281
|
-
// from: 'nitropack/runtime',
|
|
282
|
-
// imports: ['useRuntimeConfig', 'useAppConfig'],
|
|
283
|
-
// },
|
|
284
|
-
// {
|
|
285
|
-
// from: 'nitropack/runtime',
|
|
286
|
-
// imports: ['defineNitroPlugin', 'nitroPlugin'],
|
|
287
|
-
// },
|
|
288
|
-
// {
|
|
289
|
-
// from: 'nitropack/runtime/internal/cache',
|
|
290
|
-
// imports: [
|
|
291
|
-
// 'defineCachedFunction',
|
|
292
|
-
// 'defineCachedEventHandler',
|
|
293
|
-
// 'cachedFunction',
|
|
294
|
-
// 'cachedEventHandler',
|
|
295
|
-
// ],
|
|
296
|
-
// },
|
|
297
|
-
{
|
|
298
|
-
from: "silgi",
|
|
299
|
-
imports: ["useSilgiStorage"]
|
|
300
|
-
}
|
|
301
|
-
// {
|
|
302
|
-
// from: 'nitropack/runtime/internal/renderer',
|
|
303
|
-
// imports: ['defineRenderHandler'],
|
|
304
|
-
// },
|
|
305
|
-
// {
|
|
306
|
-
// from: 'nitropack/runtime/internal/meta',
|
|
307
|
-
// imports: ['defineRouteMeta'],
|
|
308
|
-
// },
|
|
309
|
-
// {
|
|
310
|
-
// from: 'nitropack/runtime/internal/route-rules',
|
|
311
|
-
// imports: ['getRouteRules'],
|
|
312
|
-
// },
|
|
313
|
-
// {
|
|
314
|
-
// from: 'nitropack/runtime/internal/context',
|
|
315
|
-
// imports: ['useEvent'],
|
|
316
|
-
// },
|
|
317
|
-
// {
|
|
318
|
-
// from: 'nitropack/runtime/internal/task',
|
|
319
|
-
// imports: ['defineTask', 'runTask'],
|
|
320
|
-
// },
|
|
321
|
-
// {
|
|
322
|
-
// from: 'nitropack/runtime/internal/error/utils',
|
|
323
|
-
// imports: ['defineNitroErrorHandler'],
|
|
324
|
-
// },
|
|
325
|
-
];
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
async function resolvePathOptions(options) {
|
|
329
|
-
options.rootDir = resolve(options.rootDir || ".");
|
|
330
|
-
options.workspaceDir = await findWorkspaceDir(options.rootDir).catch(
|
|
331
|
-
() => options.rootDir
|
|
332
|
-
);
|
|
333
|
-
options.srcDir = resolve(options.srcDir || options.rootDir);
|
|
334
|
-
for (const key of ["srcDir"]) {
|
|
335
|
-
options[key] = resolve(options.rootDir, options[key]);
|
|
336
|
-
}
|
|
337
|
-
options.build.dir = resolve(options.rootDir, options.build.dir);
|
|
338
|
-
options.build.typesDir = resolveSilgiPath(
|
|
339
|
-
options.build.typesDir || SilgiCLIDefaults.build.typesDir,
|
|
340
|
-
options,
|
|
341
|
-
options.rootDir
|
|
342
|
-
);
|
|
343
|
-
if (options.preset === "npm-package") {
|
|
344
|
-
const packageJsonPath = resolve(options.rootDir, "package.json");
|
|
345
|
-
const packageJson = await readPackageJSON(packageJsonPath);
|
|
346
|
-
if (packageJson.name === void 0) {
|
|
347
|
-
throw new Error("Package name is undefined");
|
|
348
|
-
}
|
|
349
|
-
options.alias ||= {};
|
|
350
|
-
options.alias[packageJson.name] = join(options.rootDir, "src/module");
|
|
351
|
-
options.alias[`${packageJson.name}/runtime/`] = join(options.rootDir, "src/runtime");
|
|
352
|
-
options.alias[`${packageJson.name}/runtime/*`] = join(options.rootDir, "src/runtime/*");
|
|
353
|
-
options.alias[`${packageJson.name}/types`] = join(options.rootDir, "src/types");
|
|
354
|
-
}
|
|
355
|
-
if (options.stub) {
|
|
356
|
-
options.alias = {
|
|
357
|
-
...options.alias,
|
|
358
|
-
"silgi/runtime": join(runtimeDir),
|
|
359
|
-
"#internal/silgi": join(runtimeDir),
|
|
360
|
-
"silgi/runtime/*": join(runtimeDir, "*"),
|
|
361
|
-
"#internal/silgi/*": join(runtimeDir, "*")
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
options.alias = {
|
|
365
|
-
...options.alias,
|
|
366
|
-
"~/": join(options.srcDir, "/"),
|
|
367
|
-
"@/": join(options.srcDir, "/"),
|
|
368
|
-
"~~/": join(options.rootDir, "/"),
|
|
369
|
-
"@@/": join(options.rootDir, "/")
|
|
370
|
-
};
|
|
371
|
-
if (options.preset === "npm-package") {
|
|
372
|
-
options.alias = {
|
|
373
|
-
...options.alias
|
|
374
|
-
// '#silgi/app/': join(options.build.dir, '/'),
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
if (options.alias && typeof options.alias === "object") {
|
|
378
|
-
((options.typescript.tsConfig ??= {}).compilerOptions ??= {}).paths ??= {};
|
|
379
|
-
const paths = options.typescript.tsConfig.compilerOptions.paths;
|
|
380
|
-
for (const [key, value] of Object.entries(options.alias)) {
|
|
381
|
-
if (typeof paths === "object") {
|
|
382
|
-
paths[key] = [value];
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
if (options.typescript.tsConfig.compilerOptions?.paths && typeof options.typescript.tsConfig.compilerOptions.paths === "object") {
|
|
387
|
-
((options.typescript.tsConfig ??= {}).compilerOptions ??= {}).paths ??= {};
|
|
388
|
-
const paths = options.typescript.tsConfig.compilerOptions.paths;
|
|
389
|
-
for (const [key, value] of Object.entries(options.alias)) {
|
|
390
|
-
if (typeof paths === "object") {
|
|
391
|
-
paths[key] = [value];
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
options.modulesDir = [resolve(options.rootDir, "node_modules")];
|
|
396
|
-
options.output.dir = resolveSilgiPath(
|
|
397
|
-
options.output.dir || SilgiCLIDefaults.output.dir,
|
|
398
|
-
options,
|
|
399
|
-
options.rootDir
|
|
400
|
-
);
|
|
401
|
-
options.output.publicDir = resolveSilgiPath(
|
|
402
|
-
options.output.publicDir || SilgiCLIDefaults.output.publicDir,
|
|
403
|
-
options,
|
|
404
|
-
options.rootDir
|
|
405
|
-
);
|
|
406
|
-
options.output.serverDir = resolveSilgiPath(
|
|
407
|
-
options.output.serverDir || SilgiCLIDefaults.output.serverDir,
|
|
408
|
-
options,
|
|
409
|
-
options.rootDir
|
|
410
|
-
);
|
|
411
|
-
options.serverDir = resolveSilgiPath(
|
|
412
|
-
options.serverDir || SilgiCLIDefaults.serverDir,
|
|
413
|
-
options,
|
|
414
|
-
options.rootDir
|
|
415
|
-
);
|
|
416
|
-
options.clientDir = resolveSilgiPath(
|
|
417
|
-
options.clientDir || SilgiCLIDefaults.clientDir,
|
|
418
|
-
options,
|
|
419
|
-
options.rootDir
|
|
420
|
-
);
|
|
421
|
-
options.silgi.serverDir = resolveSilgiPath(
|
|
422
|
-
options.silgi.serverDir || SilgiCLIDefaults.silgi.serverDir,
|
|
423
|
-
options,
|
|
424
|
-
options.rootDir
|
|
425
|
-
);
|
|
426
|
-
options.silgi.clientDir = resolveSilgiPath(
|
|
427
|
-
options.silgi.clientDir || SilgiCLIDefaults.silgi.clientDir,
|
|
428
|
-
options,
|
|
429
|
-
options.rootDir
|
|
430
|
-
);
|
|
431
|
-
options.silgi.publicDir = resolveSilgiPath(
|
|
432
|
-
options.silgi.publicDir || SilgiCLIDefaults.silgi.publicDir,
|
|
433
|
-
options,
|
|
434
|
-
options.rootDir
|
|
435
|
-
);
|
|
436
|
-
options.silgi.utilsDir = resolveSilgiPath(
|
|
437
|
-
options.silgi.utilsDir || SilgiCLIDefaults.silgi.utilsDir,
|
|
438
|
-
options,
|
|
439
|
-
options.rootDir
|
|
440
|
-
);
|
|
441
|
-
options.silgi.vfsDir = resolveSilgiPath(
|
|
442
|
-
options.silgi.vfsDir || SilgiCLIDefaults.silgi.vfsDir,
|
|
443
|
-
options,
|
|
444
|
-
options.rootDir
|
|
445
|
-
);
|
|
446
|
-
options.silgi.typesDir = resolveSilgiPath(
|
|
447
|
-
options.silgi.typesDir || SilgiCLIDefaults.silgi.typesDir,
|
|
448
|
-
options,
|
|
449
|
-
options.rootDir
|
|
450
|
-
);
|
|
451
|
-
options.nodeModulesDirs.push(resolve(options.workspaceDir, "node_modules"));
|
|
452
|
-
options.nodeModulesDirs.push(resolve(options.rootDir, "node_modules"));
|
|
453
|
-
options.nodeModulesDirs.push(resolve(pkgDir, "node_modules"));
|
|
454
|
-
options.nodeModulesDirs.push(resolve(pkgDir, ".."));
|
|
455
|
-
options.nodeModulesDirs = [
|
|
456
|
-
...new Set(
|
|
457
|
-
options.nodeModulesDirs.map((dir) => resolve(options.rootDir, dir))
|
|
458
|
-
)
|
|
459
|
-
];
|
|
460
|
-
options.scanDirs.unshift(options.srcDir);
|
|
461
|
-
options.scanDirs = options.scanDirs.map(
|
|
462
|
-
(dir) => resolve(options.srcDir, dir)
|
|
463
|
-
);
|
|
464
|
-
options.scanDirs = [...new Set(options.scanDirs)];
|
|
465
|
-
options.appConfigFiles ??= [];
|
|
466
|
-
options.appConfigFiles = options.appConfigFiles.map((file) => _tryResolve(resolveSilgiPath(file, options))).filter(Boolean);
|
|
467
|
-
for (const dir of options.scanDirs) {
|
|
468
|
-
const configFile = _tryResolve("app.config", dir);
|
|
469
|
-
if (configFile && !options.appConfigFiles.includes(configFile)) {
|
|
470
|
-
options.appConfigFiles.push(configFile);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
function _tryResolve(path, base = ".", extensions = ["", ".js", ".ts", ".mjs", ".cjs", ".json"]) {
|
|
475
|
-
path = resolve(base, path);
|
|
476
|
-
if (existsSync(path)) {
|
|
477
|
-
return path;
|
|
478
|
-
}
|
|
479
|
-
for (const ext of extensions) {
|
|
480
|
-
const p = path + ext;
|
|
481
|
-
if (existsSync(p)) {
|
|
482
|
-
return p;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
async function resolveStorageOptions(options) {
|
|
488
|
-
const fsMounts = {
|
|
489
|
-
root: resolve(options.rootDir),
|
|
490
|
-
src: resolve(options.srcDir),
|
|
491
|
-
build: resolve(options.build.dir),
|
|
492
|
-
cache: resolve(options.build.dir, "cache")
|
|
493
|
-
};
|
|
494
|
-
for (const p in fsMounts) {
|
|
495
|
-
options.devStorage[p] = options.devStorage[p] || {
|
|
496
|
-
driver: "fs",
|
|
497
|
-
readOnly: p === "root" || p === "src",
|
|
498
|
-
base: fsMounts[p]
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
if (options.dev && options.storage.data === void 0 && options.devStorage.data === void 0) {
|
|
502
|
-
options.devStorage.data = {
|
|
503
|
-
driver: "fs",
|
|
504
|
-
base: resolve(options.rootDir, ".data/kv")
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
async function resolveURLOptions(options) {
|
|
510
|
-
options.baseURL = withLeadingSlash(withTrailingSlash(options.baseURL));
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
const configResolvers = [
|
|
514
|
-
resolveCompatibilityOptions,
|
|
515
|
-
resolvePathOptions,
|
|
516
|
-
resolveImportsOptions,
|
|
517
|
-
// resolveRouteRulesOptions,
|
|
518
|
-
// resolveDatabaseOptions,
|
|
519
|
-
// resolveFetchOptions,
|
|
520
|
-
// resolveExportConditionsOptions,
|
|
521
|
-
// resolveRuntimeConfigOptions,
|
|
522
|
-
// resolveOpenAPIOptions,
|
|
523
|
-
resolveURLOptions,
|
|
524
|
-
// resolveAssetsOptions,
|
|
525
|
-
resolveStorageOptions
|
|
526
|
-
// resolveErrorOptions,
|
|
527
|
-
];
|
|
528
|
-
async function loadOptions(configOverrides = {}, opts = {}) {
|
|
529
|
-
const options = await _loadUserConfig(configOverrides, opts);
|
|
530
|
-
for (const resolver of configResolvers) {
|
|
531
|
-
await resolver(options);
|
|
532
|
-
}
|
|
533
|
-
return options;
|
|
534
|
-
}
|
|
535
|
-
async function _loadUserConfig(configOverrides = {}, opts = {}) {
|
|
536
|
-
const presetOverride = configOverrides.preset || process.env.SILGI_PRESET;
|
|
537
|
-
if (configOverrides.dev) ;
|
|
538
|
-
configOverrides = klona(configOverrides);
|
|
539
|
-
globalThis.defineSilgiConfig = globalThis.defineSilgiConfig || ((c) => c);
|
|
540
|
-
let compatibilityDate = configOverrides.compatibilityDate || opts.compatibilityDate || (process.env.SILGI_COMPATIBILITY_DATE || process.env.SERVER_COMPATIBILITY_DATE || process.env.COMPATIBILITY_DATE);
|
|
541
|
-
const { resolvePreset } = await import('silgi/presets');
|
|
542
|
-
const loadedConfig = await (opts.watch ? watchConfig : loadConfig)({
|
|
543
|
-
name: "silgi",
|
|
544
|
-
cwd: configOverrides.rootDir,
|
|
545
|
-
dotenv: configOverrides.dev,
|
|
546
|
-
extend: { extendKey: ["extends", "preset"] },
|
|
547
|
-
overrides: {
|
|
548
|
-
...configOverrides,
|
|
549
|
-
preset: presetOverride
|
|
550
|
-
},
|
|
551
|
-
async defaultConfig({ configs }) {
|
|
552
|
-
const getConf = (key) => configs.main?.[key] ?? configs.rc?.[key] ?? configs.packageJson?.[key];
|
|
553
|
-
if (!compatibilityDate) {
|
|
554
|
-
compatibilityDate = getConf("compatibilityDate");
|
|
555
|
-
}
|
|
556
|
-
return {
|
|
557
|
-
// typescript: {
|
|
558
|
-
// generateRuntimeConfigTypes:
|
|
559
|
-
// !framework?.name || framework.name === 'nitro',
|
|
560
|
-
// },
|
|
561
|
-
preset: presetOverride || (await resolvePreset("", {
|
|
562
|
-
static: getConf("static"),
|
|
563
|
-
compatibilityDate: compatibilityDate || fallbackCompatibilityDate
|
|
564
|
-
}))?._meta?.name
|
|
565
|
-
};
|
|
566
|
-
},
|
|
567
|
-
defaults: SilgiCLIDefaults,
|
|
568
|
-
jitiOptions: {
|
|
569
|
-
alias: {
|
|
570
|
-
"silgi/config": "silgi/config"
|
|
571
|
-
}
|
|
572
|
-
},
|
|
573
|
-
async resolve(id) {
|
|
574
|
-
const preset = await resolvePreset(id, {
|
|
575
|
-
static: configOverrides.static,
|
|
576
|
-
compatibilityDate: compatibilityDate || fallbackCompatibilityDate
|
|
577
|
-
});
|
|
578
|
-
if (preset) {
|
|
579
|
-
return {
|
|
580
|
-
config: klona(preset)
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
|
-
...opts.c12
|
|
585
|
-
});
|
|
586
|
-
delete globalThis.defineSilgiConfig;
|
|
587
|
-
const options = klona(loadedConfig.config);
|
|
588
|
-
options._config = configOverrides;
|
|
589
|
-
options._c12 = loadedConfig;
|
|
590
|
-
const _presetName = (loadedConfig.layers || []).find((l) => l.config?._meta?.name)?.config?._meta?.name || presetOverride;
|
|
591
|
-
options.preset = _presetName;
|
|
592
|
-
options.compatibilityDate = resolveCompatibilityDates(
|
|
593
|
-
compatibilityDate,
|
|
594
|
-
options.compatibilityDate
|
|
595
|
-
);
|
|
596
|
-
return options;
|
|
597
|
-
}
|
|
3
|
+
import { resolve, dirname, join, isAbsolute, relative } from 'pathe';
|
|
4
|
+
import { readPackageJSON } from 'pkg-types';
|
|
5
|
+
import { relativeWithDot, resolveSilgiModule } from 'silgi/kit';
|
|
6
|
+
import { withTrailingSlash } from 'ufo';
|
|
598
7
|
|
|
599
8
|
function getDirectory(p) {
|
|
600
9
|
try {
|
|
@@ -779,4 +188,4 @@ async function silgiGenerateType(silgi) {
|
|
|
779
188
|
};
|
|
780
189
|
}
|
|
781
190
|
|
|
782
|
-
export {
|
|
191
|
+
export { silgiGenerateType as s };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createConsola } from 'consola';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
import { createHooks } from 'hookable';
|
|
4
|
-
import { c as createRouteRules } from '../_chunks/
|
|
4
|
+
import { c as createRouteRules } from '../_chunks/silgiApp.mjs';
|
|
5
|
+
export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
|
|
5
6
|
import { getContext } from 'unctx';
|
|
6
7
|
import { Buffer } from 'node:buffer';
|
|
7
8
|
import { klona } from 'klona';
|
|
8
9
|
import { useSilgiRuntimeConfig } from 'silgi/runtime';
|
|
9
10
|
import { createStorage as createStorage$1, builtinDrivers, prefixStorage } from 'unstorage';
|
|
10
|
-
export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
|
|
11
11
|
import 'ufo';
|
|
12
12
|
|
|
13
13
|
const silgiCtx = getContext("silgi");
|
package/dist/index.mjs
CHANGED
|
@@ -3,10 +3,9 @@ export { s as silgiCLICtx, t as tryUseSilgiCLI, u as useSilgiCLI } from './_chun
|
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'defu';
|
|
5
5
|
import 'hookable';
|
|
6
|
-
import './_chunks/routeRules.mjs';
|
|
7
|
-
import 'ufo';
|
|
8
6
|
import 'unctx';
|
|
9
7
|
import 'node:buffer';
|
|
10
8
|
import 'klona';
|
|
11
9
|
import 'silgi/runtime';
|
|
12
10
|
import 'unstorage';
|
|
11
|
+
import 'ufo';
|
|
@@ -28,15 +28,15 @@ export function useSilgiRuntimeConfig(event, inlineRuntimeConfig = {}) {
|
|
|
28
28
|
}
|
|
29
29
|
const silgi = tryUseSilgi();
|
|
30
30
|
if (!silgi) {
|
|
31
|
-
if (!event) {
|
|
32
|
-
return _sharedRuntimeConfig;
|
|
33
|
-
}
|
|
34
31
|
if (globalThis._silgi_runtime) {
|
|
35
32
|
inlineRuntimeConfig = globalThis._silgi_runtime;
|
|
36
33
|
}
|
|
37
34
|
if (!_inlineSilgiRuntimeConfig) {
|
|
38
35
|
_sharedRuntimeConfig = initRuntimeConfig(envOptions, inlineRuntimeConfig);
|
|
39
36
|
}
|
|
37
|
+
if (!event) {
|
|
38
|
+
return _sharedRuntimeConfig;
|
|
39
|
+
}
|
|
40
40
|
const runtimeConfig2 = klona(_inlineSilgiRuntimeConfig);
|
|
41
41
|
applyEnv(runtimeConfig2, envOptions);
|
|
42
42
|
return runtimeConfig2;
|