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

feat(stark-testing): create separate stark-testing package and use it in all stark packages and starter #267

Merged
merged 5 commits into from
Mar 23, 2018
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
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ PACKAGES=(stark-core)
TSC_PACKAGES=()

# Packages that should not be compiled at all
NODE_PACKAGES=(stark-build)
NODE_PACKAGES=(stark-build stark-testing)

ALL_PACKAGES=(stark-build stark-core)
ALL_PACKAGES=(stark-build stark-testing stark-core)

BUILD_ALL=true
BUNDLE=true
Expand Down
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,24 @@
"stylelint-check": "stylelint-config-prettier-check",
"tsc": "tsc",
"ngc": "ngc",
"postinstall": "npm run postinstall:build && npm run postinstall:core && npm run build && npm run update:starter",
"postinstall": "npm run postinstall:build && npm run postinstall:testing && npm run postinstall:core && npm run build && npm run update:starter",
"postinstall:build": "cd packages/stark-build && npm install && cd ../..",
"postinstall:core": "cd packages/stark-core && npm install && cd ../..",
"postinstall:testing": "cd packages/stark-testing && npm install && cd ../..",
"build": "sh ./build.sh",
"build:stark-build": "sh ./build.sh --packages=stark-build",
"build:stark-core": "sh ./build.sh --packages=stark-core",
"build:build": "sh ./build.sh --packages=stark-build",
"build:core": "sh ./build.sh --packages=stark-core",
"build:testing": "sh ./build.sh --packages=stark-testing",
"preupdate:starter": "npm run clean:starter",
"update:starter": "cd starter && npm install && cd ..",
"starter": "cd starter && npm start && cd ..",
"clean": "rimraf ./dist",
"clean:stark-core": "cd packages/stark-core && rimraf ./node_modules/@nationalbankbelgium/stark-build && cd ../..",
"clean:core": "cd packages/stark-core && rimraf ./node_modules/@nationalbankbelgium/stark-build && cd ../..",
"clean:starter": "cd starter && rimraf ./dist && rimraf ./node_modules/@nationalbankbelgium && cd ..",
"clean:all": "npm run clean && npm run clean:stark-core && npm run clean:starter"
"clean:all": "npm run clean && npm run clean:core && npm run clean:starter",
"test:core": "cd packages/stark-core && npm run test-fast && cd ../..",
"test:starter": "cd starter && npm run test-fast && cd ../..",
"test:all": "npm run test:core && npm run test:starter"
},
"lint-staged": {
"*.{css,js,json,pcss,scss,ts}": [
Expand Down
9 changes: 0 additions & 9 deletions packages/stark-build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@
"husky": "0.14.3",
"imports-loader": "0.8.0",
"inline-manifest-webpack-plugin": "3.0.1",
"istanbul-instrumenter-loader": "3.0.0",
"karma": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "1.1.1",
"karma-jasmine": "1.1.1",
"karma-mocha-reporter": "2.2.5",
"karma-remap-coverage": "0.1.5",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "2.0.9",
"lint-staged": "7.0.0",
"node-sass": "4.7.2",
"postcss-cssnext": "3.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/stark-core/karma.conf.typescript.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* Look in ./config for karma.conf.js
* Look in stark-testing for karma.conf.typescript.js
*/
module.exports = require("./node_modules/@nationalbankbelgium/stark-build/config/karma.conf.typescript.js");
module.exports = require("./node_modules/@nationalbankbelgium/stark-testing/karma.conf.typescript.js");
17 changes: 4 additions & 13 deletions packages/stark-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,11 @@
},
"dependencies": {
"@types/core-js": "0.9.46",
"@types/jasmine": "2.5.36",
"@types/node": "6.0.101",
"@types/node": "6.0.102",
"cerialize": "0.1.18",
"class-validator": "0.7.3",
"core-js": "2.5.3",
"deep-freeze-strict": "1.1.1",
"jasmine-core": "2.99.1",
"karma": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-jasmine": "1.1.1",
"karma-mocha-reporter": "2.2.5",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.32",
"karma-typescript": "3.0.12",
"karma-typescript-angular2-transform": "1.0.2",
"rxjs": "5.5.6",
"zone.js": "0.8.20"
},
Expand All @@ -47,7 +37,8 @@
"@angular/compiler-cli": "5.2.9",
"@angular/core": "5.2.9",
"@angular/platform-browser": "5.2.9",
"@angular/platform-browser-dynamic": "5.2.9"
"@angular/platform-browser-dynamic": "5.2.9",
"@nationalbankbelgium/stark-testing": "../stark-testing"
},
"peerDependencies": {
"@angular/common": "5.x",
Expand All @@ -56,7 +47,7 @@
"@angular/platform-browser-dynamic": "5.x"
},
"scripts": {
"test-fast": "karma start karma.conf.typescript.js",
"test-fast": "node ./node_modules/@nationalbankbelgium/stark-testing/node_modules/karma/bin/karma start ./karma.conf.typescript.js",
"tsc": "tsc -p tsconfig.json"
}
}
6 changes: 5 additions & 1 deletion packages/stark-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"typeRoots": ["./node_modules/@types"],
"typeRoots": [
"./node_modules/@types",
"./node_modules/@nationalbankbelgium/stark-testing/node_modules/@types"
],
"lib": ["dom", "dom.iterable", "es2017"],
"paths": {
"rxjs/*": ["../../node_modules/rxjs/*"],
"@angular/*": ["node_modules/@angular/*"],
"@nationalbankbelgium/stark-core": ["."]
},
"outDir": "../../dist/packages/stark-core"
Expand Down
6 changes: 1 addition & 5 deletions packages/stark-core/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"paths": {
"@angular/*": ["node_modules/@angular/*"],
"@nationalbankbelgium/stark-build/*": ["node_modules/@nationalbankbelgium/stark-build/*"]
}
"module": "commonjs"
},
"files": null,
"include": ["**/*.ts"],
Expand Down
11 changes: 11 additions & 0 deletions packages/stark-testing/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require("path");

/**
* Helper functions.
*/
// const ROOT = path.resolve(__dirname, '..');
const _root = path.resolve(process.cwd(), "."); // project root folder

const root = path.join.bind(path, _root);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not put a peerDependency on @nbb/stark-build and use helpers directly from stark-build ?
Except if we only plan to use root(). But maybe later for e2e we will use other methods already defined stark-build/config/helpers.js.

What do you think about that ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the idea is to make Stark as flexible as possible, so normally all the testing tooling is just a decision we made in Stark and should not have any impact in the final users of Stark (install our deps in their project) if they decide use another tooling.

So, we should keep this package as independent as possible, because again, Stark is really flexible and the stark-build might not be the package selected by the user to build their app...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, we can review this later once we have a better view on how all our packages will be used in a client app.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for me


exports.root = root;
38 changes: 38 additions & 0 deletions packages/stark-testing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@nationalbankbelgium/stark-testing",
"version": "0.0.0-PLACEHOLDER-VERSION",
"main": "karma.conf.typescript.js",
"types": "stark-testing.d.ts",
"description": "Stark - Testing",
"author": "Stark Team",
"contributors": [
"PLACEHOLDER-CONTRIBUTORS"
],
"license": "MIT",
"bugs": "https://github.com/nationalbankbelgium/stark/issues",
"homepage": "https://github.com/nationalbankbelgium/stark",
"repository": {
"type": "git",
"url": "https://github.com/NationalBankBelgium/stark.git"
},
"engines": {
"node": ">=6.11.0",
"npm": ">=5.3.0"
},
"dependencies": {
"@types/jasmine": "2.8.6",
"@types/node": "6.0.102",
"istanbul-instrumenter-loader": "3.0.0",
"jasmine-core": "2.99.1",
"karma": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "1.1.1",
"karma-jasmine": "1.1.1",
"karma-mocha-reporter": "2.2.5",
"karma-remap-coverage": "0.1.5",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.32",
"karma-typescript": "3.0.12",
"karma-typescript-angular2-transform": "1.0.2"
}
}
20 changes: 20 additions & 0 deletions packages/stark-testing/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use strict";

const resolve = require("rollup-plugin-node-resolve");
const commonjs = require("rollup-plugin-commonjs");

module.exports = {
//export default {
input: "../../dist/packages-dist/stark-testing/karma.conf.typescript.js",
output: [
{
file: "../../dist/packages-dist/stark-testing/stark-testing.js",
format: "cjs",
name: "stark.testing"
}
],
plugins: [
resolve(),
commonjs() // converts date-fns to ES modules
]
};
1 change: 1 addition & 0 deletions packages/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"typeRoots": [
"./stark-build/node_modules/@types",
"./stark-core/node_modules/@types",
"./stark-testing/node_modules/@types",
"./stark-ui/node_modules/@types"
]
},
Expand Down
2 changes: 1 addition & 1 deletion starter/karma.conf.typescript.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* Look in ./config for karma.conf.js
*/
module.exports = require("./node_modules/@nationalbankbelgium/stark-build/config/karma.conf.typescript.js");
module.exports = require("./node_modules/@nationalbankbelgium/stark-testing/karma.conf.typescript.js");
13 changes: 2 additions & 11 deletions starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"@nationalbankbelgium/angular-mdi-svg": "1.7.0",
"@nationalbankbelgium/stark-build": "file:../dist/packages-dist/stark-build/nationalbankbelgium-stark-build-10.0.0-alpha.0-c691d71.tgz",
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.0.0-alpha.0-c691d71.tgz",
"@nationalbankbelgium/stark-testing": "file:../dist/packages-dist/stark-testing/nationalbankbelgium-stark-testing-10.0.0-alpha.0-c691d71.tgz",
"@uirouter/angular": "1.0.1",
"@uirouter/visualizer": "6.0.0",
"core-js": "2.5.3",
Expand All @@ -131,22 +132,12 @@
"devDependencies": {
"@types/core-js": "0.9.46",
"@types/hammerjs": "2.0.35",
"@types/jasmine": "2.8.6",
"@types/node": "6.0.101",
"@types/node": "6.0.102",
"@types/source-map": "0.5.2",
"@types/uglify-js": "2.6.30",
"cross-env": "^5.0.0",
"find-root": "^1.0.0",
"gh-pages": "^1.0.0",
"jasmine-core": "2.99.1",
"karma": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-jasmine": "1.1.1",
"karma-mocha-reporter": "2.2.5",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.32",
"karma-typescript": "3.0.12",
"karma-typescript-angular2-transform": "1.0.2",
"npm-run-all": "^4.0.2",
"optimize-js-plugin": "0.0.4",
"parse5": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion starter/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"baseUrl": "./src",
"declaration": false,
"lib": ["es2015", "dom"],
"lib": ["dom", "dom.iterable", "es2017"],
"typeRoots": ["./node_modules/@types"],
"paths": {
"@angular/*": ["../node_modules/@angular/*"],
Expand Down
9 changes: 1 addition & 8 deletions starter/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"typeRoots": ["./node_modules/@types"],
"lib": ["dom", "dom.iterable", "es2017"],
"paths": {
"@angular/*": ["node_modules/@angular/*"],
"@nationalbankbelgium/stark-build/*": ["node_modules/@nationalbankbelgium/stark-build/*"],
"@nationalbankbelgium/stark-core/*": ["node_modules/@nationalbankbelgium/stark-core/*"]
}
"module": "commonjs"
},

"angularCompilerOptions": {
Expand Down