@loopback/build 5.4.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,59 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.1.0](https://github.com/strongloop/loopback-next/compare/@loopback/build@6.0.0...@loopback/build@6.1.0) (2020-06-30)
7
+
8
+
9
+ ### Features
10
+
11
+ * **build:** add a helper to merge mocha config objects ([3ce9eef](https://github.com/strongloop/loopback-next/commit/3ce9eefdb3a286f2d2b2690ec471f00d8124efb9))
12
+
13
+
14
+
15
+
16
+
17
+ # [6.0.0](https://github.com/strongloop/loopback-next/compare/@loopback/build@5.4.3...@loopback/build@6.0.0) (2020-06-23)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * set node version to >=10.16 to support events.once ([e39da1c](https://github.com/strongloop/loopback-next/commit/e39da1ca47728eafaf83c10ce35b09b03b6a4edc))
23
+
24
+
25
+ ### Features
26
+
27
+ * **build:** upgrade to mocha 8.x ([c83270d](https://github.com/strongloop/loopback-next/commit/c83270dbdbe42e1e17fabc7b81c345df45e869d8))
28
+
29
+
30
+ ### BREAKING CHANGES
31
+
32
+ * **build:** After have upgraded to `mocha` version 8, which no longer
33
+ supports `--opts` and `test/mocha.opts`. It may break your application
34
+ if it depends on earlier version of `@loopback/build` for `npm test`.
35
+
36
+ See a list of breaking changes of mocha 8.x at:
37
+ https://github.com/mochajs/mocha/releases/tag/v8.0.0
38
+
39
+
40
+
41
+
42
+
43
+ ## [5.4.3](https://github.com/strongloop/loopback-next/compare/@loopback/build@5.4.2...@loopback/build@5.4.3) (2020-06-11)
44
+
45
+ **Note:** Version bump only for package @loopback/build
46
+
47
+
48
+
49
+
50
+
51
+ ## [5.4.2](https://github.com/strongloop/loopback-next/compare/@loopback/build@5.4.1...@loopback/build@5.4.2) (2020-05-28)
52
+
53
+ **Note:** Version bump only for package @loopback/build
54
+
55
+
56
+
57
+
58
+
6
59
  ## [5.4.1](https://github.com/strongloop/loopback-next/compare/@loopback/build@5.4.0...@loopback/build@5.4.1) (2020-05-20)
7
60
 
8
61
  **Note:** Version bump only for package @loopback/build
@@ -102,11 +102,13 @@ function run(argv, options) {
102
102
 
103
103
  const args = [];
104
104
 
105
- const cwd = process.env.LERNA_ROOT_PATH || process.cwd();
105
+ let cwd = process.env.LERNA_ROOT_PATH || process.cwd();
106
106
  if (tsConfigFile && fs.existsSync(tsConfigFile)) {
107
107
  const tsconfig = require(tsConfigFile);
108
108
  if (tsconfig.references) {
109
109
  args.unshift('-b');
110
+ // Reset the cwd for a composite project
111
+ cwd = process.cwd();
110
112
  } else {
111
113
  // Make the config file relative the current directory
112
114
  args.push('-p', path.relative(cwd, tsConfigFile));
package/bin/run-mocha.js CHANGED
@@ -24,7 +24,6 @@ function run(argv, options) {
24
24
  !utils.isOptionSet(
25
25
  mochaOpts,
26
26
  '--config', // mocha 6.x
27
- '--opts', // legacy
28
27
  '--package', // mocha 6.x
29
28
  '--no-config', // mocha 6.x
30
29
  ) && !utils.mochaConfiguredForProject();
package/bin/utils.js CHANGED
@@ -228,7 +228,6 @@ function mochaConfiguredForProject() {
228
228
  '.mocharc.json',
229
229
  '.mocharc.yaml',
230
230
  '.mocharc.yml',
231
- 'test/mocha.opts',
232
231
  ];
233
232
  return configFiles.some(f => {
234
233
  const configFile = path.join(getPackageDir(), f);
@@ -1,5 +1,5 @@
1
1
  {
2
- "require": "source-map-support/register",
2
+ "require": ["source-map-support/register"],
3
3
  "recursive": true,
4
4
  "exit": true,
5
5
  "reporter": "dot"
package/index.js CHANGED
@@ -20,3 +20,5 @@ exports.typeScriptPath = path.resolve(
20
20
  require.resolve('typescript/package.json'),
21
21
  '..',
22
22
  );
23
+
24
+ exports.mergeMochaConfigs = require('./src/merge-mocha-configs');
package/package.json CHANGED
@@ -1,46 +1,50 @@
1
1
  {
2
- "name": "@loopback/build",
3
- "description": "Build scripts and configuration files for LoopBack 4 modules",
4
- "repository": {
5
- "type": "git",
6
- "url": "https://github.com/strongloop/loopback-next.git",
7
- "directory": "packages/build"
8
- },
9
- "version": "5.4.1",
10
- "engines": {
11
- "node": ">=10"
12
- },
13
- "author": "IBM Corp.",
14
- "main": "index.js",
15
- "copyright.owner": "IBM Corp.",
16
- "license": "MIT",
17
- "dependencies": {
18
- "@loopback/eslint-config": "^7.0.1",
19
- "@types/mocha": "^7.0.2",
20
- "@types/node": "^10.17.24",
21
- "cross-spawn": "^7.0.2",
22
- "debug": "^4.1.1",
23
- "eslint": "^7.0.0",
24
- "fs-extra": "^9.0.0",
25
- "glob": "^7.1.6",
26
- "mocha": "^7.1.2",
27
- "nyc": "^15.0.1",
28
- "prettier": "^2.0.5",
29
- "rimraf": "^3.0.2",
30
- "source-map-support": "^0.5.19",
31
- "typescript": "~3.9.3"
32
- },
33
- "bin": {
34
- "lb-tsc": "./bin/compile-package.js",
35
- "lb-eslint": "./bin/run-eslint.js",
36
- "lb-prettier": "./bin/run-prettier.js",
37
- "lb-mocha": "./bin/run-mocha.js",
38
- "lb-nyc": "./bin/run-nyc.js",
39
- "lb-clean": "./bin/run-clean.js"
40
- },
41
- "scripts": {
42
- "test": "npm run mocha",
43
- "mocha": "node bin/run-mocha --timeout 30000 \"test/integration/*.js\" \"test/unit/*.js\""
44
- },
45
- "gitHead": "62aea854bf85c5a5995b59e6908fe5409f7eea96"
2
+ "name": "@loopback/build",
3
+ "description": "A set of common scripts and default configurations to build LoopBack 4 or other TypeScript modules",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/strongloop/loopback-next.git",
7
+ "directory": "packages/build"
8
+ },
9
+ "version": "6.1.0",
10
+ "engines": {
11
+ "node": ">=10.16"
12
+ },
13
+ "main": "index.js",
14
+ "author": "IBM Corp.",
15
+ "copyright.owner": "IBM Corp.",
16
+ "license": "MIT",
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "dependencies": {
21
+ "@loopback/eslint-config": "^8.0.3",
22
+ "@types/mocha": "^7.0.2",
23
+ "@types/node": "^10.17.26",
24
+ "cross-spawn": "^7.0.3",
25
+ "debug": "^4.1.1",
26
+ "eslint": "^7.3.1",
27
+ "fs-extra": "^9.0.1",
28
+ "glob": "^7.1.6",
29
+ "lodash": "^4.17.15",
30
+ "mocha": "^8.0.1",
31
+ "nyc": "^15.1.0",
32
+ "prettier": "^2.0.5",
33
+ "rimraf": "^3.0.2",
34
+ "source-map-support": "^0.5.19",
35
+ "typescript": "~3.9.5"
36
+ },
37
+ "bin": {
38
+ "lb-tsc": "./bin/compile-package.js",
39
+ "lb-eslint": "./bin/run-eslint.js",
40
+ "lb-prettier": "./bin/run-prettier.js",
41
+ "lb-mocha": "./bin/run-mocha.js",
42
+ "lb-nyc": "./bin/run-nyc.js",
43
+ "lb-clean": "./bin/run-clean.js"
44
+ },
45
+ "scripts": {
46
+ "test": "npm run mocha",
47
+ "mocha": "node bin/run-mocha --timeout 30000 \"test/integration/*.js\" \"test/unit/*.js\""
48
+ },
49
+ "gitHead": "b89db3d3b8be6a36e63e91c2331d217fda7538de"
46
50
  }
@@ -0,0 +1,39 @@
1
+ // Copyright IBM Corp. 2017,2020. All Rights Reserved.
2
+ // Node module: @loopback/build
3
+ // This file is licensed under the MIT License.
4
+ // License text available at https://opensource.org/licenses/MIT
5
+
6
+ 'use strict';
7
+
8
+ const debug = require('debug')('loopback:build:merge-mocha-configs');
9
+ const {assignWith} = require('lodash');
10
+
11
+ module.exports = mergeMochaConfigs;
12
+
13
+ /**
14
+ * Merge multiple Mocha configuration files into a single one.
15
+ *
16
+ * @param {MochaConfig[]} configs A list of Mocha configuration objects
17
+ * as provided by `.mocharc.js` files.
18
+ */
19
+ function mergeMochaConfigs(...configs) {
20
+ debug('Merging mocha configurations', ...configs);
21
+ const result = assignWith({}, ...configs, assignMochaConfigEntry);
22
+ debug('Merged config:', result);
23
+ return result;
24
+ }
25
+
26
+ function assignMochaConfigEntry(targetValue, sourceValue, key) {
27
+ switch (key) {
28
+ case 'timeout':
29
+ return Math.max(targetValue || 0, sourceValue);
30
+ case 'require':
31
+ if (Array.isArray(sourceValue)) {
32
+ debug('Adding an array of files to require:', sourceValue);
33
+ return [...(targetValue || []), ...sourceValue];
34
+ } else {
35
+ debug('Adding a single file to require:', sourceValue);
36
+ return [...(targetValue || []), sourceValue];
37
+ }
38
+ }
39
+ }