silgi 0.9.35 → 0.10.0
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/compatibility.mjs +10 -2
- package/dist/cli/init.mjs +49 -6
- package/dist/cli/loader.mjs +3 -0
- package/dist/cli/prepare.mjs +1561 -1430
- package/dist/kit/index.d.mts +4 -2
- package/dist/kit/index.d.ts +4 -2
- package/dist/kit/index.mjs +2 -1
- package/dist/meta/index.d.mts +2 -1
- package/dist/meta/index.d.ts +2 -1
- package/dist/types/index.d.mts +20 -19
- package/dist/types/index.d.ts +20 -19
- package/package.json +2 -1
package/dist/_chunks/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const version = "0.
|
|
1
|
+
const version = "0.10.0";
|
|
2
2
|
const peerDependencies = {
|
|
3
3
|
"@fastify/deepmerge": "^2.0.2",
|
|
4
4
|
"@nuxt/kit": "^3.15.3",
|
|
5
5
|
"@nuxt/schema": "^3.15.4",
|
|
6
|
+
"@silgi/ecosystem": "^0.0.10",
|
|
6
7
|
h3: "^1.14.0",
|
|
7
8
|
nitropack: "^2.10.4",
|
|
8
9
|
nuxt: "^3.15.3",
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { tryUseSilgiCLI, useSilgiCLI } from 'silgi/core';
|
|
1
2
|
import satisfies from 'semver/functions/satisfies.js';
|
|
2
|
-
import { useSilgiCLI } from 'silgi/core';
|
|
3
3
|
import { version } from 'silgi/meta';
|
|
4
4
|
|
|
5
|
+
function hasError(type, silgi) {
|
|
6
|
+
silgi = silgi ?? tryUseSilgiCLI() ?? void 0;
|
|
7
|
+
if (silgi && silgi.errors.some((error) => error.type === type)) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
const SEMANTIC_VERSION_RE = /-\d+\.[0-9a-f]+/;
|
|
6
14
|
function normalizeSemanticVersion(version) {
|
|
7
15
|
return version.replace(SEMANTIC_VERSION_RE, "");
|
|
@@ -27,4 +35,4 @@ function hasInstalledModule(moduleKey, silgi = useSilgiCLI()) {
|
|
|
27
35
|
return find?.installed ?? false;
|
|
28
36
|
}
|
|
29
37
|
|
|
30
|
-
export { checkSilgiCompatibility as c,
|
|
38
|
+
export { hasInstalledModule as a, checkSilgiCompatibility as c, hasError as h };
|
package/dist/cli/init.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { writeFileSync } from 'node:fs';
|
|
2
|
+
import * as p from '@clack/prompts';
|
|
2
3
|
import { defineCommand } from 'citty';
|
|
4
|
+
import consola from 'consola';
|
|
3
5
|
|
|
4
6
|
const init = defineCommand({
|
|
5
7
|
meta: {
|
|
@@ -9,12 +11,53 @@ const init = defineCommand({
|
|
|
9
11
|
},
|
|
10
12
|
args: {},
|
|
11
13
|
async run() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
14
|
+
p.intro("Initializing silgi config");
|
|
15
|
+
const framework = await p.select({
|
|
16
|
+
message: "Choose a framework",
|
|
17
|
+
options: [
|
|
18
|
+
{ label: "Nitro", value: "nitro" },
|
|
19
|
+
{ label: "Nuxt", value: "nuxt" },
|
|
20
|
+
{ label: "H3", value: "h3" },
|
|
21
|
+
{ label: "NPM Package", value: "npm-package" }
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
if (p.isCancel(framework)) {
|
|
25
|
+
consola.info("Silgi config initialization canceled");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const context = [
|
|
29
|
+
`import { defineSilgiConfig } from 'silgi/config'`,
|
|
30
|
+
"",
|
|
31
|
+
"export default defineSilgiConfig({",
|
|
32
|
+
` preset: '${framework}',`,
|
|
33
|
+
` compatibilityDate: '${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}',`,
|
|
34
|
+
" // Please create a namespace for your project",
|
|
35
|
+
" namespaces: [],",
|
|
36
|
+
"",
|
|
37
|
+
"})",
|
|
38
|
+
""
|
|
39
|
+
];
|
|
40
|
+
if (framework === "nitro" || framework === "nuxt") {
|
|
41
|
+
const plugin = [
|
|
42
|
+
`import { buildSilgi } from '../silgi/core'`,
|
|
43
|
+
"",
|
|
44
|
+
"export default defineNitroPlugin(async (nitro) => {",
|
|
45
|
+
" const _silgi = buildSilgi(",
|
|
46
|
+
" nitro,",
|
|
47
|
+
" {},",
|
|
48
|
+
" {",
|
|
49
|
+
" storage: useStorage(),",
|
|
50
|
+
" runtimeConfig: useRuntimeConfig(),",
|
|
51
|
+
" },",
|
|
52
|
+
" )",
|
|
53
|
+
"})",
|
|
54
|
+
""
|
|
55
|
+
];
|
|
56
|
+
writeFileSync("server/plugins/silgi.ts", plugin.join("\n"));
|
|
57
|
+
consola.success("Silgi plugin created, see server/plugins/silgi.ts");
|
|
58
|
+
}
|
|
59
|
+
writeFileSync("silgi.config.ts", context.join("\n"));
|
|
60
|
+
consola.success("Silgi config created, see silgi.config.ts");
|
|
18
61
|
}
|
|
19
62
|
});
|
|
20
63
|
|