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

Commit

Permalink
fix: improved debug output and export IManifest
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Apr 9, 2018
1 parent cdb473e commit afdd520
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"@heroku-cli/color": "^1.1.3",
"@oclif/command": "^1.4.9",
"@oclif/config": "^1.4.6",
"@oclif/config": "^1.4.7",
"@oclif/errors": "^1.0.4",
"@oclif/plugin-help": "^1.2.3",
"@oclif/plugin-warn-if-update-available": "^1.3.0",
Expand Down
2 changes: 2 additions & 0 deletions src/commands/publish/index.ts
Expand Up @@ -55,13 +55,15 @@ export default class Publish extends Command {

private async uploadNodeBinary(target: Tarballs.ITarget) {
const {platform, arch} = target
log('checking for node binary %s-%s in S3', platform, arch)
const {nodeVersion, dist, tmp, s3Config} = this.buildConfig
let key = path.join('node', `node-v${nodeVersion}`, `node-v${nodeVersion}-${platform}-${arch}`)
let Key = (platform === 'win32' ? `${key}.exe` : key) + '.gz'
try {
await s3.headObject({Bucket: s3Config.bucket!, Key})
} catch (err) {
if (err.code !== 'NotFound') throw err
log('uploading node binary %s-%s', target.platform, target.arch)
let output = dist(key)
output = await Tarballs.fetchNodeBinary({nodeVersion, platform, arch, output, tmp})
await qq.x('gzip', ['-f', output])
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
@@ -1 +1,2 @@
export {run} from '@oclif/command'
export {IManifest} from './tarballs'
7 changes: 4 additions & 3 deletions src/log.ts
@@ -1,10 +1,11 @@
import cli from 'cli-ux'
import * as qq from 'qqjs'
import * as util from 'util'

export const debug = require('debug')('oclif-dev')
debug.new = (name: string) => require('debug')(`oclif-dev:${name}`)

export function log(...msg: string[]) {
const output = qq.prettifyPaths(msg.join(' '))
debug.enabled ? debug(output) : cli.log(`oclif-dev: ${output}`)
export function log(format: string, ...args: string[]) {
args = args.map(qq.prettifyPaths)
debug.enabled ? debug(format, ...args) : cli.log(`oclif-dev: ${util.format(format, ...args)}`)
}
8 changes: 4 additions & 4 deletions src/tarballs/build.ts
Expand Up @@ -4,7 +4,7 @@ import * as qq from 'qqjs'
import {log} from '../log'

import {writeBinScripts} from './bin'
import {IConfig, ITarget, IVersionManifest} from './config'
import {IConfig, IManifest, ITarget} from './config'
import {fetchNodeBinary} from './node'

const pack = async (from: string, to: string) => {
Expand Down Expand Up @@ -108,7 +108,7 @@ export async function build({
if (vanilla.tarball.xz) await pack(baseWorkspace, dist(vanilla.tarball.xz))
}
const buildBaseManifest = async () => {
const manifest: IVersionManifest = {
const manifest: IManifest = {
version,
channel,
gz: vanilla.urls.gz,
Expand All @@ -128,11 +128,11 @@ export async function build({
sha256xz: t.manifest!.sha256xz,
}
return targets
}, {} as IVersionManifest['targets'])
}, {} as IManifest['targets'])
}
await qq.writeJSON(dist(vanilla.manifest), manifest)
}
log(`packing ${config.bin} to ${baseWorkspace}`)
log(`gathering workspace for ${config.bin} to ${baseWorkspace}`)
await extractCLI(await packCLI())
await updatePJSON()
await addDependencies()
Expand Down
6 changes: 3 additions & 3 deletions src/tarballs/config.ts
Expand Up @@ -37,12 +37,12 @@ export interface ITarget {
tarball: Tarball
manifest: string
}
manifest?: IManifest
manifest?: ITargetManifest
}

export type Tarball = {gz: string, xz?: string}

export interface IManifest {
export interface ITargetManifest {
version: string
channel: string
gz: string
Expand All @@ -51,7 +51,7 @@ export interface IManifest {
sha256xz?: string
}

export interface IVersionManifest extends IManifest {
export interface IManifest extends ITargetManifest {
rollout?: number
node: {
compatible: string
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Expand Up @@ -73,9 +73,9 @@
dependencies:
debug "^3.1.0"

"@oclif/config@^1.4.6":
version "1.4.6"
resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.4.6.tgz#cb7adde8398ea6aec669b70a8a6e7b8903cc9b45"
"@oclif/config@^1.4.7":
version "1.4.7"
resolved "https://registry.yarnpkg.com/@oclif/config/-/config-1.4.7.tgz#31edcbffa0f47ca14985cd0da31bf8a11cd9b540"
dependencies:
debug "^3.1.0"

Expand Down

0 comments on commit afdd520

Please sign in to comment.