From 473473e6b31602a8b6f5197fcec641a04d790620 Mon Sep 17 00:00:00 2001 From: Daniel Del Core Date: Tue, 18 May 2021 13:15:19 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Rename=20test=20utility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/config.json | 10 +++++----- .changeset/three-islands-rhyme.md | 6 ++++++ .changeset/young-plums-fail.md | 5 +++++ .../18.0.0/__tests__/transform.spec.ts | 4 ++-- packages/cli/src/cli.ts | 4 ++-- .../src/{run-transform.ts => apply-transform.ts} | 2 +- packages/test-utils/src/index.ts | 2 +- packages/utils/src/module-imports.ts | 4 ++-- 8 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 .changeset/three-islands-rhyme.md create mode 100644 .changeset/young-plums-fail.md rename packages/test-utils/src/{run-transform.ts => apply-transform.ts} (93%) diff --git a/.changeset/config.json b/.changeset/config.json index 09890ec42..d0affc91d 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,7 +1,7 @@ { - "$schema": "https://unpkg.com/@changesets/config@1.0.1/schema.json", - "changelog": "@changesets/cli/changelog", - "commit": false, - "access": "public", - "baseBranch": "master" + "$schema": "https://unpkg.com/@changesets/config@1.0.1/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "access": "public", + "baseBranch": "main" } diff --git a/.changeset/three-islands-rhyme.md b/.changeset/three-islands-rhyme.md new file mode 100644 index 000000000..12cd606bd --- /dev/null +++ b/.changeset/three-islands-rhyme.md @@ -0,0 +1,6 @@ +--- +'@codeshift/cli': patch +'@codeshift/utils': patch +--- + +Minor internal tweaks diff --git a/.changeset/young-plums-fail.md b/.changeset/young-plums-fail.md new file mode 100644 index 000000000..9ea252728 --- /dev/null +++ b/.changeset/young-plums-fail.md @@ -0,0 +1,5 @@ +--- +'@codeshift/test-utils': patch +--- + +Renames runTransform to applyTransform diff --git a/community/@atlaskit__avatar/18.0.0/__tests__/transform.spec.ts b/community/@atlaskit__avatar/18.0.0/__tests__/transform.spec.ts index 77d2dd018..61c82accb 100644 --- a/community/@atlaskit__avatar/18.0.0/__tests__/transform.spec.ts +++ b/community/@atlaskit__avatar/18.0.0/__tests__/transform.spec.ts @@ -1,13 +1,13 @@ jest.autoMockOff(); -import { runTransform } from '@codeshift/test-utils'; +import { applyTransform } from '@codeshift/test-utils'; import * as transformer from '../transform'; const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest; describe('Update Avatar props', () => { it('should wrap avatar in a tooltip if name is defined', () => { - const result = runTransform( + const result = applyTransform( transformer, ` import Avatar from '@atlaskit/avatar'; diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index ccb583c30..45bbc61a3 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -28,8 +28,8 @@ Options --help, 😱 Examples - # Run all transforms for "@atlaskit/button" greater than version 3.0.0 and @atlaskit/range greater than 4.0.0 - $ npx @codeshift/cli --packages @atlaskit/button@3.0.0,@atlaskit/range@4.0.0 /project/src + # Run all transforms for "@mylib/button" greater than version 3.0.0 and @mylib/range greater than 4.0.0 + $ npx @codeshift/cli --packages @mylib/button@3.0.0,@mylib/range@4.0.0 /project/src # Run the "my-custom-transform" transform of the "button" package $ npx @codeshift/cli -t my-custom-transform /project/src diff --git a/packages/test-utils/src/run-transform.ts b/packages/test-utils/src/apply-transform.ts similarity index 93% rename from packages/test-utils/src/run-transform.ts rename to packages/test-utils/src/apply-transform.ts index 0fbba2d42..515bc5fb0 100644 --- a/packages/test-utils/src/run-transform.ts +++ b/packages/test-utils/src/apply-transform.ts @@ -6,7 +6,7 @@ interface Options { parser?: Parser; } -export default function runTransform( +export default function applyTransform( transform: any, input: string, options: Options = { diff --git a/packages/test-utils/src/index.ts b/packages/test-utils/src/index.ts index 2f2bd96f0..76b9a6437 100644 --- a/packages/test-utils/src/index.ts +++ b/packages/test-utils/src/index.ts @@ -1 +1 @@ -export { default as runTransform } from './run-transform'; +export { default as applyTransform } from './apply-transform'; diff --git a/packages/utils/src/module-imports.ts b/packages/utils/src/module-imports.ts index fe3645ed0..958d6f14f 100644 --- a/packages/utils/src/module-imports.ts +++ b/packages/utils/src/module-imports.ts @@ -13,11 +13,11 @@ export function hasImportDeclaration( export function getImportDeclaration( j: core.JSCodeshift, source: ReturnType, - specifier: string, + importPath: string, ) { return source .find(j.ImportDeclaration) - .filter(path => path.node.source.value === specifier); + .filter(path => path.node.source.value === importPath); } export function getDefaultImportSpecifier(