UNPKG

4.19 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11Object.defineProperty(exports, "__esModule", { value: true });
12exports.NestCollection = void 0;
13const abstract_collection_1 = require("./abstract.collection");
14class NestCollection extends abstract_collection_1.AbstractCollection {
15 constructor(runner) {
16 super('@nestjs/schematics', runner);
17 }
18 execute(name, options) {
19 const _super = Object.create(null, {
20 execute: { get: () => super.execute }
21 });
22 return __awaiter(this, void 0, void 0, function* () {
23 const schematic = this.validate(name);
24 yield _super.execute.call(this, schematic, options);
25 });
26 }
27 getSchematics() {
28 return NestCollection.schematics.filter((item) => item.name !== 'angular-app');
29 }
30 validate(name) {
31 const schematic = NestCollection.schematics.find((s) => s.name === name || s.alias === name);
32 if (schematic === undefined || schematic === null) {
33 throw new Error(`Invalid schematic "${name}". Please, ensure that "${name}" exists in this collection.`);
34 }
35 return schematic.name;
36 }
37}
38exports.NestCollection = NestCollection;
39NestCollection.schematics = [
40 {
41 name: 'application',
42 alias: 'application',
43 description: 'Generate a new application workspace',
44 },
45 {
46 name: 'angular-app',
47 alias: 'ng-app',
48 description: '',
49 },
50 {
51 name: 'class',
52 alias: 'cl',
53 description: 'Generate a new class',
54 },
55 {
56 name: 'configuration',
57 alias: 'config',
58 description: 'Generate a CLI configuration file',
59 },
60 {
61 name: 'controller',
62 alias: 'co',
63 description: 'Generate a controller declaration',
64 },
65 {
66 name: 'decorator',
67 alias: 'd',
68 description: 'Generate a custom decorator',
69 },
70 {
71 name: 'filter',
72 alias: 'f',
73 description: 'Generate a filter declaration',
74 },
75 {
76 name: 'gateway',
77 alias: 'ga',
78 description: 'Generate a gateway declaration',
79 },
80 {
81 name: 'guard',
82 alias: 'gu',
83 description: 'Generate a guard declaration',
84 },
85 {
86 name: 'interceptor',
87 alias: 'itc',
88 description: 'Generate an interceptor declaration',
89 },
90 {
91 name: 'interface',
92 alias: 'itf',
93 description: 'Generate an interface',
94 },
95 {
96 name: 'library',
97 alias: 'lib',
98 description: 'Generate a new library within a monorepo',
99 },
100 {
101 name: 'middleware',
102 alias: 'mi',
103 description: 'Generate a middleware declaration',
104 },
105 {
106 name: 'module',
107 alias: 'mo',
108 description: 'Generate a module declaration',
109 },
110 {
111 name: 'pipe',
112 alias: 'pi',
113 description: 'Generate a pipe declaration',
114 },
115 {
116 name: 'provider',
117 alias: 'pr',
118 description: 'Generate a provider declaration',
119 },
120 {
121 name: 'resolver',
122 alias: 'r',
123 description: 'Generate a GraphQL resolver declaration',
124 },
125 {
126 name: 'resource',
127 alias: 'res',
128 description: 'Generate a new CRUD resource',
129 },
130 {
131 name: 'service',
132 alias: 's',
133 description: 'Generate a service declaration',
134 },
135 {
136 name: 'sub-app',
137 alias: 'app',
138 description: 'Generate a new application within a monorepo',
139 },
140];