Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import forestCodemod from 'forest-codemod'
✗ const forestCodemod = require('forest-codemod')
ESM-only package since v1.0.0-beta.1
ForestCodemod
✓ import { ForestCodemod } from 'forest-codemod'
✗ import ForestCodemod from 'forest-codemod'
Named export for class-based usage
runMigration
✓ import { runMigration } from 'forest-codemod'
Utility function for programmatic migration
Demonstrates programmatic migration of a ForestAdmin agent configuration file from v1 to v2 using the runMigration function.
import { runMigration } from 'forest-codemod';
import path from 'path';
const config = {
source: path.resolve('./agent-config.js'),
dest: path.resolve('./agent-config-v2.js'),
transform: 'v1-to-v2',
};
runMigration(config)
.then(() => {
console.log('Migration completed successfully');
})
.catch((err) => {
console.error('Migration failed:', err);
});
Debug
Known issues
deprecatedThe 'transform' option 'v1-to-v2' is deprecated and will be removed in version 2.0.0. Use 'upgrade-v1' instead.fixReplace 'v1-to-v2' with 'upgrade-v1' in the transform option.
affects: >=1.0.0-beta.1 <1.3.0
breakingThe 'source' and 'dest' options are now required. In older beta versions, they were optional and defaulted to current directory.fixEnsure both 'source' and 'dest' are provided when calling runMigration.
affects: >=1.0.0-beta.1
gotchaThe codemod modifies files in-place if 'dest' is not specified. Always provide a 'dest' to prevent data loss.fixAlways set the 'dest' option to a different file path.
affects: >=1.0.0-beta.1
Errors
Common errors & fixes
Error: Cannot find module 'jscodeshift'
jscodeshift is a peer dependency not installed
fixnpm install jscodeshift --save-dev
TypeError: runMigration is not a function
Importing incorrectly, using default import instead of named import
fixUse 'import { runMigration } from 'forest-codemod'' Error: Unknown transform 'v1-to-v2'
Using deprecated transform name that has been removed
fixUse 'upgrade-v1' instead
Upgrade
Version history
1.0.0-beta.1latest on npm
Audit
Dependencies
jscodeshiftrequiredcore transformation engine