Skip to content

Commit

Permalink
feat(react-native): add convert-to-inferred generator for Expo and Re…
Browse files Browse the repository at this point in the history
…act Native (#27326)

This PR adds `convert-to-inferred` generators to convert React Native an
Expo apps using executors to use the corresponding inference plugins.

Also:
1. Fixes casing for `@nx/react-native/plugin` so it is correctly set as
`upgradeTargetName` not `upgradeTargetname`
2. Migration for the above fix for existing projects
  • Loading branch information
jaysoo authored Aug 8, 2024
1 parent 2ce6797 commit d3747e0
Show file tree
Hide file tree
Showing 44 changed files with 2,574 additions and 27 deletions.
24 changes: 24 additions & 0 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -7251,6 +7251,14 @@
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "convert-to-inferred",
"path": "/nx-api/detox/generators/convert-to-inferred",
"name": "convert-to-inferred",
"children": [],
"isExternal": false,
"disableCollapsible": false
}
],
"isExternal": false,
Expand Down Expand Up @@ -7659,6 +7667,14 @@
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "convert-to-inferred",
"path": "/nx-api/expo/generators/convert-to-inferred",
"name": "convert-to-inferred",
"children": [],
"isExternal": false,
"disableCollapsible": false
}
],
"isExternal": false,
Expand Down Expand Up @@ -9233,6 +9249,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
27 changes: 27 additions & 0 deletions docs/generated/manifests/nx-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,15 @@
"originalFilePath": "/packages/detox/src/generators/application/schema.json",
"path": "/nx-api/detox/generators/application",
"type": "generator"
},
"/nx-api/detox/generators/convert-to-inferred": {
"description": "Convert existing Detox project(s) using `@nx/detox:*` executors to use `@nx/detox/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"file": "generated/packages/detox/generators/convert-to-inferred.json",
"hidden": false,
"name": "convert-to-inferred",
"originalFilePath": "/packages/detox/src/generators/convert-to-inferred/schema.json",
"path": "/nx-api/detox/generators/convert-to-inferred",
"type": "generator"
}
},
"path": "/nx-api/detox"
Expand Down Expand Up @@ -991,6 +1000,15 @@
"originalFilePath": "/packages/expo/src/generators/component/schema.json",
"path": "/nx-api/expo/generators/component",
"type": "generator"
},
"/nx-api/expo/generators/convert-to-inferred": {
"description": "Convert existing Expo project(s) using `@nx/expo:*` executors to use `@nx/expo/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"file": "generated/packages/expo/generators/convert-to-inferred.json",
"hidden": false,
"name": "convert-to-inferred",
"originalFilePath": "/packages/expo/src/generators/convert-to-inferred/schema.json",
"path": "/nx-api/expo/generators/convert-to-inferred",
"type": "generator"
}
},
"path": "/nx-api/expo"
Expand Down Expand Up @@ -2553,6 +2571,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
27 changes: 27 additions & 0 deletions docs/generated/packages-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,15 @@
"originalFilePath": "/packages/detox/src/generators/application/schema.json",
"path": "detox/generators/application",
"type": "generator"
},
{
"description": "Convert existing Detox project(s) using `@nx/detox:*` executors to use `@nx/detox/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"file": "generated/packages/detox/generators/convert-to-inferred.json",
"hidden": false,
"name": "convert-to-inferred",
"originalFilePath": "/packages/detox/src/generators/convert-to-inferred/schema.json",
"path": "detox/generators/convert-to-inferred",
"type": "generator"
}
],
"githubRoot": "https://github.com/nrwl/nx/blob/master",
Expand Down Expand Up @@ -977,6 +986,15 @@
"originalFilePath": "/packages/expo/src/generators/component/schema.json",
"path": "expo/generators/component",
"type": "generator"
},
{
"description": "Convert existing Expo project(s) using `@nx/expo:*` executors to use `@nx/expo/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"file": "generated/packages/expo/generators/convert-to-inferred.json",
"hidden": false,
"name": "convert-to-inferred",
"originalFilePath": "/packages/expo/src/generators/convert-to-inferred/schema.json",
"path": "expo/generators/convert-to-inferred",
"type": "generator"
}
],
"githubRoot": "https://github.com/nrwl/nx/blob/master",
Expand Down Expand Up @@ -2526,6 +2544,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
30 changes: 30 additions & 0 deletions docs/generated/packages/detox/generators/convert-to-inferred.json
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": "NxDetoxConvertToInferred",
"description": "Convert existing Detox project(s) using `@nx/detox:*` executors to use `@nx/detox/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"title": "Convert Detox project from executor to plugin",
"type": "object",
"properties": {
"project": {
"type": "string",
"description": "The project to convert from using the `@nx/detox:*` executors to use `@nx/detox/plugin`.",
"x-priority": "important"
},
"skipFormat": {
"type": "boolean",
"description": "Whether to format files at the end of the migration.",
"default": false
}
},
"presets": []
},
"description": "Convert existing Detox project(s) using `@nx/detox:*` executors to use `@nx/detox/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"implementation": "/packages/detox/src/generators/convert-to-inferred/convert-to-inferred.ts",
"aliases": [],
"hidden": false,
"path": "/packages/detox/src/generators/convert-to-inferred/schema.json",
"type": "generator"
}
30 changes: 30 additions & 0 deletions docs/generated/packages/expo/generators/convert-to-inferred.json
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": "NxExpoConvertToInferred",
"description": "Convert existing Expo project(s) using `@nx/expo:*` executors to use `@nx/expo/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"title": "Convert Expo project from executor to plugin",
"type": "object",
"properties": {
"project": {
"type": "string",
"description": "The project to convert from using the `@nx/expo:*` executors to use `@nx/expo/plugin`.",
"x-priority": "important"
},
"skipFormat": {
"type": "boolean",
"description": "Whether to format files at the end of the migration.",
"default": false
}
},
"presets": []
},
"description": "Convert existing Expo project(s) using `@nx/expo:*` executors to use `@nx/expo/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target.",
"implementation": "/packages/expo/src/generators/convert-to-inferred/convert-to-inferred.ts",
"aliases": [],
"hidden": false,
"path": "/packages/expo/src/generators/convert-to-inferred/schema.json",
"type": "generator"
}
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"
}
3 changes: 3 additions & 0 deletions docs/shared/reference/sitemap.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@
- [generators](/nx-api/detox/generators)
- [init](/nx-api/detox/generators/init)
- [application](/nx-api/detox/generators/application)
- [convert-to-inferred](/nx-api/detox/generators/convert-to-inferred)
- [devkit](/nx-api/devkit)
- [documents](/nx-api/devkit/documents)
- [Overview](/nx-api/devkit/documents/nx_devkit)
Expand Down Expand Up @@ -437,6 +438,7 @@
- [application](/nx-api/expo/generators/application)
- [library](/nx-api/expo/generators/library)
- [component](/nx-api/expo/generators/component)
- [convert-to-inferred](/nx-api/expo/generators/convert-to-inferred)
- [express](/nx-api/express)
- [documents](/nx-api/express/documents)
- [Overview](/nx-api/express/documents/overview)
Expand Down Expand Up @@ -628,6 +630,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/detox/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"aliases": ["app"],
"x-type": "application",
"description": "Create a Detox application."
},
"convert-to-inferred": {
"factory": "./src/generators/convert-to-inferred/convert-to-inferred",
"schema": "./src/generators/convert-to-inferred/schema.json",
"description": "Convert existing Detox project(s) using `@nx/detox:*` executors to use `@nx/detox/plugin`. Defaults to migrating all projects. Pass '--project' to migrate only one target."
}
}
}
20 changes: 10 additions & 10 deletions packages/detox/src/generators/application/application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ describe('detox application generator', () => {
binaryPath:
'../my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app',
build:
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
'ios.release': {
binaryPath:
'../my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app',
build:
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
});
Expand Down Expand Up @@ -136,14 +136,14 @@ describe('detox application generator', () => {
binaryPath:
'../my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyDirMyApp.app',
build:
"cd ../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
'ios.release': {
binaryPath:
'../my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyDirMyApp.app',
build:
"cd ../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
});
Expand Down Expand Up @@ -208,14 +208,14 @@ describe('detox application generator', () => {
binaryPath:
'../my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyDirMyApp.app',
build:
"cd ../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
'ios.release': {
binaryPath:
'../my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyDirMyApp.app',
build:
"cd ../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
});
Expand Down Expand Up @@ -279,14 +279,14 @@ describe('detox application generator', () => {
binaryPath:
'../../my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyDirMyApp.app',
build:
"cd ../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
'ios.release': {
binaryPath:
'../../my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyDirMyApp.app',
build:
"cd ../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
});
Expand Down Expand Up @@ -355,7 +355,7 @@ describe('detox application generator', () => {
binaryPath:
'../../my-dir/my-app/ios/build/Build/Products/Debug-iphonesimulator/MyDirMyApp.app',
build:
"cd ../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
'ios.local': {
Expand All @@ -368,7 +368,7 @@ describe('detox application generator', () => {
binaryPath:
'../../my-dir/my-app/ios/build/Build/Products/Release-iphonesimulator/MyDirMyApp.app',
build:
"cd ../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
"cd ../../my-dir/my-app/ios && xcodebuild -workspace MyDirMyApp.xcworkspace -scheme MyDirMyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15 Plus' -derivedDataPath ./build -quiet",
type: 'ios.app',
},
});
Expand Down
Loading

0 comments on commit d3747e0

Please sign in to comment.