@nx/react-native 18.0.0-beta.1 → 18.0.0-beta.3
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 +6 -1
- package/executors.json +5 -0
- package/generators.json +12 -11
- package/migrations.json +73 -1
- package/package.json +10 -15
- package/plugins/metro-resolver.js +4 -1
- package/plugins/plugin.d.ts +2 -0
- package/plugins/plugin.js +12 -1
- package/plugins/with-nx-metro.js +6 -2
- package/src/executors/build-android/build-android.impl.js +1 -5
- package/src/executors/build-android/build-android.impl.ts +1 -5
- package/src/executors/bundle/schema.d.ts +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +4 -0
- package/src/executors/run-android/run-android.impl.js +4 -16
- package/src/executors/run-android/run-android.impl.ts +8 -17
- package/src/executors/run-ios/run-ios.impl.js +4 -16
- package/src/executors/run-ios/run-ios.impl.ts +9 -18
- package/src/executors/start/schema.d.ts +1 -1
- package/src/executors/start/start.impl.js +11 -26
- package/src/executors/start/start.impl.ts +14 -28
- package/src/executors/storybook/storybook.impl.d.ts +4 -0
- package/src/executors/storybook/storybook.impl.js +8 -1
- package/src/executors/storybook/storybook.impl.ts +16 -5
- package/src/executors/sync-deps/sync-deps.impl.d.ts +3 -2
- package/src/executors/sync-deps/sync-deps.impl.js +28 -11
- package/src/executors/sync-deps/sync-deps.impl.ts +45 -19
- package/src/executors/upgrade/schema.d.ts +1 -0
- package/src/executors/upgrade/schema.json +11 -0
- package/src/executors/upgrade/upgrade.impl.d.ts +13 -0
- package/src/executors/upgrade/upgrade.impl.js +47 -0
- package/src/executors/upgrade/upgrade.impl.ts +64 -0
- package/src/generators/application/application.js +27 -8
- package/src/generators/application/application.spec.ts +29 -2
- package/src/generators/application/files/app/.babelrc.js.template +23 -0
- package/src/generators/application/files/app/android/app/build.gradle.template +12 -28
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +2 -6
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +22 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +45 -0
- package/src/generators/application/files/app/android/build.gradle.template +7 -20
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +2 -1
- package/src/generators/application/files/app/android/gradle.properties +0 -3
- package/src/generators/application/files/app/android/gradlew.template +12 -7
- package/src/generators/application/files/app/android/settings.gradle.template +2 -2
- package/src/generators/application/files/app/ios/Podfile.template +0 -7
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +5 -0
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +5 -8
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +11 -33
- package/src/generators/application/files/app/metro.config.js.template +0 -4
- package/src/generators/application/files/app/src/app/App.tsx.template +29 -2
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +47 -0
- package/src/generators/application/lib/add-project.js +13 -17
- package/src/generators/application/lib/normalize-options.d.ts +4 -0
- package/src/generators/application/lib/normalize-options.js +9 -3
- package/src/generators/application/lib/normalize-options.spec.ts +53 -5
- package/src/generators/application/schema.d.ts +5 -3
- package/src/generators/application/schema.json +13 -5
- package/src/generators/component-story/component-story.d.ts +5 -8
- package/src/generators/component-story/component-story.js +8 -69
- package/src/generators/component-story/schema.d.ts +1 -0
- package/src/generators/component-story/schema.json +10 -2
- package/src/generators/init/init.d.ts +1 -0
- package/src/generators/init/init.js +14 -7
- package/src/generators/init/init.spec.ts +6 -2
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/lib/normalize-options.js +1 -0
- package/src/generators/library/library.js +2 -1
- package/src/generators/library/library.spec.ts +12 -41
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +1 -1
- package/src/generators/stories/schema.d.ts +2 -0
- package/src/generators/stories/schema.json +14 -1
- package/src/generators/stories/stories.d.ts +5 -2
- package/src/generators/stories/stories.js +7 -50
- package/src/generators/storybook-configuration/configuration.d.ts +7 -2
- package/src/generators/storybook-configuration/configuration.js +15 -48
- package/src/generators/storybook-configuration/schema.d.ts +4 -2
- package/src/generators/storybook-configuration/schema.json +21 -11
- 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 +2 -2
- package/src/generators/upgrade-native/upgrade-native.d.ts +2 -0
- package/src/generators/upgrade-native/upgrade-native.js +3 -0
- package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +23 -0
- package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +15 -0
- 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__ +9 -0
- package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +82 -0
- package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +23 -0
- 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__ +14 -0
- package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +9 -0
- package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +77 -0
- package/src/generators/web-configuration/lib/normalize-schema.d.ts +17 -0
- package/src/generators/web-configuration/lib/normalize-schema.js +16 -0
- package/src/generators/web-configuration/lib/webpack-targets.d.ts +7 -0
- package/src/generators/web-configuration/lib/webpack-targets.js +75 -0
- package/src/generators/web-configuration/schema.d.ts +6 -0
- package/src/generators/web-configuration/schema.json +42 -0
- package/src/generators/web-configuration/web-configuration.d.ts +12 -0
- package/src/generators/web-configuration/web-configuration.js +85 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +0 -4
- package/src/migrations/update-16-9-0/remove-types-react-native.js +2 -9
- package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/add-upgrade-target.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.d.ts +8 -0
- package/src/migrations/update-18-0-0/add-web-configuration.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +39 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +5 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.js +57 -0
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-block-list.js +26 -0
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +68 -0
- package/src/migrations/update-18-0-0/remove-metro.d.ts +14 -0
- package/src/migrations/update-18-0-0/remove-metro.js +29 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.js +30 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +40 -0
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +13 -1
- package/src/utils/add-linting.d.ts +1 -0
- package/src/utils/add-linting.js +1 -0
- package/src/utils/add-linting.spec.ts +2 -4
- package/src/utils/ensure-dependencies.js +2 -6
- package/src/utils/testing-generators.js +1 -0
- package/src/utils/versions.d.ts +9 -12
- package/src/utils/versions.js +10 -13
- package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -75
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +0 -32
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +0 -62
- package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -20
- package/src/generators/application/files/app/babel.config.json.template +0 -10
- package/src/generators/application/lib/add-detox.d.ts +0 -3
- package/src/generators/application/lib/add-detox.js +0 -23
- package/src/generators/component-story/component-story.spec.ts +0 -427
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +0 -32
- package/src/generators/library/files/lib/babel.config.json.template +0 -19
- package/src/generators/stories/stories-app.spec.ts +0 -128
- package/src/generators/stories/stories-lib.spec.ts +0 -105
- package/src/generators/storybook-configuration/configuration.spec.ts +0 -135
- package/src/generators/storybook-configuration/files/app/storybook.ts.template +0 -9
- package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +0 -74
- package/src/generators/storybook-configuration/files/root/story-loader.ts.template +0 -5
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +0 -25
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +0 -161
- package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +0 -42
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +0 -7
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +0 -29
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +0 -65
- package/src/utils/find-all-npm-dependencies.d.ts +0 -2
- package/src/utils/find-all-npm-dependencies.js +0 -25
- package/src/utils/find-all-npm-dependencies.spec.ts +0 -95
- package/src/utils/symlink-task.d.ts +0 -2
- package/src/utils/symlink-task.js +0 -18
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
2
|
+
import { Tree, addProjectConfiguration } from '@nx/devkit';
|
|
3
|
+
import update from './remove-block-list';
|
|
4
|
+
|
|
5
|
+
describe('remove-block-list', () => {
|
|
6
|
+
let tree: Tree;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
10
|
+
addProjectConfiguration(tree, 'product', {
|
|
11
|
+
root: 'apps/product',
|
|
12
|
+
targets: {
|
|
13
|
+
start: {
|
|
14
|
+
executor: '@nx/react-native:start',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
tree.write(
|
|
19
|
+
'apps/product/metro.config.js',
|
|
20
|
+
`
|
|
21
|
+
const { withNxMetro } = require('@nx/expo');
|
|
22
|
+
const { getDefaultConfig } = require('@expo/metro-config');
|
|
23
|
+
const { mergeConfig } = require('metro-config');
|
|
24
|
+
const exclusionList = require('metro-config/src/defaults/exclusionList');
|
|
25
|
+
|
|
26
|
+
const defaultConfig = getDefaultConfig(__dirname);
|
|
27
|
+
const { assetExts, sourceExts } = defaultConfig.resolver;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Metro configuration
|
|
31
|
+
* https://facebook.github.io/metro/docs/configuration
|
|
32
|
+
*
|
|
33
|
+
* @type {import('metro-config').MetroConfig}
|
|
34
|
+
*/
|
|
35
|
+
const customConfig = {
|
|
36
|
+
transformer: {
|
|
37
|
+
babelTransformerPath: require.resolve('react-native-svg-transformer'),
|
|
38
|
+
},
|
|
39
|
+
resolver: {
|
|
40
|
+
assetExts: assetExts.filter((ext) => ext !== 'svg'),
|
|
41
|
+
sourceExts: [...sourceExts, 'svg'],
|
|
42
|
+
blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
|
|
43
|
+
unstable_enableSymlinks: true,
|
|
44
|
+
unstable_enablePackageExports: true,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
|
|
50
|
+
// Change this to true to see debugging info.
|
|
51
|
+
// Useful if you have issues resolving modules
|
|
52
|
+
debug: false,
|
|
53
|
+
// all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
|
|
54
|
+
extensions: [],
|
|
55
|
+
// Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
|
|
56
|
+
watchFolders: [],
|
|
57
|
+
});`
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should remove blockList', async () => {
|
|
62
|
+
await update(tree);
|
|
63
|
+
const metroConfig = tree.read(`apps/product/metro.config.js`).toString();
|
|
64
|
+
expect(metroConfig).not.toContain('blockList');
|
|
65
|
+
expect(metroConfig).not.toContain('unstable_enableSymlinks');
|
|
66
|
+
expect(metroConfig).not.toContain('unstable_enablePackageExports');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Remove metro-* package since it is no longer explicity required in package.json.
|
|
4
|
+
* react-native has dependency of @react-native/community-cli-plugin
|
|
5
|
+
* @react-native/community-cli-plugin has dependency of metro
|
|
6
|
+
*
|
|
7
|
+
* Also remove @react-native-community/cli-* since it is a dependency of react-native.
|
|
8
|
+
* (excpet reactNativeCommunityCliPlatformAndroidVersion because android files refer it by path)
|
|
9
|
+
*
|
|
10
|
+
* https://react-native-community.github.io/upgrade-helper/?from=0.72.6&to=0.73.1#RnDiffApp-package.json
|
|
11
|
+
* @param tree
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export default function update(tree: Tree): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
/**
|
|
5
|
+
* Remove metro-* package since it is no longer explicity required in package.json.
|
|
6
|
+
* react-native has dependency of @react-native/community-cli-plugin
|
|
7
|
+
* @react-native/community-cli-plugin has dependency of metro
|
|
8
|
+
*
|
|
9
|
+
* Also remove @react-native-community/cli-* since it is a dependency of react-native.
|
|
10
|
+
* (excpet reactNativeCommunityCliPlatformAndroidVersion because android files refer it by path)
|
|
11
|
+
*
|
|
12
|
+
* https://react-native-community.github.io/upgrade-helper/?from=0.72.6&to=0.73.1#RnDiffApp-package.json
|
|
13
|
+
* @param tree
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
async function update(tree) {
|
|
17
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, [], [
|
|
18
|
+
'metro',
|
|
19
|
+
'metro-resolver',
|
|
20
|
+
'metro-config',
|
|
21
|
+
'metro-react-native-babel-preset',
|
|
22
|
+
'metro-babel-register',
|
|
23
|
+
'metro-react-native-babel-transformer',
|
|
24
|
+
'@react-native-community/cli',
|
|
25
|
+
'@react-native-community/cli-platform-ios',
|
|
26
|
+
]);
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
28
|
+
}
|
|
29
|
+
exports.default = update;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
/**
|
|
6
|
+
* Remove ensure-symlink target.
|
|
7
|
+
* It is going to be supported by react-native version 0.73 by default.
|
|
8
|
+
*/
|
|
9
|
+
async function update(tree) {
|
|
10
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
11
|
+
for (const [projectName, config] of projects.entries()) {
|
|
12
|
+
if (config.targets?.['ensure-symlink']?.executor ===
|
|
13
|
+
'@nx/react-native:ensure-symlink') {
|
|
14
|
+
removeTargets(config.targets, 'ensure-symlink');
|
|
15
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
|
|
16
|
+
(0, fs_extra_1.removeSync)(`${config.root}/node_modules`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = update;
|
|
21
|
+
function removeTargets(targets, targetNameToRemove) {
|
|
22
|
+
for (const targetName in targets) {
|
|
23
|
+
if (targetName === targetNameToRemove) {
|
|
24
|
+
delete targets[targetName];
|
|
25
|
+
}
|
|
26
|
+
if (targets[targetName]?.dependsOn?.length) {
|
|
27
|
+
targets[targetName].dependsOn = targets[targetName].dependsOn.filter((dependsOn) => dependsOn !== targetNameToRemove);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { addProjectConfiguration, getProjects, Tree } from '@nx/devkit';
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
+
import update from './remove-symlink-target';
|
|
4
|
+
|
|
5
|
+
describe('remove-symlink-target', () => {
|
|
6
|
+
let tree: Tree;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
10
|
+
addProjectConfiguration(tree, 'product', {
|
|
11
|
+
root: 'apps/product',
|
|
12
|
+
sourceRoot: 'apps/product/src',
|
|
13
|
+
targets: {
|
|
14
|
+
'ensure-symlink': {
|
|
15
|
+
executor: '@nx/react-native:ensure-symlink',
|
|
16
|
+
options: {},
|
|
17
|
+
},
|
|
18
|
+
'bundle-android': {
|
|
19
|
+
executor: '@nx/react-native:bundle',
|
|
20
|
+
dependsOn: ['ensure-symlink'],
|
|
21
|
+
outputs: ['{options.bundleOutput}'],
|
|
22
|
+
options: {
|
|
23
|
+
entryFile: 'src/main.tsx',
|
|
24
|
+
platform: 'android',
|
|
25
|
+
bundleOutput: 'dist/apps/techy-jokes/android/main.jsbundle',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it(`should remove ensure-symlink target from project.json`, async () => {
|
|
33
|
+
await update(tree);
|
|
34
|
+
|
|
35
|
+
getProjects(tree).forEach((project) => {
|
|
36
|
+
expect(project.targets['ensure-symlink']).toBeUndefined();
|
|
37
|
+
expect(project.targets['bundle-android'].dependsOn).toEqual([]);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
package/src/utils/add-jest.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
2
|
+
export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean, addPlugin: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
|
package/src/utils/add-jest.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addJest = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const jest_1 = require("@nx/jest");
|
|
6
|
-
async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson) {
|
|
6
|
+
async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson, addPlugin) {
|
|
7
7
|
if (unitTestRunner !== 'jest') {
|
|
8
8
|
return () => { };
|
|
9
9
|
}
|
|
@@ -16,6 +16,7 @@ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, sk
|
|
|
16
16
|
compiler: 'babel',
|
|
17
17
|
skipPackageJson,
|
|
18
18
|
skipFormat: true,
|
|
19
|
+
addPlugin,
|
|
19
20
|
});
|
|
20
21
|
// overwrite the jest.config.ts file because react native needs to have special transform property
|
|
21
22
|
const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;
|
|
@@ -28,6 +29,17 @@ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, sk
|
|
|
28
29
|
moduleNameMapper: {
|
|
29
30
|
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock'
|
|
30
31
|
},
|
|
32
|
+
transform: {
|
|
33
|
+
'^.+\\.(js|ts|tsx)$': [
|
|
34
|
+
'babel-jest',
|
|
35
|
+
{
|
|
36
|
+
configFile: __dirname + '/.babelrc.js',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(
|
|
40
|
+
'react-native/jest/assetFileTransformer.js'
|
|
41
|
+
),
|
|
42
|
+
},
|
|
31
43
|
coverageDirectory: '${(0, devkit_1.offsetFromRoot)(appProjectRoot)}coverage/${appProjectRoot}'
|
|
32
44
|
};`;
|
|
33
45
|
host.write(configPath, content);
|
|
@@ -7,6 +7,7 @@ interface NormalizedSchema {
|
|
|
7
7
|
setParserOptionsProject?: boolean;
|
|
8
8
|
tsConfigPaths: string[];
|
|
9
9
|
skipPackageJson?: boolean;
|
|
10
|
+
addPlugin?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
12
13
|
export {};
|
package/src/utils/add-linting.js
CHANGED
|
@@ -16,6 +16,7 @@ async function addLinting(host, options) {
|
|
|
16
16
|
tsConfigPaths: options.tsConfigPaths,
|
|
17
17
|
skipFormat: true,
|
|
18
18
|
skipPackageJson: options.skipPackageJson,
|
|
19
|
+
addPlugin: options.addPlugin,
|
|
19
20
|
});
|
|
20
21
|
tasks.push(lintTask);
|
|
21
22
|
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
@@ -15,17 +15,15 @@ describe('Add Linting', () => {
|
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
it('should add
|
|
18
|
+
it('should add a .eslintrc.json when is passed', async () => {
|
|
19
19
|
await addLinting(tree, {
|
|
20
20
|
projectName: 'my-lib',
|
|
21
21
|
linter: Linter.EsLint,
|
|
22
22
|
tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
|
|
23
23
|
projectRoot: 'libs/my-lib',
|
|
24
24
|
});
|
|
25
|
-
const project = readProjectConfiguration(tree, 'my-lib');
|
|
26
25
|
|
|
27
|
-
expect(
|
|
28
|
-
expect(project.targets.lint.executor).toEqual('@nx/eslint:lint');
|
|
26
|
+
expect(tree.exists('libs/my-lib/.eslintrc.json')).toBeTruthy();
|
|
29
27
|
});
|
|
30
28
|
|
|
31
29
|
it('should not add lint target when "none" is passed', async () => {
|
|
@@ -9,16 +9,12 @@ function ensureDependencies(tree) {
|
|
|
9
9
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
10
10
|
'@types/node': versions_2.typesNodeVersion,
|
|
11
11
|
'@types/react': versions_2.typesReactVersion,
|
|
12
|
+
'@react-native/babel-preset': versions_2.reactNativeBabelPresetVersion,
|
|
12
13
|
'@react-native/metro-config': versions_2.reactNativeMetroConfigVersion,
|
|
13
14
|
'@testing-library/react-native': versions_2.testingLibraryReactNativeVersion,
|
|
14
15
|
'@testing-library/jest-native': versions_2.testingLibraryJestNativeVersion,
|
|
16
|
+
'@react-native-community/cli-platform-android': versions_2.reactNativeCommunityCliPlatformAndroidVersion,
|
|
15
17
|
'jest-react-native': versions_2.jestReactNativeVersion,
|
|
16
|
-
metro: versions_2.metroVersion,
|
|
17
|
-
'metro-config': versions_2.metroVersion,
|
|
18
|
-
'metro-resolver': versions_2.metroVersion,
|
|
19
|
-
'metro-babel-register': versions_2.metroVersion,
|
|
20
|
-
'metro-react-native-babel-preset': versions_2.metroVersion,
|
|
21
|
-
'metro-react-native-babel-transformer': versions_2.metroVersion,
|
|
22
18
|
'react-test-renderer': versions_2.reactTestRendererVersion,
|
|
23
19
|
'react-native-svg-transformer': versions_2.reactNativeSvgTransformerVersion,
|
|
24
20
|
'react-native-svg': versions_2.reactNativeSvgVersion,
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
|
-
export declare const reactNativeVersion = "0.
|
|
2
|
+
export declare const reactNativeVersion = "0.73.2";
|
|
3
3
|
export declare const typesNodeVersion = "18.16.9";
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const reactNativeCommunityCliAndroid = "11.3.7";
|
|
4
|
+
export declare const reactNativeCommunityCliPlatformAndroidVersion = "12.3.0";
|
|
5
|
+
export declare const reactNativeBabelPresetVersion = "^0.73.18";
|
|
6
|
+
export declare const reactNativeMetroConfigVersion = "^0.73.2";
|
|
7
|
+
export declare const reactNativeWebVersion = "^0.19.9";
|
|
9
8
|
export declare const reactVersion = "18.2.0";
|
|
10
9
|
export declare const reactDomVersion = "18.2.0";
|
|
11
10
|
export declare const reactTestRendererVersion = "18.2.0";
|
|
12
|
-
export declare const typesReactVersion = "18.
|
|
13
|
-
export declare const testingLibraryReactNativeVersion = "~12.
|
|
11
|
+
export declare const typesReactVersion = "~18.2.45";
|
|
12
|
+
export declare const testingLibraryReactNativeVersion = "~12.4.2";
|
|
14
13
|
export declare const testingLibraryJestNativeVersion = "~5.4.3";
|
|
15
14
|
export declare const jestReactNativeVersion = "18.0.0";
|
|
16
|
-
export declare const reactNativeSvgTransformerVersion = "1.
|
|
17
|
-
export declare const reactNativeSvgVersion = "
|
|
15
|
+
export declare const reactNativeSvgTransformerVersion = "1.2.0";
|
|
16
|
+
export declare const reactNativeSvgVersion = "14.1.0";
|
|
18
17
|
export declare const babelRuntimeVersion = "7.22.6";
|
|
19
|
-
export declare const reactNativeAsyncStorageVersion = "~1.19.3";
|
|
20
|
-
export declare const reactNativeSafeAreaContextVersion = "~4.7.2";
|
package/src/utils/versions.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.babelRuntimeVersion = exports.reactNativeSvgVersion = exports.reactNativeSvgTransformerVersion = exports.jestReactNativeVersion = exports.testingLibraryJestNativeVersion = exports.testingLibraryReactNativeVersion = exports.typesReactVersion = exports.reactTestRendererVersion = exports.reactDomVersion = exports.reactVersion = exports.reactNativeWebVersion = exports.reactNativeMetroConfigVersion = exports.reactNativeBabelPresetVersion = exports.reactNativeCommunityCliPlatformAndroidVersion = exports.typesNodeVersion = exports.reactNativeVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
|
-
exports.reactNativeVersion = '0.
|
|
5
|
+
exports.reactNativeVersion = '0.73.2';
|
|
6
6
|
exports.typesNodeVersion = '18.16.9';
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.reactNativeCommunityCliAndroid = '11.3.7';
|
|
7
|
+
exports.reactNativeCommunityCliPlatformAndroidVersion = '12.3.0'; // anddroid refers files from this package
|
|
8
|
+
exports.reactNativeBabelPresetVersion = '^0.73.18';
|
|
9
|
+
exports.reactNativeMetroConfigVersion = '^0.73.2';
|
|
10
|
+
exports.reactNativeWebVersion = '^0.19.9';
|
|
12
11
|
exports.reactVersion = '18.2.0';
|
|
13
12
|
exports.reactDomVersion = '18.2.0';
|
|
14
13
|
exports.reactTestRendererVersion = '18.2.0';
|
|
15
|
-
exports.typesReactVersion = '18.
|
|
16
|
-
exports.testingLibraryReactNativeVersion = '~12.
|
|
14
|
+
exports.typesReactVersion = '~18.2.45';
|
|
15
|
+
exports.testingLibraryReactNativeVersion = '~12.4.2';
|
|
17
16
|
exports.testingLibraryJestNativeVersion = '~5.4.3';
|
|
18
17
|
exports.jestReactNativeVersion = '18.0.0';
|
|
19
|
-
exports.reactNativeSvgTransformerVersion = '1.
|
|
20
|
-
exports.reactNativeSvgVersion = '
|
|
18
|
+
exports.reactNativeSvgTransformerVersion = '1.2.0';
|
|
19
|
+
exports.reactNativeSvgVersion = '14.1.0';
|
|
21
20
|
exports.babelRuntimeVersion = '7.22.6';
|
|
22
|
-
exports.reactNativeAsyncStorageVersion = '~1.19.3';
|
|
23
|
-
exports.reactNativeSafeAreaContextVersion = '~4.7.2';
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
|
5
|
-
* directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
package com.<%= lowerCaseName %>;
|
|
8
|
-
|
|
9
|
-
import android.content.Context;
|
|
10
|
-
import com.facebook.flipper.android.AndroidFlipperClient;
|
|
11
|
-
import com.facebook.flipper.android.utils.FlipperUtils;
|
|
12
|
-
import com.facebook.flipper.core.FlipperClient;
|
|
13
|
-
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
|
|
14
|
-
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
|
|
15
|
-
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
|
|
16
|
-
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
|
|
17
|
-
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
|
|
18
|
-
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
|
|
19
|
-
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
|
|
20
|
-
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
|
|
21
|
-
import com.facebook.react.ReactInstanceEventListener;
|
|
22
|
-
import com.facebook.react.ReactInstanceManager;
|
|
23
|
-
import com.facebook.react.bridge.ReactContext;
|
|
24
|
-
import com.facebook.react.modules.network.NetworkingModule;
|
|
25
|
-
import okhttp3.OkHttpClient;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Class responsible of loading Flipper inside your React Native application. This is the debug
|
|
29
|
-
* flavor of it. Here you can add your own plugins and customize the Flipper setup.
|
|
30
|
-
*/
|
|
31
|
-
public class ReactNativeFlipper {
|
|
32
|
-
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
|
|
33
|
-
if (FlipperUtils.shouldEnableFlipper(context)) {
|
|
34
|
-
final FlipperClient client = AndroidFlipperClient.getInstance(context);
|
|
35
|
-
|
|
36
|
-
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
|
|
37
|
-
client.addPlugin(new DatabasesFlipperPlugin(context));
|
|
38
|
-
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
|
|
39
|
-
client.addPlugin(CrashReporterPlugin.getInstance());
|
|
40
|
-
|
|
41
|
-
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
|
|
42
|
-
NetworkingModule.setCustomClientBuilder(
|
|
43
|
-
new NetworkingModule.CustomClientBuilder() {
|
|
44
|
-
@Override
|
|
45
|
-
public void apply(OkHttpClient.Builder builder) {
|
|
46
|
-
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
client.addPlugin(networkFlipperPlugin);
|
|
50
|
-
client.start();
|
|
51
|
-
|
|
52
|
-
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
|
|
53
|
-
// Hence we run if after all native modules have been initialized
|
|
54
|
-
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
|
|
55
|
-
if (reactContext == null) {
|
|
56
|
-
reactInstanceManager.addReactInstanceEventListener(
|
|
57
|
-
new ReactInstanceEventListener() {
|
|
58
|
-
@Override
|
|
59
|
-
public void onReactContextInitialized(ReactContext reactContext) {
|
|
60
|
-
reactInstanceManager.removeReactInstanceEventListener(this);
|
|
61
|
-
reactContext.runOnNativeModulesQueueThread(
|
|
62
|
-
new Runnable() {
|
|
63
|
-
@Override
|
|
64
|
-
public void run() {
|
|
65
|
-
client.addPlugin(new FrescoFlipperPlugin());
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
} else {
|
|
71
|
-
client.addPlugin(new FrescoFlipperPlugin());
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,32 +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;
|
|
6
|
-
import com.facebook.react.defaults.DefaultReactActivityDelegate;
|
|
7
|
-
|
|
8
|
-
public class MainActivity extends 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
|
|
15
|
-
protected String getMainComponentName() {
|
|
16
|
-
return "<%= className %>";
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
|
|
21
|
-
* DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
|
|
22
|
-
* (aka React 18) with two boolean flags.
|
|
23
|
-
*/
|
|
24
|
-
@Override
|
|
25
|
-
protected ReactActivityDelegate createReactActivityDelegate() {
|
|
26
|
-
return new DefaultReactActivityDelegate(
|
|
27
|
-
this,
|
|
28
|
-
getMainComponentName(),
|
|
29
|
-
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
|
|
30
|
-
DefaultNewArchitectureEntryPoint.getFabricEnabled());
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,62 +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.ReactNativeHost;
|
|
7
|
-
import com.facebook.react.ReactPackage;
|
|
8
|
-
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
|
|
9
|
-
import com.facebook.react.defaults.DefaultReactNativeHost;
|
|
10
|
-
import com.facebook.soloader.SoLoader;
|
|
11
|
-
import java.util.List;
|
|
12
|
-
|
|
13
|
-
public class MainApplication extends Application implements ReactApplication {
|
|
14
|
-
|
|
15
|
-
private final ReactNativeHost mReactNativeHost =
|
|
16
|
-
new DefaultReactNativeHost(this) {
|
|
17
|
-
@Override
|
|
18
|
-
public boolean getUseDeveloperSupport() {
|
|
19
|
-
return BuildConfig.DEBUG;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
@Override
|
|
23
|
-
protected List<ReactPackage> getPackages() {
|
|
24
|
-
@SuppressWarnings("UnnecessaryLocalVariable")
|
|
25
|
-
List<ReactPackage> packages = new PackageList(this).getPackages();
|
|
26
|
-
// Packages that cannot be autolinked yet can be added manually here, for example:
|
|
27
|
-
// packages.add(new MyReactNativePackage());
|
|
28
|
-
return packages;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@Override
|
|
32
|
-
protected String getJSMainModuleName() {
|
|
33
|
-
return "<%= entryFile %>";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@Override
|
|
37
|
-
protected boolean isNewArchEnabled() {
|
|
38
|
-
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@Override
|
|
42
|
-
protected Boolean isHermesEnabled() {
|
|
43
|
-
return BuildConfig.IS_HERMES_ENABLED;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
@Override
|
|
48
|
-
public ReactNativeHost getReactNativeHost() {
|
|
49
|
-
return mReactNativeHost;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@Override
|
|
53
|
-
public void onCreate() {
|
|
54
|
-
super.onCreate();
|
|
55
|
-
SoLoader.init(this, /* native exopackage */ false);
|
|
56
|
-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
57
|
-
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
|
58
|
-
DefaultNewArchitectureEntryPoint.load();
|
|
59
|
-
}
|
|
60
|
-
ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
|
5
|
-
* directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
package com.<%= lowerCaseName %>;
|
|
8
|
-
|
|
9
|
-
import android.content.Context;
|
|
10
|
-
import com.facebook.react.ReactInstanceManager;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Class responsible of loading Flipper inside your React Native application. This is the release
|
|
14
|
-
* flavor of it so it's empty as we don't want to load Flipper.
|
|
15
|
-
*/
|
|
16
|
-
public class ReactNativeFlipper {
|
|
17
|
-
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
|
|
18
|
-
// Do nothing as we don't want to initialize Flipper on Release.
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addDetox = void 0;
|
|
4
|
-
const detox_1 = require("@nx/detox");
|
|
5
|
-
const eslint_1 = require("@nx/eslint");
|
|
6
|
-
async function addDetox(host, options) {
|
|
7
|
-
if (options?.e2eTestRunner !== 'detox') {
|
|
8
|
-
return () => { };
|
|
9
|
-
}
|
|
10
|
-
return (0, detox_1.detoxApplicationGenerator)(host, {
|
|
11
|
-
...options,
|
|
12
|
-
linter: eslint_1.Linter.EsLint,
|
|
13
|
-
e2eName: `${options.projectName}-e2e`,
|
|
14
|
-
e2eDirectory: `${options.appProjectRoot}-e2e`,
|
|
15
|
-
projectNameAndRootFormat: 'as-provided',
|
|
16
|
-
appProject: options.projectName,
|
|
17
|
-
appDisplayName: options.displayName,
|
|
18
|
-
appName: options.name,
|
|
19
|
-
framework: 'react-native',
|
|
20
|
-
skipFormat: true,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.addDetox = addDetox;
|