@amaster.ai/cli 1.1.28 → 1.1.29

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @amaster.ai/cli
2
2
 
3
- `amaster-cli` 提供两类能力:
3
+ `amaster` 提供两类能力,`amaster-cli` 作为兼容命令保留:
4
4
 
5
5
  1. 模板检查
6
6
  2. Addon Marketplace
@@ -17,12 +17,12 @@
17
17
  ```bash
18
18
  export AMASTER_CLI_REGISTRY=amaster.local
19
19
 
20
- amaster-cli login
21
- amaster-cli login --registry helige-int --browser
22
- amaster-cli login --registry helige-int
23
- amaster-cli login --registry https://demo.example.com --email admin@amaster.ai --password password
24
- amaster-cli whoami
25
- amaster-cli logout
20
+ amaster login
21
+ amaster login --registry helige-int --browser
22
+ amaster login --registry helige-int
23
+ amaster login --registry https://demo.example.com --email admin@amaster.ai --password password
24
+ amaster whoami
25
+ amaster logout
26
26
  ```
27
27
 
28
28
  登录流程:
@@ -35,23 +35,23 @@ amaster-cli logout
35
35
  ## Addon 命令
36
36
 
37
37
  ```bash
38
- amaster-cli addon search crm
39
- amaster-cli addon view crm-pages
40
- amaster-cli addon view crm-pages@1.0.0
41
- amaster-cli addon versions crm-pages
42
- amaster-cli addon members crm-pages@1.0.0
43
- amaster-cli addon content crm-pages@1.0.0 lead-summary
44
-
45
- amaster-cli addon publish .
46
- amaster-cli addon publish ./dist/addon.tgz --scope official
47
- amaster-cli addon activate crm-pages
48
- amaster-cli addon deactivate crm-pages
49
- amaster-cli addon delete crm-pages
50
-
51
- amaster-cli addon install crm-pages@1.0.0
52
- amaster-cli addon install crm-pages --registry helige-int
53
- amaster-cli addon upgrade crm-pages
54
- amaster-cli addon list
38
+ amaster addon search crm
39
+ amaster addon view crm-pages
40
+ amaster addon view crm-pages@1.0.0
41
+ amaster addon versions crm-pages
42
+ amaster addon members crm-pages@1.0.0
43
+ amaster addon content crm-pages@1.0.0 lead-summary
44
+
45
+ amaster addon publish .
46
+ amaster addon publish ./dist/addon.tgz --scope official
47
+ amaster addon activate crm-pages
48
+ amaster addon deactivate crm-pages
49
+ amaster addon delete crm-pages
50
+
51
+ amaster addon install crm-pages@1.0.0
52
+ amaster addon install crm-pages --registry helige-int
53
+ amaster addon upgrade crm-pages
54
+ amaster addon list
55
55
  ```
56
56
 
57
57
  `addon search` 在未显式传 `--application-type` 时,会从当前目录向上查找最近的 `package.json`,读取同级 `app.settings.yml` 的 `type`,并自动按 `web` 或 `mini` 过滤。
@@ -76,10 +76,40 @@ amaster-cli addon list
76
76
  - `bpmn`
77
77
  - `entity`
78
78
  - `datasource`
79
+ - `settings`
79
80
 
80
81
  安装结果会写入:
81
82
 
82
83
  - `src/addons/<addon-name>/meta.json`
84
+ - `settings` 成员会深合并到应用根目录 `app.settings.yml`
85
+
86
+ Addon 可在 `addon.json` 中声明安装后的运行配置要求:
87
+
88
+ ```json
89
+ {
90
+ "install": {
91
+ "requirements": {
92
+ "envs": [
93
+ {
94
+ "key": "OAUTH_CLIENT_ID",
95
+ "required": true,
96
+ "description": "OAuth client id",
97
+ "defaultValue": "demo-client"
98
+ }
99
+ ],
100
+ "secrets": [
101
+ {
102
+ "key": "OAUTH_CLIENT_SECRET",
103
+ "required": true,
104
+ "description": "OAuth client secret"
105
+ }
106
+ ]
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ `install.requirements` 会写入 `meta.json`,并在安装/升级结果中返回 `requirements` 和 `missingRequirements`。`secrets` 只保存键名和说明,不保存密钥值。
83
113
 
84
114
  页面注册方式:
85
115
 
@@ -127,9 +157,9 @@ MCP 接入时可按 `conflicts[].path` 读取应用里的当前文件,并按 `
127
157
  命令:
128
158
 
129
159
  ```bash
130
- amaster-cli check route [--cwd <path>] [--routes-file <path>]
131
- amaster-cli check ast --stack react-vite [--cwd <path>]
132
- amaster-cli check type --stack <react-vite|taro> [--cwd <path>]
133
- amaster-cli check build --stack <react-vite|taro> [--cwd <path>]
134
- amaster-cli check all --stack <react-vite|taro> [--cwd <path>]
160
+ amaster check route [--cwd <path>] [--routes-file <path>]
161
+ amaster check ast --stack react-vite [--cwd <path>]
162
+ amaster check type --stack <react-vite|taro> [--cwd <path>]
163
+ amaster check build --stack <react-vite|taro> [--cwd <path>]
164
+ amaster check all --stack <react-vite|taro> [--cwd <path>]
135
165
  ```
package/dist/cli.cjs CHANGED
@@ -12,7 +12,7 @@ var os = require('os');
12
12
  var tar = require('tar');
13
13
  var http = require('http');
14
14
  var child_process = require('child_process');
15
- var YAML = require('yaml');
15
+ var YAML2 = require('yaml');
16
16
  var ts = require('typescript');
17
17
 
18
18
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -37,7 +37,7 @@ function _interopNamespace(e) {
37
37
  }
38
38
 
39
39
  var tar__namespace = /*#__PURE__*/_interopNamespace(tar);
40
- var YAML__default = /*#__PURE__*/_interopDefault(YAML);
40
+ var YAML2__default = /*#__PURE__*/_interopDefault(YAML2);
41
41
  var ts__default = /*#__PURE__*/_interopDefault(ts);
42
42
 
43
43
  var EXCLUDED_NAMES = /* @__PURE__ */ new Set([".git", "node_modules", ".DS_Store"]);
@@ -581,6 +581,46 @@ function validateAddonManifest(manifest) {
581
581
  if (!Array.isArray(manifest.members)) {
582
582
  throw new Error("addon.json missing members");
583
583
  }
584
+ validateInstallRequirements(manifest);
585
+ }
586
+ function validateInstallRequirements(manifest) {
587
+ const requirements = manifest.install?.requirements;
588
+ if (!requirements) {
589
+ return;
590
+ }
591
+ if (requirements.envs !== void 0 && !Array.isArray(requirements.envs)) {
592
+ throw new Error("addon.json install.requirements.envs must be an array");
593
+ }
594
+ if (requirements.secrets !== void 0 && !Array.isArray(requirements.secrets)) {
595
+ throw new Error("addon.json install.requirements.secrets must be an array");
596
+ }
597
+ for (const item of requirements.envs ?? []) {
598
+ validateRequirementItem(item, "env");
599
+ }
600
+ for (const item of requirements.secrets ?? []) {
601
+ validateRequirementItem(item, "secret");
602
+ if (item.defaultValue !== void 0) {
603
+ throw new Error("addon.json install.requirements.secrets cannot declare defaultValue");
604
+ }
605
+ }
606
+ }
607
+ function validateRequirementItem(item, kind) {
608
+ if (!item || typeof item !== "object" || Array.isArray(item)) {
609
+ throw new Error(`addon.json install.requirements.${kind}s item is invalid`);
610
+ }
611
+ const requirement = item;
612
+ if (typeof requirement.key !== "string" || !requirement.key.trim()) {
613
+ throw new Error(`addon.json install.requirements.${kind}s item missing key`);
614
+ }
615
+ if (requirement.required !== void 0 && typeof requirement.required !== "boolean") {
616
+ throw new Error(`addon.json install.requirements.${kind}s item required must be boolean`);
617
+ }
618
+ if (requirement.description !== void 0 && typeof requirement.description !== "string") {
619
+ throw new Error(`addon.json install.requirements.${kind}s item description must be string`);
620
+ }
621
+ if (requirement.defaultValue !== void 0 && typeof requirement.defaultValue !== "string") {
622
+ throw new Error(`addon.json install.requirements.${kind}s item defaultValue must be string`);
623
+ }
584
624
  }
585
625
  function resolveMemberSourcePath(member) {
586
626
  const sourcePath = member.source?.path;
@@ -631,7 +671,7 @@ async function readAppSettingsApplicationType(packageRoot) {
631
671
  if (!fs.existsSync(appSettingsPath)) {
632
672
  return null;
633
673
  }
634
- const parsed = YAML__default.default.parse(await promises$1.readFile(appSettingsPath, "utf8"));
674
+ const parsed = YAML2__default.default.parse(await promises$1.readFile(appSettingsPath, "utf8"));
635
675
  if (parsed?.type === "web" || parsed?.type === "mini") {
636
676
  return parsed.type;
637
677
  }
@@ -694,6 +734,18 @@ function isAddonInstallConflictError(error) {
694
734
  function sha256Buffer(buffer) {
695
735
  return `sha256:${crypto.createHash("sha256").update(buffer).digest("hex")}`;
696
736
  }
737
+ function stableJsonStringify(value) {
738
+ if (Array.isArray(value)) {
739
+ return `[${value.map((item) => stableJsonStringify(item)).join(",")}]`;
740
+ }
741
+ if (isPlainObject(value)) {
742
+ return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stableJsonStringify(value[key])}`).join(",")}}`;
743
+ }
744
+ return JSON.stringify(value);
745
+ }
746
+ function sha256Value(value) {
747
+ return sha256Buffer(Buffer.from(stableJsonStringify(value) ?? "undefined"));
748
+ }
697
749
  function ensurePathInsideTarget(targetDir, relativePath) {
698
750
  const absolute = path.resolve(targetDir, relativePath);
699
751
  const normalizedTarget = path.resolve(targetDir);
@@ -775,6 +827,19 @@ function resolveInstallParameters(manifest, rawParameters) {
775
827
  }
776
828
  return resolved;
777
829
  }
830
+ function resolveInstallRequirements(manifest) {
831
+ const requirements = manifest.install?.requirements ?? {};
832
+ return {
833
+ envs: requirements.envs?.map((item) => ({ ...item })),
834
+ secrets: requirements.secrets?.map((item) => ({ ...item }))
835
+ };
836
+ }
837
+ function buildMissingRequirements(requirements) {
838
+ return {
839
+ envs: requirements.envs?.filter((item) => item.required !== false).map((item) => ({ ...item })),
840
+ secrets: requirements.secrets?.filter((item) => item.required !== false).map((item) => ({ ...item }))
841
+ };
842
+ }
778
843
  function getAddonMetaPath(targetDir, addonName) {
779
844
  return path.join(targetDir, "src", "addons", addonName, "meta.json");
780
845
  }
@@ -877,19 +942,37 @@ async function buildInstallPlan(options) {
877
942
  }
878
943
  const installParameters = resolveInstallParameters(manifest, options.installParameters);
879
944
  const files = [];
945
+ const settings = [];
880
946
  const members = [];
881
947
  for (const member of manifest.members) {
882
948
  if (member.type === "skill") {
883
949
  throw new Error(`Member ${member.name} is a runtime skill. Design-time CLI install does not support skill members yet.`);
884
950
  }
885
- if (member.type === "settings") {
886
- throw new Error(`Member ${member.name} is a settings fragment. settings install is not implemented yet.`);
887
- }
888
951
  const sourceRelativePath = resolveMemberSourcePath(member);
889
952
  if (!sourceRelativePath) {
890
953
  throw new Error(`Member ${member.name} is missing source.path`);
891
954
  }
892
955
  await assertPathExists(options.extractedDir, sourceRelativePath);
956
+ if (member.type === "settings") {
957
+ const sourcePath = path.join(options.extractedDir, sourceRelativePath);
958
+ const patch = await readYamlObject(sourcePath);
959
+ settings.push({
960
+ sourcePath,
961
+ sourceRelativePath,
962
+ targetPath: "app.settings.yml",
963
+ memberName: member.name,
964
+ memberType: "settings",
965
+ patch,
966
+ paths: flattenSettingsPatch(patch)
967
+ });
968
+ members.push({
969
+ name: member.name,
970
+ type: member.type,
971
+ sourcePath: sourceRelativePath,
972
+ targetPaths: ["app.settings.yml"]
973
+ });
974
+ continue;
975
+ }
893
976
  let targetBaseRelativeDir;
894
977
  switch (member.type) {
895
978
  case "component":
@@ -955,6 +1038,7 @@ async function buildInstallPlan(options) {
955
1038
  }
956
1039
  return {
957
1040
  files,
1041
+ settings,
958
1042
  members,
959
1043
  metaPath: getAddonMetaPath(targetDir, manifest.name),
960
1044
  applicationType,
@@ -994,6 +1078,7 @@ function buildInstalledAddonMeta(options) {
994
1078
  memberTypes: [...new Set(options.manifest.members.map((member) => member.type))]
995
1079
  },
996
1080
  installParameters: options.installParameters,
1081
+ requirements: resolveInstallRequirements(options.manifest),
997
1082
  members: options.members,
998
1083
  files: options.files
999
1084
  };
@@ -1008,6 +1093,161 @@ async function writePlannedFiles(targetDir, planFiles) {
1008
1093
  await promises$1.copyFile(file.sourcePath, absoluteTargetPath);
1009
1094
  }
1010
1095
  }
1096
+ function isPlainObject(value) {
1097
+ return value !== null && typeof value === "object" && !Array.isArray(value);
1098
+ }
1099
+ async function readYamlObject(filePath) {
1100
+ const parsed = YAML2__default.default.parse(await promises$1.readFile(filePath, "utf8"));
1101
+ if (parsed == null) {
1102
+ return {};
1103
+ }
1104
+ if (!isPlainObject(parsed)) {
1105
+ throw new Error(`${filePath} must contain a YAML object`);
1106
+ }
1107
+ return parsed;
1108
+ }
1109
+ function flattenSettingsPatch(value, prefix = []) {
1110
+ const paths = [];
1111
+ for (const [key, child] of Object.entries(value)) {
1112
+ const segments = prefix.concat(key);
1113
+ if (isPlainObject(child)) {
1114
+ paths.push(...flattenSettingsPatch(child, segments));
1115
+ continue;
1116
+ }
1117
+ paths.push({
1118
+ path: segments.join("."),
1119
+ segments,
1120
+ value: child
1121
+ });
1122
+ }
1123
+ return paths;
1124
+ }
1125
+ async function readYamlDocument(targetPath) {
1126
+ const text = fs.existsSync(targetPath) ? await promises$1.readFile(targetPath, "utf8") : "";
1127
+ return YAML2__default.default.parseDocument(text);
1128
+ }
1129
+ function buildSettingsOwnershipMap(metas, excludeAddonName) {
1130
+ const ownership = /* @__PURE__ */ new Map();
1131
+ for (const meta of metas) {
1132
+ if (excludeAddonName && meta.name === excludeAddonName) {
1133
+ continue;
1134
+ }
1135
+ for (const member of meta.members) {
1136
+ for (const item of member.settings?.paths ?? []) {
1137
+ ownership.set(`${item.targetPath}#${item.path}`, meta.name);
1138
+ }
1139
+ }
1140
+ }
1141
+ return ownership;
1142
+ }
1143
+ function listPlannedSettingPaths(settings) {
1144
+ return settings.flatMap(
1145
+ (item) => item.paths.map((settingPath) => ({
1146
+ memberName: item.memberName,
1147
+ sourceRelativePath: item.sourceRelativePath,
1148
+ targetPath: item.targetPath,
1149
+ path: settingPath.path,
1150
+ segments: settingPath.segments,
1151
+ value: settingPath.value
1152
+ }))
1153
+ );
1154
+ }
1155
+ function getPlainYamlValue(document, segments) {
1156
+ const value = document.getIn(segments);
1157
+ if (value && typeof value === "object" && "toJSON" in value && typeof value.toJSON === "function") {
1158
+ return value.toJSON();
1159
+ }
1160
+ return value;
1161
+ }
1162
+ function attachAppliedSettings(members, appliedSettings) {
1163
+ return members.map((member) => {
1164
+ const applied = appliedSettings.find((item) => item.memberName === member.name);
1165
+ if (!applied) {
1166
+ return member;
1167
+ }
1168
+ return {
1169
+ ...member,
1170
+ settings: {
1171
+ targetPath: applied.targetPath,
1172
+ paths: applied.paths
1173
+ }
1174
+ };
1175
+ });
1176
+ }
1177
+ async function applyPlannedSettings(targetDir, settings) {
1178
+ const written = /* @__PURE__ */ new Set();
1179
+ const appliedSettings = [];
1180
+ for (const item of settings) {
1181
+ const targetPath = ensurePathInsideTarget(targetDir, item.targetPath);
1182
+ const document = await readYamlDocument(targetPath);
1183
+ const pathMetas = [];
1184
+ for (const settingPath of item.paths) {
1185
+ const previousValueExists = document.hasIn(settingPath.segments);
1186
+ const previousValue = previousValueExists ? getPlainYamlValue(document, settingPath.segments) : void 0;
1187
+ document.setIn(settingPath.segments, settingPath.value);
1188
+ pathMetas.push({
1189
+ targetPath: item.targetPath,
1190
+ path: settingPath.path,
1191
+ sha256: sha256Value(settingPath.value),
1192
+ previousValueExists,
1193
+ previousValue
1194
+ });
1195
+ }
1196
+ await ensureParentDirectory(targetPath);
1197
+ await promises$1.writeFile(targetPath, document.toString());
1198
+ written.add(item.targetPath);
1199
+ appliedSettings.push({
1200
+ memberName: item.memberName,
1201
+ targetPath: item.targetPath,
1202
+ paths: pathMetas
1203
+ });
1204
+ }
1205
+ return {
1206
+ writtenFiles: [...written],
1207
+ appliedSettings
1208
+ };
1209
+ }
1210
+ async function restoreObsoleteSettings(targetDir, previousMeta, nextSettings) {
1211
+ if (!previousMeta) {
1212
+ return [];
1213
+ }
1214
+ const nextSettingKeys = new Set(
1215
+ listPlannedSettingPaths(nextSettings).map((item) => `${item.targetPath}#${item.path}`)
1216
+ );
1217
+ const documents = /* @__PURE__ */ new Map();
1218
+ const written = /* @__PURE__ */ new Set();
1219
+ const getDocument = async (targetPath) => {
1220
+ const cached = documents.get(targetPath);
1221
+ if (cached) {
1222
+ return cached;
1223
+ }
1224
+ const document = await readYamlDocument(ensurePathInsideTarget(targetDir, targetPath));
1225
+ documents.set(targetPath, document);
1226
+ return document;
1227
+ };
1228
+ for (const member of previousMeta.members) {
1229
+ for (const settingPath of member.settings?.paths ?? []) {
1230
+ if (nextSettingKeys.has(`${settingPath.targetPath}#${settingPath.path}`)) {
1231
+ continue;
1232
+ }
1233
+ const document = await getDocument(settingPath.targetPath);
1234
+ const segments = settingPath.path.split(".");
1235
+ if (settingPath.previousValueExists) {
1236
+ document.setIn(segments, settingPath.previousValue);
1237
+ } else {
1238
+ document.deleteIn(segments);
1239
+ }
1240
+ written.add(settingPath.targetPath);
1241
+ }
1242
+ }
1243
+ for (const targetPath of written) {
1244
+ const document = documents.get(targetPath);
1245
+ if (document) {
1246
+ await promises$1.writeFile(ensurePathInsideTarget(targetDir, targetPath), document.toString());
1247
+ }
1248
+ }
1249
+ return [...written];
1250
+ }
1011
1251
  async function removeObsoleteFiles(targetDir, previousMeta, nextPaths) {
1012
1252
  const removed = [];
1013
1253
  for (const file of previousMeta.files) {
@@ -1024,6 +1264,7 @@ async function removeObsoleteFiles(targetDir, previousMeta, nextPaths) {
1024
1264
  }
1025
1265
  async function validateInstallConflicts(targetDir, plan, existingMetas) {
1026
1266
  const ownership = buildOwnershipMap(existingMetas);
1267
+ const settingsOwnership = buildSettingsOwnershipMap(existingMetas);
1027
1268
  const conflicts = [];
1028
1269
  for (const file of plan.files) {
1029
1270
  const owner = ownership.get(file.targetPath);
@@ -1051,6 +1292,22 @@ async function validateInstallConflicts(targetDir, plan, existingMetas) {
1051
1292
  });
1052
1293
  }
1053
1294
  }
1295
+ for (const item of listPlannedSettingPaths(plan.settings)) {
1296
+ const owner = settingsOwnership.get(`${item.targetPath}#${item.path}`);
1297
+ if (owner && owner !== plan.manifest.name) {
1298
+ conflicts.push({
1299
+ kind: "owned_by_other_addon",
1300
+ path: `${item.targetPath}#${item.path}`,
1301
+ sourcePath: item.sourceRelativePath,
1302
+ memberName: item.memberName,
1303
+ memberType: "settings",
1304
+ ownerAddon: owner,
1305
+ settingPath: item.path,
1306
+ nextValue: item.value,
1307
+ message: `${item.targetPath}#${item.path} is already managed by addon ${owner}`
1308
+ });
1309
+ }
1310
+ }
1054
1311
  if (conflicts.length) {
1055
1312
  throw new AddonInstallConflictError({
1056
1313
  operation: "install",
@@ -1066,8 +1323,12 @@ async function validateInstallConflicts(targetDir, plan, existingMetas) {
1066
1323
  }
1067
1324
  async function validateUpgradeConflicts(targetDir, plan, existingMetas, previousMeta) {
1068
1325
  const ownership = buildOwnershipMap(existingMetas, previousMeta.name);
1326
+ const settingsOwnership = buildSettingsOwnershipMap(existingMetas, previousMeta.name);
1069
1327
  const previousFilesByPath = new Map(previousMeta.files.map((file) => [file.path, file]));
1070
1328
  const nextPaths = new Set(plan.files.map((file) => file.targetPath));
1329
+ const plannedSettings = listPlannedSettingPaths(plan.settings);
1330
+ const nextSettingKeys = new Set(plannedSettings.map((item) => `${item.targetPath}#${item.path}`));
1331
+ const plannedSettingsByKey = new Map(plannedSettings.map((item) => [`${item.targetPath}#${item.path}`, item]));
1071
1332
  const conflicts = [];
1072
1333
  for (const managedFile of previousMeta.files) {
1073
1334
  const absolutePath = ensurePathInsideTarget(targetDir, managedFile.path);
@@ -1122,6 +1383,60 @@ async function validateUpgradeConflicts(targetDir, plan, existingMetas, previous
1122
1383
  });
1123
1384
  }
1124
1385
  }
1386
+ const settingsDocuments = /* @__PURE__ */ new Map();
1387
+ const getSettingsDocument = async (targetPath) => {
1388
+ const cached = settingsDocuments.get(targetPath);
1389
+ if (cached) {
1390
+ return cached;
1391
+ }
1392
+ const document = await readYamlDocument(ensurePathInsideTarget(targetDir, targetPath));
1393
+ settingsDocuments.set(targetPath, document);
1394
+ return document;
1395
+ };
1396
+ for (const member of previousMeta.members) {
1397
+ for (const settingPath of member.settings?.paths ?? []) {
1398
+ const document = await getSettingsDocument(settingPath.targetPath);
1399
+ const segments = settingPath.path.split(".");
1400
+ const currentValue = document.hasIn(segments) ? getPlainYamlValue(document, segments) : void 0;
1401
+ const actualSha256 = sha256Value(currentValue);
1402
+ if (actualSha256 === settingPath.sha256) {
1403
+ continue;
1404
+ }
1405
+ const settingKey = `${settingPath.targetPath}#${settingPath.path}`;
1406
+ const isStillManaged = nextSettingKeys.has(settingKey);
1407
+ const nextSetting = plannedSettingsByKey.get(settingKey);
1408
+ conflicts.push({
1409
+ kind: isStillManaged ? "managed_file_modified" : "obsolete_file_modified",
1410
+ path: settingKey,
1411
+ sourcePath: member.sourcePath,
1412
+ memberName: member.name,
1413
+ memberType: "settings",
1414
+ expectedSha256: settingPath.sha256,
1415
+ actualSha256,
1416
+ settingPath: settingPath.path,
1417
+ currentValue,
1418
+ nextValue: nextSetting?.value,
1419
+ previousValue: settingPath.previousValue,
1420
+ message: isStillManaged ? `managed setting modified locally: ${settingKey}` : `setting changed locally and would be restored: ${settingKey}`
1421
+ });
1422
+ }
1423
+ }
1424
+ for (const item of plannedSettings) {
1425
+ const owner = settingsOwnership.get(`${item.targetPath}#${item.path}`);
1426
+ if (owner) {
1427
+ conflicts.push({
1428
+ kind: "owned_by_other_addon",
1429
+ path: `${item.targetPath}#${item.path}`,
1430
+ sourcePath: item.sourceRelativePath,
1431
+ memberName: item.memberName,
1432
+ memberType: "settings",
1433
+ ownerAddon: owner,
1434
+ settingPath: item.path,
1435
+ nextValue: item.value,
1436
+ message: `${item.targetPath}#${item.path} is already managed by addon ${owner}`
1437
+ });
1438
+ }
1439
+ }
1125
1440
  for (const oldFile of previousMeta.files) {
1126
1441
  if (!nextPaths.has(oldFile.path)) {
1127
1442
  const absolutePath = ensurePathInsideTarget(targetDir, oldFile.path);
@@ -1289,7 +1604,9 @@ async function materializeAddon(options) {
1289
1604
  await validateUpgradeConflicts(targetDir, plan, existingMetas, previousMeta);
1290
1605
  }
1291
1606
  const removedFiles = previousMeta ? await removeObsoleteFiles(targetDir, previousMeta, new Set(plan.files.map((file) => file.targetPath))) : [];
1607
+ const restoredSettingsFiles = await restoreObsoleteSettings(targetDir, previousMeta, plan.settings);
1292
1608
  await writePlannedFiles(targetDir, plan.files);
1609
+ const settingsResult = await applyPlannedSettings(targetDir, plan.settings);
1293
1610
  const installedFiles = [];
1294
1611
  for (const plannedFile of plan.files) {
1295
1612
  installedFiles.push(
@@ -1302,7 +1619,7 @@ async function materializeAddon(options) {
1302
1619
  applicationType: plan.applicationType,
1303
1620
  organizationCode: options.organizationCode,
1304
1621
  installParameters: plan.installParameters,
1305
- members: plan.members,
1622
+ members: attachAppliedSettings(plan.members, settingsResult.appliedSettings),
1306
1623
  files: installedFiles,
1307
1624
  installedAt: previousMeta?.installedAt
1308
1625
  });
@@ -1310,10 +1627,13 @@ async function materializeAddon(options) {
1310
1627
  await promises$1.writeFile(plan.metaPath, JSON.stringify(meta, null, 2));
1311
1628
  const nextMetas = existingMetas.filter((item) => item.name !== meta.name).concat(meta);
1312
1629
  await rebuildRegistryFiles(targetDir, plan.applicationType, nextMetas.filter((item) => item.applicationType === plan.applicationType));
1630
+ const requirements = resolveInstallRequirements(plan.manifest);
1313
1631
  return {
1314
1632
  meta,
1315
- writtenFiles: installedFiles.map((file) => file.path),
1316
- removedFiles
1633
+ writtenFiles: installedFiles.map((file) => file.path).concat(restoredSettingsFiles, settingsResult.writtenFiles),
1634
+ removedFiles,
1635
+ requirements,
1636
+ missingRequirements: buildMissingRequirements(requirements)
1317
1637
  };
1318
1638
  }
1319
1639
  async function installAddonFromExtractedDirectory(options) {