openxiangda 1.0.53 → 1.0.55
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/package.json +1 -1
- package/packages/sdk/src/build-source/scripts/build-forms.mjs +7 -2
- package/packages/sdk/src/build-source/scripts/build-pages.mjs +7 -2
- package/packages/sdk/src/build-source/scripts/utils/incremental.mjs +3 -2
- package/packages/sdk/src/build-source/scripts/utils/incremental.test.ts +12 -1
- package/packages/sdk/src/build-source/scripts/utils/workspace-style-entry.mjs +29 -0
- package/templates/openxiangda-react-spa/package.json +5 -0
package/package.json
CHANGED
|
@@ -24,6 +24,10 @@ import {
|
|
|
24
24
|
formatExtractedAssetSummary,
|
|
25
25
|
} from "./utils/static-assets.mjs";
|
|
26
26
|
import { warnShadcnTailwindTokens } from "./utils/tailwind-token-warnings.mjs";
|
|
27
|
+
import {
|
|
28
|
+
createWorkspaceStyleImport,
|
|
29
|
+
listWorkspaceStyleEntryPaths,
|
|
30
|
+
} from "./utils/workspace-style-entry.mjs";
|
|
27
31
|
|
|
28
32
|
process.env.NODE_ENV = "production";
|
|
29
33
|
process.env.BABEL_ENV = "production";
|
|
@@ -110,7 +114,7 @@ function readPackageVersion(packageName) {
|
|
|
110
114
|
function createRuntimeInputHash(runtimeEntryContent, cssIsolation) {
|
|
111
115
|
const hash = crypto.createHash("sha256");
|
|
112
116
|
const configFiles = [
|
|
113
|
-
|
|
117
|
+
...listWorkspaceStyleEntryPaths(rootDir),
|
|
114
118
|
path.join(rootDir, "app-workspace.config.ts"),
|
|
115
119
|
path.join(rootDir, "tailwind.config.cjs"),
|
|
116
120
|
path.join(rootDir, "postcss.config.cjs"),
|
|
@@ -255,6 +259,7 @@ function discoverForms(filterName) {
|
|
|
255
259
|
}
|
|
256
260
|
|
|
257
261
|
function createRuntimeEntryContent() {
|
|
262
|
+
const workspaceStyleImport = createWorkspaceStyleImport(rootDir, tmpDir);
|
|
258
263
|
return `import React from 'react';
|
|
259
264
|
import { createRoot } from 'react-dom/client';
|
|
260
265
|
import { StyleProvider } from '@ant-design/cssinjs';
|
|
@@ -265,7 +270,7 @@ import 'dayjs/locale/zh-cn';
|
|
|
265
270
|
import * as SyFormComponentsModule from 'openxiangda';
|
|
266
271
|
import { antdTheme, legacyAntdTheme } from 'openxiangda/antd-theme';
|
|
267
272
|
import 'antd-mobile/es/global';
|
|
268
|
-
import '
|
|
273
|
+
import '${workspaceStyleImport}';
|
|
269
274
|
|
|
270
275
|
const runtimeVersion = '${runtimeVersionPlaceholder}';
|
|
271
276
|
dayjs.locale('zh-cn');
|
|
@@ -24,6 +24,10 @@ import {
|
|
|
24
24
|
} from "./utils/static-assets.mjs";
|
|
25
25
|
import { warnShadcnTailwindTokens } from "./utils/tailwind-token-warnings.mjs";
|
|
26
26
|
import { loadConfig } from "./utils/load-config.mjs";
|
|
27
|
+
import {
|
|
28
|
+
createWorkspaceStyleImport,
|
|
29
|
+
listWorkspaceStyleEntryPaths,
|
|
30
|
+
} from "./utils/workspace-style-entry.mjs";
|
|
27
31
|
|
|
28
32
|
process.env.NODE_ENV = "production";
|
|
29
33
|
process.env.BABEL_ENV = "production";
|
|
@@ -231,7 +235,7 @@ function createRuntimeInputHash(runtimeEntryContent, cssIsolation) {
|
|
|
231
235
|
return result;
|
|
232
236
|
}, {});
|
|
233
237
|
const configFiles = [
|
|
234
|
-
|
|
238
|
+
...listWorkspaceStyleEntryPaths(rootDir),
|
|
235
239
|
path.join(rootDir, "app-workspace.config.ts"),
|
|
236
240
|
path.join(rootDir, "tailwind.config.cjs"),
|
|
237
241
|
path.join(rootDir, "postcss.config.cjs"),
|
|
@@ -250,6 +254,7 @@ function createRuntimeInputHash(runtimeEntryContent, cssIsolation) {
|
|
|
250
254
|
}
|
|
251
255
|
|
|
252
256
|
function createRuntimeEntryContent() {
|
|
257
|
+
const workspaceStyleImport = createWorkspaceStyleImport(rootDir, tmpDir);
|
|
253
258
|
return `import * as ReactModule from 'react';
|
|
254
259
|
import * as ReactJsxRuntimeModule from 'react/jsx-runtime';
|
|
255
260
|
import * as ReactDomClientModule from 'react-dom/client';
|
|
@@ -259,7 +264,7 @@ import zhCN from 'antd/locale/zh_CN';
|
|
|
259
264
|
import * as IconsModule from '@ant-design/icons';
|
|
260
265
|
import * as OpenXiangdaModule from 'openxiangda';
|
|
261
266
|
import * as OpenXiangdaRuntimeModule from 'openxiangda/runtime';
|
|
262
|
-
import '
|
|
267
|
+
import '${workspaceStyleImport}';
|
|
263
268
|
|
|
264
269
|
const runtimeVersion = '${runtimeVersionPlaceholder}';
|
|
265
270
|
|
|
@@ -3,6 +3,7 @@ import { spawnSync } from "node:child_process";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { rootDir } from "./load-config.mjs";
|
|
6
|
+
import { WORKSPACE_STYLE_ENTRY_CANDIDATES } from "./workspace-style-entry.mjs";
|
|
6
7
|
|
|
7
8
|
const CACHE_VERSION = 1;
|
|
8
9
|
export const CACHE_FILE = path.join(rootDir, ".openxiangda", "build-cache.json");
|
|
@@ -85,7 +86,7 @@ export function computeConfigHash() {
|
|
|
85
86
|
"postcss.config.cjs",
|
|
86
87
|
"vite.config.ts",
|
|
87
88
|
"tsconfig.json",
|
|
88
|
-
|
|
89
|
+
...WORKSPACE_STYLE_ENTRY_CANDIDATES,
|
|
89
90
|
]) {
|
|
90
91
|
hash.update(name);
|
|
91
92
|
hash.update("\0");
|
|
@@ -172,7 +173,7 @@ function isGlobalWorkspaceFile(filePath) {
|
|
|
172
173
|
filePath === "postcss.config.cjs" ||
|
|
173
174
|
filePath === "vite.config.ts" ||
|
|
174
175
|
filePath === "tsconfig.json" ||
|
|
175
|
-
filePath
|
|
176
|
+
WORKSPACE_STYLE_ENTRY_CANDIDATES.includes(filePath) ||
|
|
176
177
|
filePath.startsWith("src/shared/")
|
|
177
178
|
);
|
|
178
179
|
}
|
|
@@ -128,6 +128,14 @@ describe("incremental publish cache", () => {
|
|
|
128
128
|
"export const format = String;\n",
|
|
129
129
|
"utf-8",
|
|
130
130
|
);
|
|
131
|
+
fs.mkdirSync(path.join(workspaceRoot, "src", "styles"), {
|
|
132
|
+
recursive: true,
|
|
133
|
+
});
|
|
134
|
+
fs.writeFileSync(
|
|
135
|
+
path.join(workspaceRoot, "src", "styles", "index.css"),
|
|
136
|
+
"@tailwind utilities;\n",
|
|
137
|
+
"utf-8",
|
|
138
|
+
);
|
|
131
139
|
|
|
132
140
|
const incremental = await loadIncremental(workspaceRoot);
|
|
133
141
|
const changed = incremental.resolveGitChangedWorkspaceTargets();
|
|
@@ -135,6 +143,9 @@ describe("incremental publish cache", () => {
|
|
|
135
143
|
expect(changed.available).toBe(true);
|
|
136
144
|
expect(changed.only).toEqual(["forms/customer", "pages/dashboard"]);
|
|
137
145
|
expect(changed.resourceFiles).toEqual(["src/resources/menus.json"]);
|
|
138
|
-
expect(changed.globalFiles).toEqual([
|
|
146
|
+
expect(changed.globalFiles).toEqual([
|
|
147
|
+
"src/shared/format.ts",
|
|
148
|
+
"src/styles/index.css",
|
|
149
|
+
]);
|
|
139
150
|
});
|
|
140
151
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export const WORKSPACE_STYLE_ENTRY_CANDIDATES = [
|
|
5
|
+
"src/index.css",
|
|
6
|
+
"src/styles/index.css",
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
function toPosix(filePath) {
|
|
10
|
+
return filePath.split(path.sep).join("/");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function listWorkspaceStyleEntryPaths(rootDir) {
|
|
14
|
+
return WORKSPACE_STYLE_ENTRY_CANDIDATES.map((candidate) =>
|
|
15
|
+
path.join(rootDir, candidate),
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function resolveWorkspaceStyleEntry(rootDir) {
|
|
20
|
+
const candidates = listWorkspaceStyleEntryPaths(rootDir);
|
|
21
|
+
return candidates.find((candidate) => fs.existsSync(candidate)) || candidates[0];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createWorkspaceStyleImport(rootDir, fromDir) {
|
|
25
|
+
const stylePath = resolveWorkspaceStyleEntry(rootDir);
|
|
26
|
+
let relativePath = toPosix(path.relative(fromDir, stylePath));
|
|
27
|
+
if (!relativePath.startsWith(".")) relativePath = `./${relativePath}`;
|
|
28
|
+
return relativePath;
|
|
29
|
+
}
|
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
"typegen": "openxiangda resource typegen"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"@ant-design/cssinjs": "^1.23.0",
|
|
23
|
+
"@ant-design/icons": "^6",
|
|
22
24
|
"@vitejs/plugin-react": "^4.3.0",
|
|
25
|
+
"antd": "^6.3.7",
|
|
26
|
+
"antd-mobile": "^5.37.0",
|
|
27
|
+
"dayjs": "^1.11.20",
|
|
23
28
|
"lucide-react": "^0.468.0",
|
|
24
29
|
"openxiangda": "latest",
|
|
25
30
|
"react": "18.3.1",
|