openxiangda 1.0.99 → 1.0.101

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 +65 -4
  2. package/package.json +1 -1
package/lib/cli.js CHANGED
@@ -6763,9 +6763,31 @@ async function publishDataViewResources(config, target, dataViews, result) {
6763
6763
  action: existing ? 'update' : 'create',
6764
6764
  id: data?.id,
6765
6765
  });
6766
+ if (Array.isArray(body.permissionGroups)) {
6767
+ await publishDataViewPermissionGroups(config, target, dataViewItem.code, body.permissionGroups);
6768
+ result.published.push({
6769
+ kind: 'dataViewPermissionGroup',
6770
+ code: dataViewItem.code,
6771
+ action: 'replace',
6772
+ });
6773
+ }
6766
6774
  }
6767
6775
  }
6768
6776
 
6777
+ async function publishDataViewPermissionGroups(config, target, dataViewCode, permissionGroups) {
6778
+ await requestWithAuth(
6779
+ config,
6780
+ target.profileName,
6781
+ `/openxiangda-api/v1/apps/${encodeURIComponent(target.appType)}/data-views/${encodeURIComponent(dataViewCode)}/permission-groups`,
6782
+ {
6783
+ method: 'PUT',
6784
+ body: {
6785
+ groups: permissionGroups,
6786
+ },
6787
+ }
6788
+ );
6789
+ }
6790
+
6769
6791
  async function publishRouteResources(config, target, routes, result) {
6770
6792
  for (const route of routes) {
6771
6793
  const code = route.code || route.resourceCode;
@@ -8812,12 +8834,15 @@ function normalizeLocalSourceFileForPlan(localPath, baseDir) {
8812
8834
  const resolvedLocalPath = fs.existsSync(baseResolvedPath)
8813
8835
  ? baseResolvedPath
8814
8836
  : cwdResolvedPath;
8815
- const bundlePath = resolveJsCodeBundlePathForPlan(resolvedLocalPath);
8816
- if (bundlePath && fs.existsSync(bundlePath)) {
8837
+ const sourceInfo = getJsCodeSourceInfoForPlan(resolvedLocalPath);
8838
+ if (sourceInfo) {
8839
+ ensureJsCodeBundleForPlan(sourceInfo);
8840
+ }
8841
+ if (sourceInfo?.bundlePath && fs.existsSync(sourceInfo.bundlePath)) {
8817
8842
  return {
8818
8843
  sha256: crypto
8819
8844
  .createHash('sha256')
8820
- .update(fs.readFileSync(bundlePath))
8845
+ .update(fs.readFileSync(sourceInfo.bundlePath))
8821
8846
  .digest('hex'),
8822
8847
  };
8823
8848
  }
@@ -8827,6 +8852,10 @@ function normalizeLocalSourceFileForPlan(localPath, baseDir) {
8827
8852
  }
8828
8853
 
8829
8854
  function resolveJsCodeBundlePathForPlan(localPath) {
8855
+ return getJsCodeSourceInfoForPlan(localPath)?.bundlePath || null;
8856
+ }
8857
+
8858
+ function getJsCodeSourceInfoForPlan(localPath) {
8830
8859
  const extension = path.extname(localPath).toLowerCase();
8831
8860
  if (extension && extension !== '.ts' && extension !== '.tsx') return null;
8832
8861
  const normalized = localPath.replace(/\\/g, '/');
@@ -8841,7 +8870,39 @@ function resolveJsCodeBundlePathForPlan(localPath) {
8841
8870
  ? 'automations'
8842
8871
  : 'js-code-nodes';
8843
8872
  const workspaceRoot = findWorkspaceRoot(localPath);
8844
- return path.join(workspaceRoot, 'dist', sourceKind, matched[1], 'index.cjs');
8873
+ const scriptCode = matched[1];
8874
+ return {
8875
+ workspaceRoot,
8876
+ sourceKind,
8877
+ scriptCode,
8878
+ bundlePath: path.join(workspaceRoot, 'dist', sourceKind, scriptCode, 'index.cjs'),
8879
+ };
8880
+ }
8881
+
8882
+ const jsCodePlanBuildCache = new Set();
8883
+
8884
+ function ensureJsCodeBundleForPlan(sourceInfo) {
8885
+ if (fs.existsSync(sourceInfo.bundlePath)) return;
8886
+ const cacheKey = [
8887
+ sourceInfo.workspaceRoot,
8888
+ sourceInfo.sourceKind,
8889
+ sourceInfo.scriptCode,
8890
+ ].join('\0');
8891
+ if (jsCodePlanBuildCache.has(cacheKey)) return;
8892
+ jsCodePlanBuildCache.add(cacheKey);
8893
+ const result = runWorkspaceJsCodeBuild(
8894
+ sourceInfo.workspaceRoot,
8895
+ sourceInfo.scriptCode,
8896
+ sourceInfo.sourceKind
8897
+ );
8898
+ if (result.status !== 0) {
8899
+ if (result.stdout) process.stderr.write(result.stdout);
8900
+ if (result.stderr) process.stderr.write(result.stderr);
8901
+ fail(`JS_CODE bundle构建失败,无法生成资源计划: ${sourceInfo.scriptCode}`);
8902
+ }
8903
+ if (!fs.existsSync(sourceInfo.bundlePath)) {
8904
+ fail(`JS_CODE bundle构建未生成产物,无法生成资源计划: ${sourceInfo.bundlePath}`);
8905
+ }
8845
8906
  }
8846
8907
 
8847
8908
  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.101",
4
4
  "description": "OpenXiangda CLI, workspace build tools, runtime SDK, and form components.",
5
5
  "private": false,
6
6
  "bin": {