transone-cli 0.5.0 → 0.6.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/README.md +25 -0
- package/dist/{build-mp-6j38wf4r.js → build-mp-004pd4h0.js} +50 -4
- package/dist/{build-mp-6j38wf4r.js.map → build-mp-004pd4h0.js.map} +5 -5
- package/dist/cli.js +1 -1
- package/dist/create.d.ts +1 -1
- package/dist/{index-nag8rsrg.js → index-pg5v7h1t.js} +29 -5
- package/dist/{index-nag8rsrg.js.map → index-pg5v7h1t.js.map} +5 -5
- 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.0";
|
|
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";
|
|
@@ -833,7 +853,7 @@ class MpTarget {
|
|
|
833
853
|
if (!config.mp) {
|
|
834
854
|
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
855
|
}
|
|
836
|
-
const { buildMiniProgram } = await import("./build-mp-
|
|
856
|
+
const { buildMiniProgram } = await import("./build-mp-004pd4h0.js");
|
|
837
857
|
return buildMiniProgram(config, this.dialect);
|
|
838
858
|
}
|
|
839
859
|
}
|
|
@@ -1019,6 +1039,10 @@ async function buildNativeApp(config, dialect) {
|
|
|
1019
1039
|
throw nativeError(config.entry, "\u9996\u671F\u539F\u751F App \u53EA\u652F\u6301\u4E00\u4E2A\u9875\u9762");
|
|
1020
1040
|
const screen = await analyzeNativeScreen(entries[0]);
|
|
1021
1041
|
const files = dialect.generateProject(screen, config.app);
|
|
1042
|
+
if (config.app.host !== undefined) {
|
|
1043
|
+
files[`${dialect.resourceDirectory}/transone.config.json`] = `${JSON.stringify({ host: config.app.host }, null, 2)}
|
|
1044
|
+
`;
|
|
1045
|
+
}
|
|
1022
1046
|
await rm2(config.app.outDir, { recursive: true, force: true });
|
|
1023
1047
|
const assetsBuilt = [];
|
|
1024
1048
|
for (const [relative3, content] of Object.entries(files).sort(([a], [b]) => a.localeCompare(b))) {
|
|
@@ -1344,7 +1368,7 @@ async function runTsc(root, tsconfig) {
|
|
|
1344
1368
|
import { existsSync as existsSync4, mkdirSync, writeFileSync } from "fs";
|
|
1345
1369
|
import { basename as basename2, join as join2 } from "path";
|
|
1346
1370
|
var TRANSONE_FRAMEWORK_VERSION = "0.4.0";
|
|
1347
|
-
var TRANSONE_CLI_VERSION = "0.
|
|
1371
|
+
var TRANSONE_CLI_VERSION = "0.6.0";
|
|
1348
1372
|
var GITHUB_URL = "https://github.com/geektech-team/transone";
|
|
1349
1373
|
function createProject(options = {}) {
|
|
1350
1374
|
const root = options.root ?? process.cwd();
|
|
@@ -2177,5 +2201,5 @@ function buildFailureResponse() {
|
|
|
2177
2201
|
|
|
2178
2202
|
export { TARGET_TYPES, isTargetType, MP_TARGET_TYPES, isMpTargetType, defineConfig, resolveConfig, WebTarget, MpTarget, mpWeixinTarget, mpAlipayTarget, mpBytedanceTarget, mpXiaohongshuTarget, TargetRegistry, targetRegistry, build, createProject, startDevServer };
|
|
2179
2203
|
|
|
2180
|
-
//# debugId=
|
|
2181
|
-
//# sourceMappingURL=index-
|
|
2204
|
+
//# debugId=635285A08AF2FAAB64756E2164756E21
|
|
2205
|
+
//# sourceMappingURL=index-pg5v7h1t.js.map
|