@po-ui/ng-components 22.0.0-rc.0 → 22.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/README.md +1 -1
- package/fesm2022/{po-ui-ng-components-po-chart-modal-table.component-B6drxxln.mjs → po-ui-ng-components-po-chart-modal-table.component-Cozxgj7w.mjs} +4 -4
- package/fesm2022/{po-ui-ng-components-po-chart-modal-table.component-B6drxxln.mjs.map → po-ui-ng-components-po-chart-modal-table.component-Cozxgj7w.mjs.map} +1 -1
- package/fesm2022/po-ui-ng-components.mjs +3072 -1450
- package/fesm2022/po-ui-ng-components.mjs.map +1 -1
- package/lib/components/po-accordion/po-accordion-item/po-accordion-item.component.d.ts +2 -0
- package/lib/components/po-accordion/po-accordion.component.d.ts +2 -0
- package/lib/components/po-avatar/po-avatar.component.d.ts +2 -0
- package/lib/components/po-badge/po-badge.component.d.ts +2 -0
- package/lib/components/po-breadcrumb/po-breadcrumb.component.d.ts +2 -0
- package/lib/components/po-button/enums/po-button-kind.enum.d.ts +7 -1
- package/lib/components/po-button/po-button-base.component.d.ts +27 -3
- package/lib/components/po-button/po-button.component.d.ts +4 -0
- package/lib/components/po-button-group/po-button-group.component.d.ts +2 -0
- package/lib/components/po-calendar/po-calendar-base.component.d.ts +5 -0
- package/lib/components/po-calendar/po-calendar-header/po-calendar-header.component.d.ts +2 -0
- package/lib/components/po-calendar/po-calendar-wrapper/po-calendar-wrapper.component.d.ts +12 -0
- package/lib/components/po-calendar/po-calendar.component.d.ts +13 -0
- package/lib/components/po-chart/interfaces/po-chart-serie.interface.d.ts +29 -2
- package/lib/components/po-chart/po-chart.component.d.ts +2 -0
- package/lib/components/po-container/po-container.component.d.ts +2 -0
- package/lib/components/po-context-menu/po-context-menu.component.d.ts +2 -0
- package/lib/components/po-context-tabs/po-context-tabs.component.d.ts +2 -0
- package/lib/components/po-disclaimer-group/po-disclaimer-group.component.d.ts +1 -0
- package/lib/components/po-divider/po-divider.component.d.ts +2 -0
- package/lib/components/po-dropdown/po-dropdown.component.d.ts +2 -0
- package/lib/components/po-dynamic/po-dynamic-form/po-dynamic-form.component.d.ts +1 -0
- package/lib/components/po-dynamic/po-dynamic-view/po-dynamic-view.component.d.ts +2 -0
- package/lib/components/po-field/po-checkbox/po-checkbox.component.d.ts +2 -0
- package/lib/components/po-field/po-checkbox-group/po-checkbox-group.component.d.ts +2 -0
- package/lib/components/po-field/po-combo/po-combo-option-template/po-combo-option-template.directive.d.ts +2 -0
- package/lib/components/po-field/po-combo/po-combo.component.d.ts +2 -0
- package/lib/components/po-field/po-datepicker/po-datepicker-base.component.d.ts +15 -4
- package/lib/components/po-field/po-datepicker/po-datepicker.component.d.ts +7 -0
- package/lib/components/po-field/po-datepicker-range/po-datepicker-range-base.component.d.ts +3 -0
- package/lib/components/po-field/po-datepicker-range/po-datepicker-range.component.d.ts +4 -0
- package/lib/components/po-field/po-datetimepicker/po-datetimepicker-base.component.d.ts +5 -0
- package/lib/components/po-field/po-datetimepicker/po-datetimepicker.component.d.ts +7 -0
- package/lib/components/po-field/po-decimal/po-decimal.component.d.ts +2 -0
- package/lib/components/po-field/po-email/po-email.component.d.ts +2 -0
- package/lib/components/po-field/po-field-validate.model.d.ts +2 -0
- package/lib/components/po-field/po-input/po-input.component.d.ts +2 -0
- package/lib/components/po-field/po-login/po-login.component.d.ts +1 -0
- package/lib/components/po-field/po-lookup/po-lookup.component.d.ts +2 -0
- package/lib/components/po-field/po-multiselect/po-multiselect-option-template/po-multiselect-option-template.directive.d.ts +1 -0
- package/lib/components/po-field/po-multiselect/po-multiselect.component.d.ts +1 -0
- package/lib/components/po-field/po-number/po-number.component.d.ts +2 -0
- package/lib/components/po-field/po-password/po-password.component.d.ts +2 -0
- package/lib/components/po-field/po-radio-group/po-radio-group.component.d.ts +1 -0
- package/lib/components/po-field/po-rich-text/po-rich-text.component.d.ts +2 -0
- package/lib/components/po-field/po-search-ai/po-search-ai.component.d.ts +2 -0
- package/lib/components/po-field/po-select/po-select.component.d.ts +1 -0
- package/lib/components/po-field/po-switch/po-switch.component.d.ts +2 -0
- package/lib/components/po-field/po-textarea/po-textarea.component.d.ts +1 -0
- package/lib/components/po-field/po-timepicker/po-timepicker.component.d.ts +2 -0
- package/lib/components/po-field/po-upload/po-upload.component.d.ts +2 -0
- package/lib/components/po-field/po-url/po-url.component.d.ts +1 -0
- package/lib/components/po-filter-chip/po-filter-chip.component.d.ts +2 -0
- package/lib/components/po-grid/po-grid.component.d.ts +2 -0
- package/lib/components/po-header/po-header.component.d.ts +1 -0
- package/lib/components/po-helper/po-helper.component.d.ts +1 -0
- package/lib/components/po-image/po-image.component.d.ts +1 -0
- package/lib/components/po-info/po-info.component.d.ts +2 -0
- package/lib/components/po-link/po-link.component.d.ts +2 -0
- package/lib/components/po-list-view/po-list-view-content-template/po-list-view-content-template.directive.d.ts +2 -0
- package/lib/components/po-list-view/po-list-view-detail-template/po-list-view-detail-template.directive.d.ts +2 -0
- package/lib/components/po-list-view/po-list-view.component.d.ts +2 -0
- package/lib/components/po-listbox/po-item-list/po-item-list.component.d.ts +1 -0
- package/lib/components/po-listbox/po-listbox.component.d.ts +1 -0
- package/lib/components/po-loading/po-loading-overlay/po-loading-overlay.component.d.ts +2 -0
- package/lib/components/po-menu/po-menu-header-template/po-menu-header-template.directive.d.ts +2 -0
- package/lib/components/po-menu/po-menu.component.d.ts +2 -0
- package/lib/components/po-menu-panel/po-menu-panel.component.d.ts +2 -0
- package/lib/components/po-modal/po-modal-footer/po-modal-footer.component.d.ts +2 -0
- package/lib/components/po-modal/po-modal.component.d.ts +2 -0
- package/lib/components/po-navbar/po-navbar.component.d.ts +2 -0
- package/lib/components/po-page/po-page-default/po-page-default.component.d.ts +2 -0
- package/lib/components/po-page/po-page-detail/po-page-detail.component.d.ts +2 -0
- package/lib/components/po-page/po-page-edit/po-page-edit.component.d.ts +2 -0
- package/lib/components/po-page/po-page-list/po-page-list.component.d.ts +2 -0
- package/lib/components/po-page/po-page-slide/po-page-slide-footer/po-page-slide-footer.component.d.ts +2 -0
- package/lib/components/po-page/po-page-slide/po-page-slide.component.d.ts +2 -0
- package/lib/components/po-popover/po-popover.component.d.ts +2 -0
- package/lib/components/po-popup/po-popup.component.d.ts +1 -0
- package/lib/components/po-progress/po-progress.component.d.ts +1 -0
- package/lib/components/po-search/po-search.component.d.ts +1 -0
- package/lib/components/po-skeleton/po-skeleton.component.d.ts +2 -0
- package/lib/components/po-slide/directives/po-slide-content-template.directive.d.ts +2 -0
- package/lib/components/po-slide/po-slide.component.d.ts +2 -0
- package/lib/components/po-stepper/po-step/po-step.component.d.ts +2 -0
- package/lib/components/po-stepper/po-stepper.component.d.ts +2 -0
- package/lib/components/po-table/po-table-cell-template/po-table-cell-template.directive.d.ts +2 -0
- package/lib/components/po-table/po-table-column-template/po-table-column-template.directive.d.ts +2 -0
- package/lib/components/po-table/po-table-row-template/po-table-row-template.directive.d.ts +2 -0
- package/lib/components/po-table/po-table.component.d.ts +2 -0
- package/lib/components/po-tabs/po-tab/po-tab.component.d.ts +2 -0
- package/lib/components/po-tabs/po-tabs.component.d.ts +3 -0
- package/lib/components/po-tag/po-tag.component.d.ts +2 -0
- package/lib/components/po-toaster/po-toaster.component.d.ts +2 -0
- package/lib/components/po-toolbar/po-toolbar.component.d.ts +2 -0
- package/lib/components/po-tree-view/po-tree-view.component.d.ts +2 -0
- package/lib/components/po-widget/po-widget.component.d.ts +1 -0
- package/lib/directives/po-drag-drop/po-drag.directive.d.ts +2 -0
- package/lib/directives/po-drag-drop/po-drop-list.directive.d.ts +3 -0
- package/lib/directives/po-tooltip/po-tooltip.directive.d.ts +2 -0
- package/lib/interceptors/po-http-interceptor/po-http-interceptor.service.d.ts +2 -0
- package/lib/interceptors/po-http-request/po-http-request-interceptor.service.d.ts +2 -0
- package/lib/po.module.d.ts +2 -0
- package/lib/services/po-dialog/po-dialog.service.d.ts +4 -0
- package/lib/services/po-i18n/po-i18n.service.d.ts +2 -0
- package/lib/services/po-media-query/po-media-query.service.d.ts +1 -0
- package/lib/services/po-notification/po-notification.service.d.ts +3 -0
- package/lib/services/po-theme/helpers/accessibilities/po-theme-default-aaa.constant.d.ts +1 -8
- package/lib/services/po-theme/helpers/deprecated/accessibilities/po-theme-default-aa.constant.d.ts +20 -0
- package/lib/services/po-theme/helpers/deprecated/accessibilities/po-theme-default-aaa.constant.d.ts +18 -0
- package/lib/services/po-theme/helpers/deprecated/accessibilities/po-theme-density.constant.d.ts +12 -0
- package/lib/services/po-theme/helpers/deprecated/po-theme-poui.constant.d.ts +27 -0
- package/lib/services/po-theme/helpers/deprecated/types/po-theme-dark-defaults-AA.constant.d.ts +129 -0
- package/lib/services/po-theme/helpers/deprecated/types/po-theme-dark-defaults.constant.d.ts +167 -0
- package/lib/services/po-theme/helpers/deprecated/types/po-theme-light-defaults-AA.constant.d.ts +49 -0
- package/lib/services/po-theme/helpers/deprecated/types/po-theme-light-defaults.constant.d.ts +81 -0
- package/lib/services/po-theme/helpers/shared/base.constant.d.ts +146 -0
- package/lib/services/po-theme/helpers/types/po-theme-dark-defaults-AA.constant.d.ts +3 -4
- package/lib/services/po-theme/helpers/types/po-theme-dark-defaults.constant.d.ts +4 -4
- package/lib/services/po-theme/index.d.ts +8 -0
- package/lib/services/po-theme/interfaces/po-theme.interface.d.ts +15 -0
- package/lib/services/po-theme/po-theme.service.d.ts +64 -0
- package/lib/services/po-user-guide/po-user-guide.service.d.ts +2 -0
- package/lib/utils/po-picker-mouse-down-guard.d.ts +27 -0
- package/lib/utils/util.d.ts +16 -0
- package/package.json +4 -4
- package/po-ui-ng-components-22.0.0.tgz +0 -0
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/setup-project.d.ts +2 -2
- package/schematics/ng-update/v14/index.js +1 -1
- package/schematics/ng-update/v15/index.js +1 -1
- package/schematics/ng-update/v16/index.js +1 -1
- package/schematics/ng-update/v17/index.js +1 -1
- package/schematics/ng-update/v18/index.d.ts +2 -2
- package/schematics/ng-update/v18/index.js +2 -2
- package/schematics/ng-update/v19/index.d.ts +2 -2
- package/schematics/ng-update/v19/index.js +2 -2
- package/schematics/ng-update/v2/index.js +1 -1
- package/schematics/ng-update/v20/index.d.ts +2 -2
- package/schematics/ng-update/v20/index.js +2 -2
- package/schematics/ng-update/v21/index.js +1 -1
- package/schematics/ng-update/v22/index.d.ts +20 -4
- package/schematics/ng-update/v22/index.js +37 -11
- package/schematics/ng-update/v22/index.js.map +1 -1
- package/schematics/ng-update/v22/migration-report.d.ts +36 -10
- package/schematics/ng-update/v22/migration-report.js +25 -11
- package/schematics/ng-update/v22/migration-report.js.map +1 -1
- package/schematics/ng-update/v22/theme-deprecated/changes.d.ts +24 -0
- package/schematics/ng-update/v22/theme-deprecated/changes.js +58 -0
- package/schematics/ng-update/v22/theme-deprecated/changes.js.map +1 -0
- package/schematics/ng-update/v22/theme-deprecated/index.d.ts +14 -0
- package/schematics/ng-update/v22/theme-deprecated/index.js +291 -0
- package/schematics/ng-update/v22/theme-deprecated/index.js.map +1 -0
- package/schematics/ng-update/v22/theme-deprecated/prompt.d.ts +49 -0
- package/schematics/ng-update/v22/theme-deprecated/prompt.js +59 -0
- package/schematics/ng-update/v22/theme-deprecated/prompt.js.map +1 -0
- package/schematics/ng-update/v22/theme-deprecated/theme-bootstrap-migration.d.ts +25 -0
- package/schematics/ng-update/v22/theme-deprecated/theme-bootstrap-migration.js +198 -0
- package/schematics/ng-update/v22/theme-deprecated/theme-bootstrap-migration.js.map +1 -0
- package/schematics/ng-update/v22/theme-deprecated/theme-style-migration.d.ts +23 -0
- package/schematics/ng-update/v22/theme-deprecated/theme-style-migration.js +64 -0
- package/schematics/ng-update/v22/theme-deprecated/theme-style-migration.js.map +1 -0
- package/schematics/ng-update/v22/theme-deprecated/theme-ts-migration.d.ts +29 -0
- package/schematics/ng-update/v22/theme-deprecated/theme-ts-migration.js +325 -0
- package/schematics/ng-update/v22/theme-deprecated/theme-ts-migration.js.map +1 -0
- package/schematics/ng-update/v22/theme-deprecated/ts-utils.d.ts +58 -0
- package/schematics/ng-update/v22/theme-deprecated/ts-utils.js +112 -0
- package/schematics/ng-update/v22/theme-deprecated/ts-utils.js.map +1 -0
- package/schematics/ng-update/v3/index.js +1 -1
- package/schematics/ng-update/v4/index.js +1 -1
- package/schematics/ng-update/v5/index.js +1 -1
- package/schematics/ng-update/v6/index.js +1 -1
- package/types/po-ui-ng-components.d.ts +18115 -17107
- package/po-ui-ng-components-22.0.0-rc.0.tgz +0 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.themeDeprecatedRule = themeDeprecatedRule;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@angular-devkit/core");
|
|
6
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
|
+
const project_1 = require("@po-ui/ng-schematics/project");
|
|
8
|
+
const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
|
|
9
|
+
const migration_report_1 = require("../migration-report");
|
|
10
|
+
const theme_bootstrap_migration_1 = require("./theme-bootstrap-migration");
|
|
11
|
+
const theme_style_migration_1 = require("./theme-style-migration");
|
|
12
|
+
const theme_ts_migration_1 = require("./theme-ts-migration");
|
|
13
|
+
const ts_utils_1 = require("./ts-utils");
|
|
14
|
+
const LOG_PREFIX = '[tema-anterior]';
|
|
15
|
+
const WORKSPACE_FILES = ['/angular.json', '/.angular.json'];
|
|
16
|
+
const STYLE_EXTENSIONS = ['.css', '.scss', '.sass', '.less'];
|
|
17
|
+
const IGNORED_DIRS = new Set(['node_modules', 'dist', '.angular', '.git']);
|
|
18
|
+
/** Rótulos do `Resumo_Migracao` específicos da migração do tema anterior. */
|
|
19
|
+
const THEME_SUMMARY_LABELS = {
|
|
20
|
+
summaryLine: (filesScanned, filesChanged) => `${LOG_PREFIX} ${filesScanned} arquivo(s) analisado(s), ${filesChanged} arquivo(s) alterado(s).`,
|
|
21
|
+
successLine: `${LOG_PREFIX} As constantes e os estilos foram reapontados para o tema anterior (depreciado).`,
|
|
22
|
+
emptyLine: `${LOG_PREFIX} Nenhuma referência ao tema padrão foi encontrada. Nenhum arquivo foi alterado.`,
|
|
23
|
+
warningsIntro: count => `${LOG_PREFIX} ${count} ocorrência(s) exigem revisão manual:`
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Regra da migração do tema anterior do PO UI (depreciado até a v24).
|
|
27
|
+
*
|
|
28
|
+
* Reaponta o projeto para o tema padrão anterior: constantes `*Deprecated`,
|
|
29
|
+
* arquivos CSS `-deprecated` do `@po-ui/style` e, nas aplicações que não usam o
|
|
30
|
+
* `PoThemeService`, a aplicação do tema anterior no componente principal.
|
|
31
|
+
*
|
|
32
|
+
* Diferente das demais migrações, esta regra NÃO é registrada no
|
|
33
|
+
* `migrations.json`: ela é composta na `chain` da `migration-v22` obrigatória,
|
|
34
|
+
* condicionada à resposta do desenvolvedor (ver `prompt.ts`). O gatilho e a
|
|
35
|
+
* guarda de execução em lote ficam a cargo de quem compõe a `chain`.
|
|
36
|
+
*/
|
|
37
|
+
function themeDeprecatedRule() {
|
|
38
|
+
return (tree, context) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const logger = context.logger;
|
|
41
|
+
const workspacePath = WORKSPACE_FILES.find(file => tree.exists(file));
|
|
42
|
+
const workspace = (0, project_1.getWorkspaceConfigGracefully)(tree);
|
|
43
|
+
if (!workspacePath || !workspace) {
|
|
44
|
+
logger.error(`${LOG_PREFIX} Não foi possível obter a configuração do workspace. Nenhum arquivo foi alterado.`);
|
|
45
|
+
return tree;
|
|
46
|
+
}
|
|
47
|
+
const report = (0, migration_report_1.createMigrationReport)();
|
|
48
|
+
const injectedProjects = [];
|
|
49
|
+
const projectsUsingService = [];
|
|
50
|
+
// Req. 4 — troca os CSS do `@po-ui/style` no `angular.json` (uma única vez).
|
|
51
|
+
writeResult(tree, workspacePath, readText(tree, workspacePath), theme_style_migration_1.migrateAngularJsonStyles, report, logger);
|
|
52
|
+
const visited = new Set();
|
|
53
|
+
for (const projectName of Object.keys((_a = workspace.projects) !== null && _a !== void 0 ? _a : {})) {
|
|
54
|
+
migrateProject(tree, workspace, projectName, visited, report, injectedProjects, projectsUsingService, logger);
|
|
55
|
+
}
|
|
56
|
+
printSummary(report, injectedProjects, projectsUsingService, logger);
|
|
57
|
+
return tree;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function migrateProject(tree, workspace, projectName, visited, report, injectedProjects, projectsUsingService, logger) {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const project = (0, project_1.getProjectFromWorkspace)(workspace, projectName);
|
|
63
|
+
if (!project) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const projectType = project.projectType === 'library' ? 'library' : 'application';
|
|
67
|
+
const sourceDir = (0, core_1.normalize)(`/${(_a = project.sourceRoot) !== null && _a !== void 0 ? _a : `${project.root ? `${project.root}/` : ''}src`}`);
|
|
68
|
+
const directory = tree.getDir(sourceDir);
|
|
69
|
+
if (directory.subfiles.length === 0 && directory.subdirs.length === 0) {
|
|
70
|
+
logger.warn(`${LOG_PREFIX} Projeto "${projectName}": o diretório "${sourceDir}" não existe ou está vazio.`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const ctx = { projectName, projectType, sourceDir, usesThemeService: false };
|
|
74
|
+
// Req. 3 / 4 — reescreve constantes nos `.ts` e CSS nos estilos.
|
|
75
|
+
scanDirectory(tree, sourceDir, ctx, visited, report, logger);
|
|
76
|
+
// Req. 7 — bibliotecas recebem apenas a reescrita de constantes/CSS.
|
|
77
|
+
if (projectType === 'library') {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Req. 6 — projeto que já usa o serviço: apenas reescrita, sem injeção.
|
|
81
|
+
if (ctx.usesThemeService) {
|
|
82
|
+
projectsUsingService.push(projectName);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Req. 5 — injeta o serviço e aplica o tema anterior no componente principal.
|
|
86
|
+
const bootstrap = findBootstrapComponent(tree, project, logger);
|
|
87
|
+
if ('reason' in bootstrap) {
|
|
88
|
+
report.warnings.push({
|
|
89
|
+
filePath: (_b = bootstrap.filePath) !== null && _b !== void 0 ? _b : ctx.sourceDir,
|
|
90
|
+
line: 1,
|
|
91
|
+
reason: `Projeto "${projectName}": ${bootstrap.reason} Para manter o tema anterior, chame ` +
|
|
92
|
+
`"setTheme(poThemeDefaultDeprecated)" do PoThemeService na inicialização da aplicação.`
|
|
93
|
+
});
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const changedBefore = report.filesChanged;
|
|
97
|
+
writeResult(tree, bootstrap.filePath, readText(tree, bootstrap.filePath), source => (0, theme_bootstrap_migration_1.injectDeprecatedTheme)(source, bootstrap.className), report, logger);
|
|
98
|
+
if (report.filesChanged > changedBefore) {
|
|
99
|
+
injectedProjects.push({ projectName, filePath: bootstrap.filePath });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Varredura recursiva do diretório-fonte de um `Projeto_Consumidor`.
|
|
104
|
+
*
|
|
105
|
+
* Processa `.ts` (exceto `.d.ts`) e arquivos de estilo, ignorando diretórios de
|
|
106
|
+
* build. Detecta uso do `PoThemeService` em `.ts` (exceto `.spec.ts`), contabiliza
|
|
107
|
+
* cada arquivo analisado e grava com `tree.overwrite` apenas quando o conteúdo
|
|
108
|
+
* muda. Compartilha arquivos já visitados entre projetos via `visited`.
|
|
109
|
+
*/
|
|
110
|
+
function scanDirectory(tree, dirPath, ctx, visited, report, logger) {
|
|
111
|
+
const directory = tree.getDir(dirPath);
|
|
112
|
+
directory.subfiles.forEach(file => {
|
|
113
|
+
const lower = file.toLowerCase();
|
|
114
|
+
const isTs = lower.endsWith('.ts') && !lower.endsWith('.d.ts');
|
|
115
|
+
const isStyle = STYLE_EXTENSIONS.some(ext => lower.endsWith(ext));
|
|
116
|
+
if (!isTs && !isStyle) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const filePath = `${directory.path}/${file}`;
|
|
120
|
+
const original = readText(tree, filePath);
|
|
121
|
+
if (isTs && !lower.endsWith('.spec.ts') && (0, theme_ts_migration_1.importsPoThemeService)(original)) {
|
|
122
|
+
ctx.usesThemeService = true;
|
|
123
|
+
}
|
|
124
|
+
if (visited.has(filePath)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
visited.add(filePath);
|
|
128
|
+
report.filesScanned++;
|
|
129
|
+
const migrate = isTs ? theme_ts_migration_1.migrateThemeTsContent : theme_style_migration_1.migrateStylesheetContent;
|
|
130
|
+
writeResult(tree, filePath, original, migrate, report, logger);
|
|
131
|
+
});
|
|
132
|
+
directory.subdirs.forEach(subdir => {
|
|
133
|
+
if (!IGNORED_DIRS.has(subdir)) {
|
|
134
|
+
scanDirectory(tree, `${directory.path}/${subdir}`, ctx, visited, report, logger);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/** Aplica a transformação e grava o arquivo somente quando o conteúdo mudou. */
|
|
139
|
+
function writeResult(tree, filePath, original, migrate, report, logger) {
|
|
140
|
+
var _a;
|
|
141
|
+
const result = migrate(original);
|
|
142
|
+
result.warnings.forEach((warning) => report.warnings.push(Object.assign(Object.assign({}, warning), { filePath })));
|
|
143
|
+
if (result.content === original) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
tree.overwrite(filePath, result.content);
|
|
148
|
+
report.filesChanged++;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
logger.error(`${LOG_PREFIX} Falha ao gravar "${filePath}". O conteúdo original foi preservado. ` +
|
|
152
|
+
`Detalhe: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Localiza o componente de bootstrap a partir do `main` do projeto:
|
|
157
|
+
* - standalone: primeiro argumento de `bootstrapApplication`;
|
|
158
|
+
* - NgModule: `bootstrap: [X]` do módulo passado a `bootstrapModule`.
|
|
159
|
+
*
|
|
160
|
+
* Usa `getProjectMainFile` para localizar o `main` e `isStandaloneApp` para
|
|
161
|
+
* determinar a arquitetura, seguindo o padrão da migração obrigatória da v22.
|
|
162
|
+
*/
|
|
163
|
+
function findBootstrapComponent(tree, project, logger) {
|
|
164
|
+
var _a;
|
|
165
|
+
let mainFile;
|
|
166
|
+
try {
|
|
167
|
+
mainFile = (0, core_1.normalize)(`/${(0, project_1.getProjectMainFile)(project)}`);
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
logger.warn(`${LOG_PREFIX} Não foi possível localizar o arquivo principal (main). Detalhe: ${(_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : error}`);
|
|
171
|
+
return { reason: 'não foi possível localizar o arquivo principal (main) no angular.json.' };
|
|
172
|
+
}
|
|
173
|
+
if (!tree.exists(mainFile)) {
|
|
174
|
+
return { reason: 'não foi possível localizar o arquivo principal (main) no angular.json.' };
|
|
175
|
+
}
|
|
176
|
+
const main = (0, ts_utils_1.parseSource)(readText(tree, mainFile), mainFile);
|
|
177
|
+
const call = findCall(main, ['bootstrapApplication', 'bootstrapModule']);
|
|
178
|
+
const argument = call === null || call === void 0 ? void 0 : call.arguments[0];
|
|
179
|
+
if (!call || !argument || !ts.isIdentifier(argument)) {
|
|
180
|
+
return { reason: 'não foi encontrada a chamada "bootstrapApplication" ou "bootstrapModule".', filePath: mainFile };
|
|
181
|
+
}
|
|
182
|
+
const declaringFile = resolveIdentifierFile(tree, main, mainFile, argument.text);
|
|
183
|
+
if (!declaringFile) {
|
|
184
|
+
return { reason: `não foi possível localizar o arquivo de "${argument.text}".`, filePath: mainFile };
|
|
185
|
+
}
|
|
186
|
+
let isModule;
|
|
187
|
+
try {
|
|
188
|
+
isModule = !(0, ng_ast_utils_1.isStandaloneApp)(tree, mainFile);
|
|
189
|
+
}
|
|
190
|
+
catch (_b) {
|
|
191
|
+
// Fallback determinístico pela própria chamada quando o utilitário falha.
|
|
192
|
+
const callee = call.expression;
|
|
193
|
+
isModule =
|
|
194
|
+
(ts.isPropertyAccessExpression(callee) ? callee.name.text : callee.text) === 'bootstrapModule';
|
|
195
|
+
}
|
|
196
|
+
if (!isModule) {
|
|
197
|
+
return { filePath: declaringFile, className: argument.text };
|
|
198
|
+
}
|
|
199
|
+
const moduleSource = (0, ts_utils_1.parseSource)(readText(tree, declaringFile), declaringFile);
|
|
200
|
+
const componentName = findModuleBootstrapComponent(moduleSource, argument.text);
|
|
201
|
+
if (!componentName) {
|
|
202
|
+
return { reason: `o módulo "${argument.text}" não declara um componente em "bootstrap".`, filePath: declaringFile };
|
|
203
|
+
}
|
|
204
|
+
const componentFile = resolveIdentifierFile(tree, moduleSource, declaringFile, componentName);
|
|
205
|
+
if (!componentFile) {
|
|
206
|
+
return { reason: `não foi possível localizar o arquivo de "${componentName}".`, filePath: declaringFile };
|
|
207
|
+
}
|
|
208
|
+
return { filePath: componentFile, className: componentName };
|
|
209
|
+
}
|
|
210
|
+
function findCall(sourceFile, names) {
|
|
211
|
+
let found;
|
|
212
|
+
const visit = (node) => {
|
|
213
|
+
if (found) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (ts.isCallExpression(node)) {
|
|
217
|
+
const callee = node.expression;
|
|
218
|
+
const name = ts.isIdentifier(callee)
|
|
219
|
+
? callee.text
|
|
220
|
+
: ts.isPropertyAccessExpression(callee)
|
|
221
|
+
? callee.name.text
|
|
222
|
+
: undefined;
|
|
223
|
+
if (name && names.includes(name)) {
|
|
224
|
+
found = node;
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
ts.forEachChild(node, visit);
|
|
229
|
+
};
|
|
230
|
+
visit(sourceFile);
|
|
231
|
+
return found;
|
|
232
|
+
}
|
|
233
|
+
/** Nome do primeiro componente em `bootstrap: [...]` do `@NgModule` informado. */
|
|
234
|
+
function findModuleBootstrapComponent(sourceFile, moduleName) {
|
|
235
|
+
var _a;
|
|
236
|
+
const moduleClass = sourceFile.statements.find((statement) => { var _a; return ts.isClassDeclaration(statement) && ((_a = statement.name) === null || _a === void 0 ? void 0 : _a.text) === moduleName; });
|
|
237
|
+
for (const decorator of (_a = (moduleClass && ts.getDecorators(moduleClass))) !== null && _a !== void 0 ? _a : []) {
|
|
238
|
+
const expression = decorator.expression;
|
|
239
|
+
const metadata = ts.isCallExpression(expression) ? expression.arguments[0] : undefined;
|
|
240
|
+
if (!metadata || !ts.isObjectLiteralExpression(metadata)) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
for (const property of metadata.properties) {
|
|
244
|
+
if (ts.isPropertyAssignment(property) &&
|
|
245
|
+
ts.isIdentifier(property.name) &&
|
|
246
|
+
property.name.text === 'bootstrap' &&
|
|
247
|
+
ts.isArrayLiteralExpression(property.initializer)) {
|
|
248
|
+
const first = property.initializer.elements[0];
|
|
249
|
+
return first && ts.isIdentifier(first) ? first.text : undefined;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Arquivo onde o identificador é declarado: o próprio arquivo, quando a classe
|
|
257
|
+
* está nele, ou o import relativo correspondente.
|
|
258
|
+
*/
|
|
259
|
+
function resolveIdentifierFile(tree, sourceFile, filePath, name) {
|
|
260
|
+
var _a;
|
|
261
|
+
const declaredHere = sourceFile.statements.some(statement => { var _a; return ts.isClassDeclaration(statement) && ((_a = statement.name) === null || _a === void 0 ? void 0 : _a.text) === name; });
|
|
262
|
+
if (declaredHere) {
|
|
263
|
+
return filePath;
|
|
264
|
+
}
|
|
265
|
+
for (const statement of sourceFile.statements) {
|
|
266
|
+
if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) {
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const bindings = (_a = statement.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings;
|
|
270
|
+
const imported = bindings && ts.isNamedImports(bindings) && bindings.elements.some(element => element.name.text === name);
|
|
271
|
+
const specifier = statement.moduleSpecifier.text;
|
|
272
|
+
if (imported && specifier.startsWith('.')) {
|
|
273
|
+
const base = (0, core_1.normalize)(`${filePath.slice(0, filePath.lastIndexOf('/'))}/${specifier}`);
|
|
274
|
+
return [`${base}.ts`, `${base}/index.ts`, base].find(candidate => candidate.endsWith('.ts') && tree.exists(candidate));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return undefined;
|
|
278
|
+
}
|
|
279
|
+
function readText(tree, filePath) {
|
|
280
|
+
var _a, _b;
|
|
281
|
+
return (_b = (_a = tree.read(filePath)) === null || _a === void 0 ? void 0 : _a.toString('utf-8')) !== null && _b !== void 0 ? _b : '';
|
|
282
|
+
}
|
|
283
|
+
function printSummary(report, injectedProjects, projectsUsingService, logger) {
|
|
284
|
+
// Resumo padronizado (compartilhado com a migração obrigatória da v22).
|
|
285
|
+
(0, migration_report_1.printMigrationSummary)(report, logger, THEME_SUMMARY_LABELS);
|
|
286
|
+
injectedProjects.forEach(({ projectName, filePath }) => logger.info(`${LOG_PREFIX} Projeto "${projectName}": tema anterior aplicado em "${filePath}".`));
|
|
287
|
+
projectsUsingService.forEach(projectName => logger.info(`${LOG_PREFIX} Projeto "${projectName}": já usa o PoThemeService. As constantes foram reapontadas, ` +
|
|
288
|
+
`sem injeção no componente principal.`));
|
|
289
|
+
logger.info(`${LOG_PREFIX} O tema anterior está depreciado e será removido na v24.`);
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../projects/ui/schematics/ng-update/v22/theme-deprecated/index.ts"],"names":[],"mappings":";;AAiEA,kDA4BC;;AA7FD,+CAA0D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,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CACjE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,QAAgB;;IAC5C,OAAO,MAAA,MAAA,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,mCAAI,EAAE,CAAC;AACtD,CAAC;AAED,SAAS,YAAY,CACnB,MAAuB,EACvB,gBAAkE,EAClE,oBAAmC,EACnC,MAAyB;IAEzB,wEAAwE;IACxE,IAAA,wCAAqB,EAAC,MAAM,EAAE,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAE5D,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE,CACrD,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,aAAa,WAAW,iCAAiC,QAAQ,IAAI,CAAC,CAChG,CAAC;IAEF,oBAAoB,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CACzC,MAAM,CAAC,IAAI,CACT,GAAG,UAAU,aAAa,WAAW,+DAA+D;QAClG,sCAAsC,CACzC,CACF,CAAC;IAEF,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,0DAA0D,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Texto da pergunta apresentada no `ng update`. Deixa explícito que o tema novo
|
|
3
|
+
* é o recomendado e que o anterior está depreciado e será removido na v24. A
|
|
4
|
+
* resposta padrão (vazia) é "Não".
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEPRECATED_THEME_QUESTION: string;
|
|
7
|
+
/** Interface mínima de leitura de uma linha do terminal. */
|
|
8
|
+
export interface LineReader {
|
|
9
|
+
/** Faz a pergunta e invoca `callback` com a resposta. */
|
|
10
|
+
question(query: string, callback: (answer: string) => void): void;
|
|
11
|
+
/** Encerra a interface de leitura. */
|
|
12
|
+
close(): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Dependências injetáveis do prompt, com defaults de produção. Facilita o teste
|
|
16
|
+
* sem depender de espionar o módulo `readline` (não gravável em CommonJS).
|
|
17
|
+
*/
|
|
18
|
+
export interface PromptDeps {
|
|
19
|
+
/** Indica se há terminal interativo (`stdin` e `stdout` TTY, fora de CI). */
|
|
20
|
+
isTTY: () => boolean;
|
|
21
|
+
/** Cria o leitor de linha ligado ao `stdin`/`stdout`. */
|
|
22
|
+
createReader: () => LineReader;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Indica se há um terminal realmente interativo: o `stdin` precisa aceitar
|
|
26
|
+
* resposta e o `stdout` precisa exibir a pergunta. Com a saída redirecionada
|
|
27
|
+
* (`ng update ... > log.txt`) ou em CI, a pergunta ficaria invisível e a execução
|
|
28
|
+
* pararia aguardando o Enter, então tratamos como execução em lote.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isInteractiveTerminal(stdin?: {
|
|
31
|
+
isTTY?: boolean;
|
|
32
|
+
}, stdout?: {
|
|
33
|
+
isTTY?: boolean;
|
|
34
|
+
}, env?: NodeJS.ProcessEnv): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Pergunta ao desenvolvedor se deseja retornar ao tema anterior (depreciado).
|
|
37
|
+
*
|
|
38
|
+
* Comportamento:
|
|
39
|
+
* - Resposta padrão é "Não": somente respostas afirmativas explícitas
|
|
40
|
+
* (`s`/`sim`/`y`/`yes`) resolvem `true`; vazio ou qualquer outra entrada
|
|
41
|
+
* resolve `false`.
|
|
42
|
+
* - Em ambiente SEM TTY (lote/CI), resolve `false` imediatamente, sem criar o
|
|
43
|
+
* leitor de linha. Isso honra o padrão "sem interação = não voltar ao tema
|
|
44
|
+
* antigo" e evita o deadlock histórico do `readline` dentro do `ng update`
|
|
45
|
+
* quando o `stdin` não é interativo.
|
|
46
|
+
*
|
|
47
|
+
* As dependências (`deps`) têm defaults de produção e só são informadas em teste.
|
|
48
|
+
*/
|
|
49
|
+
export declare function askReturnToDeprecatedTheme(deps?: PromptDeps): Promise<boolean>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEPRECATED_THEME_QUESTION = void 0;
|
|
4
|
+
exports.isInteractiveTerminal = isInteractiveTerminal;
|
|
5
|
+
exports.askReturnToDeprecatedTheme = askReturnToDeprecatedTheme;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const readline = tslib_1.__importStar(require("readline"));
|
|
8
|
+
/**
|
|
9
|
+
* Texto da pergunta apresentada no `ng update`. Deixa explícito que o tema novo
|
|
10
|
+
* é o recomendado e que o anterior está depreciado e será removido na v24. A
|
|
11
|
+
* resposta padrão (vazia) é "Não".
|
|
12
|
+
*/
|
|
13
|
+
exports.DEPRECATED_THEME_QUESTION = 'A v22 do @po-ui/ng-components traz uma nova experiência visual padrão e recomendamos utilizá-la. ' +
|
|
14
|
+
'O tema anterior continua disponível como depreciado até sua remoção na v24. ' +
|
|
15
|
+
'Deseja retornar ao tema anterior (depreciado)? (s/N) ';
|
|
16
|
+
/** Respostas afirmativas aceitas (comparação case-insensitive, já em trim). */
|
|
17
|
+
const AFFIRMATIVE_ANSWERS = new Set(['s', 'sim', 'y', 'yes']);
|
|
18
|
+
/**
|
|
19
|
+
* Indica se há um terminal realmente interativo: o `stdin` precisa aceitar
|
|
20
|
+
* resposta e o `stdout` precisa exibir a pergunta. Com a saída redirecionada
|
|
21
|
+
* (`ng update ... > log.txt`) ou em CI, a pergunta ficaria invisível e a execução
|
|
22
|
+
* pararia aguardando o Enter, então tratamos como execução em lote.
|
|
23
|
+
*/
|
|
24
|
+
function isInteractiveTerminal(stdin = process.stdin, stdout = process.stdout, env = process.env) {
|
|
25
|
+
const isCI = Boolean(env['CI']) && env['CI'] !== 'false' && env['CI'] !== '0';
|
|
26
|
+
return Boolean(stdin.isTTY) && Boolean(stdout.isTTY) && !isCI;
|
|
27
|
+
}
|
|
28
|
+
const defaultDeps = {
|
|
29
|
+
isTTY: () => isInteractiveTerminal(),
|
|
30
|
+
createReader: () => readline.createInterface({ input: process.stdin, output: process.stdout })
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Pergunta ao desenvolvedor se deseja retornar ao tema anterior (depreciado).
|
|
34
|
+
*
|
|
35
|
+
* Comportamento:
|
|
36
|
+
* - Resposta padrão é "Não": somente respostas afirmativas explícitas
|
|
37
|
+
* (`s`/`sim`/`y`/`yes`) resolvem `true`; vazio ou qualquer outra entrada
|
|
38
|
+
* resolve `false`.
|
|
39
|
+
* - Em ambiente SEM TTY (lote/CI), resolve `false` imediatamente, sem criar o
|
|
40
|
+
* leitor de linha. Isso honra o padrão "sem interação = não voltar ao tema
|
|
41
|
+
* antigo" e evita o deadlock histórico do `readline` dentro do `ng update`
|
|
42
|
+
* quando o `stdin` não é interativo.
|
|
43
|
+
*
|
|
44
|
+
* As dependências (`deps`) têm defaults de produção e só são informadas em teste.
|
|
45
|
+
*/
|
|
46
|
+
function askReturnToDeprecatedTheme(deps = defaultDeps) {
|
|
47
|
+
// Sem TTY: não há como interagir. Mantém o padrão "Não" sem criar o leitor.
|
|
48
|
+
if (!deps.isTTY()) {
|
|
49
|
+
return Promise.resolve(false);
|
|
50
|
+
}
|
|
51
|
+
const reader = deps.createReader();
|
|
52
|
+
return new Promise(resolve => {
|
|
53
|
+
reader.question(exports.DEPRECATED_THEME_QUESTION, (answer) => {
|
|
54
|
+
reader.close();
|
|
55
|
+
resolve(AFFIRMATIVE_ANSWERS.has((answer !== null && answer !== void 0 ? answer : '').trim().toLowerCase()));
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot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E,CAAC;IAEnC,OAAO,IAAI,OAAO,CAAU,OAAO,CAAC,EAAE;QACpC,MAAM,CAAC,QAAQ,CAAC,iCAAyB,EAAE,CAAC,MAAc,EAAE,EAAE;YAC5D,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ThemeMigrationResult } from './ts-utils';
|
|
2
|
+
/** Comentário inserido antes da chamada, para facilitar a volta ao novo tema. */
|
|
3
|
+
export declare const DEPRECATED_THEME_COMMENT = "// Tema anterior do PO UI (depreciado, remo\u00E7\u00E3o na v24). Remova esta chamada para usar o novo tema padr\u00E3o.";
|
|
4
|
+
/**
|
|
5
|
+
* Injeta o `PoThemeService` no componente principal e aplica o tema anterior
|
|
6
|
+
* (`poThemeDefaultDeprecated`) no construtor.
|
|
7
|
+
*
|
|
8
|
+
* - Adiciona os imports de `inject` (`@angular/core`) e de `PoThemeService` e
|
|
9
|
+
* `poThemeDefaultDeprecated` (`@po-ui/ng-components`), reaproveitando os já
|
|
10
|
+
* existentes (inclusive com alias).
|
|
11
|
+
* - Adiciona o campo `private readonly poThemeService = inject(PoThemeService);`
|
|
12
|
+
* no início da classe.
|
|
13
|
+
* - Insere a chamada `this.poThemeService.setTheme(poThemeDefaultDeprecated);`
|
|
14
|
+
* no início do construtor, logo após o `super()`, se houver. Sem construtor,
|
|
15
|
+
* cria um após as propriedades da classe.
|
|
16
|
+
*
|
|
17
|
+
* Não altera o arquivo quando a chamada já existe (idempotência) e devolve uma
|
|
18
|
+
* advertência quando não encontra a classe com `@Component` ou quando a classe
|
|
19
|
+
* já possui um membro `poThemeService`.
|
|
20
|
+
*
|
|
21
|
+
* @param source Conteúdo do arquivo do componente.
|
|
22
|
+
* @param className Nome da classe do componente principal. Sem ele, usa a
|
|
23
|
+
* primeira classe com `@Component` do arquivo.
|
|
24
|
+
*/
|
|
25
|
+
export declare function injectDeprecatedTheme(source: string, className?: string): ThemeMigrationResult;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEPRECATED_THEME_COMMENT = void 0;
|
|
4
|
+
exports.injectDeprecatedTheme = injectDeprecatedTheme;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
|
+
const changes_1 = require("./changes");
|
|
8
|
+
const ts_utils_1 = require("./ts-utils");
|
|
9
|
+
const ANGULAR_CORE = '@angular/core';
|
|
10
|
+
const SERVICE_FIELD = 'poThemeService';
|
|
11
|
+
/** Comentário inserido antes da chamada, para facilitar a volta ao novo tema. */
|
|
12
|
+
exports.DEPRECATED_THEME_COMMENT = '// Tema anterior do PO UI (depreciado, remoção na v24). Remova esta chamada para usar o novo tema padrão.';
|
|
13
|
+
/**
|
|
14
|
+
* Injeta o `PoThemeService` no componente principal e aplica o tema anterior
|
|
15
|
+
* (`poThemeDefaultDeprecated`) no construtor.
|
|
16
|
+
*
|
|
17
|
+
* - Adiciona os imports de `inject` (`@angular/core`) e de `PoThemeService` e
|
|
18
|
+
* `poThemeDefaultDeprecated` (`@po-ui/ng-components`), reaproveitando os já
|
|
19
|
+
* existentes (inclusive com alias).
|
|
20
|
+
* - Adiciona o campo `private readonly poThemeService = inject(PoThemeService);`
|
|
21
|
+
* no início da classe.
|
|
22
|
+
* - Insere a chamada `this.poThemeService.setTheme(poThemeDefaultDeprecated);`
|
|
23
|
+
* no início do construtor, logo após o `super()`, se houver. Sem construtor,
|
|
24
|
+
* cria um após as propriedades da classe.
|
|
25
|
+
*
|
|
26
|
+
* Não altera o arquivo quando a chamada já existe (idempotência) e devolve uma
|
|
27
|
+
* advertência quando não encontra a classe com `@Component` ou quando a classe
|
|
28
|
+
* já possui um membro `poThemeService`.
|
|
29
|
+
*
|
|
30
|
+
* @param source Conteúdo do arquivo do componente.
|
|
31
|
+
* @param className Nome da classe do componente principal. Sem ele, usa a
|
|
32
|
+
* primeira classe com `@Component` do arquivo.
|
|
33
|
+
*/
|
|
34
|
+
function injectDeprecatedTheme(source, className) {
|
|
35
|
+
var _a;
|
|
36
|
+
const sourceFile = (0, ts_utils_1.parseSource)(source);
|
|
37
|
+
const component = findComponentClass(sourceFile, className);
|
|
38
|
+
if (!component) {
|
|
39
|
+
const target = className ? `a classe "${className}" com @Component` : 'uma classe com @Component';
|
|
40
|
+
return warn(source, 1, `Não foi possível localizar ${target}. Aplique o tema anterior manualmente.`);
|
|
41
|
+
}
|
|
42
|
+
const deprecatedLocal = (0, ts_utils_1.findLocalImportName)(sourceFile, changes_1.PO_UI_PACKAGE, changes_1.PO_THEME_DEFAULT_DEPRECATED);
|
|
43
|
+
if (deprecatedLocal && callsSetThemeWith(component, deprecatedLocal)) {
|
|
44
|
+
return { content: source, changed: false, warnings: [] };
|
|
45
|
+
}
|
|
46
|
+
if (component.members.some(member => member.name && ts.isIdentifier(member.name) && member.name.text === SERVICE_FIELD)) {
|
|
47
|
+
return warn(source, lineOfNode(sourceFile, component), `A classe "${(_a = component.name) === null || _a === void 0 ? void 0 : _a.text}" já possui o membro "${SERVICE_FIELD}". Aplique o tema anterior manualmente.`);
|
|
48
|
+
}
|
|
49
|
+
const edits = [];
|
|
50
|
+
const names = addImports(sourceFile, edits);
|
|
51
|
+
const indent = detectMemberIndent(sourceFile, component);
|
|
52
|
+
const innerIndent = indent + (indent || ' ');
|
|
53
|
+
const call = `this.${SERVICE_FIELD}.setTheme(${names.deprecated});`;
|
|
54
|
+
const field = `private readonly ${SERVICE_FIELD} = ${names.inject}(${names.service});`;
|
|
55
|
+
const openBrace = component.members.pos;
|
|
56
|
+
const constructorDecl = component.members.find(ts.isConstructorDeclaration);
|
|
57
|
+
if (constructorDecl === null || constructorDecl === void 0 ? void 0 : constructorDecl.body) {
|
|
58
|
+
edits.push({ start: openBrace, end: openBrace, text: `\n${indent}${field}\n` });
|
|
59
|
+
edits.push(constructorCallEdit(sourceFile, constructorDecl.body, indent, innerIndent, call));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const ctor = [
|
|
63
|
+
`${indent}constructor() {`,
|
|
64
|
+
`${innerIndent}${exports.DEPRECATED_THEME_COMMENT}`,
|
|
65
|
+
`${innerIndent}${call}`,
|
|
66
|
+
`${indent}}`
|
|
67
|
+
].join('\n');
|
|
68
|
+
const lastProperty = lastLeadingProperty(component);
|
|
69
|
+
const closeBrace = component.getEnd() - 1;
|
|
70
|
+
if (lastProperty) {
|
|
71
|
+
edits.push({ start: openBrace, end: openBrace, text: `\n${indent}${field}\n` });
|
|
72
|
+
edits.push({ start: lastProperty.getEnd(), end: lastProperty.getEnd(), text: `\n\n${ctor}` });
|
|
73
|
+
}
|
|
74
|
+
else if (component.members.length === 0 && isBlank(source, openBrace, closeBrace)) {
|
|
75
|
+
const classIndent = indentationAt(source, component.getStart(sourceFile));
|
|
76
|
+
edits.push({ start: openBrace, end: closeBrace, text: `\n${indent}${field}\n\n${ctor}\n${classIndent}` });
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
edits.push({ start: openBrace, end: openBrace, text: `\n${indent}${field}\n\n${ctor}\n` });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const content = (0, ts_utils_1.applyEdits)(source, edits);
|
|
83
|
+
return { content, changed: content !== source, warnings: [] };
|
|
84
|
+
}
|
|
85
|
+
/** Localiza a classe com `@Component` (opcionalmente pelo nome). */
|
|
86
|
+
function findComponentClass(sourceFile, className) {
|
|
87
|
+
return sourceFile.statements.find((statement) => {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
return ts.isClassDeclaration(statement) &&
|
|
90
|
+
(!className || ((_a = statement.name) === null || _a === void 0 ? void 0 : _a.text) === className) &&
|
|
91
|
+
((_b = ts.getDecorators(statement)) !== null && _b !== void 0 ? _b : []).some(decorator => ts.isCallExpression(decorator.expression) &&
|
|
92
|
+
ts.isIdentifier(decorator.expression.expression) &&
|
|
93
|
+
decorator.expression.expression.text === 'Component');
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/** Indica se a classe já chama `.setTheme(<deprecated>...)`. */
|
|
97
|
+
function callsSetThemeWith(component, deprecatedLocal) {
|
|
98
|
+
let found = false;
|
|
99
|
+
const visit = (node) => {
|
|
100
|
+
if (ts.isCallExpression(node) &&
|
|
101
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
102
|
+
node.expression.name.text === 'setTheme' &&
|
|
103
|
+
node.arguments[0] &&
|
|
104
|
+
ts.isIdentifier(node.arguments[0]) &&
|
|
105
|
+
node.arguments[0].text === deprecatedLocal) {
|
|
106
|
+
found = true;
|
|
107
|
+
}
|
|
108
|
+
if (!found) {
|
|
109
|
+
ts.forEachChild(node, visit);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
visit(component);
|
|
113
|
+
return found;
|
|
114
|
+
}
|
|
115
|
+
/** Garante os imports necessários e devolve os nomes locais a usar. */
|
|
116
|
+
function addImports(sourceFile, edits) {
|
|
117
|
+
const injectLocal = (0, ts_utils_1.findLocalImportName)(sourceFile, ANGULAR_CORE, 'inject');
|
|
118
|
+
const serviceLocal = (0, ts_utils_1.findLocalImportName)(sourceFile, changes_1.PO_UI_PACKAGE, changes_1.PO_THEME_SERVICE);
|
|
119
|
+
const deprecatedLocal = (0, ts_utils_1.findLocalImportName)(sourceFile, changes_1.PO_UI_PACKAGE, changes_1.PO_THEME_DEFAULT_DEPRECATED);
|
|
120
|
+
const missing = [
|
|
121
|
+
{ moduleName: ANGULAR_CORE, names: injectLocal ? [] : ['inject'] },
|
|
122
|
+
{
|
|
123
|
+
moduleName: changes_1.PO_UI_PACKAGE,
|
|
124
|
+
names: [...(serviceLocal ? [] : [changes_1.PO_THEME_SERVICE]), ...(deprecatedLocal ? [] : [changes_1.PO_THEME_DEFAULT_DEPRECATED])]
|
|
125
|
+
}
|
|
126
|
+
];
|
|
127
|
+
const newLines = [];
|
|
128
|
+
for (const item of missing.filter(entry => entry.names.length > 0)) {
|
|
129
|
+
const named = (0, ts_utils_1.collectImports)(sourceFile, item.moduleName)
|
|
130
|
+
.map(ts_utils_1.getNamedImports)
|
|
131
|
+
.find(bindings => bindings && bindings.elements.length > 0);
|
|
132
|
+
if (named) {
|
|
133
|
+
edits.push((0, ts_utils_1.appendSpecifiersEdit)(named, item.names));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
newLines.push(item);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (newLines.length > 0) {
|
|
140
|
+
edits.push((0, ts_utils_1.addImportLinesEdit)(sourceFile, newLines));
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
inject: injectLocal !== null && injectLocal !== void 0 ? injectLocal : 'inject',
|
|
144
|
+
service: serviceLocal !== null && serviceLocal !== void 0 ? serviceLocal : changes_1.PO_THEME_SERVICE,
|
|
145
|
+
deprecated: deprecatedLocal !== null && deprecatedLocal !== void 0 ? deprecatedLocal : changes_1.PO_THEME_DEFAULT_DEPRECATED
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/** Edição que insere a chamada no construtor (após o `super()`, se houver). */
|
|
149
|
+
function constructorCallEdit(sourceFile, body, indent, innerIndent, call) {
|
|
150
|
+
const text = `\n${innerIndent}${exports.DEPRECATED_THEME_COMMENT}\n${innerIndent}${call}`;
|
|
151
|
+
const superCall = body.statements.find(statement => ts.isExpressionStatement(statement) &&
|
|
152
|
+
ts.isCallExpression(statement.expression) &&
|
|
153
|
+
statement.expression.expression.kind === ts.SyntaxKind.SuperKeyword);
|
|
154
|
+
if (superCall) {
|
|
155
|
+
return { start: superCall.getEnd(), end: superCall.getEnd(), text };
|
|
156
|
+
}
|
|
157
|
+
const open = body.getStart(sourceFile) + 1;
|
|
158
|
+
const close = body.getEnd() - 1;
|
|
159
|
+
if (body.statements.length === 0 && isBlank(sourceFile.getFullText(), open, close)) {
|
|
160
|
+
return { start: open, end: close, text: `${text}\n${indent}` };
|
|
161
|
+
}
|
|
162
|
+
return { start: open, end: open, text };
|
|
163
|
+
}
|
|
164
|
+
/** Última propriedade de um bloco contínuo de propriedades no início da classe. */
|
|
165
|
+
function lastLeadingProperty(component) {
|
|
166
|
+
let last;
|
|
167
|
+
for (const member of component.members) {
|
|
168
|
+
if (!ts.isPropertyDeclaration(member)) {
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
last = member;
|
|
172
|
+
}
|
|
173
|
+
return last;
|
|
174
|
+
}
|
|
175
|
+
/** Indentação dos membros da classe (padrão: 2 espaços a partir da classe). */
|
|
176
|
+
function detectMemberIndent(sourceFile, component) {
|
|
177
|
+
const text = sourceFile.getFullText();
|
|
178
|
+
const reference = component.members[0];
|
|
179
|
+
if (reference) {
|
|
180
|
+
return indentationAt(text, reference.getStart(sourceFile));
|
|
181
|
+
}
|
|
182
|
+
return `${indentationAt(text, component.getStart(sourceFile))} `;
|
|
183
|
+
}
|
|
184
|
+
function indentationAt(text, position) {
|
|
185
|
+
const lineStart = text.lastIndexOf('\n', position - 1) + 1;
|
|
186
|
+
const match = /^[ \t]*/.exec(text.slice(lineStart, position));
|
|
187
|
+
return match ? match[0] : '';
|
|
188
|
+
}
|
|
189
|
+
function isBlank(text, start, end) {
|
|
190
|
+
return text.slice(start, end).trim() === '';
|
|
191
|
+
}
|
|
192
|
+
function lineOfNode(sourceFile, node) {
|
|
193
|
+
return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;
|
|
194
|
+
}
|
|
195
|
+
function warn(source, line, reason) {
|
|
196
|
+
return { content: source, changed: false, warnings: [{ filePath: '', line, reason }] };
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=theme-bootstrap-migration.js.map
|