cli-reporter: Add informative prompts for key usage on all select calls
cli-reporter: In select, when pressing escape, kill the process
cli-reporter: In select, when we kill the process, also output a warning message
local init command: Add support for tests component
local init command: Error when a project already exists in the cwd
MODIFY
packages/@romejs/core/client/commands.ts
packages/@romejs/core/client/commands.ts
@@ -13,7 +13,7 @@ import executeMain from '../common/utils/executeMain';
import {createSingleDiagnosticError} from '@romejs/diagnostics';
import {createAbsoluteFilePath} from '@romejs/path';
import {Dict} from '@romejs/typescript-helpers';
-import {writeFile} from '@romejs/fs';
+import {writeFile, exists} from '@romejs/fs';
import {VERSION} from '../common/constants';
export const localCommands: Map<string, LocalCommand<any>> = new Map();
@@ -37,10 +37,18 @@ localCommands.set('init', {
const config: Dict<unknown> = {};
- reporter.heading('Welcome to Rome!');
+ const configPath = req.client.flags.cwd.append('rome.json');
+ if (await exists(configPath)) {
+ reporter.error(
+ `<filelink target="${configPath.join()}" emphasis>rome.json</emphasis> file already exists`,
+ );
reporter.info(
- 'Press <emphasis>space</emphasis> to select an option and <emphasis>enter</emphasis> to confirm',
+ 'Use <command>rome config</command> to update an existing config',
);
+ return false;
+ }
+
+ reporter.heading('Welcome to Rome!');
if (flags.defaults === false) {
const useDefaults = await reporter.radioConfirm(
@@ -67,6 +75,9 @@ localCommands.set('init', {
format: {
label: 'Format',
},
+ tests: {
+ label: 'Testing',
+ },
},
defaults: ['lint'],
});
@@ -76,8 +87,10 @@ localCommands.set('init', {
if (enabledComponents.has('format')) {
config.format = {enabled: true};
}
+ if (enabledComponents.has('tests')) {
+ config.tests = {enabled: true};
+ }
- const configPath = req.client.flags.cwd.append('rome.json');
await writeFile(configPath, `${JSON.stringify(config, null, ' ')}\n`);
reporter.success(

cli-reporter: Add informative prompts for key usage on all select calls
cli-reporter: In select, when pressing escape, kill the process
cli-reporter: In select, when we kill the process, also output a warning message
local init command: Add support for tests component
local init command: Error when a project already exists in the cwd