@public-ui/kolibri-cli 1.7.0-rc.0 → 1.7.0-rc.10
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 +34 -9
- package/dist/index.js +7 -5
- package/dist/migrate/index.js +15 -18
- package/dist/migrate/runner/abstract-task.js +2 -1
- package/dist/migrate/runner/task-runner.js +10 -11
- package/dist/migrate/runner/tasks/common/GenericRenamePropertyTask.js +9 -11
- package/dist/migrate/runner/tasks/common/LabelExpertSlot.js +68 -0
- package/dist/migrate/runner/tasks/common/RemovePropertyNameTask.js +8 -7
- package/dist/migrate/runner/tasks/common/RenamePropertyNameTask.js +1 -4
- package/dist/migrate/runner/tasks/test/index.js +2 -6
- package/dist/migrate/runner/tasks/v1/index.js +43 -0
- package/dist/migrate/runner/tasks/v1/input-number.js +1 -1
- package/dist/migrate/runner/tasks/v1/link-group.js +3 -2
- package/dist/migrate/runner/types.js +1 -2
- package/dist/migrate/shares/reuse.js +69 -28
- package/dist/migrate/types.js +4 -0
- package/dist/types.js +2 -1
- package/package.json +14 -14
- package/dist/migrate/runner/tasks/index.js +0 -18
- package/dist/migrate/runner/tasks/test-tasks.js +0 -12
- package/dist/migrate/runner/tasks/v1/abbr-property-renaming-title-to-label.js +0 -30
- package/dist/migrate/runner/tasks/v1/accordion-property-renaming-heading-to-label.js +0 -30
- package/dist/migrate/runner/tasks/v1/test-version-1.3.js +0 -17
- package/dist/migrate/runner/tasks/v1/test-version-current.js +0 -17
- package/dist/migrate/runner/tasks/v1/test-version-next-2.js +0 -17
- package/dist/migrate/runner/tasks/v1/test-version-next-3.js +0 -17
- package/dist/migrate/runner/tasks/v1/test-version-zero.js +0 -17
- package/dist/runner/abstract-task.js +0 -48
- package/dist/runner/task-runner.js +0 -28
- package/dist/runner/tasks/abbr-property-renaming-title-to-label.js +0 -27
- package/dist/runner/tasks/index.js +0 -6
- package/dist/runner/types.js +0 -4
- package/dist/shares/reuse.js +0 -48
package/README.md
CHANGED
|
@@ -16,12 +16,33 @@ yarn add -g @public-ui/kolibri-cli
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
Use the `kolibri` command to start the CLI.
|
|
19
|
+
The `KoliBri` CLI is intended to be executed in your project root directory. Use the `kolibri` command to start the CLI.
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
kolibri --help
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
```bash
|
|
26
|
+
,--. ,--. ,--. ,--. ,-----. ,--.
|
|
27
|
+
| .' / ,---. | | `--' | |) /_ ,--.--. `--'
|
|
28
|
+
| . ' | .-. | | | ,--. | .-. \ | .--' ,--.
|
|
29
|
+
| |\ \ | '-' | | | | | | '--' / | | | |
|
|
30
|
+
`--' `--´ `---´ `--' `--' `------´ `--' `--'
|
|
31
|
+
🚹 The accessible HTML-Standard | 👉 https://public-ui.github.io
|
|
32
|
+
|
|
33
|
+
Usage: kolibri [options] [command]
|
|
34
|
+
|
|
35
|
+
CLI for executing some helpful commands for KoliBri projects.
|
|
36
|
+
|
|
37
|
+
Options:
|
|
38
|
+
-V, --version output the version number
|
|
39
|
+
-h, --help display help for command
|
|
40
|
+
|
|
41
|
+
Commands:
|
|
42
|
+
migrate [options] <string> This command migrates KoliBri code to the current version.
|
|
43
|
+
help [command] display help for command
|
|
44
|
+
```
|
|
45
|
+
|
|
25
46
|
### Migrate
|
|
26
47
|
|
|
27
48
|
With the `migrate` command you can migrate your project to the latest version of `KoliBri`.
|
|
@@ -41,12 +62,13 @@ Actually the following migrations are available:
|
|
|
41
62
|
|
|
42
63
|
#### How does it work?
|
|
43
64
|
|
|
44
|
-
1. The migration command will check your project for clear `git history` and the `installed version` of `KoliBri`. Now it
|
|
45
|
-
2.
|
|
65
|
+
1. The migration command will check your project for clear `git history` and the `installed version` of `KoliBri`. Now it loads all available migration tasks.
|
|
66
|
+
2. Tasks in the correct version range will be executed one by one. Otherwise they will be skipped.
|
|
46
67
|
3. After that the `package.json` will be updated with the new version of `KoliBri` and execute the `npm install` command.
|
|
47
|
-
4.
|
|
68
|
+
4. If there are any pending tasks, the migration command will be executed again. Otherwise the migration is finished.
|
|
69
|
+
5. Now you can check the result and commit the changes.
|
|
48
70
|
|
|
49
|
-
|
|
71
|
+
> **Note:** You can reset the migration with `git reset --hard HEAD~1` or by discarding the affected files.
|
|
50
72
|
|
|
51
73
|
#### Help
|
|
52
74
|
|
|
@@ -62,9 +84,10 @@ kolibri migrate <path>
|
|
|
62
84
|
|
|
63
85
|
#### Options
|
|
64
86
|
|
|
65
|
-
| Option
|
|
66
|
-
|
|
|
67
|
-
| `--
|
|
87
|
+
| Option | Description | Type | Default |
|
|
88
|
+
| ------------------------------ | ----------------------------------------- | :------------------: | :------: |
|
|
89
|
+
| `--ignore-uncommitted-changes` | Allows execution with uncommitted changes | boolean | false |
|
|
90
|
+
| `--remove-mode` | Prefix property name or delete property | `delete` \| `prefix` | `prefix` |
|
|
68
91
|
|
|
69
92
|
#### Configuration
|
|
70
93
|
|
|
@@ -130,6 +153,8 @@ If the migration failed, you can reset the migration with `git reset --hard HEAD
|
|
|
130
153
|
|
|
131
154
|
Use the configuration (`.kolibri.config.json`) to exclude some tasks.
|
|
132
155
|
|
|
156
|
+
If there are multiple obsolete properties that have been migrated to just one new property, the new property may appear multiple times in the tag. You can then decide which variant to use and remove all other variants accordingly.
|
|
157
|
+
|
|
133
158
|
Maybe it can help to prepare your code in the tricky places for migration.
|
|
134
159
|
|
|
135
160
|
Please give us feedback, if you have problems with the migration: [GitHub Issues](https://github.com/public-ui/kolibri/issues/new?assignees=&labels=useful+hint&projects=&template=7_feedback.md&title=%F0%9F%92%A1+CLI%3A+)
|
|
@@ -140,4 +165,4 @@ You have always the possibility of a dry run. Because before the migration will
|
|
|
140
165
|
|
|
141
166
|
After the migration you can check the result with `git status` and `git diff`.
|
|
142
167
|
|
|
143
|
-
Is anything wrong, you can reset the migration with `git reset --hard HEAD~1
|
|
168
|
+
Is anything wrong, you can reset the migration with `git reset --hard HEAD~1` or by discarding the affected files.
|
package/dist/index.js
CHANGED
|
@@ -5,21 +5,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
|
-
const migrate_1 = __importDefault(require("./migrate"));
|
|
9
8
|
const gradient_string_1 = __importDefault(require("gradient-string"));
|
|
10
|
-
const
|
|
9
|
+
const migrate_1 = __importDefault(require("./migrate"));
|
|
10
|
+
const reuse_1 = require("./migrate/shares/reuse");
|
|
11
|
+
const versionOfPublicUiKoliBriCli = (0, reuse_1.getVersionOfPublicUiKoliBriCli)();
|
|
12
|
+
const banner = gradient_string_1.default.atlas.multiline(`
|
|
11
13
|
,--. ,--. ,--. ,--. ,-----. ,--.
|
|
12
14
|
| .' / ,---. | | \`--' | |) /_ ,--.--. \`--'
|
|
13
15
|
| . ' | .-. | | | ,--. | .-. \\ | .--' ,--.
|
|
14
16
|
| |\\ \\ | '-' | | | | | | '--' / | | | |
|
|
15
17
|
\`--' \`--´ \`---´ \`--' \`--' \`------´ \`--' \`--'
|
|
16
|
-
🚹 The accessible HTML-Standard | 👉 https://public-ui.github.io |
|
|
18
|
+
🚹 The accessible HTML-Standard | 👉 https://public-ui.github.io | ${versionOfPublicUiKoliBriCli}
|
|
17
19
|
`, {
|
|
18
20
|
interpolation: 'hsv',
|
|
19
21
|
});
|
|
20
|
-
console.log(
|
|
22
|
+
console.log(banner);
|
|
21
23
|
const program = new commander_1.Command();
|
|
22
|
-
program.name('kolibri').description('CLI for executing some helpful commands for KoliBri projects.').version(
|
|
24
|
+
program.name('kolibri').description('CLI for executing some helpful commands for KoliBri projects.').version(versionOfPublicUiKoliBriCli);
|
|
23
25
|
// Add commands
|
|
24
26
|
(0, migrate_1.default)(program);
|
|
25
27
|
program.parse();
|
package/dist/migrate/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const task_runner_1 = require("./runner/task-runner");
|
|
|
11
11
|
const test_1 = require("./runner/tasks/test");
|
|
12
12
|
const v1_1 = require("./runner/tasks/v1");
|
|
13
13
|
const reuse_1 = require("./shares/reuse");
|
|
14
|
+
const types_1 = require("./types");
|
|
14
15
|
/**
|
|
15
16
|
* This function is used to register the migrate command.
|
|
16
17
|
* @param {Command} program The program object to register the command
|
|
@@ -19,21 +20,22 @@ function default_1(program) {
|
|
|
19
20
|
program
|
|
20
21
|
.command('migrate')
|
|
21
22
|
.description('This command migrates KoliBri code to the current version.')
|
|
22
|
-
.argument('
|
|
23
|
-
.addOption(new commander_1.Option('--
|
|
24
|
-
.
|
|
23
|
+
.argument('[string]', 'Source code folder to migrate', 'src')
|
|
24
|
+
.addOption(new commander_1.Option('--ignore-uncommitted-changes', 'Allows execution with uncommitted changes').default(false))
|
|
25
|
+
.addOption(new commander_1.Option('--remove-mode <mode>', 'Prefix property name or delete property').choices(types_1.REMOVE_MODE).default('prefix'))
|
|
26
|
+
.addOption(new commander_1.Option('--test-tasks', 'Run additional test tasks').default(false).hideHelp())
|
|
25
27
|
.action((baseDir, options) => {
|
|
26
28
|
(0, child_process_1.exec)('git status --porcelain', (err, stdout) => {
|
|
27
29
|
if (err) {
|
|
28
30
|
console.error(`exec error: ${err.message}`);
|
|
29
31
|
return;
|
|
30
32
|
}
|
|
31
|
-
if (stdout) {
|
|
32
|
-
throw
|
|
33
|
+
if (!options.ignoreUncommittedChanges && stdout) {
|
|
34
|
+
throw (0, reuse_1.logAndCreateError)('There are uncommitted changes');
|
|
33
35
|
}
|
|
34
36
|
(0, reuse_1.setRemoveMode)(options.removeMode);
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
+
const versionOfPublicUiComponents = (0, reuse_1.getVersionOfPublicUiComponents)();
|
|
38
|
+
const versionOfPublicUiKoliBriCli = (0, reuse_1.getVersionOfPublicUiKoliBriCli)();
|
|
37
39
|
console.log(`
|
|
38
40
|
Current version of @public-ui/components: ${versionOfPublicUiComponents}
|
|
39
41
|
Source folder to migrate: ${baseDir}
|
|
@@ -61,7 +63,7 @@ Source folder to migrate: ${baseDir}
|
|
|
61
63
|
runner.run();
|
|
62
64
|
if (version !== runner.getPendingMinVersion()) {
|
|
63
65
|
version = runner.getPendingMinVersion();
|
|
64
|
-
let packageJson = (0, reuse_1.
|
|
66
|
+
let packageJson = (0, reuse_1.getContentOfProjectPkgJson)();
|
|
65
67
|
packageJson = packageJson.replace(/"(@public-ui\/[^"]+)":\s*".*"/g, `"$1": "${version}"`);
|
|
66
68
|
fs_1.default.writeFileSync(path_1.default.resolve(process.cwd(), 'package.json'), packageJson);
|
|
67
69
|
runner.setProjectVersion(version);
|
|
@@ -76,7 +78,7 @@ Source folder to migrate: ${baseDir}
|
|
|
76
78
|
}
|
|
77
79
|
else {
|
|
78
80
|
console.log(`
|
|
79
|
-
|
|
81
|
+
Status of all executed Tasks:`);
|
|
80
82
|
const status = runner.getStatus(true);
|
|
81
83
|
fs_1.default.writeFileSync(configFile, JSON.stringify(status.config, null, 2));
|
|
82
84
|
console.log(`
|
|
@@ -85,21 +87,16 @@ Modified files: ${reuse_1.MODIFIED_FILES.size}`);
|
|
|
85
87
|
console.log(`- ${file}`);
|
|
86
88
|
});
|
|
87
89
|
console.log(`
|
|
88
|
-
After the code migration has gone through, the code formatting may no longer
|
|
89
|
-
be as desired. Therefore, please reformat your code afterwards if necessary.
|
|
90
|
+
After the code migration has gone through, the code formatting may no longer be as desired. Therefore, please reformat your code afterwards if necessary.
|
|
90
91
|
|
|
91
|
-
Afterwards, it may be that functions or themes in newer major versions have
|
|
92
|
-
changed or are no longer included. This should be checked finally and corrected
|
|
93
|
-
manually if necessary.
|
|
92
|
+
Afterwards, it may be that functions or themes in newer major versions have changed or are no longer included. This should be checked finally and corrected manually if necessary.
|
|
94
93
|
|
|
95
|
-
Is anything wrong, you can reset the migration with "git reset --hard HEAD~1"
|
|
96
|
-
read the troubleshooting section in the readme.
|
|
97
|
-
`);
|
|
94
|
+
Is anything wrong, you can reset the migration with "git reset --hard HEAD~1" or by discarding the affected files. For more information read the troubleshooting section in the README.`);
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
97
|
const status = runner.getStatus();
|
|
101
98
|
console.log(`
|
|
102
|
-
|
|
99
|
+
Execute ${status.total} registered tasks...`);
|
|
103
100
|
runLoop();
|
|
104
101
|
});
|
|
105
102
|
});
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.AbstractTask = void 0;
|
|
7
7
|
const semver_1 = __importDefault(require("semver"));
|
|
8
8
|
const types_1 = require("../../types");
|
|
9
|
+
const reuse_1 = require("../shares/reuse");
|
|
9
10
|
class AbstractTask {
|
|
10
11
|
constructor(identifier, title, extensions, versionRange, dependentTasks = [], options = {}) {
|
|
11
12
|
this.identifier = identifier;
|
|
@@ -17,7 +18,7 @@ class AbstractTask {
|
|
|
17
18
|
this.description = options.description;
|
|
18
19
|
this.extensions = this.extensions.filter((ext) => types_1.FILE_EXTENSIONS.includes(ext));
|
|
19
20
|
if (!semver_1.default.validRange(this.versionRange)) {
|
|
20
|
-
throw
|
|
21
|
+
throw (0, reuse_1.logAndCreateError)(`[${this.identifier}] Invalid semver range version: ${this.versionRange}`);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
getDependentTasks() {
|
|
@@ -4,16 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TaskRunner = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const semver_1 = __importDefault(require("semver"));
|
|
11
|
+
const reuse_1 = require("../shares/reuse");
|
|
10
12
|
class TaskRunner {
|
|
11
13
|
constructor(baseDir, cliVersion, projectVersion, config) {
|
|
12
14
|
this.tasks = new Map();
|
|
13
15
|
this.baseDir = '/';
|
|
14
16
|
this.cliVersion = '0.0.0';
|
|
15
17
|
this.projectVersion = '0.0.0';
|
|
16
|
-
this.openRun = true;
|
|
17
18
|
this.config = {
|
|
18
19
|
migrate: {
|
|
19
20
|
tasks: {},
|
|
@@ -26,23 +27,22 @@ class TaskRunner {
|
|
|
26
27
|
}
|
|
27
28
|
setBaseDir(baseDir) {
|
|
28
29
|
if (!fs_1.default.existsSync(path_1.default.resolve(process.cwd(), baseDir))) {
|
|
29
|
-
throw
|
|
30
|
+
throw (0, reuse_1.logAndCreateError)(`Base directory "${baseDir}" does not exist`);
|
|
30
31
|
}
|
|
31
32
|
this.baseDir = baseDir;
|
|
32
33
|
}
|
|
33
34
|
setCliVersion(version) {
|
|
34
35
|
if (semver_1.default.valid(version) === null) {
|
|
35
|
-
throw
|
|
36
|
+
throw (0, reuse_1.logAndCreateError)(`Invalid CLI version: ${version}`);
|
|
36
37
|
}
|
|
37
38
|
this.cliVersion = version;
|
|
38
39
|
}
|
|
39
40
|
setProjectVersion(version) {
|
|
40
41
|
if (semver_1.default.valid(version) === null) {
|
|
41
|
-
throw
|
|
42
|
+
throw (0, reuse_1.logAndCreateError)(`Invalid project version: ${version}`);
|
|
42
43
|
}
|
|
43
44
|
if (this.projectVersion !== version) {
|
|
44
45
|
this.projectVersion = version;
|
|
45
|
-
this.openRun = true;
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
setConfig(config) {
|
|
@@ -61,7 +61,6 @@ class TaskRunner {
|
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
63
63
|
this.tasks.set(task.getIdentifier(), task);
|
|
64
|
-
this.openRun = true;
|
|
65
64
|
}
|
|
66
65
|
});
|
|
67
66
|
}
|
|
@@ -80,6 +79,9 @@ class TaskRunner {
|
|
|
80
79
|
includePrerelease: true,
|
|
81
80
|
})) {
|
|
82
81
|
// task.setStatus('running'); only of the task is async
|
|
82
|
+
if (!this.tasks.has(task.getIdentifier())) {
|
|
83
|
+
this.registerTask(task);
|
|
84
|
+
}
|
|
83
85
|
task.run(this.baseDir);
|
|
84
86
|
task.setStatus('done');
|
|
85
87
|
}
|
|
@@ -97,7 +99,6 @@ class TaskRunner {
|
|
|
97
99
|
this.tasks.forEach((task) => {
|
|
98
100
|
this.dependentTaskRun(task, task.getDependentTasks());
|
|
99
101
|
});
|
|
100
|
-
this.openRun = false;
|
|
101
102
|
}
|
|
102
103
|
getPendingMinVersion() {
|
|
103
104
|
let version = this.cliVersion;
|
|
@@ -112,9 +113,6 @@ class TaskRunner {
|
|
|
112
113
|
});
|
|
113
114
|
return version;
|
|
114
115
|
}
|
|
115
|
-
hasPendingTasks() {
|
|
116
|
-
return this.openRun || semver_1.default.lt(this.getPendingMinVersion(), this.cliVersion);
|
|
117
|
-
}
|
|
118
116
|
getStatus(outline = false) {
|
|
119
117
|
let done = 0;
|
|
120
118
|
let pending = 0;
|
|
@@ -128,7 +126,8 @@ class TaskRunner {
|
|
|
128
126
|
break;
|
|
129
127
|
}
|
|
130
128
|
if (outline) {
|
|
131
|
-
|
|
129
|
+
const status = task.getStatus();
|
|
130
|
+
console.log(`- ${task.getTitle()}:`, status === 'done' ? chalk_1.default.green(status) : chalk_1.default.yellow(status));
|
|
132
131
|
}
|
|
133
132
|
});
|
|
134
133
|
return {
|
|
@@ -8,25 +8,23 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const types_1 = require("../../../../types");
|
|
9
9
|
const reuse_1 = require("../../../shares/reuse");
|
|
10
10
|
const abstract_task_1 = require("../../abstract-task");
|
|
11
|
-
const
|
|
12
|
-
const DATA_REMOVED_REGEXP = /DataRemoved_/g; // not /DataRemoved-_/g
|
|
11
|
+
const DATA_REMOVED_REGEXP = /DataRemoved_/gi; // not /DataRemoved-_/g
|
|
13
12
|
const DATA_REMOVEDS_REGEXP = /(data-removed-){2,}/g;
|
|
14
13
|
class GenericRenamePropertyTask extends abstract_task_1.AbstractTask {
|
|
15
14
|
constructor(identifier, description, tag, oldProperty, newProperty, versionRange, dependentTasks = [], options = {}) {
|
|
16
|
-
super(identifier, description,
|
|
15
|
+
super(identifier, description, types_1.MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
|
|
16
|
+
this.newProperty = newProperty;
|
|
17
17
|
if (!reuse_1.isTagKebabCaseRegExp.test(tag)) {
|
|
18
|
-
throw
|
|
18
|
+
throw (0, reuse_1.logAndCreateError)(`Tag "${tag}" is not in kebab case.`);
|
|
19
19
|
}
|
|
20
20
|
if (!reuse_1.isPropertyKebabCaseRegExp.test(oldProperty)) {
|
|
21
|
-
throw
|
|
21
|
+
throw (0, reuse_1.logAndCreateError)(`Old property "${oldProperty}" is not in kebab case.`);
|
|
22
22
|
}
|
|
23
23
|
if (!reuse_1.isPropertyKebabCaseRegExp.test(newProperty)) {
|
|
24
|
-
throw
|
|
24
|
+
throw (0, reuse_1.logAndCreateError)(`New property "${newProperty}" is not in kebab case.`);
|
|
25
25
|
}
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
this.newPropertyInCamelCase = (0, reuse_1.kebabToCapitalCase)(newProperty);
|
|
29
|
-
this.componentRegExp = new RegExp(`(<${(0, reuse_1.kebabToCapitalCase)(tag)}[^>]+)${this.oldPropertyInCamelCase}([ >=])`, 'g');
|
|
26
|
+
this.newPropertyInCamelCase = (0, reuse_1.kebabToCamelCase)(newProperty);
|
|
27
|
+
this.componentRegExp = new RegExp(`(<${(0, reuse_1.kebabToCapitalCase)(tag)}[^>]+)${(0, reuse_1.kebabToCapitalCase)(oldProperty)}([ >=])`, 'g');
|
|
30
28
|
this.customElementRegExp = new RegExp(`(<${tag}[^>]+)${oldProperty}([ >=])`, 'g');
|
|
31
29
|
}
|
|
32
30
|
run(baseDir) {
|
|
@@ -48,7 +46,7 @@ class GenericRenamePropertyTask extends abstract_task_1.AbstractTask {
|
|
|
48
46
|
});
|
|
49
47
|
}
|
|
50
48
|
transpileCustomElementFileRename(baseDir) {
|
|
51
|
-
(0, reuse_1.filterFilesByExt)(baseDir, types_1.
|
|
49
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
|
|
52
50
|
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
53
51
|
const newContent = content
|
|
54
52
|
// Replacements
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LabelExpertSlot = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const types_1 = require("../../../../types");
|
|
9
|
+
const reuse_1 = require("../../../shares/reuse");
|
|
10
|
+
const abstract_task_1 = require("../../abstract-task");
|
|
11
|
+
const removeLineBreaksAndSpaces = (match) => {
|
|
12
|
+
return match.replace(/\r?\n/g, ' ').replace(/>\s+/g, '>').replace(/\s+</g, '<');
|
|
13
|
+
};
|
|
14
|
+
class LabelExpertSlot extends abstract_task_1.AbstractTask {
|
|
15
|
+
constructor(identifier, tag, property, versionRange, dependentTasks, options) {
|
|
16
|
+
super(identifier, `Move innerText of "${tag}" component to property "${property}"`, types_1.MARKUP_EXTENSIONS, versionRange, dependentTasks, options);
|
|
17
|
+
this.property = property;
|
|
18
|
+
if (!reuse_1.isTagKebabCaseRegExp.test(tag)) {
|
|
19
|
+
throw (0, reuse_1.logAndCreateError)(`Tag "${tag}" is not in kebab case.`);
|
|
20
|
+
}
|
|
21
|
+
if (!reuse_1.isPropertyKebabCaseRegExp.test(property)) {
|
|
22
|
+
throw (0, reuse_1.logAndCreateError)(`Property "${property}" is not in kebab case.`);
|
|
23
|
+
}
|
|
24
|
+
const tagCapitalCase = (0, reuse_1.kebabToCapitalCase)(tag);
|
|
25
|
+
this.propertyInCamelCase = (0, reuse_1.kebabToCamelCase)(property);
|
|
26
|
+
// https://regex101.com/r/WkEKxu/1
|
|
27
|
+
this.componentRegExp = new RegExp(`(<${tagCapitalCase}[^>]*)>([^<]+(\\n\\s*)*)(<\\/${tagCapitalCase}>)`, 'g');
|
|
28
|
+
this.customElementRegExp = new RegExp(`(<${tag}[^>]*)>([^<]+(\\n\\s*)*)(<\\/${tag}>)`, 'g');
|
|
29
|
+
}
|
|
30
|
+
static getInstance(tag, property, versionRange, dependentTasks = [], options = {}) {
|
|
31
|
+
const identifier = `${tag}-move-innerText-to-property-${property}`;
|
|
32
|
+
if (!this.instances.has(identifier)) {
|
|
33
|
+
this.instances.set(identifier, new LabelExpertSlot(identifier, tag, property, versionRange, dependentTasks, options));
|
|
34
|
+
}
|
|
35
|
+
return this.instances.get(identifier);
|
|
36
|
+
}
|
|
37
|
+
run(baseDir) {
|
|
38
|
+
this.transpileComponentFileDelete(baseDir);
|
|
39
|
+
this.transpileCustomElementFileDelete(baseDir);
|
|
40
|
+
}
|
|
41
|
+
transpileComponentFileDelete(baseDir) {
|
|
42
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
43
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
44
|
+
const newContent = content
|
|
45
|
+
// Replacements
|
|
46
|
+
.replace(this.componentRegExp, removeLineBreaksAndSpaces)
|
|
47
|
+
.replace(this.componentRegExp, `$1 ${this.propertyInCamelCase}="$2">$4`);
|
|
48
|
+
if (content !== newContent) {
|
|
49
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
50
|
+
fs_1.default.writeFileSync(file, newContent);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
transpileCustomElementFileDelete(baseDir) {
|
|
55
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
56
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
57
|
+
const newContent = content
|
|
58
|
+
// Replacements
|
|
59
|
+
.replace(this.customElementRegExp, removeLineBreaksAndSpaces)
|
|
60
|
+
.replace(this.customElementRegExp, `$1 ${this.property}="$2">$4`);
|
|
61
|
+
if (content !== newContent) {
|
|
62
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
63
|
+
// fs.writeFileSync(file, newContent);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.LabelExpertSlot = LabelExpertSlot;
|
|
@@ -13,15 +13,16 @@ class RemovePropertyNameTask extends GenericRenamePropertyTask_1.GenericRenamePr
|
|
|
13
13
|
constructor(identifier, tag, property, versionRange, dependentTasks, options) {
|
|
14
14
|
super(identifier, `Remove property "${property}" of "${tag}" component`, tag, property, `data-removed-${property}`, versionRange, dependentTasks, options);
|
|
15
15
|
if (!reuse_1.isTagKebabCaseRegExp.test(tag)) {
|
|
16
|
-
throw
|
|
16
|
+
throw (0, reuse_1.logAndCreateError)(`Tag "${tag}" is not in kebab case.`);
|
|
17
17
|
}
|
|
18
18
|
if (!reuse_1.isPropertyKebabCaseRegExp.test(property)) {
|
|
19
|
-
throw
|
|
19
|
+
throw (0, reuse_1.logAndCreateError)(`Property "${property}" is not in kebab case.`);
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
21
|
+
const tagCapitalCase = (0, reuse_1.kebabToCapitalCase)(tag);
|
|
22
|
+
const propertyInCamelCase = (0, reuse_1.kebabToCamelCase)(property);
|
|
23
|
+
this.componentRegExpBoolean = new RegExp(`(<${tagCapitalCase}[^>]+)${propertyInCamelCase}([ >])`, 'g');
|
|
24
|
+
this.componentRegExpCurlyBrackets = new RegExp(`(<${tagCapitalCase}[^>]+)${propertyInCamelCase}(=\\{[^\\}]+\\})`, 'g');
|
|
25
|
+
this.componentRegExpQuotationMarks = new RegExp(`(<${tagCapitalCase}[^>]+)${propertyInCamelCase}(="[^"]+")`, 'g');
|
|
25
26
|
this.customElementRegExpBoolean = new RegExp(`(<${tag}[^>]+)${property}([ >])`, 'g');
|
|
26
27
|
this.customElementRegExpCurlyBrackets = new RegExp(`(<${tag}[^>]+)${property}(=\\{[^\\}]+\\})`, 'g');
|
|
27
28
|
this.customElementRegExpQuotationMarks = new RegExp(`(<${tag}[^>]+)${property}(="[^"]+")`, 'g');
|
|
@@ -59,7 +60,7 @@ class RemovePropertyNameTask extends GenericRenamePropertyTask_1.GenericRenamePr
|
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
transpileCustomElementFileDelete(baseDir) {
|
|
62
|
-
(0, reuse_1.filterFilesByExt)(baseDir, types_1.
|
|
63
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
|
|
63
64
|
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
64
65
|
const newContent = content
|
|
65
66
|
// Replacements
|
|
@@ -3,14 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RenamePropertyNameTask = void 0;
|
|
4
4
|
const GenericRenamePropertyTask_1 = require("./GenericRenamePropertyTask");
|
|
5
5
|
class RenamePropertyNameTask extends GenericRenamePropertyTask_1.GenericRenamePropertyTask {
|
|
6
|
-
constructor(identifier, tag, oldProperty, newProperty, versionRange, dependentTasks = [], options = {}) {
|
|
7
|
-
super(identifier, `Rename property "${oldProperty}" to "${newProperty}" of "${tag}" component`, tag, oldProperty, newProperty, versionRange, dependentTasks, options);
|
|
8
|
-
}
|
|
9
6
|
static getInstance(tag, oldProperty, newProperty, versionRange, dependentTasks = [], options = {}) {
|
|
10
7
|
var _a;
|
|
11
8
|
const identifier = `${tag}-rename-property-${oldProperty}-to-${newProperty}`;
|
|
12
9
|
if (!this.instances.has(identifier)) {
|
|
13
|
-
(_a = this.instances) === null || _a === void 0 ? void 0 : _a.set(identifier, new RenamePropertyNameTask(identifier, tag, oldProperty, newProperty, versionRange, dependentTasks, options));
|
|
10
|
+
(_a = this.instances) === null || _a === void 0 ? void 0 : _a.set(identifier, new RenamePropertyNameTask(identifier, `Rename property "${oldProperty}" to "${newProperty}" of "${tag}" component`, tag, oldProperty, newProperty, versionRange, dependentTasks, options));
|
|
14
11
|
}
|
|
15
12
|
return this.instances.get(identifier);
|
|
16
13
|
}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.testTasks = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
4
|
const reuse_1 = require("../../../shares/reuse");
|
|
9
5
|
const test_version_1_3_1 = require("./test-version-1.3");
|
|
6
|
+
const test_version_current_1 = require("./test-version-current");
|
|
10
7
|
const test_version_next_2_1 = require("./test-version-next-2");
|
|
11
8
|
const test_version_next_3_1 = require("./test-version-next-3");
|
|
12
9
|
const test_version_zero_1 = require("./test-version-zero");
|
|
13
|
-
const test_version_current_1 = require("./test-version-current");
|
|
14
10
|
exports.testTasks = [];
|
|
15
11
|
exports.testTasks.push(test_version_zero_1.TestVersionZero.getInstance());
|
|
16
12
|
exports.testTasks.push(test_version_next_2_1.TestVersionNext2.getInstance());
|
|
17
13
|
exports.testTasks.push(test_version_next_3_1.TestVersionNext3.getInstance());
|
|
18
14
|
exports.testTasks.push(test_version_1_3_1.TestVersion13.getInstance());
|
|
19
|
-
const versionOfPublicUiComponents = (0, reuse_1.
|
|
15
|
+
const versionOfPublicUiComponents = (0, reuse_1.getVersionOfPublicUiComponents)();
|
|
20
16
|
exports.testTasks.push(test_version_current_1.TestVersionCurrent.getInstance(versionOfPublicUiComponents));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.v1Tasks = void 0;
|
|
4
|
+
const LabelExpertSlot_1 = require("../common/LabelExpertSlot");
|
|
4
5
|
const abbr_1 = require("./abbr");
|
|
5
6
|
const accordion_1 = require("./accordion");
|
|
6
7
|
const badge_1 = require("./badge");
|
|
@@ -18,7 +19,11 @@ const input_number_1 = require("./input-number");
|
|
|
18
19
|
const input_radio_1 = require("./input-radio");
|
|
19
20
|
const input_range_1 = require("./input-range");
|
|
20
21
|
const input_text_1 = require("./input-text");
|
|
22
|
+
const link_1 = require("./link");
|
|
23
|
+
const link_button_1 = require("./link-button");
|
|
21
24
|
const link_group_1 = require("./link-group");
|
|
25
|
+
const logo_1 = require("./logo");
|
|
26
|
+
const modal_1 = require("./modal");
|
|
22
27
|
const nav_1 = require("./nav");
|
|
23
28
|
const pagination_1 = require("./pagination");
|
|
24
29
|
const progress_1 = require("./progress");
|
|
@@ -43,6 +48,7 @@ exports.v1Tasks.push(button_link_1.ButtonLinkRemovePropertyAriaLabel);
|
|
|
43
48
|
exports.v1Tasks.push(button_link_1.ButtonLinkRenamePropertyIconOnlyToHideLabel);
|
|
44
49
|
exports.v1Tasks.push(button_1.ButtonRemovePropertyAriaCurrent);
|
|
45
50
|
exports.v1Tasks.push(button_1.ButtonRemovePropertyAriaLabel);
|
|
51
|
+
exports.v1Tasks.push(button_1.ButtonRemovePropertyIconAlign);
|
|
46
52
|
exports.v1Tasks.push(button_1.ButtonRenamePropertyIconOnlyToHideLabel);
|
|
47
53
|
exports.v1Tasks.push(card_1.CardRenamePropertyHeadingToLabel);
|
|
48
54
|
exports.v1Tasks.push(card_1.CardRenamePropertyHeadlineToLabel);
|
|
@@ -57,11 +63,34 @@ exports.v1Tasks.push(input_number_1.InputNumberRenamePropertyListToSuggestions);
|
|
|
57
63
|
exports.v1Tasks.push(input_radio_1.InputRadioRenamePropertyListToSuggestions);
|
|
58
64
|
exports.v1Tasks.push(input_range_1.InputRangeRenamePropertyListToSuggestions);
|
|
59
65
|
exports.v1Tasks.push(input_text_1.InputTextRenamePropertyListToSuggestions);
|
|
66
|
+
exports.v1Tasks.push(link_button_1.LinkButtonRemovePropertyAriaControl);
|
|
67
|
+
exports.v1Tasks.push(link_button_1.LinkButtonRenamePropertyAriaCurrentToListenAriaCurrent);
|
|
68
|
+
exports.v1Tasks.push(link_button_1.LinkButtonRemovePropertyAriaExpanded);
|
|
69
|
+
exports.v1Tasks.push(link_button_1.LinkButtonRemovePropertyAriaLabel);
|
|
70
|
+
exports.v1Tasks.push(link_button_1.LinkButtonRemovePropertyAriaSelected);
|
|
71
|
+
exports.v1Tasks.push(link_button_1.LinkButtonRemovePropertyDisabled);
|
|
72
|
+
exports.v1Tasks.push(link_button_1.LinkButtonRenamePropertyIconOnlyToHideLabel);
|
|
73
|
+
exports.v1Tasks.push(link_1.LinkRemovePropertyAriaControl);
|
|
74
|
+
exports.v1Tasks.push(link_1.LinkRenamePropertyAriaCurrentToListenAriaCurrent);
|
|
75
|
+
exports.v1Tasks.push(link_1.LinkRemovePropertyAriaExpanded);
|
|
76
|
+
exports.v1Tasks.push(link_1.LinkRemovePropertyAriaLabel);
|
|
77
|
+
exports.v1Tasks.push(link_1.LinkRemovePropertyAriaSelected);
|
|
78
|
+
exports.v1Tasks.push(link_1.LinkRemovePropertyDisabled);
|
|
79
|
+
exports.v1Tasks.push(link_1.LinkRemovePropertyIconAlign);
|
|
80
|
+
exports.v1Tasks.push(link_1.LinkRenamePropertyIconOnlyToHideLabel);
|
|
81
|
+
exports.v1Tasks.push(link_1.LinkRemovePropertySelector);
|
|
82
|
+
exports.v1Tasks.push(link_1.LinkRemovePropertyStealth);
|
|
83
|
+
exports.v1Tasks.push(link_1.LinkRemovePropertyUseCase);
|
|
84
|
+
exports.v1Tasks.push(logo_1.LogoRenamePropertyAbbrToOrg);
|
|
60
85
|
exports.v1Tasks.push(link_group_1.LinkGroupRenamePropertyAriaLabelToLabel);
|
|
86
|
+
exports.v1Tasks.push(link_group_1.LinkGroupRenamePropertyHeadingToLabel);
|
|
87
|
+
exports.v1Tasks.push(link_group_1.LinkGroupRemovePropertyHeading);
|
|
61
88
|
exports.v1Tasks.push(link_group_1.LinkGroupRemovePropertyOrdered);
|
|
89
|
+
exports.v1Tasks.push(modal_1.ModalRenamePropertyAriaLabelToLabel);
|
|
62
90
|
exports.v1Tasks.push(nav_1.NavRenamePropertyAriaLabelToLabel);
|
|
63
91
|
exports.v1Tasks.push(nav_1.NavRenamePropertyCompactToHideLabel);
|
|
64
92
|
exports.v1Tasks.push(nav_1.NavRemovePropertyHasCompactButton);
|
|
93
|
+
exports.v1Tasks.push(nav_1.NavRemovePropertyVariant);
|
|
65
94
|
exports.v1Tasks.push(nav_1.NavRenamePropertyCompactToHideLabel);
|
|
66
95
|
exports.v1Tasks.push(pagination_1.PaginationRenamePropertyCountToTotal);
|
|
67
96
|
exports.v1Tasks.push(progress_1.ProgressRenamePropertyTypeToVariant);
|
|
@@ -76,3 +105,17 @@ exports.v1Tasks.push(tabs_1.TabsRenamePropertyAriaLabelToLabel);
|
|
|
76
105
|
exports.v1Tasks.push(tabs_1.TabsRenamePropertyTabAlignToAlign);
|
|
77
106
|
exports.v1Tasks.push(toast_1.ToastRenamePropertyHeadingToLabel);
|
|
78
107
|
exports.v1Tasks.push(version_1.VersionRenamePropertyVersionToLabel);
|
|
108
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-heading', '_label', '^1'));
|
|
109
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-checkbox', '_label', '^1'));
|
|
110
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-color', '_label', '^1'));
|
|
111
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-date', '_label', '^1'));
|
|
112
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-email', '_label', '^1'));
|
|
113
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-file', '_label', '^1'));
|
|
114
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-number', '_label', '^1'));
|
|
115
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-password', '_label', '^1'));
|
|
116
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-radio', '_label', '^1'));
|
|
117
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-range', '_label', '^1'));
|
|
118
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-input-text', '_label', '^1'));
|
|
119
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-link', '_label', '^1'));
|
|
120
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-select', '_label', '^1'));
|
|
121
|
+
// v1Tasks.push(LabelExpertSlot.getInstance('kol-textarea', '_label', '^1'));
|
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InputNumberRenamePropertyListToSuggestions = void 0;
|
|
4
4
|
const RenamePropertyNameTask_1 = require("../common/RenamePropertyNameTask");
|
|
5
5
|
exports.InputNumberRenamePropertyListToSuggestions = RenamePropertyNameTask_1.RenamePropertyNameTask.getInstance('kol-input-number', '_list', '_suggestions', '^1');
|
|
6
|
-
// export const InputNumberRemovePropertyType = RemovePropertyNameTask.getInstance('kol-input-number', '_type', '^1');
|
|
6
|
+
// @todo export const InputNumberRemovePropertyType = RemovePropertyNameTask.getInstance('kol-input-number', '_type', '^1');
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinkGroupRemovePropertyOrdered = exports.LinkGroupRemovePropertyHeading = exports.LinkGroupRenamePropertyAriaLabelToLabel = void 0;
|
|
3
|
+
exports.LinkGroupRemovePropertyOrdered = exports.LinkGroupRemovePropertyHeading = exports.LinkGroupRenamePropertyHeadingToLabel = exports.LinkGroupRenamePropertyAriaLabelToLabel = void 0;
|
|
4
4
|
const RemovePropertyNameTask_1 = require("../common/RemovePropertyNameTask");
|
|
5
5
|
const RenamePropertyNameTask_1 = require("../common/RenamePropertyNameTask");
|
|
6
6
|
exports.LinkGroupRenamePropertyAriaLabelToLabel = RenamePropertyNameTask_1.RenamePropertyNameTask.getInstance('kol-link-group', '_aria-label', '_label', '^1');
|
|
7
|
-
exports.
|
|
7
|
+
exports.LinkGroupRenamePropertyHeadingToLabel = RenamePropertyNameTask_1.RenamePropertyNameTask.getInstance('kol-link-group', '_heading', '_label', '^1');
|
|
8
|
+
exports.LinkGroupRemovePropertyHeading = RemovePropertyNameTask_1.RemovePropertyNameTask.getInstance('kol-link-group', '_heading', '^1', [exports.LinkGroupRenamePropertyHeadingToLabel]);
|
|
8
9
|
exports.LinkGroupRemovePropertyOrdered = RemovePropertyNameTask_1.RemovePropertyNameTask.getInstance('kol-link-group', '_ordered', '^1');
|
|
@@ -3,9 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getVersionOfPublicUiKoliBriCli = exports.getVersionOfPublicUiComponents = exports.getContentOfProjectPkgJson = exports.getRemoveMode = exports.setRemoveMode = exports.MODIFIED_FILES = exports.kebabToCamelCase = exports.kebabToCapitalCase = exports.isPropertyKebabCaseRegExp = exports.isTagKebabCaseRegExp = exports.getPackageManagerInstallCommand = exports.filterFilesByExt = exports.logAndCreateError = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
/**
|
|
11
|
+
* This function is used to exit the process with an error message.
|
|
12
|
+
* @param {string} msg The error message
|
|
13
|
+
* @param {string} hint The hint message
|
|
14
|
+
* @returns {Error} The error object
|
|
15
|
+
*/
|
|
16
|
+
function logAndCreateError(msg, hint) {
|
|
17
|
+
const hintText = hint
|
|
18
|
+
? chalk_1.default.yellow(`
|
|
19
|
+
ℹ️ `, chalk_1.default.underline.bold(`Hinweis:`), hint, `
|
|
20
|
+
`)
|
|
21
|
+
: '';
|
|
22
|
+
console.log(chalk_1.default.red(chalk_1.default.underline.bold(`
|
|
23
|
+
Error:`), `${msg}
|
|
24
|
+
`), hintText, `
|
|
25
|
+
👉 You can report this error to`, chalk_1.default.blue(`https://github.com/public-ui/kolibri/issues/new?title=CLI:+`), `
|
|
26
|
+
`);
|
|
27
|
+
// @todo process.exit(1); // makes `hint` undefined - ?!
|
|
28
|
+
return new Error();
|
|
29
|
+
}
|
|
30
|
+
exports.logAndCreateError = logAndCreateError;
|
|
9
31
|
/**
|
|
10
32
|
* Recursively searches for files with the specified extension in the specified directory.
|
|
11
33
|
* @param {string} dir The directory to search in
|
|
@@ -28,24 +50,6 @@ function filterFilesByExt(dir, ext) {
|
|
|
28
50
|
return files;
|
|
29
51
|
}
|
|
30
52
|
exports.filterFilesByExt = filterFilesByExt;
|
|
31
|
-
/**
|
|
32
|
-
* This function is used to get the versions of @public-ui in the package.json.
|
|
33
|
-
* @param {Record<string, unknown>} packageJson The package.json as object
|
|
34
|
-
* @returns {Map<string, string>} The versions of @public-ui packages
|
|
35
|
-
*/
|
|
36
|
-
function getPublicUiVersions(packageJson) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const publicUiVersions = new Map();
|
|
39
|
-
const dependencies = (_a = packageJson.dependencies) !== null && _a !== void 0 ? _a : {};
|
|
40
|
-
const devDependencies = (_b = packageJson.devDependencies) !== null && _b !== void 0 ? _b : {};
|
|
41
|
-
for (const [name, version] of Object.entries(Object.assign(Object.assign({}, dependencies), devDependencies))) {
|
|
42
|
-
if (name.startsWith('@public-ui/')) {
|
|
43
|
-
publicUiVersions.set(name, version);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return publicUiVersions;
|
|
47
|
-
}
|
|
48
|
-
exports.getPublicUiVersions = getPublicUiVersions;
|
|
49
53
|
/**
|
|
50
54
|
* This function is used to get the version of the package.json as string.
|
|
51
55
|
* @param {string} offsetPath The offset path to the package.json
|
|
@@ -54,11 +58,10 @@ exports.getPublicUiVersions = getPublicUiVersions;
|
|
|
54
58
|
function readPackageString(offsetPath) {
|
|
55
59
|
offsetPath = path_1.default.resolve(offsetPath, 'package.json');
|
|
56
60
|
if (!fs_1.default.existsSync(offsetPath)) {
|
|
57
|
-
throw
|
|
61
|
+
throw logAndCreateError(`The following "package.json" does not exists: ${offsetPath}`);
|
|
58
62
|
}
|
|
59
63
|
return fs_1.default.readFileSync(offsetPath, 'utf8');
|
|
60
64
|
}
|
|
61
|
-
exports.readPackageString = readPackageString;
|
|
62
65
|
/**
|
|
63
66
|
* This function is used to get the version of the package.json.
|
|
64
67
|
* @param {string} offsetPath The offset path to the package.json
|
|
@@ -71,11 +74,10 @@ function readPackageJson(offsetPath) {
|
|
|
71
74
|
json = JSON.parse(content);
|
|
72
75
|
}
|
|
73
76
|
catch (err) {
|
|
74
|
-
throw
|
|
77
|
+
throw logAndCreateError(`The following "package.json" content could not parse: ${content}`);
|
|
75
78
|
}
|
|
76
79
|
return json;
|
|
77
80
|
}
|
|
78
|
-
exports.readPackageJson = readPackageJson;
|
|
79
81
|
/**
|
|
80
82
|
* This function is used to get the package manager install command.
|
|
81
83
|
* @param {string} baseDir The base directory to start searching for the package manager
|
|
@@ -90,7 +92,7 @@ function getPackageManagerInstallCommand(baseDir = process.cwd()) {
|
|
|
90
92
|
return 'npm i';
|
|
91
93
|
baseDir = path_1.default.resolve(baseDir, '..');
|
|
92
94
|
if (baseDir === '/') {
|
|
93
|
-
throw
|
|
95
|
+
throw logAndCreateError('Package manager could not detected.');
|
|
94
96
|
}
|
|
95
97
|
return getPackageManagerInstallCommand(baseDir);
|
|
96
98
|
}
|
|
@@ -99,18 +101,30 @@ exports.isTagKebabCaseRegExp = /^kol-[a-z]+(-[a-z]+)*$/;
|
|
|
99
101
|
exports.isPropertyKebabCaseRegExp = /^(data-removed-)?_[a-z]+(-[a-z]+)*$/;
|
|
100
102
|
/**
|
|
101
103
|
* Converts a kebab case string to a capital case string.
|
|
102
|
-
* @param {string}
|
|
104
|
+
* @param {string} str The kebab case string
|
|
103
105
|
* @returns {string} The capital case string
|
|
104
106
|
*/
|
|
105
|
-
function kebabToCapitalCase(
|
|
106
|
-
return
|
|
107
|
+
function kebabToCapitalCase(str) {
|
|
108
|
+
return str
|
|
107
109
|
.split('-') // Split on hyphen
|
|
108
110
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) // Capitalize each word
|
|
109
111
|
.join(''); // Join without space
|
|
110
112
|
}
|
|
111
113
|
exports.kebabToCapitalCase = kebabToCapitalCase;
|
|
114
|
+
/**
|
|
115
|
+
* Converts a kebab case string to a camel case string.
|
|
116
|
+
* @param {string} str The kebab case string
|
|
117
|
+
* @returns {string} The camel case string
|
|
118
|
+
*/
|
|
119
|
+
function kebabToCamelCase(str) {
|
|
120
|
+
return str
|
|
121
|
+
.split('-') // Split on hyphen
|
|
122
|
+
.map((word, index) => (index === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())) // Capitalize each word
|
|
123
|
+
.join(''); // Join without space
|
|
124
|
+
}
|
|
125
|
+
exports.kebabToCamelCase = kebabToCamelCase;
|
|
112
126
|
exports.MODIFIED_FILES = new Set();
|
|
113
|
-
let REMOVE_MODE = '
|
|
127
|
+
let REMOVE_MODE = 'prefix';
|
|
114
128
|
/**
|
|
115
129
|
* Sets the remove mode.
|
|
116
130
|
* @param {RemoveMode} mode The remove mode
|
|
@@ -127,3 +141,30 @@ function getRemoveMode() {
|
|
|
127
141
|
return REMOVE_MODE;
|
|
128
142
|
}
|
|
129
143
|
exports.getRemoveMode = getRemoveMode;
|
|
144
|
+
const getContentOfProjectPkgJson = () => {
|
|
145
|
+
try {
|
|
146
|
+
return readPackageString(path_1.default.resolve(process.cwd()));
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
throw logAndCreateError('Could not read content of project "package.json"!');
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
exports.getContentOfProjectPkgJson = getContentOfProjectPkgJson;
|
|
153
|
+
const getVersionOfPublicUiComponents = () => {
|
|
154
|
+
try {
|
|
155
|
+
return readPackageJson(path_1.default.resolve(process.cwd(), 'node_modules/@public-ui/components')).version;
|
|
156
|
+
}
|
|
157
|
+
catch (err) {
|
|
158
|
+
throw logAndCreateError('Could not get version of installed "@public-ui/components" package!', 'Check that you are in the root directory of your project and that the package "@public-ui/components" is installed.');
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
exports.getVersionOfPublicUiComponents = getVersionOfPublicUiComponents;
|
|
162
|
+
const getVersionOfPublicUiKoliBriCli = () => {
|
|
163
|
+
try {
|
|
164
|
+
return readPackageJson(path_1.default.resolve(__dirname, '..', '..', '..')).version;
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
throw logAndCreateError('Could not get version of global installed "@public-ui/kolibri-cli" package!', 'Install the package with: npm i -g @public-ui/kolibri-cli');
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
exports.getVersionOfPublicUiKoliBriCli = getVersionOfPublicUiKoliBriCli;
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CUSTOM_ELEMENT_FILE_EXTENSIONS = exports.COMPONENT_FILE_EXTENSIONS = exports.FILE_EXTENSIONS = void 0;
|
|
3
|
+
exports.MARKUP_EXTENSIONS = exports.CUSTOM_ELEMENT_FILE_EXTENSIONS = exports.COMPONENT_FILE_EXTENSIONS = exports.FILE_EXTENSIONS = void 0;
|
|
4
4
|
exports.FILE_EXTENSIONS = ['html', 'js', 'json', 'jsx', 'ts', 'tsx', 'vue'];
|
|
5
5
|
exports.COMPONENT_FILE_EXTENSIONS = ['jsx', 'tsx', 'vue'];
|
|
6
6
|
exports.CUSTOM_ELEMENT_FILE_EXTENSIONS = ['html', 'jsx', 'tsx', 'vue'];
|
|
7
|
+
exports.MARKUP_EXTENSIONS = exports.COMPONENT_FILE_EXTENSIONS.concat(exports.CUSTOM_ELEMENT_FILE_EXTENSIONS);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@public-ui/kolibri-cli",
|
|
3
|
-
"version": "1.7.0-rc.
|
|
3
|
+
"version": "1.7.0-rc.10",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": "https://github.com/public-ui/kolibri",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"description": "CLI for executing some helpful commands for KoliBri projects.",
|
|
19
19
|
"scripts": {
|
|
20
20
|
"reset": "pnpm i @public-ui/components@1.1.7",
|
|
21
|
-
"depcheck": "depcheck --
|
|
21
|
+
"depcheck": "depcheck --ignores=\"@public-ui/components,loglevel,mocha\"",
|
|
22
22
|
"format": "prettier -c src",
|
|
23
23
|
"lint": "eslint src && tsc --noEmit",
|
|
24
24
|
"prepack": "tsc",
|
|
25
|
-
"start": "ts-node src/index.ts migrate --test-tasks test",
|
|
25
|
+
"start": "ts-node src/index.ts migrate --ignore-uncommitted-changes --test-tasks test",
|
|
26
26
|
"restart": "pnpm reset && pnpm start",
|
|
27
27
|
"unused": "knip",
|
|
28
|
-
"
|
|
29
|
-
"watch": "nodemon --ignore package.json src/index.ts migrate --test-tasks test"
|
|
28
|
+
"watch": "nodemon --ignore package.json src/index.ts migrate --ignore-uncommitted-changes --test-tasks test"
|
|
30
29
|
},
|
|
30
|
+
"type": "commonjs",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"chalk": "
|
|
32
|
+
"chalk": "^4",
|
|
33
33
|
"commander": "11.0.0",
|
|
34
34
|
"gradient-string": "2.0.2",
|
|
35
35
|
"loglevel": "1.8.1",
|
|
@@ -37,23 +37,23 @@
|
|
|
37
37
|
"semver": "7.5.4"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@public-ui/components": "1.
|
|
40
|
+
"@public-ui/components": "1.6.2",
|
|
41
41
|
"@types/gradient-string": "1.1.2",
|
|
42
|
-
"@types/node": "20.
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
44
|
-
"@typescript-eslint/parser": "6.
|
|
45
|
-
"depcheck": "1.4.
|
|
42
|
+
"@types/node": "20.6.0",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "6.7.0",
|
|
44
|
+
"@typescript-eslint/parser": "6.7.0",
|
|
45
|
+
"depcheck": "1.4.6",
|
|
46
|
+
"eslint": "8.49.0",
|
|
46
47
|
"eslint-config-prettier": "9.0.0",
|
|
47
48
|
"eslint-plugin-html": "7.1.0",
|
|
48
|
-
"eslint-plugin-jsdoc": "46.
|
|
49
|
+
"eslint-plugin-jsdoc": "46.6.0",
|
|
49
50
|
"eslint-plugin-json": "3.1.0",
|
|
50
51
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
51
52
|
"eslint-plugin-no-loops": "0.3.0",
|
|
52
53
|
"eslint-plugin-react": "7.33.2",
|
|
53
|
-
"knip": "2.
|
|
54
|
+
"knip": "2.24.0",
|
|
54
55
|
"mocha": "10.2.0",
|
|
55
56
|
"nodemon": "3.0.1",
|
|
56
|
-
"npm-check-updates": "16.13.2",
|
|
57
57
|
"ts-node": "10.9.1",
|
|
58
58
|
"typescript": "5.2.2"
|
|
59
59
|
},
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./test"), exports);
|
|
18
|
-
__exportStar(require("./v1"), exports);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.testTasks = void 0;
|
|
4
|
-
const test_version_1_3_1 = require("./v1/test-version-1.3");
|
|
5
|
-
const test_version_next_2_1 = require("./v1/test-version-next-2");
|
|
6
|
-
const test_version_next_3_1 = require("./v1/test-version-next-3");
|
|
7
|
-
const test_version_zero_1 = require("./v1/test-version-zero");
|
|
8
|
-
exports.testTasks = [];
|
|
9
|
-
exports.testTasks.push(test_version_zero_1.TestVersionZero.getInstance());
|
|
10
|
-
exports.testTasks.push(test_version_next_2_1.TestVersionNext2.getInstance());
|
|
11
|
-
exports.testTasks.push(test_version_next_3_1.TestVersionNext3.getInstance());
|
|
12
|
-
exports.testTasks.push(test_version_1_3_1.TestVersion13.getInstance());
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbbrPropertyRenamingTitleToLabel = void 0;
|
|
4
|
-
const reuse_1 = require("../../../shares/reuse");
|
|
5
|
-
const types_1 = require("../../../../types");
|
|
6
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
7
|
-
class AbbrPropertyRenamingTitleToLabel extends abstract_task_1.AbstractTask {
|
|
8
|
-
constructor() {
|
|
9
|
-
super('abbr-property-renaming-title-to-label', 'Renaming property `_title` to `_label`', types_1.COMPONENT_FILE_EXTENSIONS.concat(types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS), '>=1 <2');
|
|
10
|
-
}
|
|
11
|
-
static getInstance() {
|
|
12
|
-
if (!(this.instance instanceof AbbrPropertyRenamingTitleToLabel)) {
|
|
13
|
-
this.instance = new AbbrPropertyRenamingTitleToLabel();
|
|
14
|
-
}
|
|
15
|
-
return this.instance;
|
|
16
|
-
}
|
|
17
|
-
run(baseDir) {
|
|
18
|
-
this.transpileComponentFile(baseDir);
|
|
19
|
-
this.transpileCustomElementFile(baseDir);
|
|
20
|
-
}
|
|
21
|
-
transpileComponentFile(baseDir) {
|
|
22
|
-
const files = (0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS);
|
|
23
|
-
this.runDummy(files);
|
|
24
|
-
}
|
|
25
|
-
transpileCustomElementFile(baseDir) {
|
|
26
|
-
const files = (0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS);
|
|
27
|
-
this.runDummy(files);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.AbbrPropertyRenamingTitleToLabel = AbbrPropertyRenamingTitleToLabel;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccordionPropertyRenamingHeadingToLabel = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
const types_1 = require("../../../../types");
|
|
6
|
-
const reuse_1 = require("../../../shares/reuse");
|
|
7
|
-
class AccordionPropertyRenamingHeadingToLabel extends abstract_task_1.AbstractTask {
|
|
8
|
-
constructor() {
|
|
9
|
-
super('accordion-property-renaming-heading-to-label copy', 'Renaming property `_heading` to `_label`', types_1.COMPONENT_FILE_EXTENSIONS.concat(types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS), '>=1 <2');
|
|
10
|
-
}
|
|
11
|
-
static getInstance() {
|
|
12
|
-
if (!(this.instance instanceof AccordionPropertyRenamingHeadingToLabel)) {
|
|
13
|
-
this.instance = new AccordionPropertyRenamingHeadingToLabel();
|
|
14
|
-
}
|
|
15
|
-
return this.instance;
|
|
16
|
-
}
|
|
17
|
-
run(baseDir) {
|
|
18
|
-
this.transpileComponentFile(baseDir);
|
|
19
|
-
this.transpileCustomElementFile(baseDir);
|
|
20
|
-
}
|
|
21
|
-
transpileComponentFile(baseDir) {
|
|
22
|
-
const files = (0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS);
|
|
23
|
-
this.runDummy(files);
|
|
24
|
-
}
|
|
25
|
-
transpileCustomElementFile(baseDir) {
|
|
26
|
-
const files = (0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS);
|
|
27
|
-
this.runDummy(files);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.AccordionPropertyRenamingHeadingToLabel = AccordionPropertyRenamingHeadingToLabel;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersion13 = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersion13 extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('test-version-1.3', 'Test version 1.3', [], '1.3');
|
|
8
|
-
}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!(this.instance instanceof TestVersion13)) {
|
|
11
|
-
this.instance = new TestVersion13();
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersion13 = TestVersion13;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersionCurrent = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersionCurrent extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor(version) {
|
|
7
|
-
super('test-version-current', 'Test version current', [], version);
|
|
8
|
-
}
|
|
9
|
-
static getInstance(version) {
|
|
10
|
-
if (!(this.instance instanceof TestVersionCurrent)) {
|
|
11
|
-
this.instance = new TestVersionCurrent(version);
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersionCurrent = TestVersionCurrent;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersionNext2 = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersionNext2 extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('test-version-next-2', 'Test version next v2', [], '^2');
|
|
8
|
-
}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!(this.instance instanceof TestVersionNext2)) {
|
|
11
|
-
this.instance = new TestVersionNext2();
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersionNext2 = TestVersionNext2;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersionNext3 = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersionNext3 extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('test-version-next-3', 'Test version next v3', [], '^3');
|
|
8
|
-
}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!(this.instance instanceof TestVersionNext3)) {
|
|
11
|
-
this.instance = new TestVersionNext3();
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersionNext3 = TestVersionNext3;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestVersionZero = void 0;
|
|
4
|
-
const abstract_task_1 = require("../../abstract-task");
|
|
5
|
-
class TestVersionZero extends abstract_task_1.AbstractTask {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('test-version-zero', 'Test version zero', [], '<1');
|
|
8
|
-
}
|
|
9
|
-
static getInstance() {
|
|
10
|
-
if (!(this.instance instanceof TestVersionZero)) {
|
|
11
|
-
this.instance = new TestVersionZero();
|
|
12
|
-
}
|
|
13
|
-
return this.instance;
|
|
14
|
-
}
|
|
15
|
-
run() { }
|
|
16
|
-
}
|
|
17
|
-
exports.TestVersionZero = TestVersionZero;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AbstractTask = void 0;
|
|
7
|
-
const types_1 = require("../types");
|
|
8
|
-
const semver_1 = __importDefault(require("semver"));
|
|
9
|
-
const reuse_1 = require("../shares/reuse");
|
|
10
|
-
class AbstractTask {
|
|
11
|
-
constructor(identifier, title, extensions, version, options = {}) {
|
|
12
|
-
this.identifier = identifier;
|
|
13
|
-
this.title = title;
|
|
14
|
-
this.extensions = extensions;
|
|
15
|
-
this.version = version;
|
|
16
|
-
this.status = 'pending';
|
|
17
|
-
this.description = options.description;
|
|
18
|
-
this.extensions = this.extensions.filter((ext) => types_1.FILE_EXTENSIONS.includes(ext));
|
|
19
|
-
if (this.version && !semver_1.default.valid(this.version)) {
|
|
20
|
-
throw new Error(`[${this.identifier}] Invalid semver version: ${this.version}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
getDescription() {
|
|
24
|
-
return this.description;
|
|
25
|
-
}
|
|
26
|
-
getFiles(baseDir) {
|
|
27
|
-
return (0, reuse_1.filterFilesByExt)(baseDir, this.extensions);
|
|
28
|
-
}
|
|
29
|
-
getIdentifier() {
|
|
30
|
-
return this.identifier;
|
|
31
|
-
}
|
|
32
|
-
getStatus() {
|
|
33
|
-
return this.status;
|
|
34
|
-
}
|
|
35
|
-
getTitle() {
|
|
36
|
-
return this.title;
|
|
37
|
-
}
|
|
38
|
-
getVersion() {
|
|
39
|
-
return this.version;
|
|
40
|
-
}
|
|
41
|
-
setStatus(status) {
|
|
42
|
-
this.status = status;
|
|
43
|
-
}
|
|
44
|
-
static getInstance() {
|
|
45
|
-
throw new Error('not implemented');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.AbstractTask = AbstractTask;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TaskRunner = void 0;
|
|
7
|
-
const semver_1 = __importDefault(require("semver"));
|
|
8
|
-
class TaskRunner {
|
|
9
|
-
constructor(baseDir, version) {
|
|
10
|
-
this.baseDir = baseDir;
|
|
11
|
-
this.version = version;
|
|
12
|
-
this.tasks = [];
|
|
13
|
-
if (semver_1.default.valid(version) === null) {
|
|
14
|
-
throw new Error(`Invalid semver version: ${version}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
registerTask(task) {
|
|
18
|
-
this.tasks.concat(Array.isArray(task) ? task : [task]);
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
run() {
|
|
22
|
-
this.tasks.forEach((task) => {
|
|
23
|
-
console.log(task.getFiles(this.baseDir));
|
|
24
|
-
// task.run();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.TaskRunner = TaskRunner;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.AbbrPropertyRenamingTitleToLabel = void 0;
|
|
7
|
-
const abstract_task_1 = require("../abstract-task");
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
class AbbrPropertyRenamingTitleToLabel extends abstract_task_1.AbstractTask {
|
|
10
|
-
constructor() {
|
|
11
|
-
super('abbr-property-renaming-title-to-label', 'Renaming property `_title` to `_label`', ['html', 'jsx', 'tsx', 'vue'], '^1');
|
|
12
|
-
}
|
|
13
|
-
static getInstance() {
|
|
14
|
-
if (!(this.instance instanceof AbbrPropertyRenamingTitleToLabel)) {
|
|
15
|
-
this.instance = new AbbrPropertyRenamingTitleToLabel();
|
|
16
|
-
}
|
|
17
|
-
return this.instance;
|
|
18
|
-
}
|
|
19
|
-
run(files) {
|
|
20
|
-
for (const file of files) {
|
|
21
|
-
let content = fs_1.default.readFileSync(file, 'utf8');
|
|
22
|
-
content = content.replace(/_title="([^"]+)"/g, '_label="$1"');
|
|
23
|
-
fs_1.default.writeFileSync(file, content);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.AbbrPropertyRenamingTitleToLabel = AbbrPropertyRenamingTitleToLabel;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tasks = void 0;
|
|
4
|
-
const abbr_property_renaming_title_to_label_1 = require("./abbr-property-renaming-title-to-label");
|
|
5
|
-
exports.tasks = [];
|
|
6
|
-
exports.tasks.push(abbr_property_renaming_title_to_label_1.AbbrPropertyRenamingTitleToLabel.getInstance());
|
package/dist/runner/types.js
DELETED
package/dist/shares/reuse.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPublicUiVersions = exports.filterFilesByExt = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
/**
|
|
10
|
-
* Recursively searches for files with the specified extension in the specified.
|
|
11
|
-
* @param {string} dir The directory to search in
|
|
12
|
-
* @param {FileExtension | FileExtension[]} ext The extension to search for
|
|
13
|
-
* @returns {string[]} The found files
|
|
14
|
-
*/
|
|
15
|
-
function filterFilesByExt(dir, ext) {
|
|
16
|
-
ext = Array.isArray(ext) ? ext : [ext];
|
|
17
|
-
let files = [];
|
|
18
|
-
const dirPath = path_1.default.resolve(process.cwd(), dir);
|
|
19
|
-
fs_1.default.readdirSync(dirPath).forEach((file) => {
|
|
20
|
-
const fullPath = path_1.default.resolve(dir, file);
|
|
21
|
-
if (fs_1.default.lstatSync(fullPath).isDirectory()) {
|
|
22
|
-
files = files.concat(filterFilesByExt(fullPath, ext));
|
|
23
|
-
}
|
|
24
|
-
else if (ext.includes(path_1.default.extname(fullPath).replace('.', ''))) {
|
|
25
|
-
files.push(fullPath);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return files;
|
|
29
|
-
}
|
|
30
|
-
exports.filterFilesByExt = filterFilesByExt;
|
|
31
|
-
/**
|
|
32
|
-
* This function is used to get the versions of @public-ui in the package.json.
|
|
33
|
-
* @param {Record<string, unknown>} packageJson The package.json as object
|
|
34
|
-
* @returns {Map<string, string>} The versions of @public-ui packages
|
|
35
|
-
*/
|
|
36
|
-
function getPublicUiVersions(packageJson) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const publicUiVersions = new Map();
|
|
39
|
-
const dependencies = (_a = packageJson.dependencies) !== null && _a !== void 0 ? _a : {};
|
|
40
|
-
const devDependencies = (_b = packageJson.devDependencies) !== null && _b !== void 0 ? _b : {};
|
|
41
|
-
for (const [name, version] of Object.entries(Object.assign(Object.assign({}, dependencies), devDependencies))) {
|
|
42
|
-
if (name.startsWith('@public-ui/')) {
|
|
43
|
-
publicUiVersions.set(name, version);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return publicUiVersions;
|
|
47
|
-
}
|
|
48
|
-
exports.getPublicUiVersions = getPublicUiVersions;
|