mirror of
https://github.com/directus/directus.git
synced 2026-02-01 03:45:03 -05:00
* merge components merge args, parser, docs, formatter, help and handlers * change directus command and add auto debug * output format fixes * adds back some reformatted and documented commands * better help output format * refactor all output flow * export cli types * more formatting fixes and param rework * fix table spacing * add yaml formatting and fix string colors * finished formatting docs * remove log * remove package-lock * update dependency versions * fix command description * workaround typescript loading * module loading fixes added command error rename human to table fix disconnect usage * add typescript loader redirect execution to local package if installed locally added command alias `directus-ctl` * fix module load directories * reimplement stdin pipe to work on linux * fix sdk server info type * info command * Fix stdin bug Disable community extensions to discourage use for now Added template to config files Added password stdin to connect to instances Fixed typescript command load * Added command suggestions and QOL features * Linter fixes * Add command hints * Separate positional options * Add back delete many, fix delete one location * Change score logic * Add whoami util command * Add short online docs * Fix typo * Fix typo * Update commands * Param consistency fix and docs update * Create commands * Update package.json version * Update package-lock * Fixed several linting problems * Update dependencies * Update lock * Remove locked dependencies * Stop conflicts when in home directory * Package lock update and npm audit fix * Fix formatting errors * Comment out extending cli section until we figure out cli ext * Update readme * Tweak dev/build/prebuild script naming * Use up to date deps * Fix dependency version in lock (fix build) Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
51 lines
1.3 KiB
JavaScript
Executable File
51 lines
1.3 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
require('dotenv').config();
|
|
|
|
const startupOptions = {
|
|
devMode: !!process.env.DIRECTUS_CLI_DEV && fs.existsSync(`${__dirname}/../src`),
|
|
useGlobal: !!process.env.DIRECTUS_CLI_DEV && !!process.env.DIRECTUS_CLI_DEV_USE_GLOBAL,
|
|
useCompiled: !!process.env.DIRECTUS_CLI_DEV && !!process.env.DIRECTUS_CLI_DEV_USE_COMPILED,
|
|
};
|
|
|
|
const entrypoint = path.resolve('./node_modules/@directus/cli/bin/directus.js');
|
|
if (__filename !== entrypoint && fs.existsSync(entrypoint) && !startupOptions.useGlobal) {
|
|
require(entrypoint);
|
|
return;
|
|
}
|
|
|
|
async function main(run) {
|
|
const debug = require('debug')('directus-cli');
|
|
try {
|
|
const { error, output } = await run(process.argv);
|
|
if (error) {
|
|
debug(error);
|
|
}
|
|
|
|
if (output) {
|
|
await output.flush(process.stdout);
|
|
process.stdout.write('\n');
|
|
}
|
|
|
|
process.exit(error ? 1 : 0);
|
|
} catch (error) {
|
|
console.error(error);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
let run = () => {};
|
|
|
|
if (!startupOptions.devMode || startupOptions.useCompiled) {
|
|
run = require(`${__dirname}/../dist/index`).default;
|
|
} else {
|
|
process.env.DEBUG = `${process.env.DEBUG ?? ''}directus-cli`;
|
|
require('ts-node').register({ project: `${__dirname}/../tsconfig.json` });
|
|
run = require(`${__dirname}/../src/index`).default;
|
|
}
|
|
|
|
main(run);
|