program.on('--help', () => { console.log(` Get started: $ postgraphile $ postgraphile -c postgres://localhost/my_db $ postgraphile --connection postgres://user:pass@localhost/my_db --schema my_schema --watch --dynamic-json `); process.exit(0); });
program .command('db:migrate') .action(function() { openConfig() var db = configuration.db(configuration) return db.migrate() .then(function () { console.log('The database was migrated') db.close() process.exit(0) }) .catch(handleDbError) })
program .command('generate') .option('-t, --tables <tables>', 'Comma delimited list of tables to generate schema from', list) .description('Generate Cube.js schema from DB tables schema') .action( (options) => generateSchema(options).catch(e => displayError(e.stack || e, { dbType: options.dbType })) ) .on('--help', () => { console.log(''); console.log('Examples:'); console.log(''); console.log(' $ cubejs generate -t orders,customers'); });
program .command('jobs') .description('List all completed jobs') .option('--completed', 'Show completed jobs') .option('--failed', 'Show failed jobs') .option('-l, --limit [limit]', 'Limit how many jobs to show') .action(function (options) { openConfig() return listJobs(queue, options.failed, options.completed, options.limit) .then(function() { queue.close() process.exit(0) }) .catch(handleDbError) })
program .usage('<command> [options]') .on('--help', () => { console.log(''); console.log('Use cubejs <command> --help for more information about a command.'); console.log(''); });
program .command('shift') .description('Run the next job in the queue') .action(function (url) { openConfig() var maxTries = configuration.queue.generationMaxTries var retryStrategy = configuration.queue.generationRetryStrategy return queue.getNext(retryStrategy, maxTries) .then(function (next) { if (!next) { queue.close() process.exit(0) } return processJob(next, configuration) }) .catch(handleDbError) })
// Match provider manifests against wanted manifests airtap.manifests(wanted, function (err, manifests) { if (err) return fail(err) if (program.listBrowsers) { manifests.forEach(simplifyManifest) console.log(toYAML(manifests)) return } airtap.test(manifests, files, config) .on('error', fail) .on('context', function (context) { // Emits one session or more (on page reload) context.on('session', function (session) { // TODO (later): merge TAP from multiple sessions session.pipe(process.stdout, { end: false }) }) }) .on('complete', function (stats) { console.log('# %d of %d browsers ok', stats.pass, stats.count) process.exit(stats.ok ? 0 : 1) }) })
program .command('purge') .description('Will remove all completed jobs') .option('--failed', 'Remove all failed jobs') .option('--new', 'Remove all new jobs') .action(function (options) { openConfig() return queue.purge(options.failed, options.new) .then(function () { queue.close() console.log('The queue was purged.') process.exit(0) }) .catch(handleDbError) })
program .command('api') .description('Start the API') .action(function (options) { // We delay initiation of queue. This is because the API will load the DB in memory as // copy A. When we make changes through the CLI this creates copy B. But next time the // user pushes to the queue using the API copy A will be persisted again. var initiateQueue = openConfig(true) var apiOptions = configuration.api var port = apiOptions.port createApi(initiateQueue, { port: port, postPushCommand: apiOptions.postPushCommand, token: apiOptions.token }).listen(port, function() { debug('Listening to port %d', port) }) })
program .command('auth <token>') .description('Authenticate access to Cube Cloud') .action( (currentToken) => authenticate(currentToken) .catch(e => displayError(e.stack || e)) ) .on('--help', () => { console.log(''); console.log('Examples:'); console.log(''); console.log(' $ cubejs auth eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkZXBsb3ltZW50SWQiOiIxIiwidXJsIjoiaHR0cHM6Ly9leGFtcGxlcy5jdWJlY2xvdWQuZGV2IiwiaWF0IjoxNTE2MjM5MDIyfQ.La3MiuqfGigfzADl1wpxZ7jlb6dY60caezgqIOoHt-c'); console.log(' $ cubejs deploy'); });
program.on("--help", () => { console.log(""); console.log(" Examples:".blue); console.log(""); console.log(" $ xmysql -u username -p password -d databaseSchema".blue); console.log(""); });
program .command('token') .option('-e, --expiry [expiry]', 'Token expiry. Set to 0 for no expiry', defaultExpiry) .option('-s, --secret [secret]', 'Cube.js app secret. Also can be set via environment variable CUBEJS_API_SECRET') .option('-p, --payload [values]', 'Payload. Example: -p foo=bar', collect, []) .description('Create JWT token') .action( (options) => token(options) .catch(e => displayError(e.stack || e)) ) .on('--help', () => { console.log(''); console.log('Examples:'); console.log(''); console.log(' $ cubejs token -e "1 day" -p foo=bar -p cool=true'); });
program .command('generate [jobID]') .description('Generate PDF for job') .action(function (jobId, options){ openConfig() return queue.getById(jobId) .then(function (job) { if (!job) { console.error('Job not found') queue.close() process.exit(1) } return processJob(job, configuration) }) .catch(handleDbError) })
program .command('create <name>') .option( '-d, --db-type <db-type>', 'Preconfigure for selected database.\n\t\t\t ' + 'Options: postgres, mysql, mongobi, athena, redshift, bigquery, mssql, clickhouse, snowflake, presto' ) .option('-t, --template <template>', 'App template. Options: express (default), serverless.') .description('Create new Cube.js app') .action( (projectName, options) => createApp(projectName, options) .catch(e => displayError(e.stack || e, { projectName, dbType: options.dbType })) ) .on('--help', () => { console.log(''); console.log('Examples:'); console.log(''); console.log(' $ cubejs create hello-world -d postgres'); });
program .command('deploy') .description('Deploy project to Cube Cloud') .action( (options) => deploy({ directory: process.cwd(), ...options }) .catch(e => displayError(e.stack || e)) ) .on('--help', () => { console.log(''); console.log('Examples:'); console.log(''); console.log(' $ cubejs deploy'); });