vendure-cli.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env node
  2. import program from 'commander';
  3. import path from 'path';
  4. import prompts from 'prompts';
  5. import { logColored } from './cli-utils';
  6. import { importProducts } from './populate';
  7. // tslint:disable-next-line:no-var-requires
  8. const version = require('../../package.json').version;
  9. // tslint:disable:no-console
  10. logColored(`
  11. _
  12. | |
  13. __ _____ _ __ __| |_ _ _ __ ___
  14. \\ \\ / / _ \\ '_ \\ / _\` | | | | '__/ _ \\
  15. \\ V / __/ | | | (_| | |_| | | | __/
  16. \\_/ \\___|_| |_|\\__,_|\\__,_|_| \\___|
  17. `);
  18. program.version(`Vendure CLI v${version}`, '-v --version').name('vendure');
  19. program
  20. .command('import-products <csvFile>')
  21. .option('-l, --language', 'Specify ISO 639-1 language code, e.g. "de", "es". Defaults to "en"')
  22. .description('Import product data from the specified csv file')
  23. .action(async (csvPath, command) => {
  24. const filePath = path.join(process.cwd(), csvPath);
  25. await importProducts(filePath, command.language);
  26. });
  27. program.parse(process.argv);
  28. if (!process.argv.slice(2).length) {
  29. program.help();
  30. }