silgi 0.8.38 → 0.8.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/index.mjs +1 -1
- package/dist/cli/loader.mjs +8 -8
- package/dist/cli/prepare.mjs +57 -44
- package/dist/kit/index.mjs +4 -4
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/loader.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { watchConfig, loadConfig } from 'c12';
|
|
|
2
2
|
import { resolveCompatibilityDatesFromEnv, formatDate, resolveCompatibilityDates } from 'compatx';
|
|
3
3
|
import { klona } from 'klona/full';
|
|
4
4
|
import { isDebug, isTest } from 'std-env';
|
|
5
|
-
import
|
|
5
|
+
import consola from 'consola';
|
|
6
6
|
import { colors } from 'consola/utils';
|
|
7
7
|
import { relative, join, resolve } from 'pathe';
|
|
8
8
|
import escapeRE from 'escape-string-regexp';
|
|
@@ -118,11 +118,11 @@ let _fallbackInfoShown = false;
|
|
|
118
118
|
let _promptedUserToUpdate = false;
|
|
119
119
|
async function _resolveDefault(options) {
|
|
120
120
|
const _todayDate = formatDate(/* @__PURE__ */ new Date());
|
|
121
|
-
const consola =
|
|
122
|
-
consola.warn(`No valid compatibility date is specified.`);
|
|
121
|
+
const consola$1 = consola.withTag("silgi");
|
|
122
|
+
consola$1.warn(`No valid compatibility date is specified.`);
|
|
123
123
|
const onFallback = () => {
|
|
124
124
|
if (!_fallbackInfoShown) {
|
|
125
|
-
consola.info(
|
|
125
|
+
consola$1.info(
|
|
126
126
|
[
|
|
127
127
|
`Using \`${fallbackCompatibilityDate}\` as fallback.`,
|
|
128
128
|
` Please specify compatibility date to avoid unwanted behavior changes:`,
|
|
@@ -135,7 +135,7 @@ async function _resolveDefault(options) {
|
|
|
135
135
|
}
|
|
136
136
|
return fallbackCompatibilityDate;
|
|
137
137
|
};
|
|
138
|
-
const shallUpdate = !_promptedUserToUpdate && await consola.prompt(
|
|
138
|
+
const shallUpdate = !_promptedUserToUpdate && await consola$1.prompt(
|
|
139
139
|
`Do you want to auto update config file to set ${colors.cyan(`compatibilityDate: '${_todayDate}'`)}?`,
|
|
140
140
|
{
|
|
141
141
|
type: "confirm",
|
|
@@ -151,7 +151,7 @@ async function _resolveDefault(options) {
|
|
|
151
151
|
configFile: "silgi.config",
|
|
152
152
|
cwd: options.rootDir,
|
|
153
153
|
async onCreate({ configFile }) {
|
|
154
|
-
const shallCreate = await consola.prompt(
|
|
154
|
+
const shallCreate = await consola$1.prompt(
|
|
155
155
|
`Do you want to initialize a new config in ${colors.cyan(relative(".", configFile))}?`,
|
|
156
156
|
{
|
|
157
157
|
type: "confirm",
|
|
@@ -167,11 +167,11 @@ async function _resolveDefault(options) {
|
|
|
167
167
|
config.compatibilityDate = _todayDate;
|
|
168
168
|
}
|
|
169
169
|
}).catch((error) => {
|
|
170
|
-
consola.error(`Failed to update config: ${error.message}`);
|
|
170
|
+
consola$1.error(`Failed to update config: ${error.message}`);
|
|
171
171
|
return null;
|
|
172
172
|
});
|
|
173
173
|
if (updateResult?.configFile) {
|
|
174
|
-
consola.success(
|
|
174
|
+
consola$1.success(
|
|
175
175
|
`Compatibility date set to \`${_todayDate}\` in \`${relative(".", updateResult.configFile)}\``
|
|
176
176
|
);
|
|
177
177
|
return _todayDate;
|
package/dist/cli/prepare.mjs
CHANGED
|
@@ -8,12 +8,12 @@ import { resolvePath, parseNodeModulePath, lookupNodeModuleSubpath, resolve as r
|
|
|
8
8
|
import { resolveAlias } from 'pathe/utils';
|
|
9
9
|
import { relativeWithDot, isDirectory, writeFile, resolveAlias as resolveAlias$1, resolvePath as resolvePath$1, normalizeTemplate, useLogger, addTemplate } from 'silgi/kit';
|
|
10
10
|
import { toExports, scanExports, createUnimport } from 'unimport';
|
|
11
|
+
import consola, { consola as consola$1 } from 'consola';
|
|
11
12
|
import { createJiti } from 'dev-jiti';
|
|
12
13
|
import { readPackageJSON } from 'pkg-types';
|
|
13
14
|
import { hash } from 'ohash';
|
|
14
15
|
import { s as silgiGenerateType } from './types.mjs';
|
|
15
16
|
import { c as commonArgs } from './common.mjs';
|
|
16
|
-
import { consola } from 'consola';
|
|
17
17
|
import { createHooks, createDebugger } from 'hookable';
|
|
18
18
|
import { useSilgiCLI, silgiCLICtx } from 'silgi/core';
|
|
19
19
|
import { pascalCase } from 'scule';
|
|
@@ -244,33 +244,48 @@ async function readCoreFile(silgi) {
|
|
|
244
244
|
debug: silgi.options.debug,
|
|
245
245
|
alias: silgi.options.alias
|
|
246
246
|
});
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
247
|
+
try {
|
|
248
|
+
const coreFile = await jiti.evalModule(
|
|
249
|
+
injectedResult.code,
|
|
250
|
+
{
|
|
251
|
+
filename: path,
|
|
252
|
+
async: true,
|
|
253
|
+
conditions: silgi.options.conditions
|
|
254
|
+
},
|
|
255
|
+
async (data, name) => {
|
|
256
|
+
return (await silgi.unimport.injectImports(data, name)).code;
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
silgi.uris = coreFile.uris;
|
|
260
|
+
silgi.schemas = coreFile.schemas;
|
|
261
|
+
silgi.services = coreFile.services;
|
|
262
|
+
silgi.shareds = coreFile.shareds;
|
|
263
|
+
silgi.modulesURIs = coreFile.modulesURIs;
|
|
264
|
+
return {
|
|
265
|
+
context,
|
|
266
|
+
object: {
|
|
267
|
+
schemas: coreFile.schemas,
|
|
268
|
+
uris: coreFile.uris,
|
|
269
|
+
services: coreFile.services,
|
|
270
|
+
shareds: coreFile.shareds,
|
|
271
|
+
modulesURIs: coreFile.modulesURIs
|
|
272
|
+
},
|
|
273
|
+
path
|
|
274
|
+
};
|
|
275
|
+
} catch (error) {
|
|
276
|
+
consola.error("Failed to read core.ts file:", error);
|
|
277
|
+
return {
|
|
278
|
+
context,
|
|
279
|
+
object: {
|
|
280
|
+
schemas: {},
|
|
281
|
+
uris: {},
|
|
282
|
+
services: {},
|
|
283
|
+
shareds: {},
|
|
284
|
+
modulesURIs: {}
|
|
285
|
+
},
|
|
286
|
+
path
|
|
287
|
+
};
|
|
288
|
+
}
|
|
274
289
|
}
|
|
275
290
|
|
|
276
291
|
function traverseObject(silgi, obj, currentPath = []) {
|
|
@@ -971,7 +986,7 @@ async function installModule(moduleToInstall, silgi = useSilgiCLI(), inlineOptio
|
|
|
971
986
|
}
|
|
972
987
|
}
|
|
973
988
|
|
|
974
|
-
const logger$1 = consola;
|
|
989
|
+
const logger$1 = consola$1;
|
|
975
990
|
async function _resolveSilgiModule(mod, silgi) {
|
|
976
991
|
let _url;
|
|
977
992
|
let buildTimeModuleMeta = {};
|
|
@@ -1066,28 +1081,26 @@ function createDependencyGraph(modules) {
|
|
|
1066
1081
|
return;
|
|
1067
1082
|
const requiredDeps = module.meta?.requiredDependencies || [];
|
|
1068
1083
|
const afterDeps = module.meta?.afterDependencies || [];
|
|
1069
|
-
requiredDeps
|
|
1084
|
+
const allDeps = /* @__PURE__ */ new Set([...requiredDeps, ...afterDeps]);
|
|
1085
|
+
allDeps.forEach((dep) => {
|
|
1070
1086
|
if (!graph.has(dep)) {
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
logger$1.debug(`${key} requires ${dep}`);
|
|
1076
|
-
});
|
|
1077
|
-
afterDeps.forEach((dep) => {
|
|
1078
|
-
if (!graph.has(dep)) {
|
|
1079
|
-
logger$1.debug(`Optional dependency for ${key}: "${dep}" (afterDependencies) not found, skipping`);
|
|
1087
|
+
if (requiredDeps.includes(dep)) {
|
|
1088
|
+
throw new Error(`Required dependency "${dep}" for module "${key}" is missing`);
|
|
1089
|
+
}
|
|
1090
|
+
logger$1.debug(`Optional dependency for ${key}: "${dep}" not found, skipping`);
|
|
1080
1091
|
return;
|
|
1081
1092
|
}
|
|
1082
|
-
graph.get(
|
|
1093
|
+
graph.get(dep)?.add(key);
|
|
1083
1094
|
inDegree.set(key, (inDegree.get(key) || 0) + 1);
|
|
1084
|
-
|
|
1095
|
+
const depType = requiredDeps.includes(dep) ? "required" : "after";
|
|
1096
|
+
logger$1.debug(`${key} depends on ${dep} (${depType})`);
|
|
1085
1097
|
});
|
|
1086
1098
|
});
|
|
1087
1099
|
logger$1.debug("\nDependency Graph:");
|
|
1088
1100
|
for (const [module, deps] of graph.entries()) {
|
|
1089
1101
|
const depsStr = Array.from(deps).join(", ");
|
|
1090
|
-
logger$1.debug(`${module} ->
|
|
1102
|
+
logger$1.debug(`${module} -> ${depsStr} (deps run after this module)`);
|
|
1103
|
+
logger$1.debug(`${module} in-degree: ${inDegree.get(module)}`);
|
|
1091
1104
|
}
|
|
1092
1105
|
return { graph, inDegree };
|
|
1093
1106
|
}
|
|
@@ -1352,7 +1365,7 @@ async function scanFiles$1(silgi) {
|
|
|
1352
1365
|
if (caseCorrected) {
|
|
1353
1366
|
const original = relative(silgi.options.serverDir, dir);
|
|
1354
1367
|
const corrected = relative(silgi.options.serverDir, join(dirname(dir), caseCorrected));
|
|
1355
|
-
consola.warn(`Components not scanned from \`~/${corrected}\`. Did you mean to name the directory \`~/${original}\` instead?`);
|
|
1368
|
+
consola$1.warn(`Components not scanned from \`~/${corrected}\`. Did you mean to name the directory \`~/${original}\` instead?`);
|
|
1356
1369
|
}
|
|
1357
1370
|
}
|
|
1358
1371
|
}
|
|
@@ -1706,7 +1719,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
1706
1719
|
hooks,
|
|
1707
1720
|
// vfs: {}
|
|
1708
1721
|
_requiredModules: {},
|
|
1709
|
-
logger: consola.withTag("silgi"),
|
|
1722
|
+
logger: consola$1.withTag("silgi"),
|
|
1710
1723
|
close: () => silgi.hooks.callHook("close", silgi),
|
|
1711
1724
|
storage: void 0,
|
|
1712
1725
|
scanModules: [],
|
package/dist/kit/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolvePath as resolvePath$1 } from 'mlly';
|
|
2
2
|
import fsp from 'node:fs/promises';
|
|
3
|
-
import
|
|
3
|
+
import consola, { consola as consola$1 } from 'consola';
|
|
4
4
|
import { relative, resolve, dirname, normalize, isAbsolute, join, parse, basename } from 'pathe';
|
|
5
5
|
import { colors } from 'consola/utils';
|
|
6
6
|
import { getProperty } from 'dot-prop';
|
|
@@ -41,7 +41,7 @@ function _compilePathTemplate(contents) {
|
|
|
41
41
|
return (params) => contents.replace(/\{\{ ?([\w.]+) ?\}\}/g, (_, match) => {
|
|
42
42
|
const val = getProperty(params, match);
|
|
43
43
|
if (!val) {
|
|
44
|
-
|
|
44
|
+
consola.warn(
|
|
45
45
|
`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`
|
|
46
46
|
);
|
|
47
47
|
}
|
|
@@ -57,7 +57,7 @@ async function writeFile(file, contents, log = false) {
|
|
|
57
57
|
typeof contents === "string" ? "utf8" : void 0
|
|
58
58
|
);
|
|
59
59
|
if (log) {
|
|
60
|
-
consola.info("Generated", prettyPath(file));
|
|
60
|
+
consola$1.info("Generated", prettyPath(file));
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
async function isDirectory$1(path) {
|
|
@@ -90,7 +90,7 @@ function isH3() {
|
|
|
90
90
|
return false;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
const logger = consola;
|
|
93
|
+
const logger = consola$1;
|
|
94
94
|
function useLogger(tag, options = {}) {
|
|
95
95
|
return tag ? logger.create(options).withTag(tag) : logger;
|
|
96
96
|
}
|
package/dist/meta/index.d.mts
CHANGED
package/dist/meta/index.d.ts
CHANGED