@ngflow/ng-architect 1.0.4 → 1.0.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/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "@ngflow/ng-architect",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Angular schematics to generate files and maintain clean architecture",
5
5
  "scripts": {
6
6
  "build": "tsc -p tsconfig.json",
7
7
  "test": "npm run build && jasmine src/**/*_spec.js"
8
8
  },
9
- "keywords": ["schematics", "angular", "automation", "architecture"],
9
+ "keywords": [
10
+ "schematics",
11
+ "angular",
12
+ "automation",
13
+ "architecture"
14
+ ],
10
15
  "author": "João Fernandes",
11
16
  "license": "MIT",
12
17
  "schematics": "./src/collection.json",
@@ -15,8 +20,8 @@
15
20
  "@angular-devkit/schematics": "^21.0.4"
16
21
  },
17
22
  "devDependencies": {
18
- "@types/node": "^20.17.19",
19
- "@types/jasmine": "~5.1.0",
23
+ "@types/jasmine": "5.1.13",
24
+ "@types/node": "20.19.27",
20
25
  "jasmine": "~5.12.0",
21
26
  "typescript": "~5.9.2"
22
27
  }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const string_utils_1 = require("../utils/string-utils");
6
+ function default_1(options) {
7
+ const componentKebab = (0, string_utils_1.toKebabCase)(options.name);
8
+ const componentPascal = (0, string_utils_1.toPascalCase)(options.name);
9
+ return (0, schematics_1.chain)([
10
+ (_tree, context) => {
11
+ context.logger.info(`✅ Creating component: ${componentPascal} (${componentKebab})`);
12
+ },
13
+ (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
14
+ (0, schematics_1.template)({ componentKebab, componentPascal, module: options.module })
15
+ ]))
16
+ ]);
17
+ }
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAYA,4BAcC;AA1BD,2DASoC;AACpC,wDAAkE;AAElE,mBAAwB,OAAY;IAClC,MAAM,cAAc,GAAG,IAAA,0BAAW,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,eAAe,GAAG,IAAA,2BAAY,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnD,OAAO,IAAA,kBAAK,EAAC;QACX,CAAC,KAAW,EAAE,OAAyB,EAAE,EAAE;YACzC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,eAAe,KAAK,cAAc,GAAG,CAAC,CAAC;QACtF,CAAC;QACD,IAAA,sBAAS,EACP,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YACpB,IAAA,qBAAQ,EAAC,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;SACtE,CAAC,CACH;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -15,7 +15,7 @@ export default function(options: any): Rule {
15
15
  const componentPascal = toPascalCase(options.name);
16
16
 
17
17
  return chain([
18
- (tree: Tree, context: SchematicContext) => {
18
+ (_tree: Tree, context: SchematicContext) => {
19
19
  context.logger.info(`✅ Creating component: ${componentPascal} (${componentKebab})`);
20
20
  },
21
21
  mergeWith(
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const string_utils_1 = require("../utils/string-utils");
6
+ const file_utils_1 = require("../utils/file-utils");
7
+ function default_1(options) {
8
+ const featureKebab = (0, string_utils_1.toKebabCase)(options.name);
9
+ const featurePascal = (0, string_utils_1.toPascalCase)(options.name);
10
+ return (0, schematics_1.chain)([
11
+ // Log inicial
12
+ (_tree, context) => {
13
+ context.logger.info(`✅ Creating feature: ${featurePascal} (${featureKebab})`);
14
+ },
15
+ // Gera os arquivos a partir do template
16
+ (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
17
+ (0, schematics_1.filter)(path => !path.endsWith('.swp')),
18
+ (0, schematics_1.template)({ featureKebab, featurePascal })
19
+ ])),
20
+ // Atualiza app.routes.ts adicionando a rota
21
+ (tree, context) => {
22
+ (0, file_utils_1.addRoute)(tree, context, featureKebab);
23
+ // Cria barrels automáticos em data, models e pages
24
+ const folders = ['data', 'models', 'pages'];
25
+ folders.forEach(folder => {
26
+ const path = `src/app/features/${featureKebab}/${folder}`;
27
+ (0, file_utils_1.createOrUpdateBarrel)(tree, context, path);
28
+ });
29
+ return tree;
30
+ }
31
+ ]);
32
+ }
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAcA,4BAgCC;AA9CD,2DAUoC;AACpC,wDAAkE;AAClE,oDAAqE;AAErE,mBAAyB,OAAyB;IAChD,MAAM,YAAY,GAAG,IAAA,0BAAW,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,IAAA,2BAAY,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD,OAAO,IAAA,kBAAK,EAAC;QACX,cAAc;QACd,CAAC,KAAW,EAAE,OAAyB,EAAE,EAAE;YACzC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,aAAa,KAAK,YAAY,GAAG,CAAC,CAAC;QAChF,CAAC;QAED,wCAAwC;QACxC,IAAA,sBAAS,EACP,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YACpB,IAAA,mBAAM,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACtC,IAAA,qBAAQ,EAAC,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;SAC1C,CAAC,CACH;QAED,4CAA4C;QAC5C,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;YACxC,IAAA,qBAAQ,EAAC,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;YAEtC,mDAAmD;YACnD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC5C,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACvB,MAAM,IAAI,GAAG,oBAAoB,YAAY,IAAI,MAAM,EAAE,CAAC;gBAC1D,IAAA,iCAAoB,EAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC5C,CAAC,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const string_utils_1 = require("../utils/string-utils");
6
+ function default_1(options) {
7
+ const serviceKebab = (0, string_utils_1.toKebabCase)(options.name);
8
+ const servicePascal = (0, string_utils_1.toPascalCase)(options.name);
9
+ return (0, schematics_1.chain)([
10
+ (_tree, context) => {
11
+ context.logger.info(`✅ Creating service: ${servicePascal} (${serviceKebab})`);
12
+ },
13
+ (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
14
+ (0, schematics_1.template)({ serviceKebab, servicePascal, store: options.store })
15
+ ]))
16
+ ]);
17
+ }
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAYA,4BAcC;AA1BD,2DASoC;AACpC,wDAAkE;AAElE,mBAAwB,OAAY;IAClC,MAAM,YAAY,GAAG,IAAA,0BAAW,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,IAAA,2BAAY,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD,OAAO,IAAA,kBAAK,EAAC;QACX,CAAC,KAAW,EAAE,OAAyB,EAAE,EAAE;YACzC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,aAAa,KAAK,YAAY,GAAG,CAAC,CAAC;QAChF,CAAC;QACD,IAAA,sBAAS,EACP,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YACpB,IAAA,qBAAQ,EAAC,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;SAChE,CAAC,CACH;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,27 @@
1
+ import {
2
+ Rule,
3
+ SchematicContext,
4
+ Tree,
5
+ apply,
6
+ chain,
7
+ mergeWith,
8
+ template,
9
+ url
10
+ } from '@angular-devkit/schematics';
11
+ import { toKebabCase, toPascalCase } from '../utils/string-utils';
12
+
13
+ export default function(options: any): Rule {
14
+ const serviceKebab = toKebabCase(options.name);
15
+ const servicePascal = toPascalCase(options.name);
16
+
17
+ return chain([
18
+ (_tree: Tree, context: SchematicContext) => {
19
+ context.logger.info(`✅ Creating service: ${servicePascal} (${serviceKebab})`);
20
+ },
21
+ mergeWith(
22
+ apply(url('./files'), [
23
+ template({ serviceKebab, servicePascal, store: options.store })
24
+ ])
25
+ )
26
+ ]);
27
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addRoute = addRoute;
4
+ exports.createOrUpdateBarrel = createOrUpdateBarrel;
5
+ const string_utils_1 = require("./string-utils");
6
+ /**
7
+ * Atualiza o app.routes.ts adicionando uma nova rota
8
+ */
9
+ function addRoute(tree, context, featureName) {
10
+ var _a;
11
+ const appRoutesPath = 'src/app/app.routes.ts';
12
+ const featureKebab = (0, string_utils_1.toKebabCase)(featureName);
13
+ const featurePascal = (0, string_utils_1.toPascalCase)(featureName);
14
+ if (!tree.exists(appRoutesPath)) {
15
+ context.logger.warn(`⚠️ ${appRoutesPath} não encontrado, rota não registrada`);
16
+ return;
17
+ }
18
+ let content = ((_a = tree.read(appRoutesPath)) === null || _a === void 0 ? void 0 : _a.toString('utf-8')) || '';
19
+ const routePattern = new RegExp(`path:\\s*['"]${featureKebab}['"]`);
20
+ if (routePattern.test(content)) {
21
+ context.logger.warn(`ℹ️ Rota "${featureKebab}" já existe em app.routes.ts`);
22
+ return;
23
+ }
24
+ const routeBlock = ` {
25
+ path: '${featureKebab}',
26
+ loadChildren: () =>
27
+ import('./features/${featureKebab}/${featureKebab}.routes')
28
+ .then(m => m.${featurePascal}Routes),
29
+ },`;
30
+ content = content.replace(/\n\];\s*$/, `\n${routeBlock}\n];`);
31
+ tree.overwrite(appRoutesPath, content);
32
+ context.logger.info(`➕ Rota "${featureKebab}" registrada em app.routes.ts`);
33
+ }
34
+ /**
35
+ * Cria ou atualiza um arquivo barrel (index.ts) em uma pasta
36
+ */
37
+ function createOrUpdateBarrel(tree, context, folderPath) {
38
+ if (!tree.exists(folderPath))
39
+ return;
40
+ const files = tree.getDir(folderPath).subfiles.filter(f => f.endsWith('.ts'));
41
+ const exports = files.map(f => `export * from './${f.replace('.ts', '')}';`).join('\n');
42
+ const barrelPath = `${folderPath}/index.ts`;
43
+ tree.overwrite(barrelPath, exports);
44
+ context.logger.info(`📦 Barrel atualizado em ${folderPath}`);
45
+ }
46
+ //# sourceMappingURL=file-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-utils.js","sourceRoot":"","sources":["file-utils.ts"],"names":[],"mappings":";;AAOA,4BA+BC;AAKD,oDAcC;AAvDD,iDAA2D;AAE3D;;GAEG;AACH,SAAgB,QAAQ,CACtB,IAAU,EACV,OAAyB,EACzB,WAAmB;;IAEnB,MAAM,aAAa,GAAG,uBAAuB,CAAC;IAC9C,MAAM,YAAY,GAAG,IAAA,0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AAC;IAC9E,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEvF,MAAM,UAAU,GAAG,GAAG,UAAU,WAAW,CAAC;IAC5C,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAEpC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ // utils/string-utils.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.toKebabCase = toKebabCase;
5
+ exports.toPascalCase = toPascalCase;
6
+ /**
7
+ * Converte uma string para kebab-case
8
+ * Ex: "UserProfile" -> "user-profile"
9
+ */
10
+ function toKebabCase(value) {
11
+ return value
12
+ .replace(/([a-z])([A-Z])/g, '$1-$2') // separa camelCase
13
+ .replace(/[\s_]+/g, '-') // substitui espaços ou underscores por "-"
14
+ .toLowerCase();
15
+ }
16
+ /**
17
+ * Converte uma string para PascalCase
18
+ * Ex: "user-profile" -> "UserProfile"
19
+ */
20
+ function toPascalCase(value) {
21
+ return value
22
+ .split(/[-_\s]/)
23
+ .map(part => part.charAt(0).toUpperCase() + part.slice(1))
24
+ .join('');
25
+ }
26
+ //# sourceMappingURL=string-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-utils.js","sourceRoot":"","sources":["string-utils.ts"],"names":[],"mappings":";AAAA,wBAAwB;;AAMxB,kCAKC;AAMD,oCAKC;AApBD;;;GAGG;AACH,SAAgB,WAAW,CAAC,KAAa;IACvC,OAAO,KAAK;SACT,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,mBAAmB;SACvD,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAa,2CAA2C;SAC/E,WAAW,EAAE,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAAa;IACxC,OAAO,KAAK;SACT,KAAK,CAAC,QAAQ,CAAC;SACf,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACzD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "baseUrl": "src",
3
+ "baseUrl": ".",
4
4
  "lib": ["es2018", "dom"],
5
5
  "module": "commonjs",
6
6
  "moduleResolution": "node",
@@ -16,17 +16,16 @@
16
16
  "sourceMap": true,
17
17
  "strictNullChecks": true,
18
18
  "target": "es6",
19
- "types": ["jasmine", "node"],
20
-
19
+ "types": ["jasmine", "node"]
21
20
  },
22
21
  "include": ["src/**/*.ts"],
23
22
  "exclude": [
24
23
  "node_modules",
25
24
  "dist",
26
25
  "src/**/*.spec.ts",
27
- "src/feature/files/**/*",
28
- "src/component/files/**/*",
29
- "src/service/files/**/*"
26
+ "src/ng-architect/feature/files/**/*",
27
+ "src/ng-architect/component/files/**/*",
28
+ "src/ng-architect/service/files/**/*"
30
29
  ]
31
30
 
32
31