@necord/schematics 1.1.5 → 1.1.6
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/dist/common/common-options.interface.d.ts +11 -0
- package/dist/common/common-options.interface.js +3 -0
- package/dist/common/common-options.interface.js.map +1 -0
- package/dist/common/index.d.ts +12 -0
- package/dist/common/index.js +75 -0
- package/dist/common/index.js.map +1 -0
- package/{src/context-menu/context-menu-options.interface.ts → dist/context-menu/context-menu-options.interface.d.ts} +1 -2
- package/dist/context-menu/context-menu-options.interface.js +3 -0
- package/dist/context-menu/context-menu-options.interface.js.map +1 -0
- package/dist/context-menu/context-menu-type.enum.d.ts +4 -0
- package/dist/context-menu/context-menu-type.enum.js +9 -0
- package/dist/context-menu/context-menu-type.enum.js.map +1 -0
- package/dist/context-menu/index.d.ts +3 -0
- package/dist/context-menu/index.js +28 -0
- package/dist/context-menu/index.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +4 -2
- package/src/collection.json +0 -13
- package/src/command/schema.json +0 -30
- package/src/common/common-options.interface.ts +0 -12
- package/src/common/index.ts +0 -88
- package/src/context-menu/context-menu-type.enum.ts +0 -4
- package/src/context-menu/files/user-menu/__name@dasherize__.commands.ts.template +0 -14
- package/src/context-menu/index.ts +0 -26
- package/src/context-menu/schema.json +0 -42
- package/src/index.ts +0 -0
- package/src/message-component/schema.json +0 -30
- package/src/modals/schema.json +0 -30
- /package/{src/context-menu/files/message-menu/__name@dasherize__.commands.ts.template → dist/index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-options.interface.js","sourceRoot":"","sources":["../../src/common/common-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Rule, Source } from '@angular-devkit/schematics';
|
|
2
|
+
import { CommonOptions } from './common-options.interface';
|
|
3
|
+
export * from './common-options.interface';
|
|
4
|
+
export declare class CommonSchematicFactory<T extends CommonOptions = CommonOptions> {
|
|
5
|
+
templatePath: string;
|
|
6
|
+
type: string;
|
|
7
|
+
metadata: string;
|
|
8
|
+
create(options: T): Rule;
|
|
9
|
+
generate(options: T): Source;
|
|
10
|
+
addDeclarationToModule(options: T): Rule;
|
|
11
|
+
transform(source: T): T;
|
|
12
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.CommonSchematicFactory = void 0;
|
|
18
|
+
const core_1 = require("@angular-devkit/core");
|
|
19
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
20
|
+
const schematics_2 = require("@nestjs/schematics");
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
__exportStar(require("./common-options.interface"), exports);
|
|
23
|
+
class CommonSchematicFactory {
|
|
24
|
+
constructor() {
|
|
25
|
+
this.templatePath = './files';
|
|
26
|
+
this.type = 'service';
|
|
27
|
+
this.metadata = 'providers';
|
|
28
|
+
}
|
|
29
|
+
create(options) {
|
|
30
|
+
options = this.transform(options);
|
|
31
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([(0, schematics_1.mergeWith)(this.generate(options)), this.addDeclarationToModule(options), (0, schematics_2.mergeSourceRoot)(options)]));
|
|
32
|
+
}
|
|
33
|
+
generate(options) {
|
|
34
|
+
return (context) => {
|
|
35
|
+
var _a;
|
|
36
|
+
return (0, schematics_1.apply)((0, schematics_1.url)((0, path_1.join)(this.templatePath)), [
|
|
37
|
+
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
|
|
38
|
+
(0, schematics_1.applyTemplates)(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { lowercase: (str) => str.toLowerCase() })),
|
|
39
|
+
(0, schematics_1.move)((_a = options.path) !== null && _a !== void 0 ? _a : '')
|
|
40
|
+
])(context);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
addDeclarationToModule(options) {
|
|
44
|
+
return (tree) => {
|
|
45
|
+
var _a;
|
|
46
|
+
options.module = new schematics_2.ModuleFinder(tree).find({
|
|
47
|
+
name: options.name,
|
|
48
|
+
path: options.path
|
|
49
|
+
});
|
|
50
|
+
if (options.module === undefined || options.module === null) {
|
|
51
|
+
return tree;
|
|
52
|
+
}
|
|
53
|
+
const rawContent = tree.read(options.module);
|
|
54
|
+
const content = (_a = rawContent === null || rawContent === void 0 ? void 0 : rawContent.toString()) !== null && _a !== void 0 ? _a : '';
|
|
55
|
+
const declarator = new schematics_2.ModuleDeclarator();
|
|
56
|
+
tree.overwrite(options.module, declarator.declare(content, options));
|
|
57
|
+
return tree;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
transform(source) {
|
|
61
|
+
const target = Object.assign({}, source);
|
|
62
|
+
target.metadata = this.metadata;
|
|
63
|
+
target.type = this.type;
|
|
64
|
+
if (target.name === null || target.name === undefined) {
|
|
65
|
+
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
66
|
+
}
|
|
67
|
+
const location = new schematics_2.NameParser().parse(target);
|
|
68
|
+
target.name = core_1.strings.dasherize(location.name);
|
|
69
|
+
target.path = core_1.strings.dasherize(location.path);
|
|
70
|
+
target.path = target.flat ? target.path : (0, path_1.join)(target.path, target.name);
|
|
71
|
+
return target;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.CommonSchematicFactory = CommonSchematicFactory;
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu-options.interface.js","sourceRoot":"","sources":["../../src/context-menu/context-menu-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextMenuType = void 0;
|
|
4
|
+
var ContextMenuType;
|
|
5
|
+
(function (ContextMenuType) {
|
|
6
|
+
ContextMenuType["Message"] = "message";
|
|
7
|
+
ContextMenuType["User"] = "user";
|
|
8
|
+
})(ContextMenuType = exports.ContextMenuType || (exports.ContextMenuType = {}));
|
|
9
|
+
//# sourceMappingURL=context-menu-type.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu-type.enum.js","sourceRoot":"","sources":["../../src/context-menu/context-menu-type.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,eAGX;AAHD,WAAY,eAAe;IAC1B,sCAAmB,CAAA;IACnB,gCAAa,CAAA;AACd,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contextMenu = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
5
|
+
const context_menu_type_enum_1 = require("./context-menu-type.enum");
|
|
6
|
+
class ContextMenuSchematicFactory extends common_1.CommonSchematicFactory {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.type = 'context-menu';
|
|
10
|
+
}
|
|
11
|
+
generate(options) {
|
|
12
|
+
switch (options.type) {
|
|
13
|
+
case context_menu_type_enum_1.ContextMenuType.Message:
|
|
14
|
+
this.templatePath = './files/message-menu';
|
|
15
|
+
break;
|
|
16
|
+
case context_menu_type_enum_1.ContextMenuType.User:
|
|
17
|
+
this.templatePath = './files/user-menu';
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
return super.generate(options);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function contextMenu(options) {
|
|
24
|
+
const contextMenuFactory = new ContextMenuSchematicFactory();
|
|
25
|
+
return contextMenuFactory.create(options);
|
|
26
|
+
}
|
|
27
|
+
exports.contextMenu = contextMenu;
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/context-menu/index.ts"],"names":[],"mappings":";;;AAAA,sCAAmD;AAGnD,qEAA2D;AAE3D,MAAM,2BAA4B,SAAQ,+BAA0C;IAApF;;QACQ,SAAI,GAAG,cAAc,CAAC;IAc9B,CAAC;IAZA,QAAQ,CAAC,OAA2B;QACnC,QAAQ,OAAO,CAAC,IAAI,EAAE;YACrB,KAAK,wCAAe,CAAC,OAAO;gBAC3B,IAAI,CAAC,YAAY,GAAG,sBAAsB,CAAC;gBAC3C,MAAM;YACP,KAAK,wCAAe,CAAC,IAAI;gBACxB,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC;gBACxC,MAAM;SACP;QAED,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACD;AAED,SAAgB,WAAW,CAAC,OAA2B;IACtD,MAAM,kBAAkB,GAAG,IAAI,2BAA2B,EAAE,CAAC;IAC7D,OAAO,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAHD,kCAGC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@necord/schematics",
|
|
3
3
|
"description": "A collection of schematics for Necord projects with NestJS",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.6",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf -rf dist && tsc -p tsconfig.json",
|
|
7
7
|
"prepublish:npm": "npm run build",
|
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
"test": "jest"
|
|
15
15
|
},
|
|
16
16
|
"schematics": "./src/collection.json",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"typings": "dist/index.d.ts",
|
|
17
19
|
"files": [
|
|
18
|
-
"
|
|
20
|
+
"dist/**/*",
|
|
19
21
|
"*.md"
|
|
20
22
|
],
|
|
21
23
|
"publishConfig": {
|
package/src/collection.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
-
"schematics": {
|
|
4
|
-
"context-menu": {
|
|
5
|
-
"description": "Generates a context menu component.",
|
|
6
|
-
"factory": "./context-menu/index#contextMenu",
|
|
7
|
-
"schema": "./context-menu/schema.json",
|
|
8
|
-
"aliases": [
|
|
9
|
-
"cm"
|
|
10
|
-
]
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
package/src/command/schema.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"properties": {
|
|
3
|
-
"name": {
|
|
4
|
-
"type": "string",
|
|
5
|
-
"minLength": 1,
|
|
6
|
-
"x-prompt": "What is the questions set name?"
|
|
7
|
-
},
|
|
8
|
-
"path": {
|
|
9
|
-
"type": "string",
|
|
10
|
-
"format": "path",
|
|
11
|
-
"description": "The path to create the service."
|
|
12
|
-
},
|
|
13
|
-
"sourceRoot": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"description": "Nest service source root directory."
|
|
16
|
-
},
|
|
17
|
-
"flat": {
|
|
18
|
-
"type": "boolean",
|
|
19
|
-
"default": false,
|
|
20
|
-
"description": "Flag to indicate if a directory is created.",
|
|
21
|
-
"x-prompt": "Create a directory?"
|
|
22
|
-
},
|
|
23
|
-
"spec": {
|
|
24
|
-
"type": "boolean",
|
|
25
|
-
"default": true,
|
|
26
|
-
"description": "Specifies if a spec file is generated.",
|
|
27
|
-
"x-prompt": "Generate spec file as well?"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
package/src/common/index.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Path, strings } from '@angular-devkit/core';
|
|
2
|
-
import {
|
|
3
|
-
apply,
|
|
4
|
-
applyTemplates,
|
|
5
|
-
branchAndMerge,
|
|
6
|
-
chain,
|
|
7
|
-
filter,
|
|
8
|
-
mergeWith,
|
|
9
|
-
move,
|
|
10
|
-
noop,
|
|
11
|
-
Rule,
|
|
12
|
-
SchematicContext,
|
|
13
|
-
SchematicsException,
|
|
14
|
-
Source,
|
|
15
|
-
Tree,
|
|
16
|
-
url
|
|
17
|
-
} from '@angular-devkit/schematics';
|
|
18
|
-
import {
|
|
19
|
-
DeclarationOptions,
|
|
20
|
-
Location,
|
|
21
|
-
mergeSourceRoot,
|
|
22
|
-
ModuleDeclarator,
|
|
23
|
-
ModuleFinder,
|
|
24
|
-
NameParser
|
|
25
|
-
} from '@nestjs/schematics';
|
|
26
|
-
import { join } from 'path';
|
|
27
|
-
import { CommonOptions } from './common-options.interface';
|
|
28
|
-
|
|
29
|
-
export * from './common-options.interface';
|
|
30
|
-
|
|
31
|
-
export class CommonSchematicFactory<T extends CommonOptions = CommonOptions> {
|
|
32
|
-
public templatePath = './files';
|
|
33
|
-
public type = 'service';
|
|
34
|
-
public metadata = 'providers';
|
|
35
|
-
|
|
36
|
-
public create(options: T): Rule {
|
|
37
|
-
options = this.transform(options);
|
|
38
|
-
return branchAndMerge(
|
|
39
|
-
chain([mergeWith(this.generate(options)), this.addDeclarationToModule(options), mergeSourceRoot(options)])
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public generate(options: T): Source {
|
|
44
|
-
return (context: SchematicContext) =>
|
|
45
|
-
apply(url(join(this.templatePath as Path)), [
|
|
46
|
-
options.spec ? noop() : filter((path: string) => !path.endsWith('.spec.ts')),
|
|
47
|
-
applyTemplates({
|
|
48
|
-
...strings,
|
|
49
|
-
...options,
|
|
50
|
-
lowercase: (str: string) => str.toLowerCase()
|
|
51
|
-
}),
|
|
52
|
-
move(options.path ?? '')
|
|
53
|
-
])(context);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public addDeclarationToModule(options: T): Rule {
|
|
57
|
-
return (tree: Tree) => {
|
|
58
|
-
options.module = new ModuleFinder(tree).find({
|
|
59
|
-
name: options.name,
|
|
60
|
-
path: options.path as Path
|
|
61
|
-
});
|
|
62
|
-
if (options.module === undefined || options.module === null) {
|
|
63
|
-
return tree;
|
|
64
|
-
}
|
|
65
|
-
const rawContent = tree.read(options.module);
|
|
66
|
-
const content = rawContent?.toString() ?? '';
|
|
67
|
-
const declarator: ModuleDeclarator = new ModuleDeclarator();
|
|
68
|
-
tree.overwrite(options.module, declarator.declare(content, options as DeclarationOptions));
|
|
69
|
-
return tree;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public transform(source: T): T {
|
|
74
|
-
const target: T = Object.assign({}, source);
|
|
75
|
-
target.metadata = this.metadata;
|
|
76
|
-
target.type = this.type;
|
|
77
|
-
|
|
78
|
-
if (target.name === null || target.name === undefined) {
|
|
79
|
-
throw new SchematicsException('Option (name) is required.');
|
|
80
|
-
}
|
|
81
|
-
const location: Location = new NameParser().parse(target);
|
|
82
|
-
target.name = strings.dasherize(location.name);
|
|
83
|
-
target.path = strings.dasherize(location.path);
|
|
84
|
-
|
|
85
|
-
target.path = target.flat ? target.path : join(target.path as Path, target.name);
|
|
86
|
-
return target;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { Context, UserCommand, UserCommandContext, TargetUser } from 'necord';
|
|
3
|
-
import { User } from 'discord.js';
|
|
4
|
-
|
|
5
|
-
@Injectable()
|
|
6
|
-
export class <%= classify(name) %>Commands {
|
|
7
|
-
@UserCommand({ name: <%= name.toLowerCase() %> })
|
|
8
|
-
public async <%= name %>(
|
|
9
|
-
@Context() [interaction]: UserCommandContext,
|
|
10
|
-
@TargetUser() user: User
|
|
11
|
-
) {
|
|
12
|
-
return interaction.reply({ content: `Hello ${user.username}!` });
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { CommonSchematicFactory } from '../common';
|
|
2
|
-
import { ContextMenuOptions } from './context-menu-options.interface';
|
|
3
|
-
import { Rule, Source } from '@angular-devkit/schematics';
|
|
4
|
-
import { ContextMenuType } from './context-menu-type.enum';
|
|
5
|
-
|
|
6
|
-
class ContextMenuSchematicFactory extends CommonSchematicFactory<ContextMenuOptions> {
|
|
7
|
-
public type = 'context-menu';
|
|
8
|
-
|
|
9
|
-
generate(options: ContextMenuOptions): Source {
|
|
10
|
-
switch (options.type) {
|
|
11
|
-
case ContextMenuType.Message:
|
|
12
|
-
this.templatePath = './files/message-menu';
|
|
13
|
-
break;
|
|
14
|
-
case ContextMenuType.User:
|
|
15
|
-
this.templatePath = './files/user-menu';
|
|
16
|
-
break;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return super.generate(options);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function contextMenu(options: ContextMenuOptions): Rule {
|
|
24
|
-
const contextMenuFactory = new ContextMenuSchematicFactory();
|
|
25
|
-
return contextMenuFactory.create(options);
|
|
26
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"properties": {
|
|
3
|
-
"name": {
|
|
4
|
-
"type": "string",
|
|
5
|
-
"minLength": 1,
|
|
6
|
-
"description": "Command name",
|
|
7
|
-
"x-prompt": "What is the command name?"
|
|
8
|
-
},
|
|
9
|
-
"path": {
|
|
10
|
-
"type": "string",
|
|
11
|
-
"format": "path",
|
|
12
|
-
"description": "The path to create the service."
|
|
13
|
-
},
|
|
14
|
-
"sourceRoot": {
|
|
15
|
-
"type": "string",
|
|
16
|
-
"description": "Nest service source root directory."
|
|
17
|
-
},
|
|
18
|
-
"flat": {
|
|
19
|
-
"type": "boolean",
|
|
20
|
-
"default": false,
|
|
21
|
-
"description": "Flag to indicate if a directory is created.",
|
|
22
|
-
"x-prompt": "Create a directory?"
|
|
23
|
-
},
|
|
24
|
-
"spec": {
|
|
25
|
-
"type": "boolean",
|
|
26
|
-
"default": true,
|
|
27
|
-
"description": "Specifies if a spec file is generated.",
|
|
28
|
-
"x-prompt": "Generate spec file as well?"
|
|
29
|
-
},
|
|
30
|
-
"type": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"description": "The type of context menu to create.",
|
|
33
|
-
"enum": [
|
|
34
|
-
"message",
|
|
35
|
-
"user"
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"required": [
|
|
40
|
-
"type"
|
|
41
|
-
]
|
|
42
|
-
}
|
package/src/index.ts
DELETED
|
File without changes
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"properties": {
|
|
3
|
-
"name": {
|
|
4
|
-
"type": "string",
|
|
5
|
-
"minLength": 1,
|
|
6
|
-
"x-prompt": "What is the questions set name?"
|
|
7
|
-
},
|
|
8
|
-
"path": {
|
|
9
|
-
"type": "string",
|
|
10
|
-
"format": "path",
|
|
11
|
-
"description": "The path to create the service."
|
|
12
|
-
},
|
|
13
|
-
"sourceRoot": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"description": "Nest service source root directory."
|
|
16
|
-
},
|
|
17
|
-
"flat": {
|
|
18
|
-
"type": "boolean",
|
|
19
|
-
"default": false,
|
|
20
|
-
"description": "Flag to indicate if a directory is created.",
|
|
21
|
-
"x-prompt": "Create a directory?"
|
|
22
|
-
},
|
|
23
|
-
"spec": {
|
|
24
|
-
"type": "boolean",
|
|
25
|
-
"default": true,
|
|
26
|
-
"description": "Specifies if a spec file is generated.",
|
|
27
|
-
"x-prompt": "Generate spec file as well?"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
package/src/modals/schema.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"properties": {
|
|
3
|
-
"name": {
|
|
4
|
-
"type": "string",
|
|
5
|
-
"minLength": 1,
|
|
6
|
-
"x-prompt": "What is the questions set name?"
|
|
7
|
-
},
|
|
8
|
-
"path": {
|
|
9
|
-
"type": "string",
|
|
10
|
-
"format": "path",
|
|
11
|
-
"description": "The path to create the service."
|
|
12
|
-
},
|
|
13
|
-
"sourceRoot": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"description": "Nest service source root directory."
|
|
16
|
-
},
|
|
17
|
-
"flat": {
|
|
18
|
-
"type": "boolean",
|
|
19
|
-
"default": false,
|
|
20
|
-
"description": "Flag to indicate if a directory is created.",
|
|
21
|
-
"x-prompt": "Create a directory?"
|
|
22
|
-
},
|
|
23
|
-
"spec": {
|
|
24
|
-
"type": "boolean",
|
|
25
|
-
"default": true,
|
|
26
|
-
"description": "Specifies if a spec file is generated.",
|
|
27
|
-
"x-prompt": "Generate spec file as well?"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
File without changes
|