@loopback/build 6.4.1 → 8.0.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 +245 -189
- package/README.md +13 -4
- package/bin/compile-package.js +31 -4
- package/config/tsconfig.common.json +3 -0
- package/package.json +14 -13
- package/src/fail-on-console-logs.js +1 -1
- package/test/integration/scripts.integration.js +25 -0
package/README.md
CHANGED
|
@@ -94,6 +94,15 @@ Now you run the scripts, such as:
|
|
|
94
94
|
| ------------------ | ------------------------------------------------------------------------------------------------- |
|
|
95
95
|
| `--copy-resources` | Copy all non-typescript files from `src` and `test` to `outDir`, preserving their relative paths. |
|
|
96
96
|
|
|
97
|
+
- Using [`ttypescript`](https://github.com/cevek/ttypescript)
|
|
98
|
+
|
|
99
|
+
### Stability: ⚠️Experimental⚠️
|
|
100
|
+
|
|
101
|
+
If you would like to use `ttypescript` and its availalbe plugins, you can
|
|
102
|
+
substitute `lb-tsc` with `lb-ttsc`, or pass the option
|
|
103
|
+
`lb-tsc --use-ttypescript`. If `ttypescript` is not installed, the default
|
|
104
|
+
TypeScript compiler `tsc` will be used instead.
|
|
105
|
+
|
|
97
106
|
4. Run builds
|
|
98
107
|
|
|
99
108
|
```sh
|
|
@@ -156,7 +165,7 @@ configured to log failed requests, it will print a log also for requests where
|
|
|
156
165
|
the failure was expected and intentional. The solution is to configure your REST
|
|
157
166
|
server to suppress error messages for that specific error code only. Our
|
|
158
167
|
`@loopback/testlab` module is providing a helper
|
|
159
|
-
[`createUnexpectedHttpErrorLogger`](https://github.com/
|
|
168
|
+
[`createUnexpectedHttpErrorLogger`](https://github.com/loopbackio/loopback-next/tree/master/packages/testlab#createUnexpectedHttpErrorLogger)
|
|
160
169
|
that makes this task super easy.
|
|
161
170
|
|
|
162
171
|
Alternatively, it's also possible to disable detection of console logs by
|
|
@@ -164,8 +173,8 @@ calling `lb-mocha` with `--allow-console-logs` argument.
|
|
|
164
173
|
|
|
165
174
|
## Contributions
|
|
166
175
|
|
|
167
|
-
- [Guidelines](https://github.com/
|
|
168
|
-
- [Join the team](https://github.com/
|
|
176
|
+
- [Guidelines](https://github.com/loopbackio/loopback-next/blob/master/docs/CONTRIBUTING.md)
|
|
177
|
+
- [Join the team](https://github.com/loopbackio/loopback-next/issues/110)
|
|
169
178
|
|
|
170
179
|
## Tests
|
|
171
180
|
|
|
@@ -174,7 +183,7 @@ run `npm test` from the root folder.
|
|
|
174
183
|
## Contributors
|
|
175
184
|
|
|
176
185
|
See
|
|
177
|
-
[all contributors](https://github.com/
|
|
186
|
+
[all contributors](https://github.com/loopbackio/loopback-next/graphs/contributors).
|
|
178
187
|
|
|
179
188
|
## License
|
|
180
189
|
|
package/bin/compile-package.js
CHANGED
|
@@ -34,8 +34,12 @@ function run(argv, options) {
|
|
|
34
34
|
|
|
35
35
|
const packageDir = utils.getPackageDir();
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const runnerName = argv[1];
|
|
38
38
|
|
|
39
|
+
const compilerOpts = argv.slice(2);
|
|
40
|
+
const runnerIsLbttsc = runnerName.includes('lb-ttsc');
|
|
41
|
+
const isUseTtscSet = utils.isOptionSet(compilerOpts, '--use-ttypescript');
|
|
42
|
+
const useTtsc = runnerIsLbttsc || isUseTtscSet;
|
|
39
43
|
const isTargetSet = utils.isOptionSet(compilerOpts, '--target');
|
|
40
44
|
const isOutDirSet = utils.isOptionSet(compilerOpts, '--outDir');
|
|
41
45
|
const isProjectSet = utils.isOptionSet(compilerOpts, '-p', '--project');
|
|
@@ -44,12 +48,35 @@ function run(argv, options) {
|
|
|
44
48
|
'--copy-resources',
|
|
45
49
|
);
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
let TSC_CLI = 'typescript/lib/tsc';
|
|
52
|
+
if (useTtsc) {
|
|
53
|
+
try {
|
|
54
|
+
require.resolve('ttypescript');
|
|
55
|
+
TSC_CLI = 'ttypescript/lib/tsc';
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (isUseTtscSet) {
|
|
58
|
+
console.error(
|
|
59
|
+
'Error using the --use-ttypescript option - ttypescript is not installed',
|
|
60
|
+
);
|
|
61
|
+
} else {
|
|
62
|
+
console.error('Error using lb-ttsc - ttypescript is not installed');
|
|
63
|
+
}
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
debug(`Using ${TSC_CLI} to compile package`);
|
|
68
|
+
|
|
69
|
+
// --copy-resources and --use-ttypescript are not a TS Compiler options,
|
|
70
|
+
// so we remove them from the list of compiler options to avoid compiler
|
|
71
|
+
// errors.
|
|
49
72
|
if (isCopyResourcesSet) {
|
|
50
73
|
compilerOpts.splice(compilerOpts.indexOf('--copy-resources'), 1);
|
|
51
74
|
}
|
|
52
75
|
|
|
76
|
+
if (isUseTtscSet) {
|
|
77
|
+
compilerOpts.splice(compilerOpts.indexOf('--use-ttypescript'), 1);
|
|
78
|
+
}
|
|
79
|
+
|
|
53
80
|
let target;
|
|
54
81
|
if (isTargetSet) {
|
|
55
82
|
const targetIx = compilerOpts.indexOf('--target');
|
|
@@ -138,7 +165,7 @@ function run(argv, options) {
|
|
|
138
165
|
|
|
139
166
|
const validArgs = validArgsForBuild(args);
|
|
140
167
|
|
|
141
|
-
return utils.runCLI(
|
|
168
|
+
return utils.runCLI(TSC_CLI, validArgs, {cwd, ...options});
|
|
142
169
|
}
|
|
143
170
|
|
|
144
171
|
/**
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
// FIXME(bajtos) LB4 is not compatible with this setting yet
|
|
11
11
|
"strictPropertyInitialization": false,
|
|
12
12
|
|
|
13
|
+
// https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#use-unknown-catch-variables
|
|
14
|
+
"useUnknownInCatchVariables": false,
|
|
15
|
+
|
|
13
16
|
"incremental": true,
|
|
14
17
|
|
|
15
18
|
"lib": ["es2020"],
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/build",
|
|
3
3
|
"description": "A set of common scripts and default configurations to build LoopBack 4 or other TypeScript modules",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "8.0.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
7
|
"lb-tsc": "./bin/compile-package.js",
|
|
8
|
+
"lb-ttsc": "./bin/compile-package.js",
|
|
8
9
|
"lb-eslint": "./bin/run-eslint.js",
|
|
9
10
|
"lb-prettier": "./bin/run-prettier.js",
|
|
10
11
|
"lb-mocha": "./bin/run-mocha.js",
|
|
@@ -16,11 +17,11 @@
|
|
|
16
17
|
"copyright.owner": "IBM Corp.",
|
|
17
18
|
"repository": {
|
|
18
19
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/
|
|
20
|
+
"url": "https://github.com/loopbackio/loopback-next.git",
|
|
20
21
|
"directory": "packages/build"
|
|
21
22
|
},
|
|
22
23
|
"engines": {
|
|
23
|
-
"node": "
|
|
24
|
+
"node": "12 || 14 || 16 || 17"
|
|
24
25
|
},
|
|
25
26
|
"scripts": {
|
|
26
27
|
"test": "npm run mocha",
|
|
@@ -30,21 +31,21 @@
|
|
|
30
31
|
"access": "public"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@loopback/eslint-config": "^
|
|
34
|
-
"@types/mocha": "^
|
|
34
|
+
"@loopback/eslint-config": "^12.0.0",
|
|
35
|
+
"@types/mocha": "^9.0.0",
|
|
35
36
|
"@types/node": "^10.17.60",
|
|
36
37
|
"cross-spawn": "^7.0.3",
|
|
37
|
-
"debug": "^4.3.
|
|
38
|
-
"eslint": "^7.
|
|
38
|
+
"debug": "^4.3.2",
|
|
39
|
+
"eslint": "^7.32.0",
|
|
39
40
|
"fs-extra": "^10.0.0",
|
|
40
|
-
"glob": "^7.
|
|
41
|
+
"glob": "^7.2.0",
|
|
41
42
|
"lodash": "^4.17.21",
|
|
42
|
-
"mocha": "^9.
|
|
43
|
+
"mocha": "^9.1.3",
|
|
43
44
|
"nyc": "^15.1.0",
|
|
44
|
-
"prettier": "^2.
|
|
45
|
+
"prettier": "^2.4.1",
|
|
45
46
|
"rimraf": "^3.0.2",
|
|
46
|
-
"source-map-support": "^0.5.
|
|
47
|
-
"typescript": "~4.
|
|
47
|
+
"source-map-support": "^0.5.20",
|
|
48
|
+
"typescript": "~4.5.2"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "00a62f630c19341ce399cec3a45563b1ead6e3b8"
|
|
50
51
|
}
|
|
@@ -95,7 +95,7 @@ function stopRecordingAndReportProblems() {
|
|
|
95
95
|
log(
|
|
96
96
|
'\n=== ATTENTION - INVALID USAGE OF CONSOLE LOGS DETECTED ===',
|
|
97
97
|
'\nLearn more at',
|
|
98
|
-
'https://github.com/
|
|
98
|
+
'https://github.com/loopbackio/loopback-next/blob/master/packages/build/README.md#a-note-on-console-logs-printed-by-tests\n',
|
|
99
99
|
);
|
|
100
100
|
|
|
101
101
|
for (const p of problems) {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const assert = require('assert');
|
|
9
9
|
const path = require('path');
|
|
10
|
+
const spawn = require('cross-spawn');
|
|
10
11
|
const fs = require('fs-extra');
|
|
11
12
|
const utils = require('../../bin/utils');
|
|
12
13
|
|
|
@@ -56,6 +57,30 @@ describe('build', /** @this {Mocha.Suite} */ function () {
|
|
|
56
57
|
});
|
|
57
58
|
});
|
|
58
59
|
|
|
60
|
+
describe('with --use-ttypescript', () => {
|
|
61
|
+
it('Returns an error if ttypescript is not installed', done => {
|
|
62
|
+
const childProcess = spawn(
|
|
63
|
+
process.execPath, // Typically '/usr/local/bin/node'
|
|
64
|
+
['../../../bin/compile-package', '--use-ttypescript'],
|
|
65
|
+
{
|
|
66
|
+
env: Object.create(process.env),
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
let processOutput;
|
|
70
|
+
childProcess.stderr.on('data', m => {
|
|
71
|
+
processOutput = m.toString('ascii');
|
|
72
|
+
});
|
|
73
|
+
childProcess.on('close', code => {
|
|
74
|
+
assert.equal(code, 1);
|
|
75
|
+
assert.equal(
|
|
76
|
+
processOutput,
|
|
77
|
+
'Error using the --use-ttypescript option - ttypescript is not installed\n',
|
|
78
|
+
);
|
|
79
|
+
done();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
59
84
|
it('honors tsconfig.build.json over tsconfig.json', () => {
|
|
60
85
|
fs.writeJSONSync('tsconfig.build.json', {
|
|
61
86
|
extends: '../../../config/tsconfig.common.json',
|