@ic-reactor/cli 0.0.0-dev → 0.0.0-dev1

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.
Files changed (2) hide show
  1. package/dist/index.js +78 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -846,8 +846,9 @@ ${error.message}`
846
846
  if (options.all) {
847
847
  selectedMethods = methods;
848
848
  } else if (options.methods && options.methods.length > 0) {
849
- selectedMethods = methods.filter((m) => options.methods.includes(m.name));
850
- const notFound = options.methods.filter(
849
+ const requestedMethods = options.methods.flatMap((m) => m.split(",")).map((m) => m.trim()).filter((m) => m.length > 0);
850
+ selectedMethods = methods.filter((m) => requestedMethods.includes(m.name));
851
+ const notFound = requestedMethods.filter(
851
852
  (name) => !methods.some((m) => m.name === name)
852
853
  );
853
854
  if (notFound.length > 0) {
@@ -900,6 +901,11 @@ ${error.message}`
900
901
  value: "suspenseInfiniteQuery",
901
902
  label: "Suspense Infinite Query",
902
903
  hint: "Paginated with Suspense"
904
+ },
905
+ {
906
+ value: "skip",
907
+ label: "Skip",
908
+ hint: "Don't generate hook for this method"
903
909
  }
904
910
  ]
905
911
  });
@@ -907,11 +913,42 @@ ${error.message}`
907
913
  p2.cancel("Cancelled.");
908
914
  process.exit(0);
909
915
  }
916
+ if (hookType === "skip") {
917
+ p2.log.info(`Skipping ${pc2.dim(method.name)}`);
918
+ continue;
919
+ }
910
920
  methodsWithHookTypes.push({ method, hookType });
911
921
  } else {
922
+ const hookType = await p2.select({
923
+ message: `Hook type for ${pc2.yellow(method.name)} (mutation)`,
924
+ options: [
925
+ {
926
+ value: "mutation",
927
+ label: "Mutation",
928
+ hint: "Standard mutation hook"
929
+ },
930
+ {
931
+ value: "skip",
932
+ label: "Skip",
933
+ hint: "Don't generate hook for this method"
934
+ }
935
+ ]
936
+ });
937
+ if (p2.isCancel(hookType)) {
938
+ p2.cancel("Cancelled.");
939
+ process.exit(0);
940
+ }
941
+ if (hookType === "skip") {
942
+ p2.log.info(`Skipping ${pc2.dim(method.name)}`);
943
+ continue;
944
+ }
912
945
  methodsWithHookTypes.push({ method, hookType: "mutation" });
913
946
  }
914
947
  }
948
+ if (methodsWithHookTypes.length === 0) {
949
+ p2.log.warn("All methods were skipped. Nothing to generate.");
950
+ process.exit(0);
951
+ }
915
952
  const canisterOutDir = path3.join(projectRoot, config.outDir, selectedCanister);
916
953
  const hooksOutDir = path3.join(canisterOutDir, "hooks");
917
954
  ensureDir(hooksOutDir);
@@ -1448,8 +1485,9 @@ async function fetchCommand(options) {
1448
1485
  if (options.all) {
1449
1486
  selectedMethods = methods;
1450
1487
  } else if (options.methods && options.methods.length > 0) {
1451
- selectedMethods = methods.filter((m) => options.methods.includes(m.name));
1452
- const notFound = options.methods.filter(
1488
+ const requestedMethods = options.methods.flatMap((m) => m.split(",")).map((m) => m.trim()).filter((m) => m.length > 0);
1489
+ selectedMethods = methods.filter((m) => requestedMethods.includes(m.name));
1490
+ const notFound = requestedMethods.filter(
1453
1491
  (name) => !methods.some((m) => m.name === name)
1454
1492
  );
1455
1493
  if (notFound.length > 0) {
@@ -1482,6 +1520,11 @@ async function fetchCommand(options) {
1482
1520
  const hookType = await p5.select({
1483
1521
  message: `Hook type for ${pc5.cyan(method.name)}`,
1484
1522
  options: [
1523
+ {
1524
+ value: "skip",
1525
+ label: "Skip",
1526
+ hint: "Don't generate hook for this method"
1527
+ },
1485
1528
  { value: "query", label: "Query", hint: "Standard query hook" },
1486
1529
  {
1487
1530
  value: "suspenseQuery",
@@ -1504,11 +1547,42 @@ async function fetchCommand(options) {
1504
1547
  p5.cancel("Cancelled.");
1505
1548
  process.exit(0);
1506
1549
  }
1550
+ if (hookType === "skip") {
1551
+ p5.log.info(`Skipping ${pc5.dim(method.name)}`);
1552
+ continue;
1553
+ }
1507
1554
  methodsWithHookTypes.push({ method, hookType });
1508
1555
  } else {
1556
+ const hookType = await p5.select({
1557
+ message: `Hook type for ${pc5.yellow(method.name)} (mutation)`,
1558
+ options: [
1559
+ {
1560
+ value: "mutation",
1561
+ label: "Mutation",
1562
+ hint: "Standard mutation hook"
1563
+ },
1564
+ {
1565
+ value: "skip",
1566
+ label: "Skip",
1567
+ hint: "Don't generate hook for this method"
1568
+ }
1569
+ ]
1570
+ });
1571
+ if (p5.isCancel(hookType)) {
1572
+ p5.cancel("Cancelled.");
1573
+ process.exit(0);
1574
+ }
1575
+ if (hookType === "skip") {
1576
+ p5.log.info(`Skipping ${pc5.dim(method.name)}`);
1577
+ continue;
1578
+ }
1509
1579
  methodsWithHookTypes.push({ method, hookType: "mutation" });
1510
1580
  }
1511
1581
  }
1582
+ if (methodsWithHookTypes.length === 0) {
1583
+ p5.log.warn("All methods were skipped. Nothing to generate.");
1584
+ process.exit(0);
1585
+ }
1512
1586
  let configPath = findConfigFile();
1513
1587
  let config;
1514
1588
  if (!configPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ic-reactor/cli",
3
- "version": "0.0.0-dev",
3
+ "version": "0.0.0-dev1",
4
4
  "type": "module",
5
5
  "description": "CLI tool to generate shadcn-style React hooks for ICP canisters",
6
6
  "main": "dist/index.js",