Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve local-run flow #839

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .deps/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
| [`@types/connect@3.4.35`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/enzyme@3.10.11`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/eslint-scope@3.7.3`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/eslint@8.4.2`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #2429 |
| [`@types/eslint@8.40.2`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #8764 |
| [`@types/estree@0.0.51`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | clearlydefined |
| [`@types/express-serve-static-core@4.17.28`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #6020 |
| [`@types/express@4.17.13`](https://github.com/DefinitelyTyped/DefinitelyTyped.git) | MIT | #5760 |
Expand Down Expand Up @@ -446,14 +446,14 @@
| [`escalade@3.1.1`](https://github.com/lukeed/escalade.git) | MIT | clearlydefined |
| [`escodegen@2.0.0`](http://github.com/estools/escodegen.git) | BSD-2-Clause | clearlydefined |
| [`eslint-config-prettier@8.5.0`](https://github.com/prettier/eslint-config-prettier.git) | MIT | clearlydefined |
| [`eslint-loader@4.0.2`](https://github.com/webpack-contrib/eslint-loader.git) | MIT | clearlydefined |
| [`eslint-plugin-notice@0.9.10`](https://github.com/nickdeis/eslint-plugin-notice) | MIT | clearlydefined |
| [`eslint-plugin-prettier@4.0.0`](git+https://github.com/prettier/eslint-plugin-prettier.git) | MIT | clearlydefined |
| [`eslint-plugin-react-hooks@4.3.0`](https://github.com/facebook/react.git) | MIT | clearlydefined |
| [`eslint-plugin-react@7.29.4`](https://github.com/yannickcr/eslint-plugin-react) | MIT | clearlydefined |
| [`eslint-scope@5.1.1`](https://github.com/eslint/eslint-scope.git) | BSD-2-Clause | clearlydefined |
| [`eslint-utils@2.1.0`](git+https://github.com/mysticatea/eslint-utils.git) | MIT | #2498 |
| [`eslint-visitor-keys@2.1.0`](https://github.com/eslint/eslint-visitor-keys.git) | Apache-2.0 | #2433 |
| [`eslint-webpack-plugin@4.0.1`](https://github.com/webpack-contrib/eslint-webpack-plugin.git) | MIT | clearlydefined |
| [`eslint@7.32.0`](https://github.com/eslint/eslint.git) | MIT | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/eslint/7.32.0) |
| [`espree@7.3.1`](https://github.com/eslint/espree.git) | BSD-2-Clause | #903 |
| [`esquery@1.4.0`](https://github.com/estools/esquery.git) | BSD-3-Clause | #1100 |
Expand Down Expand Up @@ -481,7 +481,7 @@
| [`file-loader@6.2.0`](https://github.com/webpack-contrib/file-loader.git) | MIT | clearlydefined |
| [`fill-range@7.0.1`](https://github.com/jonschlinkert/fill-range.git) | MIT | clearlydefined |
| [`finalhandler@1.2.0`](https://github.com/pillarjs/finalhandler.git) | MIT | clearlydefined |
| [`find-cache-dir@3.3.2`](https://github.com/avajs/find-cache-dir.git) | MIT | clearlydefined |
| [`find-cache-dir@2.1.0`](https://github.com/avajs/find-cache-dir.git) | MIT | clearlydefined |
| [`find-root@1.1.0`](git@github.com:js-n/find-root.git) | MIT | clearlydefined |
| [`find-up@4.1.0`](https://github.com/sindresorhus/find-up.git) | MIT | clearlydefined |
| [`flat-cache@3.0.4`](https://github.com/royriojas/flat-cache.git) | MIT | clearlydefined |
Expand Down Expand Up @@ -532,11 +532,11 @@
| [`hosted-git-info@4.1.0`](git+https://github.com/npm/hosted-git-info.git) | ISC | clearlydefined |
| [`hpack.js@2.1.6`](git+ssh://git@github.com/indutny/hpack.js.git) | MIT | clearlydefined |
| [`html-encoding-sniffer@2.0.1`](https://github.com/jsdom/html-encoding-sniffer.git) | MIT | clearlydefined |
| [`html-entities@2.3.3`](https://github.com/mdevils/html-entities.git) | MIT | clearlydefined |
| [`html-entities@2.3.3`](https://github.com/mdevils/html-entities.git) | MIT | #9043 |
| [`html-escaper@2.0.2`](https://github.com/WebReflection/html-escaper.git) | MIT | clearlydefined |
| [`html-minifier-terser@6.1.0`](git+https://github.com/terser/html-minifier-terser.git) | MIT | #2968 |
| [`html-tags@3.3.1`](https://github.com/sindresorhus/html-tags.git) | MIT | clearlydefined |
| [`html-webpack-plugin@5.5.0`](https://github.com/jantimon/html-webpack-plugin.git) | MIT | clearlydefined |
| [`html-webpack-plugin@5.5.0`](https://github.com/jantimon/html-webpack-plugin.git) | MIT | #9078 |
| [`http-cache-semantics@4.1.0`](https://github.com/kornelski/http-cache-semantics.git) | BSD-2-Clause | clearlydefined |
| [`http-deceiver@1.2.7`](git+ssh://git@github.com/indutny/http-deceiver.git) | MIT | clearlydefined |
| [`http-errors@2.0.0`](https://github.com/jshttp/http-errors.git) | MIT | clearlydefined |
Expand Down
2 changes: 1 addition & 1 deletion .deps/prod.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
| [`bcrypt-pbkdf@1.0.2`](git://github.com/joyent/node-bcrypt-pbkdf.git) | BSD-3-Clause | #2725 |
| [`big.js@5.2.2`](https://github.com/MikeMcl/big.js.git) | MIT | clearlydefined |
| [`bluebird@3.7.2`](git://github.com/petkaantonov/bluebird.git) | MIT | clearlydefined |
| [`blueimp-md5@2.19.0`](git://github.com/blueimp/JavaScript-MD5.git) | MIT | clearlydefined |
| [`blueimp-md5@2.19.0`](git://github.com/blueimp/JavaScript-MD5.git) | MIT | [clearlydefined](https://clearlydefined.io/definitions/npm/npmjs/-/blueimp-md5/2.19.0) |
| [`bn.js@4.12.0`](git@github.com:indutny/bn.js) | MIT | clearlydefined |
| [`brace-expansion@1.1.11`](git://github.com/juliangruber/brace-expansion.git) | MIT | clearlydefined |
| [`brorand@1.1.0`](git@github.com:indutny/brorand) | MIT | clearlydefined |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ yarn-error.log
!.yarn/sdks
!.yarn/versions
.pnp.*

run/.che-dashboard-pod
run/.custom-resources
60 changes: 58 additions & 2 deletions devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ commands:
label: "[UD] build"
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "yarn build:dev"
commandLine: "yarn build"
group:
kind: build
- id: watchfrontend
Expand All @@ -56,12 +56,36 @@ commands:
commandLine: "yarn --cwd packages/dashboard-backend build:watch"
group:
kind: build
- id: prepare
exec:
label: "[UD] prepare"
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "yarn start:prepare"
group:
kind: build
- id: dogfoodingprepare
exec:
label: "[UD] dogfooding prepare"
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "oc project dogfooding && export CHE_NAMESPACE='dogfooding' && export NAMESPACE='dogfooding' && yarn start:prepare"
group:
kind: build
- id: startcheinche
exec:
label: "[UD] start che-in-che"
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "oc project dogfooding && export CHE_NAMESPACE='dogfooding' && export NAMESPACE='dogfooding' && yarn start -c"
group:
kind: build
- id: start
exec:
label: "[UD] start"
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "yarn start:prepare && yarn start"
commandLine: "yarn start"
group:
kind: build
- id: runtests
Expand All @@ -72,3 +96,35 @@ commands:
commandLine: "yarn test"
group:
kind: test
- id: frontendbuildspeed
exec:
label: "[UD] frontend build speed"
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "yarn --cwd packages/dashboard-frontend build:dev --env speedMeasure=true"
group:
kind: build
- id: backendbuildspeed
exec:
label: "[UD] backend build speed"
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "yarn --cwd packages/dashboard-backend build:dev --env speedMeasure=true"
group:
kind: build
- id: frontendbundleanalyzer
exec:
label: "[UD] frontend bundle analyzer"
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "yarn --cwd packages/dashboard-frontend build --env bundleAnalyzer=true"
group:
kind: build
- id: backendbundleanalyzer
exec:
label: "[UD] backend bundle analyzer"
component: tools
workingDir: ${PROJECT_SOURCE}
commandLine: "yarn --cwd packages/dashboard-backend build --env bundleAnalyzer=true"
group:
kind: build
2 changes: 1 addition & 1 deletion packages/dashboard-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"copy-webpack-plugin": "^6.0.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-prettier": "^4.0.0",
"eslint-webpack-plugin": "^4.0.1",
"file-loader": "^6.2.0",
"jest": "^26.6.3",
"json-schema": "^0.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import {
import { createError } from './helpers/createError';
import { CustomObjectAPI, prepareCustomObjectAPI } from './helpers/prepareCustomObjectAPI';
import { startTimeoutSeconds } from '../../constants/server-config';
import { isLocalRun } from '../../localRun';
import { readFileSync } from 'fs';
import path from 'path';

const CUSTOM_RESOURCE_DEFINITIONS_API_ERROR_LABEL = 'CUSTOM_RESOURCE_DEFINITIONS_API_ERROR';

Expand All @@ -44,6 +47,11 @@ export class ServerConfigApiService implements IServerConfigApi {
}

async fetchCheCustomResource(): Promise<CustomResourceDefinition> {
if (isLocalRun()) {
return JSON.parse(
readFileSync(path.join(__dirname, '../../../../run/.custom-resources')).toString(),
);
}
if (!this.env.NAME || !this.env.NAMESPACE) {
throw createError(
undefined,
Expand Down
12 changes: 10 additions & 2 deletions packages/dashboard-backend/src/localRun/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ export function registerLocalRun(server: FastifyInstance) {

const isNativeAuth = process.env['NATIVE_AUTH'] === 'true';
const cheApiProxyUpstream = process.env['CHE_API_PROXY_UPSTREAM'] || '';
const cheHostOrigin = process.env.CHE_HOST_ORIGIN || '';
const dexIngress = process.env.DEX_INGRESS || '';
const cheHostOrigin = process.env.CHE_HOST_ORIGIN || '';
const cheInternalUrl = process.env.CHE_INTERNAL_URL || '';

let upstream: string;
if (cheInternalUrl) {
upstream = new URL(cheInternalUrl).origin;
} else {
upstream = cheApiProxyUpstream ? cheApiProxyUpstream : cheHostOrigin;
}

if (dexIngress) {
registerDexProxies(server, `https://${dexIngress}`);
Expand All @@ -43,5 +51,5 @@ export function registerLocalRun(server: FastifyInstance) {
if (isNativeAuth) {
authenticateApiRequestsHook(server);
}
registerCheApiProxy(server, cheApiProxyUpstream, cheHostOrigin);
registerCheApiProxy(server, upstream, cheHostOrigin);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ import { TextEncoder } from 'util';
(global as any).TextEncoder = TextEncoder;
import fastifyHttpProxy from '@fastify/http-proxy';

export function registerCheApiProxy(
server: FastifyInstance,
cheApiProxyUpstream: string,
origin: string,
) {
console.log(`Dashboard proxies requests to Che Server API on ${cheApiProxyUpstream}/api.`);
export function registerCheApiProxy(server: FastifyInstance, upstream: string, origin: string) {
console.log(`Dashboard proxies requests to Che Server API on ${upstream}/api.`);
// server api
server.register(fastifyHttpProxy, {
upstream: cheApiProxyUpstream ? cheApiProxyUpstream : origin,
upstream,
prefix: '/api/',
rewritePrefix: '/api/',
disableCache: true,
Expand Down
25 changes: 7 additions & 18 deletions packages/dashboard-backend/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,15 @@

const merge = require('webpack-merge');
const nodeExternals = require('webpack-node-externals');
const path = require('path');
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
const ESLintPlugin = require('eslint-webpack-plugin');
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');

const smp = new SpeedMeasurePlugin();

const common = require('./webpack.config.common');

const config = {
mode: 'development',
module: {
rules: [
{
test: /\.tsx?$/,
enforce: 'pre',
include: path.join(__dirname, 'src'),
exclude: /node_modules/,
use: [{
loader: 'eslint-loader',
options: {
cache: true,
}
}],
},
]
},
devtool: 'eval-source-map',
watchOptions: {
ignored: /node_modules/,
Expand All @@ -45,6 +29,11 @@ const config = {
externals: [
nodeExternals(),
],
plugins: [
new ESLintPlugin({
cache: true,
}),
],
};

module.exports = (env = {
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@
"css-loader": "^3.5.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-loader": "^4.0.2",
"eslint-plugin-notice": "^0.9.10",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-webpack-plugin": "^4.0.1",
"file-loader": "^6.0.0",
"hard-source-webpack-plugin": "^0.13.1",
"html-webpack-plugin": "^5.5.0",
Expand Down
20 changes: 6 additions & 14 deletions packages/dashboard-frontend/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const path = require('path');
const webpack = require('webpack');
const CleanTerminalPlugin = require('clean-terminal-webpack-plugin');
const StylelintPlugin = require('stylelint-webpack-plugin');
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
const ESLintPlugin = require('eslint-webpack-plugin');
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');

const smp = new SpeedMeasurePlugin();

Expand All @@ -26,18 +27,6 @@ const config = {
mode: 'development',
module: {
rules: [
{
test: /\.tsx?$/,
enforce: 'pre',
include: path.join(__dirname, 'src'),
exclude: /node_modules/,
use: [{
loader: 'eslint-loader',
options: {
cache: true,
}
}],
},
{
enforce: 'pre',
test: /\.(tsx|ts|jsx|js)$/,
Expand Down Expand Up @@ -79,9 +68,12 @@ const config = {
},
plugins: [
new webpack.DefinePlugin({
__isBrowser__: "true",
__isBrowser__: 'true',
'process.env.ENVIRONMENT': JSON.stringify('development'),
}),
new ESLintPlugin({
cache: true,
}),
new webpack.HotModuleReplacementPlugin(),
new CleanTerminalPlugin(),
new StylelintPlugin({
Expand Down
Loading