@typeix/schematics 8.6.1-rc.1 → 8.8.0-rc.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = void 0;
3
+ exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const path_1 = require("path");
@@ -13,7 +13,6 @@ function main(options) {
13
13
  options = transform(options);
14
14
  return (0, schematics_1.mergeWith)(generate(options, path));
15
15
  }
16
- exports.main = main;
17
16
  function transform(options) {
18
17
  const target = Object.assign({}, options);
19
18
  target.author = !!target.author ? target.author : defaults_1.DEFAULT_AUTHOR;
@@ -17,18 +17,18 @@
17
17
  "@typeix/resty": "^<%= version %>"
18
18
  },
19
19
  "devDependencies": {
20
- "@babel/core": "^7.24.7",
21
- "@babel/node": "^7.24.7",
22
- "@babel/plugin-proposal-decorators": "^7.24.7",
23
- "@babel/plugin-transform-runtime": "^7.24.7",
24
- "@babel/preset-env": "^7.24.7",
25
- "@babel/register": "^7.24.6",
26
- "@babel/runtime": "^7.24.7",
27
- "babel-plugin-root-import": "^6.6.0",
28
- "jest": "^29.7.0",
29
- "nodemon": "^3.1.3",
30
- "pino-pretty": "^10.0.0",
31
- "prettier": "^3.3.2"
20
+ "@babel/core": "~7.24.7",
21
+ "@babel/node": "~7.24.7",
22
+ "@babel/plugin-proposal-decorators": "~7.24.7",
23
+ "@babel/plugin-transform-runtime": "~7.24.7",
24
+ "@babel/preset-env": "~7.24.7",
25
+ "@babel/register": "~7.24.6",
26
+ "@babel/runtime": "~7.24.7",
27
+ "babel-plugin-root-import": "~6.6.0",
28
+ "jest": "~29.7.0",
29
+ "nodemon": "~3.1.3",
30
+ "pino-pretty": "~10.0.0",
31
+ "prettier": "~3.3.2"
32
32
  },
33
33
  "engines": {
34
34
  "node": ">=18.0.0"
@@ -26,24 +26,24 @@
26
26
  "devDependencies": {
27
27
  "@typeix/cli": "^<%= version %>",
28
28
  "@typeix/schematics": "^<%= version %>",
29
- "@types/jest": "^29.5.12",
30
- "@types/node": "^18.19.34",
31
- "@typescript-eslint/eslint-plugin": "^7.13.0",
32
- "@typescript-eslint/eslint-plugin-tslint": "^7.0.2",
33
- "eslint": "^8.57.0",
34
- "eslint-config-prettier": "^9.1.0",
35
- "eslint-plugin-prettier": "^5.1.3",
36
- "jest": "^29.7.0",
37
- "pino-pretty": "^10.0.0",
38
- "prettier": "^3.3.2",
39
- "rimraf": "^5.0.0",
40
- "ts-jest": "^29.1.4",
41
- "ts-loader": "^9.5.1",
42
- "ts-node": "^10.9.2",
43
- "tsconfig-paths": "^4.2.0",
44
- "ts-patch": "^3.2.0",
45
- "typescript": "^5.4.5",
46
- "typescript-transform-paths": "^3.4.7"
29
+ "@types/jest": "~29.5.12",
30
+ "@types/node": "~18.19.34",
31
+ "@typescript-eslint/eslint-plugin": "~7.13.0",
32
+ "@typescript-eslint/eslint-plugin-tslint": "~7.0.2",
33
+ "eslint": "~8.57.0",
34
+ "eslint-config-prettier": "~9.1.0",
35
+ "eslint-plugin-prettier": "~5.1.3",
36
+ "jest": "~29.7.0",
37
+ "pino-pretty": "~10.0.0",
38
+ "prettier": "~3.3.2",
39
+ "rimraf": "~5.0.0",
40
+ "ts-jest": "~29.1.4",
41
+ "ts-loader": "~9.5.1",
42
+ "ts-node": "~10.9.2",
43
+ "tsconfig-paths": "~4.2.0",
44
+ "ts-patch": "~3.2.0",
45
+ "typescript": "~5.6.3",
46
+ "typescript-transform-paths": "~3.5.2"
47
47
  },
48
48
  "engines": {
49
49
  "node": ">=18.0.0"
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = void 0;
3
+ exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const utils_1 = require("../../utils");
@@ -20,7 +20,6 @@ function main(options) {
20
20
  ]))(tree, context);
21
21
  };
22
22
  }
23
- exports.main = main;
24
23
  function transform(source) {
25
24
  const target = Object.assign({}, source);
26
25
  target.metadata = ELEMENT_METADATA;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = void 0;
3
+ exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const utils_1 = require("../../utils");
@@ -9,7 +9,6 @@ function main(options) {
9
9
  options = transform(options);
10
10
  return (0, schematics_1.chain)([(0, utils_2.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
11
11
  }
12
- exports.main = main;
13
12
  function transform(options) {
14
13
  const target = Object.assign({}, options);
15
14
  if (!target.name) {
@@ -1,4 +1,4 @@
1
- import {Module} from '@typeix/resty';
1
+ import {Module} from "@typeix/resty";
2
2
 
3
3
  @Module({
4
4
  providers: []
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = void 0;
3
+ exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const utils_1 = require("../../utils");
@@ -17,7 +17,6 @@ function main(options) {
17
17
  ]))(tree, context);
18
18
  };
19
19
  }
20
- exports.main = main;
21
20
  function transform(source) {
22
21
  const target = Object.assign({}, source);
23
22
  target.metadata = "imports";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = void 0;
3
+ exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const utils_1 = require("../../utils");
@@ -17,7 +17,6 @@ function main(options) {
17
17
  ]))(tree, context);
18
18
  };
19
19
  }
20
- exports.main = main;
21
20
  function transform(options) {
22
21
  const target = Object.assign({}, options);
23
22
  target.metadata = "providers";
@@ -1,7 +1,7 @@
1
1
  import {Injector} from "@typeix/resty";
2
- import {<%= classify(name) %>Service} from './<%= name %>.service';
2
+ import {<%= classify(name) %>Service} from "./<%= name %>.service";
3
3
 
4
- describe('<%= classify(name) %>Service', () => {
4
+ describe("<%= classify(name) %>Service", () => {
5
5
  let service;
6
6
 
7
7
  beforeEach(async () => {
@@ -9,7 +9,7 @@ describe('<%= classify(name) %>Service', () => {
9
9
  service = injector.get(<%= classify(name) %>Service);
10
10
  });
11
11
 
12
- it('should be defined', () => {
12
+ it("should be defined", () => {
13
13
  expect(service).toBeDefined();
14
14
  });
15
15
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = void 0;
3
+ exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const util_1 = require("util");
@@ -18,7 +18,6 @@ function main(options) {
18
18
  ]))(tree, context);
19
19
  };
20
20
  }
21
- exports.main = main;
22
21
  function transform(source) {
23
22
  const target = Object.assign({}, source);
24
23
  target.metadata = "providers";
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPackageJsonDependency = exports.addPackageJsonDependency = exports.NodeDependencyType = void 0;
3
+ exports.NodeDependencyType = void 0;
4
+ exports.addPackageJsonDependency = addPackageJsonDependency;
5
+ exports.getPackageJsonDependency = getPackageJsonDependency;
4
6
  const json_file_util_1 = require("./json-file.util");
5
7
  const PKG_JSON_PATH = "/package.json";
6
8
  var NodeDependencyType;
@@ -24,7 +26,6 @@ function addPackageJsonDependency(tree, dependency, pkgJsonPath = PKG_JSON_PATH)
24
26
  json.modify(path, version);
25
27
  }
26
28
  }
27
- exports.addPackageJsonDependency = addPackageJsonDependency;
28
29
  function getPackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) {
29
30
  const json = new json_file_util_1.JSONFile(tree, pkgJsonPath);
30
31
  for (const depType of ALL_DEPENDENCY_TYPE) {
@@ -39,4 +40,3 @@ function getPackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) {
39
40
  }
40
41
  return null;
41
42
  }
42
- exports.getPackageJsonDependency = getPackageJsonDependency;
@@ -2,8 +2,8 @@ import { DeclarationOptions } from "./module.declarator";
2
2
  export declare class MetadataManager {
3
3
  private content;
4
4
  constructor(content: string);
5
- insert(metadata: string, symbol: string, staticOptions?: DeclarationOptions["staticOptions"]): string;
6
- private getDecoratorMetadata;
5
+ insert(metadata: string, symbol: string, staticOptions?: DeclarationOptions["staticOptions"]): string | undefined;
6
+ private findFirstDecoratorMetadata;
7
7
  private getSourceNodes;
8
8
  private insertMetadataToEmptyModuleDecorator;
9
9
  private insertNewMetadataToDecorator;
@@ -7,10 +7,13 @@ class MetadataManager {
7
7
  this.content = content;
8
8
  }
9
9
  insert(metadata, symbol, staticOptions) {
10
+ var _a;
10
11
  const source = (0, typescript_1.createSourceFile)("filename.ts", this.content, typescript_1.ScriptTarget.ES2017);
11
- const decoratorNodes = this.getDecoratorMetadata(source, "@Module");
12
- const node = decoratorNodes[0];
13
- const matchingProperties = node.properties
12
+ const moduleDecoratorNode = (_a = this.findFirstDecoratorMetadata(source, "Module")) !== null && _a !== void 0 ? _a : this.findFirstDecoratorMetadata(source, "RootModule");
13
+ if (!moduleDecoratorNode) {
14
+ return;
15
+ }
16
+ const matchingProperties = moduleDecoratorNode.properties
14
17
  .filter((prop) => prop.kind === typescript_1.SyntaxKind.PropertyAssignment)
15
18
  .filter((prop) => {
16
19
  const name = prop.name;
@@ -28,7 +31,7 @@ class MetadataManager {
28
31
  symbol = staticOptions ? this.addBlankLines(symbol) : symbol;
29
32
  };
30
33
  if (matchingProperties.length === 0) {
31
- const expr = node;
34
+ const expr = moduleDecoratorNode;
32
35
  if (expr.properties.length === 0) {
33
36
  addBlankLinesIfDynamic();
34
37
  return this.insertMetadataToEmptyModuleDecorator(expr, metadata, symbol);
@@ -42,14 +45,29 @@ class MetadataManager {
42
45
  return this.insertSymbolToMetadata(source, matchingProperties, symbol, staticOptions);
43
46
  }
44
47
  }
45
- getDecoratorMetadata(source, identifier) {
46
- return this.getSourceNodes(source)
47
- .filter((node) => node.kind === typescript_1.SyntaxKind.Decorator &&
48
- node.expression.kind === typescript_1.SyntaxKind.CallExpression)
49
- .map((node) => node.expression)
50
- .filter((expr) => expr.arguments[0] &&
51
- expr.arguments[0].kind === typescript_1.SyntaxKind.ObjectLiteralExpression)
52
- .map((expr) => expr.arguments[0]);
48
+ findFirstDecoratorMetadata(source, identifier) {
49
+ var _a;
50
+ for (const node of this.getSourceNodes(source)) {
51
+ const isDecoratorFactoryNode = node.kind === typescript_1.SyntaxKind.Decorator &&
52
+ node.expression.kind === typescript_1.SyntaxKind.CallExpression;
53
+ if (!isDecoratorFactoryNode) {
54
+ continue;
55
+ }
56
+ const expr = node.expression;
57
+ const isExpectedExpression = ((_a = expr.arguments[0]) === null || _a === void 0 ? void 0 : _a.kind) === typescript_1.SyntaxKind.ObjectLiteralExpression;
58
+ if (!isExpectedExpression) {
59
+ continue;
60
+ }
61
+ if (expr.expression.kind === typescript_1.SyntaxKind.Identifier) {
62
+ const escapedText = expr.expression.escapedText;
63
+ const isTargetIdentifier = escapedText
64
+ ? escapedText.toLowerCase() === identifier.toLowerCase()
65
+ : true;
66
+ if (isTargetIdentifier) {
67
+ return expr.arguments[0];
68
+ }
69
+ }
70
+ }
53
71
  }
54
72
  getSourceNodes(sourceFile) {
55
73
  const nodes = [sourceFile];
@@ -59,7 +77,7 @@ class MetadataManager {
59
77
  if (node) {
60
78
  result.push(node);
61
79
  if (node.getChildCount(sourceFile) >= 0) {
62
- nodes.unshift(...node.getChildren());
80
+ nodes.unshift(...node.getChildren(sourceFile));
63
81
  }
64
82
  }
65
83
  }
@@ -127,12 +145,10 @@ class MetadataManager {
127
145
  }
128
146
  else {
129
147
  const text = node.getFullText(source);
130
- if (text.match(/^\r?\n/)) {
131
- toInsert = `,${text.match(/^\r?\n(\r?)\s+/)[0]}${symbol}`;
132
- }
133
- else {
134
- toInsert = `, ${symbol}`;
135
- }
148
+ const itemSeparator = (text.match(/^\r?\n(\r?)\s+/) ||
149
+ text.match(/^\r?\n/) ||
150
+ " ")[0];
151
+ toInsert = `,${itemSeparator}${symbol}`;
136
152
  }
137
153
  return this.content.split("").reduce((content, char, index) => {
138
154
  if (index === position) {
@@ -149,9 +165,6 @@ class MetadataManager {
149
165
  }
150
166
  const spacing = 6;
151
167
  let options = JSON.stringify(staticOptions.value, null, spacing);
152
- options = options.replace(/\"([^(\")"]+)\":/g, "$1:");
153
- options = options.replace(/\"/g, "'");
154
- options = options.slice(0, options.length - 1) + " }";
155
168
  symbol += `.${staticOptions.name}(${options})`;
156
169
  return symbol;
157
170
  }
@@ -23,7 +23,7 @@ class ModuleImportDeclarator {
23
23
  return contentLines.indexOf(reverseImports[0]);
24
24
  }
25
25
  buildLineToInsert(options) {
26
- return `import { ${options.symbol} } from '${this.computeRelativePath(options)}';`;
26
+ return `import {${options.symbol}} from "${this.computeRelativePath(options)}";`;
27
27
  }
28
28
  computeRelativePath(options) {
29
29
  let importModulePath;
@@ -6,7 +6,7 @@ class ModuleMetadataDeclarator {
6
6
  declare(content, options) {
7
7
  const manager = new metadata_manager_1.MetadataManager(content);
8
8
  const inserted = manager.insert(options.metadata, options.symbol, options.staticOptions);
9
- return inserted;
9
+ return inserted !== null && inserted !== void 0 ? inserted : content;
10
10
  }
11
11
  }
12
12
  exports.ModuleMetadataDeclarator = ModuleMetadataDeclarator;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeSourceRoot = exports.isInRootDirectory = void 0;
3
+ exports.isInRootDirectory = isInRootDirectory;
4
+ exports.mergeSourceRoot = mergeSourceRoot;
4
5
  const core_1 = require("@angular-devkit/core");
5
6
  const defaults_1 = require("../lib/defaults");
6
7
  function isInRootDirectory(host, extraFiles = []) {
7
8
  const files = ["typeix-cli.json", "typeix.json"].concat(extraFiles || []);
8
9
  return files.map(file => host.exists(file)).some(isPresent => isPresent);
9
10
  }
10
- exports.isInRootDirectory = isInRootDirectory;
11
11
  function mergeSourceRoot(options) {
12
12
  return (host) => {
13
13
  const isInRoot = isInRootDirectory(host, ["tsconfig.json", "package.json"]);
@@ -22,4 +22,3 @@ function mergeSourceRoot(options) {
22
22
  return host;
23
23
  };
24
24
  }
25
- exports.mergeSourceRoot = mergeSourceRoot;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@typeix/schematics",
3
3
  "testRunner": "jest-jasmine2",
4
- "version": "8.6.1-rc.1",
4
+ "version": "8.8.0-rc.1",
5
5
  "files": [
6
6
  "dist/**/*"
7
7
  ],
@@ -20,22 +20,22 @@
20
20
  "test:dev": "npm run -s test -- --watchAll"
21
21
  },
22
22
  "devDependencies": {
23
- "@commitlint/cli": "17.8.0",
24
- "@commitlint/config-angular": "17.8.0",
25
- "@typeix/resty": "^8.6.1-rc.1",
26
- "@types/fs-extra": "^11.0.1",
27
- "@types/jest": "^29.5.6",
28
- "cpx": "^1.5.0",
29
- "ts-jest": "^29.1.1",
30
- "ttypescript": "^1.5.15",
31
- "typescript-transform-paths": "^3.4.6"
23
+ "@commitlint/cli": "~17.8.1",
24
+ "@commitlint/config-angular": "~17.8.1",
25
+ "@typeix/resty": "^8.8.0-rc.1",
26
+ "@types/fs-extra": "~11.0.4",
27
+ "@types/jest": "~29.5.14",
28
+ "cpx": "~1.5.0",
29
+ "ts-jest": "~29.2.5",
30
+ "ttypescript": "~1.5.15",
31
+ "typescript-transform-paths": "~3.5.2"
32
32
  },
33
33
  "dependencies": {
34
- "@angular-devkit/core": "^16.2.6",
35
- "@angular-devkit/schematics": "^16.2.6",
36
- "fs-extra": "^11.1.1",
37
- "jsonc-parser": "^3.2.0",
38
- "pluralize": "^8.0.0"
34
+ "@angular-devkit/core": "~19.0.5",
35
+ "@angular-devkit/schematics": "~19.0.5",
36
+ "fs-extra": "~11.2.0",
37
+ "jsonc-parser": "~3.3.1",
38
+ "pluralize": "~8.0.0"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=18.0.0"
@@ -50,5 +50,5 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/typeix/schematics/issues"
52
52
  },
53
- "gitHead": "897a0c636017be6843502feae7a3a8ad1951ce21"
53
+ "gitHead": "8d95e8382394eeb45075731f936f44cd1766047c"
54
54
  }