From 91008017013e25493272c768d4d21059d7583495 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Wed, 28 Aug 2024 09:17:11 +0200 Subject: [PATCH 1/8] chore: Simplified script --- packages/cli/.npmignore | 3 +- packages/cli/codemod-test-fixture.sh | 44 ------------------------ packages/cli/codemod-test-fixtures.sh | 32 ----------------- packages/cli/update-test-fixtures.sh | 49 +++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 78 deletions(-) delete mode 100755 packages/cli/codemod-test-fixture.sh delete mode 100755 packages/cli/codemod-test-fixtures.sh create mode 100755 packages/cli/update-test-fixtures.sh diff --git a/packages/cli/.npmignore b/packages/cli/.npmignore index 7856b458..4e55df72 100644 --- a/packages/cli/.npmignore +++ b/packages/cli/.npmignore @@ -17,6 +17,5 @@ /.prettierignore /.prettierrc.cjs /build.sh -/codemod-test-fixture.sh -/codemod-test-fixtures.sh +/update-test-fixtures.sh /tests/ diff --git a/packages/cli/codemod-test-fixture.sh b/packages/cli/codemod-test-fixture.sh deleted file mode 100755 index 56c04a96..00000000 --- a/packages/cli/codemod-test-fixture.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix the expected output of a test fixture after updating the source code. -# -# B. Usage -# -# For named arguments, do not include `=` between the flag and the value. -# Positional arguments are to appear at the end. -# -# ./codemod-test-fixture.sh [OPTIONAL-FLAGS] -# -#--------- - -# Get named arguments for the binary -while getopts ":N:" flag -do - case $flag in - N) NAMED_ARGUMENTS=$OPTARG;; - esac -done - -# Get fixture name -FIXTURE=${@:$OPTIND:1} - -if [ ! $FIXTURE ] -then - echo "ERROR: Please specify the fixture name.\n" - exit 1 -elif [ ! -d "tests/fixtures/$FIXTURE/input" ] -then - echo "ERROR: Input folder \`tests/fixtures/$FIXTURE/input\` does not exist.\n" - exit 1 -fi - -rm -r "tests/fixtures/$FIXTURE/output" -cp -r "tests/fixtures/$FIXTURE/input" "tests/fixtures/$FIXTURE/output" - -./dist/bin/cli.js $NAMED_ARGUMENTS --root="tests/fixtures/$FIXTURE/output" - -echo "SUCCESS: Updated the output of $FIXTURE.\n" diff --git a/packages/cli/codemod-test-fixtures.sh b/packages/cli/codemod-test-fixtures.sh deleted file mode 100755 index 562956d4..00000000 --- a/packages/cli/codemod-test-fixtures.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix all test fixtures after updating the source code. -# -# B. Usage -# -# ./codemod-test-fixtures.sh -# -#--------- - -# Compile TypeScript -pnpm build - -./codemod-test-fixture.sh \ - -N "--name ember-codemod-pod-to-octane --typescript false" \ - javascript - -./codemod-test-fixture.sh \ - -N "--addon ast-javascript ast-template blueprints ember-cli-string json --name ember-codemod-args-to-signature --typescript false" \ - javascript-with-addons - -./codemod-test-fixture.sh \ - -N "--name ember-codemod-pod-to-octane" \ - typescript - -./codemod-test-fixture.sh \ - -N "--addon ast-javascript ast-template blueprints ember-cli-string json --name ember-codemod-args-to-signature" \ - typescript-with-addons diff --git a/packages/cli/update-test-fixtures.sh b/packages/cli/update-test-fixtures.sh new file mode 100755 index 00000000..d2739eba --- /dev/null +++ b/packages/cli/update-test-fixtures.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env sh + +#---------- +# +# A. Purpose +# +# Fix all test fixtures after updating the source code. +# +# B. Usage +# +# ./update-test-fixtures.sh +# +#--------- + +# Compile TypeScript +pnpm build + +# Update fixtures +rm -r "tests/fixtures/javascript/output" +cp -r "tests/fixtures/javascript/input" "tests/fixtures/javascript/output" + +./dist/bin/cli.js \ + --name ember-codemod-pod-to-octane \ + --root "tests/fixtures/javascript/output" \ + --typescript false + +rm -r "tests/fixtures/javascript-with-addons/output" +cp -r "tests/fixtures/javascript-with-addons/input" "tests/fixtures/javascript-with-addons/output" + +./dist/bin/cli.js \ + --addon ast-javascript ast-template blueprints ember-cli-string json \ + --name ember-codemod-args-to-signature \ + --root "tests/fixtures/javascript-with-addons/output" \ + --typescript false + +rm -r "tests/fixtures/typescript/output" +cp -r "tests/fixtures/typescript/input" "tests/fixtures/typescript/output" + +./dist/bin/cli.js \ + --name ember-codemod-pod-to-octane \ + --root "tests/fixtures/typescript/output" + +rm -r "tests/fixtures/typescript-with-addons/output" +cp -r "tests/fixtures/typescript-with-addons/input" "tests/fixtures/typescript-with-addons/output" + +./dist/bin/cli.js \ + --addon ast-javascript ast-template blueprints ember-cli-string json \ + --name ember-codemod-args-to-signature \ + --root "tests/fixtures/typescript-with-addons/output" From 7e65f71a5c51890b0005af5b5ff7ef085713b04b Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Wed, 28 Aug 2024 09:23:44 +0200 Subject: [PATCH 2/8] feature: Simplified script --- packages/cli/src/blueprints/__npmignore__ | 3 +- .../src/blueprints/codemod-test-fixture.sh | 44 ------------------- .../src/blueprints/codemod-test-fixtures.sh | 20 --------- .../src/blueprints/update-test-fixtures.sh | 23 ++++++++++ .../src/steps/create-files-from-blueprints.ts | 5 +-- 5 files changed, 25 insertions(+), 70 deletions(-) delete mode 100644 packages/cli/src/blueprints/codemod-test-fixture.sh delete mode 100644 packages/cli/src/blueprints/codemod-test-fixtures.sh create mode 100644 packages/cli/src/blueprints/update-test-fixtures.sh diff --git a/packages/cli/src/blueprints/__npmignore__ b/packages/cli/src/blueprints/__npmignore__ index fc33b3b8..4b3a1b4b 100644 --- a/packages/cli/src/blueprints/__npmignore__ +++ b/packages/cli/src/blueprints/__npmignore__ @@ -18,8 +18,7 @@ /.prettierignore /.prettierrc.cjs /build.sh -/codemod-test-fixture.sh -/codemod-test-fixtures.sh +/update-test-fixtures.sh /CONTRIBUTING.md /create-test-fixture.sh /tests/ diff --git a/packages/cli/src/blueprints/codemod-test-fixture.sh b/packages/cli/src/blueprints/codemod-test-fixture.sh deleted file mode 100644 index 5b08ff68..00000000 --- a/packages/cli/src/blueprints/codemod-test-fixture.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix the expected output of a test fixture after updating the source code. -# -# B. Usage -# -# For named arguments, do not include `=` between the flag and the value. -# Positional arguments are to appear at the end. -# -# ./codemod-test-fixture.sh [OPTIONAL-FLAGS] -# -#--------- - -# Get named arguments for the binary -while getopts ":N:" flag -do - case $flag in - N) NAMED_ARGUMENTS=$OPTARG;; - esac -done - -# Get fixture name -FIXTURE=${@:$OPTIND:1} - -if [ ! $FIXTURE ] -then - echo "ERROR: Please specify the fixture name.\n" - exit 1 -elif [ ! -d "tests/fixtures/$FIXTURE/input" ] -then - echo "ERROR: Input folder \`tests/fixtures/$FIXTURE/input\` does not exist.\n" - exit 1 -fi - -rm -r "tests/fixtures/$FIXTURE/output" -cp -r "tests/fixtures/$FIXTURE/input" "tests/fixtures/$FIXTURE/output" - -./dist/bin/<%= options.codemod.name %>.js $NAMED_ARGUMENTS --root="tests/fixtures/$FIXTURE/output" - -echo "SUCCESS: Updated the output of $FIXTURE.\n" diff --git a/packages/cli/src/blueprints/codemod-test-fixtures.sh b/packages/cli/src/blueprints/codemod-test-fixtures.sh deleted file mode 100644 index 9bbd5a69..00000000 --- a/packages/cli/src/blueprints/codemod-test-fixtures.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix all test fixtures after updating the source code. -# -# B. Usage -# -# ./codemod-test-fixtures.sh -# -#--------- - -# Compile TypeScript -<% if (options.codemod.hasTypeScript) { %>pnpm build<% } else { %># pnpm build<% } %> - -./codemod-test-fixture.sh \ - -N "" \ - sample-project diff --git a/packages/cli/src/blueprints/update-test-fixtures.sh b/packages/cli/src/blueprints/update-test-fixtures.sh new file mode 100644 index 00000000..137a27b8 --- /dev/null +++ b/packages/cli/src/blueprints/update-test-fixtures.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +#---------- +# +# A. Purpose +# +# Fix all test fixtures after updating the source code. +# +# B. Usage +# +# ./update-test-fixtures.sh +# +#--------- +<% if (options.codemod.hasTypeScript) { %> +# Compile TypeScript +pnpm build +<% } %> +# Update fixtures +rm -r "tests/fixtures/sample-project/output" +cp -r "tests/fixtures/sample-project/input" "tests/fixtures/sample-project/output" + +./dist/bin/<%= options.codemod.name %>.js \ + --root "tests/fixtures/sample-project/output" diff --git a/packages/cli/src/steps/create-files-from-blueprints.ts b/packages/cli/src/steps/create-files-from-blueprints.ts index 511397ae..9c05e87b 100644 --- a/packages/cli/src/steps/create-files-from-blueprints.ts +++ b/packages/cli/src/steps/create-files-from-blueprints.ts @@ -45,10 +45,7 @@ function resolveBlueprintFilePath( function setExecutePermissions(options: Options) { const { codemod, projectRoot } = options; - const files = new Set([ - 'codemod-test-fixture.sh', - 'codemod-test-fixtures.sh', - ]); + const files = new Set(['update-test-fixtures.sh']); if (codemod.hasTypeScript) { files.add(`bin/${codemod.name}.ts`); From 19c9b305a3040cb5c6a89f22918c592b2463e8d1 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Wed, 28 Aug 2024 09:23:50 +0200 Subject: [PATCH 3/8] chore: Updated fixtures --- .../.npmignore | 3 +- .../codemod-test-fixture.sh | 44 ------------------- .../codemod-test-fixtures.sh | 20 --------- .../update-test-fixtures.sh | 20 +++++++++ .../ember-codemod-pod-to-octane/.npmignore | 3 +- .../codemod-test-fixture.sh | 44 ------------------- .../codemod-test-fixtures.sh | 20 --------- .../update-test-fixtures.sh | 20 +++++++++ .../.npmignore | 3 +- .../codemod-test-fixture.sh | 44 ------------------- .../codemod-test-fixtures.sh | 20 --------- .../update-test-fixtures.sh | 23 ++++++++++ .../ember-codemod-pod-to-octane/.npmignore | 3 +- .../codemod-test-fixture.sh | 44 ------------------- .../codemod-test-fixtures.sh | 20 --------- .../update-test-fixtures.sh | 23 ++++++++++ 16 files changed, 90 insertions(+), 264 deletions(-) delete mode 100755 packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixture.sh delete mode 100755 packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixtures.sh create mode 100755 packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/update-test-fixtures.sh delete mode 100755 packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/codemod-test-fixture.sh delete mode 100755 packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/codemod-test-fixtures.sh create mode 100755 packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/update-test-fixtures.sh delete mode 100755 packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixture.sh delete mode 100755 packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixtures.sh create mode 100755 packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/update-test-fixtures.sh delete mode 100755 packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/codemod-test-fixture.sh delete mode 100755 packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/codemod-test-fixtures.sh create mode 100755 packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/update-test-fixtures.sh diff --git a/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/.npmignore b/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/.npmignore index fc33b3b8..4b3a1b4b 100644 --- a/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/.npmignore +++ b/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/.npmignore @@ -18,8 +18,7 @@ /.prettierignore /.prettierrc.cjs /build.sh -/codemod-test-fixture.sh -/codemod-test-fixtures.sh +/update-test-fixtures.sh /CONTRIBUTING.md /create-test-fixture.sh /tests/ diff --git a/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixture.sh b/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixture.sh deleted file mode 100755 index a78a4ae9..00000000 --- a/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixture.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix the expected output of a test fixture after updating the source code. -# -# B. Usage -# -# For named arguments, do not include `=` between the flag and the value. -# Positional arguments are to appear at the end. -# -# ./codemod-test-fixture.sh [OPTIONAL-FLAGS] -# -#--------- - -# Get named arguments for the binary -while getopts ":N:" flag -do - case $flag in - N) NAMED_ARGUMENTS=$OPTARG;; - esac -done - -# Get fixture name -FIXTURE=${@:$OPTIND:1} - -if [ ! $FIXTURE ] -then - echo "ERROR: Please specify the fixture name.\n" - exit 1 -elif [ ! -d "tests/fixtures/$FIXTURE/input" ] -then - echo "ERROR: Input folder \`tests/fixtures/$FIXTURE/input\` does not exist.\n" - exit 1 -fi - -rm -r "tests/fixtures/$FIXTURE/output" -cp -r "tests/fixtures/$FIXTURE/input" "tests/fixtures/$FIXTURE/output" - -./dist/bin/ember-codemod-args-to-signature.js $NAMED_ARGUMENTS --root="tests/fixtures/$FIXTURE/output" - -echo "SUCCESS: Updated the output of $FIXTURE.\n" diff --git a/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixtures.sh b/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixtures.sh deleted file mode 100755 index 6b06b5f0..00000000 --- a/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixtures.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix all test fixtures after updating the source code. -# -# B. Usage -# -# ./codemod-test-fixtures.sh -# -#--------- - -# Compile TypeScript -# pnpm build - -./codemod-test-fixture.sh \ - -N "" \ - sample-project diff --git a/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/update-test-fixtures.sh b/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/update-test-fixtures.sh new file mode 100755 index 00000000..3d3cf04d --- /dev/null +++ b/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/update-test-fixtures.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +#---------- +# +# A. Purpose +# +# Fix all test fixtures after updating the source code. +# +# B. Usage +# +# ./update-test-fixtures.sh +# +#--------- + +# Update fixtures +rm -r "tests/fixtures/sample-project/output" +cp -r "tests/fixtures/sample-project/input" "tests/fixtures/sample-project/output" + +./dist/bin/ember-codemod-args-to-signature.js \ + --root "tests/fixtures/sample-project/output" diff --git a/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/.npmignore b/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/.npmignore index fc33b3b8..4b3a1b4b 100644 --- a/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/.npmignore +++ b/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/.npmignore @@ -18,8 +18,7 @@ /.prettierignore /.prettierrc.cjs /build.sh -/codemod-test-fixture.sh -/codemod-test-fixtures.sh +/update-test-fixtures.sh /CONTRIBUTING.md /create-test-fixture.sh /tests/ diff --git a/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/codemod-test-fixture.sh b/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/codemod-test-fixture.sh deleted file mode 100755 index 57ceb336..00000000 --- a/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/codemod-test-fixture.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix the expected output of a test fixture after updating the source code. -# -# B. Usage -# -# For named arguments, do not include `=` between the flag and the value. -# Positional arguments are to appear at the end. -# -# ./codemod-test-fixture.sh [OPTIONAL-FLAGS] -# -#--------- - -# Get named arguments for the binary -while getopts ":N:" flag -do - case $flag in - N) NAMED_ARGUMENTS=$OPTARG;; - esac -done - -# Get fixture name -FIXTURE=${@:$OPTIND:1} - -if [ ! $FIXTURE ] -then - echo "ERROR: Please specify the fixture name.\n" - exit 1 -elif [ ! -d "tests/fixtures/$FIXTURE/input" ] -then - echo "ERROR: Input folder \`tests/fixtures/$FIXTURE/input\` does not exist.\n" - exit 1 -fi - -rm -r "tests/fixtures/$FIXTURE/output" -cp -r "tests/fixtures/$FIXTURE/input" "tests/fixtures/$FIXTURE/output" - -./dist/bin/ember-codemod-pod-to-octane.js $NAMED_ARGUMENTS --root="tests/fixtures/$FIXTURE/output" - -echo "SUCCESS: Updated the output of $FIXTURE.\n" diff --git a/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/codemod-test-fixtures.sh b/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/codemod-test-fixtures.sh deleted file mode 100755 index 6b06b5f0..00000000 --- a/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/codemod-test-fixtures.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix all test fixtures after updating the source code. -# -# B. Usage -# -# ./codemod-test-fixtures.sh -# -#--------- - -# Compile TypeScript -# pnpm build - -./codemod-test-fixture.sh \ - -N "" \ - sample-project diff --git a/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/update-test-fixtures.sh b/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/update-test-fixtures.sh new file mode 100755 index 00000000..ea35d3c0 --- /dev/null +++ b/packages/cli/tests/fixtures/javascript/output/ember-codemod-pod-to-octane/update-test-fixtures.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env sh + +#---------- +# +# A. Purpose +# +# Fix all test fixtures after updating the source code. +# +# B. Usage +# +# ./update-test-fixtures.sh +# +#--------- + +# Update fixtures +rm -r "tests/fixtures/sample-project/output" +cp -r "tests/fixtures/sample-project/input" "tests/fixtures/sample-project/output" + +./dist/bin/ember-codemod-pod-to-octane.js \ + --root "tests/fixtures/sample-project/output" diff --git a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/.npmignore b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/.npmignore index fc33b3b8..4b3a1b4b 100644 --- a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/.npmignore +++ b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/.npmignore @@ -18,8 +18,7 @@ /.prettierignore /.prettierrc.cjs /build.sh -/codemod-test-fixture.sh -/codemod-test-fixtures.sh +/update-test-fixtures.sh /CONTRIBUTING.md /create-test-fixture.sh /tests/ diff --git a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixture.sh b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixture.sh deleted file mode 100755 index a78a4ae9..00000000 --- a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixture.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix the expected output of a test fixture after updating the source code. -# -# B. Usage -# -# For named arguments, do not include `=` between the flag and the value. -# Positional arguments are to appear at the end. -# -# ./codemod-test-fixture.sh [OPTIONAL-FLAGS] -# -#--------- - -# Get named arguments for the binary -while getopts ":N:" flag -do - case $flag in - N) NAMED_ARGUMENTS=$OPTARG;; - esac -done - -# Get fixture name -FIXTURE=${@:$OPTIND:1} - -if [ ! $FIXTURE ] -then - echo "ERROR: Please specify the fixture name.\n" - exit 1 -elif [ ! -d "tests/fixtures/$FIXTURE/input" ] -then - echo "ERROR: Input folder \`tests/fixtures/$FIXTURE/input\` does not exist.\n" - exit 1 -fi - -rm -r "tests/fixtures/$FIXTURE/output" -cp -r "tests/fixtures/$FIXTURE/input" "tests/fixtures/$FIXTURE/output" - -./dist/bin/ember-codemod-args-to-signature.js $NAMED_ARGUMENTS --root="tests/fixtures/$FIXTURE/output" - -echo "SUCCESS: Updated the output of $FIXTURE.\n" diff --git a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixtures.sh b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixtures.sh deleted file mode 100755 index 5caf3c3a..00000000 --- a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/codemod-test-fixtures.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix all test fixtures after updating the source code. -# -# B. Usage -# -# ./codemod-test-fixtures.sh -# -#--------- - -# Compile TypeScript -pnpm build - -./codemod-test-fixture.sh \ - -N "" \ - sample-project diff --git a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/update-test-fixtures.sh b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/update-test-fixtures.sh new file mode 100755 index 00000000..b4c12595 --- /dev/null +++ b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/update-test-fixtures.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +#---------- +# +# A. Purpose +# +# Fix all test fixtures after updating the source code. +# +# B. Usage +# +# ./update-test-fixtures.sh +# +#--------- + +# Compile TypeScript +pnpm build + +# Update fixtures +rm -r "tests/fixtures/sample-project/output" +cp -r "tests/fixtures/sample-project/input" "tests/fixtures/sample-project/output" + +./dist/bin/ember-codemod-args-to-signature.js \ + --root "tests/fixtures/sample-project/output" diff --git a/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/.npmignore b/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/.npmignore index fc33b3b8..4b3a1b4b 100644 --- a/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/.npmignore +++ b/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/.npmignore @@ -18,8 +18,7 @@ /.prettierignore /.prettierrc.cjs /build.sh -/codemod-test-fixture.sh -/codemod-test-fixtures.sh +/update-test-fixtures.sh /CONTRIBUTING.md /create-test-fixture.sh /tests/ diff --git a/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/codemod-test-fixture.sh b/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/codemod-test-fixture.sh deleted file mode 100755 index 57ceb336..00000000 --- a/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/codemod-test-fixture.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix the expected output of a test fixture after updating the source code. -# -# B. Usage -# -# For named arguments, do not include `=` between the flag and the value. -# Positional arguments are to appear at the end. -# -# ./codemod-test-fixture.sh [OPTIONAL-FLAGS] -# -#--------- - -# Get named arguments for the binary -while getopts ":N:" flag -do - case $flag in - N) NAMED_ARGUMENTS=$OPTARG;; - esac -done - -# Get fixture name -FIXTURE=${@:$OPTIND:1} - -if [ ! $FIXTURE ] -then - echo "ERROR: Please specify the fixture name.\n" - exit 1 -elif [ ! -d "tests/fixtures/$FIXTURE/input" ] -then - echo "ERROR: Input folder \`tests/fixtures/$FIXTURE/input\` does not exist.\n" - exit 1 -fi - -rm -r "tests/fixtures/$FIXTURE/output" -cp -r "tests/fixtures/$FIXTURE/input" "tests/fixtures/$FIXTURE/output" - -./dist/bin/ember-codemod-pod-to-octane.js $NAMED_ARGUMENTS --root="tests/fixtures/$FIXTURE/output" - -echo "SUCCESS: Updated the output of $FIXTURE.\n" diff --git a/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/codemod-test-fixtures.sh b/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/codemod-test-fixtures.sh deleted file mode 100755 index 5caf3c3a..00000000 --- a/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/codemod-test-fixtures.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env sh - -#---------- -# -# A. Purpose -# -# Fix all test fixtures after updating the source code. -# -# B. Usage -# -# ./codemod-test-fixtures.sh -# -#--------- - -# Compile TypeScript -pnpm build - -./codemod-test-fixture.sh \ - -N "" \ - sample-project diff --git a/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/update-test-fixtures.sh b/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/update-test-fixtures.sh new file mode 100755 index 00000000..377296cc --- /dev/null +++ b/packages/cli/tests/fixtures/typescript/output/ember-codemod-pod-to-octane/update-test-fixtures.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +#---------- +# +# A. Purpose +# +# Fix all test fixtures after updating the source code. +# +# B. Usage +# +# ./update-test-fixtures.sh +# +#--------- + +# Compile TypeScript +pnpm build + +# Update fixtures +rm -r "tests/fixtures/sample-project/output" +cp -r "tests/fixtures/sample-project/input" "tests/fixtures/sample-project/output" + +./dist/bin/ember-codemod-pod-to-octane.js \ + --root "tests/fixtures/sample-project/output" From 0898d43674ac2d0fe34ef9350f888f38bd96db55 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Wed, 28 Aug 2024 09:25:42 +0200 Subject: [PATCH 4/8] chore: Replaced @codemod-utils/ember-cli-string with @codemod-utils/ember --- packages/cli/README.md | 2 +- packages/cli/bin/cli.ts | 2 +- packages/cli/src/types/index.ts | 2 +- packages/cli/src/utils/blueprints/get-version.ts | 2 +- .../helpers/shared-test-setups/javascript-with-addons.ts | 4 ++-- .../helpers/shared-test-setups/typescript-with-addons.ts | 4 ++-- packages/cli/update-test-fixtures.sh | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index b6e029cc..e4f911d3 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -61,7 +61,7 @@ The options are: - [`ast-javascript`](../ast/javascript/README.md) - [`ast-template`](../ast/template/README.md) - [`blueprints`](../blueprints/README.md) -- [`ember-cli-string`](../ember-cli-string/README.md) +- [`ember`](../ember/README.md) - [`json`](../json/README.md) diff --git a/packages/cli/bin/cli.ts b/packages/cli/bin/cli.ts index f3c43020..58866fc0 100755 --- a/packages/cli/bin/cli.ts +++ b/packages/cli/bin/cli.ts @@ -17,7 +17,7 @@ const argv = yargs(hideBin(process.argv)) 'ast-javascript', 'ast-template', 'blueprints', - 'ember-cli-string', + 'ember', 'json', ] as const, describe: 'Optional @codemod-utils packages to install', diff --git a/packages/cli/src/types/index.ts b/packages/cli/src/types/index.ts index 0ff90d89..c5d479f6 100644 --- a/packages/cli/src/types/index.ts +++ b/packages/cli/src/types/index.ts @@ -2,7 +2,7 @@ type Addon = | 'ast-javascript' | 'ast-template' | 'blueprints' - | 'ember-cli-string' + | 'ember' | 'json'; type CodemodOptions = { diff --git a/packages/cli/src/utils/blueprints/get-version.ts b/packages/cli/src/utils/blueprints/get-version.ts index f2908fe3..7e35db9e 100644 --- a/packages/cli/src/utils/blueprints/get-version.ts +++ b/packages/cli/src/utils/blueprints/get-version.ts @@ -8,7 +8,7 @@ const latestVersions = new Map([ ['@codemod-utils/ast-javascript', '1.2.8'], ['@codemod-utils/ast-template', '1.1.4'], ['@codemod-utils/blueprints', '1.1.5'], - ['@codemod-utils/ember-cli-string', '1.1.4'], + ['@codemod-utils/ember', '2.0.0'], ['@codemod-utils/files', '2.0.4'], ['@codemod-utils/json', '1.1.9'], ['@codemod-utils/tests', '1.1.7'], diff --git a/packages/cli/tests/helpers/shared-test-setups/javascript-with-addons.ts b/packages/cli/tests/helpers/shared-test-setups/javascript-with-addons.ts index bf7db1d0..77eb4e07 100644 --- a/packages/cli/tests/helpers/shared-test-setups/javascript-with-addons.ts +++ b/packages/cli/tests/helpers/shared-test-setups/javascript-with-addons.ts @@ -5,7 +5,7 @@ const codemodOptions: CodemodOptions = { 'ast-javascript', 'ast-template', 'blueprints', - 'ember-cli-string', + 'ember', 'json', ]), hasTypeScript: false, @@ -19,7 +19,7 @@ const options: Options = { 'ast-javascript', 'ast-template', 'blueprints', - 'ember-cli-string', + 'ember', 'json', ]), hasTypeScript: false, diff --git a/packages/cli/tests/helpers/shared-test-setups/typescript-with-addons.ts b/packages/cli/tests/helpers/shared-test-setups/typescript-with-addons.ts index 34df13fd..ddb7ae53 100644 --- a/packages/cli/tests/helpers/shared-test-setups/typescript-with-addons.ts +++ b/packages/cli/tests/helpers/shared-test-setups/typescript-with-addons.ts @@ -5,7 +5,7 @@ const codemodOptions: CodemodOptions = { 'ast-javascript', 'ast-template', 'blueprints', - 'ember-cli-string', + 'ember', 'json', ]), hasTypeScript: true, @@ -19,7 +19,7 @@ const options: Options = { 'ast-javascript', 'ast-template', 'blueprints', - 'ember-cli-string', + 'ember', 'json', ]), hasTypeScript: true, diff --git a/packages/cli/update-test-fixtures.sh b/packages/cli/update-test-fixtures.sh index d2739eba..394f0ef4 100755 --- a/packages/cli/update-test-fixtures.sh +++ b/packages/cli/update-test-fixtures.sh @@ -28,7 +28,7 @@ rm -r "tests/fixtures/javascript-with-addons/output" cp -r "tests/fixtures/javascript-with-addons/input" "tests/fixtures/javascript-with-addons/output" ./dist/bin/cli.js \ - --addon ast-javascript ast-template blueprints ember-cli-string json \ + --addon ast-javascript ast-template blueprints ember json \ --name ember-codemod-args-to-signature \ --root "tests/fixtures/javascript-with-addons/output" \ --typescript false @@ -44,6 +44,6 @@ rm -r "tests/fixtures/typescript-with-addons/output" cp -r "tests/fixtures/typescript-with-addons/input" "tests/fixtures/typescript-with-addons/output" ./dist/bin/cli.js \ - --addon ast-javascript ast-template blueprints ember-cli-string json \ + --addon ast-javascript ast-template blueprints ember json \ --name ember-codemod-args-to-signature \ --root "tests/fixtures/typescript-with-addons/output" From 6d2575f022f6406696ea6ad0629fb850b7fb47d0 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Wed, 28 Aug 2024 09:26:05 +0200 Subject: [PATCH 5/8] chore: Updated fixtures --- .../output/ember-codemod-args-to-signature/package.json | 2 +- .../output/ember-codemod-args-to-signature/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/package.json b/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/package.json index cc5beb24..f589f2e8 100644 --- a/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/package.json +++ b/packages/cli/tests/fixtures/javascript-with-addons/output/ember-codemod-args-to-signature/package.json @@ -34,7 +34,7 @@ "@codemod-utils/ast-javascript": "^1.2.8", "@codemod-utils/ast-template": "^1.1.4", "@codemod-utils/blueprints": "^1.1.5", - "@codemod-utils/ember-cli-string": "^1.1.4", + "@codemod-utils/ember": "^2.0.0", "@codemod-utils/files": "^2.0.4", "@codemod-utils/json": "^1.1.9", "yargs": "^17.7.2" diff --git a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/package.json b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/package.json index 81d73ba9..d6027b15 100644 --- a/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/package.json +++ b/packages/cli/tests/fixtures/typescript-with-addons/output/ember-codemod-args-to-signature/package.json @@ -36,7 +36,7 @@ "@codemod-utils/ast-javascript": "^1.2.8", "@codemod-utils/ast-template": "^1.1.4", "@codemod-utils/blueprints": "^1.1.5", - "@codemod-utils/ember-cli-string": "^1.1.4", + "@codemod-utils/ember": "^2.0.0", "@codemod-utils/files": "^2.0.4", "@codemod-utils/json": "^1.1.9", "yargs": "^17.7.2" From fb90ea8d06a5b5d89ce9f1b19738aca8f1c7680d Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Wed, 28 Aug 2024 09:31:28 +0200 Subject: [PATCH 6/8] feature: Made codemod name a positional argument --- packages/cli/README.md | 8 +-- packages/cli/bin/cli.ts | 77 +++++++++++++++------------- packages/cli/update-test-fixtures.sh | 8 +-- 3 files changed, 50 insertions(+), 43 deletions(-) diff --git a/packages/cli/README.md b/packages/cli/README.md index e4f911d3..37590d33 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -7,10 +7,10 @@ _CLI to create a codemod project_ ## Usage -Step 1. Use `npx` to run `@codemod-utils/cli`. Alternatively, you can globally install the package. +Step 1. Use `npx` to run `@codemod-utils/cli`. ```sh -npx @codemod-utils/cli --name +npx @codemod-utils/cli [options] ``` This will create a folder named ``. @@ -39,10 +39,10 @@ git push -u origin main ### Arguments -You must pass `--name` to name your codemod. +You must pass the name of your codemod. ```sh -npx @codemod-utils/cli --name ember-codemod-v1-to-v2 +npx @codemod-utils/cli ember-codemod-v1-to-v2 ``` diff --git a/packages/cli/bin/cli.ts b/packages/cli/bin/cli.ts index 58866fc0..99768d31 100755 --- a/packages/cli/bin/cli.ts +++ b/packages/cli/bin/cli.ts @@ -5,45 +5,52 @@ import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; import { createCodemod } from '../src/index.js'; -import type { CodemodOptions } from '../src/types/index.js'; // Provide a title to the process in `ps` process.title = '@codemod-utils/cli'; // Set codemod options -const argv = yargs(hideBin(process.argv)) - .option('addon', { - choices: [ - 'ast-javascript', - 'ast-template', - 'blueprints', - 'ember', - 'json', - ] as const, - describe: 'Optional @codemod-utils packages to install', - type: 'array', - }) - .option('name', { - demandOption: true, - describe: 'Name of your codemod', - type: 'string', - }) - .option('root', { - describe: 'Where to run @codemod-utils/cli', - type: 'string', - }) - .option('typescript', { - default: true, - describe: 'Create a TypeScript project?', - type: 'boolean', +yargs(hideBin(process.argv)) + .command({ + builder: (yargs) => { + return yargs + .positional('name', { + describe: 'Name of your codemod', + type: 'string', + }) + .option('addon', { + choices: [ + 'ast-javascript', + 'ast-template', + 'blueprints', + 'ember', + 'json', + ] as const, + describe: 'Optional @codemod-utils packages to install', + type: 'array', + }) + .option('root', { + describe: 'Where to run @codemod-utils/cli', + type: 'string', + }) + .option('typescript', { + default: true, + describe: 'Create a TypeScript project?', + type: 'boolean', + }) + .demandOption(['name']); + }, + command: '* [name]', + describe: 'Creates a codemod project', + handler: (argv) => { + createCodemod({ + addons: new Set(argv['addon']), + hasTypeScript: argv['typescript'], + name: argv['name'], + projectRoot: argv['root'] ?? process.cwd(), + }); + }, }) + .demandCommand() + .strict() .parseSync(); - -const codemodOptions: CodemodOptions = { - addons: new Set(argv['addon']), - hasTypeScript: argv['typescript'], - name: argv['name'], - projectRoot: argv['root'] ?? process.cwd(), -}; - -createCodemod(codemodOptions); diff --git a/packages/cli/update-test-fixtures.sh b/packages/cli/update-test-fixtures.sh index 394f0ef4..9f5ba52e 100755 --- a/packages/cli/update-test-fixtures.sh +++ b/packages/cli/update-test-fixtures.sh @@ -20,7 +20,7 @@ rm -r "tests/fixtures/javascript/output" cp -r "tests/fixtures/javascript/input" "tests/fixtures/javascript/output" ./dist/bin/cli.js \ - --name ember-codemod-pod-to-octane \ + ember-codemod-pod-to-octane \ --root "tests/fixtures/javascript/output" \ --typescript false @@ -28,8 +28,8 @@ rm -r "tests/fixtures/javascript-with-addons/output" cp -r "tests/fixtures/javascript-with-addons/input" "tests/fixtures/javascript-with-addons/output" ./dist/bin/cli.js \ + ember-codemod-args-to-signature \ --addon ast-javascript ast-template blueprints ember json \ - --name ember-codemod-args-to-signature \ --root "tests/fixtures/javascript-with-addons/output" \ --typescript false @@ -37,13 +37,13 @@ rm -r "tests/fixtures/typescript/output" cp -r "tests/fixtures/typescript/input" "tests/fixtures/typescript/output" ./dist/bin/cli.js \ - --name ember-codemod-pod-to-octane \ + ember-codemod-pod-to-octane \ --root "tests/fixtures/typescript/output" rm -r "tests/fixtures/typescript-with-addons/output" cp -r "tests/fixtures/typescript-with-addons/input" "tests/fixtures/typescript-with-addons/output" ./dist/bin/cli.js \ + ember-codemod-args-to-signature \ --addon ast-javascript ast-template blueprints ember json \ - --name ember-codemod-args-to-signature \ --root "tests/fixtures/typescript-with-addons/output" From bb1472173a54736fa241d0f4956d947869924915 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Wed, 28 Aug 2024 09:33:54 +0200 Subject: [PATCH 7/8] chore: Updated tutorials --- .../02-create-static-files.md | 2 +- .../03-define-options.md | 18 +++++++++++------- .../04-create-dynamic-files.md | 4 ++-- .../02-understand-the-folder-structure.md | 6 +++--- ...05-step-1-update-acceptance-tests-part-2.md | 4 ++-- .../06-step-2-update-integration-tests.md | 2 +- .../10-conclusion.md | 2 +- .../02-create-utilities.md | 2 +- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/tutorials/blueprint-for-v2-addon/02-create-static-files.md b/tutorials/blueprint-for-v2-addon/02-create-static-files.md index 065e475a..73051d5d 100644 --- a/tutorials/blueprint-for-v2-addon/02-create-static-files.md +++ b/tutorials/blueprint-for-v2-addon/02-create-static-files.md @@ -170,7 +170,7 @@ export function createFilesFromBlueprints(options: Options): void { -To see the effect of `create-files-from-blueprints`, run `./codemod-test-fixtures.sh`, then check the `sample-project`'s `output` folder. You will see that we're already a few steps closer to creating the addon and the test app. ✨ +To see the effect of `create-files-from-blueprints`, run `./update-test-fixtures.sh`, then check the `sample-project`'s `output` folder. You will see that we're already a few steps closer to creating the addon and the test app. ✨ ```sh workspace-root diff --git a/tutorials/blueprint-for-v2-addon/03-define-options.md b/tutorials/blueprint-for-v2-addon/03-define-options.md index 54a6188f..a0348a4c 100644 --- a/tutorials/blueprint-for-v2-addon/03-define-options.md +++ b/tutorials/blueprint-for-v2-addon/03-define-options.md @@ -368,11 +368,11 @@ export { codemodOptions, options }; -In order for `./codemod-test-fixtures.sh` to update the output fixture files, we pass `--addon-location` and `--addon-name` like our users would. +In order for `./update-test-fixtures.sh` to update the output fixture files, we pass `--addon-location` and `--addon-name` like our users would.
-Solution: codemod-test-fixtures.sh +Solution: update-test-fixtures.sh ```diff #!/usr/bin/env sh @@ -385,17 +385,21 @@ In order for `./codemod-test-fixtures.sh` to update the output fixture files, we # # B. Usage # -# ./codemod-test-fixtures.sh +# ./update-test-fixtures.sh # #--------- # Compile TypeScript pnpm build -./codemod-test-fixture.sh \ -- -N "" \ -+ -N "--addon-location ui/button --addon-name @my-ui/button" \ - sample-project +# Update fixtures +rm -r "tests/fixtures/sample-project/output" +cp -r "tests/fixtures/sample-project/input" "tests/fixtures/sample-project/output" + +./dist/bin/ember-codemod-pod-to-octane.js \ ++ --addon-location ui/button \ ++ --addon-name @my-ui/button \ + --root "tests/fixtures/sample-project/output" ```
diff --git a/tutorials/blueprint-for-v2-addon/04-create-dynamic-files.md b/tutorials/blueprint-for-v2-addon/04-create-dynamic-files.md index 9cb81a9a..ec92a19e 100644 --- a/tutorials/blueprint-for-v2-addon/04-create-dynamic-files.md +++ b/tutorials/blueprint-for-v2-addon/04-create-dynamic-files.md @@ -113,7 +113,7 @@ Now your turn. Update the blueprint for the test app's `package.json`. > [!NOTE] -> Often, it is easy to miscalculate data and misplace the newline character `\n` . You can run `./codemod-test-fixtures.sh` to check if the fixture files are updated correctly. +> Often, it is easy to miscalculate data and misplace the newline character `\n` . You can run `./update-test-fixtures.sh` to check if the fixture files are updated correctly. ## Resolve file paths @@ -253,7 +253,7 @@ export function createFilesFromBlueprints(options: Options): void { -Run `./codemod-test-fixtures.sh` once more to see the `package.json`'s in the right place. +Run `./update-test-fixtures.sh` once more to see the `package.json`'s in the right place. ```sh workspace-root diff --git a/tutorials/ember-codemod-rename-test-modules/02-understand-the-folder-structure.md b/tutorials/ember-codemod-rename-test-modules/02-understand-the-folder-structure.md index 02661722..dce679b6 100644 --- a/tutorials/ember-codemod-rename-test-modules/02-understand-the-folder-structure.md +++ b/tutorials/ember-codemod-rename-test-modules/02-understand-the-folder-structure.md @@ -30,7 +30,7 @@ ember-codemod-rename-test-modules │ ├── index │ ├── steps │ └── (utils) -└── codemod-test-fixtures.sh +└── update-test-fixtures.sh # Hidden: dist, dist-for-testing, tmp ``` @@ -251,13 +251,13 @@ Running the `build` script (re)creates the `dist` folder. The files in this fold Running the `test` script (re)creates the `dist-for-testing` folder. The files in this folder are what is tested. The fixture files are copied to the `tmp` folder. -### codemod-test-fixtures.sh +### update-test-fixtures.sh Acceptance tests will likely fail after you create or update a step. The shell script updates the fixture files for each output project so that the acceptance tests will pass. ```sh # From the root -./codemod-test-fixtures.sh +./update-test-fixtures.sh ``` The recommended workflow is: diff --git a/tutorials/ember-codemod-rename-test-modules/05-step-1-update-acceptance-tests-part-2.md b/tutorials/ember-codemod-rename-test-modules/05-step-1-update-acceptance-tests-part-2.md index ce787cf3..c9458c33 100644 --- a/tutorials/ember-codemod-rename-test-modules/05-step-1-update-acceptance-tests-part-2.md +++ b/tutorials/ember-codemod-rename-test-modules/05-step-1-update-acceptance-tests-part-2.md @@ -697,10 +697,10 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: ### Fix fixtures -As mentioned in [Chapter 2](./02-understand-the-folder-structure.md#codemod-test-fixturessh), acceptance tests will likely fail when you create or update a step. Run the shell script to update the output fixture files and get the acceptance tests to pass. +As mentioned in [Chapter 2](./02-understand-the-folder-structure.md#update-test-fixturessh), acceptance tests will likely fail when you create or update a step. Run the shell script to update the output fixture files and get the acceptance tests to pass. ```sh -./codemod-test-fixtures.sh +./update-test-fixtures.sh ``` That was a big chapter with lots of new information. Before moving to the next one, consider taking the day off! diff --git a/tutorials/ember-codemod-rename-test-modules/06-step-2-update-integration-tests.md b/tutorials/ember-codemod-rename-test-modules/06-step-2-update-integration-tests.md index 51dd8e91..6b410011 100644 --- a/tutorials/ember-codemod-rename-test-modules/06-step-2-update-integration-tests.md +++ b/tutorials/ember-codemod-rename-test-modules/06-step-2-update-integration-tests.md @@ -519,7 +519,7 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: -Now that we're satisfied, we can run `./codemod-test-fixtures.sh` to update the output fixture files. +Now that we're satisfied, we can run `./update-test-fixtures.sh` to update the output fixture files. (You might have noticed that I surreptitiously ignored what would happen when `entityType` is `undefined`. We will address this edge case in [Chapter 8](./08-refactor-code-part-1.md#standardize-functions). diff --git a/tutorials/ember-codemod-rename-test-modules/10-conclusion.md b/tutorials/ember-codemod-rename-test-modules/10-conclusion.md index 5476fa8d..e86fdc96 100644 --- a/tutorials/ember-codemod-rename-test-modules/10-conclusion.md +++ b/tutorials/ember-codemod-rename-test-modules/10-conclusion.md @@ -6,6 +6,6 @@ To summarize what you learned: - `@codemod-utils` provides a set of tools and conventions to help you write codemods. - Break the problem into small steps. There may be a sequence of steps that makes it easier to solve the problem. -- Before implementing the first step, create fixture project(s) for acceptance tests. You can then run `./codemod-test-fixtures.sh` to see the effect of your code change. +- Before implementing the first step, create fixture project(s) for acceptance tests. You can then run `./update-test-fixtures.sh` to see the effect of your code change. - Take the simplest approach to implement steps quickly. Prefer duplication over premature abstraction. - After implementing all steps, refactor code. Write integration and unit tests to improve documentation. diff --git a/tutorials/template-tag-components/02-create-utilities.md b/tutorials/template-tag-components/02-create-utilities.md index 0ec8b678..f08ab0db 100644 --- a/tutorials/template-tag-components/02-create-utilities.md +++ b/tutorials/template-tag-components/02-create-utilities.md @@ -299,7 +299,7 @@ export function removeTestSelectors(options: Options): void { -Run `./codemod-test-fixtures.sh`. You should see that (1) only the test selectors are removed and (2) formatting is preserved. +Run `./update-test-fixtures.sh`. You should see that (1) only the test selectors are removed and (2) formatting is preserved.
From a9bc23af4d82b5dd59e5d60cdc1fab1ef92f6eb5 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Wed, 28 Aug 2024 09:35:09 +0200 Subject: [PATCH 8/8] chore: Added changeset --- .changeset/twelve-onions-kick.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/twelve-onions-kick.md diff --git a/.changeset/twelve-onions-kick.md b/.changeset/twelve-onions-kick.md new file mode 100644 index 00000000..49decc35 --- /dev/null +++ b/.changeset/twelve-onions-kick.md @@ -0,0 +1,5 @@ +--- +"@codemod-utils/cli": major +--- + +Replaced @codemod-utils/ember-cli-string with @codemod-utils/ember. Made codemod name a positional argument.