@ornikar/kitt-universal 25.58.1-canary.01e4aa02ad8f3c2fd23f16498fb058cc1cad88cd.0 → 25.58.1-canary.54fbe4c4608384a272d662dc1049beef0b811388.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 CHANGED
@@ -3,19 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [25.58.1-canary.01e4aa02ad8f3c2fd23f16498fb058cc1cad88cd.0](https://github.com/ornikar/kitt/compare/@ornikar/kitt-universal@25.58.0...@ornikar/kitt-universal@25.58.1-canary.01e4aa02ad8f3c2fd23f16498fb058cc1cad88cd.0) (2025-06-04)
6
+ ## [25.58.1-canary.54fbe4c4608384a272d662dc1049beef0b811388.0](https://github.com/ornikar/kitt/compare/@ornikar/kitt-universal@25.58.0...@ornikar/kitt-universal@25.58.1-canary.54fbe4c4608384a272d662dc1049beef0b811388.0) (2025-06-05)
7
7
 
8
8
 
9
9
  ### Features
10
10
 
11
11
  * export scripts ([e13a36f](https://github.com/ornikar/kitt/commit/e13a36f1b24082e5bfa4eb4f00f5a7c574abcfd5))
12
12
  * implement migration script ([bae4009](https://github.com/ornikar/kitt/commit/bae4009783ca95345dc4784279778ef42eff2a4f))
13
+ * improve diffs ([528ec8d](https://github.com/ornikar/kitt/commit/528ec8d995296c9d04e8632b7088d8d85ba532fd))
13
14
  * improve transformers scripts ([2eb79c0](https://github.com/ornikar/kitt/commit/2eb79c05628d2c5894a4f321f6ec66ae80d1fdc5))
14
15
  * **kitt-universal:** add modals transformer ([a57aa3f](https://github.com/ornikar/kitt/commit/a57aa3f24ebcde42a8d45db1db89ed6dce5cd56e))
16
+ * run specific transformer ([54fbe4c](https://github.com/ornikar/kitt/commit/54fbe4c4608384a272d662dc1049beef0b811388))
15
17
 
16
18
 
17
19
  ### Bug Fixes
18
20
 
21
+ * improve error catch ([b6fabb9](https://github.com/ornikar/kitt/commit/b6fabb9edc75842b766955c43cd4ac44044f13ee))
19
22
  * scripts ([01e4aa0](https://github.com/ornikar/kitt/commit/01e4aa02ad8f3c2fd23f16498fb058cc1cad88cd))
20
23
 
21
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ornikar/kitt-universal",
3
- "version": "25.58.1-canary.01e4aa02ad8f3c2fd23f16498fb058cc1cad88cd.0",
3
+ "version": "25.58.1-canary.54fbe4c4608384a272d662dc1049beef0b811388.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "directory": "@ornikar/kitt-universal",
@@ -72,14 +72,12 @@
72
72
  "./babel-plugin-csf-to-jest": "./babel-plugin-csf-to-jest.js"
73
73
  },
74
74
  "bin": {
75
- "run-all-transforms": "./scripts/run-all-transformers.js",
76
- "run-transform": "./scripts/run-transformer.js"
75
+ "run-transformers": "./scripts/run-transformers.js"
77
76
  },
78
77
  "engines": {
79
78
  "node": ">=20.10.0"
80
79
  },
81
80
  "scripts": {
82
- "migrate": "node scripts/run-all-transforms.js",
83
81
  "build": "ORNIKAR_ONLY=kitt-universal yarn ../.. build",
84
82
  "lint:eslint": "yarn ../.. eslint --report-unused-disable-directives --quiet @ornikar/kitt-universal"
85
83
  },
@@ -169,6 +167,7 @@
169
167
  "@types/react": "18.3.23",
170
168
  "@types/react-portal": "4.0.7",
171
169
  "@types/react-transition-group": "4.2.3",
170
+ "diff": "8.0.2",
172
171
  "expo-document-picker": "11.10.1",
173
172
  "expo-image-picker": "14.7.1",
174
173
  "jscodeshift": "17.3.0",
@@ -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.find((arg) => !arg.startsWith('--'));
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.includes(transformerName)));
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
+ }
@@ -3,12 +3,16 @@
3
3
  /* eslint-disable prefer-destructuring */
4
4
  /* eslint-disable unicorn/no-array-method-this-argument */
5
5
 
6
+ // Use local jscodeshift instance directly
7
+ const jscodeshift = require('jscodeshift');
8
+
6
9
  // List of modal component names we want to transform
7
10
  const MODAL_COMPONENTS = ['FullscreenModal', 'CardModal', 'NavigationModal'];
8
11
 
9
12
  module.exports = function transformer(fileInfo, api) {
10
- // jscodeshift library
11
- const j = api.jscodeshift;
13
+ // Use the jscodeshift API to parse the file
14
+ const j = api.jscodeshift || jscodeshift;
15
+
12
16
  // Parse the source code of the file
13
17
  const root = j(fileInfo.source);
14
18
 
@@ -1,50 +0,0 @@
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
- });
@@ -1,41 +0,0 @@
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
- }