silgi 0.8.39 → 0.8.41
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 +45 -27
- 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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { defineCommand } from 'citty';
|
|
2
|
+
import consola$1, { consola } from 'consola';
|
|
2
3
|
import { join, resolve, isAbsolute, relative, dirname, basename, extname } from 'pathe';
|
|
3
4
|
import { devDependencies, version } from 'silgi/meta';
|
|
4
5
|
import { runtimeDir } from 'silgi/runtime/meta';
|
|
@@ -13,7 +14,6 @@ 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,50 @@ 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
|
-
|
|
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
|
+
if (silgi.options.debug) {
|
|
277
|
+
console.error("Failed to read core.ts file:", error);
|
|
256
278
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
shareds: coreFile.shareds,
|
|
270
|
-
modulesURIs: coreFile.modulesURIs
|
|
271
|
-
},
|
|
272
|
-
path
|
|
273
|
-
};
|
|
279
|
+
return {
|
|
280
|
+
context,
|
|
281
|
+
object: {
|
|
282
|
+
schemas: {},
|
|
283
|
+
uris: {},
|
|
284
|
+
services: {},
|
|
285
|
+
shareds: {},
|
|
286
|
+
modulesURIs: {}
|
|
287
|
+
},
|
|
288
|
+
path
|
|
289
|
+
};
|
|
290
|
+
}
|
|
274
291
|
}
|
|
275
292
|
|
|
276
293
|
function traverseObject(silgi, obj, currentPath = []) {
|
|
@@ -1792,6 +1809,7 @@ const prepare = defineCommand({
|
|
|
1792
1809
|
}
|
|
1793
1810
|
await generate();
|
|
1794
1811
|
await generate();
|
|
1812
|
+
consola$1.success("Prepare completed");
|
|
1795
1813
|
}
|
|
1796
1814
|
});
|
|
1797
1815
|
|
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