@necord/schematics 1.3.8 → 2.0.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022-2025 Alexey Filippov
3
+ Copyright (c) 2022 Alexey Filippov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -42,7 +42,7 @@ schematics --help
42
42
  Now you can execute generation commands.
43
43
 
44
44
  ```bash
45
- yarn build
45
+ npm run build
46
46
  schematics .:command
47
47
  ```
48
48
 
@@ -1,5 +1,5 @@
1
- import { CommonOptions } from '../common';
2
- import { CommandType } from './command-type.enum';
1
+ import { CommandType } from './command-type.enum.js';
2
+ import { CommonOptions } from '../common/index.js';
3
3
  export interface CommandOptions extends CommonOptions {
4
4
  strategy: CommandType;
5
5
  }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommandType = void 0;
4
- var CommandType;
1
+ export var CommandType;
5
2
  (function (CommandType) {
6
3
  CommandType["SLASH_COMMAND"] = "slash-command";
7
4
  CommandType["TEXT_COMMAND"] = "text-command";
8
- })(CommandType || (exports.CommandType = CommandType = {}));
5
+ })(CommandType || (CommandType = {}));
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { CommandOptions } from './command-options.interface';
2
+ import { CommandOptions } from './command-options.interface.js';
3
3
  export declare function command(options: CommandOptions): Rule;
@@ -1,26 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.command = command;
4
- const common_1 = require("../common");
5
- const command_type_enum_1 = require("./command-type.enum");
6
- class CommandSchematicFactory extends common_1.CommonSchematicFactory {
7
- constructor() {
8
- super(...arguments);
9
- this.type = 'command';
10
- }
1
+ import { CommonSchematicFactory } from '../common/index.js';
2
+ import { CommandType } from './command-type.enum.js';
3
+ class CommandSchematicFactory extends CommonSchematicFactory {
4
+ type = 'command';
11
5
  generate(options) {
12
6
  switch (options.strategy) {
13
- case command_type_enum_1.CommandType.TEXT_COMMAND:
7
+ case CommandType.TEXT_COMMAND:
14
8
  this.templatePath = './files/text-command';
15
9
  break;
16
- case command_type_enum_1.CommandType.SLASH_COMMAND:
10
+ case CommandType.SLASH_COMMAND:
17
11
  this.templatePath = './files/slash-command';
18
12
  break;
19
13
  }
20
14
  return super.generate(options);
21
15
  }
22
16
  }
23
- function command(options) {
17
+ export function command(options) {
24
18
  const commandFactory = new CommandSchematicFactory();
25
19
  return commandFactory.create(options);
26
20
  }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { Rule, Source } from '@angular-devkit/schematics';
2
- import { CommonOptions } from './common-options.interface';
3
- export * from './common-options.interface';
2
+ import { CommonOptions } from './common-options.interface.js';
3
+ export * from './common-options.interface.js';
4
4
  export declare class CommonSchematicFactory<T extends CommonOptions = CommonOptions> {
5
5
  templatePath: string;
6
6
  type: string;
@@ -1,36 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommonSchematicFactory = void 0;
4
- const tslib_1 = require("tslib");
5
- const core_1 = require("@angular-devkit/core");
6
- const schematics_1 = require("@angular-devkit/schematics");
7
- const schematics_2 = require("@nestjs/schematics");
8
- const path_1 = require("path");
9
- tslib_1.__exportStar(require("./common-options.interface"), exports);
10
- class CommonSchematicFactory {
11
- constructor() {
12
- this.templatePath = './files';
13
- this.type = 'service';
14
- this.metadata = 'providers';
15
- }
1
+ import { apply, applyTemplates, branchAndMerge, chain, filter, mergeWith, move, noop, SchematicsException, url } from '@angular-devkit/schematics';
2
+ import { mergeSourceRoot, ModuleDeclarator, ModuleFinder, NameParser } from '@nestjs/schematics';
3
+ import { strings } from '@angular-devkit/core';
4
+ import { join } from 'node:path';
5
+ export * from './common-options.interface.js';
6
+ export class CommonSchematicFactory {
7
+ templatePath = './files';
8
+ type = 'service';
9
+ metadata = 'providers';
16
10
  create(options) {
17
11
  options = this.transform(options);
18
- return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([(0, schematics_2.mergeSourceRoot)(options), this.addDeclarationToModule(options), (0, schematics_1.mergeWith)(this.generate(options))]));
12
+ return branchAndMerge(chain([mergeSourceRoot(options), this.addDeclarationToModule(options), mergeWith(this.generate(options))]));
19
13
  }
20
14
  generate(options) {
21
- return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, path_1.join)(this.templatePath)), [
22
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
23
- (0, schematics_1.applyTemplates)({
24
- ...core_1.strings,
15
+ return (context) => apply(url(join(this.templatePath)), [
16
+ options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
17
+ applyTemplates({
18
+ ...strings,
25
19
  ...options,
26
20
  lowercase: (str) => str.toLowerCase()
27
21
  }),
28
- (0, schematics_1.move)(options.path ?? '')
22
+ move(options.path ?? '')
29
23
  ])(context);
30
24
  }
31
25
  addDeclarationToModule(options) {
32
26
  return (tree) => {
33
- options.module = new schematics_2.ModuleFinder(tree).find({
27
+ options.module = new ModuleFinder(tree).find({
34
28
  name: options.name,
35
29
  path: options.path
36
30
  });
@@ -39,7 +33,7 @@ class CommonSchematicFactory {
39
33
  }
40
34
  const rawContent = tree.read(options.module);
41
35
  const content = rawContent?.toString() ?? '';
42
- const declarator = new schematics_2.ModuleDeclarator();
36
+ const declarator = new ModuleDeclarator();
43
37
  tree.overwrite(options.module, declarator.declare(content, options));
44
38
  return tree;
45
39
  };
@@ -49,13 +43,12 @@ class CommonSchematicFactory {
49
43
  target.metadata = this.metadata;
50
44
  target.type = this.type;
51
45
  if (target.name === null || target.name === undefined) {
52
- throw new schematics_1.SchematicsException('Option (name) is required.');
46
+ throw new SchematicsException('Option (name) is required.');
53
47
  }
54
- const location = new schematics_2.NameParser().parse(target);
55
- target.name = core_1.strings.dasherize(location.name);
56
- target.path = core_1.strings.dasherize(location.path);
57
- target.path = target.flat ? target.path : (0, path_1.join)(target.path, target.name);
48
+ const location = new NameParser().parse(target);
49
+ target.name = strings.dasherize(location.name);
50
+ target.path = strings.dasherize(location.path);
51
+ target.path = target.flat ? target.path : join(target.path, target.name);
58
52
  return target;
59
53
  }
60
54
  }
61
- exports.CommonSchematicFactory = CommonSchematicFactory;
@@ -1,5 +1,5 @@
1
- import { CommonOptions } from '../common';
2
- import { ComponentType } from './component-type.enum';
1
+ import { ComponentType } from './component-type.enum.js';
2
+ import { CommonOptions } from '../common/index.js';
3
3
  export interface ComponentOptions extends CommonOptions {
4
4
  strategy: ComponentType;
5
5
  }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComponentType = void 0;
4
- var ComponentType;
1
+ export var ComponentType;
5
2
  (function (ComponentType) {
6
3
  ComponentType["Button"] = "button";
7
4
  ComponentType["Select"] = "select";
8
- })(ComponentType || (exports.ComponentType = ComponentType = {}));
5
+ })(ComponentType || (ComponentType = {}));
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { ComponentOptions } from './component-options.interface';
2
+ import { ComponentOptions } from './component-options.interface.js';
3
3
  export declare function component(options: ComponentOptions): Rule;
@@ -1,26 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.component = component;
4
- const common_1 = require("../common");
5
- const component_type_enum_1 = require("./component-type.enum");
6
- class ComponentSchematicFactory extends common_1.CommonSchematicFactory {
7
- constructor() {
8
- super(...arguments);
9
- this.type = 'component';
10
- }
1
+ import { CommonSchematicFactory } from '../common/index.js';
2
+ import { ComponentType } from './component-type.enum.js';
3
+ class ComponentSchematicFactory extends CommonSchematicFactory {
4
+ type = 'component';
11
5
  generate(options) {
12
6
  switch (options.strategy) {
13
- case component_type_enum_1.ComponentType.Button:
7
+ case ComponentType.Button:
14
8
  this.templatePath = './files/button';
15
9
  break;
16
- case component_type_enum_1.ComponentType.Select:
10
+ case ComponentType.Select:
17
11
  this.templatePath = './files/select';
18
12
  break;
19
13
  }
20
14
  return super.generate(options);
21
15
  }
22
16
  }
23
- function component(options) {
17
+ export function component(options) {
24
18
  const commandFactory = new ComponentSchematicFactory();
25
19
  return commandFactory.create(options);
26
20
  }
@@ -1,5 +1,5 @@
1
- import { CommonOptions } from '../common';
2
- import { ContextMenuType } from './context-menu-type.enum';
1
+ import { ContextMenuType } from './context-menu-type.enum.js';
2
+ import { CommonOptions } from '../common/index.js';
3
3
  export interface ContextMenuOptions extends CommonOptions {
4
4
  strategy: ContextMenuType;
5
5
  }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContextMenuType = void 0;
4
- var ContextMenuType;
1
+ export var ContextMenuType;
5
2
  (function (ContextMenuType) {
6
3
  ContextMenuType["Message"] = "message";
7
4
  ContextMenuType["User"] = "user";
8
- })(ContextMenuType || (exports.ContextMenuType = ContextMenuType = {}));
5
+ })(ContextMenuType || (ContextMenuType = {}));
@@ -1,3 +1,3 @@
1
- import { ContextMenuOptions } from './context-menu-options.interface';
2
1
  import { Rule } from '@angular-devkit/schematics';
2
+ import { ContextMenuOptions } from './context-menu-options.interface.js';
3
3
  export declare function contextMenu(options: ContextMenuOptions): Rule;
@@ -1,26 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.contextMenu = contextMenu;
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
- }
1
+ import { ContextMenuType } from './context-menu-type.enum.js';
2
+ import { CommonSchematicFactory } from '../common/index.js';
3
+ class ContextMenuSchematicFactory extends CommonSchematicFactory {
4
+ type = 'context-menu';
11
5
  generate(options) {
12
6
  switch (options.strategy) {
13
- case context_menu_type_enum_1.ContextMenuType.Message:
7
+ case ContextMenuType.Message:
14
8
  this.templatePath = './files/message-menu';
15
9
  break;
16
- case context_menu_type_enum_1.ContextMenuType.User:
10
+ case ContextMenuType.User:
17
11
  this.templatePath = './files/user-menu';
18
12
  break;
19
13
  }
20
14
  return super.generate(options);
21
15
  }
22
16
  }
23
- function contextMenu(options) {
17
+ export function contextMenu(options) {
24
18
  const contextMenuFactory = new ContextMenuSchematicFactory();
25
19
  return contextMenuFactory.create(options);
26
20
  }
@@ -0,0 +1,11 @@
1
+ export * from './command/command-options.interface.js';
2
+ export * from './command/command-type.enum.js';
3
+ export * from './command/index.js';
4
+ export * from './common/index.js';
5
+ export * from './component/component-options.interface.js';
6
+ export * from './component/component-type.enum.js';
7
+ export * from './component/index.js';
8
+ export * from './context-menu/context-menu-options.interface.js';
9
+ export * from './context-menu/context-menu-type.enum.js';
10
+ export * from './context-menu/index.js';
11
+ export * from './modal/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from './command/command-options.interface.js';
2
+ export * from './command/command-type.enum.js';
3
+ export * from './command/index.js';
4
+ export * from './common/index.js';
5
+ export * from './component/component-options.interface.js';
6
+ export * from './component/component-type.enum.js';
7
+ export * from './component/index.js';
8
+ export * from './context-menu/context-menu-options.interface.js';
9
+ export * from './context-menu/context-menu-type.enum.js';
10
+ export * from './context-menu/index.js';
11
+ export * from './modal/index.js';
@@ -0,0 +1,12 @@
1
+ import { Injectable } from '@nestjs/common';
2
+ import { Context, Modal, ModalContext } from 'necord';
3
+
4
+ @Injectable()
5
+ export class <%= classify(name) %>Modals {
6
+ @Modal('<%= name %>')
7
+ public <%= name %>(@Ctx() [interaction]: ModalContext) {
8
+ return interaction.reply({
9
+ content: `Your fav pizza : ${interaction.fields.getTextInputValue('pizza')}`
10
+ });
11
+ }
12
+ }
@@ -1,3 +1,3 @@
1
- import { CommonOptions } from '../common';
2
1
  import { Rule } from '@angular-devkit/schematics';
2
+ import { CommonOptions } from '../common/index.js';
3
3
  export declare function modal(options: CommonOptions): Rule;
@@ -1,17 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.modal = modal;
4
- const common_1 = require("../common");
5
- class ModalSchematicFactory extends common_1.CommonSchematicFactory {
6
- constructor() {
7
- super(...arguments);
8
- this.type = 'modal';
9
- }
1
+ import { CommonSchematicFactory } from '../common/index.js';
2
+ class ModalSchematicFactory extends CommonSchematicFactory {
3
+ type = 'modal';
10
4
  generate(options) {
11
5
  return super.generate(options);
12
6
  }
13
7
  }
14
- function modal(options) {
8
+ export function modal(options) {
15
9
  const modalFactory = new ModalSchematicFactory();
16
10
  return modalFactory.create(options);
17
11
  }
package/package.json CHANGED
@@ -1,34 +1,42 @@
1
1
  {
2
2
  "name": "@necord/schematics",
3
3
  "description": "A collection of schematics for Necord projects with NestJS",
4
- "version": "1.3.8",
4
+ "version": "2.0.0",
5
+ "type": "module",
5
6
  "scripts": {
6
- "build": "rimraf -rf dist && tsc -p tsconfig.build.json",
7
+ "build": "rimraf dist tsconfig.build.tsbuildinfo && tsc -b tsconfig.build.json",
8
+ "typecheck": "tsc -b tsconfig.json --force",
7
9
  "postbuild": "npm run copy:collection && npm run copy:lib",
8
10
  "copy:collection": "copyfiles --up 1 src/collection.json dist && copyfiles --up 1 src/**/schema.json dist",
9
- "copy:lib": "copyfiles --up 1 src/**/files/**/* dist",
11
+ "copy:lib": "copyfiles --up 1 \"src/**/files/**/*\" \"src/**/files/*\" dist",
10
12
  "prepublish:npm": "npm run build",
11
13
  "publish:npm": "release-it",
12
14
  "prepublish:dev": "npm run build",
13
15
  "publish:dev": "npm publish --access public --tag dev",
14
16
  "prepare": "husky",
15
- "format": "prettier --write \"src/**/*.ts\"",
16
- "lint": "eslint --ignore-pattern .gitignore {integration,src}/**/*.ts",
17
- "test": "jest",
18
- "test:watch": "jest --watch",
19
- "test:cov": "jest --coverage",
20
- "test:ci": "jest --ci --passWithNoTests --coverage"
17
+ "format": "prettier --write \"{src,apps,libs,test}/**/*.ts\"",
18
+ "lint": "oxlint --type-aware --deny-warnings src test",
19
+ "test": "NODE_ENV=test NODE_OPTIONS=\"--require tsx/cjs\" vitest run",
20
+ "test:watch": "NODE_ENV=test NODE_OPTIONS=\"--require tsx/cjs\" vitest",
21
+ "test:cov": "NODE_ENV=test NODE_OPTIONS=\"--require tsx/cjs\" vitest run --coverage",
22
+ "test:ci": "NODE_ENV=test NODE_OPTIONS=\"--require tsx/cjs\" vitest run --coverage"
21
23
  },
22
24
  "schematics": "./dist/collection.json",
23
25
  "funding": {
24
26
  "type": "opencollective",
25
27
  "url": "https://opencollective.com/necord"
26
28
  },
27
- "main": "dist/index.js",
28
- "typings": "dist/index.d.ts",
29
+ "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "./package.json": "./package.json"
37
+ },
29
38
  "files": [
30
- "dist/**/*",
31
- "*.md"
39
+ "dist"
32
40
  ],
33
41
  "publishConfig": {
34
42
  "access": "public"
@@ -45,33 +53,34 @@
45
53
  "necord"
46
54
  ],
47
55
  "dependencies": {
48
- "@nestjs/schematics": "11.0.7",
56
+ "@nestjs/schematics": "12.0.0",
49
57
  "rxjs": "7.8.2",
50
- "tslib": "^2.8.1"
58
+ "tslib": "^2.8.1",
59
+ "typescript": "npm:@typescript/typescript6@6.0.2"
51
60
  },
52
61
  "devDependencies": {
53
- "@commitlint/cli": "19.8.1",
54
- "@commitlint/config-angular": "19.8.1",
55
- "@eslint/eslintrc": "^3.2.0",
56
- "@eslint/js": "^9.18.0",
57
- "@nestjs/testing": "^11.1.0",
58
- "@release-it/conventional-changelog": "^10.0.0",
59
- "@types/jest": "^30.0.0",
60
- "@types/node": "24.3.0",
62
+ "@commitlint/cli": "21.2.2",
63
+ "@commitlint/config-angular": "21.2.2",
64
+ "@release-it/conventional-changelog": "^12.0.0",
65
+ "@types/node": "26.4.0",
66
+ "@typescript/native": "npm:typescript@7.0.2",
67
+ "@vitest/coverage-v8": "4.1.11",
61
68
  "copyfiles": "2.4.1",
62
- "eslint": "^9.18.0",
63
- "eslint-config-prettier": "10.1.8",
64
- "eslint-plugin-import": "^2.31.0",
65
- "eslint-plugin-prettier": "^5.2.3",
66
- "globals": "^16.0.0",
69
+ "eslint": "^10.0.0",
70
+ "eslint-plugin-perfectionist": "5.11.0",
71
+ "eslint-plugin-prettier": "5.5.6",
67
72
  "husky": "9.1.7",
68
- "jest": "^30.0.0",
69
- "prettier": "3.6.2",
70
- "release-it": "19.0.4",
71
- "rimraf": "6.0.1",
72
- "ts-jest": "^29.3.2",
73
- "typescript": "5.9.2",
74
- "typescript-eslint": "^8.21.0"
73
+ "oxlint": "1.81.0",
74
+ "oxlint-tsgolint": "7.0.2001",
75
+ "prettier": "3.9.6",
76
+ "release-it": "21.0.2",
77
+ "rimraf": "6.1.3",
78
+ "tsx": "4.23.12",
79
+ "vitest": "4.1.11"
80
+ },
81
+ "engines": {
82
+ "node": "^22.22.3 || ^24.15.0 || >=26.0.0",
83
+ "npm": ">=8.6.0"
75
84
  },
76
85
  "repository": {
77
86
  "type": "git",
package/CHANGELOG.md DELETED
@@ -1,3 +0,0 @@
1
- # Changelog
2
-
3
- ## [1.3.8](https://github.com/necordjs/schematics/compare/1.3.7...1.3.8) (2025-09-03)