Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit bb821cc

Browse files
committed
fix(nestjs-generators): Add time options for change date time of migration generated for new entity
1 parent 26a6b12 commit bb821cc

5 files changed

Lines changed: 30 additions & 20 deletions

File tree

.travis/push-generators-outputs.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@ upload_files() {
1919
git push --quiet --set-upstream origin generators-outputs
2020
}
2121

22-
clear_fixtures(){
23-
rimraf ./test/fixtures
24-
mkdir ./test/fixtures
25-
}
26-
2722
run_generators(){
23+
npm run clear-generators-outputs
2824
npm run run-generators
2925
}
3026

@@ -45,9 +41,9 @@ then
4541
| sed 's/[",]//g')
4642
export PACKAGE_VERSION=$PACKAGE_VERSION
4743

48-
clear_fixtures
4944
move_down
5045
setup_git
46+
move_up
5147
run_generators
5248
move_down
5349
commit_files

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@
103103
"run-new:angular": "node ./bin/run new:angular test/fixtures/angular-new -n demo -u demo -e demo@demo.demo",
104104
"run-entity:angular": "node ./bin/run entity:angular test/fixtures/angular-entity -n demo -u demo -e demo@demo.demo -f [name,title]",
105105
"run-new:nestjs": "node ./bin/run new:nestjs test/fixtures/nestjs-new -n demo -u demo -e demo@demo.demo",
106-
"run-entity:nestjs": "node ./bin/run entity:nestjs test/fixtures/nestjs-entity -n demo -u demo -e demo@demo.demo -f [name,title]",
106+
"run-entity:nestjs": "node ./bin/run entity:nestjs test/fixtures/nestjs-entity -n demo -u demo -e demo@demo.demo -f [name,title] --time=1533634559618",
107107
"run-new": "node ./bin/run new test/fixtures/new -n demo -u demo -e demo@demo.demo",
108108
"run-entity:create-app": "node ./bin/run new test/fixtures/entity -n demo -u demo -e demo@demo.demo",
109-
"run-entity:create-entity": "node ./bin/run entity test/fixtures/entity -n demo -u demo -e demo@demo.demo -f [name,title]",
109+
"run-entity:create-entity": "node ./bin/run entity test/fixtures/entity -n demo -u demo -e demo@demo.demo -f [name,title] --time=1533634559618",
110110
"run-entity": "run-s run-entity:create-app run-entity:create-entity",
111-
"clear-generators-outputs": "run-s run-new:angular run-entity:angular run-new:nestjs run-entity:nestjs run-new run-entity",
112-
"run-generators":"run-s run-new:angular run-entity:angular run-new:nestjs run-entity:nestjs run-new run-entity"
111+
"run-generators": "run-s run-new:angular run-entity:angular run-new:nestjs run-entity:nestjs run-new run-entity",
112+
"clear-generators-outputs": "rimraf test/fixtures/angular-new test/fixtures/angular-entity test/fixtures/nestjs-new test/fixtures/nestjs-entity test/fixtures/new test/fixtures/entity"
113113
},
114114
"greenkeeper": {
115115
"ignore": [

src/commands/entity.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export class Entity extends Command {
1414
email: flags.string({ char: 'e', description: 'email' }),
1515
app: flags.string({ char: 'a', description: 'application name in angular.json and .nestcli.json' }),
1616
core: flags.string({ char: 'c', description: 'core library name in angular.json and .nestcli.json' }),
17-
web: flags.string({ char: 'w', description: 'web library name in angular.json' })
17+
web: flags.string({ char: 'w', description: 'web library name in angular.json' }),
18+
time: flags.string({ description: 'timestamp for create migration (default: current datetime)' })
1819
};
1920
static args = [{ name: 'folder' }];
2021
async run() {
@@ -28,6 +29,7 @@ export class Entity extends Command {
2829
const app = flags.app;
2930
const core = flags.core;
3031
const web = flags.web;
32+
const time = flags.time;
3133
const errorMessage = 'Before create entity, you must create project: rucken new -n demo -u demo -e demo@demo.demo';
3234
let templateBackend = '';
3335
let templateFrontend = '';
@@ -65,7 +67,8 @@ export class Entity extends Command {
6567
username,
6668
email,
6769
app,
68-
core
70+
core,
71+
time
6972
);
7073
} catch (error) {
7174
console.error(error);
@@ -94,7 +97,8 @@ export class Entity extends Command {
9497
username?: string,
9598
email?: string,
9699
app?: string,
97-
core?: string
100+
core?: string,
101+
time?: string
98102
) {
99103
return new Promise(async (resolve, reject) => {
100104
try {
@@ -119,6 +123,10 @@ export class Entity extends Command {
119123
args.push('--core');
120124
args.push(core);
121125
}
126+
if (time) {
127+
args.push('--time');
128+
args.push(time);
129+
}
122130
await NestJSEntity.run(args);
123131
resolve();
124132
} catch (error) {

src/commands/nestjs-entity.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export class NestJSEntity extends Command {
1515
email: flags.string({ char: 'e', description: 'email' }),
1616
app: flags.string({ char: 'a', description: 'application name in .nestcli.json' }),
1717
core: flags.string({ char: 'c', description: 'core library name in .nestcli.json' }),
18+
time: flags.string({ description: 'timestamp for create migration (default: current datetime)' })
1819
};
1920
static args = [{ name: 'folder' }];
2021
async run() {
@@ -27,6 +28,7 @@ export class NestJSEntity extends Command {
2728
const email = flags.email;
2829
const app = flags.app;
2930
const core = flags.core;
31+
const time = flags.time;
3032

3133
try {
3234
await this.runEntity(
@@ -37,7 +39,8 @@ export class NestJSEntity extends Command {
3739
username,
3840
email,
3941
app,
40-
core
42+
core,
43+
time
4144
);
4245
} catch (error) {
4346
console.error(error);
@@ -51,7 +54,8 @@ export class NestJSEntity extends Command {
5154
username?: string,
5255
email?: string,
5356
app?: string,
54-
core?: string
57+
core?: string,
58+
time?: string
5559
) {
5660
this.debug('Start', {
5761
template: template,
@@ -61,7 +65,8 @@ export class NestJSEntity extends Command {
6165
username: username,
6266
email: email,
6367
app: app,
64-
core: core
68+
core: core,
69+
time: time
6570
});
6671
return new Promise((resolve, reject) => {
6772
const inputFolder = folder ? folder.replace(new RegExp('\\' + sep, 'g'), '/').split(sep).join('/') : undefined;
@@ -75,7 +80,8 @@ export class NestJSEntity extends Command {
7580
username: username,
7681
email: email,
7782
app: app,
78-
core: core
83+
core: core,
84+
time: time
7985
}
8086
);
8187
this.debug('command', command);

src/utils/schematics-command-builder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,22 @@ export function schematicsCommandBuilder(
5858
projectSchematicsCli +
5959
' ' + templateFolder + ':' + templateName + ' ' +
6060
argsArray.join(' ') +
61-
'--dry-run=false --force';
61+
' --dry-run=false --force';
6262
}
6363
if (projectNodeModulesCollections['schematics'] && projectNodeModulesCollections['schematics'][templateName]) {
6464
console.log('Founded and used schematics template from project node_modules');
6565
return 'node ' +
6666
projectSchematicsCli +
6767
' ' + templateFolder + ':' + templateName + ' ' +
6868
argsArray.join(' ') +
69-
'--dry-run=false --force';
69+
' --dry-run=false --force';
7070
}
7171
if (localNodeModulesCollections['schematics'] && localNodeModulesCollections['schematics'][templateName]) {
7272
return 'node ' +
7373
localSchematicsCli +
7474
' ' + templateFolder + ':' + templateName + ' ' +
7575
argsArray.join(' ') +
76-
'--dry-run=false --force';
76+
' --dry-run=false --force';
7777
}
7878
throw new Error(`Template with name ${template} not founded`);
7979
}

0 commit comments

Comments
 (0)