fe-deploy-kit 0.0.0-stage → 1.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/LICENSE +21 -0
- package/README.md +368 -2
- package/examples/deploy.config.example.json +24 -0
- package/examples/deploy.config.example.mjs +36 -0
- package/examples/github-actions.yml +64 -0
- package/package.json +57 -4
- package/src/build.js +241 -0
- package/src/cli.js +171 -0
- package/src/commands.js +174 -0
- package/src/config.js +388 -0
- package/src/core/flow.js +463 -0
- package/src/core/fs-ops.js +87 -0
- package/src/core/guard.js +321 -0
- package/src/core/memory-remote.js +196 -0
- package/src/core/remote.js +162 -0
- package/src/deploy.js +118 -0
- package/src/index.js +111 -0
- package/src/logger.js +54 -0
- package/src/prompts.js +67 -0
- package/src/ssh.js +249 -0
- package/src/state.js +79 -0
- package/types/index.d.ts +500 -0
package/src/config.js
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import {
|
|
5
|
+
ConfigError,
|
|
6
|
+
assertFingerprint,
|
|
7
|
+
describeConfig as describeDeployConfig,
|
|
8
|
+
validateConfig as validateDeployConfig
|
|
9
|
+
} from './core/guard.js';
|
|
10
|
+
|
|
11
|
+
/** 配置文件名,按优先级自动查找(最后一个是老项目的兼容位置)。 */
|
|
12
|
+
export const CONFIG_FILENAMES = ['deploy.config.json', 'deploy.config.mjs', 'deploy.config.js', 'deploy/deploy.config.json'];
|
|
13
|
+
|
|
14
|
+
const DEPLOY_KEYS = [
|
|
15
|
+
'host',
|
|
16
|
+
'port',
|
|
17
|
+
'username',
|
|
18
|
+
'remoteRoot',
|
|
19
|
+
'remotePath',
|
|
20
|
+
'hostFingerprint',
|
|
21
|
+
'keyFile',
|
|
22
|
+
'keepBackups',
|
|
23
|
+
'appName',
|
|
24
|
+
'preserve',
|
|
25
|
+
'setPermissions'
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const EXTRA_KEYS = ['projectRoot', 'dist', 'build', 'buildMode', 'validate', 'env', 'stateDir', 'logDir'];
|
|
29
|
+
|
|
30
|
+
const ALL_KEYS = new Set([...DEPLOY_KEYS, ...EXTRA_KEYS]);
|
|
31
|
+
|
|
32
|
+
const DEFAULT_PRESERVE = ['.htaccess', '.user.ini', '.well-known'];
|
|
33
|
+
const DEFAULT_FORBIDDEN = ['.env', '.env.*', '.git/**'];
|
|
34
|
+
|
|
35
|
+
/** 只是为了让 JS 配置文件有类型提示:`export default defineConfig({ ... })`。 */
|
|
36
|
+
export function defineConfig(config) {
|
|
37
|
+
return config;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const pick = (source, keys) => Object.fromEntries(keys.filter(key => source[key] !== undefined).map(key => [key, source[key]]));
|
|
41
|
+
|
|
42
|
+
/** 按优先级查找配置文件;找不到返回 null。 */
|
|
43
|
+
export function findConfigFile({ cwd = process.cwd(), configPath = null } = {}) {
|
|
44
|
+
if (configPath) {
|
|
45
|
+
const resolved = path.resolve(cwd, configPath);
|
|
46
|
+
if (!fs.existsSync(resolved)) throw new ConfigError(`配置文件不存在:${resolved}`);
|
|
47
|
+
return resolved;
|
|
48
|
+
}
|
|
49
|
+
for (const name of CONFIG_FILENAMES) {
|
|
50
|
+
const candidate = path.resolve(cwd, name);
|
|
51
|
+
if (fs.existsSync(candidate)) return candidate;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 读取配置文件:JSON / ESM / CJS 的 .js 都支持。 */
|
|
57
|
+
export async function readConfigFile(file) {
|
|
58
|
+
if (!fs.existsSync(file)) throw new ConfigError(`配置文件不存在:${file}`);
|
|
59
|
+
if (/\.json$/i.test(file)) {
|
|
60
|
+
let raw;
|
|
61
|
+
try {
|
|
62
|
+
raw = JSON.parse(fs.readFileSync(file, 'utf8').replace(/^\uFEFF/, ''));
|
|
63
|
+
} catch (err) {
|
|
64
|
+
throw new ConfigError(`配置文件不是合法 JSON:${file}\n${err.message}`);
|
|
65
|
+
}
|
|
66
|
+
return raw;
|
|
67
|
+
}
|
|
68
|
+
if (/\.(mjs|cjs|js)$/i.test(file)) {
|
|
69
|
+
let mod;
|
|
70
|
+
try {
|
|
71
|
+
mod = await import(`${pathToFileURL(file).href}?t=${Date.now()}`);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
throw new ConfigError(`配置文件加载失败:${file}\n${err.message}`);
|
|
74
|
+
}
|
|
75
|
+
const value = mod.default ?? mod.config ?? mod;
|
|
76
|
+
if (value && typeof value === 'object' && 'default' in value && Object.keys(value).length === 1) return value.default;
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
throw new ConfigError(`不支持的配置文件类型:${file}(只支持 .json / .mjs / .js)`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function normalizeBuild(raw, projectRoot) {
|
|
83
|
+
const timeoutDefault = 10 * 60 * 1000;
|
|
84
|
+
const source = raw.build;
|
|
85
|
+
const base = { skip: false, command: null, args: null, cwd: projectRoot, env: {}, timeoutMs: timeoutDefault, mode: null };
|
|
86
|
+
|
|
87
|
+
// 兼容老配置里的 buildMode(vite build --mode xxx)
|
|
88
|
+
if (raw.buildMode !== undefined) {
|
|
89
|
+
if (typeof raw.buildMode !== 'string' || !/^[A-Za-z0-9._-]{1,32}$/.test(raw.buildMode)) {
|
|
90
|
+
throw new ConfigError('buildMode 只能是简单的模式名,例如 production / development');
|
|
91
|
+
}
|
|
92
|
+
base.mode = raw.buildMode;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (source === false || source === null) return Object.freeze({ ...base, skip: true });
|
|
96
|
+
if (source === undefined) return Object.freeze(base);
|
|
97
|
+
|
|
98
|
+
if (typeof source === 'string') {
|
|
99
|
+
return Object.freeze({ ...base, command: source });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (Array.isArray(source)) {
|
|
103
|
+
if (source.length === 0) throw new ConfigError('build 数组不能为空');
|
|
104
|
+
return Object.freeze({ ...base, command: source });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (typeof source !== 'object') {
|
|
108
|
+
throw new ConfigError('build 只能是字符串、数组、对象,或 false(跳过构建)');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const allowed = new Set(['command', 'args', 'cwd', 'env', 'timeoutMs', 'mode', 'shell', 'packageManager']);
|
|
112
|
+
const unknown = Object.keys(source).filter(key => !allowed.has(key));
|
|
113
|
+
if (unknown.length > 0) {
|
|
114
|
+
throw new ConfigError(`build 里不认识的配置项 ${unknown.map(key => `"${key}"`).join('、')}(可用:${[...allowed].join(', ')})`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const merged = { ...base };
|
|
118
|
+
if (source.command !== undefined) {
|
|
119
|
+
if (typeof source.command !== 'string' && !Array.isArray(source.command) && typeof source.command !== 'function') {
|
|
120
|
+
throw new ConfigError('build.command 必须是字符串、数组或函数');
|
|
121
|
+
}
|
|
122
|
+
merged.command = source.command;
|
|
123
|
+
}
|
|
124
|
+
if (source.args !== undefined) {
|
|
125
|
+
if (!Array.isArray(source.args) || source.args.some(arg => typeof arg !== 'string')) {
|
|
126
|
+
throw new ConfigError('build.args 必须是字符串数组');
|
|
127
|
+
}
|
|
128
|
+
merged.args = source.args;
|
|
129
|
+
}
|
|
130
|
+
if (source.cwd !== undefined) {
|
|
131
|
+
if (typeof source.cwd !== 'string') throw new ConfigError('build.cwd 必须是字符串');
|
|
132
|
+
merged.cwd = path.resolve(projectRoot, source.cwd);
|
|
133
|
+
}
|
|
134
|
+
if (source.env !== undefined) {
|
|
135
|
+
if (source.env === null || typeof source.env !== 'object' || Array.isArray(source.env)) {
|
|
136
|
+
throw new ConfigError('build.env 必须是对象');
|
|
137
|
+
}
|
|
138
|
+
for (const [key, value] of Object.entries(source.env)) {
|
|
139
|
+
if (typeof value !== 'string') throw new ConfigError(`build.env.${key} 必须是字符串`);
|
|
140
|
+
}
|
|
141
|
+
merged.env = { ...source.env };
|
|
142
|
+
}
|
|
143
|
+
if (source.timeoutMs !== undefined) {
|
|
144
|
+
if (!Number.isInteger(source.timeoutMs) || source.timeoutMs < 1000) throw new ConfigError('build.timeoutMs 最小 1000');
|
|
145
|
+
merged.timeoutMs = source.timeoutMs;
|
|
146
|
+
}
|
|
147
|
+
if (source.mode !== undefined) {
|
|
148
|
+
if (typeof source.mode !== 'string' || !/^[A-Za-z0-9._-]{1,32}$/.test(source.mode)) {
|
|
149
|
+
throw new ConfigError('build.mode 只能是简单的模式名,例如 production');
|
|
150
|
+
}
|
|
151
|
+
merged.mode = source.mode;
|
|
152
|
+
}
|
|
153
|
+
if (source.packageManager !== undefined) {
|
|
154
|
+
if (!['npm', 'pnpm', 'yarn', 'bun'].includes(source.packageManager)) {
|
|
155
|
+
throw new ConfigError('build.packageManager 只能是 npm / pnpm / yarn / bun');
|
|
156
|
+
}
|
|
157
|
+
merged.packageManager = source.packageManager;
|
|
158
|
+
}
|
|
159
|
+
return Object.freeze(merged);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function normalizeValidate(rawValidate) {
|
|
163
|
+
const defaults = {
|
|
164
|
+
requireIndexHtml: true,
|
|
165
|
+
assetPrefix: null,
|
|
166
|
+
forbidPatterns: [...DEFAULT_FORBIDDEN],
|
|
167
|
+
warnOnSourcemaps: true
|
|
168
|
+
};
|
|
169
|
+
if (rawValidate === undefined) return Object.freeze(defaults);
|
|
170
|
+
if (rawValidate === null || typeof rawValidate !== 'object' || Array.isArray(rawValidate)) {
|
|
171
|
+
throw new ConfigError('validate 必须是对象');
|
|
172
|
+
}
|
|
173
|
+
const allowed = new Set(Object.keys(defaults));
|
|
174
|
+
const unknown = Object.keys(rawValidate).filter(key => !allowed.has(key));
|
|
175
|
+
if (unknown.length > 0) {
|
|
176
|
+
throw new ConfigError(`validate 里不认识的配置项 ${unknown.map(key => `"${key}"`).join('、')}(可用:${[...allowed].join(', ')})`);
|
|
177
|
+
}
|
|
178
|
+
const merged = { ...defaults, ...rawValidate };
|
|
179
|
+
if (typeof merged.requireIndexHtml !== 'boolean') throw new ConfigError('validate.requireIndexHtml 必须是布尔值');
|
|
180
|
+
if (merged.assetPrefix !== null && (typeof merged.assetPrefix !== 'string' || !merged.assetPrefix.startsWith('/'))) {
|
|
181
|
+
throw new ConfigError('validate.assetPrefix 必须是 / 开头的字符串,或 null');
|
|
182
|
+
}
|
|
183
|
+
if (!Array.isArray(merged.forbidPatterns) || merged.forbidPatterns.some(item => typeof item !== 'string')) {
|
|
184
|
+
throw new ConfigError('validate.forbidPatterns 必须是字符串数组');
|
|
185
|
+
}
|
|
186
|
+
if (typeof merged.warnOnSourcemaps !== 'boolean') throw new ConfigError('validate.warnOnSourcemaps 必须是布尔值');
|
|
187
|
+
return Object.freeze({ ...merged, forbidPatterns: Object.freeze([...merged.forbidPatterns]) });
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function normalizeEnv(rawEnv) {
|
|
191
|
+
const defaults = { password: 'DEPLOY_PASSWORD', keyPassphrase: 'DEPLOY_KEY_PASSPHRASE' };
|
|
192
|
+
if (rawEnv === undefined) return Object.freeze(defaults);
|
|
193
|
+
if (rawEnv === null || typeof rawEnv !== 'object' || Array.isArray(rawEnv)) throw new ConfigError('env 必须是对象');
|
|
194
|
+
const merged = { ...defaults };
|
|
195
|
+
for (const key of Object.keys(defaults)) {
|
|
196
|
+
if (rawEnv[key] === undefined) continue;
|
|
197
|
+
if (typeof rawEnv[key] !== 'string' || !/^[A-Z][A-Z0-9_]*$/.test(rawEnv[key])) {
|
|
198
|
+
throw new ConfigError(`env.${key} 必须是合法的环境变量名(大写字母、数字、下划线)`);
|
|
199
|
+
}
|
|
200
|
+
merged[key] = rawEnv[key];
|
|
201
|
+
}
|
|
202
|
+
const unknown = Object.keys(rawEnv).filter(key => !(key in defaults));
|
|
203
|
+
if (unknown.length > 0) throw new ConfigError(`env 里不认识的配置项:${unknown.join('、')}(可用:${Object.keys(defaults).join(', ')})`);
|
|
204
|
+
return Object.freeze(merged);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 把原始配置规范化成一个可直接执行的配置对象。
|
|
209
|
+
* 部署相关的键交给 guard 做安全校验,构建/产物相关的键在这里校验。
|
|
210
|
+
*/
|
|
211
|
+
export function resolveConfig(raw, { configPath = null, cwd = process.cwd() } = {}) {
|
|
212
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
213
|
+
throw new ConfigError('配置文件内容必须是一个对象');
|
|
214
|
+
}
|
|
215
|
+
if ('password' in raw || 'passphrase' in raw) {
|
|
216
|
+
throw new ConfigError(
|
|
217
|
+
'不要把密码写进配置文件:请用私钥(keyFile),或设置环境变量 DEPLOY_PASSWORD / DEPLOY_KEY_PASSPHRASE'
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
const unknownKeys = Object.keys(raw).filter(key => !ALL_KEYS.has(key));
|
|
221
|
+
if (unknownKeys.length > 0) {
|
|
222
|
+
throw new ConfigError(
|
|
223
|
+
`不认识的配置项 ${unknownKeys.map(key => `"${key}"`).join('、')}(拼写错误?可用项:${[...ALL_KEYS].join(', ')})`
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const deploy = validateDeployConfig(pick(raw, DEPLOY_KEYS), { allowMissingFingerprint: true });
|
|
228
|
+
|
|
229
|
+
const baseDir = configPath ? path.dirname(configPath) : cwd;
|
|
230
|
+
const projectRoot = path.resolve(baseDir, raw.projectRoot ?? '.');
|
|
231
|
+
const build = normalizeBuild(raw, projectRoot);
|
|
232
|
+
|
|
233
|
+
let distDir;
|
|
234
|
+
if (raw.dist !== undefined) {
|
|
235
|
+
if (typeof raw.dist !== 'string' || raw.dist.trim() === '') throw new ConfigError('dist 必须是非空字符串');
|
|
236
|
+
distDir = path.resolve(build.cwd ?? projectRoot, raw.dist);
|
|
237
|
+
} else {
|
|
238
|
+
distDir = path.resolve(build.cwd ?? projectRoot, 'dist');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const validate = normalizeValidate(raw.validate);
|
|
242
|
+
const env = normalizeEnv(raw.env);
|
|
243
|
+
|
|
244
|
+
const stateDir = path.resolve(projectRoot, raw.stateDir ?? '.deploy');
|
|
245
|
+
const logDir = path.resolve(projectRoot, raw.logDir ?? path.join(stateDir, 'logs'));
|
|
246
|
+
|
|
247
|
+
return Object.freeze({
|
|
248
|
+
...deploy,
|
|
249
|
+
// guard 里的 buildMode 只是历史默认值;这里改回用户真正写的那份(没写就是 null)
|
|
250
|
+
buildMode: raw.buildMode ?? null,
|
|
251
|
+
projectRoot,
|
|
252
|
+
distDir,
|
|
253
|
+
build,
|
|
254
|
+
validate,
|
|
255
|
+
env,
|
|
256
|
+
stateDir,
|
|
257
|
+
logDir,
|
|
258
|
+
configPath,
|
|
259
|
+
raw: Object.freeze({ ...raw })
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 判断一个对象是不是已经 resolve 过的配置(可以直接复用,不必再解析一遍)。
|
|
265
|
+
*/
|
|
266
|
+
export function isResolvedConfig(value) {
|
|
267
|
+
return Boolean(
|
|
268
|
+
value &&
|
|
269
|
+
typeof value === 'object' &&
|
|
270
|
+
typeof value.distDir === 'string' &&
|
|
271
|
+
typeof value.stateDir === 'string' &&
|
|
272
|
+
typeof value.remoteRoot === 'string' &&
|
|
273
|
+
value.raw &&
|
|
274
|
+
typeof value.raw === 'object'
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 读取并规范化配置。input 可以是:对象 / 配置文件路径 / 空(自动查找)。
|
|
280
|
+
*/
|
|
281
|
+
export async function loadConfig(input = undefined, { cwd = process.cwd(), configPath = null } = {}) {
|
|
282
|
+
if (isResolvedConfig(input)) return input;
|
|
283
|
+
if (input !== undefined && input !== null && typeof input === 'object') {
|
|
284
|
+
return resolveConfig(input, { cwd });
|
|
285
|
+
}
|
|
286
|
+
const file = typeof input === 'string' ? path.resolve(cwd, input) : findConfigFile({ cwd, configPath });
|
|
287
|
+
if (!file) {
|
|
288
|
+
throw new ConfigError(
|
|
289
|
+
`没有找到配置文件(在 ${cwd} 下查找 ${CONFIG_FILENAMES.join(' / ')})。\n` +
|
|
290
|
+
'运行 npx fe-deploy init 生成一个,或手动创建 deploy.config.json。'
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
return resolveConfig(await readConfigFile(file), { configPath: file, cwd });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function writeJsonAtomic(file, value, mode = 0o600) {
|
|
297
|
+
const temp = `${file}.tmp-${process.pid}`;
|
|
298
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
299
|
+
fs.writeFileSync(temp, `${JSON.stringify(value, null, 2)}\n`, { encoding: 'utf8', mode });
|
|
300
|
+
fs.renameSync(temp, file);
|
|
301
|
+
try {
|
|
302
|
+
fs.chmodSync(file, mode);
|
|
303
|
+
} catch {
|
|
304
|
+
/* Windows 上忽略 */
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** 把部署相关配置写回 JSON 配置文件(永远不写密码,只写这些字段)。 */
|
|
309
|
+
export function saveConfigFile(file, config) {
|
|
310
|
+
const serialized = {
|
|
311
|
+
host: config.host,
|
|
312
|
+
port: config.port,
|
|
313
|
+
username: config.username,
|
|
314
|
+
remoteRoot: config.remoteRoot,
|
|
315
|
+
remotePath: config.remotePath,
|
|
316
|
+
hostFingerprint: config.hostFingerprint ?? null,
|
|
317
|
+
keyFile: config.keyFile ?? null,
|
|
318
|
+
appName: config.appName,
|
|
319
|
+
keepBackups: config.keepBackups,
|
|
320
|
+
preserve: [...config.preserve],
|
|
321
|
+
setPermissions: config.setPermissions,
|
|
322
|
+
...(config.buildMode ? { buildMode: config.buildMode } : {})
|
|
323
|
+
};
|
|
324
|
+
writeJsonAtomic(file, serialized);
|
|
325
|
+
return serialized;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* 指纹存储:
|
|
330
|
+
* - JSON 配置:直接写回配置文件(和老脚本行为一致);
|
|
331
|
+
* - JS 配置(.mjs/.js):写进 stateDir/known-hosts.json(JS 文件没法安全地改写)。
|
|
332
|
+
*/
|
|
333
|
+
export function createFingerprintStore(config) {
|
|
334
|
+
const storeFile = path.join(config.stateDir, 'known-hosts.json');
|
|
335
|
+
const key = `${config.host}:${config.port}`;
|
|
336
|
+
const readStore = () => {
|
|
337
|
+
try {
|
|
338
|
+
return JSON.parse(fs.readFileSync(storeFile, 'utf8'));
|
|
339
|
+
} catch {
|
|
340
|
+
return {};
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
return {
|
|
345
|
+
file: storeFile,
|
|
346
|
+
get() {
|
|
347
|
+
if (config.hostFingerprint) return config.hostFingerprint;
|
|
348
|
+
const record = readStore()[key];
|
|
349
|
+
return record?.fingerprint ?? null;
|
|
350
|
+
},
|
|
351
|
+
set(fingerprint) {
|
|
352
|
+
const clean = assertFingerprint(fingerprint);
|
|
353
|
+
if (config.configPath && /\.json$/i.test(config.configPath)) {
|
|
354
|
+
writeJsonAtomic(config.configPath, { ...config.raw, hostFingerprint: clean });
|
|
355
|
+
return { target: 'config', path: config.configPath };
|
|
356
|
+
}
|
|
357
|
+
const store = readStore();
|
|
358
|
+
store[key] = { fingerprint: clean, updatedAt: new Date().toISOString() };
|
|
359
|
+
writeJsonAtomic(storeFile, store);
|
|
360
|
+
return { target: 'store', path: storeFile };
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** 供日志使用的安全描述(永远不含密码)。 */
|
|
366
|
+
export function describeResolvedConfig(config) {
|
|
367
|
+
const { buildMode, ...rest } = describeDeployConfig(config);
|
|
368
|
+
return {
|
|
369
|
+
...rest,
|
|
370
|
+
buildMode: config.build.mode ?? undefined,
|
|
371
|
+
projectRoot: config.projectRoot,
|
|
372
|
+
distDir: config.distDir,
|
|
373
|
+
build: {
|
|
374
|
+
skip: config.build.skip,
|
|
375
|
+
command: Array.isArray(config.build.command) ? config.build.command.join(' ') : config.build.command,
|
|
376
|
+
mode: config.build.mode,
|
|
377
|
+
cwd: config.build.cwd
|
|
378
|
+
},
|
|
379
|
+
validate: {
|
|
380
|
+
requireIndexHtml: config.validate.requireIndexHtml,
|
|
381
|
+
assetPrefix: config.validate.assetPrefix,
|
|
382
|
+
forbidPatterns: [...config.validate.forbidPatterns]
|
|
383
|
+
},
|
|
384
|
+
configPath: config.configPath
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export { DEFAULT_PRESERVE };
|