move to npm workspace

Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
This commit is contained in:
Augustin Husson 2021-09-10 15:38:20 +02:00
parent fa56d1e43b
commit 5c42b04af7
15 changed files with 4098 additions and 12439 deletions

2
.gitignore vendored
View file

@ -25,3 +25,5 @@ npm_licenses.tar.bz2
/vendor /vendor
/.build /.build
/**/node_modules

View file

@ -5,7 +5,6 @@
"plugin:prettier/recommended" "plugin:prettier/recommended"
], ],
"rules": { "rules": {
"@typescript-eslint/camelcase": "warn",
"@typescript-eslint/explicit-function-return-type": ["off"], "@typescript-eslint/explicit-function-return-type": ["off"],
"eol-last": [ "eol-last": [
"error", "error",

View file

@ -16,14 +16,5 @@
set -ex set -ex
# build the lib (both ES2015 and CommonJS) # build the lib (both ES2015 and CommonJS)
tsc --module ES2015 --target ES2015 --outDir lib/esm tsc --module ES2015 --target ES2015 --outDir dist/esm
tsc --module commonjs --target es5 --outDir lib/cjs --downlevelIteration tsc --module commonjs --target es5 --outDir dist/cjs --downlevelIteration
# Finally, copy some useful files into the distribution folder for documentation purposes.
cp ./README.md ./lib/README.md
cp ./CHANGELOG.md ./lib/CHANGELOG.md
cp ./package.json ./lib/package.json
if [ -f "./LICENSE" ]; then
cp ./LICENSE ./lib/LICENSE
fi

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,9 @@
{ {
"name": "codemirror-promql", "name": "codemirror-promql",
"version": "0.17.0", "version": "0.18.0",
"description": "a CodeMirror mode for the PromQL language", "description": "a CodeMirror mode for the PromQL language",
"main": "cjs/index.js", "main": "dist/cjs/index.js",
"module": "esm/index.js", "module": "dist/esm/index.js",
"scripts": { "scripts": {
"build": "npm run build:grammar && npm run build:lib", "build": "npm run build:grammar && npm run build:lib",
"build:grammar": "lezer-generator src/grammar/promql.grammar -o src/grammar/parser", "build:grammar": "lezer-generator src/grammar/promql.grammar -o src/grammar/parser",
@ -44,25 +44,23 @@
"@types/chai": "^4.2.12", "@types/chai": "^4.2.12",
"@types/lru-cache": "^5.1.0", "@types/lru-cache": "^5.1.0",
"@types/mocha": "^8.0.3", "@types/mocha": "^8.0.3",
"@types/node": "^14.0.13", "@types/node": "^16.7.6",
"@typescript-eslint/eslint-plugin": "^2.22.0", "@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^2.22.0", "@typescript-eslint/parser": "^4.31.0",
"chai": "^4.2.0", "chai": "^4.2.0",
"clean-webpack-plugin": "^3.0.0",
"codecov": "^3.8.1", "codecov": "^3.8.1",
"eslint": "^6.8.0", "eslint": "^7.32.0",
"eslint-config-prettier": "^6.11.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-flowtype": "^5.2.0", "eslint-plugin-flowtype": "^5.9.2",
"eslint-plugin-import": "^2.22.0", "eslint-plugin-import": "^2.24.2",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^4.0.0",
"html-webpack-plugin": "^4.3.0",
"isomorphic-fetch": "^3.0.0", "isomorphic-fetch": "^3.0.0",
"lezer": "^0.13.1", "lezer": "^0.13.1",
"lezer-generator": "^0.13.1", "lezer-generator": "^0.13.1",
"mocha": "^8.1.2", "mocha": "^8.1.2",
"nock": "^13.0.11", "nock": "^13.0.11",
"nyc": "^15.1.0", "nyc": "^15.1.0",
"prettier": "^2.0.5", "prettier": "^2.3.2",
"ts-loader": "^7.0.4", "ts-loader": "^7.0.4",
"ts-mocha": "^8.0.0", "ts-mocha": "^8.0.0",
"ts-node": "^9.0.0", "ts-node": "^9.0.0",

View file

@ -272,10 +272,7 @@ class Cache {
} }
const labelValues = currentAssociation.get(key); const labelValues = currentAssociation.get(key);
if (labelValues === undefined) { if (labelValues === undefined) {
currentAssociation.set( currentAssociation.set(key, new Set<string>([value]));
key,
new Set<string>([value])
);
} else { } else {
labelValues.add(value); labelValues.add(value);
} }

View file

@ -8,19 +8,19 @@
"dom" "dom"
], ],
"declaration": true, "declaration": true,
"outDir": "lib", "outDir": "dist",
"strict": true, "strict": true,
"sourceMap": true, "sourceMap": true,
"moduleResolution": "node", "moduleResolution": "node",
"esModuleInterop": true, "esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"allowJs": true "allowJs": true,
"skipLibCheck": true
}, },
"include": [ "include": [
"src/" "src/"
], ],
"exclude": [ "exclude": [
"node_modules",
"src/**/*.test.ts" "src/**/*.test.ts"
] ]
} }

File diff suppressed because it is too large Load diff

13
web/ui/package.json Normal file
View file

@ -0,0 +1,13 @@
{
"name": "prometheus",
"private": true,
"scripts": {
"lint": "npm run lint --workspaces",
"start": "npm run start -w react-app",
"test": "npm run test --workspaces"
},
"workspaces": [
"react-app",
"module/*"
]
}

View file

@ -0,0 +1,19 @@
const path = require('path');
const { getLoader, loaderByName } = require('@craco/craco');
const packages = [];
packages.push(path.join(__dirname, '../module'));
module.exports = {
webpack: {
configure: (webpackConfig, arg) => {
const { isFound, match } = getLoader(webpackConfig, loaderByName('babel-loader'));
if (isFound) {
const include = Array.isArray(match.loader.include) ? match.loader.include : [match.loader.include];
match.loader.include = include.concat(packages);
}
return webpackConfig;
},
},
};

View file

@ -21,7 +21,7 @@
"@fortawesome/react-fontawesome": "^0.1.4", "@fortawesome/react-fontawesome": "^0.1.4",
"@nexucis/fuzzy": "^0.3.0", "@nexucis/fuzzy": "^0.3.0",
"bootstrap": "^4.6.0", "bootstrap": "^4.6.0",
"codemirror-promql": "^0.17.0", "codemirror-promql": "0.18.0",
"css.escape": "^1.5.1", "css.escape": "^1.5.1",
"downshift": "^3.4.8", "downshift": "^3.4.8",
"i": "^0.3.6", "i": "^0.3.6",
@ -43,11 +43,11 @@
"tempusdominus-core": "^5.0.3" "tempusdominus-core": "^5.0.3"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "craco start",
"build": "react-scripts build", "build": "craco build",
"test": "react-scripts test --runInBand --resetMocks=false", "test": "craco test --runInBand --resetMocks=false",
"test:debug": "react-scripts --inspect-brk test --runInBand --no-cache", "test:debug": "craco --inspect-brk test --runInBand --no-cache",
"eject": "react-scripts eject", "eject": "craco eject",
"lint:ci": "eslint --quiet \"src/**/*.{ts,tsx}\"", "lint:ci": "eslint --quiet \"src/**/*.{ts,tsx}\"",
"lint": "eslint --fix \"src/**/*.{ts,tsx}\"" "lint": "eslint --fix \"src/**/*.{ts,tsx}\""
}, },
@ -63,6 +63,7 @@
"not op_mini all" "not op_mini all"
], ],
"devDependencies": { "devDependencies": {
"@craco/craco": "^6.2.0",
"@testing-library/react-hooks": "^7.0.1", "@testing-library/react-hooks": "^7.0.1",
"@types/enzyme": "^3.10.9", "@types/enzyme": "^3.10.9",
"@types/flot": "0.0.32", "@types/flot": "0.0.32",

View file

@ -11,7 +11,6 @@ import { closeBrackets, closeBracketsKeymap } from '@codemirror/closebrackets';
import { highlightSelectionMatches } from '@codemirror/search'; import { highlightSelectionMatches } from '@codemirror/search';
import { commentKeymap } from '@codemirror/comment'; import { commentKeymap } from '@codemirror/comment';
import { lintKeymap } from '@codemirror/lint'; import { lintKeymap } from '@codemirror/lint';
import { PromQLExtension, CompleteStrategy } from 'codemirror-promql';
import { autocompletion, completionKeymap, CompletionContext, CompletionResult } from '@codemirror/autocomplete'; import { autocompletion, completionKeymap, CompletionContext, CompletionResult } from '@codemirror/autocomplete';
import { baseTheme, lightTheme, darkTheme, promqlHighlighter } from './CMTheme'; import { baseTheme, lightTheme, darkTheme, promqlHighlighter } from './CMTheme';
@ -19,8 +18,9 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSearch, faSpinner, faGlobeEurope } from '@fortawesome/free-solid-svg-icons'; import { faSearch, faSpinner, faGlobeEurope } from '@fortawesome/free-solid-svg-icons';
import MetricsExplorer from './MetricsExplorer'; import MetricsExplorer from './MetricsExplorer';
import { usePathPrefix } from '../../contexts/PathPrefixContext'; import { usePathPrefix } from '../../contexts/PathPrefixContext';
import { newCompleteStrategy } from 'codemirror-promql/cjs/complete';
import { useTheme } from '../../contexts/ThemeContext'; import { useTheme } from '../../contexts/ThemeContext';
import { CompleteStrategy, PromQLExtension } from 'codemirror-promql';
import { newCompleteStrategy } from 'codemirror-promql/dist/cjs/complete';
const promqlExtension = new PromQLExtension(); const promqlExtension = new PromQLExtension();

View file

@ -6,7 +6,7 @@ import moment from 'moment-timezone';
import 'tempusdominus-core'; import 'tempusdominus-core';
import 'tempusdominus-bootstrap-4'; import 'tempusdominus-bootstrap-4';
import '../../../node_modules/tempusdominus-bootstrap-4/build/css/tempusdominus-bootstrap-4.min.css'; import 'tempusdominus-bootstrap-4/build/css/tempusdominus-bootstrap-4.min.css';
import { dom, library } from '@fortawesome/fontawesome-svg-core'; import { dom, library } from '@fortawesome/fontawesome-svg-core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

View file

@ -5,14 +5,14 @@
and https://github.com/ForEvolve/bootstrap-dark/issues/49 and https://github.com/ForEvolve/bootstrap-dark/issues/49
*/ */
@import 'node_modules/bootstrap/scss/functions'; @import '~bootstrap/scss/functions';
@import 'node_modules/bootstrap/scss/variables'; @import '~bootstrap/scss/variables';
@import 'node_modules/@forevolve/bootstrap-dark/scss/dark-variables'; @import '~@forevolve/bootstrap-dark/scss/dark-variables';
@import 'node_modules/bootstrap/scss/mixins'; @import '~bootstrap/scss/mixins';
@import 'node_modules/@forevolve/bootstrap-dark/scss/mixins-overrides'; @import '~@forevolve/bootstrap-dark/scss/mixins-overrides';
@import 'node_modules/@forevolve/bootstrap-dark/scss/dark-mixins'; @import '~@forevolve/bootstrap-dark/scss/dark-mixins';
html { html {
font-family: sans-serif; // 2 font-family: sans-serif; // 2
@ -33,51 +33,51 @@ body.bootstrap-dark {
} }
.bootstrap-dark { .bootstrap-dark {
@import 'node_modules/bootstrap/scss/root'; @import '~bootstrap/scss/root';
@import 'node_modules/bootstrap/scss/type'; @import '~bootstrap/scss/type';
@import 'node_modules/bootstrap/scss/images'; @import '~bootstrap/scss/images';
@import 'node_modules/bootstrap/scss/code'; @import '~bootstrap/scss/code';
@import 'node_modules/bootstrap/scss/grid'; @import '~bootstrap/scss/grid';
@import 'node_modules/bootstrap/scss/tables'; @import '~bootstrap/scss/tables';
@import 'node_modules/@forevolve/bootstrap-dark/scss/dark-tables'; @import '~@forevolve/bootstrap-dark/scss/dark-tables';
@import 'node_modules/bootstrap/scss/forms'; @import '~bootstrap/scss/forms';
@import 'node_modules/@forevolve/bootstrap-dark/scss/form-overrides'; @import '~@forevolve/bootstrap-dark/scss/form-overrides';
@import 'node_modules/bootstrap/scss/buttons'; @import '~bootstrap/scss/buttons';
@import 'node_modules/bootstrap/scss/transitions'; @import '~bootstrap/scss/transitions';
@import 'node_modules/bootstrap/scss/dropdown'; @import '~bootstrap/scss/dropdown';
@import 'node_modules/bootstrap/scss/button-group'; @import '~bootstrap/scss/button-group';
@import 'node_modules/bootstrap/scss/input-group'; @import '~bootstrap/scss/input-group';
@import 'node_modules/@forevolve/bootstrap-dark/scss/dark-input-group'; @import '~@forevolve/bootstrap-dark/scss/dark-input-group';
@import 'node_modules/bootstrap/scss/custom-forms'; @import '~bootstrap/scss/custom-forms';
@import 'node_modules/bootstrap/scss/nav'; @import '~bootstrap/scss/nav';
@import 'node_modules/bootstrap/scss/navbar'; @import '~bootstrap/scss/navbar';
@import 'node_modules/bootstrap/scss/card'; @import '~bootstrap/scss/card';
@import 'node_modules/bootstrap/scss/breadcrumb'; @import '~bootstrap/scss/breadcrumb';
@import 'node_modules/bootstrap/scss/pagination'; @import '~bootstrap/scss/pagination';
@import 'node_modules/bootstrap/scss/badge'; @import '~bootstrap/scss/badge';
@import 'node_modules/bootstrap/scss/jumbotron'; @import '~bootstrap/scss/jumbotron';
@import 'node_modules/bootstrap/scss/alert'; @import '~bootstrap/scss/alert';
@import 'node_modules/bootstrap/scss/progress'; @import '~bootstrap/scss/progress';
@import 'node_modules/bootstrap/scss/media'; @import '~bootstrap/scss/media';
@import 'node_modules/bootstrap/scss/list-group'; @import '~bootstrap/scss/list-group';
@import 'node_modules/bootstrap/scss/close'; @import '~bootstrap/scss/close';
@import 'node_modules/bootstrap/scss/toasts'; @import '~bootstrap/scss/toasts';
@import 'node_modules/bootstrap/scss/modal'; @import '~bootstrap/scss/modal';
@import 'node_modules/bootstrap/scss/tooltip'; @import '~bootstrap/scss/tooltip';
@import 'node_modules/bootstrap/scss/popover'; @import '~bootstrap/scss/popover';
@import 'node_modules/bootstrap/scss/carousel'; @import '~bootstrap/scss/carousel';
@import 'node_modules/bootstrap/scss/spinners'; @import '~bootstrap/scss/spinners';
@import 'node_modules/bootstrap/scss/utilities'; @import '~bootstrap/scss/utilities';
.navbar-themed { .navbar-themed {
@extend .bg-dark; @extend .bg-dark;
@extend .navbar-dark; @extend .navbar-dark;
} }
@import 'node_modules/@forevolve/bootstrap-dark/scss/dark-styles'; @import '~@forevolve/bootstrap-dark/scss/dark-styles';
} }

View file

@ -6,14 +6,14 @@
and https://github.com/ForEvolve/bootstrap-dark/issues/49 and https://github.com/ForEvolve/bootstrap-dark/issues/49
*/ */
@import 'node_modules/bootstrap/scss/functions'; @import '~bootstrap/scss/functions';
@import 'node_modules/bootstrap/scss/variables'; @import '~bootstrap/scss/variables';
@import 'node_modules/bootstrap/scss/mixins'; @import '~bootstrap/scss/mixins';
@import 'node_modules/@forevolve/bootstrap-dark/scss/mixins-overrides'; @import '~@forevolve/bootstrap-dark/scss/mixins-overrides';
/* Add reboot styles using light theme variables */ /* Add reboot styles using light theme variables */
@import 'node_modules/bootstrap/scss/reboot'; @import '~bootstrap/scss/reboot';
body.bootstrap { body.bootstrap {
margin: 0; // 1 margin: 0; // 1
@ -27,41 +27,41 @@ body.bootstrap {
} }
.bootstrap { .bootstrap {
@import 'node_modules/bootstrap/scss/root'; @import '~bootstrap/scss/root';
@import 'node_modules/bootstrap/scss/type'; @import '~bootstrap/scss/type';
@import 'node_modules/bootstrap/scss/images'; @import '~bootstrap/scss/images';
@import 'node_modules/bootstrap/scss/code'; @import '~bootstrap/scss/code';
@import 'node_modules/bootstrap/scss/grid'; @import '~bootstrap/scss/grid';
@import 'node_modules/bootstrap/scss/tables'; @import '~bootstrap/scss/tables';
@import 'node_modules/bootstrap/scss/forms'; @import '~bootstrap/scss/forms';
@import 'node_modules/@forevolve/bootstrap-dark/scss/form-overrides'; @import '~@forevolve/bootstrap-dark/scss/form-overrides';
@import 'node_modules/bootstrap/scss/buttons'; @import '~bootstrap/scss/buttons';
@import 'node_modules/bootstrap/scss/transitions'; @import '~bootstrap/scss/transitions';
@import 'node_modules/bootstrap/scss/dropdown'; @import '~bootstrap/scss/dropdown';
@import 'node_modules/bootstrap/scss/button-group'; @import '~bootstrap/scss/button-group';
@import 'node_modules/bootstrap/scss/input-group'; @import '~bootstrap/scss/input-group';
@import 'node_modules/bootstrap/scss/custom-forms'; @import '~bootstrap/scss/custom-forms';
@import 'node_modules/bootstrap/scss/nav'; @import '~bootstrap/scss/nav';
@import 'node_modules/bootstrap/scss/navbar'; @import '~bootstrap/scss/navbar';
@import 'node_modules/bootstrap/scss/card'; @import '~bootstrap/scss/card';
@import 'node_modules/bootstrap/scss/breadcrumb'; @import '~bootstrap/scss/breadcrumb';
@import 'node_modules/bootstrap/scss/pagination'; @import '~bootstrap/scss/pagination';
@import 'node_modules/bootstrap/scss/badge'; @import '~bootstrap/scss/badge';
@import 'node_modules/bootstrap/scss/jumbotron'; @import '~bootstrap/scss/jumbotron';
@import 'node_modules/bootstrap/scss/alert'; @import '~bootstrap/scss/alert';
@import 'node_modules/bootstrap/scss/progress'; @import '~bootstrap/scss/progress';
@import 'node_modules/bootstrap/scss/media'; @import '~bootstrap/scss/media';
@import 'node_modules/bootstrap/scss/list-group'; @import '~bootstrap/scss/list-group';
@import 'node_modules/bootstrap/scss/close'; @import '~bootstrap/scss/close';
@import 'node_modules/bootstrap/scss/toasts'; @import '~bootstrap/scss/toasts';
@import 'node_modules/bootstrap/scss/modal'; @import '~bootstrap/scss/modal';
@import 'node_modules/bootstrap/scss/tooltip'; @import '~bootstrap/scss/tooltip';
@import 'node_modules/bootstrap/scss/popover'; @import '~bootstrap/scss/popover';
@import 'node_modules/bootstrap/scss/carousel'; @import '~bootstrap/scss/carousel';
@import 'node_modules/bootstrap/scss/spinners'; @import '~bootstrap/scss/spinners';
@import 'node_modules/bootstrap/scss/utilities'; @import '~bootstrap/scss/utilities';
.navbar-themed { .navbar-themed {
@extend .bg-light; @extend .bg-light;