@seayoo-web/finder 2.2.0 → 2.2.1

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/dist/index.js CHANGED
@@ -140,8 +140,8 @@ const FinderApiPaths = {
140
140
  upload: "/service/upload"
141
141
  };
142
142
  async function deploy(option) {
143
- const { debug, target, buffer, user, key, payload } = option;
144
- const targetServer = await findTargetServer(target, debug);
143
+ const { debug, target, buffer, user, key, payload, ignoreCache } = option;
144
+ const targetServer = await findTargetServer(target, debug, ignoreCache);
145
145
  if (!targetServer) {
146
146
  throw `finder不支持该域名部署,请检查 ${target}`.bgRed;
147
147
  }
@@ -174,8 +174,8 @@ async function deploy(option) {
174
174
  };
175
175
  }
176
176
  async function upload(option) {
177
- const { debug, target, buffer, user, key } = option;
178
- const targetServer = await findTargetServer(target, debug);
177
+ const { debug, target, buffer, user, key, ignoreCache } = option;
178
+ const targetServer = await findTargetServer(target, debug, ignoreCache);
179
179
  if (!targetServer) {
180
180
  throw `finder不支持该域名部署,请检查 ${target}`.bgRed;
181
181
  }
@@ -204,18 +204,20 @@ async function upload(option) {
204
204
  const getFinderServerFullPath = function(domain) {
205
205
  return (domain.endsWith("internal") ? "http://" : "https://") + domain;
206
206
  };
207
- async function findTargetServer(target, debug) {
207
+ async function findTargetServer(target, debug, ignoreCache) {
208
208
  const t = pure(target);
209
- await updateSupportedProjects(false, debug);
209
+ await updateSupportedProjects(!!ignoreCache, debug);
210
210
  for (const domain in FinderServers) {
211
211
  if (FinderServers[domain].find((url) => t.startsWith(url))) {
212
212
  return domain;
213
213
  }
214
214
  }
215
- await updateSupportedProjects(true, debug);
216
- for (const domain in FinderServers) {
217
- if (FinderServers[domain].find((url) => t.startsWith(url))) {
218
- return domain;
215
+ if (!ignoreCache) {
216
+ await updateSupportedProjects(true, debug);
217
+ for (const domain in FinderServers) {
218
+ if (FinderServers[domain].find((url) => t.startsWith(url))) {
219
+ return domain;
220
+ }
219
221
  }
220
222
  }
221
223
  return null;
@@ -265,7 +267,7 @@ async function getServerSupportedProjects(serverDomain, ignoreCache = false, deb
265
267
  return pureList;
266
268
  }
267
269
  async function finderDeploy(option) {
268
- const { dist, ignoreFiles, deployTo, user, key, debug, preview, commitLogs } = option;
270
+ const { dist, ignoreFiles, deployTo, user, key, debug, preview, commitLogs, ignoreCache } = option;
269
271
  if (!dist) {
270
272
  throw "部署参数 dist 缺失".bgRed;
271
273
  }
@@ -290,7 +292,7 @@ async function finderDeploy(option) {
290
292
  if (Array.isArray(deployTo)) {
291
293
  const results = await Promise.all(
292
294
  deployTo.map((target) => {
293
- return deploy({ debug, target, buffer, user, key, payload });
295
+ return deploy({ debug, target, buffer, user, key, payload, ignoreCache });
294
296
  })
295
297
  );
296
298
  const lastDeployResult = results[results.length - 1];
@@ -299,7 +301,7 @@ async function finderDeploy(option) {
299
301
  }
300
302
  return deployTo.join(",");
301
303
  }
302
- const deployResult = await deploy({ debug, target: deployTo, buffer, user, key, payload });
304
+ const deployResult = await deploy({ debug, target: deployTo, buffer, user, key, payload, ignoreCache });
303
305
  if (deployResult && deployResult.previewUrl) {
304
306
  doPreview(deployResult.previewUrl, preview);
305
307
  }
@@ -320,7 +322,7 @@ function doPreview(defaultPreviewUrl, option) {
320
322
  });
321
323
  }
322
324
  async function finderUpload(option) {
323
- const { filePath, fileContent, deployTo, user, key, preview, debug } = option;
325
+ const { filePath, fileContent, deployTo, user, key, preview, debug, ignoreCache } = option;
324
326
  if (!filePath && !fileContent) {
325
327
  throw `部署缺少参数 filePath(文件全路径) 或 fileContent(文件内容)`.bgRed;
326
328
  }
@@ -331,7 +333,7 @@ async function finderUpload(option) {
331
333
  throw `部署缺少参数 deployTo(部署目标)`.bgRed;
332
334
  }
333
335
  const content = filePath ? Buffer.from(readFileSync(filePath)) : Buffer.isBuffer(fileContent) ? fileContent : Buffer.from(fileContent || "");
334
- const resp = await upload({ debug, target: pure(deployTo), buffer: content, user, key });
336
+ const resp = await upload({ debug, target: pure(deployTo), buffer: content, user, key, ignoreCache });
335
337
  if (preview && resp.previewUrl) {
336
338
  open(resp.previewUrl);
337
339
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seayoo-web/finder",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "agent for web finder",
5
5
  "type": "module",
6
6
  "source": "index.ts",
@@ -25,6 +25,8 @@ export declare function finderDeploy(option: {
25
25
  preview?: boolean | string | string[];
26
26
  /** 代码的 commit log 信息,换行用 \n */
27
27
  commitLogs?: string;
28
+ /** 是否忽略本地缓存的服务器更新信息 */
29
+ ignoreCache?: boolean;
28
30
  }): Promise<string>;
29
31
  /** 上传一个文件到 finder */
30
32
  export declare function finderUpload(option: {
@@ -38,4 +40,5 @@ export declare function finderUpload(option: {
38
40
  key: string;
39
41
  debug?: boolean;
40
42
  preview?: boolean;
43
+ ignoreCache?: boolean;
41
44
  }): Promise<void>;
@@ -7,7 +7,7 @@ type FinderDeployVitePluginOption = Omit<Parameters<typeof finderDeploy>[0], "di
7
7
  export declare function viteDeployPlugin(option: FinderDeployVitePluginOption): {
8
8
  name: string;
9
9
  generateBundle({ dir }: {
10
- dir: string;
10
+ dir?: string;
11
11
  }): void;
12
12
  closeBundle(): Promise<void>;
13
13
  };
@@ -6,6 +6,7 @@ export declare function deploy(option: {
6
6
  user: string;
7
7
  key: string;
8
8
  payload?: Record<string, string>;
9
+ ignoreCache?: boolean;
9
10
  }): Promise<{
10
11
  previewUrl?: string;
11
12
  }>;
@@ -16,6 +17,7 @@ export declare function upload(option: {
16
17
  buffer: Buffer;
17
18
  user: string;
18
19
  key: string;
20
+ ignoreCache?: boolean;
19
21
  }): Promise<{
20
22
  previewUrl?: string;
21
23
  }>;