@rxdi/schematics 0.7.189 → 0.7.191-nightly.0
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,139 +0,0 @@
|
|
|
1
|
-
import { strings } from '@angular-devkit/core';
|
|
2
|
-
import {
|
|
3
|
-
apply,
|
|
4
|
-
branchAndMerge,
|
|
5
|
-
chain,
|
|
6
|
-
externalSchematic,
|
|
7
|
-
mergeWith,
|
|
8
|
-
move,
|
|
9
|
-
noop,
|
|
10
|
-
Rule,
|
|
11
|
-
SchematicContext,
|
|
12
|
-
template,
|
|
13
|
-
Tree,
|
|
14
|
-
url,
|
|
15
|
-
} from '@angular-devkit/schematics';
|
|
16
|
-
import { join } from 'path';
|
|
17
|
-
import * as ts from 'ts-morph';
|
|
18
|
-
import { Path } from 'typescript';
|
|
19
|
-
import {
|
|
20
|
-
DeclarationOptions,
|
|
21
|
-
ModuleDeclarator,
|
|
22
|
-
} from '../../../utils/module.declarator';
|
|
23
|
-
import { ModuleFinder } from '../../../utils/module.finder';
|
|
24
|
-
import { Location, NameParser } from '../../../utils/name.parser';
|
|
25
|
-
import { mergeSourceRoot } from '../../../utils/source-root.helpers';
|
|
26
|
-
import { ModuleOptions } from '../../module/module.schema';
|
|
27
|
-
import { AngularOptions } from './angular.schema';
|
|
28
|
-
|
|
29
|
-
export function main(options: AngularOptions): Rule {
|
|
30
|
-
options = transform(options);
|
|
31
|
-
return (tree: Tree, context: SchematicContext) => {
|
|
32
|
-
return branchAndMerge(
|
|
33
|
-
chain([
|
|
34
|
-
createAngularApplication(options),
|
|
35
|
-
mergeSourceRoot(options),
|
|
36
|
-
addDeclarationToModule(options),
|
|
37
|
-
addGlobalPrefix(),
|
|
38
|
-
mergeWith(generate(options)),
|
|
39
|
-
]),
|
|
40
|
-
)(tree, context);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function transform(source: AngularOptions): ModuleOptions {
|
|
45
|
-
const target: AngularOptions = Object.assign({}, source);
|
|
46
|
-
target.directory = target.name ? strings.dasherize(target.name) : 'client';
|
|
47
|
-
target.name = 'Angular';
|
|
48
|
-
target.metadata = 'imports';
|
|
49
|
-
target.type = 'module';
|
|
50
|
-
|
|
51
|
-
const location: Location = new NameParser().parse(target);
|
|
52
|
-
target.name = strings.dasherize(location.name);
|
|
53
|
-
target.path = join(strings.dasherize(location.path) as Path, target.name);
|
|
54
|
-
return target;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function generate(options: AngularOptions) {
|
|
58
|
-
return (context: SchematicContext) =>
|
|
59
|
-
apply(url('./files' as Path), [
|
|
60
|
-
template({
|
|
61
|
-
...strings,
|
|
62
|
-
...options,
|
|
63
|
-
}),
|
|
64
|
-
move(options.path),
|
|
65
|
-
])(context);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function createAngularApplication(options: AngularOptions): Rule {
|
|
69
|
-
if (!options.initApp) {
|
|
70
|
-
return noop();
|
|
71
|
-
}
|
|
72
|
-
return externalSchematic('@schematics/angular', 'ng-new', {
|
|
73
|
-
name: options.directory,
|
|
74
|
-
version: '7.0.0',
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function addDeclarationToModule(options: AngularOptions): Rule {
|
|
79
|
-
return (tree: Tree) => {
|
|
80
|
-
options.module = new ModuleFinder(tree).find({
|
|
81
|
-
name: options.name,
|
|
82
|
-
path: options.path as any,
|
|
83
|
-
});
|
|
84
|
-
if (!options.module) {
|
|
85
|
-
return tree;
|
|
86
|
-
}
|
|
87
|
-
const content = tree.read(options.module).toString();
|
|
88
|
-
const declarator: ModuleDeclarator = new ModuleDeclarator();
|
|
89
|
-
|
|
90
|
-
const rootPath = `${options.directory}/dist/${options.directory}`;
|
|
91
|
-
const declarationOptions = ({
|
|
92
|
-
...options,
|
|
93
|
-
staticOptions: {
|
|
94
|
-
name: 'forRoot',
|
|
95
|
-
value: {
|
|
96
|
-
rootPath,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
} as unknown) as DeclarationOptions;
|
|
100
|
-
tree.overwrite(
|
|
101
|
-
options.module,
|
|
102
|
-
declarator.declare(content, declarationOptions),
|
|
103
|
-
);
|
|
104
|
-
return tree;
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function addGlobalPrefix(): Rule {
|
|
109
|
-
return (tree: Tree) => {
|
|
110
|
-
const mainFilePath = 'src/main.ts';
|
|
111
|
-
const fileRef = tree.get(mainFilePath);
|
|
112
|
-
if (!fileRef) {
|
|
113
|
-
return tree;
|
|
114
|
-
}
|
|
115
|
-
const tsProject = new ts.Project({
|
|
116
|
-
manipulationSettings: {
|
|
117
|
-
indentationText: ts.IndentationText.TwoSpaces,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
const tsFile = tsProject.addExistingSourceFile(mainFilePath);
|
|
121
|
-
const bootstrapFunction = tsFile.getFunction('bootstrap');
|
|
122
|
-
const listenStatement = bootstrapFunction.getStatement(node =>
|
|
123
|
-
node.getText().includes('listen'),
|
|
124
|
-
);
|
|
125
|
-
const setPrefixStatement = bootstrapFunction.getStatement(node =>
|
|
126
|
-
node.getText().includes('setGlobalPrefix'),
|
|
127
|
-
);
|
|
128
|
-
if (!listenStatement || setPrefixStatement) {
|
|
129
|
-
return tree;
|
|
130
|
-
}
|
|
131
|
-
const listenExprIndex = listenStatement.getChildIndex();
|
|
132
|
-
bootstrapFunction.insertStatements(
|
|
133
|
-
listenExprIndex,
|
|
134
|
-
`app.setGlobalPrefix('api');`,
|
|
135
|
-
);
|
|
136
|
-
tree.overwrite(mainFilePath, tsFile.getFullText());
|
|
137
|
-
return tree;
|
|
138
|
-
};
|
|
139
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Path } from '@angular-devkit/core';
|
|
2
|
-
|
|
3
|
-
export interface AngularOptions {
|
|
4
|
-
/**
|
|
5
|
-
* The name of the application.
|
|
6
|
-
*/
|
|
7
|
-
name: string;
|
|
8
|
-
/**
|
|
9
|
-
* The directory of the application.
|
|
10
|
-
*/
|
|
11
|
-
directory?: string;
|
|
12
|
-
/**
|
|
13
|
-
* The path to create the module.
|
|
14
|
-
*/
|
|
15
|
-
path?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The path to insert the module declaration.
|
|
18
|
-
*/
|
|
19
|
-
module?: Path;
|
|
20
|
-
/**
|
|
21
|
-
* Flag which indicates if Angular app should be scaffolded
|
|
22
|
-
*/
|
|
23
|
-
initApp?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Metadata name affected by declaration insertion.
|
|
26
|
-
*/
|
|
27
|
-
metadata?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Nest element type name
|
|
30
|
-
*/
|
|
31
|
-
type?: string;
|
|
32
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { DynamicModule, Inject, Module, OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { HttpAdapterHost } from '@nestjs/core';
|
|
3
|
-
import {
|
|
4
|
-
ANGULAR_MODULE_OPTIONS,
|
|
5
|
-
DEFAULT_RENDER_PATH,
|
|
6
|
-
DEFAULT_ROOT_PATH,
|
|
7
|
-
} from './angular.constants';
|
|
8
|
-
import { angularProviders } from './angular.providers';
|
|
9
|
-
import { AngularModuleOptions } from './interfaces/angular-options.interface';
|
|
10
|
-
import { AbstractLoader } from './loaders/abstract.loader';
|
|
11
|
-
|
|
12
|
-
@Module({
|
|
13
|
-
providers: [...angularProviders],
|
|
14
|
-
})
|
|
15
|
-
export class AngularModule implements OnModuleInit {
|
|
16
|
-
constructor(
|
|
17
|
-
@Inject(ANGULAR_MODULE_OPTIONS)
|
|
18
|
-
private readonly ngOptions: AngularModuleOptions,
|
|
19
|
-
private readonly loader: AbstractLoader,
|
|
20
|
-
private readonly httpAdapterHost: HttpAdapterHost,
|
|
21
|
-
) {}
|
|
22
|
-
|
|
23
|
-
public static forRoot(options: AngularModuleOptions = {}): DynamicModule {
|
|
24
|
-
options.rootPath = options.rootPath || DEFAULT_ROOT_PATH;
|
|
25
|
-
options.renderPath = options.renderPath || DEFAULT_RENDER_PATH;
|
|
26
|
-
return {
|
|
27
|
-
module: AngularModule,
|
|
28
|
-
providers: [
|
|
29
|
-
{
|
|
30
|
-
provide: ANGULAR_MODULE_OPTIONS,
|
|
31
|
-
useValue: options,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public async onModuleInit() {
|
|
38
|
-
const httpAdapter = this.httpAdapterHost.httpAdapter;
|
|
39
|
-
this.loader.register(httpAdapter, this.ngOptions);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Provider } from '@nestjs/common';
|
|
2
|
-
import { HttpAdapterHost } from '@nestjs/core';
|
|
3
|
-
import { AbstractLoader } from './loaders/abstract.loader';
|
|
4
|
-
import { ExpressLoader } from './loaders/express.loader';
|
|
5
|
-
import { FastifyLoader } from './loaders/fastify.loader';
|
|
6
|
-
import { NoopLoader } from './loaders/noop.loader';
|
|
7
|
-
|
|
8
|
-
export const angularProviders: Provider[] = [
|
|
9
|
-
{
|
|
10
|
-
provide: AbstractLoader,
|
|
11
|
-
useFactory: (httpAdapterHost: HttpAdapterHost) => {
|
|
12
|
-
if (!httpAdapterHost) {
|
|
13
|
-
return new NoopLoader();
|
|
14
|
-
}
|
|
15
|
-
const httpAdapter = httpAdapterHost.httpAdapter;
|
|
16
|
-
if (
|
|
17
|
-
httpAdapter &&
|
|
18
|
-
httpAdapter.constructor &&
|
|
19
|
-
httpAdapter.constructor.name === 'FastifyAdapter'
|
|
20
|
-
) {
|
|
21
|
-
return new FastifyLoader();
|
|
22
|
-
}
|
|
23
|
-
return new ExpressLoader();
|
|
24
|
-
},
|
|
25
|
-
inject: [HttpAdapterHost],
|
|
26
|
-
},
|
|
27
|
-
];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@nestjs/common';
|
|
2
|
-
|
|
3
|
-
const MISSING_REQUIRED_DEPENDENCY = (name: string, reason: string) =>
|
|
4
|
-
`The "${name}" package is missing. Please, make sure to install this library ($ npm install ${name}) to take advantage of ${reason}.`;
|
|
5
|
-
|
|
6
|
-
const logger = new Logger('PackageLoader');
|
|
7
|
-
|
|
8
|
-
export function loadPackage<T = any>(
|
|
9
|
-
packageName: string,
|
|
10
|
-
context: string,
|
|
11
|
-
loaderFn?: () => T,
|
|
12
|
-
): T {
|
|
13
|
-
try {
|
|
14
|
-
return loaderFn ? loaderFn() : require(packageName);
|
|
15
|
-
} catch (e) {
|
|
16
|
-
logger.error(MISSING_REQUIRED_DEPENDENCY(packageName, context));
|
|
17
|
-
process.exit(1);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
export interface AngularModuleOptions {
|
|
2
|
-
/**
|
|
3
|
-
* Static files root directory.
|
|
4
|
-
* Default: "client/dist"
|
|
5
|
-
*/
|
|
6
|
-
rootPath?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Path to render Angular app.
|
|
9
|
-
* Default: * (wildcard - all paths)
|
|
10
|
-
*/
|
|
11
|
-
renderPath?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Serve static options (static files)
|
|
14
|
-
* Passed down to the underlying either `express.static` or `fastify-static.send`
|
|
15
|
-
*/
|
|
16
|
-
serveStaticOptions?: {
|
|
17
|
-
/**
|
|
18
|
-
* Enable or disable setting Cache-Control response header, defaults to true.
|
|
19
|
-
* Disabling this will ignore the immutable and maxAge options.
|
|
20
|
-
*/
|
|
21
|
-
cacheControl?: boolean;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
|
|
25
|
-
* Note this check is done on the path itself without checking if the path actually exists on the disk.
|
|
26
|
-
* If root is specified, only the dotfiles above the root are checked
|
|
27
|
-
* (i.e. the root itself can be within a dotfile when when set to "deny").
|
|
28
|
-
* The default value is 'ignore'.
|
|
29
|
-
* 'allow' No special treatment for dotfiles
|
|
30
|
-
* 'deny' Send a 403 for any request for a dotfile
|
|
31
|
-
* 'ignore' Pretend like the dotfile does not exist and call next()
|
|
32
|
-
*/
|
|
33
|
-
dotfiles?: string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Enable or disable etag generation, defaults to true.
|
|
37
|
-
*/
|
|
38
|
-
etag?: boolean;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Set file extension fallbacks. When set, if a file is not found, the given extensions
|
|
42
|
-
* will be added to the file name and search for.
|
|
43
|
-
* The first that exists will be served. Example: ['html', 'htm'].
|
|
44
|
-
* The default value is false.
|
|
45
|
-
*/
|
|
46
|
-
extensions?: string[];
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Enable or disable the immutable directive in the Cache-Control response header.
|
|
50
|
-
* If enabled, the maxAge option should also be specified to enable caching.
|
|
51
|
-
* The immutable directive will prevent supported clients from making conditional
|
|
52
|
-
* requests during the life of the maxAge option to check if the file has changed.
|
|
53
|
-
*/
|
|
54
|
-
immutable?: boolean;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* By default this module will send "index.html" files in response to a request on a directory.
|
|
58
|
-
* To disable this set false or to supply a new index pass a string or an array in preferred order.
|
|
59
|
-
*/
|
|
60
|
-
index?: boolean | string | string[];
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
|
|
64
|
-
*/
|
|
65
|
-
lastModified?: boolean;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Provide a max-age in milliseconds for http caching, defaults to 0.
|
|
69
|
-
* This can also be a string accepted by the ms module.
|
|
70
|
-
*/
|
|
71
|
-
maxAge?: number | string;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Redirect to trailing "/" when the pathname is a dir. Defaults to true.
|
|
75
|
-
*/
|
|
76
|
-
redirect?: boolean;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Function to set custom headers on response. Alterations to the headers need to occur synchronously.
|
|
80
|
-
* The function is called as fn(res, path, stat), where the arguments are:
|
|
81
|
-
* res the response object
|
|
82
|
-
* path the file path that is being sent
|
|
83
|
-
* stat the stat object of the file that is being sent
|
|
84
|
-
*/
|
|
85
|
-
setHeaders?: (res: any, path: string, stat: any) => any;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { AbstractHttpAdapter } from '@nestjs/core';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export abstract class AbstractLoader {
|
|
8
|
-
public abstract register(
|
|
9
|
-
httpAdapter: AbstractHttpAdapter,
|
|
10
|
-
options: AngularModuleOptions,
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
public getIndexFilePath(clientPath: string): string {
|
|
14
|
-
return join(clientPath, 'index.html');
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { AbstractHttpAdapter } from '@nestjs/core';
|
|
3
|
-
import { loadPackage } from '../angular.utils';
|
|
4
|
-
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
|
|
5
|
-
import { AbstractLoader } from './abstract.loader';
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class ExpressLoader extends AbstractLoader {
|
|
9
|
-
public register(
|
|
10
|
-
httpAdapter: AbstractHttpAdapter,
|
|
11
|
-
options: AngularModuleOptions,
|
|
12
|
-
) {
|
|
13
|
-
const app = httpAdapter.getInstance();
|
|
14
|
-
const express = loadPackage('express', 'AngularModule', () =>
|
|
15
|
-
require('express'),
|
|
16
|
-
);
|
|
17
|
-
const clientPath = options.rootPath;
|
|
18
|
-
const indexFilePath = this.getIndexFilePath(clientPath);
|
|
19
|
-
|
|
20
|
-
app.use(express.static(clientPath, options.serveStaticOptions));
|
|
21
|
-
app.get(options.renderPath, (req: any, res: any) =>
|
|
22
|
-
res.sendFile(indexFilePath),
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { AbstractHttpAdapter } from '@nestjs/core';
|
|
3
|
-
import * as fs from 'fs';
|
|
4
|
-
import { loadPackage } from '../angular.utils';
|
|
5
|
-
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
|
|
6
|
-
import { AbstractLoader } from './abstract.loader';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class FastifyLoader extends AbstractLoader {
|
|
10
|
-
public register(
|
|
11
|
-
httpAdapter: AbstractHttpAdapter,
|
|
12
|
-
options: AngularModuleOptions,
|
|
13
|
-
) {
|
|
14
|
-
const app = httpAdapter.getInstance();
|
|
15
|
-
const fastifyStatic = loadPackage('fastify-static', 'AngularModule', () =>
|
|
16
|
-
require('fastify-static'),
|
|
17
|
-
);
|
|
18
|
-
const { setHeaders, redirect, ...send } =
|
|
19
|
-
options.serveStaticOptions || ({} as any);
|
|
20
|
-
const clientPath = options.rootPath;
|
|
21
|
-
const indexFilePath = this.getIndexFilePath(clientPath);
|
|
22
|
-
|
|
23
|
-
app.register(fastifyStatic, {
|
|
24
|
-
root: clientPath,
|
|
25
|
-
setHeaders,
|
|
26
|
-
redirect,
|
|
27
|
-
send,
|
|
28
|
-
});
|
|
29
|
-
app.get(options.renderPath, (req: any, res: any) => {
|
|
30
|
-
const stream = fs.createReadStream(indexFilePath);
|
|
31
|
-
res.type('text/html').send(stream);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { AbstractHttpAdapter } from '@nestjs/core';
|
|
3
|
-
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
|
|
4
|
-
import { AbstractLoader } from './abstract.loader';
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class NoopLoader extends AbstractLoader {
|
|
8
|
-
public register(
|
|
9
|
-
httpAdapter: AbstractHttpAdapter,
|
|
10
|
-
options: AngularModuleOptions,
|
|
11
|
-
) {}
|
|
12
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"id": "SchematicsNestModule",
|
|
4
|
-
"title": "Nest Module 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 Angular application?"
|
|
15
|
-
},
|
|
16
|
-
"initApp": {
|
|
17
|
-
"type": "boolean",
|
|
18
|
-
"description": "Flag to skip the angular application generation.",
|
|
19
|
-
"default": false,
|
|
20
|
-
"x-prompt": "Would you like to initialize Angular application?"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"required": ["name"]
|
|
24
|
-
}
|
|
@@ -1,24 +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
|
-
return (0, schematics_1.mergeWith)(generate(transform(options)));
|
|
9
|
-
}
|
|
10
|
-
exports.main = main;
|
|
11
|
-
function transform(options) {
|
|
12
|
-
const target = Object.assign({}, options);
|
|
13
|
-
target.language =
|
|
14
|
-
target.language !== undefined ? target.language : defaults_1.DEFAULT_LANGUAGE;
|
|
15
|
-
target.collection =
|
|
16
|
-
target.collection !== undefined ? target.collection : '@nestjs/schematics';
|
|
17
|
-
return target;
|
|
18
|
-
}
|
|
19
|
-
function generate(options) {
|
|
20
|
-
return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
21
|
-
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
22
|
-
(0, schematics_1.move)(options.project),
|
|
23
|
-
]);
|
|
24
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SchematicTestRunner,
|
|
3
|
-
UnitTestTree,
|
|
4
|
-
} from '@angular-devkit/schematics/testing';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { ConfigurationOptions } from './configuration.schema';
|
|
7
|
-
|
|
8
|
-
describe('Configuration Factory', () => {
|
|
9
|
-
const runner: SchematicTestRunner = new SchematicTestRunner(
|
|
10
|
-
'.',
|
|
11
|
-
path.join(process.cwd(), 'src/collection.json'),
|
|
12
|
-
);
|
|
13
|
-
it('should manage a default configuation', () => {
|
|
14
|
-
const options: ConfigurationOptions = {
|
|
15
|
-
project: 'project',
|
|
16
|
-
};
|
|
17
|
-
const tree: UnitTestTree = runner.runSchematic('configuration', options);
|
|
18
|
-
const files: string[] = tree.files;
|
|
19
|
-
expect(
|
|
20
|
-
files.find(filename => filename === '/project/nest-cli.json'),
|
|
21
|
-
).not.toBeUndefined();
|
|
22
|
-
expect(JSON.parse(tree.readContent('/project/nest-cli.json'))).toEqual({
|
|
23
|
-
language: 'ts',
|
|
24
|
-
collection: '@nestjs/schematics',
|
|
25
|
-
sourceRoot: 'src',
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
it('should manage provided language input', () => {
|
|
29
|
-
const options: ConfigurationOptions = {
|
|
30
|
-
project: 'project',
|
|
31
|
-
language: 'js',
|
|
32
|
-
};
|
|
33
|
-
const tree: UnitTestTree = runner.runSchematic('configuration', options);
|
|
34
|
-
const files: string[] = tree.files;
|
|
35
|
-
expect(
|
|
36
|
-
files.find(filename => filename === '/project/nest-cli.json'),
|
|
37
|
-
).not.toBeUndefined();
|
|
38
|
-
expect(JSON.parse(tree.readContent('/project/nest-cli.json'))).toEqual({
|
|
39
|
-
language: 'js',
|
|
40
|
-
collection: '@nestjs/schematics',
|
|
41
|
-
sourceRoot: 'src',
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
it('should manage provided collection input', () => {
|
|
45
|
-
const options: ConfigurationOptions = {
|
|
46
|
-
project: 'project',
|
|
47
|
-
collection: 'foo',
|
|
48
|
-
};
|
|
49
|
-
const tree: UnitTestTree = runner.runSchematic('configuration', options);
|
|
50
|
-
const files: string[] = tree.files;
|
|
51
|
-
expect(
|
|
52
|
-
files.find(filename => filename === '/project/nest-cli.json'),
|
|
53
|
-
).not.toBeUndefined();
|
|
54
|
-
expect(JSON.parse(tree.readContent('/project/nest-cli.json'))).toEqual({
|
|
55
|
-
language: 'ts',
|
|
56
|
-
collection: 'foo',
|
|
57
|
-
sourceRoot: 'src',
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { join, Path, strings } from '@angular-devkit/core';
|
|
2
|
-
import {
|
|
3
|
-
apply,
|
|
4
|
-
mergeWith,
|
|
5
|
-
move,
|
|
6
|
-
Rule,
|
|
7
|
-
Source,
|
|
8
|
-
template,
|
|
9
|
-
url,
|
|
10
|
-
} from '@angular-devkit/schematics';
|
|
11
|
-
import { DEFAULT_LANGUAGE } from '../defaults';
|
|
12
|
-
import { ConfigurationOptions } from './configuration.schema';
|
|
13
|
-
|
|
14
|
-
export function main(options: ConfigurationOptions): Rule {
|
|
15
|
-
return mergeWith(generate(transform(options)));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function transform(options: ConfigurationOptions): ConfigurationOptions {
|
|
19
|
-
const target: ConfigurationOptions = Object.assign({}, options);
|
|
20
|
-
target.language =
|
|
21
|
-
target.language !== undefined ? target.language : DEFAULT_LANGUAGE;
|
|
22
|
-
target.collection =
|
|
23
|
-
target.collection !== undefined ? target.collection : '@nestjs/schematics';
|
|
24
|
-
return target;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function generate(options: ConfigurationOptions): Source {
|
|
28
|
-
return apply(url(join('./files' as Path, options.language)), [
|
|
29
|
-
template({
|
|
30
|
-
...strings,
|
|
31
|
-
...options,
|
|
32
|
-
}),
|
|
33
|
-
move(options.project),
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export interface ConfigurationOptions {
|
|
2
|
-
/**
|
|
3
|
-
* The project where generate the configuration.
|
|
4
|
-
*/
|
|
5
|
-
project: string;
|
|
6
|
-
/**
|
|
7
|
-
* The language to use in configuration (ts | js).
|
|
8
|
-
*/
|
|
9
|
-
language?: string;
|
|
10
|
-
/**
|
|
11
|
-
* The collection to use in the configuration
|
|
12
|
-
*/
|
|
13
|
-
collection?: string;
|
|
14
|
-
/**
|
|
15
|
-
* The source root directory
|
|
16
|
-
*/
|
|
17
|
-
sourceRoot?: string;
|
|
18
|
-
}
|
|
@@ -1,32 +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
|
-
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
30
|
-
(0, schematics_1.move)(options.path),
|
|
31
|
-
])(context);
|
|
32
|
-
}
|