From a63cb5ac7e877334ee3afe8e6c4e4ef3ac2c078a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Maisse?= Date: Fri, 15 May 2020 18:55:52 +0200 Subject: [PATCH] refactor(cli): migrate `generate` file to TS --- lib/cli/src/{generate.js => generate.ts} | 6 ++++-- lib/cli/src/typings.d.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) rename lib/cli/src/{generate.js => generate.ts} (95%) diff --git a/lib/cli/src/generate.js b/lib/cli/src/generate.ts similarity index 95% rename from lib/cli/src/generate.js rename to lib/cli/src/generate.ts index 242b8234cb12..ad7457026091 100644 --- a/lib/cli/src/generate.js +++ b/lib/cli/src/generate.ts @@ -3,12 +3,14 @@ import path from 'path'; import chalk from 'chalk'; import envinfo from 'envinfo'; import leven from 'leven'; -import pkg from '../package.json'; import initiate from './initiate'; import { add } from './add'; import { migrate } from './migrate'; import { extract } from './extract'; +// Cannot be `import` as it's not under TS root dir +const pkg = require('../package.json'); + const logger = console; program @@ -81,7 +83,7 @@ program.command('*', { noHelp: true }).action(() => { const [, , invalidCmd] = process.argv; logger.error(' Invalid command: %s.\n See --help for a list of available commands.', invalidCmd); // eslint-disable-next-line - const availableCommands = program.commands.map(cmd => cmd._name); + const availableCommands = program.commands.map((cmd) => cmd._name); const suggestion = availableCommands.find((cmd) => leven(cmd, invalidCmd) < 3); if (suggestion) { logger.log(`\n Did you mean ${suggestion}?`); diff --git a/lib/cli/src/typings.d.ts b/lib/cli/src/typings.d.ts index 97b8b26b9b45..75cb2ee22218 100644 --- a/lib/cli/src/typings.d.ts +++ b/lib/cli/src/typings.d.ts @@ -1 +1,2 @@ declare module '@storybook/codemod'; +declare module 'envinfo';