@trustless-work/blocks 0.0.8 → 0.0.9

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/bin/index.js CHANGED
@@ -855,6 +855,133 @@ function copyTemplate(name, { uiBase, shouldInstall = false } = {}) {
855
855
  );
856
856
  }
857
857
 
858
+ // Post-copy: materialize shared files for single-multi-release modules
859
+ try {
860
+ const isSingleMultiApproveRoot =
861
+ name === "escrows/single-multi-release/approve-milestone";
862
+ const isSingleMultiApproveDialog =
863
+ name === "escrows/single-multi-release/approve-milestone/dialog";
864
+ const isSingleMultiApproveForm =
865
+ name === "escrows/single-multi-release/approve-milestone/form";
866
+
867
+ const srcSharedDir = path.join(
868
+ TEMPLATES_DIR,
869
+ "escrows",
870
+ "single-multi-release",
871
+ "approve-milestone",
872
+ "shared"
873
+ );
874
+
875
+ function copySingleMultiApproveSharedInto(targetDir) {
876
+ if (!fs.existsSync(srcSharedDir)) return;
877
+ const entries = fs.readdirSync(srcSharedDir, { withFileTypes: true });
878
+ for (const entry of entries) {
879
+ if (!/\.(tsx?|jsx?)$/i.test(entry.name)) continue;
880
+ const entrySrc = path.join(srcSharedDir, entry.name);
881
+ const entryDest = path.join(targetDir, entry.name);
882
+ writeTransformed(entrySrc, entryDest);
883
+ }
884
+ }
885
+
886
+ if (isSingleMultiApproveRoot) {
887
+ copySingleMultiApproveSharedInto(path.join(destDir, "dialog"));
888
+ copySingleMultiApproveSharedInto(path.join(destDir, "form"));
889
+ } else if (isSingleMultiApproveDialog) {
890
+ copySingleMultiApproveSharedInto(destDir);
891
+ } else if (isSingleMultiApproveForm) {
892
+ copySingleMultiApproveSharedInto(destDir);
893
+ }
894
+ } catch (e) {
895
+ console.warn(
896
+ "⚠️ Failed to materialize shared single-multi-release approve-milestone files:",
897
+ e?.message || e
898
+ );
899
+ }
900
+
901
+ try {
902
+ const isSingleMultiChangeRoot =
903
+ name === "escrows/single-multi-release/change-milestone-status";
904
+ const isSingleMultiChangeDialog =
905
+ name === "escrows/single-multi-release/change-milestone-status/dialog";
906
+ const isSingleMultiChangeForm =
907
+ name === "escrows/single-multi-release/change-milestone-status/form";
908
+
909
+ const srcSharedDir = path.join(
910
+ TEMPLATES_DIR,
911
+ "escrows",
912
+ "single-multi-release",
913
+ "change-milestone-status",
914
+ "shared"
915
+ );
916
+
917
+ function copySingleMultiChangeSharedInto(targetDir) {
918
+ if (!fs.existsSync(srcSharedDir)) return;
919
+ const entries = fs.readdirSync(srcSharedDir, { withFileTypes: true });
920
+ for (const entry of entries) {
921
+ if (!/\.(tsx?|jsx?)$/i.test(entry.name)) continue;
922
+ const entrySrc = path.join(srcSharedDir, entry.name);
923
+ const entryDest = path.join(targetDir, entry.name);
924
+ writeTransformed(entrySrc, entryDest);
925
+ }
926
+ }
927
+
928
+ if (isSingleMultiChangeRoot) {
929
+ copySingleMultiChangeSharedInto(path.join(destDir, "dialog"));
930
+ copySingleMultiChangeSharedInto(path.join(destDir, "form"));
931
+ } else if (isSingleMultiChangeDialog) {
932
+ copySingleMultiChangeSharedInto(destDir);
933
+ } else if (isSingleMultiChangeForm) {
934
+ copySingleMultiChangeSharedInto(destDir);
935
+ }
936
+ } catch (e) {
937
+ console.warn(
938
+ "⚠️ Failed to materialize shared single-multi-release change-milestone-status files:",
939
+ e?.message || e
940
+ );
941
+ }
942
+
943
+ try {
944
+ const isSingleMultiFundRoot =
945
+ name === "escrows/single-multi-release/fund-escrow";
946
+ const isSingleMultiFundDialog =
947
+ name === "escrows/single-multi-release/fund-escrow/dialog";
948
+ const isSingleMultiFundForm =
949
+ name === "escrows/single-multi-release/fund-escrow/form";
950
+
951
+ const srcSharedDir = path.join(
952
+ TEMPLATES_DIR,
953
+ "escrows",
954
+ "single-multi-release",
955
+ "fund-escrow",
956
+ "shared"
957
+ );
958
+
959
+ function copySingleMultiFundSharedInto(targetDir) {
960
+ if (!fs.existsSync(srcSharedDir)) return;
961
+ const entries = fs.readdirSync(srcSharedDir, { withFileTypes: true });
962
+ for (const entry of entries) {
963
+ if (!/\.(tsx?|jsx?)$/i.test(entry.name)) continue;
964
+ const entrySrc = path.join(srcSharedDir, entry.name);
965
+ const entryDest = path.join(targetDir, entry.name);
966
+ writeTransformed(entrySrc, entryDest);
967
+ }
968
+ }
969
+
970
+ if (isSingleMultiFundRoot) {
971
+ copySingleMultiFundSharedInto(path.join(destDir, "dialog"));
972
+ copySingleMultiFundSharedInto(path.join(destDir, "form"));
973
+ } else if (isSingleMultiFundDialog) {
974
+ copySingleMultiFundSharedInto(destDir);
975
+ } else if (isSingleMultiFundForm) {
976
+ copySingleMultiFundSharedInto(destDir);
977
+ }
978
+ } catch (e) {
979
+ console.warn(
980
+ "⚠️ Failed to materialize shared single-multi-release fund-escrow files:",
981
+ e?.message || e
982
+ );
983
+ }
984
+
858
985
  // If adding the whole single-release bundle, materialize all shared files
859
986
  try {
860
987
  if (name === "escrows/single-release") {
@@ -942,6 +1069,48 @@ function copyTemplate(name, { uiBase, shouldInstall = false } = {}) {
942
1069
  );
943
1070
  }
944
1071
 
1072
+ // If adding the whole single-multi-release bundle, materialize all shared files
1073
+ try {
1074
+ if (name === "escrows/single-multi-release") {
1075
+ const modules = [
1076
+ "approve-milestone",
1077
+ "change-milestone-status",
1078
+ "fund-escrow",
1079
+ ];
1080
+
1081
+ for (const mod of modules) {
1082
+ const srcSharedDir = path.join(
1083
+ TEMPLATES_DIR,
1084
+ "escrows",
1085
+ "single-multi-release",
1086
+ mod,
1087
+ "shared"
1088
+ );
1089
+ if (!fs.existsSync(srcSharedDir)) continue;
1090
+
1091
+ const targets = [
1092
+ path.join(destDir, mod, "dialog"),
1093
+ path.join(destDir, mod, "form"),
1094
+ ];
1095
+
1096
+ const entries = fs.readdirSync(srcSharedDir, { withFileTypes: true });
1097
+ for (const entry of entries) {
1098
+ if (!/\.(tsx?|jsx?)$/i.test(entry.name)) continue;
1099
+ const entrySrc = path.join(srcSharedDir, entry.name);
1100
+ for (const t of targets) {
1101
+ const entryDest = path.join(t, entry.name);
1102
+ writeTransformed(entrySrc, entryDest);
1103
+ }
1104
+ }
1105
+ }
1106
+ }
1107
+ } catch (e) {
1108
+ console.warn(
1109
+ "⚠️ Failed to materialize shared files for single-multi-release bundle:",
1110
+ e?.message || e
1111
+ );
1112
+ }
1113
+
945
1114
  // If adding the root escrows bundle, also materialize single-release shared files
946
1115
  try {
947
1116
  if (name === "escrows") {
@@ -1030,6 +1199,49 @@ function copyTemplate(name, { uiBase, shouldInstall = false } = {}) {
1030
1199
  e?.message || e
1031
1200
  );
1032
1201
  }
1202
+
1203
+ // If adding the root escrows bundle, also materialize single-multi-release shared files
1204
+ try {
1205
+ if (name === "escrows") {
1206
+ const modules = [
1207
+ "approve-milestone",
1208
+ "change-milestone-status",
1209
+ "fund-escrow",
1210
+ ];
1211
+
1212
+ const baseTarget = path.join(destDir, "single-multi-release");
1213
+ for (const mod of modules) {
1214
+ const srcSharedDir = path.join(
1215
+ TEMPLATES_DIR,
1216
+ "escrows",
1217
+ "single-multi-release",
1218
+ mod,
1219
+ "shared"
1220
+ );
1221
+ if (!fs.existsSync(srcSharedDir)) continue;
1222
+
1223
+ const targets = [
1224
+ path.join(baseTarget, mod, "dialog"),
1225
+ path.join(baseTarget, mod, "form"),
1226
+ ];
1227
+
1228
+ const entries = fs.readdirSync(srcSharedDir, { withFileTypes: true });
1229
+ for (const entry of entries) {
1230
+ if (!/\.(tsx?|jsx?)$/i.test(entry.name)) continue;
1231
+ const entrySrc = path.join(srcSharedDir, entry.name);
1232
+ for (const t of targets) {
1233
+ const entryDest = path.join(t, entry.name);
1234
+ writeTransformed(entrySrc, entryDest);
1235
+ }
1236
+ }
1237
+ }
1238
+ }
1239
+ } catch (e) {
1240
+ console.warn(
1241
+ "⚠️ Failed to materialize shared files for escrows root (single-multi-release):",
1242
+ e?.message || e
1243
+ );
1244
+ }
1033
1245
  } else if (fs.existsSync(srcFile)) {
1034
1246
  fs.mkdirSync(outRoot, { recursive: true });
1035
1247
  const destFile = path.join(outRoot, name + ".tsx");
@@ -1593,5 +1805,27 @@ if (args[0] === "init") {
1593
1805
  --- Dispute escrow ---
1594
1806
  - trustless-work add escrows/single-release/dispute-escrow
1595
1807
  - trustless-work add escrows/single-release/dispute-escrow/button
1808
+
1809
+ ----------------------
1810
+ --- SINGLE-MULTI-RELEASE ---
1811
+ trustless-work add escrows/single-multi-release
1812
+
1813
+ --- Approve milestone ---
1814
+ - trustless-work add escrows/single-multi-release/approve-milestone
1815
+ - trustless-work add escrows/single-multi-release/approve-milestone/form
1816
+ - trustless-work add escrows/single-multi-release/approve-milestone/button
1817
+ - trustless-work add escrows/single-multi-release/approve-milestone/dialog
1818
+
1819
+ --- Change milestone status ---
1820
+ - trustless-work add escrows/single-multi-release/change-milestone-status
1821
+ - trustless-work add escrows/single-multi-release/change-milestone-status/form
1822
+ - trustless-work add escrows/single-multi-release/change-milestone-status/button
1823
+ - trustless-work add escrows/single-multi-release/change-milestone-status/dialog
1824
+
1825
+ --- Fund escrow ---
1826
+ - trustless-work add escrows/single-multi-release/fund-escrow
1827
+ - trustless-work add escrows/single-multi-release/fund-escrow/form
1828
+ - trustless-work add escrows/single-multi-release/fund-escrow/button
1829
+ - trustless-work add escrows/single-multi-release/fund-escrow/dialog
1596
1830
  `);
1597
1831
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustless-work/blocks",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "author": "Trustless Work",
5
5
  "keywords": [
6
6
  "react",
@@ -16,7 +16,7 @@ import {
16
16
  DialogTrigger,
17
17
  } from "__UI_BASE__/dialog";
18
18
  import { Loader2 } from "lucide-react";
19
- import { useApproveMilestone } from "../useApproveMilestone";
19
+ import { useApproveMilestone } from "./useApproveMilestone";
20
20
  import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
21
21
  import {
22
22
  Select,
@@ -8,7 +8,7 @@ import {
8
8
  FormMessage,
9
9
  } from "__UI_BASE__/form";
10
10
  import { Button } from "__UI_BASE__/button";
11
- import { useApproveMilestone } from "../useApproveMilestone";
11
+ import { useApproveMilestone } from "./useApproveMilestone";
12
12
  import { Loader2 } from "lucide-react";
13
13
  import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
14
14
  import {
@@ -18,7 +18,7 @@ import {
18
18
  DialogTrigger,
19
19
  } from "__UI_BASE__/dialog";
20
20
  import { Loader2 } from "lucide-react";
21
- import { useChangeMilestoneStatus } from "../useChangeMilestoneStatus";
21
+ import { useChangeMilestoneStatus } from "./useChangeMilestoneStatus";
22
22
  import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
23
23
  import {
24
24
  Select,
@@ -10,7 +10,7 @@ import {
10
10
  import { Input } from "__UI_BASE__/input";
11
11
  import { Textarea } from "__UI_BASE__/textarea";
12
12
  import { Button } from "__UI_BASE__/button";
13
- import { useChangeMilestoneStatus } from "../useChangeMilestoneStatus";
13
+ import { useChangeMilestoneStatus } from "./useChangeMilestoneStatus";
14
14
  import { Loader2 } from "lucide-react";
15
15
  import { useEscrowContext } from "@/components/tw-blocks/providers/EscrowProvider";
16
16
  import {
@@ -17,7 +17,7 @@ import {
17
17
  DialogTrigger,
18
18
  } from "__UI_BASE__/dialog";
19
19
  import { Loader2 } from "lucide-react";
20
- import { useFundEscrow } from "../useFundEscrow";
20
+ import { useFundEscrow } from "./useFundEscrow";
21
21
 
22
22
  export const FundEscrowDialog = () => {
23
23
  const { form, handleSubmit, isSubmitting } = useFundEscrow();
@@ -9,7 +9,7 @@ import {
9
9
  } from "__UI_BASE__/form";
10
10
  import { Input } from "__UI_BASE__/input";
11
11
  import { Button } from "__UI_BASE__/button";
12
- import { useFundEscrow } from "../useFundEscrow";
12
+ import { useFundEscrow } from "./useFundEscrow";
13
13
  import { Loader2 } from "lucide-react";
14
14
 
15
15
  export const FundEscrowForm = () => {