@wise/wds-codemods 0.0.1-experimental-5aca8b2 → 0.0.1-experimental-b974fa6

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.
Files changed (51) hide show
  1. package/package.json +6 -1
  2. package/.changeset/better-impalas-drop.md +0 -5
  3. package/.changeset/config.json +0 -13
  4. package/.changeset/quick-mails-joke.md +0 -128
  5. package/.github/CODEOWNERS +0 -1
  6. package/.github/actions/bootstrap/action.yml +0 -49
  7. package/.github/actions/commitlint/action.yml +0 -27
  8. package/.github/actions/test/action.yml +0 -23
  9. package/.github/workflows/cd-cd.yml +0 -150
  10. package/.github/workflows/renovate.yml +0 -16
  11. package/.husky/commit-msg +0 -1
  12. package/.husky/pre-commit +0 -1
  13. package/.nvmrc +0 -1
  14. package/.prettierignore +0 -1
  15. package/.prettierrc.js +0 -5
  16. package/DEVELOPER.md +0 -783
  17. package/babel.config.js +0 -28
  18. package/commitlint.config.js +0 -3
  19. package/eslint.config.js +0 -15
  20. package/jest.config.js +0 -9
  21. package/mkdocs.yml +0 -4
  22. package/renovate.json +0 -9
  23. package/src/__tests__/runCodemod.test.ts +0 -96
  24. package/src/index.ts +0 -4
  25. package/src/runCodemod.ts +0 -88
  26. package/src/transforms/button/__tests__/button.test.tsx +0 -153
  27. package/src/transforms/button/transformer.ts +0 -418
  28. package/src/transforms/helpers/__tests__/createTestTransform.test.ts +0 -27
  29. package/src/transforms/helpers/__tests__/hasImport.test.ts +0 -52
  30. package/src/transforms/helpers/__tests__/iconUtils.test.ts +0 -207
  31. package/src/transforms/helpers/__tests__/jsxElementUtils.test.ts +0 -130
  32. package/src/transforms/helpers/__tests__/jsxReportingUtils.test.ts +0 -265
  33. package/src/transforms/helpers/createTestTransform.ts +0 -18
  34. package/src/transforms/helpers/hasImport.ts +0 -60
  35. package/src/transforms/helpers/iconUtils.ts +0 -87
  36. package/src/transforms/helpers/index.ts +0 -5
  37. package/src/transforms/helpers/jsxElementUtils.ts +0 -67
  38. package/src/transforms/helpers/jsxReportingUtils.ts +0 -224
  39. package/src/utils/__tests__/getOptions.test.ts +0 -170
  40. package/src/utils/__tests__/handleError.test.ts +0 -18
  41. package/src/utils/__tests__/loadTransformModules.test.ts +0 -51
  42. package/src/utils/__tests__/reportManualReview.test.ts +0 -42
  43. package/src/utils/getOptions.ts +0 -63
  44. package/src/utils/handleError.ts +0 -6
  45. package/src/utils/index.ts +0 -4
  46. package/src/utils/loadTransformModules.ts +0 -28
  47. package/src/utils/reportManualReview.ts +0 -17
  48. package/test-button.tsx +0 -230
  49. package/test-file.js +0 -2
  50. package/tsconfig.json +0 -14
  51. package/tsdown.config.js +0 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/wds-codemods",
3
- "version": "0.0.1-experimental-5aca8b2",
3
+ "version": "0.0.1-experimental-b974fa6",
4
4
  "license": "UNLICENSED",
5
5
  "author": "Wise Payments Ltd.",
6
6
  "type": "module",
@@ -14,6 +14,11 @@
14
14
  "bin": {
15
15
  "wds-codemods": "dist/index.cjs"
16
16
  },
17
+ "files": [
18
+ "dist/",
19
+ "README.md",
20
+ "package.json"
21
+ ],
17
22
  "scripts": {
18
23
  "build": "tsdown",
19
24
  "changeset": "changeset",
@@ -1,5 +0,0 @@
1
- ---
2
- '@wise/wds-codemods': patch
3
- ---
4
-
5
- NPM release setup
@@ -1,13 +0,0 @@
1
- {
2
- "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
3
- "changelog": ["@changesets/changelog-github", { "repo": "transferwise/wds-codemods" }],
4
- "commit": false,
5
- "fixed": [],
6
- "linked": [],
7
- "access": "public",
8
- "baseBranch": "main",
9
- "updateInternalDependencies": "minor",
10
- "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
11
- "onlyUpdatePeerDependentsWhenOutOfRange": true
12
- }
13
- }
@@ -1,128 +0,0 @@
1
- ---
2
- '@wise/wds-codemods': major
3
- ---
4
-
5
- # 🎉 @wise/wds-codemods@1.0.0 - Initial Release
6
-
7
- Welcome to the first major release of WDS Codemods! This comprehensive toolkit provides automated migration support for Wise Design System components, making it easy to upgrade your codebase to the latest component versions.
8
-
9
- ## ✨ Core Features
10
-
11
- ### 🔧 Transform Engine
12
-
13
- - **Interactive CLI**: Choose transforms and configure options with an intuitive command-line interface
14
- - **Dry Run Mode**: Preview changes before applying them to your codebase
15
- - **Monorepo Support**: Built-in support for monorepo package structures with automatic package detection
16
- - **Smart Package Detection**: Automatically detects package versions in both `package.json` dependencies and `node_modules`
17
- - **Comprehensive Reporting**: Generates detailed reports for manual review items that require developer attention
18
-
19
- ### 🎯 Button Component Transform
20
-
21
- - **ActionButton Migration**: Automatically converts deprecated `ActionButton` components to modern `Button` with `v2` prop
22
- - **Legacy Prop Migration**: Transforms legacy props (`priority`, `size`, `type`, `htmlType`, `sentiment`) to new API
23
- - **Enum Value Conversion**: Converts enum values (e.g., `Priority.PRIMARY`, `Size.LARGE`) to string literals
24
- - **Icon Integration**: Intelligently processes icon children and converts them to `addonStart`/`addonEnd` props
25
- - **Link Button Handling**: Properly migrates `as="a"` usage with automatic `href` management
26
- - **Smart Size Mapping**: Maps legacy size values to new design tokens (`xs`, `sm`, `md`, `lg`, `xl`)
27
-
28
- ### 🛡️ Robust Validation & Safety
29
-
30
- - **Package Version Validation**: Ensures transforms only run when target packages are present and meet version requirements
31
- - **TypeScript & JSX Support**: Full support for TypeScript and JSX syntax parsing
32
- - **Expression Analysis**: Handles complex expressions, conditionals, and dynamic values with appropriate fallbacks
33
- - **Gitignore Integration**: Respects `.gitignore` patterns to avoid processing unnecessary files
34
- - **Caching System**: Intelligent caching for package version checks to improve performance
35
-
36
- ### 📊 Advanced Reporting
37
-
38
- - **Manual Review Detection**: Identifies code patterns that require human attention
39
- - **Line-by-Line Reporting**: Precise location reporting for manual review items
40
- - **Issue Classification**: Categorizes issues by type (deprecated props, unsupported values, ambiguous expressions)
41
- - **Batch Processing**: Handles multiple files and provides comprehensive summary reports
42
-
43
- ## 🚀 Usage Examples
44
-
45
- ### Basic Usage
46
-
47
- ```bash
48
- npx @wise/wds-codemods
49
- ```
50
-
51
- ### Advanced Usage
52
-
53
- ```bash
54
- # Run specific transform on a directory
55
- npx @wise/wds-codemods button ./src --dry
56
-
57
- # Target monorepo packages
58
- npx @wise/wds-codemods button ./packages --monorepo
59
-
60
- # Custom ignore patterns
61
- npx @wise/wds-codemods button ./src --ignore-pattern "**/*.test.tsx,**/stories/**"
62
- ```
63
-
64
- ## 📋 Supported Transforms
65
-
66
- ### Button Transform (`button`)
67
-
68
- Migrates Button and ActionButton components from `@transferwise/components` v46.5.0+
69
-
70
- **Transformations include:**
71
-
72
- - ✅ `ActionButton` → `Button` with `v2` prop
73
- - ✅ Legacy prop migrations (`priority`, `size`, `type`, etc.)
74
- - ✅ Enum value conversions
75
- - ✅ Icon children processing
76
- - ✅ Link button handling (`as="a"` → proper href management)
77
- - ✅ Sentiment mapping (`type="negative"` → `sentiment="negative"`)
78
-
79
- ## 🏗️ Architecture Highlights
80
-
81
- ### Modular Design
82
-
83
- - **Transform System**: Extensible architecture for adding new component transforms
84
- - **Helper Utilities**: Reusable utilities for JSX manipulation, reporting, and validation
85
- - **Package Detection**: Multi-strategy package version detection (dependencies + node_modules)
86
- - **Test Infrastructure**: Comprehensive testing utilities for transform development
87
-
88
- ### Developer Experience
89
-
90
- - **Type Safety**: Full TypeScript support with proper type definitions
91
- - **Error Handling**: Graceful error handling with helpful error messages
92
- - **Debug Support**: Extensive debug logging for troubleshooting
93
- - **Extensible**: Easy to add new transforms and extend existing functionality
94
-
95
- ## 🧪 Quality Assurance
96
-
97
- This release includes:
98
-
99
- - ✅ **100% Test Coverage** for core utilities and transforms
100
- - ✅ **End-to-End Testing** with real-world code examples
101
- - ✅ **Edge Case Handling** for complex expressions and unusual patterns
102
- - ✅ **Performance Optimization** with intelligent caching and batching
103
- - ✅ **Memory Management** for large codebases
104
-
105
- ## 🔮 What's Next?
106
-
107
- This foundation enables:
108
-
109
- - 🎯 Additional component transforms (Forms, Navigation, etc.)
110
- - 🚀 Enhanced reporting and analytics
111
- - 🔧 IDE integrations and tooling
112
- - 📱 Support for additional package managers
113
- - 🌍 Community contributions and extensibility
114
-
115
- ## 🙏 Getting Started
116
-
117
- 1. Install the package: `npm install -D @wise/wds-codemods`
118
- 2. Run your first transform: `npx @wise/wds-codemods`
119
- 3. Review the generated `codemod-report.txt` for any manual review items
120
- 4. Commit your changes and enjoy your modernized codebase!
121
-
122
- ---
123
-
124
- **Breaking Changes**: This is the initial release, so no breaking changes from previous versions.
125
-
126
- **Migration Guide**: See our documentation for detailed migration examples and best practices.
127
-
128
- Ready to modernize your Wise Design System components? Let's go! 🚀
@@ -1 +0,0 @@
1
- * @transferwise/design-system-web
@@ -1,49 +0,0 @@
1
- name: 'Bootstrap'
2
- description: 'Set up Node.js and install dependencies'
3
-
4
- inputs:
5
- github-token:
6
- description: 'GitHub token for authentication'
7
- required: true
8
- npm-token-automation:
9
- description: 'NPM token for authentication'
10
- required: false
11
-
12
- runs:
13
- using: 'composite'
14
- steps:
15
- - name: Setup Node.js
16
- uses: actions/setup-node@v4
17
- with:
18
- node-version-file: '.nvmrc'
19
- registry-url: 'https://registry.npmjs.org'
20
-
21
- - name: Setup pnpm
22
- uses: pnpm/action-setup@v4
23
-
24
- - name: Configure npm registry
25
- shell: bash
26
- run: |
27
- echo "registry=https://registry.npmjs.org/" > .npmrc
28
- echo "//registry.npmjs.org/:_authToken=${{ inputs.npm-token-automation }}" >> .npmrc
29
- env:
30
- NODE_AUTH_TOKEN: ${{ inputs.npm-token-automation }}
31
-
32
- - name: Get pnpm store directory
33
- shell: bash
34
- run: |
35
- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
36
-
37
- - name: Setup pnpm cache
38
- uses: actions/cache@v4
39
- with:
40
- path: ${{ env.STORE_PATH }}
41
- key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
42
- restore-keys: |
43
- ${{ runner.os }}-pnpm-store-
44
-
45
- - name: Install dependencies
46
- shell: bash
47
- run: pnpm install --frozen-lockfile
48
- env:
49
- NODE_AUTH_TOKEN: ${{ inputs.npm-token-automation }}
@@ -1,27 +0,0 @@
1
- name: Commitlint
2
- description: 'Lint all commit messages for the project'
3
-
4
- inputs:
5
- github-token:
6
- required: true
7
- description: 'secrets.GITHUB_TOKEN'
8
-
9
- runs:
10
- using: composite
11
- steps:
12
- - name: 🔐 Mark repo directory as safe for git # https://github.blog/2022-04-12-git-security-vulnerability-announced/
13
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
14
- shell: bash
15
-
16
- - name: 🛠️ Bootstrap dependencies
17
- uses: ./.github/actions/bootstrap
18
- with:
19
- github-token: ${{ inputs.github-token }}
20
-
21
- - name: Fetch full commit history
22
- run: git fetch --unshallow
23
- shell: bash
24
-
25
- - name: Run Commitlint
26
- run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
27
- shell: bash
@@ -1,23 +0,0 @@
1
- name: Test
2
- description: 'Run all tests for the project'
3
-
4
- inputs:
5
- github-token:
6
- required: true
7
- description: 'secrets.GITHUB_TOKEN'
8
-
9
- runs:
10
- using: composite
11
- steps:
12
- - name: 🔐 Mark repo directory as safe for git # https://github.blog/2022-04-12-git-security-vulnerability-announced/
13
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
14
- shell: bash
15
-
16
- - name: 🛠️ Bootstrap dependencies
17
- uses: ./.github/actions/bootstrap
18
- with:
19
- github-token: ${{ inputs.github-token }}
20
-
21
- - name: 🧪 Run tests
22
- run: pnpm run test
23
- shell: bash
@@ -1,150 +0,0 @@
1
- name: '🚀 CI/CD'
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- pull_request:
8
-
9
- concurrency:
10
- group: ${{ github.workflow }}-${{ github.ref }}
11
- cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
12
-
13
- env:
14
- DO_NOT_TRACK: 1
15
-
16
- jobs:
17
- pipeline:
18
- name: '🚀 Build, Lint & Test'
19
- runs-on: ubuntu-latest
20
-
21
- steps:
22
- - name: 🛒 Check out repository
23
- uses: actions/checkout@v5
24
-
25
- - name: ⚙️ Bootstrap
26
- uses: ./.github/actions/bootstrap
27
- with:
28
- github-token: ${{ secrets.GITHUB_TOKEN }}
29
- npm-token-automation: ${{ secrets.NPM_TOKEN_AUTOMATION }}
30
-
31
- - name: 📝 Lint
32
- run: pnpm run lint
33
-
34
- - name: 🧪 Run Tests
35
- run: pnpm test
36
-
37
- - name: 🏗️ Build
38
- run: pnpm run build
39
-
40
- publish-branch:
41
- name: 🚀 Publish experimental packages
42
- if: ${{ github.event_name == 'pull_request' && !startsWith(github.head_ref, 'changeset-release/') }}
43
- runs-on: ubuntu-latest
44
- timeout-minutes: 10
45
- needs: [pipeline]
46
-
47
- steps:
48
- - name: 🛒 Check out repository
49
- uses: actions/checkout@v5
50
- with:
51
- token: ${{ secrets.GH_ACCESS_TOKEN }}
52
-
53
- - name: ⚙️ Bootstrap
54
- uses: ./.github/actions/bootstrap
55
- with:
56
- github-token: ${{ secrets.GITHUB_TOKEN }}
57
- npm-token-automation: ${{ secrets.NPM_TOKEN_AUTOMATION }}
58
-
59
- - name: 🏗️ Build
60
- run: pnpm run build
61
-
62
- - name: Setup npm token
63
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN_AUTOMATION }}" >> ~/.npmrc
64
- shell: bash
65
-
66
- - name: Publish snapshot release on npm
67
- id: publish-experimental
68
- run: |
69
- # Get current version from package.json
70
- CURRENT_VERSION=$(node -p "require('./package.json').version")
71
- EXPERIMENTAL_VERSION="${CURRENT_VERSION}-experimental-${GITHUB_SHA:0:7}"
72
-
73
- # Update package.json version directly
74
- npm version $EXPERIMENTAL_VERSION --no-git-tag-version
75
-
76
- # Publish the experimental version and capture output
77
- PUBLISH_OUTPUT=$(npm publish --tag experimental 2>&1)
78
- echo "$PUBLISH_OUTPUT"
79
-
80
- # Extract the published package name and version from npm output
81
- PUBLISHED_PACKAGE=$(echo "$PUBLISH_OUTPUT" | grep -o '@wise/wds-codemods@[^[:space:]]*' | head -1)
82
- echo "published_package=$PUBLISHED_PACKAGE" >> $GITHUB_OUTPUT
83
- env:
84
- GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
85
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_AUTOMATION }}
86
-
87
- - name: Update job status with build ID
88
- uses: actions/github-script@v7
89
- with:
90
- github-token: ${{ secrets.GH_ACCESS_TOKEN }}
91
- script: |
92
- const publishedPackage = '${{ steps.publish-experimental.outputs.published_package }}';
93
-
94
- await github.rest.repos.createCommitStatus({
95
- owner: context.repo.owner,
96
- repo: context.repo.repo,
97
- sha: context.sha,
98
- state: 'success',
99
- target_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
100
- description: publishedPackage,
101
- context: 'experimental-build'
102
- });
103
-
104
- publish:
105
- name: 🚀 Publish stable packages
106
- if: ${{ github.ref == 'refs/heads/main' }}
107
- runs-on: ubuntu-latest
108
- needs: [pipeline]
109
-
110
- steps:
111
- - name: 🛒 Check out repository
112
- uses: actions/checkout@v5
113
- with:
114
- token: ${{ secrets.GH_ACCESS_TOKEN }}
115
-
116
- - name: ⚙️ Bootstrap
117
- uses: ./.github/actions/bootstrap
118
- with:
119
- github-token: ${{ secrets.GITHUB_TOKEN }}
120
- npm-token-automation: ${{ secrets.NPM_TOKEN_AUTOMATION }}
121
-
122
- - name: 🏗️ Build
123
- run: pnpm run build
124
-
125
- - name: 👩‍💻 Set GitHub credentials
126
- run: |
127
- mkdir -p ~/.ssh
128
- ssh-keyscan github.com >> ~/.ssh/known_hosts
129
- git config --global user.name "tw-actions"
130
- git config --global user.email circle@circle.tw.ee
131
-
132
- - name: 🔐 Set up commit signing
133
- uses: crazy-max/ghaction-import-gpg@v6
134
- with:
135
- gpg_private_key: ${{ secrets.GPG_SIGN_KEY }}
136
- git_config_global: true
137
- git_user_signingkey: true
138
- git_commit_gpgsign: true
139
-
140
- - name: Create changesets release PR
141
- id: changesets
142
- uses: changesets/action@v1
143
- with:
144
- publish: pnpm release
145
- commit: 'chore: release'
146
- title: 'chore: release new version and update changelog'
147
- setupGitUser: false
148
- env:
149
- GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
150
- NPM_TOKEN: ${{ secrets.NPM_TOKEN_AUTOMATION }}
@@ -1,16 +0,0 @@
1
- name: Renovate
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- paths:
8
- - pnpm-lock.yaml
9
- schedule:
10
- - cron: '0 2 * * 1' # Run every Monday at 2AM
11
- workflow_dispatch:
12
-
13
- jobs:
14
- renovate:
15
- uses: transferwise/renovate-workflows/.github/workflows/run.yaml@v1
16
- secrets: inherit
package/.husky/commit-msg DELETED
@@ -1 +0,0 @@
1
- npx --no -- commitlint --edit $1
package/.husky/pre-commit DELETED
@@ -1 +0,0 @@
1
- pnpm lint
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- lts/*
package/.prettierignore DELETED
@@ -1 +0,0 @@
1
- pnpm-lock.yaml
package/.prettierrc.js DELETED
@@ -1,5 +0,0 @@
1
- export default {
2
- printWidth: 100,
3
- singleQuote: true,
4
- trailingComma: 'all',
5
- };