@suspensive/codemods 0.1.1 → 0.2.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.
@@ -29,7 +29,7 @@ var import_extra_typings = require("@commander-js/extra-typings");
29
29
  // package.json
30
30
  var package_default = {
31
31
  name: "@suspensive/codemods",
32
- version: "0.1.1",
32
+ version: "0.2.0",
33
33
  description: "Codemods for @suspensive.",
34
34
  keywords: [
35
35
  "suspensive",
@@ -95,12 +95,12 @@ function onCancel() {
95
95
  }
96
96
  var jscodeshiftExecutable = require.resolve(".bin/jscodeshift");
97
97
  var transformerDirectory = (0, import_node_path.join)(__dirname, "../", "../", "dist", "transforms");
98
- async function transformRunner(transform, path) {
98
+ async function transformRunner(transform, path, options) {
99
99
  let transformer = transform ?? "";
100
100
  let directory = path ?? "";
101
101
  if (transform && !TRANSFORMER_INQUIRER_CHOICES.find((x) => x.title === transform)) {
102
102
  console.error("Invalid transform choice, pick one of:");
103
- console.error(TRANSFORMER_INQUIRER_CHOICES.map((x) => "- " + x.title).join("\n"));
103
+ console.error(TRANSFORMER_INQUIRER_CHOICES.map((x) => `- ${+x.title}`).join("\n"));
104
104
  process.exit(1);
105
105
  }
106
106
  if (!transform) {
@@ -134,6 +134,12 @@ async function transformRunner(transform, path) {
134
134
  directory = res.path;
135
135
  }
136
136
  const args = [];
137
+ if (options?.dry) {
138
+ args.push("--dry");
139
+ }
140
+ if (options?.print) {
141
+ args.push("--print");
142
+ }
137
143
  args.push("--no-babel");
138
144
  args.push("--ignore-pattern=**/node_modules/**");
139
145
  args.push("--ignore-pattern=**/.next/**");
@@ -172,5 +178,5 @@ async function transformRunner(transform, path) {
172
178
 
173
179
  // src/bin/codemods.ts
174
180
  var program = new import_extra_typings.Command(package_default.name);
175
- program.description(package_default.description).version(package_default.version, "-v, --version", "Output the current version of @suspensive/codemods.").argument("[codemod]", "Codemod slug to run.").argument("[path]", "Path to source directory.").usage("[codemod] [path]").helpOption("-h, --help", "Display this help message.").action((codemod, path) => transformRunner(codemod, path));
181
+ program.description(package_default.description).version(package_default.version, "-v, --version", "Output the current version of @suspensive/codemods.").argument("[codemod]", 'Codemod slug to run. See "https://suspensive.org/docs/codemods/motivation"').argument("[path]", "Path to source directory.").usage("[codemod] [path]").helpOption("-h, --help", "Display this help message.").option("-d, --dry", "Dry run (no changes are made to files)").option("-p, --print", "Print transformed files to stdout, useful for development").action(transformRunner);
176
182
  program.parse(process.argv);
@@ -49,12 +49,12 @@ function onCancel() {
49
49
  }
50
50
  var jscodeshiftExecutable = require.resolve(".bin/jscodeshift");
51
51
  var transformerDirectory = (0, import_node_path.join)(__dirname, "../", "../", "dist", "transforms");
52
- async function transformRunner(transform, path) {
52
+ async function transformRunner(transform, path, options) {
53
53
  let transformer = transform ?? "";
54
54
  let directory = path ?? "";
55
55
  if (transform && !TRANSFORMER_INQUIRER_CHOICES.find((x) => x.title === transform)) {
56
56
  console.error("Invalid transform choice, pick one of:");
57
- console.error(TRANSFORMER_INQUIRER_CHOICES.map((x) => "- " + x.title).join("\n"));
57
+ console.error(TRANSFORMER_INQUIRER_CHOICES.map((x) => `- ${+x.title}`).join("\n"));
58
58
  process.exit(1);
59
59
  }
60
60
  if (!transform) {
@@ -88,6 +88,12 @@ async function transformRunner(transform, path) {
88
88
  directory = res.path;
89
89
  }
90
90
  const args = [];
91
+ if (options?.dry) {
92
+ args.push("--dry");
93
+ }
94
+ if (options?.print) {
95
+ args.push("--print");
96
+ }
91
97
  args.push("--no-babel");
92
98
  args.push("--ignore-pattern=**/node_modules/**");
93
99
  args.push("--ignore-pattern=**/.next/**");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suspensive/codemods",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Codemods for @suspensive.",
5
5
  "keywords": [
6
6
  "suspensive",