mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: MEGA - Make Eslint Great Again 💅 (#26094)
* Fix lint error in types.ts * Bump eslint and its deps to latest * Add eslintignore and remove not needed eslintrcs * Change webpack configs eslint config * Update package.jsons and removed unused eslintrc files * Chore yarn lint --fix 💅 * Add devenv to eslintignore * Remove eslint disable comments for rules that are not used * Remaining eslint fixes 💅 * Bump grafana/eslint-config 💥 * Modify package.json No need for duplicate checks. * Modify eslintignore to ignore data and dist folders * Revert removing .eslintrc to make sure not to use certain packages * Modify package.json to remove not needed command * Use gitignore for ignoring paths
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"extends": ["@grafana/eslint-config"],
|
||||
"rules": {
|
||||
"no-restricted-imports": [2, "^@grafana/runtime.*"]
|
||||
"no-restricted-imports": ["error", { "patterns": ["@grafana/runtime"] }]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,121 +1,153 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var getPluginId_1 = require("../../config/utils/getPluginId");
|
||||
var pluginValidation_1 = require("../../config/utils/pluginValidation");
|
||||
var env_1 = require("../../plugins/env");
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
'use strict';
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
var tslib_1 = require('tslib');
|
||||
var getPluginId_1 = require('../../config/utils/getPluginId');
|
||||
var pluginValidation_1 = require('../../config/utils/pluginValidation');
|
||||
var env_1 = require('../../plugins/env');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
// @ts-ignore
|
||||
// import execa = require('execa');
|
||||
var githubClient_1 = tslib_1.__importDefault(require("./githubClient"));
|
||||
var resolveContentType = function (extension) {
|
||||
if (extension.startsWith('.')) {
|
||||
extension = extension.substr(1);
|
||||
}
|
||||
switch (extension) {
|
||||
case 'zip':
|
||||
return 'application/zip';
|
||||
case 'json':
|
||||
return 'application/json';
|
||||
case 'sha1':
|
||||
return 'text/plain';
|
||||
default:
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
var githubClient_1 = tslib_1.__importDefault(require('./githubClient'));
|
||||
var resolveContentType = function(extension) {
|
||||
if (extension.startsWith('.')) {
|
||||
extension = extension.substr(1);
|
||||
}
|
||||
switch (extension) {
|
||||
case 'zip':
|
||||
return 'application/zip';
|
||||
case 'json':
|
||||
return 'application/json';
|
||||
case 'sha1':
|
||||
return 'text/plain';
|
||||
default:
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
};
|
||||
var GitHubRelease = /** @class */ (function () {
|
||||
function GitHubRelease(token, username, repository, releaseNotes, commitHash) {
|
||||
this.token = token;
|
||||
this.username = username;
|
||||
this.repository = repository;
|
||||
this.releaseNotes = releaseNotes;
|
||||
this.commitHash = commitHash;
|
||||
this.git = new githubClient_1.default({
|
||||
required: true,
|
||||
repo: repository,
|
||||
var GitHubRelease = /** @class */ (function() {
|
||||
function GitHubRelease(token, username, repository, releaseNotes, commitHash) {
|
||||
this.token = token;
|
||||
this.username = username;
|
||||
this.repository = repository;
|
||||
this.releaseNotes = releaseNotes;
|
||||
this.commitHash = commitHash;
|
||||
this.git = new githubClient_1.default({
|
||||
required: true,
|
||||
repo: repository,
|
||||
});
|
||||
}
|
||||
GitHubRelease.prototype.publishAssets = function(srcLocation, destUrl) {
|
||||
var _this = this;
|
||||
// Add the assets. Loop through files in the ci/dist folder and upload each asset.
|
||||
var files = fs.readdirSync(srcLocation);
|
||||
return files.map(function(file) {
|
||||
return tslib_1.__awaiter(_this, void 0, void 0, function() {
|
||||
var fileStat, fileData;
|
||||
return tslib_1.__generator(this, function(_a) {
|
||||
fileStat = fs.statSync(srcLocation + '/' + file);
|
||||
fileData = fs.readFileSync(srcLocation + '/' + file);
|
||||
return [
|
||||
2 /*return*/,
|
||||
this.git.client.post(destUrl + '?name=' + file, fileData, {
|
||||
headers: {
|
||||
'Content-Type': resolveContentType(path.extname(file)),
|
||||
'Content-Length': fileStat.size,
|
||||
},
|
||||
maxContentLength: fileStat.size * 2 * 1024 * 1024,
|
||||
}),
|
||||
];
|
||||
});
|
||||
}
|
||||
GitHubRelease.prototype.publishAssets = function (srcLocation, destUrl) {
|
||||
var _this = this;
|
||||
// Add the assets. Loop through files in the ci/dist folder and upload each asset.
|
||||
var files = fs.readdirSync(srcLocation);
|
||||
return files.map(function (file) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||
var fileStat, fileData;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
fileStat = fs.statSync(srcLocation + "/" + file);
|
||||
fileData = fs.readFileSync(srcLocation + "/" + file);
|
||||
return [2 /*return*/, this.git.client.post(destUrl + "?name=" + file, fileData, {
|
||||
headers: {
|
||||
'Content-Type': resolveContentType(path.extname(file)),
|
||||
'Content-Length': fileStat.size,
|
||||
},
|
||||
maxContentLength: fileStat.size * 2 * 1024 * 1024,
|
||||
})];
|
||||
});
|
||||
}); });
|
||||
};
|
||||
GitHubRelease.prototype.release = function () {
|
||||
var _a, _b, _c, _d;
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var ciDir, distDir, distContentDir, pluginJsonFile, pluginInfo, PUBLISH_DIR, commitHash, latestRelease, reason_1, newReleaseResponse, publishPromises, reason_2;
|
||||
return tslib_1.__generator(this, function (_e) {
|
||||
switch (_e.label) {
|
||||
case 0:
|
||||
ciDir = env_1.getCiFolder();
|
||||
distDir = path.resolve(ciDir, 'dist');
|
||||
distContentDir = path.resolve(distDir, getPluginId_1.getPluginId());
|
||||
pluginJsonFile = path.resolve(distContentDir, 'plugin.json');
|
||||
pluginInfo = pluginValidation_1.getPluginJson(pluginJsonFile).info;
|
||||
PUBLISH_DIR = path.resolve(env_1.getCiFolder(), 'packages');
|
||||
commitHash = this.commitHash || ((_a = pluginInfo.build) === null || _a === void 0 ? void 0 : _a.hash);
|
||||
_e.label = 1;
|
||||
case 1:
|
||||
_e.trys.push([1, 5, , 6]);
|
||||
return [4 /*yield*/, this.git.client.get("releases/tags/v" + pluginInfo.version)];
|
||||
case 2:
|
||||
latestRelease = _e.sent();
|
||||
if (!(latestRelease.data.tag_name === "v" + pluginInfo.version)) return [3 /*break*/, 4];
|
||||
return [4 /*yield*/, this.git.client.delete("releases/" + latestRelease.data.id)];
|
||||
case 3:
|
||||
_e.sent();
|
||||
_e.label = 4;
|
||||
case 4: return [3 /*break*/, 6];
|
||||
case 5:
|
||||
reason_1 = _e.sent();
|
||||
if (reason_1.response.status !== 404) {
|
||||
// 404 just means no release found. Not an error. Anything else though, re throw the error
|
||||
throw reason_1;
|
||||
}
|
||||
return [3 /*break*/, 6];
|
||||
case 6:
|
||||
_e.trys.push([6, 9, , 10]);
|
||||
return [4 /*yield*/, this.git.client.post('releases', {
|
||||
tag_name: "v" + pluginInfo.version,
|
||||
target_commitish: commitHash,
|
||||
name: "v" + pluginInfo.version,
|
||||
body: this.releaseNotes,
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
})];
|
||||
case 7:
|
||||
newReleaseResponse = _e.sent();
|
||||
publishPromises = this.publishAssets(PUBLISH_DIR, "https://uploads.github.com/repos/" + this.username + "/" + this.repository + "/releases/" + newReleaseResponse.data.id + "/assets");
|
||||
return [4 /*yield*/, Promise.all(publishPromises)];
|
||||
case 8:
|
||||
_e.sent();
|
||||
return [3 /*break*/, 10];
|
||||
case 9:
|
||||
reason_2 = _e.sent();
|
||||
console.log(reason_2);
|
||||
// Rethrow the error so that we can trigger a non-zero exit code to circle-ci
|
||||
throw reason_2;
|
||||
case 10: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return GitHubRelease;
|
||||
}());
|
||||
});
|
||||
});
|
||||
};
|
||||
GitHubRelease.prototype.release = function() {
|
||||
var _a, _b, _c, _d;
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
||||
var ciDir,
|
||||
distDir,
|
||||
distContentDir,
|
||||
pluginJsonFile,
|
||||
pluginInfo,
|
||||
PUBLISH_DIR,
|
||||
commitHash,
|
||||
latestRelease,
|
||||
reason_1,
|
||||
newReleaseResponse,
|
||||
publishPromises,
|
||||
reason_2;
|
||||
return tslib_1.__generator(this, function(_e) {
|
||||
switch (_e.label) {
|
||||
case 0:
|
||||
ciDir = env_1.getCiFolder();
|
||||
distDir = path.resolve(ciDir, 'dist');
|
||||
distContentDir = path.resolve(distDir, getPluginId_1.getPluginId());
|
||||
pluginJsonFile = path.resolve(distContentDir, 'plugin.json');
|
||||
pluginInfo = pluginValidation_1.getPluginJson(pluginJsonFile).info;
|
||||
PUBLISH_DIR = path.resolve(env_1.getCiFolder(), 'packages');
|
||||
commitHash = this.commitHash || ((_a = pluginInfo.build) === null || _a === void 0 ? void 0 : _a.hash);
|
||||
_e.label = 1;
|
||||
case 1:
|
||||
_e.trys.push([1, 5, , 6]);
|
||||
return [4 /*yield*/, this.git.client.get('releases/tags/v' + pluginInfo.version)];
|
||||
case 2:
|
||||
latestRelease = _e.sent();
|
||||
if (!(latestRelease.data.tag_name === 'v' + pluginInfo.version)) {
|
||||
return [3 /*break*/, 4];
|
||||
}
|
||||
return [4 /*yield*/, this.git.client.delete('releases/' + latestRelease.data.id)];
|
||||
case 3:
|
||||
_e.sent();
|
||||
_e.label = 4;
|
||||
case 4:
|
||||
return [3 /*break*/, 6];
|
||||
case 5:
|
||||
reason_1 = _e.sent();
|
||||
if (reason_1.response.status !== 404) {
|
||||
// 404 just means no release found. Not an error. Anything else though, re throw the error
|
||||
throw reason_1;
|
||||
}
|
||||
return [3 /*break*/, 6];
|
||||
case 6:
|
||||
_e.trys.push([6, 9, , 10]);
|
||||
return [
|
||||
4 /*yield*/,
|
||||
this.git.client.post('releases', {
|
||||
tag_name: 'v' + pluginInfo.version,
|
||||
target_commitish: commitHash,
|
||||
name: 'v' + pluginInfo.version,
|
||||
body: this.releaseNotes,
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
}),
|
||||
];
|
||||
case 7:
|
||||
newReleaseResponse = _e.sent();
|
||||
publishPromises = this.publishAssets(
|
||||
PUBLISH_DIR,
|
||||
'https://uploads.github.com/repos/' +
|
||||
this.username +
|
||||
'/' +
|
||||
this.repository +
|
||||
'/releases/' +
|
||||
newReleaseResponse.data.id +
|
||||
'/assets'
|
||||
);
|
||||
return [4 /*yield*/, Promise.all(publishPromises)];
|
||||
case 8:
|
||||
_e.sent();
|
||||
return [3 /*break*/, 10];
|
||||
case 9:
|
||||
reason_2 = _e.sent();
|
||||
console.log(reason_2);
|
||||
// Rethrow the error so that we can trigger a non-zero exit code to circle-ci
|
||||
throw reason_2;
|
||||
case 10:
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return GitHubRelease;
|
||||
})();
|
||||
exports.GitHubRelease = GitHubRelease;
|
||||
//# sourceMappingURL=githubRelease.js.map7027e10521e9
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
"scripts": {
|
||||
"build": "grafana-toolkit toolkit:build",
|
||||
"clean": "rimraf ./dist ./compiled",
|
||||
"lint": "eslint src/ --ext=.js,.ts,.tsx",
|
||||
"precommit": "npm run lint & npm run typecheck",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
@@ -30,7 +29,7 @@
|
||||
"@babel/core": "7.9.0",
|
||||
"@babel/preset-env": "7.9.0",
|
||||
"@grafana/data": "next",
|
||||
"@grafana/eslint-config": "^1.0.0-rc1",
|
||||
"@grafana/eslint-config": "2.0.0",
|
||||
"@grafana/tsconfig": "^1.0.0-rc1",
|
||||
"@grafana/ui": "next",
|
||||
"@types/command-exists": "^1.2.0",
|
||||
@@ -48,8 +47,8 @@
|
||||
"@types/semver": "^6.0.0",
|
||||
"@types/tmp": "^0.1.0",
|
||||
"@types/webpack": "4.41.7",
|
||||
"@typescript-eslint/eslint-plugin": "2.24.0",
|
||||
"@typescript-eslint/parser": "2.24.0",
|
||||
"@typescript-eslint/eslint-plugin": "3.6.0",
|
||||
"@typescript-eslint/parser": "3.6.0",
|
||||
"axios": "0.19.2",
|
||||
"babel-jest": "24.8.0",
|
||||
"babel-loader": "8.1.0",
|
||||
@@ -60,10 +59,11 @@
|
||||
"concurrently": "4.1.0",
|
||||
"copy-webpack-plugin": "5.1.1",
|
||||
"css-loader": "^3.0.0",
|
||||
"eslint": "6.8.0",
|
||||
"eslint-config-prettier": "6.10.0",
|
||||
"eslint-plugin-jsdoc": "22.1.0",
|
||||
"eslint-plugin-prettier": "3.1.2",
|
||||
"eslint": "7.4.0",
|
||||
"eslint-config-prettier": "6.11.0",
|
||||
"eslint-plugin-jsdoc": "28.6.1",
|
||||
"eslint-plugin-prettier": "3.1.4",
|
||||
"eslint-plugin-react-hooks": "4.0.5",
|
||||
"execa": "^1.0.0",
|
||||
"expect-puppeteer": "4.1.1",
|
||||
"file-loader": "^4.0.0",
|
||||
|
||||
Reference in New Issue
Block a user