Skip to content

Commit cb84cf4

Browse files
Merge pull request #18 from DIG-Network/release/v0.0.1-alpha.19
Release/v0.0.1 alpha.19
2 parents 5e8a1c3 + 6cbf506 commit cb84cf4

File tree

4 files changed

+78
-46
lines changed

4 files changed

+78
-46
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [0.0.1-alpha.19](https://github.com/DIG-Network/dig-cli/compare/v0.0.1-alpha.18...v0.0.1-alpha.19) (2024-09-10)
6+
57
### [0.0.1-alpha.18](https://github.com/DIG-Network/dig-cli/compare/v0.0.1-alpha.17...v0.0.1-alpha.18) (2024-09-10)
68

79
### [0.0.1-alpha.17](https://github.com/DIG-Network/dig-cli/compare/v0.0.1-alpha.16...v0.0.1-alpha.17) (2024-09-10)

package-lock.json

Lines changed: 32 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dignetwork/dig-chia-cli",
3-
"version": "0.0.1-alpha.18",
3+
"version": "0.0.1-alpha.19",
44
"description": "",
55
"type": "commonjs",
66
"main": "./dist/index.js",
@@ -24,7 +24,7 @@
2424
"LICENSE"
2525
],
2626
"dependencies": {
27-
"@dignetwork/dig-sdk": "^0.0.1-alpha.9",
27+
"@dignetwork/dig-sdk": "^0.0.1-alpha.11",
2828
"bip39": "^3.1.0",
2929
"datalayer-driver": "^0.1.21",
3030
"inquirer": "^10.1.8",

src/actions/clone.ts

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,55 @@ export const clone = async (
1313
storeId: string,
1414
skipData: boolean = false
1515
): Promise<void> => {
16-
console.log(`Cloning store: ${storeId}`);
16+
try {
17+
console.log(`Cloning store: ${storeId}`);
1718

18-
const storeDir = path.join(DIG_FOLDER_PATH, "stores", storeId);
19+
const storeDir = path.join(DIG_FOLDER_PATH, "stores", storeId);
1920

20-
// Check if the store directory already exists
21-
if (fs.existsSync(storeDir)) {
22-
console.error(`Store with ID ${storeId} already exists at ${storeDir}.`);
23-
process.exit(1); // Exit the process with an error code
24-
}
21+
// Check if the store directory already exists
22+
if (fs.existsSync(storeDir)) {
23+
console.error(`Store with ID ${storeId} already exists at ${storeDir}.`);
24+
process.exit(1); // Exit the process with an error code
25+
}
2526

26-
try {
27-
// Create an instance of DigNetwork
28-
const digNetwork = new DigNetwork(storeId);
29-
30-
// Pull files from the network using DigNetwork
31-
await digNetwork.downloadFiles(true, true, skipData);
32-
} catch (error: any) {
33-
console.error(error.message);
34-
process.exit(1); // Exit the process with an error code
35-
}
27+
try {
28+
// Create an instance of DigNetwork
29+
const digNetwork = new DigNetwork(storeId);
30+
31+
// Pull files from the network using DigNetwork
32+
await digNetwork.downloadFiles(true, true, skipData);
33+
} catch (error: any) {
34+
console.error(error.message);
35+
process.exit(1); // Exit the process with an error code
36+
}
3637

37-
const dataStore = DataStore.from(storeId);
38+
const dataStore = DataStore.from(storeId);
3839

39-
if (skipData) {
40-
console.log("Skipping store integrity check due to --skip-data flag.");
41-
return;
42-
}
43-
44-
try {
45-
// Perform the store integrity check after pulling files
46-
const storeIntegrityCheck = await waitForPromise(
47-
() => dataStore.validate(),
48-
"Checking store integrity...",
49-
"Store integrity check passed.",
50-
"Store integrity check failed."
51-
);
52-
53-
// Handle integrity check failure
54-
if (!storeIntegrityCheck) {
40+
if (skipData) {
41+
console.log("Skipping store integrity check due to --skip-data flag.");
42+
return;
43+
}
44+
45+
try {
46+
// Perform the store integrity check after pulling files
47+
const storeIntegrityCheck = await waitForPromise(
48+
() => dataStore.validate(),
49+
"Checking store integrity...",
50+
"Store integrity check passed.",
51+
"Store integrity check failed."
52+
);
53+
54+
// Handle integrity check failure
55+
if (!storeIntegrityCheck) {
56+
console.error("Store integrity check failed. Reverting Clone");
57+
fs.rmdirSync(path.resolve(STORE_PATH, storeId), { recursive: true });
58+
}
59+
} catch (error: any) {
60+
console.trace(error.message);
5561
console.error("Store integrity check failed. Reverting Clone");
5662
fs.rmdirSync(path.resolve(STORE_PATH, storeId), { recursive: true });
5763
}
58-
} catch (error: any) {
59-
console.trace(error.message);
60-
console.error("Store integrity check failed. Reverting Clone");
61-
fs.rmdirSync(path.resolve(STORE_PATH, storeId), { recursive: true });
64+
} finally {
65+
process.exit(0);
6266
}
6367
};

0 commit comments

Comments
 (0)