Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

Commit

Permalink
feat: --targets flag on pack
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Aug 31, 2018
1 parent 48dd636 commit b1fdd21
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 92 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"bugs": "https://github.com/oclif/dev-cli/issues",
"dependencies": {
"@oclif/command": "^1.5.0",
"@oclif/config": "^1.7.0",
"@oclif/config": "^1.7.3",
"@oclif/errors": "^1.2.0",
"@oclif/plugin-help": "^2.1.0",
"cli-ux": "^4.8.0",
"cli-ux": "^4.8.1",
"debug": "^3.1.0",
"fs-extra": "^7.0.0",
"lodash": "^4.17.10",
Expand All @@ -21,7 +21,7 @@
"tslib": "^1.9.3"
},
"devDependencies": {
"@oclif/plugin-legacy": "^1.0.18",
"@oclif/plugin-legacy": "^1.1.0",
"@oclif/test": "^1.2.0",
"@oclif/tslint": "^2.0.0",
"@types/chai": "^4.1.4",
Expand All @@ -31,16 +31,16 @@
"@types/lodash": "^4.14.116",
"@types/lodash.template": "^4.4.4",
"@types/mocha": "^5.2.5",
"@types/node": "^10.7.1",
"@types/node": "^10.9.4",
"@types/supports-color": "^5.3.0",
"@types/write-json-file": "^2.2.1",
"aws-sdk": "^2.295.0",
"aws-sdk": "^2.307.0",
"chai": "^4.1.2",
"globby": "^8.0.1",
"mocha": "^5.2.0",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "^3.0.1"
"typescript": "^3.0.3"
},
"engines": {
"node": ">=8.0.0"
Expand Down
4 changes: 3 additions & 1 deletion src/commands/pack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ This can be used to create oclif CLIs that use the system node or that come prel

static flags = {
root: flags.string({char: 'r', description: 'path to oclif CLI root', default: '.', required: true}),
targets: flags.string({char: 't', description: 'comma-separated targets to pack (e.g.: linux-arm,win32-x64)'}),
}

async run() {
const prevCwd = qq.cwd()
if (process.platform === 'win32') throw new Error('pack does not function on windows')
const {flags} = this.parse(Pack)
const buildConfig = await Tarballs.buildConfig(flags.root)
const targets = flags.targets !== undefined ? flags.targets.split(',') : undefined
const buildConfig = await Tarballs.buildConfig(flags.root, targets)
await Tarballs.build(buildConfig)
qq.cd(prevCwd)
}
Expand Down
4 changes: 2 additions & 2 deletions src/tarballs/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function Tmp(config: Config.IConfig) {
return tmp
}

export async function buildConfig(root: string): Promise<IConfig> {
export async function buildConfig(root: string, targets?: string[]): Promise<IConfig> {
const config = await Config.load({root: path.resolve(root), devPlugins: false, userPlugins: false})
const channel = config.channel
root = config.root
Expand All @@ -70,7 +70,7 @@ export async function buildConfig(root: string): Promise<IConfig> {
if (target && target.platform) return qq.join(base, [target.platform, target.arch].join('-'), config.s3Key('baseDir', target))
return qq.join(base, config.s3Key('baseDir', target))
},
targets: (updateConfig.node.targets || TARGETS).map(t => {
targets: (targets || updateConfig.node.targets || TARGETS).map(t => {
const [platform, arch] = t.split('-') as [Config.PlatformTypes, Config.ArchTypes]
return {platform, arch}
}),
Expand Down
Loading

0 comments on commit b1fdd21

Please sign in to comment.