Skip to content

Commit

Permalink
Initial commit with typescript + husky
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesAPetts committed Nov 3, 2020
0 parents commit 0b3379a
Show file tree
Hide file tree
Showing 33 changed files with 17,200 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Use the latest 2.1 version of CircleCI pipeline processing engine, see https://circleci.com/docs/2.0/configuration-reference/
version: 2.1

defaults: &defaults
working_directory: ~/repo
# https://circleci.com/docs/2.0/circleci-images/#language-image-variants
docker:
- image: circleci/node:10.15.1
environment:
TERM: xterm # Enable colors in term

jobs:
CHECKOUT:
<<: *defaults
steps:
- checkout
- restore_cache:
name: Restore Package Cache
keys:
- packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }}
- packages-v1-{{ .Branch }}-
- packages-v1-
- run: yarn install
- save_cache:
name: Save Package Cache
paths:
- ~/.cache/yarn
key: packages-v1-{{ .Branch }}-{{ checksum "yarn.lock" }}
- persist_to_workspace:
root: ~/repo
paths: .

BUILD:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run: npm run build && npm run build:release
# https://circleci.com/docs/2.0/collect-test-data/#karma
# - store_test_results:
# path: reports/junit
# - store_artifacts:
# path: reports/junit
- persist_to_workspace:
root: ~/repo
paths: .

NPM_PUBLISH:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Avoid hosts unknown for github
command:
mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking
no\n" > ~/.ssh/config
- run:
name: Publish using Semantic Release
command: npx [email protected] --debug

workflows:
version: 2

# PULL REQUEST
PULL_REQUEST:
jobs:
- CHECKOUT:
filters:
branches:
ignore:
- master
- feature/*
- hotfix/*
- BUILD:
requires:
- CHECKOUT

# MERGE TO MASTER
TEST_AND_RELEASE:
jobs:
- CHECKOUT:
filters:
branches:
only: master
- BUILD:
requires:
- CHECKOUT
- NPM_PUBLISH:
requires:
- BUILD
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.css
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"extends": [
"react-app",
"eslint:recommended",
"plugin:react/recommended",
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint"],
"parser": "babel-eslint",
"env": {
"jest": true
},
"settings": {
"react": {
"version": "detect"
}
},
"globals": {
"context": true,
"assert": true
},
"rules": {
"no-console": "warn",
"no-undef": "warn",
"no-unused-vars": "warn"
}
}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# dependencies
node_modules

# builds
build
dist
.rpt2_cache

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
.idea
.yalc
yalc.lock
package-lock.json
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"trailingComma": "es5",
"printWidth": 80,
"proseWrap": "always",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
3 changes: 3 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"branch": "master"
}
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}
30 changes: 30 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"editor.rulers": [80, 120],

// ===
// Spacing
// ===

"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.trimAutoWhitespace": true,
"files.trimTrailingWhitespace": true,
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,

// ===
// Event Triggers
// ===

"editor.formatOnSave": true,
"eslint.autoFixOnSave": true,
"eslint.run": "onSave",
"eslint.validate": [
{ "language": "javascript", "autoFix": true },
{ "language": "javascriptreact", "autoFix": true }
],
"prettier.disableLanguages": [],
"prettier.endOfLine": "lf",
"workbench.colorCustomizations": {}
}
102 changes: 102 additions & 0 deletions .webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
const path = require('path');
const webpack = require('webpack');
const autoprefixer = require('autoprefixer');
// Plugins
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin;
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

// const ENTRY_VTK_EXT = path.join(__dirname, './../tsDist/src/index.js');
// const SRC_PATH = path.join(__dirname, './../tsDist/src');

const ENTRY_VTK_EXT = path.join(__dirname, './../src/index.js');
const SRC_PATH = path.join(__dirname, './../src');
const OUT_PATH = path.join(__dirname, './../dist');

/**
* `argv` are options from the CLI. They will override our config here if set.
* `-d` - Development shorthand, sets `debug`, `devtool`, and `mode`
* `-p` - Production shorthand, sets `minimize`, `NODE_ENV`, and `mode`
*/
module.exports = (env, argv) => {
const isProdBuild = argv.mode !== 'development';
const outputFilename = isProdBuild ? '[name].umd.min.js' : '[name].umd.js';

return {
entry: {
index: ENTRY_VTK_EXT,
},
devtool: 'source-map',
output: {
path: OUT_PATH,
filename: outputFilename,
library: 'VTKViewport',
libraryTarget: 'umd',
globalObject: 'this',
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: ['ts-loader'],
},
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: () => [autoprefixer('last 2 version', 'ie >= 10')],
},
},
],
},
],
},
resolve: {
modules: [path.resolve(__dirname, './../node_modules'), SRC_PATH],
},
externals: [
// :wave:
/\b(vtk.js)/,
// Used to build/load metadata
{
'cornerstone-core': {
commonjs: 'cornerstone-core',
commonjs2: 'cornerstone-core',
amd: 'cornerstone-core',
root: 'cornerstone',
},
'cornerstone-tools': {
commonjs: 'cornerstone-tools',
commonjs2: 'cornerstone-tools',
amd: 'cornerstone-tools',
root: 'cornerstoneTools',
},
//
react: 'react',
},
],
node: {
// https://github.com/webpack-contrib/style-loader/issues/200
Buffer: false,
},
plugins: [
// Uncomment to generate bundle analyzer
// new BundleAnalyzerPlugin(),
// Show build progress
new webpack.ProgressPlugin(),
// Clear dist between builds
// new CleanWebpackPlugin(),
],
};
};
Loading

0 comments on commit 0b3379a

Please sign in to comment.