From 5856ce06186fbb7426ab4405d751b33feeddaa3c Mon Sep 17 00:00:00 2001 From: Amadeo Pellicce Date: Sun, 12 Mar 2023 20:35:35 -0700 Subject: [PATCH 1/4] 1.0.190 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d72a996..178c7ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map3xyz/assets-helper", - "version": "1.0.189", + "version": "1.0.190", "description": "A library for maintaining the assets repo.", "author": "pellicceama", "keywords": [ From 4654809b98de6272b1beed9f35f3ac303f744a6c Mon Sep 17 00:00:00 2001 From: Amadeo Pellicce Date: Mon, 13 Mar 2023 11:24:47 -0700 Subject: [PATCH 2/4] Adding min number of assets parameters and failing if it doesn't find them --- package.json | 2 +- src/releaser/db/sync-database.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 178c7ab..2cf7cc3 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "prepareTest": "yarn ts-node ./src/cache.ts", "test": "yarn prepareTest && yarn build && ava", "bundle": "yarn build && pkg . --out-dir ./exec/", - "release-db": "ts-node ./src/releaser/sync/sync-database.ts" + "release-db": "ts-node ./src/releaser/db/sync-database.ts" }, "devDependencies": { "@types/ethereum-checksum-address": "^0.0.0", diff --git a/src/releaser/db/sync-database.ts b/src/releaser/db/sync-database.ts index 87f5350..988ef35 100644 --- a/src/releaser/db/sync-database.ts +++ b/src/releaser/db/sync-database.ts @@ -55,13 +55,29 @@ export async function createAssetDb(assetRepo: string = "/tmp/assets", assetDb: await db.exec("COMMIT"); + const assetsNumber = await getNumberOfAssetsInDb(db); + + if(assetsNumber < (process.env.MIN_NUMBER_OF_ASSETS || 1000)) { + console.error(`Asset DB has only ${assetsNumber} assets, exiting`); + process.exit(1); + } + + console.log(`Added ${assetsNumber} to Assets DB`); + await db.close(); await createRelease(octokit, commitId, assetDb); + console.log("Asset DB Released"); return Promise.resolve(); } +createAssetDb(); + +async function getNumberOfAssetsInDb(db): Promise { + const result = await db.get("SELECT COUNT(*) AS count FROM asset"); + return result.count; +} async function getLatestRelease(octokit: Octokit): Promise { let release = null; From a1bfb9a69131dab9c1167798f5ce677ab0f0d418 Mon Sep 17 00:00:00 2001 From: Amadeo Pellicce Date: Mon, 13 Mar 2023 11:24:58 -0700 Subject: [PATCH 3/4] removing uncessary call --- src/releaser/db/sync-database.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/releaser/db/sync-database.ts b/src/releaser/db/sync-database.ts index 988ef35..3106b9b 100644 --- a/src/releaser/db/sync-database.ts +++ b/src/releaser/db/sync-database.ts @@ -72,8 +72,6 @@ export async function createAssetDb(assetRepo: string = "/tmp/assets", assetDb: return Promise.resolve(); } -createAssetDb(); - async function getNumberOfAssetsInDb(db): Promise { const result = await db.get("SELECT COUNT(*) AS count FROM asset"); return result.count; From 814d9e5d626bca404f49f75c851027772eb13a91 Mon Sep 17 00:00:00 2001 From: Amadeo Pellicce Date: Mon, 13 Mar 2023 11:25:25 -0700 Subject: [PATCH 4/4] 1.0.191 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2cf7cc3..1e5131d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map3xyz/assets-helper", - "version": "1.0.190", + "version": "1.0.191", "description": "A library for maintaining the assets repo.", "author": "pellicceama", "keywords": [