@tinycloud/operations 0.4.0-beta.13 → 0.4.0-beta.14
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/coverage.json +6 -0
- package/dist/artifacts.cjs +9 -3
- package/dist/artifacts.cjs.map +1 -1
- package/dist/artifacts.js +9 -3
- package/dist/artifacts.js.map +1 -1
- package/dist/cli-runtime.cjs +9 -3
- package/dist/cli-runtime.cjs.map +1 -1
- package/dist/cli-runtime.js +9 -3
- package/dist/cli-runtime.js.map +1 -1
- package/dist/delegation-binding.cjs +9 -3
- package/dist/delegation-binding.cjs.map +1 -1
- package/dist/delegation-binding.js +9 -3
- package/dist/delegation-binding.js.map +1 -1
- package/dist/index.cjs +9 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.js.map +1 -1
- package/dist/state.cjs +9 -3
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.cts +7 -0
- package/dist/state.d.ts +7 -0
- package/dist/state.js +9 -3
- package/dist/state.js.map +1 -1
- package/package.json +4 -4
package/coverage.json
CHANGED
|
@@ -35,6 +35,12 @@
|
|
|
35
35
|
{ "command": "kv delete <key>", "status": "legacy" },
|
|
36
36
|
{ "command": "kv list", "status": "legacy" },
|
|
37
37
|
{ "command": "kv head <key>", "status": "legacy" },
|
|
38
|
+
{ "command": "replica", "status": "legacy" },
|
|
39
|
+
{ "command": "replica sync", "status": "legacy" },
|
|
40
|
+
{ "command": "replica get <key>", "status": "legacy" },
|
|
41
|
+
{ "command": "replica list [prefix]", "status": "legacy" },
|
|
42
|
+
{ "command": "replica status", "status": "legacy" },
|
|
43
|
+
{ "command": "replica reset", "status": "legacy" },
|
|
38
44
|
{ "command": "space", "status": "legacy" },
|
|
39
45
|
{ "command": "space list", "status": "legacy" },
|
|
40
46
|
{ "command": "space create <name>", "status": "legacy" },
|
package/dist/artifacts.cjs
CHANGED
|
@@ -589,7 +589,8 @@ async function acquireProfileLock(profile, options) {
|
|
|
589
589
|
const lockPath = profileLockPath(profile);
|
|
590
590
|
const turnDirectory = profileTurnLockPath(profile);
|
|
591
591
|
const directory = profilePath(profile);
|
|
592
|
-
|
|
592
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) throw new ProfileDeletedError(profile);
|
|
593
|
+
if (!options.requireProfile) await (0, import_promises.mkdir)(directory, { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
593
594
|
await (0, import_promises.mkdir)((0, import_node_path.dirname)(turnDirectory), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
594
595
|
for (const path of [tinycloudHomePath(), profilesPath(), directory]) {
|
|
595
596
|
await (0, import_promises.chmod)(path, PRIVATE_DIR_MODE).catch((error) => {
|
|
@@ -598,11 +599,15 @@ async function acquireProfileLock(profile, options) {
|
|
|
598
599
|
}
|
|
599
600
|
const { turn, firstWaitedTurn } = await acquireTurn(profile, turnDirectory, deadline);
|
|
600
601
|
try {
|
|
602
|
+
if (options.requireProfile && !await exists(profileConfigPath(profile))) {
|
|
603
|
+
await (0, import_promises.rmdir)(directory).catch(() => void 0);
|
|
604
|
+
throw new ProfileDeletedError(profile);
|
|
605
|
+
}
|
|
601
606
|
const deletion = await readJson((0, import_node_path.join)(turnDirectory, "deleted.json")).catch(() => null);
|
|
602
607
|
const deletedWhileWaiting = typeof deletion?.slot === "number" && deletion.slot >= firstWaitedTurn;
|
|
603
608
|
while (true) {
|
|
604
609
|
const token = (0, import_node_crypto.randomUUID)();
|
|
605
|
-
if (await publishProfileLock(profile, lockPath, token)) {
|
|
610
|
+
if (await publishProfileLock(profile, lockPath, token, options.requireProfile === true)) {
|
|
606
611
|
return {
|
|
607
612
|
deletedWhileWaiting,
|
|
608
613
|
turnSlot: turn.slot,
|
|
@@ -853,12 +858,13 @@ async function collectTurns(profile, turn) {
|
|
|
853
858
|
}
|
|
854
859
|
}
|
|
855
860
|
}
|
|
856
|
-
async function publishProfileLock(profile, lockPath, token) {
|
|
861
|
+
async function publishProfileLock(profile, lockPath, token, requireProfile) {
|
|
857
862
|
try {
|
|
858
863
|
await (0, import_promises.mkdir)(lockPath, { mode: PRIVATE_DIR_MODE });
|
|
859
864
|
} catch (error) {
|
|
860
865
|
if (isErrno(error, "EEXIST")) return false;
|
|
861
866
|
if (!isErrno(error, "ENOENT")) throw error;
|
|
867
|
+
if (requireProfile) throw new ProfileDeletedError(profile);
|
|
862
868
|
await (0, import_promises.mkdir)(profilePath(profile), { recursive: true, mode: PRIVATE_DIR_MODE });
|
|
863
869
|
return false;
|
|
864
870
|
}
|