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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.27.11";
4
+ const version = "0.27.13";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -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
- for (const cmd of Object.keys(cliJson)) {
152
- const scripts = cliJson[cmd];
153
- for (const scriptName of Object.keys(scripts)) {
154
- const script = scripts[scriptName];
155
- if (script.type === "function") {
156
- availableFunctions.push({
157
- command: cmd,
158
- script: scriptName,
159
- handler: script
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("No functions found in cli.json");
184
+ consola.warn(`No functions found in the ${selectedGroup} group`);
166
185
  return;
167
186
  }
168
187
  const selectedFunction = await p.select({
169
- message: "Select a function to run",
170
- options: availableFunctions.map((fn) => ({
171
- label: `${fn.command} \u2192 ${fn.script}`,
172
- value: `${fn.command}:${fn.script}`,
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 [selectedCmd, selectedScript] = selectedFunction.split(":");
179
- const functionDef = cliJson[selectedCmd][selectedScript];
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: selectedCmd,
182
- script: selectedScript,
183
- handler: functionDef
204
+ command: selectedFunctionObj.command,
205
+ script: selectedFunctionObj.script,
206
+ handler: selectedFunctionObj.handler
184
207
  }];
185
208
  } else {
186
209
  const scripts = cliJson[commandName];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.27.11",
4
+ "version": "0.27.13",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {