@ornikar/kitt-universal 25.58.1-canary.01e4aa02ad8f3c2fd23f16498fb058cc1cad88cd.0 → 25.58.1-canary.95e9af38cc4e878fc97c4391877d7b879da5b220.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,7 +3,7 @@
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.95e9af38cc4e878fc97c4391877d7b879da5b220.0](https://github.com/ornikar/kitt/compare/@ornikar/kitt-universal@25.58.0...@ornikar/kitt-universal@25.58.1-canary.95e9af38cc4e878fc97c4391877d7b879da5b220.0) (2025-06-05)
7
7
 
8
8
 
9
9
  ### Features
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.95e9af38cc4e878fc97c4391877d7b879da5b220.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "directory": "@ornikar/kitt-universal",
@@ -169,6 +169,7 @@
169
169
  "@types/react": "18.3.23",
170
170
  "@types/react-portal": "4.0.7",
171
171
  "@types/react-transition-group": "4.2.3",
172
+ "diff": "8.0.2",
172
173
  "expo-document-picker": "11.10.1",
173
174
  "expo-image-picker": "14.7.1",
174
175
  "jscodeshift": "17.3.0",
@@ -1,28 +1,29 @@
1
1
  #!/usr/bin/env node
2
+ /* eslint-disable global-require */
3
+ /* eslint-disable import/no-dynamic-require */
2
4
 
3
5
  'use strict';
4
6
 
5
- const { spawnSync } = require('node:child_process');
6
7
  const fs = require('node:fs');
7
8
  const path = require('node:path');
9
+ const { diffLines } = require('diff');
10
+ const jscodeshift = require('jscodeshift');
8
11
 
9
- // --- Handle CLI arguments ---
10
- const targetPath = process.argv[2];
12
+ const args = process.argv.slice(2);
13
+ const targetPath = args.find((arg) => !arg.startsWith('--'));
14
+ const isDryRun = args.includes('--dry');
11
15
 
12
16
  if (!targetPath) {
13
- console.error('❌ Usage: node scripts/run-all-transformers.js <targetPath>');
17
+ console.error('❌ Usage: node scripts/run-all-transformers.js <targetPath> [--dry]');
14
18
  process.exit(1);
15
19
  }
16
20
 
17
- // Ensure the path exists
18
21
  if (!fs.existsSync(targetPath)) {
19
22
  console.error(`❌ Path "${targetPath}" does not exist.`);
20
23
  process.exit(1);
21
24
  }
22
25
 
23
26
  const transformsDir = path.join(__dirname, 'transformers');
24
-
25
- // Read all .js files in the transformers directory
26
27
  const transformFiles = fs.readdirSync(transformsDir).filter((file) => file.endsWith('.js'));
27
28
 
28
29
  if (transformFiles.length === 0) {
@@ -30,21 +31,68 @@ if (transformFiles.length === 0) {
30
31
  process.exit(0);
31
32
  }
32
33
 
33
- console.log(`🛠 Found ${transformFiles.length} transformer(s) to apply to: ${targetPath}\n`);
34
+ console.log(`🛠 Found ${transformFiles.length} transformer(s) to apply to: ${targetPath}`);
35
+
36
+ // Utility to recursively collect all .ts/.tsx files
37
+ function getAllFiles(dir) {
38
+ let results = [];
39
+ for (const entry of fs.readdirSync(dir)) {
40
+ const fullPath = path.join(dir, entry);
41
+ const stat = fs.statSync(fullPath);
42
+ if (stat.isDirectory()) {
43
+ results = [...results, ...getAllFiles(fullPath)];
44
+ } else if (fullPath.endsWith('.ts') || fullPath.endsWith('.tsx')) {
45
+ results.push(fullPath);
46
+ }
47
+ }
48
+ return results;
49
+ }
50
+
51
+ const filesToTransform = fs.statSync(targetPath).isDirectory() ? getAllFiles(targetPath) : [targetPath];
52
+ const updatedFiles = new Set();
53
+
54
+ // Execute each transformer
55
+ for (const transformFile of transformFiles) {
56
+ const transformPath = path.join(transformsDir, transformFile);
57
+ const transformer = require(transformPath);
58
+ console.log(`➡️ Running transformer: ${transformFile}`);
34
59
 
35
- transformFiles.forEach((file) => {
36
- const transformPath = path.join(transformsDir, file);
37
- console.log(`➡️ Running transformer: ${file}`);
60
+ for (const filePath of filesToTransform) {
61
+ const source = fs.readFileSync(filePath, 'utf8');
38
62
 
39
- const result = spawnSync(
40
- 'jscodeshift',
41
- ['-t', transformPath, targetPath, '--parser=tsx'],
42
- { stdio: 'inherit' }, // Show output in terminal
43
- );
63
+ try {
64
+ const transformed = transformer(
65
+ { path: filePath, source },
66
+ { jscodeshift: jscodeshift.withParser('tsx') },
67
+ { printOptions: { quote: 'single', trailingComma: true } },
68
+ );
44
69
 
45
- if (result.error) {
46
- console.error(`❌ Error running ${file}:`, result.error.message);
47
- } else {
48
- console.log(`✅ Finished: ${file}\n`);
70
+ if (typeof transformed === 'string' && transformed !== source) {
71
+ if (isDryRun) {
72
+ console.log(`🔍 ${filePath}`);
73
+ const diff = diffLines(source, transformed);
74
+ diff.forEach((part) => {
75
+ const color = part.added ? '\u001B[32m' : part.removed ? '\u001B[31m' : '\u001B[0m';
76
+ process.stdout.write(`${color + part.value}\u001B[0m`);
77
+ });
78
+ } else {
79
+ fs.writeFileSync(filePath, transformed, 'utf8');
80
+ console.log(`✅ Updated: ${filePath}`);
81
+ }
82
+
83
+ updatedFiles.add(filePath);
84
+ }
85
+ } catch (error) {
86
+ console.error(`❌ Error transforming ${filePath}:`, error.message);
87
+ }
49
88
  }
50
- });
89
+
90
+ console.log(`✅ Finished: ${transformFile}\n`);
91
+ }
92
+
93
+ if (isDryRun) {
94
+ console.log(`🚧 Dry run complete. ${updatedFiles.size} file(s) would be modified.`);
95
+ console.log('Run without --dry to apply changes.');
96
+ } else {
97
+ console.log(`🏁 All transformers done. ${updatedFiles.size} file(s) modified.`);
98
+ }
@@ -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