Skip to content

Commit 61737ed

Browse files
feat!: use zero questions mode by default.
feat!: "-y" argv replaced with "-v" with opposite meaning feat!: "noQuestions" replaced with "extraQuestions" with opposite meaning BREAKING CHANGE: use zero questions mode by default. BREAKING CHANGE: "-y" argv replaced with "-v" with opposite meaning. BREAKING CHANGE: "noQuestions" replaced with "extraQuestions" with opposite meaning.
1 parent 740b335 commit 61737ed

12 files changed

Lines changed: 49 additions & 41 deletions

docs/en/create-hermione-app.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ Without specifying the path, project will be created in the current directory.
1414

1515
If you already have a project at given path, the tool will try to guess used package manager.
1616

17-
### No questions mode
17+
### Extra questions mode
1818

19-
You can add `-y` or `--yes` argument to launch a tool in *no-questions* mode:
19+
By default, project will be created with zero questions.
20+
21+
You can add `-v` or `--verbose` argument to launch a tool in *extra-questions* mode, to pick custom package manager or pick extra plugins:
2022

2123
```bash
22-
npm init hermione-app my-app -- -y
24+
npm init hermione-app my-app -- -v
2325
```
2426

2527
In this mode you won't be asked questions about desired plugins and packet manager.
2628

27-
Default packet manager, used with `--yes` argument: `npm`
29+
Default packet manager, used without `--verbose` argument: `npm`
2830

29-
Default plugins, installed with `--yes` argument:
31+
Default plugins, installed without `--verbose` argument:
3032
- [html-reporter](https://github.com/gemini-testing/html-reporter)
3133

3234
### Lang
@@ -86,14 +88,14 @@ createHermioneApp.run({
8688

8789
**Required parameter**
8890

89-
Default tool's CLI handles given path and `--yes` argument. In this callback you need to at least specify `path` and `noQuestions` values:
91+
Default tool's CLI handles given path and `--verbose` argument. In this callback you need to at least specify `path` and `extraQuestions` values:
9092

9193
```ts
9294
import type { DefaultOpts } from "create-hermione-app";
9395

9496
const argvOpts = {
9597
path: ".",
96-
noQuestions: true
98+
extraQuestions: false
9799
};
98100

99101
const createOpts = (defaultOpts: DefaultOpts) => {
@@ -160,7 +162,7 @@ const generalPromptsHandler: HandleGeneralPromptsCallback = (hermioneConfig, ans
160162
};
161163
```
162164

163-
If `GeneralPrompt` does not have `default` value, the question will be asked even with `noQuestions: true`
165+
If `GeneralPrompt` does not have `default` value, the question will be asked with `extraQuestions: false`
164166

165167
#### createPluginsConfig
166168

@@ -245,7 +247,7 @@ const createOpts = (defaultOpts: DefaultOpts) => {
245247
return {
246248
...defaultOpts,
247249
path: ".",
248-
noQuestions: false
250+
extraQuestions: false
249251
};
250252
};
251253
```

docs/ru/create-hermione-app.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@ npm init hermione-app my-app
1414

1515
Если по указанному пути уже имеется проект, инструмент попробует определить используемый пакетный менеджер, и будет использовать его для установки пакетов.
1616

17-
### Режим «без вопросов»
17+
### Режим продвинутой установки
1818

19-
Вы можете добавить аргумент `-y` или `--yes` чтобы запустить инструмент в режиме «без вопросов».
19+
По умолчанию, проект будет настроен без всяких вопросов.
20+
21+
Для запуска инструмента в режиме продвинутой установки, Вы можете добавить аргумент `-v` или `--verbose`. Это позволит выбрать пакетный менеджер или сразу установить дополнительные плагины.
22+
23+
```bash
24+
npm init hermione-app my-app -- -v
25+
```
2026

2127
В этом режиме у вас не будут спрашивать о желаемых плагинах и пакетном менеджере, будут использоваться настройки по умолчанию.
2228

23-
Пакетный менеджер по умолчанию, используемый с аргументом `--yes`: `npm`
29+
Пакетный менеджер по умолчанию, используемый без аргумента `--verbose`: `npm`
2430

25-
Плагины по умолчанию, устанавливаемые с аргументом `--yes`:
31+
Плагины по умолчанию, устанавливаемые без аргумента `--verbose`:
2632
- [html-reporter](https://github.com/gemini-testing/html-reporter)
2733

2834
### Язык
@@ -82,15 +88,15 @@ createHermioneApp.run({
8288

8389
**Обязательный параметр.**
8490

85-
Консольный интерфейс по умолчанию обрабатывает данный путь и аргумент `--yes`.
86-
В этом коллбэке вам необходимо указать как минимум значения `path` и `noQuestions`:
91+
Консольный интерфейс по умолчанию обрабатывает данный путь и аргумент `--verbose`.
92+
В этом коллбэке вам необходимо указать, как минимум, значения `path` и `extraQuestions`:
8793

8894
```ts
8995
import type { DefaultOpts } from "create-hermione-app";
9096

9197
const argvOpts = {
9298
path: ".",
93-
noQuestions: true
99+
extraQuestions: false
94100
};
95101

96102
const createOpts = (defaultOpts: DefaultOpts) => {
@@ -156,7 +162,7 @@ const generalPromptsHandler: HandleGeneralPromptsCallback = (hermioneConfig, ans
156162
};
157163
```
158164

159-
Если у `GeneralPrompt` не указать значение по умолчанию, вопрос будет задан даже при `noQuestions: true`
165+
Если у `GeneralPrompt` не указать значение по умолчанию, вопрос будет задан даже при `extraQuestions: false`
160166

161167
#### createPluginsConfig
162168

@@ -241,7 +247,7 @@ const createOpts = (defaultOpts: DefaultOpts) => {
241247
return {
242248
...defaultOpts,
243249
path: ".",
244-
noQuestions: false
250+
extraQuestions: false
245251
};
246252
};
247253
```

src/bin/create-hermione-app.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ const argv = yargs(hideBin(process.argv))
1717
description: "Language, which will be used to write hermione tests",
1818
choices: ["ts", "js"],
1919
})
20-
.option("yes", {
21-
alias: "y",
20+
.option("verbose", {
21+
alias: "v",
2222
type: "boolean",
2323
default: false,
24-
description: "Auto configuration with 0 questions",
24+
description: "Advanced configuration with extra questions",
2525
})
2626
.parse();
2727

src/configBuilder.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,30 @@ describe("configBuilder", () => {
4747

4848
describe("should do nothing if", () => {
4949
it("prompts are empty", () => {
50-
configBuilder.handleGeneralQuestions([], [jest.fn()], { path: "/", noQuestions: false });
50+
configBuilder.handleGeneralQuestions([], [jest.fn()], { path: "/", extraQuestions: true });
5151

5252
expectConfig(defaultHermioneConfig);
5353
});
5454

5555
it("handlers are empty", () => {
5656
configBuilder.handleGeneralQuestions([{ message: "foo", type: "input", name: "bar" }], [], {
5757
path: "/",
58-
noQuestions: false,
58+
extraQuestions: true,
5959
});
6060

6161
expectConfig(defaultHermioneConfig);
6262
});
6363
});
6464

65-
it("should not ask extra questions in 'noQuestions' mode", () => {
65+
it("should not ask extra questions if 'extraQuestions' is not set", () => {
6666
configBuilder.handleGeneralQuestions(
6767
[
6868
{ message: "first silent question", type: "input", name: "1", default: "42" },
6969
{ message: "loud question", type: "input", name: "2" },
7070
{ message: "second silent question", type: "input", name: "3", default: "42" },
7171
],
7272
[jest.fn()],
73-
{ path: "/", noQuestions: true },
73+
{ path: "/", extraQuestions: false },
7474
);
7575

7676
expect(inquirer.prompt).toBeCalledWith([{ message: "loud question", type: "input", name: "2" }]);
@@ -93,7 +93,7 @@ describe("configBuilder", () => {
9393

9494
configBuilder.handleGeneralQuestions(questions, [firstHandler, secondHandler], {
9595
path: "/",
96-
noQuestions: false,
96+
extraQuestions: true,
9797
});
9898
});
9999
});

src/configBuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class ConfigBuilder {
3535
async handleGeneralQuestions(
3636
promts: GeneralPrompt[],
3737
handlers: HandleGeneralPromptsCallback[],
38-
{ path, noQuestions }: { path: string; noQuestions: boolean },
38+
{ path, extraQuestions }: { path: string; extraQuestions: boolean },
3939
): Promise<Answers> {
4040
const answers: Answers = {
4141
_path: path,
@@ -54,7 +54,7 @@ export class ConfigBuilder {
5454
return acc;
5555
}, {});
5656

57-
const promptsToAsk = noQuestions ? promts.filter(prompt => _.isUndefined(prompt.default)) : promts;
57+
const promptsToAsk = extraQuestions ? promts : promts.filter(prompt => _.isUndefined(prompt.default));
5858
const inquirerAnswers = await inquirer.prompt(promptsToAsk);
5959

6060
Object.assign(answers, defaults, inquirerAnswers, answers);

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const run = async ({
5959
const opts = createOpts(defaultToolOpts);
6060
const configBuilder = ConfigBuilder.create(createBaseConfig, { language: opts.language });
6161

62-
const packageManager = await initApp(opts.path, opts.noQuestions);
62+
const packageManager = await initApp(opts.path, opts.extraQuestions);
6363

6464
const generalPromptsHandlers = generalPromptsHandler
6565
? [baseGeneralPromptsHandler, generalPromptsHandler]

src/package.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Colors } from "./utils/colors";
1414
import { askQuestion, packageNameFromPlugin } from "./utils";
1515
import type { PackageManager } from "./constants/packageManagement";
1616

17-
const getPackageManager = async (dirPath: string, noQuestions: boolean): Promise<PackageManager> => {
17+
const getPackageManager = async (dirPath: string, extraQuestions: boolean): Promise<PackageManager> => {
1818
let packageManager: PackageManager | undefined;
1919
const packageManagers = Object.keys(PMS) as PackageManager[];
2020
await Promise.all(
@@ -30,7 +30,7 @@ const getPackageManager = async (dirPath: string, noQuestions: boolean): Promise
3030
return packageManager;
3131
}
3232

33-
if (noQuestions) {
33+
if (!extraQuestions) {
3434
return DEFAULT_PM;
3535
}
3636

@@ -54,7 +54,7 @@ const initNodeProject = (dirPath: string, packageManager: PackageManager): Promi
5454
);
5555
});
5656

57-
export const initApp = async (dirPath: string, noQuestions: boolean): Promise<PackageManager> => {
57+
export const initApp = async (dirPath: string, extraQuestions: boolean): Promise<PackageManager> => {
5858
await fsUtils.ensureDirectory(dirPath);
5959

6060
const isHermioneJsConfigExist = await fsUtils.exists(path.resolve(dirPath, HERMIONE_JS_CONFIG_NAME));
@@ -73,7 +73,7 @@ export const initApp = async (dirPath: string, noQuestions: boolean): Promise<Pa
7373
process.exit(1);
7474
}
7575

76-
const packageManager = await getPackageManager(dirPath, noQuestions);
76+
const packageManager = await getPackageManager(dirPath, extraQuestions);
7777

7878
const isPackageJsonExist = await fsUtils.exists(path.resolve(dirPath, PACKAGE_JSON));
7979
if (!isPackageJsonExist) {

src/plugins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ const askPluginNames = async (opts: ToolOpts): Promise<{ pluginNames: string[];
6363
};
6464

6565
export const getPluginNames = async (opts: ToolOpts): Promise<{ pluginNames: string[]; configNotes: ConfigNote[] }> => {
66-
return opts.noQuestions ? getDefaultPluginNames(opts) : await askPluginNames(opts);
66+
return opts.extraQuestions ? await askPluginNames(opts) : getDefaultPluginNames(opts);
6767
};

src/types/toolArgv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { Language } from "./hermioneConfig";
33
export interface ToolArgv {
44
$0: string;
55
_: string[];
6-
yes?: boolean;
6+
verbose?: boolean;
77
lang?: Language;
88
}

src/types/toolOpts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type HandleGeneralPromptsCallback = (
3333
export interface ArgvOpts {
3434
path: string;
3535
language: Language;
36-
noQuestions: boolean;
36+
extraQuestions: boolean;
3737
}
3838

3939
export interface DefaultOpts {

0 commit comments

Comments
 (0)