@skalenetwork/upgrade-tools 3.0.0-safe-mock.1 → 3.0.0-safe-mock.2
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/dist/src/version.js +18 -1
- package/package.json +2 -1
package/dist/src/version.js
CHANGED
|
@@ -8,6 +8,23 @@ const child_process_1 = require("child_process");
|
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const util_1 = __importDefault(require("util"));
|
|
10
10
|
const exec = util_1.default.promisify(child_process_1.exec);
|
|
11
|
+
class VersionNotFound extends Error {
|
|
12
|
+
}
|
|
13
|
+
async function getVersionFilename(folder) {
|
|
14
|
+
if (folder === undefined) {
|
|
15
|
+
return getVersionFilename((await exec("git rev-parse --show-toplevel")).stdout.trim());
|
|
16
|
+
}
|
|
17
|
+
const VERSION_FILENAME = 'VERSION', path = `${folder}/${VERSION_FILENAME}`;
|
|
18
|
+
if ((0, fs_1.existsSync)(path)) {
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
21
|
+
for (const entry of await fs_1.promises.readdir(folder, { withFileTypes: true, recursive: true })) {
|
|
22
|
+
if (entry.isFile() && entry.name === VERSION_FILENAME) {
|
|
23
|
+
return `${entry.path}/${entry.name}`;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
throw new VersionNotFound("Can't find version file");
|
|
27
|
+
}
|
|
11
28
|
const getVersion = async () => {
|
|
12
29
|
if (process.env.VERSION) {
|
|
13
30
|
return process.env.VERSION;
|
|
@@ -17,7 +34,7 @@ const getVersion = async () => {
|
|
|
17
34
|
return tag;
|
|
18
35
|
}
|
|
19
36
|
catch {
|
|
20
|
-
return (await fs_1.promises.readFile(
|
|
37
|
+
return (await fs_1.promises.readFile(await getVersionFilename(), "utf-8")).trim();
|
|
21
38
|
}
|
|
22
39
|
};
|
|
23
40
|
exports.getVersion = getVersion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skalenetwork/upgrade-tools",
|
|
3
|
-
"version": "3.0.0-safe-mock.
|
|
3
|
+
"version": "3.0.0-safe-mock.2",
|
|
4
4
|
"description": "Scripts to support upgrades of smart contracts",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*"
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@tsconfig/recommended": "^1.0.2",
|
|
28
28
|
"@typechain/ethers-v5": "^9.0.0",
|
|
29
29
|
"@typechain/hardhat": "^8.0.0",
|
|
30
|
+
"@types/node": "^20.6.0",
|
|
30
31
|
"@typescript-eslint/eslint-plugin": "^6.6.0",
|
|
31
32
|
"@typescript-eslint/parser": "^6.6.0",
|
|
32
33
|
"cspell": "^7.0.0",
|