zen-fs-config 0.7.17 → 0.7.19
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/dist/index.js +39 -14
- package/dist/index.mjs +39 -14
- package/dist/zen-fs-config.js +39 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5032,10 +5032,9 @@ var ConfigRepo = class {
|
|
|
5032
5032
|
}
|
|
5033
5033
|
}
|
|
5034
5034
|
const bytes = new TextEncoder().encode(type);
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
await this.
|
|
5038
|
-
await this.cachedFS.writeFile(path, bytes);
|
|
5035
|
+
if (!await this.safeExists(this.cachedFS, GROUP_TYPE_FILE)) {
|
|
5036
|
+
await this.ensureDir(GROUP_TYPE_FILE);
|
|
5037
|
+
await this.cachedFS.writeFile(GROUP_TYPE_FILE, bytes);
|
|
5039
5038
|
}
|
|
5040
5039
|
const existingDescriptor = await readGroupDescriptor(this.cachedFS);
|
|
5041
5040
|
if (!existingDescriptor) {
|
|
@@ -5074,6 +5073,14 @@ var ConfigRepo = class {
|
|
|
5074
5073
|
log5.log(`[ConfigRepo] assigned group instanceId ${this.instanceId} (kind=${existingDescriptor?.kind ?? "config"})`);
|
|
5075
5074
|
}
|
|
5076
5075
|
log5.log(`[ConfigRepo] group-type set to "${type}"`);
|
|
5076
|
+
if (await this.safeExists(this.cachedFS, LEGACY_GROUP_TYPE_FILE)) {
|
|
5077
|
+
try {
|
|
5078
|
+
await this.cachedFS.unlink(LEGACY_GROUP_TYPE_FILE);
|
|
5079
|
+
log5.log("[ConfigRepo] removed stale legacy .meta/group-type");
|
|
5080
|
+
} catch (err) {
|
|
5081
|
+
log5.warn(`[ConfigRepo] failed to remove legacy .meta/group-type: ${err.message}`);
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
5077
5084
|
}
|
|
5078
5085
|
/** Read the group-type marker. Returns null if not set (new path, then legacy). */
|
|
5079
5086
|
async getGroupType() {
|
|
@@ -6537,18 +6544,23 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
6537
6544
|
log5.error(`[createConfigRepo] Failed to ensure /.meta/:`, err.message);
|
|
6538
6545
|
}
|
|
6539
6546
|
}
|
|
6547
|
+
const declaredIdentity = await readGroupDescriptor(primaryInstance);
|
|
6548
|
+
if (declaredIdentity?.kind === "data") {
|
|
6549
|
+
throw new Error(
|
|
6550
|
+
`[createConfigRepo] \u8BE5\u8FDC\u7AEF\u6839\u7684 .meta/group.json \u58F0\u660E\u4E3A\u6570\u636E\u7EC4\uFF08kind=data \xB7 id=${declaredIdentity.id ?? "?"}\uFF09\u2014\u2014\u62D2\u7EDD\u5728\u8FD9\u91CC\u521D\u59CB\u5316\u914D\u7F6E\u7EC4\u3002\u8981\u7ED9\u6570\u636E\u7EC4\u6362\u4E13\u5C5E\u8FDC\u7AEF\u6839\uFF0C\u6216\u5728\u914D\u7F6E\u7EC4\u4FA7\u89E3\u9664\u5BF9\u8BE5\u6839\u7684\u7ED1\u5B9A\u3002`
|
|
6551
|
+
);
|
|
6552
|
+
}
|
|
6540
6553
|
try {
|
|
6541
6554
|
const groupTypeBytes = new TextEncoder().encode("config-sync");
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
}
|
|
6555
|
+
const markerPath = `${CONFIG_DIR}/group-type`;
|
|
6556
|
+
try {
|
|
6557
|
+
await primaryInstance.readFile(markerPath);
|
|
6558
|
+
} catch {
|
|
6559
|
+
await ensureParentDir2(primaryInstance, markerPath);
|
|
6560
|
+
await primaryInstance.writeFile(markerPath, groupTypeBytes);
|
|
6561
|
+
log5.log(`[createConfigRepo] group-type set to "config-sync" at ${markerPath}`);
|
|
6550
6562
|
}
|
|
6551
|
-
if (!
|
|
6563
|
+
if (!declaredIdentity) {
|
|
6552
6564
|
await writeGroupDescriptor(primaryInstance, {
|
|
6553
6565
|
schemaVersion: 2,
|
|
6554
6566
|
kind: "config",
|
|
@@ -6557,6 +6569,11 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
6557
6569
|
features: CONFIG_GROUP_FEATURES
|
|
6558
6570
|
});
|
|
6559
6571
|
}
|
|
6572
|
+
try {
|
|
6573
|
+
await primaryInstance.unlink(`${META_DIR}/group-type`);
|
|
6574
|
+
log5.log("[createConfigRepo] removed stale legacy .meta/group-type");
|
|
6575
|
+
} catch {
|
|
6576
|
+
}
|
|
6560
6577
|
} catch (err) {
|
|
6561
6578
|
log5.warn(`[createConfigRepo] Failed to write group metadata:`, err.message);
|
|
6562
6579
|
}
|
|
@@ -6821,7 +6838,15 @@ async function detectGroupTypeDetailed(type, options) {
|
|
|
6821
6838
|
} catch {
|
|
6822
6839
|
}
|
|
6823
6840
|
}
|
|
6824
|
-
|
|
6841
|
+
if (remote?.kind === "data") {
|
|
6842
|
+
log6("detectGroupType: no marker, but .meta/group.json declares kind=data \u2192 data-sync");
|
|
6843
|
+
return { groupType: "data-sync", remote };
|
|
6844
|
+
}
|
|
6845
|
+
if (remote?.kind === "config") {
|
|
6846
|
+
log6("detectGroupType: no marker, but .meta/group.json declares kind=config \u2192 config-sync");
|
|
6847
|
+
return { groupType: "config-sync", remote };
|
|
6848
|
+
}
|
|
6849
|
+
log6(`detectGroupType: no group-type file and no descriptor kind (new backend)`);
|
|
6825
6850
|
return { groupType: null, remote };
|
|
6826
6851
|
} finally {
|
|
6827
6852
|
if (tempBackend?.dispose) {
|
package/dist/index.mjs
CHANGED
|
@@ -4273,10 +4273,9 @@ var ConfigRepo = class {
|
|
|
4273
4273
|
}
|
|
4274
4274
|
}
|
|
4275
4275
|
const bytes = new TextEncoder().encode(type);
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
await this.
|
|
4279
|
-
await this.cachedFS.writeFile(path, bytes);
|
|
4276
|
+
if (!await this.safeExists(this.cachedFS, GROUP_TYPE_FILE)) {
|
|
4277
|
+
await this.ensureDir(GROUP_TYPE_FILE);
|
|
4278
|
+
await this.cachedFS.writeFile(GROUP_TYPE_FILE, bytes);
|
|
4280
4279
|
}
|
|
4281
4280
|
const existingDescriptor = await readGroupDescriptor(this.cachedFS);
|
|
4282
4281
|
if (!existingDescriptor) {
|
|
@@ -4315,6 +4314,14 @@ var ConfigRepo = class {
|
|
|
4315
4314
|
log5.log(`[ConfigRepo] assigned group instanceId ${this.instanceId} (kind=${existingDescriptor?.kind ?? "config"})`);
|
|
4316
4315
|
}
|
|
4317
4316
|
log5.log(`[ConfigRepo] group-type set to "${type}"`);
|
|
4317
|
+
if (await this.safeExists(this.cachedFS, LEGACY_GROUP_TYPE_FILE)) {
|
|
4318
|
+
try {
|
|
4319
|
+
await this.cachedFS.unlink(LEGACY_GROUP_TYPE_FILE);
|
|
4320
|
+
log5.log("[ConfigRepo] removed stale legacy .meta/group-type");
|
|
4321
|
+
} catch (err) {
|
|
4322
|
+
log5.warn(`[ConfigRepo] failed to remove legacy .meta/group-type: ${err.message}`);
|
|
4323
|
+
}
|
|
4324
|
+
}
|
|
4318
4325
|
}
|
|
4319
4326
|
/** Read the group-type marker. Returns null if not set (new path, then legacy). */
|
|
4320
4327
|
async getGroupType() {
|
|
@@ -5778,18 +5785,23 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
5778
5785
|
log5.error(`[createConfigRepo] Failed to ensure /.meta/:`, err.message);
|
|
5779
5786
|
}
|
|
5780
5787
|
}
|
|
5788
|
+
const declaredIdentity = await readGroupDescriptor(primaryInstance);
|
|
5789
|
+
if (declaredIdentity?.kind === "data") {
|
|
5790
|
+
throw new Error(
|
|
5791
|
+
`[createConfigRepo] \u8BE5\u8FDC\u7AEF\u6839\u7684 .meta/group.json \u58F0\u660E\u4E3A\u6570\u636E\u7EC4\uFF08kind=data \xB7 id=${declaredIdentity.id ?? "?"}\uFF09\u2014\u2014\u62D2\u7EDD\u5728\u8FD9\u91CC\u521D\u59CB\u5316\u914D\u7F6E\u7EC4\u3002\u8981\u7ED9\u6570\u636E\u7EC4\u6362\u4E13\u5C5E\u8FDC\u7AEF\u6839\uFF0C\u6216\u5728\u914D\u7F6E\u7EC4\u4FA7\u89E3\u9664\u5BF9\u8BE5\u6839\u7684\u7ED1\u5B9A\u3002`
|
|
5792
|
+
);
|
|
5793
|
+
}
|
|
5781
5794
|
try {
|
|
5782
5795
|
const groupTypeBytes = new TextEncoder().encode("config-sync");
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
}
|
|
5796
|
+
const markerPath = `${CONFIG_DIR}/group-type`;
|
|
5797
|
+
try {
|
|
5798
|
+
await primaryInstance.readFile(markerPath);
|
|
5799
|
+
} catch {
|
|
5800
|
+
await ensureParentDir2(primaryInstance, markerPath);
|
|
5801
|
+
await primaryInstance.writeFile(markerPath, groupTypeBytes);
|
|
5802
|
+
log5.log(`[createConfigRepo] group-type set to "config-sync" at ${markerPath}`);
|
|
5791
5803
|
}
|
|
5792
|
-
if (!
|
|
5804
|
+
if (!declaredIdentity) {
|
|
5793
5805
|
await writeGroupDescriptor(primaryInstance, {
|
|
5794
5806
|
schemaVersion: 2,
|
|
5795
5807
|
kind: "config",
|
|
@@ -5798,6 +5810,11 @@ async function createConfigRepo(appId, options = {}) {
|
|
|
5798
5810
|
features: CONFIG_GROUP_FEATURES
|
|
5799
5811
|
});
|
|
5800
5812
|
}
|
|
5813
|
+
try {
|
|
5814
|
+
await primaryInstance.unlink(`${META_DIR}/group-type`);
|
|
5815
|
+
log5.log("[createConfigRepo] removed stale legacy .meta/group-type");
|
|
5816
|
+
} catch {
|
|
5817
|
+
}
|
|
5801
5818
|
} catch (err) {
|
|
5802
5819
|
log5.warn(`[createConfigRepo] Failed to write group metadata:`, err.message);
|
|
5803
5820
|
}
|
|
@@ -6061,7 +6078,15 @@ async function detectGroupTypeDetailed(type, options) {
|
|
|
6061
6078
|
} catch {
|
|
6062
6079
|
}
|
|
6063
6080
|
}
|
|
6064
|
-
|
|
6081
|
+
if (remote?.kind === "data") {
|
|
6082
|
+
log6("detectGroupType: no marker, but .meta/group.json declares kind=data \u2192 data-sync");
|
|
6083
|
+
return { groupType: "data-sync", remote };
|
|
6084
|
+
}
|
|
6085
|
+
if (remote?.kind === "config") {
|
|
6086
|
+
log6("detectGroupType: no marker, but .meta/group.json declares kind=config \u2192 config-sync");
|
|
6087
|
+
return { groupType: "config-sync", remote };
|
|
6088
|
+
}
|
|
6089
|
+
log6(`detectGroupType: no group-type file and no descriptor kind (new backend)`);
|
|
6065
6090
|
return { groupType: null, remote };
|
|
6066
6091
|
} finally {
|
|
6067
6092
|
if (tempBackend?.dispose) {
|
package/dist/zen-fs-config.js
CHANGED
|
@@ -30989,10 +30989,9 @@ var ZenFSConfig = (() => {
|
|
|
30989
30989
|
}
|
|
30990
30990
|
}
|
|
30991
30991
|
const bytes = new TextEncoder().encode(type);
|
|
30992
|
-
|
|
30993
|
-
|
|
30994
|
-
await this.
|
|
30995
|
-
await this.cachedFS.writeFile(path, bytes);
|
|
30992
|
+
if (!await this.safeExists(this.cachedFS, GROUP_TYPE_FILE)) {
|
|
30993
|
+
await this.ensureDir(GROUP_TYPE_FILE);
|
|
30994
|
+
await this.cachedFS.writeFile(GROUP_TYPE_FILE, bytes);
|
|
30996
30995
|
}
|
|
30997
30996
|
const existingDescriptor = await readGroupDescriptor(this.cachedFS);
|
|
30998
30997
|
if (!existingDescriptor) {
|
|
@@ -31031,6 +31030,14 @@ var ZenFSConfig = (() => {
|
|
|
31031
31030
|
log9.log(`[ConfigRepo] assigned group instanceId ${this.instanceId} (kind=${existingDescriptor?.kind ?? "config"})`);
|
|
31032
31031
|
}
|
|
31033
31032
|
log9.log(`[ConfigRepo] group-type set to "${type}"`);
|
|
31033
|
+
if (await this.safeExists(this.cachedFS, LEGACY_GROUP_TYPE_FILE)) {
|
|
31034
|
+
try {
|
|
31035
|
+
await this.cachedFS.unlink(LEGACY_GROUP_TYPE_FILE);
|
|
31036
|
+
log9.log("[ConfigRepo] removed stale legacy .meta/group-type");
|
|
31037
|
+
} catch (err2) {
|
|
31038
|
+
log9.warn(`[ConfigRepo] failed to remove legacy .meta/group-type: ${err2.message}`);
|
|
31039
|
+
}
|
|
31040
|
+
}
|
|
31034
31041
|
}
|
|
31035
31042
|
/** Read the group-type marker. Returns null if not set (new path, then legacy). */
|
|
31036
31043
|
async getGroupType() {
|
|
@@ -32494,18 +32501,23 @@ var ZenFSConfig = (() => {
|
|
|
32494
32501
|
log9.error(`[createConfigRepo] Failed to ensure /.meta/:`, err2.message);
|
|
32495
32502
|
}
|
|
32496
32503
|
}
|
|
32504
|
+
const declaredIdentity = await readGroupDescriptor(primaryInstance);
|
|
32505
|
+
if (declaredIdentity?.kind === "data") {
|
|
32506
|
+
throw new Error(
|
|
32507
|
+
`[createConfigRepo] \u8BE5\u8FDC\u7AEF\u6839\u7684 .meta/group.json \u58F0\u660E\u4E3A\u6570\u636E\u7EC4\uFF08kind=data \xB7 id=${declaredIdentity.id ?? "?"}\uFF09\u2014\u2014\u62D2\u7EDD\u5728\u8FD9\u91CC\u521D\u59CB\u5316\u914D\u7F6E\u7EC4\u3002\u8981\u7ED9\u6570\u636E\u7EC4\u6362\u4E13\u5C5E\u8FDC\u7AEF\u6839\uFF0C\u6216\u5728\u914D\u7F6E\u7EC4\u4FA7\u89E3\u9664\u5BF9\u8BE5\u6839\u7684\u7ED1\u5B9A\u3002`
|
|
32508
|
+
);
|
|
32509
|
+
}
|
|
32497
32510
|
try {
|
|
32498
32511
|
const groupTypeBytes = new TextEncoder().encode("config-sync");
|
|
32499
|
-
|
|
32500
|
-
|
|
32501
|
-
|
|
32502
|
-
|
|
32503
|
-
|
|
32504
|
-
|
|
32505
|
-
|
|
32506
|
-
}
|
|
32512
|
+
const markerPath = `${CONFIG_DIR}/group-type`;
|
|
32513
|
+
try {
|
|
32514
|
+
await primaryInstance.readFile(markerPath);
|
|
32515
|
+
} catch {
|
|
32516
|
+
await ensureParentDir2(primaryInstance, markerPath);
|
|
32517
|
+
await primaryInstance.writeFile(markerPath, groupTypeBytes);
|
|
32518
|
+
log9.log(`[createConfigRepo] group-type set to "config-sync" at ${markerPath}`);
|
|
32507
32519
|
}
|
|
32508
|
-
if (!
|
|
32520
|
+
if (!declaredIdentity) {
|
|
32509
32521
|
await writeGroupDescriptor(primaryInstance, {
|
|
32510
32522
|
schemaVersion: 2,
|
|
32511
32523
|
kind: "config",
|
|
@@ -32514,6 +32526,11 @@ var ZenFSConfig = (() => {
|
|
|
32514
32526
|
features: CONFIG_GROUP_FEATURES
|
|
32515
32527
|
});
|
|
32516
32528
|
}
|
|
32529
|
+
try {
|
|
32530
|
+
await primaryInstance.unlink(`${META_DIR}/group-type`);
|
|
32531
|
+
log9.log("[createConfigRepo] removed stale legacy .meta/group-type");
|
|
32532
|
+
} catch {
|
|
32533
|
+
}
|
|
32517
32534
|
} catch (err2) {
|
|
32518
32535
|
log9.warn(`[createConfigRepo] Failed to write group metadata:`, err2.message);
|
|
32519
32536
|
}
|
|
@@ -32778,7 +32795,15 @@ var ZenFSConfig = (() => {
|
|
|
32778
32795
|
} catch {
|
|
32779
32796
|
}
|
|
32780
32797
|
}
|
|
32781
|
-
|
|
32798
|
+
if (remote?.kind === "data") {
|
|
32799
|
+
log10("detectGroupType: no marker, but .meta/group.json declares kind=data \u2192 data-sync");
|
|
32800
|
+
return { groupType: "data-sync", remote };
|
|
32801
|
+
}
|
|
32802
|
+
if (remote?.kind === "config") {
|
|
32803
|
+
log10("detectGroupType: no marker, but .meta/group.json declares kind=config \u2192 config-sync");
|
|
32804
|
+
return { groupType: "config-sync", remote };
|
|
32805
|
+
}
|
|
32806
|
+
log10(`detectGroupType: no group-type file and no descriptor kind (new backend)`);
|
|
32782
32807
|
return { groupType: null, remote };
|
|
32783
32808
|
} finally {
|
|
32784
32809
|
if (tempBackend?.dispose) {
|