silgi 0.27.11 → 0.27.13
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/prepare.mjs +44 -21
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -147,40 +147,63 @@ 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
|
|
197
|
+
const selectedIndex = Number.parseInt(selectedFunction, 10);
|
|
198
|
+
const selectedFunctionObj = availableFunctions[selectedIndex];
|
|
199
|
+
if (!selectedFunctionObj || !selectedFunctionObj.handler) {
|
|
200
|
+
consola.error("Selected function not found or invalid");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
180
203
|
selectedCommands = [{
|
|
181
|
-
command:
|
|
182
|
-
script:
|
|
183
|
-
handler:
|
|
204
|
+
command: selectedFunctionObj.command,
|
|
205
|
+
script: selectedFunctionObj.script,
|
|
206
|
+
handler: selectedFunctionObj.handler
|
|
184
207
|
}];
|
|
185
208
|
} else {
|
|
186
209
|
const scripts = cliJson[commandName];
|