@resolve-components/theme 1.2.2 → 1.2.4
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 +2 -2
- package/schematics/ng-add/index.js +63 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resolve-components/theme",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"schematics": "./collection.json",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "ðŸâ€ÂÂÂÂÂÂ¥ Fully customizable Angular UI components made with â¤︠using Angular CDK ðŸâ€ÂÂÂÂÂÂ¥",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@angular/common": ">=17.0.0",
|
|
8
8
|
"@angular/core": ">=17.0.0",
|
|
@@ -286,6 +286,67 @@ function addGlobalStyles(options) {
|
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
288
|
// ---------------------------------------------------------------------------
|
|
289
|
+
// Rule: wrap app.html with <rc-layout>
|
|
290
|
+
// ---------------------------------------------------------------------------
|
|
291
|
+
function addRcLayoutToTemplate(options) {
|
|
292
|
+
return (tree, ctx) => {
|
|
293
|
+
const cfg = resolveProjectConfig(tree, options);
|
|
294
|
+
const sourceRoot = cfg?.sourceRoot ?? 'src';
|
|
295
|
+
const templatePath = `${sourceRoot}/app/app.html`;
|
|
296
|
+
if (!tree.exists(templatePath)) {
|
|
297
|
+
ctx.logger.warn(`⚠ ${templatePath} not found — wrap your root template with <rc-layout> manually.`);
|
|
298
|
+
return tree;
|
|
299
|
+
}
|
|
300
|
+
const content = tree.read(templatePath).toString('utf-8');
|
|
301
|
+
if (content.includes('<rc-layout'))
|
|
302
|
+
return tree;
|
|
303
|
+
const wrapped = `<rc-layout>\n${content.trimEnd()}\n</rc-layout>\n`;
|
|
304
|
+
tree.overwrite(templatePath, wrapped);
|
|
305
|
+
ctx.logger.info(` Wrapped ${templatePath} with <rc-layout>`);
|
|
306
|
+
return tree;
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
// ---------------------------------------------------------------------------
|
|
310
|
+
// Rule: add RcLayout to app.ts imports
|
|
311
|
+
// ---------------------------------------------------------------------------
|
|
312
|
+
function addRcLayoutToAppComponent(options) {
|
|
313
|
+
return (tree, ctx) => {
|
|
314
|
+
const cfg = resolveProjectConfig(tree, options);
|
|
315
|
+
const sourceRoot = cfg?.sourceRoot ?? 'src';
|
|
316
|
+
// Support both app.ts and app.component.ts
|
|
317
|
+
const appTsPath = tree.exists(`${sourceRoot}/app/app.ts`)
|
|
318
|
+
? `${sourceRoot}/app/app.ts`
|
|
319
|
+
: tree.exists(`${sourceRoot}/app/app.component.ts`)
|
|
320
|
+
? `${sourceRoot}/app/app.component.ts`
|
|
321
|
+
: null;
|
|
322
|
+
if (!appTsPath) {
|
|
323
|
+
ctx.logger.warn(`⚠ app.ts / app.component.ts not found — add RcLayout to your root component imports manually.`);
|
|
324
|
+
return tree;
|
|
325
|
+
}
|
|
326
|
+
let content = tree.read(appTsPath).toString('utf-8');
|
|
327
|
+
if (content.includes('RcLayout'))
|
|
328
|
+
return tree;
|
|
329
|
+
// Add import statement after last existing import
|
|
330
|
+
const importLine = `import { RcLayout } from '@resolve-components/theme';\n`;
|
|
331
|
+
const lastImportMatch = [...content.matchAll(/^import .*?;\n/gms)]
|
|
332
|
+
.filter((m) => !m[0].includes('\n '))
|
|
333
|
+
.pop();
|
|
334
|
+
if (lastImportMatch) {
|
|
335
|
+
const insertAt = lastImportMatch.index + lastImportMatch[0].length;
|
|
336
|
+
content =
|
|
337
|
+
content.slice(0, insertAt) + importLine + content.slice(insertAt);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
content = importLine + content;
|
|
341
|
+
}
|
|
342
|
+
// Add RcLayout to the component's imports array
|
|
343
|
+
content = content.replace(/(imports:\s*\[)/, `$1RcLayout, `);
|
|
344
|
+
tree.overwrite(appTsPath, content);
|
|
345
|
+
ctx.logger.info(` Added RcLayout import → ${appTsPath}`);
|
|
346
|
+
return tree;
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
// ---------------------------------------------------------------------------
|
|
289
350
|
// Exported schematic factory
|
|
290
351
|
// ---------------------------------------------------------------------------
|
|
291
352
|
function ngAdd(options) {
|
|
@@ -296,6 +357,8 @@ function ngAdd(options) {
|
|
|
296
357
|
addBuildConfig(options),
|
|
297
358
|
addProviderToConfig(options),
|
|
298
359
|
addGlobalStyles(options),
|
|
360
|
+
addRcLayoutToTemplate(options),
|
|
361
|
+
addRcLayoutToAppComponent(options),
|
|
299
362
|
(_tree, ctx) => {
|
|
300
363
|
ctx.addTask(new tasks_1.NodePackageInstallTask());
|
|
301
364
|
ctx.logger.info('\n✅ @resolve-components/theme setup complete!');
|