Skip to content

Commit 0f2c9a1

Browse files
committed
🔥 Remove it option
Now detected depending on environment (test or CI)
1 parent 371d20a commit 0f2c9a1

File tree

4 files changed

+33
-66
lines changed

4 files changed

+33
-66
lines changed

libs/create-qwikdev-astro/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
| Name | Description |
4545
| :--------------------------------------| :----------------------------------------|
4646
| `--help` (`-h`) | Display available flags. |
47-
| `--it` | Execute actions interactively. |
4847
| `--dry-run` | Walk through steps without executing. |
4948
| `--force` / `--no-force` (`-f` / `--no-f`) | Overwrite target directory if it exists. |
5049
| `--add` / `--no-add` (`-a` / `--no-a`) | Add QwikDev/astro to existing project. |
@@ -70,7 +69,7 @@
7069
```typescript
7170
import { run } from '@qwikdev/create-astro';
7271
73-
run(["./qwik-astro-app", "node", "--it"]);
72+
run(["./qwik-astro-app", "node"]);
7473
```
7574
7675
**Definition type:**
@@ -87,7 +86,6 @@
8786
ci?: boolean;
8887
yes?: boolean;
8988
no?: boolean;
90-
it?: boolean;
9189
dryRun?: boolean;
9290
};
9391
```
@@ -104,7 +102,6 @@ export const defaultDefinition = {
104102
biome: undefined,
105103
git: undefined,
106104
ci: undefined,
107-
it: undefined,
108105
yes: undefined,
109106
no: undefined,
110107
dryRun: undefined

libs/create-qwikdev-astro/src/app.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const defaultDefinition = {
4242
biome: undefined,
4343
git: undefined,
4444
ci: undefined,
45-
it: undefined,
4645
yes: undefined,
4746
no: undefined,
4847
dryRun: undefined,
@@ -51,7 +50,7 @@ export const defaultDefinition = {
5150

5251
export type Adapter = "node" | "deno" | "none";
5352

54-
export type Input = Required<Omit<Definition, "it" | "yes" | "no">> & {
53+
export type Input = Required<Omit<Definition, "yes" | "no">> & {
5554
outDir: string;
5655
packageName: string;
5756
};
@@ -166,7 +165,6 @@ export class Application extends Program<Definition, Input> {
166165
const destination =
167166
definition.destination === defaultDefinition.destination
168167
? await this.scanString(
169-
definition,
170168
`Where would you like to create your new project? ${this.gray(
171169
`(Use '.' or './' for current directory)`
172170
)}`,
@@ -211,7 +209,6 @@ export class Application extends Program<Definition, Input> {
211209
false
212210
)) &&
213211
(await this.scanChoice(
214-
definition,
215212
"Which adapter do you prefer?",
216213
[
217214
{
@@ -273,7 +270,6 @@ export class Application extends Program<Definition, Input> {
273270
packageName = definition.yes
274271
? packageName
275272
: await this.scanString(
276-
definition,
277273
"What should be the name of this package?",
278274
exists && !force ? (getPackageJson(outDir).name ?? packageName) : packageName
279275
);

libs/create-qwikdev-astro/src/core.ts

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export class Command {
134134
}
135135

136136
export type Definition = {
137-
it?: boolean;
138137
yes?: boolean;
139138
no?: boolean;
140139
};
@@ -180,13 +179,6 @@ export abstract class Program<
180179
});
181180
}
182181

183-
if (this.#interactive) {
184-
_command.option("it", {
185-
type: "boolean",
186-
desc: "Execute actions interactively"
187-
});
188-
}
189-
190182
this.commands.add(_command);
191183

192184
return _command;
@@ -283,7 +275,7 @@ export abstract class Program<
283275

284276
let input: U;
285277

286-
if (this.isIt(definition)) {
278+
if (this.isIt()) {
287279
input = await this.interact(definition);
288280
} else {
289281
input = this.validate(definition);
@@ -292,8 +284,8 @@ export abstract class Program<
292284
return await this.execute(input);
293285
}
294286

295-
isIt(definition: T): boolean {
296-
return this.#interactive && (definition.it || !(isTest() || isCI()));
287+
isIt(): boolean {
288+
return this.#interactive && !(isTest() || isCI());
297289
}
298290

299291
abstract validate(definition: T): U;
@@ -400,13 +392,11 @@ export abstract class Program<
400392
definition: T,
401393
message: string
402394
): Promise<
403-
typeof definition.it extends true
404-
? boolean
405-
: typeof definition.no extends true
406-
? false
407-
: typeof definition.yes extends true
408-
? true
409-
: undefined
395+
typeof definition.no extends true
396+
? false
397+
: typeof definition.yes extends true
398+
? true
399+
: undefined
410400
>;
411401
async scanBoolean(
412402
definition: T,
@@ -417,20 +407,18 @@ export abstract class Program<
417407
? false
418408
: typeof definition.yes extends true
419409
? true
420-
: typeof initialValue
410+
: boolean
421411
>;
422412
async scanBoolean(
423413
definition: T,
424414
message: string,
425415
initialValue?: boolean
426416
): Promise<
427-
typeof definition.it extends true
428-
? boolean
429-
: typeof definition.no extends true
430-
? false
431-
: typeof definition.yes extends true
432-
? true
433-
: typeof initialValue
417+
typeof definition.no extends true
418+
? false
419+
: typeof definition.yes extends true
420+
? true
421+
: typeof initialValue
434422
> {
435423
const value = this.getInteraction(message);
436424

@@ -444,29 +432,25 @@ export abstract class Program<
444432
? scanBoolean(
445433
message,
446434
initialValue,
447-
this.isIt(definition),
435+
this.isIt(),
448436
this.#useYes && definition.yes,
449437
this.#useNo && definition.no
450438
)
451439
: scanBoolean(
452440
message,
453441
undefined,
454-
this.isIt(definition),
442+
this.isIt(),
455443
this.#useYes && definition.yes,
456444
this.#useNo && definition.no
457445
);
458446
}
459447

448+
async scanString(message: string): Promise<string | undefined>;
449+
async scanString(message: string, initialValue: string): Promise<string>;
460450
async scanString(
461-
definition: T,
462-
message: string
463-
): Promise<typeof definition.it extends true ? string : undefined>;
464-
async scanString(definition: T, message: string, initialValue: string): Promise<string>;
465-
async scanString(
466-
definition: T,
467451
message: string,
468452
initialValue?: string
469-
): Promise<typeof definition.it extends true ? string : typeof initialValue> {
453+
): Promise<string | typeof initialValue> {
470454
const value = this.getInteraction(message);
471455

472456
if (value !== undefined) {
@@ -476,27 +460,24 @@ export abstract class Program<
476460
}
477461

478462
return initialValue
479-
? scanString(message, initialValue, this.isIt(definition))
480-
: scanString(message, undefined, this.isIt(definition));
463+
? scanString(message, initialValue, this.isIt())
464+
: scanString(message, undefined, this.isIt());
481465
}
482466

483467
async scanChoice<V extends string>(
484-
definition: T,
485468
message: string,
486469
options: { value: string; label: string }[]
487-
): Promise<typeof definition.it extends true ? V : undefined>;
470+
): Promise<V | undefined>;
488471
async scanChoice<V extends string>(
489-
definition: T,
490472
message: string,
491473
options: { value: string; label: string }[],
492474
initialValue: V
493-
): Promise<typeof definition.it extends true ? V : undefined>;
475+
): Promise<V>;
494476
async scanChoice<V extends string>(
495-
definition: T,
496477
message: string,
497478
options: { value: string; label: string }[],
498479
initialValue?: V
499-
): Promise<typeof definition.it extends true ? V : typeof initialValue> {
480+
): Promise<V | typeof initialValue> {
500481
const value = this.getInteraction(message);
501482

502483
if (value !== undefined) {
@@ -509,8 +490,8 @@ export abstract class Program<
509490
}
510491

511492
return initialValue
512-
? scanChoice(message, options, initialValue, this.isIt(definition))
513-
: scanChoice(message, options, undefined, this.isIt(definition));
493+
? scanChoice(message, options, initialValue, this.isIt())
494+
: scanChoice(message, options, undefined, this.isIt());
514495
}
515496

516497
panic(message: string): never {

libs/create-qwikdev-astro/src/tester.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ export class ProgramTester<
1515
return this;
1616
}
1717

18-
async scanString(
19-
definition: T,
20-
message: string,
21-
initialValue?: string
22-
): Promise<ValueTester> {
23-
definition.it = false;
24-
18+
async scanString(message: string, initialValue?: string): Promise<ValueTester> {
2519
const value =
2620
initialValue === undefined
27-
? await this.program.scanString(definition, message)
28-
: await this.program.scanString(definition, message, initialValue);
21+
? await this.program.scanString(message)
22+
: await this.program.scanString(message, initialValue);
2923

3024
return new ValueTester(value);
3125
}
@@ -44,15 +38,14 @@ export class ProgramTester<
4438
}
4539

4640
async scanChoice(
47-
definition: T,
4841
message: string,
4942
options: { value: string; label: string }[],
5043
initialValue?: string
5144
): Promise<ValueTester> {
5245
const value =
5346
initialValue === undefined
54-
? await this.program.scanChoice(definition, message, options)
55-
: await this.program.scanChoice(definition, message, options, initialValue);
47+
? await this.program.scanChoice(message, options)
48+
: await this.program.scanChoice(message, options, initialValue);
5649

5750
return new ValueTester(value);
5851
}

0 commit comments

Comments
 (0)