@nx/react-native 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba
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/LICENSE +1 -1
- package/README.md +1 -1
- package/migrations.json +78 -287
- package/package.json +11 -10
- package/plugins/plugin.js +17 -38
- package/plugins/with-nx-metro.js +3 -2
- package/project.json +1 -3
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +1 -1
- package/src/executors/storybook/schema.d.ts +1 -0
- package/src/executors/storybook/storybook.impl.d.ts +1 -1
- package/src/executors/storybook/storybook.impl.js +10 -3
- package/src/generators/application/files/app/Gemfile.template +4 -2
- package/src/generators/application/files/app/android/app/build.gradle.template +0 -1
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +1 -3
- package/src/generators/application/files/app/android/build.gradle.template +3 -3
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/src/generators/application/files/app/android/gradlew.bat +10 -10
- package/src/generators/application/files/app/android/gradlew.template +7 -7
- package/src/generators/application/files/app/ios/Podfile.template +2 -17
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +2 -2
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +1 -1
- package/src/generators/application/files/app/ios/__className__/PrivacyInfo.xcprivacy +38 -0
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +5 -1
- package/src/generators/application/files/app/metro.config.js.template +1 -1
- package/src/generators/application/files/app/tsconfig.app.json.template +1 -1
- package/src/generators/application/lib/normalize-options.d.ts +3 -0
- package/src/generators/application/lib/normalize-options.js +23 -0
- package/src/generators/application/schema.json +2 -2
- package/src/generators/component/schema.d.ts +1 -1
- package/src/generators/component/schema.json +1 -1
- package/src/generators/init/init.js +44 -31
- package/src/generators/init/lib/gitignore-entries.d.ts +1 -1
- package/src/generators/init/lib/gitignore-entries.js +2 -2
- package/src/generators/library/files/lib/tsconfig.lib.json.template +1 -1
- package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +3 -3
- package/src/migrations/update-18-0-0/change-storybook-targets.js +1 -1
- package/src/utils/add-jest.js +2 -2
- package/src/utils/versions.d.ts +9 -9
- package/src/utils/versions.js +9 -9
- package/src/executors/build-android/build-android.impl.ts +0 -69
- package/src/executors/build-ios/build-ios.impl.ts +0 -77
- package/src/executors/bundle/bundle.impl.ts +0 -77
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +0 -22
- package/src/executors/pod-install/pod-install.impl.ts +0 -21
- package/src/executors/run-android/run-android.impl.ts +0 -94
- package/src/executors/run-ios/run-ios.impl.ts +0 -92
- package/src/executors/start/start.impl.ts +0 -111
- package/src/executors/storybook/storybook.impl.ts +0 -85
- package/src/executors/sync-deps/sync-deps.impl.ts +0 -140
- package/src/executors/upgrade/upgrade.impl.ts +0 -64
- package/src/generators/application/application.spec.ts +0 -258
- package/src/generators/application/files/app/test-setup.ts.template +0 -1
- package/src/generators/application/lib/normalize-options.spec.ts +0 -196
- package/src/generators/component/component.spec.ts +0 -127
- package/src/generators/init/init.spec.ts +0 -38
- package/src/generators/library/files/lib/test-setup.ts.template +0 -1
- package/src/generators/library/library.spec.ts +0 -420
- package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +0 -2
- package/src/migrations/update-15-0-0/add-babel-inputs.js +0 -9
- package/src/migrations/update-15-0-0/add-babel-inputs.spec.ts +0 -73
- package/src/migrations/update-15-9-1/add-build-ios-target.d.ts +0 -5
- package/src/migrations/update-15-9-1/add-build-ios-target.js +0 -29
- package/src/migrations/update-15-9-1/add-build-ios-target.spec.ts +0 -36
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts +0 -37
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +0 -39
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +0 -68
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +0 -40
- package/src/utils/add-linting.spec.ts +0 -40
- package/src/utils/ensure-node-modules-symlink.spec.ts +0 -108
- package/src/utils/find-all-npm-dependencies.spec.ts +0 -103
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import * as chalk from 'chalk';
|
|
3
|
-
import {
|
|
4
|
-
ExecutorContext,
|
|
5
|
-
ProjectGraph,
|
|
6
|
-
logger,
|
|
7
|
-
readCachedProjectGraph,
|
|
8
|
-
readJsonFile,
|
|
9
|
-
writeJsonFile,
|
|
10
|
-
} from '@nx/devkit';
|
|
11
|
-
|
|
12
|
-
import { ReactNativeSyncDepsOptions } from './schema';
|
|
13
|
-
import { findAllNpmDependencies } from '../../utils/find-all-npm-dependencies';
|
|
14
|
-
import { PackageJson } from 'nx/src/utils/package-json';
|
|
15
|
-
|
|
16
|
-
export interface ReactNativeSyncDepsOutput {
|
|
17
|
-
success: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default async function* syncDepsExecutor(
|
|
21
|
-
options: ReactNativeSyncDepsOptions,
|
|
22
|
-
context: ExecutorContext
|
|
23
|
-
): AsyncGenerator<ReactNativeSyncDepsOutput> {
|
|
24
|
-
const projectRoot =
|
|
25
|
-
context.projectsConfigurations.projects[context.projectName].root;
|
|
26
|
-
|
|
27
|
-
const workspacePackageJsonPath = join(context.root, 'package.json');
|
|
28
|
-
const projectPackageJsonPath = join(
|
|
29
|
-
context.root,
|
|
30
|
-
projectRoot,
|
|
31
|
-
'package.json'
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const workspacePackageJson = readJsonFile(workspacePackageJsonPath);
|
|
35
|
-
const projectPackageJson = readJsonFile(projectPackageJsonPath);
|
|
36
|
-
displayNewlyAddedDepsMessage(
|
|
37
|
-
context.projectName,
|
|
38
|
-
await syncDeps(
|
|
39
|
-
context.projectName,
|
|
40
|
-
projectPackageJson,
|
|
41
|
-
projectPackageJsonPath,
|
|
42
|
-
workspacePackageJson,
|
|
43
|
-
context.projectGraph,
|
|
44
|
-
typeof options.include === 'string'
|
|
45
|
-
? options.include.split(',')
|
|
46
|
-
: options.include,
|
|
47
|
-
typeof options.exclude === 'string'
|
|
48
|
-
? options.exclude.split(',')
|
|
49
|
-
: options.exclude,
|
|
50
|
-
options.all
|
|
51
|
-
)
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
yield { success: true };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export async function syncDeps(
|
|
58
|
-
projectName: string,
|
|
59
|
-
projectPackageJson: PackageJson,
|
|
60
|
-
projectPackageJsonPath: string,
|
|
61
|
-
workspacePackageJson: PackageJson,
|
|
62
|
-
projectGraph: ProjectGraph = readCachedProjectGraph(),
|
|
63
|
-
include: string[] = [],
|
|
64
|
-
exclude: string[] = [],
|
|
65
|
-
all: boolean = false
|
|
66
|
-
): Promise<string[]> {
|
|
67
|
-
let npmDeps = all
|
|
68
|
-
? Object.keys(workspacePackageJson.dependencies || {})
|
|
69
|
-
: findAllNpmDependencies(projectGraph, projectName);
|
|
70
|
-
let npmDevdeps = all
|
|
71
|
-
? Object.keys(workspacePackageJson.devDependencies || {})
|
|
72
|
-
: [];
|
|
73
|
-
|
|
74
|
-
const newDeps = [];
|
|
75
|
-
let updated = false;
|
|
76
|
-
|
|
77
|
-
if (!projectPackageJson.dependencies) {
|
|
78
|
-
projectPackageJson.dependencies = {};
|
|
79
|
-
updated = true;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (include && include.length) {
|
|
83
|
-
npmDeps.push(...include);
|
|
84
|
-
}
|
|
85
|
-
if (exclude && exclude.length) {
|
|
86
|
-
npmDeps = npmDeps.filter((dep) => !exclude.includes(dep));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (!projectPackageJson.devDependencies) {
|
|
90
|
-
projectPackageJson.devDependencies = {};
|
|
91
|
-
}
|
|
92
|
-
if (!projectPackageJson.dependencies) {
|
|
93
|
-
projectPackageJson.dependencies = {};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
npmDeps.forEach((dep) => {
|
|
97
|
-
if (
|
|
98
|
-
!projectPackageJson.dependencies[dep] &&
|
|
99
|
-
!projectPackageJson.devDependencies[dep]
|
|
100
|
-
) {
|
|
101
|
-
projectPackageJson.dependencies[dep] = '*';
|
|
102
|
-
newDeps.push(dep);
|
|
103
|
-
updated = true;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
npmDevdeps.forEach((dep) => {
|
|
107
|
-
if (
|
|
108
|
-
!projectPackageJson.dependencies[dep] &&
|
|
109
|
-
!projectPackageJson.devDependencies[dep]
|
|
110
|
-
) {
|
|
111
|
-
projectPackageJson.devDependencies[dep] = '*';
|
|
112
|
-
newDeps.push(dep);
|
|
113
|
-
updated = true;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
if (updated) {
|
|
118
|
-
writeJsonFile(projectPackageJsonPath, projectPackageJson);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return newDeps;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function displayNewlyAddedDepsMessage(
|
|
125
|
-
projectName: string,
|
|
126
|
-
deps: string[]
|
|
127
|
-
) {
|
|
128
|
-
if (deps.length > 0) {
|
|
129
|
-
logger.info(`${chalk.bold.cyan(
|
|
130
|
-
'info'
|
|
131
|
-
)} Added entries to 'package.json' for '${projectName}' (for autolink):
|
|
132
|
-
${deps.map((d) => chalk.bold.cyan(`"${d}": "*"`)).join('\n ')}`);
|
|
133
|
-
} else {
|
|
134
|
-
logger.info(
|
|
135
|
-
`${chalk.bold.cyan(
|
|
136
|
-
'info'
|
|
137
|
-
)} Dependencies for '${projectName}' are up to date! No changes made.`
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
@@ -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,258 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Tree,
|
|
3
|
-
getProjects,
|
|
4
|
-
readJson,
|
|
5
|
-
readProjectConfiguration,
|
|
6
|
-
} from '@nx/devkit';
|
|
7
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
8
|
-
import { Linter } from '@nx/eslint';
|
|
9
|
-
import { reactNativeApplicationGenerator } from './application';
|
|
10
|
-
|
|
11
|
-
describe('app', () => {
|
|
12
|
-
let appTree: Tree;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
appTree = createTreeWithEmptyWorkspace();
|
|
16
|
-
appTree.write('.gitignore', '');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should update configuration', async () => {
|
|
20
|
-
await reactNativeApplicationGenerator(appTree, {
|
|
21
|
-
name: 'my-app',
|
|
22
|
-
displayName: 'myApp',
|
|
23
|
-
linter: Linter.EsLint,
|
|
24
|
-
e2eTestRunner: 'none',
|
|
25
|
-
install: false,
|
|
26
|
-
projectNameAndRootFormat: 'as-provided',
|
|
27
|
-
unitTestRunner: 'none',
|
|
28
|
-
bundler: 'vite',
|
|
29
|
-
});
|
|
30
|
-
const projects = getProjects(appTree);
|
|
31
|
-
|
|
32
|
-
expect(projects.get('my-app').root).toEqual('my-app');
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should update nx.json', async () => {
|
|
36
|
-
await reactNativeApplicationGenerator(appTree, {
|
|
37
|
-
name: 'my-app',
|
|
38
|
-
displayName: 'myApp',
|
|
39
|
-
tags: 'one,two',
|
|
40
|
-
linter: Linter.EsLint,
|
|
41
|
-
e2eTestRunner: 'none',
|
|
42
|
-
install: false,
|
|
43
|
-
projectNameAndRootFormat: 'as-provided',
|
|
44
|
-
unitTestRunner: 'none',
|
|
45
|
-
bundler: 'vite',
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const projectConfiguration = readProjectConfiguration(appTree, 'my-app');
|
|
49
|
-
expect(projectConfiguration).toMatchObject({
|
|
50
|
-
tags: ['one', 'two'],
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('should generate files', async () => {
|
|
55
|
-
await reactNativeApplicationGenerator(appTree, {
|
|
56
|
-
name: 'my-app',
|
|
57
|
-
displayName: 'myApp',
|
|
58
|
-
linter: Linter.EsLint,
|
|
59
|
-
e2eTestRunner: 'none',
|
|
60
|
-
install: false,
|
|
61
|
-
projectNameAndRootFormat: 'as-provided',
|
|
62
|
-
unitTestRunner: 'jest',
|
|
63
|
-
bundler: 'vite',
|
|
64
|
-
});
|
|
65
|
-
expect(appTree.exists('my-app/src/app/App.tsx')).toBeTruthy();
|
|
66
|
-
expect(appTree.exists('my-app/src/main.tsx')).toBeTruthy();
|
|
67
|
-
|
|
68
|
-
const tsconfig = readJson(appTree, 'my-app/tsconfig.json');
|
|
69
|
-
expect(tsconfig.extends).toEqual('../tsconfig.base.json');
|
|
70
|
-
|
|
71
|
-
expect(appTree.exists('my-app/.eslintrc.json')).toBe(true);
|
|
72
|
-
expect(appTree.read('my-app/jest.config.ts', 'utf-8'))
|
|
73
|
-
.toMatchInlineSnapshot(`
|
|
74
|
-
"module.exports = {
|
|
75
|
-
displayName: 'my-app',
|
|
76
|
-
preset: 'react-native',
|
|
77
|
-
resolver: '@nx/jest/plugins/resolver',
|
|
78
|
-
moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
|
|
79
|
-
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
|
|
80
|
-
moduleNameMapper: {
|
|
81
|
-
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
|
82
|
-
},
|
|
83
|
-
transform: {
|
|
84
|
-
'^.+.(js|ts|tsx)$': [
|
|
85
|
-
'babel-jest',
|
|
86
|
-
{
|
|
87
|
-
configFile: __dirname + '/.babelrc.js',
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
'^.+.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(
|
|
91
|
-
'react-native/jest/assetFileTransformer.js'
|
|
92
|
-
),
|
|
93
|
-
},
|
|
94
|
-
coverageDirectory: '../coverage/my-app',
|
|
95
|
-
};
|
|
96
|
-
"
|
|
97
|
-
`);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should generate targets', async () => {
|
|
101
|
-
await reactNativeApplicationGenerator(appTree, {
|
|
102
|
-
name: 'my-app',
|
|
103
|
-
displayName: 'myApp',
|
|
104
|
-
linter: Linter.EsLint,
|
|
105
|
-
e2eTestRunner: 'none',
|
|
106
|
-
install: false,
|
|
107
|
-
projectNameAndRootFormat: 'as-provided',
|
|
108
|
-
unitTestRunner: 'jest',
|
|
109
|
-
bundler: 'vite',
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
expect(appTree.exists('my-app/jest.config.ts')).toBeTruthy();
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
|
|
116
|
-
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
117
|
-
|
|
118
|
-
await reactNativeApplicationGenerator(appTree, {
|
|
119
|
-
name: 'my-app',
|
|
120
|
-
displayName: 'myApp',
|
|
121
|
-
linter: Linter.EsLint,
|
|
122
|
-
e2eTestRunner: 'none',
|
|
123
|
-
install: false,
|
|
124
|
-
projectNameAndRootFormat: 'as-provided',
|
|
125
|
-
unitTestRunner: 'none',
|
|
126
|
-
bundler: 'vite',
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const tsconfig = readJson(appTree, 'my-app/tsconfig.json');
|
|
130
|
-
expect(tsconfig.extends).toEqual('../tsconfig.json');
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
describe('detox', () => {
|
|
134
|
-
it('should create e2e app with directory', async () => {
|
|
135
|
-
await reactNativeApplicationGenerator(appTree, {
|
|
136
|
-
name: 'my-app',
|
|
137
|
-
directory: 'my-dir',
|
|
138
|
-
linter: Linter.EsLint,
|
|
139
|
-
e2eTestRunner: 'detox',
|
|
140
|
-
install: false,
|
|
141
|
-
projectNameAndRootFormat: 'as-provided',
|
|
142
|
-
bundler: 'vite',
|
|
143
|
-
unitTestRunner: 'none',
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const projects = getProjects(appTree);
|
|
147
|
-
expect(projects.get('my-app').root).toEqual('my-dir');
|
|
148
|
-
|
|
149
|
-
expect(appTree.exists('my-dir-e2e/.detoxrc.json')).toBeTruthy();
|
|
150
|
-
const detoxrc = appTree.read('my-dir-e2e/.detoxrc.json', 'utf-8');
|
|
151
|
-
// Strip trailing commas
|
|
152
|
-
const detoxrcJson = JSON.parse(
|
|
153
|
-
detoxrc.replace(/(?<=(true|false|null|["\d}\]])\s*),(?=\s*[}\]])/g, '')
|
|
154
|
-
);
|
|
155
|
-
expect(detoxrcJson.apps).toEqual({
|
|
156
|
-
'android.debug': {
|
|
157
|
-
binaryPath:
|
|
158
|
-
'../my-dir/android/app/build/outputs/apk/debug/app-debug.apk',
|
|
159
|
-
build:
|
|
160
|
-
'cd ../my-dir/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
|
|
161
|
-
type: 'android.apk',
|
|
162
|
-
},
|
|
163
|
-
'android.release': {
|
|
164
|
-
binaryPath:
|
|
165
|
-
'../my-dir/android/app/build/outputs/apk/release/app-release.apk',
|
|
166
|
-
build:
|
|
167
|
-
'cd ../my-dir/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
|
|
168
|
-
type: 'android.apk',
|
|
169
|
-
},
|
|
170
|
-
'ios.debug': {
|
|
171
|
-
binaryPath:
|
|
172
|
-
'../my-dir/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app',
|
|
173
|
-
build:
|
|
174
|
-
"cd ../my-dir/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
|
175
|
-
type: 'ios.app',
|
|
176
|
-
},
|
|
177
|
-
'ios.release': {
|
|
178
|
-
binaryPath:
|
|
179
|
-
'../my-dir/ios/build/Build/Products/Release-iphonesimulator/MyApp.app',
|
|
180
|
-
build:
|
|
181
|
-
"cd ../my-dir/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
|
182
|
-
type: 'ios.app',
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('should create e2e app without directory', async () => {
|
|
188
|
-
await reactNativeApplicationGenerator(appTree, {
|
|
189
|
-
name: 'my-app',
|
|
190
|
-
linter: Linter.EsLint,
|
|
191
|
-
e2eTestRunner: 'detox',
|
|
192
|
-
install: false,
|
|
193
|
-
projectNameAndRootFormat: 'as-provided',
|
|
194
|
-
bundler: 'vite',
|
|
195
|
-
unitTestRunner: 'none',
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
const projects = getProjects(appTree);
|
|
199
|
-
expect(projects.get('my-app').root).toEqual('my-app');
|
|
200
|
-
|
|
201
|
-
const detoxrc = appTree.read('my-app-e2e/.detoxrc.json', 'utf-8');
|
|
202
|
-
// Strip trailing commas
|
|
203
|
-
const detoxrcJson = JSON.parse(
|
|
204
|
-
detoxrc.replace(/(?<=(true|false|null|["\d}\]])\s*),(?=\s*[}\]])/g, '')
|
|
205
|
-
);
|
|
206
|
-
expect(detoxrcJson.apps).toEqual({
|
|
207
|
-
'android.debug': {
|
|
208
|
-
binaryPath:
|
|
209
|
-
'../my-app/android/app/build/outputs/apk/debug/app-debug.apk',
|
|
210
|
-
build:
|
|
211
|
-
'cd ../my-app/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
|
|
212
|
-
type: 'android.apk',
|
|
213
|
-
},
|
|
214
|
-
'android.release': {
|
|
215
|
-
binaryPath:
|
|
216
|
-
'../my-app/android/app/build/outputs/apk/release/app-release.apk',
|
|
217
|
-
build:
|
|
218
|
-
'cd ../my-app/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
|
|
219
|
-
type: 'android.apk',
|
|
220
|
-
},
|
|
221
|
-
'ios.debug': {
|
|
222
|
-
binaryPath:
|
|
223
|
-
'../my-app/ios/build/Build/Products/Debug-iphonesimulator/MyApp.app',
|
|
224
|
-
build:
|
|
225
|
-
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
|
226
|
-
type: 'ios.app',
|
|
227
|
-
},
|
|
228
|
-
'ios.release': {
|
|
229
|
-
binaryPath:
|
|
230
|
-
'../my-app/ios/build/Build/Products/Release-iphonesimulator/MyApp.app',
|
|
231
|
-
build:
|
|
232
|
-
"cd ../my-app/ios && xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14' -derivedDataPath ./build -quiet",
|
|
233
|
-
type: 'ios.app',
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
describe('--skipPackageJson', () => {
|
|
240
|
-
it('should not add or update dependencies when true', async () => {
|
|
241
|
-
const packageJsonBefore = readJson(appTree, 'package.json');
|
|
242
|
-
|
|
243
|
-
await reactNativeApplicationGenerator(appTree, {
|
|
244
|
-
name: 'my-app',
|
|
245
|
-
displayName: 'myApp',
|
|
246
|
-
linter: Linter.EsLint,
|
|
247
|
-
e2eTestRunner: 'none',
|
|
248
|
-
install: false,
|
|
249
|
-
skipPackageJson: true,
|
|
250
|
-
projectNameAndRootFormat: 'as-provided',
|
|
251
|
-
unitTestRunner: 'none',
|
|
252
|
-
bundler: 'webpack',
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
expect(readJson(appTree, 'package.json')).toEqual(packageJsonBefore);
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-native/extend-expect';
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
|
2
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
-
import { Linter } from '@nx/eslint';
|
|
4
|
-
import { Schema } from '../schema';
|
|
5
|
-
import { normalizeOptions } from './normalize-options';
|
|
6
|
-
|
|
7
|
-
describe('Normalize Options', () => {
|
|
8
|
-
let appTree: Tree;
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
appTree = createTreeWithEmptyWorkspace();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should normalize options with name in kebab case', async () => {
|
|
15
|
-
const schema: Schema = {
|
|
16
|
-
name: 'my-app',
|
|
17
|
-
linter: Linter.EsLint,
|
|
18
|
-
e2eTestRunner: 'none',
|
|
19
|
-
install: false,
|
|
20
|
-
projectNameAndRootFormat: 'as-provided',
|
|
21
|
-
unitTestRunner: 'none',
|
|
22
|
-
bundler: 'vite',
|
|
23
|
-
};
|
|
24
|
-
const options = await normalizeOptions(appTree, schema);
|
|
25
|
-
expect(options).toEqual({
|
|
26
|
-
addPlugin: true,
|
|
27
|
-
androidProjectRoot: 'my-app/android',
|
|
28
|
-
appProjectRoot: 'my-app',
|
|
29
|
-
fileName: 'my-app',
|
|
30
|
-
className: 'MyApp',
|
|
31
|
-
displayName: 'MyApp',
|
|
32
|
-
iosProjectRoot: 'my-app/ios',
|
|
33
|
-
lowerCaseName: 'myapp',
|
|
34
|
-
name: 'my-app',
|
|
35
|
-
parsedTags: [],
|
|
36
|
-
projectName: 'my-app',
|
|
37
|
-
projectNameAndRootFormat: 'as-provided',
|
|
38
|
-
linter: Linter.EsLint,
|
|
39
|
-
entryFile: 'src/main.tsx',
|
|
40
|
-
e2eTestRunner: 'none',
|
|
41
|
-
unitTestRunner: 'none',
|
|
42
|
-
install: false,
|
|
43
|
-
bundler: 'vite',
|
|
44
|
-
rootProject: false,
|
|
45
|
-
e2eProjectName: 'my-app-e2e',
|
|
46
|
-
e2eProjectRoot: 'my-app-e2e',
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should normalize options with name in camel case', async () => {
|
|
51
|
-
const schema: Schema = {
|
|
52
|
-
name: 'myApp',
|
|
53
|
-
e2eTestRunner: 'none',
|
|
54
|
-
install: false,
|
|
55
|
-
projectNameAndRootFormat: 'as-provided',
|
|
56
|
-
linter: Linter.None,
|
|
57
|
-
unitTestRunner: 'none',
|
|
58
|
-
bundler: 'vite',
|
|
59
|
-
};
|
|
60
|
-
const options = await normalizeOptions(appTree, schema);
|
|
61
|
-
expect(options).toEqual({
|
|
62
|
-
addPlugin: true,
|
|
63
|
-
androidProjectRoot: 'myApp/android',
|
|
64
|
-
appProjectRoot: 'myApp',
|
|
65
|
-
className: 'MyApp',
|
|
66
|
-
fileName: 'my-app',
|
|
67
|
-
displayName: 'MyApp',
|
|
68
|
-
iosProjectRoot: 'myApp/ios',
|
|
69
|
-
lowerCaseName: 'myapp',
|
|
70
|
-
name: 'myApp',
|
|
71
|
-
parsedTags: [],
|
|
72
|
-
projectName: 'myApp',
|
|
73
|
-
projectNameAndRootFormat: 'as-provided',
|
|
74
|
-
entryFile: 'src/main.tsx',
|
|
75
|
-
e2eTestRunner: 'none',
|
|
76
|
-
unitTestRunner: 'none',
|
|
77
|
-
install: false,
|
|
78
|
-
bundler: 'vite',
|
|
79
|
-
linter: Linter.None,
|
|
80
|
-
rootProject: false,
|
|
81
|
-
e2eProjectName: 'my-app-e2e',
|
|
82
|
-
e2eProjectRoot: 'myApp-e2e',
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('should normalize options with directory', async () => {
|
|
87
|
-
const schema: Schema = {
|
|
88
|
-
name: 'my-app',
|
|
89
|
-
directory: 'directory/my-app',
|
|
90
|
-
e2eTestRunner: 'none',
|
|
91
|
-
install: false,
|
|
92
|
-
projectNameAndRootFormat: 'as-provided',
|
|
93
|
-
linter: Linter.None,
|
|
94
|
-
unitTestRunner: 'none',
|
|
95
|
-
bundler: 'vite',
|
|
96
|
-
};
|
|
97
|
-
const options = await normalizeOptions(appTree, schema);
|
|
98
|
-
expect(options).toEqual({
|
|
99
|
-
addPlugin: true,
|
|
100
|
-
androidProjectRoot: 'directory/my-app/android',
|
|
101
|
-
appProjectRoot: 'directory/my-app',
|
|
102
|
-
className: 'MyApp',
|
|
103
|
-
fileName: 'my-app',
|
|
104
|
-
displayName: 'MyApp',
|
|
105
|
-
iosProjectRoot: 'directory/my-app/ios',
|
|
106
|
-
lowerCaseName: 'myapp',
|
|
107
|
-
name: 'my-app',
|
|
108
|
-
directory: 'directory/my-app',
|
|
109
|
-
parsedTags: [],
|
|
110
|
-
projectName: 'my-app',
|
|
111
|
-
projectNameAndRootFormat: 'as-provided',
|
|
112
|
-
entryFile: 'src/main.tsx',
|
|
113
|
-
e2eTestRunner: 'none',
|
|
114
|
-
unitTestRunner: 'none',
|
|
115
|
-
install: false,
|
|
116
|
-
bundler: 'vite',
|
|
117
|
-
linter: Linter.None,
|
|
118
|
-
rootProject: false,
|
|
119
|
-
e2eProjectName: 'my-app-e2e',
|
|
120
|
-
e2eProjectRoot: 'directory/my-app-e2e',
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should normalize options that has directory in its name', async () => {
|
|
125
|
-
const schema: Schema = {
|
|
126
|
-
name: 'directory/my-app',
|
|
127
|
-
e2eTestRunner: 'none',
|
|
128
|
-
install: false,
|
|
129
|
-
projectNameAndRootFormat: 'as-provided',
|
|
130
|
-
linter: Linter.None,
|
|
131
|
-
unitTestRunner: 'none',
|
|
132
|
-
bundler: 'vite',
|
|
133
|
-
};
|
|
134
|
-
const options = await normalizeOptions(appTree, schema);
|
|
135
|
-
expect(options).toEqual({
|
|
136
|
-
addPlugin: true,
|
|
137
|
-
androidProjectRoot: 'directory/my-app/android',
|
|
138
|
-
appProjectRoot: 'directory/my-app',
|
|
139
|
-
className: 'DirectoryMyApp',
|
|
140
|
-
fileName: 'directory/my-app',
|
|
141
|
-
displayName: 'DirectoryMyApp',
|
|
142
|
-
iosProjectRoot: 'directory/my-app/ios',
|
|
143
|
-
lowerCaseName: 'directorymyapp',
|
|
144
|
-
name: 'my-app',
|
|
145
|
-
parsedTags: [],
|
|
146
|
-
projectName: 'my-app',
|
|
147
|
-
projectNameAndRootFormat: 'as-provided',
|
|
148
|
-
entryFile: 'src/main.tsx',
|
|
149
|
-
e2eTestRunner: 'none',
|
|
150
|
-
unitTestRunner: 'none',
|
|
151
|
-
install: false,
|
|
152
|
-
bundler: 'vite',
|
|
153
|
-
linter: Linter.None,
|
|
154
|
-
rootProject: false,
|
|
155
|
-
e2eProjectName: 'directory/my-app-e2e',
|
|
156
|
-
e2eProjectRoot: 'directory/my-app-e2e',
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('should normalize options with display name', async () => {
|
|
161
|
-
const schema: Schema = {
|
|
162
|
-
name: 'my-app',
|
|
163
|
-
displayName: 'My App',
|
|
164
|
-
e2eTestRunner: 'none',
|
|
165
|
-
install: false,
|
|
166
|
-
projectNameAndRootFormat: 'as-provided',
|
|
167
|
-
linter: Linter.None,
|
|
168
|
-
unitTestRunner: 'none',
|
|
169
|
-
bundler: 'vite',
|
|
170
|
-
};
|
|
171
|
-
const options = await normalizeOptions(appTree, schema);
|
|
172
|
-
expect(options).toEqual({
|
|
173
|
-
addPlugin: true,
|
|
174
|
-
androidProjectRoot: 'my-app/android',
|
|
175
|
-
appProjectRoot: 'my-app',
|
|
176
|
-
className: 'MyApp',
|
|
177
|
-
fileName: 'my-app',
|
|
178
|
-
displayName: 'My App',
|
|
179
|
-
iosProjectRoot: 'my-app/ios',
|
|
180
|
-
lowerCaseName: 'myapp',
|
|
181
|
-
name: 'my-app',
|
|
182
|
-
parsedTags: [],
|
|
183
|
-
projectName: 'my-app',
|
|
184
|
-
projectNameAndRootFormat: 'as-provided',
|
|
185
|
-
entryFile: 'src/main.tsx',
|
|
186
|
-
e2eTestRunner: 'none',
|
|
187
|
-
unitTestRunner: 'none',
|
|
188
|
-
install: false,
|
|
189
|
-
bundler: 'vite',
|
|
190
|
-
linter: Linter.None,
|
|
191
|
-
rootProject: false,
|
|
192
|
-
e2eProjectName: 'my-app-e2e',
|
|
193
|
-
e2eProjectRoot: 'my-app-e2e',
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
});
|