Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transforms for v37 #19

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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