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.
- package/package.json +10 -8
- package/src/add-app-template/index.js +2 -1
- package/src/add-app-template/index.js.map +1 -1
- package/src/add-app-template/index.ts +30 -0
- package/src/add-app-template/index_spec.js +6 -5
- package/src/add-app-template/index_spec.js.map +1 -1
- package/src/add-app-template/index_spec.ts +73 -0
- package/src/add-app-template/schema.json +7 -3
- package/src/add-layout/files/devextreme.json +1 -1
- package/src/add-layout/files/src/app/__name__.component.html +3 -3
- package/src/add-layout/files/src/app/__name__.component.ts +1 -1
- package/src/add-layout/files/src/app/app-routing.module.ts +1 -1
- package/src/add-layout/files/src/app/layouts/side-nav-inner-toolbar/side-nav-inner-toolbar.component.ts +13 -11
- package/src/add-layout/files/src/app/layouts/side-nav-outer-toolbar/side-nav-outer-toolbar.component.ts +10 -9
- package/src/add-layout/files/src/app/layouts/single-card/single-card.component.ts +4 -4
- package/src/add-layout/files/src/app/not-authorized-container.ts +2 -0
- package/src/add-layout/files/src/app/shared/components/change-password-form/change-password-form.component.html +8 -6
- package/src/add-layout/files/src/app/shared/components/change-password-form/change-password-form.component.ts +6 -15
- package/src/add-layout/files/src/app/shared/components/create-account-form/create-account-form.component.html +9 -7
- package/src/add-layout/files/src/app/shared/components/create-account-form/create-account-form.component.ts +4 -13
- package/src/add-layout/files/src/app/shared/components/header/header.component.ts +11 -6
- package/src/add-layout/files/src/app/shared/components/login-form/login-form.component.html +8 -6
- package/src/add-layout/files/src/app/shared/components/login-form/login-form.component.ts +2 -12
- package/src/add-layout/files/src/app/shared/components/reset-password-form/reset-password-form.component.html +8 -6
- package/src/add-layout/files/src/app/shared/components/reset-password-form/reset-password-form.component.ts +2 -12
- package/src/add-layout/files/src/app/shared/components/side-navigation-menu/side-navigation-menu.component.ts +8 -7
- package/src/add-layout/files/src/app/shared/components/user-panel/user-panel.component.html +5 -2
- package/src/add-layout/files/src/app/shared/components/user-panel/user-panel.component.ts +3 -2
- package/src/add-layout/files/src/app/shared/services/auth.service.ts +11 -5
- package/src/add-layout/files/src/app/shared/services/screen.service.ts +2 -2
- package/src/add-layout/files/src/app/unauthenticated-content.ts +53 -0
- package/src/add-layout/files/src/dx-styles.scss +4 -0
- package/src/add-layout/index.js +45 -31
- package/src/add-layout/index.js.map +1 -1
- package/src/add-layout/index.ts +384 -0
- package/src/add-layout/index_spec.js +42 -28
- package/src/add-layout/index_spec.js.map +1 -1
- package/src/add-layout/index_spec.ts +340 -0
- package/src/add-layout/schema.json +6 -2
- package/src/add-sample-views/files/pages/home/home.component.html +5 -5
- package/src/add-sample-views/files/pages/profile/profile.component.ts +1 -1
- package/src/add-sample-views/files/pages/tasks/tasks.component.html +1 -0
- package/src/add-sample-views/index.js +13 -4
- package/src/add-sample-views/index.js.map +1 -1
- package/src/add-sample-views/index.ts +141 -0
- package/src/add-sample-views/index_spec.js +5 -4
- package/src/add-sample-views/index_spec.js.map +1 -1
- package/src/add-sample-views/index_spec.ts +74 -0
- package/src/add-sample-views/schema.json +1 -1
- package/src/add-view/index.d.ts +2 -2
- package/src/add-view/index.js +33 -22
- package/src/add-view/index.js.map +1 -1
- package/src/add-view/index.ts +166 -0
- package/src/add-view/index_spec.js +12 -12
- package/src/add-view/index_spec.js.map +1 -1
- package/src/add-view/index_spec.ts +155 -0
- package/src/add-view/schema.json +4 -4
- package/src/collection.json +2 -1
- package/src/install/index.js +16 -3
- package/src/install/index.js.map +1 -1
- package/src/install/index.ts +88 -0
- package/src/install/index_spec.js +10 -9
- package/src/install/index_spec.js.map +1 -1
- package/src/install/index_spec.ts +106 -0
- package/src/install/schema.json +2 -2
- package/src/utility/array.js +1 -0
- package/src/utility/array.js.map +1 -1
- package/src/utility/array.ts +3 -0
- package/src/utility/change.js +1 -0
- package/src/utility/change.js.map +1 -1
- package/src/utility/change.ts +66 -0
- package/src/utility/latest-versions.d.ts +1 -1
- package/src/utility/latest-versions.js +3 -2
- package/src/utility/latest-versions.js.map +1 -1
- package/src/utility/latest-versions.ts +6 -0
- package/src/utility/modify-json-file.d.ts +1 -0
- package/src/utility/modify-json-file.js +7 -3
- package/src/utility/modify-json-file.js.map +1 -1
- package/src/utility/modify-json-file.ts +16 -0
- package/src/utility/project.d.ts +4 -4
- package/src/utility/project.js +35 -12
- package/src/utility/project.js.map +1 -1
- package/src/utility/project.ts +30 -0
- package/src/utility/routing.js +1 -0
- package/src/utility/routing.js.map +1 -1
- package/src/utility/routing.ts +44 -0
- package/src/utility/source.js +1 -0
- package/src/utility/source.js.map +1 -1
- package/src/utility/source.ts +16 -0
- package/src/utility/string.js +1 -0
- package/src/utility/string.js.map +1 -1
- package/src/utility/string.ts +5 -0
- package/src/utility/styles.d.ts +1 -2
- package/src/utility/styles.js +3 -4
- package/src/utility/styles.js.map +1 -1
- package/src/utility/styles.ts +30 -0
package/src/add-view/schema.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
3
|
-
"id": "SchematicsDevextremeAddView",
|
3
|
+
"$id": "SchematicsDevextremeAddView",
|
4
4
|
"title": "Add a view to a DevExtreme Angular application",
|
5
5
|
"type": "object",
|
6
6
|
"properties": {
|
@@ -30,10 +30,10 @@
|
|
30
30
|
"type": "string",
|
31
31
|
"description": "The name of a project to modify"
|
32
32
|
},
|
33
|
-
"
|
33
|
+
"skipTests": {
|
34
34
|
"type": "boolean",
|
35
|
-
"description": "
|
36
|
-
"default":
|
35
|
+
"description": "When true, does not create \"spec.ts\" test files for the new component.",
|
36
|
+
"default": false
|
37
37
|
},
|
38
38
|
"inlineStyle": {
|
39
39
|
"description": "Specifies whether to define styles in the ts file",
|
package/src/collection.json
CHANGED
@@ -8,7 +8,8 @@
|
|
8
8
|
},
|
9
9
|
"add-layout": {
|
10
10
|
"description": "Add DevExtreme Layout to the Angular application.",
|
11
|
-
"factory": "./add-layout/index"
|
11
|
+
"factory": "./add-layout/index",
|
12
|
+
"schema": "./add-layout/schema.json"
|
12
13
|
},
|
13
14
|
"add-sample-views": {
|
14
15
|
"description": "Add Sample views to the Angular application.",
|
package/src/install/index.js
CHANGED
@@ -1,4 +1,13 @@
|
|
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
12
|
const schematics_1 = require("@angular-devkit/schematics");
|
4
13
|
const styles_1 = require("../utility/styles");
|
@@ -6,6 +15,7 @@ const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
6
15
|
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
7
16
|
const latest_versions_1 = require("../utility/latest-versions");
|
8
17
|
const modify_json_file_1 = require("../utility/modify-json-file");
|
18
|
+
const project_1 = require("../utility/project");
|
9
19
|
function default_1(options) {
|
10
20
|
return schematics_1.chain([
|
11
21
|
(host) => addDevExtremeDependency(host, { dxversion: options.dxversion }),
|
@@ -41,10 +51,13 @@ function addDevExtremeDependency(host, options) {
|
|
41
51
|
return host;
|
42
52
|
}
|
43
53
|
function addDevExtremeCSS(host, options) {
|
44
|
-
|
45
|
-
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
55
|
+
const projectName = yield project_1.getProjectName(host, options.project);
|
56
|
+
modify_json_file_1.modifyJSONFile(host, './angular.json', config => {
|
57
|
+
return styles_1.addStylesToApp(projectName, config);
|
58
|
+
});
|
59
|
+
return host;
|
46
60
|
});
|
47
|
-
return host;
|
48
61
|
}
|
49
62
|
function reqisterJSZip(host) {
|
50
63
|
modify_json_file_1.modifyJSONFile(host, './tsconfig.app.json', config => {
|
package/src/install/index.js.map
CHANGED
@@ -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":";;;;;;;;;;;AAAA,2DAKoC;AAEpC,8CAAmD;AAEnD,2EAGkD;AAElD,4DAE0C;AAE1C,gEAA4D;AAC5D,kEAA6D;AAC7D,gDAAoD;AAEpD,mBAAwB,OAAY;IAClC,OAAO,kBAAK,CAAC;QACX,CAAC,IAAU,EAAE,EAAE,CAAC,uBAAuB,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;QAC/E,CAAC,IAAU,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;QACpE,CAAC,IAAU,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC;QACnC,CAAC,CAAC,EAAE,OAAyB,EAAE,EAAE;YAC/B,OAAO,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAChD,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AATD,4BASC;AAED,SAAS,uBAAuB,CAAC,IAAU,EAAE,OAAY;IACvD,uCAAwB,CAAC,IAAI,EAAE;QAC7B,IAAI,EAAE,iCAAkB,CAAC,OAAO;QAChC,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,OAAO,CAAC,SAAS,IAAI,gCAAc,CAAC,YAAY,CAAC;KAC3D,CAAC,CAAC;IACH,uCAAwB,CAAC,IAAI,EAAE;QAC7B,IAAI,EAAE,iCAAkB,CAAC,OAAO;QAChC,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,OAAO,CAAC,SAAS,IAAI,gCAA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AAO,IAAI,CAAC;AACd,CAAC"}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import {
|
2
|
+
Rule,
|
3
|
+
Tree,
|
4
|
+
SchematicContext,
|
5
|
+
chain
|
6
|
+
} from '@angular-devkit/schematics';
|
7
|
+
|
8
|
+
import { addStylesToApp } from '../utility/styles';
|
9
|
+
|
10
|
+
import {
|
11
|
+
NodeDependencyType,
|
12
|
+
addPackageJsonDependency
|
13
|
+
} from '@schematics/angular/utility/dependencies';
|
14
|
+
|
15
|
+
import {
|
16
|
+
NodePackageInstallTask
|
17
|
+
} from '@angular-devkit/schematics/tasks';
|
18
|
+
|
19
|
+
import { latestVersions } from '../utility/latest-versions';
|
20
|
+
import { modifyJSONFile } from '../utility/modify-json-file';
|
21
|
+
import { getProjectName } from '../utility/project';
|
22
|
+
|
23
|
+
export default function(options: any): Rule {
|
24
|
+
return chain([
|
25
|
+
(host: Tree) => addDevExtremeDependency(host, { dxversion: options.dxversion }),
|
26
|
+
(host: Tree) => addDevExtremeCSS(host, { project: options.project }),
|
27
|
+
(host: Tree) => reqisterJSZip(host),
|
28
|
+
(_, context: SchematicContext) => {
|
29
|
+
context.addTask(new NodePackageInstallTask());
|
30
|
+
}
|
31
|
+
]);
|
32
|
+
}
|
33
|
+
|
34
|
+
function addDevExtremeDependency(host: Tree, options: any) {
|
35
|
+
addPackageJsonDependency(host, {
|
36
|
+
type: NodeDependencyType.Default,
|
37
|
+
name: 'devextreme',
|
38
|
+
version: options.dxversion || latestVersions['devextreme']
|
39
|
+
});
|
40
|
+
addPackageJsonDependency(host, {
|
41
|
+
type: NodeDependencyType.Default,
|
42
|
+
name: 'devextreme-angular',
|
43
|
+
version: options.dxversion || latestVersions['devextreme-angular']
|
44
|
+
});
|
45
|
+
addPackageJsonDependency(host, {
|
46
|
+
type: NodeDependencyType.Dev,
|
47
|
+
name: 'devextreme-cli',
|
48
|
+
version: latestVersions['devextreme-cli']
|
49
|
+
});
|
50
|
+
addPackageJsonDependency(host, {
|
51
|
+
type: NodeDependencyType.Dev,
|
52
|
+
name: 'devextreme-themebuilder',
|
53
|
+
version: options.dxversion || latestVersions['devextreme']
|
54
|
+
});
|
55
|
+
|
56
|
+
return host;
|
57
|
+
}
|
58
|
+
|
59
|
+
async function addDevExtremeCSS(host: Tree, options: any) {
|
60
|
+
const projectName = await getProjectName(host, options.project);
|
61
|
+
modifyJSONFile(host, './angular.json', config => {
|
62
|
+
|
63
|
+
return addStylesToApp(projectName, config);
|
64
|
+
});
|
65
|
+
|
66
|
+
return host;
|
67
|
+
}
|
68
|
+
|
69
|
+
function reqisterJSZip(host: Tree) {
|
70
|
+
modifyJSONFile(host, './tsconfig.app.json', config => {
|
71
|
+
const compilerOptions = config['compilerOptions'];
|
72
|
+
let paths = compilerOptions['paths'];
|
73
|
+
|
74
|
+
if (!paths) {
|
75
|
+
paths = {};
|
76
|
+
}
|
77
|
+
|
78
|
+
if (!paths['jszip']) {
|
79
|
+
paths['jszip'] = ['node_modules/jszip/dist/jszip.min.js'];
|
80
|
+
}
|
81
|
+
|
82
|
+
compilerOptions['paths'] = paths;
|
83
|
+
|
84
|
+
return config;
|
85
|
+
});
|
86
|
+
|
87
|
+
return host;
|
88
|
+
}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
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); }); }
|
3
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
4
5
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
6
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) :
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
9
|
});
|
9
10
|
};
|
@@ -27,16 +28,16 @@ describe('install', () => {
|
|
27
28
|
const workspaceOptions = {
|
28
29
|
name: 'workspace',
|
29
30
|
// TODO: use angular latest-versions module
|
30
|
-
version: '
|
31
|
+
version: '12.0.0'
|
31
32
|
};
|
32
33
|
const angularSchematicsCollection = require.resolve('../../node_modules/@schematics/angular/collection.json');
|
33
34
|
const schematicRunner = new testing_1.SchematicTestRunner('@schematics/angular', angularSchematicsCollection);
|
34
35
|
let appTree;
|
35
|
-
beforeEach(() => __awaiter(
|
36
|
+
beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
|
36
37
|
appTree = yield schematicRunner.runSchematicAsync('workspace', workspaceOptions).toPromise();
|
37
38
|
appTree = yield schematicRunner.runSchematicAsync('application', appOptions, appTree).toPromise();
|
38
39
|
}));
|
39
|
-
it('should add devextreme dependency (default)', () => __awaiter(
|
40
|
+
it('should add devextreme dependency (default)', () => __awaiter(void 0, void 0, void 0, function* () {
|
40
41
|
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
41
42
|
const tree = yield runner.runSchematicAsync('install', {}, appTree).toPromise();
|
42
43
|
const packageConfig = JSON.parse(tree.readContent('package.json'));
|
@@ -44,20 +45,20 @@ describe('install', () => {
|
|
44
45
|
expect(packageConfig.dependencies['devextreme-angular']).toBe(latest_versions_1.latestVersions['devextreme-angular']);
|
45
46
|
expect(packageConfig.devDependencies['devextreme-themebuilder']).toBe(latest_versions_1.latestVersions['devextreme']);
|
46
47
|
}));
|
47
|
-
it('should add devextreme dependency (custom)', () => __awaiter(
|
48
|
+
it('should add devextreme dependency (custom)', () => __awaiter(void 0, void 0, void 0, function* () {
|
48
49
|
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
49
50
|
const tree = yield runner.runSchematicAsync('install', { dxversion: '18.2.5' }, appTree).toPromise();
|
50
51
|
const packageConfig = JSON.parse(tree.readContent('package.json'));
|
51
52
|
expect(packageConfig.dependencies.devextreme).toBe('18.2.5');
|
52
53
|
expect(packageConfig.devDependencies['devextreme-themebuilder']).toBe('18.2.5');
|
53
54
|
}));
|
54
|
-
it('should add devextreme cli devDependency', () => __awaiter(
|
55
|
+
it('should add devextreme cli devDependency', () => __awaiter(void 0, void 0, void 0, function* () {
|
55
56
|
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
56
57
|
const tree = yield runner.runSchematicAsync('install', { dxversion: '18.2.5' }, appTree).toPromise();
|
57
58
|
const packageConfig = JSON.parse(tree.readContent('package.json'));
|
58
59
|
expect(packageConfig.devDependencies['devextreme-cli']).toBeDefined();
|
59
60
|
}));
|
60
|
-
it('should add devextreme styles', () => __awaiter(
|
61
|
+
it('should add devextreme styles', () => __awaiter(void 0, void 0, void 0, function* () {
|
61
62
|
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
62
63
|
const tree = yield runner.runSchematicAsync('install', {}, appTree).toPromise();
|
63
64
|
const angularConfig = JSON.parse(tree.readContent('angular.json'));
|
@@ -65,14 +66,14 @@ describe('install', () => {
|
|
65
66
|
expect(styles[0]).toBe('node_modules/devextreme/dist/css/dx.common.css');
|
66
67
|
expect(styles[1]).toBe('node_modules/devextreme/dist/css/dx.light.css');
|
67
68
|
}));
|
68
|
-
it('should register jszip', () => __awaiter(
|
69
|
+
it('should register jszip', () => __awaiter(void 0, void 0, void 0, function* () {
|
69
70
|
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
70
71
|
const tree = yield runner.runSchematicAsync('install', {}, appTree).toPromise();
|
71
72
|
const tsconfig = JSON.parse(tree.readContent('tsconfig.app.json'));
|
72
73
|
const jszip = tsconfig['compilerOptions']['paths']['jszip'];
|
73
74
|
expect(jszip[0]).toBe('node_modules/jszip/dist/jszip.min.js');
|
74
75
|
}));
|
75
|
-
it('should add devextreme styles to the specified project', () => __awaiter(
|
76
|
+
it('should add devextreme styles to the specified project', () => __awaiter(void 0, void 0, void 0, function* () {
|
76
77
|
const secondAppOptions = {
|
77
78
|
name: 'testApp2',
|
78
79
|
inlineStyle: false,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,gEAAuF;AAEvF,6BAA6B;AAC7B,gEAA4D;AAE5D,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAElE,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACvB,8CAA8C;IAC9C,MAAM,UAAU,GAAQ;QACtB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,KAAK;QAClB,cAAc,EAAE,KAAK;QACrB,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,KAAK;QAChB,eAAe,EAAE,KAAK;KACvB,CAAC;IAEF,MAAM,gBAAgB,GAAqB;QACzC,IAAI,EAAE,WAAW;QACjB,2CAA2C;QAC3C,OAAO,EAAE,QAAQ;KAClB,CAAC;IAEF,MAAM,2BAA2B,GAAG,OAAO,CAAC,OAAO,CAAC,wDAAwD,CAAC,CAAC;IAC9G,MAAM,eAAe,GAAG,IAAI,6BAAmB,CAAC,qBAAqB,EAAE,2BAA2B,CAAC,CAAC;IACpG,IAAI,OAAqB,CAAC;IAE1B,UAAU,CAAC,GAAS,EAAE;QACpB,OAAO,GAAG,MAAM,eAAe,CAAC,iBAAiB,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC,SAAS,EAAE,CAAC;QAC7F,OAAO,GAAG,MAAM,eAAe,CAAC,iBAAiB,CAAC,aAAa,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC;IACpG,CAAC,CAAA,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAS,EAAE;QAC1D,MAAM,MAAM,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAA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C,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;QAEhG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QACzE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;QAExE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzG,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
|
2
|
+
import { Schema as WorkspaceOptions } from '@schematics/angular/workspace/schema';
|
3
|
+
import * as path from 'path';
|
4
|
+
import { latestVersions } from '../utility/latest-versions';
|
5
|
+
|
6
|
+
const collectionPath = path.join(__dirname, '../collection.json');
|
7
|
+
|
8
|
+
describe('install', () => {
|
9
|
+
// TODO: Extract workspase preparing somewhere
|
10
|
+
const appOptions: any = {
|
11
|
+
name: 'testApp',
|
12
|
+
projectRoot: '',
|
13
|
+
inlineStyle: false,
|
14
|
+
inlineTemplate: false,
|
15
|
+
routing: true,
|
16
|
+
style: 'css',
|
17
|
+
skipTests: false,
|
18
|
+
skipPackageJson: false
|
19
|
+
};
|
20
|
+
|
21
|
+
const workspaceOptions: WorkspaceOptions = {
|
22
|
+
name: 'workspace',
|
23
|
+
// TODO: use angular latest-versions module
|
24
|
+
version: '12.0.0'
|
25
|
+
};
|
26
|
+
|
27
|
+
const angularSchematicsCollection = require.resolve('../../node_modules/@schematics/angular/collection.json');
|
28
|
+
const schematicRunner = new SchematicTestRunner('@schematics/angular', angularSchematicsCollection);
|
29
|
+
let appTree: UnitTestTree;
|
30
|
+
|
31
|
+
beforeEach(async () => {
|
32
|
+
appTree = await schematicRunner.runSchematicAsync('workspace', workspaceOptions).toPromise();
|
33
|
+
appTree = await schematicRunner.runSchematicAsync('application', appOptions, appTree).toPromise();
|
34
|
+
});
|
35
|
+
|
36
|
+
it('should add devextreme dependency (default)', async () => {
|
37
|
+
const runner = new SchematicTestRunner('schematics', collectionPath);
|
38
|
+
const tree = await runner.runSchematicAsync('install', {}, appTree).toPromise();
|
39
|
+
const packageConfig = JSON.parse(tree.readContent('package.json'));
|
40
|
+
|
41
|
+
expect(packageConfig.dependencies['devextreme']).toBe(latestVersions['devextreme']);
|
42
|
+
expect(packageConfig.dependencies['devextreme-angular']).toBe(latestVersions['devextreme-angular']);
|
43
|
+
expect(packageConfig.devDependencies['devextreme-themebuilder']).toBe(latestVersions['devextreme']);
|
44
|
+
});
|
45
|
+
|
46
|
+
it('should add devextreme dependency (custom)', async () => {
|
47
|
+
const runner = new SchematicTestRunner('schematics', collectionPath);
|
48
|
+
const tree = await runner.runSchematicAsync('install', { dxversion: '18.2.5' }, appTree).toPromise();
|
49
|
+
const packageConfig = JSON.parse(tree.readContent('package.json'));
|
50
|
+
|
51
|
+
expect(packageConfig.dependencies.devextreme).toBe('18.2.5');
|
52
|
+
expect(packageConfig.devDependencies['devextreme-themebuilder']).toBe('18.2.5');
|
53
|
+
});
|
54
|
+
|
55
|
+
it('should add devextreme cli devDependency', async () => {
|
56
|
+
const runner = new SchematicTestRunner('schematics', collectionPath);
|
57
|
+
const tree = await runner.runSchematicAsync('install', { dxversion: '18.2.5' }, appTree).toPromise();
|
58
|
+
const packageConfig = JSON.parse(tree.readContent('package.json'));
|
59
|
+
|
60
|
+
expect(packageConfig.devDependencies['devextreme-cli']).toBeDefined();
|
61
|
+
});
|
62
|
+
|
63
|
+
it('should add devextreme styles', async () => {
|
64
|
+
const runner = new SchematicTestRunner('schematics', collectionPath);
|
65
|
+
const tree = await runner.runSchematicAsync('install', {}, appTree).toPromise();
|
66
|
+
const angularConfig = JSON.parse(tree.readContent('angular.json'));
|
67
|
+
const styles = angularConfig['projects']['testApp']['architect']['build']['options']['styles'];
|
68
|
+
|
69
|
+
expect(styles[0]).toBe('node_modules/devextreme/dist/css/dx.common.css');
|
70
|
+
expect(styles[1]).toBe('node_modules/devextreme/dist/css/dx.light.css');
|
71
|
+
});
|
72
|
+
|
73
|
+
it('should register jszip', async () => {
|
74
|
+
const runner = new SchematicTestRunner('schematics', collectionPath);
|
75
|
+
const tree = await runner.runSchematicAsync('install', {}, appTree).toPromise();
|
76
|
+
const tsconfig = JSON.parse(tree.readContent('tsconfig.app.json'));
|
77
|
+
const jszip = tsconfig['compilerOptions']['paths']['jszip'];
|
78
|
+
|
79
|
+
expect(jszip[0]).toBe('node_modules/jszip/dist/jszip.min.js');
|
80
|
+
});
|
81
|
+
|
82
|
+
it('should add devextreme styles to the specified project', async () => {
|
83
|
+
const secondAppOptions: any = {
|
84
|
+
name: 'testApp2',
|
85
|
+
inlineStyle: false,
|
86
|
+
inlineTemplate: false,
|
87
|
+
projectRoot: 'src2',
|
88
|
+
routing: true,
|
89
|
+
style: 'css',
|
90
|
+
skipTests: false,
|
91
|
+
skipPackageJson: false
|
92
|
+
};
|
93
|
+
|
94
|
+
appTree = await schematicRunner.runSchematicAsync('application', secondAppOptions, appTree).toPromise();
|
95
|
+
|
96
|
+
const runner = new SchematicTestRunner('schematics', collectionPath);
|
97
|
+
const tree = await runner.runSchematicAsync('install', { project: 'testApp2' }, appTree).toPromise();
|
98
|
+
const angularConfig = JSON.parse(tree.readContent('angular.json'));
|
99
|
+
const styles = angularConfig['projects']['testApp2']['architect']['build']['options']['styles'];
|
100
|
+
|
101
|
+
expect(styles[0]).toBe('node_modules/devextreme/dist/css/dx.common.css');
|
102
|
+
expect(styles[1]).toBe('node_modules/devextreme/dist/css/dx.light.css');
|
103
|
+
|
104
|
+
expect(angularConfig['projects']['testApp']['architect']['build']['options']['styles'].length).toBe(1);
|
105
|
+
});
|
106
|
+
});
|
package/src/install/schema.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
3
|
-
"id": "SchematicsDevextremeInstall",
|
3
|
+
"$id": "SchematicsDevextremeInstall",
|
4
4
|
"title": "Add DevExtreme to an Angular application",
|
5
5
|
"type": "object",
|
6
6
|
"properties": {
|
7
7
|
"dxversion": {
|
8
8
|
"type": "string",
|
9
9
|
"description": "The DevExtreme version",
|
10
|
-
"default": "
|
10
|
+
"default": "^21.2.4"
|
11
11
|
},
|
12
12
|
"project": {
|
13
13
|
"type": "string",
|
package/src/utility/array.js
CHANGED
package/src/utility/array.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["array.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["array.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,GAAe;IAC7C,OAAQ,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAC5B,CAAC;AAFD,0CAEC"}
|
package/src/utility/change.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"change.js","sourceRoot":"","sources":["change.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"change.js","sourceRoot":"","sources":["change.ts"],"names":[],"mappings":";;;AAOA,MAAM,OAAO,GAAG;CACf,CAAC;AAEF,SAAgB,YAAY,CAAC,IAAU,EAAE,OAAiB,EAAE,QAAgB;IAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE5C,OAAO,CAAC,OAAO,CAAC,CAAC,MAAoB,EAAE,EAAE;QACvC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,YAAY,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,KAAK,KAAK,EAAE;YAC9B,YAAY,GAAG,YAAY,GAAG,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC/D,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;SACnB;aAAM;YACL,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC;SACnB;KACF;IAED,YAAY,CAAC,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IAEhC,OAAO,IAAI,CAAC;AACd,CAAC;AAzCD,8CAyCC"}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
2
|
+
import { InsertChange, Change } from '@schematics/angular/utility/change';
|
3
|
+
|
4
|
+
import {
|
5
|
+
Node
|
6
|
+
} from 'typescript';
|
7
|
+
|
8
|
+
const newLine = `
|
9
|
+
`;
|
10
|
+
|
11
|
+
export function applyChanges(host: Tree, changes: Change[], filePath: string) {
|
12
|
+
const recorder = host.beginUpdate(filePath);
|
13
|
+
|
14
|
+
changes.forEach((change: InsertChange) => {
|
15
|
+
recorder.insertLeft(change.pos, change.toAdd);
|
16
|
+
});
|
17
|
+
|
18
|
+
host.commitUpdate(recorder);
|
19
|
+
|
20
|
+
return host;
|
21
|
+
}
|
22
|
+
|
23
|
+
// TODO: implement options.index
|
24
|
+
// TODO: implement spaces shift calculation
|
25
|
+
export function insertItemToArray(
|
26
|
+
host: Tree,
|
27
|
+
filePath: string,
|
28
|
+
node: Node,
|
29
|
+
item: string,
|
30
|
+
options: { location: 'start' | 'end' } = { location: 'start' }
|
31
|
+
) {
|
32
|
+
const isItemValid = /^\s*\{[\s\S]*\}\s*$/m.test(item);
|
33
|
+
if (!isItemValid) {
|
34
|
+
return host;
|
35
|
+
}
|
36
|
+
|
37
|
+
const nodeContent = node.getText();
|
38
|
+
const nodePosition = node.getStart();
|
39
|
+
const leftBracketPosition = nodePosition + nodeContent.indexOf('[');
|
40
|
+
const rightBracketPosition = nodePosition + nodeContent.lastIndexOf(']');
|
41
|
+
let itemPosition = leftBracketPosition + 1;
|
42
|
+
let fileRecorder = host.beginUpdate(filePath);
|
43
|
+
|
44
|
+
item = newLine + item;
|
45
|
+
|
46
|
+
const isNodeEmpty = !/\[[\s\S]*\S+[\s\S]*\]/m.test(nodeContent);
|
47
|
+
if (isNodeEmpty) {
|
48
|
+
const formattedArray = `[${newLine}]`;
|
49
|
+
fileRecorder.remove(leftBracketPosition, rightBracketPosition - leftBracketPosition + 1);
|
50
|
+
fileRecorder.insertLeft(leftBracketPosition, formattedArray);
|
51
|
+
host.commitUpdate(fileRecorder);
|
52
|
+
fileRecorder = host.beginUpdate(filePath);
|
53
|
+
} else {
|
54
|
+
if (options.location === 'end') {
|
55
|
+
itemPosition = nodePosition + nodeContent.lastIndexOf('}') + 1;
|
56
|
+
item = ',' + item;
|
57
|
+
} else {
|
58
|
+
item = item + ',';
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
fileRecorder.insertLeft(itemPosition, item);
|
63
|
+
host.commitUpdate(fileRecorder);
|
64
|
+
|
65
|
+
return host;
|
66
|
+
}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.latestVersions = void 0;
|
3
4
|
// TODO: implement
|
4
5
|
exports.latestVersions = {
|
5
|
-
'devextreme': '
|
6
|
-
'devextreme-angular': '
|
6
|
+
'devextreme': '^21.2.4',
|
7
|
+
'devextreme-angular': '^21.2.4',
|
7
8
|
'devextreme-cli': 'latest'
|
8
9
|
};
|
9
10
|
//# sourceMappingURL=latest-versions.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"latest-versions.js","sourceRoot":"","sources":["latest-versions.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"latest-versions.js","sourceRoot":"","sources":["latest-versions.ts"],"names":[],"mappings":";;;AAAA,kBAAkB;AACL,QAAA,cAAc,GAAG;IAC5B,YAAY,EAAE,SAAS;IACvB,oBAAoB,EAAE,SAAS;IAC/B,gBAAgB,EAAE,QAAQ;CAC3B,CAAC"}
|
@@ -1,9 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.modifyJSONFile = exports.parseJson = void 0;
|
4
|
+
const parseJson = (str) => {
|
5
|
+
return JSON.parse(str.replace(/\/\*[\S\s]+?\*\/\r?\n/g, ''));
|
6
|
+
};
|
7
|
+
exports.parseJson = parseJson;
|
3
8
|
function modifyJSONFile(host, path, callback) {
|
4
|
-
|
5
|
-
|
6
|
-
let obj = JSON.parse(serializedConfig);
|
9
|
+
const serializedConfig = host.read(path).toString();
|
10
|
+
let obj = exports.parseJson(serializedConfig);
|
7
11
|
obj = callback(obj);
|
8
12
|
host.overwrite(path, `${JSON.stringify(obj, null, 2)}\n`);
|
9
13
|
return host;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"modify-json-file.js","sourceRoot":"","sources":["modify-json-file.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"modify-json-file.js","sourceRoot":"","sources":["modify-json-file.ts"],"names":[],"mappings":";;;AAEO,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,EAAE;IACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/D,CAAC,CAAC;AAFW,QAAA,SAAS,aAEpB;AAEF,SAAgB,cAAc,CAAC,IAAU,EAAE,IAAY,EAAE,QAA2B;IAClF,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAE,CAAC,QAAQ,EAAE,CAAC;IACrD,IAAI,GAAG,GAAG,iBAAS,CAAC,gBAAgB,CAAC,CAAC;IAEtC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAEpB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAE1D,OAAO,IAAI,CAAC;AACd,CAAC;AATD,wCASC"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { Tree } from '@angular-devkit/schematics';
|
2
|
+
|
3
|
+
export const parseJson = (str: string) => {
|
4
|
+
return JSON.parse(str.replace(/\/\*[\S\s]+?\*\/\r?\n/g, ''));
|
5
|
+
};
|
6
|
+
|
7
|
+
export function modifyJSONFile(host: Tree, path: string, callback: (obj: any) => any) {
|
8
|
+
const serializedConfig = host.read(path)!.toString();
|
9
|
+
let obj = parseJson(serializedConfig);
|
10
|
+
|
11
|
+
obj = callback(obj);
|
12
|
+
|
13
|
+
host.overwrite(path, `${JSON.stringify(obj, null, 2)}\n`);
|
14
|
+
|
15
|
+
return host;
|
16
|
+
}
|
package/src/utility/project.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Tree } from '@angular-devkit/schematics';
|
2
|
-
export declare function getProjectName(host: Tree,
|
3
|
-
export declare function getApplicationPath(host: Tree, projectName: string): string
|
4
|
-
export declare function getSourceRootPath(host: Tree, projectName: string): string
|
5
|
-
export declare function getRootPath(host: Tree, projectName: string): string
|
2
|
+
export declare function getProjectName(host: Tree, projectName: string): Promise<string>;
|
3
|
+
export declare function getApplicationPath(host: Tree, projectName: string): Promise<string>;
|
4
|
+
export declare function getSourceRootPath(host: Tree, projectName: string): Promise<string | undefined>;
|
5
|
+
export declare function getRootPath(host: Tree, projectName: string): Promise<string | undefined>;
|