new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-21 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bufferCount.js","sources":["../../src/internal/operators/bufferCount.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,4CAA2C;AA2D3C,SAAgB,WAAW,CAAI,UAAkB,EAAE,gBAA+B;IAA/B,iCAAA,EAAA,uBAA+B;IAChF,OAAO,SAAS,2BAA2B,CAAC,MAAqB;QAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAI,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC;AAJD,kCAIC;AAED;IAGE,6BAAoB,UAAkB,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,gCAAC;AAAD,CAAC,AAtCD,CAA2C,uBAAU,GAsCpD"}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { async } from '../scheduler/async';
|
||||
import { audit } from './audit';
|
||||
import { timer } from '../observable/timer';
|
||||
export function auditTime(duration, scheduler = async) {
|
||||
return audit(() => timer(duration, scheduler));
|
||||
}
|
||||
//# sourceMappingURL=auditTime.js.map
|
||||
@@ -0,0 +1,20 @@
|
||||
/** PURE_IMPORTS_START _util_isArray,_observable_combineLatest,_observable_from PURE_IMPORTS_END */
|
||||
import { isArray } from '../util/isArray';
|
||||
import { CombineLatestOperator } from '../observable/combineLatest';
|
||||
import { from } from '../observable/from';
|
||||
var none = {};
|
||||
export function combineLatest() {
|
||||
var observables = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
observables[_i] = arguments[_i];
|
||||
}
|
||||
var project = null;
|
||||
if (typeof observables[observables.length - 1] === 'function') {
|
||||
project = observables.pop();
|
||||
}
|
||||
if (observables.length === 1 && isArray(observables[0])) {
|
||||
observables = observables[0].slice();
|
||||
}
|
||||
return function (source) { return source.lift.call(from([source].concat(observables)), new CombineLatestOperator(project)); };
|
||||
}
|
||||
//# sourceMappingURL=combineLatest.js.map
|
||||
@@ -0,0 +1,8 @@
|
||||
import { OperatorFunction } from '../types';
|
||||
export declare function pluck<T, K1 extends keyof T>(k1: K1): OperatorFunction<T, T[K1]>;
|
||||
export declare function pluck<T, K1 extends keyof T, K2 extends keyof T[K1]>(k1: K1, k2: K2): OperatorFunction<T, T[K1][K2]>;
|
||||
export declare function pluck<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(k1: K1, k2: K2, k3: K3): OperatorFunction<T, T[K1][K2][K3]>;
|
||||
export declare function pluck<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(k1: K1, k2: K2, k3: K3, k4: K4): OperatorFunction<T, T[K1][K2][K3][K4]>;
|
||||
export declare function pluck<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], K5 extends keyof T[K1][K2][K3][K4]>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5): OperatorFunction<T, T[K1][K2][K3][K4][K5]>;
|
||||
export declare function pluck<T, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], K5 extends keyof T[K1][K2][K3][K4], K6 extends keyof T[K1][K2][K3][K4][K5]>(k1: K1, k2: K2, k3: K3, k4: K4, k5: K5, k6: K6): OperatorFunction<T, T[K1][K2][K3][K4][K5][K6]>;
|
||||
export declare function pluck<T, R>(...properties: string[]): OperatorFunction<T, R>;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"canReportError.js","sources":["../../../src/internal/util/canReportError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAS3C,MAAM,UAAU,cAAc,CAAC,QAAwC;IACrE,OAAO,QAAQ,EAAE;QACT,IAAA,aAAoD,EAAlD,oBAAM,EAAE,4BAAW,EAAE,wBAAS,CAAqB;QAC3D,IAAI,QAAM,IAAI,SAAS,EAAE;YACvB,OAAO,KAAK,CAAC;SACd;aAAM,IAAI,WAAW,IAAI,WAAW,YAAY,UAAU,EAAE;YAC3D,QAAQ,GAAG,WAAW,CAAC;SACxB;aAAM;YACL,QAAQ,GAAG,IAAI,CAAC;SACjB;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
||||
@@ -0,0 +1,29 @@
|
||||
var abort = require('./abort.js')
|
||||
, async = require('./async.js')
|
||||
;
|
||||
|
||||
// API
|
||||
module.exports = terminator;
|
||||
|
||||
/**
|
||||
* Terminates jobs in the attached state context
|
||||
*
|
||||
* @this AsyncKitState#
|
||||
* @param {function} callback - final callback to invoke after termination
|
||||
*/
|
||||
function terminator(callback)
|
||||
{
|
||||
if (!Object.keys(this.jobs).length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// fast forward iteration index
|
||||
this.index = this.size;
|
||||
|
||||
// abort jobs
|
||||
abort(this);
|
||||
|
||||
// send back results we have so far
|
||||
async(callback)(null, this.results);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("rxjs-compat/operator/reduce"));
|
||||
//# sourceMappingURL=reduce.js.map
|
||||
@@ -0,0 +1,10 @@
|
||||
// Blob constructor
|
||||
// http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob
|
||||
|
||||
Modernizr.addTest('blobconstructor', function () {
|
||||
try {
|
||||
return !!new Blob();
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"subscribeToArray.js","sources":["../../src/internal/util/subscribeToArray.ts"],"names":[],"mappings":";;AAMa,QAAA,gBAAgB,GAAG,UAAI,KAAmB,IAAK,OAAA,UAAC,UAAyB;IACpF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtE,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KAC3B;IACD,UAAU,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC,EAL2D,CAK3D,CAAC"}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"2":"C K L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t"},C:{"2":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB DC EC"},D:{"2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC"},E:{"2":"I u J E F G A B C K L H GC zB HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC"},F:{"2":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d OC PC QC RC qB 9B SC rB"},G:{"2":"F zB TC AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B"},H:{"2":"nC"},I:{"2":"tB I D oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"2":"A B C e qB 9B rB"},L:{"2":"D"},M:{"2":"D"},N:{"2":"A B"},O:{"2":"uC"},P:{"2":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"2":"1B"},R:{"2":"8C"},S:{"2":"9C"}},B:6,C:"Temporal"};
|
||||
@@ -0,0 +1 @@
|
||||
export * from 'rxjs-compat/observable/empty';
|
||||
@@ -0,0 +1,12 @@
|
||||
// Method of allowing calculated values for length units, i.e. width: calc(100%-3em) http://caniuse.com/#search=calc
|
||||
// By @calvein
|
||||
|
||||
Modernizr.addTest('csscalc', function() {
|
||||
var prop = 'width:';
|
||||
var value = 'calc(10px);';
|
||||
var el = document.createElement('div');
|
||||
|
||||
el.style.cssText = prop + Modernizr._prefixes.join(value + prop);
|
||||
|
||||
return !!el.style.length;
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Observer.js","sources":["../../src/internal/Observer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,CAAC,MAAM,KAAK,GAAkB;IAClC,MAAM,EAAE,IAAI;IACZ,IAAI,CAAC,KAAU,IAAoB,CAAC;IACpC,KAAK,CAAC,GAAQ;QACZ,IAAI,MAAM,CAAC,qCAAqC,EAAE;YAChD,MAAM,GAAG,CAAC;SACX;aAAM;YACL,eAAe,CAAC,GAAG,CAAC,CAAC;SACtB;IACH,CAAC;IACD,QAAQ,KAAoB,CAAC;CAC9B,CAAC"}
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "is-ci",
|
||||
"version": "3.0.0",
|
||||
"description": "Detect if the current environment is a CI server",
|
||||
"bin": "bin.js",
|
||||
"main": "index.js",
|
||||
"author": "Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/watson/is-ci.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/watson/is-ci/issues"
|
||||
},
|
||||
"homepage": "https://github.com/watson/is-ci",
|
||||
"keywords": [
|
||||
"ci",
|
||||
"continuous",
|
||||
"integration",
|
||||
"test",
|
||||
"detect"
|
||||
],
|
||||
"coordinates": [
|
||||
55.778272,
|
||||
12.593116
|
||||
],
|
||||
"scripts": {
|
||||
"test": "standard && node test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"ci-info": "^3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"clear-module": "^4.1.1",
|
||||
"standard": "^16.0.3"
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,303 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
const globby = require('globby');
|
||||
const mime = require('mime-types');
|
||||
const _ = require('lodash');
|
||||
const retry = require('async-retry');
|
||||
const pkg = require('../../../package.json');
|
||||
const { format, parseVersion, e } = require('../../util');
|
||||
const Release = require('../GitRelease');
|
||||
const prompts = require('./prompts');
|
||||
|
||||
const docs = 'https://git.io/release-it-github';
|
||||
|
||||
const RETRY_CODES = [408, 413, 429, 500, 502, 503, 504, 521, 522, 524];
|
||||
|
||||
const DEFAULT_RETRY_MIN_TIMEOUT = 1000;
|
||||
|
||||
const parseErrormsg = err => {
|
||||
let msg = err;
|
||||
if (err instanceof Error) {
|
||||
const { status, message, headers } = err;
|
||||
msg = `${_.get(headers, 'status', status)} (${message})`;
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
class GitHub extends Release {
|
||||
constructor(...args) {
|
||||
super(...args);
|
||||
this.registerPrompts(prompts);
|
||||
}
|
||||
|
||||
async init() {
|
||||
const { skipChecks, tokenRef, isUpdate } = this.options;
|
||||
|
||||
await super.init();
|
||||
|
||||
if (!skipChecks) {
|
||||
if (!this.token) {
|
||||
throw e(`Environment variable "${tokenRef}" is required for GitHub releases.`, docs);
|
||||
}
|
||||
|
||||
// If we're running on GitHub Actions, we can skip the authentication and
|
||||
// collaborator checks. Ref: https://bit.ly/2vsyRzu
|
||||
if (process.env.GITHUB_ACTIONS) {
|
||||
this.setContext({ username: process.env.GITHUB_ACTOR });
|
||||
} else {
|
||||
if (!(await this.isAuthenticated())) {
|
||||
throw e(`Could not authenticate with GitHub using environment variable "${tokenRef}".`, docs);
|
||||
}
|
||||
|
||||
if (!(await this.isCollaborator())) {
|
||||
const { repository } = this.getContext('repo');
|
||||
const { username } = this.getContext();
|
||||
throw e(`User ${username} is not a collaborator for ${repository}.`, docs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isUpdate) {
|
||||
try {
|
||||
const { id, upload_url } = await this.getLatestRelease();
|
||||
this.setContext({ isUpdate: true, isReleased: true, releaseId: id, upload_url });
|
||||
} catch (error) {
|
||||
const { latestTagName } = this.getContext();
|
||||
this.log.warn(`GitHub release for tag ${latestTagName} was not found. Creating new release.`);
|
||||
this.setContext({ isUpdate: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async isAuthenticated() {
|
||||
if (this.config.isDryRun) return true;
|
||||
try {
|
||||
this.log.verbose('octokit users#getAuthenticated');
|
||||
const { data } = await this.client.users.getAuthenticated();
|
||||
this.setContext({ username: data.login });
|
||||
return true;
|
||||
} catch (error) {
|
||||
this.debug(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async isCollaborator() {
|
||||
if (this.config.isDryRun) return true;
|
||||
const { owner, project: repo } = this.getContext('repo');
|
||||
const { username } = this.getContext();
|
||||
try {
|
||||
const options = { owner, repo, username };
|
||||
this.log.verbose(`octokit repos#checkCollaborator (${username})`);
|
||||
await this.client.repos.checkCollaborator(options);
|
||||
return true;
|
||||
} catch (error) {
|
||||
this.debug(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async release() {
|
||||
const { assets } = this.options;
|
||||
const { isUpdate } = this.getContext();
|
||||
const { isCI } = this.config;
|
||||
|
||||
const type = isUpdate ? 'update' : 'create';
|
||||
const publishMethod = `${type}Release`;
|
||||
|
||||
if (isCI) {
|
||||
await this.step({ task: () => this[publishMethod](), label: `GitHub ${type} release` });
|
||||
return this.step({ enabled: assets, task: () => this.uploadAssets(), label: 'GitHub upload assets' });
|
||||
} else {
|
||||
const release = async () => {
|
||||
await this[publishMethod]();
|
||||
return this.uploadAssets();
|
||||
};
|
||||
return this.step({ task: release, label: `GitHub ${type} release`, prompt: 'release' });
|
||||
}
|
||||
}
|
||||
|
||||
handleError(err, bail) {
|
||||
const message = parseErrormsg(err);
|
||||
const githubError = new Error(message);
|
||||
this.log.verbose(err.errors);
|
||||
this.debug(err);
|
||||
if (!_.includes(RETRY_CODES, err.status)) {
|
||||
return bail(githubError);
|
||||
}
|
||||
throw githubError;
|
||||
}
|
||||
|
||||
get client() {
|
||||
if (this._client) return this._client;
|
||||
const { proxy, timeout } = this.options;
|
||||
const host = this.options.host || this.getContext('repo.host');
|
||||
const isGitHub = host === 'github.com';
|
||||
const baseUrl = `https://${isGitHub ? 'api.github.com' : host}${isGitHub ? '' : '/api/v3'}`;
|
||||
const options = {
|
||||
baseUrl,
|
||||
auth: `token ${this.token}`,
|
||||
userAgent: `release-it/${pkg.version}`,
|
||||
log: this.config.isDebug ? console : null,
|
||||
request: {
|
||||
timeout
|
||||
}
|
||||
};
|
||||
|
||||
if (proxy) {
|
||||
options.proxy = proxy;
|
||||
}
|
||||
|
||||
const client = new Octokit(options);
|
||||
|
||||
this._client = client;
|
||||
return client;
|
||||
}
|
||||
|
||||
async getLatestRelease() {
|
||||
const { owner, project: repo } = this.getContext('repo');
|
||||
try {
|
||||
const options = {
|
||||
owner,
|
||||
repo
|
||||
};
|
||||
this.debug(options);
|
||||
const response = await this.client.repos.listReleases({ owner, repo, per_page: 1, page: 1 });
|
||||
this.debug(response.data[0]);
|
||||
return response.data[0];
|
||||
} catch (err) {
|
||||
return this.handleError(err, () => {});
|
||||
}
|
||||
}
|
||||
|
||||
getOctokitReleaseOptions(options = {}) {
|
||||
const { owner, project: repo } = this.getContext('repo');
|
||||
const { releaseName, draft = false, preRelease = false } = this.options;
|
||||
const { version, tagName, releaseNotes } = this.getContext();
|
||||
const { isPreRelease } = parseVersion(version);
|
||||
const name = format(releaseName, this.config.getContext());
|
||||
const body = releaseNotes;
|
||||
|
||||
return Object.assign(options, {
|
||||
owner,
|
||||
repo,
|
||||
tag_name: tagName,
|
||||
name,
|
||||
body,
|
||||
draft,
|
||||
prerelease: isPreRelease || preRelease
|
||||
});
|
||||
}
|
||||
|
||||
retry(fn) {
|
||||
const { retryMinTimeout } = this.options;
|
||||
return retry(fn, {
|
||||
retries: 2,
|
||||
minTimeout: typeof retryMinTimeout === 'number' ? retryMinTimeout : DEFAULT_RETRY_MIN_TIMEOUT
|
||||
});
|
||||
}
|
||||
|
||||
async createRelease() {
|
||||
const options = this.getOctokitReleaseOptions();
|
||||
const { isDryRun } = this.config;
|
||||
|
||||
this.log.exec(`octokit repos.createRelease "${options.name}" (${options.tag_name})`, { isDryRun });
|
||||
|
||||
if (isDryRun) {
|
||||
this.setContext({ isReleased: true, releaseUrl: this.getReleaseUrlFallback(options.tag_name) });
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.retry(async bail => {
|
||||
try {
|
||||
this.debug(options);
|
||||
const response = await this.client.repos.createRelease(options);
|
||||
this.debug(response.data);
|
||||
const { html_url, upload_url, id } = response.data;
|
||||
this.setContext({ isReleased: true, releaseId: id, releaseUrl: html_url, upload_url });
|
||||
this.log.verbose(`octokit repos.createRelease: done (${response.headers.location})`);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
return this.handleError(err, bail);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
uploadAsset(filePath) {
|
||||
const url = this.getContext('upload_url');
|
||||
const name = path.basename(filePath);
|
||||
const contentType = mime.contentType(name) || 'application/octet-stream';
|
||||
const contentLength = fs.statSync(filePath).size;
|
||||
|
||||
return this.retry(async bail => {
|
||||
try {
|
||||
const options = {
|
||||
url,
|
||||
data: fs.createReadStream(filePath),
|
||||
name,
|
||||
headers: {
|
||||
'content-type': contentType,
|
||||
'content-length': contentLength
|
||||
}
|
||||
};
|
||||
this.debug(options);
|
||||
const response = await this.client.repos.uploadReleaseAsset(options);
|
||||
this.debug(response.data);
|
||||
this.log.verbose(`octokit repos.uploadReleaseAsset: done (${response.data.browser_download_url})`);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
return this.handleError(err, bail);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
uploadAssets() {
|
||||
const { assets } = this.options;
|
||||
const { isReleased } = this.getContext();
|
||||
const { isDryRun } = this.config;
|
||||
|
||||
this.log.exec('octokit repos.uploadReleaseAssets', assets, { isDryRun });
|
||||
|
||||
if (!assets || !isReleased || isDryRun) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return globby(assets).then(files => {
|
||||
if (!files.length) {
|
||||
this.log.warn(`octokit repos.uploadReleaseAssets: did not find "${assets}" relative to ${process.cwd()}`);
|
||||
}
|
||||
return Promise.all(files.map(filePath => this.uploadAsset(filePath)));
|
||||
});
|
||||
}
|
||||
|
||||
getReleaseUrlFallback(tagName) {
|
||||
const { host, repository } = this.getContext('repo');
|
||||
return `https://${host}/${repository}/releases/tag/${tagName}`;
|
||||
}
|
||||
|
||||
updateRelease() {
|
||||
const { isDryRun } = this.config;
|
||||
const release_id = this.getContext('releaseId');
|
||||
const options = this.getOctokitReleaseOptions({ release_id });
|
||||
|
||||
this.log.exec(`octokit repos.updateRelease (${options.tag_name})`, { isDryRun });
|
||||
|
||||
if (isDryRun) return true;
|
||||
|
||||
return this.retry(async bail => {
|
||||
try {
|
||||
this.debug(options);
|
||||
const response = await this.client.repos.updateRelease(options);
|
||||
this.setContext({ releaseUrl: response.data.html_url });
|
||||
this.debug(response.data);
|
||||
this.log.verbose(`octokit repos.updateRelease: done (${response.headers.location})`);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return this.handleError(err, bail);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GitHub;
|
||||
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = unescape;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function unescape(str) {
|
||||
(0, _assertString.default)(str);
|
||||
return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(///g, '/').replace(/\/g, '\\').replace(/`/g, '`');
|
||||
}
|
||||
|
||||
module.exports = exports.default;
|
||||
module.exports.default = exports.default;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mergeMapTo.js","sources":["../../../src/internal/operators/mergeMapTo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAiDtC,MAAM,UAAU,UAAU,CACxB,eAAkB,EAClB,cAAwH,EACxH,UAA6C;IAA7C,2BAAA,EAAA,aAAqB,MAAM,CAAC,iBAAiB;IAE7C,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE;QACxC,OAAO,QAAQ,CAAC,cAAM,OAAA,eAAe,EAAf,CAAe,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;KACpE;IACD,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;QACtC,UAAU,GAAG,cAAc,CAAC;KAC7B;IACD,OAAO,QAAQ,CAAC,cAAM,OAAA,eAAe,EAAf,CAAe,EAAE,UAAU,CAAC,CAAC;AACrD,CAAC"}
|
||||
Reference in New Issue
Block a user