cdk-codemod
Advanced tools
Comparing version 0.0.2 to 0.0.4
@@ -13,7 +13,7 @@ #!/usr/bin/env node | ||
const Runner_1 = __importDefault(require("jscodeshift/dist/Runner")); | ||
const package_json_1 = require("./package-json"); | ||
const args = process.argv.slice(2); | ||
const example = args.includes("--example"); | ||
const dryRun = args.includes("--dry-run"); | ||
let options, positionalArguments; | ||
function run(paths, options) { | ||
const run = async (inputPaths) => { | ||
const baseFolder = example ? path_1.default.resolve("test/fixtures") : cwd(); | ||
@@ -23,3 +23,3 @@ const transformPath = props.transformPath || example | ||
: path_1.default.resolve("lib/transformers/index.js"); | ||
const options = props.options || { | ||
const options = { | ||
dry: dryRun || example, | ||
@@ -30,12 +30,22 @@ print: true, | ||
}; | ||
const paths = props.paths || listFiles(baseFolder, [], ".ts"); | ||
Runner_1.default.run(transformPath, paths, options); | ||
} | ||
const paths = inputPaths || listFiles(baseFolder, [], ".ts"); | ||
await Runner_1.default.run(transformPath, paths, options); | ||
const updatedPackages = await (0, package_json_1.updatePackageJson)(baseFolder); | ||
const updatedCdks = await updateCdkJson(baseFolder); | ||
// write updatedPackages and updatedCdks to files | ||
if (!dryRun) { | ||
const jsonUpdates = { ...updatedPackages, ...updatedCdks }; | ||
Object.keys(jsonUpdates).forEach((key) => { | ||
writeFileSync(key, jsonUpdates[key]); | ||
}); | ||
await reinstall(updatedPackages); | ||
} | ||
}; | ||
if (options.stdin) { | ||
let buffer = ""; | ||
process.stdin.on("data", (data) => (buffer += data)); | ||
process.stdin.on("end", () => run(buffer.split("\n"), options)); | ||
process.stdin.on("end", () => run(buffer.split("\n"))); | ||
} | ||
else { | ||
run(positionalArguments, options); | ||
run(); | ||
} |
{ | ||
"name": "cdk-codemod", | ||
"version": "0.0.2", | ||
"version": "0.0.4", | ||
"description": "Collection of codemod scripts that help update AWS CDK from Version 1 to Version 2", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
18447
15
383
2