Skip to content

Commit

Permalink
Merge pull request #18 from DIG-Network/release/v0.0.1-alpha.19
Browse files Browse the repository at this point in the history
Release/v0.0.1 alpha.19
  • Loading branch information
MichaelTaylor3D authored Sep 10, 2024
2 parents 5e8a1c3 + 6cbf506 commit cb84cf4
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 46 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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.

### [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)

### [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)

### [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)
Expand Down
38 changes: 32 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dignetwork/dig-chia-cli",
"version": "0.0.1-alpha.18",
"version": "0.0.1-alpha.19",
"description": "",
"type": "commonjs",
"main": "./dist/index.js",
Expand All @@ -24,7 +24,7 @@
"LICENSE"
],
"dependencies": {
"@dignetwork/dig-sdk": "^0.0.1-alpha.9",
"@dignetwork/dig-sdk": "^0.0.1-alpha.11",
"bip39": "^3.1.0",
"datalayer-driver": "^0.1.21",
"inquirer": "^10.1.8",
Expand Down
80 changes: 42 additions & 38 deletions src/actions/clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,55 @@ export const clone = async (
storeId: string,
skipData: boolean = false
): Promise<void> => {
console.log(`Cloning store: ${storeId}`);
try {
console.log(`Cloning store: ${storeId}`);

const storeDir = path.join(DIG_FOLDER_PATH, "stores", storeId);
const storeDir = path.join(DIG_FOLDER_PATH, "stores", storeId);

// Check if the store directory already exists
if (fs.existsSync(storeDir)) {
console.error(`Store with ID ${storeId} already exists at ${storeDir}.`);
process.exit(1); // Exit the process with an error code
}
// Check if the store directory already exists
if (fs.existsSync(storeDir)) {
console.error(`Store with ID ${storeId} already exists at ${storeDir}.`);
process.exit(1); // Exit the process with an error code
}

try {
// Create an instance of DigNetwork
const digNetwork = new DigNetwork(storeId);

// Pull files from the network using DigNetwork
await digNetwork.downloadFiles(true, true, skipData);
} catch (error: any) {
console.error(error.message);
process.exit(1); // Exit the process with an error code
}
try {
// Create an instance of DigNetwork
const digNetwork = new DigNetwork(storeId);

// Pull files from the network using DigNetwork
await digNetwork.downloadFiles(true, true, skipData);
} catch (error: any) {
console.error(error.message);
process.exit(1); // Exit the process with an error code
}

const dataStore = DataStore.from(storeId);
const dataStore = DataStore.from(storeId);

if (skipData) {
console.log("Skipping store integrity check due to --skip-data flag.");
return;
}

try {
// Perform the store integrity check after pulling files
const storeIntegrityCheck = await waitForPromise(
() => dataStore.validate(),
"Checking store integrity...",
"Store integrity check passed.",
"Store integrity check failed."
);

// Handle integrity check failure
if (!storeIntegrityCheck) {
if (skipData) {
console.log("Skipping store integrity check due to --skip-data flag.");
return;
}

try {
// Perform the store integrity check after pulling files
const storeIntegrityCheck = await waitForPromise(
() => dataStore.validate(),
"Checking store integrity...",
"Store integrity check passed.",
"Store integrity check failed."
);

// Handle integrity check failure
if (!storeIntegrityCheck) {
console.error("Store integrity check failed. Reverting Clone");
fs.rmdirSync(path.resolve(STORE_PATH, storeId), { recursive: true });
}
} catch (error: any) {
console.trace(error.message);
console.error("Store integrity check failed. Reverting Clone");
fs.rmdirSync(path.resolve(STORE_PATH, storeId), { recursive: true });
}
} catch (error: any) {
console.trace(error.message);
console.error("Store integrity check failed. Reverting Clone");
fs.rmdirSync(path.resolve(STORE_PATH, storeId), { recursive: true });
} finally {
process.exit(0);
}
};

0 comments on commit cb84cf4

Please sign in to comment.