silgi 0.25.13 → 0.25.15
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/cli/index.mjs +1 -1
- package/dist/cli/init.mjs +43 -8
- package/dist/kit/index.mjs +59 -9
- package/package.json +1 -1
- package/dist/_chunks/fs.mjs +0 -59
package/dist/cli/index.mjs
CHANGED
package/dist/cli/init.mjs
CHANGED
|
@@ -1,13 +1,49 @@
|
|
|
1
1
|
import { writeFileSync } from 'node:fs';
|
|
2
2
|
import * as p from '@clack/prompts';
|
|
3
|
-
import { defineCommand } from 'citty';
|
|
3
|
+
import { defineCommand, runCommand } from 'citty';
|
|
4
4
|
import consola from 'consola';
|
|
5
5
|
import fsp from 'node:fs/promises';
|
|
6
6
|
import { dirname } from 'pathe';
|
|
7
|
-
import {
|
|
7
|
+
import { p as prepare } from './prepare.mjs';
|
|
8
|
+
import 'silgi/meta';
|
|
9
|
+
import './writeTypesAndFiles.mjs';
|
|
10
|
+
import 'knitwork';
|
|
11
|
+
import 'silgi/kit';
|
|
12
|
+
import 'hookable';
|
|
8
13
|
import 'silgi';
|
|
14
|
+
import 'silgi/runtime/meta';
|
|
15
|
+
import 'unimport';
|
|
16
|
+
import '../_chunks/routeRules.mjs';
|
|
17
|
+
import 'ufo';
|
|
18
|
+
import 'dotenv';
|
|
19
|
+
import 'mlly';
|
|
20
|
+
import 'dev-jiti';
|
|
21
|
+
import './compatibility.mjs';
|
|
22
|
+
import 'semver/functions/satisfies.js';
|
|
23
|
+
import 'node:url';
|
|
24
|
+
import 'defu';
|
|
25
|
+
import 'exsolve';
|
|
26
|
+
import 'untyped';
|
|
27
|
+
import 'globby';
|
|
28
|
+
import 'ignore';
|
|
29
|
+
import '@oxc-parser/wasm';
|
|
30
|
+
import 'klona';
|
|
31
|
+
import 'silgi/runtime';
|
|
32
|
+
import 'unstorage';
|
|
33
|
+
import 'scule';
|
|
34
|
+
import './types.mjs';
|
|
35
|
+
import 'c12';
|
|
36
|
+
import 'compatx';
|
|
37
|
+
import 'klona/full';
|
|
38
|
+
import 'std-env';
|
|
9
39
|
import 'consola/utils';
|
|
10
|
-
import '
|
|
40
|
+
import 'escape-string-regexp';
|
|
41
|
+
import 'pkg-types';
|
|
42
|
+
import 'pathe/utils';
|
|
43
|
+
import 'node:child_process';
|
|
44
|
+
import 'picocolors';
|
|
45
|
+
import '../_chunks/silgiApp.mjs';
|
|
46
|
+
import 'unctx';
|
|
11
47
|
|
|
12
48
|
const init = defineCommand({
|
|
13
49
|
meta: {
|
|
@@ -48,10 +84,6 @@ const init = defineCommand({
|
|
|
48
84
|
`import { buildSilgi } from '../silgi/core'`,
|
|
49
85
|
"",
|
|
50
86
|
"export default defineNitroPlugin(async (nitro) => {",
|
|
51
|
-
"if (!globalThis.__nitro__) {",
|
|
52
|
-
" globalThis.__nitro__ = {}",
|
|
53
|
-
"}",
|
|
54
|
-
"globalThis.__nitro__.useRuntimeConfig = useRuntimeConfig",
|
|
55
87
|
"",
|
|
56
88
|
" const _silgi = buildSilgi(",
|
|
57
89
|
" nitro,",
|
|
@@ -66,8 +98,11 @@ const init = defineCommand({
|
|
|
66
98
|
];
|
|
67
99
|
const file = "server/plugins/silgi.ts";
|
|
68
100
|
await fsp.mkdir(dirname(file), { recursive: true });
|
|
69
|
-
|
|
101
|
+
writeFileSync(file, plugin.join("\n"));
|
|
70
102
|
consola.success("Silgi plugin created, see server/plugins/silgi.ts");
|
|
103
|
+
runCommand(prepare, {
|
|
104
|
+
rawArgs: []
|
|
105
|
+
});
|
|
71
106
|
}
|
|
72
107
|
writeFileSync("silgi.config.ts", context.join("\n"));
|
|
73
108
|
consola.success("Silgi config created, see silgi.config.ts");
|
package/dist/kit/index.mjs
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import { tryUseSilgiCLI,
|
|
1
|
+
import { tryUseSilgiCLI, useSilgiCLI, useSilgi } from 'silgi';
|
|
2
2
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
3
3
|
import { resolvePath as resolvePath$1 } from 'mlly';
|
|
4
|
-
|
|
4
|
+
import fsp from 'node:fs/promises';
|
|
5
|
+
import consola, { consola as consola$1 } from 'consola';
|
|
6
|
+
import { relative, resolve, dirname, normalize, isAbsolute, join, parse, basename } from 'pathe';
|
|
7
|
+
import { colors } from 'consola/utils';
|
|
8
|
+
import { getProperty } from 'dot-prop';
|
|
5
9
|
import { genString, genObjectFromRaw, genObjectFromValues, genObjectFromRawEntries } from 'knitwork';
|
|
6
10
|
import { hash as hash$1 } from 'ohash';
|
|
7
11
|
import { camelCase } from 'scule';
|
|
8
|
-
import { consola } from 'consola';
|
|
9
12
|
import { defu } from 'defu';
|
|
10
13
|
import { c as checkSilgiCompatibility } from '../cli/compatibility.mjs';
|
|
11
14
|
import { withLeadingSlash } from 'ufo';
|
|
12
15
|
import { existsSync, promises } from 'node:fs';
|
|
13
|
-
import { dirname, resolve, normalize, isAbsolute, join, relative, parse, basename } from 'pathe';
|
|
14
16
|
import { resolveAlias as resolveAlias$1 } from 'pathe/utils';
|
|
15
17
|
import { hash as hash$2 } from 'silgi/kit';
|
|
16
|
-
import 'node:fs/promises';
|
|
17
|
-
import 'consola/utils';
|
|
18
|
-
import 'dot-prop';
|
|
19
18
|
import 'semver/functions/satisfies.js';
|
|
20
19
|
import 'silgi/meta';
|
|
21
20
|
|
|
@@ -37,6 +36,57 @@ async function tryResolveModule(id, url = import.meta.url) {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
|
|
39
|
+
function prettyPath(p, highlight = true) {
|
|
40
|
+
p = relative(process.cwd(), p);
|
|
41
|
+
return highlight ? colors.cyan(p) : p;
|
|
42
|
+
}
|
|
43
|
+
function resolveSilgiPath(path, silgiCLIOptions, base) {
|
|
44
|
+
if (typeof path !== "string") {
|
|
45
|
+
throw new TypeError(`Invalid path: ${path}`);
|
|
46
|
+
}
|
|
47
|
+
path = _compilePathTemplate(path)(silgiCLIOptions);
|
|
48
|
+
for (const base2 in silgiCLIOptions.alias) {
|
|
49
|
+
if (path.startsWith(base2)) {
|
|
50
|
+
path = silgiCLIOptions.alias[base2] + path.slice(base2.length);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return resolve(base || silgiCLIOptions.srcDir, path);
|
|
54
|
+
}
|
|
55
|
+
function _compilePathTemplate(contents) {
|
|
56
|
+
return (params) => contents.replace(/\{\{ ?([\w.]+) ?\}\}/g, (_, match) => {
|
|
57
|
+
const val = getProperty(params, match);
|
|
58
|
+
if (!val) {
|
|
59
|
+
consola.warn(
|
|
60
|
+
`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
return val || `${match}`;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function writeFile(file, contents, log = false) {
|
|
68
|
+
const silgi = useSilgiCLI();
|
|
69
|
+
if (silgi.errors.length) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
await fsp.mkdir(dirname(file), { recursive: true });
|
|
73
|
+
await fsp.writeFile(
|
|
74
|
+
file,
|
|
75
|
+
contents,
|
|
76
|
+
typeof contents === "string" ? "utf8" : void 0
|
|
77
|
+
);
|
|
78
|
+
if (log) {
|
|
79
|
+
consola$1.info("Generated", prettyPath(file));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function isDirectory$1(path) {
|
|
83
|
+
try {
|
|
84
|
+
return (await fsp.stat(path)).isDirectory();
|
|
85
|
+
} catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
40
90
|
const reservedCode = /* @__PURE__ */ new Set([
|
|
41
91
|
"process",
|
|
42
92
|
"global",
|
|
@@ -104,7 +154,7 @@ function isH3() {
|
|
|
104
154
|
return false;
|
|
105
155
|
}
|
|
106
156
|
|
|
107
|
-
const logger = consola;
|
|
157
|
+
const logger = consola$1;
|
|
108
158
|
function useLogger(tag, options = {}) {
|
|
109
159
|
return tag ? logger.create(options).withTag(tag) : logger;
|
|
110
160
|
}
|
|
@@ -476,4 +526,4 @@ function isValidIp(ip) {
|
|
|
476
526
|
return false;
|
|
477
527
|
}
|
|
478
528
|
|
|
479
|
-
export { MODE_RE, addTemplate, baseHeaderBannerComment, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, genEnsureSafeVar, getAllEntries, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse };
|
|
529
|
+
export { MODE_RE, addTemplate, baseHeaderBannerComment, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, genEnsureSafeVar, getAllEntries, getIpAddress, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|
package/package.json
CHANGED
package/dist/_chunks/fs.mjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import fsp from 'node:fs/promises';
|
|
2
|
-
import consola, { consola as consola$1 } from 'consola';
|
|
3
|
-
import { relative, resolve, dirname } from 'pathe';
|
|
4
|
-
import { useSilgiCLI } from 'silgi';
|
|
5
|
-
import { colors } from 'consola/utils';
|
|
6
|
-
import { getProperty } from 'dot-prop';
|
|
7
|
-
|
|
8
|
-
function prettyPath(p, highlight = true) {
|
|
9
|
-
p = relative(process.cwd(), p);
|
|
10
|
-
return highlight ? colors.cyan(p) : p;
|
|
11
|
-
}
|
|
12
|
-
function resolveSilgiPath(path, silgiCLIOptions, base) {
|
|
13
|
-
if (typeof path !== "string") {
|
|
14
|
-
throw new TypeError(`Invalid path: ${path}`);
|
|
15
|
-
}
|
|
16
|
-
path = _compilePathTemplate(path)(silgiCLIOptions);
|
|
17
|
-
for (const base2 in silgiCLIOptions.alias) {
|
|
18
|
-
if (path.startsWith(base2)) {
|
|
19
|
-
path = silgiCLIOptions.alias[base2] + path.slice(base2.length);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return resolve(base || silgiCLIOptions.srcDir, path);
|
|
23
|
-
}
|
|
24
|
-
function _compilePathTemplate(contents) {
|
|
25
|
-
return (params) => contents.replace(/\{\{ ?([\w.]+) ?\}\}/g, (_, match) => {
|
|
26
|
-
const val = getProperty(params, match);
|
|
27
|
-
if (!val) {
|
|
28
|
-
consola.warn(
|
|
29
|
-
`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
return val || `${match}`;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async function writeFile(file, contents, log = false) {
|
|
37
|
-
const silgi = useSilgiCLI();
|
|
38
|
-
if (silgi.errors.length) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
await fsp.mkdir(dirname(file), { recursive: true });
|
|
42
|
-
await fsp.writeFile(
|
|
43
|
-
file,
|
|
44
|
-
contents,
|
|
45
|
-
typeof contents === "string" ? "utf8" : void 0
|
|
46
|
-
);
|
|
47
|
-
if (log) {
|
|
48
|
-
consola$1.info("Generated", prettyPath(file));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async function isDirectory(path) {
|
|
52
|
-
try {
|
|
53
|
-
return (await fsp.stat(path)).isDirectory();
|
|
54
|
-
} catch {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { isDirectory as i, prettyPath as p, resolveSilgiPath as r, writeFile as w };
|