rigjs 2.0.0-alpha.1 → 2.0.0-alpha.12
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/built/index.js +115 -114
- package/demo/cicd.rig.json5 +4 -4
- package/demo/package.json +3 -1
- package/demo/package.rig.json5 +10 -5
- package/demo/src/App.vue +6 -0
- package/lib/build/index.ts +35 -5
- package/lib/classes/cicd/CICD.ts +1 -1
- package/lib/classes/cicd/CICDCmd.ts +1 -0
- package/lib/classes/cicd/Deploy/AliDeploy.ts +25 -12
- package/lib/classes/cicd/Deploy/CDN.ts +117 -54
- package/lib/classes/cicd/Endpoint.ts +9 -5
- package/lib/deploy/index.ts +12 -16
- package/lib/preinstall/index.js +159 -107
- package/lib/publish/index.ts +84 -0
- package/lib/rig/index.ts +8 -0
- package/package.json +3 -2
- package/lib/publish/index.js +0 -14
package/demo/cicd.rig.json5
CHANGED
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
},
|
|
18
18
|
endpoints: {
|
|
19
19
|
'ykp/test/oem1': {
|
|
20
|
-
build: '
|
|
20
|
+
build: 'cross-env PUBLIC_PATH=$public_path npx vue-cli-service build --mode oem1',
|
|
21
21
|
defines: {
|
|
22
22
|
NGINX_REPLACE_B: 'http://',
|
|
23
23
|
NGINX_REPLACE_A: '替换了',
|
|
24
24
|
},
|
|
25
|
-
domain: '
|
|
25
|
+
domain: 'cdn.rys.com',
|
|
26
26
|
},
|
|
27
27
|
'ykp/test/oem2': {
|
|
28
28
|
// build: 'yarn build:test:oem2',
|
|
29
|
-
build: '
|
|
29
|
+
build: 'cross-env PUBLIC_PATH=$public_path npx vue-cli-service build --mode oem2',
|
|
30
30
|
defines: {
|
|
31
31
|
NGINX_REPLACE_B: 'http://',
|
|
32
32
|
NGINX_REPLACE_A: '替换了',
|
|
33
33
|
},
|
|
34
|
-
domain: '
|
|
34
|
+
domain: 'cdn.rys.com'
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
groups: [
|
package/demo/package.json
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"core-js": "^3.8.3",
|
|
16
|
-
"vue": "^2.6.14"
|
|
16
|
+
"vue": "^2.6.14",
|
|
17
|
+
"rig-test-1": "git+ssh://git@github.com:FlashHand/rig-test-1.git#1.0.1",
|
|
18
|
+
"rig-test-2": "git+ssh://git@github.com:FlashHand/rig-test-2.git#1.0.1"
|
|
17
19
|
},
|
|
18
20
|
"devDependencies": {
|
|
19
21
|
"@babel/core": "^7.12.16",
|
package/demo/package.rig.json5
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
{
|
|
3
|
+
name: "rig-test-1",
|
|
4
|
+
source: "git@github.com:FlashHand/rig-test-1.git",
|
|
5
|
+
version: "1.0.1",
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
name: "rig-test-2",
|
|
9
|
+
source: "git@github.com:FlashHand/rig-test-2.git",
|
|
10
|
+
version: "1.0.1",
|
|
11
|
+
},
|
|
7
12
|
]
|
package/demo/src/App.vue
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<div id="app">
|
|
3
3
|
<img alt="Vue logo" src="./assets/logo.png">
|
|
4
4
|
<HelloWorld msg="Welcome to Your Vue.js App"/>
|
|
5
|
+
<span>test_replace:{{ test_replace}}</span>
|
|
5
6
|
</div>
|
|
6
7
|
</template>
|
|
7
8
|
|
|
@@ -10,6 +11,11 @@ import HelloWorld from './components/HelloWorld.vue'
|
|
|
10
11
|
|
|
11
12
|
export default {
|
|
12
13
|
name: 'App',
|
|
14
|
+
data() {
|
|
15
|
+
return {
|
|
16
|
+
test_replace: 'NGINX_REPLACE_A'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
13
19
|
components: {
|
|
14
20
|
HelloWorld
|
|
15
21
|
}
|
package/lib/build/index.ts
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
import fsHelper from '../utils/fsHelper';
|
|
2
|
-
import CICD from '@/classes/cicd/CICD';
|
|
2
|
+
import CICD, {Define} from '@/classes/cicd/CICD';
|
|
3
3
|
import CICDCmd from '@/classes/cicd/CICDCmd';
|
|
4
4
|
import shell from 'shelljs';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
const replaceDefine = (target:string,defines?:Define)=>{
|
|
8
|
+
const dirs = fs.readdirSync(target);
|
|
9
|
+
for (let dir of dirs){
|
|
10
|
+
const stat = fs.statSync(path.join(target, dir));
|
|
11
|
+
if (stat.isDirectory()){
|
|
12
|
+
replaceDefine(path.join(target, dir),defines);
|
|
13
|
+
}else{
|
|
14
|
+
if (defines){
|
|
15
|
+
const namePieces = dir.split('.');
|
|
16
|
+
const fileType = namePieces[namePieces.length - 1];
|
|
17
|
+
if (['js','ts'].indexOf(fileType)>=0){
|
|
18
|
+
let file = fs.readFileSync(path.join(target, dir)).toString();
|
|
19
|
+
const replaceArr = Object.keys(defines);
|
|
20
|
+
for (let replace of replaceArr){
|
|
21
|
+
file = file.replace(new RegExp(replace,'g'),defines[replace] as string);
|
|
22
|
+
}
|
|
23
|
+
fs.writeFileSync(path.join(target, dir),file);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
7
29
|
export default async (cmd: any) => {
|
|
8
30
|
//create cicd object
|
|
9
31
|
const cicd = CICD.createByDefault(cmd);
|
|
@@ -12,10 +34,18 @@ export default async (cmd: any) => {
|
|
|
12
34
|
console.log(cicd)
|
|
13
35
|
//build by cicdCmd and cicdConfig
|
|
14
36
|
console.log(cicdCmd.endpoints);
|
|
37
|
+
|
|
15
38
|
for (let i = 0; i < cicdCmd.endpoints.length; i++) {
|
|
16
39
|
const ep = cicdCmd.endpoints[i];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
40
|
+
ep.build = ep.build.replace('$public_path', ep.publicPath);
|
|
41
|
+
try{
|
|
42
|
+
//替换define中的$public_path
|
|
43
|
+
ep.defines = JSON.parse(JSON.stringify(ep.defines).replace('$public_path', ep.publicPath));
|
|
44
|
+
}catch (e) {
|
|
45
|
+
console.log(e.message);
|
|
46
|
+
}
|
|
47
|
+
console.log('exec build:', ep.build);
|
|
48
|
+
shell.exec(ep.build);
|
|
49
|
+
replaceDefine(path.join(cicd.source.root_path, ep.dir), ep.defines);
|
|
20
50
|
}
|
|
21
51
|
}
|
package/lib/classes/cicd/CICD.ts
CHANGED
|
@@ -55,6 +55,7 @@ class CICDCmd {
|
|
|
55
55
|
const sufDir = this.dirStrArr.slice(this.dirInSchemaStrArr.length, this.dirStrArr.length).join('/');
|
|
56
56
|
this.endpoints = this.endpoints.map(ep => {
|
|
57
57
|
ep.deployDir = path.join(ep.deployDir, sufDir);
|
|
58
|
+
ep.publicPath = ep.deployDir;
|
|
58
59
|
return ep;
|
|
59
60
|
});
|
|
60
61
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import aliOSS from
|
|
2
|
-
import fs from
|
|
1
|
+
import aliOSS from 'ali-oss';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { DeployTarget } from '../CICD';
|
|
3
4
|
class AliOSS {
|
|
4
5
|
ossClient: aliOSS;
|
|
5
|
-
constructor(
|
|
6
|
+
constructor(target: DeployTarget) {
|
|
6
7
|
this.ossClient = new aliOSS({
|
|
7
|
-
region,
|
|
8
|
-
accessKeyId:
|
|
9
|
-
accessKeySecret:
|
|
10
|
-
bucket,
|
|
8
|
+
region: target.region,
|
|
9
|
+
accessKeyId: target.access_key,
|
|
10
|
+
accessKeySecret: target.access_secret,
|
|
11
|
+
bucket: target.bucket,
|
|
11
12
|
timeout: 600000,
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
private async progress(p: number, filePath: string, ossPath: string) {
|
|
16
17
|
// 上传进度。
|
|
17
|
-
process.stdout.clearLine(
|
|
18
|
+
process.stdout.clearLine(1);
|
|
18
19
|
process.stdout.cursorTo(0);
|
|
19
20
|
process.stdout.write(
|
|
20
21
|
`progress: ${p.toFixed(2)}%, Upload '${filePath}' To OSS_PATH:${ossPath}`
|
|
@@ -27,19 +28,31 @@ class AliOSS {
|
|
|
27
28
|
dir: string
|
|
28
29
|
) {
|
|
29
30
|
for (let i = 0; i < filesList.length; i++) {
|
|
30
|
-
const filePath = filesList[i].split(
|
|
31
|
+
const filePath = filesList[i].split('dist\\')[1];
|
|
31
32
|
const ossPath =
|
|
32
|
-
ossBasePath + filePath.replace(/\\/g,
|
|
33
|
+
ossBasePath + filePath.replace(/\\/g, '/').replace(dir, '');
|
|
34
|
+
|
|
35
|
+
//@ts-ignore
|
|
36
|
+
let options: aliOSS.PutStreamOptions = {
|
|
37
|
+
contentLength: fs.statSync(filesList[i]).size,
|
|
38
|
+
};
|
|
39
|
+
if (filesList[i].includes('index.html')) {
|
|
40
|
+
options = Object.assign({ headers: { 'Cache-Control': 'max-age=0' } });
|
|
41
|
+
}
|
|
33
42
|
const fileResult = await this.ossClient.putStream(
|
|
34
43
|
ossPath,
|
|
35
|
-
fs.createReadStream(filesList[i])
|
|
44
|
+
fs.createReadStream(filesList[i]),
|
|
45
|
+
options
|
|
36
46
|
);
|
|
47
|
+
if (fileResult.res.status !== 200) {
|
|
48
|
+
throw new Error('Upload OSS Error');
|
|
49
|
+
}
|
|
37
50
|
if (fileResult.res.status === 200) {
|
|
38
51
|
const p = ((i + 1) * 100) / filesList.length;
|
|
39
52
|
this.progress(p, filesList[i], ossPath);
|
|
40
53
|
}
|
|
41
54
|
}
|
|
42
|
-
console.log(
|
|
55
|
+
console.log('\n');
|
|
43
56
|
}
|
|
44
57
|
}
|
|
45
58
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import moment from
|
|
2
|
-
import qs from
|
|
3
|
-
import crypto from
|
|
4
|
-
import axios from
|
|
5
|
-
import * as uuid from
|
|
1
|
+
import moment from 'dayjs';
|
|
2
|
+
import qs from 'qs';
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import * as uuid from 'uuid';
|
|
6
|
+
import { DeployTarget } from '../CICD';
|
|
6
7
|
|
|
7
|
-
type TFlag =
|
|
8
|
+
type TFlag = 'break' | 'enhance_break' | null;
|
|
8
9
|
|
|
9
10
|
class CDN {
|
|
10
11
|
AccessKeySecret: string;
|
|
11
12
|
AccessKeyId: string;
|
|
12
|
-
constructor(
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
13
|
+
constructor(target: DeployTarget) {
|
|
14
|
+
this.AccessKeyId = target.access_key;
|
|
15
|
+
this.AccessKeySecret = target.access_secret;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* 访问CDN通用接口
|
|
@@ -22,31 +23,39 @@ class CDN {
|
|
|
22
23
|
private async getCdnData(actionName: string, paramObj: Object) {
|
|
23
24
|
let config = {
|
|
24
25
|
Action: actionName,
|
|
25
|
-
Format:
|
|
26
|
-
Version:
|
|
26
|
+
Format: 'JSON',
|
|
27
|
+
Version: '2018-05-10',
|
|
27
28
|
AccessKeyId: this.AccessKeyId,
|
|
28
|
-
SignatureMethod:
|
|
29
|
+
SignatureMethod: 'HMAC-SHA1',
|
|
29
30
|
Timestamp: moment().toDate().toISOString(),
|
|
30
|
-
SignatureVersion:
|
|
31
|
+
SignatureVersion: '1.0',
|
|
31
32
|
SignatureNonce: uuid.v1(),
|
|
32
33
|
};
|
|
33
34
|
config = Object.assign(config, paramObj);
|
|
34
35
|
let paramConfig = qs.stringify(config, {
|
|
35
|
-
sort: (a:
|
|
36
|
+
sort: (a: any, b: any) => {
|
|
36
37
|
return a < b ? -1 : 1;
|
|
37
38
|
},
|
|
38
|
-
charset:
|
|
39
|
+
charset: 'utf-8',
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
const strSign = `GET&%2F&${encodeURIComponent(paramConfig)}`;
|
|
42
|
-
console.log(`strSign: ${strSign}`);
|
|
43
|
-
const hmacSha1 = crypto.createHmac(
|
|
43
|
+
// console.log(`strSign: ${strSign}\n`);
|
|
44
|
+
const hmacSha1 = crypto.createHmac('sha1', `${this.AccessKeySecret}&`);
|
|
44
45
|
hmacSha1.update(strSign);
|
|
45
|
-
const signature = hmacSha1.digest(
|
|
46
|
-
|
|
46
|
+
const signature = hmacSha1.digest('base64');
|
|
47
|
+
config = Object.assign(config, {
|
|
48
|
+
Signature: signature,
|
|
49
|
+
});
|
|
50
|
+
paramConfig = qs.stringify(config, {
|
|
51
|
+
sort: (a, b) => {
|
|
52
|
+
return a < b ? -1 : 1;
|
|
53
|
+
},
|
|
54
|
+
charset: 'utf-8',
|
|
55
|
+
format: 'RFC3986',
|
|
56
|
+
});
|
|
47
57
|
|
|
48
58
|
const url = `http://cdn.aliyuncs.com?${paramConfig}`;
|
|
49
|
-
console.log(url);
|
|
50
59
|
|
|
51
60
|
const res = await axios.create().get(url);
|
|
52
61
|
return res.data;
|
|
@@ -66,35 +75,42 @@ class CDN {
|
|
|
66
75
|
targetUrls: string[],
|
|
67
76
|
flags: TFlag[]
|
|
68
77
|
) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
try {
|
|
79
|
+
if (sourceUrls.length !== targetUrls.length) {
|
|
80
|
+
throw new Error(`sourceUrls's length not equal targetUrls's length`);
|
|
81
|
+
}
|
|
82
|
+
const Functions: Object[] = [];
|
|
83
|
+
sourceUrls.forEach((item, index) => {
|
|
84
|
+
Functions.push({
|
|
85
|
+
functionArgs: [
|
|
86
|
+
{
|
|
87
|
+
argName: 'source_url',
|
|
88
|
+
argValue: item,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
argName: 'target_url',
|
|
92
|
+
argValue: targetUrls[index],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
argName: 'flag',
|
|
96
|
+
argValue: flags[index],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
functionName: 'back_to_origin_url_rewrite',
|
|
100
|
+
});
|
|
90
101
|
});
|
|
91
|
-
});
|
|
92
102
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
const data = await this.getCdnData('BatchSetCdnDomainConfig', {
|
|
104
|
+
DomainNames: domainName,
|
|
105
|
+
Functions: JSON.stringify(Functions),
|
|
106
|
+
});
|
|
107
|
+
return data;
|
|
108
|
+
} catch (e) {
|
|
109
|
+
console.error(
|
|
110
|
+
`Error: ${e.response ? JSON.stringify(e.response.data.Message) : e}`
|
|
111
|
+
);
|
|
112
|
+
throw new Error(e.response.data.Message);
|
|
113
|
+
}
|
|
98
114
|
}
|
|
99
115
|
|
|
100
116
|
/**
|
|
@@ -102,12 +118,21 @@ class CDN {
|
|
|
102
118
|
* @param {刷新URL, 格式为加速域名或刷新的文件或目录。多个URL之间使用换行符(\n)或(\r\n)分隔} objectPath
|
|
103
119
|
* @param {刷新的类型 File: 文件; Directory: 目录} objectType
|
|
104
120
|
*/
|
|
105
|
-
public async refreshCache(objectPath: string, objectType
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
public async refreshCache(objectPath: string, objectType?: string) {
|
|
122
|
+
try {
|
|
123
|
+
let param = {
|
|
124
|
+
ObjectPath: objectPath,
|
|
125
|
+
};
|
|
126
|
+
if (objectType) {
|
|
127
|
+
param = Object.assign(param, { ObjectType: objectType });
|
|
128
|
+
}
|
|
129
|
+
const data = await this.getCdnData('RefreshObjectCaches', param);
|
|
130
|
+
return data;
|
|
131
|
+
} catch (e) {
|
|
132
|
+
console.error('Error:');
|
|
133
|
+
console.error(e.response.data.Message);
|
|
134
|
+
throw new Error(e.response.data.Message);
|
|
135
|
+
}
|
|
111
136
|
}
|
|
112
137
|
|
|
113
138
|
/**
|
|
@@ -116,11 +141,49 @@ class CDN {
|
|
|
116
141
|
* @returns
|
|
117
142
|
*/
|
|
118
143
|
async pushCache(objectPath: string) {
|
|
119
|
-
const data = await this.getCdnData(
|
|
144
|
+
const data = await this.getCdnData('PushObjectCache', {
|
|
120
145
|
ObjectPath: objectPath,
|
|
121
146
|
});
|
|
122
147
|
return data;
|
|
123
148
|
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 通过任务编号查询刷新预热任务信息
|
|
152
|
+
* @param {支持同时传入多个任务ID,多个任务ID之间用英文逗号(,)分隔,最多支持同时传入10个任务ID} taskIds
|
|
153
|
+
* @returns
|
|
154
|
+
*/
|
|
155
|
+
async describeRefreshTaskById(taskIds: string) {
|
|
156
|
+
try {
|
|
157
|
+
const data = await this.getCdnData('DescribeRefreshTaskById', {
|
|
158
|
+
TaskId: taskIds,
|
|
159
|
+
});
|
|
160
|
+
return data;
|
|
161
|
+
} catch (e) {
|
|
162
|
+
console.error('Error:');
|
|
163
|
+
console.error(e.response.data.Message);
|
|
164
|
+
throw new Error(e.response.data.Message);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 刷新CDN节点
|
|
170
|
+
* @param {加速域名} domainName
|
|
171
|
+
* @param {功能配置ID} configId
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
async describeCdnDomainConfigs(domainName: string, configId?: string) {
|
|
175
|
+
try {
|
|
176
|
+
const data = await this.getCdnData('DescribeCdnDomainConfigs', {
|
|
177
|
+
DomainName: domainName,
|
|
178
|
+
ConfigId: configId,
|
|
179
|
+
});
|
|
180
|
+
return data;
|
|
181
|
+
} catch (e) {
|
|
182
|
+
console.error('Error:');
|
|
183
|
+
console.error(e.response.data.Message);
|
|
184
|
+
throw new Error(e.response.data.Message);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
124
187
|
}
|
|
125
188
|
|
|
126
189
|
export default CDN;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CICDConfig, DefineDict, DirGroup} from './CICD';
|
|
1
|
+
import {CICDConfig, Define, DefineDict, DeployTarget, DirGroup} from './CICD';
|
|
2
2
|
import {mkdirSync} from 'fs';
|
|
3
3
|
import DirLevel from '@/classes/cicd/DirLevel';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ interface EndpointInfo {
|
|
|
6
6
|
build: string;
|
|
7
7
|
target: string;
|
|
8
8
|
domain: string;
|
|
9
|
-
|
|
9
|
+
defines: Define;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface EndpointDict {
|
|
@@ -20,21 +20,25 @@ class Endpoint {
|
|
|
20
20
|
target: string;
|
|
21
21
|
build: string;
|
|
22
22
|
domain: string;
|
|
23
|
-
deployDir: string;
|
|
24
|
-
|
|
23
|
+
deployDir: string = '';
|
|
24
|
+
|
|
25
|
+
publicPath: string = '';
|
|
26
|
+
defines: Define;
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
constructor(dir: string, info: EndpointInfo, schema: DirLevel[]) {
|
|
28
30
|
this.dir = dir;
|
|
29
31
|
this.deployDir = dir;
|
|
32
|
+
this.publicPath = dir;
|
|
30
33
|
this.dirStrArr = dir.split('/').filter(d => d.length > 0);
|
|
31
34
|
this.dirArr = DirLevel.createDirArr(dir, schema);
|
|
32
35
|
this.target = info.target;
|
|
33
36
|
this.build = info.build;
|
|
34
37
|
this.domain = info.domain;
|
|
35
|
-
this.
|
|
38
|
+
this.defines = info.defines;
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
|
|
38
42
|
static createEndpointArr(cicdConfig: CICDConfig, schema: DirLevel[]) {
|
|
39
43
|
const endpointDict = cicdConfig.endpoints;
|
|
40
44
|
return Object.keys(endpointDict).map(dir => {
|
package/lib/deploy/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import CICD from
|
|
4
|
-
import CICDCmd from
|
|
5
|
-
import AliOSS from
|
|
6
|
-
import CDN from
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import CICD from '@/classes/cicd/CICD';
|
|
4
|
+
import CICDCmd from '@/classes/cicd/CICDCmd';
|
|
5
|
+
import AliOSS from '@/classes/cicd/Deploy/AliDeploy';
|
|
6
|
+
import CDN from '@/classes/cicd/Deploy/CDN';
|
|
7
7
|
|
|
8
8
|
let filesList: string[] = [];
|
|
9
9
|
const traverseFolder = (url: string) => {
|
|
@@ -22,6 +22,7 @@ const traverseFolder = (url: string) => {
|
|
|
22
22
|
|
|
23
23
|
export default async (cmd: any) => {
|
|
24
24
|
try {
|
|
25
|
+
console.log('Start Deploy-----');
|
|
25
26
|
//create cicd object
|
|
26
27
|
const cicd = CICD.createByDefault(cmd);
|
|
27
28
|
//construct cmd object
|
|
@@ -31,8 +32,8 @@ export default async (cmd: any) => {
|
|
|
31
32
|
? cicdCmd.cicd.target[0]
|
|
32
33
|
: cicdCmd.cicd.target;
|
|
33
34
|
|
|
34
|
-
const aliOss = new AliOSS(target
|
|
35
|
-
|
|
35
|
+
const aliOss = new AliOSS(target);
|
|
36
|
+
console.log('Please Wait for Upload OSS...');
|
|
36
37
|
for (let i = 0; i < cicdCmd.endpoints.length; i++) {
|
|
37
38
|
const distPath = path.join(
|
|
38
39
|
process.cwd(),
|
|
@@ -42,18 +43,13 @@ export default async (cmd: any) => {
|
|
|
42
43
|
traverseFolder(distPath);
|
|
43
44
|
await aliOss.putStreamFiles(
|
|
44
45
|
filesList,
|
|
45
|
-
cicdCmd.endpoints[i].deployDir.replace(/\\/g,
|
|
46
|
+
cicdCmd.endpoints[i].deployDir.replace(/\\/g, '/'),
|
|
46
47
|
cicdCmd.endpoints[i].dir
|
|
47
48
|
);
|
|
48
|
-
|
|
49
|
-
// await cdn.setRWriteUri(
|
|
50
|
-
// cicdCmd.endpoints[i].domain,
|
|
51
|
-
// [""],
|
|
52
|
-
// [""],
|
|
53
|
-
// ["break"]
|
|
54
|
-
// );
|
|
55
49
|
filesList = [];
|
|
56
50
|
}
|
|
51
|
+
console.log('Upload OSS Done');
|
|
52
|
+
console.log('Deploy Done-----');
|
|
57
53
|
} catch (e) {
|
|
58
54
|
throw e;
|
|
59
55
|
}
|