Skip to content

Commit

Permalink
build: Switch to @loopback/build
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondfeng committed Oct 31, 2017
1 parent 6eacee7 commit f3d3a26
Show file tree
Hide file tree
Showing 48 changed files with 691 additions and 574 deletions.
17 changes: 17 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"include": [
"packages/example-codehub/src/**",
"packages/*/dist*/*"
],
"exclude": [
"packages/core/*/promisify.*"
],
"extension": [
".js",
".ts"
],
"reporter": [
"html"
]
}

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packages/*/dist
packages/*/dist6
packages/*/api-docs
package.json
packages/*/package.json
77 changes: 0 additions & 77 deletions bin/compile-package.js

This file was deleted.

26 changes: 0 additions & 26 deletions bin/generate-apidocs.js

This file was deleted.

50 changes: 0 additions & 50 deletions bin/select-dist.js

This file was deleted.

33 changes: 6 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,29 @@
"cz-conventional-changelog": "^2.0.0",
"lerna": "^2.4.0",
"mocha": "^4.0.0",
"nyc": "^11.2.1",
"prettier": "^1.7.3",
"request": "^2.83.0",
"request-promise": "^4.2.2",
"strong-docs": "^1.6.0",
"tslint": "^5.7.0",
"typescript": "^2.5.3"
"request-promise": "^4.2.2"
},
"scripts": {
"bootstrap": "npm i && lerna bootstrap",
"coverage:ci": "nyc report --reporter=text-lcov | coveralls",
"coverage:ci": "node packages/build/bin/run-nyc report --reporter=text-lcov | coveralls",
"precoverage": "npm test",
"coverage": "open coverage/index.html",
"lint": "npm run prettier:check && npm run tslint",
"lint:fix": "npm run prettier:fix && npm run tslint:fix",
"tslint": "tslint -c tslint.full.json --project tsconfig.json",
"tslint": "node packages/build/bin/run-tslint --project tsconfig.json",
"tslint:fix": "npm run tslint -- --fix",
"prettier:cli": "prettier \"**/*.ts\"",
"prettier:cli": "node packages/build/bin/run-prettier \"**/*.ts\"",
"prettier:check": "npm run prettier:cli -- -l",
"prettier:fix": "npm run prettier:cli -- --write",
"clean": "lerna run --loglevel=silent clean",
"build": "lerna run --loglevel=silent build",
"build:current": "lerna run --loglevel=silent build:current",
"pretest": "npm run build:current",
"test": "nyc npm run mocha",
"mocha": "node bin/select-dist mocha --exit --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\"",
"test": "node packages/build/bin/run-nyc npm run mocha",
"mocha": "node packages/build/bin/select-dist mocha --exit --opts test/mocha.opts \"packages/*/DIST/test/**/*.js\"",
"posttest": "npm run lint"
},
"nyc": {
"include": [
"packages/example-codehub/src/**",
"packages/*/dist*/*"
],
"exclude": [
"packages/core/*/promisify.*"
],
"extension": [
".js",
".ts"
],
"reporter": [
"html"
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
Expand Down
17 changes: 9 additions & 8 deletions packages/authentication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
"node": ">=6"
},
"scripts": {
"acceptance": "node ../../bin/select-dist mocha --opts ../../test/mocha.opts 'DIST/test/acceptance/**/*.js'",
"acceptance": "lb-dist mocha --opts ../../test/mocha.opts 'DIST/test/acceptance/**/*.js'",
"build": "npm run build:dist && npm run build:dist6",
"build:current": "node ../../bin/compile-package",
"build:dist": "node ../../bin/compile-package es2017",
"build:dist6": "node ../../bin/compile-package es2015",
"build:apidocs": "node ../../bin/generate-apidocs",
"build:current": "lb-tsc",
"build:dist": "lb-tsc es2017",
"build:dist6": "lb-tsc es2015",
"build:apidocs": "lb-apidocs",
"clean": "rm -rf loopback-authentication*.tgz dist* package",
"integration": "node ../../bin/select-dist mocha --opts ../../test/mocha.opts 'DIST/test/integration/**/*.js'",
"integration": "lb-dist mocha --opts ../../test/mocha.opts 'DIST/test/integration/**/*.js'",
"prepublish": "npm run build && npm run build:apidocs",
"pretest": "npm run build:current",
"test": "node ../../bin/select-dist mocha --opts ../../test/mocha.opts 'DIST/test/unit/**/*.js' 'DIST/test/integration/**/*.js' 'DIST/test/acceptance/**/*.js'",
"unit": "node bin/select-dist mocha --opts ../../test/mocha.opts 'DIST/test/unit/**/*.js'",
"test": "lb-dist mocha --opts ../../test/mocha.opts 'DIST/test/unit/**/*.js' 'DIST/test/integration/**/*.js' 'DIST/test/acceptance/**/*.js'",
"unit": "lb-dist mocha --opts ../../test/mocha.opts 'DIST/test/unit/**/*.js'",
"verify": "npm pack && tar xf loopback-authentication*.tgz && tree package && npm run clean"
},
"author": "IBM",
Expand All @@ -32,6 +32,7 @@
"passport-strategy": "^1.0.0"
},
"devDependencies": {
"@loopback/build": "^4.0.0-alpha.1",
"@loopback/openapi-spec-builder": "^4.0.0-alpha.8",
"@loopback/testlab": "^4.0.0-alpha.10",
"passport-http": "^0.3.0"
Expand Down
7 changes: 2 additions & 5 deletions packages/authentication/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.common.json",
"extends": "../build/config/tsconfig.common.json",
"compilerOptions": {
"rootDir": "."
},
"include": [
"src",
"test"
]
"include": ["src", "test"]
}
7 changes: 0 additions & 7 deletions packages/build/CODEOWNERS

This file was deleted.

59 changes: 55 additions & 4 deletions packages/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
The module contains a set of common scripts and default configurations to
build LoopBack 4 modules, including:

- lb-tsc: Use `tsc` to compile typescript files
- lb-tsc: Use [`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) to compile typescript files
- lb-dist: Detect the correct distribution target: `dist` => ES2017, `dist6` => ES2015
- lb-tslint: Run `tslint` with `<project>/tslint.build.json`
- lb-prettier: Run `prettier`
- lb-tslint: Run [`tslint`](https://github.com/palantir/tslint)
- lb-prettier: Run [`prettier`](https://github.com/prettier/prettier)
- lb-nyc: Run [`nyc`](https://github.com/istanbuljs/nyc)

These scripts first try to locate the CLI from target project dependencies and fall back to bundled ones in `@loopback/build`.

# Usage

Expand Down Expand Up @@ -40,7 +43,55 @@ To use `@loopback/build` for your package:
},
```

3. Run builds
3. Override default configurations in your project

- lb-tsc
- Create `tsconfig.build.json` in your project's root directory
```json
{
"$schema": "http://json.schemastore.org/tsconfig",
"extends": "./node_modules/@loopback/build/config/tsconfig.common.json",
"compilerOptions": {
"rootDir": "."
},
"include": ["src", "test"]
}
```
- Set options for the script
```
lb-tsc -p tsconfig.json
```

- lb-tslint
- Create `tslint.build.json` in your project's root directory
```json
{
"$schema": "http://json.schemastore.org/tslint",
"extends": [
"./node_modules/@loopback/build/config/tslint.common.json"
],
// This configuration files enabled rules which require type checking
// and therefore cannot be run by Visual Studio Code TSLint extension
// See https://github.com/Microsoft/vscode-tslint/issues/70
"rules": {
// These rules find errors related to TypeScript features.


// These rules catch common errors in JS programming or otherwise
// confusing constructs that are prone to producing bugs.

"await-promise": true,
"no-floating-promises": true,
"no-void-expression": [true, "ignore-arrow-function-shorthand"]
}
}
```
- Set options for the script
``
lb-tslint -c tslint.json -p tsconfig.json
```

4. Run builds

```
npm run build
Expand Down
Loading

0 comments on commit f3d3a26

Please sign in to comment.