silgi 0.7.1 → 0.7.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.
Files changed (83) hide show
  1. package/dist/_chunks/index.mjs +5 -0
  2. package/dist/cli/{utils/compatibility.mjs → compatibility.mjs} +1 -1
  3. package/dist/cli/config/index.d.mts +11 -0
  4. package/dist/cli/config/index.d.ts +11 -0
  5. package/dist/{core/config/types.mjs → cli/config/index.mjs} +19 -2
  6. package/dist/cli/index.mjs +3 -3
  7. package/dist/cli/loader.mjs +581 -0
  8. package/dist/cli/prepare.mjs +1488 -0
  9. package/dist/core/index.d.mts +2 -10
  10. package/dist/core/index.d.ts +2 -10
  11. package/dist/core/index.mjs +943 -16
  12. package/dist/ecosystem/nitro/index.mjs +62 -1
  13. package/dist/ecosystem/nuxt/module.mjs +1 -1
  14. package/dist/kit/index.mjs +299 -10
  15. package/dist/meta/index.d.mts +1 -1
  16. package/dist/meta/index.d.ts +1 -1
  17. package/dist/meta/index.mjs +1 -1
  18. package/package.json +5 -1
  19. package/dist/cli/build/framework/h3.mjs +0 -46
  20. package/dist/cli/build/framework/index.mjs +0 -7
  21. package/dist/cli/build/framework/nitro.mjs +0 -28
  22. package/dist/cli/build/framework/nuxt.mjs +0 -9
  23. package/dist/cli/build/prepare.mjs +0 -7
  24. package/dist/cli/build/scanURIs.mjs +0 -27
  25. package/dist/cli/build/template/framework.mjs +0 -91
  26. package/dist/cli/build/template/schema.mjs +0 -115
  27. package/dist/cli/build/template/silgi.mjs +0 -149
  28. package/dist/cli/build/types.mjs +0 -130
  29. package/dist/cli/commands/prepare.mjs +0 -49
  30. package/dist/cli/common.mjs +0 -13
  31. package/dist/cli/core/app.mjs +0 -89
  32. package/dist/cli/core/scan.mjs +0 -40
  33. package/dist/cli/core/silgi.mjs +0 -77
  34. package/dist/cli/core/storage.mjs +0 -11
  35. package/dist/cli/core/templates.mjs +0 -29
  36. package/dist/cli/module/exportScan.mjs +0 -69
  37. package/dist/cli/module/install.mjs +0 -52
  38. package/dist/cli/module/scan.mjs +0 -141
  39. package/dist/cli/utils/generateRouterDTS.mjs +0 -84
  40. package/dist/cli/utils/ignore.mjs +0 -46
  41. package/dist/cli/utils/readCoreFile.mjs +0 -47
  42. package/dist/cli/utils/scan.mjs +0 -147
  43. package/dist/cli/utils/storage.mjs +0 -21
  44. package/dist/cli/utils/uri.mjs +0 -71
  45. package/dist/core/config/defaults.mjs +0 -96
  46. package/dist/core/config/loader.mjs +0 -98
  47. package/dist/core/config/resolvers/compatibility.mjs +0 -90
  48. package/dist/core/config/resolvers/imports.mjs +0 -96
  49. package/dist/core/config/resolvers/paths.mjs +0 -194
  50. package/dist/core/config/resolvers/storage.mjs +0 -25
  51. package/dist/core/config/resolvers/url.mjs +0 -7
  52. package/dist/core/createSilgi.mjs +0 -84
  53. package/dist/core/error.mjs +0 -227
  54. package/dist/core/fetch/ofetch.mjs +0 -35
  55. package/dist/core/parser.mjs +0 -136
  56. package/dist/core/silgi.mjs +0 -114
  57. package/dist/core/silgiApp.mjs +0 -15
  58. package/dist/core/unctx.mjs +0 -27
  59. package/dist/core/uris/uri.mjs +0 -33
  60. package/dist/core/uris/utils.mjs +0 -127
  61. package/dist/core/utils/event.mjs +0 -5
  62. package/dist/core/utils/global.mjs +0 -12
  63. package/dist/core/utils/merge.mjs +0 -25
  64. package/dist/core/utils/schema.mjs +0 -5
  65. package/dist/core/utils/service.mjs +0 -5
  66. package/dist/core/utils/shared.mjs +0 -5
  67. package/dist/core/utils/storage.mjs +0 -70
  68. package/dist/ecosystem/nitro/module.mjs +0 -62
  69. package/dist/kit/esm.mjs +0 -10
  70. package/dist/kit/fs.mjs +0 -25
  71. package/dist/kit/isFramework.mjs +0 -25
  72. package/dist/kit/logger.mjs +0 -8
  73. package/dist/kit/module.mjs +0 -73
  74. package/dist/kit/path.mjs +0 -34
  75. package/dist/kit/preset.mjs +0 -6
  76. package/dist/kit/resolve.mjs +0 -78
  77. package/dist/kit/template.mjs +0 -47
  78. package/dist/kit/utils.mjs +0 -20
  79. package/dist/package.json.mjs +0 -5
  80. package/dist/schema/common.mjs +0 -43
  81. package/dist/schema/index.mjs +0 -9
  82. package/dist/schema/internal.mjs +0 -22
  83. /package/dist/cli/{commands/init.mjs → init.mjs} +0 -0
@@ -1,71 +0,0 @@
1
- function traverseObject(silgi, obj, currentPath = []) {
2
- const uriMap = /* @__PURE__ */ new Map();
3
- function traverse(node, path = []) {
4
- if (!node || typeof node !== "object")
5
- return;
6
- if (path.length === 4) {
7
- const basePath = path.join("/");
8
- let paramString = "";
9
- if (node.router) {
10
- let params = null;
11
- if (node.router?._def?.typeName !== void 0) {
12
- try {
13
- const shape = node.router?.shape?.params?.shape;
14
- params = shape ? Object.keys(shape) : null;
15
- } catch {
16
- params = null;
17
- }
18
- }
19
- if (params?.length) {
20
- paramString = params.map((p) => `:${p}`).join("/");
21
- }
22
- }
23
- uriMap.set(basePath, paramString);
24
- return;
25
- }
26
- for (const key in node) {
27
- if (!["_type", "fields"].includes(key)) {
28
- traverse(node[key], [...path, key]);
29
- }
30
- }
31
- }
32
- traverse(obj, currentPath);
33
- return uriMap;
34
- }
35
- function scanActionModulesUris(silgi, obj, currentPath = []) {
36
- const uriMap = {};
37
- function traverse(node, path = []) {
38
- if (!node || typeof node !== "object")
39
- return;
40
- if (path.length === 4) {
41
- const basePath = path.join("/");
42
- let moduleName = "";
43
- if (node.modules?.yoga) {
44
- let rootFieldName = null;
45
- if (node.modules?.yoga?.rootFieldName) {
46
- moduleName = "yoga";
47
- rootFieldName = node.modules?.yoga?.rootFieldName;
48
- }
49
- if (!rootFieldName) {
50
- return;
51
- }
52
- uriMap[moduleName] ??= {};
53
- if (uriMap[moduleName].rootFieldName) {
54
- silgi.logger.withTag("scanActionModulesUris").error(`Hata ${moduleName} ${rootFieldName} ${basePath} bu zaten burada kullanilmis.`);
55
- }
56
- uriMap[moduleName].rootFieldName ??= {};
57
- uriMap[moduleName].rootFieldName[rootFieldName] = basePath;
58
- }
59
- return;
60
- }
61
- for (const key in node) {
62
- if (!["_type", "fields"].includes(key)) {
63
- traverse(node[key], [...path, key]);
64
- }
65
- }
66
- }
67
- traverse(obj, currentPath);
68
- return uriMap;
69
- }
70
-
71
- export { scanActionModulesUris, traverseObject };
@@ -1,96 +0,0 @@
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
- // Dirs
12
- scanDirs: [],
13
- build: {
14
- dir: ".silgi",
15
- typesDir: "{{ build.dir }}/types",
16
- templates: []
17
- },
18
- output: {
19
- dir: "{{ rootDir }}/.output",
20
- serverDir: "{{ output.dir }}/server",
21
- publicDir: "{{ output.dir }}/public"
22
- },
23
- serverDir: "{{ rootDir }}/server",
24
- clientDir: "{{ rootDir }}/client",
25
- silgi: {
26
- serverDir: "{{ serverDir }}/silgi",
27
- clientDir: "{{ clientDir }}/silgi",
28
- publicDir: "{{ silgi.serverDir }}/public",
29
- utilsDir: "{{ silgi.serverDir }}/utils",
30
- vfsDir: "{{ silgi.serverDir }}/vfs",
31
- typesDir: "{{ silgi.serverDir }}/types"
32
- },
33
- // Modules
34
- _modules: [],
35
- modules: [],
36
- // Features
37
- // experimental: {},
38
- future: {},
39
- storage: {},
40
- devStorage: {},
41
- stub: false,
42
- // bundledStorage: [],
43
- // publicAssets: [],
44
- // serverAssets: [],
45
- plugins: [],
46
- // tasks: {},
47
- // scheduledTasks: {},
48
- imports: {
49
- exclude: [],
50
- dirs: [],
51
- presets: [],
52
- virtualImports: ["#silgiImports"]
53
- },
54
- // virtual: {},
55
- // compressPublicAssets: false,
56
- ignore: [],
57
- // Dev
58
- dev: false,
59
- // devServer: { watch: [] },
60
- watchOptions: { ignoreInitial: true },
61
- // devProxy: {},
62
- // Logging
63
- // logging: {
64
- // compressedSizes: true,
65
- // buildSuccess: true,
66
- // },
67
- // Routing
68
- // baseURL: process.env.NITRO_APP_BASE_URL || '/',
69
- // handlers: [],
70
- // devHandlers: [],
71
- // errorHandler: undefined,
72
- // routeRules: {},
73
- // Advanced
74
- typescript: {
75
- strict: false,
76
- generateTsConfig: true,
77
- // generateRuntimeConfigTypes: true,
78
- tsconfigPath: "types/silgi.tsconfig.json",
79
- internalPaths: false,
80
- tsConfig: {},
81
- customConditions: []
82
- },
83
- conditions: [],
84
- nodeModulesDirs: [],
85
- // hooks: {},
86
- commands: {},
87
- // Framework
88
- framework: {
89
- name: "h3",
90
- version: ""
91
- },
92
- extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".vue"],
93
- ignoreOptions: void 0
94
- };
95
-
96
- export { SilgiCLIDefaults };
@@ -1,98 +0,0 @@
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": "silgi/config",
69
- "silgi/config": "silgi/config"
70
- }
71
- },
72
- async resolve(id) {
73
- const preset = await resolvePreset(id, {
74
- static: configOverrides.static,
75
- compatibilityDate: compatibilityDate || fallbackCompatibilityDate
76
- });
77
- if (preset) {
78
- return {
79
- config: klona(preset)
80
- };
81
- }
82
- },
83
- ...opts.c12
84
- });
85
- delete globalThis.defineSilgiConfig;
86
- const options = klona(loadedConfig.config);
87
- options._config = configOverrides;
88
- options._c12 = loadedConfig;
89
- const _presetName = (loadedConfig.layers || []).find((l) => l.config?._meta?.name)?.config?._meta?.name || presetOverride;
90
- options.preset = _presetName;
91
- options.compatibilityDate = resolveCompatibilityDates(
92
- compatibilityDate,
93
- options.compatibilityDate
94
- );
95
- return options;
96
- }
97
-
98
- export { loadOptions };
@@ -1,90 +0,0 @@
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 };
@@ -1,96 +0,0 @@
1
- import escapeRE from 'escape-string-regexp';
2
- import { resolveModuleExportNames } from 'mlly';
3
- import { join } from 'pathe';
4
-
5
- async function resolveImportsOptions(options) {
6
- if (options.imports === false) {
7
- return;
8
- }
9
- options.imports.presets ??= [];
10
- options.imports.presets.push(...getSilgiImportsPreset());
11
- if (options.preset === "h3") {
12
- const h3Exports = await resolveModuleExportNames("h3", {
13
- url: import.meta.url
14
- });
15
- options.imports.presets ??= [];
16
- options.imports.presets.push({
17
- from: "h3",
18
- imports: h3Exports.filter((n) => !/^[A-Z]/.test(n) && n !== "use")
19
- });
20
- }
21
- options.imports.dirs ??= [];
22
- options.imports.dirs.push(
23
- ...options.scanDirs.map((dir) => join(dir, "utils/**/*"))
24
- );
25
- if (Array.isArray(options.imports.exclude) && options.imports.exclude.length === 0) {
26
- options.imports.exclude.push(/[/\\]\.git[/\\]/);
27
- options.imports.exclude.push(options.build.dir);
28
- const scanDirsInNodeModules = options.scanDirs.map((dir) => dir.match(/(?<=\/)node_modules\/(.+)$/)?.[1]).filter(Boolean);
29
- options.imports.exclude.push(
30
- scanDirsInNodeModules.length > 0 ? new RegExp(
31
- `node_modules\\/(?!${scanDirsInNodeModules.map((dir) => escapeRE(dir)).join("|")})`
32
- ) : /[/\\]node_modules[/\\]/
33
- );
34
- }
35
- }
36
- function getSilgiImportsPreset() {
37
- return [
38
- // TODO: buraya bizim importlarimiz gelecek.
39
- {
40
- from: "silgi",
41
- imports: [
42
- "createShared",
43
- "useSilgi",
44
- "createService",
45
- "createSchema"
46
- ]
47
- },
48
- // {
49
- // from: 'nitropack/runtime',
50
- // imports: ['useRuntimeConfig', 'useAppConfig'],
51
- // },
52
- // {
53
- // from: 'nitropack/runtime',
54
- // imports: ['defineNitroPlugin', 'nitroPlugin'],
55
- // },
56
- // {
57
- // from: 'nitropack/runtime/internal/cache',
58
- // imports: [
59
- // 'defineCachedFunction',
60
- // 'defineCachedEventHandler',
61
- // 'cachedFunction',
62
- // 'cachedEventHandler',
63
- // ],
64
- // },
65
- {
66
- from: "silgi/core",
67
- imports: ["useSilgiStorage"]
68
- }
69
- // {
70
- // from: 'nitropack/runtime/internal/renderer',
71
- // imports: ['defineRenderHandler'],
72
- // },
73
- // {
74
- // from: 'nitropack/runtime/internal/meta',
75
- // imports: ['defineRouteMeta'],
76
- // },
77
- // {
78
- // from: 'nitropack/runtime/internal/route-rules',
79
- // imports: ['getRouteRules'],
80
- // },
81
- // {
82
- // from: 'nitropack/runtime/internal/context',
83
- // imports: ['useEvent'],
84
- // },
85
- // {
86
- // from: 'nitropack/runtime/internal/task',
87
- // imports: ['defineTask', 'runTask'],
88
- // },
89
- // {
90
- // from: 'nitropack/runtime/internal/error/utils',
91
- // imports: ['defineNitroErrorHandler'],
92
- // },
93
- ];
94
- }
95
-
96
- export { resolveImportsOptions };
@@ -1,194 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import { pathToFileURL } from 'node:url';
3
- import { resolvePath as resolvePath$1 } from 'mlly';
4
- import { resolve, join, isAbsolute } from 'pathe';
5
- import { findWorkspaceDir, readPackageJSON } from 'pkg-types';
6
- import { resolveSilgiPath, resolveAlias, resolvePath } from 'silgi/kit';
7
- import { runtimeDir, pkgDir } from 'silgi/runtime/meta';
8
- import { isRelative } from 'ufo';
9
- import { SilgiCLIDefaults } from '../defaults.mjs';
10
-
11
- async function resolvePathOptions(options) {
12
- options.rootDir = resolve(options.rootDir || ".");
13
- options.workspaceDir = await findWorkspaceDir(options.rootDir).catch(
14
- () => options.rootDir
15
- );
16
- options.srcDir = resolve(options.srcDir || options.rootDir);
17
- for (const key of ["srcDir"]) {
18
- options[key] = resolve(options.rootDir, options[key]);
19
- }
20
- options.build.dir = resolve(options.rootDir, options.build.dir);
21
- options.build.typesDir = resolveSilgiPath(
22
- options.build.typesDir || SilgiCLIDefaults.build.typesDir,
23
- options,
24
- options.rootDir
25
- );
26
- if (options.preset === "npm-package") {
27
- const packageJsonPath = resolve(options.rootDir, "package.json");
28
- const packageJson = await readPackageJSON(packageJsonPath);
29
- if (packageJson.name === void 0) {
30
- throw new Error("Package name is undefined");
31
- }
32
- options.alias ||= {};
33
- options.alias[packageJson.name] = join(options.rootDir, "src/module.ts");
34
- options.alias[`${packageJson.name}/runtime/`] = join(options.rootDir, "src/runtime/");
35
- }
36
- if (options.typescript?.internalPaths || options.stub) {
37
- options.alias = {
38
- ...options.alias,
39
- "silgi/runtime": join(runtimeDir),
40
- "#internal/silgi": join(runtimeDir),
41
- "silgi/runtime/*": join(runtimeDir, "*"),
42
- "#internal/silgi/*": join(runtimeDir, "*")
43
- };
44
- options.typescript.customConditions = [
45
- ...options.typescript.customConditions,
46
- "silgiTypes"
47
- ];
48
- options.conditions ||= [];
49
- options.conditions.push("silgi");
50
- }
51
- options.alias = {
52
- ...options.alias,
53
- "~/": join(options.srcDir, "/"),
54
- "@/": join(options.srcDir, "/"),
55
- "~~/": join(options.rootDir, "/"),
56
- "@@/": join(options.rootDir, "/")
57
- };
58
- if (options.preset === "npm-package") {
59
- options.alias = {
60
- ...options.alias,
61
- "#silgi/app/": join(options.build.dir, "/")
62
- };
63
- }
64
- if (options.alias && typeof options.alias === "object") {
65
- ((options.typescript.tsConfig ??= {}).compilerOptions ??= {}).paths ??= {};
66
- const paths = options.typescript.tsConfig.compilerOptions.paths;
67
- for (const [key, value] of Object.entries(options.alias)) {
68
- if (typeof paths === "object") {
69
- paths[key] = [value];
70
- }
71
- }
72
- }
73
- if (options.typescript.tsConfig.compilerOptions?.paths && typeof options.typescript.tsConfig.compilerOptions.paths === "object") {
74
- ((options.typescript.tsConfig ??= {}).compilerOptions ??= {}).paths ??= {};
75
- const paths = options.typescript.tsConfig.compilerOptions.paths;
76
- for (const [key, value] of Object.entries(options.alias)) {
77
- if (typeof paths === "object") {
78
- paths[key] = [value];
79
- }
80
- }
81
- }
82
- options.modulesDir = [resolve(options.rootDir, "node_modules")];
83
- options.output.dir = resolveSilgiPath(
84
- options.output.dir || SilgiCLIDefaults.output.dir,
85
- options,
86
- options.rootDir
87
- );
88
- options.output.publicDir = resolveSilgiPath(
89
- options.output.publicDir || SilgiCLIDefaults.output.publicDir,
90
- options,
91
- options.rootDir
92
- );
93
- options.output.serverDir = resolveSilgiPath(
94
- options.output.serverDir || SilgiCLIDefaults.output.serverDir,
95
- options,
96
- options.rootDir
97
- );
98
- options.serverDir = resolveSilgiPath(
99
- options.serverDir || SilgiCLIDefaults.serverDir,
100
- options,
101
- options.rootDir
102
- );
103
- options.clientDir = resolveSilgiPath(
104
- options.clientDir || SilgiCLIDefaults.clientDir,
105
- options,
106
- options.rootDir
107
- );
108
- options.silgi.serverDir = resolveSilgiPath(
109
- options.silgi.serverDir || SilgiCLIDefaults.silgi.serverDir,
110
- options,
111
- options.rootDir
112
- );
113
- options.silgi.clientDir = resolveSilgiPath(
114
- options.silgi.clientDir || SilgiCLIDefaults.silgi.clientDir,
115
- options,
116
- options.rootDir
117
- );
118
- options.silgi.publicDir = resolveSilgiPath(
119
- options.silgi.publicDir || SilgiCLIDefaults.silgi.publicDir,
120
- options,
121
- options.rootDir
122
- );
123
- options.silgi.utilsDir = resolveSilgiPath(
124
- options.silgi.utilsDir || SilgiCLIDefaults.silgi.utilsDir,
125
- options,
126
- options.rootDir
127
- );
128
- options.silgi.vfsDir = resolveSilgiPath(
129
- options.silgi.vfsDir || SilgiCLIDefaults.silgi.vfsDir,
130
- options,
131
- options.rootDir
132
- );
133
- options.silgi.typesDir = resolveSilgiPath(
134
- options.silgi.typesDir || SilgiCLIDefaults.silgi.typesDir,
135
- options,
136
- options.rootDir
137
- );
138
- options.nodeModulesDirs.push(resolve(options.workspaceDir, "node_modules"));
139
- options.nodeModulesDirs.push(resolve(options.rootDir, "node_modules"));
140
- options.nodeModulesDirs.push(resolve(pkgDir, "node_modules"));
141
- options.nodeModulesDirs.push(resolve(pkgDir, ".."));
142
- options.nodeModulesDirs = [
143
- ...new Set(
144
- options.nodeModulesDirs.map((dir) => resolve(options.rootDir, dir))
145
- )
146
- ];
147
- options.scanDirs.unshift(options.srcDir);
148
- options.scanDirs = options.scanDirs.map(
149
- (dir) => resolve(options.srcDir, dir)
150
- );
151
- options.scanDirs = [...new Set(options.scanDirs)];
152
- options.appConfigFiles ??= [];
153
- options.appConfigFiles = options.appConfigFiles.map((file) => _tryResolve(resolveSilgiPath(file, options))).filter(Boolean);
154
- for (const dir of options.scanDirs) {
155
- const configFile = _tryResolve("app.config", dir);
156
- if (configFile && !options.appConfigFiles.includes(configFile)) {
157
- options.appConfigFiles.push(configFile);
158
- }
159
- }
160
- const modulesRuntimePaths = {};
161
- if (options.typescript?.internalPaths) {
162
- for (let i of options.modules) {
163
- if (typeof i === "string") {
164
- i = resolveAlias(i, options.alias);
165
- if (isRelative(i)) {
166
- i = resolve(options.rootDir, i);
167
- }
168
- const src = isAbsolute(i) ? pathToFileURL(await resolvePath(i, { fallbackToOriginal: false, extensions: options.extensions })).href : await resolvePath$1(i, { url: options.modulesDir.map((m) => pathToFileURL(m.replace(/\/node_modules\/?$/, ""))), extensions: options.extensions });
169
- const cleanPath = src.replace(/(\/(?:src|dist)(?:\/runtime)?(?:\/.*)?$)/, "");
170
- modulesRuntimePaths[`${i}/runtime`] = `${cleanPath}/src/runtime`;
171
- }
172
- }
173
- for (const [key, value] of Object.entries(modulesRuntimePaths)) {
174
- options.alias = {
175
- ...options.alias,
176
- [`${key}`]: value
177
- };
178
- }
179
- }
180
- }
181
- function _tryResolve(path, base = ".", extensions = ["", ".js", ".ts", ".mjs", ".cjs", ".json"]) {
182
- path = resolve(base, path);
183
- if (existsSync(path)) {
184
- return path;
185
- }
186
- for (const ext of extensions) {
187
- const p = path + ext;
188
- if (existsSync(p)) {
189
- return p;
190
- }
191
- }
192
- }
193
-
194
- export { resolvePathOptions };
@@ -1,25 +0,0 @@
1
- import { resolve } from 'pathe';
2
-
3
- async function resolveStorageOptions(options) {
4
- const fsMounts = {
5
- root: resolve(options.rootDir),
6
- src: resolve(options.srcDir),
7
- build: resolve(options.build.dir),
8
- cache: resolve(options.build.dir, "cache")
9
- };
10
- for (const p in fsMounts) {
11
- options.devStorage[p] = options.devStorage[p] || {
12
- driver: "fs",
13
- readOnly: p === "root" || p === "src",
14
- base: fsMounts[p]
15
- };
16
- }
17
- if (options.dev && options.storage.data === void 0 && options.devStorage.data === void 0) {
18
- options.devStorage.data = {
19
- driver: "fs",
20
- base: resolve(options.rootDir, ".data/kv")
21
- };
22
- }
23
- }
24
-
25
- export { resolveStorageOptions };
@@ -1,7 +0,0 @@
1
- import { withLeadingSlash, withTrailingSlash } from 'ufo';
2
-
3
- async function resolveURLOptions(options) {
4
- options.baseURL = withLeadingSlash(withTrailingSlash(options.baseURL));
5
- }
6
-
7
- export { resolveURLOptions };