mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
fixed issues in init command and cli
This commit is contained in:
parent
d6f6d26a0c
commit
c17d17ac36
@ -232,6 +232,7 @@ MyProject
|
||||
│ │ └── User.ts // sample entity
|
||||
│ ├── migration // place where your migrations will be stored
|
||||
│ └── index.ts // start point of your application
|
||||
├── .gitignore // standard gitignore file
|
||||
├── ormconfig.json // your database and ORM configuration
|
||||
├── package.json // your node module dependencies
|
||||
├── README.md // simple readme file of your project
|
||||
|
||||
@ -45,6 +45,7 @@ export class InitCommand {
|
||||
await CommandUtils.createFile(basePath + "/package.json", InitCommand.getPackageJsonTemplate(projectName), false);
|
||||
if (isDocker)
|
||||
await CommandUtils.createFile(basePath + "/docker-compose.yml", InitCommand.getDockerComposeTemplate(database), false);
|
||||
await CommandUtils.createFile(basePath + "/.gitignore", InitCommand.getGitIgnoreFile());
|
||||
await CommandUtils.createFile(basePath + "/README.md", InitCommand.getReadmeTemplate({ docker: isDocker }), false);
|
||||
await CommandUtils.createFile(basePath + "/tsconfig.json", InitCommand.getTsConfigTemplate());
|
||||
await CommandUtils.createFile(basePath + "/ormconfig.json", InitCommand.getOrmConfigTemplate(database));
|
||||
@ -82,19 +83,7 @@ export class InitCommand {
|
||||
* Gets contents of the ormconfig file.
|
||||
*/
|
||||
protected static getOrmConfigTemplate(database: string): string {
|
||||
const options: ObjectLiteral = {
|
||||
synchronize: true,
|
||||
logging: false,
|
||||
entities: [
|
||||
"src/entity/**/*.ts"
|
||||
],
|
||||
migrations: [
|
||||
"src/migration/**/*.ts"
|
||||
],
|
||||
subscribers: [
|
||||
"src/subscriber/**/*.ts"
|
||||
]
|
||||
};
|
||||
const options: ObjectLiteral = { };
|
||||
switch (database) {
|
||||
case "mysql":
|
||||
Object.assign(options, {
|
||||
@ -157,6 +146,19 @@ export class InitCommand {
|
||||
});
|
||||
break;
|
||||
}
|
||||
Object.assign(options, {
|
||||
synchronize: true,
|
||||
logging: false,
|
||||
entities: [
|
||||
"src/entity/**/*.ts"
|
||||
],
|
||||
migrations: [
|
||||
"src/migration/**/*.ts"
|
||||
],
|
||||
subscribers: [
|
||||
"src/subscriber/**/*.ts"
|
||||
]
|
||||
});
|
||||
return JSON.stringify(options, undefined, 3);
|
||||
}
|
||||
|
||||
@ -170,6 +172,7 @@ export class InitCommand {
|
||||
target: "es5",
|
||||
module: "commonjs",
|
||||
moduleResolution: "node",
|
||||
outDir: "./build",
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
sourceMap: true
|
||||
@ -178,6 +181,18 @@ export class InitCommand {
|
||||
, undefined, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets contents of the .gitignore file.
|
||||
*/
|
||||
protected static getGitIgnoreFile(): string {
|
||||
return `.idea/
|
||||
.vscode/
|
||||
node_modules/
|
||||
build/
|
||||
tmp/
|
||||
temp/`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets contents of the user entity.
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user