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

feat: jsx migration script #869

Merged
merged 19 commits into from
Aug 29, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
docs: update for new namespace
KaiVandivier committed Aug 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 5df327a703801d8a2cc59e9c5d2156181a95e504
2 changes: 2 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
- [`d2-app-scripts pack`](scripts/pack.md)
- [`d2-app-scripts deploy`](scripts/deploy.md)
- [`d2-app-scripts publish`](scripts/publish.md)
- [**Migrate**](scripts/migrate)
- [`d2-app-scripts migrate js-to-jsx`](scripts/migrate/js-to-jsx.md)
- [**Configuration**](config.md)
- [Types - `app`, `lib`](config/types)
- [`d2.config.js` Reference](config/d2-config-js-reference.md)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# d2-app-scripts jsx-migration
# d2-app-scripts migrate js-to-jsx

Converts files with `.js` extensions to `.jsx` if the file contains JSX syntax. This is intended as a helper for moving `@dhis2/cli-app-scripts` to Vite, which prefers files to be named as such to avoid unnecessarily parsing vanilla JS files for JSX syntax.

@@ -7,7 +7,7 @@ Converts files with `.js` extensions to `.jsx` if the file contains JSX syntax.
This should usually be run from the root directory of a project.

```sh
yarn d2-app-scripts jsx-migration
yarn d2-app-scripts migrate js-to-jsx
```

By default, this will crawl through each `.js` file in the `src` directory (using the glob `src/**/*.js`), look for JSX syntax in the file, then rename the file to use a `.jsx` extension if appropriate.
@@ -31,7 +31,7 @@ Since imports will only be updated within the scope of that glob, a directory th
Example:

```sh
yarn d2-app-scripts jsx-migration --globString "src/components/**/*.js"
yarn d2-app-scripts migrate js-to-jsx --globString "src/components/**/*.js"
```

Since the glob string will be reused and manipulated by the script, make sure to use quotes around the argument so that the shell doesn't handle it as a normal glob.
@@ -41,10 +41,11 @@ Contents of `node_modules` directories will always be ignored. `d2.config.js` wi
## Usage

```sh
> d2-app-scripts jsx-migration --help
d2-app-scripts jsx-migration
> d2-app-scripts migrate js-to-jsx --help
d2-app-scripts migrate js-to-jsx

Renames .js files to .jsx -- also handles file imports and d2.config.js
Renames .js files that include JSX to .jsx. Also handles file imports and
d2.config.js

Global Options:
-h, --help Show help [boolean]