@cloudbase/cli 2.3.12-alpha.1 → 2.3.12-alpha.3
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/lib/commands/addon/index.js +30 -33
- package/package.json +1 -1
|
@@ -46,6 +46,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
47
|
exports.AddonPush = exports.AddonPull = void 0;
|
|
48
48
|
const cloud_api_1 = require("@cloudbase/cloud-api");
|
|
49
|
+
const toolbox_1 = require("@cloudbase/toolbox");
|
|
49
50
|
const decorators_1 = require("../../decorators");
|
|
50
51
|
const utils_1 = require("../../utils");
|
|
51
52
|
const common_1 = require("../common");
|
|
@@ -59,17 +60,18 @@ let AddonPull = class AddonPull extends common_1.Command {
|
|
|
59
60
|
desc: '环境 ID'
|
|
60
61
|
}
|
|
61
62
|
],
|
|
62
|
-
desc: '
|
|
63
|
+
desc: '拉取插件/资源代码',
|
|
63
64
|
requiredEnvId: true,
|
|
64
65
|
hasNameArg: true
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
execute(ctx, options) {
|
|
68
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
const
|
|
70
|
-
const {
|
|
70
|
+
const cloudService = yield getCloudServiceInstance(ctx);
|
|
71
|
+
const { resource } = options;
|
|
72
|
+
const { name } = getParams(ctx.params);
|
|
71
73
|
Promise.resolve().then(() => __importStar(require('@cloudbase/addon-cli'))).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
yield res.pull({ name, resource, envId: ctx.envId,
|
|
74
|
+
yield res.pull({ name, resource, envId: ctx.envId, cloudService });
|
|
73
75
|
}));
|
|
74
76
|
});
|
|
75
77
|
}
|
|
@@ -92,7 +94,7 @@ let AddonPush = class AddonPush extends common_1.Command {
|
|
|
92
94
|
get options() {
|
|
93
95
|
return getOptions({
|
|
94
96
|
childCmd: 'push',
|
|
95
|
-
desc: '
|
|
97
|
+
desc: '推送插件/资源代码',
|
|
96
98
|
options: [],
|
|
97
99
|
requiredEnvId: true,
|
|
98
100
|
hasNameArg: false
|
|
@@ -100,10 +102,10 @@ let AddonPush = class AddonPush extends common_1.Command {
|
|
|
100
102
|
}
|
|
101
103
|
execute(ctx, options) {
|
|
102
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const
|
|
104
|
-
const { resource } =
|
|
105
|
+
const cloudService = yield getCloudServiceInstance(ctx);
|
|
106
|
+
const { resource } = options;
|
|
105
107
|
Promise.resolve().then(() => __importStar(require('@cloudbase/addon-cli'))).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
yield res.push({
|
|
108
|
+
yield res.push({ cloudService, envId: ctx.envId, resource });
|
|
107
109
|
}));
|
|
108
110
|
});
|
|
109
111
|
}
|
|
@@ -122,7 +124,7 @@ AddonPush = __decorate([
|
|
|
122
124
|
})
|
|
123
125
|
], AddonPush);
|
|
124
126
|
exports.AddonPush = AddonPush;
|
|
125
|
-
function
|
|
127
|
+
function getCloudServiceInstance(ctx) {
|
|
126
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
129
|
let credential;
|
|
128
130
|
if (ctx.hasPrivateSettings) {
|
|
@@ -133,41 +135,36 @@ function getTcbServiceInstance(ctx) {
|
|
|
133
135
|
else {
|
|
134
136
|
credential = yield utils_1.authSupevisor.getLoginState();
|
|
135
137
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
return {
|
|
139
|
+
lowcode: cloud_api_1.CloudApiService.getInstance({
|
|
140
|
+
service: 'lowcode',
|
|
141
|
+
proxy: (0, toolbox_1.getProxy)(),
|
|
142
|
+
credential,
|
|
143
|
+
version: '2021-01-08'
|
|
144
|
+
}),
|
|
145
|
+
tcb: cloud_api_1.CloudApiService.getInstance({ service: 'tcb', proxy: (0, toolbox_1.getProxy)(), credential })
|
|
146
|
+
};
|
|
138
147
|
});
|
|
139
148
|
}
|
|
140
149
|
function getOptions({ childCmd, options, desc, requiredEnvId, hasNameArg }) {
|
|
141
150
|
return {
|
|
142
151
|
cmd: 'addon',
|
|
143
152
|
childCmd,
|
|
144
|
-
options
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
153
|
+
options: [
|
|
154
|
+
{
|
|
155
|
+
flags: '--resource <resource>',
|
|
156
|
+
desc: '资源名称。当想操作指定资源而非插件时使用。当前支持 automation'
|
|
157
|
+
},
|
|
158
|
+
...options
|
|
159
|
+
],
|
|
160
|
+
args: hasNameArg ? [{ flags: '[name]' }] : [],
|
|
148
161
|
desc,
|
|
149
162
|
requiredEnvId
|
|
150
163
|
};
|
|
151
164
|
}
|
|
152
|
-
function getParams(ctxParams
|
|
165
|
+
function getParams(ctxParams) {
|
|
153
166
|
const params = ctxParams.filter((param) => typeof param === 'string');
|
|
154
|
-
let name, resource;
|
|
155
|
-
if (hasNameArg) {
|
|
156
|
-
if (params.length === 1) {
|
|
157
|
-
name = params[0];
|
|
158
|
-
}
|
|
159
|
-
else if (params.length === 2) {
|
|
160
|
-
resource = params[0];
|
|
161
|
-
name = params[1];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
if (params.length === 1) {
|
|
166
|
-
resource = params[0];
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
167
|
return {
|
|
170
|
-
name
|
|
171
|
-
resource
|
|
168
|
+
name: params[0]
|
|
172
169
|
};
|
|
173
170
|
}
|