@nx/react-native 17.0.4 → 17.0.6
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/.eslintrc.json +1 -7
- package/LICENSE +1 -1
- package/README.md +4 -9
- package/executors.json +0 -5
- package/generators.json +11 -12
- package/migrations.json +0 -126
- package/package.json +15 -11
- package/plugins/metro-resolver.js +1 -4
- package/plugins/with-nx-metro.js +2 -6
- package/src/executors/build-android/build-android.impl.js +6 -2
- package/src/executors/build-android/build-android.impl.ts +6 -2
- package/src/executors/build-android/schema.json +1 -1
- package/src/executors/build-ios/schema.json +1 -1
- package/src/executors/bundle/schema.d.ts +1 -1
- package/src/executors/bundle/schema.json +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +0 -4
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +0 -4
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +0 -4
- package/src/executors/ensure-symlink/schema.json +1 -1
- package/src/executors/pod-install/schema.json +1 -1
- package/src/executors/run-android/run-android.impl.js +17 -5
- package/src/executors/run-android/run-android.impl.ts +18 -9
- package/src/executors/run-android/schema.json +1 -1
- package/src/executors/run-ios/run-ios.impl.js +16 -4
- package/src/executors/run-ios/run-ios.impl.ts +18 -9
- package/src/executors/run-ios/schema.json +1 -1
- package/src/executors/start/schema.d.ts +1 -1
- package/src/executors/start/schema.json +1 -1
- package/src/executors/start/start.impl.js +26 -11
- package/src/executors/start/start.impl.ts +28 -14
- package/src/executors/storybook/storybook.impl.d.ts +0 -4
- package/src/executors/storybook/storybook.impl.js +2 -15
- package/src/executors/storybook/storybook.impl.ts +7 -26
- package/src/executors/sync-deps/schema.d.ts +0 -1
- package/src/executors/sync-deps/schema.json +1 -6
- package/src/executors/sync-deps/sync-deps.impl.d.ts +1 -2
- package/src/executors/sync-deps/sync-deps.impl.js +11 -33
- package/src/executors/sync-deps/sync-deps.impl.ts +18 -57
- package/src/generators/application/application.js +8 -52
- package/src/generators/application/application.spec.ts +2 -29
- package/src/generators/application/files/app/Gemfile.template +1 -2
- package/src/generators/application/files/app/android/app/build.gradle.template +28 -12
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +6 -2
- package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +75 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +32 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +62 -0
- package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +20 -0
- package/src/generators/application/files/app/android/build.gradle.template +20 -7
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +1 -2
- package/src/generators/application/files/app/android/gradle.properties +3 -0
- package/src/generators/application/files/app/android/gradlew.template +7 -12
- package/src/generators/application/files/app/android/settings.gradle.template +2 -2
- package/src/generators/application/files/app/babel.config.json.template +3 -0
- package/src/generators/application/files/app/ios/Podfile.template +7 -0
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +0 -5
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +8 -5
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +33 -11
- package/src/generators/application/files/app/metro.config.js.template +5 -1
- package/src/generators/application/files/app/src/app/App.tsx.template +13 -50
- package/src/generators/application/lib/add-detox.d.ts +3 -0
- package/src/generators/application/lib/add-detox.js +23 -0
- package/src/generators/application/lib/add-project.js +18 -18
- package/src/generators/application/lib/normalize-options.d.ts +0 -7
- package/src/generators/application/lib/normalize-options.js +3 -35
- package/src/generators/application/lib/normalize-options.spec.ts +7 -70
- package/src/generators/application/schema.d.ts +3 -5
- package/src/generators/application/schema.json +6 -14
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +1 -1
- package/src/generators/component/schema.d.ts +3 -3
- package/src/generators/component/schema.json +4 -4
- package/src/generators/component-story/component-story.d.ts +8 -5
- package/src/generators/component-story/component-story.js +69 -8
- package/src/generators/component-story/component-story.spec.ts +428 -0
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +32 -0
- package/src/generators/component-story/schema.d.ts +0 -1
- package/src/generators/component-story/schema.json +3 -11
- package/src/generators/init/init.d.ts +1 -2
- package/src/generators/init/init.js +56 -55
- package/src/generators/init/init.spec.ts +6 -7
- package/src/generators/init/schema.d.ts +3 -3
- package/src/generators/init/schema.json +18 -13
- package/src/generators/library/files/lib/babel.config.json.template +17 -0
- package/src/generators/library/lib/normalize-options.js +0 -5
- package/src/generators/library/library.js +38 -48
- package/src/generators/library/library.spec.ts +60 -12
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +2 -2
- package/src/generators/stories/schema.d.ts +0 -2
- package/src/generators/stories/schema.json +2 -15
- package/src/generators/stories/stories-app.spec.ts +128 -0
- package/src/generators/stories/stories-lib.spec.ts +105 -0
- package/src/generators/stories/stories.d.ts +2 -5
- package/src/generators/stories/stories.js +50 -7
- package/src/generators/storybook-configuration/configuration.d.ts +2 -7
- package/src/generators/storybook-configuration/configuration.js +48 -18
- package/src/generators/storybook-configuration/configuration.spec.ts +135 -0
- package/src/generators/storybook-configuration/files/app/storybook.ts.template +9 -0
- package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +74 -0
- package/src/generators/storybook-configuration/files/root/story-loader.ts.template +5 -0
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +6 -0
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +25 -0
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +161 -0
- package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +6 -0
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +42 -0
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +7 -0
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +29 -0
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +65 -0
- package/src/generators/storybook-configuration/schema.d.ts +2 -4
- package/src/generators/storybook-configuration/schema.json +12 -22
- package/src/generators/upgrade-native/lib/normalize-options.d.ts +1 -1
- package/src/generators/upgrade-native/schema.d.ts +1 -1
- package/src/generators/upgrade-native/schema.json +3 -3
- package/src/generators/upgrade-native/upgrade-native.d.ts +0 -2
- package/src/generators/upgrade-native/upgrade-native.js +0 -3
- package/src/migrations/update-16-6-0/update-metro-config.js +5 -1
- package/src/migrations/update-16-9-0/remove-types-react-native.js +9 -2
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +1 -13
- package/src/utils/add-linting.d.ts +0 -1
- package/src/utils/add-linting.js +1 -1
- package/src/utils/add-linting.spec.ts +6 -4
- package/src/utils/chmod-android-gradle-files.js +2 -6
- package/src/utils/find-all-npm-dependencies.js +3 -5
- package/src/utils/find-all-npm-dependencies.spec.ts +9 -17
- package/src/utils/symlink-task.d.ts +2 -0
- package/src/utils/symlink-task.js +18 -0
- package/src/utils/testing-generators.js +0 -1
- package/src/utils/versions.d.ts +13 -10
- package/src/utils/versions.js +14 -11
- package/plugin.d.ts +0 -1
- package/plugin.js +0 -6
- package/plugins/plugin.d.ts +0 -14
- package/plugins/plugin.js +0 -162
- package/src/executors/upgrade/schema.d.ts +0 -1
- package/src/executors/upgrade/schema.json +0 -11
- package/src/executors/upgrade/upgrade.impl.d.ts +0 -13
- package/src/executors/upgrade/upgrade.impl.js +0 -47
- package/src/executors/upgrade/upgrade.impl.ts +0 -64
- package/src/generators/application/files/app/.babelrc.js.template +0 -23
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +0 -22
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +0 -45
- package/src/generators/application/lib/add-e2e.d.ts +0 -3
- package/src/generators/application/lib/add-e2e.js +0 -46
- package/src/generators/library/files/lib/.babelrc.js.template +0 -21
- package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +0 -23
- package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +0 -15
- package/src/generators/web-configuration/files/base-vite/public/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ +0 -9
- package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +0 -82
- package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +0 -23
- package/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ +0 -14
- package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +0 -9
- package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +0 -77
- package/src/generators/web-configuration/lib/normalize-schema.d.ts +0 -17
- package/src/generators/web-configuration/lib/normalize-schema.js +0 -16
- package/src/generators/web-configuration/lib/webpack-targets.d.ts +0 -7
- package/src/generators/web-configuration/lib/webpack-targets.js +0 -75
- package/src/generators/web-configuration/schema.d.ts +0 -6
- package/src/generators/web-configuration/schema.json +0 -42
- package/src/generators/web-configuration/web-configuration.d.ts +0 -12
- package/src/generators/web-configuration/web-configuration.js +0 -87
- package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +0 -6
- package/src/migrations/update-18-0-0/add-upgrade-target.js +0 -33
- package/src/migrations/update-18-0-0/add-web-configuration.d.ts +0 -8
- package/src/migrations/update-18-0-0/add-web-configuration.js +0 -33
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +0 -39
- package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +0 -5
- package/src/migrations/update-18-0-0/change-storybook-targets.js +0 -57
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +0 -6
- package/src/migrations/update-18-0-0/remove-block-list.js +0 -28
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +0 -68
- package/src/migrations/update-18-0-0/remove-metro.d.ts +0 -14
- package/src/migrations/update-18-0-0/remove-metro.js +0 -29
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +0 -6
- package/src/migrations/update-18-0-0/remove-symlink-target.js +0 -30
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +0 -40
- package/src/utils/ensure-dependencies.d.ts +0 -2
- package/src/utils/ensure-dependencies.js +0 -30
package/plugins/plugin.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const js_1 = require("@nx/js");
|
|
7
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
10
|
-
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
11
|
-
const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'react-native.hash');
|
|
12
|
-
const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
|
|
13
|
-
const calculatedTargets = {};
|
|
14
|
-
function readTargetsCache() {
|
|
15
|
-
return (0, devkit_1.readJsonFile)(cachePath);
|
|
16
|
-
}
|
|
17
|
-
function writeTargetsToCache(targets) {
|
|
18
|
-
(0, devkit_1.writeJsonFile)(cachePath, targets);
|
|
19
|
-
}
|
|
20
|
-
const createDependencies = () => {
|
|
21
|
-
writeTargetsToCache(calculatedTargets);
|
|
22
|
-
return [];
|
|
23
|
-
};
|
|
24
|
-
exports.createDependencies = createDependencies;
|
|
25
|
-
exports.createNodes = [
|
|
26
|
-
'**/app.{json,config.js}',
|
|
27
|
-
(configFilePath, options, context) => {
|
|
28
|
-
options = normalizeOptions(options);
|
|
29
|
-
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
30
|
-
// Do not create a project if package.json or project.json or metro.config.js isn't there.
|
|
31
|
-
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
32
|
-
if (!siblingFiles.includes('package.json') ||
|
|
33
|
-
!siblingFiles.includes('metro.config.js')) {
|
|
34
|
-
return {};
|
|
35
|
-
}
|
|
36
|
-
const appConfig = getAppConfig(configFilePath, context);
|
|
37
|
-
if (appConfig.expo) {
|
|
38
|
-
return {};
|
|
39
|
-
}
|
|
40
|
-
const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
|
|
41
|
-
(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
|
|
42
|
-
]);
|
|
43
|
-
const targets = targetsCache[hash]
|
|
44
|
-
? targetsCache[hash]
|
|
45
|
-
: buildReactNativeTargets(projectRoot, options, context);
|
|
46
|
-
calculatedTargets[hash] = targets;
|
|
47
|
-
return {
|
|
48
|
-
projects: {
|
|
49
|
-
[projectRoot]: {
|
|
50
|
-
targets,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
function buildReactNativeTargets(projectRoot, options, context) {
|
|
57
|
-
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
58
|
-
const targets = {
|
|
59
|
-
[options.startTargetName]: {
|
|
60
|
-
command: `react-native start`,
|
|
61
|
-
options: { cwd: projectRoot },
|
|
62
|
-
},
|
|
63
|
-
[options.podInstallTargetName]: {
|
|
64
|
-
command: `pod install`,
|
|
65
|
-
options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot, 'ios') },
|
|
66
|
-
dependsOn: [`${options.syncDepsTargetName}`],
|
|
67
|
-
cache: true,
|
|
68
|
-
inputs: getInputs(namedInputs),
|
|
69
|
-
outputs: [
|
|
70
|
-
getOutputs(projectRoot, 'ios/Pods'),
|
|
71
|
-
getOutputs(projectRoot, 'ios/Podfile.lock'),
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
[options.runIosTargetName]: {
|
|
75
|
-
command: `react-native run-ios`,
|
|
76
|
-
options: { cwd: projectRoot },
|
|
77
|
-
},
|
|
78
|
-
[options.runAndroidTargetName]: {
|
|
79
|
-
command: `react-native run-android`,
|
|
80
|
-
options: { cwd: projectRoot },
|
|
81
|
-
},
|
|
82
|
-
[options.buildIosTargetName]: {
|
|
83
|
-
command: `react-native build-ios`,
|
|
84
|
-
options: { cwd: projectRoot },
|
|
85
|
-
cache: true,
|
|
86
|
-
dependsOn: [`^${options.buildIosTargetName}`],
|
|
87
|
-
inputs: getInputs(namedInputs),
|
|
88
|
-
outputs: [getOutputs(projectRoot, 'ios/build/Build/Products')],
|
|
89
|
-
},
|
|
90
|
-
[options.buildAndroidTargetName]: {
|
|
91
|
-
command: `react-native build-android`,
|
|
92
|
-
options: { cwd: projectRoot },
|
|
93
|
-
cache: true,
|
|
94
|
-
dependsOn: [`^${options.buildAndroidTargetName}`],
|
|
95
|
-
inputs: getInputs(namedInputs),
|
|
96
|
-
outputs: [getOutputs(projectRoot, 'android/app/build/outputs')],
|
|
97
|
-
},
|
|
98
|
-
[options.bundleTargetName]: {
|
|
99
|
-
command: `react-native bundle`,
|
|
100
|
-
options: { cwd: projectRoot },
|
|
101
|
-
dependsOn: [`^${options.bundleTargetName}`],
|
|
102
|
-
inputs: getInputs(namedInputs),
|
|
103
|
-
},
|
|
104
|
-
[options.syncDepsTargetName]: {
|
|
105
|
-
executor: '@nx/react-native:sync-deps',
|
|
106
|
-
},
|
|
107
|
-
[options.upgradeTargetname]: {
|
|
108
|
-
command: `react-native upgrade`,
|
|
109
|
-
options: { cwd: projectRoot },
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
return targets;
|
|
113
|
-
}
|
|
114
|
-
function getAppConfig(configFilePath, context) {
|
|
115
|
-
const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
116
|
-
let module = load(resolvedPath);
|
|
117
|
-
return module.default ?? module;
|
|
118
|
-
}
|
|
119
|
-
function getInputs(namedInputs) {
|
|
120
|
-
return [
|
|
121
|
-
...('production' in namedInputs
|
|
122
|
-
? ['default', '^production']
|
|
123
|
-
: ['default', '^default']),
|
|
124
|
-
{
|
|
125
|
-
externalDependencies: ['react-native'],
|
|
126
|
-
},
|
|
127
|
-
];
|
|
128
|
-
}
|
|
129
|
-
function getOutputs(projectRoot, dir) {
|
|
130
|
-
if (projectRoot === '.') {
|
|
131
|
-
return `{projectRoot}/${dir}`;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
return `{workspaceRoot}/${projectRoot}/${dir}`;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Load the module after ensuring that the require cache is cleared.
|
|
139
|
-
*/
|
|
140
|
-
function load(path) {
|
|
141
|
-
// Clear cache if the path is in the cache
|
|
142
|
-
if (require.cache[path]) {
|
|
143
|
-
for (const k of Object.keys(require.cache)) {
|
|
144
|
-
delete require.cache[k];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
// Then require
|
|
148
|
-
return require(path);
|
|
149
|
-
}
|
|
150
|
-
function normalizeOptions(options) {
|
|
151
|
-
options ??= {};
|
|
152
|
-
options.startTargetName ??= 'start';
|
|
153
|
-
options.podInstallTargetName ??= 'pod-install';
|
|
154
|
-
options.runIosTargetName ??= 'run-ios';
|
|
155
|
-
options.runAndroidTargetName ??= 'run-android';
|
|
156
|
-
options.buildIosTargetName ??= 'build-ios';
|
|
157
|
-
options.buildAndroidTargetName ??= 'build-android';
|
|
158
|
-
options.bundleTargetName ??= 'bundle';
|
|
159
|
-
options.syncDepsTargetName ??= 'sync-deps';
|
|
160
|
-
options.upgradeTargetname ??= 'upgrade';
|
|
161
|
-
return options;
|
|
162
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export interface UpgradeExecutorSchema {}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"version": 2,
|
|
4
|
-
"cli": "nx",
|
|
5
|
-
"$id": "NxReactNativeUpgrade",
|
|
6
|
-
"title": "React Native Upgrade Executor",
|
|
7
|
-
"description": "Upgrade React Native code for project.",
|
|
8
|
-
"type": "object",
|
|
9
|
-
"properties": {},
|
|
10
|
-
"required": []
|
|
11
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
3
|
-
import { ChildProcess } from 'child_process';
|
|
4
|
-
import { UpgradeExecutorSchema } from './schema';
|
|
5
|
-
export interface ReactNativeUpgradeOutput {
|
|
6
|
-
success: boolean;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* This executor is equivalent to `npx react-native upgrade`.
|
|
10
|
-
* https://github.com/react-native-community/cli/blob/main/packages/cli/src/commands/upgrade/upgrade.ts
|
|
11
|
-
*/
|
|
12
|
-
export default function upgradeExecutor(options: UpgradeExecutorSchema, context: ExecutorContext): AsyncGenerator<ReactNativeUpgradeOutput>;
|
|
13
|
-
export declare function runCliUpgrade(workspaceRoot: string, projectRoot: string): Promise<ChildProcess>;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runCliUpgrade = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
|
-
/**
|
|
7
|
-
* This executor is equivalent to `npx react-native upgrade`.
|
|
8
|
-
* https://github.com/react-native-community/cli/blob/main/packages/cli/src/commands/upgrade/upgrade.ts
|
|
9
|
-
*/
|
|
10
|
-
async function* upgradeExecutor(options, context) {
|
|
11
|
-
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
12
|
-
await runCliUpgrade(context.root, projectRoot);
|
|
13
|
-
yield { success: true };
|
|
14
|
-
}
|
|
15
|
-
exports.default = upgradeExecutor;
|
|
16
|
-
function runCliUpgrade(workspaceRoot, projectRoot) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['upgrade'], {
|
|
19
|
-
stdio: 'inherit',
|
|
20
|
-
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
21
|
-
env: process.env,
|
|
22
|
-
});
|
|
23
|
-
/**
|
|
24
|
-
* Ensure the child process is killed when the parent exits
|
|
25
|
-
*/
|
|
26
|
-
const processExitListener = (signal) => () => {
|
|
27
|
-
childProcess.kill(signal);
|
|
28
|
-
process.exit();
|
|
29
|
-
};
|
|
30
|
-
process.once('exit', (signal) => childProcess.kill(signal));
|
|
31
|
-
process.once('SIGTERM', processExitListener);
|
|
32
|
-
process.once('SIGINT', processExitListener);
|
|
33
|
-
process.once('SIGQUIT', processExitListener);
|
|
34
|
-
childProcess.on('error', (err) => {
|
|
35
|
-
reject(err);
|
|
36
|
-
});
|
|
37
|
-
childProcess.on('exit', (code) => {
|
|
38
|
-
if (code === 0) {
|
|
39
|
-
resolve(childProcess);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
reject(code);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
exports.runCliUpgrade = runCliUpgrade;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { resolve as pathResolve } from 'path';
|
|
3
|
-
import { ChildProcess, fork } from 'child_process';
|
|
4
|
-
|
|
5
|
-
import { UpgradeExecutorSchema } from './schema';
|
|
6
|
-
|
|
7
|
-
export interface ReactNativeUpgradeOutput {
|
|
8
|
-
success: boolean;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* This executor is equivalent to `npx react-native upgrade`.
|
|
13
|
-
* https://github.com/react-native-community/cli/blob/main/packages/cli/src/commands/upgrade/upgrade.ts
|
|
14
|
-
*/
|
|
15
|
-
export default async function* upgradeExecutor(
|
|
16
|
-
options: UpgradeExecutorSchema,
|
|
17
|
-
context: ExecutorContext
|
|
18
|
-
): AsyncGenerator<ReactNativeUpgradeOutput> {
|
|
19
|
-
const projectRoot =
|
|
20
|
-
context.projectsConfigurations.projects[context.projectName].root;
|
|
21
|
-
|
|
22
|
-
await runCliUpgrade(context.root, projectRoot);
|
|
23
|
-
yield { success: true };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function runCliUpgrade(
|
|
27
|
-
workspaceRoot: string,
|
|
28
|
-
projectRoot: string
|
|
29
|
-
): Promise<ChildProcess> {
|
|
30
|
-
return new Promise<ChildProcess>((resolve, reject) => {
|
|
31
|
-
const childProcess = fork(
|
|
32
|
-
require.resolve('react-native/cli.js'),
|
|
33
|
-
['upgrade'],
|
|
34
|
-
{
|
|
35
|
-
stdio: 'inherit',
|
|
36
|
-
cwd: pathResolve(workspaceRoot, projectRoot),
|
|
37
|
-
env: process.env,
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Ensure the child process is killed when the parent exits
|
|
43
|
-
*/
|
|
44
|
-
const processExitListener = (signal?: number | NodeJS.Signals) => () => {
|
|
45
|
-
childProcess.kill(signal);
|
|
46
|
-
process.exit();
|
|
47
|
-
};
|
|
48
|
-
process.once('exit', (signal) => childProcess.kill(signal));
|
|
49
|
-
process.once('SIGTERM', processExitListener);
|
|
50
|
-
process.once('SIGINT', processExitListener);
|
|
51
|
-
process.once('SIGQUIT', processExitListener);
|
|
52
|
-
|
|
53
|
-
childProcess.on('error', (err) => {
|
|
54
|
-
reject(err);
|
|
55
|
-
});
|
|
56
|
-
childProcess.on('exit', (code) => {
|
|
57
|
-
if (code === 0) {
|
|
58
|
-
resolve(childProcess);
|
|
59
|
-
} else {
|
|
60
|
-
reject(code);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module.exports = function (api) {
|
|
2
|
-
api.cache(true);
|
|
3
|
-
|
|
4
|
-
if (
|
|
5
|
-
process.env.NX_TASK_TARGET_TARGET === 'build' ||
|
|
6
|
-
process.env.NX_TASK_TARGET_TARGET.includes('storybook')
|
|
7
|
-
) {
|
|
8
|
-
return {
|
|
9
|
-
presets: [
|
|
10
|
-
[
|
|
11
|
-
'@nx/react/babel',
|
|
12
|
-
{
|
|
13
|
-
runtime: 'automatic',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
],
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
presets: [['module:@react-native/babel-preset', { "useTransformReactJSX": true }]],
|
|
22
|
-
};
|
|
23
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
package com.<%= lowerCaseName %>
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactActivity
|
|
4
|
-
import com.facebook.react.ReactActivityDelegate
|
|
5
|
-
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
|
6
|
-
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
|
7
|
-
|
|
8
|
-
class MainActivity : ReactActivity() {
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Returns the name of the main component registered from JavaScript. This is used to schedule
|
|
12
|
-
* rendering of the component.
|
|
13
|
-
*/
|
|
14
|
-
override fun getMainComponentName(): String = "<%= className %>"
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
|
|
18
|
-
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
|
19
|
-
*/
|
|
20
|
-
override fun createReactActivityDelegate(): ReactActivityDelegate =
|
|
21
|
-
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
|
|
22
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
package com.<%= lowerCaseName %>
|
|
2
|
-
|
|
3
|
-
import android.app.Application
|
|
4
|
-
import com.facebook.react.PackageList
|
|
5
|
-
import com.facebook.react.ReactApplication
|
|
6
|
-
import com.facebook.react.ReactHost
|
|
7
|
-
import com.facebook.react.ReactNativeHost
|
|
8
|
-
import com.facebook.react.ReactPackage
|
|
9
|
-
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
|
|
10
|
-
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
|
11
|
-
import com.facebook.react.defaults.DefaultReactNativeHost
|
|
12
|
-
import com.facebook.react.flipper.ReactNativeFlipper
|
|
13
|
-
import com.facebook.soloader.SoLoader
|
|
14
|
-
|
|
15
|
-
class MainApplication : Application(), ReactApplication {
|
|
16
|
-
|
|
17
|
-
override val reactNativeHost: ReactNativeHost =
|
|
18
|
-
object : DefaultReactNativeHost(this) {
|
|
19
|
-
override fun getPackages(): List<ReactPackage> {
|
|
20
|
-
// Packages that cannot be autolinked yet can be added manually here, for example:
|
|
21
|
-
// packages.add(new MyReactNativePackage());
|
|
22
|
-
return PackageList(this).packages
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
override fun getJSMainModuleName(): String = "src/main"
|
|
26
|
-
|
|
27
|
-
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
|
28
|
-
|
|
29
|
-
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
30
|
-
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
override val reactHost: ReactHost
|
|
34
|
-
get() = getDefaultReactHost(this.applicationContext, reactNativeHost)
|
|
35
|
-
|
|
36
|
-
override fun onCreate() {
|
|
37
|
-
super.onCreate()
|
|
38
|
-
SoLoader.init(this, false)
|
|
39
|
-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
40
|
-
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
|
41
|
-
load()
|
|
42
|
-
}
|
|
43
|
-
ReactNativeFlipper.initializeFlipper(this, reactNativeHost.reactInstanceManager)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addE2e = void 0;
|
|
4
|
-
const add_e2e_1 = require("@nx/react/src/generators/application/lib/add-e2e");
|
|
5
|
-
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const versions_1 = require("../../../utils/versions");
|
|
7
|
-
async function addE2e(host, options) {
|
|
8
|
-
switch (options.e2eTestRunner) {
|
|
9
|
-
case 'cypress':
|
|
10
|
-
return (0, add_e2e_1.addE2e)(host, {
|
|
11
|
-
...options,
|
|
12
|
-
e2eTestRunner: 'cypress',
|
|
13
|
-
style: 'none',
|
|
14
|
-
styledModule: null,
|
|
15
|
-
hasStyles: false,
|
|
16
|
-
unitTestRunner: 'none',
|
|
17
|
-
});
|
|
18
|
-
case 'playwright':
|
|
19
|
-
return (0, add_e2e_1.addE2e)(host, {
|
|
20
|
-
...options,
|
|
21
|
-
e2eTestRunner: 'playwright',
|
|
22
|
-
style: 'none',
|
|
23
|
-
styledModule: null,
|
|
24
|
-
hasStyles: false,
|
|
25
|
-
unitTestRunner: 'none',
|
|
26
|
-
});
|
|
27
|
-
case 'detox':
|
|
28
|
-
const { detoxApplicationGenerator } = (0, devkit_1.ensurePackage)('@nx/detox', versions_1.nxVersion);
|
|
29
|
-
return detoxApplicationGenerator(host, {
|
|
30
|
-
...options,
|
|
31
|
-
e2eName: options.e2eProjectName,
|
|
32
|
-
e2eDirectory: options.e2eProjectRoot,
|
|
33
|
-
projectNameAndRootFormat: 'as-provided',
|
|
34
|
-
appProject: options.projectName,
|
|
35
|
-
appDisplayName: options.displayName,
|
|
36
|
-
appName: options.name,
|
|
37
|
-
framework: 'react-native',
|
|
38
|
-
setParserOptionsProject: options.setParserOptionsProject,
|
|
39
|
-
skipFormat: true,
|
|
40
|
-
});
|
|
41
|
-
case 'none':
|
|
42
|
-
default:
|
|
43
|
-
return () => { };
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.addE2e = addE2e;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module.exports = function (api) {
|
|
2
|
-
api.cache(true);
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
presets: [
|
|
6
|
-
[
|
|
7
|
-
'@nx/react/babel',
|
|
8
|
-
{
|
|
9
|
-
runtime: 'automatic',
|
|
10
|
-
useBuiltIns: 'usage',
|
|
11
|
-
},
|
|
12
|
-
],
|
|
13
|
-
],
|
|
14
|
-
plugins: [],
|
|
15
|
-
env: {
|
|
16
|
-
test: {
|
|
17
|
-
presets: [['module:@react-native/babel-preset', { "useTransformReactJSX": true }]],
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module.exports = function (api) {
|
|
2
|
-
api.cache(true);
|
|
3
|
-
|
|
4
|
-
if (
|
|
5
|
-
process.env.NX_TASK_TARGET_TARGET === 'build' ||
|
|
6
|
-
process.env.NX_TASK_TARGET_TARGET.includes('storybook')
|
|
7
|
-
) {
|
|
8
|
-
return {
|
|
9
|
-
presets: [
|
|
10
|
-
[
|
|
11
|
-
'@nx/react/babel',
|
|
12
|
-
{
|
|
13
|
-
runtime: 'automatic',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
],
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
presets: [['module:@react-native/babel-preset', { "useTransformReactJSX": true }]],
|
|
22
|
-
};
|
|
23
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" style="height: 100%">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<title><%= className %></title>
|
|
6
|
-
<base href="/" />
|
|
7
|
-
|
|
8
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
-
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
|
10
|
-
</head>
|
|
11
|
-
<body style="height:100%">
|
|
12
|
-
<div id="root" style="display: flex; height: 100%"></div>
|
|
13
|
-
<script type="module" src="/src/main-web.tsx"></script>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
|
Binary file
|
|
File without changes
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite';
|
|
2
|
-
import react from '@vitejs/plugin-react';
|
|
3
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
4
|
-
import * as esbuild from 'esbuild';
|
|
5
|
-
import { readFileSync } from 'fs';
|
|
6
|
-
|
|
7
|
-
const extensions = [
|
|
8
|
-
'.mjs',
|
|
9
|
-
'.web.tsx',
|
|
10
|
-
'.tsx',
|
|
11
|
-
'.web.ts',
|
|
12
|
-
'.ts',
|
|
13
|
-
'.web.jsx',
|
|
14
|
-
'.jsx',
|
|
15
|
-
'.web.js',
|
|
16
|
-
'.js',
|
|
17
|
-
'.css',
|
|
18
|
-
'.json',
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const rollupPlugin = (matchers: RegExp[]) => ({
|
|
22
|
-
name: 'js-in-jsx',
|
|
23
|
-
load(id: string) {
|
|
24
|
-
if (matchers.some((matcher) => matcher.test(id)) && id.endsWith('.js')) {
|
|
25
|
-
const file = readFileSync(id, { encoding: 'utf-8' });
|
|
26
|
-
return esbuild.transformSync(file, { loader: 'jsx', jsx: 'automatic' });
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export default defineConfig({
|
|
32
|
-
root: __dirname,
|
|
33
|
-
cacheDir: '../../node_modules/.vite/<%= fileName %>',
|
|
34
|
-
define: {
|
|
35
|
-
global: 'window',
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
resolve: {
|
|
39
|
-
extensions,
|
|
40
|
-
alias: {
|
|
41
|
-
'react-native': 'react-native-web',
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
build: {
|
|
46
|
-
reportCompressedSize: true,
|
|
47
|
-
commonjsOptions: { transformMixedEsModules: true },
|
|
48
|
-
outDir: '../../dist/apps/<%= fileName %>/web',
|
|
49
|
-
rollupOptions: {
|
|
50
|
-
plugins: [rollupPlugin([/react-native-vector-icons/])],
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
server: {
|
|
55
|
-
port: 4200,
|
|
56
|
-
host: 'localhost',
|
|
57
|
-
fs: {
|
|
58
|
-
// Allow serving files from one level up to the project root
|
|
59
|
-
allow: ['..'],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
preview: {
|
|
64
|
-
port: 4300,
|
|
65
|
-
host: 'localhost',
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
optimizeDeps: {
|
|
69
|
-
esbuildOptions: {
|
|
70
|
-
resolveExtensions: extensions,
|
|
71
|
-
jsx: 'automatic',
|
|
72
|
-
loader: { '.js': 'jsx' },
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
plugins: [react(), nxViteTsPaths()],
|
|
77
|
-
|
|
78
|
-
// Uncomment this if you are using workers.
|
|
79
|
-
// worker: {
|
|
80
|
-
// plugins: [ nxViteTsPaths() ],
|
|
81
|
-
// },
|
|
82
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module.exports = function (api) {
|
|
2
|
-
api.cache(true);
|
|
3
|
-
|
|
4
|
-
if (
|
|
5
|
-
process.env.NX_TASK_TARGET_TARGET === 'build' ||
|
|
6
|
-
process.env.NX_TASK_TARGET_TARGET.includes('storybook')
|
|
7
|
-
) {
|
|
8
|
-
return {
|
|
9
|
-
presets: [
|
|
10
|
-
[
|
|
11
|
-
'@nx/react/babel',
|
|
12
|
-
{
|
|
13
|
-
runtime: 'automatic',
|
|
14
|
-
},
|
|
15
|
-
],
|
|
16
|
-
],
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
presets: [['module:@react-native/babel-preset', { "useTransformReactJSX": true }]],
|
|
22
|
-
};
|
|
23
|
-
};
|
|
File without changes
|
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" style="height: 100%">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<title><%= className %></title>
|
|
6
|
-
<base href="/" />
|
|
7
|
-
|
|
8
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
-
<link rel="icon" type="image/x-icon" href="favicon.ico" />
|
|
10
|
-
</head>
|
|
11
|
-
<body style="height:100%">
|
|
12
|
-
<div id="root" style="display: flex; height: 100%"></div>
|
|
13
|
-
</body>
|
|
14
|
-
</html>
|