mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 09:20:31 +00:00
commit
4505d892f8
86 changed files with 3451 additions and 3318 deletions
16
.editorconfig
Normal file
16
.editorconfig
Normal file
|
@ -0,0 +1,16 @@
|
|||
root = true
|
||||
|
||||
[*.js]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.go]
|
||||
indent_style = tab
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
end_of_line = lf
|
|
@ -1,37 +1,32 @@
|
|||
module.exports = {
|
||||
"extends": [
|
||||
extends: [
|
||||
"standard",
|
||||
"plugin:jest/recommended",
|
||||
"plugin:react/recommended",
|
||||
"prettier",
|
||||
"prettier/react"
|
||||
],
|
||||
"plugins": [
|
||||
"react",
|
||||
"jest",
|
||||
"prettier"
|
||||
],
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2016,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
plugins: ["react", "jest", "prettier"],
|
||||
parser: "babel-eslint",
|
||||
parserOptions: {
|
||||
ecmaVersion: 2016,
|
||||
sourceType: "module",
|
||||
ecmaFeatures: {
|
||||
jsx: true
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"es6": true,
|
||||
"browser": true,
|
||||
"node": true,
|
||||
env: {
|
||||
es6: true,
|
||||
browser: true,
|
||||
node: true,
|
||||
"jest/globals": true
|
||||
},
|
||||
"rules": {
|
||||
rules: {
|
||||
"react/prop-types": 1,
|
||||
"prettier/prettier": [
|
||||
"error",
|
||||
{
|
||||
"trailingComma": "all",
|
||||
"useTabs": true
|
||||
trailingComma: "all",
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -140,11 +140,8 @@ export default class Default extends Component {
|
|||
exact={true}
|
||||
component={UserReposMenu}
|
||||
/>
|
||||
<Route
|
||||
path="/account/"
|
||||
exact={false}
|
||||
component={undefined}
|
||||
/>BuildMenu
|
||||
<Route path="/account/" exact={false} component={undefined} />
|
||||
BuildMenu
|
||||
<Route
|
||||
path="/:owner/:repo/:build(\d*)/:proc(\d*)"
|
||||
exact={true}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { displayMessage } from "./message";
|
||||
|
||||
/**
|
||||
* Generates a personal access token and stores the results in
|
||||
* the state tree.
|
||||
* Generates a personal access token and stores the results in
|
||||
* the state tree.
|
||||
*
|
||||
* @param {Object} tree - The drone state tree.
|
||||
* @param {Object} client - The drone client.
|
||||
|
|
267
web/vendor/drone-js/index.js
vendored
267
web/vendor/drone-js/index.js
vendored
|
@ -1,4 +1,4 @@
|
|||
(function (global, factory) {
|
||||
(function(global, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(["exports"], factory);
|
||||
} else if (typeof exports !== "undefined") {
|
||||
|
@ -10,7 +10,7 @@
|
|||
factory(mod.exports);
|
||||
global.index = mod.exports;
|
||||
}
|
||||
})(this, function (exports) {
|
||||
})(this, function(exports) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
|
@ -23,7 +23,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
var _createClass = function () {
|
||||
var _createClass = (function() {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
|
@ -34,14 +34,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
return function(Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
})();
|
||||
|
||||
var DroneClient = function () {
|
||||
var DroneClient = (function() {
|
||||
function DroneClient(server, token, csrf) {
|
||||
_classCallCheck(this, DroneClient);
|
||||
|
||||
|
@ -50,160 +50,260 @@
|
|||
this.csrf = csrf;
|
||||
}
|
||||
|
||||
_createClass(DroneClient, [{
|
||||
_createClass(
|
||||
DroneClient,
|
||||
[
|
||||
{
|
||||
key: "getRepoList",
|
||||
value: function getRepoList(opts) {
|
||||
var query = encodeQueryString(opts);
|
||||
return this._get("/api/user/repos?" + query);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getRepo",
|
||||
value: function getRepo(owner, repo) {
|
||||
return this._get("/api/repos/" + owner + "/" + repo);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "activateRepo",
|
||||
value: function activateRepo(owner, repo) {
|
||||
return this._post("/api/repos/" + owner + "/" + repo);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "updateRepo",
|
||||
value: function updateRepo(owner, repo, data) {
|
||||
return this._patch("/api/repos/" + owner + "/" + repo, data);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "deleteRepo",
|
||||
value: function deleteRepo(owner, repo) {
|
||||
return this._delete("/api/repos/" + owner + "/" + repo);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getBuildList",
|
||||
value: function getBuildList(owner, repo, opts) {
|
||||
var query = encodeQueryString(opts);
|
||||
return this._get("/api/repos/" + owner + "/" + repo + "/builds?" + query);
|
||||
return this._get(
|
||||
"/api/repos/" + owner + "/" + repo + "/builds?" + query
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getBuild",
|
||||
value: function getBuild(owner, repo, number) {
|
||||
return this._get("/api/repos/" + owner + "/" + repo + "/builds/" + number);
|
||||
return this._get(
|
||||
"/api/repos/" + owner + "/" + repo + "/builds/" + number
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getBuildFeed",
|
||||
value: function getBuildFeed(opts) {
|
||||
var query = encodeQueryString(opts);
|
||||
return this._get("/api/user/feed?" + query);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "cancelBuild",
|
||||
value: function cancelBuild(owner, repo, number, ppid) {
|
||||
return this._delete("/api/repos/" + owner + "/" + repo + "/builds/" + number + "/" + ppid);
|
||||
return this._delete(
|
||||
"/api/repos/" +
|
||||
owner +
|
||||
"/" +
|
||||
repo +
|
||||
"/builds/" +
|
||||
number +
|
||||
"/" +
|
||||
ppid
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "approveBuild",
|
||||
value: function approveBuild(owner, repo, build) {
|
||||
return this._post("/api/repos/" + owner + "/" + repo + "/builds/" + build + "/approve");
|
||||
return this._post(
|
||||
"/api/repos/" +
|
||||
owner +
|
||||
"/" +
|
||||
repo +
|
||||
"/builds/" +
|
||||
build +
|
||||
"/approve"
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "declineBuild",
|
||||
value: function declineBuild(owner, repo, build) {
|
||||
return this._post("/api/repos/" + owner + "/" + repo + "/builds/" + build + "/decline");
|
||||
return this._post(
|
||||
"/api/repos/" +
|
||||
owner +
|
||||
"/" +
|
||||
repo +
|
||||
"/builds/" +
|
||||
build +
|
||||
"/decline"
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "restartBuild",
|
||||
value: function restartBuild(owner, repo, build, opts) {
|
||||
var query = encodeQueryString(opts);
|
||||
return this._post("/api/repos/" + owner + "/" + repo + "/builds/" + build + "?" + query);
|
||||
return this._post(
|
||||
"/api/repos/" +
|
||||
owner +
|
||||
"/" +
|
||||
repo +
|
||||
"/builds/" +
|
||||
build +
|
||||
"?" +
|
||||
query
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getLogs",
|
||||
value: function getLogs(owner, repo, build, proc) {
|
||||
return this._get("/api/repos/" + owner + "/" + repo + "/logs/" + build + "/" + proc);
|
||||
return this._get(
|
||||
"/api/repos/" + owner + "/" + repo + "/logs/" + build + "/" + proc
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getArtifact",
|
||||
value: function getArtifact(owner, repo, build, proc, file) {
|
||||
return this._get("/api/repos/" + owner + "/" + repo + "/files/" + build + "/" + proc + "/" + file + "?raw=true");
|
||||
return this._get(
|
||||
"/api/repos/" +
|
||||
owner +
|
||||
"/" +
|
||||
repo +
|
||||
"/files/" +
|
||||
build +
|
||||
"/" +
|
||||
proc +
|
||||
"/" +
|
||||
file +
|
||||
"?raw=true"
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getArtifactList",
|
||||
value: function getArtifactList(owner, repo, build) {
|
||||
return this._get("/api/repos/" + owner + "/" + repo + "/files/" + build);
|
||||
return this._get(
|
||||
"/api/repos/" + owner + "/" + repo + "/files/" + build
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getSecretList",
|
||||
value: function getSecretList(owner, repo) {
|
||||
return this._get("/api/repos/" + owner + "/" + repo + "/secrets");
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "createSecret",
|
||||
value: function createSecret(owner, repo, secret) {
|
||||
return this._post("/api/repos/" + owner + "/" + repo + "/secrets", secret);
|
||||
return this._post(
|
||||
"/api/repos/" + owner + "/" + repo + "/secrets",
|
||||
secret
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "deleteSecret",
|
||||
value: function deleteSecret(owner, repo, secret) {
|
||||
return this._delete("/api/repos/" + owner + "/" + repo + "/secrets/" + secret);
|
||||
return this._delete(
|
||||
"/api/repos/" + owner + "/" + repo + "/secrets/" + secret
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getRegistryList",
|
||||
value: function getRegistryList(owner, repo) {
|
||||
return this._get("/api/repos/" + owner + "/" + repo + "/registry");
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "createRegistry",
|
||||
value: function createRegistry(owner, repo, registry) {
|
||||
return this._post("/api/repos/" + owner + "/" + repo + "/registry", registry);
|
||||
return this._post(
|
||||
"/api/repos/" + owner + "/" + repo + "/registry",
|
||||
registry
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "deleteRegistry",
|
||||
value: function deleteRegistry(owner, repo, address) {
|
||||
return this._delete("/api/repos/" + owner + "/" + repo + "/registry/" + address);
|
||||
return this._delete(
|
||||
"/api/repos/" + owner + "/" + repo + "/registry/" + address
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getSelf",
|
||||
value: function getSelf() {
|
||||
return this._get("/api/user");
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "getToken",
|
||||
value: function getToken() {
|
||||
return this._post("/api/user/token");
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "on",
|
||||
value: function on(callback) {
|
||||
return this._subscribe("/stream/events", callback, {
|
||||
reconnect: true
|
||||
});
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "stream",
|
||||
value: function stream(owner, repo, build, proc, callback) {
|
||||
return this._subscribe("/stream/logs/" + owner + "/" + repo + "/" + build + "/" + proc, callback, {
|
||||
return this._subscribe(
|
||||
"/stream/logs/" + owner + "/" + repo + "/" + build + "/" + proc,
|
||||
callback,
|
||||
{
|
||||
reconnect: false
|
||||
});
|
||||
}
|
||||
}, {
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
key: "_get",
|
||||
value: function _get(path) {
|
||||
return this._request("GET", path, null);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "_post",
|
||||
value: function _post(path, data) {
|
||||
return this._request("POST", path, data);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "_patch",
|
||||
value: function _patch(path, data) {
|
||||
return this._request("PATCH", path, data);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "_delete",
|
||||
value: function _delete(path) {
|
||||
return this._request("DELETE", path, null);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "_subscribe",
|
||||
value: function _subscribe(path, callback, opts) {
|
||||
var query = encodeQueryString({
|
||||
|
@ -213,12 +313,12 @@
|
|||
path = this.token ? path + "?" + query : path;
|
||||
|
||||
var events = new EventSource(path);
|
||||
events.onmessage = function (event) {
|
||||
events.onmessage = function(event) {
|
||||
var data = JSON.parse(event.data);
|
||||
callback(data);
|
||||
};
|
||||
if (!opts.reconnect) {
|
||||
events.onerror = function (err) {
|
||||
events.onerror = function(err) {
|
||||
if (err.data === "eof") {
|
||||
events.close();
|
||||
}
|
||||
|
@ -226,7 +326,8 @@
|
|||
}
|
||||
return events;
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "_request",
|
||||
value: function _request(method, path, data) {
|
||||
var endpoint = [this.server, path].join("");
|
||||
|
@ -238,8 +339,9 @@
|
|||
if (method !== "GET" && this.csrf) {
|
||||
xhr.setRequestHeader("X-CSRF-TOKEN", this.csrf);
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
xhr.onload = function () {
|
||||
return new Promise(
|
||||
function(resolve, reject) {
|
||||
xhr.onload = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status >= 300) {
|
||||
var error = {
|
||||
|
@ -253,14 +355,17 @@
|
|||
return;
|
||||
}
|
||||
var contentType = xhr.getResponseHeader("Content-Type");
|
||||
if (contentType && contentType.startsWith("application/json")) {
|
||||
if (
|
||||
contentType &&
|
||||
contentType.startsWith("application/json")
|
||||
) {
|
||||
resolve(JSON.parse(xhr.response));
|
||||
} else {
|
||||
resolve(xhr.response);
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
xhr.onerror = function (e) {
|
||||
xhr.onerror = function(e) {
|
||||
reject(e);
|
||||
};
|
||||
if (data) {
|
||||
|
@ -269,38 +374,58 @@
|
|||
} else {
|
||||
xhr.send();
|
||||
}
|
||||
}.bind(this));
|
||||
}.bind(this)
|
||||
);
|
||||
}
|
||||
}], [{
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
key: "fromEnviron",
|
||||
value: function fromEnviron() {
|
||||
return new DroneClient(process && process.env && process.env.DRONE_SERVER, process && process.env && process.env.DRONE_TOKEN, process && process.env && process.env.DRONE_CSRF);
|
||||
return new DroneClient(
|
||||
process && process.env && process.env.DRONE_SERVER,
|
||||
process && process.env && process.env.DRONE_TOKEN,
|
||||
process && process.env && process.env.DRONE_CSRF
|
||||
);
|
||||
}
|
||||
}, {
|
||||
},
|
||||
{
|
||||
key: "fromWindow",
|
||||
value: function fromWindow() {
|
||||
return new DroneClient(window && window.DRONE_SERVER, window && window.DRONE_TOKEN, window && window.DRONE_CSRF);
|
||||
return new DroneClient(
|
||||
window && window.DRONE_SERVER,
|
||||
window && window.DRONE_TOKEN,
|
||||
window && window.DRONE_CSRF
|
||||
);
|
||||
}
|
||||
}]);
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
return DroneClient;
|
||||
}();
|
||||
})();
|
||||
|
||||
exports.default = DroneClient;
|
||||
|
||||
|
||||
/**
|
||||
* Encodes the values into url encoded form sorted by key.
|
||||
*
|
||||
* @param {object} query parameters in key value object.
|
||||
* @return {string} query parameter string
|
||||
*/
|
||||
var encodeQueryString = exports.encodeQueryString = function encodeQueryString() {
|
||||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var encodeQueryString = (exports.encodeQueryString = function encodeQueryString() {
|
||||
var params =
|
||||
arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
return params ? Object.keys(params).sort().map(function (key) {
|
||||
return params
|
||||
? Object.keys(params)
|
||||
.sort()
|
||||
.map(function(key) {
|
||||
var val = params[key];
|
||||
return encodeURIComponent(key) + "=" + encodeURIComponent(val);
|
||||
}).join("&") : "";
|
||||
};
|
||||
})
|
||||
.join("&")
|
||||
: "";
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue