silgi 0.8.39 → 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.
@@ -1,4 +1,4 @@
1
- const version = "0.8.39";
1
+ const version = "0.8.40";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.2.0",
4
4
  "@fastify/deepmerge": "^2.0.2",
@@ -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 _consola from 'consola';
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 = _consola.withTag("silgi");
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;
@@ -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
- const coreFile = await jiti.evalModule(
248
- injectedResult.code,
249
- {
250
- filename: path,
251
- async: true,
252
- conditions: silgi.options.conditions
253
- },
254
- async (data, name) => {
255
- return (await silgi.unimport.injectImports(data, name)).code;
256
- }
257
- );
258
- silgi.uris = coreFile.uris;
259
- silgi.schemas = coreFile.schemas;
260
- silgi.services = coreFile.services;
261
- silgi.shareds = coreFile.shareds;
262
- silgi.modulesURIs = coreFile.modulesURIs;
263
- return {
264
- context,
265
- object: {
266
- schemas: coreFile.schemas,
267
- uris: coreFile.uris,
268
- services: coreFile.services,
269
- shareds: coreFile.shareds,
270
- modulesURIs: coreFile.modulesURIs
271
- },
272
- path
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 = {};
@@ -1350,7 +1365,7 @@ async function scanFiles$1(silgi) {
1350
1365
  if (caseCorrected) {
1351
1366
  const original = relative(silgi.options.serverDir, dir);
1352
1367
  const corrected = relative(silgi.options.serverDir, join(dirname(dir), caseCorrected));
1353
- 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?`);
1354
1369
  }
1355
1370
  }
1356
1371
  }
@@ -1704,7 +1719,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
1704
1719
  hooks,
1705
1720
  // vfs: {}
1706
1721
  _requiredModules: {},
1707
- logger: consola.withTag("silgi"),
1722
+ logger: consola$1.withTag("silgi"),
1708
1723
  close: () => silgi.hooks.callHook("close", silgi),
1709
1724
  storage: void 0,
1710
1725
  scanModules: [],
@@ -1,6 +1,6 @@
1
1
  import { resolvePath as resolvePath$1 } from 'mlly';
2
2
  import fsp from 'node:fs/promises';
3
- import _consola, { consola } from 'consola';
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
- _consola.warn(
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
  }
@@ -1,4 +1,4 @@
1
- const version = "0.8.39";
1
+ const version = "0.8.40";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.2.0",
4
4
  "@fastify/deepmerge": "^2.0.2",
@@ -1,4 +1,4 @@
1
- const version = "0.8.39";
1
+ const version = "0.8.40";
2
2
  const devDependencies = {
3
3
  "@antfu/eslint-config": "^4.2.0",
4
4
  "@fastify/deepmerge": "^2.0.2",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.8.39",
4
+ "version": "0.8.40",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {