Skip to content

Commit 1026a46

Browse files
committed
'[CHECKPOINT]'
1 parent aff0bb8 commit 1026a46

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

projects/wml-schematics/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"peerDependencies": {
99
"@angular/common": "^19.0.5",
1010
"@angular/core": "^19.0.5",
11-
"@windmillcode/angular-wml-components-base": "^19.0.5000",
12-
"@windmillcode/wml-components-base": "^19.0.5000"
11+
"@windmillcode/angular-wml-components-base": "^19.0.5001",
12+
"@windmillcode/wml-components-base": "^19.0.5001"
1313
},
1414
"private": false,
1515
"repository": {
@@ -22,5 +22,5 @@
2222
"postbuild": "npx copyfiles schematics/collection.json schematics/*/schema.json schematics/*/files/** ../../dist/wml-schematics/",
2323
"test": "npx ng test templates --code-coverage"
2424
},
25-
"version": "19.0.5000"
25+
"version": "19.0.5001"
2626
}

projects/wml-schematics/schematics/template-component/index.ts

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type TemplateComponentSchema = {
2525
flat?: boolean;
2626
type: string;
2727
isPageModule: boolean;
28+
isLayout: boolean;
2829
route?: string;
2930
routeKey?: string;
3031
routesFilePath?:string;
@@ -87,6 +88,7 @@ export function generateComponentTemplate(
8788
templateSources.push(mergeWith(subTemplateSource, MergeStrategy.Overwrite));
8889
}
8990

91+
9092
let routingModulePath: Path | undefined;
9193

9294
if(options.route){
@@ -95,6 +97,18 @@ export function generateComponentTemplate(
9597
options.isPageModule = true
9698
}
9799

100+
let appIntegration = noop()
101+
if(options.isPageModule){
102+
appIntegration = modifyAppToAddNewPage(options)
103+
}
104+
else if(options.isLayout){
105+
appIntegration = (tree: Tree) => {
106+
applyAdditionalAppFeaturesForNewComponent(options, tree);
107+
}
108+
}
109+
else if(!options.isLayout){
110+
appIntegration = addDeclarationToModuleCpntsArr(options)
111+
}
98112
return chain([
99113
externalSchematic('@schematics/angular', 'component', {
100114
name: options.name,
@@ -103,17 +117,16 @@ export function generateComponentTemplate(
103117
project: options.project,
104118
style: 'scss',
105119
skipImport: !options.isPageModule,
120+
// skipImport:true,
106121
module:options.module
107122
}),
108123
options.route && options.standalone ? addRouteDeclarationToNgModule(options, routingModulePath,"component") : noop(),
109-
options.isPageModule
110-
? modifyAppToAddNewPage(options)
111-
: addDeclarationToModuleCpntsArr(options),
112-
...templateSources,
113-
(tree: Tree, _context: SchematicContext) => {
114-
excludeSubFolders(options, tree, _context);
115-
return tree;
116-
}
124+
appIntegration,
125+
...templateSources,
126+
(tree: Tree, _context: SchematicContext) => {
127+
excludeSubFolders(options, tree, _context);
128+
return tree;
129+
}
117130

118131
])
119132
}
@@ -192,12 +205,7 @@ function addDeclarationToModuleCpntsArr(options: TemplateComponentSchema) {
192205
// add import path
193206
addTsImportPath(options, modulePath, changes, moduleFile, componentVar, tree);
194207

195-
196-
197-
// add scss
198-
addScssToAppStyles(options, tree);
199-
200-
updateIdPrefixObj(options, tree)
208+
applyAdditionalAppFeaturesForNewComponent(options, tree);
201209
return tree;
202210
};
203211
}
@@ -305,6 +313,12 @@ let addRouteEntryToEnvArr = (options: TemplateComponentSchema, tree: Tree) => {
305313
}
306314
};
307315

316+
function applyAdditionalAppFeaturesForNewComponent(options: TemplateComponentSchema, tree:Tree) {
317+
addScssToAppStyles(options, tree);
318+
319+
updateIdPrefixObj(options, tree);
320+
}
321+
308322
function addScssToAppStyles(options: TemplateComponentSchema, tree: Tree) {
309323
try {
310324
let filePath = getFilePath(options);

projects/wml-schematics/schematics/template-component/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
"isPageModule":{
8080
"type":"boolean",
8181
"description":"whether the component is a page or not (page standalone component if you will)"
82+
},
83+
"isLayout":{
84+
"type":"boolean",
85+
"description":"whether the component is a layout or not"
8286
}
8387

8488
},

projects/wml-schematics/tsconfig.lib.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"inlineSources": true,
99
"types": [],
1010
"noUnusedLocals": false,
11-
"noUnusedParameters": false
11+
"noUnusedParameters": false,
12+
"strict": false
1213
},
1314
"exclude": [
1415
"src/test.ts",

0 commit comments

Comments
 (0)