Skip to content

Commit

Permalink
add transforms for v37 (#19)
Browse files Browse the repository at this point in the history
* make room for another preset

* add transforms for 37

* update lock file

* remove node version for workflow

* add new transforms to readme
  • Loading branch information
siddharthkp authored Nov 26, 2024
1 parent ac3015f commit a13afbf
Show file tree
Hide file tree
Showing 16 changed files with 963 additions and 302 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install dependencies
run: npm ci
Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,21 @@ npx primer-react-migrate [src directory] -p [preset name] [--create-commits]
npx primer-react-migrate [src directory] -m [migration name] [--create-commits]
# Example:
npx primer-react-migrate src -p v35 --create-commits
npx primer-react-migrate src -p v37 --create-commits
npx primer-react-migrate src -m use-deprecated-button
```

 

### Available migrations::
### Available presets:

- v37
- v35

 

### Available migrations:

```
use-deprecated-flex
Expand All @@ -45,4 +52,16 @@ use-main-button
use-main-actionlist
use-main-actionmenu
use-main-pagelayout
use-deprecated-dialog
use-deprecated-tooltip
use-deprecated-octicon
use-deprecated-pagehead
use-deprecated-tabnav
rename-drafts-to-experimental
use-main-dialog
use-main-tooltip
use-main-stack
```
40 changes: 33 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const { resolve } = require('path');
const loader = require('./src/utils/loader');
const createProject = require('./src/utils/create-project');
const { createCommit, getPrettyMessage } = require('./src/utils/create-commit');
const { deprecate } = require('util');

const project = createProject();

Expand All @@ -18,7 +19,7 @@ const preset = args.preset || args.p;
const migration = args.migration || args.m;
const createCommits = args['create-commits'];

const migrations = [
const v35Migrations = [
// old deprecations
'use-deprecated-borderbox',
'use-deprecated-flex',
Expand Down Expand Up @@ -46,9 +47,36 @@ const migrations = [
'use-main-pagelayout'
];

if (preset === 'v35') {
async function runSequentially() {
for (const migrationName of migrations) {
const v37Migrations = [
// deprecrations
'use-deprecated-dialog',
'use-deprecated-tooltip',
'use-deprecated-octicon',
'use-deprecated-pagehead',
'use-deprecated-tabnav',

// drafts is renamed to experimental
'rename-drafts-to-experimental',

// promotions, should be run after deprecations
'use-main-dialog',
'use-main-tooltip',
'use-main-stack'
];

const allMigrations = [...v35Migrations, ...v37Migrations];

if (preset) {
if (preset === 'v35') runSequentially(v35Migrations);
else if (preset === 'v37') runSequentially(v37Migrations);
else {
console.log(
'Preset not found! Check the list of available presets on https://github.com/primer/react-migrate'
);
}

async function runSequentially(presetMigrations) {
for (const migrationName of presetMigrations) {
const message = getPrettyMessage(migrationName);
const { success, skip } = loader(message);

Expand All @@ -60,10 +88,8 @@ if (preset === 'v35') {
} else await success();
}
}

runSequentially();
} else {
if (migrations.includes(migration)) {
if (allMigrations.includes(migration)) {
const path = './src/' + migration + '.js';
require(path)(project);
if (createCommits) createCommit(migration);
Expand Down
Loading

0 comments on commit a13afbf

Please sign in to comment.