@nx/expo 17.3.0-beta.1 → 17.3.0-beta.2
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 +9 -9
- package/plugin.d.ts +1 -0
- package/plugin.js +5 -0
- package/plugins/plugin.d.ts +14 -0
- package/plugins/plugin.js +160 -0
- package/src/generators/application/application.js +1 -1
- package/src/generators/application/lib/add-project.js +5 -1
- package/src/generators/init/init.js +29 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/expo",
|
|
3
|
-
"version": "17.3.0-beta.
|
|
3
|
+
"version": "17.3.0-beta.2",
|
|
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": [
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"tslib": "^2.3.0",
|
|
35
35
|
"tsconfig-paths": "^4.1.2",
|
|
36
36
|
"tsconfig-paths-webpack-plugin": "^4.0.0",
|
|
37
|
-
"@nx/detox": "17.3.0-beta.
|
|
38
|
-
"@nx/devkit": "17.3.0-beta.
|
|
39
|
-
"@nx/jest": "17.3.0-beta.
|
|
40
|
-
"@nx/js": "17.3.0-beta.
|
|
41
|
-
"@nx/eslint": "17.3.0-beta.
|
|
42
|
-
"@nx/react": "17.3.0-beta.
|
|
43
|
-
"@nx/webpack": "17.3.0-beta.
|
|
44
|
-
"@nrwl/expo": "17.3.0-beta.
|
|
37
|
+
"@nx/detox": "17.3.0-beta.2",
|
|
38
|
+
"@nx/devkit": "17.3.0-beta.2",
|
|
39
|
+
"@nx/jest": "17.3.0-beta.2",
|
|
40
|
+
"@nx/js": "17.3.0-beta.2",
|
|
41
|
+
"@nx/eslint": "17.3.0-beta.2",
|
|
42
|
+
"@nx/react": "17.3.0-beta.2",
|
|
43
|
+
"@nx/webpack": "17.3.0-beta.2",
|
|
44
|
+
"@nrwl/expo": "17.3.0-beta.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"expo": ">= 49.0.0",
|
package/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createNodes, ExpoPluginOptions } from './plugins/plugin';
|
package/plugin.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodes = void 0;
|
|
4
|
+
var plugin_1 = require("./plugins/plugin");
|
|
5
|
+
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CreateDependencies, CreateNodes } from '@nx/devkit';
|
|
2
|
+
export interface ExpoPluginOptions {
|
|
3
|
+
startTargetName?: string;
|
|
4
|
+
runIosTargetName?: string;
|
|
5
|
+
runAndroidTargetName?: string;
|
|
6
|
+
exportTargetName?: string;
|
|
7
|
+
exportWebTargetName?: string;
|
|
8
|
+
prebuildTargetName?: string;
|
|
9
|
+
installTargetName?: string;
|
|
10
|
+
buildTargetName?: string;
|
|
11
|
+
submitTargetName?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const createDependencies: CreateDependencies;
|
|
14
|
+
export declare const createNodes: CreateNodes<ExpoPluginOptions>;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const js_1 = require("@nx/js");
|
|
7
|
+
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
10
|
+
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
11
|
+
const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'expo.hash');
|
|
12
|
+
const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
|
|
13
|
+
const calculatedTargets = {};
|
|
14
|
+
function readTargetsCache() {
|
|
15
|
+
return (0, devkit_1.readJsonFile)(cachePath);
|
|
16
|
+
}
|
|
17
|
+
function writeTargetsToCache(targets) {
|
|
18
|
+
(0, devkit_1.writeJsonFile)(cachePath, targets);
|
|
19
|
+
}
|
|
20
|
+
const createDependencies = () => {
|
|
21
|
+
writeTargetsToCache(calculatedTargets);
|
|
22
|
+
return [];
|
|
23
|
+
};
|
|
24
|
+
exports.createDependencies = createDependencies;
|
|
25
|
+
exports.createNodes = [
|
|
26
|
+
'**/app.{json,config.js}',
|
|
27
|
+
(configFilePath, options, context) => {
|
|
28
|
+
options = normalizeOptions(options);
|
|
29
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
30
|
+
// Do not create a project if package.json or project.json or metro.config.js isn't there.
|
|
31
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
32
|
+
if (!siblingFiles.includes('package.json') ||
|
|
33
|
+
!siblingFiles.includes('project.json') ||
|
|
34
|
+
!siblingFiles.includes('metro.config.js')) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
const appConfig = getAppConfig(configFilePath, context);
|
|
38
|
+
// if appConfig.expo is not defined
|
|
39
|
+
if (!appConfig.expo) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
|
|
43
|
+
(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
|
|
44
|
+
]);
|
|
45
|
+
const targets = targetsCache[hash]
|
|
46
|
+
? targetsCache[hash]
|
|
47
|
+
: buildExpoTargets(projectRoot, options, context);
|
|
48
|
+
calculatedTargets[hash] = targets;
|
|
49
|
+
return {
|
|
50
|
+
projects: {
|
|
51
|
+
[projectRoot]: {
|
|
52
|
+
targets,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
function buildExpoTargets(projectRoot, options, context) {
|
|
59
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
60
|
+
const targets = {
|
|
61
|
+
[options.startTargetName]: {
|
|
62
|
+
command: `expo start`,
|
|
63
|
+
options: { cwd: projectRoot },
|
|
64
|
+
},
|
|
65
|
+
[options.runIosTargetName]: {
|
|
66
|
+
command: `expo run:ios`,
|
|
67
|
+
options: { cwd: projectRoot },
|
|
68
|
+
},
|
|
69
|
+
[options.runAndroidTargetName]: {
|
|
70
|
+
command: `expo run:android`,
|
|
71
|
+
options: { cwd: projectRoot },
|
|
72
|
+
},
|
|
73
|
+
[options.exportTargetName]: {
|
|
74
|
+
command: `expo export`,
|
|
75
|
+
options: { cwd: projectRoot },
|
|
76
|
+
cache: true,
|
|
77
|
+
dependsOn: [`^${options.exportTargetName}`],
|
|
78
|
+
inputs: getInputs(namedInputs),
|
|
79
|
+
outputs: [getOutputs(projectRoot, 'dist')],
|
|
80
|
+
},
|
|
81
|
+
[options.exportWebTargetName]: {
|
|
82
|
+
command: `expo export:web`,
|
|
83
|
+
options: { cwd: projectRoot },
|
|
84
|
+
cache: true,
|
|
85
|
+
dependsOn: [`^${options.exportWebTargetName}`],
|
|
86
|
+
inputs: getInputs(namedInputs),
|
|
87
|
+
outputs: [getOutputs(projectRoot, 'web-build')],
|
|
88
|
+
},
|
|
89
|
+
[options.installTargetName]: {
|
|
90
|
+
command: `expo install`,
|
|
91
|
+
options: { cwd: devkit_1.workspaceRoot }, // install at workspace root
|
|
92
|
+
},
|
|
93
|
+
[options.prebuildTargetName]: {
|
|
94
|
+
command: `expo prebuild`,
|
|
95
|
+
options: { cwd: projectRoot },
|
|
96
|
+
},
|
|
97
|
+
[options.buildTargetName]: {
|
|
98
|
+
command: `eas build`,
|
|
99
|
+
options: { cwd: projectRoot },
|
|
100
|
+
dependsOn: [`^${options.buildTargetName}`],
|
|
101
|
+
inputs: getInputs(namedInputs),
|
|
102
|
+
},
|
|
103
|
+
[options.submitTargetName]: {
|
|
104
|
+
command: `eas submit`,
|
|
105
|
+
options: { cwd: projectRoot },
|
|
106
|
+
dependsOn: [`^${options.submitTargetName}`],
|
|
107
|
+
inputs: getInputs(namedInputs),
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
return targets;
|
|
111
|
+
}
|
|
112
|
+
function getAppConfig(configFilePath, context) {
|
|
113
|
+
const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
114
|
+
let module = load(resolvedPath);
|
|
115
|
+
return module.default ?? module;
|
|
116
|
+
}
|
|
117
|
+
function getInputs(namedInputs) {
|
|
118
|
+
return [
|
|
119
|
+
...('production' in namedInputs
|
|
120
|
+
? ['default', '^production']
|
|
121
|
+
: ['default', '^default']),
|
|
122
|
+
{
|
|
123
|
+
externalDependencies: ['react-native'],
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
function getOutputs(projectRoot, dir) {
|
|
128
|
+
if (projectRoot === '.') {
|
|
129
|
+
return `{projectRoot}/${dir}`;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return `{workspaceRoot}/${projectRoot}/${dir}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Load the module after ensuring that the require cache is cleared.
|
|
137
|
+
*/
|
|
138
|
+
function load(path) {
|
|
139
|
+
// Clear cache if the path is in the cache
|
|
140
|
+
if (require.cache[path]) {
|
|
141
|
+
for (const k of Object.keys(require.cache)) {
|
|
142
|
+
delete require.cache[k];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Then require
|
|
146
|
+
return require(path);
|
|
147
|
+
}
|
|
148
|
+
function normalizeOptions(options) {
|
|
149
|
+
options ??= {};
|
|
150
|
+
options.startTargetName ??= 'start';
|
|
151
|
+
options.runIosTargetName ??= 'run-ios';
|
|
152
|
+
options.runAndroidTargetName ??= 'run-android';
|
|
153
|
+
options.exportTargetName ??= 'export';
|
|
154
|
+
options.exportWebTargetName ??= 'export-web';
|
|
155
|
+
options.prebuildTargetName ??= 'prebuild';
|
|
156
|
+
options.installTargetName ??= 'install';
|
|
157
|
+
options.buildTargetName ??= 'build';
|
|
158
|
+
options.submitTargetName ??= 'submit';
|
|
159
|
+
return options;
|
|
160
|
+
}
|
|
@@ -20,9 +20,9 @@ async function expoApplicationGenerator(host, schema) {
|
|
|
20
20
|
exports.expoApplicationGenerator = expoApplicationGenerator;
|
|
21
21
|
async function expoApplicationGeneratorInternal(host, schema) {
|
|
22
22
|
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
23
|
+
const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
|
|
23
24
|
(0, create_application_files_1.createApplicationFiles)(host, options);
|
|
24
25
|
(0, add_project_1.addProject)(host, options);
|
|
25
|
-
const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
|
|
26
26
|
const lintTask = await (0, add_linting_1.addLinting)(host, {
|
|
27
27
|
...options,
|
|
28
28
|
projectRoot: options.appProjectRoot,
|
|
@@ -3,11 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addProject = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
function addProject(host, options) {
|
|
6
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
7
|
+
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
8
|
+
? p === '@nx/expo/plugin'
|
|
9
|
+
: p.plugin === '@nx/expo/plugin');
|
|
6
10
|
const projectConfiguration = {
|
|
7
11
|
root: options.appProjectRoot,
|
|
8
12
|
sourceRoot: `${options.appProjectRoot}/src`,
|
|
9
13
|
projectType: 'application',
|
|
10
|
-
targets: {
|
|
14
|
+
targets: hasPlugin ? {} : getTargets(options),
|
|
11
15
|
tags: options.parsedTags,
|
|
12
16
|
};
|
|
13
17
|
(0, devkit_1.addProjectConfiguration)(host, options.projectName, projectConfiguration, options.standaloneConfig);
|
|
@@ -31,6 +31,9 @@ async function expoInitGenerator(host, schema) {
|
|
|
31
31
|
});
|
|
32
32
|
tasks.push(detoxTask);
|
|
33
33
|
}
|
|
34
|
+
if (process.env.NX_PCV3 === 'true') {
|
|
35
|
+
addPlugin(host);
|
|
36
|
+
}
|
|
34
37
|
if (!schema.skipFormat) {
|
|
35
38
|
await (0, devkit_1.formatFiles)(host);
|
|
36
39
|
}
|
|
@@ -67,4 +70,30 @@ exports.updateDependencies = updateDependencies;
|
|
|
67
70
|
function moveDependency(host) {
|
|
68
71
|
return (0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/react-native'], []);
|
|
69
72
|
}
|
|
73
|
+
function addPlugin(host) {
|
|
74
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
75
|
+
nxJson.plugins ??= [];
|
|
76
|
+
for (const plugin of nxJson.plugins) {
|
|
77
|
+
if (typeof plugin === 'string'
|
|
78
|
+
? plugin === '@nx/expo/plugin'
|
|
79
|
+
: plugin.plugin === '@nx/expo/plugin') {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
nxJson.plugins.push({
|
|
84
|
+
plugin: '@nx/expo/plugin',
|
|
85
|
+
options: {
|
|
86
|
+
startTargetName: 'start',
|
|
87
|
+
runIosTargetName: 'run-ios',
|
|
88
|
+
runAndroidTargetName: 'run-android',
|
|
89
|
+
exportTargetName: 'export',
|
|
90
|
+
exportWebTargetName: 'export-web',
|
|
91
|
+
prebuildTargetName: 'prebuild',
|
|
92
|
+
installTargetName: 'install',
|
|
93
|
+
buildTargetName: 'build',
|
|
94
|
+
submitTargetName: 'submit',
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
98
|
+
}
|
|
70
99
|
exports.default = expoInitGenerator;
|