silgi 0.17.8 → 0.17.9
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 +2 -1
- package/dist/cli/dev.mjs +1 -0
- package/dist/cli/prepare.mjs +1 -0
- package/dist/cli/writeTypesAndFiles.mjs +57 -46
- package/dist/kit/index.d.mts +2 -1
- package/dist/kit/index.d.ts +2 -1
- package/dist/kit/index.mjs +5 -2
- package/dist/meta/index.d.mts +2 -1
- package/dist/meta/index.d.ts +2 -1
- package/package.json +2 -1
package/dist/_chunks/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = "0.17.
|
|
1
|
+
const version = "0.17.9";
|
|
2
2
|
const peerDependencies = {
|
|
3
3
|
"@fastify/deepmerge": "^2.0.2",
|
|
4
4
|
"@nuxt/kit": "^3.15.3",
|
|
@@ -27,6 +27,7 @@ const dependencies = {
|
|
|
27
27
|
"dot-prop": "catalog:",
|
|
28
28
|
dotenv: "catalog:",
|
|
29
29
|
"escape-string-regexp": "catalog:",
|
|
30
|
+
exsolve: "^1.0.4",
|
|
30
31
|
globby: "catalog:",
|
|
31
32
|
hookable: "catalog:",
|
|
32
33
|
ignore: "catalog:",
|
package/dist/cli/dev.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -2,19 +2,20 @@ import { existsSync, promises, readFileSync, writeFileSync, mkdirSync } from 'no
|
|
|
2
2
|
import { readdir, readFile } from 'node:fs/promises';
|
|
3
3
|
import consola$1, { consola } from 'consola';
|
|
4
4
|
import { createHooks, createDebugger } from 'hookable';
|
|
5
|
-
import { join, resolve,
|
|
5
|
+
import { join, resolve, relative, dirname, basename, extname, isAbsolute } from 'pathe';
|
|
6
6
|
import { useSilgiCLI, silgiCLICtx } from 'silgi/core';
|
|
7
|
-
import { relativeWithDot, hash, resolveAlias,
|
|
7
|
+
import { relativeWithDot, hash, resolveAlias, directoryToURL, writeFile, parseServices, normalizeTemplate, useLogger, addTemplate, initRuntimeConfig, hasError as hasError$1, resolveSilgiPath, isDirectory } from 'silgi/kit';
|
|
8
8
|
import { runtimeDir } from 'silgi/runtime/meta';
|
|
9
9
|
import { autoImportTypes } from 'silgi/types';
|
|
10
10
|
import { scanExports, createUnimport, toExports } from 'unimport';
|
|
11
11
|
import { c as createRouteRules } from '../_chunks/routeRules.mjs';
|
|
12
12
|
import { p as prepareEnv } from './env.mjs';
|
|
13
|
-
import { resolveModuleExportNames,
|
|
13
|
+
import { resolveModuleExportNames, resolvePath, parseNodeModulePath, lookupNodeModuleSubpath } from 'mlly';
|
|
14
14
|
import { createJiti } from 'dev-jiti';
|
|
15
15
|
import { a as hasInstalledModule, h as hasError } from './compatibility.mjs';
|
|
16
|
-
import {
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
17
17
|
import defu, { defu as defu$1 } from 'defu';
|
|
18
|
+
import { resolveModuleURL } from 'exsolve';
|
|
18
19
|
import { isRelative, withTrailingSlash } from 'ufo';
|
|
19
20
|
import { globby } from 'globby';
|
|
20
21
|
import ignore from 'ignore';
|
|
@@ -387,70 +388,80 @@ async function installModule(moduleToInstall, silgi = useSilgiCLI(), inlineOptio
|
|
|
387
388
|
}
|
|
388
389
|
}
|
|
389
390
|
|
|
390
|
-
const
|
|
391
|
-
async function _resolveSilgiModule(
|
|
392
|
-
let
|
|
391
|
+
const MissingModuleMatcher = /Cannot find module\s+['"]?([^'")\s]+)['"]?/i;
|
|
392
|
+
async function _resolveSilgiModule(silgiModule, silgi) {
|
|
393
|
+
let resolvedModulePath;
|
|
393
394
|
let buildTimeModuleMeta = {};
|
|
394
395
|
const jiti = createJiti(silgi.options.rootDir, {
|
|
395
396
|
alias: silgi.options.alias
|
|
396
397
|
});
|
|
397
|
-
if (typeof
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
mod = resolve(silgi.options.rootDir, mod);
|
|
398
|
+
if (typeof silgiModule === "string") {
|
|
399
|
+
silgiModule = resolveAlias(silgiModule, silgi.options.alias);
|
|
400
|
+
if (isRelative(silgiModule)) {
|
|
401
|
+
silgiModule = resolve(silgi.options.rootDir, silgiModule);
|
|
402
402
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
403
|
+
try {
|
|
404
|
+
const src = resolveModuleURL(silgiModule, {
|
|
405
|
+
from: silgi.options.modulesDir.map((m) => directoryToURL(m.replace(/\/node_modules\/?$/, "/"))),
|
|
406
|
+
suffixes: ["silgi", "silgi/index", "module", "module/index", "", "index"],
|
|
407
|
+
extensions: [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"],
|
|
408
|
+
conditions: silgi.options.conditions
|
|
409
|
+
});
|
|
410
|
+
console.log("src:", src);
|
|
411
|
+
resolvedModulePath = fileURLToPath(src);
|
|
412
|
+
const resolvedSilgiModule = await jiti.import(src, { default: true });
|
|
413
|
+
if (typeof resolvedSilgiModule !== "function") {
|
|
414
|
+
throw new TypeError(`Nuxt module should be a function: ${silgiModule}.`);
|
|
415
|
+
}
|
|
416
|
+
silgiModule = await jiti.import(src, {
|
|
417
|
+
default: true,
|
|
418
|
+
conditions: silgi.options.conditions
|
|
419
|
+
});
|
|
420
|
+
const moduleMetadataPath = new URL("module.json", src);
|
|
421
|
+
if (existsSync(moduleMetadataPath)) {
|
|
422
|
+
buildTimeModuleMeta = JSON.parse(await promises.readFile(moduleMetadataPath, "utf-8"));
|
|
423
|
+
} else {
|
|
424
|
+
if (typeof silgiModule === "function") {
|
|
425
|
+
const meta = await silgiModule.getMeta?.();
|
|
426
|
+
const _exports = await scanExports(resolvedModulePath, true);
|
|
427
|
+
buildTimeModuleMeta = {
|
|
428
|
+
...meta,
|
|
429
|
+
exports: _exports.map(({ from, ...rest }) => rest)
|
|
430
|
+
};
|
|
425
431
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
432
|
+
}
|
|
433
|
+
} catch (error) {
|
|
434
|
+
const code = error.code;
|
|
435
|
+
if (code === "MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_UNSUPPORTED_DIR_IMPORT" || code === "ENOTDIR") {
|
|
436
|
+
throw new TypeError(`Could not load \`${silgiModule}\`. Is it installed?`);
|
|
437
|
+
}
|
|
438
|
+
if (code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND") {
|
|
439
|
+
const module = MissingModuleMatcher.exec(error.message)?.[1];
|
|
440
|
+
if (module && !module.includes(silgiModule)) {
|
|
441
|
+
throw new TypeError(`Error while importing module \`${silgiModule}\`: ${error}`);
|
|
431
442
|
}
|
|
432
|
-
logger$1.error(`Error while importing module \`${mod}\`: ${error}`);
|
|
433
|
-
throw error;
|
|
434
443
|
}
|
|
435
444
|
}
|
|
436
445
|
}
|
|
437
446
|
if (!buildTimeModuleMeta) {
|
|
438
|
-
throw new Error(`Module ${
|
|
447
|
+
throw new Error(`Module ${silgiModule} is not a valid Silgi module`);
|
|
439
448
|
}
|
|
440
|
-
if (typeof
|
|
449
|
+
if (typeof silgiModule === "function") {
|
|
441
450
|
if (silgi.scanModules.some((m) => m.meta?.configKey === buildTimeModuleMeta.configKey)) {
|
|
442
451
|
throw new Error(`Module with key \`${buildTimeModuleMeta.configKey}\` already exists`);
|
|
443
452
|
}
|
|
444
|
-
const options = await
|
|
453
|
+
const options = await silgiModule.getOptions?.() || {};
|
|
445
454
|
if (options) {
|
|
446
455
|
silgi.options._c12.config[buildTimeModuleMeta.configKey] = defu(
|
|
447
456
|
silgi.options._c12.config[buildTimeModuleMeta.configKey] || {},
|
|
448
457
|
options || {}
|
|
449
458
|
);
|
|
459
|
+
} else {
|
|
460
|
+
throw new TypeError(`Could not load \`${silgiModule}\`. Is it installed?`);
|
|
450
461
|
}
|
|
451
462
|
silgi.scanModules.push({
|
|
452
463
|
meta: buildTimeModuleMeta,
|
|
453
|
-
entryPath:
|
|
464
|
+
entryPath: resolvedModulePath || "",
|
|
454
465
|
installed: false,
|
|
455
466
|
options
|
|
456
467
|
});
|
|
@@ -2126,7 +2137,7 @@ async function writeTypesAndFiles(silgi) {
|
|
|
2126
2137
|
}
|
|
2127
2138
|
let path = resolveAlias$1(i.from, silgi.options.alias);
|
|
2128
2139
|
if (isAbsolute(path)) {
|
|
2129
|
-
const resolvedPath = await resolvePath
|
|
2140
|
+
const resolvedPath = await resolvePath(i.from, {
|
|
2130
2141
|
url: silgi.options.nodeModulesDirs
|
|
2131
2142
|
}).catch(() => null);
|
|
2132
2143
|
if (resolvedPath) {
|
package/dist/kit/index.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ import { IncomingMessage } from 'node:http';
|
|
|
6
6
|
|
|
7
7
|
declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
|
|
8
8
|
|
|
9
|
+
declare function directoryToURL(dir: string): URL;
|
|
9
10
|
/**
|
|
10
11
|
* Resolve a module from a given root path using an algorithm patterned on
|
|
11
12
|
* the upcoming `import.meta.resolve`. It returns a file URL
|
|
@@ -149,4 +150,4 @@ declare const MODE_RE: RegExp;
|
|
|
149
150
|
declare function hasSilgiModule(moduleKey: string, silgi?: SilgiCLI): boolean;
|
|
150
151
|
declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolean;
|
|
151
152
|
|
|
152
|
-
export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, filterInPlace, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useSilgiRuntimeConfig, writeFile };
|
|
153
|
+
export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useSilgiRuntimeConfig, writeFile };
|
package/dist/kit/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { IncomingMessage } from 'node:http';
|
|
|
6
6
|
|
|
7
7
|
declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
|
|
8
8
|
|
|
9
|
+
declare function directoryToURL(dir: string): URL;
|
|
9
10
|
/**
|
|
10
11
|
* Resolve a module from a given root path using an algorithm patterned on
|
|
11
12
|
* the upcoming `import.meta.resolve`. It returns a file URL
|
|
@@ -149,4 +150,4 @@ declare const MODE_RE: RegExp;
|
|
|
149
150
|
declare function hasSilgiModule(moduleKey: string, silgi?: SilgiCLI): boolean;
|
|
150
151
|
declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolean;
|
|
151
152
|
|
|
152
|
-
export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, filterInPlace, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useSilgiRuntimeConfig, writeFile };
|
|
153
|
+
export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useSilgiRuntimeConfig, writeFile };
|
package/dist/kit/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { c as checkSilgiCompatibility } from '../cli/compatibility.mjs';
|
|
2
2
|
export { h as hasError } from '../cli/compatibility.mjs';
|
|
3
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
3
4
|
import { resolvePath as resolvePath$1 } from 'mlly';
|
|
4
5
|
import fsp from 'node:fs/promises';
|
|
5
6
|
import consola, { consola as consola$1 } from 'consola';
|
|
@@ -12,7 +13,6 @@ import { useSilgi, tryUseSilgiCLI, useSilgiCLI, tryUseSilgi } from 'silgi/core';
|
|
|
12
13
|
import { defu } from 'defu';
|
|
13
14
|
import { withLeadingSlash } from 'ufo';
|
|
14
15
|
import { existsSync, promises } from 'node:fs';
|
|
15
|
-
import { fileURLToPath } from 'node:url';
|
|
16
16
|
import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
|
|
17
17
|
import destr from 'destr';
|
|
18
18
|
import { klona } from 'klona';
|
|
@@ -20,6 +20,9 @@ import { hash as hash$2 } from 'silgi/kit';
|
|
|
20
20
|
import 'semver/functions/satisfies.js';
|
|
21
21
|
import 'silgi/meta';
|
|
22
22
|
|
|
23
|
+
function directoryToURL(dir) {
|
|
24
|
+
return pathToFileURL(`${dir}/`);
|
|
25
|
+
}
|
|
23
26
|
async function tryResolveModule(id, url = import.meta.url) {
|
|
24
27
|
try {
|
|
25
28
|
return await resolvePath$1(id, { url });
|
|
@@ -571,4 +574,4 @@ function isValidIp(ip) {
|
|
|
571
574
|
return false;
|
|
572
575
|
}
|
|
573
576
|
|
|
574
|
-
export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, filterInPlace, getIpAddress, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useSilgiRuntimeConfig, writeFile };
|
|
577
|
+
export { MODE_RE, addTemplate, applyEnv, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, getIpAddress, hasInstalledModule, hasSilgiModule, hash, initRuntimeConfig, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useSilgiRuntimeConfig, writeFile };
|
package/dist/meta/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = "0.17.
|
|
1
|
+
const version = "0.17.9";
|
|
2
2
|
const peerDependencies = {
|
|
3
3
|
"@fastify/deepmerge": "^2.0.2",
|
|
4
4
|
"@nuxt/kit": "^3.15.3",
|
|
@@ -27,6 +27,7 @@ const dependencies = {
|
|
|
27
27
|
"dot-prop": "catalog:",
|
|
28
28
|
dotenv: "catalog:",
|
|
29
29
|
"escape-string-regexp": "catalog:",
|
|
30
|
+
exsolve: "^1.0.4",
|
|
30
31
|
globby: "catalog:",
|
|
31
32
|
hookable: "catalog:",
|
|
32
33
|
ignore: "catalog:",
|
package/dist/meta/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = "0.17.
|
|
1
|
+
const version = "0.17.9";
|
|
2
2
|
const peerDependencies = {
|
|
3
3
|
"@fastify/deepmerge": "^2.0.2",
|
|
4
4
|
"@nuxt/kit": "^3.15.3",
|
|
@@ -27,6 +27,7 @@ const dependencies = {
|
|
|
27
27
|
"dot-prop": "catalog:",
|
|
28
28
|
dotenv: "catalog:",
|
|
29
29
|
"escape-string-regexp": "catalog:",
|
|
30
|
+
exsolve: "^1.0.4",
|
|
30
31
|
globby: "catalog:",
|
|
31
32
|
hookable: "catalog:",
|
|
32
33
|
ignore: "catalog:",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.9",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -126,6 +126,7 @@
|
|
|
126
126
|
"dot-prop": "^9.0.0",
|
|
127
127
|
"dotenv": "^16.4.7",
|
|
128
128
|
"escape-string-regexp": "^5.0.0",
|
|
129
|
+
"exsolve": "^1.0.4",
|
|
129
130
|
"globby": "^14.1.0",
|
|
130
131
|
"hookable": "^5.5.3",
|
|
131
132
|
"ignore": "^7.0.3",
|