silgi 0.28.12 → 0.29.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/cli/index.mjs +1 -1
- package/dist/kit/index.d.mts +4 -2
- package/dist/kit/index.mjs +54 -48
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/kit/index.d.mts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, SilgiTemplate, ResolvedSilgiTemplate, SilgiEvents } from 'silgi/types';
|
|
1
|
+
import { Commands, SilgiCLI, ModuleOptionsCustom, ModuleDefinition, SilgiModule, ServiceParseModule, SilgiPreset, SilgiPresetMeta, SilgiTemplate, ResolvedSilgiTemplate, SilgiEvents } from 'silgi/types';
|
|
2
2
|
import { Buffer } from 'node:buffer';
|
|
3
3
|
import { ConsolaOptions, ConsolaInstance } from 'consola';
|
|
4
4
|
import * as rfc6902 from 'rfc6902';
|
|
5
5
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
6
6
|
|
|
7
|
+
declare function addCommands(data: Commands | Commands[]): Promise<void>;
|
|
8
|
+
|
|
7
9
|
declare function addNPMPackage(data: {
|
|
8
10
|
name: string;
|
|
9
11
|
version?: string;
|
|
@@ -289,5 +291,5 @@ declare function hasInstalledModule(moduleKey: string, silgi?: SilgiCLI): boolea
|
|
|
289
291
|
declare const baseHeaderBannerComment: string[];
|
|
290
292
|
declare function processFilePath(src: string): string;
|
|
291
293
|
|
|
292
|
-
export { MODE_RE, MigrationStatus, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|
|
294
|
+
export { MODE_RE, MigrationStatus, addCommands, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory, isH3, isNitro, isNuxt, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|
|
293
295
|
export type { FunctionConfig, JsonPatch, MigrationData, MigrationInfo, MigrationOptions, MigrationResult };
|
package/dist/kit/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { u as useSilgiCLI$1 } from '../_chunks/silgiApp.mjs';
|
|
2
|
+
import { relative, resolve, dirname, join, normalize, isAbsolute, parse, basename } from 'pathe';
|
|
3
|
+
import { useSilgiCLI, tryUseSilgiCLI, useSilgi } from 'silgi';
|
|
1
4
|
import { execSync } from 'node:child_process';
|
|
2
|
-
import { u as useSilgiCLI } from '../_chunks/silgiApp.mjs';
|
|
3
|
-
import { tryUseSilgiCLI, useSilgiCLI as useSilgiCLI$1, useSilgi } from 'silgi';
|
|
4
5
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
5
6
|
import { resolvePath as resolvePath$1 } from 'mlly';
|
|
6
7
|
import fsp, { mkdir, readFile, writeFile as writeFile$1 } from 'node:fs/promises';
|
|
7
8
|
import consola, { consola as consola$1 } from 'consola';
|
|
8
|
-
import { relative, resolve, dirname, join, normalize, isAbsolute, parse, basename } from 'pathe';
|
|
9
9
|
import { colors } from 'consola/utils';
|
|
10
10
|
import { getProperty } from 'dot-prop';
|
|
11
11
|
import { genString, genObjectFromRaw, genObjectFromValues, genObjectFromRawEntries } from 'knitwork';
|
|
@@ -22,9 +22,54 @@ import 'unctx';
|
|
|
22
22
|
import 'semver/functions/satisfies.js';
|
|
23
23
|
import 'silgi/meta';
|
|
24
24
|
|
|
25
|
+
const RELATIVE_RE = /^([^.])/;
|
|
26
|
+
function relativeWithDot(from, to) {
|
|
27
|
+
return relative(from, to).replace(RELATIVE_RE, "./$1") || ".";
|
|
28
|
+
}
|
|
29
|
+
function toArray(value) {
|
|
30
|
+
return Array.isArray(value) ? value : [value];
|
|
31
|
+
}
|
|
32
|
+
function filterInPlace(array, predicate) {
|
|
33
|
+
for (let i = array.length; i--; i >= 0) {
|
|
34
|
+
if (!predicate(array[i], i, array)) {
|
|
35
|
+
array.splice(i, 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return array;
|
|
39
|
+
}
|
|
40
|
+
const MODE_RE = /\.(server|client)(\.\w+)*$/;
|
|
41
|
+
function hasSilgiModule(moduleKey, silgi = useSilgiCLI()) {
|
|
42
|
+
return silgi.scanModules.some(({ meta }) => meta.configKey === moduleKey) || Object.keys(silgi.scanModules).includes(moduleKey);
|
|
43
|
+
}
|
|
44
|
+
function hasInstalledModule(moduleKey, silgi = useSilgiCLI()) {
|
|
45
|
+
const find = silgi.scanModules.find(({ meta }) => meta.configKey === moduleKey);
|
|
46
|
+
return find?.installed ?? false;
|
|
47
|
+
}
|
|
48
|
+
const baseHeaderBannerComment = [
|
|
49
|
+
"// DO NOT EDIT THIS FILE",
|
|
50
|
+
"// This file is generated by Silgi",
|
|
51
|
+
"/* eslint-disable */",
|
|
52
|
+
"/* prettier-ignore */",
|
|
53
|
+
"/* tslint:disable */"
|
|
54
|
+
];
|
|
55
|
+
function processFilePath(src) {
|
|
56
|
+
const silgi = useSilgiCLI();
|
|
57
|
+
if (silgi.options.typescript.removeFileExtension) {
|
|
58
|
+
src = src.replace(/\.ts$/, "");
|
|
59
|
+
return src;
|
|
60
|
+
}
|
|
61
|
+
return src;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function addCommands(data) {
|
|
65
|
+
useSilgiCLI$1().hook("prepare:commands", (commads) => {
|
|
66
|
+
commads.push(...toArray(data));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
25
70
|
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
26
71
|
async function addNPMPackage(data) {
|
|
27
|
-
const silgi = useSilgiCLI();
|
|
72
|
+
const silgi = useSilgiCLI$1();
|
|
28
73
|
for (const item of data) {
|
|
29
74
|
if (item.when === false) {
|
|
30
75
|
continue;
|
|
@@ -96,7 +141,7 @@ function _compilePathTemplate(contents) {
|
|
|
96
141
|
}
|
|
97
142
|
|
|
98
143
|
async function writeFile(file, contents, log = false) {
|
|
99
|
-
const silgi = useSilgiCLI
|
|
144
|
+
const silgi = useSilgiCLI();
|
|
100
145
|
if (silgi.errors.length) {
|
|
101
146
|
return;
|
|
102
147
|
}
|
|
@@ -599,7 +644,7 @@ function _defineSilgiModule(definition) {
|
|
|
599
644
|
}
|
|
600
645
|
const module = defu(definition, { meta: {} });
|
|
601
646
|
module.meta.configKey ||= module.meta.name;
|
|
602
|
-
async function getOptions(inlineOptions, silgi = useSilgiCLI
|
|
647
|
+
async function getOptions(inlineOptions, silgi = useSilgiCLI()) {
|
|
603
648
|
const nuxtConfigOptionsKey = module.meta.configKey || module.meta.name;
|
|
604
649
|
const nuxtConfigOptions = nuxtConfigOptionsKey && nuxtConfigOptionsKey in silgi.options ? silgi.options[nuxtConfigOptionsKey] : {};
|
|
605
650
|
const optionsDefaults = typeof module.defaults === "function" ? await module.defaults(silgi) : module.defaults ?? {};
|
|
@@ -783,47 +828,8 @@ async function resolveSilgiModule(base, paths) {
|
|
|
783
828
|
return resolved;
|
|
784
829
|
}
|
|
785
830
|
|
|
786
|
-
const RELATIVE_RE = /^([^.])/;
|
|
787
|
-
function relativeWithDot(from, to) {
|
|
788
|
-
return relative(from, to).replace(RELATIVE_RE, "./$1") || ".";
|
|
789
|
-
}
|
|
790
|
-
function toArray(value) {
|
|
791
|
-
return Array.isArray(value) ? value : [value];
|
|
792
|
-
}
|
|
793
|
-
function filterInPlace(array, predicate) {
|
|
794
|
-
for (let i = array.length; i--; i >= 0) {
|
|
795
|
-
if (!predicate(array[i], i, array)) {
|
|
796
|
-
array.splice(i, 1);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
return array;
|
|
800
|
-
}
|
|
801
|
-
const MODE_RE = /\.(server|client)(\.\w+)*$/;
|
|
802
|
-
function hasSilgiModule(moduleKey, silgi = useSilgiCLI$1()) {
|
|
803
|
-
return silgi.scanModules.some(({ meta }) => meta.configKey === moduleKey) || Object.keys(silgi.scanModules).includes(moduleKey);
|
|
804
|
-
}
|
|
805
|
-
function hasInstalledModule(moduleKey, silgi = useSilgiCLI$1()) {
|
|
806
|
-
const find = silgi.scanModules.find(({ meta }) => meta.configKey === moduleKey);
|
|
807
|
-
return find?.installed ?? false;
|
|
808
|
-
}
|
|
809
|
-
const baseHeaderBannerComment = [
|
|
810
|
-
"// DO NOT EDIT THIS FILE",
|
|
811
|
-
"// This file is generated by Silgi",
|
|
812
|
-
"/* eslint-disable */",
|
|
813
|
-
"/* prettier-ignore */",
|
|
814
|
-
"/* tslint:disable */"
|
|
815
|
-
];
|
|
816
|
-
function processFilePath(src) {
|
|
817
|
-
const silgi = useSilgiCLI$1();
|
|
818
|
-
if (silgi.options.typescript.removeFileExtension) {
|
|
819
|
-
src = src.replace(/\.ts$/, "");
|
|
820
|
-
return src;
|
|
821
|
-
}
|
|
822
|
-
return src;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
831
|
function addTemplate(_template) {
|
|
826
|
-
const silgi = useSilgiCLI
|
|
832
|
+
const silgi = useSilgiCLI();
|
|
827
833
|
const template = normalizeTemplate(_template);
|
|
828
834
|
filterInPlace(silgi.options.build.templates, (p) => normalizeTemplate(p).dst !== template.dst);
|
|
829
835
|
silgi.options.build.templates.push(template);
|
|
@@ -857,7 +863,7 @@ function normalizeTemplate(template, buildDir) {
|
|
|
857
863
|
template.write = true;
|
|
858
864
|
}
|
|
859
865
|
if (!template.dst) {
|
|
860
|
-
const silgi = useSilgiCLI
|
|
866
|
+
const silgi = useSilgiCLI();
|
|
861
867
|
const dir = template.where === ".silgi" ? silgi.options.build.dir : template.where === "server" ? silgi.options.silgi.serverDir : template.where === "client" ? silgi.options.silgi.clientDir : silgi.options.silgi.serverDir;
|
|
862
868
|
template.dst = resolve(buildDir ?? dir, template.filename);
|
|
863
869
|
}
|
|
@@ -952,4 +958,4 @@ function isValidIp(ip) {
|
|
|
952
958
|
return false;
|
|
953
959
|
}
|
|
954
960
|
|
|
955
|
-
export { MODE_RE, MigrationStatus, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|
|
961
|
+
export { MODE_RE, MigrationStatus, addCommands, addNPMPackage, addTemplate, baseHeaderBannerComment, createFunction, createFunctionConfigs, createResolver, defineSilgiModule, defineSilgiPreset, directoryToURL, filterInPlace, formatFunctions, genEnsureSafeVar, generateMigration, getAllEntries, getIpAddress, getMigration, hasError, hasInstalledModule, hasSilgiModule, hash, ipAddress, isDirectory$1 as isDirectory, isH3, isNitro, isNuxt, listMigrations, migrationDown, migrationUp, normalizeTemplate, parseServices, prettyPath, processFilePath, relativeWithDot, resolveAlias, resolvePath, resolveSilgiModule, resolveSilgiPath, serviceParseModule, toArray, tryResolveModule, useLogger, useRequest, useResponse, writeFile };
|