|
| 1 | +<!-- Generated by SpecStory --> |
| 2 | + |
| 3 | +# Update script for gradle-batch replacement (2025-06-09 21:55:33) |
| 4 | + |
| 5 | +_**User**_ |
| 6 | + |
| 7 | +@gradle-batch.impl.js @replace-batch-runner.js |
| 8 | + |
| 9 | +update script to repalce gradle-batch.impl |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +_**Assistant**_ |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +Read file: replace-batch-runner.js |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +```diff |
| 28 | + const path = require('path'); |
| 29 | + |
| 30 | +- function replaceJar(sourceJar, targetJar) { |
| 31 | +- if (!fs.existsSync(sourceJar)) { |
| 32 | +- console.error(`❌ Source JAR not found at: ${sourceJar}`); |
| 33 | ++ function replaceFile(sourceFile, targetFile) { |
| 34 | ++ if (!fs.existsSync(sourceFile)) { |
| 35 | ++ console.error(`❌ Source file not found at: ${sourceFile}`); |
| 36 | + process.exit(1); |
| 37 | + } |
| 38 | + |
| 39 | +- if (!fs.existsSync(targetJar)) { |
| 40 | +- console.error(`❌ Target JAR not found at: ${targetJar}`); |
| 41 | ++ if (!fs.existsSync(targetFile)) { |
| 42 | ++ console.error(`❌ Target file not found at: ${targetFile}`); |
| 43 | + process.exit(1); |
| 44 | + } |
| 45 | + |
| 46 | + try { |
| 47 | +- fs.copyFileSync(sourceJar, targetJar); |
| 48 | +- console.log(`✅ Replaced ${targetJar} with ${sourceJar}`); |
| 49 | ++ fs.copyFileSync(sourceFile, targetFile); |
| 50 | ++ console.log(`✅ Replaced ${targetFile} with ${sourceFile}`); |
| 51 | + } catch (err) { |
| 52 | +- console.error(`❌ Failed to replace JAR: ${err.message}`); |
| 53 | ++ console.error(`❌ Failed to replace file: ${err.message}`); |
| 54 | + process.exit(1); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + const workspaceRoot = process.cwd(); // assumes script is run from workspace root |
| 59 | +- replaceJar(path.join(workspaceRoot, 'batch-runner.jar'), path.join(workspaceRoot, 'node_modules/@nx/gradle/batch-runner/build/libs/batch-runner.jar')); |
| 60 | +- replaceJar(path.join(workspaceRoot, 'batch-runner-all.jar'), path.join(workspaceRoot, 'node_modules/@nx/gradle/batch-runner/build/libs/batch-runner-all.jar')); |
| 61 | ++ replaceFile(path.join(workspaceRoot, 'batch-runner.jar'), path.join(workspaceRoot, 'node_modules/@nx/gradle/batch-runner/build/libs/batch-runner.jar')); |
| 62 | ++ replaceFile(path.join(workspaceRoot, 'batch-runner-all.jar'), path.join(workspaceRoot, 'node_modules/@nx/gradle/batch-runner/build/libs/batch-runner-all.jar')); |
| 63 | ++ replaceFile(path.join(workspaceRoot, 'gradle-batch.impl.js'), path.join(workspaceRoot, 'node_modules/@nx/gradle/src/executors/gradle/gradle-batch.impl.js')); |
| 64 | +``` |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +I've updated the `replace-batch-runner.js` script. It now uses a more generic `replaceFile` function and includes a line to replace `gradle-batch.impl.js`. |
| 73 | + |
| 74 | +Here's how the updated `replace-batch-runner.js` looks: |
| 75 | +```1:26:replace-batch-runner.js |
| 76 | +const fs = require('fs'); |
| 77 | +const path = require('path'); |
| 78 | + |
| 79 | +function replaceFile(sourceFile, targetFile) { |
| 80 | + if (!fs.existsSync(sourceFile)) { |
| 81 | + console.error(`❌ Source file not found at: ${sourceFile}`); |
| 82 | + process.exit(1); |
| 83 | + } |
| 84 | + |
| 85 | + if (!fs.existsSync(targetFile)) { |
| 86 | + console.error(`❌ Target file not found at: ${targetFile}`); |
| 87 | + process.exit(1); |
| 88 | + } |
| 89 | + |
| 90 | + try { |
| 91 | + fs.copyFileSync(sourceFile, targetFile); |
| 92 | + console.log(`✅ Replaced ${targetFile} with ${sourceFile}`); |
| 93 | + } catch (err) { |
| 94 | + console.error(`❌ Failed to replace file: ${err.message}`); |
| 95 | + process.exit(1); |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +const workspaceRoot = process.cwd(); // assumes script is run from workspace root |
| 100 | +replaceFile(path.join(workspaceRoot, 'batch-runner.jar'), path.join(workspaceRoot, 'node_modules/@nx/gradle/batch-runner/build/libs/batch-runner.jar')); |
| 101 | +replaceFile(path.join(workspaceRoot, 'batch-runner-all.jar'), path.join(workspaceRoot, 'node_modules/@nx/gradle/batch-runner/build/libs/batch-runner-all.jar')); |
| 102 | +replaceFile(path.join(workspaceRoot, 'gradle-batch.impl.js'), path.join(workspaceRoot, 'node_modules/@nx/gradle/src/executors/gradle/gradle-batch.impl.js')); |
| 103 | +``` |
| 104 | + |
| 105 | +--- |
| 106 | + |
0 commit comments