From 8f88fe1cf1e63b20600d603728d063e7a563993f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Andrade?= Date: Thu, 2 May 2024 20:55:21 +0200 Subject: [PATCH] Keep uploads when regenerating pfps --- README.md | 48 +++++++++++++++++------------------ package.json | 2 +- src/commands/pfps/generate.ts | 17 +++++++++++-- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 5025a86..fbb6609 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ $ npm install -g @nefty/cli $ nefty COMMAND running command... $ nefty (--version) -@nefty/cli/0.2.12 darwin-arm64 node-v18.19.1 +@nefty/cli/0.2.13 darwin-arm64 node-v18.19.1 $ nefty --help [COMMAND] USAGE $ nefty COMMAND @@ -273,7 +273,7 @@ DESCRIPTION Manages a collection's assets. ``` -_See code: [src/commands/assets/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/assets/index.ts)_ +_See code: [src/commands/assets/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/assets/index.ts)_ ## `nefty assets mint INPUT` @@ -300,7 +300,7 @@ EXAMPLES $ nefty assets mint test.xls -c alpacaworlds ``` -_See code: [src/commands/assets/mint.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/assets/mint.ts)_ +_See code: [src/commands/assets/mint.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/assets/mint.ts)_ ## `nefty config` @@ -314,7 +314,7 @@ DESCRIPTION Manages the configuration. ``` -_See code: [src/commands/config/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/config/index.ts)_ +_See code: [src/commands/config/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/config/index.ts)_ ## `nefty config auth` @@ -333,7 +333,7 @@ EXAMPLES $ nefty config auth auth ``` -_See code: [src/commands/config/auth.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/config/auth.ts)_ +_See code: [src/commands/config/auth.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/config/auth.ts)_ ## `nefty config get` @@ -350,7 +350,7 @@ EXAMPLES $ nefty config get ``` -_See code: [src/commands/config/get.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/config/get.ts)_ +_See code: [src/commands/config/get.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/config/get.ts)_ ## `nefty config init` @@ -370,7 +370,7 @@ EXAMPLES $ nefty config init ``` -_See code: [src/commands/config/init.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/config/init.ts)_ +_See code: [src/commands/config/init.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/config/init.ts)_ ## `nefty config set [PROPERTY] [VALUE]` @@ -393,7 +393,7 @@ EXAMPLES $ nefty config set explorerUrl https://waxblock.io ``` -_See code: [src/commands/config/set.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/config/set.ts)_ +_See code: [src/commands/config/set.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/config/set.ts)_ ## `nefty generate` @@ -407,7 +407,7 @@ DESCRIPTION Generates excel files to use in other batch commands. ``` -_See code: [src/commands/generate/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/generate/index.ts)_ +_See code: [src/commands/generate/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/generate/index.ts)_ ## `nefty generate mint-file OUTPUT` @@ -439,7 +439,7 @@ EXAMPLES $ nefty generate mint-file mints.xlsx -c alpacaworlds ``` -_See code: [src/commands/generate/mint-file.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/generate/mint-file.ts)_ +_See code: [src/commands/generate/mint-file.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/generate/mint-file.ts)_ ## `nefty generate pfp-file OUTPUT` @@ -471,7 +471,7 @@ EXAMPLES $ nefty generate pfp-file pfp-layers.xlsx -l Body -l Face -l Hair -a ``` -_See code: [src/commands/generate/pfp-file.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/generate/pfp-file.ts)_ +_See code: [src/commands/generate/pfp-file.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/generate/pfp-file.ts)_ ## `nefty generate template-file OUTPUT` @@ -503,7 +503,7 @@ EXAMPLES $ nefty generate template-file templates.xlsx -c alpacaworlds ``` -_See code: [src/commands/generate/template-file.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/generate/template-file.ts)_ +_See code: [src/commands/generate/template-file.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/generate/template-file.ts)_ ## `nefty generate token-transfer-file OUTPUT` @@ -525,7 +525,7 @@ EXAMPLES $ nefty generate token-transfer-file transfers.xlsx ``` -_See code: [src/commands/generate/token-transfer-file.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/generate/token-transfer-file.ts)_ +_See code: [src/commands/generate/token-transfer-file.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/generate/token-transfer-file.ts)_ ## `nefty help [COMMAND]` @@ -559,7 +559,7 @@ DESCRIPTION Commands to manage a PFP collection. ``` -_See code: [src/commands/pfps/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/pfps/index.ts)_ +_See code: [src/commands/pfps/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/pfps/index.ts)_ ## `nefty pfps build INPUT` @@ -590,7 +590,7 @@ EXAMPLES $ nefty pfps build ./pfps-folder -c alpacaworls -t 11324 -a alpacaworlds -n "My NFT" -r ``` -_See code: [src/commands/pfps/build.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/pfps/build.ts)_ +_See code: [src/commands/pfps/build.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/pfps/build.ts)_ ## `nefty pfps cover INPUT` @@ -622,7 +622,7 @@ EXAMPLES ff28ca1c5749e6a6369dae7fe7d334b5b5ca40e43f1c345e7f0b4b22b36c0c6b ``` -_See code: [src/commands/pfps/cover.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/pfps/cover.ts)_ +_See code: [src/commands/pfps/cover.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/pfps/cover.ts)_ ## `nefty pfps generate INPUT OUTPUT` @@ -652,7 +652,7 @@ EXAMPLES $ nefty pfps generate pfps-specs.xlsx pfps ``` -_See code: [src/commands/pfps/generate.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/pfps/generate.ts)_ +_See code: [src/commands/pfps/generate.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/pfps/generate.ts)_ ## `nefty pfps mint INPUT` @@ -678,7 +678,7 @@ EXAMPLES $ nefty pfps mint ./pfps-folder ``` -_See code: [src/commands/pfps/mint.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/pfps/mint.ts)_ +_See code: [src/commands/pfps/mint.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/pfps/mint.ts)_ ## `nefty pfps mosaic INPUT` @@ -711,7 +711,7 @@ EXAMPLES ff28ca1c5749e6a6369dae7fe7d334b5b5ca40e43f1c345e7f0b4b22b36c0c6b ``` -_See code: [src/commands/pfps/mosaic.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/pfps/mosaic.ts)_ +_See code: [src/commands/pfps/mosaic.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/pfps/mosaic.ts)_ ## `nefty templates` @@ -725,7 +725,7 @@ DESCRIPTION Manages a collection's templates. ``` -_See code: [src/commands/templates/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/templates/index.ts)_ +_See code: [src/commands/templates/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/templates/index.ts)_ ## `nefty templates create INPUT` @@ -749,7 +749,7 @@ EXAMPLES $ nefty templates create template.xls -c alpacaworlds ``` -_See code: [src/commands/templates/create.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/templates/create.ts)_ +_See code: [src/commands/templates/create.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/templates/create.ts)_ ## `nefty templates export OUTPUT` @@ -781,7 +781,7 @@ EXAMPLES $ nefty templates export templates.xlsx -c alpacaworlds ``` -_See code: [src/commands/templates/export.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/templates/export.ts)_ +_See code: [src/commands/templates/export.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/templates/export.ts)_ ## `nefty tokens` @@ -795,7 +795,7 @@ DESCRIPTION Manages an account's tokens ``` -_See code: [src/commands/tokens/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/tokens/index.ts)_ +_See code: [src/commands/tokens/index.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/tokens/index.ts)_ ## `nefty tokens transfer INPUT` @@ -818,5 +818,5 @@ EXAMPLES $ nefty tokens transfer test.xls ``` -_See code: [src/commands/tokens/transfer.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.12/src/commands/tokens/transfer.ts)_ +_See code: [src/commands/tokens/transfer.ts](https://github.com/neftyblocks/neftyblocks-cli/blob/v0.2.13/src/commands/tokens/transfer.ts)_ diff --git a/package.json b/package.json index e58477c..3c6a1ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nefty/cli", - "version": "0.2.12", + "version": "0.2.13", "description": "The NeftyBlocks cli will help you manage your collection with commands to create templates, mint assets, and more.", "keywords": [ "oclif" diff --git a/src/commands/pfps/generate.ts b/src/commands/pfps/generate.ts index b9eeeea..e0fe922 100644 --- a/src/commands/pfps/generate.ts +++ b/src/commands/pfps/generate.ts @@ -5,7 +5,7 @@ import { downloadImage, fileExists } from '../../utils/file-utils.js'; import { SingleBar } from 'cli-progress'; import writeXlsxFile from 'write-excel-file/node'; import { generateImage, generatePfps, readPfpLayerSpecs } from '../../services/pfp-service.js'; -import { existsSync, mkdirSync, rmSync, writeFileSync } from 'node:fs'; +import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { PfpManifest } from '../../types/pfps.js'; import { confirmPrompt, makeSpinner } from '../../utils/tty-utils.js'; import PfpCoverCommand from './cover.js'; @@ -73,7 +73,6 @@ export default class GeneratePfpsCommand extends BaseCommand { if (!overwrite) { return; } else { - rmSync(manifestPath, { force: true }); rmSync(excelPath, { force: true }); rmSync(imagesFolder, { recursive: true, force: true }); } @@ -129,6 +128,20 @@ export default class GeneratePfpsCommand extends BaseCommand { pfps: [], }; + if (existsSync(manifestPath)) { + try { + const currentManifest = JSON.parse(readFileSync(manifestPath, 'utf-8')); + manifest.uploads = currentManifest.uploads; + } catch (error) { + const shouldDelete = await confirmPrompt('Manifest file is corrupted, do you want to delete it?'); + if (shouldDelete) { + rmSync(manifestPath, { force: true }); + } else { + return; + } + } + } + const headerRow = [ { type: String,