@rigxyz/tapd 0.6.4 → 0.6.7
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/bin.js +56 -5
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-F3HYZR2Y.js → chunk-32K6ANXS.js} +0 -0
- package/dist/chunk-32K6ANXS.js.map +1 -0
- package/dist/index.d.ts +53 -7
- package/dist/index.js +3 -1
- package/package.json +1 -1
- package/dist/chunk-F3HYZR2Y.js.map +0 -1
package/dist/bin.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
ImportTokenScopeError,
|
|
6
6
|
ImportValidationFailed,
|
|
7
7
|
InvalidInviteUrlError,
|
|
8
|
+
MAX_FILE_BYTES,
|
|
8
9
|
NotInitializedError,
|
|
9
10
|
OrgForbiddenError,
|
|
10
11
|
RelayClient,
|
|
@@ -22,12 +23,14 @@ import {
|
|
|
22
23
|
loadImportMounts,
|
|
23
24
|
mint,
|
|
24
25
|
openStateDb,
|
|
26
|
+
quarantineFiles,
|
|
25
27
|
readBindingConfig,
|
|
28
|
+
readNotSynced,
|
|
26
29
|
removeImport,
|
|
27
30
|
revoke,
|
|
28
31
|
safeResolveRigPath,
|
|
29
32
|
start
|
|
30
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-32K6ANXS.js";
|
|
31
34
|
|
|
32
35
|
// src/bin.ts
|
|
33
36
|
import { join as pathJoin, resolve } from "path";
|
|
@@ -264,9 +267,9 @@ async function restore(opts) {
|
|
|
264
267
|
const overwrote = existsSync3(targetAbs);
|
|
265
268
|
mkdirSync2(dirname2(targetAbs), { recursive: true });
|
|
266
269
|
const tmp = `${targetAbs}.tap-restore-tmp.${Date.now().toString(36)}`;
|
|
267
|
-
|
|
268
|
-
writeFileSync2(tmp, bytes, { mode });
|
|
270
|
+
writeFileSync2(tmp, bytes, { mode: 420 });
|
|
269
271
|
renameSync(tmp, targetAbs);
|
|
272
|
+
await quarantineFiles([targetAbs]);
|
|
270
273
|
return {
|
|
271
274
|
path: opts.path,
|
|
272
275
|
restoredFromCursor: writeEvent.id,
|
|
@@ -281,7 +284,7 @@ import { existsSync as existsSync4 } from "fs";
|
|
|
281
284
|
import { join as join4 } from "path";
|
|
282
285
|
|
|
283
286
|
// src/version.ts
|
|
284
|
-
var TAPD_VERSION = "0.6.
|
|
287
|
+
var TAPD_VERSION = "0.6.7";
|
|
285
288
|
|
|
286
289
|
// src/status.ts
|
|
287
290
|
var STATE_KEY_LAST_APPLY_ERROR = "last_apply_error";
|
|
@@ -302,6 +305,7 @@ function statusToJson(report) {
|
|
|
302
305
|
trackedPaths: report.trackedPaths,
|
|
303
306
|
pendingApplies: report.pendingApplies,
|
|
304
307
|
pendingUploads: report.pendingUploads,
|
|
308
|
+
notSynced: report.notSynced,
|
|
305
309
|
conflicts: report.conflicts,
|
|
306
310
|
lastApplyError: report.lastApplyError,
|
|
307
311
|
offline: report.offline,
|
|
@@ -356,6 +360,7 @@ async function status(opts) {
|
|
|
356
360
|
pendingPeek: [],
|
|
357
361
|
pendingApplies: 0,
|
|
358
362
|
pendingUploads: 0,
|
|
363
|
+
notSynced: [],
|
|
359
364
|
conflicts: [],
|
|
360
365
|
conflictCount: 0,
|
|
361
366
|
lastApplyError: null,
|
|
@@ -416,6 +421,7 @@ async function status(opts) {
|
|
|
416
421
|
pendingPeek,
|
|
417
422
|
pendingApplies,
|
|
418
423
|
pendingUploads,
|
|
424
|
+
notSynced: readNotSynced(db),
|
|
419
425
|
conflicts,
|
|
420
426
|
conflictCount,
|
|
421
427
|
lastApplyError,
|
|
@@ -591,6 +597,8 @@ ${C.bold().cyan("tapd init OPTIONS")}
|
|
|
591
597
|
${C.dim("--relay <url>")} override (defaults to the logged-in relay)
|
|
592
598
|
${C.dim("--device-label <l>")} default 'owner'
|
|
593
599
|
${C.dim("--org <slug>")} create this binding under an org you belong to
|
|
600
|
+
${C.dim("--kind <rig|space>")} create it as a space (default: rig)
|
|
601
|
+
${C.dim("--defer-upload")} create the binding only; \`tapd start\` uploads the files
|
|
594
602
|
${C.dim("--dir <path>")} default cwd
|
|
595
603
|
|
|
596
604
|
${C.bold().cyan("tapd join OPTIONS")}
|
|
@@ -1136,6 +1144,37 @@ async function runStatus(flags2) {
|
|
|
1136
1144
|
` last err: ${C.red(e.reason)} ${C.dim(`(${e.op} ${e.path} @ ${e.eventId}${e.at ? `, ${e.at}` : ""})`)}`
|
|
1137
1145
|
);
|
|
1138
1146
|
}
|
|
1147
|
+
const overQuota = report.notSynced.filter((f) => f.reason === "quota_exceeded");
|
|
1148
|
+
const tooLarge = report.notSynced.filter((f) => f.reason === "file_too_large");
|
|
1149
|
+
const mb = (n) => `${Math.round(n / (1024 * 1024))} MB`;
|
|
1150
|
+
const plural = (n) => `${n} file${n === 1 ? "" : "s"}`;
|
|
1151
|
+
if (overQuota.length > 0) {
|
|
1152
|
+
const limit = overQuota.find((f) => f.limitBytes !== void 0)?.limitBytes;
|
|
1153
|
+
console.log(
|
|
1154
|
+
` ${C.yellow(`${plural(overQuota.length)} not synced`)}: over the space's ${limit ? `${mb(limit)} ` : ""}storage limit`
|
|
1155
|
+
);
|
|
1156
|
+
for (const f of overQuota) console.log(C.dim(` ${f.path}`));
|
|
1157
|
+
}
|
|
1158
|
+
if (tooLarge.length > 0) {
|
|
1159
|
+
console.log(
|
|
1160
|
+
` ${C.yellow(`${plural(tooLarge.length)} not synced`)}: over the ${mb(MAX_FILE_BYTES)} per-file limit`
|
|
1161
|
+
);
|
|
1162
|
+
for (const f of tooLarge) console.log(C.dim(` ${f.path}`));
|
|
1163
|
+
}
|
|
1164
|
+
const ownerOnly = report.notSynced.filter((f) => f.reason === "owner_only");
|
|
1165
|
+
if (ownerOnly.length > 0) {
|
|
1166
|
+
console.log(
|
|
1167
|
+
` ${C.yellow(`${plural(ownerOnly.length)} not synced`)}: agent instructions only the space's owner can change`
|
|
1168
|
+
);
|
|
1169
|
+
for (const f of ownerOnly) console.log(C.dim(` ${f.path}`));
|
|
1170
|
+
}
|
|
1171
|
+
const protectedPaths = report.notSynced.filter((f) => f.reason === "protected");
|
|
1172
|
+
if (protectedPaths.length > 0) {
|
|
1173
|
+
console.log(
|
|
1174
|
+
` ${C.yellow(`${plural(protectedPaths.length)} not synced`)}: protected paths never sync between members`
|
|
1175
|
+
);
|
|
1176
|
+
for (const f of protectedPaths) console.log(C.dim(` ${f.path}`));
|
|
1177
|
+
}
|
|
1139
1178
|
} else {
|
|
1140
1179
|
console.log(C.dim(" (import-only meta-rig \u2014 no primary binding)"));
|
|
1141
1180
|
}
|
|
@@ -1404,9 +1443,18 @@ async function runInit(flags2) {
|
|
|
1404
1443
|
process.exit(2);
|
|
1405
1444
|
}
|
|
1406
1445
|
const org = orgRaw;
|
|
1446
|
+
const kindRaw = flags2.get("kind");
|
|
1447
|
+
if (kindRaw !== void 0 && kindRaw !== "rig" && kindRaw !== "space") {
|
|
1448
|
+
const msg = "--kind must be rig or space";
|
|
1449
|
+
if (json) printJsonError("invalid_flag", msg);
|
|
1450
|
+
else console.error(kleur.red("error:"), msg);
|
|
1451
|
+
process.exit(2);
|
|
1452
|
+
}
|
|
1453
|
+
const kind = kindRaw;
|
|
1454
|
+
const deferUpload = flags2.get("defer-upload") === true;
|
|
1407
1455
|
let result;
|
|
1408
1456
|
try {
|
|
1409
|
-
result = await init({ rootDir, relayUrl, accessToken, bindingName: name, deviceLabel, org });
|
|
1457
|
+
result = await init({ rootDir, relayUrl, accessToken, bindingName: name, deviceLabel, org, kind, deferUpload });
|
|
1410
1458
|
} catch (err) {
|
|
1411
1459
|
if (err instanceof AlreadyInitializedError) {
|
|
1412
1460
|
if (json) printJsonError("already_initialized", err.message);
|
|
@@ -1428,6 +1476,8 @@ async function runInit(flags2) {
|
|
|
1428
1476
|
protocolVersion: PROTOCOL_VERSION,
|
|
1429
1477
|
bindingId: result.binding.id,
|
|
1430
1478
|
bindingName: result.binding.name,
|
|
1479
|
+
// What the relay made (an older relay ignores `kind` and says nothing).
|
|
1480
|
+
kind: result.binding.kind ?? null,
|
|
1431
1481
|
deviceId: result.device.id,
|
|
1432
1482
|
deviceLabel: result.device.label,
|
|
1433
1483
|
relayUrl,
|
|
@@ -1436,6 +1486,7 @@ async function runInit(flags2) {
|
|
|
1436
1486
|
reusedHashes: result.reusedHashes,
|
|
1437
1487
|
submittedEvents: result.submittedEvents,
|
|
1438
1488
|
cursor: result.cursor,
|
|
1489
|
+
deferredUpload: result.deferredUpload,
|
|
1439
1490
|
warnings: result.warnings
|
|
1440
1491
|
});
|
|
1441
1492
|
return;
|