@cloudbase/framework-plugin-low-code 1.1.5 → 1.2.1-alpha.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/lib/index.d.ts CHANGED
@@ -66,6 +66,7 @@ export interface IFrameworkPluginLowCodeInputs {
66
66
  };
67
67
  calsVersion?: string;
68
68
  ignoreInstall?: boolean;
69
+ runtimeEndpointType?: 'tcb-api' | 'wechat-service';
69
70
  }
70
71
  export declare type ResolvedInputs = IFrameworkPluginLowCodeInputs & typeof DEFAULT_INPUTS;
71
72
  declare class LowCodePlugin extends Plugin {
@@ -76,7 +77,7 @@ declare class LowCodePlugin extends Plugin {
76
77
  protected _appPath: string;
77
78
  protected _authPlugin: any;
78
79
  protected _miniprogramePlugin: any;
79
- protected _webPlugin: any;
80
+ protected _deployer: any;
80
81
  protected _functionPlugin: any;
81
82
  protected _productBasePath?: string;
82
83
  protected _timeMap: {};
@@ -90,8 +91,11 @@ declare class LowCodePlugin extends Plugin {
90
91
  };
91
92
  constructor(name: string, api: PluginServiceApi, inputs: IFrameworkPluginLowCodeInputs);
92
93
  _initDir(): void;
93
- _subPluginConstructor(resolveInputs: ResolvedInputs): void;
94
- _getWebRootPath(): string;
94
+ _subPluginConstructor(resolveInputs: ResolvedInputs): Promise<void>;
95
+ _getWebRootPath({ appId, deployOptions }: {
96
+ appId: any;
97
+ deployOptions: any;
98
+ }): string;
95
99
  _time(label: any): void;
96
100
  _timeEnd(label: any): number | undefined;
97
101
  init(): Promise<void>;
@@ -101,17 +105,12 @@ declare class LowCodePlugin extends Plugin {
101
105
  build(): Promise<string>;
102
106
  compile(): Promise<any>;
103
107
  deploy(): Promise<void>;
104
- mpAnalyzeAndCleanCode(distDir: string): Promise<void>;
105
108
  _getHostingInfoTask(envId: any, loose?: boolean): Promise<any[]>;
106
109
  _getHostingInfo(envId: any, loose?: boolean): any;
107
110
  _checkIsVersion(version: any): boolean;
108
- _handleCIProduct(): Promise<void>;
109
111
  _postPersistentDependiences(): Promise<void>;
110
112
  _debugInfo(): Promise<void>;
111
113
  _zipDir(src: any, dist: any): Promise<unknown>;
112
- _postProcessAdminPortal(): Promise<void>;
113
- _postProcessWebsiteConfig(): Promise<void>;
114
- _checkBroswerHisroty(): boolean;
115
114
  }
116
115
  export declare const plugin: typeof LowCodePlugin;
117
116
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAOA,OAAW,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAIrE,OAAO,EAEL,SAAS,EAET,cAAc,EACd,WAAW,EACX,OAAO,EAMR,MAAM,4BAA4B,CAAC;AAgBpC,eAAO,MAAM,SAAS,WAAW,CAAC;AAiBlC,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;CAoBnB,CAAC;AAEF,MAAM,WAAW,6BAA6B;IAM5C,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAMhB,OAAO,CAAC,EAAE,OAAO,CAAC;IAIlB,KAAK,EAAE,MAAM,CAAC;IAId,oBAAoB,EAAE,GAAG,CAAC;IAI1B,uBAAuB,CAAC,EAAE,GAAG,EAAE,CAAC;IAIhC,YAAY,CAAC,EAAsB,GAAG,EAAE,CAAC;IAKzC,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAK5B,cAAc,CAAC,EAAE,cAAc,CAAC;IAIhC,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,cAAc,CAAC,EAAE,MAAM,CAAC;IAIxB,OAAO,CAAC,EAAgB,GAAG,EAAE,CAAC;IAI9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAK5B,aAAa,EAAE;QAIb,IAAI,EAAE,WAAW,CAAC;QAIlB,OAAO,CAAC,EAAE,MAAM,CAAC;QAIjB,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AAK,UAAQ;IAqB1C,eAAe,CAAC,OAAO,KAAA;IAIjB,2BAA2B;IA6D3B,UAAU;IAoBV,OAAO,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA;CAcxB;AA4BD,eAAO,MAAM,MAAM,sBAAgB,CAAC"}
package/lib/index.js CHANGED
@@ -50,25 +50,18 @@ exports.plugin = exports.DIST_PATH = void 0;
50
50
  const fs_extra_1 = __importDefault(require("fs-extra"));
51
51
  const path_1 = __importDefault(require("path"));
52
52
  const framework_core_1 = require("@cloudbase/framework-core");
53
- const framework_plugin_mp_1 = require("@cloudbase/framework-plugin-mp");
54
- const framework_plugin_website_1 = require("@cloudbase/framework-plugin-website");
53
+ const mpPlugin_1 = require("./mpPlugin");
55
54
  const framework_plugin_auth_1 = require("@cloudbase/framework-plugin-auth");
55
+ const lowcode_deployer_1 = __importStar(require("@cloudbase/lowcode-deployer"));
56
56
  const lowcode_builder_1 = require("@cloudbase/lowcode-builder");
57
- const generate_1 = require("./generate");
58
- const postProcess_1 = require("./utils/postProcess");
59
57
  const lodash_1 = require("lodash");
60
58
  const archiver_1 = __importDefault(require("archiver"));
61
59
  const cos_nodejs_sdk_v5_1 = __importDefault(require("cos-nodejs-sdk-v5"));
62
- const mpci = __importStar(require("miniprogram-ci"));
63
- const qrcode_1 = __importDefault(require("qrcode"));
64
- const url_1 = __importDefault(require("url"));
65
- const private_1 = require("./config/private");
66
60
  exports.DIST_PATH = './dist';
67
61
  const DEBUG_PATH = './debug';
68
62
  const QRCODE_PATH = './qrcode.jpg';
69
63
  const LOG_FILE = 'build.log';
70
64
  const DEFAULT_CLOUDFUNCTION_ROOT_NAME = 'cloudfunctions';
71
- const DEFAULT_CLOUDFUNCTION_ROOT_PATH = path_1.default.join(DEFAULT_CLOUDFUNCTION_ROOT_NAME, '/');
72
65
  const DEFAULT_INPUTS = {
73
66
  _inputFile: 'input.json',
74
67
  debug: false,
@@ -92,7 +85,6 @@ const DEFAULT_INPUTS = {
92
85
  };
93
86
  class LowCodePlugin extends framework_core_1.Plugin {
94
87
  constructor(name, api, inputs) {
95
- var _a, _b, _c;
96
88
  super(name, api, inputs);
97
89
  this.name = name;
98
90
  this.api = api;
@@ -108,56 +100,17 @@ class LowCodePlugin extends framework_core_1.Plugin {
108
100
  if (!this._resolvedInputs.mainAppSerializeData) {
109
101
  throw new Error('缺少必须参数: mainAppSerializeData');
110
102
  }
111
- let map = {};
112
- this._resolvedInputs.dependencies = (this._resolvedInputs.dependencies || []).reduce((list, item) => {
113
- if (!map[`${item.name}@${item.version}`]) {
114
- map[`${item.name}@${item.version}`] = true;
115
- list.push(item);
116
- }
117
- return list;
118
- }, []);
119
- if (!this._resolvedInputs.mainAppSerializeData.extra) {
120
- this._resolvedInputs.mainAppSerializeData.extra = {};
121
- }
122
- if (!this._resolvedInputs.mainAppSerializeData.mpPkgUrl) {
123
- if (this._resolvedInputs.buildTypeList.includes(lowcode_builder_1.BuildType.APP) ||
124
- this._resolvedInputs.buildTypeList.includes(lowcode_builder_1.BuildType.XPAGE_PC) ||
125
- this._resolvedInputs.buildTypeList.includes(lowcode_builder_1.BuildType.ADMIN_PORTAL)) {
126
- this._resolvedInputs.mainAppSerializeData.extra.historyType = lowcode_builder_1.HISTORY_TYPE.HASH;
127
- }
128
- }
129
- if (!((_b = (_a = this._resolvedInputs.mainAppSerializeData) === null || _a === void 0 ? void 0 : _a.extra) === null || _b === void 0 ? void 0 : _b.envId)) {
130
- this._resolvedInputs.mainAppSerializeData.extra.envId = envId;
131
- }
103
+ this._resolvedInputs = (0, lowcode_builder_1.normalizeInputs)(this._resolvedInputs, {
104
+ envId,
105
+ getWebRootPath: ({ appId, deployOptions }) => {
106
+ return this._getWebRootPath({ appId, deployOptions });
107
+ },
108
+ });
132
109
  if ((0, lowcode_builder_1.buildAsWebByBuildType)(this._resolvedInputs.buildTypeList)) {
133
- const { appId, mainAppSerializeData } = this._resolvedInputs;
134
- let { appConfig = {} } = mainAppSerializeData.extra;
135
- let { window = {} } = appConfig;
136
- let path = this._getWebRootPath();
137
- window.publicPath = path;
138
- window.basename = (0, lowcode_builder_1.buildAsAdminPortalByBuildType)(this._resolvedInputs.buildTypeList)
139
- ? `app/${appId}${((_c = this._resolvedInputs.deployOptions) === null || _c === void 0 ? void 0 : _c.mode) !== lowcode_builder_1.DEPLOY_MODE.UPLOAD ? '-preview' : ''}`
140
- : (0, lowcode_builder_1.buildAsXPageByBuildType)(this._resolvedInputs.buildTypeList)
141
- ? '/'
142
- : path;
143
- appConfig.window = window;
144
- this._resolvedInputs.mainAppSerializeData.extra.appConfig = appConfig;
145
- this._resolvedInputs.subAppSerializeDataList = [];
146
- if (this._resolvedInputs.mainAppSerializeData.extra.miniprogramPlugins) {
147
- this._resolvedInputs.mainAppSerializeData.extra.miniprogramPlugins = [];
148
- }
149
- }
150
- else {
151
- const { mpAppId, mpDeployPrivateKey, deployOptions } = this._resolvedInputs;
152
- if (deployOptions.mpAppId === undefined) {
153
- deployOptions.mpAppId = mpAppId;
154
- }
110
+ const { mpDeployPrivateKey, deployOptions } = this._resolvedInputs;
155
111
  if (deployOptions.mpDeployPrivateKey === undefined) {
156
112
  deployOptions.mpDeployPrivateKey = mpDeployPrivateKey;
157
113
  }
158
- if (deployOptions.targetMpAppId === undefined) {
159
- deployOptions.targetMpAppId = deployOptions.mpAppId;
160
- }
161
114
  }
162
115
  this._initDir();
163
116
  this.api.logger.debug(`low-code plugin construct at ${Date.now()}`);
@@ -168,68 +121,102 @@ class LowCodePlugin extends framework_core_1.Plugin {
168
121
  fs_extra_1.default.removeSync(path_1.default.resolve(this.api.projectPath, DEBUG_PATH));
169
122
  }
170
123
  _subPluginConstructor(resolveInputs) {
171
- var _a, _b;
172
- if (resolveInputs.runtime === lowcode_builder_1.RUNTIME.CLI) {
173
- return;
174
- }
175
- let { buildTypeList, deployOptions } = resolveInputs;
176
- this._authPlugin = new framework_plugin_auth_1.plugin('auth', this.api, {
177
- configs: [
178
- {
179
- platform: 'NONLOGIN',
180
- status: 'ENABLE',
181
- platformId: '',
182
- platformSecret: '',
183
- },
184
- {
185
- platform: 'ANONYMOUS',
186
- status: 'ENABLE',
187
- platformId: '',
188
- platformSecret: '',
189
- },
190
- ],
191
- });
192
- if (buildTypeList.includes(lowcode_builder_1.BuildType.MP)) {
193
- if (deployOptions.mpDeployPrivateKey) {
194
- fs_extra_1.default.writeFileSync(path_1.default.join(this.api.projectPath, `./private.${deployOptions.mpAppId}.key`), deployOptions.mpDeployPrivateKey, 'base64');
124
+ var _a, _b, _c, _d;
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ if (resolveInputs.runtime === lowcode_builder_1.RUNTIME.CLI) {
127
+ return;
195
128
  }
196
- let projectJson = fs_extra_1.default.readJsonSync(path_1.default.resolve(this.api.projectPath, exports.DIST_PATH, 'project.config.json'));
197
- let { cloudfunctionRoot, miniprogramRoot = './' } = projectJson;
198
- let setting = {
199
- es6: true,
200
- es7: true,
201
- minify: true,
202
- codeProtect: false,
203
- useCompilerPlugins: ['typescript'],
204
- };
205
- this._miniprogramePlugin = new framework_plugin_mp_1.plugin('miniprograme', this.api, {
206
- appid: deployOptions.mpAppId,
207
- privateKeyPath: `./private.${deployOptions.mpAppId}.key`,
208
- localPath: exports.DIST_PATH,
209
- ignores: ['node_modules/**/*', LOG_FILE].concat(cloudfunctionRoot ? [path_1.default.join(cloudfunctionRoot, '**/*')] : []),
210
- deployMode: deployOptions.mpAppId === deployOptions.targetMpAppId ? deployOptions.mode : lowcode_builder_1.DEPLOY_MODE.UPLOAD,
211
- uploadOptions: {
212
- version: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.version) || '1.0.0',
213
- desc: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.description) || '',
214
- setting,
215
- },
216
- previewOptions: {
217
- qrcodeOutputPath: path_1.default.resolve(this.api.projectPath, QRCODE_PATH),
218
- pagePath: (_b = (_a = fs_extra_1.default.readJsonSync(path_1.default.resolve(this.api.projectPath, exports.DIST_PATH, miniprogramRoot, 'app.json'))) === null || _a === void 0 ? void 0 : _a.pages) === null || _b === void 0 ? void 0 : _b[0],
219
- setting,
220
- },
221
- });
222
- }
223
- else if ((0, lowcode_builder_1.buildAsWebByBuildType)(buildTypeList)) {
224
- this._webPlugin = new framework_plugin_website_1.plugin('web', this.api, {
225
- outputPath: exports.DIST_PATH,
226
- cloudPath: this._getWebRootPath(),
227
- ignore: ['.git', '.github', 'node_modules', 'cloudbaserc.js', LOG_FILE, DEFAULT_CLOUDFUNCTION_ROOT_NAME],
129
+ let { buildTypeList, deployOptions } = resolveInputs;
130
+ this._authPlugin = new framework_plugin_auth_1.plugin('auth', this.api, {
131
+ configs: [
132
+ {
133
+ platform: 'NONLOGIN',
134
+ status: 'ENABLE',
135
+ platformId: '',
136
+ platformSecret: '',
137
+ },
138
+ {
139
+ platform: 'ANONYMOUS',
140
+ status: 'ENABLE',
141
+ platformId: '',
142
+ platformSecret: '',
143
+ },
144
+ ],
228
145
  });
229
- }
146
+ const artifactOptions = this._resolvedInputs.runtime === lowcode_builder_1.RUNTIME.CI
147
+ ? {
148
+ credential: this._resolvedInputs.credential,
149
+ bucket: ((_a = this._resolvedInputs.storage) === null || _a === void 0 ? void 0 : _a.bucket) || '',
150
+ region: ((_b = this._resolvedInputs.storage) === null || _b === void 0 ? void 0 : _b.region) || '',
151
+ baseKey: this._productBasePath || '',
152
+ }
153
+ : undefined;
154
+ if (buildTypeList.includes(lowcode_builder_1.BuildType.MP)) {
155
+ if (deployOptions.mpDeployPrivateKey) {
156
+ fs_extra_1.default.writeFileSync(path_1.default.join(this.api.projectPath, `./private.${deployOptions.mpAppId}.key`), deployOptions.mpDeployPrivateKey, 'base64');
157
+ }
158
+ let projectJson = fs_extra_1.default.readJsonSync(path_1.default.resolve(this.api.projectPath, exports.DIST_PATH, 'project.config.json'));
159
+ let { cloudfunctionRoot, miniprogramRoot = './' } = projectJson;
160
+ let setting = {
161
+ es6: true,
162
+ es7: true,
163
+ minify: true,
164
+ codeProtect: false,
165
+ useCompilerPlugins: ['typescript'],
166
+ };
167
+ this._miniprogramePlugin = new mpPlugin_1.plugin('miniprograme', this.api, {
168
+ appid: deployOptions.mpAppId,
169
+ privateKeyPath: `./private.${deployOptions.mpAppId}.key`,
170
+ localPath: exports.DIST_PATH,
171
+ ignores: ['node_modules/**/*', LOG_FILE].concat(cloudfunctionRoot ? [path_1.default.join(cloudfunctionRoot, '**/*')] : []),
172
+ deployMode: deployOptions.mpAppId === deployOptions.targetMpAppId ? deployOptions.mode : lowcode_builder_1.DEPLOY_MODE.UPLOAD,
173
+ uploadOptions: {
174
+ version: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.version) || '1.0.0',
175
+ desc: (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.description) || '',
176
+ setting,
177
+ },
178
+ previewOptions: {
179
+ qrcodeOutputPath: path_1.default.resolve(this.api.projectPath, QRCODE_PATH),
180
+ pagePath: (_d = (_c = fs_extra_1.default.readJsonSync(path_1.default.resolve(this.api.projectPath, exports.DIST_PATH, miniprogramRoot, 'app.json'))) === null || _c === void 0 ? void 0 : _c.pages) === null || _d === void 0 ? void 0 : _d[0],
181
+ setting,
182
+ },
183
+ artifactOptions,
184
+ deployerOprions: {
185
+ appId: this._resolvedInputs.appId,
186
+ envId: this.api.envId,
187
+ credential: yield this.api.getCredential(),
188
+ },
189
+ });
190
+ }
191
+ else {
192
+ const credential = yield this.api.getCredential();
193
+ this._deployer = new lowcode_deployer_1.default({
194
+ api: this.api,
195
+ logger: this.api.logger,
196
+ appId: this._resolvedInputs.appId,
197
+ envId: this.api.envId,
198
+ type: 'WEB',
199
+ mode: this._resolvedInputs.deployOptions.mode === lowcode_builder_1.DEPLOY_MODE.UPLOAD ? lowcode_deployer_1.EDeployMode.PRODUCTION : lowcode_deployer_1.EDeployMode.PREVIEW,
200
+ projectPath: path_1.default.resolve(this.api.projectPath, exports.DIST_PATH),
201
+ credential,
202
+ ignores: ['.git', '.github', 'node_modules', 'cloudbaserc.js', LOG_FILE, DEFAULT_CLOUDFUNCTION_ROOT_NAME],
203
+ webOptions: {
204
+ cloudPath: this._getWebRootPath(this._resolvedInputs),
205
+ buildTypeList: this._resolvedInputs.buildTypeList,
206
+ credential,
207
+ gatewayConfig: this._gatewayConfig
208
+ ? {
209
+ domain: this._gatewayConfig.Domain,
210
+ path: this._gatewayConfig.Path,
211
+ }
212
+ : undefined,
213
+ },
214
+ artifactOptions,
215
+ });
216
+ }
217
+ });
230
218
  }
231
- _getWebRootPath() {
232
- let { appId, deployOptions } = this._resolvedInputs;
219
+ _getWebRootPath({ appId, deployOptions }) {
233
220
  return (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === lowcode_builder_1.DEPLOY_MODE.PREVIEW ? `/${appId}/preview/` : `/${appId}/production/`;
234
221
  }
235
222
  _time(label) {
@@ -257,25 +244,19 @@ class LowCodePlugin extends framework_core_1.Plugin {
257
244
  return __awaiter(this, void 0, void 0, function* () { });
258
245
  }
259
246
  build() {
260
- var _a, _b, _c, _d, _e, _f;
247
+ var _a, _b, _c, _d, _e;
261
248
  return __awaiter(this, void 0, void 0, function* () {
262
249
  let { logger } = this.api;
263
250
  const staticDir = path_1.default.resolve(__dirname, '../../../static');
264
- let { debug, subAppSerializeDataList, dependencies, appId, buildTypeList, generateMpType, plugins, extraData = { isComposite: false, compProps: {} }, } = this._resolvedInputs;
251
+ let { debug, subAppSerializeDataList, dependencies, appId, buildTypeList, generateMpType, plugins, extraData, runtimeEndpointType, } = this._resolvedInputs;
265
252
  const webpackMode = ((_a = this._resolvedInputs.deployOptions) === null || _a === void 0 ? void 0 : _a.mode) === lowcode_builder_1.DEPLOY_MODE.UPLOAD
266
253
  ? lowcode_builder_1.WebpackModeType.PRODUCTION
267
254
  : lowcode_builder_1.WebpackModeType.NONE;
268
255
  let miniAppDir = '';
269
256
  let webAppDir = '';
270
- const h5url = `./${appId}/index.html`;
271
- if (extraData.isComposite) {
272
- Object.keys(extraData.compProps.events).forEach((eName) => {
273
- extraData.compProps.events[eName] = `$$EVENT_${eName}$$`;
274
- });
275
- }
276
257
  try {
277
258
  const { envId } = this.api;
278
- let [website, hostingDatas] = yield this._getHostingInfoTask(envId, true);
259
+ let [website] = yield this._getHostingInfoTask(envId, true);
279
260
  this._website = website;
280
261
  }
281
262
  catch (e) {
@@ -286,11 +267,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
286
267
  if ((0, lowcode_builder_1.buildAsWebByBuildType)(buildTypeList)) {
287
268
  let { appConfig = {} } = this._resolvedInputs.mainAppSerializeData.extra;
288
269
  let { window = {} } = appConfig;
289
- if ((0, lowcode_builder_1.buildAsXPageByBuildType)(buildTypeList)) {
290
- window.publicPath =
291
- ((_d = this._resolvedInputs.deployOptions) === null || _d === void 0 ? void 0 : _d.publicPath) || `https://${domain}${this._getWebRootPath()}`;
292
- }
293
- else if (this._resolvedInputs.deployOptions.mode === lowcode_builder_1.DEPLOY_MODE.UPLOAD) {
270
+ if (!(0, lowcode_builder_1.buildAsXPageByBuildType)(buildTypeList) && this._resolvedInputs.deployOptions.mode === lowcode_builder_1.DEPLOY_MODE.UPLOAD) {
294
271
  try {
295
272
  const { Data = {} } = yield this.api.cloudbaseManager.commonService('lowcode', '2021-01-08').call({
296
273
  Action: 'DescribeAppCustomUrls',
@@ -300,11 +277,11 @@ class LowCodePlugin extends framework_core_1.Plugin {
300
277
  WeAppId: appId,
301
278
  },
302
279
  });
303
- this.api.logger.debug('DescribeAppCustomUrls:', (_e = Data === null || Data === void 0 ? void 0 : Data.Items) === null || _e === void 0 ? void 0 : _e[0]);
304
- this._gatewayConfig = (_f = Data === null || Data === void 0 ? void 0 : Data.Items) === null || _f === void 0 ? void 0 : _f[0];
280
+ this.api.logger.debug('DescribeAppCustomUrls:', (_d = Data === null || Data === void 0 ? void 0 : Data.Items) === null || _d === void 0 ? void 0 : _d[0]);
281
+ this._gatewayConfig = (_e = Data === null || Data === void 0 ? void 0 : Data.Items) === null || _e === void 0 ? void 0 : _e[0];
305
282
  if (this._gatewayConfig) {
306
283
  const path = this._gatewayConfig.Path;
307
- window.publicPath = `https://${domain}${this._getWebRootPath()}`;
284
+ window.publicPath = `https://${domain}${this._getWebRootPath(this._resolvedInputs)}`;
308
285
  if (!(0, lowcode_builder_1.buildAsAdminPortalByBuildType)(buildTypeList)) {
309
286
  window.basename = path;
310
287
  window._indexPage = true;
@@ -344,13 +321,13 @@ class LowCodePlugin extends framework_core_1.Plugin {
344
321
  extraData,
345
322
  resourceAppId: this._resolvedInputs.mpAppId,
346
323
  domain,
324
+ endpointType: runtimeEndpointType,
347
325
  }, (err, result) => __awaiter(this, void 0, void 0, function* () {
348
- var _a;
349
326
  if (!err) {
350
327
  try {
351
328
  const { appConfig = {} } = this._resolvedInputs.mainAppSerializeData.extra;
352
329
  const { publicPath = '' } = (appConfig === null || appConfig === void 0 ? void 0 : appConfig.window) || {};
353
- const { outDir = '', timeElapsed = 0, plugins } = result || {};
330
+ const { outDir = '', timeElapsed = 0 } = result || {};
354
331
  if (buildTypeList.includes(lowcode_builder_1.BuildType.MP)) {
355
332
  miniAppDir = outDir;
356
333
  }
@@ -358,37 +335,14 @@ class LowCodePlugin extends framework_core_1.Plugin {
358
335
  webAppDir = path_1.default.resolve(outDir, 'preview');
359
336
  }
360
337
  logger.debug(`=== Compilation finished at ${outDir}, elapsed time: ${timeElapsed / 1000}s.===\n`);
361
- if (buildTypeList.includes(lowcode_builder_1.BuildType.MP) && miniAppDir) {
362
- let projectJsonPath = path_1.default.resolve(miniAppDir, 'project.config.json');
363
- yield (0, postProcess_1.postprocessProjectConfig)(projectJsonPath, {
364
- appid: this._resolvedInputs.deployOptions.mpAppId,
365
- cloudfunctionRoot: undefined,
366
- });
367
- yield (0, postProcess_1.postprocessDeployExtraJson)(miniAppDir, this._resolvedInputs.deployOptions);
368
- if (generateMpType === lowcode_builder_1.GenerateMpType.APP) {
369
- fs_extra_1.default.removeSync(path_1.default.resolve(miniAppDir, 'miniprogram_npm'));
370
- }
371
- if (outDir) {
372
- if (plugins) {
373
- yield (0, generate_1.handleMpPlugins)(plugins, outDir);
374
- }
375
- }
376
- }
377
- else if ((0, lowcode_builder_1.buildAsWebByBuildType)(buildTypeList) && webAppDir) {
378
- const staticAppDir = path_1.default.join(staticDir, publicPath);
379
- fs_extra_1.default.ensureDirSync(staticAppDir);
380
- }
381
338
  let distPath = path_1.default.resolve(this.api.projectPath, exports.DIST_PATH);
382
339
  if (miniAppDir) {
383
340
  fs_extra_1.default.copySync(miniAppDir, distPath);
384
341
  }
385
342
  else if (webAppDir) {
343
+ const staticAppDir = path_1.default.join(staticDir, publicPath);
344
+ fs_extra_1.default.ensureDirSync(staticAppDir);
386
345
  fs_extra_1.default.copySync(webAppDir, distPath);
387
- if ((0, lowcode_builder_1.buildAsWebByBuildType)(buildTypeList) &&
388
- !(0, lowcode_builder_1.buildAsAdminPortalByBuildType)(buildTypeList) &&
389
- this._checkBroswerHisroty()) {
390
- yield Promise.all((((_a = this._resolvedInputs.mainAppSerializeData) === null || _a === void 0 ? void 0 : _a.items) || []).map((page) => fs_extra_1.default.copy(path_1.default.join(distPath, 'index.html'), path_1.default.join(distPath, page.id, 'index.html'))));
391
- }
392
346
  }
393
347
  resolve(distPath);
394
348
  }
@@ -398,28 +352,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
398
352
  }
399
353
  }
400
354
  else {
401
- if (err.length) {
402
- let messageList = (err[0] || '').split('\n');
403
- let lineIndex = 0;
404
- let reg = /node_modules\/@babel/;
405
- messageList.find((str, index) => {
406
- if (reg.test(str)) {
407
- lineIndex = index;
408
- return true;
409
- }
410
- else {
411
- return false;
412
- }
413
- });
414
- if (lineIndex) {
415
- messageList = messageList.slice(0, lineIndex);
416
- }
417
- let error = new Error(messageList.join('\n'));
418
- reject(error);
419
- }
420
- else {
421
- reject(err);
422
- }
355
+ reject(err);
423
356
  }
424
357
  }));
425
358
  }
@@ -431,33 +364,18 @@ class LowCodePlugin extends framework_core_1.Plugin {
431
364
  resumeConsoleOutput();
432
365
  }
433
366
  logger.info(`code generated successfully, cost ${this._timeEnd("build process")}s: ${this._appPath}`);
434
- this._subPluginConstructor(this._resolvedInputs);
367
+ yield this._subPluginConstructor(this._resolvedInputs);
435
368
  if (this._miniprogramePlugin) {
436
369
  this._time("build mp plugin");
437
370
  yield this._miniprogramePlugin.init();
438
- try {
439
- yield this.mpAnalyzeAndCleanCode(this._appPath);
440
- }
441
- catch (e) {
442
- logger.info(`miniprogram stream line file: ${e}`);
443
- }
444
371
  yield this._miniprogramePlugin.build();
445
372
  logger.debug(`miniprograme plugin build cost ${this._timeEnd("build mp plugin")}s`);
446
373
  }
447
- else if (this._webPlugin) {
448
- this._time("build web plugin");
449
- yield this._webPlugin.init();
450
- yield this._webPlugin.build();
451
- logger.debug(`website plugin build cost ${this._timeEnd("build web plugin")}s`);
452
- }
453
374
  }
454
375
  catch (e) {
455
376
  if (debug) {
456
377
  yield this._debugInfo();
457
378
  }
458
- if (this._resolvedInputs.runtime === lowcode_builder_1.RUNTIME.CI) {
459
- yield this._handleCIProduct();
460
- }
461
379
  logger.info(`low-code build fail: ${e}`);
462
380
  throw e;
463
381
  }
@@ -466,7 +384,6 @@ class LowCodePlugin extends framework_core_1.Plugin {
466
384
  });
467
385
  }
468
386
  compile() {
469
- var _a;
470
387
  return __awaiter(this, void 0, void 0, function* () {
471
388
  try {
472
389
  this._time("compile");
@@ -484,56 +401,8 @@ class LowCodePlugin extends framework_core_1.Plugin {
484
401
  if (this._miniprogramePlugin) {
485
402
  res = (0, lodash_1.merge)(res, yield this._miniprogramePlugin.compile());
486
403
  }
487
- else if ((0, lowcode_builder_1.buildAsWebByBuildType)(this._resolvedInputs.buildTypeList) && this._webPlugin) {
488
- try {
489
- const HostingProvider = (_a = this.api.resourceProviders) === null || _a === void 0 ? void 0 : _a.hosting;
490
- const { envId } = this.api;
491
- let [website, hostingDatas] = yield this._getHostingInfoTask(envId, false);
492
- if (HostingProvider) {
493
- if (!hostingDatas) {
494
- hostingDatas = (yield HostingProvider.getHostingInfo({ envId })).data;
495
- }
496
- let domains = hostingDatas.map((item) => item.cdnDomain);
497
- this._domain = domains;
498
- }
499
- if (website) {
500
- this._website = website;
501
- }
502
- }
503
- catch (e) {
504
- this.api.logger.error('获取静态托管失败: ', e);
505
- throw e;
506
- }
507
- const privateJsPath = path_1.default.join('/', 'tmp', private_1.PRIVATE_JS_NAME);
508
- try {
509
- yield fs_extra_1.default.ensureFile(privateJsPath);
510
- yield fs_extra_1.default.writeFile(privateJsPath, private_1.PRIVATE_JS_CODE, {
511
- encoding: 'utf8',
512
- flag: 'w',
513
- });
514
- }
515
- catch (e) {
516
- this.api.logger.error('创建私有化JS文件失败:', e);
517
- throw e;
518
- }
519
- if (!(0, lowcode_builder_1.buildAsXPageByBuildType)(this._resolvedInputs.buildTypeList)) {
520
- const deployContent = [
521
- ...(this._webPlugin.buildOutput.static || []),
522
- ...(this._webPlugin.buildOutput.staticConfig || []),
523
- {
524
- src: privateJsPath,
525
- cloudPath: `/weda-config/${private_1.PRIVATE_JS_NAME}`,
526
- },
527
- ];
528
- yield Promise.all(deployContent.map((options) => this.api.cloudbaseManager.hosting.uploadFiles({
529
- localPath: options.src,
530
- cloudPath: options.cloudPath,
531
- ignore: this._webPlugin.resolvedInputs.ignore,
532
- })));
533
- }
534
- else {
535
- this.api.logger.info('xpage 跳过部署流程');
536
- }
404
+ else if ((0, lowcode_builder_1.buildAsWebByBuildType)(this._resolvedInputs.buildTypeList)) {
405
+ this._deployer.deploy();
537
406
  }
538
407
  if (!Object.keys(res.Resources || {}).length && !Object.keys(res.Config || {}).length) {
539
408
  this._skipInstallExt = true;
@@ -545,9 +414,6 @@ class LowCodePlugin extends framework_core_1.Plugin {
545
414
  if (this._resolvedInputs.debug) {
546
415
  yield this._debugInfo();
547
416
  }
548
- if (this._resolvedInputs.runtime === lowcode_builder_1.RUNTIME.CI) {
549
- yield this._handleCIProduct();
550
- }
551
417
  throw e;
552
418
  }
553
419
  });
@@ -559,57 +425,6 @@ class LowCodePlugin extends framework_core_1.Plugin {
559
425
  if (this._miniprogramePlugin) {
560
426
  yield this._miniprogramePlugin.deploy();
561
427
  }
562
- else if (this._webPlugin) {
563
- yield this._webPlugin.deploy();
564
- if ((0, lowcode_builder_1.buildAsAdminPortalByBuildType)(this._resolvedInputs.buildTypeList)) {
565
- yield this._postProcessAdminPortal();
566
- }
567
- else {
568
- yield this._postProcessWebsiteConfig();
569
- }
570
- try {
571
- const { deployOptions, appId } = this._resolvedInputs;
572
- const isPreview = (deployOptions === null || deployOptions === void 0 ? void 0 : deployOptions.mode) === lowcode_builder_1.DEPLOY_MODE.PREVIEW;
573
- const link = (0, lowcode_builder_1.buildAsAdminPortalByBuildType)(this._resolvedInputs.buildTypeList)
574
- ? `https://${this._website.cdnDomain}/adminportal/#/app/${isPreview ? `${appId}-preview` : appId}?envType=${isPreview ? 'preview' : 'prod'}`
575
- : this._gatewayConfig
576
- ? `https://${this._gatewayConfig.Domain + this._gatewayConfig.Path}`
577
- : `https://${this._website.cdnDomain + this._webPlugin.resolvedInputs.cloudPath}`;
578
- const qrcodeOutputPath = path_1.default.resolve(this.api.projectPath, QRCODE_PATH);
579
- yield qrcode_1.default.toFile(path_1.default.resolve(this.api.projectPath, QRCODE_PATH), link, {
580
- errorCorrectionLevel: 'M',
581
- type: 'image/jpeg',
582
- scale: 12,
583
- margin: 2,
584
- });
585
- this.api.logger.info(`${this.api.emoji('🚀')} 网站部署成功:${link}`);
586
- this.api.logger.info(`${this.api.emoji('🚀')} 网站部署成功, 访问二维码地址:${this.api.genClickableLink(url_1.default.format({
587
- protocol: 'file:',
588
- host: qrcodeOutputPath,
589
- }))}`);
590
- }
591
- catch (e) {
592
- this.api.logger.error('网站部署失败: ', e);
593
- throw e;
594
- }
595
- }
596
- try {
597
- let publishAppCustomNavRes = yield this.api.cloudbaseManager.commonService('lowcode', '2021-01-08').call({
598
- Action: 'PublishAppCustomNav',
599
- Param: {
600
- WeAppId: this._resolvedInputs.appId,
601
- EnvId: this.api.envId,
602
- PublishType: this._resolvedInputs.deployOptions.mode === lowcode_builder_1.DEPLOY_MODE.UPLOAD ? 'product' : 'preview',
603
- },
604
- });
605
- this.api.logger.info(`${this.api.emoji('🚀')} custom publish success: ${JSON.stringify(publishAppCustomNavRes)}`);
606
- }
607
- catch (e) {
608
- this.api.logger.error(`${this.api.emoji('🚀')} custom publish fail: ${JSON.stringify(e)}`);
609
- if ((e === null || e === void 0 ? void 0 : e.code) !== 'ResourceNotFound') {
610
- throw e;
611
- }
612
- }
613
428
  if (this._skipInstallExt) {
614
429
  try {
615
430
  yield this.api.cloudApi.tcbService.request('CloudBaseCIResultCallback', {
@@ -634,45 +449,12 @@ class LowCodePlugin extends framework_core_1.Plugin {
634
449
  yield this._debugInfo();
635
450
  }
636
451
  if (this._resolvedInputs.runtime === lowcode_builder_1.RUNTIME.CI) {
637
- yield this._handleCIProduct();
638
452
  yield this._postPersistentDependiences();
639
453
  }
640
454
  }
641
455
  return;
642
456
  });
643
457
  }
644
- mpAnalyzeAndCleanCode(distDir) {
645
- return __awaiter(this, void 0, void 0, function* () {
646
- let { deployOptions } = this._resolvedInputs;
647
- const project = new mpci.Project({
648
- appid: deployOptions.mpAppId,
649
- projectPath: distDir,
650
- type: 'miniProgram',
651
- privateKeyPath: `./private.${deployOptions.mpAppId}.key`,
652
- });
653
- const analyseRes = yield mpci.analyseCode(project);
654
- if (analyseRes) {
655
- const codeExtensions = new Set(['.wxml', '.wxss', '.wxs', '.js', '.json', '.json', '.ts']);
656
- const { files } = analyseRes;
657
- const filesToDelete = files
658
- .filter((f) => {
659
- var _a, _b;
660
- if (codeExtensions.has(f.ext) && !f.moduleId && ((_b = (_a = f.path) === null || _a === void 0 ? void 0 : _a.startsWith) === null || _b === void 0 ? void 0 : _b.call(_a, 'materials/'))) {
661
- return true;
662
- }
663
- return false;
664
- })
665
- .map((f) => f.path);
666
- this.api.logger.warn('-------------------filesToDelete', filesToDelete.join('\n'));
667
- yield Promise.all(filesToDelete.map((f) => __awaiter(this, void 0, void 0, function* () {
668
- yield fs_extra_1.default.remove(path_1.default.join(distDir, f));
669
- })));
670
- }
671
- else {
672
- this.api.logger.warn('小程序代码静态分析失败');
673
- }
674
- });
675
- }
676
458
  _getHostingInfoTask(envId, loose = false) {
677
459
  return __awaiter(this, void 0, void 0, function* () {
678
460
  let timeout = null;
@@ -716,105 +498,6 @@ class LowCodePlugin extends framework_core_1.Plugin {
716
498
  _checkIsVersion(version) {
717
499
  return version === 'latest' || String(version).startsWith('2');
718
500
  }
719
- _handleCIProduct() {
720
- return __awaiter(this, void 0, void 0, function* () {
721
- try {
722
- fs_extra_1.default.ensureDirSync(path_1.default.resolve(this.api.projectPath, exports.DIST_PATH));
723
- const zipPath = path_1.default.resolve(this.api.projectPath, `${this._resolvedInputs.appId}.zip`);
724
- yield this._zipDir(path_1.default.resolve(this.api.projectPath, exports.DIST_PATH), zipPath);
725
- let { credential, storage } = this._resolvedInputs;
726
- let cos = (credential === null || credential === void 0 ? void 0 : credential.token)
727
- ? new cos_nodejs_sdk_v5_1.default({
728
- getAuthorization(options, callback) {
729
- callback({
730
- TmpSecretId: (credential === null || credential === void 0 ? void 0 : credential.secretId) || '',
731
- TmpSecretKey: (credential === null || credential === void 0 ? void 0 : credential.secretKey) || '',
732
- XCosSecurityToken: (credential === null || credential === void 0 ? void 0 : credential.token) || '',
733
- ExpiredTime: Math.floor(Date.now() / 1000) + 600,
734
- StartTime: Math.floor(Date.now() / 1000),
735
- });
736
- },
737
- })
738
- : new cos_nodejs_sdk_v5_1.default({
739
- SecretId: credential === null || credential === void 0 ? void 0 : credential.secretId,
740
- SecretKey: credential === null || credential === void 0 ? void 0 : credential.secretKey,
741
- });
742
- yield new Promise((resolve, reject) => {
743
- cos.putObject({
744
- Bucket: (storage === null || storage === void 0 ? void 0 : storage.bucket) || '',
745
- Region: (storage === null || storage === void 0 ? void 0 : storage.region) || '',
746
- Key: `${this._productBasePath}/dist.zip`,
747
- Body: fs_extra_1.default.createReadStream(zipPath),
748
- }, (err, data) => {
749
- if (err) {
750
- reject(err);
751
- }
752
- else {
753
- resolve(data);
754
- }
755
- });
756
- });
757
- fs_extra_1.default.removeSync(zipPath);
758
- if (fs_extra_1.default.existsSync(path_1.default.resolve(this.api.projectPath, QRCODE_PATH))) {
759
- yield new Promise((resolve, reject) => {
760
- cos.putObject({
761
- Bucket: (storage === null || storage === void 0 ? void 0 : storage.bucket) || '',
762
- Region: (storage === null || storage === void 0 ? void 0 : storage.region) || '',
763
- Key: `${this._productBasePath}/qrcode.jpg`,
764
- Body: fs_extra_1.default.createReadStream(path_1.default.resolve(this.api.projectPath, QRCODE_PATH)),
765
- }, (err, data) => {
766
- if (err) {
767
- reject(err);
768
- }
769
- else {
770
- resolve(data);
771
- }
772
- });
773
- });
774
- }
775
- if (this._logFilePath) {
776
- yield new Promise((resolve, reject) => {
777
- cos.putObject({
778
- Bucket: (storage === null || storage === void 0 ? void 0 : storage.bucket) || '',
779
- Region: (storage === null || storage === void 0 ? void 0 : storage.region) || '',
780
- Key: `${this._productBasePath}/${LOG_FILE}`,
781
- Body: fs_extra_1.default.createReadStream(this._logFilePath),
782
- }, (err, data) => {
783
- if (err) {
784
- reject(err);
785
- }
786
- else {
787
- resolve(data);
788
- }
789
- });
790
- });
791
- }
792
- if (fs_extra_1.default.existsSync(path_1.default.resolve(this.api.projectPath, DEBUG_PATH)) && this._resolvedInputs.debug) {
793
- const zipPath = path_1.default.resolve(this.api.projectPath, `debug.zip`);
794
- yield this._zipDir(path_1.default.resolve(this.api.projectPath, DEBUG_PATH), zipPath);
795
- yield new Promise((resolve, reject) => {
796
- cos.putObject({
797
- Bucket: (storage === null || storage === void 0 ? void 0 : storage.bucket) || '',
798
- Region: (storage === null || storage === void 0 ? void 0 : storage.region) || '',
799
- Key: `${this._productBasePath}/debug.zip`,
800
- Body: fs_extra_1.default.createReadStream(zipPath),
801
- }, (err, data) => {
802
- if (err) {
803
- reject(err);
804
- }
805
- else {
806
- resolve(data);
807
- }
808
- });
809
- });
810
- }
811
- this.api.logger.info(`${this.api.emoji('🚀')} 上传制品成功。`);
812
- }
813
- catch (e) {
814
- this.api.logger.error(`${this.api.emoji('🚀')} 上传制品失败:`, e);
815
- }
816
- });
817
- }
818
501
  _postPersistentDependiences() {
819
502
  return __awaiter(this, void 0, void 0, function* () {
820
503
  let promises = [];
@@ -896,80 +579,6 @@ class LowCodePlugin extends framework_core_1.Plugin {
896
579
  });
897
580
  });
898
581
  }
899
- _postProcessAdminPortal() {
900
- var _a, _b;
901
- return __awaiter(this, void 0, void 0, function* () {
902
- const { buildTypeList } = this._resolvedInputs;
903
- if ((0, lowcode_builder_1.buildAsAdminPortalByBuildType)(buildTypeList)) {
904
- try {
905
- if (((_b = (_a = this._resolvedInputs) === null || _a === void 0 ? void 0 : _a.deployOptions) === null || _b === void 0 ? void 0 : _b.mode) === lowcode_builder_1.DEPLOY_MODE.UPLOAD) {
906
- yield this.api.cloudbaseManager.commonService('lowcode', '2021-01-08').call({
907
- Action: 'PublishAppCustomUrl',
908
- Param: {
909
- EnvId: this.api.envId,
910
- WeAppId: this._resolvedInputs.appId,
911
- },
912
- });
913
- }
914
- this.api.logger.info('PublishAppCustomUrl成功');
915
- }
916
- catch (e) {
917
- this.api.logger.error('PublishAppCustomUrl失败: ', e);
918
- }
919
- }
920
- });
921
- }
922
- _postProcessWebsiteConfig() {
923
- var _a, _b;
924
- return __awaiter(this, void 0, void 0, function* () {
925
- const hostingService = this.api.cloudbaseManager.hosting;
926
- try {
927
- let domains = this._domain;
928
- let { Domains: domainList } = yield hostingService.tcbCheckResource({
929
- domains,
930
- });
931
- if (!this._website) {
932
- throw new Error('检查静态托管开通超时');
933
- }
934
- let modifyDomainConfigPromises = domainList
935
- .filter((item) => item.DomainConfig.FollowRedirect !== 'on')
936
- .map((item) => hostingService.tcbModifyAttribute({
937
- domain: item.Domain,
938
- domainId: item.DomainId,
939
- domainConfig: { FollowRedirect: 'on' },
940
- }));
941
- yield Promise.all(modifyDomainConfigPromises);
942
- yield Promise.all([
943
- ((_b = (_a = this._resolvedInputs) === null || _a === void 0 ? void 0 : _a.deployOptions) === null || _b === void 0 ? void 0 : _b.mode) === lowcode_builder_1.DEPLOY_MODE.UPLOAD
944
- ? this.api.cloudbaseManager
945
- .commonService('lowcode', '2021-01-08')
946
- .call({
947
- Action: 'PublishAppCustomUrl',
948
- Param: {
949
- EnvId: this.api.envId,
950
- WeAppId: this._resolvedInputs.appId,
951
- IndexPath: this._getWebRootPath(),
952
- },
953
- })
954
- .catch((e) => {
955
- this.api.logger.error('自定义域名发布失败: ', e);
956
- if ((e === null || e === void 0 ? void 0 : e.code) !== 'ResourceNotFound') {
957
- throw e;
958
- }
959
- })
960
- : Promise.resolve(),
961
- ]);
962
- }
963
- catch (e) {
964
- this.api.logger.error('网站路由注册失败: ', e);
965
- throw e;
966
- }
967
- });
968
- }
969
- _checkBroswerHisroty() {
970
- let historyType = this._resolvedInputs.mainAppSerializeData.extra.historyType ? lowcode_builder_1.HISTORY_TYPE.HASH : '';
971
- return !historyType || historyType === lowcode_builder_1.HISTORY_TYPE.BROWSER;
972
- }
973
582
  }
974
583
  function resolveInputs(inputs, defaultInputs) {
975
584
  return Object.assign({}, defaultInputs, inputs);
package/lib/mpPlugin.d.ts CHANGED
@@ -10,6 +10,11 @@ interface IFrameworkPluginMiniProgramInputs {
10
10
  uploadOptions?: IMiniProgramUploadOptions;
11
11
  commands?: Record<string, string>;
12
12
  artifactOptions?: any;
13
+ deployerOprions: {
14
+ appId: string;
15
+ envId: string;
16
+ credential: any;
17
+ };
13
18
  }
14
19
  interface IMiniProgramUploadOptions {
15
20
  version?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"mpPlugin.d.ts","sourceRoot":"","sources":["../src/mpPlugin.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAMrE,UAAU,iCAAiC;IAIzC,KAAK,EAAE,MAAM,CAA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MlB,WAAW,CAAC,EAAE,MAAM,CAAC;IAMrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,wBAAwB;IAMhC,GAAG,CAAC,EAAE,OAAO,CAAC;IAMd,MAAM,CAAC,EAAE,OAAO,CAAC;IAMjB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,uBAAuB;IAI/B,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,cAAM,kBAAmB,SAAQ,MAAM;IAKlB,IAAI,EAAE,MAAM;IAAS,GAAG,EAAE,gBAAgB;IAAS,MAAM,EAAE,iCAAiC;IAJ/G,SAAS,CAAC,cAAc,EAAE,iCAAiC,CAAC;IAC5D,SAAS,CAAC,WAAW,EAAE,uBAAuB,CAAC;IAC/C,SAAS,CAAC,QAAQ,MAAC;gBAEA,IAAI,EAAE,MAAM,EAAS,GAAG,EAAE,gBAAgB,EAAS,MAAM,EAAE,iCAAiC;IAezG,IAAI;IAQV,OAAO;IAwDD,GAAG;IAKH,MAAM;IAKN,OAAO;IAKP,KAAK;IAgCL,OAAO;IAyBP,MAAM;CAsBb;AAMD,eAAO,MAAM,MAAM,2BAAqB,CAAC"}
package/lib/mpPlugin.js CHANGED
@@ -89,21 +89,11 @@ class MiniProgramsPlugin extends framework_core_1.Plugin {
89
89
  if (!fs_1.default.existsSync(path_1.default.resolve(projectPath, localPath, MP_CONFIG_FILENAME))) {
90
90
  throw new Error('项目内找不到小程序配置文件 project.config.json,请在 cloudbaserc.json 中指明小程序应用的项目路径 localPath.');
91
91
  }
92
- this.deployer = new lowcode_deployer_1.default({
93
- api: this.api,
94
- logger: this.api.logger,
95
- type: 'MP',
96
- mode: ((_a = this.resolvedInputs) === null || _a === void 0 ? void 0 : _a.deployMode) === 'upload' ? lowcode_deployer_1.EDeployMode.PRODUCTION : lowcode_deployer_1.EDeployMode.PREVIEW,
97
- projectPath: path_1.default.resolve(projectPath, localPath),
98
- ignores: this.resolvedInputs.ignores,
99
- mpAppId: appid,
100
- miniprogramOptions: {
92
+ this.deployer = new lowcode_deployer_1.default(Object.assign({ api: this.api, logger: this.api.logger, type: 'MP', mode: ((_a = this.resolvedInputs) === null || _a === void 0 ? void 0 : _a.deployMode) === 'upload' ? lowcode_deployer_1.EDeployMode.PRODUCTION : lowcode_deployer_1.EDeployMode.PREVIEW, projectPath: path_1.default.resolve(projectPath, localPath), ignores: this.resolvedInputs.ignores, mpAppId: appid, miniprogramOptions: {
101
93
  privateKeyPath: path_1.default.resolve(projectPath, this.resolvedInputs.privateKeyPath),
102
94
  uploadOptions: this.resolvedInputs.uploadOptions,
103
95
  previewOptions: this.resolvedInputs.previewOptions,
104
- },
105
- artifactOptions: this.resolvedInputs.artifactOptions,
106
- });
96
+ }, artifactOptions: this.resolvedInputs.artifactOptions }, this.resolvedInputs.deployerOprions));
107
97
  }
108
98
  run() {
109
99
  return __awaiter(this, void 0, void 0, function* () { });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "1.1.5",
3
+ "version": "1.2.1-alpha.0",
4
4
  "description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
5
5
  "author": "yhsunshining@gmail.com",
6
6
  "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
@@ -37,12 +37,13 @@
37
37
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@cloudbase/cals": "^0.5.0",
40
+ "@cloudbase/cals": "^0.5.2",
41
41
  "@cloudbase/framework-core": "^1.8.16",
42
42
  "@cloudbase/framework-plugin-auth": "^1.8.16",
43
43
  "@cloudbase/framework-plugin-mp": "1.9.5-beta.0",
44
44
  "@cloudbase/framework-plugin-website": "^1.8.17",
45
- "@cloudbase/lowcode-builder": "^1.1.10",
45
+ "@cloudbase/lowcode-builder": "^1.2.1-alpha.0",
46
+ "@cloudbase/lowcode-deployer": "^0.0.1-alpha.11",
46
47
  "@formily/react-schema-renderer": "1.1.7",
47
48
  "archiver": "^4.0.1",
48
49
  "compressing": "^1.4.0",