taiga-ui 3.0.0-rc.4 → 3.0.0
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 +28 -25
- package/schematics/collection.json +0 -16
- package/schematics/ng-add/constants/modules.d.ts +0 -8
- package/schematics/ng-add/constants/modules.js +0 -35
- package/schematics/ng-add/constants/versions.d.ts +0 -4
- package/schematics/ng-add/constants/versions.js +0 -8
- package/schematics/ng-add/index.d.ts +0 -3
- package/schematics/ng-add/index.js +0 -60
- package/schematics/ng-add/schema.d.ts +0 -8
- package/schematics/ng-add/schema.js +0 -2
- package/schematics/ng-add/schema.json +0 -86
- package/schematics/ng-add/setup-project.d.ts +0 -3
- package/schematics/ng-add/setup-project.js +0 -16
- package/schematics/ng-add/steps/add-taiga-icons.d.ts +0 -4
- package/schematics/ng-add/steps/add-taiga-icons.js +0 -27
- package/schematics/ng-add/steps/add-taiga-modules.d.ts +0 -3
- package/schematics/ng-add/steps/add-taiga-modules.js +0 -69
- package/schematics/ng-add/steps/add-taiga-styles.d.ts +0 -4
- package/schematics/ng-add/steps/add-taiga-styles.js +0 -27
- package/schematics/ng-add/steps/wrap-with-tui-root.d.ts +0 -3
- package/schematics/ng-add/steps/wrap-with-tui-root.js +0 -75
- package/schematics/utils/get-project-target-options.d.ts +0 -2
- package/schematics/utils/get-project-target-options.js +0 -13
- package/schematics/utils/get-project.d.ts +0 -3
- package/schematics/utils/get-project.js +0 -14
package/package.json
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"name": "taiga-ui",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Taiga UI package that provides ng add command for Taiga library",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"kit",
|
|
8
|
+
"ui",
|
|
9
|
+
"component-library",
|
|
10
|
+
"component",
|
|
11
|
+
"service",
|
|
12
|
+
"directive"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/tinkoff/taiga-ui",
|
|
15
|
+
"repository": "https://github.com/tinkoff/taiga-ui",
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@taiga-ui/cdk": "^3.0.0",
|
|
19
|
+
"tslib": "^2.0.0"
|
|
20
|
+
},
|
|
21
|
+
"schematics": "../@taiga-ui/cdk/schematics/collection.json",
|
|
22
|
+
"main": "bundles/taiga-ui.umd.js",
|
|
23
|
+
"module": "fesm2015/taiga-ui.js",
|
|
24
|
+
"es2015": "fesm2015/taiga-ui.js",
|
|
25
|
+
"esm2015": "esm2015/taiga-ui.js",
|
|
26
|
+
"fesm2015": "fesm2015/taiga-ui.js",
|
|
27
|
+
"typings": "taiga-ui.d.ts",
|
|
28
|
+
"sideEffects": false
|
|
29
|
+
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
|
|
3
|
-
"schematics": {
|
|
4
|
-
"ng-add": {
|
|
5
|
-
"description": "Add Taiga UI to the project.",
|
|
6
|
-
"factory": "./ng-add/index#ngAdd",
|
|
7
|
-
"schema": "./ng-add/schema.json"
|
|
8
|
-
},
|
|
9
|
-
"ng-add-setup-project": {
|
|
10
|
-
"private": true,
|
|
11
|
-
"description": "Sets up the project after dependencies have been installed",
|
|
12
|
-
"factory": "./ng-add/setup-project",
|
|
13
|
-
"schema": "./ng-add/schema.json"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface ImportingModule {
|
|
2
|
-
name: string;
|
|
3
|
-
packageName: string;
|
|
4
|
-
}
|
|
5
|
-
export declare const MAIN_MODULES: ReadonlyArray<ImportingModule>;
|
|
6
|
-
export declare const DIALOG_MODULES: ReadonlyArray<ImportingModule>;
|
|
7
|
-
export declare const ALERT_MODULES: ReadonlyArray<ImportingModule>;
|
|
8
|
-
export declare const SANITIZER_MODULES: ReadonlyArray<ImportingModule>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SANITIZER_MODULES = exports.ALERT_MODULES = exports.DIALOG_MODULES = exports.MAIN_MODULES = void 0;
|
|
4
|
-
exports.MAIN_MODULES = [
|
|
5
|
-
{
|
|
6
|
-
name: 'BrowserAnimationsModule',
|
|
7
|
-
packageName: '@angular/platform-browser/animations',
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
name: 'TuiRootModule',
|
|
11
|
-
packageName: '@taiga-ui/core',
|
|
12
|
-
},
|
|
13
|
-
];
|
|
14
|
-
exports.DIALOG_MODULES = [
|
|
15
|
-
{
|
|
16
|
-
name: 'TuiDialogModule',
|
|
17
|
-
packageName: '@taiga-ui/core',
|
|
18
|
-
},
|
|
19
|
-
];
|
|
20
|
-
exports.ALERT_MODULES = [
|
|
21
|
-
{
|
|
22
|
-
name: 'TuiAlertModule',
|
|
23
|
-
packageName: '@taiga-ui/core',
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
exports.SANITIZER_MODULES = [
|
|
27
|
-
{
|
|
28
|
-
name: 'TUI_SANITIZER',
|
|
29
|
-
packageName: '@taiga-ui/core',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'NgDompurifySanitizer',
|
|
33
|
-
packageName: '@tinkoff/ng-dompurify',
|
|
34
|
-
},
|
|
35
|
-
];
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DOMPURIFY_TYPES_VERSION = exports.DOMPURIFY_VERSION = exports.NG_DOMPURIFY_VERSION = exports.TAIGA_VERSION = void 0;
|
|
4
|
-
const package_json_1 = require("../../../package.json");
|
|
5
|
-
exports.TAIGA_VERSION = `^${package_json_1.version}`;
|
|
6
|
-
exports.NG_DOMPURIFY_VERSION = '3.0.0';
|
|
7
|
-
exports.DOMPURIFY_VERSION = '2.2.9';
|
|
8
|
-
exports.DOMPURIFY_TYPES_VERSION = '2.2.3';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ngAdd = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
6
|
-
const ng_morph_1 = require("ng-morph");
|
|
7
|
-
const versions_1 = require("./constants/versions");
|
|
8
|
-
const MAIN_PACKAGES = ['core', 'cdk', 'kit', 'icons'];
|
|
9
|
-
function ngAdd(options) {
|
|
10
|
-
return (tree, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
-
context.logger.info(`The main packages will be installed - ${MAIN_PACKAGES}`);
|
|
12
|
-
addDependencies(tree, options);
|
|
13
|
-
context.addTask(new tasks_1.NodePackageInstallTask(), [
|
|
14
|
-
context.addTask(new tasks_1.RunSchematicTask('ng-add-setup-project', options)),
|
|
15
|
-
]);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
exports.ngAdd = ngAdd;
|
|
19
|
-
function addDependencies(tree, options) {
|
|
20
|
-
const packages = [...MAIN_PACKAGES, ...options.addons];
|
|
21
|
-
packages.forEach(pack => {
|
|
22
|
-
ng_morph_1.addPackageJsonDependency(tree, {
|
|
23
|
-
name: `@taiga-ui/${pack}`,
|
|
24
|
-
version: versions_1.TAIGA_VERSION,
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
ng_morph_1.removePackageJsonDependency(tree, 'taiga-ui');
|
|
28
|
-
if (options.addSanitizer) {
|
|
29
|
-
ng_morph_1.addPackageJsonDependency(tree, {
|
|
30
|
-
name: '@tinkoff/ng-dompurify',
|
|
31
|
-
version: versions_1.NG_DOMPURIFY_VERSION,
|
|
32
|
-
});
|
|
33
|
-
ng_morph_1.addPackageJsonDependency(tree, {
|
|
34
|
-
name: 'dompurify',
|
|
35
|
-
version: versions_1.DOMPURIFY_VERSION,
|
|
36
|
-
});
|
|
37
|
-
ng_morph_1.addPackageJsonDependency(tree, {
|
|
38
|
-
name: '@types/dompurify',
|
|
39
|
-
version: versions_1.DOMPURIFY_TYPES_VERSION,
|
|
40
|
-
type: ng_morph_1.NodeDependencyType.Dev,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
if (packages.includes('addon-table') || packages.includes('addon-mobile')) {
|
|
44
|
-
addAngularCdkDep(tree);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function addAngularCdkDep(tree) {
|
|
48
|
-
var _a;
|
|
49
|
-
const angularCore = (_a = ng_morph_1.getPackageJsonDependency(tree, '@angular/core')) === null || _a === void 0 ? void 0 : _a.version;
|
|
50
|
-
if (!angularCore) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const majorVersionArr = angularCore.match(/[0-9]+/);
|
|
54
|
-
if (majorVersionArr) {
|
|
55
|
-
ng_morph_1.addPackageJsonDependency(tree, {
|
|
56
|
-
name: '@angular/cdk',
|
|
57
|
-
version: `^${majorVersionArr[0]}.0.0`,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
-
"$id": "taiga-ui-ng-add",
|
|
4
|
-
"title": "Taiga UI ng-add",
|
|
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
|
-
"addDialogsModule": {
|
|
15
|
-
"description": "Setting up dialog module",
|
|
16
|
-
"type": "boolean",
|
|
17
|
-
"default": true,
|
|
18
|
-
"x-prompt": {
|
|
19
|
-
"message": "Do you want to use Taiga UI dialogs?",
|
|
20
|
-
"type": "confirmation"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"addSanitizer": {
|
|
24
|
-
"description": "Setting up TUI_SANITIZER",
|
|
25
|
-
"type": "boolean",
|
|
26
|
-
"default": true,
|
|
27
|
-
"x-prompt": {
|
|
28
|
-
"message": "Do you plan on using custom SVGs/icons or addon-editor? If `Yes` we will include ng-dompurify as sanitizer, read more: https://taiga-ui.dev/icon-set#sanitizer",
|
|
29
|
-
"type": "confirmation"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"addAlertModule": {
|
|
33
|
-
"description": "Setting up alerts module",
|
|
34
|
-
"type": "boolean",
|
|
35
|
-
"default": true,
|
|
36
|
-
"x-prompt": {
|
|
37
|
-
"message": "Do you want to use Taiga UI alerts?",
|
|
38
|
-
"type": "confirmation"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"addons": {
|
|
42
|
-
"description": "Setting up additional packages",
|
|
43
|
-
"type": "array",
|
|
44
|
-
"x-prompt": {
|
|
45
|
-
"message": "Choose additional packages to install",
|
|
46
|
-
"type": "list",
|
|
47
|
-
"multiselect": true,
|
|
48
|
-
"items": [
|
|
49
|
-
{
|
|
50
|
-
"value": "addon-doc",
|
|
51
|
-
"label": "addon-doc Taiga UI based library for developing documentation portals for Angular libraries"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"value": "addon-charts",
|
|
55
|
-
"label": "addon-charts Components for various charts, graphs and visualizations"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"value": "addon-commerce",
|
|
59
|
-
"label": "addon-commerce Money-related extension with currencies, credit card inputs and validators"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"value": "addon-mobile",
|
|
63
|
-
"label": "addon-mobile Components and tools specific to mobile version of the app"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"value": "addon-table",
|
|
67
|
-
"label": "addon-table Interactive table component and related utilities"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
"value": "addon-tablebars",
|
|
71
|
-
"label": "addon-tablebars Group action sliding toolbar"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"value": "addon-editor",
|
|
75
|
-
"label": "addon-editor Rich text editor extension with related components"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
"value": "addon-preview",
|
|
79
|
-
"label": "addon preview Custom fullscreen dialog to preview various content such as documents, images etc."
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
"required": []
|
|
86
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
4
|
-
const add_taiga_icons_1 = require("./steps/add-taiga-icons");
|
|
5
|
-
const add_taiga_modules_1 = require("./steps/add-taiga-modules");
|
|
6
|
-
const add_taiga_styles_1 = require("./steps/add-taiga-styles");
|
|
7
|
-
const wrap_with_tui_root_1 = require("./steps/wrap-with-tui-root");
|
|
8
|
-
function ngAddSetupProject(options) {
|
|
9
|
-
return schematics_1.chain([
|
|
10
|
-
add_taiga_styles_1.addTaigaStyles(options),
|
|
11
|
-
add_taiga_modules_1.addTaigaModules(options),
|
|
12
|
-
add_taiga_icons_1.addTaigaIcons(options),
|
|
13
|
-
wrap_with_tui_root_1.wrapWithTuiRootComponent(options),
|
|
14
|
-
]);
|
|
15
|
-
}
|
|
16
|
-
exports.default = ngAddSetupProject;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addTaigaStylesToAngularJson = exports.addTaigaIcons = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
|
-
const get_project_1 = require("../../utils/get-project");
|
|
7
|
-
const get_project_target_options_1 = require("../../utils/get-project-target-options");
|
|
8
|
-
const ICON_ASSETS = {
|
|
9
|
-
glob: '**/*',
|
|
10
|
-
input: 'node_modules/@taiga-ui/icons/src',
|
|
11
|
-
output: 'assets/taiga-ui/icons',
|
|
12
|
-
};
|
|
13
|
-
function addTaigaIcons(options) {
|
|
14
|
-
return (_) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
return addTaigaStylesToAngularJson(options);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
exports.addTaigaIcons = addTaigaIcons;
|
|
19
|
-
function addTaigaStylesToAngularJson(options) {
|
|
20
|
-
return workspace_1.updateWorkspace(workspace => {
|
|
21
|
-
const project = get_project_1.getProject(options, workspace);
|
|
22
|
-
const targetOptions = get_project_target_options_1.getProjectTargetOptions(project, 'build');
|
|
23
|
-
const assets = targetOptions.assets;
|
|
24
|
-
targetOptions.assets = assets ? [...assets, ICON_ASSETS] : [ICON_ASSETS];
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
exports.addTaigaStylesToAngularJson = addTaigaStylesToAngularJson;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addTaigaModules = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
|
-
const ng_morph_1 = require("ng-morph");
|
|
7
|
-
const get_project_1 = require("../../utils/get-project");
|
|
8
|
-
const get_project_target_options_1 = require("../../utils/get-project-target-options");
|
|
9
|
-
const modules_1 = require("../constants/modules");
|
|
10
|
-
function addTaigaModules(options) {
|
|
11
|
-
return (tree, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
const workspace = yield workspace_1.getWorkspace(tree);
|
|
13
|
-
const project = get_project_1.getProject(options, workspace);
|
|
14
|
-
const buildOptions = get_project_target_options_1.getProjectTargetOptions(project, 'build');
|
|
15
|
-
ng_morph_1.setActiveProject(ng_morph_1.createProject(tree, '/', ['**/*.ts', '**/*.json']));
|
|
16
|
-
const mainModule = ng_morph_1.getMainModule(buildOptions.main);
|
|
17
|
-
addTuiModules(mainModule, options, context);
|
|
18
|
-
addTuiProviders(mainModule, options);
|
|
19
|
-
ng_morph_1.saveActiveProject();
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
exports.addTaigaModules = addTaigaModules;
|
|
23
|
-
function addTuiModules(mainModule, options, context) {
|
|
24
|
-
const modules = [
|
|
25
|
-
...modules_1.MAIN_MODULES,
|
|
26
|
-
...(options.addDialogsModule ? modules_1.DIALOG_MODULES : []),
|
|
27
|
-
...(options.addAlertModule ? modules_1.ALERT_MODULES : []),
|
|
28
|
-
];
|
|
29
|
-
const mainModulePath = mainModule.getSourceFile().getFilePath();
|
|
30
|
-
modules.forEach(module => {
|
|
31
|
-
ng_morph_1.addImportToNgModule(mainModule, module.name, { unique: true });
|
|
32
|
-
addUniqueImport(mainModulePath, module.name, module.packageName);
|
|
33
|
-
});
|
|
34
|
-
context.logger.info(`${modules.map(module => module.name)} was added to ${mainModulePath}`);
|
|
35
|
-
}
|
|
36
|
-
function addTuiProviders(mainModule, options) {
|
|
37
|
-
if (!options.addSanitizer) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
ng_morph_1.addProviderToNgModule(mainModule, '{provide: TUI_SANITIZER, useClass: NgDompurifySanitizer}', { unique: true });
|
|
41
|
-
modules_1.SANITIZER_MODULES.forEach(module => {
|
|
42
|
-
addUniqueImport(mainModule.getSourceFile().getFilePath(), module.name, module.packageName);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function addUniqueImport(filePath, namedImport, packageName) {
|
|
46
|
-
const existingNamedImport = ng_morph_1.getImports(filePath, {
|
|
47
|
-
namedImports: namedImport,
|
|
48
|
-
moduleSpecifier: packageName,
|
|
49
|
-
});
|
|
50
|
-
if (existingNamedImport.length) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const existingDeclaration = ng_morph_1.getImports(filePath, {
|
|
54
|
-
moduleSpecifier: packageName,
|
|
55
|
-
});
|
|
56
|
-
if (existingDeclaration.length) {
|
|
57
|
-
const modules = existingDeclaration[0]
|
|
58
|
-
.getNamedImports()
|
|
59
|
-
.map(namedImport => namedImport.getText());
|
|
60
|
-
ng_morph_1.editImports(existingDeclaration, () => ({
|
|
61
|
-
namedImports: [...modules, namedImport],
|
|
62
|
-
}));
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
ng_morph_1.addImports(filePath, {
|
|
66
|
-
moduleSpecifier: packageName,
|
|
67
|
-
namedImports: [namedImport],
|
|
68
|
-
});
|
|
69
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addTaigaStylesToAngularJson = exports.addTaigaStyles = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
|
-
const get_project_1 = require("../../utils/get-project");
|
|
7
|
-
const get_project_target_options_1 = require("../../utils/get-project-target-options");
|
|
8
|
-
const TAIGA_GLOBAL_STYLE = ['node_modules/@taiga-ui/styles/taiga-ui-global.less'];
|
|
9
|
-
const TAIGA_THEME_STYLE = 'node_modules/@taiga-ui/core/styles/taiga-ui-theme.less';
|
|
10
|
-
function addTaigaStyles(options) {
|
|
11
|
-
return (_) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
return addTaigaStylesToAngularJson(options);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
exports.addTaigaStyles = addTaigaStyles;
|
|
16
|
-
function addTaigaStylesToAngularJson(options) {
|
|
17
|
-
return workspace_1.updateWorkspace(workspace => {
|
|
18
|
-
const project = get_project_1.getProject(options, workspace);
|
|
19
|
-
const targetOptions = get_project_target_options_1.getProjectTargetOptions(project, 'build');
|
|
20
|
-
const styles = targetOptions.styles;
|
|
21
|
-
const taigaStyles = [TAIGA_THEME_STYLE, ...TAIGA_GLOBAL_STYLE];
|
|
22
|
-
targetOptions.styles = styles
|
|
23
|
-
? Array.from(new Set([...taigaStyles, ...styles]))
|
|
24
|
-
: taigaStyles;
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
exports.addTaigaStylesToAngularJson = addTaigaStylesToAngularJson;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapWithTuiRootComponent = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
6
|
-
const ng_morph_1 = require("ng-morph");
|
|
7
|
-
const get_project_1 = require("../../utils/get-project");
|
|
8
|
-
const get_project_target_options_1 = require("../../utils/get-project-target-options");
|
|
9
|
-
function wrapWithTuiRootComponent(options) {
|
|
10
|
-
return (tree, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
11
|
-
const workspace = yield workspace_1.getWorkspace(tree);
|
|
12
|
-
const project = get_project_1.getProject(options, workspace);
|
|
13
|
-
const buildOptions = get_project_target_options_1.getProjectTargetOptions(project, 'build');
|
|
14
|
-
const appTemplatePath = getAppTemplatePath(tree, buildOptions.main);
|
|
15
|
-
if (!appTemplatePath) {
|
|
16
|
-
context.logger.error('Could not find the default main template file for this project.');
|
|
17
|
-
context.logger.info('Consider manually wrapping content of your app with tui-root');
|
|
18
|
-
context.logger.info('More information at https://taiga-ui.dev/getting-started');
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
addTuiRootComponent(appTemplatePath, context, tree);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
exports.wrapWithTuiRootComponent = wrapWithTuiRootComponent;
|
|
25
|
-
function addTuiRootComponent(filePath, context, tree) {
|
|
26
|
-
const buffer = tree.read(filePath);
|
|
27
|
-
if (!buffer) {
|
|
28
|
-
context.logger.error(`Could not read the default template file within the project ${filePath}`);
|
|
29
|
-
context.logger.info('Consider manually wrapping content of your app with tui-root');
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const htmlContent = buffer.toString();
|
|
33
|
-
const openTag = '<tui-root>' + '\n';
|
|
34
|
-
const closeTag = '\n' + '</tui-root>';
|
|
35
|
-
if (htmlContent.includes(openTag)) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const recorder = tree.beginUpdate(filePath);
|
|
39
|
-
recorder.insertLeft(0, openTag);
|
|
40
|
-
recorder.insertLeft(htmlContent.length, closeTag);
|
|
41
|
-
tree.commitUpdate(recorder);
|
|
42
|
-
context.logger.info(`Content of the app was wrapped with tui-root component in ${filePath}`);
|
|
43
|
-
}
|
|
44
|
-
function getAppTemplatePath(tree, mainPath) {
|
|
45
|
-
ng_morph_1.setActiveProject(ng_morph_1.createProject(tree, '/', ['**/*.ts', '**/*.json']));
|
|
46
|
-
const mainModule = ng_morph_1.getMainModule(mainPath);
|
|
47
|
-
const mainInitializer = getInitializer(mainModule, 'NgModule', 'declarations');
|
|
48
|
-
if (!ng_morph_1.Node.isArrayLiteralExpression(mainInitializer)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const appIdentifier = mainInitializer.getElements()[0];
|
|
52
|
-
const appComponent = appIdentifier.getDefinitionNodes()[0];
|
|
53
|
-
const templateInitializer = getInitializer(appComponent, 'Component', 'templateUrl');
|
|
54
|
-
const appComponentPath = appComponent.getSourceFile().getFilePath().split('/');
|
|
55
|
-
const templateUrlPath = `${appComponentPath
|
|
56
|
-
.splice(0, appComponentPath.length - 1)
|
|
57
|
-
.join('/')}/${templateInitializer === null || templateInitializer === void 0 ? void 0 : templateInitializer.getText().replace(/['"]/g, '')}`;
|
|
58
|
-
ng_morph_1.saveActiveProject();
|
|
59
|
-
return templateUrlPath;
|
|
60
|
-
}
|
|
61
|
-
function getInitializer(classDeclaration, decoratorName, propertyName) {
|
|
62
|
-
const decorator = classDeclaration.getDecorator(decoratorName);
|
|
63
|
-
if (!decorator) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const [metadata] = decorator.getArguments();
|
|
67
|
-
if (!ng_morph_1.Node.isObjectLiteralExpression(metadata)) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const property = metadata.getProperty(propertyName);
|
|
71
|
-
if (!ng_morph_1.Node.isPropertyAssignment(property)) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
return property.getInitializer();
|
|
75
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectTargetOptions = void 0;
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
function getProjectTargetOptions(project, buildTarget) {
|
|
6
|
-
var _a;
|
|
7
|
-
const buildTargetObject = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.get(buildTarget);
|
|
8
|
-
if (buildTargetObject && buildTargetObject.options) {
|
|
9
|
-
return buildTargetObject.options;
|
|
10
|
-
}
|
|
11
|
-
throw new schematics_1.SchematicsException(`Cannot determine project target configuration for: ${buildTarget}.`);
|
|
12
|
-
}
|
|
13
|
-
exports.getProjectTargetOptions = getProjectTargetOptions;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProject = void 0;
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
function getProject(options, workspace) {
|
|
6
|
-
var _a;
|
|
7
|
-
const projectName = options.project || ((_a = workspace.extensions.defaultProject) === null || _a === void 0 ? void 0 : _a.toString()) || '';
|
|
8
|
-
const project = workspace.projects.get(projectName);
|
|
9
|
-
if (!project) {
|
|
10
|
-
throw new schematics_1.SchematicsException(`Unable to find project '${projectName}' in the workspace`);
|
|
11
|
-
}
|
|
12
|
-
return project;
|
|
13
|
-
}
|
|
14
|
-
exports.getProject = getProject;
|