@nx/expo 16.8.0-beta.1 → 16.8.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/generators.json CHANGED
@@ -38,14 +38,14 @@
38
38
  "hidden": true
39
39
  },
40
40
  "application": {
41
- "factory": "./src/generators/application/application#expoApplicationGenerator",
41
+ "factory": "./src/generators/application/application#expoApplicationGeneratorInternal",
42
42
  "schema": "./src/generators/application/schema.json",
43
43
  "aliases": ["app"],
44
44
  "x-type": "application",
45
45
  "description": "Create an application"
46
46
  },
47
47
  "library": {
48
- "factory": "./src/generators/library/library#expoLibraryGenerator",
48
+ "factory": "./src/generators/library/library#expoLibraryGeneratorInternal",
49
49
  "schema": "./src/generators/library/schema.json",
50
50
  "aliases": ["lib"],
51
51
  "x-type": "library",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/expo",
3
- "version": "16.8.0-beta.1",
3
+ "version": "16.8.0-beta.3",
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": [
@@ -26,14 +26,14 @@
26
26
  "main": "./index.js",
27
27
  "types": "index.d.ts",
28
28
  "dependencies": {
29
- "@nrwl/expo": "16.8.0-beta.1",
30
- "@nx/detox": "16.8.0-beta.1",
31
- "@nx/devkit": "16.8.0-beta.1",
32
- "@nx/jest": "16.8.0-beta.1",
33
- "@nx/js": "16.8.0-beta.1",
34
- "@nx/linter": "16.8.0-beta.1",
35
- "@nx/react": "16.8.0-beta.1",
36
- "@nx/webpack": "16.8.0-beta.1",
29
+ "@nrwl/expo": "16.8.0-beta.3",
30
+ "@nx/detox": "16.8.0-beta.3",
31
+ "@nx/devkit": "16.8.0-beta.3",
32
+ "@nx/jest": "16.8.0-beta.3",
33
+ "@nx/js": "16.8.0-beta.3",
34
+ "@nx/linter": "16.8.0-beta.3",
35
+ "@nx/react": "16.8.0-beta.3",
36
+ "@nx/webpack": "16.8.0-beta.3",
37
37
  "chalk": "^4.1.0",
38
38
  "enhanced-resolve": "^5.8.3",
39
39
  "fs-extra": "^11.1.0",
@@ -60,5 +60,5 @@
60
60
  "access": "public"
61
61
  },
62
62
  "type": "commonjs",
63
- "gitHead": "231a998e004c13e559c171ba6c164a9127886153"
63
+ "gitHead": "dcd48165a485bc8db57a1fb02b96a0772de3b7e9"
64
64
  }
@@ -1,5 +1,6 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function expoApplicationGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function expoApplicationGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
5
  export default expoApplicationGenerator;
5
6
  export declare const expoApplicationSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expoApplicationSchematic = exports.expoApplicationGenerator = void 0;
3
+ exports.expoApplicationSchematic = exports.expoApplicationGeneratorInternal = exports.expoApplicationGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const symlink_task_1 = require("../../utils/symlink-task");
@@ -14,7 +14,13 @@ const add_eas_scripts_1 = require("./lib/add-eas-scripts");
14
14
  const add_detox_1 = require("./lib/add-detox");
15
15
  function expoApplicationGenerator(host, schema) {
16
16
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
- const options = (0, normalize_options_1.normalizeOptions)(host, schema);
17
+ return yield expoApplicationGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
18
+ });
19
+ }
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);
18
24
  (0, create_application_files_1.createApplicationFiles)(host, options);
19
25
  (0, add_project_1.addProject)(host, options);
20
26
  const initTask = yield (0, init_1.default)(host, Object.assign(Object.assign({}, options), { skipFormat: true }));
@@ -31,6 +37,6 @@ function expoApplicationGenerator(host, schema) {
31
37
  return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask);
32
38
  });
33
39
  }
34
- exports.expoApplicationGenerator = expoApplicationGenerator;
40
+ exports.expoApplicationGeneratorInternal = expoApplicationGeneratorInternal;
35
41
  exports.default = expoApplicationGenerator;
36
42
  exports.expoApplicationSchematic = (0, devkit_1.convertNxGenerator)(expoApplicationGenerator);
@@ -9,7 +9,7 @@ function addDetox(host, options) {
9
9
  if ((options === null || options === void 0 ? void 0 : options.e2eTestRunner) !== 'detox') {
10
10
  return () => { };
11
11
  }
12
- return (0, detox_1.detoxApplicationGenerator)(host, Object.assign(Object.assign({}, options), { linter: linter_1.Linter.EsLint, e2eName: `${options.name}-e2e`, e2eDirectory: options.directory, appProject: options.projectName, appDisplayName: options.displayName, appName: options.name, framework: 'expo', setParserOptionsProject: options.setParserOptionsProject, skipFormat: true }));
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 }));
13
13
  });
14
14
  }
15
15
  exports.addDetox = addDetox;
@@ -25,7 +25,7 @@ function getTargets(options) {
25
25
  architect.serve = {
26
26
  executor: 'nx:run-commands',
27
27
  options: {
28
- command: `nx start ${options.name}`,
28
+ command: `nx start ${options.projectName}`,
29
29
  },
30
30
  };
31
31
  architect['run-ios'] = {
@@ -7,4 +7,4 @@ export interface NormalizedSchema extends Schema {
7
7
  lowerCaseName: string;
8
8
  parsedTags: string[];
9
9
  }
10
- export declare function normalizeOptions(host: Tree, options: Schema): NormalizedSchema;
10
+ export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -1,28 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
6
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
5
7
  function normalizeOptions(host, options) {
6
- const { fileName, className } = (0, devkit_1.names)(options.name);
7
- const { appsDir } = (0, devkit_1.getWorkspaceLayout)(host);
8
- const directoryName = options.directory
9
- ? (0, devkit_1.names)(options.directory).fileName
10
- : '';
11
- const projectDirectory = directoryName
12
- ? `${directoryName}/${fileName}`
13
- : fileName;
14
- const appProjectName = projectDirectory.replace(new RegExp('/', 'g'), '-');
15
- const appProjectRoot = (0, devkit_1.joinPathFragments)(appsDir, projectDirectory);
16
- const parsedTags = options.tags
17
- ? options.tags.split(',').map((s) => s.trim())
18
- : [];
19
- /**
20
- * if options.name is "my-app"
21
- * name: "my-app", className: 'MyApp', lowerCaseName: 'myapp', displayName: 'MyApp', projectName: 'my-app', appProjectRoot: 'apps/my-app', androidProjectRoot: 'apps/my-app/android', iosProjectRoot: 'apps/my-app/ios'
22
- * if options.name is "myApp"
23
- * name: "my-app", className: 'MyApp', lowerCaseName: 'myapp', displayName: 'MyApp', projectName: 'my-app', appProjectRoot: 'apps/my-app', androidProjectRoot: 'apps/my-app/android', iosProjectRoot: 'apps/my-app/ios'
24
- */
25
- return Object.assign(Object.assign({}, options), { unitTestRunner: options.unitTestRunner || 'jest', e2eTestRunner: options.e2eTestRunner || 'detox', name: fileName, className, lowerCaseName: className.toLowerCase(), displayName: options.displayName || className, projectName: appProjectName, appProjectRoot,
26
- parsedTags });
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 });
23
+ });
27
24
  }
28
25
  exports.normalizeOptions = normalizeOptions;
@@ -1,4 +1,5 @@
1
- import { Linter } from '@nx/linter';
1
+ import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import type { Linter } from '@nx/linter';
2
3
 
3
4
  export interface Schema {
4
5
  name: string;
@@ -6,6 +7,7 @@ export interface Schema {
6
7
  style?: string;
7
8
  skipFormat: boolean; // default is false
8
9
  directory?: string;
10
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
9
11
  tags?: string;
10
12
  unitTestRunner: 'jest' | 'none'; // default is jest
11
13
  pascalCaseFiles?: boolean;
@@ -22,7 +22,8 @@
22
22
  "$source": "argv",
23
23
  "index": 0
24
24
  },
25
- "x-prompt": "What name would you like to use for the application?"
25
+ "x-prompt": "What name would you like to use for the application?",
26
+ "pattern": "^[a-zA-Z][^:]*$"
26
27
  },
27
28
  "displayName": {
28
29
  "description": "The display name to show in the application. Defaults to name.",
@@ -33,6 +34,11 @@
33
34
  "type": "string",
34
35
  "x-priority": "important"
35
36
  },
37
+ "projectNameAndRootFormat": {
38
+ "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
39
+ "type": "string",
40
+ "enum": ["as-provided", "derived"]
41
+ },
36
42
  "skipFormat": {
37
43
  "description": "Skip formatting files",
38
44
  "type": "boolean",
@@ -6,6 +6,7 @@ const ts = require("typescript");
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const normalize_options_1 = require("./lib/normalize-options");
8
8
  const add_import_1 = require("./lib/add-import");
9
+ const path_1 = require("path");
9
10
  function expoComponentGenerator(host, schema) {
10
11
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
12
  const options = yield (0, normalize_options_1.normalizeOptions)(host, schema);
@@ -19,7 +20,7 @@ function expoComponentGenerator(host, schema) {
19
20
  exports.expoComponentGenerator = expoComponentGenerator;
20
21
  function createComponentFiles(host, options) {
21
22
  const componentDir = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.directory);
22
- (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), componentDir, Object.assign(Object.assign({}, options), { tmpl: '' }));
23
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), componentDir, Object.assign(Object.assign({}, options), { tmpl: '' }));
23
24
  for (const c of host.listChanges()) {
24
25
  let deleteFile = false;
25
26
  if (options.skipTests && /.*spec.tsx/.test(c.path)) {
@@ -5,8 +5,7 @@ export interface NormalizedSchema extends Schema {
5
5
  fileName: string;
6
6
  projectRoot: string;
7
7
  routePath: string;
8
- projectDirectory: string;
9
8
  parsedTags: string[];
10
9
  appMain: string;
11
10
  }
12
- export declare function normalizeOptions(host: Tree, options: Schema): NormalizedSchema;
11
+ export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -1,27 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
4
+ const tslib_1 = require("tslib");
5
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  function normalizeOptions(host, options) {
7
- const name = (0, devkit_1.names)(options.name).fileName;
8
- const projectDirectory = options.directory
9
- ? `${(0, devkit_1.names)(options.directory).fileName}/${name}`
10
- : name;
11
- const projectName = projectDirectory.replace(new RegExp('/', 'g'), '-');
12
- const fileName = projectName;
13
- const { libsDir } = (0, devkit_1.getWorkspaceLayout)(host);
14
- const projectRoot = (0, devkit_1.joinPathFragments)(libsDir, projectDirectory);
15
- const parsedTags = options.tags
16
- ? options.tags.split(',').map((s) => s.trim())
17
- : [];
18
- const importPath = options.importPath || (0, get_import_path_1.getImportPath)(host, projectDirectory);
19
- const appMain = options.js ? 'src/index.js' : 'src/index.ts';
20
- const normalized = Object.assign(Object.assign({}, options), { fileName, routePath: `/${name}`, name: projectName, projectRoot,
21
- projectDirectory,
22
- parsedTags,
23
- importPath,
24
- appMain });
25
- return normalized;
7
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
+ const { projectName, names: projectNames, projectRoot, importPath, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
9
+ name: options.name,
10
+ projectType: 'library',
11
+ directory: options.directory,
12
+ importPath: options.importPath,
13
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
14
+ callingGenerator: '@nx/expo:library',
15
+ });
16
+ const parsedTags = options.tags
17
+ ? options.tags.split(',').map((s) => s.trim())
18
+ : [];
19
+ const appMain = options.js ? 'src/index.js' : 'src/index.ts';
20
+ const normalized = Object.assign(Object.assign({}, options), { fileName: projectName, routePath: `/${projectNames.projectSimpleName}`, name: projectName, projectRoot,
21
+ parsedTags,
22
+ importPath,
23
+ appMain });
24
+ return normalized;
25
+ });
26
26
  }
27
27
  exports.normalizeOptions = normalizeOptions;
@@ -1,5 +1,6 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function expoLibraryGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function expoLibraryGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
5
  export default expoLibraryGenerator;
5
6
  export declare const expoLibrarySchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.expoLibrarySchematic = exports.expoLibraryGenerator = void 0;
3
+ exports.expoLibrarySchematic = exports.expoLibraryGeneratorInternal = exports.expoLibraryGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const js_1 = require("@nx/js");
@@ -11,7 +11,13 @@ const versions_1 = require("../../utils/versions");
11
11
  const normalize_options_1 = require("./lib/normalize-options");
12
12
  function expoLibraryGenerator(host, schema) {
13
13
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
- const options = (0, normalize_options_1.normalizeOptions)(host, schema);
14
+ return yield expoLibraryGeneratorInternal(host, Object.assign({ projectNameAndRootFormat: 'derived' }, schema));
15
+ });
16
+ }
17
+ exports.expoLibraryGenerator = expoLibraryGenerator;
18
+ function expoLibraryGeneratorInternal(host, schema) {
19
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
+ const options = yield (0, normalize_options_1.normalizeOptions)(host, schema);
15
21
  if (options.publishable === true && !schema.importPath) {
16
22
  throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
17
23
  }
@@ -43,14 +49,13 @@ function expoLibraryGenerator(host, schema) {
43
49
  return (0, devkit_1.runTasksInSerial)(...tasks);
44
50
  });
45
51
  }
46
- exports.expoLibraryGenerator = expoLibraryGenerator;
52
+ exports.expoLibraryGeneratorInternal = expoLibraryGeneratorInternal;
47
53
  function addProject(host, options) {
48
54
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
49
55
  const targets = {};
50
56
  let task;
51
57
  if (options.publishable || options.buildable) {
52
58
  const { rollupInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
53
- const { libsDir } = (0, devkit_1.getWorkspaceLayout)(host);
54
59
  const external = [
55
60
  'react/jsx-runtime',
56
61
  'react-native',
@@ -61,7 +66,7 @@ function addProject(host, options) {
61
66
  executor: '@nx/rollup:rollup',
62
67
  outputs: ['{options.outputPath}'],
63
68
  options: {
64
- outputPath: `dist/${libsDir}/${options.projectDirectory}`,
69
+ outputPath: `dist/${options.projectRoot}`,
65
70
  tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
66
71
  project: `${options.projectRoot}/package.json`,
67
72
  entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
@@ -1,4 +1,5 @@
1
- import { Linter } from '@nx/linter';
1
+ import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import type { Linter } from '@nx/linter';
2
3
 
3
4
  /**
4
5
  * Same as the @nx/react library schema, except it removes keys: style, component, routing, appProject
@@ -6,6 +7,7 @@ import { Linter } from '@nx/linter';
6
7
  export interface Schema {
7
8
  name: string;
8
9
  directory?: string;
10
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
9
11
  skipTsConfig: boolean; // default is false
10
12
  skipFormat: boolean; // default is false
11
13
  tags?: string;
@@ -19,13 +19,18 @@
19
19
  "index": 0
20
20
  },
21
21
  "x-prompt": "What name would you like to use for the library?",
22
- "pattern": "^[a-zA-Z].*$"
22
+ "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
23
23
  },
24
24
  "directory": {
25
25
  "type": "string",
26
26
  "description": "A directory where the lib is placed.",
27
27
  "x-priority": "important"
28
28
  },
29
+ "projectNameAndRootFormat": {
30
+ "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
31
+ "type": "string",
32
+ "enum": ["as-provided", "derived"]
33
+ },
29
34
  "linter": {
30
35
  "description": "The tool to use for running lint checks.",
31
36
  "type": "string",
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const linter_1 = require("@nx/linter");
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const lint_1 = require("@nx/react/src/utils/lint");
8
+ const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
8
9
  function addLinting(host, options) {
9
10
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
11
  if (options.linter === linter_1.Linter.None) {
@@ -20,18 +21,15 @@ function addLinting(host, options) {
20
21
  skipPackageJson: options.skipPackageJson,
21
22
  });
22
23
  tasks.push(lintTask);
23
- (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, '.eslintrc.json'), (json) => {
24
- json = (0, lint_1.extendReactEslintJson)(json);
25
- json.ignorePatterns = [
26
- ...json.ignorePatterns,
24
+ if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
25
+ (0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
26
+ (0, eslint_file_1.addIgnoresToLintConfig)(host, options.projectRoot, [
27
27
  '.expo',
28
- 'node_modules',
29
28
  'web-build',
30
29
  'cache',
31
30
  'dist',
32
- ];
33
- return json;
34
- });
31
+ ]);
32
+ }
35
33
  if (!options.skipPackageJson) {
36
34
  const installTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
37
35
  tasks.push(installTask);