Skip to content

Commit

Permalink
ci: ensure unified tsconfig and remove mocks, test, stories from build (
Browse files Browse the repository at this point in the history
#436)

* ci: ensure unified tsconfig and remove mocks,test,stories from build
* ci: move certificates into certificate folder inside script

Signed-off-by: Nastya Rusina <[email protected]>
  • Loading branch information
anrusina committed May 17, 2022
1 parent 92987f5 commit 13fa646
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 114 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,4 @@ yarn-error.log

# Certs
.srl
script/rootCA.*
script/server.crt
script/server.csr
script/server.key
certificate/
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"packages/zapp/**"
],
"scripts": {
"clean": "yarn workspace @flyteconsole/client-app clean",
"start": "yarn workspace @flyteconsole/client-app start",
"start:prod": "yarn workspace @flyteconsole/client-app start:prod",
"build:prod": "yarn workspace @flyteconsole/client-app build:prod",
Expand Down
7 changes: 7 additions & 0 deletions packages/zapp/console/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const BASE_URL = process.env.BASE_URL || '';
*/
const ASSETS_PATH = `${BASE_URL}/assets/`;

/**
* Certificate path required for local development, should not include trailing '/'.
* Located at top level of the repository in script folder
*/
const CERTIFICATE_PATH = '../../../script/certificate';

// Defines a file to be required which will provide implementations for
// any user-definable code.
const PLUGINS_MODULE = process.env.PLUGINS_MODULE;
Expand All @@ -43,6 +49,7 @@ module.exports = {
ENABLE_GA,
GA_TRACKING_ID,
ASSETS_PATH,
CERTIFICATE_PATH,
LOCAL_DEV_HOST,
processEnv: {
ADMIN_API_URL,
Expand Down
4 changes: 2 additions & 2 deletions packages/zapp/console/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const port = process.env.PORT || 3000;
if (env.ADMIN_API_USE_SSL === 'https') {
const fs = require('fs');
const https = require('https');
var privateKey = fs.readFileSync('../../../script/server.key');
var certificate = fs.readFileSync('../../../script/server.crt');
var privateKey = fs.readFileSync(`${env.CERTIFICATE_PATH}/server.key`);
var certificate = fs.readFileSync(`${env.CERTIFICATE_PATH}/server.crt`);

server = https
.createServer(
Expand Down
1 change: 0 additions & 1 deletion packages/zapp/console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"main": "index.js",
"scripts": {
"clean": "rm -rf dist",
"prebuild": "yarn run clean",
"build": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' webpack --config webpack.dev.config.ts --mode=development",
"build:prod": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' NODE_ENV=production webpack --config webpack.prod.config.ts --mode=production --progress",
"start": "webpack serve --open --config webpack.dev.config.ts --hot",
Expand Down
1 change: 0 additions & 1 deletion packages/zapp/console/src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { env } from 'common/env';
import { Protobuf } from 'flyteidl';
import * as Long from 'long';

Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { makeStyles, Theme } from '@material-ui/core/styles';
import { BlobDimensionality } from 'models/Common/types';
import * as React from 'react';
import { blobFormatHelperText, blobUriHelperText, defaultBlobValue } from './constants';
import { blobFormatHelperText, blobUriHelperText } from './constants';
import { InputProps } from './types';
import { getLaunchInputId, isBlobValue } from './utils';

Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Checkbox, debounce, FormControlLabel, FormGroup, Typography } from '@material-ui/core';
import { Checkbox, debounce, FormControlLabel, FormGroup } from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { NamedEntity } from 'models/Common/types';
import * as React from 'react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ export const SearchableList = <T extends {}>(props: SearchableListProps<T>) => {
);
};

export { SearchResult, PropertyGetter };
export type { SearchResult, PropertyGetter };
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Typography } from '@material-ui/core';
import { makeStyles, Theme } from '@material-ui/core/styles';
import { listhoverColor, separatorColor } from 'components/Theme/constants';
import { NamedEntity } from 'models/Common/types';
Expand Down
Empty file.
56 changes: 9 additions & 47 deletions packages/zapp/console/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,16 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowJs": true,
"baseUrl": "src",
"checkJs": false,
"downlevelIteration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"jsx": "react",
"lib": ["es6", "es2021", "dom", "dom.iterable"],
"module": "commonjs",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitAny": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"baseUrl": "./src",
"outDir": "./dist",
"removeComments": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es6",
"types": ["node", "webpack-env", "jest", "@testing-library/jest-dom"],

"composite": true,
"paths": {
"@flyteconsole/*": ["../../plugins/*/src"]
}
// TODO: this items should be removed when violations are fixed:
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitAny": false,
"exactOptionalPropertyTypes": false,
"noImplicitOverride": false
},
"references": [{ "path": "../../plugins/components" }],
// "extends": "../../../tsconfig.base.json",
// "compilerOptions": {
// "rootDir": "./src",
// "outDir": "./dist"
// },
// "references": [{ "path": "../../plugins/components" }],
"include": ["src/**/*"],
"exclude": [
"**/__mocks__",
"**/test",
"**/mocks",
// baseline
"**/node_modules",
"**/dist",
"**/lib",
"**/src/**/*.spec.*",
"**/src/**/*.test.*",
"**/src/**/*.stories.*"
]
"include": ["src/**/*"]
}
23 changes: 20 additions & 3 deletions packages/zapp/console/webpack.dev.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import * as webpack from 'webpack';
import * as HTMLWebpackPlugin from 'html-webpack-plugin';
import * as path from 'path';
import { processEnv as env, LOCAL_DEV_HOST } from './env';
import chalk from 'chalk';
import { LOCAL_DEV_HOST, CERTIFICATE_PATH } from './env';

const { merge } = require('webpack-merge');
const fs = require('fs');
const common = require('./webpack.common.config');

const devtool = 'eval-cheap-module-source-map';

// Check if certificate provided and if not - exit early
if (
!fs.existsSync(`${CERTIFICATE_PATH}/server.key`) ||
!fs.existsSync(`${CERTIFICATE_PATH}/server.crt`)
) {
console.log(
chalk.red(`ERROR: Can not locate server.key and server.crt in ${CERTIFICATE_PATH} location`),
);
console.log(
chalk.red('Please re-genereate your site certificates by running'),
'make generate_ssl',
chalk.red('than re-run the command'),
);
process.exit(0);
}

/**
* Client configuration
*
Expand All @@ -27,8 +44,8 @@ export const clientConfig: webpack.Configuration = merge(common.default.clientCo
server: {
type: 'https',
options: {
key: fs.readFileSync('../../../script/server.key'),
cert: fs.readFileSync('../../../script/server.crt'),
key: fs.readFileSync(`${CERTIFICATE_PATH}/server.key`),
cert: fs.readFileSync(`${CERTIFICATE_PATH}/server.crt`),
},
},
client: {
Expand Down
15 changes: 9 additions & 6 deletions script/generate_ssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

script="$0"
basename="$(dirname $script)"

echo "Script name $script resides in $basename directory."
output="$basename/certificate"

openssl genrsa -des3 -out "$basename/rootCA.key" 2048
openssl req -x509 -new -nodes -key "$basename/rootCA.key" -sha256 -days 1024 -out "$basename/rootCA.pem"
openssl req -new -sha256 -nodes -out "$basename/server.csr" -newkey rsa:2048 -keyout "$basename/server.key" -config <( cat "$basename/server.csr.cnf" )
openssl x509 -req -in "$basename/server.csr" -CA "$basename/rootCA.pem" -CAkey "$basename/rootCA.key" -CAcreateserial -out "$basename/server.crt" -days 500 -sha256 -extfile "$basename/v3.ext"
echo "Script name $script resides in $basename directory. Output would be written to: $output"

mkdir -p $output

openssl genrsa -des3 -out "$output/rootCA.key" 2048
openssl req -x509 -new -nodes -key "$output/rootCA.key" -sha256 -days 1024 -out "$output/rootCA.pem"
openssl req -new -sha256 -nodes -out "$output/server.csr" -newkey rsa:2048 -keyout "$output/server.key" -config <( cat "$basename/server.csr.cnf" )
openssl x509 -req -in "$output/server.csr" -CA "$output/rootCA.pem" -CAkey "$output/rootCA.key" -CAcreateserial -out "$output/server.crt" -days 500 -sha256 -extfile "$basename/v3.ext"
79 changes: 33 additions & 46 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,47 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"allowJs": true,
"strict": true,
"checkJs": false,
"downlevelIteration": true,
"allowJs": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"removeComments": false,
"importHelpers": true,

"jsx": "react",
"lib": ["es6", "es2021", "dom", "dom.iterable"],
// TODO: switch target to "esnext" when babel would be removed.
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noImplicitAny": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"outDir": "./dist",
"removeComments": false,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es6",
"types": ["node", "webpack-env", "jest"],

// "lib": ["dom", "dom.iterable", "es2018"],
// "jsx": "react",
// "target": "esnext",
// "module": "commonjs",
// "moduleResolution": "node",
"types": ["node", "webpack-env", "jest", "@testing-library/jest-dom"],

// "allowJs": false,
// "allowUnreachableCode": false,
// "esModuleInterop": true,
// "strict": true,
// "isolatedModules": true,
// "declaration": true,
// "noUnusedLocals": true,
// "noUnusedParameters": true,
// "noImplicitReturns": true,
// "noImplicitThis": true,
// "noImplicitAny": true,
// "importHelpers": true,
// "declarationMap": true,
// "useDefineForClassFields": true,
// "useUnknownInCatchVariables": false,
// "resolveJsonModule": true,
// "experimentalDecorators": true,
// "skipLibCheck": true,
"isolatedModules": true,
"declaration": true,
"declarationMap": true,
"downlevelIteration": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"useDefineForClassFields": true,
"useUnknownInCatchVariables": false,

// // More strict
// "exactOptionalPropertyTypes": false, // true,
// "noUncheckedIndexedAccess": false,
// "noFallthroughCasesInSwitch": true,
// "noPropertyAccessFromIndexSignature": false,
// "noImplicitOverride": true,
// More strict rules
"exactOptionalPropertyTypes": true,
"noUncheckedIndexedAccess": false,
"noPropertyAccessFromIndexSignature": false,
"noImplicitOverride": true,
"noFallthroughCasesInSwitch": true,

"sourceMap": true,
"composite": true,
"baseUrl": ".",
"outDir": "./dist",
"paths": {
"@flyteconsole/*": ["./packages/plugins/*/src", "./packages/zapp/*/src"]
}
Expand All @@ -69,6 +52,10 @@
"**/lib",
"**/src/**/*.spec.*",
"**/src/**/*.test.*",
"**/src/**/*.stories.*"
"**/src/**/*.stories.*",
// old code patterns
"**/__mocks__",
"**/test",
"**/mocks"
]
}

0 comments on commit 13fa646

Please sign in to comment.