openxiangda 1.0.99 → 1.0.100

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.
Files changed (2) hide show
  1. package/lib/cli.js +43 -4
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -8812,12 +8812,15 @@ function normalizeLocalSourceFileForPlan(localPath, baseDir) {
8812
8812
  const resolvedLocalPath = fs.existsSync(baseResolvedPath)
8813
8813
  ? baseResolvedPath
8814
8814
  : cwdResolvedPath;
8815
- const bundlePath = resolveJsCodeBundlePathForPlan(resolvedLocalPath);
8816
- if (bundlePath && fs.existsSync(bundlePath)) {
8815
+ const sourceInfo = getJsCodeSourceInfoForPlan(resolvedLocalPath);
8816
+ if (sourceInfo) {
8817
+ ensureJsCodeBundleForPlan(sourceInfo);
8818
+ }
8819
+ if (sourceInfo?.bundlePath && fs.existsSync(sourceInfo.bundlePath)) {
8817
8820
  return {
8818
8821
  sha256: crypto
8819
8822
  .createHash('sha256')
8820
- .update(fs.readFileSync(bundlePath))
8823
+ .update(fs.readFileSync(sourceInfo.bundlePath))
8821
8824
  .digest('hex'),
8822
8825
  };
8823
8826
  }
@@ -8827,6 +8830,10 @@ function normalizeLocalSourceFileForPlan(localPath, baseDir) {
8827
8830
  }
8828
8831
 
8829
8832
  function resolveJsCodeBundlePathForPlan(localPath) {
8833
+ return getJsCodeSourceInfoForPlan(localPath)?.bundlePath || null;
8834
+ }
8835
+
8836
+ function getJsCodeSourceInfoForPlan(localPath) {
8830
8837
  const extension = path.extname(localPath).toLowerCase();
8831
8838
  if (extension && extension !== '.ts' && extension !== '.tsx') return null;
8832
8839
  const normalized = localPath.replace(/\\/g, '/');
@@ -8841,7 +8848,39 @@ function resolveJsCodeBundlePathForPlan(localPath) {
8841
8848
  ? 'automations'
8842
8849
  : 'js-code-nodes';
8843
8850
  const workspaceRoot = findWorkspaceRoot(localPath);
8844
- return path.join(workspaceRoot, 'dist', sourceKind, matched[1], 'index.cjs');
8851
+ const scriptCode = matched[1];
8852
+ return {
8853
+ workspaceRoot,
8854
+ sourceKind,
8855
+ scriptCode,
8856
+ bundlePath: path.join(workspaceRoot, 'dist', sourceKind, scriptCode, 'index.cjs'),
8857
+ };
8858
+ }
8859
+
8860
+ const jsCodePlanBuildCache = new Set();
8861
+
8862
+ function ensureJsCodeBundleForPlan(sourceInfo) {
8863
+ if (fs.existsSync(sourceInfo.bundlePath)) return;
8864
+ const cacheKey = [
8865
+ sourceInfo.workspaceRoot,
8866
+ sourceInfo.sourceKind,
8867
+ sourceInfo.scriptCode,
8868
+ ].join('\0');
8869
+ if (jsCodePlanBuildCache.has(cacheKey)) return;
8870
+ jsCodePlanBuildCache.add(cacheKey);
8871
+ const result = runWorkspaceJsCodeBuild(
8872
+ sourceInfo.workspaceRoot,
8873
+ sourceInfo.scriptCode,
8874
+ sourceInfo.sourceKind
8875
+ );
8876
+ if (result.status !== 0) {
8877
+ if (result.stdout) process.stderr.write(result.stdout);
8878
+ if (result.stderr) process.stderr.write(result.stderr);
8879
+ fail(`JS_CODE bundle构建失败,无法生成资源计划: ${sourceInfo.scriptCode}`);
8880
+ }
8881
+ if (!fs.existsSync(sourceInfo.bundlePath)) {
8882
+ fail(`JS_CODE bundle构建未生成产物,无法生成资源计划: ${sourceInfo.bundlePath}`);
8883
+ }
8845
8884
  }
8846
8885
 
8847
8886
  function sortObjectForStableJson(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openxiangda",
3
- "version": "1.0.99",
3
+ "version": "1.0.100",
4
4
  "description": "OpenXiangda CLI, workspace build tools, runtime SDK, and form components.",
5
5
  "private": false,
6
6
  "bin": {