@ornikar/kitt-universal 25.57.1-canary.d93d8eb261b0f9e02792bcdfb3163f1e8a2add4a.0 → 25.58.1-canary.01e4aa02ad8f3c2fd23f16498fb058cc1cad88cd.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 +19 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/index-node-20.10.es.web.mjs.map +1 -1
- package/dist/index.es.js +17 -17
- package/dist/index.es.js.map +1 -1
- package/dist/index.es.web.js +18 -18
- package/dist/index.es.web.js.map +1 -1
- package/dist/linaria-themes-metro.es.android.js.map +1 -1
- package/dist/linaria-themes-metro.es.ios.js.map +1 -1
- package/dist/linaria-themes-node-20.10.cjs.js.map +1 -1
- package/dist/linaria-themes-node-20.10.cjs.web.js.map +1 -1
- package/dist/linaria-themes-node-20.10.es.mjs.map +1 -1
- package/dist/linaria-themes-node-20.10.es.web.mjs.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +10 -4
- package/scripts/run-all-transformers.js +50 -0
- package/scripts/run-transformer.js +41 -0
- package/scripts/transformers/modals.js +98 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ornikar/kitt-universal",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.58.1-canary.01e4aa02ad8f3c2fd23f16498fb058cc1cad88cd.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "@ornikar/kitt-universal",
|
|
@@ -71,10 +71,15 @@
|
|
|
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-all-transforms": "./scripts/run-all-transformers.js",
|
|
76
|
+
"run-transform": "./scripts/run-transformer.js"
|
|
77
|
+
},
|
|
74
78
|
"engines": {
|
|
75
79
|
"node": ">=20.10.0"
|
|
76
80
|
},
|
|
77
81
|
"scripts": {
|
|
82
|
+
"migrate": "node scripts/run-all-transforms.js",
|
|
78
83
|
"build": "ORNIKAR_ONLY=kitt-universal yarn ../.. build",
|
|
79
84
|
"lint:eslint": "yarn ../.. eslint --report-unused-disable-directives --quiet @ornikar/kitt-universal"
|
|
80
85
|
},
|
|
@@ -98,7 +103,7 @@
|
|
|
98
103
|
"@floating-ui/react-native": "0.8.0",
|
|
99
104
|
"@googlemaps/js-api-loader": "1.16.2",
|
|
100
105
|
"@ornikar/eslint-config-kitt": "^4.0.3",
|
|
101
|
-
"@ornikar/kitt-icons": "11.
|
|
106
|
+
"@ornikar/kitt-icons": "^11.15.0",
|
|
102
107
|
"@react-native-community/datetimepicker": "^8.0.1",
|
|
103
108
|
"@twemoji/parser": "15.1.1",
|
|
104
109
|
"downshift": "7.6.0",
|
|
@@ -118,7 +123,7 @@
|
|
|
118
123
|
"expo-image-picker": "^14.7.1",
|
|
119
124
|
"expo-linear-gradient": "^12.7.2",
|
|
120
125
|
"expo-web-browser": "^12.8.2",
|
|
121
|
-
"react": "^18.
|
|
126
|
+
"react": "^18.3.1",
|
|
122
127
|
"react-dom": "^18.2.0",
|
|
123
128
|
"react-intl": "^6.0.0",
|
|
124
129
|
"react-native": ">=0.73.5",
|
|
@@ -161,11 +166,12 @@
|
|
|
161
166
|
"@phosphor-icons/core": "2.1.1",
|
|
162
167
|
"@react-native-picker/picker": "2.4.3",
|
|
163
168
|
"@types/googlemaps": "3.43.3",
|
|
164
|
-
"@types/react": "18.3.
|
|
169
|
+
"@types/react": "18.3.23",
|
|
165
170
|
"@types/react-portal": "4.0.7",
|
|
166
171
|
"@types/react-transition-group": "4.2.3",
|
|
167
172
|
"expo-document-picker": "11.10.1",
|
|
168
173
|
"expo-image-picker": "14.7.1",
|
|
174
|
+
"jscodeshift": "17.3.0",
|
|
169
175
|
"react": "18.3.1",
|
|
170
176
|
"react-dom": "18.3.1",
|
|
171
177
|
"react-error-boundary": "3.1.4",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const { spawnSync } = require('node:child_process');
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
|
|
9
|
+
// --- Handle CLI arguments ---
|
|
10
|
+
const targetPath = process.argv[2];
|
|
11
|
+
|
|
12
|
+
if (!targetPath) {
|
|
13
|
+
console.error('❌ Usage: node scripts/run-all-transformers.js <targetPath>');
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Ensure the path exists
|
|
18
|
+
if (!fs.existsSync(targetPath)) {
|
|
19
|
+
console.error(`❌ Path "${targetPath}" does not exist.`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const transformsDir = path.join(__dirname, 'transformers');
|
|
24
|
+
|
|
25
|
+
// Read all .js files in the transformers directory
|
|
26
|
+
const transformFiles = fs.readdirSync(transformsDir).filter((file) => file.endsWith('.js'));
|
|
27
|
+
|
|
28
|
+
if (transformFiles.length === 0) {
|
|
29
|
+
console.log('✅ No transformers to apply.');
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log(`🛠 Found ${transformFiles.length} transformer(s) to apply to: ${targetPath}\n`);
|
|
34
|
+
|
|
35
|
+
transformFiles.forEach((file) => {
|
|
36
|
+
const transformPath = path.join(transformsDir, file);
|
|
37
|
+
console.log(`➡️ Running transformer: ${file}`);
|
|
38
|
+
|
|
39
|
+
const result = spawnSync(
|
|
40
|
+
'jscodeshift',
|
|
41
|
+
['-t', transformPath, targetPath, '--parser=tsx'],
|
|
42
|
+
{ stdio: 'inherit' }, // Show output in terminal
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (result.error) {
|
|
46
|
+
console.error(`❌ Error running ${file}:`, result.error.message);
|
|
47
|
+
} else {
|
|
48
|
+
console.log(`✅ Finished: ${file}\n`);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const { spawnSync } = require('node:child_process');
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
|
|
9
|
+
// --- Handle CLI arguments ---
|
|
10
|
+
const transformerName = process.argv[2];
|
|
11
|
+
const targetPath = process.argv[3];
|
|
12
|
+
|
|
13
|
+
if (!transformerName || !targetPath) {
|
|
14
|
+
console.error('❌ Usage: node scripts/run-transformer.js <transformerName> <targetPath>');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const transformPath = path.join(__dirname, 'transformers', `${transformerName}.js`);
|
|
19
|
+
|
|
20
|
+
// Ensure the transformer file exists
|
|
21
|
+
if (!fs.existsSync(transformPath)) {
|
|
22
|
+
console.error(`❌ Transform "${transformerName}" not found at ${transformPath}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Ensure the path exists
|
|
27
|
+
if (!fs.existsSync(targetPath)) {
|
|
28
|
+
console.error(`❌ Target path "${targetPath}" does not exist.`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log(`➡️ Running transformer "${transformerName}" on ${targetPath}\n`);
|
|
33
|
+
|
|
34
|
+
const result = spawnSync('jscodeshift', ['-t', transformPath, targetPath, '--parser=tsx'], { stdio: 'inherit' });
|
|
35
|
+
|
|
36
|
+
if (result.error) {
|
|
37
|
+
console.error('❌ Error:', result.error.message);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
} else {
|
|
40
|
+
console.log(`✅ Transform "${transformerName}" completed.`);
|
|
41
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable prefer-destructuring */
|
|
4
|
+
/* eslint-disable unicorn/no-array-method-this-argument */
|
|
5
|
+
|
|
6
|
+
// List of modal component names we want to transform
|
|
7
|
+
const MODAL_COMPONENTS = ['FullscreenModal', 'CardModal', 'NavigationModal'];
|
|
8
|
+
|
|
9
|
+
module.exports = function transformer(fileInfo, api) {
|
|
10
|
+
// jscodeshift library
|
|
11
|
+
const j = api.jscodeshift;
|
|
12
|
+
// Parse the source code of the file
|
|
13
|
+
const root = j(fileInfo.source);
|
|
14
|
+
|
|
15
|
+
// Iterate over each modal component found in the source code
|
|
16
|
+
MODAL_COMPONENTS.forEach((componentName) => {
|
|
17
|
+
// Find instances of the modal component
|
|
18
|
+
root
|
|
19
|
+
.find(j.JSXElement, {
|
|
20
|
+
openingElement: {
|
|
21
|
+
name: { type: 'JSXIdentifier', name: componentName },
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
.forEach((path) => {
|
|
25
|
+
// Get the node (the JSXElement) from the path
|
|
26
|
+
const node = path.node;
|
|
27
|
+
|
|
28
|
+
// Check if the modal component already has children or if it is self-closing
|
|
29
|
+
const hasChildren = Array.isArray(node.children) && node.children.length > 0;
|
|
30
|
+
if (!node.openingElement.selfClosing && hasChildren) {
|
|
31
|
+
// If it already has children, do nothing and skip transformation
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Extract the attributes from the JSX element (like `header`, `body`, `footer`)
|
|
36
|
+
const attributes = node.openingElement.attributes;
|
|
37
|
+
|
|
38
|
+
// Initialize a map to hold potential new children: header, body, footer
|
|
39
|
+
const newChildrenMap = {
|
|
40
|
+
header: null,
|
|
41
|
+
body: null,
|
|
42
|
+
footer: null,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// An array to keep attributes that are not `header`, `body`, or `footer`
|
|
46
|
+
const keptAttributes = [];
|
|
47
|
+
|
|
48
|
+
// Loop over the attributes to check if any match `header`, `body`, or `footer`
|
|
49
|
+
attributes.forEach((attr) => {
|
|
50
|
+
if (
|
|
51
|
+
attr.type === 'JSXAttribute' &&
|
|
52
|
+
attr.name &&
|
|
53
|
+
Object.prototype.hasOwnProperty.call(newChildrenMap, attr.name.name)
|
|
54
|
+
) {
|
|
55
|
+
const key = attr.name.name;
|
|
56
|
+
const value = attr.value;
|
|
57
|
+
|
|
58
|
+
// Check if the value of the attribute is an expression (like a ternary)
|
|
59
|
+
if (value?.type === 'JSXExpressionContainer') {
|
|
60
|
+
const expression = value.expression;
|
|
61
|
+
|
|
62
|
+
// If it's a JSXElement or JSXFragment, keep it as it is
|
|
63
|
+
if (j.JSXElement.check(expression) || j.JSXFragment.check(expression)) {
|
|
64
|
+
newChildrenMap[key] = expression;
|
|
65
|
+
} else {
|
|
66
|
+
// Otherwise, wrap it in an expression container to handle non-JSX expressions
|
|
67
|
+
newChildrenMap[key] = j.jsxExpressionContainer(expression);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
// Keep any other attributes (that are not header/body/footer)
|
|
72
|
+
keptAttributes.push(attr);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// If no new children were found (no `header`, `body`, or `footer`), do nothing
|
|
77
|
+
if (Object.values(newChildrenMap).every((v) => v === null)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// If the modal component was self-closing, convert it to a regular JSX element with children
|
|
82
|
+
if (node.openingElement.selfClosing) {
|
|
83
|
+
node.openingElement.selfClosing = false;
|
|
84
|
+
node.closingElement = j.jsxClosingElement(j.jsxIdentifier(node.openingElement.name.name));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Retain all the other attributes and set the new ones
|
|
88
|
+
node.openingElement.attributes = keptAttributes;
|
|
89
|
+
|
|
90
|
+
// Force the order of children: header → body → footer
|
|
91
|
+
const orderedChildren = Object.values(newChildrenMap).filter(Boolean);
|
|
92
|
+
node.children = orderedChildren;
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Return the modified source code after transformation
|
|
97
|
+
return root.toSource({ quote: 'single' });
|
|
98
|
+
};
|