@rxdi/schematics 0.7.190 → 0.7.191-nightly.1
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/component/component.factory.js +1 -2
- package/lib/controller/controller.factory.js +1 -2
- package/lib/effect/effect.factory.js +2 -4
- package/lib/effect/effect.factory.ts +1 -2
- package/lib/guard/guard.factory.js +1 -2
- package/lib/interceptor/interceptor.factory.js +1 -2
- package/lib/module/module.factory.js +1 -2
- package/lib/service/service.factory.js +2 -4
- package/lib/service/service.factory.ts +1 -2
- package/package.json +8 -8
- package/utils/source-root.helpers.js +2 -3
- package/lib/application/application.factory.d.ts +0 -3
- package/lib/application/application.factory.js +0 -35
- package/lib/application/application.factory.test.ts +0 -88
- package/lib/application/application.factory.ts +0 -54
- package/lib/application/application.schema.d.ts +0 -34
- package/lib/application/files/js/.babelrc +0 -4
- package/lib/application/files/js/.prettierrc +0 -4
- package/lib/application/files/js/README.md +0 -37
- package/lib/application/files/js/index.js +0 -3
- package/lib/application/files/js/jsconfig.json +0 -9
- package/lib/application/files/js/nest-cli.json +0 -5
- package/lib/application/files/js/nodemon.json +0 -6
- package/lib/application/files/js/package.json +0 -46
- package/lib/application/files/js/test/app.e2e-spec.js +0 -23
- package/lib/application/files/js/test/jest-e2e.json +0 -5
- package/lib/application/files/ts/.prettierrc +0 -4
- package/lib/application/files/ts/README.md +0 -75
- package/lib/application/files/ts/nest-cli.json +0 -5
- package/lib/application/files/ts/nodemon-debug.json +0 -6
- package/lib/application/files/ts/nodemon.json +0 -6
- package/lib/application/files/ts/package.json +0 -58
- package/lib/application/files/ts/test/app.e2e-spec.ts +0 -23
- package/lib/application/files/ts/test/jest-e2e.json +0 -9
- package/lib/application/files/ts/tsconfig.build.json +0 -4
- package/lib/application/schema.json +0 -49
- package/lib/class/class.factory.d.ts +0 -3
- package/lib/class/class.factory.js +0 -35
- package/lib/class/class.factory.test.ts +0 -100
- package/lib/class/class.factory.ts +0 -54
- package/lib/class/class.schema.d.ts +0 -28
- package/lib/class/files/js/__name__.js +0 -1
- package/lib/class/files/js/__name__.spec.js +0 -7
- package/lib/class/files/ts/__name__.spec.ts +0 -7
- package/lib/class/files/ts/__name__.ts +0 -1
- package/lib/class/schema.json +0 -39
- package/lib/client-app/angular/angular.factory.d.ts +0 -3
- package/lib/client-app/angular/angular.factory.js +0 -97
- package/lib/client-app/angular/angular.factory.ts +0 -139
- package/lib/client-app/angular/angular.schema.d.ts +0 -32
- package/lib/client-app/angular/files/angular.constants.ts +0 -4
- package/lib/client-app/angular/files/angular.module.ts +0 -41
- package/lib/client-app/angular/files/angular.providers.ts +0 -27
- package/lib/client-app/angular/files/angular.utils.ts +0 -19
- package/lib/client-app/angular/files/interfaces/angular-options.interface.ts +0 -87
- package/lib/client-app/angular/files/loaders/abstract.loader.ts +0 -16
- package/lib/client-app/angular/files/loaders/express.loader.ts +0 -25
- package/lib/client-app/angular/files/loaders/fastify.loader.ts +0 -34
- package/lib/client-app/angular/files/loaders/noop.loader.ts +0 -12
- package/lib/client-app/angular/schema.json +0 -24
- package/lib/configuration/configuration.factory.d.ts +0 -3
- package/lib/configuration/configuration.factory.js +0 -24
- package/lib/configuration/configuration.factory.test.ts +0 -60
- package/lib/configuration/configuration.factory.ts +0 -35
- package/lib/configuration/configuration.schema.d.ts +0 -18
- package/lib/configuration/files/js/nest-cli.json +0 -5
- package/lib/configuration/files/ts/nest-cli.json +0 -5
- package/lib/decorator/decorator.factory.d.ts +0 -3
- package/lib/decorator/decorator.factory.js +0 -32
- package/lib/decorator/decorator.factory.test.ts +0 -111
- package/lib/decorator/decorator.factory.ts +0 -48
- package/lib/decorator/decorator.schema.d.ts +0 -24
- package/lib/decorator/files/js/__name__.decorator.js +0 -3
- package/lib/decorator/files/ts/__name__.decorator.ts +0 -3
- package/lib/decorator/schema.json +0 -35
- package/lib/filter/files/js/__name__.filter.js +0 -6
- package/lib/filter/files/js/__name__.filter.spec.js +0 -7
- package/lib/filter/files/ts/__name__.filter.spec.ts +0 -7
- package/lib/filter/files/ts/__name__.filter.ts +0 -6
- package/lib/filter/filter.factory.d.ts +0 -3
- package/lib/filter/filter.factory.js +0 -33
- package/lib/filter/filter.factory.test.ts +0 -147
- package/lib/filter/filter.factory.ts +0 -51
- package/lib/filter/filter.schema.d.ts +0 -28
- package/lib/filter/schema.json +0 -39
- package/lib/gateway/files/js/__name__.gateway.js +0 -9
- package/lib/gateway/files/js/__name__.gateway.spec.js +0 -18
- package/lib/gateway/files/ts/__name__.gateway.spec.ts +0 -18
- package/lib/gateway/files/ts/__name__.gateway.ts +0 -9
- package/lib/gateway/gateway.factory.d.ts +0 -3
- package/lib/gateway/gateway.factory.js +0 -61
- package/lib/gateway/gateway.factory.test.ts +0 -147
- package/lib/gateway/gateway.factory.ts +0 -92
- package/lib/gateway/gateway.schema.d.ts +0 -36
- package/lib/gateway/schema.json +0 -39
- package/lib/interface/files/__name__.interface.ts +0 -1
- package/lib/interface/interface.factory.d.ts +0 -3
- package/lib/interface/interface.factory.js +0 -31
- package/lib/interface/interface.factory.test.ts +0 -84
- package/lib/interface/interface.factory.ts +0 -47
- package/lib/interface/interface.schema.d.ts +0 -20
- package/lib/interface/schema.json +0 -31
- package/lib/library/files/js/.babelrc +0 -4
- package/lib/library/files/js/jsconfig.json +0 -9
- package/lib/library/files/js/package.json +0 -8
- package/lib/library/files/js/src/__name__.module.js +0 -8
- package/lib/library/files/js/src/__name__.service.js +0 -4
- package/lib/library/files/js/src/__name__.service.spec.js +0 -18
- package/lib/library/files/js/src/index.js +0 -2
- package/lib/library/files/ts/package.json +0 -8
- package/lib/library/files/ts/src/__name__.module.ts +0 -8
- package/lib/library/files/ts/src/__name__.service.spec.ts +0 -18
- package/lib/library/files/ts/src/__name__.service.ts +0 -4
- package/lib/library/files/ts/src/index.ts +0 -2
- package/lib/library/files/ts/tsconfig.lib.json +0 -5
- package/lib/library/library.factory.d.ts +0 -3
- package/lib/library/library.factory.js +0 -97
- package/lib/library/library.factory.test.ts +0 -68
- package/lib/library/library.factory.ts +0 -158
- package/lib/library/library.schema.d.ts +0 -24
- package/lib/library/schema.json +0 -37
- package/lib/pipe/files/js/__name__.pipe.js +0 -8
- package/lib/pipe/files/js/__name__.pipe.spec.js +0 -7
- package/lib/pipe/files/ts/__name__.pipe.spec.ts +0 -7
- package/lib/pipe/files/ts/__name__.pipe.ts +0 -8
- package/lib/pipe/pipe.factory.d.ts +0 -3
- package/lib/pipe/pipe.factory.js +0 -33
- package/lib/pipe/pipe.factory.test.ts +0 -141
- package/lib/pipe/pipe.factory.ts +0 -51
- package/lib/pipe/pipe.schema.d.ts +0 -28
- package/lib/pipe/schema.json +0 -39
- package/lib/resolver/files/js/__name__.resolver.js +0 -4
- package/lib/resolver/files/js/__name__.resolver.spec.js +0 -18
- package/lib/resolver/files/ts/__name__.resolver.spec.ts +0 -18
- package/lib/resolver/files/ts/__name__.resolver.ts +0 -4
- package/lib/resolver/resolver.factory.d.ts +0 -3
- package/lib/resolver/resolver.factory.js +0 -61
- package/lib/resolver/resolver.factory.test.ts +0 -117
- package/lib/resolver/resolver.factory.ts +0 -92
- package/lib/resolver/resolver.schema.d.ts +0 -36
- package/lib/resolver/schema.json +0 -39
|
@@ -1,75 +0,0 @@
|
|
|
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).
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = void 0;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const name_parser_1 = require("../../utils/name.parser");
|
|
7
|
-
const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
8
|
-
const defaults_1 = require("../defaults");
|
|
9
|
-
function main(options) {
|
|
10
|
-
options = transform(options);
|
|
11
|
-
return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
|
|
12
|
-
}
|
|
13
|
-
exports.main = main;
|
|
14
|
-
function transform(options) {
|
|
15
|
-
const target = Object.assign({}, options);
|
|
16
|
-
if (!target.name) {
|
|
17
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
18
|
-
}
|
|
19
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
20
|
-
target.name = core_1.strings.dasherize(location.name);
|
|
21
|
-
target.language =
|
|
22
|
-
target.language !== undefined ? target.language : defaults_1.DEFAULT_LANGUAGE;
|
|
23
|
-
target.path = core_1.strings.dasherize(location.path);
|
|
24
|
-
target.path = target.flat
|
|
25
|
-
? target.path
|
|
26
|
-
: (0, core_1.join)(target.path, target.name);
|
|
27
|
-
return target;
|
|
28
|
-
}
|
|
29
|
-
function generate(options) {
|
|
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
|
-
])(context);
|
|
35
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SchematicTestRunner,
|
|
3
|
-
UnitTestTree,
|
|
4
|
-
} from '@angular-devkit/schematics/testing';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { ClassOptions } from './class.schema';
|
|
7
|
-
|
|
8
|
-
describe('Class Factory', () => {
|
|
9
|
-
const runner: SchematicTestRunner = new SchematicTestRunner(
|
|
10
|
-
'.',
|
|
11
|
-
path.join(process.cwd(), 'src/collection.json'),
|
|
12
|
-
);
|
|
13
|
-
it('should manage name only', () => {
|
|
14
|
-
const options: ClassOptions = {
|
|
15
|
-
name: 'foo',
|
|
16
|
-
spec: true,
|
|
17
|
-
flat: true,
|
|
18
|
-
};
|
|
19
|
-
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
20
|
-
const files: string[] = tree.files;
|
|
21
|
-
|
|
22
|
-
expect(files.find(filename => filename === '/foo.ts')).not.toBeUndefined();
|
|
23
|
-
expect(tree.readContent('/foo.ts')).toEqual('export class Foo {}\n');
|
|
24
|
-
});
|
|
25
|
-
it('should manage name as a path', () => {
|
|
26
|
-
const options: ClassOptions = {
|
|
27
|
-
name: 'bar/foo',
|
|
28
|
-
flat: false,
|
|
29
|
-
spec: false,
|
|
30
|
-
};
|
|
31
|
-
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
32
|
-
const files: string[] = tree.files;
|
|
33
|
-
expect(
|
|
34
|
-
files.find(filename => filename === '/bar/foo/foo.ts'),
|
|
35
|
-
).not.toBeUndefined();
|
|
36
|
-
expect(tree.readContent('/bar/foo/foo.ts')).toEqual(
|
|
37
|
-
'export class Foo {}\n',
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
it('should manage name and path', () => {
|
|
41
|
-
const options: ClassOptions = {
|
|
42
|
-
name: 'foo',
|
|
43
|
-
path: 'baz',
|
|
44
|
-
flat: false,
|
|
45
|
-
spec: false,
|
|
46
|
-
};
|
|
47
|
-
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
48
|
-
const files: string[] = tree.files;
|
|
49
|
-
expect(
|
|
50
|
-
files.find(filename => filename === '/baz/foo/foo.ts'),
|
|
51
|
-
).not.toBeUndefined();
|
|
52
|
-
expect(tree.readContent('/baz/foo/foo.ts')).toEqual(
|
|
53
|
-
'export class Foo {}\n',
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
it('should manage name to dasherize', () => {
|
|
57
|
-
const options: ClassOptions = {
|
|
58
|
-
name: 'fooBar',
|
|
59
|
-
flat: false,
|
|
60
|
-
spec: false,
|
|
61
|
-
};
|
|
62
|
-
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
63
|
-
const files: string[] = tree.files;
|
|
64
|
-
expect(
|
|
65
|
-
files.find(filename => filename === '/foo-bar/foo-bar.ts'),
|
|
66
|
-
).not.toBeUndefined();
|
|
67
|
-
expect(tree.readContent('/foo-bar/foo-bar.ts')).toEqual(
|
|
68
|
-
'export class FooBar {}\n',
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
it('should manage path to dasherize', () => {
|
|
72
|
-
const options: ClassOptions = {
|
|
73
|
-
name: 'barBaz/foo',
|
|
74
|
-
spec: false,
|
|
75
|
-
flat: false,
|
|
76
|
-
};
|
|
77
|
-
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
78
|
-
const files: string[] = tree.files;
|
|
79
|
-
expect(
|
|
80
|
-
files.find(filename => filename === '/bar-baz/foo/foo.ts'),
|
|
81
|
-
).not.toBeUndefined();
|
|
82
|
-
expect(tree.readContent('/bar-baz/foo/foo.ts')).toEqual(
|
|
83
|
-
'export class Foo {}\n',
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
it('should manage javascript file', () => {
|
|
87
|
-
const options: ClassOptions = {
|
|
88
|
-
name: 'foo',
|
|
89
|
-
language: 'js',
|
|
90
|
-
flat: false,
|
|
91
|
-
spec: false,
|
|
92
|
-
};
|
|
93
|
-
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
94
|
-
const files: string[] = tree.files;
|
|
95
|
-
expect(
|
|
96
|
-
files.find(filename => filename === '/foo/foo.js'),
|
|
97
|
-
).not.toBeUndefined();
|
|
98
|
-
expect(tree.readContent('/foo/foo.js')).toEqual('export class Foo {}\n');
|
|
99
|
-
});
|
|
100
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { join, Path, strings } from '@angular-devkit/core';
|
|
2
|
-
import {
|
|
3
|
-
apply,
|
|
4
|
-
chain,
|
|
5
|
-
filter,
|
|
6
|
-
mergeWith,
|
|
7
|
-
move,
|
|
8
|
-
noop,
|
|
9
|
-
Rule,
|
|
10
|
-
SchematicContext,
|
|
11
|
-
SchematicsException,
|
|
12
|
-
Source,
|
|
13
|
-
template,
|
|
14
|
-
url,
|
|
15
|
-
} from '@angular-devkit/schematics';
|
|
16
|
-
import { Location, NameParser } from '../../utils/name.parser';
|
|
17
|
-
import { mergeSourceRoot } from '../../utils/source-root.helpers';
|
|
18
|
-
import { DEFAULT_LANGUAGE } from '../defaults';
|
|
19
|
-
import { ClassOptions } from './class.schema';
|
|
20
|
-
|
|
21
|
-
export function main(options: ClassOptions): Rule {
|
|
22
|
-
options = transform(options);
|
|
23
|
-
return chain([mergeSourceRoot(options), mergeWith(generate(options))]);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function transform(options: ClassOptions): ClassOptions {
|
|
27
|
-
const target: ClassOptions = Object.assign({}, options);
|
|
28
|
-
if (!target.name) {
|
|
29
|
-
throw new SchematicsException('Option (name) is required.');
|
|
30
|
-
}
|
|
31
|
-
const location: Location = new NameParser().parse(target);
|
|
32
|
-
target.name = strings.dasherize(location.name);
|
|
33
|
-
target.language =
|
|
34
|
-
target.language !== undefined ? target.language : DEFAULT_LANGUAGE;
|
|
35
|
-
|
|
36
|
-
target.path = strings.dasherize(location.path);
|
|
37
|
-
target.path = target.flat
|
|
38
|
-
? target.path
|
|
39
|
-
: join(target.path as Path, target.name);
|
|
40
|
-
|
|
41
|
-
return target;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function generate(options: ClassOptions): Source {
|
|
45
|
-
return (context: SchematicContext) =>
|
|
46
|
-
apply(url(join('./files' as Path, options.language)), [
|
|
47
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
48
|
-
template({
|
|
49
|
-
...strings,
|
|
50
|
-
...options,
|
|
51
|
-
}),
|
|
52
|
-
move(options.path),
|
|
53
|
-
])(context);
|
|
54
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Path } from '@angular-devkit/core';
|
|
2
|
-
|
|
3
|
-
export interface ClassOptions {
|
|
4
|
-
/**
|
|
5
|
-
* The name of the class.
|
|
6
|
-
*/
|
|
7
|
-
name: string;
|
|
8
|
-
/**
|
|
9
|
-
* The path to create the class.
|
|
10
|
-
*/
|
|
11
|
-
path?: string | Path;
|
|
12
|
-
/**
|
|
13
|
-
* Application language.
|
|
14
|
-
*/
|
|
15
|
-
language?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The source root path
|
|
18
|
-
*/
|
|
19
|
-
sourceRoot?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Specifies if a spec file is generated.
|
|
22
|
-
*/
|
|
23
|
-
spec?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Flag to indicate if a directory is created.
|
|
26
|
-
*/
|
|
27
|
-
flat?: boolean;
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export class <%= classify(name) %> {}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export class <%= classify(name) %> {}
|
package/lib/class/schema.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"id": "SchematicsNestClass",
|
|
4
|
-
"title": "Nest Class Options Schema",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "The name of the class.",
|
|
10
|
-
"$default": {
|
|
11
|
-
"$source": "argv",
|
|
12
|
-
"index": 0
|
|
13
|
-
},
|
|
14
|
-
"x-prompt": "What name would you like to use for the class?"
|
|
15
|
-
},
|
|
16
|
-
"flat": {
|
|
17
|
-
"default": true,
|
|
18
|
-
"description": "Flag to indicate if a directory is created."
|
|
19
|
-
},
|
|
20
|
-
"spec": {
|
|
21
|
-
"default": true,
|
|
22
|
-
"description": "Specifies if a spec file is generated."
|
|
23
|
-
},
|
|
24
|
-
"path": {
|
|
25
|
-
"type": "string",
|
|
26
|
-
"format": "path",
|
|
27
|
-
"description": "The path to create the class."
|
|
28
|
-
},
|
|
29
|
-
"language": {
|
|
30
|
-
"type": "string",
|
|
31
|
-
"description": "Nest class language (ts/js)."
|
|
32
|
-
},
|
|
33
|
-
"sourceRoot": {
|
|
34
|
-
"type": "string",
|
|
35
|
-
"description": "Nest controller source root directory."
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"required": ["name"]
|
|
39
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = void 0;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const ts = require("ts-morph");
|
|
8
|
-
const module_declarator_1 = require("../../../utils/module.declarator");
|
|
9
|
-
const module_finder_1 = require("../../../utils/module.finder");
|
|
10
|
-
const name_parser_1 = require("../../../utils/name.parser");
|
|
11
|
-
const source_root_helpers_1 = require("../../../utils/source-root.helpers");
|
|
12
|
-
function main(options) {
|
|
13
|
-
options = transform(options);
|
|
14
|
-
return (tree, context) => {
|
|
15
|
-
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
16
|
-
createAngularApplication(options),
|
|
17
|
-
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
18
|
-
addDeclarationToModule(options),
|
|
19
|
-
addGlobalPrefix(),
|
|
20
|
-
(0, schematics_1.mergeWith)(generate(options)),
|
|
21
|
-
]))(tree, context);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.main = main;
|
|
25
|
-
function transform(source) {
|
|
26
|
-
const target = Object.assign({}, source);
|
|
27
|
-
target.directory = target.name ? core_1.strings.dasherize(target.name) : 'client';
|
|
28
|
-
target.name = 'Angular';
|
|
29
|
-
target.metadata = 'imports';
|
|
30
|
-
target.type = 'module';
|
|
31
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
32
|
-
target.name = core_1.strings.dasherize(location.name);
|
|
33
|
-
target.path = (0, path_1.join)(core_1.strings.dasherize(location.path), target.name);
|
|
34
|
-
return target;
|
|
35
|
-
}
|
|
36
|
-
function generate(options) {
|
|
37
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
38
|
-
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
39
|
-
(0, schematics_1.move)(options.path),
|
|
40
|
-
])(context);
|
|
41
|
-
}
|
|
42
|
-
function createAngularApplication(options) {
|
|
43
|
-
if (!options.initApp) {
|
|
44
|
-
return (0, schematics_1.noop)();
|
|
45
|
-
}
|
|
46
|
-
return (0, schematics_1.externalSchematic)('@schematics/angular', 'ng-new', {
|
|
47
|
-
name: options.directory,
|
|
48
|
-
version: '7.0.0',
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function addDeclarationToModule(options) {
|
|
52
|
-
return (tree) => {
|
|
53
|
-
options.module = new module_finder_1.ModuleFinder(tree).find({
|
|
54
|
-
name: options.name,
|
|
55
|
-
path: options.path,
|
|
56
|
-
});
|
|
57
|
-
if (!options.module) {
|
|
58
|
-
return tree;
|
|
59
|
-
}
|
|
60
|
-
const content = tree.read(options.module).toString();
|
|
61
|
-
const declarator = new module_declarator_1.ModuleDeclarator();
|
|
62
|
-
const rootPath = `${options.directory}/dist/${options.directory}`;
|
|
63
|
-
const declarationOptions = Object.assign(Object.assign({}, options), { staticOptions: {
|
|
64
|
-
name: 'forRoot',
|
|
65
|
-
value: {
|
|
66
|
-
rootPath,
|
|
67
|
-
},
|
|
68
|
-
} });
|
|
69
|
-
tree.overwrite(options.module, declarator.declare(content, declarationOptions));
|
|
70
|
-
return tree;
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function addGlobalPrefix() {
|
|
74
|
-
return (tree) => {
|
|
75
|
-
const mainFilePath = 'src/main.ts';
|
|
76
|
-
const fileRef = tree.get(mainFilePath);
|
|
77
|
-
if (!fileRef) {
|
|
78
|
-
return tree;
|
|
79
|
-
}
|
|
80
|
-
const tsProject = new ts.Project({
|
|
81
|
-
manipulationSettings: {
|
|
82
|
-
indentationText: ts.IndentationText.TwoSpaces,
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
const tsFile = tsProject.addExistingSourceFile(mainFilePath);
|
|
86
|
-
const bootstrapFunction = tsFile.getFunction('bootstrap');
|
|
87
|
-
const listenStatement = bootstrapFunction.getStatement(node => node.getText().includes('listen'));
|
|
88
|
-
const setPrefixStatement = bootstrapFunction.getStatement(node => node.getText().includes('setGlobalPrefix'));
|
|
89
|
-
if (!listenStatement || setPrefixStatement) {
|
|
90
|
-
return tree;
|
|
91
|
-
}
|
|
92
|
-
const listenExprIndex = listenStatement.getChildIndex();
|
|
93
|
-
bootstrapFunction.insertStatements(listenExprIndex, `app.setGlobalPrefix('api');`);
|
|
94
|
-
tree.overwrite(mainFilePath, tsFile.getFullText());
|
|
95
|
-
return tree;
|
|
96
|
-
};
|
|
97
|
-
}
|