@qaecy/cue-cli 0.0.43 → 0.0.44
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 +49 -2
- 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,45 @@ 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
|
+
}
|
|
9224
9263
|
if (verbose)
|
|
9225
9264
|
console.info("Building sync base \u23F3");
|
|
9226
9265
|
const resolvedPath = (0, import_path3.resolve)(path);
|
|
@@ -9810,6 +9849,14 @@ Project created \u2705`);
|
|
|
9810
9849
|
console.error("Aborted: input stream closed before all prompts were answered.");
|
|
9811
9850
|
process.exit(1);
|
|
9812
9851
|
}
|
|
9852
|
+
if (err instanceof Error && err.message.includes("403")) {
|
|
9853
|
+
console.error("You do not have permission to create a project. Only organization admins can create projects.");
|
|
9854
|
+
process.exit(1);
|
|
9855
|
+
}
|
|
9856
|
+
if (err instanceof Error && /\b5\d\d\b/.test(err.message)) {
|
|
9857
|
+
console.error(`Server error: Project creation failed. Contact your administrator.`);
|
|
9858
|
+
process.exit(1);
|
|
9859
|
+
}
|
|
9813
9860
|
throw err;
|
|
9814
9861
|
} finally {
|
|
9815
9862
|
rl.close();
|
|
@@ -9830,7 +9877,7 @@ try {
|
|
|
9830
9877
|
}
|
|
9831
9878
|
var program = new import_commander.Command();
|
|
9832
9879
|
program.name("cue-cli").description("Cue Command Line Interface").version(packageJson.version);
|
|
9833
|
-
program.command("sync").description("Sync files to Cue").
|
|
9880
|
+
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
9881
|
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
9882
|
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
9883
|
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);
|