diff --git a/package.json b/package.json index d72a996..1e5131d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map3xyz/assets-helper", - "version": "1.0.189", + "version": "1.0.191", "description": "A library for maintaining the assets repo.", "author": "pellicceama", "keywords": [ @@ -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..3106b9b 100644 --- a/src/releaser/db/sync-database.ts +++ b/src/releaser/db/sync-database.ts @@ -55,13 +55,27 @@ 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(); } +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;