Skip to content

Commit c17d17a

Browse files
author
Umed Khudoiberdiev
committed
fixed issues in init command and cli
1 parent d6f6d26 commit c17d17a

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ MyProject
232232
│ │ └── User.ts // sample entity
233233
│ ├── migration // place where your migrations will be stored
234234
│ └── index.ts // start point of your application
235+
├── .gitignore // standard gitignore file
235236
├── ormconfig.json // your database and ORM configuration
236237
├── package.json // your node module dependencies
237238
├── README.md // simple readme file of your project

src/commands/InitCommand.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class InitCommand {
4545
await CommandUtils.createFile(basePath + "/package.json", InitCommand.getPackageJsonTemplate(projectName), false);
4646
if (isDocker)
4747
await CommandUtils.createFile(basePath + "/docker-compose.yml", InitCommand.getDockerComposeTemplate(database), false);
48+
await CommandUtils.createFile(basePath + "/.gitignore", InitCommand.getGitIgnoreFile());
4849
await CommandUtils.createFile(basePath + "/README.md", InitCommand.getReadmeTemplate({ docker: isDocker }), false);
4950
await CommandUtils.createFile(basePath + "/tsconfig.json", InitCommand.getTsConfigTemplate());
5051
await CommandUtils.createFile(basePath + "/ormconfig.json", InitCommand.getOrmConfigTemplate(database));
@@ -82,19 +83,7 @@ export class InitCommand {
8283
* Gets contents of the ormconfig file.
8384
*/
8485
protected static getOrmConfigTemplate(database: string): string {
85-
const options: ObjectLiteral = {
86-
synchronize: true,
87-
logging: false,
88-
entities: [
89-
"src/entity/**/*.ts"
90-
],
91-
migrations: [
92-
"src/migration/**/*.ts"
93-
],
94-
subscribers: [
95-
"src/subscriber/**/*.ts"
96-
]
97-
};
86+
const options: ObjectLiteral = { };
9887
switch (database) {
9988
case "mysql":
10089
Object.assign(options, {
@@ -157,6 +146,19 @@ export class InitCommand {
157146
});
158147
break;
159148
}
149+
Object.assign(options, {
150+
synchronize: true,
151+
logging: false,
152+
entities: [
153+
"src/entity/**/*.ts"
154+
],
155+
migrations: [
156+
"src/migration/**/*.ts"
157+
],
158+
subscribers: [
159+
"src/subscriber/**/*.ts"
160+
]
161+
});
160162
return JSON.stringify(options, undefined, 3);
161163
}
162164

@@ -170,6 +172,7 @@ export class InitCommand {
170172
target: "es5",
171173
module: "commonjs",
172174
moduleResolution: "node",
175+
outDir: "./build",
173176
emitDecoratorMetadata: true,
174177
experimentalDecorators: true,
175178
sourceMap: true
@@ -178,6 +181,18 @@ export class InitCommand {
178181
, undefined, 3);
179182
}
180183

184+
/**
185+
* Gets contents of the .gitignore file.
186+
*/
187+
protected static getGitIgnoreFile(): string {
188+
return `.idea/
189+
.vscode/
190+
node_modules/
191+
build/
192+
tmp/
193+
temp/`;
194+
}
195+
181196
/**
182197
* Gets contents of the user entity.
183198
*/

0 commit comments

Comments
 (0)