rigjs 2.0.0-alpha.15 → 2.0.0-alpha.18

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.
@@ -12,7 +12,7 @@
12
12
  access_secret: '${as}',
13
13
  root_path: '/',
14
14
  uri_rewrite: {
15
- original: 'view-fp',
15
+ original: '/view-fp',
16
16
  }
17
17
  },
18
18
  endpoints: {
@@ -44,9 +44,11 @@ export default async (cmd: any) => {
44
44
  ep.build = ep.build.replace(regexPublicPath, ep.publicPath);
45
45
  try {
46
46
  //替换define中的$public_path
47
- ep.defines = JSON5.parse(JSON5.stringify(ep.defines).replace(regexPublicPath, ep.publicPath));
47
+ Object.keys(ep.defines).forEach(key=>{
48
+ ep.defines[key] = ep.defines[key].replace(regexPublicPath, ep.publicPath);
49
+ })
48
50
  } catch (e) {
49
- console.log('JSON5 error:', e.message);
51
+ console.log('JSON5 error:', ep.defines,e.message);
50
52
  }
51
53
  console.log('exec build:', ep, ep.build, ep.defines);
52
54
  shell.exec(ep.build);
@@ -7,6 +7,14 @@ import { DeployTarget } from '../CICD';
7
7
 
8
8
  type TFlag = 'break' | 'enhance_break' | null;
9
9
 
10
+ enum CDNInterfaceEnum {
11
+ BatchSetCdnDomainConfig = 'BatchSetCdnDomainConfig', //批量修改域名信息
12
+ RefreshObjectCaches = 'RefreshObjectCaches', //刷新节点上的文件内容
13
+ PushObjectCache = 'PushObjectCache', //预热CDN节点
14
+ DescribeRefreshTaskById = 'DescribeRefreshTaskById', //通过任务编号查询刷新预热任务信息
15
+ DescribeCdnDomainConfigs = 'DescribeCdnDomainConfigs', // 获取加速域名的配置信息
16
+ }
17
+
10
18
  class CDN {
11
19
  AccessKeySecret: string;
12
20
  AccessKeyId: string;
@@ -100,7 +108,7 @@ class CDN {
100
108
  });
101
109
  });
102
110
 
103
- const data = await this.getCdnData('BatchSetCdnDomainConfig', {
111
+ const data = await this.getCdnData(CDNInterfaceEnum.BatchSetCdnDomainConfig, {
104
112
  DomainNames: domainName,
105
113
  Functions: JSON.stringify(Functions),
106
114
  });
@@ -126,7 +134,7 @@ class CDN {
126
134
  if (objectType) {
127
135
  param = Object.assign(param, { ObjectType: objectType });
128
136
  }
129
- const data = await this.getCdnData('RefreshObjectCaches', param);
137
+ const data = await this.getCdnData(CDNInterfaceEnum.RefreshObjectCaches, param);
130
138
  return data;
131
139
  } catch (e) {
132
140
  console.error('Error:');
@@ -141,7 +149,7 @@ class CDN {
141
149
  * @returns
142
150
  */
143
151
  async pushCache(objectPath: string) {
144
- const data = await this.getCdnData('PushObjectCache', {
152
+ const data = await this.getCdnData(CDNInterfaceEnum.PushObjectCache, {
145
153
  ObjectPath: objectPath,
146
154
  });
147
155
  return data;
@@ -154,7 +162,7 @@ class CDN {
154
162
  */
155
163
  async describeRefreshTaskById(taskIds: string) {
156
164
  try {
157
- const data = await this.getCdnData('DescribeRefreshTaskById', {
165
+ const data = await this.getCdnData(CDNInterfaceEnum.DescribeRefreshTaskById, {
158
166
  TaskId: taskIds,
159
167
  });
160
168
  return data;
@@ -166,14 +174,14 @@ class CDN {
166
174
  }
167
175
 
168
176
  /**
169
- * 刷新CDN节点
177
+ * 获取加速域名的配置信息
170
178
  * @param {加速域名} domainName
171
179
  * @param {功能配置ID} configId
172
180
  * @returns
173
181
  */
174
182
  async describeCdnDomainConfigs(domainName: string, configId?: string) {
175
183
  try {
176
- const data = await this.getCdnData('DescribeCdnDomainConfigs', {
184
+ const data = await this.getCdnData(CDNInterfaceEnum.DescribeCdnDomainConfigs, {
177
185
  DomainName: domainName,
178
186
  ConfigId: configId,
179
187
  });
@@ -27,6 +27,7 @@ export default async (cmd: any) => {
27
27
  const cicd = CICD.createByDefault(cmd);
28
28
  //construct cmd object
29
29
  const cicdCmd = new CICDCmd(cmd, cicd);
30
+ console.log('cicdCmd:', cicdCmd);
30
31
 
31
32
  const target = Array.isArray(cicdCmd.cicd.target)
32
33
  ? cicdCmd.cicd.target[0]
@@ -1,8 +1,5 @@
1
- import fsHelper from '../utils/fsHelper';
2
1
  import CICD from '@/classes/cicd/CICD';
3
2
  import CICDCmd from '@/classes/cicd/CICDCmd';
4
- import shell from 'shelljs';
5
- import path from 'path';
6
3
  import CDN from '@/classes/cicd/Deploy/CDN';
7
4
 
8
5
  const setRWriteUri = async (
@@ -15,11 +12,10 @@ const setRWriteUri = async (
15
12
  domain,
16
13
  [original],
17
14
  [deployDir],
18
- ['enhance_break']
15
+ [null]
19
16
  );
20
17
 
21
18
  const configId = rwriteResult?.DomainConfigList.DomainConfigModel[0].ConfigId;
22
- console.log('Please Wait For Set RWrite URI...');
23
19
  while (true) {
24
20
  const configInfo = await cdn.describeCdnDomainConfigs(domain, configId);
25
21
  if (configInfo.DomainConfigs.DomainConfig[0].Status === 'success') {
@@ -29,7 +25,6 @@ const setRWriteUri = async (
29
25
  throw new Error('cdn rewrite fail');
30
26
  }
31
27
  }
32
- console.log('Set RWrite URI Done');
33
28
  };
34
29
 
35
30
  const refreshCache = async (urls: string[], cdn: CDN) => {
@@ -67,17 +62,25 @@ export default async (cmd: any) => {
67
62
 
68
63
  const cdn = new CDN(target);
69
64
  const urls: string[] = [];
65
+ const setRWriteUriPromises: Promise<any>[] = [];
70
66
  for (const endpoint of cicdCmd.endpoints) {
71
67
  // 目前只支持set一个original
72
- await setRWriteUri(
73
- endpoint.domain,
74
- `/${target.uri_rewrite.original}`,
75
- `/${endpoint.deployDir.replace(/\\/g, '/')}/index.html`,
76
- cdn
68
+ setRWriteUriPromises.push(
69
+ setRWriteUri(
70
+ endpoint.domain,
71
+ `${target.uri_rewrite.original}`,
72
+ `/${endpoint.deployDir.replace(/\\/g, '/')}/index.html`,
73
+ cdn
74
+ )
77
75
  );
78
76
  urls.push(`https://${endpoint.domain}/${target.uri_rewrite.original}`);
79
77
  }
80
78
 
79
+ // 回源URI改写
80
+ console.log('Please Wait For Set RWrite URI...');
81
+ await Promise.all(setRWriteUriPromises);
82
+ console.log('Set RWrite URI Done');
83
+
81
84
  //刷新cdn
82
85
  await refreshCache(urls, cdn);
83
86
  console.log('Publish Done-----');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rigjs",
3
- "version": "2.0.0-alpha.15",
3
+ "version": "2.0.0-alpha.18",
4
4
  "description": "A multi-repos dev tool based on yarn and git.Rig is inspired by cocoapods. Not like those monorepo solutions,rig is a tool for organizing multi-repos.",
5
5
  "keywords": [
6
6
  "modular",