forked from roerohan/react-vnc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepublish.js
71 lines (66 loc) · 1.65 KB
/
prepublish.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const fs = require('fs');
const path = require('path');
const pkg = require('./package.json');
// NOTE(roerohan): remove dependencies that are not needed for the library.
const {
react,
'react-scripts': reactScripts,
'react-dom': reactDom,
'@testing-library/jest-dom': testingLibraryjestDom,
'@testing-library/react': testingLibraryReact,
'@testing-library/user-event': testingLibraryUserEvent,
'@types/jest': typesJest,
'@types/node': typesNode,
'@types/react': typesReact,
'@types/react-dom': typesReactDom,
'web-vitals': webVitals,
...dependencies
} = pkg.dependencies;
const peerDependencies = {
react: '>=16.0.0',
'react-scripts': '>=4.0.0',
'react-dom': '>=16.0.0',
};
// NOTE(Springboard Edit): Keep the publish:sbvr script in tact
const {
start,
build,
test,
eject,
'build:lib': buildLib,
lint,
'lint:fix': lintFix,
prepare,
prepack,
prepublishOnly,
postpublish,
submodule,
...scripts
} = pkg.scripts;
fs.writeFileSync('package.json', JSON.stringify({
name: pkg.name,
description: pkg.description,
version: pkg.version,
repository: pkg.repository,
keywords: pkg.keywords,
main: pkg.main,
module: pkg.module,
exports: pkg.exports,
typings: pkg.typings,
publishConfig: pkg.publishConfig,
dependencies,
peerDependencies,
scripts,
}, null, 4));
// NOTE(Springboard Edit): Remove non-essential files from dist directory
const builtDir = path.join('dist', 'types');
const builtTypesFiles = fs.readdirSync(builtDir);
builtTypesFiles.forEach(builtTypeFile => {
switch (builtTypeFile) {
case "lib": return;
case "noVNC": return;
default:
fs.rmSync(path.join(builtDir, builtTypeFile));
return;
}
});