diff --git a/package.json b/package.json index ef7e444786..3b00189ad1 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "@types/json-stable-stringify": "^1.0.32", "@types/lodash.merge": "^4.6.6", "@types/long": "^4.0.0", - "@types/node": "14.0.13", + "@types/node": "^14.14.0", "@types/node-fetch": "^2.5.7", "@types/normalize-wheel": "^1.0.0", "@types/object.fromentries": "^2.0.0", diff --git a/products/jbrowse-cli/README.md b/products/jbrowse-cli/README.md index 75d74a621a..90f10a1996 100644 --- a/products/jbrowse-cli/README.md +++ b/products/jbrowse-cli/README.md @@ -518,6 +518,8 @@ OPTIONS --branch=branch Download a development build from a named git branch + --clean Removes old js,map,and LICENSE files in the installation + --nightly Download the latest development build from the main branch EXAMPLES diff --git a/products/jbrowse-cli/src/base.ts b/products/jbrowse-cli/src/base.ts index 51ca03bfe0..70c7a63e1e 100644 --- a/products/jbrowse-cli/src/base.ts +++ b/products/jbrowse-cli/src/base.ts @@ -291,7 +291,7 @@ export default abstract class JBrowseCommand extends Command { } return file } - return this.error(`Error: Could not find version: ${response.statusText}`, { + return this.error(`Could not find version: ${response.statusText}`, { exit: 90, }) } diff --git a/products/jbrowse-cli/src/commands/upgrade.ts b/products/jbrowse-cli/src/commands/upgrade.ts index cc970a9155..7b84f12d44 100644 --- a/products/jbrowse-cli/src/commands/upgrade.ts +++ b/products/jbrowse-cli/src/commands/upgrade.ts @@ -5,6 +5,8 @@ import fetch from 'node-fetch' import unzip from 'unzipper' import JBrowseCommand from '../base' +const { rm } = fs.promises + export default class Upgrade extends JBrowseCommand { static description = 'Upgrades JBrowse 2 to latest version' @@ -55,6 +57,9 @@ export default class Upgrade extends JBrowseCommand { nightly: flags.boolean({ description: 'Download the latest development build from the main branch', }), + clean: flags.boolean({ + description: 'Removes old js,map,and LICENSE files in the installation', + }), url: flags.string({ char: 'u', description: 'A direct URL to a JBrowse 2 release', @@ -64,13 +69,10 @@ export default class Upgrade extends JBrowseCommand { async run() { const { args: runArgs, flags: runFlags } = this.parse(Upgrade) const { localPath: argsPath } = runArgs as { localPath: string } - - const { listVersions, tag, url, branch, nightly } = runFlags + const { clean, listVersions, tag, url, branch, nightly } = runFlags if (listVersions) { - const versions = (await this.fetchGithubVersions()).map( - version => version.tag_name, - ) + const versions = (await this.fetchGithubVersions()).map(v => v.tag_name) this.log(`All JBrowse versions:\n${versions.join('\n')}`) this.exit() } @@ -111,6 +113,14 @@ export default class Upgrade extends JBrowseCommand { ) } + if (clean) { + this.log('Note: Clean requires node.js 14+') + await rm(path.join(argsPath, 'static'), { force: true, recursive: true }) + const files = fs.readdirSync(argsPath) + files + .filter(f => f.includes('worker.js')) + .forEach(f => fs.unlinkSync(path.join(argsPath, f))) + } await response.body.pipe(unzip.Extract({ path: argsPath })).promise() this.log(`Unpacked ${locationUrl} at ${argsPath}`) } diff --git a/yarn.lock b/yarn.lock index f88cbf3dbc..ad02c7919c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4755,12 +4755,7 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.18.tgz#3b4fed5cfb58010e3a2be4b6e74615e4847f1074" integrity sha512-eKj4f/BsN/qcculZiRSujogjvp5O/k4lOW5m35NopjZM/QwLOR075a8pJW5hD+Rtdm2DaCVPENS6KtSQnUD6BA== -"@types/node@14.0.13": - version "14.0.13" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.13.tgz#ee1128e881b874c371374c1f72201893616417c9" - integrity sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA== - -"@types/node@^14.0.10", "@types/node@^14.6.2": +"@types/node@^14.0.10", "@types/node@^14.14.0", "@types/node@^14.6.2": version "14.18.12" resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.12.tgz#0d4557fd3b94497d793efd4e7d92df2f83b4ef24" integrity sha512-q4jlIR71hUpWTnGhXWcakgkZeHa3CCjcQcnuzU8M891BAWA2jHiziiWEPEkdS5pFsz7H9HJiy8BrK7tBRNrY7A== @@ -7692,7 +7687,7 @@ clone@~0.1.9: resolved "https://registry.yarnpkg.com/clone/-/clone-0.1.19.tgz#613fb68639b26a494ac53253e15b1a6bd88ada85" integrity sha1-YT+2hjmyaklKxTJT4Vsaa9iK2oU= -clsx@^1.0.0, clsx@^1.0.4, clsx@^1.1.0, clsx@^1.1.1: +clsx@^1.0.4, clsx@^1.1.0, clsx@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.1.1.tgz#98b3134f9abbdf23b2663491ace13c5c03a73188" integrity sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==