@public-ui/kolibri-cli 3.0.7-rc.0 → 4.0.0-alpha.1
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.
|
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.v4Tasks = void 0;
|
|
4
4
|
const id_1 = require("./id");
|
|
5
5
|
const msg_1 = require("./msg");
|
|
6
|
+
const toast_1 = require("./toast");
|
|
7
|
+
const toaster_1 = require("./toaster");
|
|
6
8
|
exports.v4Tasks = [];
|
|
7
9
|
exports.v4Tasks.push(...id_1.RemoveIdPropTasks);
|
|
8
10
|
exports.v4Tasks.push(...msg_1.RemoveMsgPropsTasks);
|
|
11
|
+
exports.v4Tasks.push(toast_1.RemoveToastVariantTask.getInstance('^4'));
|
|
12
|
+
exports.v4Tasks.push(toaster_1.RemoveToasterGetInstanceOptionsTask.getInstance('^4'));
|
|
@@ -0,0 +1,56 @@
|
|
|
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.RemoveToastVariantTask = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const reuse_1 = require("../../../shares/reuse");
|
|
9
|
+
const abstract_task_1 = require("../../abstract-task");
|
|
10
|
+
// Toast migration should cover JavaScript/TypeScript files where toast services are used
|
|
11
|
+
const TOAST_FILE_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx', 'vue'];
|
|
12
|
+
class RemoveToastVariantTask extends abstract_task_1.AbstractTask {
|
|
13
|
+
toastEnqueueVariantRegExp;
|
|
14
|
+
toastObjectVariantRegExp;
|
|
15
|
+
constructor(identifier, versionRange, dependentTasks, options) {
|
|
16
|
+
super(identifier, 'Remove "variant" property from Toast objects in enqueue() calls', TOAST_FILE_EXTENSIONS, versionRange, dependentTasks, options);
|
|
17
|
+
// Match variant property in enqueue() calls - multiline support
|
|
18
|
+
this.toastEnqueueVariantRegExp = /(\benqueue\s*\(\s*\{[\s\S]*?)(\s*,?\s*variant\s*:\s*['"]\w+['"][\s\S]*?(?=\s*[,}]))([,\s]*[\s\S]*?\})/g;
|
|
19
|
+
// Match variant property in toast objects - multiline support
|
|
20
|
+
this.toastObjectVariantRegExp = /(\{\s*[\s\S]*?)(\s*,?\s*variant\s*:\s*['"]\w+['"][\s\S]*?(?=\s*[,}]))([,\s]*[\s\S]*?\})/g;
|
|
21
|
+
}
|
|
22
|
+
static getInstance(versionRange, dependentTasks, options) {
|
|
23
|
+
const identifier = `remove-toast-variant-${versionRange}`;
|
|
24
|
+
return new RemoveToastVariantTask(identifier, versionRange, dependentTasks, options);
|
|
25
|
+
}
|
|
26
|
+
run(baseDir) {
|
|
27
|
+
this.transpileFiles(baseDir);
|
|
28
|
+
}
|
|
29
|
+
transpileFiles(baseDir) {
|
|
30
|
+
(0, reuse_1.filterFilesByExt)(baseDir, TOAST_FILE_EXTENSIONS).forEach((file) => {
|
|
31
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
32
|
+
let newContent = content;
|
|
33
|
+
let modified = false;
|
|
34
|
+
// Simple RegEx to match variant lines
|
|
35
|
+
const variantLineRegExp = /^(\s*)variant\s*:\s*['"]\w+['"],?\s*$/gm;
|
|
36
|
+
// Check if the file likely contains toast-related code
|
|
37
|
+
if (content.includes('enqueue') || (content.includes('type:') && content.includes('variant:'))) {
|
|
38
|
+
newContent = newContent.replace(variantLineRegExp, () => {
|
|
39
|
+
modified = true;
|
|
40
|
+
return ''; // Remove the entire line
|
|
41
|
+
});
|
|
42
|
+
// Clean up potential comma issues after removing lines
|
|
43
|
+
newContent = newContent.replace(/,(\s*\n\s*\})/g, '$1'); // Comma before closing brace
|
|
44
|
+
newContent = newContent.replace(/\{(\s*\n\s*,)/g, '{$1'.replace(',', '')); // Comma after opening brace
|
|
45
|
+
newContent = newContent.replace(/,(\s*\n\s*,)/g, '$1'); // Double commas
|
|
46
|
+
// Remove excessive empty lines
|
|
47
|
+
newContent = newContent.replace(/\n\s*\n\s*\n/g, '\n\n');
|
|
48
|
+
}
|
|
49
|
+
if (modified && (0, reuse_1.getRemoveMode)()) {
|
|
50
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
51
|
+
fs_1.default.writeFileSync(file, newContent);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.RemoveToastVariantTask = RemoveToastVariantTask;
|
|
@@ -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.RemoveToasterGetInstanceOptionsTask = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const reuse_1 = require("../../../shares/reuse");
|
|
9
|
+
const abstract_task_1 = require("../../abstract-task");
|
|
10
|
+
// ToasterService migration should cover JavaScript/TypeScript files where the service is used
|
|
11
|
+
const TOASTER_FILE_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx', 'vue'];
|
|
12
|
+
class RemoveToasterGetInstanceOptionsTask extends abstract_task_1.AbstractTask {
|
|
13
|
+
getInstanceOptionsRegExp;
|
|
14
|
+
constructor(identifier, versionRange, dependentTasks, options) {
|
|
15
|
+
super(identifier, 'Remove "defaultVariant" option from ToasterService.getInstance() calls', TOASTER_FILE_EXTENSIONS, versionRange, dependentTasks, options);
|
|
16
|
+
// Match ToasterService.getInstance(document, { defaultVariant: '...' })
|
|
17
|
+
// This regex captures the service call and removes the options parameter if it only contains defaultVariant
|
|
18
|
+
this.getInstanceOptionsRegExp = /(\bToasterService\.getInstance\s*\(\s*[^,)]+)(\s*,\s*\{\s*defaultVariant\s*:\s*['"]\w+['"]\s*\})(\s*\))/g;
|
|
19
|
+
}
|
|
20
|
+
static getInstance(versionRange, dependentTasks, options) {
|
|
21
|
+
const identifier = `remove-toaster-get-instance-options-${versionRange}`;
|
|
22
|
+
return new RemoveToasterGetInstanceOptionsTask(identifier, versionRange, dependentTasks, options);
|
|
23
|
+
}
|
|
24
|
+
run(baseDir) {
|
|
25
|
+
this.transpileFiles(baseDir);
|
|
26
|
+
}
|
|
27
|
+
transpileFiles(baseDir) {
|
|
28
|
+
(0, reuse_1.filterFilesByExt)(baseDir, TOASTER_FILE_EXTENSIONS).forEach((file) => {
|
|
29
|
+
const content = fs_1.default.readFileSync(file, 'utf8');
|
|
30
|
+
let newContent = content;
|
|
31
|
+
let modified = false;
|
|
32
|
+
// Remove defaultVariant options from ToasterService.getInstance() calls
|
|
33
|
+
newContent = newContent.replace(this.getInstanceOptionsRegExp, (match, before, optionsParam, after) => {
|
|
34
|
+
modified = true;
|
|
35
|
+
// Simply remove the options parameter entirely
|
|
36
|
+
return before + after;
|
|
37
|
+
});
|
|
38
|
+
// Also handle more complex cases where there might be other options mixed in
|
|
39
|
+
// Match any options object that contains defaultVariant and remove just that property
|
|
40
|
+
const complexOptionsRegExp = /(\bToasterService\.getInstance\s*\(\s*[^,)]+\s*,\s*\{[^}]*?)(?:,\s*)?defaultVariant\s*:\s*['"]\w+['"](?:,\s*)?([^}]*\})/g;
|
|
41
|
+
newContent = newContent.replace(complexOptionsRegExp, (match, before, after) => {
|
|
42
|
+
// Only modify if we haven't already handled this with the simpler regex
|
|
43
|
+
if (!this.getInstanceOptionsRegExp.test(match)) {
|
|
44
|
+
modified = true;
|
|
45
|
+
// Clean up potential double commas
|
|
46
|
+
const cleanBefore = before.replace(/,\s*$/, '');
|
|
47
|
+
const cleanAfter = after.replace(/^\s*,/, '');
|
|
48
|
+
// Check if the options object would be empty after removing defaultVariant
|
|
49
|
+
if (cleanAfter.trim() === '}' && cleanBefore.trim().endsWith('{')) {
|
|
50
|
+
// Remove the entire options parameter
|
|
51
|
+
return cleanBefore.replace(/\s*,\s*\{\s*$/, '');
|
|
52
|
+
}
|
|
53
|
+
// Add comma if needed between remaining properties
|
|
54
|
+
if (cleanBefore.trim() !== '{' && cleanAfter.trim() !== '}' && !cleanBefore.endsWith(',') && !cleanAfter.startsWith(',')) {
|
|
55
|
+
return cleanBefore + ',' + cleanAfter;
|
|
56
|
+
}
|
|
57
|
+
return cleanBefore + cleanAfter;
|
|
58
|
+
}
|
|
59
|
+
return match;
|
|
60
|
+
});
|
|
61
|
+
if (modified && (0, reuse_1.getRemoveMode)()) {
|
|
62
|
+
reuse_1.MODIFIED_FILES.add(file);
|
|
63
|
+
fs_1.default.writeFileSync(file, newContent);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.RemoveToasterGetInstanceOptionsTask = RemoveToasterGetInstanceOptionsTask;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@public-ui/kolibri-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"homepage": "https://public-ui.github.io",
|
|
6
6
|
"repository": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"eslint-plugin-json": "3.1.0",
|
|
44
44
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
45
45
|
"eslint-plugin-react": "7.37.5",
|
|
46
|
-
"knip": "5.64.
|
|
46
|
+
"knip": "5.64.1",
|
|
47
47
|
"mocha": "11.7.2",
|
|
48
48
|
"nodemon": "3.1.10",
|
|
49
49
|
"rimraf": "6.0.1",
|
|
50
50
|
"ts-node": "10.9.2",
|
|
51
51
|
"typescript": "5.9.2",
|
|
52
|
-
"@public-ui/components": "
|
|
52
|
+
"@public-ui/components": "4.0.0-alpha.1"
|
|
53
53
|
},
|
|
54
54
|
"files": [
|
|
55
55
|
"dist"
|
|
@@ -61,11 +61,12 @@
|
|
|
61
61
|
"lint": "pnpm lint:eslint && pnpm lint:tsc",
|
|
62
62
|
"lint:eslint": "eslint src",
|
|
63
63
|
"lint:tsc": "tsc --noemit",
|
|
64
|
-
"
|
|
64
|
+
"pretest": "pnpm build",
|
|
65
65
|
"restart": "pnpm reset && pnpm start",
|
|
66
|
-
"
|
|
67
|
-
"watch": "nodemon --ignore package.json src/index.ts migrate --ignore-uncommitted-changes --test-tasks test",
|
|
66
|
+
"start": "rimraf test && cpy \"../../samples/react/src/components\" test/src && cpy \"../../samples/react/public/*.html\" test/ && ts-node src/index.ts migrate --ignore-uncommitted-changes --test-tasks test",
|
|
68
67
|
"test": "pnpm test:unit",
|
|
69
|
-
"test:unit": "cross-env TS_NODE_PROJECT=tsconfig.test.json mocha --require ts-node/register test/**/*.ts --no-experimental-strip-types"
|
|
68
|
+
"test:unit": "cross-env TS_NODE_PROJECT=tsconfig.test.json mocha --require ts-node/register test/**/*.ts --no-experimental-strip-types",
|
|
69
|
+
"unused": "knip",
|
|
70
|
+
"watch": "nodemon --ignore package.json src/index.ts migrate --ignore-uncommitted-changes --test-tasks test"
|
|
70
71
|
}
|
|
71
72
|
}
|