silgi 0.27.12 → 0.28.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/build.mjs +1 -0
- package/dist/cli/dev.mjs +1 -0
- package/dist/cli/index.mjs +1 -1
- package/dist/cli/init.mjs +1 -0
- package/dist/cli/install.mjs +1 -0
- package/dist/cli/prepare.mjs +40 -23
- package/dist/cli/silgi.mjs +11 -1
- package/dist/types/index.d.mts +6 -0
- package/package.json +9 -8
package/dist/build.mjs
CHANGED
package/dist/cli/dev.mjs
CHANGED
package/dist/cli/index.mjs
CHANGED
package/dist/cli/init.mjs
CHANGED
package/dist/cli/install.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -147,45 +147,62 @@ const command$1 = defineCommand({
|
|
|
147
147
|
}
|
|
148
148
|
).flat();
|
|
149
149
|
} else if (commandName === "functions") {
|
|
150
|
+
const functionGroups = Object.keys(cliJson).reduce((groups, cmdName) => {
|
|
151
|
+
const scripts2 = cliJson[cmdName];
|
|
152
|
+
if (!Object.values(scripts2).some((script) => script.type === "function")) {
|
|
153
|
+
return groups;
|
|
154
|
+
}
|
|
155
|
+
groups.push(cmdName);
|
|
156
|
+
return groups;
|
|
157
|
+
}, []);
|
|
158
|
+
if (functionGroups.length === 0) {
|
|
159
|
+
consola.warn("No function groups found in cli.json");
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const selectedGroup = await p.select({
|
|
163
|
+
message: "Select a project group",
|
|
164
|
+
options: functionGroups.map((group) => ({
|
|
165
|
+
label: group,
|
|
166
|
+
value: group
|
|
167
|
+
}))
|
|
168
|
+
});
|
|
169
|
+
if (!selectedGroup)
|
|
170
|
+
return;
|
|
150
171
|
const availableFunctions = [];
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
161
|
-
}
|
|
172
|
+
const scripts = cliJson[selectedGroup];
|
|
173
|
+
for (const scriptName of Object.keys(scripts)) {
|
|
174
|
+
const script = scripts[scriptName];
|
|
175
|
+
if (script && script.type === "function") {
|
|
176
|
+
availableFunctions.push({
|
|
177
|
+
command: selectedGroup,
|
|
178
|
+
script: scriptName,
|
|
179
|
+
handler: script
|
|
180
|
+
});
|
|
162
181
|
}
|
|
163
182
|
}
|
|
164
183
|
if (availableFunctions.length === 0) {
|
|
165
|
-
consola.warn(
|
|
184
|
+
consola.warn(`No functions found in the ${selectedGroup} group`);
|
|
166
185
|
return;
|
|
167
186
|
}
|
|
168
187
|
const selectedFunction = await p.select({
|
|
169
|
-
message:
|
|
170
|
-
options: availableFunctions.map((fn) => ({
|
|
171
|
-
label:
|
|
172
|
-
value:
|
|
188
|
+
message: `Select a function from ${selectedGroup}`,
|
|
189
|
+
options: availableFunctions.map((fn, index) => ({
|
|
190
|
+
label: fn.script,
|
|
191
|
+
value: index.toString(),
|
|
173
192
|
hint: fn.handler.description || void 0
|
|
174
193
|
}))
|
|
175
194
|
});
|
|
176
195
|
if (!selectedFunction)
|
|
177
196
|
return;
|
|
178
|
-
const
|
|
179
|
-
const selectedFunctionObj = availableFunctions
|
|
180
|
-
(fn) => fn.command === selectedCmd && fn.script === selectedScript
|
|
181
|
-
);
|
|
197
|
+
const selectedIndex = Number.parseInt(selectedFunction, 10);
|
|
198
|
+
const selectedFunctionObj = availableFunctions[selectedIndex];
|
|
182
199
|
if (!selectedFunctionObj || !selectedFunctionObj.handler) {
|
|
183
|
-
consola.error(
|
|
200
|
+
consola.error("Selected function not found or invalid");
|
|
184
201
|
return;
|
|
185
202
|
}
|
|
186
203
|
selectedCommands = [{
|
|
187
|
-
command:
|
|
188
|
-
script:
|
|
204
|
+
command: selectedFunctionObj.command,
|
|
205
|
+
script: selectedFunctionObj.script,
|
|
189
206
|
handler: selectedFunctionObj.handler
|
|
190
207
|
}];
|
|
191
208
|
} else {
|
package/dist/cli/silgi.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { generateTypes, resolveSchema } from 'untyped';
|
|
|
13
13
|
import { s as silgiGenerateType, l as loadOptions } from './types.mjs';
|
|
14
14
|
import { createHooks, createDebugger } from 'hookable';
|
|
15
15
|
import { useSilgiCLI, replaceRuntimeValues, silgiCLICtx, autoImportTypes } from 'silgi';
|
|
16
|
+
import { createAdapter } from 'unadapter';
|
|
16
17
|
import { c as createRouteRules } from '../_chunks/routeRules.mjs';
|
|
17
18
|
import * as p from '@clack/prompts';
|
|
18
19
|
import * as dotenv from 'dotenv';
|
|
@@ -2346,8 +2347,17 @@ async function createSilgiCLI(config = {}, opts = {}) {
|
|
|
2346
2347
|
hook: hooks.hook,
|
|
2347
2348
|
async updateConfig(_config) {
|
|
2348
2349
|
},
|
|
2349
|
-
routeRules: void 0
|
|
2350
|
+
routeRules: void 0,
|
|
2351
|
+
adapter: void 0
|
|
2350
2352
|
};
|
|
2353
|
+
if (Object.keys(silgi.options.database).length) {
|
|
2354
|
+
for (const [key, value] of Object.entries(silgi.options.database)) {
|
|
2355
|
+
silgi.adapter[key] = createAdapter(
|
|
2356
|
+
value.tables,
|
|
2357
|
+
value.adapter
|
|
2358
|
+
);
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2351
2361
|
await prepareEnv(options);
|
|
2352
2362
|
const routeRules = createRouteRules();
|
|
2353
2363
|
routeRules.importRules(options.routeRules ?? {});
|
package/dist/types/index.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ import { Ignore, Options } from 'ignore';
|
|
|
8
8
|
import { TSConfig } from 'pkg-types';
|
|
9
9
|
import { PresetName, PresetOptions, PresetNameInput } from 'silgi/presets';
|
|
10
10
|
import { ResolvedServiceType as ResolvedServiceType$1, SilgiRuntimeShareds as SilgiRuntimeShareds$1, SilgiRuntimeOptions as SilgiRuntimeOptions$1, RouteRules as RouteRules$1, ModuleMeta as ModuleMeta$1, SilgiModule as SilgiModule$1, SilgiRouteRules as SilgiRouteRules$1, DotenvOptions as DotenvOptions$1, EnvOptions as EnvOptions$1, SilgiRuntimeConfig as SilgiRuntimeConfig$1, ServiceParseModule as ServiceParseModule$1, SilgiCLIHooks as SilgiCLIHooks$1, StorageMounts as StorageMounts$1, SilgiTemplate as SilgiTemplate$1, SilgiFrameworkInfo as SilgiFrameworkInfo$1 } from 'silgi/types';
|
|
11
|
+
import { Adapter, TablesSchema, InferModelTypes, AdapterOptions } from 'unadapter/types';
|
|
11
12
|
import { UnimportPluginOptions } from 'unimport/unplugin';
|
|
12
13
|
import { H3Event } from 'h3';
|
|
13
14
|
import { NitroRuntimeConfig } from 'nitropack/types';
|
|
@@ -88,6 +89,7 @@ interface SilgiCLI {
|
|
|
88
89
|
tags?: (keyof SilgiCommands)[];
|
|
89
90
|
enabled?: boolean;
|
|
90
91
|
}>>;
|
|
92
|
+
adapter: Record<string, Adapter<Record<string, any>, TablesSchema, InferModelTypes<TablesSchema>>>;
|
|
91
93
|
}
|
|
92
94
|
type SilgiCLIDynamicConfig = Pick<SilgiCLIConfig, 'routeRules'>;
|
|
93
95
|
interface SilgiFrameworkInfo {
|
|
@@ -811,6 +813,10 @@ interface SilgiCLIOptions extends PresetOptions {
|
|
|
811
813
|
}>>;
|
|
812
814
|
installPackages: Record<'dependencies' | 'devDependencies', Record<string, string>>;
|
|
813
815
|
apiFul: ApifulConfig;
|
|
816
|
+
database: Record<string, {
|
|
817
|
+
adapter: Adapter<any, TablesSchema, any>;
|
|
818
|
+
tables: (options: AdapterOptions) => TablesSchema;
|
|
819
|
+
} & AdapterOptions>;
|
|
814
820
|
}
|
|
815
821
|
/**
|
|
816
822
|
* Silgi input config (silgi.config)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silgi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.28.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
"destr": "^2.0.5",
|
|
82
82
|
"dev-jiti": "^2.4.2",
|
|
83
83
|
"dot-prop": "^9.0.0",
|
|
84
|
-
"dotenv": "^16.
|
|
84
|
+
"dotenv": "^16.5.0",
|
|
85
85
|
"escape-string-regexp": "^5.0.0",
|
|
86
|
-
"exsolve": "^1.0.
|
|
86
|
+
"exsolve": "^1.0.5",
|
|
87
87
|
"globby": "^14.1.0",
|
|
88
88
|
"hookable": "^5.5.3",
|
|
89
89
|
"ignore": "^7.0.3",
|
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
"semver": "^7.7.1",
|
|
100
100
|
"std-env": "^3.9.0",
|
|
101
101
|
"ufo": "^1.6.1",
|
|
102
|
+
"unadapter": "^0.1.0",
|
|
102
103
|
"unctx": "^2.4.1",
|
|
103
104
|
"unimport": "^5.0.0",
|
|
104
105
|
"unstorage": "^1.15.0",
|
|
@@ -108,19 +109,19 @@
|
|
|
108
109
|
"@antfu/eslint-config": "^4.12.0",
|
|
109
110
|
"@nuxt/kit": "^3.16.2",
|
|
110
111
|
"@nuxt/schema": "^3.16.2",
|
|
111
|
-
"@silgi/ecosystem": "^0.4.
|
|
112
|
-
"@types/node": "^22.14.
|
|
112
|
+
"@silgi/ecosystem": "^0.4.10",
|
|
113
|
+
"@types/node": "^22.14.1",
|
|
113
114
|
"@types/semver": "^7.7.0",
|
|
114
115
|
"@vitest/coverage-v8": "3.0.5",
|
|
115
|
-
"eslint": "^9.
|
|
116
|
+
"eslint": "^9.25.0",
|
|
116
117
|
"h3": "^1.15.1",
|
|
117
|
-
"nitropack": "^2.11.
|
|
118
|
+
"nitropack": "^2.11.9",
|
|
118
119
|
"nuxt": "^3.16.2",
|
|
119
120
|
"typescript": "^5.8.3",
|
|
120
121
|
"unbuild": "^3.5.0",
|
|
121
122
|
"vitest": "^3.1.1",
|
|
122
123
|
"vue": "^3.5.13",
|
|
123
|
-
"zod": "^3.24.
|
|
124
|
+
"zod": "^3.24.3"
|
|
124
125
|
},
|
|
125
126
|
"resolutions": {
|
|
126
127
|
"silgi": "link:."
|