@taole/deploy-helper 0.7.0 → 0.7.2

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.
Files changed (2) hide show
  1. package/lib/offlinePkg.mjs +22 -12
  2. package/package.json +1 -1
@@ -120,6 +120,7 @@ export async function syncApi(userDeployHelperConfig, mode, offlineConfig, packa
120
120
  }
121
121
 
122
122
  /**
123
+ * @deprecated 不再需要这个函数, 如果插件使用的是@taole/vite-plugin-dynamic-base, 则不需要这个函数
123
124
  * hack
124
125
  * 由于vite-plugin-dynamic-base插件和legacy插件同时使用, 生存的入口文件中代码有点问题,这里直接修改有问题的代码
125
126
  */
@@ -166,16 +167,23 @@ export function checkOfflinePkg(config) {
166
167
  const packageJson = getJsonConfig(config.workDir, "package.json");
167
168
  const userDeployHelperConfig = getUserDeployHelperConfig();
168
169
  const distPath = join(config.workDir, offlineConfig && offlineConfig.distDir ? offlineConfig.distDir : "dist");
170
+ const allDeps = {
171
+ ...packageJson.devDependencies,
172
+ ...packageJson.dependencies,
173
+ };
174
+ const useOldPDB = !!allDeps['vite-plugin-dynamic-base'];
169
175
 
170
176
  // 如果offlineConfig.remove为true,则不构建离线包
171
177
  const willRemovePkg = offlineConfig && offlineConfig.name && offlineConfig.remove === true && offlineConfig.skip !== true;
172
- const willSkip = !offlineConfig || !offlineConfig.name || offlineConfig.skip === true;
178
+ const willSkip = !offlineConfig || !offlineConfig.name || offlineConfig.skip === true || (offlineConfig.onlyTest === true && config.mode === "prod");
173
179
  if (willRemovePkg) {
174
180
  return {
175
181
  canBuild: true,
176
182
  errorMsg: "",
177
183
  hookPostBuild: async () => {
178
- fixEntryHtml(config, offlineConfig);
184
+ if (useOldPDB) {
185
+ fixEntryHtml(config, offlineConfig);
186
+ }
179
187
  log(`开始删除离线包${offlineConfig.name}`);
180
188
  await syncApi(userDeployHelperConfig, config.mode, offlineConfig, null);
181
189
  }
@@ -194,13 +202,8 @@ export function checkOfflinePkg(config) {
194
202
  errorMsg = "啊没有package.json?";
195
203
  canBuildOfflinePkg = false;
196
204
  } else {
197
- // 暂时不检查这个
198
- const allDeps = {
199
- ...packageJson.devDependencies,
200
- ...packageJson.dependencies,
201
- };
202
- if (!allDeps['@vitejs/plugin-legacy'] || !allDeps['vite-plugin-dynamic-base']) {
203
- errorMsg = "检查到项目中未安装依赖@vitejs/plugin-legacy和vite-plugin-dynamic-base, 请先安装依赖并调整构建代码以支持离线化,相关文档:https://alidocs.dingtalk.com/i/nodes/ydxXB52LJqexwD71F9K5XNMrJqjMp697?doc_type=wiki_doc";
205
+ if (!allDeps['@vitejs/plugin-legacy'] || (!allDeps['vite-plugin-dynamic-base'] && !allDeps['@taole/vite-plugin-dynamic-base'])) {
206
+ errorMsg = "检查到项目中未安装依赖@vitejs/plugin-legacy和@taole/vite-plugin-dynamic-base, 请先安装依赖并调整构建代码以支持离线化,相关文档:https://alidocs.dingtalk.com/i/nodes/ydxXB52LJqexwD71F9K5XNMrJqjMp697?doc_type=wiki_doc";
204
207
  canBuildOfflinePkg = false;
205
208
  }
206
209
  }
@@ -219,11 +222,16 @@ export function checkOfflinePkg(config) {
219
222
  errorMsg: ""
220
223
  }
221
224
  }
225
+ if (offlineConfig.onlyTest === true && config.mode === "prod") {
226
+ console.log(`离线包${offlineConfig.name}只用于测试环境, 跳过构建线上环境的离线包构建`);
227
+ }
222
228
  return {
223
229
  canBuild: true,
224
230
  errorMsg: "",
225
231
  hookPostBuild: async () => {
226
- fixEntryHtml(config, offlineConfig);
232
+ if (useOldPDB) {
233
+ fixEntryHtml(config, offlineConfig);
234
+ }
227
235
  }
228
236
  }
229
237
  }
@@ -234,9 +242,11 @@ export function checkOfflinePkg(config) {
234
242
  }
235
243
  }
236
244
  const hookPostBuild = async () => {
237
- if(!offlineConfig || !config) return;
245
+ if (!offlineConfig || !config) return;
238
246
  // 在构建完成后,执行一些操作
239
- fixEntryHtml(config, offlineConfig);
247
+ if (useOldPDB) {
248
+ fixEntryHtml(config, offlineConfig);
249
+ }
240
250
  // 开始进行打包流程
241
251
  const offlinePkgDir = join(config.workDir, "./offlinepkgDist");
242
252
  if (fs.existsSync(offlinePkgDir)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taole/deploy-helper",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "脚本部署工具,用于将项目部署到测试环境或生产环境",
5
5
  "main": "index.mjs",
6
6
  "type": "module",