mediasoup-client 3.6.84 → 3.6.85
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/lib/handlers/sdp/MediaSection.d.ts.map +1 -1
- package/lib/handlers/sdp/MediaSection.js +0 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/npm-scripts.mjs +248 -0
- package/package.json +19 -19
- package/lib/handlers/sdp/types.d.ts +0 -6
- package/lib/handlers/sdp/types.d.ts.map +0 -1
- package/lib/handlers/sdp/types.js +0 -2
- package/npm-scripts.js +0 -221
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaSection.d.ts","sourceRoot":"","sources":["../../../src/handlers/sdp/MediaSection.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,aAAa,EACb,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EACN,SAAS,EACT,aAAa,EAIb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"MediaSection.d.ts","sourceRoot":"","sources":["../../../src/handlers/sdp/MediaSection.ts"],"names":[],"mappings":"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"}
|
|
@@ -323,9 +323,6 @@ class AnswerMediaSection extends MediaSection {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
const raw = this._mediaObject.simulcast.list1;
|
|
326
|
-
// NOTE: Ignore bug in @types/sdp-transform.
|
|
327
|
-
// Ongoing PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64119
|
|
328
|
-
// @ts-ignore
|
|
329
326
|
const simulcastStreams = sdpTransform.parseSimulcastStreamList(raw);
|
|
330
327
|
for (const simulcastStream of simulcastStreams) {
|
|
331
328
|
for (const simulcastFormat of simulcastStream) {
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/npm-scripts.mjs
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import process from 'process';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
|
|
6
|
+
const PKG = JSON.parse(fs.readFileSync('./package.json').toString());
|
|
7
|
+
const IS_WINDOWS = os.platform() === 'win32';
|
|
8
|
+
const MAYOR_VERSION = PKG.version.split('.')[0];
|
|
9
|
+
|
|
10
|
+
const task = process.argv.slice(2).join(' ');
|
|
11
|
+
|
|
12
|
+
run();
|
|
13
|
+
|
|
14
|
+
async function run()
|
|
15
|
+
{
|
|
16
|
+
switch (task)
|
|
17
|
+
{
|
|
18
|
+
// As per NPM documentation (https://docs.npmjs.com/cli/v9/using-npm/scripts)
|
|
19
|
+
// `prepare` script:
|
|
20
|
+
//
|
|
21
|
+
// - Runs BEFORE the package is packed, i.e. during `npm publish` and `npm pack`.
|
|
22
|
+
// - Runs on local `npm install` without any arguments.
|
|
23
|
+
// - NOTE: If a package being installed through git contains a `prepare` script,
|
|
24
|
+
// its dependencies and devDependencies will be installed, and the `prepare`
|
|
25
|
+
// script will be run, before the package is packaged and installed.
|
|
26
|
+
//
|
|
27
|
+
// So here we compile TypeScript to JavaScript.
|
|
28
|
+
case 'prepare':
|
|
29
|
+
{
|
|
30
|
+
buildTypescript(/* force */ false);
|
|
31
|
+
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
case 'typescript:build':
|
|
36
|
+
{
|
|
37
|
+
installDeps();
|
|
38
|
+
buildTypescript(/* force */ true);
|
|
39
|
+
replaceVersion();
|
|
40
|
+
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
case 'typescript:watch':
|
|
45
|
+
{
|
|
46
|
+
// NOTE: Load dep on demand since it's a devDependency.
|
|
47
|
+
const { TscWatchClient } = await import('tsc-watch/client.js');
|
|
48
|
+
|
|
49
|
+
const watch = new TscWatchClient();
|
|
50
|
+
|
|
51
|
+
deleteLib();
|
|
52
|
+
|
|
53
|
+
watch.on('success', replaceVersion);
|
|
54
|
+
watch.start('--pretty');
|
|
55
|
+
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
case 'lint':
|
|
60
|
+
{
|
|
61
|
+
lint();
|
|
62
|
+
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
case 'test':
|
|
67
|
+
{
|
|
68
|
+
buildTypescript(/* force */ false);
|
|
69
|
+
replaceVersion();
|
|
70
|
+
test();
|
|
71
|
+
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
case 'coverage':
|
|
76
|
+
{
|
|
77
|
+
buildTypescript(/* force */ false);
|
|
78
|
+
replaceVersion();
|
|
79
|
+
executeCmd('jest --coverage');
|
|
80
|
+
executeCmd('open-cli coverage/lcov-report/index.html');
|
|
81
|
+
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
case 'install-deps':
|
|
86
|
+
{
|
|
87
|
+
installDeps();
|
|
88
|
+
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case 'release:check':
|
|
93
|
+
{
|
|
94
|
+
checkRelease();
|
|
95
|
+
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
case 'release':
|
|
100
|
+
{
|
|
101
|
+
checkRelease();
|
|
102
|
+
|
|
103
|
+
executeCmd(`git commit -am '${PKG.version}'`);
|
|
104
|
+
executeCmd(`git tag -a ${PKG.version} -m '${PKG.version}'`);
|
|
105
|
+
executeCmd(`git push origin v${MAYOR_VERSION}`);
|
|
106
|
+
executeCmd(`git push origin '${PKG.version}'`);
|
|
107
|
+
executeCmd('npm publish');
|
|
108
|
+
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
default:
|
|
113
|
+
{
|
|
114
|
+
logError('unknown task');
|
|
115
|
+
|
|
116
|
+
exitWithError();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function replaceVersion()
|
|
122
|
+
{
|
|
123
|
+
logInfo('replaceVersion()');
|
|
124
|
+
|
|
125
|
+
const files = [ 'lib/index.js', 'lib/index.d.ts' ];
|
|
126
|
+
|
|
127
|
+
for (const file of files)
|
|
128
|
+
{
|
|
129
|
+
const text = fs.readFileSync(file, { encoding: 'utf8' });
|
|
130
|
+
const result = text.replace(/__MEDIASOUP_CLIENT_VERSION__/g, PKG.version);
|
|
131
|
+
|
|
132
|
+
fs.writeFileSync(file, result, { encoding: 'utf8' });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function deleteLib()
|
|
137
|
+
{
|
|
138
|
+
if (!fs.existsSync('lib'))
|
|
139
|
+
{
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
logInfo('deleteLib()');
|
|
144
|
+
|
|
145
|
+
if (!IS_WINDOWS)
|
|
146
|
+
{
|
|
147
|
+
executeCmd('rm -rf lib');
|
|
148
|
+
}
|
|
149
|
+
else
|
|
150
|
+
{
|
|
151
|
+
// NOTE: This command fails in Windows if the dir doesn't exist.
|
|
152
|
+
executeCmd('rmdir /s /q "lib"', /* exitOnError */ false);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function buildTypescript(force = false)
|
|
157
|
+
{
|
|
158
|
+
if (!force && fs.existsSync('lib'))
|
|
159
|
+
{
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
logInfo('buildTypescript()');
|
|
164
|
+
|
|
165
|
+
deleteLib();
|
|
166
|
+
executeCmd('tsc');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function lint()
|
|
170
|
+
{
|
|
171
|
+
logInfo('lint()');
|
|
172
|
+
|
|
173
|
+
executeCmd('eslint -c .eslintrc.js --max-warnings 0 src .eslintrc.js npm-scripts.mjs');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function test()
|
|
177
|
+
{
|
|
178
|
+
logInfo('test()');
|
|
179
|
+
|
|
180
|
+
executeCmd('jest');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function installDeps()
|
|
184
|
+
{
|
|
185
|
+
logInfo('installDeps()');
|
|
186
|
+
|
|
187
|
+
// Install/update deps.
|
|
188
|
+
executeCmd('npm ci --ignore-scripts');
|
|
189
|
+
// Update package-lock.json.
|
|
190
|
+
executeCmd('npm install --package-lock-only --ignore-scripts');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function checkRelease()
|
|
194
|
+
{
|
|
195
|
+
logInfo('checkRelease()');
|
|
196
|
+
|
|
197
|
+
installDeps();
|
|
198
|
+
buildTypescript(/* force */ true);
|
|
199
|
+
replaceVersion();
|
|
200
|
+
lint();
|
|
201
|
+
test();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function executeCmd(command, exitOnError = true)
|
|
205
|
+
{
|
|
206
|
+
logInfo(`executeCmd(): ${command}`);
|
|
207
|
+
|
|
208
|
+
try
|
|
209
|
+
{
|
|
210
|
+
execSync(command, { stdio: [ 'ignore', process.stdout, process.stderr ] });
|
|
211
|
+
}
|
|
212
|
+
catch (error)
|
|
213
|
+
{
|
|
214
|
+
if (exitOnError)
|
|
215
|
+
{
|
|
216
|
+
logError(`executeCmd() failed, exiting: ${error}`);
|
|
217
|
+
exitWithError();
|
|
218
|
+
}
|
|
219
|
+
else
|
|
220
|
+
{
|
|
221
|
+
logInfo(`executeCmd() failed, ignoring: ${error}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function logInfo(message)
|
|
227
|
+
{
|
|
228
|
+
// eslint-disable-next-line no-console
|
|
229
|
+
console.log(`npm-scripts \x1b[36m[INFO] [${task}]\x1b\[0m`, message);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// eslint-disable-next-line no-unused-vars
|
|
233
|
+
function logWarn(message)
|
|
234
|
+
{
|
|
235
|
+
// eslint-disable-next-line no-console
|
|
236
|
+
console.warn(`npm-scripts \x1b[33m[WARN] [${task}]\x1b\[0m`, message);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function logError(message)
|
|
240
|
+
{
|
|
241
|
+
// eslint-disable-next-line no-console
|
|
242
|
+
console.error(`npm-scripts \x1b[31m[ERROR] [${task}]\x1b\[0m`, message);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function exitWithError()
|
|
246
|
+
{
|
|
247
|
+
process.exit(1);
|
|
248
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mediasoup-client",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.85",
|
|
4
4
|
"description": "mediasoup client side JavaScript library",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"main": "lib/index.js",
|
|
20
20
|
"types": "lib/index.d.ts",
|
|
21
21
|
"files": [
|
|
22
|
-
"npm-scripts.
|
|
22
|
+
"npm-scripts.mjs",
|
|
23
23
|
"lib"
|
|
24
24
|
],
|
|
25
25
|
"keywords": [
|
|
@@ -29,18 +29,18 @@
|
|
|
29
29
|
"nodejs"
|
|
30
30
|
],
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=16"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"prepare": "node npm-scripts.
|
|
36
|
-
"typescript:build": "node npm-scripts.
|
|
37
|
-
"typescript:watch": "node npm-scripts.
|
|
38
|
-
"lint": "node npm-scripts.
|
|
39
|
-
"test": "node npm-scripts.
|
|
40
|
-
"coverage": "node npm-scripts.
|
|
41
|
-
"install-deps": "node npm-scripts.
|
|
42
|
-
"release:check": "node npm-scripts.
|
|
43
|
-
"release": "node npm-scripts.
|
|
35
|
+
"prepare": "node npm-scripts.mjs prepare",
|
|
36
|
+
"typescript:build": "node npm-scripts.mjs typescript:build",
|
|
37
|
+
"typescript:watch": "node npm-scripts.mjs typescript:watch",
|
|
38
|
+
"lint": "node npm-scripts.mjs lint",
|
|
39
|
+
"test": "node npm-scripts.mjs test",
|
|
40
|
+
"coverage": "node npm-scripts.mjs coverage",
|
|
41
|
+
"install-deps": "node npm-scripts.mjs install-deps",
|
|
42
|
+
"release:check": "node npm-scripts.mjs release:check",
|
|
43
|
+
"release": "node npm-scripts.mjs release"
|
|
44
44
|
},
|
|
45
45
|
"jest": {
|
|
46
46
|
"verbose": true,
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"cacheDirectory": ".cache/jest"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@types/debug": "^4.1.
|
|
64
|
+
"@types/debug": "^4.1.8",
|
|
65
65
|
"awaitqueue": "^3.0.1",
|
|
66
66
|
"bowser": "^2.11.0",
|
|
67
67
|
"debug": "^4.3.4",
|
|
@@ -74,16 +74,16 @@
|
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/events": "^3.0.0",
|
|
77
|
-
"@types/jest": "^29.5.
|
|
77
|
+
"@types/jest": "^29.5.2",
|
|
78
78
|
"@types/sdp-transform": "^2.4.6",
|
|
79
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
80
|
-
"@typescript-eslint/parser": "^5.
|
|
81
|
-
"eslint": "^8.
|
|
79
|
+
"@typescript-eslint/eslint-plugin": "^5.59.11",
|
|
80
|
+
"@typescript-eslint/parser": "^5.59.11",
|
|
81
|
+
"eslint": "^8.42.0",
|
|
82
82
|
"eslint-plugin-jest": "^27.2.1",
|
|
83
83
|
"jest": "^29.5.0",
|
|
84
84
|
"open-cli": "^7.2.0",
|
|
85
85
|
"ts-jest": "^29.1.0",
|
|
86
|
-
"tsc-watch": "^6.0.
|
|
87
|
-
"typescript": "^5.
|
|
86
|
+
"tsc-watch": "^6.0.4",
|
|
87
|
+
"typescript": "^5.1.3"
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/handlers/sdp/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG,eAAe,EAAE,CAAC;AAGhD,MAAM,MAAM,eAAe,GAC3B;IACC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;CAChB,CAAC"}
|
package/npm-scripts.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
const process = require('process');
|
|
4
|
-
const os = require('os');
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const { execSync } = require('child_process');
|
|
7
|
-
const { version } = require('./package.json');
|
|
8
|
-
|
|
9
|
-
const isWindows = os.platform() === 'win32';
|
|
10
|
-
const task = process.argv.slice(2).join(' ');
|
|
11
|
-
|
|
12
|
-
// mediasoup mayor version.
|
|
13
|
-
const MAYOR_VERSION = version.split('.')[0];
|
|
14
|
-
|
|
15
|
-
console.log(`npm-scripts.js [INFO] running task "${task}"`);
|
|
16
|
-
|
|
17
|
-
switch (task)
|
|
18
|
-
{
|
|
19
|
-
// As per NPM documentation (https://docs.npmjs.com/cli/v9/using-npm/scripts)
|
|
20
|
-
// `prepare` script:
|
|
21
|
-
//
|
|
22
|
-
// - Runs BEFORE the package is packed, i.e. during `npm publish` and `npm pack`.
|
|
23
|
-
// - Runs on local `npm install` without any arguments.
|
|
24
|
-
// - NOTE: If a package being installed through git contains a `prepare` script,
|
|
25
|
-
// its dependencies and devDependencies will be installed, and the `prepare`
|
|
26
|
-
// script will be run, before the package is packaged and installed.
|
|
27
|
-
//
|
|
28
|
-
// So here we compile TypeScript to JavaScript.
|
|
29
|
-
case 'prepare':
|
|
30
|
-
{
|
|
31
|
-
buildTypescript(/* force */ false);
|
|
32
|
-
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
case 'typescript:build':
|
|
37
|
-
{
|
|
38
|
-
installDeps();
|
|
39
|
-
buildTypescript(/* force */ true);
|
|
40
|
-
replaceVersion();
|
|
41
|
-
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
case 'typescript:watch':
|
|
46
|
-
{
|
|
47
|
-
deleteLib();
|
|
48
|
-
|
|
49
|
-
const { TscWatchClient } = require('tsc-watch/client');
|
|
50
|
-
const watch = new TscWatchClient();
|
|
51
|
-
|
|
52
|
-
watch.on('success', replaceVersion);
|
|
53
|
-
watch.start('--pretty');
|
|
54
|
-
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
case 'lint':
|
|
59
|
-
{
|
|
60
|
-
lint();
|
|
61
|
-
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
case 'test':
|
|
66
|
-
{
|
|
67
|
-
buildTypescript(/* force */ false);
|
|
68
|
-
replaceVersion();
|
|
69
|
-
test();
|
|
70
|
-
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
case 'coverage':
|
|
75
|
-
{
|
|
76
|
-
buildTypescript(/* force */ false);
|
|
77
|
-
replaceVersion();
|
|
78
|
-
executeCmd('jest --coverage');
|
|
79
|
-
executeCmd('open-cli coverage/lcov-report/index.html');
|
|
80
|
-
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
case 'install-deps':
|
|
85
|
-
{
|
|
86
|
-
installDeps();
|
|
87
|
-
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
case 'release:check':
|
|
92
|
-
{
|
|
93
|
-
checkRelease();
|
|
94
|
-
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
case 'release':
|
|
99
|
-
{
|
|
100
|
-
checkRelease();
|
|
101
|
-
executeCmd(`git commit -am '${version}'`);
|
|
102
|
-
executeCmd(`git tag -a ${version} -m '${version}'`);
|
|
103
|
-
executeCmd(`git push origin v${MAYOR_VERSION}`);
|
|
104
|
-
executeCmd(`git push origin '${version}'`);
|
|
105
|
-
executeCmd('npm publish');
|
|
106
|
-
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
default:
|
|
111
|
-
{
|
|
112
|
-
throw new TypeError(`unknown task "${task}"`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function replaceVersion()
|
|
117
|
-
{
|
|
118
|
-
console.log('npm-scripts.js [INFO] replaceVersion()');
|
|
119
|
-
|
|
120
|
-
const files = [ 'lib/index.js', 'lib/index.d.ts' ];
|
|
121
|
-
|
|
122
|
-
for (const file of files)
|
|
123
|
-
{
|
|
124
|
-
const text = fs.readFileSync(file, { encoding: 'utf8' });
|
|
125
|
-
const result = text.replace(/__MEDIASOUP_CLIENT_VERSION__/g, version);
|
|
126
|
-
|
|
127
|
-
fs.writeFileSync(file, result, { encoding: 'utf8' });
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function deleteLib()
|
|
132
|
-
{
|
|
133
|
-
if (!fs.existsSync('lib'))
|
|
134
|
-
{
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
console.log('npm-scripts.js [INFO] deleteLib()');
|
|
139
|
-
|
|
140
|
-
if (!isWindows)
|
|
141
|
-
{
|
|
142
|
-
executeCmd('rm -rf lib');
|
|
143
|
-
}
|
|
144
|
-
else
|
|
145
|
-
{
|
|
146
|
-
// NOTE: This command fails in Windows if the dir doesn't exist.
|
|
147
|
-
executeCmd('rmdir /s /q "lib"', /* exitOnError */ false);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function buildTypescript(force = false)
|
|
152
|
-
{
|
|
153
|
-
if (!force && fs.existsSync('lib'))
|
|
154
|
-
{
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
console.log('npm-scripts.js [INFO] buildTypescript()');
|
|
159
|
-
|
|
160
|
-
deleteLib();
|
|
161
|
-
|
|
162
|
-
executeCmd('tsc');
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function lint()
|
|
166
|
-
{
|
|
167
|
-
console.log('npm-scripts.js [INFO] lint()');
|
|
168
|
-
|
|
169
|
-
executeCmd('eslint -c .eslintrc.js --max-warnings 0 src .eslintrc.js npm-scripts.js');
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function test()
|
|
173
|
-
{
|
|
174
|
-
console.log('npm-scripts.js [INFO] test()');
|
|
175
|
-
|
|
176
|
-
executeCmd('jest');
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function installDeps()
|
|
180
|
-
{
|
|
181
|
-
console.log('npm-scripts.js [INFO] installDeps()');
|
|
182
|
-
|
|
183
|
-
// Install/update deps.
|
|
184
|
-
executeCmd('npm ci --ignore-scripts');
|
|
185
|
-
// Update package-lock.json.
|
|
186
|
-
executeCmd('npm install --package-lock-only --ignore-scripts');
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function checkRelease()
|
|
190
|
-
{
|
|
191
|
-
console.log('npm-scripts.js [INFO] checkRelease()');
|
|
192
|
-
|
|
193
|
-
installDeps();
|
|
194
|
-
buildTypescript(/* force */ true);
|
|
195
|
-
replaceVersion();
|
|
196
|
-
lint();
|
|
197
|
-
test();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function executeCmd(command, exitOnError = true)
|
|
201
|
-
{
|
|
202
|
-
console.log(`npm-scripts.js [INFO] executeCmd(): ${command}`);
|
|
203
|
-
|
|
204
|
-
try
|
|
205
|
-
{
|
|
206
|
-
execSync(command, { stdio: [ 'ignore', process.stdout, process.stderr ] });
|
|
207
|
-
}
|
|
208
|
-
catch (error)
|
|
209
|
-
{
|
|
210
|
-
if (exitOnError)
|
|
211
|
-
{
|
|
212
|
-
console.error(`npm-scripts.js [ERROR] executeCmd() failed, exiting: ${error}`);
|
|
213
|
-
|
|
214
|
-
process.exit(1);
|
|
215
|
-
}
|
|
216
|
-
else
|
|
217
|
-
{
|
|
218
|
-
console.log(`npm-scripts.js [INFO] executeCmd() failed, ignoring: ${error}`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|