transone-cli 0.5.0 → 0.6.1
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/README.md +27 -0
- package/dist/{build-mp-6j38wf4r.js → build-mp-vk5ap2cw.js} +52 -6
- package/dist/{build-mp-6j38wf4r.js.map → build-mp-vk5ap2cw.js.map} +5 -5
- package/dist/cli.js +1 -1
- package/dist/create.d.ts +1 -1
- package/dist/{index-nag8rsrg.js → index-z1sm57t6.js} +30 -5
- package/dist/{index-nag8rsrg.js.map → index-z1sm57t6.js.map} +6 -6
- package/dist/index.js +1 -1
- package/dist/types.d.ts +9 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
package/dist/create.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export interface CreateProjectResult {
|
|
|
11
11
|
/** Published framework version referenced by generated projects. */
|
|
12
12
|
export declare const TRANSONE_FRAMEWORK_VERSION = "0.4.0";
|
|
13
13
|
/** Published CLI version referenced by generated projects. */
|
|
14
|
-
export declare const TRANSONE_CLI_VERSION = "0.
|
|
14
|
+
export declare const TRANSONE_CLI_VERSION = "0.6.1";
|
|
15
15
|
export declare const GITHUB_URL = "https://github.com/geektech-team/transone";
|
|
16
16
|
export declare function createProject(options?: CreateProjectOptions): CreateProjectResult;
|
|
@@ -118,12 +118,16 @@ function pickAppConfig(app, target) {
|
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
if (isAppConfigMap(app)) {
|
|
121
|
-
return
|
|
121
|
+
return {
|
|
122
|
+
...app.host !== undefined ? { host: app.host } : {},
|
|
123
|
+
...isAppTargetType(target) ? app[target] : {}
|
|
124
|
+
};
|
|
122
125
|
}
|
|
123
126
|
return app;
|
|
124
127
|
}
|
|
125
128
|
async function resolveApp(root, outDirOverride, app, target, fallbackPages) {
|
|
126
129
|
return {
|
|
130
|
+
...app.host !== undefined ? { host: app.host } : {},
|
|
127
131
|
appName: app.appName ?? "TransOne",
|
|
128
132
|
bundleId: app.bundleId ?? "com.transone.app",
|
|
129
133
|
outDir: resolve(root, outDirOverride ?? app.outDir ?? `dist/build/${target}`),
|
|
@@ -167,6 +171,7 @@ function mergeMpRecords(common, overrides) {
|
|
|
167
171
|
}
|
|
168
172
|
function resolveMiniProgram(root, outDirOverride, mp, pages, target) {
|
|
169
173
|
return {
|
|
174
|
+
...mp.host !== undefined ? { host: mp.host } : {},
|
|
170
175
|
appId: mp.appId ?? "touristappid",
|
|
171
176
|
outDir: resolve(root, outDirOverride ?? mp.outDir ?? (MP_DEFAULT_OUT_DIRS[target] ?? "dist/build/mp-weixin")),
|
|
172
177
|
navigationBarTitleText: mp.navigationBarTitleText ?? "TransOne",
|
|
@@ -315,6 +320,7 @@ function validateUserConfig(config) {
|
|
|
315
320
|
}
|
|
316
321
|
function validateAppConfig(app) {
|
|
317
322
|
assertRecord(app, "Config app");
|
|
323
|
+
validateApiHost(app.host, "Config app.host");
|
|
318
324
|
if (isAppConfigMap(app)) {
|
|
319
325
|
const flatKeys = ["appName", "bundleId", "outDir", "minPlatformVersion", "publicDir", "pages"];
|
|
320
326
|
if (flatKeys.some((key) => (key in app))) {
|
|
@@ -331,6 +337,7 @@ function validateAppConfig(app) {
|
|
|
331
337
|
}
|
|
332
338
|
function validateSingleAppConfig(app, label) {
|
|
333
339
|
assertRecord(app, label);
|
|
340
|
+
validateApiHost(app.host, `${label}.host`);
|
|
334
341
|
for (const key of ["appName", "bundleId", "outDir", "minPlatformVersion", "publicDir"]) {
|
|
335
342
|
if (app[key] !== undefined && typeof app[key] !== "string") {
|
|
336
343
|
throw new Error(`${label}.${key} must be a string`);
|
|
@@ -351,6 +358,7 @@ function validateMpConfig(mp) {
|
|
|
351
358
|
}
|
|
352
359
|
function validateMiniProgramConfig(mp, label) {
|
|
353
360
|
assertRecord(mp, label);
|
|
361
|
+
validateApiHost(mp.host, `${label}.host`);
|
|
354
362
|
for (const key of ["appId", "outDir", "navigationBarTitleText", "publicDir"]) {
|
|
355
363
|
if (mp[key] !== undefined && typeof mp[key] !== "string") {
|
|
356
364
|
throw new Error(`${label}.${key} must be a string`);
|
|
@@ -476,6 +484,18 @@ function assertRecord(value, name) {
|
|
|
476
484
|
function isRecord(value) {
|
|
477
485
|
return typeof value === "object" && value !== null && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
478
486
|
}
|
|
487
|
+
function validateApiHost(host, label) {
|
|
488
|
+
if (host === undefined)
|
|
489
|
+
return;
|
|
490
|
+
if (typeof host !== "string")
|
|
491
|
+
throw new Error(`${label} must be a string`);
|
|
492
|
+
try {
|
|
493
|
+
const url = new URL(host);
|
|
494
|
+
if (url.protocol === "http:" || url.protocol === "https:")
|
|
495
|
+
return;
|
|
496
|
+
} catch {}
|
|
497
|
+
throw new Error(`${label} must use http or https`);
|
|
498
|
+
}
|
|
479
499
|
|
|
480
500
|
// src/target/web-target.ts
|
|
481
501
|
import { mkdir, rm, writeFile } from "fs/promises";
|
|
@@ -720,6 +740,7 @@ var MP_WEIXIN_DIALECT = {
|
|
|
720
740
|
backgroundTextStyle: "light"
|
|
721
741
|
}),
|
|
722
742
|
appJsonExtras: () => ({
|
|
743
|
+
lazyCodeLoading: "requiredComponents",
|
|
723
744
|
style: "v2",
|
|
724
745
|
sitemapLocation: "sitemap.json"
|
|
725
746
|
}),
|
|
@@ -833,7 +854,7 @@ class MpTarget {
|
|
|
833
854
|
if (!config.mp) {
|
|
834
855
|
throw new Error("Mini program build requires config.mp\uFF08\u8BF7\u5728 transone.config.ts \u914D\u7F6E mp \u5B57\u6BB5\uFF0C" + "\u5982 appId / pages / outDir\uFF09");
|
|
835
856
|
}
|
|
836
|
-
const { buildMiniProgram } = await import("./build-mp-
|
|
857
|
+
const { buildMiniProgram } = await import("./build-mp-vk5ap2cw.js");
|
|
837
858
|
return buildMiniProgram(config, this.dialect);
|
|
838
859
|
}
|
|
839
860
|
}
|
|
@@ -1019,6 +1040,10 @@ async function buildNativeApp(config, dialect) {
|
|
|
1019
1040
|
throw nativeError(config.entry, "\u9996\u671F\u539F\u751F App \u53EA\u652F\u6301\u4E00\u4E2A\u9875\u9762");
|
|
1020
1041
|
const screen = await analyzeNativeScreen(entries[0]);
|
|
1021
1042
|
const files = dialect.generateProject(screen, config.app);
|
|
1043
|
+
if (config.app.host !== undefined) {
|
|
1044
|
+
files[`${dialect.resourceDirectory}/transone.config.json`] = `${JSON.stringify({ host: config.app.host }, null, 2)}
|
|
1045
|
+
`;
|
|
1046
|
+
}
|
|
1022
1047
|
await rm2(config.app.outDir, { recursive: true, force: true });
|
|
1023
1048
|
const assetsBuilt = [];
|
|
1024
1049
|
for (const [relative3, content] of Object.entries(files).sort(([a], [b]) => a.localeCompare(b))) {
|
|
@@ -1344,7 +1369,7 @@ async function runTsc(root, tsconfig) {
|
|
|
1344
1369
|
import { existsSync as existsSync4, mkdirSync, writeFileSync } from "fs";
|
|
1345
1370
|
import { basename as basename2, join as join2 } from "path";
|
|
1346
1371
|
var TRANSONE_FRAMEWORK_VERSION = "0.4.0";
|
|
1347
|
-
var TRANSONE_CLI_VERSION = "0.
|
|
1372
|
+
var TRANSONE_CLI_VERSION = "0.6.1";
|
|
1348
1373
|
var GITHUB_URL = "https://github.com/geektech-team/transone";
|
|
1349
1374
|
function createProject(options = {}) {
|
|
1350
1375
|
const root = options.root ?? process.cwd();
|
|
@@ -2177,5 +2202,5 @@ function buildFailureResponse() {
|
|
|
2177
2202
|
|
|
2178
2203
|
export { TARGET_TYPES, isTargetType, MP_TARGET_TYPES, isMpTargetType, defineConfig, resolveConfig, WebTarget, MpTarget, mpWeixinTarget, mpAlipayTarget, mpBytedanceTarget, mpXiaohongshuTarget, TargetRegistry, targetRegistry, build, createProject, startDevServer };
|
|
2179
2204
|
|
|
2180
|
-
//# debugId=
|
|
2181
|
-
//# sourceMappingURL=index-
|
|
2205
|
+
//# debugId=5C8800968D2B97E564756E2164756E21
|
|
2206
|
+
//# sourceMappingURL=index-z1sm57t6.js.map
|