@pushwoosh/frontend-builder-engine 3.1.2 → 3.1.4
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/pushwoosh-engine.js +38 -11
- package/package.json +1 -1
package/lib/pushwoosh-engine.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const childProcess = require('child_process');
|
|
2
|
+
const { existsSync, readFileSync } = require('fs');
|
|
2
3
|
const fs = require('fs').promises;
|
|
3
4
|
const { program, Command } = require('commander');
|
|
4
5
|
const path = require('path');
|
|
@@ -8,6 +9,31 @@ const { buildStyledComponents } = require('./build-babel');
|
|
|
8
9
|
const { loadTsConfig } = require('./lib-build-tsconfig');
|
|
9
10
|
const { loadPushwooshConfig, listFilesInDirectoryRecursively } = require('./helpers');
|
|
10
11
|
|
|
12
|
+
// Printed commands are resolved from the engine's own dependencies, so a project gets no
|
|
13
|
+
// webpack/knip of its own in node_modules/.bin (pnpm does not hoist them).
|
|
14
|
+
const packageDir = (name) => {
|
|
15
|
+
let dir = path.dirname(require.resolve(name));
|
|
16
|
+
for (;;) {
|
|
17
|
+
const manifest = path.join(dir, 'package.json');
|
|
18
|
+
if (existsSync(manifest) && JSON.parse(readFileSync(manifest, 'utf8')).name === name) {
|
|
19
|
+
return dir;
|
|
20
|
+
}
|
|
21
|
+
dir = path.dirname(dir);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const bin = (name, command = name) => {
|
|
26
|
+
const dir = packageDir(name);
|
|
27
|
+
const manifest = JSON.parse(readFileSync(path.join(dir, 'package.json'), 'utf8'));
|
|
28
|
+
const entry = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin[command];
|
|
29
|
+
return `node ${path.join(dir, entry)}`;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const engineFile = (file) => path.join(__dirname, file);
|
|
33
|
+
|
|
34
|
+
// lib:check-types still sees these; only the published build leaves them out.
|
|
35
|
+
const LIB_TEST_FILES = ['./src/**/__tests__/**', './src/**/*.test.*', './src/**/*.spec.*'];
|
|
36
|
+
|
|
11
37
|
program
|
|
12
38
|
.version('1.0.0')
|
|
13
39
|
.description('Build lib')
|
|
@@ -20,7 +46,8 @@ program
|
|
|
20
46
|
const tsConfig = loadTsConfig({
|
|
21
47
|
compilerOptions: {
|
|
22
48
|
outDir: targetDir,
|
|
23
|
-
}
|
|
49
|
+
},
|
|
50
|
+
exclude: LIB_TEST_FILES,
|
|
24
51
|
});
|
|
25
52
|
await buildTs(curDir, tsConfig);
|
|
26
53
|
await buildStyledComponents(targetDir, targetDir);
|
|
@@ -55,9 +82,9 @@ program
|
|
|
55
82
|
.description('Playground command')
|
|
56
83
|
.action(async () => {
|
|
57
84
|
const cmd = [
|
|
58
|
-
'
|
|
85
|
+
bin('webpack-dev-server'),
|
|
59
86
|
'--config',
|
|
60
|
-
'
|
|
87
|
+
engineFile('webpack.playground.config.js'),
|
|
61
88
|
'--stats-error-details',
|
|
62
89
|
];
|
|
63
90
|
console.log(cmd.join(' '));
|
|
@@ -87,10 +114,10 @@ program
|
|
|
87
114
|
.description('App dev command')
|
|
88
115
|
.action(async () => {
|
|
89
116
|
const cmd = [
|
|
90
|
-
'
|
|
117
|
+
bin('webpack-cli'),
|
|
91
118
|
'serve',
|
|
92
119
|
'--config',
|
|
93
|
-
'
|
|
120
|
+
engineFile('webpack.application.config.js'),
|
|
94
121
|
];
|
|
95
122
|
console.log(cmd.join(' '));
|
|
96
123
|
}),
|
|
@@ -102,9 +129,9 @@ program
|
|
|
102
129
|
.description('App build command')
|
|
103
130
|
.action(async () => {
|
|
104
131
|
const cmd = [
|
|
105
|
-
'
|
|
132
|
+
bin('webpack-cli'),
|
|
106
133
|
'--config',
|
|
107
|
-
'
|
|
134
|
+
engineFile('webpack.application.config.js'),
|
|
108
135
|
'--stats-error-details',
|
|
109
136
|
'--mode=production'
|
|
110
137
|
];
|
|
@@ -118,9 +145,9 @@ program
|
|
|
118
145
|
.description('App dead code check command')
|
|
119
146
|
.action(async () => {
|
|
120
147
|
const cmd = [
|
|
121
|
-
'
|
|
148
|
+
bin('knip'),
|
|
122
149
|
'--config',
|
|
123
|
-
'
|
|
150
|
+
engineFile('knip.application.json'),
|
|
124
151
|
'--no-config-hints',
|
|
125
152
|
];
|
|
126
153
|
console.log(cmd.join(' '));
|
|
@@ -133,9 +160,9 @@ program
|
|
|
133
160
|
.description('App analyze command')
|
|
134
161
|
.action(async () => {
|
|
135
162
|
const cmd = [
|
|
136
|
-
'
|
|
163
|
+
bin('webpack-cli'),
|
|
137
164
|
'--config',
|
|
138
|
-
'
|
|
165
|
+
engineFile('webpack.application.config.js'),
|
|
139
166
|
'--mode=production',
|
|
140
167
|
'--env',
|
|
141
168
|
'analyze',
|