Merge pull request #107 from laszlocph/editorconfig

Editorconfig
This commit is contained in:
Laszlo Fogas 2019-11-15 14:47:52 +01:00 committed by GitHub
commit 4505d892f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
86 changed files with 3451 additions and 3318 deletions

16
.editorconfig Normal file
View 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

View file

@ -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",
}
]
}

View file

@ -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}

View file

@ -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.

View file

@ -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("&")
: "";
});
});