@nx/expo 16.8.0-beta.4 → 16.8.0-beta.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.
Files changed (46) hide show
  1. package/package.json +10 -10
  2. package/plugins/metro-resolver.js +4 -5
  3. package/plugins/with-nx-metro.js +23 -27
  4. package/plugins/with-nx-webpack.js +34 -38
  5. package/src/executors/build/build.impl.js +21 -24
  6. package/src/executors/build-list/build-list.impl.js +14 -17
  7. package/src/executors/download/download.impl.js +46 -48
  8. package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -7
  9. package/src/executors/export/export.impl.js +12 -15
  10. package/src/executors/install/install.impl.js +13 -16
  11. package/src/executors/prebuild/prebuild.impl.js +17 -20
  12. package/src/executors/run/run.impl.js +25 -28
  13. package/src/executors/start/start.impl.js +15 -18
  14. package/src/executors/submit/submit.impl.js +10 -13
  15. package/src/executors/sync-deps/sync-deps.impl.js +32 -37
  16. package/src/executors/update/update.impl.js +13 -16
  17. package/src/generators/application/application.js +23 -21
  18. package/src/generators/application/lib/add-detox.js +16 -7
  19. package/src/generators/application/lib/add-project.js +1 -1
  20. package/src/generators/application/lib/create-application-files.js +6 -2
  21. package/src/generators/application/lib/normalize-options.js +24 -17
  22. package/src/generators/component/component.js +11 -11
  23. package/src/generators/component/lib/normalize-options.js +36 -37
  24. package/src/generators/init/init.js +27 -24
  25. package/src/generators/init/lib/add-git-ignore-entry.js +1 -2
  26. package/src/generators/library/lib/normalize-options.js +23 -20
  27. package/src/generators/library/library.js +95 -79
  28. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js +18 -22
  29. package/src/migrations/update-14-1-2/add-eject-target-14-1-2.js +11 -15
  30. package/src/migrations/update-14-4-3/add-eas-build-target.js +26 -30
  31. package/src/migrations/update-14-5-1/add-eas-update-target.js +12 -16
  32. package/src/migrations/update-15-0-3/add-new-expo-cli-targets.js +44 -48
  33. package/src/migrations/update-15-0-3/change-jest-preset.js +17 -21
  34. package/src/migrations/update-15-8-3/change-webpack-to-metro.js +18 -23
  35. package/src/migrations/update-16-0-0/add-jest-expo.js +15 -19
  36. package/src/migrations/update-16-0-0/remove-deprecated-targets.js +23 -27
  37. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
  38. package/src/migrations/update-16-1-4/add-detox-app-json.js +20 -24
  39. package/src/migrations/update-16-1-4/update-eas-scripts.js +9 -7
  40. package/src/migrations/update-16-2-2/add-submit-target.js +12 -16
  41. package/src/migrations/update-16-6-0/add-depends-on.js +11 -15
  42. package/src/migrations/update-16-6-0/update-metro-config.js +11 -15
  43. package/src/utils/add-jest.js +19 -22
  44. package/src/utils/add-linting.js +27 -30
  45. package/src/utils/find-all-npm-dependencies.js +1 -2
  46. package/src/utils/symlink-task.js +1 -1
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const path_1 = require("path");
6
5
  const child_process_1 = require("child_process");
@@ -10,35 +9,33 @@ const prebuild_impl_1 = require("../prebuild/prebuild.impl");
10
9
  const pod_install_task_1 = require("../../utils/pod-install-task");
11
10
  const install_impl_1 = require("../install/install.impl");
12
11
  let childProcess;
13
- function runExecutor(options, context) {
14
- return tslib_1.__asyncGenerator(this, arguments, function* runExecutor_1() {
15
- if ((0, os_1.platform)() !== 'darwin' && options.platform === 'ios') {
16
- throw new Error(`The run-ios build requires Mac to run`);
17
- }
18
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
19
- if (!(0, fs_extra_1.existsSync)((0, path_1.join)(context.root, projectRoot, options.platform))) {
20
- yield tslib_1.__await((0, prebuild_impl_1.prebuildAsync)(context.root, projectRoot, {
21
- install: options.install,
22
- platform: options.platform,
23
- clean: options.clean,
24
- }));
25
- }
26
- if (options.install) {
27
- yield tslib_1.__await((0, install_impl_1.installAsync)(context.root, {}));
28
- if (options.platform === 'ios') {
29
- (0, pod_install_task_1.podInstall)((0, path_1.join)(context.root, projectRoot, 'ios'));
30
- }
31
- }
32
- try {
33
- yield tslib_1.__await(runCliRun(context.root, projectRoot, options));
34
- yield yield tslib_1.__await({ success: true });
12
+ async function* runExecutor(options, context) {
13
+ if ((0, os_1.platform)() !== 'darwin' && options.platform === 'ios') {
14
+ throw new Error(`The run-ios build requires Mac to run`);
15
+ }
16
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
17
+ if (!(0, fs_extra_1.existsSync)((0, path_1.join)(context.root, projectRoot, options.platform))) {
18
+ await (0, prebuild_impl_1.prebuildAsync)(context.root, projectRoot, {
19
+ install: options.install,
20
+ platform: options.platform,
21
+ clean: options.clean,
22
+ });
23
+ }
24
+ if (options.install) {
25
+ await (0, install_impl_1.installAsync)(context.root, {});
26
+ if (options.platform === 'ios') {
27
+ (0, pod_install_task_1.podInstall)((0, path_1.join)(context.root, projectRoot, 'ios'));
35
28
  }
36
- finally {
37
- if (childProcess) {
38
- childProcess.kill();
39
- }
29
+ }
30
+ try {
31
+ await runCliRun(context.root, projectRoot, options);
32
+ yield { success: true };
33
+ }
34
+ finally {
35
+ if (childProcess) {
36
+ childProcess.kill();
40
37
  }
41
- });
38
+ }
42
39
  }
43
40
  exports.default = runExecutor;
44
41
  function runCliRun(workspaceRoot, projectRoot, options) {
@@ -1,29 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const chalk = require("chalk");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const child_process_1 = require("child_process");
7
6
  const path_1 = require("path");
8
7
  let childProcess;
9
- function startExecutor(options, context) {
10
- return tslib_1.__asyncGenerator(this, arguments, function* startExecutor_1() {
11
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
12
- try {
13
- const baseUrl = `http://localhost:${options.port}`;
14
- devkit_1.logger.info(chalk.cyan(`Packager is ready at ${baseUrl}`));
15
- yield tslib_1.__await(startAsync(context.root, projectRoot, options));
16
- yield yield tslib_1.__await({
17
- baseUrl,
18
- success: true,
19
- });
8
+ async function* startExecutor(options, context) {
9
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
10
+ try {
11
+ const baseUrl = `http://localhost:${options.port}`;
12
+ devkit_1.logger.info(chalk.cyan(`Packager is ready at ${baseUrl}`));
13
+ await startAsync(context.root, projectRoot, options);
14
+ yield {
15
+ baseUrl,
16
+ success: true,
17
+ };
18
+ }
19
+ finally {
20
+ if (childProcess) {
21
+ childProcess.kill();
20
22
  }
21
- finally {
22
- if (childProcess) {
23
- childProcess.kill();
24
- }
25
- }
26
- });
23
+ }
27
24
  }
28
25
  exports.default = startExecutor;
29
26
  function startAsync(workspaceRoot, projectRoot, options) {
@@ -1,23 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const path_1 = require("path");
6
5
  const child_process_1 = require("child_process");
7
6
  let childProcess;
8
- function submitExecutor(options, context) {
9
- return tslib_1.__asyncGenerator(this, arguments, function* submitExecutor_1() {
10
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
11
- try {
12
- yield tslib_1.__await(runCliSubmit(context.root, projectRoot, options));
13
- yield yield tslib_1.__await({ success: true });
7
+ async function* submitExecutor(options, context) {
8
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
9
+ try {
10
+ await runCliSubmit(context.root, projectRoot, options);
11
+ yield { success: true };
12
+ }
13
+ finally {
14
+ if (childProcess) {
15
+ childProcess.kill();
14
16
  }
15
- finally {
16
- if (childProcess) {
17
- childProcess.kill();
18
- }
19
- }
20
- });
17
+ }
21
18
  }
22
19
  exports.default = submitExecutor;
23
20
  function runCliSubmit(workspaceRoot, projectRoot, options) {
@@ -1,52 +1,47 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.displayNewlyAddedDepsMessage = exports.syncDeps = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const path_1 = require("path");
6
5
  const chalk = require("chalk");
7
6
  const devkit_1 = require("@nx/devkit");
8
7
  const find_all_npm_dependencies_1 = require("../../utils/find-all-npm-dependencies");
9
- function syncDepsExecutor(options, context) {
10
- return tslib_1.__asyncGenerator(this, arguments, function* syncDepsExecutor_1() {
11
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
12
- displayNewlyAddedDepsMessage(context.projectName, yield tslib_1.__await(syncDeps(context.projectName, projectRoot, context.root, context.projectGraph, typeof options.include === 'string'
13
- ? options.include.split(',')
14
- : options.include, typeof options.exclude === 'string'
15
- ? options.exclude.split(',')
16
- : options.exclude)));
17
- yield yield tslib_1.__await({ success: true });
18
- });
8
+ async function* syncDepsExecutor(options, context) {
9
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
10
+ displayNewlyAddedDepsMessage(context.projectName, await syncDeps(context.projectName, projectRoot, context.root, context.projectGraph, typeof options.include === 'string'
11
+ ? options.include.split(',')
12
+ : options.include, typeof options.exclude === 'string'
13
+ ? options.exclude.split(',')
14
+ : options.exclude));
15
+ yield { success: true };
19
16
  }
20
17
  exports.default = syncDepsExecutor;
21
- function syncDeps(projectName, projectRoot, workspaceRoot, projectGraph, include = [], exclude = []) {
22
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
- let npmDeps = (0, find_all_npm_dependencies_1.findAllNpmDependencies)(projectGraph, projectName);
24
- const packageJsonPath = (0, path_1.join)(workspaceRoot, projectRoot, 'package.json');
25
- const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
26
- const newDeps = [];
27
- let updated = false;
28
- if (!packageJson.dependencies) {
29
- packageJson.dependencies = {};
18
+ async function syncDeps(projectName, projectRoot, workspaceRoot, projectGraph, include = [], exclude = []) {
19
+ let npmDeps = (0, find_all_npm_dependencies_1.findAllNpmDependencies)(projectGraph, projectName);
20
+ const packageJsonPath = (0, path_1.join)(workspaceRoot, projectRoot, 'package.json');
21
+ const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
22
+ const newDeps = [];
23
+ let updated = false;
24
+ if (!packageJson.dependencies) {
25
+ packageJson.dependencies = {};
26
+ updated = true;
27
+ }
28
+ if (include && include.length) {
29
+ npmDeps.push(...include);
30
+ }
31
+ if (exclude && exclude.length) {
32
+ npmDeps = npmDeps.filter((dep) => !exclude.includes(dep));
33
+ }
34
+ npmDeps.forEach((dep) => {
35
+ if (!packageJson.dependencies[dep]) {
36
+ packageJson.dependencies[dep] = '*';
37
+ newDeps.push(dep);
30
38
  updated = true;
31
39
  }
32
- if (include && include.length) {
33
- npmDeps.push(...include);
34
- }
35
- if (exclude && exclude.length) {
36
- npmDeps = npmDeps.filter((dep) => !exclude.includes(dep));
37
- }
38
- npmDeps.forEach((dep) => {
39
- if (!packageJson.dependencies[dep]) {
40
- packageJson.dependencies[dep] = '*';
41
- newDeps.push(dep);
42
- updated = true;
43
- }
44
- });
45
- if (updated) {
46
- (0, devkit_1.writeJsonFile)(packageJsonPath, packageJson);
47
- }
48
- return newDeps;
49
40
  });
41
+ if (updated) {
42
+ (0, devkit_1.writeJsonFile)(packageJsonPath, packageJson);
43
+ }
44
+ return newDeps;
50
45
  }
51
46
  exports.syncDeps = syncDeps;
52
47
  function displayNewlyAddedDepsMessage(projectName, deps) {
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const path_1 = require("path");
6
5
  const child_process_1 = require("child_process");
@@ -8,22 +7,20 @@ const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-s
8
7
  const sync_deps_impl_1 = require("../sync-deps/sync-deps.impl");
9
8
  const install_impl_1 = require("../install/install.impl");
10
9
  let childProcess;
11
- function buildExecutor(options, context) {
12
- return tslib_1.__asyncGenerator(this, arguments, function* buildExecutor_1() {
13
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
14
- yield tslib_1.__await((0, install_impl_1.installAsync)(context.root, { packages: ['expo-updates'] }));
15
- (0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, yield tslib_1.__await((0, sync_deps_impl_1.syncDeps)(context.projectName, projectRoot, context.root, context.projectGraph, ['expo-updates'])));
16
- (0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
17
- try {
18
- yield tslib_1.__await(runCliUpdate(context.root, projectRoot, options));
19
- yield yield tslib_1.__await({ success: true });
10
+ async function* buildExecutor(options, context) {
11
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
12
+ await (0, install_impl_1.installAsync)(context.root, { packages: ['expo-updates'] });
13
+ (0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, await (0, sync_deps_impl_1.syncDeps)(context.projectName, projectRoot, context.root, context.projectGraph, ['expo-updates']));
14
+ (0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
15
+ try {
16
+ await runCliUpdate(context.root, projectRoot, options);
17
+ yield { success: true };
18
+ }
19
+ finally {
20
+ if (childProcess) {
21
+ childProcess.kill();
20
22
  }
21
- finally {
22
- if (childProcess) {
23
- childProcess.kill();
24
- }
25
- }
26
- });
23
+ }
27
24
  }
28
25
  exports.default = buildExecutor;
29
26
  function runCliUpdate(workspaceRoot, projectRoot, options) {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expoApplicationSchematic = exports.expoApplicationGeneratorInternal = exports.expoApplicationGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const symlink_task_1 = require("../../utils/symlink-task");
7
6
  const add_linting_1 = require("../../utils/add-linting");
@@ -12,30 +11,33 @@ const add_project_1 = require("./lib/add-project");
12
11
  const create_application_files_1 = require("./lib/create-application-files");
13
12
  const add_eas_scripts_1 = require("./lib/add-eas-scripts");
14
13
  const add_detox_1 = require("./lib/add-detox");
15
- function expoApplicationGenerator(host, schema) {
16
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
- return yield expoApplicationGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
14
+ async function expoApplicationGenerator(host, schema) {
15
+ return await expoApplicationGeneratorInternal(host, {
16
+ projectNameAndRootFormat: 'derived',
17
+ ...schema,
18
18
  });
19
19
  }
20
20
  exports.expoApplicationGenerator = expoApplicationGenerator;
21
- function expoApplicationGeneratorInternal(host, schema) {
22
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
- const options = yield (0, normalize_options_1.normalizeOptions)(host, schema);
24
- (0, create_application_files_1.createApplicationFiles)(host, options);
25
- (0, add_project_1.addProject)(host, options);
26
- const initTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
27
- const lintTask = yield (0, add_linting_1.addLinting)(host, Object.assign(Object.assign({}, options), { projectRoot: options.appProjectRoot, tsConfigPaths: [
28
- (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
29
- ] }));
30
- const jestTask = yield (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson);
31
- const detoxTask = yield (0, add_detox_1.addDetox)(host, options);
32
- const symlinkTask = (0, symlink_task_1.runSymlink)(host.root, options.appProjectRoot);
33
- (0, add_eas_scripts_1.addEasScripts)(host);
34
- if (!options.skipFormat) {
35
- yield (0, devkit_1.formatFiles)(host);
36
- }
37
- return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask);
21
+ async function expoApplicationGeneratorInternal(host, schema) {
22
+ const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
23
+ (0, create_application_files_1.createApplicationFiles)(host, options);
24
+ (0, add_project_1.addProject)(host, options);
25
+ const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
26
+ const lintTask = await (0, add_linting_1.addLinting)(host, {
27
+ ...options,
28
+ projectRoot: options.appProjectRoot,
29
+ tsConfigPaths: [
30
+ (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
31
+ ],
38
32
  });
33
+ const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson);
34
+ const detoxTask = await (0, add_detox_1.addDetox)(host, options);
35
+ const symlinkTask = (0, symlink_task_1.runSymlink)(host.root, options.appProjectRoot);
36
+ (0, add_eas_scripts_1.addEasScripts)(host);
37
+ if (!options.skipFormat) {
38
+ await (0, devkit_1.formatFiles)(host);
39
+ }
40
+ return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask);
39
41
  }
40
42
  exports.expoApplicationGeneratorInternal = expoApplicationGeneratorInternal;
41
43
  exports.default = expoApplicationGenerator;
@@ -1,15 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addDetox = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const detox_1 = require("@nx/detox");
6
5
  const linter_1 = require("@nx/linter");
7
- function addDetox(host, options) {
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- if ((options === null || options === void 0 ? void 0 : options.e2eTestRunner) !== 'detox') {
10
- return () => { };
11
- }
12
- return (0, detox_1.detoxApplicationGenerator)(host, Object.assign(Object.assign({}, options), { linter: linter_1.Linter.EsLint, e2eName: `${options.projectName}-e2e`, e2eDirectory: `${options.appProjectRoot}-e2e`, projectNameAndRootFormat: 'as-provided', appProject: options.projectName, appDisplayName: options.displayName, appName: options.name, framework: 'expo', setParserOptionsProject: options.setParserOptionsProject, skipFormat: true }));
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: linter_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: 'expo',
20
+ setParserOptionsProject: options.setParserOptionsProject,
21
+ skipFormat: true,
13
22
  });
14
23
  }
15
24
  exports.addDetox = addDetox;
@@ -7,7 +7,7 @@ function addProject(host, options) {
7
7
  root: options.appProjectRoot,
8
8
  sourceRoot: `${options.appProjectRoot}/src`,
9
9
  projectType: 'application',
10
- targets: Object.assign({}, getTargets(options)),
10
+ targets: { ...getTargets(options) },
11
11
  tags: options.parsedTags,
12
12
  };
13
13
  (0, devkit_1.addProjectConfiguration)(host, options.projectName, projectConfiguration, options.standaloneConfig);
@@ -12,9 +12,13 @@ function createApplicationFiles(host, options) {
12
12
  };
13
13
  const packageManager = (0, devkit_1.detectPackageManager)(host.root);
14
14
  const packageLockFile = packageManagerLockFile[packageManager];
15
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files'), options.appProjectRoot, Object.assign(Object.assign({}, options), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot), packageManager,
15
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files'), options.appProjectRoot, {
16
+ ...options,
17
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
18
+ packageManager,
16
19
  packageLockFile,
17
- easCliVersion: versions_1.easCliVersion }));
20
+ easCliVersion: versions_1.easCliVersion,
21
+ });
18
22
  if (options.unitTestRunner === 'none') {
19
23
  host.delete((0, path_1.join)(options.appProjectRoot, `App.spec.tsx`));
20
24
  }
@@ -1,25 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
7
- function normalizeOptions(host, options) {
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, projectNameAndRootFormat, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
10
- name: options.name,
11
- projectType: 'application',
12
- directory: options.directory,
13
- projectNameAndRootFormat: options.projectNameAndRootFormat,
14
- callingGenerator: '@nx/expo:application',
15
- });
16
- options.projectNameAndRootFormat = projectNameAndRootFormat;
17
- const { className } = (0, devkit_1.names)(options.name);
18
- const parsedTags = options.tags
19
- ? options.tags.split(',').map((s) => s.trim())
20
- : [];
21
- return Object.assign(Object.assign({}, options), { unitTestRunner: options.unitTestRunner || 'jest', e2eTestRunner: options.e2eTestRunner || 'detox', name: projectNames.projectSimpleName, className, lowerCaseName: className.toLowerCase(), displayName: options.displayName || className, projectName: appProjectName, appProjectRoot,
22
- parsedTags });
6
+ async function normalizeOptions(host, options) {
7
+ const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
8
+ name: options.name,
9
+ projectType: 'application',
10
+ directory: options.directory,
11
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
12
+ callingGenerator: '@nx/expo:application',
23
13
  });
14
+ options.projectNameAndRootFormat = projectNameAndRootFormat;
15
+ const { className } = (0, devkit_1.names)(options.name);
16
+ const parsedTags = options.tags
17
+ ? options.tags.split(',').map((s) => s.trim())
18
+ : [];
19
+ return {
20
+ ...options,
21
+ unitTestRunner: options.unitTestRunner || 'jest',
22
+ e2eTestRunner: options.e2eTestRunner || 'detox',
23
+ name: projectNames.projectSimpleName,
24
+ className,
25
+ lowerCaseName: className.toLowerCase(),
26
+ displayName: options.displayName || className,
27
+ projectName: appProjectName,
28
+ appProjectRoot,
29
+ parsedTags,
30
+ };
24
31
  }
25
32
  exports.normalizeOptions = normalizeOptions;
@@ -1,26 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.expoComponentSchematic = exports.expoComponentGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const ts = require("typescript");
6
5
  const devkit_1 = require("@nx/devkit");
7
6
  const normalize_options_1 = require("./lib/normalize-options");
8
7
  const add_import_1 = require("./lib/add-import");
9
8
  const path_1 = require("path");
10
- function expoComponentGenerator(host, schema) {
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const options = yield (0, normalize_options_1.normalizeOptions)(host, schema);
13
- createComponentFiles(host, options);
14
- addExportsToBarrel(host, options);
15
- if (options.skipFormat) {
16
- yield (0, devkit_1.formatFiles)(host);
17
- }
18
- });
9
+ async function expoComponentGenerator(host, schema) {
10
+ const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
11
+ createComponentFiles(host, options);
12
+ addExportsToBarrel(host, options);
13
+ if (options.skipFormat) {
14
+ await (0, devkit_1.formatFiles)(host);
15
+ }
19
16
  }
20
17
  exports.expoComponentGenerator = expoComponentGenerator;
21
18
  function createComponentFiles(host, options) {
22
19
  const componentDir = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.directory);
23
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), componentDir, Object.assign(Object.assign({}, options), { tmpl: '' }));
20
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), componentDir, {
21
+ ...options,
22
+ tmpl: '',
23
+ });
24
24
  for (const c of host.listChanges()) {
25
25
  let deleteFile = false;
26
26
  if (options.skipTests && /.*spec.tsx/.test(c.path)) {
@@ -1,46 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
- function normalizeOptions(host, options) {
7
- var _a;
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- assertValidOptions(options);
10
- const { className, fileName } = (0, devkit_1.names)(options.name);
11
- const componentFileName = options.pascalCaseFiles ? className : fileName;
12
- const project = (0, devkit_1.getProjects)(host).get(options.project);
13
- if (!project) {
14
- devkit_1.logger.error(`Cannot find the ${options.project} project. Please double check the project name.`);
15
- throw new Error();
16
- }
17
- const { sourceRoot: projectSourceRoot, projectType } = project;
18
- const directory = yield getDirectory(host, options);
19
- if (options.export && projectType === 'application') {
20
- devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
21
- }
22
- options.classComponent = (_a = options.classComponent) !== null && _a !== void 0 ? _a : false;
23
- return Object.assign(Object.assign({}, options), { directory,
24
- className, fileName: componentFileName, projectSourceRoot });
25
- });
5
+ async function normalizeOptions(host, options) {
6
+ assertValidOptions(options);
7
+ const { className, fileName } = (0, devkit_1.names)(options.name);
8
+ const componentFileName = options.pascalCaseFiles ? className : fileName;
9
+ const project = (0, devkit_1.getProjects)(host).get(options.project);
10
+ if (!project) {
11
+ devkit_1.logger.error(`Cannot find the ${options.project} project. Please double check the project name.`);
12
+ throw new Error();
13
+ }
14
+ const { sourceRoot: projectSourceRoot, projectType } = project;
15
+ const directory = await getDirectory(host, options);
16
+ if (options.export && projectType === 'application') {
17
+ devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
18
+ }
19
+ options.classComponent = options.classComponent ?? false;
20
+ return {
21
+ ...options,
22
+ directory,
23
+ className,
24
+ fileName: componentFileName,
25
+ projectSourceRoot,
26
+ };
26
27
  }
27
28
  exports.normalizeOptions = normalizeOptions;
28
- function getDirectory(host, options) {
29
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
30
- const fileName = (0, devkit_1.names)(options.name).fileName;
31
- const workspace = (0, devkit_1.getProjects)(host);
32
- let baseDir;
33
- if (options.directory) {
34
- baseDir = options.directory;
35
- }
36
- else {
37
- baseDir =
38
- workspace.get(options.project).projectType === 'application'
39
- ? 'app'
40
- : 'lib';
41
- }
42
- return options.flat ? baseDir : (0, devkit_1.joinPathFragments)(baseDir, fileName);
43
- });
29
+ async function getDirectory(host, options) {
30
+ const fileName = (0, devkit_1.names)(options.name).fileName;
31
+ const workspace = (0, devkit_1.getProjects)(host);
32
+ let baseDir;
33
+ if (options.directory) {
34
+ baseDir = options.directory;
35
+ }
36
+ else {
37
+ baseDir =
38
+ workspace.get(options.project).projectType === 'application'
39
+ ? 'app'
40
+ : 'lib';
41
+ }
42
+ return options.flat ? baseDir : (0, devkit_1.joinPathFragments)(baseDir, fileName);
44
43
  }
45
44
  function assertValidOptions(options) {
46
45
  const slashes = ['/', '\\'];