@olenbetong/appframe-vite 6.3.2 → 6.3.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.
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
2
|
+
import { dirname, relative, resolve, sep } from "node:path";
|
|
3
3
|
import { Client } from "@olenbetong/appframe-data";
|
|
4
4
|
import { config } from "dotenv";
|
|
5
5
|
import { getLoginInfo } from "./devServer.js";
|
|
6
6
|
import { fetchAndGenerate, formatWithBiome } from "./resourceGenerate.js";
|
|
7
7
|
import { entryToCLIOptions, readResourcesConfig } from "./resourcesConfig.js";
|
|
8
8
|
config({ quiet: true });
|
|
9
|
+
/**
|
|
10
|
+
* If `entry.master` is a bare ID (no colon), look it up in the data objects list and
|
|
11
|
+
* inject the relative import path so the generator emits the correct import statement.
|
|
12
|
+
*/
|
|
13
|
+
function resolveMasterImport(entry, allDataObjects) {
|
|
14
|
+
if (!entry.master || entry.master.includes(":")) {
|
|
15
|
+
return entry;
|
|
16
|
+
}
|
|
17
|
+
let masterId = entry.master;
|
|
18
|
+
let masterEntry = allDataObjects.find((e) => e.id === masterId);
|
|
19
|
+
if (!masterEntry) {
|
|
20
|
+
return entry;
|
|
21
|
+
}
|
|
22
|
+
let thisOutputPath = resolve(process.cwd(), entry.output ?? `src/data/${entry.id}.ts`);
|
|
23
|
+
let masterOutputPath = resolve(process.cwd(), masterEntry.output ?? `src/data/${masterEntry.id}.ts`);
|
|
24
|
+
let rel = relative(dirname(thisOutputPath), masterOutputPath).replace(/\.ts$/, "").split(sep).join("/");
|
|
25
|
+
if (!rel.startsWith(".")) {
|
|
26
|
+
rel = `./${rel}`;
|
|
27
|
+
}
|
|
28
|
+
return { ...entry, master: `${masterId}:${rel}` };
|
|
29
|
+
}
|
|
9
30
|
export async function generateFromConfig(configPath) {
|
|
10
31
|
let { hostname, username, password } = await getLoginInfo();
|
|
11
32
|
let resourcesConfig = await readResourcesConfig(configPath);
|
|
@@ -20,8 +41,10 @@ export async function generateFromConfig(configPath) {
|
|
|
20
41
|
let client = new Client(hostname);
|
|
21
42
|
await client.login(username, password);
|
|
22
43
|
let errors = [];
|
|
44
|
+
let allDataObjects = resourcesConfig.dataObjects ?? [];
|
|
23
45
|
for (let { entry } of allEntries) {
|
|
24
|
-
let
|
|
46
|
+
let resolvedEntry = resolveMasterImport(entry, allDataObjects);
|
|
47
|
+
let options = entryToCLIOptions(resolvedEntry, resourcesConfig.server ?? hostname);
|
|
25
48
|
options.output = resolve(process.cwd(), entry.output ?? `src/data/${entry.id}.ts`);
|
|
26
49
|
try {
|
|
27
50
|
let content = await fetchAndGenerate(entry.resource, options, client);
|
package/lib/resourceGenerate.js
CHANGED
|
@@ -436,7 +436,7 @@ ${fieldTypes}}`;
|
|
|
436
436
|
}
|
|
437
437
|
dsOptions.push(`id: "${options.id}"`);
|
|
438
438
|
if (options.master && options.linkFields) {
|
|
439
|
-
dsOptions.push(`masterDataObject: ${options.master.split(":")[0]}`);
|
|
439
|
+
dsOptions.push(`masterDataObject: ${options.master.split(":")[0]} as any`);
|
|
440
440
|
let fields = options.linkFields.split(",");
|
|
441
441
|
linkFields = `linkFields: {\n\t\t${fields
|
|
442
442
|
.map((field) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/appframe-vite",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.3",
|
|
4
4
|
"description": "Tools to use and deploy Vite applications to Appframe",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@olenbetong/appframe-data": "1.5.0",
|
|
33
|
-
"body-parser": "^2.
|
|
34
|
-
"chalk": "
|
|
33
|
+
"body-parser": "^2.3.0",
|
|
34
|
+
"chalk": "5.6.2",
|
|
35
35
|
"chokidar": "^5.0.0",
|
|
36
|
-
"commander": "
|
|
36
|
+
"commander": "15.0.0",
|
|
37
37
|
"dotenv": "^17.4.2",
|
|
38
38
|
"fuzzy": "^0.1.3",
|
|
39
39
|
"inquirer": "^13.4.3",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/jsdom": "^27.0.0",
|
|
48
|
-
"@types/node": "25.9.
|
|
48
|
+
"@types/node": "25.9.3",
|
|
49
49
|
"typescript": "6.0.3",
|
|
50
|
-
"vite": "8.0.
|
|
50
|
+
"vite": "8.0.16"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"vite": ">=5.0.0"
|