Skip to content

Commit

Permalink
Add --clean to upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Feb 18, 2022
1 parent ab41f01 commit bd6b9c9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions products/jbrowse-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion products/jbrowse-cli/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
Expand Down
20 changes: 15 additions & 5 deletions products/jbrowse-cli/src/commands/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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',
Expand All @@ -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()
}
Expand Down Expand Up @@ -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}`)
}
Expand Down
9 changes: 2 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand Down Expand Up @@ -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==
Expand Down

0 comments on commit bd6b9c9

Please sign in to comment.