mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Grunt: Removes grunt dependency and replaces some of its usage (#29461)
* Grunt: Removes grunt dependency and replaces some of it usage with alternatives * Removed precommit toolkit task * Fixed toolkit import * Some cleanup of unused / not working stuff in build.go * Removed sass errors
This commit is contained in:
parent
754aca25c5
commit
dc93749287
@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"extends": ["@grafana/eslint-config"],
|
"extends": ["@grafana/eslint-config"],
|
||||||
"root": true,
|
"root": true,
|
||||||
|
"plugins": [
|
||||||
|
"no-only-tests"
|
||||||
|
],
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
{
|
||||||
"files": [
|
"files": [
|
||||||
@ -18,7 +21,8 @@
|
|||||||
"react/no-unknown-property": "off",
|
"react/no-unknown-property": "off",
|
||||||
"react/no-children-prop": "off",
|
"react/no-children-prop": "off",
|
||||||
"react/no-find-dom-node": "off",
|
"react/no-find-dom-node": "off",
|
||||||
"react/no-render-return-value": "off"
|
"react/no-render-return-value": "off",
|
||||||
|
"no-only-tests/no-only-tests": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
66
Gruntfile.js
66
Gruntfile.js
@ -1,66 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
module.exports = function(grunt) {
|
|
||||||
var os = require('os');
|
|
||||||
var config = {
|
|
||||||
pkg: grunt.file.readJSON('package.json'),
|
|
||||||
baseDir: '.',
|
|
||||||
srcDir: 'public',
|
|
||||||
genDir: 'public_gen',
|
|
||||||
destDir: 'dist',
|
|
||||||
tempDir: 'tmp',
|
|
||||||
platform: process.platform.replace('win32', 'windows'),
|
|
||||||
enterprise: false,
|
|
||||||
libc: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (grunt.option('platform')) {
|
|
||||||
config.platform = grunt.option('platform');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grunt.option('enterprise')) {
|
|
||||||
config.enterprise = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grunt.option('arch')) {
|
|
||||||
config.arch = grunt.option('arch');
|
|
||||||
} else {
|
|
||||||
config.arch = os.arch();
|
|
||||||
|
|
||||||
if (process.platform.match(/^win/)) {
|
|
||||||
config.arch = process.env.hasOwnProperty('ProgramFiles(x86)') ? 'x64' : 'x86';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (grunt.option('libc')) {
|
|
||||||
config.libc = grunt.option('libc');
|
|
||||||
}
|
|
||||||
|
|
||||||
config.pkg.version = grunt.option('pkgVer') || config.pkg.version;
|
|
||||||
|
|
||||||
console.log('Version', config.pkg.version);
|
|
||||||
|
|
||||||
// load plugins
|
|
||||||
require('load-grunt-tasks')(grunt);
|
|
||||||
|
|
||||||
// load task definitions
|
|
||||||
grunt.loadTasks('./scripts/grunt');
|
|
||||||
|
|
||||||
// Utility function to load plugin settings into config
|
|
||||||
function loadConfig(config, path) {
|
|
||||||
require('glob')
|
|
||||||
.sync('*', { cwd: path })
|
|
||||||
.forEach(function(option) {
|
|
||||||
var key = option.replace(/\.js$/, '');
|
|
||||||
// If key already exists, extend it. It is your responsibility to avoid naming collisions
|
|
||||||
config[key] = config[key] || {};
|
|
||||||
grunt.util._.extend(config[key], require(path + option)(config, grunt));
|
|
||||||
});
|
|
||||||
// technically not required
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge that object with what with whatever we have here
|
|
||||||
loadConfig(config, './scripts/grunt/options/');
|
|
||||||
// pass the config to grunt
|
|
||||||
grunt.initConfig(config);
|
|
||||||
};
|
|
259
build.go
259
build.go
@ -30,13 +30,13 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
//versionRe = regexp.MustCompile(`-[0-9]{1,3}-g[0-9a-f]{5,10}`)
|
//versionRe = regexp.MustCompile(`-[0-9]{1,3}-g[0-9a-f]{5,10}`)
|
||||||
goarch string
|
goarch string
|
||||||
goos string
|
goos string
|
||||||
gocc string
|
gocc string
|
||||||
cgo bool
|
cgo bool
|
||||||
libc string
|
libc string
|
||||||
pkgArch string
|
pkgArch string
|
||||||
version string = "v1"
|
version string = "v1"
|
||||||
buildTags []string
|
buildTags []string
|
||||||
// deb & rpm does not support semver so have to handle their version a little differently
|
// deb & rpm does not support semver so have to handle their version a little differently
|
||||||
linuxPackageVersion string = "v1"
|
linuxPackageVersion string = "v1"
|
||||||
@ -125,34 +125,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "build-frontend":
|
case "build-frontend":
|
||||||
grunt(gruntBuildArg("build")...)
|
yarn("build")
|
||||||
|
|
||||||
case "test":
|
|
||||||
test("./pkg/...")
|
|
||||||
grunt("test")
|
|
||||||
|
|
||||||
case "package":
|
|
||||||
grunt(gruntBuildArg("build")...)
|
|
||||||
grunt(gruntBuildArg("package")...)
|
|
||||||
if goos == linux {
|
|
||||||
createLinuxPackages()
|
|
||||||
}
|
|
||||||
|
|
||||||
case "package-only":
|
|
||||||
grunt(gruntBuildArg("package")...)
|
|
||||||
if goos == linux {
|
|
||||||
createLinuxPackages()
|
|
||||||
}
|
|
||||||
case "pkg-archive":
|
|
||||||
grunt(gruntBuildArg("package")...)
|
|
||||||
|
|
||||||
case "pkg-rpm":
|
|
||||||
grunt(gruntBuildArg("release")...)
|
|
||||||
createRpmPackages()
|
|
||||||
|
|
||||||
case "pkg-deb":
|
|
||||||
grunt(gruntBuildArg("release")...)
|
|
||||||
createDebPackages()
|
|
||||||
|
|
||||||
case "sha-dist":
|
case "sha-dist":
|
||||||
shaFilesInDist()
|
shaFilesInDist()
|
||||||
@ -233,202 +206,8 @@ func readVersionFromPackageJson() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type linuxPackageOptions struct {
|
func yarn(params ...string) {
|
||||||
packageType string
|
runPrint(`yarn run`, params...)
|
||||||
packageArch string
|
|
||||||
homeDir string
|
|
||||||
homeBinDir string
|
|
||||||
binPath string
|
|
||||||
serverBinPath string
|
|
||||||
cliBinPath string
|
|
||||||
configDir string
|
|
||||||
ldapFilePath string
|
|
||||||
etcDefaultPath string
|
|
||||||
etcDefaultFilePath string
|
|
||||||
initdScriptFilePath string
|
|
||||||
systemdServiceFilePath string
|
|
||||||
|
|
||||||
postinstSrc string
|
|
||||||
initdScriptSrc string
|
|
||||||
defaultFileSrc string
|
|
||||||
systemdFileSrc string
|
|
||||||
cliBinaryWrapperSrc string
|
|
||||||
|
|
||||||
depends []string
|
|
||||||
}
|
|
||||||
|
|
||||||
func createDebPackages() {
|
|
||||||
debPkgArch := pkgArch
|
|
||||||
if pkgArch == "armv7" || pkgArch == "armv6" {
|
|
||||||
debPkgArch = "armhf"
|
|
||||||
}
|
|
||||||
|
|
||||||
createPackage(linuxPackageOptions{
|
|
||||||
packageType: "deb",
|
|
||||||
packageArch: debPkgArch,
|
|
||||||
homeDir: "/usr/share/grafana",
|
|
||||||
homeBinDir: "/usr/share/grafana/bin",
|
|
||||||
binPath: "/usr/sbin",
|
|
||||||
configDir: "/etc/grafana",
|
|
||||||
etcDefaultPath: "/etc/default",
|
|
||||||
etcDefaultFilePath: "/etc/default/grafana-server",
|
|
||||||
initdScriptFilePath: "/etc/init.d/grafana-server",
|
|
||||||
systemdServiceFilePath: "/usr/lib/systemd/system/grafana-server.service",
|
|
||||||
|
|
||||||
postinstSrc: "packaging/deb/control/postinst",
|
|
||||||
initdScriptSrc: "packaging/deb/init.d/grafana-server",
|
|
||||||
defaultFileSrc: "packaging/deb/default/grafana-server",
|
|
||||||
systemdFileSrc: "packaging/deb/systemd/grafana-server.service",
|
|
||||||
cliBinaryWrapperSrc: "packaging/wrappers/grafana-cli",
|
|
||||||
|
|
||||||
depends: []string{"adduser", "libfontconfig1"},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func createRpmPackages() {
|
|
||||||
rpmPkgArch := pkgArch
|
|
||||||
switch {
|
|
||||||
case pkgArch == "armv7":
|
|
||||||
rpmPkgArch = "armhfp"
|
|
||||||
case pkgArch == "arm64":
|
|
||||||
rpmPkgArch = "aarch64"
|
|
||||||
}
|
|
||||||
createPackage(linuxPackageOptions{
|
|
||||||
packageType: "rpm",
|
|
||||||
packageArch: rpmPkgArch,
|
|
||||||
homeDir: "/usr/share/grafana",
|
|
||||||
homeBinDir: "/usr/share/grafana/bin",
|
|
||||||
binPath: "/usr/sbin",
|
|
||||||
configDir: "/etc/grafana",
|
|
||||||
etcDefaultPath: "/etc/sysconfig",
|
|
||||||
etcDefaultFilePath: "/etc/sysconfig/grafana-server",
|
|
||||||
initdScriptFilePath: "/etc/init.d/grafana-server",
|
|
||||||
systemdServiceFilePath: "/usr/lib/systemd/system/grafana-server.service",
|
|
||||||
|
|
||||||
postinstSrc: "packaging/rpm/control/postinst",
|
|
||||||
initdScriptSrc: "packaging/rpm/init.d/grafana-server",
|
|
||||||
defaultFileSrc: "packaging/rpm/sysconfig/grafana-server",
|
|
||||||
systemdFileSrc: "packaging/rpm/systemd/grafana-server.service",
|
|
||||||
cliBinaryWrapperSrc: "packaging/wrappers/grafana-cli",
|
|
||||||
|
|
||||||
depends: []string{"/sbin/service", "fontconfig", "freetype", "urw-fonts"},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func createLinuxPackages() {
|
|
||||||
if !skipDebGen {
|
|
||||||
createDebPackages()
|
|
||||||
}
|
|
||||||
|
|
||||||
if !skipRpmGen {
|
|
||||||
createRpmPackages()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func createPackage(options linuxPackageOptions) {
|
|
||||||
packageRoot, _ := ioutil.TempDir("", "grafana-linux-pack")
|
|
||||||
|
|
||||||
// create directories
|
|
||||||
runPrint("mkdir", "-p", filepath.Join(packageRoot, options.homeDir))
|
|
||||||
runPrint("mkdir", "-p", filepath.Join(packageRoot, options.configDir))
|
|
||||||
runPrint("mkdir", "-p", filepath.Join(packageRoot, "/etc/init.d"))
|
|
||||||
runPrint("mkdir", "-p", filepath.Join(packageRoot, options.etcDefaultPath))
|
|
||||||
runPrint("mkdir", "-p", filepath.Join(packageRoot, "/usr/lib/systemd/system"))
|
|
||||||
runPrint("mkdir", "-p", filepath.Join(packageRoot, "/usr/sbin"))
|
|
||||||
|
|
||||||
// copy grafana-cli wrapper
|
|
||||||
runPrint("cp", "-p", options.cliBinaryWrapperSrc, filepath.Join(packageRoot, "/usr/sbin/"+cliBinary))
|
|
||||||
|
|
||||||
// copy grafana-server binary
|
|
||||||
runPrint("cp", "-p", filepath.Join(workingDir, "tmp/bin/"+serverBinary), filepath.Join(packageRoot, "/usr/sbin/"+serverBinary))
|
|
||||||
|
|
||||||
// copy init.d script
|
|
||||||
runPrint("cp", "-p", options.initdScriptSrc, filepath.Join(packageRoot, options.initdScriptFilePath))
|
|
||||||
// copy environment var file
|
|
||||||
runPrint("cp", "-p", options.defaultFileSrc, filepath.Join(packageRoot, options.etcDefaultFilePath))
|
|
||||||
// copy systemd file
|
|
||||||
runPrint("cp", "-p", options.systemdFileSrc, filepath.Join(packageRoot, options.systemdServiceFilePath))
|
|
||||||
// copy release files
|
|
||||||
runPrint("cp", "-a", filepath.Join(workingDir, "tmp")+"/.", filepath.Join(packageRoot, options.homeDir))
|
|
||||||
// remove bin path
|
|
||||||
runPrint("rm", "-rf", filepath.Join(packageRoot, options.homeDir, "bin"))
|
|
||||||
|
|
||||||
// create /bin within home
|
|
||||||
runPrint("mkdir", "-p", filepath.Join(packageRoot, options.homeBinDir))
|
|
||||||
// The grafana-cli binary is exposed through a wrapper to ensure a proper
|
|
||||||
// configuration is in place. To enable that, we need to store the original
|
|
||||||
// binary in a separate location to avoid conflicts.
|
|
||||||
runPrint("cp", "-p", filepath.Join(workingDir, "tmp/bin/"+cliBinary), filepath.Join(packageRoot, options.homeBinDir, cliBinary))
|
|
||||||
|
|
||||||
args := []string{
|
|
||||||
"-s", "dir",
|
|
||||||
"--description", "Grafana",
|
|
||||||
"-C", packageRoot,
|
|
||||||
"--url", "https://grafana.com",
|
|
||||||
"--maintainer", "contact@grafana.com",
|
|
||||||
"--config-files", options.initdScriptFilePath,
|
|
||||||
"--config-files", options.etcDefaultFilePath,
|
|
||||||
"--config-files", options.systemdServiceFilePath,
|
|
||||||
"--after-install", options.postinstSrc,
|
|
||||||
|
|
||||||
"--version", linuxPackageVersion,
|
|
||||||
"-p", "./dist",
|
|
||||||
}
|
|
||||||
|
|
||||||
name := "grafana"
|
|
||||||
if enterprise {
|
|
||||||
name += "-enterprise"
|
|
||||||
args = append(args, "--replaces", "grafana")
|
|
||||||
}
|
|
||||||
fmt.Printf("pkgArch is set to '%s', generated arch is '%s'\n", pkgArch, options.packageArch)
|
|
||||||
if pkgArch == "armv6" {
|
|
||||||
name += "-rpi"
|
|
||||||
args = append(args, "--replaces", "grafana")
|
|
||||||
}
|
|
||||||
args = append(args, "--name", name)
|
|
||||||
|
|
||||||
description := "Grafana"
|
|
||||||
if enterprise {
|
|
||||||
description += " Enterprise"
|
|
||||||
}
|
|
||||||
|
|
||||||
if !enterprise {
|
|
||||||
args = append(args, "--license", "\"Apache 2.0\"")
|
|
||||||
}
|
|
||||||
|
|
||||||
if options.packageType == "rpm" {
|
|
||||||
args = append(args, "--rpm-posttrans", "packaging/rpm/control/posttrans")
|
|
||||||
}
|
|
||||||
|
|
||||||
if options.packageType == "deb" {
|
|
||||||
args = append(args, "--deb-no-default-config-files")
|
|
||||||
}
|
|
||||||
|
|
||||||
if options.packageArch != "" {
|
|
||||||
args = append(args, "-a", options.packageArch)
|
|
||||||
}
|
|
||||||
|
|
||||||
if linuxPackageIteration != "" {
|
|
||||||
args = append(args, "--iteration", linuxPackageIteration)
|
|
||||||
}
|
|
||||||
|
|
||||||
// add dependencies
|
|
||||||
for _, dep := range options.depends {
|
|
||||||
args = append(args, "--depends", dep)
|
|
||||||
}
|
|
||||||
|
|
||||||
args = append(args, ".")
|
|
||||||
|
|
||||||
fmt.Println("Creating package: ", options.packageType)
|
|
||||||
runPrint("fpm", append([]string{"-t", options.packageType}, args...)...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func grunt(params ...string) {
|
|
||||||
if runtime.GOOS == windows {
|
|
||||||
runPrint(`.\node_modules\.bin\grunt`, params...)
|
|
||||||
} else {
|
|
||||||
runPrint("./node_modules/.bin/grunt", params...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func genPackageVersion() string {
|
func genPackageVersion() string {
|
||||||
@ -439,24 +218,6 @@ func genPackageVersion() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func gruntBuildArg(task string) []string {
|
|
||||||
args := []string{task}
|
|
||||||
args = append(args, fmt.Sprintf("--pkgVer=%v", genPackageVersion()))
|
|
||||||
if pkgArch != "" {
|
|
||||||
args = append(args, fmt.Sprintf("--arch=%v", pkgArch))
|
|
||||||
}
|
|
||||||
if libc != "" {
|
|
||||||
args = append(args, fmt.Sprintf("--libc=%s", libc))
|
|
||||||
}
|
|
||||||
if enterprise {
|
|
||||||
args = append(args, "--enterprise")
|
|
||||||
}
|
|
||||||
|
|
||||||
args = append(args, fmt.Sprintf("--platform=%v", goos))
|
|
||||||
|
|
||||||
return args
|
|
||||||
}
|
|
||||||
|
|
||||||
func setup() {
|
func setup() {
|
||||||
args := []string{"install", "-v"}
|
args := []string{"install", "-v"}
|
||||||
if goos == windows {
|
if goos == windows {
|
||||||
|
29
package.json
29
package.json
@ -7,13 +7,15 @@
|
|||||||
"repository": "github:grafana/grafana",
|
"repository": "github:grafana/grafana",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"api-tests": "jest --notify --watch --config=devenv/e2e-api-tests/jest.js",
|
"api-tests": "jest --notify --watch --config=devenv/e2e-api-tests/jest.js",
|
||||||
"build": "grunt build",
|
"build": "node ./node_modules/webpack/bin/webpack.js --config scripts/webpack/webpack.prod.js",
|
||||||
"dev": "webpack --progress --colors --config scripts/webpack/webpack.dev.js",
|
"dev": "webpack --progress --colors --config scripts/webpack/webpack.dev.js",
|
||||||
"e2e": "./e2e/start-and-run-suite",
|
"e2e": "./e2e/start-and-run-suite",
|
||||||
"e2e:debug": "./e2e/start-and-run-suite debug",
|
"e2e:debug": "./e2e/start-and-run-suite debug",
|
||||||
"e2e:dev": "./e2e/start-and-run-suite dev",
|
"e2e:dev": "./e2e/start-and-run-suite dev",
|
||||||
"test": "jest --notify --watch",
|
"test": "jest --notify --watch",
|
||||||
"lint": "eslint . --ext .js,.tsx,.ts --cache",
|
"lint": "yarn run lint:ts && yarn run lint:sass",
|
||||||
|
"lint:ts": "eslint . --ext .js,.tsx,.ts --cache",
|
||||||
|
"lint:sass": "yarn run sass-lint -c public/sass/.sass-lint.yml 'public/sass/**/*.scss, packages/**/*.scss' -v -i '**/node_modules/**/*.scss'",
|
||||||
"test:ci": "mkdir -p reports/junit && export JEST_JUNIT_OUTPUT_DIR=reports/junit && jest --ci --reporters=default --reporters=jest-junit -w ${TEST_MAX_WORKERS:-100%}",
|
"test:ci": "mkdir -p reports/junit && export JEST_JUNIT_OUTPUT_DIR=reports/junit && jest --ci --reporters=default --reporters=jest-junit -w ${TEST_MAX_WORKERS:-100%}",
|
||||||
"lint:fix": "yarn lint --fix",
|
"lint:fix": "yarn lint --fix",
|
||||||
"packages:build": "lerna run clean && lerna run build --ignore @grafana-plugins/input-datasource",
|
"packages:build": "lerna run clean && lerna run build --ignore @grafana-plugins/input-datasource",
|
||||||
@ -27,7 +29,7 @@
|
|||||||
"packages:publishDev": "lerna publish from-package --contents dist --dist-tag dev --yes --registry http://grafana-npm.local:4873 --force-publish=*",
|
"packages:publishDev": "lerna publish from-package --contents dist --dist-tag dev --yes --registry http://grafana-npm.local:4873 --force-publish=*",
|
||||||
"packages:typecheck": "lerna run typecheck",
|
"packages:typecheck": "lerna run typecheck",
|
||||||
"packages:clean": "lerna run clean",
|
"packages:clean": "lerna run clean",
|
||||||
"precommit": "grafana-toolkit precommit",
|
"precommit": "yarn run lint-staged",
|
||||||
"prettier:check": "prettier --list-different \"**/*.{ts,tsx,scss}\"",
|
"prettier:check": "prettier --list-different \"**/*.{ts,tsx,scss}\"",
|
||||||
"prettier:write": "prettier --list-different \"**/*.{ts,tsx,scss}\" --write",
|
"prettier:write": "prettier --list-different \"**/*.{ts,tsx,scss}\" --write",
|
||||||
"start": "grafana-toolkit core:start --watchTheme",
|
"start": "grafana-toolkit core:start --watchTheme",
|
||||||
@ -38,10 +40,10 @@
|
|||||||
"storybook": "yarn workspace @grafana/ui storybook --ci",
|
"storybook": "yarn workspace @grafana/ui storybook --ci",
|
||||||
"storybook:build": "yarn workspace @grafana/ui storybook:build",
|
"storybook:build": "yarn workspace @grafana/ui storybook:build",
|
||||||
"themes:generate": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/generateSassVariableFiles.ts",
|
"themes:generate": "ts-node --project ./scripts/cli/tsconfig.json ./scripts/cli/generateSassVariableFiles.ts",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit && yarn run packages:typecheck",
|
||||||
"plugins:build-bundled": "grafana-toolkit plugin:bundle-managed",
|
"plugins:build-bundled": "grafana-toolkit plugin:bundle-managed",
|
||||||
"watch": "yarn start -d watch,start core:start --watchTheme",
|
"watch": "yarn start -d watch,start core:start --watchTheme",
|
||||||
"ci:test-frontend": "yarn run prettier:check && yarn run packages:typecheck && yarn run typecheck && yarn grunt no-only-tests && yarn run test:ci"
|
"ci:test-frontend": "yarn run prettier:check && yarn run typecheck && yarn run lint && yarn run test:ci && yarn grafana-toolkit node-version-check"
|
||||||
},
|
},
|
||||||
"grafana": {
|
"grafana": {
|
||||||
"whatsNewUrl": "https://grafana.com/docs/grafana/latest/guides/whats-new-in-v7-3/",
|
"whatsNewUrl": "https://grafana.com/docs/grafana/latest/guides/whats-new-in-v7-3/",
|
||||||
@ -49,7 +51,7 @@
|
|||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "lint-staged && npm run precommit"
|
"pre-commit": "yarn run precommit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
@ -134,9 +136,10 @@
|
|||||||
"es-abstract": "1.18.0-next.1",
|
"es-abstract": "1.18.0-next.1",
|
||||||
"es6-promise": "4.2.8",
|
"es6-promise": "4.2.8",
|
||||||
"es6-shim": "0.35.5",
|
"es6-shim": "0.35.5",
|
||||||
"eslint": "7.4.0",
|
"eslint": "^7.14.0",
|
||||||
"eslint-config-prettier": "6.11.0",
|
"eslint-config-prettier": "6.11.0",
|
||||||
"eslint-plugin-jsdoc": "28.6.1",
|
"eslint-plugin-jsdoc": "28.6.1",
|
||||||
|
"eslint-plugin-no-only-tests": "^2.4.0",
|
||||||
"eslint-plugin-prettier": "3.1.4",
|
"eslint-plugin-prettier": "3.1.4",
|
||||||
"eslint-plugin-react": "7.21.5",
|
"eslint-plugin-react": "7.21.5",
|
||||||
"eslint-plugin-react-hooks": "4.1.2",
|
"eslint-plugin-react-hooks": "4.1.2",
|
||||||
@ -146,18 +149,6 @@
|
|||||||
"fork-ts-checker-webpack-plugin": "5.0.0",
|
"fork-ts-checker-webpack-plugin": "5.0.0",
|
||||||
"gaze": "1.1.3",
|
"gaze": "1.1.3",
|
||||||
"glob": "7.1.6",
|
"glob": "7.1.6",
|
||||||
"grunt": "1.0.4",
|
|
||||||
"grunt-angular-templates": "1.1.0",
|
|
||||||
"grunt-cli": "1.3.2",
|
|
||||||
"grunt-contrib-clean": "2.0.0",
|
|
||||||
"grunt-contrib-copy": "1.0.0",
|
|
||||||
"grunt-exec": "3.0.0",
|
|
||||||
"grunt-newer": "1.3.0",
|
|
||||||
"grunt-notify": "0.4.5",
|
|
||||||
"grunt-postcss": "0.9.0",
|
|
||||||
"grunt-sass-lint": "0.2.4",
|
|
||||||
"grunt-usemin": "3.1.1",
|
|
||||||
"grunt-webpack": "3.1.3",
|
|
||||||
"html-loader": "0.5.5",
|
"html-loader": "0.5.5",
|
||||||
"html-webpack-harddisk-plugin": "1.0.1",
|
"html-webpack-harddisk-plugin": "1.0.1",
|
||||||
"html-webpack-plugin": "3.2.0",
|
"html-webpack-plugin": "3.2.0",
|
||||||
|
@ -5,7 +5,6 @@ import chalk from 'chalk';
|
|||||||
import { startTask } from './tasks/core.start';
|
import { startTask } from './tasks/core.start';
|
||||||
import { changelogTask } from './tasks/changelog';
|
import { changelogTask } from './tasks/changelog';
|
||||||
import { cherryPickTask } from './tasks/cherrypick';
|
import { cherryPickTask } from './tasks/cherrypick';
|
||||||
import { precommitTask } from './tasks/precommit';
|
|
||||||
import { templateTask } from './tasks/template';
|
import { templateTask } from './tasks/template';
|
||||||
import { pluginBuildTask } from './tasks/plugin.build';
|
import { pluginBuildTask } from './tasks/plugin.build';
|
||||||
import { toolkitBuildTask } from './tasks/toolkit.build';
|
import { toolkitBuildTask } from './tasks/toolkit.build';
|
||||||
@ -21,6 +20,7 @@ import { pluginCreateTask } from './tasks/plugin.create';
|
|||||||
import { pluginSignTask } from './tasks/plugin.sign';
|
import { pluginSignTask } from './tasks/plugin.sign';
|
||||||
import { bundleManagedTask } from './tasks/plugin/bundle.managed';
|
import { bundleManagedTask } from './tasks/plugin/bundle.managed';
|
||||||
import { componentCreateTask } from './tasks/component.create';
|
import { componentCreateTask } from './tasks/component.create';
|
||||||
|
import { nodeVersionCheckerTask } from './tasks/nodeVersionChecker';
|
||||||
|
|
||||||
export const run = (includeInternalScripts = false) => {
|
export const run = (includeInternalScripts = false) => {
|
||||||
if (includeInternalScripts) {
|
if (includeInternalScripts) {
|
||||||
@ -74,10 +74,10 @@ export const run = (includeInternalScripts = false) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('precommit')
|
.command('node-version-check')
|
||||||
.description('Executes checks')
|
.description('Verify node version')
|
||||||
.action(async cmd => {
|
.action(async cmd => {
|
||||||
await execTask(precommitTask)({});
|
await execTask(nodeVersionCheckerTask)({});
|
||||||
});
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
|
@ -15,7 +15,7 @@ const packageJsonFile = 'package.json';
|
|||||||
|
|
||||||
const failures: FailedVersionCheck[] = [];
|
const failures: FailedVersionCheck[] = [];
|
||||||
|
|
||||||
export const nodeVersionFiles = [packageJsonFile, 'Dockerfile', '.circleci/config.yml'];
|
export const nodeVersionFiles = [packageJsonFile, 'Dockerfile'];
|
||||||
|
|
||||||
const nodeVersionCheckerRunner: TaskRunner<NodeVersionCheckerOptions> = async () => {
|
const nodeVersionCheckerRunner: TaskRunner<NodeVersionCheckerOptions> = async () => {
|
||||||
// Read version from package json and treat that as the expected version in all other locations
|
// Read version from package json and treat that as the expected version in all other locations
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
import { Task, TaskRunner } from './task';
|
|
||||||
import chalk from 'chalk';
|
|
||||||
// @ts-ignore
|
|
||||||
import get from 'lodash/get';
|
|
||||||
// @ts-ignore
|
|
||||||
import flatten from 'lodash/flatten';
|
|
||||||
import execa = require('execa');
|
|
||||||
import { nodeVersionCheckerTask, nodeVersionFiles } from './nodeVersionChecker';
|
|
||||||
import { execTask } from '../utils/execTask';
|
|
||||||
const simpleGit = require('simple-git/promise')(process.cwd());
|
|
||||||
|
|
||||||
interface PrecommitOptions {}
|
|
||||||
|
|
||||||
interface GitStatus {
|
|
||||||
files: GitFile[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GitFile {
|
|
||||||
path: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const precommitRunner: TaskRunner<PrecommitOptions> = async () => {
|
|
||||||
const status: GitStatus = await simpleGit.status();
|
|
||||||
const sassFiles = status.files.filter(
|
|
||||||
file => file.path.match(/^[a-zA-Z0-9\_\-\/]+(\.scss)$/g) || file.path.indexOf('.sass-lint.yml') > -1
|
|
||||||
);
|
|
||||||
|
|
||||||
const testFiles = status.files.filter(file => file.path.match(/^[a-zA-Z0-9\_\-\/]+(\.test.(ts|tsx))$/g));
|
|
||||||
const goTestFiles = status.files.filter(file => file.path.match(/^[a-zA-Z0-9\_\-\/]+(\_test.go)$/g));
|
|
||||||
const affectedNodeVersionFiles = status.files
|
|
||||||
.filter(file => nodeVersionFiles.indexOf(file.path) !== -1)
|
|
||||||
.map(f => f.path);
|
|
||||||
|
|
||||||
const gruntTasks = [];
|
|
||||||
|
|
||||||
if (affectedNodeVersionFiles.length > 0) {
|
|
||||||
await execTask(nodeVersionCheckerTask)({});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sassFiles.length > 0) {
|
|
||||||
gruntTasks.push('sasslint');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (testFiles.length) {
|
|
||||||
gruntTasks.push('no-only-tests');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (goTestFiles.length) {
|
|
||||||
gruntTasks.push('no-focus-convey-tests');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gruntTasks.length > 0) {
|
|
||||||
console.log(chalk.yellow(`Precommit checks: ${gruntTasks.join(', ')}`));
|
|
||||||
const task = execa('grunt', gruntTasks);
|
|
||||||
// @ts-ignore
|
|
||||||
const stream = task.stdout;
|
|
||||||
if (stream) {
|
|
||||||
stream.pipe(process.stdout);
|
|
||||||
}
|
|
||||||
return task;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(chalk.yellow('Skipping precommit checks, no front-end changes detected'));
|
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const precommitTask = new Task<PrecommitOptions>('Precommit task', precommitRunner);
|
|
@ -1,6 +0,0 @@
|
|||||||
module.exports = function(grunt) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// Concat and Minify the src directory into dist
|
|
||||||
grunt.registerTask('build', ['clean:release', 'clean:build', 'exec:webpack']);
|
|
||||||
};
|
|
@ -1,56 +0,0 @@
|
|||||||
// Lint and build CSS
|
|
||||||
module.exports = function(grunt) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
grunt.registerTask('default', [
|
|
||||||
'clean:build',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
grunt.registerTask('test', [
|
|
||||||
'sasslint',
|
|
||||||
'eslint',
|
|
||||||
'typecheck',
|
|
||||||
'exec:jest',
|
|
||||||
'no-only-tests',
|
|
||||||
'no-focus-convey-tests'
|
|
||||||
]);
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
grunt.registerTask('eslint', [
|
|
||||||
'newer:exec:eslint'
|
|
||||||
]);
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
grunt.registerTask('typecheck', [
|
|
||||||
'newer:exec:typecheckPackages',
|
|
||||||
'newer:exec:typecheckRoot'
|
|
||||||
]);
|
|
||||||
|
|
||||||
grunt.registerTask('no-only-tests', function() {
|
|
||||||
var files = grunt.file.expand(
|
|
||||||
'public/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
|
|
||||||
'packages/grafana-data/**/*@(_specs|.test).@(ts|js|tsx|jsx)',
|
|
||||||
'packages/**/*@(_specs|.test).@(ts|js|tsx|jsx)'
|
|
||||||
);
|
|
||||||
grepFiles(files, '.only(', 'found only statement in test: ');
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.registerTask('no-focus-convey-tests', function() {
|
|
||||||
var files = grunt.file.expand('pkg/**/*_test.go');
|
|
||||||
grepFiles(files, 'FocusConvey(', 'found FocusConvey statement in test: ');
|
|
||||||
});
|
|
||||||
|
|
||||||
function grepFiles(files, pattern, errorMessage) {
|
|
||||||
files.forEach(function(spec) {
|
|
||||||
var rows = grunt.file.read(spec).split('\n');
|
|
||||||
rows.forEach(function(row) {
|
|
||||||
if (row.indexOf(pattern) > 0) {
|
|
||||||
grunt.log.errorlns(row);
|
|
||||||
grunt.fail.warn(errorMessage + spec);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,10 +0,0 @@
|
|||||||
module.exports = function(config) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
return {
|
|
||||||
release: ['<%= destDir %>', '<%= tempDir %>', '<%= genDir %>'],
|
|
||||||
build: ['<%= srcDir %>/build'],
|
|
||||||
temp: ['<%= tempDir %>'],
|
|
||||||
packaging: [],
|
|
||||||
};
|
|
||||||
};
|
|
@ -1,32 +0,0 @@
|
|||||||
module.exports = function(config) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var task = {
|
|
||||||
release: {
|
|
||||||
options: {
|
|
||||||
archive:
|
|
||||||
'<%= destDir %>/<%= pkg.name %><%= enterprise ? "-enterprise" : "" %>-<%= pkg.version %>.<%= platform %>-<%= arch %><%= libc ? "-" + libc : "" %>.tar.gz',
|
|
||||||
},
|
|
||||||
files: [
|
|
||||||
{
|
|
||||||
expand: true,
|
|
||||||
cwd: '<%= tempDir %>',
|
|
||||||
src: ['**/*'],
|
|
||||||
dest: '<%= pkg.name %>-<%= pkg.version %>/',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
expand: true,
|
|
||||||
src: ['LICENSE', 'README.md', 'NOTICE.md'],
|
|
||||||
dest: '<%= pkg.name %>-<%= pkg.version %>/',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (config.platform === 'windows') {
|
|
||||||
task.release.options.archive =
|
|
||||||
'<%= destDir %>/<%= pkg.name %><%= enterprise ? "-enterprise" : "" %>-<%= pkg.version %>.<%= platform %>-<%= arch %>.zip';
|
|
||||||
}
|
|
||||||
|
|
||||||
return task;
|
|
||||||
};
|
|
@ -1,16 +0,0 @@
|
|||||||
module.exports = function(config, grunt) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
return {
|
|
||||||
eslint: {
|
|
||||||
command: 'yarn lint',
|
|
||||||
},
|
|
||||||
typecheckPackages: {
|
|
||||||
command: 'yarn packages:typecheck',
|
|
||||||
},
|
|
||||||
typecheckRoot: {
|
|
||||||
command: 'yarn typecheck',
|
|
||||||
},
|
|
||||||
webpack: 'node ./node_modules/webpack/bin/webpack.js --config scripts/webpack/webpack.prod.js',
|
|
||||||
};
|
|
||||||
};
|
|
@ -1,9 +0,0 @@
|
|||||||
module.exports = function(config) {
|
|
||||||
'use strict';
|
|
||||||
return {
|
|
||||||
options: {
|
|
||||||
configFile: 'public/sass/.sass-lint.yml',
|
|
||||||
},
|
|
||||||
src: ['public/sass/**/*.scss', 'packages/**/*.scss', '!**/node_modules/**/*.scss'],
|
|
||||||
};
|
|
||||||
};
|
|
@ -1,13 +0,0 @@
|
|||||||
const dev = require('../../webpack/webpack.dev.js');
|
|
||||||
const prod = require('../../webpack/webpack.prod.js');
|
|
||||||
|
|
||||||
module.exports = function() {
|
|
||||||
'use strict';
|
|
||||||
return {
|
|
||||||
options: {
|
|
||||||
stats: false,
|
|
||||||
},
|
|
||||||
dev: dev,
|
|
||||||
prod: prod,
|
|
||||||
};
|
|
||||||
};
|
|
@ -1,40 +0,0 @@
|
|||||||
var path = require('path');
|
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// build then zip
|
|
||||||
grunt.registerTask('release', ['build', 'build-post-process']);
|
|
||||||
|
|
||||||
// package into archives
|
|
||||||
grunt.registerTask('package', ['clean:temp', 'build-post-process']);
|
|
||||||
|
|
||||||
grunt.registerTask('build-post-process', function() {
|
|
||||||
grunt.config('copy.public_to_temp', {
|
|
||||||
expand: true,
|
|
||||||
cwd: '<%= srcDir %>',
|
|
||||||
src: '**/*',
|
|
||||||
dest: '<%= tempDir %>/public/',
|
|
||||||
});
|
|
||||||
grunt.config('copy.backend_bin', {
|
|
||||||
cwd: 'bin/<%= platform %>-<%= arch %><%= libc ? "-" + libc : "" %>',
|
|
||||||
expand: true,
|
|
||||||
src: ['*'],
|
|
||||||
options: { mode: true },
|
|
||||||
dest: '<%= tempDir %>/bin/',
|
|
||||||
});
|
|
||||||
grunt.config('copy.backend_files', {
|
|
||||||
expand: true,
|
|
||||||
src: ['conf/**', 'tools/**', 'scripts/*'],
|
|
||||||
options: { mode: true },
|
|
||||||
dest: '<%= tempDir %>',
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.task.run('copy:public_to_temp');
|
|
||||||
grunt.task.run('copy:backend_bin');
|
|
||||||
grunt.task.run('copy:backend_files');
|
|
||||||
grunt.task.run('clean:packaging');
|
|
||||||
|
|
||||||
grunt.file.write(path.join(grunt.config('tempDir'), 'VERSION'), grunt.config('pkg.version'));
|
|
||||||
});
|
|
||||||
};
|
|
@ -1,46 +0,0 @@
|
|||||||
module.exports = function(grunt) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function escapeRegExp(str) {
|
|
||||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractColour(line) {
|
|
||||||
var regex = /\s*:\s*(#[a-fA-F0-9]{3,6})\s*(!default|!default;)?/;
|
|
||||||
var matches = line.match(regex);
|
|
||||||
return matches ? matches[1] : matches;
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractVariable(line) {
|
|
||||||
var matches = line.match(/(\$[0-9a-zA-Z_-]+)\s*(!default|!default;)?/);
|
|
||||||
return matches ? matches[1] : matches;
|
|
||||||
}
|
|
||||||
|
|
||||||
function readVars(file, obj) {
|
|
||||||
var content = grunt.file.read(file);
|
|
||||||
var lines = content.split('\n');
|
|
||||||
|
|
||||||
lines.forEach(function(line) {
|
|
||||||
var variable = extractVariable(line);
|
|
||||||
if (variable) {
|
|
||||||
var color = extractColour(line, variable);
|
|
||||||
if (color) {
|
|
||||||
obj[variable] = color;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
grunt.registerTask('styleguide', function() {
|
|
||||||
var data = {
|
|
||||||
dark: {},
|
|
||||||
light: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
readVars('public/sass/_variables.dark.scss', data.dark);
|
|
||||||
readVars('public/sass/_variables.light.scss', data.light);
|
|
||||||
|
|
||||||
var styleGuideJson = grunt.config().srcDir + '/build/styleguide.json';
|
|
||||||
grunt.file.write(styleGuideJson, JSON.stringify(data, null, 4));
|
|
||||||
});
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user