@fundamental-ngx/core 0.38.0-rc.1 → 0.38.0-rc.2
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/fundamental-ngx-core-v0.38.0-rc.2.tgz +0 -0
- package/package.json +2 -2
- package/schematics/add-animations/index.d.ts +3 -0
- package/schematics/add-animations/index.js +49 -0
- package/schematics/add-animations/index.js.map +1 -0
- package/schematics/add-animations/index.ts +60 -0
- package/schematics/add-animations/schema.json +21 -0
- package/schematics/add-dependencies/index.d.ts +3 -0
- package/schematics/add-dependencies/index.js +63 -0
- package/schematics/add-dependencies/index.js.map +1 -0
- package/schematics/add-dependencies/index.ts +78 -0
- package/schematics/add-dependencies/schema.json +15 -0
- package/schematics/add-styles/index.d.ts +3 -0
- package/schematics/add-styles/index.js +91 -0
- package/schematics/add-styles/index.js.map +1 -0
- package/schematics/add-styles/index.ts +134 -0
- package/schematics/add-styles/schema.json +15 -0
- package/schematics/add-theming/index.d.ts +2 -0
- package/schematics/add-theming/index.js +137 -0
- package/schematics/add-theming/index.js.map +1 -0
- package/schematics/add-theming/index.ts +201 -0
- package/schematics/add-theming/schema.json +15 -0
- package/schematics/collection.json +30 -0
- package/schematics/{ng-add → models}/schema.d.ts +0 -0
- package/schematics/{ng-add → models}/schema.js +0 -0
- package/schematics/models/schema.js.map +1 -0
- package/schematics/{ng-add → models}/schema.ts +0 -0
- package/schematics/ng-add/index.d.ts +3 -1
- package/schematics/ng-add/index.js +13 -296
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/index.ts +14 -446
- package/schematics/utils/package-utils.d.ts +2 -1
- package/schematics/utils/package-utils.js +9 -1
- package/schematics/utils/package-utils.js.map +1 -1
- package/schematics/utils/package-utils.ts +10 -1
- package/fundamental-ngx-core-v0.38.0-rc.1.tgz +0 -0
- package/schematics/ng-add/schema.js.map +0 -1
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fundamental-ngx/core",
|
|
3
|
-
"version": "0.38.0-rc.
|
|
3
|
+
"version": "0.38.0-rc.2",
|
|
4
4
|
"schematics": "./schematics/collection.json",
|
|
5
5
|
"ng-update": {
|
|
6
6
|
"migrations": "./schematics/migrations.json"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"focus-trap": "6.7.3",
|
|
32
|
-
"@fundamental-ngx/i18n": "0.38.0-rc.
|
|
32
|
+
"@fundamental-ngx/i18n": "0.38.0-rc.2",
|
|
33
33
|
"fast-deep-equal": "3.1.3",
|
|
34
34
|
"lodash-es": "4.17.21",
|
|
35
35
|
"tslib": "^2.0.0",
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.addAnimations = void 0;
|
|
13
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
|
+
const schematics_2 = require("@angular/cdk/schematics");
|
|
15
|
+
const ng_module_utils_1 = require("../utils/ng-module-utils");
|
|
16
|
+
function addAnimations(options) {
|
|
17
|
+
return (0, schematics_1.chain)([addAnimationsModule(options)]);
|
|
18
|
+
}
|
|
19
|
+
exports.addAnimations = addAnimations;
|
|
20
|
+
function addAnimationsModule(options) {
|
|
21
|
+
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const browserAnimationsModuleName = 'BrowserAnimationsModule';
|
|
23
|
+
const noopAnimationsModuleName = 'NoopAnimationsModule';
|
|
24
|
+
const modulePath = yield (0, schematics_2.findModuleFromOptions)(tree, options);
|
|
25
|
+
if (!modulePath) {
|
|
26
|
+
context.logger.warn(`⚠️ Could not set up animations because root module not found. Please manually set up animations.`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (options.animations) {
|
|
30
|
+
if ((0, ng_module_utils_1.hasModuleImport)(tree, modulePath, noopAnimationsModuleName)) {
|
|
31
|
+
context.logger.warn(`⚠️ Could not set up "${browserAnimationsModuleName} because "${noopAnimationsModuleName}" is already imported. Please manually set up browser animations.`);
|
|
32
|
+
return tree;
|
|
33
|
+
}
|
|
34
|
+
if ((0, ng_module_utils_1.hasModuleImport)(tree, modulePath, browserAnimationsModuleName)) {
|
|
35
|
+
context.logger.info(`✅️ Import of ${browserAnimationsModuleName} already present in app module. Skipping.`);
|
|
36
|
+
return tree;
|
|
37
|
+
}
|
|
38
|
+
(0, schematics_2.addModuleImportToModule)(tree, modulePath, browserAnimationsModuleName, '@angular/platform-browser/animations');
|
|
39
|
+
context.logger.info(`✅️ Added ${browserAnimationsModuleName} to app module.`);
|
|
40
|
+
return tree;
|
|
41
|
+
}
|
|
42
|
+
if (!(0, ng_module_utils_1.hasModuleImport)(tree, modulePath, browserAnimationsModuleName)) {
|
|
43
|
+
(0, schematics_2.addModuleImportToModule)(tree, modulePath, noopAnimationsModuleName, '@angular/platform-browser/animations');
|
|
44
|
+
context.logger.info(`✅️ Added ${noopAnimationsModuleName} to app module.`);
|
|
45
|
+
}
|
|
46
|
+
return tree;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["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,EAAC,IAAI,EAAE,UAAU,EAAE,2BAA2B,CAAC,EAAE;YACjE,IAAA,oCAAuB,EAAC,IAAI,EAAE,UAAU,EAAE,wBAAwB,EAAE,sCAAsC,CAAC,CAAC;YAE5G,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,wBAAwB,iBAAiB,CAAC,CAAC;SAC9E;QAED,OAAO,IAAI,CAAC;IAChB,CAAC,CAAA,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Rule, Tree, SchematicContext, chain } from '@angular-devkit/schematics';
|
|
2
|
+
import { findModuleFromOptions, addModuleImportToModule } from '@angular/cdk/schematics';
|
|
3
|
+
import { Schema } from '../models/schema';
|
|
4
|
+
import { hasModuleImport } from '../utils/ng-module-utils';
|
|
5
|
+
|
|
6
|
+
export function addAnimations(options: Schema): Rule {
|
|
7
|
+
return chain([addAnimationsModule(options)]);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function addAnimationsModule(options: Schema): any {
|
|
11
|
+
return async (tree: Tree, context: SchematicContext) => {
|
|
12
|
+
const browserAnimationsModuleName = 'BrowserAnimationsModule';
|
|
13
|
+
const noopAnimationsModuleName = 'NoopAnimationsModule';
|
|
14
|
+
const modulePath = await findModuleFromOptions(tree, options as any);
|
|
15
|
+
|
|
16
|
+
if (!modulePath) {
|
|
17
|
+
context.logger.warn(
|
|
18
|
+
`⚠️ Could not set up animations because root module not found. Please manually set up animations.`
|
|
19
|
+
);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (options.animations) {
|
|
24
|
+
if (hasModuleImport(tree, modulePath, noopAnimationsModuleName)) {
|
|
25
|
+
context.logger.warn(
|
|
26
|
+
`⚠️ Could not set up "${browserAnimationsModuleName} because "${noopAnimationsModuleName}" is already imported. Please manually set up browser animations.`
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return tree;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (hasModuleImport(tree, modulePath, browserAnimationsModuleName)) {
|
|
33
|
+
context.logger.info(
|
|
34
|
+
`✅️ Import of ${browserAnimationsModuleName} already present in app module. Skipping.`
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return tree;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
addModuleImportToModule(
|
|
41
|
+
tree,
|
|
42
|
+
modulePath,
|
|
43
|
+
browserAnimationsModuleName,
|
|
44
|
+
'@angular/platform-browser/animations'
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
context.logger.info(`✅️ Added ${browserAnimationsModuleName} to app module.`);
|
|
48
|
+
|
|
49
|
+
return tree;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!hasModuleImport(tree, modulePath, browserAnimationsModuleName)) {
|
|
53
|
+
addModuleImportToModule(tree, modulePath, noopAnimationsModuleName, '@angular/platform-browser/animations');
|
|
54
|
+
|
|
55
|
+
context.logger.info(`✅️ Added ${noopAnimationsModuleName} to app module.`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return tree;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "fundamental-ngx-add-animations",
|
|
4
|
+
"title": "Fundamental Library for Angular add-animations schematic",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the project.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "projectName"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"animations": {
|
|
15
|
+
"type": "boolean",
|
|
16
|
+
"default": true,
|
|
17
|
+
"description": "Whether Angular browser animations should be set up.",
|
|
18
|
+
"x-prompt": "Set up browser animations for Fundamental Library for Angular?"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDependencies = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
|
6
|
+
const package_utils_1 = require("../utils/package-utils");
|
|
7
|
+
function addDependencies(options) {
|
|
8
|
+
return (0, schematics_1.chain)([addExternalLibraries(options), (0, package_utils_1.installDependencies)()]);
|
|
9
|
+
}
|
|
10
|
+
exports.addDependencies = addDependencies;
|
|
11
|
+
function addExternalLibraries(options) {
|
|
12
|
+
return (tree, context) => {
|
|
13
|
+
const ngCoreVersionTag = (0, package_utils_1.getPackageVersionFromPackageJson)(tree, '@angular/core');
|
|
14
|
+
const dependencies = [];
|
|
15
|
+
if (!(0, package_utils_1.hasPackage)(tree, '@angular/forms')) {
|
|
16
|
+
dependencies.push({
|
|
17
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
18
|
+
version: `${ngCoreVersionTag}`,
|
|
19
|
+
name: '@angular/forms'
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (options.animations && !(0, package_utils_1.hasPackage)(tree, '@angular/animations')) {
|
|
23
|
+
dependencies.push({
|
|
24
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
25
|
+
version: `${ngCoreVersionTag}`,
|
|
26
|
+
name: '@angular/animations'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (!(0, package_utils_1.hasPackage)(tree, '@angular/cdk')) {
|
|
30
|
+
dependencies.push({
|
|
31
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
32
|
+
version: `${ngCoreVersionTag}`,
|
|
33
|
+
name: '@angular/cdk'
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (!(0, package_utils_1.hasPackage)(tree, 'fundamental-styles') ||
|
|
37
|
+
(0, package_utils_1.checkPackageVersion)(tree, 'fundamental-styles', '0.26.0-rc.27', '<')) {
|
|
38
|
+
dependencies.push({
|
|
39
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
40
|
+
// Will be replaced with the real version during sync-version script run
|
|
41
|
+
version: `0.26.0-rc.27`,
|
|
42
|
+
name: 'fundamental-styles',
|
|
43
|
+
overwrite: true
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (!(0, package_utils_1.hasPackage)(tree, '@sap-theming/theming-base-content') ||
|
|
47
|
+
(0, package_utils_1.checkPackageVersion)(tree, '@sap-theming/theming-base-content', '11.1.47', '<')) {
|
|
48
|
+
dependencies.push({
|
|
49
|
+
type: dependencies_1.NodeDependencyType.Default,
|
|
50
|
+
// Will be replaced with the real version during sync-version script run
|
|
51
|
+
version: `11.1.47`,
|
|
52
|
+
name: '@sap-theming/theming-base-content',
|
|
53
|
+
overwrite: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
dependencies.forEach((dependency) => {
|
|
57
|
+
(0, dependencies_1.addPackageJsonDependency)(tree, dependency);
|
|
58
|
+
context.logger.info(`✅️ Added ${dependency.name} to ${dependency.type}.`);
|
|
59
|
+
});
|
|
60
|
+
return tree;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/core/schematics/add-dependencies/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiF;AACjF,2EAAwH;AAExH,0DAKgC;AAEhC,SAAgB,eAAe,CAAC,OAAe;IAC3C,OAAO,IAAA,kBAAK,EAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,IAAA,mCAAmB,GAAE,CAAC,CAAC,CAAC;AACzE,CAAC;AAFD,0CAEC;AAED,SAAS,oBAAoB,CAAC,OAAe;IACzC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC7C,MAAM,gBAAgB,GAAG,IAAA,gD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AAE,yBAAyB,EAAE,GAAG,CAAC,EAChG;YACE,YAAY,CAAC,IAAI,CAAC;gBACd,IAAI,EAAE,iCAAkB,CAAC,OAAO;gBAChC,wEAAwE;gBACxE,OAAO,EAAE,yBAAyB;gBAClC,IAAI,EAAE,mCAAmC;gBACzC,SAAS,EAAE,IAAI;aAClB,CAAC,CAAC;SACN;QAED,YAAY,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YAChC,IAAA,uCAAwB,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAE3C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,UAAU,CAAC,IAAI,OAAO,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Rule, Tree, SchematicContext, chain } from '@angular-devkit/schematics';
|
|
2
|
+
import { NodeDependency, NodeDependencyType, addPackageJsonDependency } from '@schematics/angular/utility/dependencies';
|
|
3
|
+
import { Schema } from '../models/schema';
|
|
4
|
+
import {
|
|
5
|
+
getPackageVersionFromPackageJson,
|
|
6
|
+
hasPackage,
|
|
7
|
+
checkPackageVersion,
|
|
8
|
+
installDependencies
|
|
9
|
+
} from '../utils/package-utils';
|
|
10
|
+
|
|
11
|
+
export function addDependencies(options: Schema): Rule {
|
|
12
|
+
return chain([addExternalLibraries(options), installDependencies()]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function addExternalLibraries(options: Schema): Rule {
|
|
16
|
+
return (tree: Tree, context: SchematicContext) => {
|
|
17
|
+
const ngCoreVersionTag = getPackageVersionFromPackageJson(tree, '@angular/core');
|
|
18
|
+
const dependencies: NodeDependency[] = [];
|
|
19
|
+
|
|
20
|
+
if (!hasPackage(tree, '@angular/forms')) {
|
|
21
|
+
dependencies.push({
|
|
22
|
+
type: NodeDependencyType.Default,
|
|
23
|
+
version: `${ngCoreVersionTag}`,
|
|
24
|
+
name: '@angular/forms'
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (options.animations && !hasPackage(tree, '@angular/animations')) {
|
|
29
|
+
dependencies.push({
|
|
30
|
+
type: NodeDependencyType.Default,
|
|
31
|
+
version: `${ngCoreVersionTag}`,
|
|
32
|
+
name: '@angular/animations'
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!hasPackage(tree, '@angular/cdk')) {
|
|
37
|
+
dependencies.push({
|
|
38
|
+
type: NodeDependencyType.Default,
|
|
39
|
+
version: `${ngCoreVersionTag}`,
|
|
40
|
+
name: '@angular/cdk'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
!hasPackage(tree, 'fundamental-styles') ||
|
|
46
|
+
checkPackageVersion(tree, 'fundamental-styles', 'FDSTYLES_VER_PLACEHOLDER', '<')
|
|
47
|
+
) {
|
|
48
|
+
dependencies.push({
|
|
49
|
+
type: NodeDependencyType.Default,
|
|
50
|
+
// Will be replaced with the real version during sync-version script run
|
|
51
|
+
version: `FDSTYLES_VER_PLACEHOLDER`,
|
|
52
|
+
name: 'fundamental-styles',
|
|
53
|
+
overwrite: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (
|
|
58
|
+
!hasPackage(tree, '@sap-theming/theming-base-content') ||
|
|
59
|
+
checkPackageVersion(tree, '@sap-theming/theming-base-content', 'THEMING_VER_PLACEHOLDER', '<')
|
|
60
|
+
) {
|
|
61
|
+
dependencies.push({
|
|
62
|
+
type: NodeDependencyType.Default,
|
|
63
|
+
// Will be replaced with the real version during sync-version script run
|
|
64
|
+
version: `THEMING_VER_PLACEHOLDER`,
|
|
65
|
+
name: '@sap-theming/theming-base-content',
|
|
66
|
+
overwrite: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
dependencies.forEach((dependency) => {
|
|
71
|
+
addPackageJsonDependency(tree, dependency);
|
|
72
|
+
|
|
73
|
+
context.logger.info(`✅️ Added ${dependency.name} to ${dependency.type}.`);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return tree;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "fundamental-ngx-add-dependencies",
|
|
4
|
+
"title": "Fundamental Library for Angular add-dependencies schematic",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the project.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "projectName"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addStyles = void 0;
|
|
4
|
+
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const angularConfigPath = '/angular.json';
|
|
6
|
+
function addStyles(options) {
|
|
7
|
+
return (0, schematics_1.chain)([addStylesToConfig(options), addAssetsToConfig(options)]);
|
|
8
|
+
}
|
|
9
|
+
exports.addStyles = addStyles;
|
|
10
|
+
function addStylesToConfig(options) {
|
|
11
|
+
return (tree, context) => {
|
|
12
|
+
const workspaceJson = _getWorkspaceJson(tree);
|
|
13
|
+
try {
|
|
14
|
+
const additionalStyles = ['./node_modules/@fundamental-ngx/core/styles/fundamental-ngx-core.css'];
|
|
15
|
+
if (options.fonts) {
|
|
16
|
+
additionalStyles.push('./node_modules/fundamental-styles/dist/fonts/sap_fonts.css');
|
|
17
|
+
}
|
|
18
|
+
let stylesArray = workspaceJson.projects[options.project].architect.build.options['styles'];
|
|
19
|
+
let stylesUpdated = false;
|
|
20
|
+
additionalStyles.forEach((additionalStyle) => {
|
|
21
|
+
if (!stylesArray.find((jsonStyle) => typeof jsonStyle === 'string' && jsonStyle === `${additionalStyle}`)) {
|
|
22
|
+
stylesUpdated = true;
|
|
23
|
+
stylesArray.push(additionalStyle);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
if (!stylesUpdated) {
|
|
27
|
+
context.logger.info(`✅️ Found duplicate styles in angular.json. Skipping.`);
|
|
28
|
+
if (options.fonts) {
|
|
29
|
+
context.logger.info(`✅️ Found duplicate font styles to angular.json.`);
|
|
30
|
+
}
|
|
31
|
+
return tree;
|
|
32
|
+
}
|
|
33
|
+
workspaceJson.projects[options.project].architect.build.options['styles'] = stylesArray;
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
throw new schematics_1.SchematicsException(`Unable to find angular.json project styles. Please manually configure your styles array.`);
|
|
37
|
+
}
|
|
38
|
+
tree.overwrite(angularConfigPath, JSON.stringify(workspaceJson, null, 2));
|
|
39
|
+
context.logger.info(`✅️ Added styles to angular.json.`);
|
|
40
|
+
if (options.fonts) {
|
|
41
|
+
context.logger.info(`✅️ Added font styles to angular.json.`);
|
|
42
|
+
}
|
|
43
|
+
return tree;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function addAssetsToConfig(options) {
|
|
47
|
+
return (tree, context) => {
|
|
48
|
+
const workspaceJson = _getWorkspaceJson(tree);
|
|
49
|
+
try {
|
|
50
|
+
const additionalAssets = [
|
|
51
|
+
{
|
|
52
|
+
glob: '**/css_variables.css',
|
|
53
|
+
input: './node_modules/@sap-theming/theming-base-content/content/Base/baseLib/',
|
|
54
|
+
output: './assets/theming-base/'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
glob: '**/*',
|
|
58
|
+
input: './node_modules/fundamental-styles/dist/theming/',
|
|
59
|
+
output: './assets/fundamental-styles-theming/'
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
let assetsArray = workspaceJson.projects[options.project].architect.build.options['assets'];
|
|
63
|
+
let assetsUpdated = false;
|
|
64
|
+
additionalAssets.forEach((asset) => {
|
|
65
|
+
if (!assetsArray.find((jsonAsset) => typeof jsonAsset === 'object' && jsonAsset.input === asset.input)) {
|
|
66
|
+
assetsUpdated = true;
|
|
67
|
+
assetsArray.push(asset);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
if (!assetsUpdated) {
|
|
71
|
+
context.logger.info(`✅️ Found duplicate assets in angular.json. Skipping.`);
|
|
72
|
+
return tree;
|
|
73
|
+
}
|
|
74
|
+
workspaceJson.projects[options.project].architect.build.options['assets'] = assetsArray;
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
throw new schematics_1.SchematicsException(`Unable to find angular.json project assets. Please manually configure your assets array.`);
|
|
78
|
+
}
|
|
79
|
+
tree.overwrite(angularConfigPath, JSON.stringify(workspaceJson, null, 2));
|
|
80
|
+
context.logger.info(`✅️ Added assets to angular.json.`);
|
|
81
|
+
return tree;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function _getWorkspaceJson(tree) {
|
|
85
|
+
const workspaceConfig = tree.read(angularConfigPath);
|
|
86
|
+
if (!workspaceConfig) {
|
|
87
|
+
throw new schematics_1.SchematicsException(`Unable to find angular.json. Please manually configure your assets & styles arrays.`);
|
|
88
|
+
}
|
|
89
|
+
return JSON.parse(workspaceConfig.toString());
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/core/schematics/add-styles/index.ts"],"names":[],"mappings":";;;AAAA,2DAAsG;AAItG,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAQ1C,SAAgB,SAAS,CAAC,OAAe;IACrC,OAAO,IAAA,kBAAK,EAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAA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AAC;YAEH,IAAI,CAAC,aAAa,EAAE;gBAChB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;gBAC5E,OAAO,IAAI,CAAC;aACf;YAEA,aAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAE,CAAC,SAAU,CAAC,KAAM,CAAC,OAAe,CAAC,QAAQ,CAAC,GAAG,WAAW,CAAC;SACxG;QAAC,OAAO,CAAC,EAAE;YACR,MAAM,IAAI,gCAAmB,CACzB,0FAA0F,CAC7F,CAAC;SACL;QAED,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAE1E,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QAExD,OAAO,IAAI,CAAC;IAChB,CAAC,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAU;IACjC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAErD,IAAI,CAAC,eAAe,EAAE;QAClB,MAAM,IAAI,gCAAmB,CACzB,qFAAqF,CACxF,CAAC;KACL;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { chain, Rule, SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics';
|
|
2
|
+
import { WorkspaceSchema } from '@schematics/angular/utility/workspace-models';
|
|
3
|
+
import { Schema } from '../models/schema';
|
|
4
|
+
|
|
5
|
+
const angularConfigPath = '/angular.json';
|
|
6
|
+
|
|
7
|
+
interface AngularAssets {
|
|
8
|
+
glob: string;
|
|
9
|
+
input: string;
|
|
10
|
+
output: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function addStyles(options: Schema): Rule {
|
|
14
|
+
return chain([addStylesToConfig(options), addAssetsToConfig(options)]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function addStylesToConfig(options: Schema): Rule {
|
|
18
|
+
return (tree: Tree, context: SchematicContext) => {
|
|
19
|
+
const workspaceJson = _getWorkspaceJson(tree);
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const additionalStyles = ['./node_modules/@fundamental-ngx/core/styles/fundamental-ngx-core.css'];
|
|
23
|
+
|
|
24
|
+
if (options.fonts) {
|
|
25
|
+
additionalStyles.push('./node_modules/fundamental-styles/dist/fonts/sap_fonts.css');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let stylesArray: (string | AngularAssets)[] = (
|
|
29
|
+
workspaceJson!.projects[options.project]!.architect!.build!.options as any
|
|
30
|
+
)['styles'];
|
|
31
|
+
let stylesUpdated = false;
|
|
32
|
+
|
|
33
|
+
additionalStyles.forEach((additionalStyle) => {
|
|
34
|
+
if (
|
|
35
|
+
!stylesArray.find(
|
|
36
|
+
(jsonStyle) => typeof jsonStyle === 'string' && jsonStyle === `${additionalStyle}`
|
|
37
|
+
)
|
|
38
|
+
) {
|
|
39
|
+
stylesUpdated = true;
|
|
40
|
+
stylesArray.push(additionalStyle);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (!stylesUpdated) {
|
|
45
|
+
context.logger.info(`✅️ Found duplicate styles in angular.json. Skipping.`);
|
|
46
|
+
|
|
47
|
+
if (options.fonts) {
|
|
48
|
+
context.logger.info(`✅️ Found duplicate font styles to angular.json.`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return tree;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
(workspaceJson!.projects[options.project]!.architect!.build!.options as any)['styles'] = stylesArray;
|
|
55
|
+
} catch (e) {
|
|
56
|
+
throw new SchematicsException(
|
|
57
|
+
`Unable to find angular.json project styles. Please manually configure your styles array.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
tree.overwrite(angularConfigPath, JSON.stringify(workspaceJson, null, 2));
|
|
62
|
+
|
|
63
|
+
context.logger.info(`✅️ Added styles to angular.json.`);
|
|
64
|
+
|
|
65
|
+
if (options.fonts) {
|
|
66
|
+
context.logger.info(`✅️ Added font styles to angular.json.`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return tree;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function addAssetsToConfig(options: Schema): Rule {
|
|
74
|
+
return (tree: Tree, context: SchematicContext) => {
|
|
75
|
+
const workspaceJson = _getWorkspaceJson(tree);
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
const additionalAssets: AngularAssets[] = [
|
|
79
|
+
{
|
|
80
|
+
glob: '**/css_variables.css',
|
|
81
|
+
input: './node_modules/@sap-theming/theming-base-content/content/Base/baseLib/',
|
|
82
|
+
output: './assets/theming-base/'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
glob: '**/*',
|
|
86
|
+
input: './node_modules/fundamental-styles/dist/theming/',
|
|
87
|
+
output: './assets/fundamental-styles-theming/'
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
let assetsArray: (string | AngularAssets)[] = (
|
|
91
|
+
workspaceJson!.projects[options.project]!.architect!.build!.options as any
|
|
92
|
+
)['assets'];
|
|
93
|
+
let assetsUpdated = false;
|
|
94
|
+
|
|
95
|
+
additionalAssets.forEach((asset) => {
|
|
96
|
+
if (
|
|
97
|
+
!assetsArray.find((jsonAsset) => typeof jsonAsset === 'object' && jsonAsset.input === asset.input)
|
|
98
|
+
) {
|
|
99
|
+
assetsUpdated = true;
|
|
100
|
+
assetsArray.push(asset);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (!assetsUpdated) {
|
|
105
|
+
context.logger.info(`✅️ Found duplicate assets in angular.json. Skipping.`);
|
|
106
|
+
return tree;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
(workspaceJson!.projects[options.project]!.architect!.build!.options as any)['assets'] = assetsArray;
|
|
110
|
+
} catch (e) {
|
|
111
|
+
throw new SchematicsException(
|
|
112
|
+
`Unable to find angular.json project assets. Please manually configure your assets array.`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
tree.overwrite(angularConfigPath, JSON.stringify(workspaceJson, null, 2));
|
|
117
|
+
|
|
118
|
+
context.logger.info(`✅️ Added assets to angular.json.`);
|
|
119
|
+
|
|
120
|
+
return tree;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function _getWorkspaceJson(tree: Tree): WorkspaceSchema {
|
|
125
|
+
const workspaceConfig = tree.read(angularConfigPath);
|
|
126
|
+
|
|
127
|
+
if (!workspaceConfig) {
|
|
128
|
+
throw new SchematicsException(
|
|
129
|
+
`Unable to find angular.json. Please manually configure your assets & styles arrays.`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return JSON.parse(workspaceConfig.toString());
|
|
134
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "fundamental-ngx-add-styles",
|
|
4
|
+
"title": "Fundamental Library for Angular add-styles schematic",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the project.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "projectName"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|