@rxdi/schematics 0.7.124 → 0.7.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/application/application.factory.js +4 -4
- package/lib/application/application.factory.test.ts +88 -0
- package/lib/application/application.factory.ts +54 -0
- package/lib/application/application.schema.d.ts +34 -0
- package/lib/application/files/js/.babelrc +4 -0
- package/lib/application/files/js/.prettierrc +4 -0
- package/lib/application/files/js/README.md +37 -0
- package/lib/application/files/js/index.js +3 -0
- package/lib/application/files/js/jsconfig.json +9 -0
- package/lib/application/files/js/nest-cli.json +5 -0
- package/lib/application/files/js/nodemon.json +6 -0
- package/lib/application/files/js/package.json +46 -0
- package/lib/application/files/js/test/app.e2e-spec.js +23 -0
- package/lib/application/files/js/test/jest-e2e.json +5 -0
- package/lib/application/files/ts/.prettierrc +4 -0
- package/lib/application/files/ts/README.md +75 -0
- package/lib/application/files/ts/nest-cli.json +5 -0
- package/lib/application/files/ts/nodemon-debug.json +6 -0
- package/lib/application/files/ts/nodemon.json +6 -0
- package/lib/application/files/ts/package.json +58 -0
- package/lib/application/files/ts/test/app.e2e-spec.ts +23 -0
- package/lib/application/files/ts/test/jest-e2e.json +9 -0
- package/lib/application/files/ts/tsconfig.build.json +4 -0
- package/lib/application/schema.json +49 -0
- package/lib/class/class.factory.js +6 -6
- package/lib/class/class.factory.test.ts +100 -0
- package/lib/class/class.factory.ts +54 -0
- package/lib/class/class.schema.d.ts +28 -0
- package/lib/class/files/js/__name__.js +1 -0
- package/lib/class/files/js/__name__.spec.js +7 -0
- package/lib/class/files/ts/__name__.spec.ts +7 -0
- package/lib/class/files/ts/__name__.ts +1 -0
- package/lib/class/schema.json +39 -0
- package/lib/client-app/angular/angular.factory.js +9 -9
- package/lib/client-app/angular/angular.factory.ts +139 -0
- package/lib/client-app/angular/angular.schema.d.ts +32 -0
- package/lib/client-app/angular/files/angular.constants.ts +4 -0
- package/lib/client-app/angular/files/angular.module.ts +41 -0
- package/lib/client-app/angular/files/angular.providers.ts +27 -0
- package/lib/client-app/angular/files/angular.utils.ts +19 -0
- package/lib/client-app/angular/files/interfaces/angular-options.interface.ts +87 -0
- package/lib/client-app/angular/files/loaders/abstract.loader.ts +16 -0
- package/lib/client-app/angular/files/loaders/express.loader.ts +25 -0
- package/lib/client-app/angular/files/loaders/fastify.loader.ts +34 -0
- package/lib/client-app/angular/files/loaders/noop.loader.ts +12 -0
- package/lib/client-app/angular/schema.json +24 -0
- package/lib/component/component.factory.js +8 -8
- package/lib/component/component.factory.test.ts +191 -0
- package/lib/component/component.factory.ts +91 -0
- package/lib/component/component.schema.d.ts +44 -0
- package/lib/component/files/js/__name__.component.js +56 -0
- package/lib/component/files/js/__name__.component.spec.js +31 -0
- package/lib/component/files/ts/__name__.component.spec.ts +31 -0
- package/lib/component/files/ts/__name__.component.ts +56 -0
- package/lib/component/schema.json +47 -0
- package/lib/configuration/configuration.factory.js +4 -4
- package/lib/configuration/configuration.factory.test.ts +60 -0
- package/lib/configuration/configuration.factory.ts +35 -0
- package/lib/configuration/configuration.schema.d.ts +18 -0
- package/lib/configuration/files/js/nest-cli.json +5 -0
- package/lib/configuration/files/ts/nest-cli.json +5 -0
- package/lib/controller/controller.factory.js +8 -8
- package/lib/controller/controller.factory.test.ts +191 -0
- package/lib/controller/controller.factory.ts +91 -0
- package/lib/controller/controller.schema.d.ts +44 -0
- package/lib/controller/files/js/__name__.controller.js +24 -0
- package/lib/controller/files/js/__name__.controller.spec.js +61 -0
- package/lib/controller/files/ts/__name__.controller.spec.ts +61 -0
- package/lib/controller/files/ts/__name__.controller.ts +24 -0
- package/lib/controller/schema.json +47 -0
- package/lib/decorator/decorator.factory.js +5 -5
- package/lib/decorator/decorator.factory.test.ts +111 -0
- package/lib/decorator/decorator.factory.ts +48 -0
- package/lib/decorator/decorator.schema.d.ts +24 -0
- package/lib/decorator/files/js/__name__.decorator.js +3 -0
- package/lib/decorator/files/ts/__name__.decorator.ts +3 -0
- package/lib/decorator/schema.json +35 -0
- package/lib/defaults.ts +6 -0
- package/lib/effect/effect.factory.js +9 -9
- package/lib/effect/effect.factory.test.ts +190 -0
- package/lib/effect/effect.factory.ts +91 -0
- package/lib/effect/effect.schema.d.ts +44 -0
- package/lib/effect/files/js/__name__.effect.js +11 -0
- package/lib/effect/files/js/__name__.effect.spec.js +17 -0
- package/lib/effect/files/ts/__name__.effect.spec.ts +17 -0
- package/lib/effect/files/ts/__name__.effect.ts +11 -0
- package/lib/effect/schema.json +39 -0
- package/lib/filter/files/js/__name__.filter.js +6 -0
- package/lib/filter/files/js/__name__.filter.spec.js +7 -0
- package/lib/filter/files/ts/__name__.filter.spec.ts +7 -0
- package/lib/filter/files/ts/__name__.filter.ts +6 -0
- package/lib/filter/filter.factory.js +6 -6
- package/lib/filter/filter.factory.test.ts +147 -0
- package/lib/filter/filter.factory.ts +51 -0
- package/lib/filter/filter.schema.d.ts +28 -0
- package/lib/filter/schema.json +39 -0
- package/lib/gateway/files/js/__name__.gateway.js +9 -0
- package/lib/gateway/files/js/__name__.gateway.spec.js +18 -0
- package/lib/gateway/files/ts/__name__.gateway.spec.ts +18 -0
- package/lib/gateway/files/ts/__name__.gateway.ts +9 -0
- package/lib/gateway/gateway.factory.js +8 -8
- package/lib/gateway/gateway.factory.test.ts +147 -0
- package/lib/gateway/gateway.factory.ts +92 -0
- package/lib/gateway/gateway.schema.d.ts +36 -0
- package/lib/gateway/schema.json +39 -0
- package/lib/guard/files/js/__name__.guard.js +17 -0
- package/lib/guard/files/js/__name__.guard.spec.js +7 -0
- package/lib/guard/files/ts/__name__.guard.spec.ts +7 -0
- package/lib/guard/files/ts/__name__.guard.ts +17 -0
- package/lib/guard/guard.factory.js +6 -6
- package/lib/guard/guard.factory.test.ts +156 -0
- package/lib/guard/guard.factory.ts +51 -0
- package/lib/guard/guard.schema.d.ts +28 -0
- package/lib/guard/schema.json +39 -0
- package/lib/interceptor/files/js/__name__.interceptor.js +18 -0
- package/lib/interceptor/files/js/__name__.interceptor.spec.js +7 -0
- package/lib/interceptor/files/ts/__name__.interceptor.spec.ts +7 -0
- package/lib/interceptor/files/ts/__name__.interceptor.ts +19 -0
- package/lib/interceptor/interceptor.factory.js +6 -6
- package/lib/interceptor/interceptor.factory.test.ts +146 -0
- package/lib/interceptor/interceptor.factory.ts +51 -0
- package/lib/interceptor/interceptor.schema.d.ts +28 -0
- package/lib/interceptor/schema.json +39 -0
- package/lib/interface/files/__name__.interface.ts +1 -0
- package/lib/interface/interface.factory.js +5 -5
- package/lib/interface/interface.factory.test.ts +84 -0
- package/lib/interface/interface.factory.ts +47 -0
- package/lib/interface/interface.schema.d.ts +20 -0
- package/lib/interface/schema.json +31 -0
- package/lib/library/files/js/.babelrc +4 -0
- package/lib/library/files/js/jsconfig.json +9 -0
- package/lib/library/files/js/package.json +8 -0
- package/lib/library/files/js/src/__name__.module.js +8 -0
- package/lib/library/files/js/src/__name__.service.js +4 -0
- package/lib/library/files/js/src/__name__.service.spec.js +18 -0
- package/lib/library/files/js/src/index.js +2 -0
- package/lib/library/files/ts/package.json +8 -0
- package/lib/library/files/ts/src/__name__.module.ts +8 -0
- package/lib/library/files/ts/src/__name__.service.spec.ts +18 -0
- package/lib/library/files/ts/src/__name__.service.ts +4 -0
- package/lib/library/files/ts/src/index.ts +2 -0
- package/lib/library/files/ts/tsconfig.lib.json +5 -0
- package/lib/library/library.factory.js +12 -12
- package/lib/library/library.factory.test.ts +68 -0
- package/lib/library/library.factory.ts +158 -0
- package/lib/library/library.schema.d.ts +24 -0
- package/lib/library/schema.json +37 -0
- package/lib/module/files/js/__name__.module.js +4 -0
- package/lib/module/files/ts/__name__.module.ts +4 -0
- package/lib/module/module.factory.js +7 -7
- package/lib/module/module.factory.test.ts +165 -0
- package/lib/module/module.factory.ts +79 -0
- package/lib/module/module.schema.d.ts +36 -0
- package/lib/module/schema.json +40 -0
- package/lib/pipe/files/js/__name__.pipe.js +8 -0
- package/lib/pipe/files/js/__name__.pipe.spec.js +7 -0
- package/lib/pipe/files/ts/__name__.pipe.spec.ts +7 -0
- package/lib/pipe/files/ts/__name__.pipe.ts +8 -0
- package/lib/pipe/pipe.factory.js +6 -6
- package/lib/pipe/pipe.factory.test.ts +141 -0
- package/lib/pipe/pipe.factory.ts +51 -0
- package/lib/pipe/pipe.schema.d.ts +28 -0
- package/lib/pipe/schema.json +39 -0
- package/lib/plugin/files/js/__name__.plugin.js +28 -0
- package/lib/plugin/files/js/__name__.plugin.spec.js +7 -0
- package/lib/plugin/files/ts/__name__.plugin.spec.ts +7 -0
- package/lib/plugin/files/ts/__name__.plugin.ts +28 -0
- package/lib/plugin/plugin.factory.d.ts +2 -2
- package/lib/plugin/plugin.factory.js +1 -2
- package/lib/plugin/plugin.factory.test.ts +191 -0
- package/lib/plugin/plugin.factory.ts +91 -0
- package/lib/plugin/plugin.schema.d.ts +44 -0
- package/lib/plugin/schema.json +52 -0
- package/lib/provider/files/js/__name__.js +4 -0
- package/lib/provider/files/js/__name__.spec.js +17 -0
- package/lib/provider/files/ts/__name__.spec.ts +17 -0
- package/lib/provider/files/ts/__name__.ts +4 -0
- package/lib/provider/provider.factory.js +1 -2
- package/lib/provider/provider.factory.test.ts +151 -0
- package/lib/provider/provider.factory.ts +89 -0
- package/lib/provider/provider.schema.d.ts +44 -0
- package/lib/provider/schema.json +39 -0
- package/lib/resolver/files/js/__name__.resolver.js +4 -0
- package/lib/resolver/files/js/__name__.resolver.spec.js +18 -0
- package/lib/resolver/files/ts/__name__.resolver.spec.ts +18 -0
- package/lib/resolver/files/ts/__name__.resolver.ts +4 -0
- package/lib/resolver/resolver.factory.js +8 -8
- package/lib/resolver/resolver.factory.test.ts +117 -0
- package/lib/resolver/resolver.factory.ts +92 -0
- package/lib/resolver/resolver.schema.d.ts +36 -0
- package/lib/resolver/schema.json +39 -0
- package/lib/service/files/js/__name__.service.js +4 -0
- package/lib/service/files/js/__name__.service.spec.js +17 -0
- package/lib/service/files/ts/__name__.service.spec.ts +17 -0
- package/lib/service/files/ts/__name__.service.ts +4 -0
- package/lib/service/schema.json +39 -0
- package/lib/service/service.factory.js +9 -9
- package/lib/service/service.factory.test.ts +190 -0
- package/lib/service/service.factory.ts +91 -0
- package/lib/service/service.schema.d.ts +44 -0
- package/lib/type/files/js/__name__.type.js +10 -0
- package/lib/type/files/ts/__name__.type.ts +10 -0
- package/lib/type/schema.json +43 -0
- package/lib/type/type.factory.d.ts +1 -1
- package/lib/type/type.factory.js +1 -2
- package/lib/type/type.factory.test.ts +191 -0
- package/lib/type/type.factory.ts +91 -0
- package/lib/type/type.schema.d.ts +44 -0
- package/package.json +2 -2
- package/utils/metadata.manager.js +1 -1
- package/utils/metadata.manager.ts +219 -0
- package/utils/module-import.declarator.js +2 -2
- package/utils/module-import.declarator.ts +41 -0
- package/utils/module-metadata.declarator.ts +14 -0
- package/utils/module.declarator.js +2 -2
- package/utils/module.declarator.ts +41 -0
- package/utils/module.finder.js +1 -1
- package/utils/module.finder.ts +32 -0
- package/utils/name.parser.js +3 -3
- package/utils/name.parser.ts +29 -0
- package/utils/path.solver.js +2 -2
- package/utils/path.solver.ts +17 -0
- package/utils/source-root.helpers.js +2 -2
- package/utils/source-root.helpers.ts +30 -0
|
@@ -6,7 +6,7 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
|
6
6
|
const defaults_1 = require("../defaults");
|
|
7
7
|
function main(options) {
|
|
8
8
|
options = transform(options);
|
|
9
|
-
return schematics_1.mergeWith(generate(options));
|
|
9
|
+
return (0, schematics_1.mergeWith)(generate(options));
|
|
10
10
|
}
|
|
11
11
|
exports.main = main;
|
|
12
12
|
function transform(options) {
|
|
@@ -28,8 +28,8 @@ function transform(options) {
|
|
|
28
28
|
return target;
|
|
29
29
|
}
|
|
30
30
|
function generate(options) {
|
|
31
|
-
return schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
32
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
33
|
-
schematics_1.move(options.name),
|
|
31
|
+
return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
32
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
33
|
+
(0, schematics_1.move)(options.name),
|
|
34
34
|
]);
|
|
35
35
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { ApplicationOptions } from './application.schema';
|
|
4
|
+
|
|
5
|
+
describe('Application Factory', () => {
|
|
6
|
+
const runner: SchematicTestRunner = new SchematicTestRunner(
|
|
7
|
+
'.',
|
|
8
|
+
path.join(process.cwd(), 'src/collection.json'),
|
|
9
|
+
);
|
|
10
|
+
it('should manage name only', () => {
|
|
11
|
+
const options: ApplicationOptions = {
|
|
12
|
+
name: 'project',
|
|
13
|
+
};
|
|
14
|
+
const tree: UnitTestTree = runner.runSchematic('application', options);
|
|
15
|
+
const files: string[] = tree.files;
|
|
16
|
+
expect(files).toEqual([
|
|
17
|
+
'/project/.gitignore',
|
|
18
|
+
'/project/.prettierrc',
|
|
19
|
+
'/project/README.md',
|
|
20
|
+
'/project/nest-cli.json',
|
|
21
|
+
'/project/nodemon-debug.json',
|
|
22
|
+
'/project/nodemon.json',
|
|
23
|
+
'/project/package.json',
|
|
24
|
+
'/project/tsconfig.build.json',
|
|
25
|
+
'/project/tsconfig.json',
|
|
26
|
+
'/project/tslint.json',
|
|
27
|
+
'/project/src/app.controller.spec.ts',
|
|
28
|
+
'/project/src/app.controller.ts',
|
|
29
|
+
'/project/src/app.module.ts',
|
|
30
|
+
'/project/src/app.service.ts',
|
|
31
|
+
'/project/src/main.ts',
|
|
32
|
+
'/project/test/app.e2e-spec.ts',
|
|
33
|
+
'/project/test/jest-e2e.json',
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
it('should manage name to dasherize', () => {
|
|
37
|
+
const options: ApplicationOptions = {
|
|
38
|
+
name: 'awesomeProject',
|
|
39
|
+
};
|
|
40
|
+
const tree: UnitTestTree = runner.runSchematic('application', options);
|
|
41
|
+
const files: string[] = tree.files;
|
|
42
|
+
expect(files).toEqual([
|
|
43
|
+
'/awesome-project/.gitignore',
|
|
44
|
+
'/awesome-project/.prettierrc',
|
|
45
|
+
'/awesome-project/README.md',
|
|
46
|
+
'/awesome-project/nest-cli.json',
|
|
47
|
+
'/awesome-project/nodemon-debug.json',
|
|
48
|
+
'/awesome-project/nodemon.json',
|
|
49
|
+
'/awesome-project/package.json',
|
|
50
|
+
'/awesome-project/tsconfig.build.json',
|
|
51
|
+
'/awesome-project/tsconfig.json',
|
|
52
|
+
'/awesome-project/tslint.json',
|
|
53
|
+
'/awesome-project/src/app.controller.spec.ts',
|
|
54
|
+
'/awesome-project/src/app.controller.ts',
|
|
55
|
+
'/awesome-project/src/app.module.ts',
|
|
56
|
+
'/awesome-project/src/app.service.ts',
|
|
57
|
+
'/awesome-project/src/main.ts',
|
|
58
|
+
'/awesome-project/test/app.e2e-spec.ts',
|
|
59
|
+
'/awesome-project/test/jest-e2e.json',
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
it('should manage javascript files', () => {
|
|
63
|
+
const options: ApplicationOptions = {
|
|
64
|
+
name: 'project',
|
|
65
|
+
language: 'js',
|
|
66
|
+
};
|
|
67
|
+
const tree: UnitTestTree = runner.runSchematic('application', options);
|
|
68
|
+
const files: string[] = tree.files;
|
|
69
|
+
expect(files).toEqual([
|
|
70
|
+
'/project/.babelrc',
|
|
71
|
+
'/project/.gitignore',
|
|
72
|
+
'/project/.prettierrc',
|
|
73
|
+
'/project/README.md',
|
|
74
|
+
'/project/index.js',
|
|
75
|
+
'/project/jsconfig.json',
|
|
76
|
+
'/project/nest-cli.json',
|
|
77
|
+
'/project/nodemon.json',
|
|
78
|
+
'/project/package.json',
|
|
79
|
+
'/project/src/app.controller.js',
|
|
80
|
+
'/project/src/app.controller.spec.js',
|
|
81
|
+
'/project/src/app.module.js',
|
|
82
|
+
'/project/src/app.service.js',
|
|
83
|
+
'/project/src/main.js',
|
|
84
|
+
'/project/test/app.e2e-spec.js',
|
|
85
|
+
'/project/test/jest-e2e.json',
|
|
86
|
+
]);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { join, Path, strings } from '@angular-devkit/core';
|
|
2
|
+
import {
|
|
3
|
+
apply,
|
|
4
|
+
mergeWith,
|
|
5
|
+
move,
|
|
6
|
+
Rule,
|
|
7
|
+
SchematicsException,
|
|
8
|
+
Source,
|
|
9
|
+
template,
|
|
10
|
+
url,
|
|
11
|
+
} from '@angular-devkit/schematics';
|
|
12
|
+
import {
|
|
13
|
+
DEFAULT_AUTHOR,
|
|
14
|
+
DEFAULT_DESCRIPTION,
|
|
15
|
+
DEFAULT_LANGUAGE,
|
|
16
|
+
DEFAULT_VERSION,
|
|
17
|
+
} from '../defaults';
|
|
18
|
+
import { ApplicationOptions } from './application.schema';
|
|
19
|
+
|
|
20
|
+
export function main(options: ApplicationOptions): Rule {
|
|
21
|
+
options = transform(options);
|
|
22
|
+
return mergeWith(generate(options));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function transform(options: ApplicationOptions): ApplicationOptions {
|
|
26
|
+
const target: ApplicationOptions = Object.assign({}, options);
|
|
27
|
+
|
|
28
|
+
target.author = !!target.author ? target.author : DEFAULT_AUTHOR;
|
|
29
|
+
target.description = !!target.description
|
|
30
|
+
? target.description
|
|
31
|
+
: DEFAULT_DESCRIPTION;
|
|
32
|
+
target.language = !!target.language ? target.language : DEFAULT_LANGUAGE;
|
|
33
|
+
target.name = strings.dasherize(target.name);
|
|
34
|
+
target.version = !!target.version ? target.version : DEFAULT_VERSION;
|
|
35
|
+
|
|
36
|
+
target.packageManager = !!target.packageManager
|
|
37
|
+
? target.packageManager
|
|
38
|
+
: 'npm';
|
|
39
|
+
target.dependencies = !!target.dependencies ? target.dependencies : '';
|
|
40
|
+
target.devDependencies = !!target.devDependencies
|
|
41
|
+
? target.devDependencies
|
|
42
|
+
: '';
|
|
43
|
+
return target;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function generate(options: ApplicationOptions): Source {
|
|
47
|
+
return apply(url(join('./files' as Path, options.language)), [
|
|
48
|
+
template({
|
|
49
|
+
...strings,
|
|
50
|
+
...options,
|
|
51
|
+
}),
|
|
52
|
+
move(options.name),
|
|
53
|
+
]);
|
|
54
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface ApplicationOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The Nest application name.
|
|
4
|
+
*/
|
|
5
|
+
name: string;
|
|
6
|
+
/**
|
|
7
|
+
* The Nest application author.
|
|
8
|
+
*/
|
|
9
|
+
author?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The Nest application description.
|
|
12
|
+
*/
|
|
13
|
+
description?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The Nest application version.
|
|
16
|
+
*/
|
|
17
|
+
version?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Application language.
|
|
20
|
+
*/
|
|
21
|
+
language?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The used package manager.
|
|
24
|
+
*/
|
|
25
|
+
packageManager?: 'npm' | 'yarn';
|
|
26
|
+
/**
|
|
27
|
+
* The Nest included production dependencies (comma separated values).
|
|
28
|
+
*/
|
|
29
|
+
dependencies?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The Nest included development dependencies (comma separated values).
|
|
32
|
+
*/
|
|
33
|
+
devDependencies?: string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# <%= name %>
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
<%= description %>
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ <%= packageManager %> install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Running the app
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# development
|
|
17
|
+
$ <%= packageManager %> run start
|
|
18
|
+
|
|
19
|
+
# watch mode
|
|
20
|
+
$ <%= packageManager %> run start:dev
|
|
21
|
+
|
|
22
|
+
# production mode
|
|
23
|
+
<%= packageManager %> run start:prod
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Test
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# unit tests
|
|
30
|
+
$ <%= packageManager %> run test
|
|
31
|
+
|
|
32
|
+
# e2e tests
|
|
33
|
+
$ <%= packageManager %> run test:e2e
|
|
34
|
+
|
|
35
|
+
# test coverage
|
|
36
|
+
$ <%= packageManager %> run test:cov
|
|
37
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= name %>",
|
|
3
|
+
"version": "<%= version %>",
|
|
4
|
+
"description": "<%= description %>",
|
|
5
|
+
"author": "<%= author %>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"format": "prettier --write \"**/*.js\"",
|
|
9
|
+
"start": "babel-node index.js",
|
|
10
|
+
"start:dev": "nodemon",
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"test:cov": "jest --coverage",
|
|
13
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@nestjs/common": "^6.0.0",
|
|
17
|
+
"@nestjs/core": "^6.0.0",
|
|
18
|
+
"@nestjs/platform-express": "^6.0.0", <% if (dependencies.indexOf('microservices') !== -1) { %>
|
|
19
|
+
"@nestjs/microservices": "^6.0.0", <% } %><% if (dependencies.indexOf('websockets') !== -1) { %>
|
|
20
|
+
"@nestjs/websockets": "^6.0.0", <% } %>
|
|
21
|
+
"reflect-metadata": "^0.1.12",
|
|
22
|
+
"rxjs": "^6.4.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@nestjs/testing": "^6.0.0",
|
|
26
|
+
"babel-cli": "^6.26.0",
|
|
27
|
+
"babel-core": "^6.26.0",
|
|
28
|
+
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
|
29
|
+
"babel-polyfill": "^6.26.0",
|
|
30
|
+
"babel-preset-env": "^1.6.0",
|
|
31
|
+
"babel-preset-stage-0": "^6.24.1",
|
|
32
|
+
"jest": "^22.4.3",
|
|
33
|
+
"nodemon": "^1.14.1",
|
|
34
|
+
"prettier": "^1.11.1",
|
|
35
|
+
"supertest": "^3.0.0"
|
|
36
|
+
},
|
|
37
|
+
"jest": {
|
|
38
|
+
"moduleFileExtensions": [
|
|
39
|
+
"js",
|
|
40
|
+
"json"
|
|
41
|
+
],
|
|
42
|
+
"rootDir": "src",
|
|
43
|
+
"testRegex": ".spec.js$",
|
|
44
|
+
"coverageDirectory": "../coverage"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Test } from '@nestjs/testing';
|
|
2
|
+
import * as request from 'supertest';
|
|
3
|
+
import { AppModule } from '../src/app.module';
|
|
4
|
+
|
|
5
|
+
describe('AppController (e2e)', () => {
|
|
6
|
+
let app;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
const moduleFixture = await Test.createTestingModule({
|
|
10
|
+
imports: [AppModule],
|
|
11
|
+
}).compile();
|
|
12
|
+
|
|
13
|
+
app = moduleFixture.createNestApplication();
|
|
14
|
+
await app.init();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('/ (GET)', () => {
|
|
18
|
+
return request(app.getHttpServer())
|
|
19
|
+
.get('/')
|
|
20
|
+
.expect(200)
|
|
21
|
+
.expect('Hello World!');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
|
|
6
|
+
[travis-url]: https://travis-ci.org/nestjs/nest
|
|
7
|
+
[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
|
|
8
|
+
[linux-url]: https://travis-ci.org/nestjs/nest
|
|
9
|
+
|
|
10
|
+
<p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
|
14
|
+
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
|
15
|
+
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
|
16
|
+
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
|
17
|
+
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
|
|
18
|
+
<a href="https://gitter.im/nestjs/nestjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"><img src="https://badges.gitter.im/nestjs/nestjs.svg" alt="Gitter" /></a>
|
|
19
|
+
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
|
20
|
+
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
|
21
|
+
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
|
|
22
|
+
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
|
23
|
+
</p>
|
|
24
|
+
<!--[](https://opencollective.com/nest#backer)
|
|
25
|
+
[](https://opencollective.com/nest#sponsor)-->
|
|
26
|
+
|
|
27
|
+
## Description
|
|
28
|
+
|
|
29
|
+
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
$ <%= packageManager %> install
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Running the app
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# development
|
|
41
|
+
$ <%= packageManager %> run start
|
|
42
|
+
|
|
43
|
+
# watch mode
|
|
44
|
+
$ <%= packageManager %> run start:dev
|
|
45
|
+
|
|
46
|
+
# production mode
|
|
47
|
+
$ <%= packageManager %> run start:prod
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Test
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# unit tests
|
|
54
|
+
$ <%= packageManager %> run test
|
|
55
|
+
|
|
56
|
+
# e2e tests
|
|
57
|
+
$ <%= packageManager %> run test:e2e
|
|
58
|
+
|
|
59
|
+
# test coverage
|
|
60
|
+
$ <%= packageManager %> run test:cov
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Support
|
|
64
|
+
|
|
65
|
+
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
|
66
|
+
|
|
67
|
+
## Stay in touch
|
|
68
|
+
|
|
69
|
+
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
|
70
|
+
- Website - [https://nestjs.com](https://nestjs.com/)
|
|
71
|
+
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
Nest is [MIT licensed](LICENSE).
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= name %>",
|
|
3
|
+
"version": "<%= version %>",
|
|
4
|
+
"description": "<%= description %>",
|
|
5
|
+
"author": "<%= author %>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc -p tsconfig.build.json",
|
|
9
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
10
|
+
"start": "ts-node -r tsconfig-paths/register src/main.ts",
|
|
11
|
+
"start:dev": "nodemon",
|
|
12
|
+
"start:debug": "nodemon --config nodemon-debug.json",
|
|
13
|
+
"prestart:prod": "rimraf dist && npm run build",
|
|
14
|
+
"start:prod": "node dist/main.js",
|
|
15
|
+
"lint": "tslint -p tsconfig.json -c tslint.json",
|
|
16
|
+
"test": "jest",
|
|
17
|
+
"test:watch": "jest --watch",
|
|
18
|
+
"test:cov": "jest --coverage",
|
|
19
|
+
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
20
|
+
"test:e2e": "jest --config ./test/jest-e2e.json"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@nestjs/common": "^6.0.0",
|
|
24
|
+
"@nestjs/core": "^6.0.0",
|
|
25
|
+
"@nestjs/platform-express": "^6.0.0", <% if (dependencies.indexOf('microservices') !== -1) { %>
|
|
26
|
+
"@nestjs/microservices": "^6.0.0", <% } %><% if (dependencies.indexOf('websockets') !== -1) { %>
|
|
27
|
+
"@nestjs/websockets": "^6.0.0", <% } %>
|
|
28
|
+
"reflect-metadata": "^0.1.12",
|
|
29
|
+
"rimraf": "^2.6.2",
|
|
30
|
+
"rxjs": "^6.4.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/express": "^4.16.0",
|
|
34
|
+
"@types/jest": "^23.3.13",
|
|
35
|
+
"@types/node": "^10.12.18",
|
|
36
|
+
"@types/supertest": "^2.0.7",
|
|
37
|
+
"@nestjs/testing": "^6.0.0",
|
|
38
|
+
"jest": "^23.6.0",
|
|
39
|
+
"nodemon": "^1.18.9",
|
|
40
|
+
"prettier": "^1.15.3",
|
|
41
|
+
"supertest": "^3.4.1",
|
|
42
|
+
"ts-jest": "^23.10.5",
|
|
43
|
+
"ts-node": "^7.0.1",
|
|
44
|
+
"tsconfig-paths": "^3.7.0",
|
|
45
|
+
"tslint": "5.12.1",
|
|
46
|
+
"typescript": "^3.2.4"
|
|
47
|
+
},
|
|
48
|
+
"jest": {
|
|
49
|
+
"moduleFileExtensions": ["js", "json", "ts"],
|
|
50
|
+
"rootDir": "src",
|
|
51
|
+
"testRegex": ".spec.ts$",
|
|
52
|
+
"transform": {
|
|
53
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
54
|
+
},
|
|
55
|
+
"coverageDirectory": "../coverage",
|
|
56
|
+
"testEnvironment": "node"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Test, TestingModule } from '@nestjs/testing';
|
|
2
|
+
import * as request from 'supertest';
|
|
3
|
+
import { AppModule } from './../src/app.module';
|
|
4
|
+
|
|
5
|
+
describe('AppController (e2e)', () => {
|
|
6
|
+
let app;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
const moduleFixture: TestingModule = await Test.createTestingModule({
|
|
10
|
+
imports: [AppModule],
|
|
11
|
+
}).compile();
|
|
12
|
+
|
|
13
|
+
app = moduleFixture.createNestApplication();
|
|
14
|
+
await app.init();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('/ (GET)', () => {
|
|
18
|
+
return request(app.getHttpServer())
|
|
19
|
+
.get('/')
|
|
20
|
+
.expect(200)
|
|
21
|
+
.expect('Hello World!');
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"id": "SchematicsNestApplication",
|
|
4
|
+
"title": "Nest Application Options Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the application.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
},
|
|
14
|
+
"x-prompt": "What name would you like to use for the new project?"
|
|
15
|
+
},
|
|
16
|
+
"author": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Nest application author.",
|
|
19
|
+
"default": ""
|
|
20
|
+
},
|
|
21
|
+
"description": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Nest application description.",
|
|
24
|
+
"default": ""
|
|
25
|
+
},
|
|
26
|
+
"version": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "Nest application version.",
|
|
29
|
+
"default": "0.0.1"
|
|
30
|
+
},
|
|
31
|
+
"language": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "Nest application language."
|
|
34
|
+
},
|
|
35
|
+
"packageManager": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Nest application package manager."
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "Nest application dependencies."
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Nest application development dependencies."
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"required": ["name"]
|
|
49
|
+
}
|
|
@@ -8,7 +8,7 @@ const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
|
8
8
|
const defaults_1 = require("../defaults");
|
|
9
9
|
function main(options) {
|
|
10
10
|
options = transform(options);
|
|
11
|
-
return schematics_1.chain([source_root_helpers_1.mergeSourceRoot(options), schematics_1.mergeWith(generate(options))]);
|
|
11
|
+
return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
|
|
12
12
|
}
|
|
13
13
|
exports.main = main;
|
|
14
14
|
function transform(options) {
|
|
@@ -23,13 +23,13 @@ function transform(options) {
|
|
|
23
23
|
target.path = core_1.strings.dasherize(location.path);
|
|
24
24
|
target.path = target.flat
|
|
25
25
|
? target.path
|
|
26
|
-
: core_1.join(target.path, target.name);
|
|
26
|
+
: (0, core_1.join)(target.path, target.name);
|
|
27
27
|
return target;
|
|
28
28
|
}
|
|
29
29
|
function generate(options) {
|
|
30
|
-
return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
31
|
-
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
|
|
32
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
33
|
-
schematics_1.move(options.path),
|
|
30
|
+
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
31
|
+
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
|
|
32
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
33
|
+
(0, schematics_1.move)(options.path),
|
|
34
34
|
])(context);
|
|
35
35
|
}
|