UNPKG

4.42 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const command_1 = require("@oclif/command");
4// import * as Octokit from '@octokit/rest'
5// import * as fs from 'fs-extra'
6// import * as path from 'path'
7// import * as qq from 'qqjs'
8// import * as Tarballs from '../../tarballs'
9// import {log as action} from '../../tarballs/log'
10class Publish extends command_1.Command {
11 // octokit = new Octokit()
12 async run() {
13 this.warn('TODO: finish this');
14 // if (!process.env.GH_TOKEN) throw new Error('GH_TOKEN must be set')
15 // const {flags} = this.parse(Publish)
16 // if (process.platform === 'win32') throw new Error('pack does not function on windows')
17 // const {'node-version': nodeVersion, prerelease, draft} = flags
18 // const channel = flags.prerelease ? 'prerelease' : 'stable'
19 // const root = path.resolve(flags.root)
20 // const config = await Tarballs.config(root)
21 // const version = config.version
22 // const baseWorkspace = qq.join([config.root, 'tmp', 'base'])
23 // const updateConfig = config.pjson.oclif.update || {}
24 // const targets = updateConfig.node && updateConfig.node.targets || []
25 // if (!targets) throw new Error('specify oclif.targets in package.json')
26 // // first create the generic base workspace that will be copied later
27 // await Tarballs.build({config, channel, output: baseWorkspace, version})
28 // const tarballs: {target: string, tarball: string}[] = []
29 // for (let [platform, arch] of targets.map(t => t.split('-'))) {
30 // const t = await Tarballs.target({config, platform, arch, channel, version, baseWorkspace, nodeVersion, xz: flags.xz})
31 // tarballs.push(t)
32 // }
33 // this.octokit.authenticate({
34 // type: 'token',
35 // token: process.env.GH_TOKEN,
36 // })
37 // const tag = `v${version}`
38 // const [owner, repo] = config.pjson.repository.split('/')
39 // const commitish = await Tarballs.gitSha(config.root)
40 // const release = await this.findOrCreateRelease({owner, repo, tag, prerelease, draft, commitish})
41 // for (let {tarball} of tarballs) {
42 // await this.addFileToRelease(release, `${tarball}.tar.gz`)
43 // if (flags.xz) await this.addFileToRelease(release, `${tarball}.tar.xz`)
44 // }
45 // }
46 // async findOrCreateRelease({owner, repo, tag, prerelease, draft, commitish}: {owner: string, repo: string, tag: string, prerelease: boolean, draft: boolean, commitish: string}) {
47 // const findRelease = async () => {
48 // const {data} = await this.octokit.repos.getReleaseByTag({owner, repo, tag})
49 // action(`found existing release ${tag}`)
50 // return data
51 // }
52 // const createRelease = async () => {
53 // action(`creating ${tag} release`)
54 // const {data} = await this.octokit.repos.createRelease({
55 // owner,
56 // repo,
57 // target_commitish: commitish,
58 // tag_name: tag,
59 // prerelease,
60 // draft,
61 // })
62 // return data
63 // }
64 // try {
65 // return await findRelease()
66 // } catch (err) {
67 // this.debug(err)
68 // }
69 // return createRelease()
70 // }
71 // async addFileToRelease(release: {upload_url: string}, file: string) {
72 // action(`uploading ${file}`)
73 // await this.octokit.repos.uploadAsset({
74 // url: release.upload_url,
75 // file: fs.createReadStream(file),
76 // contentType: 'application/gzip',
77 // contentLength: fs.statSync(file).size,
78 // name: qq.path.basename(file),
79 // label: qq.path.basename(file),
80 // })
81 }
82}
83exports.default = Publish;
84Publish.description = 'publish an oclif CLI to GitHub Releases';
85Publish.hidden = true;
86Publish.flags = {
87// root: flags.string({char: 'r', description: 'path to oclif CLI root', default: '.', required: true}),
88// 'node-version': flags.string({description: 'node version of binary to get', default: process.versions.node, required: true}),
89// xz: flags.boolean({description: 'also create xz tarballs'}),
90// prerelease: flags.boolean({description: 'identify as prerelease'}),
91// draft: flags.boolean({description: 'create an unpublished release'}),
92};