devextreme-schematics 1.3.0-beta.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. package/package.json +10 -8
  2. package/src/add-app-template/index.js +2 -1
  3. package/src/add-app-template/index.js.map +1 -1
  4. package/src/add-app-template/index.ts +30 -0
  5. package/src/add-app-template/index_spec.js +6 -5
  6. package/src/add-app-template/index_spec.js.map +1 -1
  7. package/src/add-app-template/index_spec.ts +73 -0
  8. package/src/add-app-template/schema.json +7 -3
  9. package/src/add-layout/files/devextreme.json +1 -1
  10. package/src/add-layout/files/src/app/__name__.component.html +3 -3
  11. package/src/add-layout/files/src/app/__name__.component.ts +1 -1
  12. package/src/add-layout/files/src/app/app-routing.module.ts +1 -1
  13. package/src/add-layout/files/src/app/layouts/side-nav-inner-toolbar/side-nav-inner-toolbar.component.ts +13 -11
  14. package/src/add-layout/files/src/app/layouts/side-nav-outer-toolbar/side-nav-outer-toolbar.component.ts +10 -9
  15. package/src/add-layout/files/src/app/layouts/single-card/single-card.component.ts +4 -4
  16. package/src/add-layout/files/src/app/not-authorized-container.ts +2 -0
  17. package/src/add-layout/files/src/app/shared/components/change-password-form/change-password-form.component.html +8 -6
  18. package/src/add-layout/files/src/app/shared/components/change-password-form/change-password-form.component.ts +6 -15
  19. package/src/add-layout/files/src/app/shared/components/create-account-form/create-account-form.component.html +9 -7
  20. package/src/add-layout/files/src/app/shared/components/create-account-form/create-account-form.component.ts +4 -13
  21. package/src/add-layout/files/src/app/shared/components/header/header.component.ts +11 -6
  22. package/src/add-layout/files/src/app/shared/components/login-form/login-form.component.html +8 -6
  23. package/src/add-layout/files/src/app/shared/components/login-form/login-form.component.ts +2 -12
  24. package/src/add-layout/files/src/app/shared/components/reset-password-form/reset-password-form.component.html +8 -6
  25. package/src/add-layout/files/src/app/shared/components/reset-password-form/reset-password-form.component.ts +2 -12
  26. package/src/add-layout/files/src/app/shared/components/side-navigation-menu/side-navigation-menu.component.ts +8 -7
  27. package/src/add-layout/files/src/app/shared/components/user-panel/user-panel.component.html +5 -2
  28. package/src/add-layout/files/src/app/shared/components/user-panel/user-panel.component.ts +3 -2
  29. package/src/add-layout/files/src/app/shared/services/auth.service.ts +11 -5
  30. package/src/add-layout/files/src/app/shared/services/screen.service.ts +2 -2
  31. package/src/add-layout/files/src/app/unauthenticated-content.ts +53 -0
  32. package/src/add-layout/files/src/dx-styles.scss +4 -0
  33. package/src/add-layout/index.js +45 -31
  34. package/src/add-layout/index.js.map +1 -1
  35. package/src/add-layout/index.ts +384 -0
  36. package/src/add-layout/index_spec.js +42 -28
  37. package/src/add-layout/index_spec.js.map +1 -1
  38. package/src/add-layout/index_spec.ts +340 -0
  39. package/src/add-layout/schema.json +6 -2
  40. package/src/add-sample-views/files/pages/home/home.component.html +5 -5
  41. package/src/add-sample-views/files/pages/profile/profile.component.ts +1 -1
  42. package/src/add-sample-views/files/pages/tasks/tasks.component.html +1 -0
  43. package/src/add-sample-views/index.js +13 -4
  44. package/src/add-sample-views/index.js.map +1 -1
  45. package/src/add-sample-views/index.ts +141 -0
  46. package/src/add-sample-views/index_spec.js +5 -4
  47. package/src/add-sample-views/index_spec.js.map +1 -1
  48. package/src/add-sample-views/index_spec.ts +74 -0
  49. package/src/add-sample-views/schema.json +1 -1
  50. package/src/add-view/index.d.ts +2 -2
  51. package/src/add-view/index.js +33 -22
  52. package/src/add-view/index.js.map +1 -1
  53. package/src/add-view/index.ts +166 -0
  54. package/src/add-view/index_spec.js +12 -12
  55. package/src/add-view/index_spec.js.map +1 -1
  56. package/src/add-view/index_spec.ts +155 -0
  57. package/src/add-view/schema.json +4 -4
  58. package/src/collection.json +2 -1
  59. package/src/install/index.js +16 -3
  60. package/src/install/index.js.map +1 -1
  61. package/src/install/index.ts +88 -0
  62. package/src/install/index_spec.js +10 -9
  63. package/src/install/index_spec.js.map +1 -1
  64. package/src/install/index_spec.ts +106 -0
  65. package/src/install/schema.json +2 -2
  66. package/src/utility/array.js +1 -0
  67. package/src/utility/array.js.map +1 -1
  68. package/src/utility/array.ts +3 -0
  69. package/src/utility/change.js +1 -0
  70. package/src/utility/change.js.map +1 -1
  71. package/src/utility/change.ts +66 -0
  72. package/src/utility/latest-versions.d.ts +1 -1
  73. package/src/utility/latest-versions.js +3 -2
  74. package/src/utility/latest-versions.js.map +1 -1
  75. package/src/utility/latest-versions.ts +6 -0
  76. package/src/utility/modify-json-file.d.ts +1 -0
  77. package/src/utility/modify-json-file.js +7 -3
  78. package/src/utility/modify-json-file.js.map +1 -1
  79. package/src/utility/modify-json-file.ts +16 -0
  80. package/src/utility/project.d.ts +4 -4
  81. package/src/utility/project.js +35 -12
  82. package/src/utility/project.js.map +1 -1
  83. package/src/utility/project.ts +30 -0
  84. package/src/utility/routing.js +1 -0
  85. package/src/utility/routing.js.map +1 -1
  86. package/src/utility/routing.ts +44 -0
  87. package/src/utility/source.js +1 -0
  88. package/src/utility/source.js.map +1 -1
  89. package/src/utility/source.ts +16 -0
  90. package/src/utility/string.js +1 -0
  91. package/src/utility/string.js.map +1 -1
  92. package/src/utility/string.ts +5 -0
  93. package/src/utility/styles.d.ts +1 -2
  94. package/src/utility/styles.js +3 -4
  95. package/src/utility/styles.js.map +1 -1
  96. package/src/utility/styles.ts +30 -0
@@ -1,26 +1,49 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const config_1 = require("@schematics/angular/utility/config");
4
- function getProjectName(host, project) {
5
- const projectName = project;
6
- const workspace = config_1.getWorkspace(host);
7
- const projects = Object.keys(workspace.projects);
8
- return projectName && projects.indexOf(projectName) > -1 ? projectName : workspace.defaultProject;
12
+ exports.getRootPath = exports.getSourceRootPath = exports.getApplicationPath = exports.getProjectName = void 0;
13
+ const workspace_1 = require("@schematics/angular/utility/workspace");
14
+ function getProjectName(host, projectName) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const projects = [];
17
+ const workspace = yield workspace_1.getWorkspace(host);
18
+ /* tslint:disable-next-line:variable-name */
19
+ workspace.projects.forEach((_v, k) => {
20
+ projects.push(k);
21
+ });
22
+ return projectName && projects.includes(projectName) ? projectName : projects[0];
23
+ });
9
24
  }
10
25
  exports.getProjectName = getProjectName;
11
26
  function getApplicationPath(host, projectName) {
12
- const sourcePath = getSourceRootPath(host, projectName);
13
- return sourcePath ? `${sourcePath}/app/` : 'src/app/';
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const sourcePath = yield getSourceRootPath(host, projectName);
29
+ return sourcePath ? `${sourcePath}/app/` : 'src/app/';
30
+ });
14
31
  }
15
32
  exports.getApplicationPath = getApplicationPath;
16
33
  function getSourceRootPath(host, projectName) {
17
- const project = config_1.getWorkspace(host).projects[projectName];
18
- return project.sourceRoot || project.root;
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const workspace = yield workspace_1.getWorkspace(host);
36
+ const project = workspace.projects.get(projectName);
37
+ return project && (project.sourceRoot || project.root);
38
+ });
19
39
  }
20
40
  exports.getSourceRootPath = getSourceRootPath;
21
41
  function getRootPath(host, projectName) {
22
- const project = config_1.getWorkspace(host).projects[projectName];
23
- return project.root;
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const workspace = yield workspace_1.getWorkspace(host);
44
+ const project = workspace.projects.get(projectName);
45
+ return project && project.root;
46
+ });
24
47
  }
25
48
  exports.getRootPath = getRootPath;
26
49
  //# sourceMappingURL=project.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"project.js","sourceRoot":"","sources":["project.ts"],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angular-devkit/schematics';
2
+ import { getWorkspace } from '@schematics/angular/utility/workspace';
3
+
4
+ export async function getProjectName(host: Tree, projectName: string) {
5
+ const projects: string[] = [];
6
+ const workspace = await getWorkspace(host);
7
+ /* tslint:disable-next-line:variable-name */
8
+ workspace.projects.forEach((_v, k) => {
9
+ projects.push(k);
10
+ });
11
+
12
+ return projectName && projects.includes(projectName) ? projectName : projects[0];
13
+ }
14
+
15
+ export async function getApplicationPath(host: Tree, projectName: string) {
16
+ const sourcePath = await getSourceRootPath(host, projectName);
17
+ return sourcePath ? `${sourcePath}/app/` : 'src/app/';
18
+ }
19
+
20
+ export async function getSourceRootPath(host: Tree, projectName: string) {
21
+ const workspace = await getWorkspace(host);
22
+ const project = workspace.projects.get(projectName);
23
+ return project && (project.sourceRoot || project.root);
24
+ }
25
+
26
+ export async function getRootPath(host: Tree, projectName: string) {
27
+ const workspace = await getWorkspace(host);
28
+ const project = workspace.projects.get(projectName);
29
+ return project && project.root;
30
+ }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findRoutesInSource = exports.getRoute = exports.hasComponentInRoutes = void 0;
3
4
  const typescript_1 = require("typescript");
4
5
  const core_1 = require("@angular-devkit/core");
5
6
  function getRouteComponentName(pageName) {
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["routing.ts"],"names":[],"mappings":";;AAAA,2CAIoB;AAEpB,+CAI8B;AAE9B,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,OAAO,GAAG,cAAO,CAAC,QAAQ,CAAC,eAAQ,CAAC,gBAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC;AACvE,CAAC;AAED,SAAgB,oBAAoB,CAAC,MAAY,EAAE,IAAY;IAC7D,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IACpC,MAAM,aAAa,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAClD,OA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,QAAQ,CAAC,IAAY;IACnC,OAAO;aACI,cAAO,CAAC,SAAS,CAAC,IAAI,CAAC;iBACnB,qBAAqB,CAAC,IAAI,CAAC;;IAExC,CAAC;AACL,CAAC;AAND,4BAMC;AAED,SAAS,eAAe,CAAC,IAAU,EAAE,IAAY;IAC7C,OAAO,IAAI,CAAC,IAAI,KAAK,uBAAU,CAAC,iBAAiB;QAC/C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AACtC,CAAC;AAEH,SAAgB,kBAAkB,CAAC,MAAkB;IACnD,uCAAuC;IACvC,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;YAC/B,OAAO,IAAI,CAAC;SACb;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AARD,gDAQC"}
@@ -0,0 +1,44 @@
1
+ import {
2
+ Node,
3
+ SourceFile,
4
+ SyntaxKind
5
+ } from 'typescript';
6
+
7
+ import {
8
+ strings,
9
+ basename,
10
+ normalize
11
+ } from '@angular-devkit/core';
12
+
13
+ function getRouteComponentName(pageName: string) {
14
+ return `${strings.classify(basename(normalize(pageName)))}Component`;
15
+ }
16
+
17
+ export function hasComponentInRoutes(routes: Node, name: string) {
18
+ const routesText = routes.getText();
19
+ const componentName = getRouteComponentName(name);
20
+ return routesText.indexOf(componentName) !== -1;
21
+ }
22
+
23
+ export function getRoute(name: string) {
24
+ return ` {
25
+ path: '${strings.dasherize(name)}',
26
+ component: ${getRouteComponentName(name)},
27
+ canActivate: [ AuthGuardService ]
28
+ }`;
29
+ }
30
+
31
+ function isRouteVariable(node: Node, text: string) {
32
+ return node.kind === SyntaxKind.VariableStatement &&
33
+ text.search(/\:\s*Routes/) !== -1;
34
+ }
35
+
36
+ export function findRoutesInSource(source: SourceFile) {
37
+ // TODO: try to use ast-utils/findNodes
38
+ return source.forEachChild((node) => {
39
+ const text = node.getText();
40
+ if (isRouteVariable(node, text)) {
41
+ return node;
42
+ }
43
+ });
44
+ }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSourceFile = void 0;
3
4
  const typescript_1 = require("typescript");
4
5
  function getSourceFile(host, filePath) {
5
6
  const buffer = host.read(filePath);
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts"],"names":[],"mappings":";;AACA,2CAIoB;AAEpB,SAAgB,aAAa,CAAC,IAAU,EAAE,QAAgB;IACxD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEnC,IAAI,CAAC,MAAM,EAAE;QACX,OAAO;KACR;IACD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAC,QAAQ,EAAE,CAAC;IACvD,OAAO,6BAAgB,CAAC,QAAQ,EAAE,cAAc,EAAE,yBAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC/E,CAAC;AARD,sCAQC"}
1
+ {"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts"],"names":[],"mappings":";;;AACA,2CAIoB;AAEpB,SAAgB,aAAa,CAAC,IAAU,EAAE,QAAgB;IACxD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEnC,IAAI,CAAC,MAAM,EAAE;QACX,OAAO;KACR;IACD,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAE,CAAC,QAAQ,EAAE,CAAC;IACvD,OAAO,6BAAgB,CAAC,QAAQ,EAAE,cAAc,EAAE,yBAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC/E,CAAC;AARD,sCAQC"}
@@ -0,0 +1,16 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ import {
3
+ createSourceFile,
4
+ ScriptTarget,
5
+ SourceFile
6
+ } from 'typescript';
7
+
8
+ export function getSourceFile(host: Tree, filePath: string): SourceFile | undefined {
9
+ const buffer = host.read(filePath);
10
+
11
+ if (!buffer) {
12
+ return;
13
+ }
14
+ const serializedFile = host.read(filePath)!.toString();
15
+ return createSourceFile(filePath, serializedFile, ScriptTarget.Latest, true);
16
+ }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.humanize = void 0;
3
4
  const core_1 = require("@angular-devkit/core");
4
5
  function humanize(str) {
5
6
  return str.split('-').map((part) => core_1.strings.capitalize(part)).join(' ');
@@ -1 +1 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["string.ts"],"names":[],"mappings":";;AAAA,+CAA+C;AAE/C,SAAgB,QAAQ,CAAC,GAAW;IAClC,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,cAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClF,CAAC;AAFD,4BAEC"}
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["string.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAE/C,SAAgB,QAAQ,CAAC,GAAW;IAClC,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,cAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClF,CAAC;AAFD,4BAEC"}
@@ -0,0 +1,5 @@
1
+ import { strings } from '@angular-devkit/core';
2
+
3
+ export function humanize(str: string) {
4
+ return str.split('-').map((part: string) => strings.capitalize(part)).join(' ');
5
+ }
@@ -1,2 +1 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export declare function addStylesToApp(host: Tree, project: string, config: any, styles?: Array<any>): any;
1
+ export declare function addStylesToApp(project: string, config: any, styles?: Array<any>): any;
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const project_1 = require("./project");
3
+ exports.addStylesToApp = void 0;
4
4
  const array_1 = require("./array");
5
5
  function cleanStyles(projectStyles, defaultStyles) {
6
6
  return projectStyles.filter((style) => {
7
7
  return style !== defaultStyles[0] && style !== defaultStyles[1];
8
8
  });
9
9
  }
10
- function addStylesToApp(host, project, config, styles) {
11
- const projectName = project_1.getProjectName(host, project);
12
- const projectBuildOptopns = config['projects'][projectName]['architect']['build']['options'];
10
+ function addStylesToApp(project, config, styles) {
11
+ const projectBuildOptopns = config['projects'][project]['architect']['build']['options'];
13
12
  const defaultStyles = [
14
13
  'node_modules/devextreme/dist/css/dx.light.css',
15
14
  'node_modules/devextreme/dist/css/dx.common.css'
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["styles.ts"],"names":[],"mappings":";;AACA,uCAA2C;AAC3C,mCAA0C;AAE1C,SAAS,WAAW,CAAC,aAAyB,EAAE,aAAkB;IAChE,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QACpC,OAAO,KAAK,KAAK,aAAa,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,aAAa,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAgB,cAAc,CAAC,IAAU,EAAE,OAAe,EAAE,MAAW,EAAE,MAAmB;IAC1F,MAAM,WAAW,GAAG,wBAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAClD,MAAM,mBAAmB,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;IAC7F,MAAM,aAAa,GAAG;QACpB,+CAA+C;QAC/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,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,mBAAmB,CAAC,QAAQ,CAAC,GAAG,uBAAe,CAAC,aAAa,CAAC,CAAC;IAE/D,OAAO,MAAM,CAAC;AAChB,CAAC;AArBD,wCAqBC"}
@@ -0,0 +1,30 @@
1
+ import { makeArrayUnique } from './array';
2
+
3
+ function cleanStyles(projectStyles: Array<any>, defaultStyles: any) {
4
+ return projectStyles.filter((style) => {
5
+ return style !== defaultStyles[0] && style !== defaultStyles[1];
6
+ });
7
+ }
8
+
9
+ export function addStylesToApp(project: string, config: any, styles?: Array<any>) {
10
+ const projectBuildOptopns = config['projects'][project]['architect']['build']['options'];
11
+ const defaultStyles = [
12
+ 'node_modules/devextreme/dist/css/dx.light.css',
13
+ 'node_modules/devextreme/dist/css/dx.common.css'
14
+ ];
15
+ let projectStyles = projectBuildOptopns['styles'];
16
+
17
+ if (!styles) {
18
+ styles = defaultStyles;
19
+ } else {
20
+ projectStyles = cleanStyles(projectStyles, defaultStyles);
21
+ }
22
+
23
+ styles.forEach((style) => {
24
+ projectStyles.unshift(style);
25
+ });
26
+
27
+ projectBuildOptopns['styles'] = makeArrayUnique(projectStyles);
28
+
29
+ return config;
30
+ }