@ngflow/ng-architect 1.2.3 → 1.2.5
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 +1 -1
- package/src/ng-architect/component/schema.json +3 -3
- package/src/ng-architect/feature/index.js +7 -1
- package/src/ng-architect/feature/index.js.map +1 -1
- package/src/ng-architect/feature/index.ts +11 -1
- package/src/ng-architect/feature/schema.json +2 -2
- package/src/ng-architect/service/schema.json +2 -2
- package/src/ng-architect/utils/options-validator.js +12 -0
- package/src/ng-architect/utils/options-validator.js.map +1 -0
- package/src/ng-architect/utils/options-validator.ts +18 -0
- package/src/ng-architect/utils/routes-utils.js +4 -10
- package/src/ng-architect/utils/routes-utils.js.map +1 -1
- package/src/ng-architect/utils/routes-utils.ts +7 -11
- package/src/ng-architect/utils/structure-resolver.js +23 -0
- package/src/ng-architect/utils/structure-resolver.js.map +1 -0
- package/src/ng-architect/utils/structure-resolver.ts +34 -0
package/package.json
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"name": { "type": "string", "description": "Component name" },
|
|
9
9
|
"structure": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"enum": ["flat", "domain-driven", "module-driven", "monorepo"],
|
|
12
|
-
"default": "
|
|
13
|
-
|
|
11
|
+
"enum": ["auto", "flat", "domain-driven", "module-driven", "monorepo"],
|
|
12
|
+
"default": "auto"
|
|
13
|
+
},
|
|
14
14
|
"module": { "type": "string", "description": "Module name (for module-driven structure)" },
|
|
15
15
|
"app": { "type": "string", "description": "App name (for monorepo)" },
|
|
16
16
|
"lib": { "type": "string", "description": "Lib name (for monorepo)" }
|
|
@@ -4,6 +4,8 @@ exports.default = default_1;
|
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
5
|
const string_utils_1 = require("../utils/string-utils");
|
|
6
6
|
const routes_utils_1 = require("../utils/routes-utils");
|
|
7
|
+
const structure_resolver_1 = require("../utils/structure-resolver");
|
|
8
|
+
const options_validator_1 = require("../utils/options-validator");
|
|
7
9
|
function default_1(options) {
|
|
8
10
|
const featureKebab = (0, string_utils_1.toKebabCase)(options.name);
|
|
9
11
|
const featurePascal = (0, string_utils_1.toPascalCase)(options.name);
|
|
@@ -35,9 +37,13 @@ function default_1(options) {
|
|
|
35
37
|
throw new Error(`Invalid structure: ${options.structure}`);
|
|
36
38
|
}
|
|
37
39
|
return (0, schematics_1.chain)([
|
|
38
|
-
(
|
|
40
|
+
(tree, context) => {
|
|
39
41
|
context.logger.info(`🟢 Creating feature: ${featurePascal} (${featureKebab})`);
|
|
40
42
|
context.logger.info(`Structure: ${options.structure}`);
|
|
43
|
+
const resolved = (0, structure_resolver_1.resolveStructure)(tree, options);
|
|
44
|
+
options.structure = resolved;
|
|
45
|
+
context.logger.info(`📐 Structure resolved to: ${resolved}`);
|
|
46
|
+
(0, options_validator_1.validateOptions)(options, resolved);
|
|
41
47
|
},
|
|
42
48
|
(0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [(0, schematics_1.template)({ featureKebab, featurePascal }), (0, schematics_1.move)(basePath)])),
|
|
43
49
|
(_tree, context) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAgBA,4BAsFC;AAtGD,2DAUoC;AACpC,wDAAkE;AAClE,wDAAwD;AACxD,oEAA+D;AAC/D,kEAA6D;AAE7D,mBAAyB,OAAY;IACnC,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,IAAI,QAAgB,CAAC;IACrB,IAAI,UAAU,GAAa,EAAE,CAAC;IAE9B,QAAQ,OAAO,CAAC,SAAS,EAAE,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CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBAClC,OAAO,oBAAoB,IAAI,IAAI,CAAC;gBACtC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAEd,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,UAAU,WAAW,CAAC,EAAE,CAAC;oBAC5C,KAAK,CAAC,MAAM,CAAC,GAAG,UAAU,WAAW,EAAE,aAAa,CAAC,CAAC;gBACxD,CAAC;qBAAM,CAAC;oBACN,6DAA6D;oBAC7D,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,WAAW,CAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;oBACzE,MAAM,UAAU,GAAG,KAAK;yBACrB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAC,EAAE,CAAC,IAAI,CAAC;yBACrD,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;yBACxC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACd,IAAI,UAAU;wBAAE,KAAK,CAAC,SAAS,CAAC,GAAG,UAAU,WAAW,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC;gBAC1F,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
} from '@angular-devkit/schematics';
|
|
12
12
|
import { toKebabCase, toPascalCase } from '../utils/string-utils';
|
|
13
13
|
import { updateAppRoutes } from '../utils/routes-utils';
|
|
14
|
+
import { resolveStructure } from '../utils/structure-resolver';
|
|
15
|
+
import { validateOptions } from '../utils/options-validator';
|
|
14
16
|
|
|
15
17
|
export default function (options: any): Rule {
|
|
16
18
|
const featureKebab = toKebabCase(options.name);
|
|
@@ -21,6 +23,7 @@ export default function (options: any): Rule {
|
|
|
21
23
|
|
|
22
24
|
switch (options.structure) {
|
|
23
25
|
case 'flat':
|
|
26
|
+
|
|
24
27
|
basePath = `src/app/${featureKebab}`;
|
|
25
28
|
break;
|
|
26
29
|
|
|
@@ -49,15 +52,22 @@ export default function (options: any): Rule {
|
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
return chain([
|
|
52
|
-
(
|
|
55
|
+
(tree: Tree, context: SchematicContext) => {
|
|
53
56
|
context.logger.info(`🟢 Creating feature: ${featurePascal} (${featureKebab})`);
|
|
54
57
|
context.logger.info(`Structure: ${options.structure}`);
|
|
58
|
+
const resolved = resolveStructure(tree, options);
|
|
59
|
+
options.structure = resolved;
|
|
60
|
+
|
|
61
|
+
context.logger.info(`📐 Structure resolved to: ${resolved}`);
|
|
62
|
+
|
|
63
|
+
validateOptions(options, resolved);
|
|
55
64
|
},
|
|
56
65
|
|
|
57
66
|
mergeWith(apply(url('./files'), [template({ featureKebab, featurePascal }), move(basePath)])),
|
|
58
67
|
|
|
59
68
|
(_tree: Tree, context: SchematicContext) => {
|
|
60
69
|
context.logger.info(`🟢 Updating app.routes.ts with ${featurePascal}Page...`);
|
|
70
|
+
|
|
61
71
|
updateAppRoutes(_tree, featureKebab, featurePascal, options.structure, options);
|
|
62
72
|
},
|
|
63
73
|
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"structure": {
|
|
13
13
|
"type": "string",
|
|
14
|
-
"enum": ["flat", "domain-driven", "module-driven", "monorepo"],
|
|
15
|
-
"default": "
|
|
14
|
+
"enum": ["auto", "flat", "domain-driven", "module-driven", "monorepo"],
|
|
15
|
+
"default": "auto",
|
|
16
16
|
"description": "Project structure for feature"
|
|
17
17
|
},
|
|
18
18
|
"module": {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"name": { "type": "string", "description": "Service name" },
|
|
9
9
|
"structure": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"enum": ["flat", "domain-driven", "module-driven", "monorepo"],
|
|
12
|
-
"default": "
|
|
11
|
+
"enum": ["auto", "flat", "domain-driven", "module-driven", "monorepo"],
|
|
12
|
+
"default": "auto"
|
|
13
13
|
},
|
|
14
14
|
"module": { "type": "string", "description": "Module name (for module-driven structure)" },
|
|
15
15
|
"app": { "type": "string", "description": "App name (for monorepo)" },
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateOptions = validateOptions;
|
|
4
|
+
function validateOptions(options, structure) {
|
|
5
|
+
if (structure === 'module-driven' && !options.module) {
|
|
6
|
+
throw new Error('❌ structure=module-driven requires --module=<moduleName>');
|
|
7
|
+
}
|
|
8
|
+
if (structure === 'monorepo' && !options.app && !options.lib) {
|
|
9
|
+
throw new Error('❌ structure=monorepo requires --app or --lib');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=options-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-validator.js","sourceRoot":"","sources":["options-validator.ts"],"names":[],"mappings":";;AAEA,0CAeC;AAfD,SAAgB,eAAe,CAC7B,OAAY,EACZ,SAAoB;IAEpB,IAAI,SAAS,KAAK,eAAe,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,KAAK,UAAU,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QAC7D,MAAM,IAAI,KAAK,CACb,8CAA8C,CAC/C,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Structure } from './structure-resolver';
|
|
2
|
+
|
|
3
|
+
export function validateOptions(
|
|
4
|
+
options: any,
|
|
5
|
+
structure: Structure
|
|
6
|
+
) {
|
|
7
|
+
if (structure === 'module-driven' && !options.module) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
'❌ structure=module-driven requires --module=<moduleName>'
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (structure === 'monorepo' && !options.app && !options.lib) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
'❌ structure=monorepo requires --app or --lib'
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -35,7 +35,7 @@ function updateAppRoutes(tree, featureKebab, featurePascal, structure, options)
|
|
|
35
35
|
const importPath = (() => {
|
|
36
36
|
switch (structure) {
|
|
37
37
|
case 'flat':
|
|
38
|
-
return `./${featureKebab}/${featureKebab}.page`;
|
|
38
|
+
return `./${featureKebab}/pages/${featureKebab}.page`;
|
|
39
39
|
case 'domain-driven':
|
|
40
40
|
return `./features/${featureKebab}/pages/${featureKebab}.page`;
|
|
41
41
|
case 'module-driven':
|
|
@@ -44,17 +44,11 @@ function updateAppRoutes(tree, featureKebab, featurePascal, structure, options)
|
|
|
44
44
|
return `./${featureKebab}/pages/${featureKebab}.page`;
|
|
45
45
|
}
|
|
46
46
|
})();
|
|
47
|
-
const importStatement =
|
|
48
|
-
|
|
49
|
-
const routeEntry = structure === 'module-driven' || structure === 'domain-driven'
|
|
50
|
-
? ` { path: '${featureKebab}', loadChildren: () => import('${importPath.replace('.page', '.module')}').then(m => m.${featurePascal}Module) },`
|
|
51
|
-
: ` { path: '${featureKebab}', component: ${featurePascal}Page },`;
|
|
47
|
+
const importStatement = `// Lazy-loaded standalone component: ${featurePascal}Page\n`;
|
|
48
|
+
const routeEntry = ` { path: '${featureKebab}', loadComponent: () => import('${importPath}').then(c => c.${featurePascal}Page) },`;
|
|
52
49
|
// Evitar duplicação
|
|
53
|
-
if (!content.includes(importStatement)) {
|
|
54
|
-
content = importStatement + content;
|
|
55
|
-
}
|
|
56
50
|
if (!content.includes(routeEntry)) {
|
|
57
|
-
content = content.replace(/export const routes: Routes = \[/, (match) => match + '\n' + routeEntry);
|
|
51
|
+
content = importStatement + content.replace(/export const routes: Routes = \[/, (match) => match + '\n' + routeEntry);
|
|
58
52
|
}
|
|
59
53
|
tree.overwrite(routesFilePath, content);
|
|
60
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-utils.js","sourceRoot":"","sources":["routes-utils.ts"],"names":[],"mappings":";;AAEA,
|
|
1
|
+
{"version":3,"file":"routes-utils.js","sourceRoot":"","sources":["routes-utils.ts"],"names":[],"mappings":";;AAEA,0CAmEC;AAnED,SAAgB,eAAe,CAC7B,IAAU,EACV,YAAoB,EACpB,aAAqB,EACrB,SAAiB,EACjB,OAAY;;IAEZ,IAAI,cAAc,GAAW,EAAE,CAAC;IAEhC,0CAA0C;IAC1C,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC;QACZ,KAAK,eAAe,CAAC;QACrB,KAAK,eAAe;YAClB,cAAc,GAAG,uBAAuB,CAAC;YACzC,MAAM;QAER,KAAK,UAAU;YACb,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;gBAChB,cAAc,GAAG,QAAQ,OAAO,CAAC,GAAG,wBAAwB,CAAC;YAC/D,CAAC;iBAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;gBACvB,4CAA4C;gBAC5C,cAAc,GAAG,QAAQ,OAAO,CAAC,GAAG,wBAAwB,CAAC;gBAC7D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;oBACjC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,kFAAkF,CAAC,CAAC;gBAClH,CAAC;YACH,CAAC;YACD,MAAM;QAER;YACE,MAAM,IAAI,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,+BAA+B;IAC/B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,kFAAkF,CAAC,CAAC;IAClH,CAAC;IAED,IAAI,OAAO,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,KAAI,EAAE,CAAC;IAEjE,oBAAoB;IACpB,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE;QACvB,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,MAAM;gBACT,OAAO,KAAK,YAAY,UAAU,YAAY,OAAO,CAAC;YACxD,KAAK,eAAe;gBAClB,OAAO,cAAc,YAAY,UAAU,YAAY,OAAO,CAAC;YACjE,KAAK,eAAe;gBAClB,OAAO,KAAK,OAAO,CAAC,MAAM,IAAI,YAAY,UAAU,YAAY,OAAO,CAAC;YAC1E,KAAK,UAAU;gBACb,OAAO,KAAK,YAAY,UAAU,YAAY,OAAO,CAAC;QAC1D,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IAEL,MAAM,eAAe,GAAG,wCAAwC,aAAa,QAAQ,CAAC;IAEtF,MAAM,UAAU,GAAG,cAAc,YAAY,mCAAmC,UAAU,kBAAkB,aAAa,UAAU,CAAC;IAEpI,oBAAoB;IACpB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,OAAO,GAAG,eAAe,GAAG,OAAO,CAAC,OAAO,CACzC,kCAAkC,EAClC,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI,GAAG,UAAU,CAC7C,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -44,7 +44,7 @@ export function updateAppRoutes(
|
|
|
44
44
|
const importPath = (() => {
|
|
45
45
|
switch (structure) {
|
|
46
46
|
case 'flat':
|
|
47
|
-
return `./${featureKebab}/${featureKebab}.page`;
|
|
47
|
+
return `./${featureKebab}/pages/${featureKebab}.page`;
|
|
48
48
|
case 'domain-driven':
|
|
49
49
|
return `./features/${featureKebab}/pages/${featureKebab}.page`;
|
|
50
50
|
case 'module-driven':
|
|
@@ -54,20 +54,16 @@ export function updateAppRoutes(
|
|
|
54
54
|
}
|
|
55
55
|
})();
|
|
56
56
|
|
|
57
|
-
const importStatement =
|
|
57
|
+
const importStatement = `// Lazy-loaded standalone component: ${featurePascal}Page\n`;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
const routeEntry =
|
|
61
|
-
structure === 'module-driven' || structure === 'domain-driven'
|
|
62
|
-
? ` { path: '${featureKebab}', loadChildren: () => import('${importPath.replace('.page', '.module')}').then(m => m.${featurePascal}Module) },`
|
|
63
|
-
: ` { path: '${featureKebab}', component: ${featurePascal}Page },`;
|
|
59
|
+
const routeEntry = ` { path: '${featureKebab}', loadComponent: () => import('${importPath}').then(c => c.${featurePascal}Page) },`;
|
|
64
60
|
|
|
65
61
|
// Evitar duplicação
|
|
66
|
-
if (!content.includes(importStatement)) {
|
|
67
|
-
content = importStatement + content;
|
|
68
|
-
}
|
|
69
62
|
if (!content.includes(routeEntry)) {
|
|
70
|
-
content = content.replace(
|
|
63
|
+
content = importStatement + content.replace(
|
|
64
|
+
/export const routes: Routes = \[/,
|
|
65
|
+
(match: string) => match + '\n' + routeEntry
|
|
66
|
+
);
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
tree.overwrite(routesFilePath, content);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveStructure = resolveStructure;
|
|
4
|
+
function resolveStructure(tree, options) {
|
|
5
|
+
if (options.structure && options.structure !== 'auto') {
|
|
6
|
+
return options.structure;
|
|
7
|
+
}
|
|
8
|
+
// Monorepo
|
|
9
|
+
if (tree.exists('apps') || tree.exists('libs')) {
|
|
10
|
+
return 'monorepo';
|
|
11
|
+
}
|
|
12
|
+
// Domain-driven
|
|
13
|
+
if (tree.exists('src/app/features')) {
|
|
14
|
+
return 'domain-driven';
|
|
15
|
+
}
|
|
16
|
+
// Flat standalone
|
|
17
|
+
if (tree.exists('src/app/app.routes.ts')) {
|
|
18
|
+
return 'flat';
|
|
19
|
+
}
|
|
20
|
+
// Fallback seguro
|
|
21
|
+
return 'domain-driven';
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=structure-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structure-resolver.js","sourceRoot":"","sources":["structure-resolver.ts"],"names":[],"mappings":";;AAQA,4CAyBC;AAzBD,SAAgB,gBAAgB,CAC9B,IAAU,EACV,OAAY;IAEZ,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;QACtD,OAAO,OAAO,CAAC,SAAS,CAAC;IAC3B,CAAC;IAED,WAAW;IACX,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/C,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,gBAAgB;IAChB,IAAI,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACpC,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,kBAAkB;IAClB,IAAI,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE,CAAC;QACzC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,kBAAkB;IAClB,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
|
2
|
+
|
|
3
|
+
export type Structure =
|
|
4
|
+
| 'flat'
|
|
5
|
+
| 'domain-driven'
|
|
6
|
+
| 'module-driven'
|
|
7
|
+
| 'monorepo';
|
|
8
|
+
|
|
9
|
+
export function resolveStructure(
|
|
10
|
+
tree: Tree,
|
|
11
|
+
options: any
|
|
12
|
+
): Structure {
|
|
13
|
+
if (options.structure && options.structure !== 'auto') {
|
|
14
|
+
return options.structure;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Monorepo
|
|
18
|
+
if (tree.exists('apps') || tree.exists('libs')) {
|
|
19
|
+
return 'monorepo';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Domain-driven
|
|
23
|
+
if (tree.exists('src/app/features')) {
|
|
24
|
+
return 'domain-driven';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Flat standalone
|
|
28
|
+
if (tree.exists('src/app/app.routes.ts')) {
|
|
29
|
+
return 'flat';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Fallback seguro
|
|
33
|
+
return 'domain-driven';
|
|
34
|
+
}
|