@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,18 +0,0 @@
|
|
|
1
|
-
import { Test, TestingModule } from '@nestjs/testing';
|
|
2
|
-
import { <%= classify(name) %>Service } from './<%= name %>.service';
|
|
3
|
-
|
|
4
|
-
describe('<%= classify(name) %>Service', () => {
|
|
5
|
-
let service: <%= classify(name) %>Service;
|
|
6
|
-
|
|
7
|
-
beforeEach(async () => {
|
|
8
|
-
const module: TestingModule = await Test.createTestingModule({
|
|
9
|
-
providers: [<%= classify(name) %>Service],
|
|
10
|
-
}).compile();
|
|
11
|
-
|
|
12
|
-
service = module.get<<%= classify(name) %>Service>(<%= classify(name) %>Service);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should be defined', () => {
|
|
16
|
-
expect(service).toBeDefined();
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -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 defaults_1 = require("../defaults");
|
|
7
|
-
function main(options) {
|
|
8
|
-
options = transform(options);
|
|
9
|
-
return (0, schematics_1.chain)([
|
|
10
|
-
updateTsConfig(options.name, options.prefix, options.path),
|
|
11
|
-
addLibraryToCliOptions(options.path, options.name),
|
|
12
|
-
(0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(generate(options))),
|
|
13
|
-
]);
|
|
14
|
-
}
|
|
15
|
-
exports.main = main;
|
|
16
|
-
function transform(options) {
|
|
17
|
-
const target = Object.assign({}, options);
|
|
18
|
-
const defaultSourceRoot = options.rootDir !== undefined ? options.rootDir : defaults_1.DEFAULT_LIB_PATH;
|
|
19
|
-
if (!target.name) {
|
|
20
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
21
|
-
}
|
|
22
|
-
target.language = !!target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
|
|
23
|
-
target.name = core_1.strings.dasherize(target.name);
|
|
24
|
-
target.path =
|
|
25
|
-
target.path !== undefined
|
|
26
|
-
? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), target.path)
|
|
27
|
-
: (0, core_1.normalize)(defaultSourceRoot);
|
|
28
|
-
target.prefix = target.prefix || '@app';
|
|
29
|
-
return target;
|
|
30
|
-
}
|
|
31
|
-
function updateJsonFile(host, path, callback) {
|
|
32
|
-
const source = host.read(path);
|
|
33
|
-
if (source) {
|
|
34
|
-
const sourceText = source.toString('utf-8');
|
|
35
|
-
const json = (0, core_1.parseJson)(sourceText);
|
|
36
|
-
callback(json);
|
|
37
|
-
host.overwrite(path, JSON.stringify(json, null, 2));
|
|
38
|
-
}
|
|
39
|
-
return host;
|
|
40
|
-
}
|
|
41
|
-
function updateTsConfig(packageName, packagePrefix, root) {
|
|
42
|
-
return (host) => {
|
|
43
|
-
if (!host.exists('tsconfig.json')) {
|
|
44
|
-
return host;
|
|
45
|
-
}
|
|
46
|
-
const distRoot = (0, core_1.join)(root, packageName, 'src');
|
|
47
|
-
const packageKey = packagePrefix
|
|
48
|
-
? packagePrefix + '/' + packageName
|
|
49
|
-
: packageName;
|
|
50
|
-
return updateJsonFile(host, 'tsconfig.json', (tsconfig) => {
|
|
51
|
-
if (!tsconfig.compilerOptions) {
|
|
52
|
-
tsconfig.compilerOptions = {};
|
|
53
|
-
}
|
|
54
|
-
if (!tsconfig.compilerOptions.baseUrl) {
|
|
55
|
-
tsconfig.compilerOptions.baseUrl = './';
|
|
56
|
-
}
|
|
57
|
-
if (!tsconfig.compilerOptions.paths) {
|
|
58
|
-
tsconfig.compilerOptions.paths = {};
|
|
59
|
-
}
|
|
60
|
-
if (!tsconfig.compilerOptions.paths[packageKey]) {
|
|
61
|
-
tsconfig.compilerOptions.paths[packageKey] = [];
|
|
62
|
-
}
|
|
63
|
-
tsconfig.compilerOptions.paths[packageKey].push(distRoot);
|
|
64
|
-
const deepPackagePath = packageKey + '/*';
|
|
65
|
-
if (!tsconfig.compilerOptions.paths[deepPackagePath]) {
|
|
66
|
-
tsconfig.compilerOptions.paths[deepPackagePath] = [];
|
|
67
|
-
}
|
|
68
|
-
tsconfig.compilerOptions.paths[deepPackagePath].push(distRoot + '/*');
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function addLibraryToCliOptions(projectRoot, projectName) {
|
|
73
|
-
const project = {
|
|
74
|
-
root: (0, core_1.join)(projectRoot, projectName),
|
|
75
|
-
sourceRoot: (0, core_1.join)(projectRoot, projectName, 'src'),
|
|
76
|
-
};
|
|
77
|
-
return (host) => {
|
|
78
|
-
const nestCliFileExists = host.exists('nest-cli.json');
|
|
79
|
-
const nestFileExists = host.exists('nest.json');
|
|
80
|
-
if (!nestCliFileExists && !nestFileExists) {
|
|
81
|
-
return host;
|
|
82
|
-
}
|
|
83
|
-
return updateJsonFile(host, nestCliFileExists ? 'nest-cli.json' : 'nest.json', (optionsFile) => {
|
|
84
|
-
if (!optionsFile.projects) {
|
|
85
|
-
optionsFile.projects = {};
|
|
86
|
-
}
|
|
87
|
-
optionsFile.projects[projectName] = project;
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
function generate(options) {
|
|
92
|
-
const path = (0, core_1.join)(options.path, options.name);
|
|
93
|
-
return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
94
|
-
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
95
|
-
(0, schematics_1.move)(path),
|
|
96
|
-
]);
|
|
97
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SchematicTestRunner,
|
|
3
|
-
UnitTestTree,
|
|
4
|
-
} from '@angular-devkit/schematics/testing';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { LibraryOptions } from './library.schema';
|
|
7
|
-
|
|
8
|
-
describe('Library 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: LibraryOptions = {
|
|
15
|
-
name: 'project',
|
|
16
|
-
prefix: 'app',
|
|
17
|
-
};
|
|
18
|
-
const tree: UnitTestTree = runner.runSchematic('library', options);
|
|
19
|
-
const files: string[] = tree.files;
|
|
20
|
-
expect(files).toEqual([
|
|
21
|
-
'/libs/project/.gitignore',
|
|
22
|
-
'/libs/project/package.json',
|
|
23
|
-
'/libs/project/tsconfig.lib.json',
|
|
24
|
-
'/libs/project/tslint.json',
|
|
25
|
-
'/libs/project/src/index.ts',
|
|
26
|
-
'/libs/project/src/project.module.ts',
|
|
27
|
-
'/libs/project/src/project.service.spec.ts',
|
|
28
|
-
'/libs/project/src/project.service.ts',
|
|
29
|
-
]);
|
|
30
|
-
});
|
|
31
|
-
it('should manage name to dasherize', () => {
|
|
32
|
-
const options: LibraryOptions = {
|
|
33
|
-
name: 'awesomeProject',
|
|
34
|
-
prefix: 'app',
|
|
35
|
-
};
|
|
36
|
-
const tree: UnitTestTree = runner.runSchematic('library', options);
|
|
37
|
-
const files: string[] = tree.files;
|
|
38
|
-
expect(files).toEqual([
|
|
39
|
-
'/libs/awesome-project/.gitignore',
|
|
40
|
-
'/libs/awesome-project/package.json',
|
|
41
|
-
'/libs/awesome-project/tsconfig.lib.json',
|
|
42
|
-
'/libs/awesome-project/tslint.json',
|
|
43
|
-
'/libs/awesome-project/src/index.ts',
|
|
44
|
-
'/libs/awesome-project/src/awesome-project.module.ts',
|
|
45
|
-
'/libs/awesome-project/src/awesome-project.service.spec.ts',
|
|
46
|
-
'/libs/awesome-project/src/awesome-project.service.ts',
|
|
47
|
-
]);
|
|
48
|
-
});
|
|
49
|
-
it('should manage javascript files', () => {
|
|
50
|
-
const options: LibraryOptions = {
|
|
51
|
-
name: 'project',
|
|
52
|
-
language: 'js',
|
|
53
|
-
prefix: 'app',
|
|
54
|
-
};
|
|
55
|
-
const tree: UnitTestTree = runner.runSchematic('library', options);
|
|
56
|
-
const files: string[] = tree.files;
|
|
57
|
-
expect(files).toEqual([
|
|
58
|
-
'/libs/project/.babelrc',
|
|
59
|
-
'/libs/project/.gitignore',
|
|
60
|
-
'/libs/project/jsconfig.json',
|
|
61
|
-
'/libs/project/package.json',
|
|
62
|
-
'/libs/project/src/index.js',
|
|
63
|
-
'/libs/project/src/project.module.js',
|
|
64
|
-
'/libs/project/src/project.service.js',
|
|
65
|
-
'/libs/project/src/project.service.spec.js',
|
|
66
|
-
]);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
join,
|
|
3
|
-
normalize,
|
|
4
|
-
parseJson,
|
|
5
|
-
Path,
|
|
6
|
-
strings,
|
|
7
|
-
} from '@angular-devkit/core';
|
|
8
|
-
import {
|
|
9
|
-
apply,
|
|
10
|
-
branchAndMerge,
|
|
11
|
-
chain,
|
|
12
|
-
mergeWith,
|
|
13
|
-
move,
|
|
14
|
-
Rule,
|
|
15
|
-
SchematicsException,
|
|
16
|
-
Source,
|
|
17
|
-
template,
|
|
18
|
-
Tree,
|
|
19
|
-
url,
|
|
20
|
-
} from '@angular-devkit/schematics';
|
|
21
|
-
import { DEFAULT_LANGUAGE, DEFAULT_LIB_PATH } from '../defaults';
|
|
22
|
-
import { LibraryOptions } from './library.schema';
|
|
23
|
-
|
|
24
|
-
type UpdateJsonFn<T> = (obj: T) => T | void;
|
|
25
|
-
interface TsConfigPartialType {
|
|
26
|
-
compilerOptions: {
|
|
27
|
-
baseUrl: string;
|
|
28
|
-
paths: {
|
|
29
|
-
[key: string]: string[];
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function main(options: LibraryOptions): Rule {
|
|
35
|
-
options = transform(options);
|
|
36
|
-
return chain([
|
|
37
|
-
updateTsConfig(options.name, options.prefix, options.path),
|
|
38
|
-
addLibraryToCliOptions(options.path, options.name),
|
|
39
|
-
branchAndMerge(mergeWith(generate(options))),
|
|
40
|
-
]);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function transform(options: LibraryOptions): LibraryOptions {
|
|
44
|
-
const target: LibraryOptions = Object.assign({}, options);
|
|
45
|
-
const defaultSourceRoot =
|
|
46
|
-
options.rootDir !== undefined ? options.rootDir : DEFAULT_LIB_PATH;
|
|
47
|
-
|
|
48
|
-
if (!target.name) {
|
|
49
|
-
throw new SchematicsException('Option (name) is required.');
|
|
50
|
-
}
|
|
51
|
-
target.language = !!target.language ? target.language : DEFAULT_LANGUAGE;
|
|
52
|
-
target.name = strings.dasherize(target.name);
|
|
53
|
-
target.path =
|
|
54
|
-
target.path !== undefined
|
|
55
|
-
? join(normalize(defaultSourceRoot), target.path)
|
|
56
|
-
: normalize(defaultSourceRoot);
|
|
57
|
-
|
|
58
|
-
target.prefix = target.prefix || '@app';
|
|
59
|
-
return target;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function updateJsonFile<T>(
|
|
63
|
-
host: Tree,
|
|
64
|
-
path: string,
|
|
65
|
-
callback: UpdateJsonFn<T>,
|
|
66
|
-
): Tree {
|
|
67
|
-
const source = host.read(path);
|
|
68
|
-
if (source) {
|
|
69
|
-
const sourceText = source.toString('utf-8');
|
|
70
|
-
const json = parseJson(sourceText);
|
|
71
|
-
callback((json as {}) as T);
|
|
72
|
-
host.overwrite(path, JSON.stringify(json, null, 2));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return host;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function updateTsConfig(
|
|
79
|
-
packageName: string,
|
|
80
|
-
packagePrefix: string,
|
|
81
|
-
root: string,
|
|
82
|
-
) {
|
|
83
|
-
return (host: Tree) => {
|
|
84
|
-
if (!host.exists('tsconfig.json')) {
|
|
85
|
-
return host;
|
|
86
|
-
}
|
|
87
|
-
const distRoot = join(root as Path, packageName, 'src');
|
|
88
|
-
const packageKey = packagePrefix
|
|
89
|
-
? packagePrefix + '/' + packageName
|
|
90
|
-
: packageName;
|
|
91
|
-
|
|
92
|
-
return updateJsonFile(
|
|
93
|
-
host,
|
|
94
|
-
'tsconfig.json',
|
|
95
|
-
(tsconfig: TsConfigPartialType) => {
|
|
96
|
-
if (!tsconfig.compilerOptions) {
|
|
97
|
-
tsconfig.compilerOptions = {} as any;
|
|
98
|
-
}
|
|
99
|
-
if (!tsconfig.compilerOptions.baseUrl) {
|
|
100
|
-
tsconfig.compilerOptions.baseUrl = './';
|
|
101
|
-
}
|
|
102
|
-
if (!tsconfig.compilerOptions.paths) {
|
|
103
|
-
tsconfig.compilerOptions.paths = {};
|
|
104
|
-
}
|
|
105
|
-
if (!tsconfig.compilerOptions.paths[packageKey]) {
|
|
106
|
-
tsconfig.compilerOptions.paths[packageKey] = [];
|
|
107
|
-
}
|
|
108
|
-
tsconfig.compilerOptions.paths[packageKey].push(distRoot);
|
|
109
|
-
|
|
110
|
-
const deepPackagePath = packageKey + '/*';
|
|
111
|
-
if (!tsconfig.compilerOptions.paths[deepPackagePath]) {
|
|
112
|
-
tsconfig.compilerOptions.paths[deepPackagePath] = [];
|
|
113
|
-
}
|
|
114
|
-
tsconfig.compilerOptions.paths[deepPackagePath].push(distRoot + '/*');
|
|
115
|
-
},
|
|
116
|
-
);
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function addLibraryToCliOptions(
|
|
121
|
-
projectRoot: string,
|
|
122
|
-
projectName: string,
|
|
123
|
-
): Rule {
|
|
124
|
-
const project = {
|
|
125
|
-
root: join(projectRoot as Path, projectName),
|
|
126
|
-
sourceRoot: join(projectRoot as Path, projectName, 'src'),
|
|
127
|
-
};
|
|
128
|
-
return (host: Tree) => {
|
|
129
|
-
const nestCliFileExists = host.exists('nest-cli.json');
|
|
130
|
-
const nestFileExists = host.exists('nest.json');
|
|
131
|
-
|
|
132
|
-
if (!nestCliFileExists && !nestFileExists) {
|
|
133
|
-
return host;
|
|
134
|
-
}
|
|
135
|
-
return updateJsonFile(
|
|
136
|
-
host,
|
|
137
|
-
nestCliFileExists ? 'nest-cli.json' : 'nest.json',
|
|
138
|
-
(optionsFile: Record<string, any>) => {
|
|
139
|
-
if (!optionsFile.projects) {
|
|
140
|
-
optionsFile.projects = {} as any;
|
|
141
|
-
}
|
|
142
|
-
optionsFile.projects[projectName] = project;
|
|
143
|
-
},
|
|
144
|
-
);
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function generate(options: LibraryOptions): Source {
|
|
149
|
-
const path = join(options.path as Path, options.name);
|
|
150
|
-
|
|
151
|
-
return apply(url(join('./files' as Path, options.language)), [
|
|
152
|
-
template({
|
|
153
|
-
...strings,
|
|
154
|
-
...options,
|
|
155
|
-
}),
|
|
156
|
-
move(path),
|
|
157
|
-
]);
|
|
158
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Path } from '@angular-devkit/core';
|
|
2
|
-
|
|
3
|
-
export interface LibraryOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Nest library name.
|
|
6
|
-
*/
|
|
7
|
-
name: string;
|
|
8
|
-
/**
|
|
9
|
-
* Prefix (scope)
|
|
10
|
-
*/
|
|
11
|
-
prefix?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Application language.
|
|
14
|
-
*/
|
|
15
|
-
language?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The path to create the library.
|
|
18
|
-
*/
|
|
19
|
-
path?: string | Path;
|
|
20
|
-
/**
|
|
21
|
-
* The libraries root directory
|
|
22
|
-
*/
|
|
23
|
-
rootDir?: string | Path;
|
|
24
|
-
}
|
package/lib/library/schema.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"id": "SchematicsNestLibrary",
|
|
4
|
-
"title": "Nest Library Options Schema",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "The name of the library.",
|
|
10
|
-
"$default": {
|
|
11
|
-
"$source": "argv",
|
|
12
|
-
"index": 0
|
|
13
|
-
},
|
|
14
|
-
"x-prompt": "What name would you like to use for the library?"
|
|
15
|
-
},
|
|
16
|
-
"prefix": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"description": "The prefix of the library.",
|
|
19
|
-
"x-prompt": "What prefix would you like to use for the library (default: @app)?"
|
|
20
|
-
},
|
|
21
|
-
"language": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"description": "Nest library language."
|
|
24
|
-
},
|
|
25
|
-
"path": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"format": "path",
|
|
28
|
-
"description": "The path to create the library."
|
|
29
|
-
},
|
|
30
|
-
"rootDir": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"format": "path",
|
|
33
|
-
"description": "The libraries root directory."
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"required": ["name", "prefix"]
|
|
37
|
-
}
|
package/lib/pipe/pipe.factory.js
DELETED
|
@@ -1,33 +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
|
-
function main(options) {
|
|
9
|
-
options = transform(options);
|
|
10
|
-
return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
|
|
11
|
-
}
|
|
12
|
-
exports.main = main;
|
|
13
|
-
function transform(options) {
|
|
14
|
-
const target = Object.assign({}, options);
|
|
15
|
-
if (!target.name) {
|
|
16
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
17
|
-
}
|
|
18
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
19
|
-
target.name = core_1.strings.dasherize(location.name);
|
|
20
|
-
target.path = core_1.strings.dasherize(location.path);
|
|
21
|
-
target.language = target.language !== undefined ? target.language : 'ts';
|
|
22
|
-
target.path = target.flat
|
|
23
|
-
? target.path
|
|
24
|
-
: (0, core_1.join)(target.path, target.name);
|
|
25
|
-
return target;
|
|
26
|
-
}
|
|
27
|
-
function generate(options) {
|
|
28
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
29
|
-
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
|
|
30
|
-
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
31
|
-
(0, schematics_1.move)(options.path),
|
|
32
|
-
])(context);
|
|
33
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SchematicTestRunner,
|
|
3
|
-
UnitTestTree,
|
|
4
|
-
} from '@angular-devkit/schematics/testing';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { PipeOptions } from './pipe.schema';
|
|
7
|
-
|
|
8
|
-
describe('Pipe 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: PipeOptions = {
|
|
15
|
-
name: 'foo',
|
|
16
|
-
flat: false,
|
|
17
|
-
};
|
|
18
|
-
const tree: UnitTestTree = runner.runSchematic('pipe', options);
|
|
19
|
-
const files: string[] = tree.files;
|
|
20
|
-
expect(
|
|
21
|
-
files.find(filename => filename === '/foo/foo.pipe.ts'),
|
|
22
|
-
).not.toBeUndefined();
|
|
23
|
-
expect(tree.readContent('/foo/foo.pipe.ts')).toEqual(
|
|
24
|
-
"import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';\n" +
|
|
25
|
-
'\n' +
|
|
26
|
-
'@Injectable()\n' +
|
|
27
|
-
'export class FooPipe implements PipeTransform {\n' +
|
|
28
|
-
' transform(value: any, metadata: ArgumentMetadata) {\n' +
|
|
29
|
-
' return value;\n' +
|
|
30
|
-
' }\n' +
|
|
31
|
-
'}\n',
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
it('should manage name as a path', () => {
|
|
35
|
-
const options: PipeOptions = {
|
|
36
|
-
name: 'bar/foo',
|
|
37
|
-
flat: false,
|
|
38
|
-
};
|
|
39
|
-
const tree: UnitTestTree = runner.runSchematic('pipe', options);
|
|
40
|
-
const files: string[] = tree.files;
|
|
41
|
-
expect(
|
|
42
|
-
files.find(filename => filename === '/bar/foo/foo.pipe.ts'),
|
|
43
|
-
).not.toBeUndefined();
|
|
44
|
-
expect(tree.readContent('/bar/foo/foo.pipe.ts')).toEqual(
|
|
45
|
-
"import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';\n" +
|
|
46
|
-
'\n' +
|
|
47
|
-
'@Injectable()\n' +
|
|
48
|
-
'export class FooPipe implements PipeTransform {\n' +
|
|
49
|
-
' transform(value: any, metadata: ArgumentMetadata) {\n' +
|
|
50
|
-
' return value;\n' +
|
|
51
|
-
' }\n' +
|
|
52
|
-
'}\n',
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
it('should manage name and path', () => {
|
|
56
|
-
const options: PipeOptions = {
|
|
57
|
-
name: 'foo',
|
|
58
|
-
path: 'baz',
|
|
59
|
-
flat: false,
|
|
60
|
-
};
|
|
61
|
-
const tree: UnitTestTree = runner.runSchematic('pipe', options);
|
|
62
|
-
const files: string[] = tree.files;
|
|
63
|
-
expect(
|
|
64
|
-
files.find(filename => filename === '/baz/foo/foo.pipe.ts'),
|
|
65
|
-
).not.toBeUndefined();
|
|
66
|
-
expect(tree.readContent('/baz/foo/foo.pipe.ts')).toEqual(
|
|
67
|
-
"import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';\n" +
|
|
68
|
-
'\n' +
|
|
69
|
-
'@Injectable()\n' +
|
|
70
|
-
'export class FooPipe implements PipeTransform {\n' +
|
|
71
|
-
' transform(value: any, metadata: ArgumentMetadata) {\n' +
|
|
72
|
-
' return value;\n' +
|
|
73
|
-
' }\n' +
|
|
74
|
-
'}\n',
|
|
75
|
-
);
|
|
76
|
-
});
|
|
77
|
-
it('should manage name to dasherize', () => {
|
|
78
|
-
const options: PipeOptions = {
|
|
79
|
-
name: 'fooBar',
|
|
80
|
-
flat: false,
|
|
81
|
-
};
|
|
82
|
-
const tree: UnitTestTree = runner.runSchematic('pipe', options);
|
|
83
|
-
const files: string[] = tree.files;
|
|
84
|
-
expect(
|
|
85
|
-
files.find(filename => filename === '/foo-bar/foo-bar.pipe.ts'),
|
|
86
|
-
).not.toBeUndefined();
|
|
87
|
-
expect(tree.readContent('/foo-bar/foo-bar.pipe.ts')).toEqual(
|
|
88
|
-
"import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';\n" +
|
|
89
|
-
'\n' +
|
|
90
|
-
'@Injectable()\n' +
|
|
91
|
-
'export class FooBarPipe implements PipeTransform {\n' +
|
|
92
|
-
' transform(value: any, metadata: ArgumentMetadata) {\n' +
|
|
93
|
-
' return value;\n' +
|
|
94
|
-
' }\n' +
|
|
95
|
-
'}\n',
|
|
96
|
-
);
|
|
97
|
-
});
|
|
98
|
-
it('should manage path to dasherize', () => {
|
|
99
|
-
const options: PipeOptions = {
|
|
100
|
-
name: 'barBaz/foo',
|
|
101
|
-
flat: false,
|
|
102
|
-
};
|
|
103
|
-
const tree: UnitTestTree = runner.runSchematic('pipe', options);
|
|
104
|
-
const files: string[] = tree.files;
|
|
105
|
-
expect(
|
|
106
|
-
files.find(filename => filename === '/bar-baz/foo/foo.pipe.ts'),
|
|
107
|
-
).not.toBeUndefined();
|
|
108
|
-
expect(tree.readContent('/bar-baz/foo/foo.pipe.ts')).toEqual(
|
|
109
|
-
"import { ArgumentMetadata, Injectable, PipeTransform } from '@nestjs/common';\n" +
|
|
110
|
-
'\n' +
|
|
111
|
-
'@Injectable()\n' +
|
|
112
|
-
'export class FooPipe implements PipeTransform {\n' +
|
|
113
|
-
' transform(value: any, metadata: ArgumentMetadata) {\n' +
|
|
114
|
-
' return value;\n' +
|
|
115
|
-
' }\n' +
|
|
116
|
-
'}\n',
|
|
117
|
-
);
|
|
118
|
-
});
|
|
119
|
-
it('should manage javascript file', () => {
|
|
120
|
-
const options: PipeOptions = {
|
|
121
|
-
name: 'foo',
|
|
122
|
-
language: 'js',
|
|
123
|
-
flat: false,
|
|
124
|
-
};
|
|
125
|
-
const tree: UnitTestTree = runner.runSchematic('pipe', options);
|
|
126
|
-
const files: string[] = tree.files;
|
|
127
|
-
expect(
|
|
128
|
-
files.find(filename => filename === '/foo/foo.pipe.js'),
|
|
129
|
-
).not.toBeUndefined();
|
|
130
|
-
expect(tree.readContent('/foo/foo.pipe.js')).toEqual(
|
|
131
|
-
"import { Injectable } from '@nestjs/common';\n" +
|
|
132
|
-
'\n' +
|
|
133
|
-
'@Injectable()\n' +
|
|
134
|
-
'export class FooPipe {\n' +
|
|
135
|
-
' transform(value, metadata) {\n' +
|
|
136
|
-
' return value;\n' +
|
|
137
|
-
' }\n' +
|
|
138
|
-
'}\n',
|
|
139
|
-
);
|
|
140
|
-
});
|
|
141
|
-
});
|