openxiangda 1.0.186 → 1.0.187

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.
@@ -806,7 +806,8 @@ function assertTargetIdentity(target) {
806
806
  );
807
807
  }
808
808
  const boundAppType = normalizeOptionalString(target.bound.appType);
809
- const stateBound = target.state.profiles?.[profile];
809
+ const managedStateBound = resolveManagedStateBinding(target, appType);
810
+ const stateBound = managedStateBound || target.state.profiles?.[profile];
810
811
  const stateAppType = normalizeOptionalString(stateBound?.appType);
811
812
  if (
812
813
  (boundAppType && boundAppType !== appType) ||
@@ -820,6 +821,26 @@ function assertTargetIdentity(target) {
820
821
  return { appType, profile };
821
822
  }
822
823
 
824
+ function resolveManagedStateBinding(target, appType) {
825
+ const targetName = normalizeOptionalString(target?.targetName);
826
+ if (!targetName) return null;
827
+ const binding = target.state?.targets?.[targetName];
828
+ const bindingAppType = normalizeOptionalString(binding?.appType);
829
+ const environmentId = normalizeOptionalString(target.environmentId);
830
+ const bindingEnvironmentId = normalizeOptionalString(binding?.environmentId);
831
+ if (
832
+ !binding ||
833
+ bindingAppType !== appType ||
834
+ (environmentId && bindingEnvironmentId !== environmentId)
835
+ ) {
836
+ throw changeBaselineError(
837
+ 'CHANGE_BASELINE_TARGET_INVALID',
838
+ `change baseline managed target ${targetName} 与 state.targets binding 不一致`
839
+ );
840
+ }
841
+ return binding;
842
+ }
843
+
823
844
  function assertInputIdentity(input, identity) {
824
845
  const appType = normalizeOptionalString(input.appType);
825
846
  const profile = normalizeOptionalString(input.profile);
@@ -839,7 +860,11 @@ function assertInputIdentity(input, identity) {
839
860
 
840
861
  function persistTargetState(target, options) {
841
862
  target.bound.updatedAt = normalizeNow(options.now);
842
- if (target.state.profiles?.[target.profileName]) {
863
+ const targetName = normalizeOptionalString(target.targetName);
864
+ if (targetName) {
865
+ target.state.targets ||= {};
866
+ target.state.targets[targetName] = target.bound;
867
+ } else if (target.state.profiles?.[target.profileName]) {
843
868
  target.state.profiles[target.profileName] = target.bound;
844
869
  }
845
870
  (options.saveState || saveProjectState)(
@@ -63,9 +63,7 @@ function savePublishLease(target, input, options = {}) {
63
63
  publishLease: lease,
64
64
  };
65
65
  target.bound.updatedAt = new Date().toISOString();
66
- if (target.state.profiles?.[target.profileName]) {
67
- target.state.profiles[target.profileName] = target.bound;
68
- }
66
+ persistTargetBinding(target);
69
67
  (options.saveState || saveProjectState)(target.state, options.cwd || process.cwd());
70
68
  return lease;
71
69
  }
@@ -80,13 +78,21 @@ function clearPublishLease(target, leaseId, options = {}) {
80
78
  delete target.bound.promotion;
81
79
  }
82
80
  target.bound.updatedAt = new Date().toISOString();
83
- if (target.state.profiles?.[target.profileName]) {
84
- target.state.profiles[target.profileName] = target.bound;
85
- }
81
+ persistTargetBinding(target);
86
82
  (options.saveState || saveProjectState)(target.state, options.cwd || process.cwd());
87
83
  return true;
88
84
  }
89
85
 
86
+ function persistTargetBinding(target) {
87
+ const targetName = String(target?.targetName || '').trim();
88
+ if (targetName) {
89
+ target.state.targets ||= {};
90
+ target.state.targets[targetName] = target.bound;
91
+ } else if (target.state.profiles?.[target.profileName]) {
92
+ target.state.profiles[target.profileName] = target.bound;
93
+ }
94
+ }
95
+
90
96
  function normalizePublishLease(input, target) {
91
97
  const leaseId = String(input?.leaseId || '').trim();
92
98
  const expiresAt = normalizeDate(input?.expiresAt, 'expiresAt');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openxiangda",
3
- "version": "1.0.186",
3
+ "version": "1.0.187",
4
4
  "description": "OpenXiangda CLI, workspace build tools, runtime SDK, and form components.",
5
5
  "private": false,
6
6
  "bin": {