@mckit/schematics 0.0.8 → 0.0.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@mckit/schematics",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "A blank schematics",
5
5
  "scripts": {
6
6
  "build": "tsc -p tsconfig.json",
@@ -12,6 +12,10 @@
12
12
  "add-login-page": {
13
13
  "description": "Config and create login page",
14
14
  "factory": "./add-login-page/index#addLoginPage"
15
+ },
16
+ "install-layout-fuse": {
17
+ "description": "Install layout fuse",
18
+ "factory": "./install-layout-fuse/index#install"
15
19
  }
16
20
  }
17
21
  }
@@ -1,2 +1,2 @@
1
1
  import { SchematicContext, Tree } from '@angular-devkit/schematics';
2
- export declare function addRoute(routeText: string, tree: Tree, context: SchematicContext): import("@angular-devkit/schematics/src/tree/interface").Tree | undefined;
2
+ export declare function addRoute(routeText: string, tree: Tree, context: SchematicContext, importsText?: string | undefined): import("@angular-devkit/schematics/src/tree/interface").Tree | undefined;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addRoute = addRoute;
4
- function addRoute(routeText, tree, context) {
4
+ function addRoute(routeText, tree, context, importsText = undefined) {
5
5
  var _a;
6
6
  const filePath = 'src/app/app.routes.ts';
7
7
  if (!tree.exists(filePath)) {
@@ -9,10 +9,12 @@ function addRoute(routeText, tree, context) {
9
9
  return tree;
10
10
  }
11
11
  const content = ((_a = tree.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString('utf-8')) || '';
12
- const updatedContent = content.replace(/\[\s*([\s\S]*?)\s*\]/, (_, routes) => {
12
+ let updatedContent = content.replace(/\[\s*([\s\S]*?)\s*\]/, (_, routes) => {
13
13
  return `[${routes.trim() ? routes.trim() + ', ' : ''}${routeText}]`;
14
14
  });
15
+ if (importsText != undefined) {
16
+ updatedContent = importsText + '\n' + updatedContent;
17
+ }
15
18
  tree.overwrite(filePath, updatedContent);
16
- context.logger.info(`✅ Ruta añadida correctamente`);
17
19
  }
18
20
  //# sourceMappingURL=add-route.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-route.js","sourceRoot":"","sources":["add-route.ts"],"names":[],"mappings":";;AAEA,4BAiBC;AAjBD,SAAgB,QAAQ,CAAC,SAAiB,EAAE,IAAU,EAAE,OAAyB;;IAC7E,MAAM,QAAQ,GAAG,uBAAuB,CAAC;IAEzC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,KAAI,EAAE,CAAC;IAE7D,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QACzE,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,GAAG,CAAC;IACxE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IAEzC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;AACxD,CAAC"}
1
+ {"version":3,"file":"add-route.js","sourceRoot":"","sources":["add-route.ts"],"names":[],"mappings":";;AAEA,4BAmBC;AAnBD,SAAgB,QAAQ,CAAC,SAAiB,EAAE,IAAU,EAAE,OAAyB,EAAE,cAAgC,SAAS;;IACxH,MAAM,QAAQ,GAAG,uBAAuB,CAAC;IAEzC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,KAAI,EAAE,CAAC;IAE7D,IAAI,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QACvE,OAAO,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,GAAG,CAAC;IACxE,CAAC,CAAC,CAAC;IAEH,IAAG,WAAW,IAAI,SAAS,EAAC,CAAC;QACzB,cAAc,GAAG,WAAW,GAAG,IAAI,GAAG,cAAc,CAAC;IACzD,CAAC;IAED,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ export declare function addSourceInStyles(tree: Tree, sourceText: string): void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addSourceInStyles = addSourceInStyles;
4
+ const insert_string_at_1 = require("./insert-string-at");
5
+ function addSourceInStyles(tree, sourceText) {
6
+ const filePath = 'src/styles.scss';
7
+ if (!tree.exists(filePath)) {
8
+ return;
9
+ }
10
+ const fileBuffer = tree.read(filePath);
11
+ const content = fileBuffer ? fileBuffer.toString() : '';
12
+ if (!content.includes('@use "tailwindcss";')) {
13
+ return;
14
+ }
15
+ // Search last @source
16
+ const sourcePosition = content.lastIndexOf('@source');
17
+ // Search last ;
18
+ const sourceEndPosition = content.indexOf(';', sourcePosition);
19
+ // Add the new @source after the last @source
20
+ const updatedContent = (0, insert_string_at_1.insertStringAt)(content, sourceText, sourceEndPosition + 1);
21
+ tree.overwrite(filePath, updatedContent);
22
+ }
23
+ //# sourceMappingURL=add-source-in-styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-source-in-styles.js","sourceRoot":"","sources":["add-source-in-styles.ts"],"names":[],"mappings":";;AAGA,8CAsBC;AAxBD,yDAAoD;AAEpD,SAAgB,iBAAiB,CAAC,IAAU,EAAE,UAAkB;IAC5D,MAAM,QAAQ,GAAG,iBAAiB,CAAC;IAEnC,IAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAC,CAAC;QACvB,OAAO;IACX,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAExD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC;QAC3C,OAAO;IACX,CAAC;IAED,sBAAsB;IACtB,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACtD,gBAAgB;IAChB,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAC/D,6CAA6C;IAC7C,MAAM,cAAc,GAAG,IAAA,iCAAc,EAAC,OAAO,EAAE,UAAU,EAAE,iBAAiB,GAAG,CAAC,CAAC,CAAC;IAElF,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function insertStringAt(originalString: string, stringToInsert: string, position: number): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.insertStringAt = insertStringAt;
4
+ function insertStringAt(originalString, stringToInsert, position) {
5
+ if (position > originalString.length) {
6
+ // Si la posición está fuera del rango, simplemente agrega el string al final
7
+ return originalString + stringToInsert;
8
+ }
9
+ // Dividir el original en dos partes: antes y después de la posición
10
+ const before = originalString.slice(0, position);
11
+ const after = originalString.slice(position);
12
+ // Insertar el string en la posición deseada
13
+ return before + stringToInsert + after;
14
+ }
15
+ //# sourceMappingURL=insert-string-at.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert-string-at.js","sourceRoot":"","sources":["insert-string-at.ts"],"names":[],"mappings":";;AAAA,wCAYC;AAZD,SAAgB,cAAc,CAAC,cAAsB,EAAE,cAAsB,EAAE,QAAgB;IAC3F,IAAI,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC;QACnC,6EAA6E;QAC7E,OAAO,cAAc,GAAG,cAAc,CAAC;IAC3C,CAAC;IAED,oEAAoE;IACpE,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAE7C,4CAA4C;IAC5C,OAAO,MAAM,GAAG,cAAc,GAAG,KAAK,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { Component, inject } from '@angular/core';
2
+ import { RouterOutlet } from '@angular/router';
3
+ import { MCFooterService, MCSidebarService, MCTopbarService } from '@mckit/layout-core';
4
+ import { MCIconToggleSidebarButton } from '@mckit/layout';
5
+ import { MCImage, MCMenu, MCSubtitle } from '@mckit/core';
6
+ import { FooterComponent } from './layout/footer/footer.component';
7
+ import { MCAvatarWithMenu } from '@mckit/auth';
8
+
9
+ @Component({
10
+ selector: 'app-root',
11
+ imports: [RouterOutlet],
12
+ templateUrl: './app.component.html',
13
+ styleUrl: './app.component.scss'
14
+ })
15
+ export class AppComponent {
16
+ sidebarService = inject(MCSidebarService);
17
+ topbarService = inject(MCTopbarService);
18
+ footerService = inject(MCFooterService);
19
+
20
+ items: Array<MenuItem> = [
21
+ {
22
+ label: 'Hi Matias',
23
+ items: [
24
+ {
25
+ label: 'Integrations ',
26
+ icon: 'pi pi-link',
27
+ routerLink: '/integrations'
28
+ },
29
+ {
30
+ label: 'Logout ',
31
+ icon: 'pi pi-window-maximize',
32
+ command: () => this.onLogout()
33
+ }
34
+ ]
35
+ }
36
+ ];
37
+
38
+ ngOnInit(): void {
39
+ this.loadSidebar();
40
+ this.loadTopbar();
41
+ this.loadFooter();
42
+ }
43
+
44
+ onLogout() {
45
+ /*this.authService.removeUser()
46
+ .subscribe(res => window.location.reload());*/
47
+ }
48
+
49
+ loadTopbar() {
50
+ this.topbarService.addComponentToLeft(new MCIconToggleSidebarButton());
51
+
52
+ this.topbarService.addComponentToRight(new DarkModeButton());
53
+ this.topbarService.addComponentToRight(new MCAvatarWithMenu(this.items));
54
+ }
55
+
56
+ loadSidebar() {
57
+ /**
58
+ * Add components in sidebar all at once
59
+ */
60
+ this.sidebarService.setComponents([
61
+ new MCImage('https://tots.agency/assets/img/logos/logo-horiz-black-color.svg', 150),
62
+ new MCSubtitle('MENU'),
63
+ new MCMenu([
64
+ { label: 'Accounts', link: '/accounts', icon: 'pi pi-building-columns' },
65
+ { label: 'Records', link: '/records', icon: 'pi pi-building-columns' },
66
+ ])
67
+ ]);
68
+ }
69
+
70
+ loadFooter() {
71
+ this.footerService.addComponent({ component: FooterComponent, config: { } });
72
+ }
73
+ }
@@ -0,0 +1,2 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ export declare function install(_options: any): Rule;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.install = install;
4
+ const run_command_1 = require("../core/run-command");
5
+ const add_route_1 = require("../core/add-route");
6
+ const get_content_by_file_1 = require("../core/get-content-by-file");
7
+ const add_source_in_styles_1 = require("../core/add-source-in-styles");
8
+ // You don't have to export the function as default. You can also have more than one rule factory
9
+ // per file.
10
+ function install(_options) {
11
+ return (tree, _context) => {
12
+ // Install the required dependencies
13
+ (0, run_command_1.runCommand)('npm install --save @mckit/layout-core @mckit/layout @mckit/layout-fuse', _context);
14
+ // Config SCSS
15
+ (0, add_source_in_styles_1.addSourceInStyles)(tree, `
16
+ @source "../node_modules/@mckit/layout-core";
17
+ @source "../node_modules/@mckit/layout";
18
+ @source "../node_modules/@mckit/layout-fuse";
19
+ `);
20
+ // Add Route
21
+ (0, add_route_1.addRoute)(`{
22
+ path: '',
23
+ component: MCFuseLayoutComponent,
24
+ //canActivate: [mcAuthGuard],
25
+ children: []
26
+ },`, tree, _context, `import { MCFuseLayoutComponent } from '@mckit/layout-fuse';`);
27
+ // Generate Footer component
28
+ (0, run_command_1.runCommand)('ng g c layout/footer', _context);
29
+ // Replace App Component
30
+ const component = (0, get_content_by_file_1.getContentByFile)(__dirname, 'app.component.ts.template');
31
+ tree.overwrite('src/app/app.component.ts', component !== null && component !== void 0 ? component : '');
32
+ return tree;
33
+ };
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAQA,0BA6BC;AApCD,qDAAiD;AACjD,iDAA6C;AAC7C,qEAA+D;AAC/D,uEAAiE;AAEjE,iGAAiG;AACjG,YAAY;AACZ,SAAgB,OAAO,CAAC,QAAa;IACnC,OAAO,CAAC,IAAU,EAAE,QAA0B,EAAE,EAAE;QAChD,oCAAoC;QACpC,IAAA,wBAAU,EAAC,wEAAwE,EAAE,QAAQ,CAAC,CAAC;QAE/F,cAAc;QACd,IAAA,wCAAiB,EAAC,IAAI,EAAE;;;;CAI3B,CAAC,CAAC;QAEC,YAAY;QACZ,IAAA,oBAAQ,EAAC;;;;;KAKR,EAAE,IAAI,EAAE,QAAQ,EAAE,6DAA6D,CAAC,CAAC;QAElF,4BAA4B;QAC5B,IAAA,wBAAU,EAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC;QAE7C,wBAAwB;QACxB,MAAM,SAAS,GAAG,IAAA,sCAAgB,EAAC,SAAS,EAAE,2BAA2B,CAAC,CAAC;QAC3E,IAAI,CAAC,SAAS,CAAC,0BAA0B,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}