Fix extension CLI not executing any command (#7667)

This commit is contained in:
Nicola Krumschmidt
2021-08-27 16:27:14 +02:00
committed by GitHub
parent fe882fd407
commit 40f8d2ef99
3 changed files with 24 additions and 28 deletions

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('./dist/cjs/cli/index.js');
require('./dist/cjs/cli/run.js');

View File

@@ -1,31 +1,4 @@
import { Command } from 'commander';
import create from './commands/create';
import build from './commands/build';
const pkg = require('../../../package.json');
if (require.main === module) {
run();
}
function run() {
const program = new Command();
program.name('directus-extension').usage('[command] [options]');
program.version(pkg.version, '-v, --version');
program.command('create').arguments('<type> <name>').description('Scaffold a new Directus extension').action(create);
program
.command('build')
.description('Bundle a Directus extension to a single entrypoint')
.option('-t, --type <type>', 'overwrite the extension type read from package manifest')
.option('-i, --input <file>', 'overwrite the entrypoint read from package manifest')
.option('-o, --output <file>', 'overwrite the output file read from package manifest')
.option('-f, --force', 'ignore the package manifest')
.action(build);
program.parse(process.argv);
}
export { create, build };

View File

@@ -0,0 +1,23 @@
import { Command } from 'commander';
import create from './commands/create';
import build from './commands/build';
const pkg = require('../../../package.json');
const program = new Command();
program.name('directus-extension').usage('[command] [options]');
program.version(pkg.version, '-v, --version');
program.command('create').arguments('<type> <name>').description('Scaffold a new Directus extension').action(create);
program
.command('build')
.description('Bundle a Directus extension to a single entrypoint')
.option('-t, --type <type>', 'overwrite the extension type read from package manifest')
.option('-i, --input <file>', 'overwrite the entrypoint read from package manifest')
.option('-o, --output <file>', 'overwrite the output file read from package manifest')
.option('-f, --force', 'ignore the package manifest')
.action(build);
program.parse(process.argv);