openxiangda 1.0.97 → 1.0.99
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/lib/cli.js +133 -16
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -3542,7 +3542,8 @@ async function resource(args) {
|
|
|
3542
3542
|
return;
|
|
3543
3543
|
}
|
|
3544
3544
|
|
|
3545
|
-
const
|
|
3545
|
+
const typeFilters = getResourceTypeFilters(positional, flags);
|
|
3546
|
+
const manifest = loadWorkspaceResources({ typeFilters });
|
|
3546
3547
|
if (subcommand === 'typegen') {
|
|
3547
3548
|
const result = generateResourceTypes(manifest, flags.out || flags.output);
|
|
3548
3549
|
if (flags.json) return writeJson(result);
|
|
@@ -4958,11 +4959,108 @@ const RESOURCE_SPECS = [
|
|
|
4958
4959
|
},
|
|
4959
4960
|
];
|
|
4960
4961
|
|
|
4961
|
-
|
|
4962
|
+
const RESOURCE_TYPE_ALIASES = new Map([
|
|
4963
|
+
['role', 'roles'],
|
|
4964
|
+
['roles', 'roles'],
|
|
4965
|
+
['connector', 'connectors'],
|
|
4966
|
+
['connectors', 'connectors'],
|
|
4967
|
+
['notification', 'notifications'],
|
|
4968
|
+
['notifications', 'notifications'],
|
|
4969
|
+
['notification-template', 'notifications'],
|
|
4970
|
+
['notification-templates', 'notifications'],
|
|
4971
|
+
['notification-type-config', 'notifications'],
|
|
4972
|
+
['notification-type-configs', 'notifications'],
|
|
4973
|
+
['menu', 'menus'],
|
|
4974
|
+
['menus', 'menus'],
|
|
4975
|
+
['workflow', 'workflows'],
|
|
4976
|
+
['workflows', 'workflows'],
|
|
4977
|
+
['automation', 'automations'],
|
|
4978
|
+
['automations', 'automations'],
|
|
4979
|
+
['function', 'functions'],
|
|
4980
|
+
['functions', 'functions'],
|
|
4981
|
+
['data-view', 'dataViews'],
|
|
4982
|
+
['data-views', 'dataViews'],
|
|
4983
|
+
['dataview', 'dataViews'],
|
|
4984
|
+
['dataviews', 'dataViews'],
|
|
4985
|
+
['data-view-resource', 'dataViews'],
|
|
4986
|
+
['auth', 'authConfigs'],
|
|
4987
|
+
['auth-config', 'authConfigs'],
|
|
4988
|
+
['auth-configs', 'authConfigs'],
|
|
4989
|
+
['authconfig', 'authConfigs'],
|
|
4990
|
+
['authconfigs', 'authConfigs'],
|
|
4991
|
+
['route', 'routes'],
|
|
4992
|
+
['routes', 'routes'],
|
|
4993
|
+
['public-access', 'publicAccessPolicies'],
|
|
4994
|
+
['public-access-policy', 'publicAccessPolicies'],
|
|
4995
|
+
['public-access-policies', 'publicAccessPolicies'],
|
|
4996
|
+
['publicaccess', 'publicAccessPolicies'],
|
|
4997
|
+
['publicaccesspolicy', 'publicAccessPolicies'],
|
|
4998
|
+
['publicaccesspolicies', 'publicAccessPolicies'],
|
|
4999
|
+
['page-permission-group', 'pagePermissionGroups'],
|
|
5000
|
+
['page-permission-groups', 'pagePermissionGroups'],
|
|
5001
|
+
['page-group', 'pagePermissionGroups'],
|
|
5002
|
+
['page-groups', 'pagePermissionGroups'],
|
|
5003
|
+
['pagepermissiongroup', 'pagePermissionGroups'],
|
|
5004
|
+
['pagepermissiongroups', 'pagePermissionGroups'],
|
|
5005
|
+
['form-permission-group', 'formPermissionGroups'],
|
|
5006
|
+
['form-permission-groups', 'formPermissionGroups'],
|
|
5007
|
+
['form-group', 'formPermissionGroups'],
|
|
5008
|
+
['form-groups', 'formPermissionGroups'],
|
|
5009
|
+
['formpermissiongroup', 'formPermissionGroups'],
|
|
5010
|
+
['formpermissiongroups', 'formPermissionGroups'],
|
|
5011
|
+
['form-setting', 'formSettings'],
|
|
5012
|
+
['form-settings', 'formSettings'],
|
|
5013
|
+
['settings-form', 'formSettings'],
|
|
5014
|
+
['settings-forms', 'formSettings'],
|
|
5015
|
+
['formsetting', 'formSettings'],
|
|
5016
|
+
['formsettings', 'formSettings'],
|
|
5017
|
+
]);
|
|
5018
|
+
|
|
5019
|
+
function getResourceTypeFilters(positional = [], flags = {}) {
|
|
5020
|
+
const rawValues = [
|
|
5021
|
+
...positional,
|
|
5022
|
+
flags.type,
|
|
5023
|
+
flags['resource-type'],
|
|
5024
|
+
flags['resource-types'],
|
|
5025
|
+
]
|
|
5026
|
+
.filter(Boolean)
|
|
5027
|
+
.flatMap(value => String(value).split(','))
|
|
5028
|
+
.map(value => value.trim())
|
|
5029
|
+
.filter(Boolean);
|
|
5030
|
+
|
|
5031
|
+
if (rawValues.length === 0) return null;
|
|
5032
|
+
|
|
5033
|
+
const filters = new Set();
|
|
5034
|
+
for (const rawType of rawValues) {
|
|
5035
|
+
const normalized = normalizeResourceTypeAlias(rawType);
|
|
5036
|
+
const key = RESOURCE_TYPE_ALIASES.get(normalized);
|
|
5037
|
+
if (!key) {
|
|
5038
|
+
fail(`未知资源类型: ${rawType}`);
|
|
5039
|
+
}
|
|
5040
|
+
filters.add(key);
|
|
5041
|
+
}
|
|
5042
|
+
return filters;
|
|
5043
|
+
}
|
|
5044
|
+
|
|
5045
|
+
function normalizeResourceTypeAlias(value) {
|
|
5046
|
+
return String(value || '')
|
|
5047
|
+
.trim()
|
|
5048
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
5049
|
+
.replace(/[_\s]+/g, '-')
|
|
5050
|
+
.toLowerCase();
|
|
5051
|
+
}
|
|
5052
|
+
|
|
5053
|
+
function loadWorkspaceResources(options = {}) {
|
|
4962
5054
|
const baseDir = path.join(process.cwd(), 'src', 'resources');
|
|
4963
|
-
const
|
|
5055
|
+
const typeFilters = options.typeFilters || null;
|
|
5056
|
+
const manifest = {
|
|
5057
|
+
baseDir,
|
|
5058
|
+
...(typeFilters ? { resourceTypeFilters: Array.from(typeFilters).sort() } : {}),
|
|
5059
|
+
};
|
|
4964
5060
|
for (const spec of RESOURCE_SPECS) {
|
|
4965
|
-
manifest[spec.key] =
|
|
5061
|
+
manifest[spec.key] = !typeFilters || typeFilters.has(spec.key)
|
|
5062
|
+
? readResourceItems(baseDir, spec)
|
|
5063
|
+
: [];
|
|
4966
5064
|
}
|
|
4967
5065
|
return manifest;
|
|
4968
5066
|
}
|
|
@@ -5733,6 +5831,7 @@ async function buildResourcePlan(config, target, manifest) {
|
|
|
5733
5831
|
return {
|
|
5734
5832
|
appType: target.appType,
|
|
5735
5833
|
profile: target.profileName,
|
|
5834
|
+
...(manifest.resourceTypeFilters ? { resourceTypeFilters: manifest.resourceTypeFilters } : {}),
|
|
5736
5835
|
actions,
|
|
5737
5836
|
summary: summarizeActions(actions),
|
|
5738
5837
|
};
|
|
@@ -5742,6 +5841,7 @@ async function publishResourceManifest(config, target, manifest, options = {}) {
|
|
|
5742
5841
|
const result = {
|
|
5743
5842
|
appType: target.appType,
|
|
5744
5843
|
profile: target.profileName,
|
|
5844
|
+
...(manifest.resourceTypeFilters ? { resourceTypeFilters: manifest.resourceTypeFilters } : {}),
|
|
5745
5845
|
published: [],
|
|
5746
5846
|
pruned: [],
|
|
5747
5847
|
warnings: [],
|
|
@@ -8467,7 +8567,9 @@ function clonePlainJson(value) {
|
|
|
8467
8567
|
function workflowEquals(bound, desired, existing) {
|
|
8468
8568
|
if (!existing) return false;
|
|
8469
8569
|
const desiredDefinition = resolveManifestPlainJson(desired, 'definitionJson', 'definitionFile');
|
|
8470
|
-
const desiredView =
|
|
8570
|
+
const desiredView =
|
|
8571
|
+
resolveManifestPlainJson(desired, 'viewJson', 'viewFile', true) ??
|
|
8572
|
+
resolveManifestPlainJson(desired, 'previewJson', 'previewFile', true);
|
|
8471
8573
|
const desiredFormUuid = resolveManifestFormUuid(bound, desired);
|
|
8472
8574
|
return (
|
|
8473
8575
|
String(existing.resourceCode || '') === String(desired.code || desired.resourceCode || '') &&
|
|
@@ -8482,7 +8584,9 @@ function automationEquals(target, desired, existing) {
|
|
|
8482
8584
|
if (!existing) return false;
|
|
8483
8585
|
const desiredDefinition = resolveManifestPlainJson(desired, 'definitionJson', 'definitionFile');
|
|
8484
8586
|
applyResourceBindingsToRuntimeDefinition(target.bound, desired, desiredDefinition);
|
|
8485
|
-
const desiredView =
|
|
8587
|
+
const desiredView =
|
|
8588
|
+
resolveManifestPlainJson(desired, 'viewJson', 'viewFile', true) ??
|
|
8589
|
+
resolveManifestPlainJson(desired, 'previewJson', 'previewFile', true);
|
|
8486
8590
|
const automationPayload = resolveAutomationManifestPayload(target, desired);
|
|
8487
8591
|
const desiredTags =
|
|
8488
8592
|
desired.tags === undefined
|
|
@@ -8497,17 +8601,29 @@ function automationEquals(target, desired, existing) {
|
|
|
8497
8601
|
? Boolean(desired.isEnabled)
|
|
8498
8602
|
: undefined;
|
|
8499
8603
|
|
|
8604
|
+
const matches = {
|
|
8605
|
+
resourceCode: String(existing.resourceCode || '') === String(desired.code || desired.resourceCode || ''),
|
|
8606
|
+
name: String(existing.name || '') === String(desired.name || desired.code || ''),
|
|
8607
|
+
description: String(existing.description || '') === String(desired.description || ''),
|
|
8608
|
+
formUuid: String(existing.formUuid || '') === String(automationPayload.formUuid || ''),
|
|
8609
|
+
triggerConfig: jsonEqualsForPlan(existing.triggerConfig, automationPayload.triggerConfig, desired.__dir),
|
|
8610
|
+
definitionJson: jsonEqualsForPlan(existing.definitionJson, desiredDefinition, desired.__dir),
|
|
8611
|
+
viewJson: optionalJsonEqualsForPlan(existing.viewJson, desiredView, desired.__dir),
|
|
8612
|
+
tags: desiredTags === undefined ? true : String(existing.tags || '') === desiredTags,
|
|
8613
|
+
published: desired.publish ? Boolean(existing.isPublished) === true : true,
|
|
8614
|
+
enabled: desiredEnabled === undefined ? true : Boolean(existing.isEnabled) === desiredEnabled,
|
|
8615
|
+
};
|
|
8500
8616
|
return (
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8617
|
+
matches.resourceCode &&
|
|
8618
|
+
matches.name &&
|
|
8619
|
+
matches.description &&
|
|
8620
|
+
matches.formUuid &&
|
|
8621
|
+
matches.triggerConfig &&
|
|
8622
|
+
matches.definitionJson &&
|
|
8623
|
+
matches.viewJson &&
|
|
8624
|
+
matches.tags &&
|
|
8625
|
+
matches.published &&
|
|
8626
|
+
matches.enabled
|
|
8511
8627
|
);
|
|
8512
8628
|
}
|
|
8513
8629
|
|
|
@@ -8685,6 +8801,7 @@ function normalizeJsonForPlan(value, baseDir, keyName) {
|
|
|
8685
8801
|
result.runtimeMode = result.runtimeMode || 'trusted_node';
|
|
8686
8802
|
result.sourceType = result.sourceType || 'file_snapshot';
|
|
8687
8803
|
}
|
|
8804
|
+
if (result.code === '') delete result.code;
|
|
8688
8805
|
return sortObjectForStableJson(result);
|
|
8689
8806
|
}
|
|
8690
8807
|
|