@prosopo/scripts 3.0.10 → 3.0.12

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 (118) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/cjs/cli/index.cjs +105 -0
  3. package/dist/cjs/contract/import.cjs +183 -0
  4. package/dist/cjs/contract/index.cjs +4 -0
  5. package/dist/cjs/index.cjs +25 -0
  6. package/dist/cjs/scripts/setVersion.cjs +132 -0
  7. package/dist/cjs/setup/index.cjs +7 -0
  8. package/dist/cjs/setup/provider.cjs +11 -0
  9. package/dist/cjs/setup/setup.cjs +138 -0
  10. package/dist/cjs/setup/site.cjs +25 -0
  11. package/dist/cjs/util/exec.cjs +46 -0
  12. package/dist/cjs/util/fluxLogDappDetails.cjs +18 -0
  13. package/dist/cjs/util/index.cjs +13 -0
  14. package/dist/cjs/util/loadContractFiles.cjs +44 -0
  15. package/dist/cjs/util/updateEnv.cjs +71 -0
  16. package/dist/cli/index.js +96 -99
  17. package/dist/contract/import.js +169 -149
  18. package/dist/contract/index.js +4 -2
  19. package/dist/index.js +25 -5
  20. package/dist/scripts/setVersion.js +115 -121
  21. package/dist/setup/index.js +7 -3
  22. package/dist/setup/provider.js +8 -6
  23. package/dist/setup/setup.js +113 -113
  24. package/dist/setup/site.js +23 -19
  25. package/dist/util/exec.js +42 -41
  26. package/dist/util/fluxLogDappDetails.js +17 -15
  27. package/dist/util/index.js +13 -5
  28. package/dist/util/loadContractFiles.js +34 -30
  29. package/dist/util/updateEnv.js +59 -54
  30. package/package.json +29 -21
  31. package/vite.cjs.config.ts +19 -0
  32. package/vite.esm.config.ts +20 -0
  33. package/dist/cli/index.d.ts +0 -2
  34. package/dist/cli/index.d.ts.map +0 -1
  35. package/dist/cli/index.js.map +0 -1
  36. package/dist/contract/import.d.ts +0 -3
  37. package/dist/contract/import.d.ts.map +0 -1
  38. package/dist/contract/import.js.map +0 -1
  39. package/dist/contract/index.d.ts +0 -2
  40. package/dist/contract/index.d.ts.map +0 -1
  41. package/dist/contract/index.js.map +0 -1
  42. package/dist/index.d.ts +0 -5
  43. package/dist/index.d.ts.map +0 -1
  44. package/dist/index.js.map +0 -1
  45. package/dist/scripts/bytesToHex.d.ts +0 -2
  46. package/dist/scripts/bytesToHex.d.ts.map +0 -1
  47. package/dist/scripts/bytesToHex.js +0 -7
  48. package/dist/scripts/bytesToHex.js.map +0 -1
  49. package/dist/scripts/convertAccount.d.ts +0 -2
  50. package/dist/scripts/convertAccount.d.ts.map +0 -1
  51. package/dist/scripts/convertAccount.js +0 -24
  52. package/dist/scripts/convertAccount.js.map +0 -1
  53. package/dist/scripts/encodeDecode.d.ts +0 -2
  54. package/dist/scripts/encodeDecode.d.ts.map +0 -1
  55. package/dist/scripts/encodeDecode.js +0 -108
  56. package/dist/scripts/encodeDecode.js.map +0 -1
  57. package/dist/scripts/findUnused.d.ts +0 -2
  58. package/dist/scripts/findUnused.d.ts.map +0 -1
  59. package/dist/scripts/findUnused.js +0 -80
  60. package/dist/scripts/findUnused.js.map +0 -1
  61. package/dist/scripts/generateMnemonic.d.ts +0 -2
  62. package/dist/scripts/generateMnemonic.d.ts.map +0 -1
  63. package/dist/scripts/generateMnemonic.js +0 -26
  64. package/dist/scripts/generateMnemonic.js.map +0 -1
  65. package/dist/scripts/getBlock.d.ts +0 -2
  66. package/dist/scripts/getBlock.d.ts.map +0 -1
  67. package/dist/scripts/getBlock.js +0 -17
  68. package/dist/scripts/getBlock.js.map +0 -1
  69. package/dist/scripts/getContractInfoOf.d.ts +0 -2
  70. package/dist/scripts/getContractInfoOf.d.ts.map +0 -1
  71. package/dist/scripts/getContractInfoOf.js +0 -40
  72. package/dist/scripts/getContractInfoOf.js.map +0 -1
  73. package/dist/scripts/hash.d.ts +0 -2
  74. package/dist/scripts/hash.d.ts.map +0 -1
  75. package/dist/scripts/hash.js +0 -41
  76. package/dist/scripts/hash.js.map +0 -1
  77. package/dist/scripts/hexToBytes.d.ts +0 -2
  78. package/dist/scripts/hexToBytes.d.ts.map +0 -1
  79. package/dist/scripts/hexToBytes.js +0 -6
  80. package/dist/scripts/hexToBytes.js.map +0 -1
  81. package/dist/scripts/setVersion.d.ts +0 -2
  82. package/dist/scripts/setVersion.d.ts.map +0 -1
  83. package/dist/scripts/setVersion.js.map +0 -1
  84. package/dist/scripts/sign.d.ts +0 -2
  85. package/dist/scripts/sign.d.ts.map +0 -1
  86. package/dist/scripts/sign.js +0 -41
  87. package/dist/scripts/sign.js.map +0 -1
  88. package/dist/scripts/testImport.d.ts +0 -2
  89. package/dist/scripts/testImport.d.ts.map +0 -1
  90. package/dist/scripts/testImport.js +0 -13
  91. package/dist/scripts/testImport.js.map +0 -1
  92. package/dist/setup/index.d.ts +0 -3
  93. package/dist/setup/index.d.ts.map +0 -1
  94. package/dist/setup/index.js.map +0 -1
  95. package/dist/setup/provider.d.ts +0 -3
  96. package/dist/setup/provider.d.ts.map +0 -1
  97. package/dist/setup/provider.js.map +0 -1
  98. package/dist/setup/setup.d.ts +0 -3
  99. package/dist/setup/setup.d.ts.map +0 -1
  100. package/dist/setup/setup.js.map +0 -1
  101. package/dist/setup/site.d.ts +0 -4
  102. package/dist/setup/site.d.ts.map +0 -1
  103. package/dist/setup/site.js.map +0 -1
  104. package/dist/util/exec.d.ts +0 -10
  105. package/dist/util/exec.d.ts.map +0 -1
  106. package/dist/util/exec.js.map +0 -1
  107. package/dist/util/fluxLogDappDetails.d.ts +0 -2
  108. package/dist/util/fluxLogDappDetails.d.ts.map +0 -1
  109. package/dist/util/fluxLogDappDetails.js.map +0 -1
  110. package/dist/util/index.d.ts +0 -5
  111. package/dist/util/index.d.ts.map +0 -1
  112. package/dist/util/index.js.map +0 -1
  113. package/dist/util/loadContractFiles.d.ts +0 -4
  114. package/dist/util/loadContractFiles.d.ts.map +0 -1
  115. package/dist/util/loadContractFiles.js.map +0 -1
  116. package/dist/util/updateEnv.d.ts +0 -5
  117. package/dist/util/updateEnv.d.ts.map +0 -1
  118. package/dist/util/updateEnv.js.map +0 -1
@@ -2,163 +2,183 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { ProsopoEnvError } from "@prosopo/common";
4
4
  import { lodash } from "@prosopo/util/lodash";
5
- import { exec } from "../util/index.js";
5
+ import "../util/index.js";
6
+ import { exec } from "../util/exec.js";
6
7
  const replaceExtension = (file, ext) => {
7
- const parts = file.split(".");
8
- parts.pop();
9
- parts.push(ext);
10
- return parts.join(".");
8
+ const parts = file.split(".");
9
+ parts.pop();
10
+ parts.push(ext);
11
+ return parts.join(".");
11
12
  };
12
13
  async function importContract(pathToAbis, pathToOutput) {
13
- const verbose = false;
14
- pathToAbis = path.relative(process.cwd(), pathToAbis);
15
- pathToOutput = path.relative(process.cwd(), pathToOutput);
16
- if (!fs.existsSync(pathToAbis))
17
- throw new ProsopoEnvError("FS.FILE_NOT_FOUND", {
18
- context: { error: `Path to ABIs does not exist: ${pathToAbis}` },
19
- });
20
- await exec(`mkdir -p ${pathToOutput}`);
21
- const cmd = `npx @prosopo/typechain-polkadot --in ${pathToAbis} --out ${pathToOutput}`;
22
- await exec(cmd);
23
- const name = path.basename(pathToAbis);
24
- await exec(`cp ${pathToAbis}/${name}.json ${pathToOutput}/${name}.json`);
25
- const _ = lodash();
26
- const writeIndexJsFiles = (src) => {
27
- const typeChainDirs = fs.readdirSync(src).filter((file) => {
28
- return fs.lstatSync(`${src}/${file}`).isDirectory();
29
- });
30
- const rootExports = [];
31
- const typeChainExports = [
32
- {
33
- dir: "build-extrinsic",
34
- defaultExportName: "extrinsics",
35
- },
36
- {
37
- dir: "constructors",
38
- },
39
- {
40
- dir: "contract-info",
41
- exports: [
42
- {
43
- name: "ContractAbi",
44
- },
45
- {
46
- name: "ContractFile",
47
- },
48
- ],
49
- },
50
- {
51
- dir: "contracts",
52
- defaultExportName: "contract",
53
- },
54
- {
55
- dir: "data",
56
- },
57
- {
58
- dir: "event-data",
59
- },
60
- {
61
- dir: "events",
62
- },
63
- {
64
- dir: "mixed-methods",
65
- defaultExportName: "methods",
66
- },
67
- {
68
- dir: "query",
69
- defaultExportName: "query",
70
- },
71
- {
72
- dir: "tx-sign-and-send",
73
- defaultExportName: "tx",
74
- },
75
- ];
76
- let file = "";
77
- for (const typeChainExport of typeChainExports) {
78
- const dirPath = `${src}/${typeChainExport.dir}`;
79
- const files = fs.readdirSync(dirPath);
80
- if (files.length !== 1) {
81
- throw new ProsopoEnvError("FS.INVALID_DIR_FORMAT", {
82
- context: {
83
- error: `Expected 1 file in ${dirPath}, found ${files.length}`,
84
- },
85
- });
86
- }
87
- file = files[0] || "";
88
- if (file === "") {
89
- throw new ProsopoEnvError("FS.FILE_NOT_FOUND", {
90
- context: { error: `No file found in ${dirPath}` },
91
- });
92
- }
93
- if (file.endsWith(".ts")) {
94
- file = replaceExtension(file, "js");
95
- }
96
- if (typeChainExport.defaultExportName !== undefined) {
97
- const name = _.upperFirst(_.camelCase(typeChainExport.defaultExportName || typeChainExport.dir));
98
- rootExports.push(`export { default as ${name} } from './${typeChainExport.dir}/${file}'`);
99
- }
100
- if (typeChainExport.exports !== undefined) {
101
- for (const namedExport of typeChainExport.exports) {
102
- const alias = namedExport.alias ? ` as ${namedExport.alias}` : "";
103
- rootExports.push(`export { ${namedExport.name}${alias} } from './${typeChainExport.dir}/${file}'`);
104
- }
105
- }
106
- }
107
- rootExports.push(`export * from './shared/utils.js'`);
108
- const regex = /export\s+([a-z]+)\s+(\w+)/g;
109
- const fileTs = replaceExtension(file, "ts");
110
- const typesArgumentsFileContent = fs.readFileSync(`${src}/types-arguments/${fileTs}`, "utf8");
111
- const typesReturnsFileContent = fs.readFileSync(`${src}/types-returns/${fileTs}`, "utf8");
112
- const argumentTypes = Array.from(typesArgumentsFileContent.matchAll(regex)).map((match) => {
113
- return {
114
- name: match[2] || "",
115
- category: match[1] || "",
116
- };
14
+ const verbose = false;
15
+ pathToAbis = path.relative(process.cwd(), pathToAbis);
16
+ pathToOutput = path.relative(process.cwd(), pathToOutput);
17
+ if (!fs.existsSync(pathToAbis))
18
+ throw new ProsopoEnvError("FS.FILE_NOT_FOUND", {
19
+ context: { error: `Path to ABIs does not exist: ${pathToAbis}` }
20
+ });
21
+ await exec(`mkdir -p ${pathToOutput}`);
22
+ const cmd = `npx @prosopo/typechain-polkadot --in ${pathToAbis} --out ${pathToOutput}`;
23
+ await exec(cmd);
24
+ const name = path.basename(pathToAbis);
25
+ await exec(`cp ${pathToAbis}/${name}.json ${pathToOutput}/${name}.json`);
26
+ const _ = lodash();
27
+ const writeIndexJsFiles = (src) => {
28
+ const typeChainDirs = fs.readdirSync(src).filter((file2) => {
29
+ return fs.lstatSync(`${src}/${file2}`).isDirectory();
30
+ });
31
+ const rootExports = [];
32
+ const typeChainExports = [
33
+ {
34
+ dir: "build-extrinsic",
35
+ defaultExportName: "extrinsics"
36
+ },
37
+ {
38
+ dir: "constructors"
39
+ },
40
+ {
41
+ dir: "contract-info",
42
+ exports: [
43
+ {
44
+ name: "ContractAbi"
45
+ },
46
+ {
47
+ name: "ContractFile"
48
+ }
49
+ ]
50
+ },
51
+ {
52
+ dir: "contracts",
53
+ defaultExportName: "contract"
54
+ },
55
+ {
56
+ dir: "data"
57
+ },
58
+ {
59
+ dir: "event-data"
60
+ },
61
+ // { // no events used so this is empty - not sure about structure so left out
62
+ // dir: 'event-types'
63
+ // },
64
+ {
65
+ dir: "events"
66
+ },
67
+ {
68
+ dir: "mixed-methods",
69
+ defaultExportName: "methods"
70
+ },
71
+ {
72
+ dir: "query",
73
+ defaultExportName: "query"
74
+ },
75
+ {
76
+ dir: "tx-sign-and-send",
77
+ defaultExportName: "tx"
78
+ }
79
+ ];
80
+ let file = "";
81
+ for (const typeChainExport of typeChainExports) {
82
+ const dirPath = `${src}/${typeChainExport.dir}`;
83
+ const files = fs.readdirSync(dirPath);
84
+ if (files.length !== 1) {
85
+ throw new ProsopoEnvError("FS.INVALID_DIR_FORMAT", {
86
+ context: {
87
+ error: `Expected 1 file in ${dirPath}, found ${files.length}`
88
+ }
117
89
  });
118
- const returnTypes = Array.from(typesReturnsFileContent.matchAll(regex)).map((match) => {
119
- return {
120
- name: match[2] || "",
121
- category: match[1] || "",
122
- };
90
+ }
91
+ file = files[0] || "";
92
+ if (file === "") {
93
+ throw new ProsopoEnvError("FS.FILE_NOT_FOUND", {
94
+ context: { error: `No file found in ${dirPath}` }
123
95
  });
124
- const argumentTypeNames = argumentTypes.map((entry) => entry.name);
125
- const uniqueTypes = [...argumentTypes];
126
- const locations = [...argumentTypes.map(() => "types-arguments")];
127
- for (const entry of returnTypes) {
128
- if (!argumentTypeNames.includes(entry.name)) {
129
- uniqueTypes.push(entry);
130
- locations.push("types-arguments");
131
- }
132
- else {
133
- locations.push("types-returns");
134
- }
96
+ }
97
+ if (file.endsWith(".ts")) {
98
+ file = replaceExtension(file, "js");
99
+ }
100
+ if (typeChainExport.defaultExportName !== void 0) {
101
+ const name2 = _.upperFirst(
102
+ _.camelCase(typeChainExport.defaultExportName || typeChainExport.dir)
103
+ );
104
+ rootExports.push(
105
+ `export { default as ${name2} } from './${typeChainExport.dir}/${file}'`
106
+ );
107
+ }
108
+ if (typeChainExport.exports !== void 0) {
109
+ for (const namedExport of typeChainExport.exports) {
110
+ const alias = namedExport.alias ? ` as ${namedExport.alias}` : "";
111
+ rootExports.push(
112
+ `export { ${namedExport.name}${alias} } from './${typeChainExport.dir}/${file}'`
113
+ );
135
114
  }
136
- uniqueTypes.forEach((entry, i) => {
137
- const location = locations[i];
138
- const prefix = entry.category === "type" || entry.category === "interface"
139
- ? " type"
140
- : "";
141
- rootExports.push(`export${prefix} { ${entry.name} } from './${location}/${file}'`);
142
- });
143
- fs.writeFileSync(`${src}/index.ts`, rootExports.join("\n"));
144
- };
145
- writeIndexJsFiles(pathToOutput);
146
- }
147
- const getExtension = (str) => {
148
- const i = str.indexOf("assert");
149
- if (i >= 0) {
150
- str = str.slice(0, i);
115
+ }
151
116
  }
152
- const arr = str.split(".");
153
- if (arr.length <= 1) {
154
- return "";
117
+ rootExports.push(`export * from './shared/utils.js'`);
118
+ const regex = /export\s+([a-z]+)\s+(\w+)/g;
119
+ const fileTs = replaceExtension(file, "ts");
120
+ const typesArgumentsFileContent = fs.readFileSync(
121
+ `${src}/types-arguments/${fileTs}`,
122
+ "utf8"
123
+ );
124
+ const typesReturnsFileContent = fs.readFileSync(
125
+ `${src}/types-returns/${fileTs}`,
126
+ "utf8"
127
+ );
128
+ const argumentTypes = Array.from(
129
+ typesArgumentsFileContent.matchAll(regex)
130
+ ).map((match) => {
131
+ return {
132
+ name: match[2] || "",
133
+ category: match[1] || ""
134
+ };
135
+ });
136
+ const returnTypes = Array.from(
137
+ typesReturnsFileContent.matchAll(regex)
138
+ ).map((match) => {
139
+ return {
140
+ name: match[2] || "",
141
+ category: match[1] || ""
142
+ };
143
+ });
144
+ const argumentTypeNames = argumentTypes.map((entry) => entry.name);
145
+ const uniqueTypes = [...argumentTypes];
146
+ const locations = [...argumentTypes.map(() => "types-arguments")];
147
+ for (const entry of returnTypes) {
148
+ if (!argumentTypeNames.includes(entry.name)) {
149
+ uniqueTypes.push(entry);
150
+ locations.push("types-arguments");
151
+ } else {
152
+ locations.push("types-returns");
153
+ }
155
154
  }
156
- return arr.pop();
155
+ uniqueTypes.forEach((entry, i) => {
156
+ const location = locations[i];
157
+ const prefix = entry.category === "type" || entry.category === "interface" ? " type" : "";
158
+ rootExports.push(
159
+ `export${prefix} { ${entry.name} } from './${location}/${file}'`
160
+ );
161
+ });
162
+ fs.writeFileSync(`${src}/index.ts`, rootExports.join("\n"));
163
+ };
164
+ writeIndexJsFiles(pathToOutput);
165
+ }
166
+ const getExtension = (str) => {
167
+ const i = str.indexOf("assert");
168
+ if (i >= 0) {
169
+ str = str.slice(0, i);
170
+ }
171
+ const arr = str.split(".");
172
+ if (arr.length <= 1) {
173
+ return "";
174
+ }
175
+ return arr.pop();
157
176
  };
158
177
  const getPath = (str) => {
159
- const j = Math.max(str.lastIndexOf('"'), str.lastIndexOf("'"));
160
- const i = Math.max(str.indexOf('"'), str.indexOf("'"));
161
- return str.slice(i + 1, j);
178
+ const j = Math.max(str.lastIndexOf('"'), str.lastIndexOf("'"));
179
+ const i = Math.max(str.indexOf('"'), str.indexOf("'"));
180
+ return str.slice(i + 1, j);
181
+ };
182
+ export {
183
+ importContract as default
162
184
  };
163
- export default importContract;
164
- //# sourceMappingURL=import.js.map
@@ -1,2 +1,4 @@
1
- export { default as importContract } from "./import.js";
2
- //# sourceMappingURL=index.js.map
1
+ import { default as default2 } from "./import.js";
2
+ export {
3
+ default2 as importContract
4
+ };
package/dist/index.js CHANGED
@@ -1,5 +1,25 @@
1
- export * from "./setup/index.js";
2
- export * from "./util/index.js";
3
- export * from "./cli/index.js";
4
- export * from "./contract/index.js";
5
- //# sourceMappingURL=index.js.map
1
+ import "./setup/index.js";
2
+ import "./util/index.js";
3
+ import { processArgs } from "./cli/index.js";
4
+ import "./contract/index.js";
5
+ import { setup, updateEnvFile } from "./setup/setup.js";
6
+ import { setupProvider } from "./setup/provider.js";
7
+ import { AbiJSON, Wasm } from "./util/loadContractFiles.js";
8
+ import { findEnvFiles, updateDemoHTMLFiles, updateEnvFiles } from "./util/updateEnv.js";
9
+ import { exec } from "./util/exec.js";
10
+ import { extractReferrersFromLogs } from "./util/fluxLogDappDetails.js";
11
+ import { default as default2 } from "./contract/import.js";
12
+ export {
13
+ AbiJSON,
14
+ Wasm,
15
+ exec,
16
+ extractReferrersFromLogs,
17
+ findEnvFiles,
18
+ default2 as importContract,
19
+ processArgs,
20
+ setup,
21
+ setupProvider,
22
+ updateDemoHTMLFiles,
23
+ updateEnvFile,
24
+ updateEnvFiles
25
+ };
@@ -1,139 +1,133 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { parse, stringify } from "@iarna/toml";
4
- import { getLogger, parseLogLevel } from "@prosopo/common";
5
- import { getRootDir } from "@prosopo/config";
4
+ import { parseLogLevel, getLogger } from "@prosopo/common";
6
5
  import { loadEnv } from "@prosopo/dotenv";
6
+ import { getRootDir } from "@prosopo/workspace";
7
7
  loadEnv();
8
8
  const logLevel = parseLogLevel(process.env.PROSOPO_LOG_LEVEL);
9
9
  const log = getLogger(logLevel, "setVersion");
10
10
  log.info(() => ({ data: { logLevel } }));
11
11
  const parseVersion = (version) => {
12
- try {
13
- const parts = version.split(".");
14
- if (parts.length !== 3) {
15
- throw new Error();
16
- }
17
- let [major, minor, patch] = parts;
18
- major = Number.parseInt(major ?? "").toString();
19
- minor = Number.parseInt(minor ?? "").toString();
20
- patch = Number.parseInt(patch ?? "").toString();
21
- if (major === "NaN" || minor === "NaN" || patch === "NaN") {
22
- throw new Error();
23
- }
24
- return `${major}.${minor}.${patch}`;
12
+ try {
13
+ const parts = version.split(".");
14
+ if (parts.length !== 3) {
15
+ throw new Error();
25
16
  }
26
- catch (e) {
27
- throw new Error("Version must be in the format of x.y.z");
17
+ let [major, minor, patch] = parts;
18
+ major = Number.parseInt(major ?? "").toString();
19
+ minor = Number.parseInt(minor ?? "").toString();
20
+ patch = Number.parseInt(patch ?? "").toString();
21
+ if (major === "NaN" || minor === "NaN" || patch === "NaN") {
22
+ throw new Error();
28
23
  }
24
+ return `${major}.${minor}.${patch}`;
25
+ } catch (e) {
26
+ throw new Error("Version must be in the format of x.y.z");
27
+ }
29
28
  };
30
29
  const find = (pth, filter) => {
31
- const files = fs.readdirSync(pth);
32
- const results = [];
33
- for (const file of files) {
34
- const fullPath = path.join(pth, file);
35
- if (filter(fullPath)) {
36
- results.push(fullPath);
37
- }
38
- try {
39
- if (fs.statSync(fullPath).isDirectory()) {
40
- results.push(...find(fullPath, filter));
41
- }
42
- }
43
- catch (e) {
44
- log.debug(() => ({ data: { fullPath }, msg: "Not a directory" }));
45
- }
30
+ const files = fs.readdirSync(pth);
31
+ const results = [];
32
+ for (const file of files) {
33
+ const fullPath = path.join(pth, file);
34
+ if (filter(fullPath)) {
35
+ results.push(fullPath);
36
+ }
37
+ try {
38
+ if (fs.statSync(fullPath).isDirectory()) {
39
+ results.push(...find(fullPath, filter));
40
+ }
41
+ } catch (e) {
42
+ log.debug(() => ({ data: { fullPath }, msg: "Not a directory" }));
46
43
  }
47
- return results;
44
+ }
45
+ return results;
48
46
  };
49
- export default async function setVersion(versionIn, ignore) {
50
- log.info(() => ({ data: { versionIn }, msg: "Setting version to" }));
51
- const version = parseVersion(versionIn);
52
- const root = getRootDir();
53
- const ignorePaths = ["node_modules", "cargo-cache", ...(ignore ?? [])];
54
- log.debug(() => ({ data: { ignorePaths }, msg: "Ignoring paths" }));
55
- const files = find(root, (pth) => {
56
- if (ignorePaths.some((ignorePath) => pth.includes(ignorePath))) {
57
- return false;
58
- }
59
- const basename = path.basename(pth);
60
- return basename === "package.json" || basename === "Cargo.toml";
61
- });
62
- files
63
- .filter((pth) => path.extname(pth) === ".json")
64
- .forEach((pth) => {
65
- log.debug(() => ({ data: { pth }, msg: "setting version in" }));
66
- const content = fs.readFileSync(pth, "utf8");
67
- const jsonContent = JSON.parse(content);
68
- if (jsonContent.version) {
69
- jsonContent.version = version;
70
- }
71
- for (const obj of [
72
- jsonContent.dependencies ?? {},
73
- jsonContent.devDependencies ?? {},
74
- jsonContent.peerDependencies ?? {},
75
- ]) {
76
- for (const key of Object.keys(obj)) {
77
- if (key.startsWith("@prosopo") && !key.includes("typechain")) {
78
- log.debug(() => ({
79
- data: { key, version, pth },
80
- msg: "setting dependency version",
81
- }));
82
- obj[key] = version;
83
- }
84
- }
85
- }
86
- fs.writeFileSync(pth, `${JSON.stringify(jsonContent, null, 4)}\n`);
87
- });
88
- files
89
- .filter((pth) => path.extname(pth) === ".toml")
90
- .filter((pth) => {
91
- return !ignorePaths.some((ignorePath) => pth.includes(ignorePath));
92
- })
93
- .forEach((pth) => {
94
- log.debug(() => ({ data: { pth }, msg: "setting version in" }));
95
- const content = fs.readFileSync(pth, "utf8");
96
- const tomlContent = parse(content);
97
- if (tomlContent.workspace) {
98
- if (tomlContent.workspace.version) {
99
- tomlContent.workspace.version = version;
100
- }
101
- }
102
- else {
103
- tomlContent.package.version = version;
104
- }
105
- fs.writeFileSync(pth, `${stringify(tomlContent)}\n`);
106
- });
107
- files
108
- .filter((pth) => path.extname(pth) === ".toml")
109
- .forEach((pth) => {
110
- log.debug(() => ({
111
- data: { pth },
112
- msg: "setting dependency versions in",
113
- }));
114
- const content = fs.readFileSync(pth, "utf8");
115
- const tomlContent = parse(content);
116
- if (tomlContent.workspace) {
117
- if (tomlContent.workspace.version) {
118
- tomlContent.workspace.version = version;
119
- }
47
+ async function setVersion(versionIn, ignore) {
48
+ log.info(() => ({ data: { versionIn }, msg: "Setting version to" }));
49
+ const version = parseVersion(versionIn);
50
+ const root = getRootDir();
51
+ const ignorePaths = ["node_modules", "cargo-cache", ...ignore ?? []];
52
+ log.debug(() => ({ data: { ignorePaths }, msg: "Ignoring paths" }));
53
+ const files = find(root, (pth) => {
54
+ if (ignorePaths.some((ignorePath) => pth.includes(ignorePath))) {
55
+ return false;
56
+ }
57
+ const basename = path.basename(pth);
58
+ return basename === "package.json" || basename === "Cargo.toml";
59
+ });
60
+ files.filter((pth) => path.extname(pth) === ".json").forEach((pth) => {
61
+ log.debug(() => ({ data: { pth }, msg: "setting version in" }));
62
+ const content = fs.readFileSync(pth, "utf8");
63
+ const jsonContent = JSON.parse(content);
64
+ if (jsonContent.version) {
65
+ jsonContent.version = version;
66
+ }
67
+ for (const obj of [
68
+ jsonContent.dependencies ?? {},
69
+ jsonContent.devDependencies ?? {},
70
+ jsonContent.peerDependencies ?? {}
71
+ ]) {
72
+ for (const key of Object.keys(obj)) {
73
+ if (key.startsWith("@prosopo") && !key.includes("typechain")) {
74
+ log.debug(() => ({
75
+ data: { key, version, pth },
76
+ msg: "setting dependency version"
77
+ }));
78
+ obj[key] = version;
120
79
  }
121
- else {
122
- for (const obj of [
123
- tomlContent.dependencies ?? {},
124
- tomlContent["dev-dependencies"] ?? {},
125
- ]) {
126
- for (const [key, value] of Object.entries(obj)) {
127
- if (value.path) {
128
- path.join(value.path, "Cargo.toml");
129
- const depContent = fs.readFileSync(pth, "utf8");
130
- const depTomlContent = parse(depContent);
131
- value.version = depTomlContent.version;
132
- }
133
- }
134
- }
80
+ }
81
+ }
82
+ fs.writeFileSync(pth, `${JSON.stringify(jsonContent, null, 4)}
83
+ `);
84
+ });
85
+ files.filter((pth) => path.extname(pth) === ".toml").filter((pth) => {
86
+ return !ignorePaths.some((ignorePath) => pth.includes(ignorePath));
87
+ }).forEach((pth) => {
88
+ log.debug(() => ({ data: { pth }, msg: "setting version in" }));
89
+ const content = fs.readFileSync(pth, "utf8");
90
+ const tomlContent = parse(content);
91
+ if (tomlContent.workspace) {
92
+ if (tomlContent.workspace.version) {
93
+ tomlContent.workspace.version = version;
94
+ }
95
+ } else {
96
+ tomlContent.package.version = version;
97
+ }
98
+ fs.writeFileSync(pth, `${stringify(tomlContent)}
99
+ `);
100
+ });
101
+ files.filter((pth) => path.extname(pth) === ".toml").forEach((pth) => {
102
+ log.debug(() => ({
103
+ data: { pth },
104
+ msg: "setting dependency versions in"
105
+ }));
106
+ const content = fs.readFileSync(pth, "utf8");
107
+ const tomlContent = parse(content);
108
+ if (tomlContent.workspace) {
109
+ if (tomlContent.workspace.version) {
110
+ tomlContent.workspace.version = version;
111
+ }
112
+ } else {
113
+ for (const obj of [
114
+ tomlContent.dependencies ?? {},
115
+ tomlContent["dev-dependencies"] ?? {}
116
+ ]) {
117
+ for (const [key, value] of Object.entries(obj)) {
118
+ if (value.path) {
119
+ path.join(value.path, "Cargo.toml");
120
+ const depContent = fs.readFileSync(pth, "utf8");
121
+ const depTomlContent = parse(depContent);
122
+ value.version = depTomlContent.version;
123
+ }
135
124
  }
136
- fs.writeFileSync(pth, `${stringify(tomlContent)}\n`);
137
- });
125
+ }
126
+ }
127
+ fs.writeFileSync(pth, `${stringify(tomlContent)}
128
+ `);
129
+ });
138
130
  }
139
- //# sourceMappingURL=setVersion.js.map
131
+ export {
132
+ setVersion as default
133
+ };
@@ -1,3 +1,7 @@
1
- export * from "./setup.js";
2
- export * from "./provider.js";
3
- //# sourceMappingURL=index.js.map
1
+ import { setup, updateEnvFile } from "./setup.js";
2
+ import { setupProvider } from "./provider.js";
3
+ export {
4
+ setup,
5
+ setupProvider,
6
+ updateEnvFile
7
+ };
@@ -1,9 +1,11 @@
1
1
  import { datasetWithSolutionHashes } from "@prosopo/datasets";
2
2
  import { Tasks } from "@prosopo/provider";
3
- export async function setupProvider(env) {
4
- const logger = env.logger;
5
- const tasks = new Tasks(env);
6
- logger.info(() => ({ msg: " - providerSetDataset" }));
7
- await tasks.datasetManager.providerSetDataset(datasetWithSolutionHashes);
3
+ async function setupProvider(env) {
4
+ const logger = env.logger;
5
+ const tasks = new Tasks(env);
6
+ logger.info(() => ({ msg: " - providerSetDataset" }));
7
+ await tasks.datasetManager.providerSetDataset(datasetWithSolutionHashes);
8
8
  }
9
- //# sourceMappingURL=provider.js.map
9
+ export {
10
+ setupProvider
11
+ };