@nx/expo 0.0.0-pr-11-e92ae29 → 0.0.0-pr-29464-ce29f31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/expo",
3
- "version": "0.0.0-pr-11-e92ae29",
3
+ "version": "0.0.0-pr-29464-ce29f31",
4
4
  "private": false,
5
5
  "description": "The Expo Plugin for Nx contains executors and generators for managing and developing an expo application within your workspace. For example, you can directly build for different target platforms as well as generate projects and publish your code.",
6
6
  "keywords": [
@@ -28,13 +28,13 @@
28
28
  "main": "./index",
29
29
  "types": "index.d.ts",
30
30
  "dependencies": {
31
- "@nx/devkit": "0.0.0-pr-11-e92ae29",
32
- "@nx/eslint": "0.0.0-pr-11-e92ae29",
33
- "@nx/jest": "0.0.0-pr-11-e92ae29",
34
- "@nx/js": "0.0.0-pr-11-e92ae29",
35
- "@nx/react": "0.0.0-pr-11-e92ae29",
36
- "@nx/web": "0.0.0-pr-11-e92ae29",
37
- "@nx/webpack": "0.0.0-pr-11-e92ae29",
31
+ "@nx/devkit": "0.0.0-pr-29464-ce29f31",
32
+ "@nx/eslint": "0.0.0-pr-29464-ce29f31",
33
+ "@nx/jest": "0.0.0-pr-29464-ce29f31",
34
+ "@nx/js": "0.0.0-pr-29464-ce29f31",
35
+ "@nx/react": "0.0.0-pr-29464-ce29f31",
36
+ "@nx/web": "0.0.0-pr-29464-ce29f31",
37
+ "@nx/webpack": "0.0.0-pr-29464-ce29f31",
38
38
  "enhanced-resolve": "^5.8.3",
39
39
  "metro-config": "~0.80.4",
40
40
  "metro-resolver": "~0.80.4",
@@ -42,6 +42,11 @@ async function expoApplicationGeneratorInternal(host, schema) {
42
42
  (0, init_root_babel_config_1.initRootBabelConfig)(host);
43
43
  await (0, create_application_files_1.createApplicationFiles)(host, options);
44
44
  (0, add_project_1.addProject)(host, options);
45
+ // If we are using the new TS solution
46
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
47
+ if (options.isTsSolutionSetup) {
48
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
49
+ }
45
50
  const lintTask = await (0, add_linting_1.addLinting)(host, {
46
51
  ...options,
47
52
  projectRoot: options.appProjectRoot,
@@ -63,11 +68,6 @@ async function expoApplicationGeneratorInternal(host, schema) {
63
68
  }, options.linter === 'eslint'
64
69
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
65
70
  : undefined);
66
- // If we are using the new TS solution
67
- // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
68
- if (options.useTsSolution) {
69
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
70
- }
71
71
  (0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
72
72
  if (!options.skipFormat) {
73
73
  await (0, devkit_1.formatFiles)(host);
@@ -27,8 +27,6 @@ async function addE2e(tree, options) {
27
27
  version: '0.0.1',
28
28
  private: true,
29
29
  nx: {
30
- projectType: 'application',
31
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
32
30
  implicitDependencies: [options.projectName],
33
31
  },
34
32
  });
@@ -84,8 +82,6 @@ async function addE2e(tree, options) {
84
82
  version: '0.0.1',
85
83
  private: true,
86
84
  nx: {
87
- projectType: 'application',
88
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
89
85
  implicitDependencies: [options.projectName],
90
86
  },
91
87
  });
@@ -135,7 +131,7 @@ async function addE2e(tree, options) {
135
131
  e2eDirectory: options.e2eProjectRoot,
136
132
  appProject: options.projectName,
137
133
  appDisplayName: options.displayName,
138
- appName: options.name,
134
+ appName: options.simpleName,
139
135
  framework: 'expo',
140
136
  setParserOptionsProject: options.setParserOptionsProject,
141
137
  skipFormat: true,
@@ -5,9 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  const has_expo_plugin_1 = require("../../../utils/has-expo-plugin");
6
6
  const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
7
7
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
9
8
  function addProject(host, options) {
10
- const nxJson = (0, devkit_1.readNxJson)(host);
11
9
  const hasPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(host);
12
10
  if (!hasPlugin) {
13
11
  (0, target_defaults_utils_1.addBuildTargetDefaults)(host, '@nx/expo:build');
@@ -20,19 +18,23 @@ function addProject(host, options) {
20
18
  tags: options.parsedTags,
21
19
  };
22
20
  if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
23
- const packageName = (0, get_import_path_1.getImportPath)(host, options.name);
24
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
25
- name: packageName,
21
+ const packageJson = {
22
+ name: options.importPath,
26
23
  version: '0.0.1',
27
24
  private: true,
28
- nx: {
29
- name: packageName === options.name ? undefined : options.name,
30
- projectType: 'application',
31
- sourceRoot: `${options.appProjectRoot}/src`,
32
- targets: hasPlugin ? undefined : getTargets(options),
33
- tags: options.parsedTags?.length ? options.parsedTags : undefined,
34
- },
35
- });
25
+ };
26
+ if (options.importPath !== options.projectName) {
27
+ packageJson.nx = { name: options.projectName };
28
+ }
29
+ if (!hasPlugin) {
30
+ packageJson.nx ??= {};
31
+ packageJson.nx.targets = getTargets(options);
32
+ }
33
+ if (options.parsedTags?.length) {
34
+ packageJson.nx ??= {};
35
+ packageJson.nx.tags = options.parsedTags;
36
+ }
37
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
36
38
  }
37
39
  else {
38
40
  (0, devkit_1.addProjectConfiguration)(host, options.projectName, projectConfiguration, options.standaloneConfig);
@@ -1,9 +1,11 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { Schema } from '../schema';
3
- export interface NormalizedSchema extends Schema {
3
+ export interface NormalizedSchema extends Omit<Schema, 'name' | 'useTsSolution'> {
4
4
  className: string;
5
+ simpleName: string;
5
6
  projectName: string;
6
7
  appProjectRoot: string;
8
+ importPath: string;
7
9
  lowerCaseName: string;
8
10
  parsedTags: string[];
9
11
  rootProject: boolean;
@@ -5,8 +5,8 @@ const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
7
  async function normalizeOptions(host, options) {
8
- await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
9
- const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
8
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
9
+ const { projectName, names: projectNames, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
10
10
  name: options.name,
11
11
  projectType: 'application',
12
12
  directory: options.directory,
@@ -15,27 +15,30 @@ async function normalizeOptions(host, options) {
15
15
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
16
16
  nxJson.useInferencePlugins !== false;
17
17
  options.addPlugin ??= addPluginDefault;
18
- const { className } = (0, devkit_1.names)(options.name);
18
+ const { className } = (0, devkit_1.names)(projectName);
19
19
  const parsedTags = options.tags
20
20
  ? options.tags.split(',').map((s) => s.trim())
21
21
  : [];
22
22
  const rootProject = appProjectRoot === '.';
23
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
24
+ const appProjectName = !isTsSolutionSetup || options.name ? projectName : importPath;
23
25
  const e2eProjectName = rootProject ? 'e2e' : `${appProjectName}-e2e`;
24
26
  const e2eProjectRoot = rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
25
27
  return {
26
28
  ...options,
27
29
  unitTestRunner: options.unitTestRunner || 'jest',
28
30
  e2eTestRunner: options.e2eTestRunner || 'none',
29
- name: projectNames.projectSimpleName,
31
+ simpleName: projectNames.projectSimpleName,
30
32
  className,
31
33
  lowerCaseName: className.toLowerCase(),
32
34
  displayName: options.displayName || className,
33
35
  projectName: appProjectName,
34
36
  appProjectRoot,
37
+ importPath,
35
38
  parsedTags,
36
39
  rootProject,
37
40
  e2eProjectName,
38
41
  e2eProjectRoot,
39
- isTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
42
+ isTsSolutionSetup,
40
43
  };
41
44
  }
@@ -29,7 +29,9 @@ function addExportsToBarrel(host, options) {
29
29
  const proj = workspace.get(options.projectName);
30
30
  const isApp = (0, ts_solution_setup_1.getProjectType)(host, proj.root, proj.projectType) === 'application';
31
31
  if (options.export && !isApp) {
32
- const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
32
+ const indexFilePath = (0, devkit_1.joinPathFragments)(...(options.projectSourceRoot
33
+ ? [options.projectSourceRoot]
34
+ : [options.projectRoot, 'src']), options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
33
35
  if (!host.exists(indexFilePath)) {
34
36
  return;
35
37
  }
@@ -10,5 +10,6 @@ export interface NormalizedSchema extends Omit<Schema, 'js'> {
10
10
  className: string;
11
11
  filePath: string;
12
12
  projectName: string;
13
+ projectRoot: string;
13
14
  }
14
15
  export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -31,5 +31,6 @@ async function normalizeOptions(host, options) {
31
31
  filePath,
32
32
  projectSourceRoot,
33
33
  projectName,
34
+ projectRoot: root,
34
35
  };
35
36
  }
@@ -5,9 +5,9 @@ export interface NormalizedSchema extends Schema {
5
5
  fileName: string;
6
6
  projectName: string;
7
7
  projectRoot: string;
8
+ importPath: string;
8
9
  routePath: string;
9
10
  parsedTags: string[];
10
- appMain: string;
11
11
  isUsingTsSolutionConfig: boolean;
12
12
  }
13
13
  export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -4,9 +4,8 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
8
7
  async function normalizeOptions(host, options) {
9
- await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
8
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
10
9
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
11
10
  name: options.name,
12
11
  projectType: 'library',
@@ -20,20 +19,16 @@ async function normalizeOptions(host, options) {
20
19
  const parsedTags = options.tags
21
20
  ? options.tags.split(',').map((s) => s.trim())
22
21
  : [];
23
- const appMain = options.js ? 'src/index.js' : 'src/index.ts';
24
22
  const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
25
23
  const normalized = {
26
24
  ...options,
27
25
  fileName: projectName,
28
26
  routePath: `/${projectNames.projectSimpleName}`,
29
27
  name: projectName,
30
- projectName: isUsingTsSolutionConfig
31
- ? (0, get_import_path_1.getImportPath)(host, projectName)
32
- : projectName,
28
+ projectName: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
33
29
  projectRoot,
34
30
  parsedTags,
35
31
  importPath,
36
- appMain,
37
32
  isUsingTsSolutionConfig,
38
33
  };
39
34
  return normalized;
@@ -7,14 +7,17 @@ const js_1 = require("@nx/js");
7
7
  const init_1 = require("../init/init");
8
8
  const add_linting_1 = require("../../utils/add-linting");
9
9
  const add_jest_1 = require("../../utils/add-jest");
10
- const versions_1 = require("../../utils/versions");
11
10
  const normalize_options_1 = require("./lib/normalize-options");
12
11
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
13
12
  const init_root_babel_config_1 = require("../../utils/init-root-babel-config");
14
- const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
15
13
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
16
14
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
17
15
  const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
16
+ const add_rollup_build_target_1 = require("@nx/react/src/generators/library/lib/add-rollup-build-target");
17
+ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
18
+ const component_1 = require("../component/component");
19
+ const path_1 = require("path");
20
+ const versions_1 = require("../../utils/versions");
18
21
  async function expoLibraryGenerator(host, schema) {
19
22
  return await expoLibraryGeneratorInternal(host, {
20
23
  addPlugin: false,
@@ -56,12 +59,19 @@ async function expoLibraryGeneratorInternal(host, schema) {
56
59
  tasks.push(lintTask);
57
60
  const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin);
58
61
  tasks.push(jestTask);
59
- if (options.publishable || options.buildable) {
60
- updateLibPackageNpmScope(host, options);
61
- }
62
+ const relativeCwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
63
+ const path = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
64
+ const componentTask = await (0, component_1.expoComponentGenerator)(host, {
65
+ path: relativeCwd ? (0, path_1.relative)(relativeCwd, path) : path,
66
+ skipTests: options.unitTestRunner === 'none',
67
+ export: true,
68
+ skipFormat: true,
69
+ js: options.js,
70
+ });
71
+ tasks.push(() => componentTask);
62
72
  if (!options.skipTsConfig && !options.isUsingTsSolutionConfig) {
63
73
  (0, js_1.addTsConfigPath)(host, options.importPath, [
64
- (0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
74
+ (0, devkit_1.joinPathFragments)(options.projectRoot, options.js ? './src/index.js' : './src/index.ts'),
65
75
  ]);
66
76
  }
67
77
  (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.projectRoot, 'tsconfig.lib.json', {
@@ -93,71 +103,54 @@ async function addProject(host, options) {
93
103
  targets: {},
94
104
  };
95
105
  if (options.isUsingTsSolutionConfig) {
96
- const sourceEntry = !options.buildable
97
- ? options.js
98
- ? './src/index.js'
99
- : './src/index.ts'
100
- : undefined;
101
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
106
+ const packageJson = {
102
107
  name: options.projectName,
103
108
  version: '0.0.1',
104
- main: sourceEntry,
105
- types: sourceEntry,
106
- // For buildable libraries, the entries are configured by the bundler (i.e. Rollup).
107
- exports: options.buildable
108
- ? undefined
109
- : {
110
- './package.json': './package.json',
111
- '.': options.js
112
- ? './src/index.js'
113
- : {
114
- types: './src/index.ts',
115
- import: './src/index.ts',
116
- default: './src/index.ts',
117
- },
118
- },
119
- nx: options.parsedTags?.length
120
- ? {
121
- tags: options.parsedTags,
122
- }
123
- : undefined,
124
- });
109
+ ...determineEntryFields(options),
110
+ files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
111
+ peerDependencies: {
112
+ react: versions_1.reactVersion,
113
+ 'react-native': versions_1.reactNativeVersion,
114
+ },
115
+ };
116
+ if (options.projectName !== options.importPath) {
117
+ packageJson.nx = { name: options.projectName };
118
+ }
119
+ if (options.parsedTags?.length) {
120
+ packageJson.nx ??= {};
121
+ packageJson.nx.tags = options.parsedTags;
122
+ }
123
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), packageJson);
125
124
  }
126
125
  else {
127
126
  (0, devkit_1.addProjectConfiguration)(host, options.name, project);
128
127
  }
129
- if (!options.publishable && !options.buildable) {
130
- return () => { };
128
+ if (options.publishable || options.buildable) {
129
+ const external = new Set([
130
+ 'react/jsx-runtime',
131
+ 'react-native',
132
+ 'react',
133
+ 'react-dom',
134
+ ]);
135
+ const rollupTask = await (0, add_rollup_build_target_1.addRollupBuildTarget)(host, {
136
+ ...options,
137
+ name: options.projectName,
138
+ format: ['cjs', 'esm'],
139
+ style: 'none',
140
+ js: options.js,
141
+ skipFormat: true,
142
+ }, external);
143
+ (0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
144
+ json.peerDependencies = {
145
+ ...json.peerDependencies,
146
+ react: versions_1.reactVersion,
147
+ 'react-native': versions_1.reactNativeVersion,
148
+ };
149
+ return json;
150
+ });
151
+ return rollupTask;
131
152
  }
132
- const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
133
- const rollupConfigTask = await configurationGenerator(host, {
134
- ...options,
135
- project: options.projectName,
136
- skipFormat: true,
137
- });
138
- const external = ['react/jsx-runtime', 'react-native', 'react', 'react-dom'];
139
- (0, target_defaults_utils_1.addBuildTargetDefaults)(host, '@nx/rollup:rollup');
140
- project.targets.build = {
141
- executor: '@nx/rollup:rollup',
142
- outputs: ['{options.outputPath}'],
143
- options: {
144
- outputPath: `dist/${options.projectRoot}`,
145
- tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
146
- project: `${options.projectRoot}/package.json`,
147
- entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
148
- external,
149
- rollupConfig: `@nx/react/plugins/bundle-rollup`,
150
- assets: [
151
- {
152
- glob: `${options.projectRoot}/README.md`,
153
- input: '.',
154
- output: '.',
155
- },
156
- ],
157
- },
158
- };
159
- (0, devkit_1.updateProjectConfiguration)(host, options.projectName, project);
160
- return rollupConfigTask;
153
+ return () => { };
161
154
  }
162
155
  function updateTsConfig(tree, options) {
163
156
  (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), (json) => {
@@ -181,29 +174,25 @@ function createFiles(host, options) {
181
174
  offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
182
175
  rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot),
183
176
  });
184
- if (!options.publishable &&
185
- !options.buildable &&
186
- !options.isUsingTsSolutionConfig) {
187
- host.delete(`${options.projectRoot}/package.json`);
188
- }
189
177
  if (options.js) {
190
178
  (0, devkit_1.toJS)(host);
191
179
  }
192
180
  updateTsConfig(host, options);
193
181
  }
194
- function updateLibPackageNpmScope(host, options) {
195
- return (0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
196
- json.name = options.importPath;
197
- json.peerDependencies = {
198
- react: versions_1.reactVersion,
199
- 'react-native': versions_1.reactNativeVersion,
200
- };
201
- return json;
202
- });
203
- }
204
- function maybeJs(options, path) {
205
- return options.js && (path.endsWith('.ts') || path.endsWith('.tsx'))
206
- ? path.replace(/\.tsx?$/, '.js')
207
- : path;
182
+ function determineEntryFields(options) {
183
+ return {
184
+ main: options.js ? './src/index.js' : './src/index.ts',
185
+ types: options.js ? './src/index.js' : './src/index.ts',
186
+ exports: {
187
+ '.': options.js
188
+ ? './src/index.js'
189
+ : {
190
+ types: './src/index.ts',
191
+ import: './src/index.ts',
192
+ default: './src/index.ts',
193
+ },
194
+ './package.json': './package.json',
195
+ },
196
+ };
208
197
  }
209
198
  exports.default = expoLibraryGenerator;
@@ -1,5 +0,0 @@
1
- {
2
- "name": "<%= projectName %>",
3
- "version": "0.0.1",
4
- "main": "<%= appMain %>"
5
- }