@public-ui/visual-tests 1.7.0-rc.8 → 1.7.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 +25 -140
- package/package.json +48 -45
- package/playwright.config.js +59 -0
- package/src/index.js +80 -0
- package/tests/axe-snapshots.spec.js +82 -0
- package/tests/sample-app.routes.js +387 -0
- package/tests/theme-snapshots.spec.js +70 -0
- package/src/index.ts +0 -33
- package/src/migrate/index.ts +0 -127
- package/src/migrate/runner/abstract-task.ts +0 -64
- package/src/migrate/runner/task-runner.ts +0 -163
- package/src/migrate/runner/tasks/common/GenericRenamePropertyTask.ts +0 -85
- package/src/migrate/runner/tasks/common/LabelExpertSlot.ts +0 -96
- package/src/migrate/runner/tasks/common/RemovePropertyNameTask.ts +0 -104
- package/src/migrate/runner/tasks/common/RenamePropertyNameTask.ts +0 -31
- package/src/migrate/runner/tasks/test/index.ts +0 -16
- package/src/migrate/runner/tasks/test/test-dummy.ts +0 -20
- package/src/migrate/runner/tasks/test/test-version-1.3.ts +0 -7
- package/src/migrate/runner/tasks/test/test-version-current.ts +0 -7
- package/src/migrate/runner/tasks/test/test-version-next-2.ts +0 -7
- package/src/migrate/runner/tasks/test/test-version-next-3.ts +0 -7
- package/src/migrate/runner/tasks/test/test-version-zero.ts +0 -7
- package/src/migrate/runner/tasks/v1/abbr.ts +0 -3
- package/src/migrate/runner/tasks/v1/accordion.ts +0 -3
- package/src/migrate/runner/tasks/v1/badge.ts +0 -6
- package/src/migrate/runner/tasks/v1/breadcrumb.ts +0 -3
- package/src/migrate/runner/tasks/v1/button-link.ts +0 -6
- package/src/migrate/runner/tasks/v1/button.ts +0 -8
- package/src/migrate/runner/tasks/v1/card.ts +0 -4
- package/src/migrate/runner/tasks/v1/details.ts +0 -3
- package/src/migrate/runner/tasks/v1/icon.ts +0 -5
- package/src/migrate/runner/tasks/v1/index.ts +0 -151
- package/src/migrate/runner/tasks/v1/input-checkbox.ts +0 -3
- package/src/migrate/runner/tasks/v1/input-color.ts +0 -3
- package/src/migrate/runner/tasks/v1/input-date.ts +0 -3
- package/src/migrate/runner/tasks/v1/input-email.ts +0 -3
- package/src/migrate/runner/tasks/v1/input-number.ts +0 -4
- package/src/migrate/runner/tasks/v1/input-radio.ts +0 -3
- package/src/migrate/runner/tasks/v1/input-range.ts +0 -3
- package/src/migrate/runner/tasks/v1/input-text.ts +0 -3
- package/src/migrate/runner/tasks/v1/link-button.ts +0 -15
- package/src/migrate/runner/tasks/v1/link-group.ts +0 -7
- package/src/migrate/runner/tasks/v1/link.ts +0 -15
- package/src/migrate/runner/tasks/v1/logo.ts +0 -3
- package/src/migrate/runner/tasks/v1/modal.ts +0 -3
- package/src/migrate/runner/tasks/v1/nav.ts +0 -7
- package/src/migrate/runner/tasks/v1/pagination.ts +0 -3
- package/src/migrate/runner/tasks/v1/progress.ts +0 -3
- package/src/migrate/runner/tasks/v1/quote.ts +0 -3
- package/src/migrate/runner/tasks/v1/select.ts +0 -4
- package/src/migrate/runner/tasks/v1/skip-nav.ts +0 -3
- package/src/migrate/runner/tasks/v1/span.ts +0 -3
- package/src/migrate/runner/tasks/v1/split-button.ts +0 -3
- package/src/migrate/runner/tasks/v1/table.ts +0 -3
- package/src/migrate/runner/tasks/v1/tabs.ts +0 -4
- package/src/migrate/runner/tasks/v1/toast.ts +0 -3
- package/src/migrate/runner/tasks/v1/version.ts +0 -3
- package/src/migrate/runner/types.ts +0 -2
- package/src/migrate/shares/reuse.ts +0 -182
- package/src/migrate/types.ts +0 -2
- package/src/types.ts +0 -23
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import semver from 'semver';
|
|
5
|
-
|
|
6
|
-
import { Configuration } from '../../types';
|
|
7
|
-
import { logAndCreateError } from '../shares/reuse';
|
|
8
|
-
import { AbstractTask } from './abstract-task';
|
|
9
|
-
|
|
10
|
-
export class TaskRunner {
|
|
11
|
-
private readonly tasks: Map<string, AbstractTask> = new Map();
|
|
12
|
-
private baseDir: string = '/';
|
|
13
|
-
private cliVersion: string = '0.0.0';
|
|
14
|
-
private projectVersion: string = '0.0.0';
|
|
15
|
-
private readonly config: Configuration = {
|
|
16
|
-
migrate: {
|
|
17
|
-
tasks: {},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
public constructor(baseDir: string, cliVersion: string, projectVersion: string, config: Configuration) {
|
|
22
|
-
this.setBaseDir(baseDir);
|
|
23
|
-
this.setCliVersion(cliVersion);
|
|
24
|
-
this.setProjectVersion(projectVersion);
|
|
25
|
-
this.setConfig(config);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
private setBaseDir(baseDir: string): void {
|
|
29
|
-
if (!fs.existsSync(path.resolve(process.cwd(), baseDir))) {
|
|
30
|
-
throw logAndCreateError(`Base directory "${baseDir}" does not exist`);
|
|
31
|
-
}
|
|
32
|
-
this.baseDir = baseDir;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private setCliVersion(version: string): void {
|
|
36
|
-
if (semver.valid(version) === null) {
|
|
37
|
-
throw logAndCreateError(`Invalid CLI version: ${version}`);
|
|
38
|
-
}
|
|
39
|
-
this.cliVersion = version;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public setProjectVersion(version: string): void {
|
|
43
|
-
if (semver.valid(version) === null) {
|
|
44
|
-
throw logAndCreateError(`Invalid project version: ${version}`);
|
|
45
|
-
}
|
|
46
|
-
if (this.projectVersion !== version) {
|
|
47
|
-
this.projectVersion = version;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private setConfig(config: Configuration): void {
|
|
52
|
-
if (config.migrate?.tasks) {
|
|
53
|
-
this.config.migrate!.tasks = {
|
|
54
|
-
...this.config.migrate!.tasks,
|
|
55
|
-
...config.migrate?.tasks,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public registerTasks(tasks: AbstractTask[]): void {
|
|
61
|
-
tasks.forEach((task) => {
|
|
62
|
-
if (
|
|
63
|
-
semver.gtr(this.projectVersion, task.getVersionRange(), {
|
|
64
|
-
includePrerelease: true,
|
|
65
|
-
})
|
|
66
|
-
) {
|
|
67
|
-
console.log(
|
|
68
|
-
`Task "${task.getTitle()}" will be excluded. The current version (${
|
|
69
|
-
this.projectVersion
|
|
70
|
-
}) is greater than the task version range (${task.getVersionRange()}).`,
|
|
71
|
-
);
|
|
72
|
-
this.config.migrate!.tasks[task.getIdentifier()] = false;
|
|
73
|
-
} else {
|
|
74
|
-
this.tasks.set(task.getIdentifier(), task);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private registerTask(task: AbstractTask): void {
|
|
80
|
-
this.registerTasks([task]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private runTask(task: AbstractTask): void {
|
|
84
|
-
if (this.config.migrate?.tasks[task.getIdentifier()] === false) {
|
|
85
|
-
task.setStatus('skipped');
|
|
86
|
-
} else {
|
|
87
|
-
this.config.migrate!.tasks[task.getIdentifier()] = true;
|
|
88
|
-
if (
|
|
89
|
-
task.getStatus() === 'pending' &&
|
|
90
|
-
semver.satisfies(this.projectVersion, task.getVersionRange(), {
|
|
91
|
-
includePrerelease: true,
|
|
92
|
-
})
|
|
93
|
-
) {
|
|
94
|
-
// task.setStatus('running'); only of the task is async
|
|
95
|
-
if (!this.tasks.has(task.getIdentifier())) {
|
|
96
|
-
this.registerTask(task);
|
|
97
|
-
}
|
|
98
|
-
task.run(this.baseDir);
|
|
99
|
-
task.setStatus('done');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
private dependentTaskRun(task: AbstractTask, dependentTasks: AbstractTask[]) {
|
|
105
|
-
dependentTasks.forEach((dependentTask) => {
|
|
106
|
-
this.dependentTaskRun(dependentTask, dependentTask.getDependentTasks());
|
|
107
|
-
});
|
|
108
|
-
if (dependentTasks.every((dependentTask) => dependentTask.getStatus() === 'done')) {
|
|
109
|
-
this.runTask(task);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public run(): void {
|
|
114
|
-
this.tasks.forEach((task) => {
|
|
115
|
-
this.dependentTaskRun(task, task.getDependentTasks());
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
public getPendingMinVersion(): string {
|
|
120
|
-
let version: string = this.cliVersion;
|
|
121
|
-
this.tasks.forEach((task) => {
|
|
122
|
-
if (task.getStatus() === 'pending') {
|
|
123
|
-
const minVersion = semver.minVersion(task.getVersionRange())?.raw ?? this.cliVersion;
|
|
124
|
-
if (semver.gt(version, minVersion)) {
|
|
125
|
-
version = minVersion;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
return version;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public getStatus(outline = false): {
|
|
133
|
-
done: number;
|
|
134
|
-
pending: number;
|
|
135
|
-
total: number;
|
|
136
|
-
nextVersion: string | null;
|
|
137
|
-
config: Configuration;
|
|
138
|
-
} {
|
|
139
|
-
let done = 0;
|
|
140
|
-
let pending = 0;
|
|
141
|
-
this.tasks.forEach((task) => {
|
|
142
|
-
switch (task.getStatus()) {
|
|
143
|
-
case 'done':
|
|
144
|
-
done++;
|
|
145
|
-
break;
|
|
146
|
-
case 'pending':
|
|
147
|
-
pending++;
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
if (outline) {
|
|
151
|
-
const status = task.getStatus();
|
|
152
|
-
console.log(`- ${task.getTitle()}:`, status === 'done' ? chalk.green(status) : chalk.yellow(status));
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
return {
|
|
156
|
-
done: done,
|
|
157
|
-
pending: pending,
|
|
158
|
-
total: this.tasks.size,
|
|
159
|
-
nextVersion: this.getPendingMinVersion(),
|
|
160
|
-
config: this.config,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
import { COMPONENT_FILE_EXTENSIONS, CUSTOM_ELEMENT_FILE_EXTENSIONS, MARKUP_EXTENSIONS } from '../../../../types';
|
|
4
|
-
import {
|
|
5
|
-
filterFilesByExt,
|
|
6
|
-
isPropertyKebabCaseRegExp,
|
|
7
|
-
isTagKebabCaseRegExp,
|
|
8
|
-
kebabToCamelCase,
|
|
9
|
-
kebabToCapitalCase,
|
|
10
|
-
logAndCreateError,
|
|
11
|
-
MODIFIED_FILES,
|
|
12
|
-
} from '../../../shares/reuse';
|
|
13
|
-
import { AbstractTask, TaskOptions } from '../../abstract-task';
|
|
14
|
-
|
|
15
|
-
const DATA_REMOVED_REGEXP = /DataRemoved_/gi; // not /DataRemoved-_/g
|
|
16
|
-
const DATA_REMOVEDS_REGEXP = /(data-removed-){2,}/g;
|
|
17
|
-
|
|
18
|
-
export class GenericRenamePropertyTask extends AbstractTask {
|
|
19
|
-
private readonly componentRegExp: RegExp;
|
|
20
|
-
private readonly customElementRegExp: RegExp;
|
|
21
|
-
|
|
22
|
-
private readonly newPropertyInCamelCase: string;
|
|
23
|
-
|
|
24
|
-
protected constructor(
|
|
25
|
-
identifier: string,
|
|
26
|
-
description: string,
|
|
27
|
-
tag: string,
|
|
28
|
-
oldProperty: string,
|
|
29
|
-
private readonly newProperty: string,
|
|
30
|
-
versionRange: string,
|
|
31
|
-
dependentTasks: AbstractTask[] = [],
|
|
32
|
-
options: TaskOptions = {},
|
|
33
|
-
) {
|
|
34
|
-
super(identifier, description, MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
|
|
35
|
-
|
|
36
|
-
if (!isTagKebabCaseRegExp.test(tag)) {
|
|
37
|
-
throw logAndCreateError(`Tag "${tag}" is not in kebab case.`);
|
|
38
|
-
}
|
|
39
|
-
if (!isPropertyKebabCaseRegExp.test(oldProperty)) {
|
|
40
|
-
throw logAndCreateError(`Old property "${oldProperty}" is not in kebab case.`);
|
|
41
|
-
}
|
|
42
|
-
if (!isPropertyKebabCaseRegExp.test(newProperty)) {
|
|
43
|
-
throw logAndCreateError(`New property "${newProperty}" is not in kebab case.`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
this.newPropertyInCamelCase = kebabToCamelCase(newProperty);
|
|
47
|
-
|
|
48
|
-
this.componentRegExp = new RegExp(`(<${kebabToCapitalCase(tag)}[^>]+)${kebabToCapitalCase(oldProperty)}([ >=])`, 'g');
|
|
49
|
-
this.customElementRegExp = new RegExp(`(<${tag}[^>]+)${oldProperty}([ >=])`, 'g');
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public run(baseDir: string): void {
|
|
53
|
-
this.transpileComponentFileRename(baseDir);
|
|
54
|
-
this.transpileCustomElementFileRename(baseDir);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private transpileComponentFileRename(baseDir: string): void {
|
|
58
|
-
filterFilesByExt(baseDir, COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
59
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
60
|
-
const newContent = content
|
|
61
|
-
// Replacements
|
|
62
|
-
.replace(this.componentRegExp, `$1${this.newPropertyInCamelCase}$2`)
|
|
63
|
-
.replace(DATA_REMOVED_REGEXP, 'data-removed-_')
|
|
64
|
-
.replace(DATA_REMOVEDS_REGEXP, 'data-removed-');
|
|
65
|
-
if (content !== newContent) {
|
|
66
|
-
MODIFIED_FILES.add(file);
|
|
67
|
-
fs.writeFileSync(file, newContent);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private transpileCustomElementFileRename(baseDir: string): void {
|
|
73
|
-
filterFilesByExt(baseDir, CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
|
|
74
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
75
|
-
const newContent = content
|
|
76
|
-
// Replacements
|
|
77
|
-
.replace(this.customElementRegExp, `$1${this.newProperty}$2`)
|
|
78
|
-
.replace(DATA_REMOVEDS_REGEXP, 'data-removed-');
|
|
79
|
-
if (content !== newContent) {
|
|
80
|
-
MODIFIED_FILES.add(file);
|
|
81
|
-
fs.writeFileSync(file, newContent);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
import { COMPONENT_FILE_EXTENSIONS, MARKUP_EXTENSIONS } from '../../../../types';
|
|
4
|
-
import {
|
|
5
|
-
filterFilesByExt,
|
|
6
|
-
isPropertyKebabCaseRegExp,
|
|
7
|
-
isTagKebabCaseRegExp,
|
|
8
|
-
kebabToCamelCase,
|
|
9
|
-
kebabToCapitalCase,
|
|
10
|
-
logAndCreateError,
|
|
11
|
-
MODIFIED_FILES,
|
|
12
|
-
} from '../../../shares/reuse';
|
|
13
|
-
import { AbstractTask, TaskOptions } from '../../abstract-task';
|
|
14
|
-
|
|
15
|
-
const removeLineBreaksAndSpaces = (match: string) => {
|
|
16
|
-
return match.replace(/\r?\n/g, ' ').replace(/>\s+/g, '>').replace(/\s+</g, '<');
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export class LabelExpertSlot extends AbstractTask {
|
|
20
|
-
private readonly componentRegExp: RegExp;
|
|
21
|
-
private readonly customElementRegExp: RegExp;
|
|
22
|
-
private readonly propertyInCamelCase: string;
|
|
23
|
-
|
|
24
|
-
private constructor(
|
|
25
|
-
identifier: string,
|
|
26
|
-
tag: string,
|
|
27
|
-
private readonly property: string,
|
|
28
|
-
versionRange: string,
|
|
29
|
-
dependentTasks: AbstractTask[],
|
|
30
|
-
options: TaskOptions,
|
|
31
|
-
) {
|
|
32
|
-
super(identifier, `Move innerText of "${tag}" component to property "${property}"`, MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
|
|
33
|
-
|
|
34
|
-
if (!isTagKebabCaseRegExp.test(tag)) {
|
|
35
|
-
throw logAndCreateError(`Tag "${tag}" is not in kebab case.`);
|
|
36
|
-
}
|
|
37
|
-
if (!isPropertyKebabCaseRegExp.test(property)) {
|
|
38
|
-
throw logAndCreateError(`Property "${property}" is not in kebab case.`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const tagCapitalCase = kebabToCapitalCase(tag);
|
|
42
|
-
this.propertyInCamelCase = kebabToCamelCase(property);
|
|
43
|
-
|
|
44
|
-
// https://regex101.com/r/WkEKxu/1
|
|
45
|
-
|
|
46
|
-
this.componentRegExp = new RegExp(`(<${tagCapitalCase}[^>]*)>([^<]+(\\n\\s*)*)(<\\/${tagCapitalCase}>)`, 'g');
|
|
47
|
-
this.customElementRegExp = new RegExp(`(<${tag}[^>]*)>([^<]+(\\n\\s*)*)(<\\/${tag}>)`, 'g');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public static getInstance(
|
|
51
|
-
tag: string,
|
|
52
|
-
property: string,
|
|
53
|
-
versionRange: string,
|
|
54
|
-
dependentTasks: AbstractTask[] = [],
|
|
55
|
-
options: TaskOptions = {},
|
|
56
|
-
): LabelExpertSlot {
|
|
57
|
-
const identifier = `${tag}-move-innerText-to-property-${property}`;
|
|
58
|
-
if (!this.instances.has(identifier)) {
|
|
59
|
-
this.instances.set(identifier, new LabelExpertSlot(identifier, tag, property, versionRange, dependentTasks, options));
|
|
60
|
-
}
|
|
61
|
-
return this.instances.get(identifier) as LabelExpertSlot;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public run(baseDir: string): void {
|
|
65
|
-
this.transpileComponentFileDelete(baseDir);
|
|
66
|
-
this.transpileCustomElementFileDelete(baseDir);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
private transpileComponentFileDelete(baseDir: string): void {
|
|
70
|
-
filterFilesByExt(baseDir, COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
71
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
72
|
-
const newContent = content
|
|
73
|
-
// Replacements
|
|
74
|
-
.replace(this.componentRegExp, removeLineBreaksAndSpaces)
|
|
75
|
-
.replace(this.componentRegExp, `$1 ${this.propertyInCamelCase}="$2">$4`);
|
|
76
|
-
if (content !== newContent) {
|
|
77
|
-
MODIFIED_FILES.add(file);
|
|
78
|
-
fs.writeFileSync(file, newContent);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private transpileCustomElementFileDelete(baseDir: string): void {
|
|
84
|
-
filterFilesByExt(baseDir, COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
85
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
86
|
-
const newContent = content
|
|
87
|
-
// Replacements
|
|
88
|
-
.replace(this.customElementRegExp, removeLineBreaksAndSpaces)
|
|
89
|
-
.replace(this.customElementRegExp, `$1 ${this.property}="$2">$4`);
|
|
90
|
-
if (content !== newContent) {
|
|
91
|
-
MODIFIED_FILES.add(file);
|
|
92
|
-
// fs.writeFileSync(file, newContent);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
import { COMPONENT_FILE_EXTENSIONS, CUSTOM_ELEMENT_FILE_EXTENSIONS } from '../../../../types';
|
|
4
|
-
import {
|
|
5
|
-
filterFilesByExt,
|
|
6
|
-
getRemoveMode,
|
|
7
|
-
isPropertyKebabCaseRegExp,
|
|
8
|
-
isTagKebabCaseRegExp,
|
|
9
|
-
kebabToCamelCase,
|
|
10
|
-
kebabToCapitalCase,
|
|
11
|
-
logAndCreateError,
|
|
12
|
-
MODIFIED_FILES,
|
|
13
|
-
} from '../../../shares/reuse';
|
|
14
|
-
import { AbstractTask, TaskOptions } from '../../abstract-task';
|
|
15
|
-
import { GenericRenamePropertyTask } from './GenericRenamePropertyTask';
|
|
16
|
-
|
|
17
|
-
const DATA_REMOVED_REGEXP = /data-removed-/g;
|
|
18
|
-
|
|
19
|
-
export class RemovePropertyNameTask extends GenericRenamePropertyTask {
|
|
20
|
-
private readonly componentRegExpBoolean: RegExp;
|
|
21
|
-
private readonly componentRegExpCurlyBrackets: RegExp;
|
|
22
|
-
private readonly componentRegExpQuotationMarks: RegExp;
|
|
23
|
-
private readonly customElementRegExpBoolean: RegExp;
|
|
24
|
-
private readonly customElementRegExpCurlyBrackets: RegExp;
|
|
25
|
-
private readonly customElementRegExpQuotationMarks: RegExp;
|
|
26
|
-
|
|
27
|
-
protected constructor(identifier: string, tag: string, property: string, versionRange: string, dependentTasks?: AbstractTask[], options?: TaskOptions) {
|
|
28
|
-
super(identifier, `Remove property "${property}" of "${tag}" component`, tag, property, `data-removed-${property}`, versionRange, dependentTasks, options);
|
|
29
|
-
|
|
30
|
-
if (!isTagKebabCaseRegExp.test(tag)) {
|
|
31
|
-
throw logAndCreateError(`Tag "${tag}" is not in kebab case.`);
|
|
32
|
-
}
|
|
33
|
-
if (!isPropertyKebabCaseRegExp.test(property)) {
|
|
34
|
-
throw logAndCreateError(`Property "${property}" is not in kebab case.`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const tagCapitalCase = kebabToCapitalCase(tag);
|
|
38
|
-
const propertyInCamelCase = kebabToCamelCase(property);
|
|
39
|
-
|
|
40
|
-
this.componentRegExpBoolean = new RegExp(`(<${tagCapitalCase}[^>]+)${propertyInCamelCase}([ >])`, 'g');
|
|
41
|
-
this.componentRegExpCurlyBrackets = new RegExp(`(<${tagCapitalCase}[^>]+)${propertyInCamelCase}(=\\{[^\\}]+\\})`, 'g');
|
|
42
|
-
this.componentRegExpQuotationMarks = new RegExp(`(<${tagCapitalCase}[^>]+)${propertyInCamelCase}(="[^"]+")`, 'g');
|
|
43
|
-
this.customElementRegExpBoolean = new RegExp(`(<${tag}[^>]+)${property}([ >])`, 'g');
|
|
44
|
-
this.customElementRegExpCurlyBrackets = new RegExp(`(<${tag}[^>]+)${property}(=\\{[^\\}]+\\})`, 'g');
|
|
45
|
-
this.customElementRegExpQuotationMarks = new RegExp(`(<${tag}[^>]+)${property}(="[^"]+")`, 'g');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public static getInstance(
|
|
49
|
-
tag: string,
|
|
50
|
-
property: string,
|
|
51
|
-
versionRange: string,
|
|
52
|
-
dependentTasks: AbstractTask[] = [],
|
|
53
|
-
options: TaskOptions = {},
|
|
54
|
-
): RemovePropertyNameTask {
|
|
55
|
-
const identifier = `${tag}-remove-property-${property}`;
|
|
56
|
-
if (!this.instances.has(identifier)) {
|
|
57
|
-
this.instances.set(identifier, new RemovePropertyNameTask(identifier, tag, property, versionRange, dependentTasks, options));
|
|
58
|
-
}
|
|
59
|
-
return this.instances.get(identifier) as RemovePropertyNameTask;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
public run(baseDir: string): void {
|
|
63
|
-
switch (getRemoveMode()) {
|
|
64
|
-
case 'delete':
|
|
65
|
-
this.transpileComponentFileDelete(baseDir);
|
|
66
|
-
this.transpileCustomElementFileDelete(baseDir);
|
|
67
|
-
break;
|
|
68
|
-
default:
|
|
69
|
-
super.run(baseDir);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
private transpileComponentFileDelete(baseDir: string): void {
|
|
74
|
-
filterFilesByExt(baseDir, COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
75
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
76
|
-
const newContent = content
|
|
77
|
-
// Replacements
|
|
78
|
-
.replace(DATA_REMOVED_REGEXP, ``)
|
|
79
|
-
.replace(this.componentRegExpBoolean, `$1$2`)
|
|
80
|
-
.replace(this.componentRegExpCurlyBrackets, `$1`)
|
|
81
|
-
.replace(this.componentRegExpQuotationMarks, `$1`);
|
|
82
|
-
if (content !== newContent) {
|
|
83
|
-
MODIFIED_FILES.add(file);
|
|
84
|
-
fs.writeFileSync(file, newContent);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private transpileCustomElementFileDelete(baseDir: string): void {
|
|
90
|
-
filterFilesByExt(baseDir, CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
|
|
91
|
-
const content = fs.readFileSync(file, 'utf8');
|
|
92
|
-
const newContent = content
|
|
93
|
-
// Replacements
|
|
94
|
-
.replace(DATA_REMOVED_REGEXP, ``)
|
|
95
|
-
.replace(this.customElementRegExpBoolean, `$1$2`)
|
|
96
|
-
.replace(this.customElementRegExpCurlyBrackets, `$1`)
|
|
97
|
-
.replace(this.customElementRegExpQuotationMarks, `$1`);
|
|
98
|
-
if (content !== newContent) {
|
|
99
|
-
MODIFIED_FILES.add(file);
|
|
100
|
-
fs.writeFileSync(file, newContent);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AbstractTask, TaskOptions } from '../../abstract-task';
|
|
2
|
-
import { GenericRenamePropertyTask } from './GenericRenamePropertyTask';
|
|
3
|
-
|
|
4
|
-
export class RenamePropertyNameTask extends GenericRenamePropertyTask {
|
|
5
|
-
public static getInstance(
|
|
6
|
-
tag: string,
|
|
7
|
-
oldProperty: string,
|
|
8
|
-
newProperty: string,
|
|
9
|
-
versionRange: string,
|
|
10
|
-
dependentTasks: AbstractTask[] = [],
|
|
11
|
-
options: TaskOptions = {},
|
|
12
|
-
): RenamePropertyNameTask {
|
|
13
|
-
const identifier = `${tag}-rename-property-${oldProperty}-to-${newProperty}`;
|
|
14
|
-
if (!this.instances.has(identifier)) {
|
|
15
|
-
this.instances?.set(
|
|
16
|
-
identifier,
|
|
17
|
-
new RenamePropertyNameTask(
|
|
18
|
-
identifier,
|
|
19
|
-
`Rename property "${oldProperty}" to "${newProperty}" of "${tag}" component`,
|
|
20
|
-
tag,
|
|
21
|
-
oldProperty,
|
|
22
|
-
newProperty,
|
|
23
|
-
versionRange,
|
|
24
|
-
dependentTasks,
|
|
25
|
-
options,
|
|
26
|
-
),
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
return this.instances.get(identifier) as RenamePropertyNameTask;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getVersionOfPublicUiComponents } from '../../../shares/reuse';
|
|
2
|
-
import { AbstractTask } from '../../abstract-task';
|
|
3
|
-
import { TestVersion13 } from './test-version-1.3';
|
|
4
|
-
import { TestVersionCurrent } from './test-version-current';
|
|
5
|
-
import { TestVersionNext2 } from './test-version-next-2';
|
|
6
|
-
import { TestVersionNext3 } from './test-version-next-3';
|
|
7
|
-
import { TestVersionZero } from './test-version-zero';
|
|
8
|
-
|
|
9
|
-
export const testTasks: AbstractTask[] = [];
|
|
10
|
-
testTasks.push(TestVersionZero.getInstance());
|
|
11
|
-
testTasks.push(TestVersionNext2.getInstance());
|
|
12
|
-
testTasks.push(TestVersionNext3.getInstance());
|
|
13
|
-
testTasks.push(TestVersion13.getInstance());
|
|
14
|
-
|
|
15
|
-
const versionOfPublicUiComponents = getVersionOfPublicUiComponents();
|
|
16
|
-
testTasks.push(TestVersionCurrent.getInstance(versionOfPublicUiComponents));
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { FileExtension } from '../../../../types';
|
|
2
|
-
import { AbstractTask, TaskOptions } from '../../abstract-task';
|
|
3
|
-
|
|
4
|
-
export class TestDummy extends AbstractTask {
|
|
5
|
-
protected static getInstance(
|
|
6
|
-
identifier: string,
|
|
7
|
-
title: string,
|
|
8
|
-
extensions: FileExtension[],
|
|
9
|
-
versionRange: string,
|
|
10
|
-
dependentTasks: AbstractTask[] = [],
|
|
11
|
-
options: TaskOptions = {},
|
|
12
|
-
): TestDummy {
|
|
13
|
-
if (!this.instances.has(identifier)) {
|
|
14
|
-
this.instances.set(identifier, new TestDummy(identifier, title, extensions, versionRange, dependentTasks, options));
|
|
15
|
-
}
|
|
16
|
-
return this.instances.get(identifier) as TestDummy;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public run(): void {}
|
|
20
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { RemovePropertyNameTask } from '../common/RemovePropertyNameTask';
|
|
2
|
-
import { RenamePropertyNameTask } from '../common/RenamePropertyNameTask';
|
|
3
|
-
|
|
4
|
-
export const BadgeRemovePropertyIconOnly = RemovePropertyNameTask.getInstance('kol-badge', '_icon-only', '^1');
|
|
5
|
-
export const BadgeRenamePropertyIconOnlyToHideLabel = RenamePropertyNameTask.getInstance('kol-badge', '_icon-only', '_hide-label', '^1');
|
|
6
|
-
export const BadgeRemovePropertyHideLabel = RemovePropertyNameTask.getInstance('kol-badge', '_hide-label', '^1', [BadgeRenamePropertyIconOnlyToHideLabel]);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { RemovePropertyNameTask } from '../common/RemovePropertyNameTask';
|
|
2
|
-
import { RenamePropertyNameTask } from '../common/RenamePropertyNameTask';
|
|
3
|
-
|
|
4
|
-
export const ButtonLinkRemovePropertyAriaCurrent = RemovePropertyNameTask.getInstance('kol-button-link', '_aria-current', '^1');
|
|
5
|
-
export const ButtonLinkRemovePropertyAriaLabel = RemovePropertyNameTask.getInstance('kol-button-link', '_aria-label', '^1');
|
|
6
|
-
export const ButtonLinkRenamePropertyIconOnlyToHideLabel = RenamePropertyNameTask.getInstance('kol-button-link', '_icon-only', '_hide-label', '^1');
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RemovePropertyNameTask } from '../common/RemovePropertyNameTask';
|
|
2
|
-
import { RenamePropertyNameTask } from '../common/RenamePropertyNameTask';
|
|
3
|
-
|
|
4
|
-
export const ButtonRemovePropertyAriaCurrent = RemovePropertyNameTask.getInstance('kol-button', '_aria-current', '^1');
|
|
5
|
-
export const ButtonRemovePropertyAriaLabel = RemovePropertyNameTask.getInstance('kol-button', '_aria-label', '^1');
|
|
6
|
-
// @todo: handle _icon-align in _icon
|
|
7
|
-
export const ButtonRemovePropertyIconAlign = RemovePropertyNameTask.getInstance('kol-button', '_icon-align', '^1');
|
|
8
|
-
export const ButtonRenamePropertyIconOnlyToHideLabel = RenamePropertyNameTask.getInstance('kol-button', '_icon-only', '_hide-label', '^1');
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { RenamePropertyNameTask } from '../common/RenamePropertyNameTask';
|
|
2
|
-
|
|
3
|
-
export const CardRenamePropertyHeadingToLabel = RenamePropertyNameTask.getInstance('kol-card', '_heading', '_label', '^1');
|
|
4
|
-
export const CardRenamePropertyHeadlineToLabel = RenamePropertyNameTask.getInstance('kol-card', '_headline', '_label', '^1');
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RemovePropertyNameTask } from '../common/RemovePropertyNameTask';
|
|
2
|
-
import { RenamePropertyNameTask } from '../common/RenamePropertyNameTask';
|
|
3
|
-
|
|
4
|
-
export const IconRenamePropertyAriaLabelToLabel = RenamePropertyNameTask.getInstance('kol-icon', '_aria-label', '_label', '^1');
|
|
5
|
-
export const IconRemovePropertyPart = RemovePropertyNameTask.getInstance('kol-icon', '_part', '^1');
|