@pushwoosh/frontend-builder-engine 3.1.2 → 3.1.3
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 +33 -10
- 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,28 @@ 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
|
+
|
|
11
34
|
program
|
|
12
35
|
.version('1.0.0')
|
|
13
36
|
.description('Build lib')
|
|
@@ -55,9 +78,9 @@ program
|
|
|
55
78
|
.description('Playground command')
|
|
56
79
|
.action(async () => {
|
|
57
80
|
const cmd = [
|
|
58
|
-
'
|
|
81
|
+
bin('webpack-dev-server'),
|
|
59
82
|
'--config',
|
|
60
|
-
'
|
|
83
|
+
engineFile('webpack.playground.config.js'),
|
|
61
84
|
'--stats-error-details',
|
|
62
85
|
];
|
|
63
86
|
console.log(cmd.join(' '));
|
|
@@ -87,10 +110,10 @@ program
|
|
|
87
110
|
.description('App dev command')
|
|
88
111
|
.action(async () => {
|
|
89
112
|
const cmd = [
|
|
90
|
-
'
|
|
113
|
+
bin('webpack-cli'),
|
|
91
114
|
'serve',
|
|
92
115
|
'--config',
|
|
93
|
-
'
|
|
116
|
+
engineFile('webpack.application.config.js'),
|
|
94
117
|
];
|
|
95
118
|
console.log(cmd.join(' '));
|
|
96
119
|
}),
|
|
@@ -102,9 +125,9 @@ program
|
|
|
102
125
|
.description('App build command')
|
|
103
126
|
.action(async () => {
|
|
104
127
|
const cmd = [
|
|
105
|
-
'
|
|
128
|
+
bin('webpack-cli'),
|
|
106
129
|
'--config',
|
|
107
|
-
'
|
|
130
|
+
engineFile('webpack.application.config.js'),
|
|
108
131
|
'--stats-error-details',
|
|
109
132
|
'--mode=production'
|
|
110
133
|
];
|
|
@@ -118,9 +141,9 @@ program
|
|
|
118
141
|
.description('App dead code check command')
|
|
119
142
|
.action(async () => {
|
|
120
143
|
const cmd = [
|
|
121
|
-
'
|
|
144
|
+
bin('knip'),
|
|
122
145
|
'--config',
|
|
123
|
-
'
|
|
146
|
+
engineFile('knip.application.json'),
|
|
124
147
|
'--no-config-hints',
|
|
125
148
|
];
|
|
126
149
|
console.log(cmd.join(' '));
|
|
@@ -133,9 +156,9 @@ program
|
|
|
133
156
|
.description('App analyze command')
|
|
134
157
|
.action(async () => {
|
|
135
158
|
const cmd = [
|
|
136
|
-
'
|
|
159
|
+
bin('webpack-cli'),
|
|
137
160
|
'--config',
|
|
138
|
-
'
|
|
161
|
+
engineFile('webpack.application.config.js'),
|
|
139
162
|
'--mode=production',
|
|
140
163
|
'--env',
|
|
141
164
|
'analyze',
|