@cloudbase/framework-plugin-low-code 1.0.7 → 1.0.9
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 +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -29
- package/lib/mpPlugin.d.ts +54 -0
- package/lib/mpPlugin.d.ts.map +1 -0
- package/lib/mpPlugin.js +147 -0
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -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,CA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AO,KAAA;IAIjB,gBAAgB;IA8GhB,2BAA2B;IA6D3B,UAAU;IAoBV,OAAO,CAAC,GAAG,KAAA,EAAE,IAAI,KAAA;IAejB,uBAAuB;IAoBvB,yBAAyB;IAkD/B,oBAAoB;CAKrB;AA4BD,eAAO,MAAM,MAAM,sBAAgB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -200,6 +200,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
200
200
|
es7: true,
|
|
201
201
|
minify: true,
|
|
202
202
|
codeProtect: false,
|
|
203
|
+
useCompilerPlugins: ['typescript'],
|
|
203
204
|
};
|
|
204
205
|
this._miniprogramePlugin = new framework_plugin_mp_1.plugin('miniprograme', this.api, {
|
|
205
206
|
appid: deployOptions.mpAppId,
|
|
@@ -930,34 +931,6 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
930
931
|
if (!this._website) {
|
|
931
932
|
throw new Error('检查静态托管开通超时');
|
|
932
933
|
}
|
|
933
|
-
if (this._checkBroswerHisroty()) {
|
|
934
|
-
let { WebsiteConfiguration } = yield hostingService.getWebsiteConfig();
|
|
935
|
-
let path = this._getWebRootPath();
|
|
936
|
-
let rules = (WebsiteConfiguration.RoutingRules || []).reduce((arr, rule) => {
|
|
937
|
-
let meta = {};
|
|
938
|
-
let { Condition, Redirect } = rule;
|
|
939
|
-
if (Condition.HttpErrorCodeReturnedEquals) {
|
|
940
|
-
meta.httpErrorCodeReturnedEquals = Condition.HttpErrorCodeReturnedEquals;
|
|
941
|
-
}
|
|
942
|
-
if (Condition.KeyPrefixEquals) {
|
|
943
|
-
meta.keyPrefixEquals = Condition.KeyPrefixEquals;
|
|
944
|
-
}
|
|
945
|
-
if (Redirect.ReplaceKeyWith) {
|
|
946
|
-
meta.replaceKeyWith = Redirect.ReplaceKeyWith;
|
|
947
|
-
}
|
|
948
|
-
if (Redirect.ReplaceKeyPrefixWith) {
|
|
949
|
-
meta.replaceKeyPrefixWith = Redirect.ReplaceKeyPrefixWith;
|
|
950
|
-
}
|
|
951
|
-
if (`/${meta.keyPrefixEquals}`.startsWith(path)) {
|
|
952
|
-
return arr;
|
|
953
|
-
}
|
|
954
|
-
if (meta.httpErrorCodeReturnedEquals !== '404') {
|
|
955
|
-
arr.push(meta);
|
|
956
|
-
}
|
|
957
|
-
return arr;
|
|
958
|
-
}, []);
|
|
959
|
-
this._rules = rules;
|
|
960
|
-
}
|
|
961
934
|
let modifyDomainConfigPromises = domainList
|
|
962
935
|
.filter((item) => item.DomainConfig.FollowRedirect !== 'on')
|
|
963
936
|
.map((item) => hostingService.tcbModifyAttribute({
|
|
@@ -987,7 +960,6 @@ class LowCodePlugin extends framework_core_1.Plugin {
|
|
|
987
960
|
: Promise.resolve(),
|
|
988
961
|
hostingService.setWebsiteDocument({
|
|
989
962
|
indexDocument: 'index.html',
|
|
990
|
-
routingRules: this._rules,
|
|
991
963
|
}),
|
|
992
964
|
]);
|
|
993
965
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Plugin, PluginServiceApi } from '@cloudbase/framework-core';
|
|
2
|
+
interface IFrameworkPluginMiniProgramInputs {
|
|
3
|
+
appid: string;
|
|
4
|
+
privateKeyPath: string;
|
|
5
|
+
privateKey?: string;
|
|
6
|
+
localPath: string;
|
|
7
|
+
ignores?: string[];
|
|
8
|
+
deployMode?: 'preview' | 'upload';
|
|
9
|
+
previewOptions?: IMiniProgramPreviewOptions;
|
|
10
|
+
uploadOptions?: IMiniProgramUploadOptions;
|
|
11
|
+
commands?: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
interface IMiniProgramUploadOptions {
|
|
14
|
+
version?: string;
|
|
15
|
+
desc?: string;
|
|
16
|
+
setting?: IMiniProgramBuildSetting;
|
|
17
|
+
}
|
|
18
|
+
interface IMiniProgramPreviewOptions {
|
|
19
|
+
desc?: string;
|
|
20
|
+
setting?: IMiniProgramBuildSetting;
|
|
21
|
+
qrcodeOutputPath?: string;
|
|
22
|
+
pagePath?: string;
|
|
23
|
+
searchQuery?: string;
|
|
24
|
+
scene?: number;
|
|
25
|
+
}
|
|
26
|
+
interface IMiniProgramBuildSetting {
|
|
27
|
+
es6?: boolean;
|
|
28
|
+
minify?: boolean;
|
|
29
|
+
codeProtect?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface IMiniProgramBuildOutput {
|
|
32
|
+
link?: string;
|
|
33
|
+
version?: string;
|
|
34
|
+
}
|
|
35
|
+
declare class MiniProgramsPlugin extends Plugin {
|
|
36
|
+
name: string;
|
|
37
|
+
api: PluginServiceApi;
|
|
38
|
+
inputs: IFrameworkPluginMiniProgramInputs;
|
|
39
|
+
protected resolvedInputs: IFrameworkPluginMiniProgramInputs;
|
|
40
|
+
protected buildOutput: IMiniProgramBuildOutput;
|
|
41
|
+
protected deployer: any;
|
|
42
|
+
constructor(name: string, api: PluginServiceApi, inputs: IFrameworkPluginMiniProgramInputs);
|
|
43
|
+
init(): Promise<void>;
|
|
44
|
+
_initCI(): void;
|
|
45
|
+
run(): Promise<void>;
|
|
46
|
+
remove(): Promise<void>;
|
|
47
|
+
genCode(): Promise<void>;
|
|
48
|
+
build(): Promise<void>;
|
|
49
|
+
compile(): Promise<{}>;
|
|
50
|
+
deploy(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export declare const plugin: typeof MiniProgramsPlugin;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=mpPlugin.d.ts.map
|
|
@@ -0,0 +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,CAAC;IAMd,cAAc,EAAE,MAAM,CAAC;IAKvB,UAAU,CAAC,EAAE,MAAM,CAAC;IAMpB,SAAS,EAAE,MAAM,CAAC;IAMlB,OAAO,CAAC,EAAE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K;IAgCL,OAAO;IAyBP,MAAM;CAsBb;AAMD,eAAO,MAAM,MAAM,2BAAqB,CAAC"}
|
package/lib/mpPlugin.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.plugin = void 0;
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const url_1 = __importDefault(require("url"));
|
|
19
|
+
const child_process_1 = require("child_process");
|
|
20
|
+
const util_1 = require("util");
|
|
21
|
+
const framework_core_1 = require("@cloudbase/framework-core");
|
|
22
|
+
const lowcode_deployer_1 = require("@cloudbase/lowcode-deployer");
|
|
23
|
+
const SUPPORT_DEPLOY_MODE = ['upload', 'preview'];
|
|
24
|
+
const MP_CONFIG_FILENAME = 'project.config.json';
|
|
25
|
+
class MiniProgramsPlugin extends framework_core_1.Plugin {
|
|
26
|
+
constructor(name, api, inputs) {
|
|
27
|
+
super(name, api, inputs);
|
|
28
|
+
this.name = name;
|
|
29
|
+
this.api = api;
|
|
30
|
+
this.inputs = inputs;
|
|
31
|
+
const DEFAULT_INPUTS = {
|
|
32
|
+
localPath: './',
|
|
33
|
+
deployMode: 'preview',
|
|
34
|
+
ignores: ['node_modules/**/*'],
|
|
35
|
+
};
|
|
36
|
+
this.resolvedInputs = resolveInputs(this.inputs, DEFAULT_INPUTS);
|
|
37
|
+
this.buildOutput = {};
|
|
38
|
+
}
|
|
39
|
+
init() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
this.api.logger.debug('MiniProgramPlugin: init', this.resolvedInputs);
|
|
42
|
+
this._initCI();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
_initCI() {
|
|
46
|
+
var _a;
|
|
47
|
+
const { projectPath } = this.api;
|
|
48
|
+
const { appid, privateKeyPath, privateKey, localPath, deployMode } = this.resolvedInputs;
|
|
49
|
+
if (!appid) {
|
|
50
|
+
throw new Error('小程序 appid 不能为空,请在 cloudbaserc.json 中指明 appid. 小程序 appid 一般可以在 project.config.json 中找到');
|
|
51
|
+
}
|
|
52
|
+
if (!privateKey) {
|
|
53
|
+
if (!privateKeyPath || !fs_1.default.existsSync(path_1.default.resolve(projectPath, privateKeyPath))) {
|
|
54
|
+
throw new Error('找不到小程序的部署私钥,请在 cloudbaserc.json 指明私钥文件路径 privateKeyPath. 小程序的部署私钥可在微信公众平台上登录后获取');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const keyPath = path_1.default.resolve(projectPath, './private.key');
|
|
59
|
+
const key = Buffer.from(privateKey, 'base64');
|
|
60
|
+
fs_1.default.writeFileSync(keyPath, key.toString());
|
|
61
|
+
this.resolvedInputs.privateKeyPath = keyPath;
|
|
62
|
+
}
|
|
63
|
+
if (deployMode && !SUPPORT_DEPLOY_MODE.includes(deployMode)) {
|
|
64
|
+
throw new Error(`CloudBase Framework: 不支持的小程序部署模式 '${deployMode}'`);
|
|
65
|
+
}
|
|
66
|
+
if (!fs_1.default.existsSync(path_1.default.resolve(projectPath, localPath, MP_CONFIG_FILENAME))) {
|
|
67
|
+
throw new Error('项目内找不到小程序配置文件 project.config.json,请在 cloudbaserc.json 中指明小程序应用的项目路径 localPath.');
|
|
68
|
+
}
|
|
69
|
+
this.deployer = new lowcode_deployer_1.deployer({
|
|
70
|
+
logger: this.api.logger,
|
|
71
|
+
type: 'MP',
|
|
72
|
+
mode: ((_a = this.resolvedInputs) === null || _a === void 0 ? void 0 : _a.deployMode) === 'upload' ? 'PRODUCTION' : 'PREIVEW',
|
|
73
|
+
projectPath: path_1.default.resolve(projectPath, localPath),
|
|
74
|
+
ignores: this.resolvedInputs.ignores,
|
|
75
|
+
mpAppId: appid,
|
|
76
|
+
miniprogramOptions: {
|
|
77
|
+
privateKeyPath: path_1.default.resolve(projectPath, this.resolvedInputs.privateKeyPath),
|
|
78
|
+
uploadOptions: this.resolvedInputs.uploadOptions,
|
|
79
|
+
previewOptions: this.resolvedInputs.previewOptions,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
run() {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
85
|
+
}
|
|
86
|
+
remove() {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
88
|
+
}
|
|
89
|
+
genCode() {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
|
91
|
+
}
|
|
92
|
+
build() {
|
|
93
|
+
var _a;
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
this.api.logger.debug('MiniProgramPlugin: build', this.resolvedInputs);
|
|
96
|
+
const { build: buildCommand, install: installCommand } = ((_a = this.resolvedInputs) === null || _a === void 0 ? void 0 : _a.commands) || {};
|
|
97
|
+
if (installCommand) {
|
|
98
|
+
this.api.logger.info(installCommand);
|
|
99
|
+
yield (0, util_1.promisify)(child_process_1.exec)(installCommand);
|
|
100
|
+
}
|
|
101
|
+
if (buildCommand) {
|
|
102
|
+
this.api.logger.info(buildCommand);
|
|
103
|
+
yield (0, util_1.promisify)(child_process_1.exec)(buildCommand);
|
|
104
|
+
}
|
|
105
|
+
yield this.deployer._genearteMiniprogramNPM();
|
|
106
|
+
return;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
compile() {
|
|
110
|
+
var _a;
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
switch ((_a = this.resolvedInputs) === null || _a === void 0 ? void 0 : _a.deployMode) {
|
|
113
|
+
case 'upload':
|
|
114
|
+
case 'preview': {
|
|
115
|
+
this.buildOutput = yield this.deployer.deploy();
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
default: {
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return {};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
deploy() {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
this.api.logger.debug('MiniProgramPlugin: deploy', this.resolvedInputs, this.buildOutput);
|
|
128
|
+
const { link, version } = this.buildOutput || {};
|
|
129
|
+
if (link) {
|
|
130
|
+
this.api.logger.info(`${this.api.emoji('🚀')} 小程序(预览版)部署成功,预览二维码地址:${this.api.genClickableLink(url_1.default.format({
|
|
131
|
+
protocol: 'file:',
|
|
132
|
+
host: link,
|
|
133
|
+
}))}`);
|
|
134
|
+
}
|
|
135
|
+
else if (version) {
|
|
136
|
+
this.api.logger.info(`${this.api.emoji('🚀')} 小程序(体验版v${version})上传成功,请在小程序管理后台将其设置为体验版本`);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
throw new Error(`invalid buildOutput: ${this.buildOutput}`);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function resolveInputs(inputs, defaultInputs) {
|
|
145
|
+
return Object.assign({}, defaultInputs, inputs);
|
|
146
|
+
}
|
|
147
|
+
exports.plugin = MiniProgramsPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/framework-plugin-low-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
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",
|
|
@@ -42,7 +42,7 @@
|
|
|
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.0.
|
|
45
|
+
"@cloudbase/lowcode-builder": "^1.0.39",
|
|
46
46
|
"@formily/react-schema-renderer": "1.1.7",
|
|
47
47
|
"archiver": "^4.0.1",
|
|
48
48
|
"compressing": "^1.4.0",
|