Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tarballs based commands not considering config from package.json … #830

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/commands/pack/tarballs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@ 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)',
default: Tarballs.TARGETS.join(','),
}),
xz: Flags.boolean({description: 'also build xz', allowNo: true, default: true}),
tarball: Flags.string({char: 't', description: 'optionally specify a path to a tarball already generated by NPM', required: false}),
targets: Flags.string({char: 't', description: 'comma-separated targets to pack (e.g.: linux-arm,win32-x64)'}),
xz: Flags.boolean({description: 'also build xz', allowNo: true}),
tarball: Flags.string({char: 'l', description: 'optionally specify a path to a tarball already generated by NPM', required: false}),
}

async run(): Promise<void> {
const prevCwd = qq.cwd()
if (process.platform === 'win32') throw new Error('pack does not function on windows')
const {flags} = await this.parse(PackTarballs)
const targets = flags.targets.split(',')
const buildConfig = await Tarballs.buildConfig(flags.root, {xz: flags.xz, targets: targets})
const buildConfig = await Tarballs.buildConfig(flags.root, {xz: flags.xz, targets: flags?.targets?.split(',')})
if (buildConfig.targets.length === 0) {
throw new Error('Please specify one or more valid targets.')
}
Expand Down
11 changes: 3 additions & 8 deletions src/commands/promote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,19 @@ export default class Promote extends Command {
version: Flags.string({description: 'semantic version of the CLI to promote', required: true}),
sha: Flags.string({description: '7-digit short git commit SHA of the CLI to promote', required: true}),
channel: Flags.string({description: 'which channel to promote to', required: true, default: 'stable'}),
targets: Flags.string({
char: 't',
description: 'comma-separated targets to promote (e.g.: linux-arm,win32-x64)',
default: Tarballs.TARGETS.join(','),
}),
targets: Flags.string({char: 't', description: 'comma-separated targets to promote (e.g.: linux-arm,win32-x64)'}),
deb: Flags.boolean({char: 'd', description: 'promote debian artifacts'}),
macos: Flags.boolean({char: 'm', description: 'promote macOS pkg'}),
win: Flags.boolean({char: 'w', description: 'promote Windows exe'}),
'max-age': Flags.string({char: 'a', description: 'cache control max-age in seconds', default: '86400'}),
xz: Flags.boolean({description: 'also upload xz', allowNo: true, default: true}),
xz: Flags.boolean({description: 'also upload xz', allowNo: true}),
indexes: Flags.boolean({description: 'append the promoted urls into the index files'}),
}

async run(): Promise<void> {
const {flags} = await this.parse(Promote)
const maxAge = `max-age=${flags['max-age']}`
const targets = flags.targets.split(',')
const buildConfig = await Tarballs.buildConfig(flags.root, {targets})
const buildConfig = await Tarballs.buildConfig(flags.root, {targets: flags?.targets?.split(',')})
const {s3Config, config} = buildConfig
const indexDefaults = {
version: flags.version,
Expand Down
13 changes: 4 additions & 9 deletions src/commands/upload/tarballs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ export default class UploadTarballs extends Command {

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 upload (e.g.: linux-arm,win32-x64)',
default: Tarballs.TARGETS.join(','),
}),
xz: Flags.boolean({description: 'also upload xz', allowNo: true, default: true}),
targets: Flags.string({char: 't', description: 'comma-separated targets to upload (e.g.: linux-arm,win32-x64)'}),
xz: Flags.boolean({description: 'also upload xz', allowNo: true}),
}

async run(): Promise<void> {
const {flags} = await this.parse(UploadTarballs)
if (process.platform === 'win32') throw new Error('upload does not function on windows')
const targets = flags.targets.split(',')
const buildConfig = await Tarballs.buildConfig(flags.root, {targets, xz: flags.xz})
const buildConfig = await Tarballs.buildConfig(flags.root, {xz: flags.xz, targets: flags?.targets?.split(',')})
const {s3Config, dist, config, xz} = buildConfig

// fail early if targets are not built
Expand Down Expand Up @@ -77,7 +72,7 @@ export default class UploadTarballs extends Command {
await aws.s3.uploadFile(dist(manifest), {...ManifestS3Options, Key: cloudKey})
}

if (targets.length > 0) log('uploading targets')
if (buildConfig.targets.length > 0) log('uploading targets')
// eslint-disable-next-line no-await-in-loop
for (const target of buildConfig.targets) await uploadTarball(target)
log(`done uploading tarballs & manifests for v${config.version}-${buildConfig.gitSha}`)
Expand Down
2 changes: 1 addition & 1 deletion src/tarballs/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function buildConfig(root: string, options: {xz?: boolean; targets?
config,
tmp,
updateConfig,
xz: typeof options.xz === 'boolean' ? options.xz : Boolean(updateConfig.s3.xz),
xz: options?.xz ?? updateConfig?.s3?.xz ?? true,
dist: (...args: string[]) => path.join(config.root, 'dist', ...args),
s3Config: updateConfig.s3,
nodeVersion,
Expand Down