@qaecy/cue-cli 0.0.43 → 0.0.45
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/main.js +70 -14
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -9205,7 +9205,7 @@ function askConfirm(question) {
|
|
|
9205
9205
|
});
|
|
9206
9206
|
}
|
|
9207
9207
|
async function syncHandler(options) {
|
|
9208
|
-
const {
|
|
9208
|
+
const { path, verbose, provider, emulators, zip, legacy, metadataOnly } = options;
|
|
9209
9209
|
try {
|
|
9210
9210
|
const cue = new CueNode({
|
|
9211
9211
|
apiKey: FIREBASE_CONFIG().apiKey,
|
|
@@ -9221,6 +9221,66 @@ async function syncHandler(options) {
|
|
|
9221
9221
|
);
|
|
9222
9222
|
process.exit(1);
|
|
9223
9223
|
}
|
|
9224
|
+
let space = options.space;
|
|
9225
|
+
if (!space) {
|
|
9226
|
+
const tempUser = await cue.auth.signInWithApiKey(key).catch((err) => {
|
|
9227
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
9228
|
+
console.error(`Couldn't authenticate. ${cause}`);
|
|
9229
|
+
process.exit(1);
|
|
9230
|
+
});
|
|
9231
|
+
const allProjects = await cue.projects.listProjects();
|
|
9232
|
+
const syncable = allProjects.filter(
|
|
9233
|
+
(p) => p.syncers?.includes(tempUser.uid) || p.admins?.includes(tempUser.uid)
|
|
9234
|
+
);
|
|
9235
|
+
if (syncable.length === 0) {
|
|
9236
|
+
console.error("You do not have syncer or admin rights on any project.");
|
|
9237
|
+
process.exit(1);
|
|
9238
|
+
}
|
|
9239
|
+
if (syncable.length === 1) {
|
|
9240
|
+
space = syncable[0].id;
|
|
9241
|
+
console.info(`Using project: ${syncable[0].name} (${space})`);
|
|
9242
|
+
} else {
|
|
9243
|
+
console.log("\nProjects you can sync to:");
|
|
9244
|
+
syncable.forEach((p, i) => console.log(` ${i + 1}. ${p.name} (${p.id})`));
|
|
9245
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
9246
|
+
space = await new Promise((resolveInput) => {
|
|
9247
|
+
rl.question(`Enter number (1-${syncable.length}): `, (answer) => {
|
|
9248
|
+
rl.close();
|
|
9249
|
+
const idx = parseInt(answer.trim(), 10) - 1;
|
|
9250
|
+
if (idx >= 0 && idx < syncable.length) {
|
|
9251
|
+
resolveInput(syncable[idx].id);
|
|
9252
|
+
} else {
|
|
9253
|
+
console.error("Invalid selection.");
|
|
9254
|
+
process.exit(1);
|
|
9255
|
+
}
|
|
9256
|
+
});
|
|
9257
|
+
});
|
|
9258
|
+
}
|
|
9259
|
+
}
|
|
9260
|
+
if (!space) {
|
|
9261
|
+
process.exit(1);
|
|
9262
|
+
}
|
|
9263
|
+
if (verbose)
|
|
9264
|
+
console.info("Authenticating \u23F3");
|
|
9265
|
+
let user;
|
|
9266
|
+
try {
|
|
9267
|
+
user = await cue.auth.signInWithApiKey(key, space);
|
|
9268
|
+
} catch (err) {
|
|
9269
|
+
const cause = err instanceof Error ? err.message : String(err);
|
|
9270
|
+
console.error(`Couldn't authenticate. ${cause}`);
|
|
9271
|
+
process.exit(1);
|
|
9272
|
+
}
|
|
9273
|
+
if (verbose)
|
|
9274
|
+
console.info("Authenticated \u2705\n");
|
|
9275
|
+
const projectDoc = await cue.projects.getProject(space);
|
|
9276
|
+
if (projectDoc) {
|
|
9277
|
+
const isSuperAdmin = await cue.auth.checkSuperAdmin();
|
|
9278
|
+
const canSync = isSuperAdmin || projectDoc.syncers?.includes(user.uid) || projectDoc.admins?.includes(user.uid);
|
|
9279
|
+
if (!canSync) {
|
|
9280
|
+
console.error(`You don't have sync rights on project ${space}.`);
|
|
9281
|
+
process.exit(1);
|
|
9282
|
+
}
|
|
9283
|
+
}
|
|
9224
9284
|
if (verbose)
|
|
9225
9285
|
console.info("Building sync base \u23F3");
|
|
9226
9286
|
const resolvedPath = (0, import_path3.resolve)(path);
|
|
@@ -9258,18 +9318,6 @@ async function syncHandler(options) {
|
|
|
9258
9318
|
}
|
|
9259
9319
|
if (verbose)
|
|
9260
9320
|
console.info("Built sync base \u2705\n");
|
|
9261
|
-
if (verbose)
|
|
9262
|
-
console.info("Authenticating \u23F3");
|
|
9263
|
-
let user;
|
|
9264
|
-
try {
|
|
9265
|
-
user = await cue.auth.signInWithApiKey(key, space);
|
|
9266
|
-
} catch (err) {
|
|
9267
|
-
const cause = err instanceof Error ? err.message : String(err);
|
|
9268
|
-
console.error(`Couldn't authenticate. ${cause}`);
|
|
9269
|
-
process.exit(1);
|
|
9270
|
-
}
|
|
9271
|
-
if (verbose)
|
|
9272
|
-
console.info("Authenticated \u2705\n");
|
|
9273
9321
|
if (metadataOnly) {
|
|
9274
9322
|
console.info(`Pushing metadata for ${localFiles.length} file(s) \u23F3`);
|
|
9275
9323
|
await cue.api.sync.pushAllMetadata(localFiles, {
|
|
@@ -9810,6 +9858,14 @@ Project created \u2705`);
|
|
|
9810
9858
|
console.error("Aborted: input stream closed before all prompts were answered.");
|
|
9811
9859
|
process.exit(1);
|
|
9812
9860
|
}
|
|
9861
|
+
if (err instanceof Error && err.message.includes("403")) {
|
|
9862
|
+
console.error("You do not have permission to create a project. Only organization admins can create projects.");
|
|
9863
|
+
process.exit(1);
|
|
9864
|
+
}
|
|
9865
|
+
if (err instanceof Error && /\b5\d\d\b/.test(err.message)) {
|
|
9866
|
+
console.error(`Server error: Project creation failed. Contact your administrator.`);
|
|
9867
|
+
process.exit(1);
|
|
9868
|
+
}
|
|
9813
9869
|
throw err;
|
|
9814
9870
|
} finally {
|
|
9815
9871
|
rl.close();
|
|
@@ -9830,7 +9886,7 @@ try {
|
|
|
9830
9886
|
}
|
|
9831
9887
|
var program = new import_commander.Command();
|
|
9832
9888
|
program.name("cue-cli").description("Cue Command Line Interface").version(packageJson.version);
|
|
9833
|
-
program.command("sync").description("Sync files to Cue").
|
|
9889
|
+
program.command("sync").description("Sync files to Cue").option("-s, --space <id>", "Specify the space ID (omit to pick interactively)").requiredOption("-p, --path <id>", "Specify the folder path (required)").option("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("--provider <provider ID>", "Specify the provider ID (eg. sharepoint, drive, dropbox) or leave empty for default provider", "").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).option("-z, --zip", 'Include zipped content (will be unzipped to path "<zip_path>_unzipped". Max uncompressed size: 500 MB, max recursion depth: 3)', false).option("--legacy", "Write RDF as BLOBs to the processed bucket instead of patching the graph directly", false).option("--metadata-only", "Push filesystem-structure metadata for all local files without checking credits or remote state", false).action(syncHandler);
|
|
9834
9890
|
program.command("dump").description("Dump Cue Knowledge Graph data to file\n Examples:\n $ cue-cli dump -s <space_id> -l -v\n $ cue-cli dump -s <space_id> -j -v").requiredOption("-s, --space <id>", "Specify the space ID (required)").option("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).option("-q, --query", "Uses a construct query to get the dump rather than using the /data endpoint", false).option("-j, --jelly", "Downloads a Jelly file rather than the standard Gzipped NQuads format", false).option("-l, --load", "Loads the dumped file into a local triplestore (requires emulators)", false).action(dumpHandler);
|
|
9835
9891
|
program.command("compare").description("Compares folder content to files already updated to Cue").requiredOption("-s, --space <id>", "Specify the space ID (required)").requiredOption("-p, --path <id>", "Specify the folder path (required)").option("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("--provider <provider ID>", "Specify the provider ID (eg. sharepoint, drive, dropbox) or leave empty for default provider", "").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).option("-z, --zip", "Include zipped content (will temporarily unzip files with same logic as when syncing and delete them again after the comparison)", false).action(compareHandler);
|
|
9836
9892
|
program.command("dump-processed").description("Dump processed files to local folder").requiredOption("-s, --space <id>", "Specify the space ID (required)").requiredOption("-p, --processor <id>", "Id of the processor to dump processed files from (required) [eg. writers-blob, processors-cad-files]").option("-k, --key <api-key>", "Specify the API key (or set CUE_API_KEY env variable)").option("-v, --verbose", "Enable verbose output", false).option("-e, --emulators", "Uses emulators for sync", false).action(dumpProcessedHandler);
|