@xfe-repo/mini-app 0.0.17 → 0.1.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/deploy/.drone.yml +7 -2
- package/dist/chunk-4JD7C4FF.mjs +168 -0
- package/dist/chunk-EQD7HO6T.mjs +39 -0
- package/dist/chunk-MLSNG3O7.mjs +263 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.mjs +171 -0
- package/dist/config.d.mts +3 -0
- package/dist/config.mjs +2 -0
- package/dist/preview.d.mts +7 -0
- package/dist/preview.mjs +2 -0
- package/dist/upload.d.mts +3 -0
- package/dist/upload.mjs +3 -0
- package/package.json +1 -1
package/deploy/.drone.yml
CHANGED
|
@@ -179,8 +179,13 @@ steps:
|
|
|
179
179
|
- sed -i "s/<<ENV_TYPE>>/test/g" deploy/helm/values.test.yaml
|
|
180
180
|
- sed -i "s/<<APP_SUFFIX>>/-$HOST_PREFIX/g" deploy/helm/values.test.yaml
|
|
181
181
|
- sed -i "s/<<HOST_PREFIX>>/$HOST_PREFIX/g" deploy/helm/values.test.yaml
|
|
182
|
-
-
|
|
183
|
-
-
|
|
182
|
+
- sed -i "s/deployment/$appName-$HOST_PREFIX/g" deploy/helm/Chart.yaml
|
|
183
|
+
- sed -i "s/1.0.0/0.0.0-$CI_COMMIT_SHA/g" deploy/helm/Chart.yaml
|
|
184
|
+
- helm upgrade --install "$appName-$HOST_PREFIX" deploy/helm/ \
|
|
185
|
+
-f deploy/helm/values.test.yaml \
|
|
186
|
+
--namespace deployment-test \
|
|
187
|
+
--create-namespace \
|
|
188
|
+
--history-max 5 \
|
|
184
189
|
when:
|
|
185
190
|
event:
|
|
186
191
|
- custom
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _ts_generator(thisArg, body) {
|
|
31
|
+
var f, y, t, g, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
};
|
|
40
|
+
return g = {
|
|
41
|
+
next: verb(0),
|
|
42
|
+
"throw": verb(1),
|
|
43
|
+
"return": verb(2)
|
|
44
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
+
return this;
|
|
46
|
+
}), g;
|
|
47
|
+
function verb(n) {
|
|
48
|
+
return function(v) {
|
|
49
|
+
return step([
|
|
50
|
+
n,
|
|
51
|
+
v
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function step(op) {
|
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
+
while(_)try {
|
|
58
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
59
|
+
if (y = 0, t) op = [
|
|
60
|
+
op[0] & 2,
|
|
61
|
+
t.value
|
|
62
|
+
];
|
|
63
|
+
switch(op[0]){
|
|
64
|
+
case 0:
|
|
65
|
+
case 1:
|
|
66
|
+
t = op;
|
|
67
|
+
break;
|
|
68
|
+
case 4:
|
|
69
|
+
_.label++;
|
|
70
|
+
return {
|
|
71
|
+
value: op[1],
|
|
72
|
+
done: false
|
|
73
|
+
};
|
|
74
|
+
case 5:
|
|
75
|
+
_.label++;
|
|
76
|
+
y = op[1];
|
|
77
|
+
op = [
|
|
78
|
+
0
|
|
79
|
+
];
|
|
80
|
+
continue;
|
|
81
|
+
case 7:
|
|
82
|
+
op = _.ops.pop();
|
|
83
|
+
_.trys.pop();
|
|
84
|
+
continue;
|
|
85
|
+
default:
|
|
86
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
+
_ = 0;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
+
_.label = op[1];
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
+
_.label = t[1];
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (t && _.label < t[2]) {
|
|
100
|
+
_.label = t[2];
|
|
101
|
+
_.ops.push(op);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (t[2]) _.ops.pop();
|
|
105
|
+
_.trys.pop();
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
op = body.call(thisArg, _);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
op = [
|
|
111
|
+
6,
|
|
112
|
+
e
|
|
113
|
+
];
|
|
114
|
+
y = 0;
|
|
115
|
+
} finally{
|
|
116
|
+
f = t = 0;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] & 5) throw op[1];
|
|
119
|
+
return {
|
|
120
|
+
value: op[0] ? op[1] : void 0,
|
|
121
|
+
done: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
import { choiceRobot, getProject } from "./chunk-MLSNG3O7.mjs";
|
|
126
|
+
// src/upload.ts
|
|
127
|
+
import { upload } from "miniprogram-ci";
|
|
128
|
+
function uploadMini(version) {
|
|
129
|
+
return _uploadMini.apply(this, arguments);
|
|
130
|
+
}
|
|
131
|
+
function _uploadMini() {
|
|
132
|
+
_uploadMini = _async_to_generator(function(version) {
|
|
133
|
+
var desc, progress, project, robot, onProgressUpdate;
|
|
134
|
+
var _arguments = arguments;
|
|
135
|
+
return _ts_generator(this, function(_state) {
|
|
136
|
+
switch(_state.label){
|
|
137
|
+
case 0:
|
|
138
|
+
desc = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : "", progress = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : false;
|
|
139
|
+
if (!version) throw new Error("请传递版本号! -v 或者 --version");
|
|
140
|
+
project = getProject();
|
|
141
|
+
robot = choiceRobot();
|
|
142
|
+
onProgressUpdate = progress ? console.log : function() {
|
|
143
|
+
return null;
|
|
144
|
+
};
|
|
145
|
+
return [
|
|
146
|
+
4,
|
|
147
|
+
upload({
|
|
148
|
+
project: project,
|
|
149
|
+
version: version,
|
|
150
|
+
robot: robot,
|
|
151
|
+
desc: desc,
|
|
152
|
+
onProgressUpdate: onProgressUpdate,
|
|
153
|
+
setting: {
|
|
154
|
+
es6: true
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
];
|
|
158
|
+
case 1:
|
|
159
|
+
_state.sent();
|
|
160
|
+
return [
|
|
161
|
+
2
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
return _uploadMini.apply(this, arguments);
|
|
167
|
+
}
|
|
168
|
+
export { uploadMini };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import yaml from "yaml";
|
|
5
|
+
var configDeploy = function() {
|
|
6
|
+
var xfeConfig = JSON.parse(fs.readFileSync("./xfe.json", "utf8"));
|
|
7
|
+
if (!(xfeConfig === null || xfeConfig === void 0 ? void 0 : xfeConfig.deploy)) return;
|
|
8
|
+
var droneConfigFilePath = path.resolve(__dirname, "../deploy/.drone.yml");
|
|
9
|
+
fs.cpSync(droneConfigFilePath, xfeConfig.deploy.droneConfigPath || "./.drone.yml");
|
|
10
|
+
var valuesYamlFilePath = path.resolve(__dirname, "../deploy/helm/values.yaml");
|
|
11
|
+
var valuesYamlFile = fs.readFileSync(valuesYamlFilePath, "utf8");
|
|
12
|
+
var valuesYaml = yaml.parse(valuesYamlFile);
|
|
13
|
+
if (!valuesYaml.virtualService) valuesYaml.virtualService = {};
|
|
14
|
+
if (!valuesYaml.virtualService.hosts) valuesYaml.virtualService.hosts = {
|
|
15
|
+
test: [],
|
|
16
|
+
stage: [],
|
|
17
|
+
prod: []
|
|
18
|
+
};
|
|
19
|
+
var _xfeConfig_deploy = xfeConfig.deploy, _xfeConfig_deploy_virtualServiceEnabled = _xfeConfig_deploy.virtualServiceEnabled, virtualServiceEnabled = _xfeConfig_deploy_virtualServiceEnabled === void 0 ? true : _xfeConfig_deploy_virtualServiceEnabled, _xfeConfig_deploy_hostsProd = _xfeConfig_deploy.hostsProd, hostsProd = _xfeConfig_deploy_hostsProd === void 0 ? [] : _xfeConfig_deploy_hostsProd, _xfeConfig_deploy_hostsStage = _xfeConfig_deploy.hostsStage, hostsStage = _xfeConfig_deploy_hostsStage === void 0 ? [] : _xfeConfig_deploy_hostsStage, _xfeConfig_deploy_hostsTest = _xfeConfig_deploy.hostsTest, hostsTest = _xfeConfig_deploy_hostsTest === void 0 ? [] : _xfeConfig_deploy_hostsTest, _xfeConfig_deploy_gateways = _xfeConfig_deploy.gateways, gateways = _xfeConfig_deploy_gateways === void 0 ? [
|
|
20
|
+
"common-gateway-eshetang"
|
|
21
|
+
] : _xfeConfig_deploy_gateways;
|
|
22
|
+
var _xfeConfig_deploy1 = xfeConfig.deploy, _xfeConfig_deploy_targetK8s = _xfeConfig_deploy1.targetK8s, targetK8s = _xfeConfig_deploy_targetK8s === void 0 ? "saas" : _xfeConfig_deploy_targetK8s, _xfeConfig_deploy_targetNamespace = _xfeConfig_deploy1.targetNamespace, targetNamespace = _xfeConfig_deploy_targetNamespace === void 0 ? "" : _xfeConfig_deploy_targetNamespace;
|
|
23
|
+
valuesYaml.virtualService.enabled = virtualServiceEnabled;
|
|
24
|
+
valuesYaml.virtualService.gateways = gateways;
|
|
25
|
+
valuesYaml.virtualService.hosts.prod = hostsProd;
|
|
26
|
+
valuesYaml.virtualService.hosts.stage = hostsStage;
|
|
27
|
+
valuesYaml.virtualService.hosts.test = hostsTest;
|
|
28
|
+
valuesYaml.targetK8s = targetK8s;
|
|
29
|
+
valuesYaml.namespace = targetNamespace;
|
|
30
|
+
var valuesYamlStr = yaml.stringify(valuesYaml, {
|
|
31
|
+
defaultStringType: "QUOTE_SINGLE",
|
|
32
|
+
defaultKeyType: "PLAIN"
|
|
33
|
+
});
|
|
34
|
+
fs.writeFileSync(valuesYamlFilePath, valuesYamlStr, "utf8");
|
|
35
|
+
};
|
|
36
|
+
var config = function() {
|
|
37
|
+
configDeploy();
|
|
38
|
+
};
|
|
39
|
+
export { config };
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// src/preview.ts
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_with_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return arr;
|
|
9
|
+
}
|
|
10
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
11
|
+
try {
|
|
12
|
+
var info = gen[key](arg);
|
|
13
|
+
var value = info.value;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (info.done) {
|
|
19
|
+
resolve(value);
|
|
20
|
+
} else {
|
|
21
|
+
Promise.resolve(value).then(_next, _throw);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function _async_to_generator(fn) {
|
|
25
|
+
return function() {
|
|
26
|
+
var self = this, args = arguments;
|
|
27
|
+
return new Promise(function(resolve, reject) {
|
|
28
|
+
var gen = fn.apply(self, args);
|
|
29
|
+
function _next(value) {
|
|
30
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
31
|
+
}
|
|
32
|
+
function _throw(err) {
|
|
33
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
34
|
+
}
|
|
35
|
+
_next(undefined);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function _iterable_to_array_limit(arr, i) {
|
|
40
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
41
|
+
if (_i == null) return;
|
|
42
|
+
var _arr = [];
|
|
43
|
+
var _n = true;
|
|
44
|
+
var _d = false;
|
|
45
|
+
var _s, _e;
|
|
46
|
+
try {
|
|
47
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
48
|
+
_arr.push(_s.value);
|
|
49
|
+
if (i && _arr.length === i) break;
|
|
50
|
+
}
|
|
51
|
+
} catch (err) {
|
|
52
|
+
_d = true;
|
|
53
|
+
_e = err;
|
|
54
|
+
} finally{
|
|
55
|
+
try {
|
|
56
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
57
|
+
} finally{
|
|
58
|
+
if (_d) throw _e;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return _arr;
|
|
62
|
+
}
|
|
63
|
+
function _non_iterable_rest() {
|
|
64
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
65
|
+
}
|
|
66
|
+
function _sliced_to_array(arr, i) {
|
|
67
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
68
|
+
}
|
|
69
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
70
|
+
if (!o) return;
|
|
71
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
72
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
73
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
74
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
75
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
76
|
+
}
|
|
77
|
+
function _ts_generator(thisArg, body) {
|
|
78
|
+
var f, y, t, g, _ = {
|
|
79
|
+
label: 0,
|
|
80
|
+
sent: function() {
|
|
81
|
+
if (t[0] & 1) throw t[1];
|
|
82
|
+
return t[1];
|
|
83
|
+
},
|
|
84
|
+
trys: [],
|
|
85
|
+
ops: []
|
|
86
|
+
};
|
|
87
|
+
return g = {
|
|
88
|
+
next: verb(0),
|
|
89
|
+
"throw": verb(1),
|
|
90
|
+
"return": verb(2)
|
|
91
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
92
|
+
return this;
|
|
93
|
+
}), g;
|
|
94
|
+
function verb(n) {
|
|
95
|
+
return function(v) {
|
|
96
|
+
return step([
|
|
97
|
+
n,
|
|
98
|
+
v
|
|
99
|
+
]);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function step(op) {
|
|
103
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
104
|
+
while(_)try {
|
|
105
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
106
|
+
if (y = 0, t) op = [
|
|
107
|
+
op[0] & 2,
|
|
108
|
+
t.value
|
|
109
|
+
];
|
|
110
|
+
switch(op[0]){
|
|
111
|
+
case 0:
|
|
112
|
+
case 1:
|
|
113
|
+
t = op;
|
|
114
|
+
break;
|
|
115
|
+
case 4:
|
|
116
|
+
_.label++;
|
|
117
|
+
return {
|
|
118
|
+
value: op[1],
|
|
119
|
+
done: false
|
|
120
|
+
};
|
|
121
|
+
case 5:
|
|
122
|
+
_.label++;
|
|
123
|
+
y = op[1];
|
|
124
|
+
op = [
|
|
125
|
+
0
|
|
126
|
+
];
|
|
127
|
+
continue;
|
|
128
|
+
case 7:
|
|
129
|
+
op = _.ops.pop();
|
|
130
|
+
_.trys.pop();
|
|
131
|
+
continue;
|
|
132
|
+
default:
|
|
133
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
134
|
+
_ = 0;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
138
|
+
_.label = op[1];
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
142
|
+
_.label = t[1];
|
|
143
|
+
t = op;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
if (t && _.label < t[2]) {
|
|
147
|
+
_.label = t[2];
|
|
148
|
+
_.ops.push(op);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
if (t[2]) _.ops.pop();
|
|
152
|
+
_.trys.pop();
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
op = body.call(thisArg, _);
|
|
156
|
+
} catch (e) {
|
|
157
|
+
op = [
|
|
158
|
+
6,
|
|
159
|
+
e
|
|
160
|
+
];
|
|
161
|
+
y = 0;
|
|
162
|
+
} finally{
|
|
163
|
+
f = t = 0;
|
|
164
|
+
}
|
|
165
|
+
if (op[0] & 5) throw op[1];
|
|
166
|
+
return {
|
|
167
|
+
value: op[0] ? op[1] : void 0,
|
|
168
|
+
done: true
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
import fs from "fs";
|
|
173
|
+
import path from "path";
|
|
174
|
+
import { Project, preview } from "miniprogram-ci";
|
|
175
|
+
var getProject = function() {
|
|
176
|
+
var rwaPrivateKey = "", rawProjectConfig = "";
|
|
177
|
+
var projectRoot = process.cwd();
|
|
178
|
+
try {
|
|
179
|
+
rwaPrivateKey = fs.readFileSync(path.join(projectRoot, "private.key")).toString();
|
|
180
|
+
} catch (e) {
|
|
181
|
+
console.error("Error: 请在项目根目录下创建 private.key 文件,内容为小程序的私钥");
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
try {
|
|
185
|
+
rawProjectConfig = fs.readFileSync(path.join(projectRoot, "project.config.json")).toString();
|
|
186
|
+
} catch (e) {
|
|
187
|
+
console.error("Error: 请在项目根目录下创建 project.config.json 文件,内容为小程序的配置");
|
|
188
|
+
process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
var projectConfig = JSON.parse(rawProjectConfig);
|
|
191
|
+
return new Project({
|
|
192
|
+
appid: projectConfig.appid,
|
|
193
|
+
projectPath: projectConfig.miniprogramRoot,
|
|
194
|
+
privateKey: rwaPrivateKey,
|
|
195
|
+
type: "miniProgram",
|
|
196
|
+
ignores: [
|
|
197
|
+
"node_modules/**/*"
|
|
198
|
+
]
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
function previewMini(version) {
|
|
202
|
+
return _previewMini.apply(this, arguments);
|
|
203
|
+
}
|
|
204
|
+
function _previewMini() {
|
|
205
|
+
_previewMini = _async_to_generator(function(version) {
|
|
206
|
+
var pageUrl, desc, scene, progress, _pageUrl_split, pagePath, searchQuery, project, robot;
|
|
207
|
+
var _arguments = arguments;
|
|
208
|
+
return _ts_generator(this, function(_state) {
|
|
209
|
+
switch(_state.label){
|
|
210
|
+
case 0:
|
|
211
|
+
pageUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : "", desc = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : "", scene = _arguments.length > 3 && _arguments[3] !== void 0 ? _arguments[3] : 1011, progress = _arguments.length > 4 && _arguments[4] !== void 0 ? _arguments[4] : false;
|
|
212
|
+
_pageUrl_split = _sliced_to_array(pageUrl.split("?"), 2), pagePath = _pageUrl_split[0], searchQuery = _pageUrl_split[1];
|
|
213
|
+
project = getProject();
|
|
214
|
+
robot = choiceRobot();
|
|
215
|
+
return [
|
|
216
|
+
4,
|
|
217
|
+
preview({
|
|
218
|
+
project: project,
|
|
219
|
+
version: version,
|
|
220
|
+
qrcodeFormat: "terminal",
|
|
221
|
+
qrcodeOutputDest: "deploy/preview.qrcode.jpg",
|
|
222
|
+
pagePath: pagePath,
|
|
223
|
+
searchQuery: searchQuery,
|
|
224
|
+
desc: desc,
|
|
225
|
+
robot: robot,
|
|
226
|
+
scene: scene
|
|
227
|
+
})
|
|
228
|
+
];
|
|
229
|
+
case 1:
|
|
230
|
+
_state.sent();
|
|
231
|
+
return [
|
|
232
|
+
2
|
|
233
|
+
];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
return _previewMini.apply(this, arguments);
|
|
238
|
+
}
|
|
239
|
+
var choiceRobot = function() {
|
|
240
|
+
var _process_env = process.env, _process_env_API_ENV = _process_env.API_ENV, API_ENV = _process_env_API_ENV === void 0 ? "" : _process_env_API_ENV;
|
|
241
|
+
var groups = (API_ENV.match(RegExp("^(?<env>prod|beta|stage|test)(?<sn>.*)")) || {}).groups;
|
|
242
|
+
var env = (groups === null || groups === void 0 ? void 0 : groups.env) || "other";
|
|
243
|
+
var sn = Number(groups === null || groups === void 0 ? void 0 : groups.sn) || 0;
|
|
244
|
+
var robot;
|
|
245
|
+
switch(env){
|
|
246
|
+
case "prod":
|
|
247
|
+
case "beta":
|
|
248
|
+
robot = 1;
|
|
249
|
+
break;
|
|
250
|
+
case "stage":
|
|
251
|
+
robot = 2;
|
|
252
|
+
break;
|
|
253
|
+
case "test":
|
|
254
|
+
robot = sn % 29 >= 3 ? sn % 29 : 3;
|
|
255
|
+
break;
|
|
256
|
+
case "other":
|
|
257
|
+
robot = 30;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
console.log("将使用CI".concat(robot, "机器人"));
|
|
261
|
+
return robot;
|
|
262
|
+
};
|
|
263
|
+
export { getProject, previewMini, choiceRobot };
|
package/dist/cli.d.mts
ADDED
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _define_property(obj, key, value) {
|
|
10
|
+
if (key in obj) {
|
|
11
|
+
Object.defineProperty(obj, key, {
|
|
12
|
+
value: value,
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
obj[key] = value;
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
function _iterable_to_array_limit(arr, i) {
|
|
23
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
24
|
+
if (_i == null) return;
|
|
25
|
+
var _arr = [];
|
|
26
|
+
var _n = true;
|
|
27
|
+
var _d = false;
|
|
28
|
+
var _s, _e;
|
|
29
|
+
try {
|
|
30
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
31
|
+
_arr.push(_s.value);
|
|
32
|
+
if (i && _arr.length === i) break;
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_d = true;
|
|
36
|
+
_e = err;
|
|
37
|
+
} finally{
|
|
38
|
+
try {
|
|
39
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
40
|
+
} finally{
|
|
41
|
+
if (_d) throw _e;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return _arr;
|
|
45
|
+
}
|
|
46
|
+
function _non_iterable_rest() {
|
|
47
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
48
|
+
}
|
|
49
|
+
function _object_spread(target) {
|
|
50
|
+
for(var i = 1; i < arguments.length; i++){
|
|
51
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
52
|
+
var ownKeys = Object.keys(source);
|
|
53
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
54
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
55
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
ownKeys.forEach(function(key) {
|
|
59
|
+
_define_property(target, key, source[key]);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return target;
|
|
63
|
+
}
|
|
64
|
+
function ownKeys(object, enumerableOnly) {
|
|
65
|
+
var keys = Object.keys(object);
|
|
66
|
+
if (Object.getOwnPropertySymbols) {
|
|
67
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
68
|
+
if (enumerableOnly) {
|
|
69
|
+
symbols = symbols.filter(function(sym) {
|
|
70
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
keys.push.apply(keys, symbols);
|
|
74
|
+
}
|
|
75
|
+
return keys;
|
|
76
|
+
}
|
|
77
|
+
function _object_spread_props(target, source) {
|
|
78
|
+
source = source != null ? source : {};
|
|
79
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
80
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
81
|
+
} else {
|
|
82
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
83
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
function _object_without_properties(source, excluded) {
|
|
89
|
+
if (source == null) return {};
|
|
90
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
91
|
+
var key, i;
|
|
92
|
+
if (Object.getOwnPropertySymbols) {
|
|
93
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
94
|
+
for(i = 0; i < sourceSymbolKeys.length; i++){
|
|
95
|
+
key = sourceSymbolKeys[i];
|
|
96
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
97
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
98
|
+
target[key] = source[key];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return target;
|
|
102
|
+
}
|
|
103
|
+
function _object_without_properties_loose(source, excluded) {
|
|
104
|
+
if (source == null) return {};
|
|
105
|
+
var target = {};
|
|
106
|
+
var sourceKeys = Object.keys(source);
|
|
107
|
+
var key, i;
|
|
108
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
109
|
+
key = sourceKeys[i];
|
|
110
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
111
|
+
target[key] = source[key];
|
|
112
|
+
}
|
|
113
|
+
return target;
|
|
114
|
+
}
|
|
115
|
+
function _sliced_to_array(arr, i) {
|
|
116
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
117
|
+
}
|
|
118
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
119
|
+
if (!o) return;
|
|
120
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
121
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
122
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
123
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
124
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
125
|
+
}
|
|
126
|
+
import { config } from "./chunk-EQD7HO6T.mjs";
|
|
127
|
+
import { uploadMini } from "./chunk-4JD7C4FF.mjs";
|
|
128
|
+
import { previewMini } from "./chunk-MLSNG3O7.mjs";
|
|
129
|
+
// src/cli.ts
|
|
130
|
+
import minimist from "minimist";
|
|
131
|
+
import path from "path";
|
|
132
|
+
import { execSync } from "child_process";
|
|
133
|
+
var argv = minimist(process.argv.slice(2));
|
|
134
|
+
var commands = argv._, args = _object_without_properties(argv, [
|
|
135
|
+
"_"
|
|
136
|
+
]);
|
|
137
|
+
var _commands = _sliced_to_array(commands, 1), command = _commands[0];
|
|
138
|
+
var appPackageRoot = path.resolve(__dirname, "../");
|
|
139
|
+
var appProjectRoot = process.cwd();
|
|
140
|
+
var env = _object_spread_props(_object_spread({}, process.env), {
|
|
141
|
+
APP_PROJECT_ROOT: appProjectRoot
|
|
142
|
+
});
|
|
143
|
+
var argsString = Object.entries(args).map(function(param) {
|
|
144
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
145
|
+
return "--".concat(key, "=").concat(value);
|
|
146
|
+
}).join(" ");
|
|
147
|
+
if (command === "dev") {
|
|
148
|
+
execSync("taro build --watch ".concat(argsString), {
|
|
149
|
+
stdio: "inherit",
|
|
150
|
+
cwd: appPackageRoot,
|
|
151
|
+
env: env
|
|
152
|
+
});
|
|
153
|
+
} else if (command === "build") {
|
|
154
|
+
execSync("taro build ".concat(argsString), {
|
|
155
|
+
stdio: "inherit",
|
|
156
|
+
cwd: appPackageRoot,
|
|
157
|
+
env: env
|
|
158
|
+
});
|
|
159
|
+
} else if (command === "config") {
|
|
160
|
+
config();
|
|
161
|
+
} else if (command === "upload") {
|
|
162
|
+
var v = argv.v, version = argv.version, d = argv.d, desc = argv.desc, P = argv.P, progress = argv.progress;
|
|
163
|
+
void uploadMini(v || version, d || desc, P || progress).catch(console.error).finally(function() {
|
|
164
|
+
return process.exit(0);
|
|
165
|
+
});
|
|
166
|
+
} else if (command === "preview") {
|
|
167
|
+
var v1 = argv.v, version1 = argv.version, p = argv.p, previewPath = argv.path, d1 = argv.d, desc1 = argv.desc, s = argv.s, scene = argv.scene, P1 = argv.P, progress1 = argv.progress;
|
|
168
|
+
void previewMini(v1 || version1, p || previewPath, d1 || desc1, s || scene, P1 || progress1).finally(function() {
|
|
169
|
+
return process.exit(0);
|
|
170
|
+
});
|
|
171
|
+
}
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Project } from 'miniprogram-ci';
|
|
2
|
+
|
|
3
|
+
declare const getProject: () => Project;
|
|
4
|
+
declare function previewMini(version: string, pageUrl?: string, desc?: string, scene?: number, progress?: boolean): Promise<void>;
|
|
5
|
+
declare const choiceRobot: () => number | undefined;
|
|
6
|
+
|
|
7
|
+
export { choiceRobot, getProject, previewMini };
|
package/dist/preview.mjs
ADDED
package/dist/upload.mjs
ADDED