Skip to content

Commit

Permalink
feat(react-native): add convert-to-inferred generator for React Native
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Aug 7, 2024
1 parent 2eca727 commit 0015cc4
Show file tree
Hide file tree
Showing 17 changed files with 750 additions and 4 deletions.
8 changes: 8 additions & 0 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -9217,6 +9217,14 @@
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "convert-to-inferred",
"path": "/nx-api/react-native/generators/convert-to-inferred",
"name": "convert-to-inferred",
"children": [],
"isExternal": false,
"disableCollapsible": false
}
],
"isExternal": false,
Expand Down
9 changes: 9 additions & 0 deletions docs/generated/manifests/nx-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,15 @@
"originalFilePath": "/packages/react-native/src/generators/web-configuration/schema.json",
"path": "/nx-api/react-native/generators/web-configuration",
"type": "generator"
},
"/nx-api/react-native/generators/convert-to-inferred": {
"description": "Convert existing React Native project(s) using `@nx/react-native:*` executors to use `@nx/react-native/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"file": "generated/packages/react-native/generators/convert-to-inferred.json",
"hidden": false,
"name": "convert-to-inferred",
"originalFilePath": "/packages/react-native/src/generators/convert-to-inferred/schema.json",
"path": "/nx-api/react-native/generators/convert-to-inferred",
"type": "generator"
}
},
"path": "/nx-api/react-native"
Expand Down
9 changes: 9 additions & 0 deletions docs/generated/packages-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2535,6 +2535,15 @@
"originalFilePath": "/packages/react-native/src/generators/web-configuration/schema.json",
"path": "react-native/generators/web-configuration",
"type": "generator"
},
{
"description": "Convert existing React Native project(s) using `@nx/react-native:*` executors to use `@nx/react-native/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"file": "generated/packages/react-native/generators/convert-to-inferred.json",
"hidden": false,
"name": "convert-to-inferred",
"originalFilePath": "/packages/react-native/src/generators/convert-to-inferred/schema.json",
"path": "react-native/generators/convert-to-inferred",
"type": "generator"
}
],
"githubRoot": "https://github.com/nrwl/nx/blob/master",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "convert-to-inferred",
"factory": "./src/generators/convert-to-inferred/convert-to-inferred",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "NxReactNativeConvertToInferred",
"description": "Convert existing React Native project(s) using `@nx/react-native:*` executors to use `@nx/react-native/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"title": "Convert React Native project from executor to plugin",
"type": "object",
"properties": {
"project": {
"type": "string",
"description": "The project to convert from using the `@nx/react-native:*` executors to use `@nx/react-native/plugin`.",
"x-priority": "important"
},
"skipFormat": {
"type": "boolean",
"description": "Whether to format files at the end of the migration.",
"default": false
}
},
"presets": []
},
"description": "Convert existing React Native project(s) using `@nx/react-native:*` executors to use `@nx/react-native/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"implementation": "/packages/react-native/src/generators/convert-to-inferred/convert-to-inferred.ts",
"aliases": [],
"hidden": false,
"path": "/packages/react-native/src/generators/convert-to-inferred/schema.json",
"type": "generator"
}
1 change: 1 addition & 0 deletions docs/shared/reference/sitemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@
- [stories](/nx-api/react-native/generators/stories)
- [upgrade-native](/nx-api/react-native/generators/upgrade-native)
- [web-configuration](/nx-api/react-native/generators/web-configuration)
- [convert-to-inferred](/nx-api/react-native/generators/convert-to-inferred)
- [remix](/nx-api/remix)
- [documents](/nx-api/remix/documents)
- [Overview](/nx-api/remix/documents/overview)
Expand Down
5 changes: 5 additions & 0 deletions packages/react-native/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
"factory": "./src/generators/web-configuration/web-configuration#webConfigurationGenerator",
"schema": "./src/generators/web-configuration/schema.json",
"description": "Set up web configuration for a React Native app"
},
"convert-to-inferred": {
"factory": "./src/generators/convert-to-inferred/convert-to-inferred",
"schema": "./src/generators/convert-to-inferred/schema.json",
"description": "Convert existing React Native project(s) using `@nx/react-native:*` executors to use `@nx/react-native/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target."
}
}
}
6 changes: 6 additions & 0 deletions packages/react-native/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
"version": "18.0.0-beta.0",
"description": "Add upgrade target to react native projects",
"implementation": "./src/migrations/update-18-0-0/add-upgrade-target"
},
"update-19-6-0-rename-upgrade-target-name": {
"cli": "nx",
"version": "19.6.0-beta.1",
"description": "Rename upgrade target name to fix casing.",
"implementation": "./src/migrations/update-19-6-0/rename-upgrade-target-name"
}
},
"packageJsonUpdates": {
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ReactNativePluginOptions {
buildAndroidTargetName?: string;
bundleTargetName?: string;
syncDepsTargetName?: string;
upgradeTargetname?: string;
upgradeTargetName?: string;
}

const cachePath = join(workspaceDataDirectory, 'react-native.hash');
Expand Down Expand Up @@ -143,7 +143,7 @@ function buildReactNativeTargets(
[options.syncDepsTargetName]: {
executor: '@nx/react-native:sync-deps',
},
[options.upgradeTargetname]: {
[options.upgradeTargetName]: {
command: `react-native upgrade`,
options: { cwd: projectRoot },
},
Expand Down Expand Up @@ -194,6 +194,6 @@ function normalizeOptions(
options.buildAndroidTargetName ??= 'build-android';
options.bundleTargetName ??= 'bundle';
options.syncDepsTargetName ??= 'sync-deps';
options.upgradeTargetname ??= 'upgrade';
options.upgradeTargetName ??= 'upgrade';
return options;
}
Loading

0 comments on commit 0015cc4

Please sign in to comment.