Skip to content

Commit 0d42cea

Browse files
author
Peter Ullrich
committed
refactoring to one file one ...
1 parent 647bedf commit 0d42cea

File tree

11 files changed

+71
-58
lines changed

11 files changed

+71
-58
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.9",
2+
"version": "0.1.10",
33
"name": "dotup-typescript-yeoman-generators",
44
"author": {
55
"name": "Peter Ullrich",

src/BaseGenerator.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,12 @@ import { NpmApi, NpmVersion } from 'npm-registry-api';
66
import * as path from 'path';
77
import generator from 'yeoman-generator';
88
// import { Question } from 'yeoman-generator';
9-
import { IStepQuestion } from './IStepQuestion';
9+
import { IStepQuestion } from './questions/IStepQuestion';
1010
import { Project } from './project/Project';
1111
import { ProjectInfo } from './project/ProjectInfo';
1212
import { ProjectPathAnalyser } from './project/ProjectPathAnalyser';
13-
import { Question } from './Question';
14-
15-
interface StringProperty {
16-
[key: string]: string;
17-
}
18-
19-
export type MethodsToRegister<T extends string> = FunctionNamesOnly<Pick<BaseGenerator<T>,
20-
'initializing' | 'prompting' | 'configuring' | 'default' | 'writing' |
21-
'install' | 'end'
22-
>>;
23-
24-
export enum InquirerQuestionType {
25-
input = 'input',
26-
number = 'number',
27-
confirm = 'confirm',
28-
list = 'list',
29-
rawlist = 'rawlist',
30-
password = 'password'
31-
}
32-
33-
export type GeneratorOptions<T extends string> = Partial<TypeSaveProperty<Nested<T, string>>>;
13+
import { Question } from './questions/Question';
14+
import { StringProperty, GeneratorOptions, MethodsToRegister } from './Types';
3415

3516
export abstract class BaseGenerator<TStep extends string> extends generator {
3617

src/Types.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { FunctionNamesOnly, TypeSaveProperty, Nested } from 'dotup-ts-types';
2+
import { BaseGenerator } from './BaseGenerator';
3+
4+
export interface StringProperty {
5+
[key: string]: string;
6+
}
7+
8+
9+
export type MethodsToRegister<T extends string> = FunctionNamesOnly<Pick<BaseGenerator<T>,
10+
'initializing' | 'prompting' | 'configuring' | 'default' | 'writing' |
11+
'install' | 'end'
12+
>>;
13+
14+
export enum InquirerQuestionType {
15+
input = 'input',
16+
number = 'number',
17+
confirm = 'confirm',
18+
list = 'list',
19+
rawlist = 'rawlist',
20+
password = 'password'
21+
}
22+
23+
export type GeneratorOptions<T extends string> = Partial<TypeSaveProperty<Nested<T, string>>>;

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// This is the library entry point
22
export * from './project/index';
3+
export * from './questions/index';
34
export * from './BaseGenerator';
4-
export * from './IStepQuestion';
5-
export * from './Question';
5+
export * from './questions/IStepQuestion';
6+
export * from './questions/Question';
7+
export * from './Types';

src/questions/ConfirmQuestion.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { InquirerQuestionType } from '..';
2+
import { Question } from './Question';
3+
export class ConfirmQuestion<T> extends Question<T> {
4+
constructor(name: string, message: string, store: boolean = true) {
5+
super(name, undefined);
6+
this.store = store;
7+
this.type = InquirerQuestionType.confirm;
8+
this.message = message;
9+
}
10+
}
File renamed without changes.

src/questions/InputQuestion.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Question } from './Question';
2+
import { InquirerQuestionType } from '../Types';
3+
export class InputQuestion<T> extends Question<T> {
4+
constructor(name: string, message: string, store: boolean = true) {
5+
super(name, undefined);
6+
this.store = store;
7+
this.type = InquirerQuestionType.input;
8+
this.message = message;
9+
}
10+
}

src/questions/OptionalQuestion.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Question } from './Question';
2+
export class OptionalQuestion<T> extends Question<T> {
3+
constructor(name: string, props: Partial<Question<T>>) {
4+
super(name, props);
5+
this.isRequired = false;
6+
}
7+
}

src/Question.ts renamed to src/questions/Question.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// tslint:disable: max-classes-per-file
22
import { Answers, ChoiceType } from 'inquirer';
3-
import { InquirerQuestionType } from './BaseGenerator';
43
import { IStepQuestion } from './IStepQuestion';
54

65
export class Question<T> implements IStepQuestion<T> {
@@ -50,35 +49,3 @@ export class Question<T> implements IStepQuestion<T> {
5049

5150
}
5251
}
53-
54-
export class OptionalQuestion<T> extends Question<T> {
55-
constructor(name: string, props: Partial<Question<T>>) {
56-
super(name, props);
57-
this.isRequired = false;
58-
}
59-
}
60-
61-
export class StoreQuestion<T> extends Question<T> {
62-
constructor(name: string, props: Partial<Question<T>>) {
63-
super(name, props);
64-
this.store = true;
65-
}
66-
}
67-
68-
export class InputQuestion<T> extends Question<T> {
69-
constructor(name: string, message: string, store: boolean = true) {
70-
super(name, undefined);
71-
this.store = store;
72-
this.type = InquirerQuestionType.input;
73-
this.message = message;
74-
}
75-
}
76-
77-
export class ConfirmQuestion<T> extends Question<T> {
78-
constructor(name: string, message: string, store: boolean = true) {
79-
super(name, undefined);
80-
this.store = store;
81-
this.type = InquirerQuestionType.confirm;
82-
this.message = message;
83-
}
84-
}

src/questions/StoreQuestion.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Question } from './Question';
2+
export class StoreQuestion<T> extends Question<T> {
3+
constructor(name: string, props: Partial<Question<T>>) {
4+
super(name, props);
5+
this.store = true;
6+
}
7+
}

0 commit comments

Comments
 (0)