1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const command_1 = require("@oclif/command");
|
4 | const qq = require("qqjs");
|
5 | const aws_1 = require("../../aws");
|
6 | const log_1 = require("../../log");
|
7 | const Tarballs = require("../../tarballs");
|
8 | class PublishDeb extends command_1.Command {
|
9 | async run() {
|
10 | const { flags } = this.parse(PublishDeb);
|
11 | const buildConfig = await Tarballs.buildConfig(flags.root);
|
12 | const { s3Config, version, config } = buildConfig;
|
13 | const dist = (f) => buildConfig.dist(qq.join('deb', f));
|
14 | if (!await qq.exists(dist('Release')))
|
15 | this.error('run "oclif-dev pack:deb" before publishing');
|
16 | const S3Options = {
|
17 | Bucket: s3Config.bucket,
|
18 | ACL: s3Config.acl || 'public-read',
|
19 | };
|
20 | const remoteBase = buildConfig.channel === 'stable' ? 'apt' : `channels/${buildConfig.channel}/apt`;
|
21 | const upload = (file) => {
|
22 | return aws_1.default.s3.uploadFile(dist(file), Object.assign(Object.assign({}, S3Options), { CacheControl: 'max-age=86400', Key: [remoteBase, file].join('/') }));
|
23 | };
|
24 | const debVersion = `${buildConfig.version.split('-')[0]}-1`;
|
25 | const uploadDeb = async (arch) => {
|
26 | const deb = `${config.bin}_${debVersion}_${arch}.deb`;
|
27 | if (await qq.exists(dist(deb)))
|
28 | await upload(deb);
|
29 | };
|
30 | await uploadDeb('amd64');
|
31 | await uploadDeb('i386');
|
32 | await upload('Packages.gz');
|
33 | await upload('Packages.xz');
|
34 | await upload('Packages.bz2');
|
35 | await upload('Release');
|
36 | if (await qq.exists(dist('InRelease')))
|
37 | await upload('InRelease');
|
38 | if (await qq.exists(dist('Release.gpg')))
|
39 | await upload('Release.gpg');
|
40 | log_1.log(`published deb ${version}`);
|
41 | }
|
42 | }
|
43 | exports.default = PublishDeb;
|
44 | PublishDeb.description = 'publish deb package built with pack:deb';
|
45 | PublishDeb.flags = {
|
46 | root: command_1.flags.string({ char: 'r', description: 'path to oclif CLI root', default: '.', required: true }),
|
47 | };
|