@nx/react-native 19.5.7 → 19.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators.json +5 -0
- package/migrations.json +6 -0
- package/package.json +8 -8
- package/plugins/plugin.d.ts +1 -1
- package/plugins/plugin.js +2 -2
- package/src/generators/application/application.js +1 -1
- package/src/generators/application/files/nx-welcome/claimed/src/app/App.tsx.template +737 -0
- package/src/generators/application/files/{app → nx-welcome/not-configured}/src/app/App.tsx.template +106 -114
- package/src/generators/application/files/nx-welcome/unclaimed/src/app/App.tsx.template +737 -0
- package/src/generators/application/lib/add-e2e.js +4 -0
- package/src/generators/application/lib/create-application-files.d.ts +1 -1
- package/src/generators/application/lib/create-application-files.js +12 -1
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts +7 -0
- package/src/generators/convert-to-inferred/convert-to-inferred.js +92 -0
- package/src/generators/convert-to-inferred/lib/create-process-options.d.ts +6 -0
- package/src/generators/convert-to-inferred/lib/create-process-options.js +39 -0
- package/src/generators/convert-to-inferred/lib/post-target-transformer.d.ts +6 -0
- package/src/generators/convert-to-inferred/lib/post-target-transformer.js +34 -0
- package/src/generators/convert-to-inferred/lib/process-start-options.d.ts +2 -0
- package/src/generators/convert-to-inferred/lib/process-start-options.js +23 -0
- package/src/generators/convert-to-inferred/schema.json +19 -0
- package/src/generators/init/init.js +1 -1
- package/src/migrations/update-19-6-0/rename-upgrade-target-name.d.ts +5 -0
- package/src/migrations/update-19-6-0/rename-upgrade-target-name.js +25 -0
|
@@ -14,6 +14,8 @@ async function addE2e(host, options) {
|
|
|
14
14
|
styledModule: null,
|
|
15
15
|
hasStyles: false,
|
|
16
16
|
unitTestRunner: 'none',
|
|
17
|
+
e2eCiWebServerTarget: options.e2eWebServerTarget,
|
|
18
|
+
e2eCiBaseUrl: options.e2eWebServerAddress,
|
|
17
19
|
});
|
|
18
20
|
case 'playwright':
|
|
19
21
|
return (0, add_e2e_1.addE2e)(host, {
|
|
@@ -23,6 +25,8 @@ async function addE2e(host, options) {
|
|
|
23
25
|
styledModule: null,
|
|
24
26
|
hasStyles: false,
|
|
25
27
|
unitTestRunner: 'none',
|
|
28
|
+
e2eCiWebServerTarget: options.e2eWebServerTarget,
|
|
29
|
+
e2eCiBaseUrl: options.e2eWebServerAddress,
|
|
26
30
|
});
|
|
27
31
|
case 'detox':
|
|
28
32
|
const { detoxApplicationGenerator } = (0, devkit_1.ensurePackage)('@nx/detox', versions_1.nxVersion);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { NormalizedSchema } from './normalize-options';
|
|
3
|
-
export declare function createApplicationFiles(host: Tree, options: NormalizedSchema): void
|
|
3
|
+
export declare function createApplicationFiles(host: Tree, options: NormalizedSchema): Promise<void>;
|
|
@@ -4,13 +4,24 @@ exports.createApplicationFiles = createApplicationFiles;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const js_1 = require("@nx/js");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
|
|
7
|
+
const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
|
|
8
|
+
async function createApplicationFiles(host, options) {
|
|
9
|
+
const onBoardingStatus = await (0, onboarding_1.createNxCloudOnboardingURLForWelcomeApp)(host, options.nxCloudToken);
|
|
10
|
+
const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
|
|
11
|
+
(await (0, onboarding_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
|
|
8
12
|
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), options.appProjectRoot, {
|
|
9
13
|
...options,
|
|
10
14
|
entryFileIos: 'src/main',
|
|
11
15
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
12
16
|
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot),
|
|
13
17
|
});
|
|
18
|
+
(0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, `../files/nx-welcome/${onBoardingStatus}`), options.appProjectRoot, {
|
|
19
|
+
...options,
|
|
20
|
+
connectCloudUrl,
|
|
21
|
+
entryFileIos: 'src/main',
|
|
22
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
|
|
23
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.appProjectRoot),
|
|
24
|
+
});
|
|
14
25
|
if (options.unitTestRunner === 'none') {
|
|
15
26
|
host.delete((0, path_1.join)(options.appProjectRoot, `/src/app/App.spec.tsx`));
|
|
16
27
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToInferred = convertToInferred;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const aggregate_log_util_1 = require("@nx/devkit/src/generators/plugin-migrations/aggregate-log-util");
|
|
6
|
+
const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
|
|
7
|
+
const plugin_1 = require("../../../plugins/plugin");
|
|
8
|
+
const post_target_transformer_1 = require("./lib/post-target-transformer");
|
|
9
|
+
const process_start_options_1 = require("./lib/process-start-options");
|
|
10
|
+
const create_process_options_1 = require("./lib/create-process-options");
|
|
11
|
+
async function convertToInferred(tree, options) {
|
|
12
|
+
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
13
|
+
const migrationLogs = new aggregate_log_util_1.AggregatedLog();
|
|
14
|
+
const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPluginV1)(tree, projectGraph, '@nx/react-native/plugin', plugin_1.createNodes, {
|
|
15
|
+
buildAndroidTargetName: 'build-android',
|
|
16
|
+
buildIosTargetName: 'build-ios',
|
|
17
|
+
bundleTargetName: 'bundle',
|
|
18
|
+
podInstallTargetName: 'pod-install',
|
|
19
|
+
runAndroidTargetName: 'run-android',
|
|
20
|
+
runIosTargetName: 'run-ios',
|
|
21
|
+
startTargetName: 'start',
|
|
22
|
+
syncDepsTargetName: 'sync-deps',
|
|
23
|
+
upgradeTargetName: 'upgrade',
|
|
24
|
+
}, [
|
|
25
|
+
{
|
|
26
|
+
executors: ['@nx/react-native:build-android'],
|
|
27
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs, (0, create_process_options_1.createProcessOptions)('@nx/react-native:build-android', ['port', 'resetCache'], [])),
|
|
28
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
29
|
+
buildAndroidTargetName: targetName,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
executors: ['@nx/react-native:build-ios'],
|
|
34
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs, (0, create_process_options_1.createProcessOptions)('@nx/react-native:build-ios', ['port', 'resetCache'], ['buildFolder'])),
|
|
35
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
36
|
+
buildIosTargetName: targetName,
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
executors: ['@nx/react-native:run-android'],
|
|
41
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs, (0, create_process_options_1.createProcessOptions)('@nx/react-native:run-android', ['port', 'resetCache'], ['appId', 'appIdSuffix', 'deviceId'])),
|
|
42
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
43
|
+
runAndroidTargetName: targetName,
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
executors: ['@nx/react-native:pod-install'],
|
|
48
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs),
|
|
49
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
50
|
+
podInstallTargetName: targetName,
|
|
51
|
+
}),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
executors: ['@nx/react-native:run-ios'],
|
|
55
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs, (0, create_process_options_1.createProcessOptions)('@nx/react-native:run-ios', ['port', 'resetCache'], ['buildFolder'])),
|
|
56
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
57
|
+
runIosTargetName: targetName,
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
executors: ['@nx/react-native:start'],
|
|
62
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs, process_start_options_1.processStartOptions),
|
|
63
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
64
|
+
startTargetName: targetName,
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
executors: ['@nx/react-native:sync-deps'],
|
|
69
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs),
|
|
70
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
71
|
+
startTargetName: targetName,
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
executors: ['@nx/react-native:upgrade'],
|
|
76
|
+
postTargetTransformer: (0, post_target_transformer_1.postTargetTransformer)(migrationLogs),
|
|
77
|
+
targetPluginOptionMapper: (targetName) => ({
|
|
78
|
+
upgradeTargetName: targetName,
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
], options.project);
|
|
82
|
+
if (migratedProjects.size === 0) {
|
|
83
|
+
throw new Error('Could not find any targets to migrate.');
|
|
84
|
+
}
|
|
85
|
+
if (!options.skipFormat) {
|
|
86
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
87
|
+
}
|
|
88
|
+
return () => {
|
|
89
|
+
migrationLogs.flushLogs();
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
exports.default = convertToInferred;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
|
|
2
|
+
/**
|
|
3
|
+
* Logic copied from `packages/react-native/src/utils/get-cli-options.ts`,
|
|
4
|
+
* which was used by most executors to map their options to CLI options.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createProcessOptions(executorName: string, optionKeysToIgnore: string[], optionKeysInCamelName: string[]): (projectName: string, options: any, migrationLogs: AggregatedLog) => void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProcessOptions = createProcessOptions;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/**
|
|
6
|
+
* Logic copied from `packages/react-native/src/utils/get-cli-options.ts`,
|
|
7
|
+
* which was used by most executors to map their options to CLI options.
|
|
8
|
+
*/
|
|
9
|
+
function createProcessOptions(executorName, optionKeysToIgnore, optionKeysInCamelName) {
|
|
10
|
+
return (projectName, options, migrationLogs) => {
|
|
11
|
+
const args = [];
|
|
12
|
+
for (const optionKey of Object.keys(options)) {
|
|
13
|
+
const optionValue = options[optionKey];
|
|
14
|
+
delete options[optionKey];
|
|
15
|
+
if (optionKeysToIgnore.includes(optionKey)) {
|
|
16
|
+
migrationLogs.addLog({
|
|
17
|
+
project: projectName,
|
|
18
|
+
executorName,
|
|
19
|
+
log: `Unable to migrate '${optionKey}' to inferred target configuration.`,
|
|
20
|
+
});
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const cliKey = optionKeysInCamelName.includes(optionKey)
|
|
24
|
+
? (0, devkit_1.names)(optionKey).propertyName
|
|
25
|
+
: (0, devkit_1.names)(optionKey).fileName; // cli uses kebab case as default
|
|
26
|
+
if (Array.isArray(optionValue)) {
|
|
27
|
+
args.push(`--${cliKey}`, optionValue.join(','));
|
|
28
|
+
}
|
|
29
|
+
else if (typeof optionValue === 'boolean' && optionValue) {
|
|
30
|
+
// no need to pass in the value when it is true, just the flag name
|
|
31
|
+
args.push(`--${cliKey}`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
args.push(`--${cliKey}`, optionValue);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
options.args = args;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TargetConfiguration, Tree } from '@nx/devkit';
|
|
2
|
+
import type { AggregatedLog } from '@nx/devkit/src/generators/plugin-migrations/aggregate-log-util';
|
|
3
|
+
export declare function postTargetTransformer(migrationLogs: AggregatedLog, processOptions?: (projectName: string, options: any, migrationLogs: AggregatedLog) => void): (target: TargetConfiguration, _tree: Tree, projectDetails: {
|
|
4
|
+
projectName: string;
|
|
5
|
+
root: string;
|
|
6
|
+
}, inferredTargetConfiguration: TargetConfiguration) => TargetConfiguration<any>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postTargetTransformer = postTargetTransformer;
|
|
4
|
+
const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
|
|
5
|
+
function postTargetTransformer(migrationLogs, processOptions) {
|
|
6
|
+
return (target, _tree, projectDetails, inferredTargetConfiguration) => {
|
|
7
|
+
if (target.options && processOptions) {
|
|
8
|
+
processOptions(projectDetails.projectName, target.options, migrationLogs);
|
|
9
|
+
}
|
|
10
|
+
if (target.configurations && processOptions) {
|
|
11
|
+
for (const configurationName in target.configurations) {
|
|
12
|
+
const configuration = target.configurations[configurationName];
|
|
13
|
+
processOptions(projectDetails.projectName, configuration, migrationLogs);
|
|
14
|
+
}
|
|
15
|
+
if (Object.keys(target.configurations).length === 0) {
|
|
16
|
+
if ('defaultConfiguration' in target) {
|
|
17
|
+
delete target.defaultConfiguration;
|
|
18
|
+
}
|
|
19
|
+
delete target.configurations;
|
|
20
|
+
}
|
|
21
|
+
if ('defaultConfiguration' in target &&
|
|
22
|
+
!target.configurations[target.defaultConfiguration]) {
|
|
23
|
+
delete target.defaultConfiguration;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target.outputs) {
|
|
27
|
+
(0, plugin_migration_utils_1.processTargetOutputs)(target, [], inferredTargetConfiguration, {
|
|
28
|
+
projectName: projectDetails.projectName,
|
|
29
|
+
projectRoot: projectDetails.root,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processStartOptions = processStartOptions;
|
|
4
|
+
function processStartOptions(_projectName, options, _migrationLogs) {
|
|
5
|
+
const args = [];
|
|
6
|
+
for (const k of Object.keys(options)) {
|
|
7
|
+
if (k === 'resetCache') {
|
|
8
|
+
if (options[k] === true) {
|
|
9
|
+
args.push(`--reset-cache`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else if (k === 'interactive') {
|
|
13
|
+
if (options[k] === false) {
|
|
14
|
+
args.push(`--no-interactive`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
args.push(`--${k}`, options[k]);
|
|
19
|
+
}
|
|
20
|
+
delete options[k];
|
|
21
|
+
}
|
|
22
|
+
options.args = args;
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxReactNativeConvertToInferred",
|
|
4
|
+
"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.",
|
|
5
|
+
"title": "Convert React Native project from executor to plugin",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"project": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The project to convert from using the `@nx/react-native:*` executors to use `@nx/react-native/plugin`.",
|
|
11
|
+
"x-priority": "important"
|
|
12
|
+
},
|
|
13
|
+
"skipFormat": {
|
|
14
|
+
"type": "boolean",
|
|
15
|
+
"description": "Whether to format files at the end of the migration.",
|
|
16
|
+
"default": false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -23,7 +23,7 @@ async function reactNativeInitGeneratorInternal(host, schema) {
|
|
|
23
23
|
if (schema.addPlugin) {
|
|
24
24
|
await (0, add_plugin_1.addPluginV1)(host, await (0, devkit_1.createProjectGraphAsync)(), '@nx/react-native/plugin', plugin_1.createNodes, {
|
|
25
25
|
startTargetName: ['start', 'react-native:start', 'react-native-start'],
|
|
26
|
-
|
|
26
|
+
upgradeTargetName: [
|
|
27
27
|
'update',
|
|
28
28
|
'react-native:update',
|
|
29
29
|
'react-native-update',
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/**
|
|
6
|
+
* There was a typo in @nx/react-native/plugin, where "upgradeTargetName" was "upgradeTargetname"
|
|
7
|
+
*/
|
|
8
|
+
async function update(tree) {
|
|
9
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
10
|
+
let updated = false;
|
|
11
|
+
for (const plugin of nxJson.plugins) {
|
|
12
|
+
if (typeof plugin === 'string')
|
|
13
|
+
continue;
|
|
14
|
+
if (plugin.plugin !== '@nx/react-native/plugin')
|
|
15
|
+
continue;
|
|
16
|
+
if (plugin.options['upgradeTargetname']) {
|
|
17
|
+
plugin.options['upgradeTargetName'] = plugin.options['upgradeTargetname'];
|
|
18
|
+
delete plugin.options['upgradeTargetname'];
|
|
19
|
+
updated = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (updated)
|
|
23
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
24
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
25
|
+
}
|