@ornikar/kitt-universal 25.60.0 → 25.61.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/CHANGELOG.md +14 -0
- package/dist/definitions/ActionCard/ActionCard.d.ts.map +1 -1
- package/dist/definitions/BottomSheet/BottomSheet.d.ts +1 -1
- package/dist/definitions/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/definitions/BottomSheet/useBottomSheet.d.ts +1 -1
- package/dist/definitions/BottomSheet/useBottomSheet.d.ts.map +1 -1
- package/dist/definitions/BottomSheet/useStaticBottomSheet.d.ts +1 -1
- package/dist/definitions/BottomSheet/useStaticBottomSheet.d.ts.map +1 -1
- package/dist/definitions/Button/Button.d.ts +1 -1
- package/dist/definitions/Button/Button.d.ts.map +1 -1
- package/dist/definitions/Choices/Choices.d.ts +3 -3
- package/dist/definitions/Choices/Choices.d.ts.map +1 -1
- package/dist/definitions/ExternalAppLink/ExternalAppLink.d.ts +9 -9
- package/dist/definitions/ExternalAppLink/ExternalAppLink.d.ts.map +1 -1
- package/dist/definitions/ExternalLink/ExternalLink.d.ts +4 -4
- package/dist/definitions/ExternalLink/ExternalLink.d.ts.map +1 -1
- package/dist/definitions/ExternalLink/ExternalLink.web.d.ts +2 -2
- package/dist/definitions/ExternalLink/ExternalLink.web.d.ts.map +1 -1
- package/dist/definitions/GoogleMapsAutocompleteProvider/GoogleMapsAutocompleteProvider.d.ts +2 -2
- package/dist/definitions/GoogleMapsAutocompleteProvider/GoogleMapsAutocompleteProvider.d.ts.map +1 -1
- package/dist/definitions/Icon/Icon.d.ts +1 -1
- package/dist/definitions/Icon/Icon.d.ts.map +1 -1
- package/dist/definitions/Icon/SpinningIcon.d.ts +1 -1
- package/dist/definitions/Icon/SpinningIcon.d.ts.map +1 -1
- package/dist/definitions/IconButton/IconButton.d.ts +1 -1
- package/dist/definitions/IconButton/IconButton.d.ts.map +1 -1
- package/dist/definitions/ModalBehaviour/ModalBehaviour.d.ts +1 -1
- package/dist/definitions/ModalBehaviour/ModalBehaviour.d.ts.map +1 -1
- package/dist/definitions/Picker/Picker.d.ts +2 -2
- package/dist/definitions/Picker/Picker.d.ts.map +1 -1
- package/dist/definitions/Tag/Tag.d.ts +1 -1
- package/dist/definitions/Tag/Tag.d.ts.map +1 -1
- package/dist/definitions/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/definitions/Toast/Toast.utils.d.ts +1 -1
- package/dist/definitions/Toast/Toast.utils.d.ts.map +1 -1
- package/dist/definitions/Tooltip/Tooltip.d.ts +2 -2
- package/dist/definitions/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/definitions/forms/DatePicker/components/KeyboardDatePicker.d.ts.map +1 -1
- package/dist/definitions/forms/InputIcon/InputIcon.d.ts +1 -1
- package/dist/definitions/forms/InputIcon/InputIcon.d.ts.map +1 -1
- package/dist/definitions/forms/InputTag/InputTag.d.ts +1 -1
- package/dist/definitions/forms/InputTag/InputTag.d.ts.map +1 -1
- package/dist/definitions/forms/InputText/InputText.d.ts.map +1 -1
- package/dist/definitions/forms/Radio/OuterCircle.d.ts +2 -2
- package/dist/definitions/forms/Radio/OuterCircle.d.ts.map +1 -1
- package/dist/definitions/utils/tests/renderWithProvidersUtils.d.ts +3 -3
- package/dist/definitions/utils/tests/renderWithProvidersUtils.d.ts.map +1 -1
- package/dist/index-metro.es.android.js.map +1 -1
- package/dist/index-metro.es.ios.js.map +1 -1
- package/dist/index-node-20.10.cjs.js.map +1 -1
- package/dist/index-node-20.10.cjs.web.js.map +1 -1
- package/dist/index-node-20.10.es.mjs.map +1 -1
- package/dist/index-node-20.10.es.web.mjs.map +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.web.js.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +6 -1
- package/scripts/run-transformers.js +113 -0
- package/scripts/transformers/modals.js +102 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ornikar/kitt-universal",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.61.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "@ornikar/kitt-universal",
|
|
@@ -71,6 +71,9 @@
|
|
|
71
71
|
"./translations/es-ES.json": "./translations/es-ES.json",
|
|
72
72
|
"./babel-plugin-csf-to-jest": "./babel-plugin-csf-to-jest.js"
|
|
73
73
|
},
|
|
74
|
+
"bin": {
|
|
75
|
+
"run-transformers": "./scripts/run-transformers.js"
|
|
76
|
+
},
|
|
74
77
|
"engines": {
|
|
75
78
|
"node": ">=20.10.0"
|
|
76
79
|
},
|
|
@@ -164,8 +167,10 @@
|
|
|
164
167
|
"@types/react": "18.3.23",
|
|
165
168
|
"@types/react-portal": "4.0.7",
|
|
166
169
|
"@types/react-transition-group": "4.2.3",
|
|
170
|
+
"diff": "8.0.2",
|
|
167
171
|
"expo-document-picker": "11.10.1",
|
|
168
172
|
"expo-image-picker": "14.7.1",
|
|
173
|
+
"jscodeshift": "17.3.0",
|
|
169
174
|
"react": "18.3.1",
|
|
170
175
|
"react-dom": "18.3.1",
|
|
171
176
|
"react-error-boundary": "3.1.4",
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* eslint-disable global-require */
|
|
4
|
+
/* eslint-disable import/no-dynamic-require */
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const fs = require('node:fs');
|
|
9
|
+
const path = require('node:path');
|
|
10
|
+
const { diffLines } = require('diff');
|
|
11
|
+
const jscodeshift = require('jscodeshift');
|
|
12
|
+
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
const [targetPath] = args;
|
|
15
|
+
|
|
16
|
+
// Check for --dry argument to enable dry run mode
|
|
17
|
+
const isDryRun = args.includes('--dry');
|
|
18
|
+
|
|
19
|
+
// Check for --only argument to run a specific transformer
|
|
20
|
+
const onlyArg = args.find((arg) => arg.startsWith('--only='));
|
|
21
|
+
const transformerName = onlyArg ? onlyArg.split('=')[1] : null;
|
|
22
|
+
|
|
23
|
+
if (!targetPath) {
|
|
24
|
+
console.error('❌ Usage: node scripts/run-transformers.js <targetPath> [--dry] [--only=<transformerName>]');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!fs.existsSync(targetPath)) {
|
|
29
|
+
console.error(`❌ Path "${targetPath}" does not exist.`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const transformsDir = path.join(__dirname, 'transformers');
|
|
34
|
+
const transformFiles = fs
|
|
35
|
+
.readdirSync(transformsDir)
|
|
36
|
+
.filter((file) => file.endsWith('.js') && (!transformerName || file === `${transformerName}.js`));
|
|
37
|
+
|
|
38
|
+
if (transformFiles.length === 0) {
|
|
39
|
+
console.log('✅ No transformers to apply.');
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log(`🛠 Found ${transformFiles.length} transformer(s) to apply to: ${targetPath}`);
|
|
44
|
+
|
|
45
|
+
// Utility to recursively collect all .ts/.tsx files
|
|
46
|
+
function getAllFiles(dir) {
|
|
47
|
+
let results = [];
|
|
48
|
+
for (const entry of fs.readdirSync(dir)) {
|
|
49
|
+
const fullPath = path.join(dir, entry);
|
|
50
|
+
const stat = fs.statSync(fullPath);
|
|
51
|
+
if (stat.isDirectory()) {
|
|
52
|
+
results = [...results, ...getAllFiles(fullPath)];
|
|
53
|
+
} else if (fullPath.endsWith('.ts') || fullPath.endsWith('.tsx')) {
|
|
54
|
+
results.push(fullPath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return results;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const filesToTransform = fs.statSync(targetPath).isDirectory() ? getAllFiles(targetPath) : [targetPath];
|
|
61
|
+
const updatedFiles = new Set();
|
|
62
|
+
|
|
63
|
+
// Execute each transformer
|
|
64
|
+
for (const transformFile of transformFiles) {
|
|
65
|
+
const transformPath = path.join(transformsDir, transformFile);
|
|
66
|
+
const transformer = require(transformPath);
|
|
67
|
+
console.log(`➡️ Running transformer: ${transformFile}`);
|
|
68
|
+
|
|
69
|
+
for (const filePath of filesToTransform) {
|
|
70
|
+
const source = fs.readFileSync(filePath, 'utf8');
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
const transformed = transformer(
|
|
74
|
+
{ path: filePath, source },
|
|
75
|
+
{ jscodeshift: jscodeshift.withParser('tsx') },
|
|
76
|
+
{ printOptions: { quote: 'single', trailingComma: true } },
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
if (typeof transformed === 'string' && transformed !== source) {
|
|
80
|
+
if (isDryRun) {
|
|
81
|
+
console.log(`🔍 ${filePath}`);
|
|
82
|
+
const diff = diffLines(source, transformed);
|
|
83
|
+
diff.forEach((part) => {
|
|
84
|
+
const color = part.added ? '\u001B[32m' : part.removed ? '\u001B[31m' : '\u001B[0m';
|
|
85
|
+
const prefix = part.added ? '+' : part.removed ? '-' : ' ';
|
|
86
|
+
const lines = part.value.split('\n').map((line) => `${prefix} ${line}`);
|
|
87
|
+
process.stdout.write(`${color}${lines.join('\n')}\u001B[0m\n`);
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
fs.writeFileSync(filePath, transformed, 'utf8');
|
|
91
|
+
console.log(`✅ Updated: ${filePath}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
updatedFiles.add(filePath);
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
if (error.message.includes('TSSatisfiesExpression')) {
|
|
98
|
+
console.warn(`⚠️ Skipping unsupported file (satisfies): ${filePath}`);
|
|
99
|
+
} else {
|
|
100
|
+
console.error(`❌ Error transforming ${filePath}:`, error.message);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
console.log(`✅ Finished: ${transformFile}\n`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (isDryRun) {
|
|
109
|
+
console.log(`🚧 Dry run complete. ${updatedFiles.size} file(s) would be modified.`);
|
|
110
|
+
console.log('Run without --dry to apply changes.');
|
|
111
|
+
} else {
|
|
112
|
+
console.log(`🏁 All transformers done. ${updatedFiles.size} file(s) modified.`);
|
|
113
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable prefer-destructuring */
|
|
4
|
+
/* eslint-disable unicorn/no-array-method-this-argument */
|
|
5
|
+
|
|
6
|
+
// Use local jscodeshift instance directly
|
|
7
|
+
const jscodeshift = require('jscodeshift');
|
|
8
|
+
|
|
9
|
+
// List of modal component names we want to transform
|
|
10
|
+
const MODAL_COMPONENTS = ['FullscreenModal', 'CardModal', 'NavigationModal'];
|
|
11
|
+
|
|
12
|
+
module.exports = function transformer(fileInfo, api) {
|
|
13
|
+
// Use the jscodeshift API to parse the file
|
|
14
|
+
const j = api.jscodeshift || jscodeshift;
|
|
15
|
+
|
|
16
|
+
// Parse the source code of the file
|
|
17
|
+
const root = j(fileInfo.source);
|
|
18
|
+
|
|
19
|
+
// Iterate over each modal component found in the source code
|
|
20
|
+
MODAL_COMPONENTS.forEach((componentName) => {
|
|
21
|
+
// Find instances of the modal component
|
|
22
|
+
root
|
|
23
|
+
.find(j.JSXElement, {
|
|
24
|
+
openingElement: {
|
|
25
|
+
name: { type: 'JSXIdentifier', name: componentName },
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
.forEach((path) => {
|
|
29
|
+
// Get the node (the JSXElement) from the path
|
|
30
|
+
const node = path.node;
|
|
31
|
+
|
|
32
|
+
// Check if the modal component already has children or if it is self-closing
|
|
33
|
+
const hasChildren = Array.isArray(node.children) && node.children.length > 0;
|
|
34
|
+
if (!node.openingElement.selfClosing && hasChildren) {
|
|
35
|
+
// If it already has children, do nothing and skip transformation
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Extract the attributes from the JSX element (like `header`, `body`, `footer`)
|
|
40
|
+
const attributes = node.openingElement.attributes;
|
|
41
|
+
|
|
42
|
+
// Initialize a map to hold potential new children: header, body, footer
|
|
43
|
+
const newChildrenMap = {
|
|
44
|
+
header: null,
|
|
45
|
+
body: null,
|
|
46
|
+
footer: null,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// An array to keep attributes that are not `header`, `body`, or `footer`
|
|
50
|
+
const keptAttributes = [];
|
|
51
|
+
|
|
52
|
+
// Loop over the attributes to check if any match `header`, `body`, or `footer`
|
|
53
|
+
attributes.forEach((attr) => {
|
|
54
|
+
if (
|
|
55
|
+
attr.type === 'JSXAttribute' &&
|
|
56
|
+
attr.name &&
|
|
57
|
+
Object.prototype.hasOwnProperty.call(newChildrenMap, attr.name.name)
|
|
58
|
+
) {
|
|
59
|
+
const key = attr.name.name;
|
|
60
|
+
const value = attr.value;
|
|
61
|
+
|
|
62
|
+
// Check if the value of the attribute is an expression (like a ternary)
|
|
63
|
+
if (value?.type === 'JSXExpressionContainer') {
|
|
64
|
+
const expression = value.expression;
|
|
65
|
+
|
|
66
|
+
// If it's a JSXElement or JSXFragment, keep it as it is
|
|
67
|
+
if (j.JSXElement.check(expression) || j.JSXFragment.check(expression)) {
|
|
68
|
+
newChildrenMap[key] = expression;
|
|
69
|
+
} else {
|
|
70
|
+
// Otherwise, wrap it in an expression container to handle non-JSX expressions
|
|
71
|
+
newChildrenMap[key] = j.jsxExpressionContainer(expression);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
// Keep any other attributes (that are not header/body/footer)
|
|
76
|
+
keptAttributes.push(attr);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// If no new children were found (no `header`, `body`, or `footer`), do nothing
|
|
81
|
+
if (Object.values(newChildrenMap).every((v) => v === null)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// If the modal component was self-closing, convert it to a regular JSX element with children
|
|
86
|
+
if (node.openingElement.selfClosing) {
|
|
87
|
+
node.openingElement.selfClosing = false;
|
|
88
|
+
node.closingElement = j.jsxClosingElement(j.jsxIdentifier(node.openingElement.name.name));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Retain all the other attributes and set the new ones
|
|
92
|
+
node.openingElement.attributes = keptAttributes;
|
|
93
|
+
|
|
94
|
+
// Force the order of children: header → body → footer
|
|
95
|
+
const orderedChildren = Object.values(newChildrenMap).filter(Boolean);
|
|
96
|
+
node.children = orderedChildren;
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Return the modified source code after transformation
|
|
101
|
+
return root.toSource({ quote: 'single' });
|
|
102
|
+
};
|