/** * CLI command map and entry point * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { CLIOptions, Inquirerer, extractFirst } from 'inquirerer'; import contextCmd from './commands/context'; import authCmd from './commands/auth'; import commitCmd from './commands/commit'; import getAllTreeNodesRecordCmd from './commands/get-all-tree-nodes-record'; import objectCmd from './commands/object'; import refCmd from './commands/ref'; import storeCmd from './commands/store'; import initEmptyRepoCmd from './commands/init-empty-repo'; import insertNodeAtPathCmd from './commands/insert-node-at-path'; import insertNodesAtPathsCmd from './commands/insert-nodes-at-paths'; import provisionBucketCmd from './commands/provision-bucket'; import setAndCommitCmd from './commands/set-and-commit'; import setDataAtPathCmd from './commands/set-data-at-path'; import setManyAndCommitCmd from './commands/set-many-and-commit'; const createCommandMap: () => Record< string, ( argv: Partial>, prompter: Inquirerer, options: CLIOptions ) => Promise > = () => ({ context: contextCmd, auth: authCmd, commit: commitCmd, 'get-all-tree-nodes-record': getAllTreeNodesRecordCmd, object: objectCmd, ref: refCmd, store: storeCmd, 'init-empty-repo': initEmptyRepoCmd, 'insert-node-at-path': insertNodeAtPathCmd, 'insert-nodes-at-paths': insertNodesAtPathsCmd, 'provision-bucket': provisionBucketCmd, 'set-and-commit': setAndCommitCmd, 'set-data-at-path': setDataAtPathCmd, 'set-many-and-commit': setManyAndCommitCmd, }); const usage = "\ncsdk \n\nCommands:\n context Manage API contexts\n auth Manage authentication\n commit commit CRUD operations\n get-all-tree-nodes-record getAllTreeNodesRecord CRUD operations\n object object CRUD operations\n ref ref CRUD operations\n store store CRUD operations\n init-empty-repo initEmptyRepo\n insert-node-at-path insertNodeAtPath\n insert-nodes-at-paths insertNodesAtPaths\n provision-bucket Reconcile an S3 bucket for a logical bucket in the database.\nRecords the request on the bucket row via RLS; the bucket's job\ntrigger then enqueues the same storage:provision_bucket job used on\nINSERT, and repeated requests collapse into one pending job. This is\nidempotent for an already-reconciled bucket; failures become GraphQL\nerrors.\n set-and-commit setAndCommit\n set-data-at-path setDataAtPath\n set-many-and-commit setManyAndCommit\n\n --help, -h Show this help message\n --version, -v Show version\n"; export const commands = async ( argv: Partial>, prompter: Inquirerer, options: CLIOptions ) => { if (argv.help || argv.h) { console.log(usage); process.exit(0); } let { first: command, newArgv } = extractFirst(argv); const commandMap = createCommandMap(); if (!command) { const answer = await prompter.prompt(argv, [ { type: 'autocomplete', name: 'command', message: 'What do you want to do?', options: Object.keys(commandMap), }, ]); command = answer.command as string; } const commandFn = commandMap[command]; if (!commandFn) { console.log(usage); console.error(`Unknown command: ${command}`); process.exit(1); } await commandFn(newArgv, prompter, options); prompter.close(); return argv; };