@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.
- package/CHANGELOG.md +44 -0
- package/dist/cjs/cli/index.cjs +105 -0
- package/dist/cjs/contract/import.cjs +183 -0
- package/dist/cjs/contract/index.cjs +4 -0
- package/dist/cjs/index.cjs +25 -0
- package/dist/cjs/scripts/setVersion.cjs +132 -0
- package/dist/cjs/setup/index.cjs +7 -0
- package/dist/cjs/setup/provider.cjs +11 -0
- package/dist/cjs/setup/setup.cjs +138 -0
- package/dist/cjs/setup/site.cjs +25 -0
- package/dist/cjs/util/exec.cjs +46 -0
- package/dist/cjs/util/fluxLogDappDetails.cjs +18 -0
- package/dist/cjs/util/index.cjs +13 -0
- package/dist/cjs/util/loadContractFiles.cjs +44 -0
- package/dist/cjs/util/updateEnv.cjs +71 -0
- package/dist/cli/index.js +96 -99
- package/dist/contract/import.js +169 -149
- package/dist/contract/index.js +4 -2
- package/dist/index.js +25 -5
- package/dist/scripts/setVersion.js +115 -121
- package/dist/setup/index.js +7 -3
- package/dist/setup/provider.js +8 -6
- package/dist/setup/setup.js +113 -113
- package/dist/setup/site.js +23 -19
- package/dist/util/exec.js +42 -41
- package/dist/util/fluxLogDappDetails.js +17 -15
- package/dist/util/index.js +13 -5
- package/dist/util/loadContractFiles.js +34 -30
- package/dist/util/updateEnv.js +59 -54
- package/package.json +29 -21
- package/vite.cjs.config.ts +19 -0
- package/vite.esm.config.ts +20 -0
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/contract/import.d.ts +0 -3
- package/dist/contract/import.d.ts.map +0 -1
- package/dist/contract/import.js.map +0 -1
- package/dist/contract/index.d.ts +0 -2
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/contract/index.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/scripts/bytesToHex.d.ts +0 -2
- package/dist/scripts/bytesToHex.d.ts.map +0 -1
- package/dist/scripts/bytesToHex.js +0 -7
- package/dist/scripts/bytesToHex.js.map +0 -1
- package/dist/scripts/convertAccount.d.ts +0 -2
- package/dist/scripts/convertAccount.d.ts.map +0 -1
- package/dist/scripts/convertAccount.js +0 -24
- package/dist/scripts/convertAccount.js.map +0 -1
- package/dist/scripts/encodeDecode.d.ts +0 -2
- package/dist/scripts/encodeDecode.d.ts.map +0 -1
- package/dist/scripts/encodeDecode.js +0 -108
- package/dist/scripts/encodeDecode.js.map +0 -1
- package/dist/scripts/findUnused.d.ts +0 -2
- package/dist/scripts/findUnused.d.ts.map +0 -1
- package/dist/scripts/findUnused.js +0 -80
- package/dist/scripts/findUnused.js.map +0 -1
- package/dist/scripts/generateMnemonic.d.ts +0 -2
- package/dist/scripts/generateMnemonic.d.ts.map +0 -1
- package/dist/scripts/generateMnemonic.js +0 -26
- package/dist/scripts/generateMnemonic.js.map +0 -1
- package/dist/scripts/getBlock.d.ts +0 -2
- package/dist/scripts/getBlock.d.ts.map +0 -1
- package/dist/scripts/getBlock.js +0 -17
- package/dist/scripts/getBlock.js.map +0 -1
- package/dist/scripts/getContractInfoOf.d.ts +0 -2
- package/dist/scripts/getContractInfoOf.d.ts.map +0 -1
- package/dist/scripts/getContractInfoOf.js +0 -40
- package/dist/scripts/getContractInfoOf.js.map +0 -1
- package/dist/scripts/hash.d.ts +0 -2
- package/dist/scripts/hash.d.ts.map +0 -1
- package/dist/scripts/hash.js +0 -41
- package/dist/scripts/hash.js.map +0 -1
- package/dist/scripts/hexToBytes.d.ts +0 -2
- package/dist/scripts/hexToBytes.d.ts.map +0 -1
- package/dist/scripts/hexToBytes.js +0 -6
- package/dist/scripts/hexToBytes.js.map +0 -1
- package/dist/scripts/setVersion.d.ts +0 -2
- package/dist/scripts/setVersion.d.ts.map +0 -1
- package/dist/scripts/setVersion.js.map +0 -1
- package/dist/scripts/sign.d.ts +0 -2
- package/dist/scripts/sign.d.ts.map +0 -1
- package/dist/scripts/sign.js +0 -41
- package/dist/scripts/sign.js.map +0 -1
- package/dist/scripts/testImport.d.ts +0 -2
- package/dist/scripts/testImport.d.ts.map +0 -1
- package/dist/scripts/testImport.js +0 -13
- package/dist/scripts/testImport.js.map +0 -1
- package/dist/setup/index.d.ts +0 -3
- package/dist/setup/index.d.ts.map +0 -1
- package/dist/setup/index.js.map +0 -1
- package/dist/setup/provider.d.ts +0 -3
- package/dist/setup/provider.d.ts.map +0 -1
- package/dist/setup/provider.js.map +0 -1
- package/dist/setup/setup.d.ts +0 -3
- package/dist/setup/setup.d.ts.map +0 -1
- package/dist/setup/setup.js.map +0 -1
- package/dist/setup/site.d.ts +0 -4
- package/dist/setup/site.d.ts.map +0 -1
- package/dist/setup/site.js.map +0 -1
- package/dist/util/exec.d.ts +0 -10
- package/dist/util/exec.d.ts.map +0 -1
- package/dist/util/exec.js.map +0 -1
- package/dist/util/fluxLogDappDetails.d.ts +0 -2
- package/dist/util/fluxLogDappDetails.d.ts.map +0 -1
- package/dist/util/fluxLogDappDetails.js.map +0 -1
- package/dist/util/index.d.ts +0 -5
- package/dist/util/index.d.ts.map +0 -1
- package/dist/util/index.js.map +0 -1
- package/dist/util/loadContractFiles.d.ts +0 -4
- package/dist/util/loadContractFiles.d.ts.map +0 -1
- package/dist/util/loadContractFiles.js.map +0 -1
- package/dist/util/updateEnv.d.ts +0 -5
- package/dist/util/updateEnv.d.ts.map +0 -1
- package/dist/util/updateEnv.js.map +0 -1
package/dist/contract/import.js
CHANGED
|
@@ -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
|
|
5
|
+
import "../util/index.js";
|
|
6
|
+
import { exec } from "../util/exec.js";
|
|
6
7
|
const replaceExtension = (file, ext) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
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
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
package/dist/contract/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 {
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
44
|
+
}
|
|
45
|
+
return results;
|
|
48
46
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
137
|
-
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
fs.writeFileSync(pth, `${stringify(tomlContent)}
|
|
128
|
+
`);
|
|
129
|
+
});
|
|
138
130
|
}
|
|
139
|
-
|
|
131
|
+
export {
|
|
132
|
+
setVersion as default
|
|
133
|
+
};
|
package/dist/setup/index.js
CHANGED
package/dist/setup/provider.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { datasetWithSolutionHashes } from "@prosopo/datasets";
|
|
2
2
|
import { Tasks } from "@prosopo/provider";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
9
|
+
export {
|
|
10
|
+
setupProvider
|
|
11
|
+
};
|