Skip to content

Conversation

@sam-b-rose
Copy link
Member

@sam-b-rose sam-b-rose commented Jul 20, 2022

Adds the beginnings of the @shopify/polaris-migrator package. This package applies code transformations to help update
Polaris apps and the Polaris codebase.

Usage

npx @shopify/polaris-migrator <migration> <path>

Run tests for @shopify/polaris-migrator

yarn test --filter=@shopify/polaris-migrator 

@sam-b-rose sam-b-rose force-pushed the add-polaris-migrator branch 3 times, most recently from 3db0d76 to c855b1c Compare July 25, 2022 21:26
@sam-b-rose sam-b-rose added the 🤖Skip Changelog Causes CI to ignore changelog update check. label Jul 25, 2022
@sam-b-rose sam-b-rose changed the title @shopify/polaris-migrator Create @shopify/polaris-migrator package Jul 25, 2022
@sam-b-rose sam-b-rose force-pushed the add-polaris-migrator branch from c855b1c to aee2299 Compare July 25, 2022 21:35
@sam-b-rose sam-b-rose force-pushed the add-polaris-migrator branch 7 times, most recently from 6474907 to 8315b33 Compare August 1, 2022 19:17
@sam-b-rose sam-b-rose removed the 🤖Skip Changelog Causes CI to ignore changelog update check. label Aug 1, 2022
@sam-b-rose sam-b-rose force-pushed the add-polaris-migrator branch from 8315b33 to 0c3aae5 Compare August 1, 2022 19:33
@sam-b-rose sam-b-rose marked this pull request as ready for review August 1, 2022 19:33
@sam-b-rose
Copy link
Member Author

/snapit

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2022

🫰✨ Thanks @samrose3! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/[email protected]
yarn add @shopify/[email protected]

@sam-b-rose sam-b-rose force-pushed the add-polaris-migrator branch from 0c3aae5 to bee4966 Compare August 1, 2022 20:03
@sam-b-rose
Copy link
Member Author

/snapit

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2022

🫰✨ Thanks @samrose3! Your snapshots have been published to npm.

Test the snapshots by updating your package.json with the newly published versions:

yarn add @shopify/[email protected]
yarn add @shopify/[email protected]

@sam-b-rose sam-b-rose force-pushed the add-polaris-migrator branch from bee4966 to 18e114a Compare August 1, 2022 20:53
Copy link
Member

@BPScott BPScott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heck yeah I love me some codemods!

Dropped some comments around the place. Noteably I think it'd be very valuable to use postcss-value-parser to get a better AST for handling transforms of prop values.

postcssPlugin: 'ReplaceSassSpacing',
Declaration(decl) {
decl.value = decl.value.replace(
createRegexFromMap(spacingMap),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of the usage of regex here. It looks like it can match false positives like my-spacing(), and miss variations in whitespace/quoting like spacing( none ), spacing('none') and spacing( "none" ) (admittedly as we use prettier our whitespace should be pretty conventional so this shouldn't be a huuuge issue for our codebases).

I'd expect us to have a better AST here. There should be AST nodes for stuff like "this is a function with a name and these specific arguments" - you should be able to be able to say "only act when you find a function name, whose name is "spacing" and has these specific values as the first argument". We should leverage a tokeniser, rather than trying to fuzzy match ourselves. It looks like this behaviour of transforming values into "this is a function call" etc is provided by postcss-value-parser

stylelint has a demo of using postcss-value-parser https://github.com/stylelint/stylelint/blob/main/lib/rules/function-allowed-list/index.js#L36

@sam-b-rose
Copy link
Member Author

Closing in favor of new iteration in #6852

sam-b-rose added a commit that referenced this pull request Sep 6, 2022
Closes #6943

Adds the beginnings of the `@shopify/polaris-migrator` package. This package applies code transformations to help update 
Polaris apps and the Polaris codebase.

## Usage

```sh
npx @shopify/polaris-migrator <migration> <path>
```

Run tests for `@shopify/polaris-migrator`

```sh
yarn test --filter=@shopify/polaris-migrator 
```

Original PR branch: #6701
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants