@public-ui/kolibri-cli 1.7.0-rc.13 → 1.7.0-rc.14
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 +9 -5
- package/dist/migrate/index.js +21 -3
- package/dist/migrate/runner/tasks/common/LabelExpertSlot.js +5 -3
- package/dist/migrate/runner/tasks/common/RefactorPropertyLabelReplaceFalse.js +53 -0
- package/dist/migrate/runner/tasks/common/VsCodeSettingsReconfigureTask.js +9 -4
- package/dist/migrate/runner/tasks/v1/index.js +14 -15
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -53,14 +53,17 @@ Actually the following migrations are available:
|
|
|
53
53
|
- Component removal (no one yet)
|
|
54
54
|
- Property renaming ✓
|
|
55
55
|
- Property removal ✓
|
|
56
|
-
- Property type change (`_label={false}`) ⏰
|
|
57
56
|
- Slots renaming (`content`) ✓
|
|
58
57
|
- Slots removal (`footer`, `header`) ✓
|
|
59
58
|
- Logic refactoring (no one yet)
|
|
60
59
|
- Expert-Slot refactoring ⏰
|
|
60
|
+
- Move `innerText` to property ✓
|
|
61
|
+
- Property type change (remove `_label={false}`) ⏰
|
|
62
|
+
- Set `_label=""` to activate the expert slot ⏰
|
|
61
63
|
- `.vscode/settings.json` add IntelliSense for HTML ✓
|
|
62
64
|
- `.gitignore` exclude `.kolibri.migrate.json` ✓
|
|
63
65
|
- `.tsconfig` add `@public-ui/components` to `types` array ✓
|
|
66
|
+
- Format modified files (`prettier@^3`) ✓
|
|
64
67
|
|
|
65
68
|
#### How does it work?
|
|
66
69
|
|
|
@@ -86,10 +89,11 @@ kolibri migrate <path>
|
|
|
86
89
|
|
|
87
90
|
#### Options
|
|
88
91
|
|
|
89
|
-
| Option | Description
|
|
90
|
-
| ------------------------------ |
|
|
91
|
-
| `--
|
|
92
|
-
| `--
|
|
92
|
+
| Option | Description | Type | Default |
|
|
93
|
+
| ------------------------------ | ---------------------------------------------- | :------------------: | :------: |
|
|
94
|
+
| `--format` | Try to format the modified files with prettier | boolean | true |
|
|
95
|
+
| `--ignore-uncommitted-changes` | Allows execution with unconfirmed changes | boolean | false |
|
|
96
|
+
| `--remove-mode` | Prefix property name or delete property | `delete` \| `prefix` | `prefix` |
|
|
93
97
|
|
|
94
98
|
#### Configuration
|
|
95
99
|
|
package/dist/migrate/index.js
CHANGED
|
@@ -3,6 +3,7 @@ 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
|
+
const node_child_process_1 = __importDefault(require("node:child_process"));
|
|
6
7
|
const child_process_1 = require("child_process");
|
|
7
8
|
const commander_1 = require("commander");
|
|
8
9
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -22,6 +23,7 @@ function default_1(program) {
|
|
|
22
23
|
.command('migrate')
|
|
23
24
|
.description('This command migrates KoliBri code to the current version.')
|
|
24
25
|
.argument('[string]', 'Source code folder to migrate', 'src')
|
|
26
|
+
.addOption(new commander_1.Option('--format', 'Try to format the modified files with prettier').default(true))
|
|
25
27
|
.addOption(new commander_1.Option('--ignore-uncommitted-changes', 'Allows execution with uncommitted changes').default(false))
|
|
26
28
|
.addOption(new commander_1.Option('--remove-mode <mode>', 'Prefix property name or delete property').choices(types_1.REMOVE_MODE).default('prefix'))
|
|
27
29
|
.addOption(new commander_1.Option('--test-tasks', 'Run additional test tasks').default(false).hideHelp())
|
|
@@ -88,12 +90,28 @@ Modified files: ${reuse_1.MODIFIED_FILES.size}`);
|
|
|
88
90
|
reuse_1.MODIFIED_FILES.forEach((file) => {
|
|
89
91
|
console.log(`- ${file}`);
|
|
90
92
|
});
|
|
93
|
+
if (options.format) {
|
|
94
|
+
console.log(`
|
|
95
|
+
We try to format the modified files with prettier...`);
|
|
96
|
+
try {
|
|
97
|
+
node_child_process_1.default.execFileSync('npx', ['prettier', '-w', ...Array.from(reuse_1.MODIFIED_FILES)], {
|
|
98
|
+
encoding: 'utf-8',
|
|
99
|
+
});
|
|
100
|
+
console.log(`Modified files have been formatted.`);
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
console.log(`Modified files could not be formatted. Please format them manually: npx prettier ${baseDir} -w`);
|
|
104
|
+
}
|
|
105
|
+
console.log();
|
|
106
|
+
}
|
|
91
107
|
console.log(`
|
|
92
|
-
After the code
|
|
108
|
+
After migrating the code, the formatting of the code may no longer be as desired. Therefore, reformat your code afterwards if necessary: npx prettier ${baseDir} -w
|
|
109
|
+
|
|
110
|
+
When migrating the labels, the text (innerText) is assigned 1 to 1 to the _label property. There could be the following situation, where manual corrections have to be made: _label={\`I am {count} years old.\`} -> _label={\`I am \${count} years old.\`} (add a $)
|
|
93
111
|
|
|
94
|
-
Afterwards, it may be that functions or themes
|
|
112
|
+
Afterwards, it may be that functions or themes have changed or are no longer included in newer major versions. This should be checked finally and corrected manually if necessary.
|
|
95
113
|
|
|
96
|
-
|
|
114
|
+
If something is wrong, the migration can be stopped with "git reset --hard HEAD~1" or by discarding the affected files. For more information, read the troubleshooting section in the README.`);
|
|
97
115
|
}
|
|
98
116
|
}
|
|
99
117
|
const status = runner.getStatus();
|
|
@@ -26,6 +26,8 @@ class LabelExpertSlot extends abstract_task_1.AbstractTask {
|
|
|
26
26
|
// https://regex101.com/r/WkEKxu/1
|
|
27
27
|
this.componentRegExp = new RegExp(`(<${tagCapitalCase}[^>]*)>([^<]+(\\n\\s*)*)(<\\/${tagCapitalCase}>)`, 'g');
|
|
28
28
|
this.customElementRegExp = new RegExp(`(<${tag}[^>]*)>([^<]+(\\n\\s*)*)(<\\/${tag}>)`, 'g');
|
|
29
|
+
this.componentRegExp = new RegExp(`(<${tagCapitalCase}[^>]+)>([^<>]+)(<\\/${tagCapitalCase}>)`, 'g');
|
|
30
|
+
this.customElementRegExp = new RegExp(`(<${tag}[^>]+)>([^<>]+)(<\\/${tag}>)`, 'g');
|
|
29
31
|
}
|
|
30
32
|
static getInstance(tag, property, versionRange, dependentTasks = [], options = {}) {
|
|
31
33
|
const identifier = `${tag}-move-innerText-to-property-${property}`;
|
|
@@ -44,7 +46,7 @@ class LabelExpertSlot extends abstract_task_1.AbstractTask {
|
|
|
44
46
|
const newContent = content
|
|
45
47
|
// Replacements
|
|
46
48
|
.replace(this.componentRegExp, removeLineBreaksAndSpaces)
|
|
47
|
-
.replace(this.componentRegExp, `$1 ${this.propertyInCamelCase}=
|
|
49
|
+
.replace(this.componentRegExp, `$1 ${this.propertyInCamelCase}={\`$2\`}/>`);
|
|
48
50
|
if (content !== newContent) {
|
|
49
51
|
reuse_1.MODIFIED_FILES.add(file);
|
|
50
52
|
fs_1.default.writeFileSync(file, newContent);
|
|
@@ -57,10 +59,10 @@ class LabelExpertSlot extends abstract_task_1.AbstractTask {
|
|
|
57
59
|
const newContent = content
|
|
58
60
|
// Replacements
|
|
59
61
|
.replace(this.customElementRegExp, removeLineBreaksAndSpaces)
|
|
60
|
-
.replace(this.customElementRegExp, `$1 ${this.property}=
|
|
62
|
+
.replace(this.customElementRegExp, `$1 ${this.property}={\`$2\`}/>`);
|
|
61
63
|
if (content !== newContent) {
|
|
62
64
|
reuse_1.MODIFIED_FILES.add(file);
|
|
63
|
-
|
|
65
|
+
fs_1.default.writeFileSync(file, newContent);
|
|
64
66
|
}
|
|
65
67
|
});
|
|
66
68
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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.RefactorPropertyLabelReplaceFalse = 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
|
+
class RefactorPropertyLabelReplaceFalse extends abstract_task_1.AbstractTask {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(`refactor-property-label-replace-false`, `Refactor property "_label" - replace "false" with ""`, types_1.MARKUP_EXTENSIONS, '>=1.6 <=1.7');
|
|
14
|
+
this.componentRegExp = /_label={false}/g;
|
|
15
|
+
this.customElementRegExp = /_label="false"/g;
|
|
16
|
+
}
|
|
17
|
+
static getInstance() {
|
|
18
|
+
const identifier = `refact-property-label-replace-false`;
|
|
19
|
+
if (!this.instances.has(identifier)) {
|
|
20
|
+
this.instances.set(identifier, new RefactorPropertyLabelReplaceFalse());
|
|
21
|
+
}
|
|
22
|
+
return this.instances.get(identifier);
|
|
23
|
+
}
|
|
24
|
+
run(baseDir) {
|
|
25
|
+
this.transpileComponentFileDelete(baseDir);
|
|
26
|
+
this.transpileCustomElementFileDelete(baseDir);
|
|
27
|
+
}
|
|
28
|
+
transpileComponentFileDelete(baseDir) {
|
|
29
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.COMPONENT_FILE_EXTENSIONS).forEach((file) => {
|
|
30
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
31
|
+
const newContent = content
|
|
32
|
+
// Replacements
|
|
33
|
+
.replace(this.componentRegExp, `_label=""`);
|
|
34
|
+
if (content !== newContent) {
|
|
35
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
36
|
+
fs_1.default.writeFileSync(file, newContent);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
transpileCustomElementFileDelete(baseDir) {
|
|
41
|
+
(0, reuse_1.filterFilesByExt)(baseDir, types_1.CUSTOM_ELEMENT_FILE_EXTENSIONS).forEach((file) => {
|
|
42
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
43
|
+
const newContent = content
|
|
44
|
+
// Replacements
|
|
45
|
+
.replace(this.customElementRegExp, `_label=""`);
|
|
46
|
+
if (content !== newContent) {
|
|
47
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
48
|
+
fs_1.default.writeFileSync(file, newContent);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.RefactorPropertyLabelReplaceFalse = RefactorPropertyLabelReplaceFalse;
|
|
@@ -33,10 +33,15 @@ class VsCodeSettingsReconfigureTask extends abstract_task_1.AbstractTask {
|
|
|
33
33
|
run() {
|
|
34
34
|
const settingsPath = path_1.default.join(process.cwd(), '.vscode', 'settings.json');
|
|
35
35
|
if (fs_1.default.existsSync(settingsPath)) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
try {
|
|
37
|
+
const fileContent = JSON.parse(fs_1.default.readFileSync(settingsPath, 'utf8'));
|
|
38
|
+
fileContent[this.key] = this.value;
|
|
39
|
+
fs_1.default.writeFileSync(settingsPath, JSON.stringify(fileContent, null, 2));
|
|
40
|
+
reuse_1.MODIFIED_FILES.add(settingsPath);
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
console.log(`Advice: Your .vscode/settings.json file is not valid JSON.`);
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
else {
|
|
42
47
|
fs_1.default.mkdirSync(path_1.default.dirname(settingsPath), { recursive: true });
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.v1Tasks = void 0;
|
|
4
4
|
const LabelExpertSlot_1 = require("../common/LabelExpertSlot");
|
|
5
5
|
const MarkRemovedSlotTask_1 = require("../common/MarkRemovedSlotTask");
|
|
6
|
+
const RefactorPropertyLabelReplaceFalse_1 = require("../common/RefactorPropertyLabelReplaceFalse");
|
|
6
7
|
const RenameSlotNameTask_1 = require("../common/RenameSlotNameTask");
|
|
7
8
|
const abbr_1 = require("./abbr");
|
|
8
9
|
const accordion_1 = require("./accordion");
|
|
@@ -110,24 +111,22 @@ exports.v1Tasks.push(toast_1.ToastRemovePropertyNameShowDuration);
|
|
|
110
111
|
exports.v1Tasks.push(toast_1.ToastRenamePropertyHeadingToLabel);
|
|
111
112
|
exports.v1Tasks.push(version_1.VersionRenamePropertyVersionToLabel);
|
|
112
113
|
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-heading', '_label', '^1'));
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-checkbox', '_label', '^1'));
|
|
115
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-color', '_label', '^1'));
|
|
116
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-date', '_label', '^1'));
|
|
117
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-email', '_label', '^1'));
|
|
118
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-file', '_label', '^1'));
|
|
119
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-number', '_label', '^1'));
|
|
120
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-password', '_label', '^1'));
|
|
121
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-radio', '_label', '^1'));
|
|
122
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-range', '_label', '^1'));
|
|
123
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-input-text', '_label', '^1'));
|
|
123
124
|
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-link', '_label', '^1'));
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-select', '_label', '^1'));
|
|
126
|
+
exports.v1Tasks.push(LabelExpertSlot_1.LabelExpertSlot.getInstance('kol-textarea', '_label', '^1'));
|
|
126
127
|
exports.v1Tasks.push(MarkRemovedSlotTask_1.MarkRemovedSlotTask.getInstance('kol-accordion', 'header', '^1'));
|
|
127
128
|
exports.v1Tasks.push(MarkRemovedSlotTask_1.MarkRemovedSlotTask.getInstance('kol-card', 'footer', '^1'));
|
|
128
129
|
exports.v1Tasks.push(MarkRemovedSlotTask_1.MarkRemovedSlotTask.getInstance('kol-card', 'header', '^1'));
|
|
129
130
|
exports.v1Tasks.push(RenameSlotNameTask_1.RenameSlotNameTask.getInstance('kol-accordion', 'content', '', '^1'));
|
|
130
131
|
exports.v1Tasks.push(RenameSlotNameTask_1.RenameSlotNameTask.getInstance('kol-card', 'content', '', '^1'));
|
|
131
|
-
|
|
132
|
-
// .vscode/settings.json
|
|
133
|
-
// tsconfig.json
|
|
132
|
+
exports.v1Tasks.push(RefactorPropertyLabelReplaceFalse_1.RefactorPropertyLabelReplaceFalse.getInstance());
|
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.14",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": "https://github.com/public-ui/kolibri",
|
|
@@ -38,22 +38,22 @@
|
|
|
38
38
|
"semver": "7.5.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@public-ui/components": "1.
|
|
42
|
-
"@types/gradient-string": "1.1.
|
|
43
|
-
"@types/node": "20.6.
|
|
41
|
+
"@public-ui/components": "1.7.0-rc.14",
|
|
42
|
+
"@types/gradient-string": "1.1.3",
|
|
43
|
+
"@types/node": "20.6.5",
|
|
44
44
|
"@typescript-eslint/eslint-plugin": "6.7.2",
|
|
45
45
|
"@typescript-eslint/parser": "6.7.2",
|
|
46
46
|
"cpy-cli": "5.0.0",
|
|
47
47
|
"depcheck": "1.4.6",
|
|
48
|
-
"eslint": "8.
|
|
48
|
+
"eslint": "8.50.0",
|
|
49
49
|
"eslint-config-prettier": "9.0.0",
|
|
50
50
|
"eslint-plugin-html": "7.1.0",
|
|
51
|
-
"eslint-plugin-jsdoc": "46.8.
|
|
51
|
+
"eslint-plugin-jsdoc": "46.8.2",
|
|
52
52
|
"eslint-plugin-json": "3.1.0",
|
|
53
53
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
54
54
|
"eslint-plugin-no-loops": "0.3.0",
|
|
55
55
|
"eslint-plugin-react": "7.33.2",
|
|
56
|
-
"knip": "2.
|
|
56
|
+
"knip": "2.27.1",
|
|
57
57
|
"mocha": "10.2.0",
|
|
58
58
|
"nodemon": "3.0.1",
|
|
59
59
|
"rimraf": "3.0.2",
|