vendure-cli.ts 1.1 KB

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