expo-modules-autolinking 3.0.0 → 3.0.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/CHANGELOG.md +16 -0
- package/build/autolinking/findModules.d.ts +11 -5
- package/build/autolinking/findModules.js +8 -16
- package/build/autolinking/findModules.js.map +1 -1
- package/build/autolinking/generatePackageList.d.ts +16 -10
- package/build/autolinking/generatePackageList.js +13 -28
- package/build/autolinking/generatePackageList.js.map +1 -1
- package/build/autolinking/getConfiguration.d.ts +9 -2
- package/build/autolinking/getConfiguration.js +9 -4
- package/build/autolinking/getConfiguration.js.map +1 -1
- package/build/autolinking/index.d.ts +22 -17
- package/build/autolinking/index.js +23 -47
- package/build/autolinking/index.js.map +1 -1
- package/build/autolinking/resolveModules.d.ts +13 -9
- package/build/autolinking/resolveModules.js +21 -18
- package/build/autolinking/resolveModules.js.map +1 -1
- package/build/commands/autolinkingOptions.d.ts +50 -0
- package/build/commands/autolinkingOptions.js +168 -0
- package/build/commands/autolinkingOptions.js.map +1 -0
- package/build/commands/generateModulesProviderCommand.d.ts +3 -0
- package/build/commands/generateModulesProviderCommand.js +35 -0
- package/build/commands/generateModulesProviderCommand.js.map +1 -0
- package/build/commands/generatePackageListCommand.d.ts +6 -0
- package/build/commands/generatePackageListCommand.js +39 -0
- package/build/commands/generatePackageListCommand.js.map +1 -0
- package/build/commands/reactNativeConfigCommand.d.ts +3 -0
- package/build/commands/reactNativeConfigCommand.js +36 -0
- package/build/commands/reactNativeConfigCommand.js.map +1 -0
- package/build/commands/resolveCommand.d.ts +3 -0
- package/build/commands/resolveCommand.js +63 -0
- package/build/commands/resolveCommand.js.map +1 -0
- package/build/commands/searchCommand.d.ts +2 -0
- package/build/commands/searchCommand.js +27 -0
- package/build/commands/searchCommand.js.map +1 -0
- package/build/{autolinking/verifySearchResults.d.ts → commands/verifyCommand.d.ts} +4 -2
- package/build/{autolinking/verifySearchResults.js → commands/verifyCommand.js} +24 -3
- package/build/commands/verifyCommand.js.map +1 -0
- package/build/dependencies/CachedDependenciesLinker.d.ts +2 -1
- package/build/dependencies/CachedDependenciesLinker.js +23 -9
- package/build/dependencies/CachedDependenciesLinker.js.map +1 -1
- package/build/exports.d.ts +17 -1
- package/build/exports.js +48 -1
- package/build/exports.js.map +1 -1
- package/build/index.js +18 -162
- package/build/index.js.map +1 -1
- package/build/platforms/{android.d.ts → android/android.d.ts} +7 -2
- package/build/platforms/{android.js → android/android.js} +1 -5
- package/build/platforms/android/android.js.map +1 -0
- package/build/platforms/android/index.d.ts +1 -0
- package/build/platforms/android/index.js +9 -0
- package/build/platforms/android/index.js.map +1 -0
- package/build/platforms/{apple.d.ts → apple/apple.d.ts} +6 -6
- package/build/platforms/{apple.js → apple/apple.js} +5 -7
- package/build/platforms/apple/apple.js.map +1 -0
- package/build/platforms/apple/index.d.ts +1 -0
- package/build/platforms/apple/index.js +8 -0
- package/build/platforms/apple/index.js.map +1 -0
- package/build/platforms/index.d.ts +15 -0
- package/build/{autolinking/utils.js → platforms/index.js} +6 -1
- package/build/platforms/index.js.map +1 -0
- package/build/reactNativeConfig/reactNativeConfig.d.ts +11 -2
- package/build/reactNativeConfig/reactNativeConfig.js +13 -15
- package/build/reactNativeConfig/reactNativeConfig.js.map +1 -1
- package/build/reactNativeConfig/reactNativeConfig.types.d.ts +4 -33
- package/build/reactNativeConfig/reactNativeConfig.types.js.map +1 -1
- package/build/types.d.ts +1 -58
- package/build/types.js.map +1 -1
- package/package.json +3 -3
- package/src/autolinking/findModules.ts +18 -16
- package/src/autolinking/generatePackageList.ts +30 -31
- package/src/autolinking/getConfiguration.ts +16 -5
- package/src/autolinking/index.ts +48 -41
- package/src/autolinking/resolveModules.ts +47 -34
- package/src/commands/autolinkingOptions.ts +265 -0
- package/src/commands/generateModulesProviderCommand.ts +60 -0
- package/src/commands/generatePackageListCommand.ts +67 -0
- package/src/commands/reactNativeConfigCommand.ts +50 -0
- package/src/commands/resolveCommand.ts +101 -0
- package/src/commands/searchCommand.ts +35 -0
- package/src/{autolinking/verifySearchResults.ts → commands/verifyCommand.ts} +48 -6
- package/src/dependencies/CachedDependenciesLinker.ts +30 -12
- package/src/exports.ts +65 -0
- package/src/index.ts +18 -286
- package/src/platforms/{android.ts → android/android.ts} +10 -12
- package/src/platforms/android/index.ts +6 -0
- package/src/platforms/{apple.ts → apple/apple.ts} +10 -11
- package/src/platforms/apple/index.ts +5 -0
- package/src/platforms/index.ts +49 -0
- package/src/reactNativeConfig/reactNativeConfig.ts +25 -28
- package/src/reactNativeConfig/reactNativeConfig.types.ts +4 -35
- package/src/types.ts +10 -70
- package/build/autolinking/mergeLinkingOptions.d.ts +0 -27
- package/build/autolinking/mergeLinkingOptions.js +0 -112
- package/build/autolinking/mergeLinkingOptions.js.map +0 -1
- package/build/autolinking/utils.d.ts +0 -2
- package/build/autolinking/utils.js.map +0 -1
- package/build/autolinking/verifySearchResults.js.map +0 -1
- package/build/platforms/android.js.map +0 -1
- package/build/platforms/apple.js.map +0 -1
- package/src/autolinking/mergeLinkingOptions.ts +0 -146
- package/src/autolinking/utils.ts +0 -15
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.filterMapSearchPaths = void 0;
|
|
7
|
+
exports.registerAutolinkingArguments = registerAutolinkingArguments;
|
|
8
|
+
exports.createAutolinkingOptionsLoader = createAutolinkingOptionsLoader;
|
|
9
|
+
const find_up_1 = __importDefault(require("find-up"));
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const isJSONObject = (x) => x != null && typeof x === 'object';
|
|
13
|
+
const resolvePathMaybe = (target, basePath) => {
|
|
14
|
+
if (typeof target !== 'string') {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
let resolved = path_1.default.resolve(basePath, target);
|
|
18
|
+
if (fs_1.default.existsSync(resolved)) {
|
|
19
|
+
return resolved;
|
|
20
|
+
}
|
|
21
|
+
else if ((resolved = path_1.default.resolve(target)) && fs_1.default.existsSync(target)) {
|
|
22
|
+
// TODO(@kitten): This is here for legacy support. However, this *will* be inconsistent
|
|
23
|
+
// This relies on the current working directory, and hence, can behave differently depending
|
|
24
|
+
// on where the command was invoked.
|
|
25
|
+
return target;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const filterMapSearchPaths = (searchPaths, basePath) => {
|
|
32
|
+
if (Array.isArray(searchPaths)) {
|
|
33
|
+
return searchPaths
|
|
34
|
+
.map((searchPath) => resolvePathMaybe(searchPath, basePath))
|
|
35
|
+
.filter((searchPath) => searchPath != null);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.filterMapSearchPaths = filterMapSearchPaths;
|
|
42
|
+
const parsePackageJsonOptions = (packageJson, appRoot, platform) => {
|
|
43
|
+
const expo = isJSONObject(packageJson.expo) ? packageJson.expo : null;
|
|
44
|
+
const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;
|
|
45
|
+
let platformOptions = null;
|
|
46
|
+
if (platform) {
|
|
47
|
+
autolinkingOptions && isJSONObject(autolinkingOptions[platform])
|
|
48
|
+
? autolinkingOptions[platform]
|
|
49
|
+
: null;
|
|
50
|
+
if (!platformOptions && platform === 'apple') {
|
|
51
|
+
// NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should
|
|
52
|
+
// be the base option for other apple platforms, but changing this now is a breaking change
|
|
53
|
+
platformOptions =
|
|
54
|
+
autolinkingOptions && isJSONObject(autolinkingOptions.ios) ? autolinkingOptions.ios : null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const mergedOptions = { ...autolinkingOptions, ...platformOptions };
|
|
58
|
+
const outputOptions = {};
|
|
59
|
+
// legacy_shallowReactNativeLinking
|
|
60
|
+
if (mergedOptions.legacy_shallowReactNativeLinking != null) {
|
|
61
|
+
outputOptions.legacy_shallowReactNativeLinking =
|
|
62
|
+
!!mergedOptions.legacy_shallowReactNativeLinking;
|
|
63
|
+
}
|
|
64
|
+
// searchPaths
|
|
65
|
+
if (typeof mergedOptions.searchPaths === 'string' || Array.isArray(mergedOptions.searchPaths)) {
|
|
66
|
+
const rawSearchPaths = typeof mergedOptions.searchPaths === 'string'
|
|
67
|
+
? [mergedOptions.searchPaths]
|
|
68
|
+
: mergedOptions.searchPaths;
|
|
69
|
+
outputOptions.searchPaths = (0, exports.filterMapSearchPaths)(rawSearchPaths, appRoot);
|
|
70
|
+
}
|
|
71
|
+
// nativeModulesDir
|
|
72
|
+
if (typeof mergedOptions.nativeModulesDir === 'string') {
|
|
73
|
+
outputOptions.nativeModulesDir = resolvePathMaybe(mergedOptions.nativeModulesDir, appRoot);
|
|
74
|
+
}
|
|
75
|
+
// exclude
|
|
76
|
+
if (Array.isArray(mergedOptions.exclude)) {
|
|
77
|
+
outputOptions.exclude = mergedOptions.exclude.filter((x) => typeof x === 'string');
|
|
78
|
+
}
|
|
79
|
+
// buildFromSource
|
|
80
|
+
if (Array.isArray(mergedOptions.buildFromSource)) {
|
|
81
|
+
outputOptions.buildFromSource = mergedOptions.buildFromSource.filter((x) => typeof x === 'string');
|
|
82
|
+
}
|
|
83
|
+
// flags
|
|
84
|
+
if (isJSONObject(mergedOptions.flags)) {
|
|
85
|
+
outputOptions.flags = { ...mergedOptions.flags };
|
|
86
|
+
}
|
|
87
|
+
return outputOptions;
|
|
88
|
+
};
|
|
89
|
+
function registerAutolinkingArguments(command) {
|
|
90
|
+
return command
|
|
91
|
+
.option('-e, --exclude <exclude...>', 'Package names to exclude when looking up for modules.', (value, previous) => (previous ?? []).concat(value))
|
|
92
|
+
.option('-p, --platform [platform]', 'The platform that the resulting modules must support. Available options: "apple", "android"', 'apple')
|
|
93
|
+
.option(
|
|
94
|
+
// NOTE(@kitten): For backwards-compatibility, this is still called `project-root`, but it
|
|
95
|
+
// really is a replacement path for the current working directory. Henceforth called `commandRoot`
|
|
96
|
+
'--project-root <projectRoot>', 'The path to the root of the project. Defaults to current working directory', process.cwd());
|
|
97
|
+
}
|
|
98
|
+
const parseExtraArgumentsOptions = (args) => {
|
|
99
|
+
const cwd = process.cwd();
|
|
100
|
+
const platform = args.platform || undefined;
|
|
101
|
+
const commandRoot = resolvePathMaybe(args.projectRoot, cwd) || cwd;
|
|
102
|
+
const extraSearchPaths = (0, exports.filterMapSearchPaths)(args.searchPaths, commandRoot);
|
|
103
|
+
const extraExclude = args.exclude?.filter((name) => typeof name === 'string');
|
|
104
|
+
return {
|
|
105
|
+
platform,
|
|
106
|
+
commandRoot,
|
|
107
|
+
extraSearchPaths,
|
|
108
|
+
extraExclude,
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
const findPackageJsonPathAsync = async (commandRoot) => {
|
|
112
|
+
const cwd = process.cwd();
|
|
113
|
+
const result = await (0, find_up_1.default)('package.json', { cwd: commandRoot || cwd });
|
|
114
|
+
if (!result) {
|
|
115
|
+
throw new Error(`Couldn't find "package.json" up from path "${commandRoot || cwd}"`);
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
};
|
|
119
|
+
const loadPackageJSONAsync = async (packageJsonPath) => {
|
|
120
|
+
const packageJsonText = await fs_1.default.promises.readFile(packageJsonPath, 'utf8');
|
|
121
|
+
return JSON.parse(packageJsonText);
|
|
122
|
+
};
|
|
123
|
+
function createAutolinkingOptionsLoader(argumentsOptions) {
|
|
124
|
+
const extraArgumentsOptions = parseExtraArgumentsOptions(argumentsOptions ?? {});
|
|
125
|
+
const { commandRoot } = extraArgumentsOptions;
|
|
126
|
+
let _packageJsonPath$;
|
|
127
|
+
const getPackageJsonPath = () => {
|
|
128
|
+
return _packageJsonPath$ || (_packageJsonPath$ = findPackageJsonPathAsync(commandRoot));
|
|
129
|
+
};
|
|
130
|
+
let _packageJson$;
|
|
131
|
+
const getPackageJson = async () => _packageJson$ || (_packageJson$ = loadPackageJSONAsync(await getPackageJsonPath()));
|
|
132
|
+
const getAppRoot = async () => path_1.default.dirname(await getPackageJsonPath());
|
|
133
|
+
return {
|
|
134
|
+
getCommandRoot: () => commandRoot,
|
|
135
|
+
getAppRoot,
|
|
136
|
+
async getPlatformOptions(platform = extraArgumentsOptions.platform) {
|
|
137
|
+
const packageJson = await getPackageJson();
|
|
138
|
+
const appRoot = await getAppRoot();
|
|
139
|
+
const options = parsePackageJsonOptions(packageJson, appRoot, platform);
|
|
140
|
+
if (extraArgumentsOptions.extraSearchPaths) {
|
|
141
|
+
options.searchPaths = [
|
|
142
|
+
...extraArgumentsOptions.extraSearchPaths,
|
|
143
|
+
...(options.searchPaths ?? []),
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
if (extraArgumentsOptions.extraExclude) {
|
|
147
|
+
options.exclude = [...(options.exclude ?? []), ...extraArgumentsOptions.extraExclude];
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
...normalizeAutolinkingOptions(options, appRoot),
|
|
151
|
+
platform,
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const normalizeAutolinkingOptions = (options, appRoot) => {
|
|
157
|
+
return {
|
|
158
|
+
legacy_shallowReactNativeLinking: options.legacy_shallowReactNativeLinking ?? false,
|
|
159
|
+
searchPaths: options.searchPaths ?? [],
|
|
160
|
+
nativeModulesDir: options.nativeModulesDir
|
|
161
|
+
? (resolvePathMaybe(options.nativeModulesDir, appRoot) ?? null)
|
|
162
|
+
: (resolvePathMaybe('./modules', appRoot) ?? null),
|
|
163
|
+
exclude: options.exclude ?? [],
|
|
164
|
+
buildFromSource: options.buildFromSource,
|
|
165
|
+
flags: options.flags,
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=autolinkingOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autolinkingOptions.js","sourceRoot":"","sources":["../../src/commands/autolinkingOptions.ts"],"names":[],"mappings":";;;;;;AAwIA,oEAmBC;AAoDD,wEAyCC;AAvPD,sDAA6B;AAC7B,4CAAoB;AACpB,gDAAwB;AAmCxB,MAAM,YAAY,GAAG,CAAC,CAAU,EAAgC,EAAE,CAChE,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC;AAErC,MAAM,gBAAgB,GAAG,CAAC,MAAe,EAAE,QAAgB,EAAiB,EAAE;IAC5E,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9C,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC;IAClB,CAAC;SAAM,IAAI,CAAC,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,YAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACtE,uFAAuF;QACvF,4FAA4F;QAC5F,oCAAoC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEK,MAAM,oBAAoB,GAAG,CAClC,WAAoB,EACpB,QAAgB,EACM,EAAE;IACxB,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,OAAO,WAAW;aACf,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,gBAAgB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;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WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;YAExE,IAAI,qBAAqB,CAAC,gBAAgB,EAAE,CAAC;gBAC3C,OAAO,CAAC,WAAW,GAAG;oBACpB,GAAG,qBAAqB,CAAC,gBAAgB;oBACzC,GAAG,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;iBAC/B,CAAC;YACJ,CAAC;YACD,IAAI,qBAAqB,CAAC,YAAY,EAAE,CAAC;gBACvC,OAAO,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;YACxF,CAAC;YAED,OAAO;gBACL,GAAG,2BAA2B,CAAC,OAAO,EAAE,OAAO,CAAC;gBAChD,QAAQ;aACT,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,2BAA2B,GAAG,CAClC,OAAoC,EACpC,OAAe,EACK,EAAE;IACtB,OAAO;QACL,gCAAgC,EAAE,OAAO,CAAC,gCAAgC,IAAI,KAAK;QACnF,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE;QACtC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YACxC,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,gBAAgB,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;YAC/D,CAAC,CAAC,CAAC,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;QACpD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;QAC9B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,KAAK,EAAE,OAAO,CAAC,KAAK;KACrB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import commander from 'commander';\nimport findUp from 'find-up';\nimport fs from 'fs';\nimport path from 'path';\n\nimport { SupportedPlatform } from '../types';\n\nexport interface AutolinkingOptions {\n /** Only scan direct \"dependencies\" of a project for React Native modules, rather than including transitive dependencies.\n * @remarks\n * Before SDK 54, React Native modules would only be linked if they were listed as dependencies\n * of a project. However, in SDK 54+ transitive React Native modules dependencies are also\n * auto-linked, unless this flag is enabled.\n * @defaultValue `false`\n */\n legacy_shallowReactNativeLinking: boolean;\n /** Extra modules directories to search for native modules.\n * @defaultValue `[]`\n */\n searchPaths: string[];\n /** Local native modules directory to add to autolinking.\n * @defaultValue `\"./modules\"`\n */\n nativeModulesDir: string | null;\n /** Native modules to exclude from autolinking by name.\n * @defaultValue `[]`\n */\n exclude: string[];\n /** A list of package names to opt out of prebuilt Expo modules (Android-only)\n * @defaultValue `[]`\n */\n buildFromSource?: string[];\n /** CocoaPods flags to pass to each autolinked pod (Apple/iOS-only)\n * @defaultValue `[]`\n */\n flags?: Record<string, any>;\n}\n\nconst isJSONObject = (x: unknown): x is Record<string, unknown> =>\n x != null && typeof x === 'object';\n\nconst resolvePathMaybe = (target: unknown, basePath: string): string | null => {\n if (typeof target !== 'string') {\n return null;\n }\n let resolved = path.resolve(basePath, target);\n if (fs.existsSync(resolved)) {\n return resolved;\n } else if ((resolved = path.resolve(target)) && fs.existsSync(target)) {\n // TODO(@kitten): This is here for legacy support. However, this *will* be inconsistent\n // This relies on the current working directory, and hence, can behave differently depending\n // on where the command was invoked.\n return target;\n } else {\n return null;\n }\n};\n\nexport const filterMapSearchPaths = (\n searchPaths: unknown,\n basePath: string\n): string[] | undefined => {\n if (Array.isArray(searchPaths)) {\n return searchPaths\n .map((searchPath) => resolvePathMaybe(searchPath, basePath))\n .filter((searchPath) => searchPath != null);\n } else {\n return undefined;\n }\n};\n\nconst parsePackageJsonOptions = (\n packageJson: Record<string, unknown>,\n appRoot: string,\n platform: SupportedPlatform | null | undefined\n): Partial<AutolinkingOptions> => {\n const expo = isJSONObject(packageJson.expo) ? packageJson.expo : null;\n const autolinkingOptions = expo && isJSONObject(expo.autolinking) ? expo.autolinking : null;\n let platformOptions: Record<string, unknown> | null = null;\n if (platform) {\n autolinkingOptions && isJSONObject(autolinkingOptions[platform])\n ? autolinkingOptions[platform]\n : null;\n if (!platformOptions && platform === 'apple') {\n // NOTE: `platform: 'apple'` has a fallback on `ios`. This doesn't make much sense, since apple should\n // be the base option for other apple platforms, but changing this now is a breaking change\n platformOptions =\n autolinkingOptions && isJSONObject(autolinkingOptions.ios) ? autolinkingOptions.ios : null;\n }\n }\n const mergedOptions = { ...autolinkingOptions, ...platformOptions };\n const outputOptions: Partial<AutolinkingOptions> = {};\n // legacy_shallowReactNativeLinking\n if (mergedOptions.legacy_shallowReactNativeLinking != null) {\n outputOptions.legacy_shallowReactNativeLinking =\n !!mergedOptions.legacy_shallowReactNativeLinking;\n }\n // searchPaths\n if (typeof mergedOptions.searchPaths === 'string' || Array.isArray(mergedOptions.searchPaths)) {\n const rawSearchPaths =\n typeof mergedOptions.searchPaths === 'string'\n ? [mergedOptions.searchPaths]\n : mergedOptions.searchPaths;\n outputOptions.searchPaths = filterMapSearchPaths(rawSearchPaths, appRoot);\n }\n // nativeModulesDir\n if (typeof mergedOptions.nativeModulesDir === 'string') {\n outputOptions.nativeModulesDir = resolvePathMaybe(mergedOptions.nativeModulesDir, appRoot);\n }\n // exclude\n if (Array.isArray(mergedOptions.exclude)) {\n outputOptions.exclude = mergedOptions.exclude.filter((x) => typeof x === 'string');\n }\n // buildFromSource\n if (Array.isArray(mergedOptions.buildFromSource)) {\n outputOptions.buildFromSource = mergedOptions.buildFromSource.filter(\n (x) => typeof x === 'string'\n );\n }\n // flags\n if (isJSONObject(mergedOptions.flags)) {\n outputOptions.flags = { ...mergedOptions.flags };\n }\n return outputOptions;\n};\n\n/** Common commandline arguments for autolinking commands (Not to be confused with `AutolinkingOptions` */\nexport interface AutolinkingCommonArguments {\n projectRoot?: string | null;\n // NOTE(@kitten): These are added to other `searchPaths` entries\n searchPaths?: string[] | null;\n // NOTE(@kitten): These are added to other `exclude` entries\n exclude?: string[] | null;\n platform?: SupportedPlatform | null;\n}\n\nexport function registerAutolinkingArguments(command: commander.Command): commander.Command {\n return command\n .option<string[] | null>(\n '-e, --exclude <exclude...>',\n 'Package names to exclude when looking up for modules.',\n (value, previous) => (previous ?? []).concat(value)\n )\n .option(\n '-p, --platform [platform]',\n 'The platform that the resulting modules must support. Available options: \"apple\", \"android\"',\n 'apple'\n )\n .option(\n // NOTE(@kitten): For backwards-compatibility, this is still called `project-root`, but it\n // really is a replacement path for the current working directory. Henceforth called `commandRoot`\n '--project-root <projectRoot>',\n 'The path to the root of the project. Defaults to current working directory',\n process.cwd()\n );\n}\n\ninterface ArgumentsAutolinkingOptions {\n /** The root directory that will be considered the base path for all other target paths */\n commandRoot: string;\n /** The platform to autolink against. If not passed or unknown, no specific autolinking search logic will be applied */\n platform?: SupportedPlatform;\n /** Added search paths to search for native modules (Usually passed as CLI rest argument. */\n extraSearchPaths?: string[];\n /** Added native module names to exclude from autolined native modules (Usually passed as CLI argument) */\n extraExclude?: string[];\n}\n\nconst parseExtraArgumentsOptions = (\n args: AutolinkingCommonArguments\n): ArgumentsAutolinkingOptions => {\n const cwd = process.cwd();\n const platform = args.platform || undefined;\n const commandRoot = resolvePathMaybe(args.projectRoot, cwd) || cwd;\n const extraSearchPaths = filterMapSearchPaths(args.searchPaths, commandRoot);\n const extraExclude = args.exclude?.filter((name) => typeof name === 'string');\n return {\n platform,\n commandRoot,\n extraSearchPaths,\n extraExclude,\n };\n};\n\nconst findPackageJsonPathAsync = async (commandRoot: string | null): Promise<string> => {\n const cwd = process.cwd();\n const result = await findUp('package.json', { cwd: commandRoot || cwd });\n if (!result) {\n throw new Error(`Couldn't find \"package.json\" up from path \"${commandRoot || cwd}\"`);\n }\n return result;\n};\n\nconst loadPackageJSONAsync = async (packageJsonPath: string): Promise<Record<string, unknown>> => {\n const packageJsonText = await fs.promises.readFile(packageJsonPath, 'utf8');\n return JSON.parse(packageJsonText);\n};\n\nexport interface LinkingOptionsLoader {\n getCommandRoot(): string;\n getAppRoot(): Promise<string>;\n getPlatformOptions<T extends SupportedPlatform | undefined>(\n platform: T\n ): Promise<AutolinkingOptions & { platform: T }>;\n getPlatformOptions(): Promise<AutolinkingOptions>;\n}\n\nexport function createAutolinkingOptionsLoader(\n argumentsOptions?: AutolinkingCommonArguments\n): LinkingOptionsLoader {\n const extraArgumentsOptions = parseExtraArgumentsOptions(argumentsOptions ?? {});\n const { commandRoot } = extraArgumentsOptions;\n\n let _packageJsonPath$: Promise<string> | undefined;\n const getPackageJsonPath = () => {\n return _packageJsonPath$ || (_packageJsonPath$ = findPackageJsonPathAsync(commandRoot));\n };\n\n let _packageJson$: Promise<Record<string, unknown>> | undefined;\n const getPackageJson = async () =>\n _packageJson$ || (_packageJson$ = loadPackageJSONAsync(await getPackageJsonPath()));\n\n const getAppRoot = async () => path.dirname(await getPackageJsonPath());\n\n return {\n getCommandRoot: () => commandRoot,\n getAppRoot,\n async getPlatformOptions(platform = extraArgumentsOptions.platform) {\n const packageJson = await getPackageJson();\n const appRoot = await getAppRoot();\n const options = parsePackageJsonOptions(packageJson, appRoot, platform);\n\n if (extraArgumentsOptions.extraSearchPaths) {\n options.searchPaths = [\n ...extraArgumentsOptions.extraSearchPaths,\n ...(options.searchPaths ?? []),\n ];\n }\n if (extraArgumentsOptions.extraExclude) {\n options.exclude = [...(options.exclude ?? []), ...extraArgumentsOptions.extraExclude];\n }\n\n return {\n ...normalizeAutolinkingOptions(options, appRoot),\n platform,\n };\n },\n };\n}\n\nconst normalizeAutolinkingOptions = (\n options: Partial<AutolinkingOptions>,\n appRoot: string\n): AutolinkingOptions => {\n return {\n legacy_shallowReactNativeLinking: options.legacy_shallowReactNativeLinking ?? false,\n searchPaths: options.searchPaths ?? [],\n nativeModulesDir: options.nativeModulesDir\n ? (resolvePathMaybe(options.nativeModulesDir, appRoot) ?? null)\n : (resolvePathMaybe('./modules', appRoot) ?? null),\n exclude: options.exclude ?? [],\n buildFromSource: options.buildFromSource,\n flags: options.flags,\n };\n};\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateModulesProviderCommand = generateModulesProviderCommand;
|
|
4
|
+
const autolinkingOptions_1 = require("./autolinkingOptions");
|
|
5
|
+
const findModules_1 = require("../autolinking/findModules");
|
|
6
|
+
const generatePackageList_1 = require("../autolinking/generatePackageList");
|
|
7
|
+
const resolveModules_1 = require("../autolinking/resolveModules");
|
|
8
|
+
/** Generates a source file listing all packages to link in the runtime */
|
|
9
|
+
function generateModulesProviderCommand(cli) {
|
|
10
|
+
return (0, autolinkingOptions_1.registerAutolinkingArguments)(cli.command('generate-modules-provider [searchPaths...]'))
|
|
11
|
+
.option('-t, --target <path>', 'Path to the target file, where the package list should be written to.')
|
|
12
|
+
.option('--entitlement <path>', 'Path to the Apple code signing entitlements file.')
|
|
13
|
+
.option('-p, --packages <packages...>', 'Names of the packages to include in the generated modules provider.')
|
|
14
|
+
.action(async (searchPaths, commandArguments) => {
|
|
15
|
+
const platform = commandArguments.platform ?? 'apple';
|
|
16
|
+
const autolinkingOptionsLoader = (0, autolinkingOptions_1.createAutolinkingOptionsLoader)({
|
|
17
|
+
...commandArguments,
|
|
18
|
+
searchPaths,
|
|
19
|
+
});
|
|
20
|
+
const autolinkingOptions = await autolinkingOptionsLoader.getPlatformOptions(platform);
|
|
21
|
+
const expoModulesSearchResults = await (0, findModules_1.findModulesAsync)({
|
|
22
|
+
autolinkingOptions: await autolinkingOptionsLoader.getPlatformOptions(platform),
|
|
23
|
+
appRoot: await autolinkingOptionsLoader.getAppRoot(),
|
|
24
|
+
});
|
|
25
|
+
const expoModulesResolveResults = await (0, resolveModules_1.resolveModulesAsync)(expoModulesSearchResults, autolinkingOptions);
|
|
26
|
+
const includeModules = new Set(commandArguments.packages ?? []);
|
|
27
|
+
const filteredModules = expoModulesResolveResults.filter((module) => includeModules.has(module.packageName));
|
|
28
|
+
await (0, generatePackageList_1.generateModulesProviderAsync)(filteredModules, {
|
|
29
|
+
platform,
|
|
30
|
+
targetPath: commandArguments.target,
|
|
31
|
+
entitlementPath: commandArguments.entitlement ?? null,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=generateModulesProviderCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateModulesProviderCommand.js","sourceRoot":"","sources":["../../src/commands/generateModulesProviderCommand.ts"],"names":[],"mappings":";;AAkBA,wEAyCC;AAzDD,6DAI8B;AAC9B,4DAA8D;AAC9D,4EAAkF;AAClF,kEAAoE;AAQpE,0EAA0E;AAC1E,SAAgB,8BAA8B,CAAC,GAA8B;IAC3E,OAAO,IAAA,iDAA4B,EAAC,GAAG,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAAC;SAC3F,MAAM,CACL,qBAAqB,EACrB,uEAAuE,CACxE;SACA,MAAM,CAAC,sBAAsB,EAAE,mDAAmD,CAAC;SACnF,MAAM,CACL,8BAA8B,EAC9B,qEAAqE,CACtE;SACA,MAAM,CACL,KAAK,EAAE,WAA4B,EAAE,gBAAkD,EAAE,EAAE;QACzF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,IAAI,OAAO,CAAC;QACtD,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC;YAC9D,GAAG,gBAAgB;YACnB,WAAW;SACZ,CAAC,CAAC;QACH,MAAM,kBAAkB,GAAG,MAAM,wBAAwB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAEvF,MAAM,wBAAwB,GAAG,MAAM,IAAA,8BAAgB,EAAC;YACtD,kBAAkB,EAAE,MAAM,wBAAwB,CAAC,kBAAkB,CAAC,QAAQ,CAAC;YAC/E,OAAO,EAAE,MAAM,wBAAwB,CAAC,UAAU,EAAE;SACrD,CAAC,CAAC;QACH,MAAM,yBAAyB,GAAG,MAAM,IAAA,oCAAmB,EACzD,wBAAwB,EACxB,kBAAkB,CACnB,CAAC;QAEF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;QAChE,MAAM,eAAe,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAClE,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CACvC,CAAC;QAEF,MAAM,IAAA,kDAA4B,EAAC,eAAe,EAAE;YAClD,QAAQ;YACR,UAAU,EAAE,gBAAgB,CAAC,MAAM;YACnC,eAAe,EAAE,gBAAgB,CAAC,WAAW,IAAI,IAAI;SACtD,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACN,CAAC","sourcesContent":["import commander from 'commander';\n\nimport {\n AutolinkingCommonArguments,\n createAutolinkingOptionsLoader,\n registerAutolinkingArguments,\n} from './autolinkingOptions';\nimport { findModulesAsync } from '../autolinking/findModules';\nimport { generateModulesProviderAsync } from '../autolinking/generatePackageList';\nimport { resolveModulesAsync } from '../autolinking/resolveModules';\n\ninterface GenerateModulesProviderArguments extends AutolinkingCommonArguments {\n target: string;\n entitlement?: string;\n packages?: string[] | null;\n}\n\n/** Generates a source file listing all packages to link in the runtime */\nexport function generateModulesProviderCommand(cli: commander.CommanderStatic) {\n return registerAutolinkingArguments(cli.command('generate-modules-provider [searchPaths...]'))\n .option(\n '-t, --target <path>',\n 'Path to the target file, where the package list should be written to.'\n )\n .option('--entitlement <path>', 'Path to the Apple code signing entitlements file.')\n .option(\n '-p, --packages <packages...>',\n 'Names of the packages to include in the generated modules provider.'\n )\n .action(\n async (searchPaths: string[] | null, commandArguments: GenerateModulesProviderArguments) => {\n const platform = commandArguments.platform ?? 'apple';\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader({\n ...commandArguments,\n searchPaths,\n });\n const autolinkingOptions = await autolinkingOptionsLoader.getPlatformOptions(platform);\n\n const expoModulesSearchResults = await findModulesAsync({\n autolinkingOptions: await autolinkingOptionsLoader.getPlatformOptions(platform),\n appRoot: await autolinkingOptionsLoader.getAppRoot(),\n });\n const expoModulesResolveResults = await resolveModulesAsync(\n expoModulesSearchResults,\n autolinkingOptions\n );\n\n const includeModules = new Set(commandArguments.packages ?? []);\n const filteredModules = expoModulesResolveResults.filter((module) =>\n includeModules.has(module.packageName)\n );\n\n await generateModulesProviderAsync(filteredModules, {\n platform,\n targetPath: commandArguments.target,\n entitlementPath: commandArguments.entitlement ?? null,\n });\n }\n );\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import commander from 'commander';
|
|
2
|
+
/** Generates a source file listing all packages to link.
|
|
3
|
+
* @privateRemarks
|
|
4
|
+
* This command is deprecated for apple platforms, use `generate-modules-provider` instead.
|
|
5
|
+
*/
|
|
6
|
+
export declare function generatePackageListCommand(cli: commander.CommanderStatic): commander.Command;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generatePackageListCommand = generatePackageListCommand;
|
|
4
|
+
const autolinkingOptions_1 = require("./autolinkingOptions");
|
|
5
|
+
const findModules_1 = require("../autolinking/findModules");
|
|
6
|
+
const generatePackageList_1 = require("../autolinking/generatePackageList");
|
|
7
|
+
const resolveModules_1 = require("../autolinking/resolveModules");
|
|
8
|
+
/** Generates a source file listing all packages to link.
|
|
9
|
+
* @privateRemarks
|
|
10
|
+
* This command is deprecated for apple platforms, use `generate-modules-provider` instead.
|
|
11
|
+
*/
|
|
12
|
+
function generatePackageListCommand(cli) {
|
|
13
|
+
return (0, autolinkingOptions_1.registerAutolinkingArguments)(cli.command('generate-package-list [searchPaths...]'))
|
|
14
|
+
.option('-t, --target <path>', 'Path to the target file, where the package list should be written to.')
|
|
15
|
+
.option('-n, --namespace <namespace>', 'Java package name under which the package list should be placed.')
|
|
16
|
+
.option('--empty', 'Whether to only generate an empty list. Might be used when the user opts-out of autolinking.', false)
|
|
17
|
+
.action(async (searchPaths, commandArguments) => {
|
|
18
|
+
const platform = commandArguments.platform ?? 'android';
|
|
19
|
+
const autolinkingOptionsLoader = (0, autolinkingOptions_1.createAutolinkingOptionsLoader)({
|
|
20
|
+
...commandArguments,
|
|
21
|
+
searchPaths,
|
|
22
|
+
});
|
|
23
|
+
let expoModulesResolveResults = [];
|
|
24
|
+
if (!commandArguments.empty) {
|
|
25
|
+
const autolinkingOptions = await autolinkingOptionsLoader.getPlatformOptions(platform);
|
|
26
|
+
const expoModulesSearchResults = await (0, findModules_1.findModulesAsync)({
|
|
27
|
+
autolinkingOptions: await autolinkingOptionsLoader.getPlatformOptions(platform),
|
|
28
|
+
appRoot: await autolinkingOptionsLoader.getAppRoot(),
|
|
29
|
+
});
|
|
30
|
+
expoModulesResolveResults = await (0, resolveModules_1.resolveModulesAsync)(expoModulesSearchResults, autolinkingOptions);
|
|
31
|
+
}
|
|
32
|
+
await (0, generatePackageList_1.generatePackageListAsync)(expoModulesResolveResults, {
|
|
33
|
+
platform,
|
|
34
|
+
targetPath: commandArguments.target,
|
|
35
|
+
namespace: commandArguments.namespace,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=generatePackageListCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generatePackageListCommand.js","sourceRoot":"","sources":["../../src/commands/generatePackageListCommand.ts"],"names":[],"mappings":";;AAsBA,gEA4CC;AAhED,6DAI8B;AAC9B,4DAA8D;AAC9D,4EAA8E;AAC9E,kEAAoE;AASpE;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,GAA8B;IACvE,OAAO,IAAA,iDAA4B,EAAC,GAAG,CAAC,OAAO,CAAC,wCAAwC,CAAC,CAAC;SACvF,MAAM,CACL,qBAAqB,EACrB,uEAAuE,CACxE;SACA,MAAM,CACL,6BAA6B,EAC7B,kEAAkE,CACnE;SACA,MAAM,CACL,SAAS,EACT,8FAA8F,EAC9F,KAAK,CACN;SACA,MAAM,CACL,KAAK,EAAE,WAA4B,EAAE,gBAA8C,EAAE,EAAE;QACrF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,IAAI,SAAS,CAAC;QACxD,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC;YAC9D,GAAG,gBAAgB;YACnB,WAAW;SACZ,CAAC,CAAC;QAEH,IAAI,yBAAyB,GAAuB,EAAE,CAAC;QACvD,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAC5B,MAAM,kBAAkB,GAAG,MAAM,wBAAwB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;YAEvF,MAAM,wBAAwB,GAAG,MAAM,IAAA,8BAAgB,EAAC;gBACtD,kBAAkB,EAAE,MAAM,wBAAwB,CAAC,kBAAkB,CAAC,QAAQ,CAAC;gBAC/E,OAAO,EAAE,MAAM,wBAAwB,CAAC,UAAU,EAAE;aACrD,CAAC,CAAC;YACH,yBAAyB,GAAG,MAAM,IAAA,oCAAmB,EACnD,wBAAwB,EACxB,kBAAkB,CACnB,CAAC;QACJ,CAAC;QAED,MAAM,IAAA,8CAAwB,EAAC,yBAAyB,EAAE;YACxD,QAAQ;YACR,UAAU,EAAE,gBAAgB,CAAC,MAAM;YACnC,SAAS,EAAE,gBAAgB,CAAC,SAAS;SACtC,CAAC,CAAC;IACL,CAAC,CACF,CAAC;AACN,CAAC","sourcesContent":["import commander from 'commander';\n\nimport {\n AutolinkingCommonArguments,\n createAutolinkingOptionsLoader,\n registerAutolinkingArguments,\n} from './autolinkingOptions';\nimport { findModulesAsync } from '../autolinking/findModules';\nimport { generatePackageListAsync } from '../autolinking/generatePackageList';\nimport { resolveModulesAsync } from '../autolinking/resolveModules';\nimport type { ModuleDescriptor } from '../types';\n\ninterface GeneratePackageListArguments extends AutolinkingCommonArguments {\n target: string;\n namespace: string;\n empty: boolean;\n}\n\n/** Generates a source file listing all packages to link.\n * @privateRemarks\n * This command is deprecated for apple platforms, use `generate-modules-provider` instead.\n */\nexport function generatePackageListCommand(cli: commander.CommanderStatic) {\n return registerAutolinkingArguments(cli.command('generate-package-list [searchPaths...]'))\n .option(\n '-t, --target <path>',\n 'Path to the target file, where the package list should be written to.'\n )\n .option(\n '-n, --namespace <namespace>',\n 'Java package name under which the package list should be placed.'\n )\n .option(\n '--empty',\n 'Whether to only generate an empty list. Might be used when the user opts-out of autolinking.',\n false\n )\n .action(\n async (searchPaths: string[] | null, commandArguments: GeneratePackageListArguments) => {\n const platform = commandArguments.platform ?? 'android';\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader({\n ...commandArguments,\n searchPaths,\n });\n\n let expoModulesResolveResults: ModuleDescriptor[] = [];\n if (!commandArguments.empty) {\n const autolinkingOptions = await autolinkingOptionsLoader.getPlatformOptions(platform);\n\n const expoModulesSearchResults = await findModulesAsync({\n autolinkingOptions: await autolinkingOptionsLoader.getPlatformOptions(platform),\n appRoot: await autolinkingOptionsLoader.getAppRoot(),\n });\n expoModulesResolveResults = await resolveModulesAsync(\n expoModulesSearchResults,\n autolinkingOptions\n );\n }\n\n await generatePackageListAsync(expoModulesResolveResults, {\n platform,\n targetPath: commandArguments.target,\n namespace: commandArguments.namespace,\n });\n }\n );\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactNativeConfigCommand = reactNativeConfigCommand;
|
|
4
|
+
const autolinkingOptions_1 = require("./autolinkingOptions");
|
|
5
|
+
const reactNativeConfig_1 = require("../reactNativeConfig");
|
|
6
|
+
/** The react-native-config command (like RN CLI linking) */
|
|
7
|
+
function reactNativeConfigCommand(cli) {
|
|
8
|
+
return (0, autolinkingOptions_1.registerAutolinkingArguments)(cli.command('react-native-config [searchPaths...]'))
|
|
9
|
+
.option('-p, --platform [platform]', 'The platform that the resulting modules must support. Available options: "android", "ios"', 'ios')
|
|
10
|
+
.option('--source-dir <sourceDir>', 'The path to the native source directory')
|
|
11
|
+
.option('-j, --json', 'Output results in the plain JSON format.', () => true, false)
|
|
12
|
+
.action(async (searchPaths, commandArguments) => {
|
|
13
|
+
// TODO(@kitten): Do we need to restrict this?
|
|
14
|
+
const platform = commandArguments.platform ?? 'ios';
|
|
15
|
+
if (platform !== 'android' && platform !== 'ios') {
|
|
16
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
17
|
+
}
|
|
18
|
+
const autolinkingOptionsLoader = (0, autolinkingOptions_1.createAutolinkingOptionsLoader)({
|
|
19
|
+
...commandArguments,
|
|
20
|
+
searchPaths,
|
|
21
|
+
});
|
|
22
|
+
const reactNativeConfig = await (0, reactNativeConfig_1.createReactNativeConfigAsync)({
|
|
23
|
+
autolinkingOptions: await autolinkingOptionsLoader.getPlatformOptions(platform),
|
|
24
|
+
appRoot: await autolinkingOptionsLoader.getAppRoot(),
|
|
25
|
+
// NOTE(@kitten): This is currently not validated, and assumed to be validated later
|
|
26
|
+
sourceDir: commandArguments.sourceDir ?? undefined,
|
|
27
|
+
});
|
|
28
|
+
if (commandArguments.json) {
|
|
29
|
+
console.log(JSON.stringify(reactNativeConfig));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.log(require('util').inspect(reactNativeConfig, false, null, true));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=reactNativeConfigCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactNativeConfigCommand.js","sourceRoot":"","sources":["../../src/commands/reactNativeConfigCommand.ts"],"names":[],"mappings":";;AAeA,4DAkCC;AA/CD,6DAI8B;AAC9B,4DAAoE;AAOpE,4DAA4D;AAC5D,SAAgB,wBAAwB,CAAC,GAA8B;IACrE,OAAO,IAAA,iDAA4B,EAAC,GAAG,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC;SACrF,MAAM,CACL,2BAA2B,EAC3B,2FAA2F,EAC3F,KAAK,CACN;SACA,MAAM,CAAC,0BAA0B,EAAE,yCAAyC,CAAC;SAC7E,MAAM,CAAC,YAAY,EAAE,0CAA0C,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;SACnF,MAAM,CAAC,KAAK,EAAE,WAA4B,EAAE,gBAA4C,EAAE,EAAE;QAC3F,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,IAAI,KAAK,CAAC;QACpD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC;YAC9D,GAAG,gBAAgB;YACnB,WAAW;SACZ,CAAC,CAAC;QAEH,MAAM,iBAAiB,GAAG,MAAM,IAAA,gDAA4B,EAAC;YAC3D,kBAAkB,EAAE,MAAM,wBAAwB,CAAC,kBAAkB,CAAC,QAAQ,CAAC;YAC/E,OAAO,EAAE,MAAM,wBAAwB,CAAC,UAAU,EAAE;YACpD,oFAAoF;YACpF,SAAS,EAAE,gBAAgB,CAAC,SAAS,IAAI,SAAS;SACnD,CAAC,CAAC;QAEH,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import commander from 'commander';\n\nimport {\n AutolinkingCommonArguments,\n createAutolinkingOptionsLoader,\n registerAutolinkingArguments,\n} from './autolinkingOptions';\nimport { createReactNativeConfigAsync } from '../reactNativeConfig';\n\ninterface ReactNativeConfigArguments extends AutolinkingCommonArguments {\n sourceDir?: string | null;\n json?: boolean | null;\n}\n\n/** The react-native-config command (like RN CLI linking) */\nexport function reactNativeConfigCommand(cli: commander.CommanderStatic) {\n return registerAutolinkingArguments(cli.command('react-native-config [searchPaths...]'))\n .option(\n '-p, --platform [platform]',\n 'The platform that the resulting modules must support. Available options: \"android\", \"ios\"',\n 'ios'\n )\n .option('--source-dir <sourceDir>', 'The path to the native source directory')\n .option('-j, --json', 'Output results in the plain JSON format.', () => true, false)\n .action(async (searchPaths: string[] | null, commandArguments: ReactNativeConfigArguments) => {\n // TODO(@kitten): Do we need to restrict this?\n const platform = commandArguments.platform ?? 'ios';\n if (platform !== 'android' && platform !== 'ios') {\n throw new Error(`Unsupported platform: ${platform}`);\n }\n\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader({\n ...commandArguments,\n searchPaths,\n });\n\n const reactNativeConfig = await createReactNativeConfigAsync({\n autolinkingOptions: await autolinkingOptionsLoader.getPlatformOptions(platform),\n appRoot: await autolinkingOptionsLoader.getAppRoot(),\n // NOTE(@kitten): This is currently not validated, and assumed to be validated later\n sourceDir: commandArguments.sourceDir ?? undefined,\n });\n\n if (commandArguments.json) {\n console.log(JSON.stringify(reactNativeConfig));\n } else {\n console.log(require('util').inspect(reactNativeConfig, false, null, true));\n }\n });\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveCommand = resolveCommand;
|
|
4
|
+
const autolinkingOptions_1 = require("./autolinkingOptions");
|
|
5
|
+
const findModules_1 = require("../autolinking/findModules");
|
|
6
|
+
const getConfiguration_1 = require("../autolinking/getConfiguration");
|
|
7
|
+
const resolveModules_1 = require("../autolinking/resolveModules");
|
|
8
|
+
function hasCoreFeatures(module) {
|
|
9
|
+
return module.coreFeatures !== undefined;
|
|
10
|
+
}
|
|
11
|
+
/** Searches for available expo modules and resolves the results for given platform. */
|
|
12
|
+
function resolveCommand(cli) {
|
|
13
|
+
return (0, autolinkingOptions_1.registerAutolinkingArguments)(cli.command('resolve [searchPaths...]'))
|
|
14
|
+
.option('-j, --json', 'Output results in the plain JSON format.', () => true, false)
|
|
15
|
+
.action(async (searchPaths, commandArguments) => {
|
|
16
|
+
const platform = commandArguments.platform ?? 'apple';
|
|
17
|
+
const autolinkingOptionsLoader = (0, autolinkingOptions_1.createAutolinkingOptionsLoader)({
|
|
18
|
+
...commandArguments,
|
|
19
|
+
searchPaths,
|
|
20
|
+
});
|
|
21
|
+
const autolinkingOptions = await autolinkingOptionsLoader.getPlatformOptions(platform);
|
|
22
|
+
const appRoot = await autolinkingOptionsLoader.getAppRoot();
|
|
23
|
+
const expoModulesSearchResults = await (0, findModules_1.findModulesAsync)({
|
|
24
|
+
autolinkingOptions,
|
|
25
|
+
appRoot,
|
|
26
|
+
});
|
|
27
|
+
const expoModulesResolveResults = await (0, resolveModules_1.resolveModulesAsync)(expoModulesSearchResults, autolinkingOptions);
|
|
28
|
+
const extraDependencies = await (0, resolveModules_1.resolveExtraBuildDependenciesAsync)({
|
|
29
|
+
commandRoot: autolinkingOptionsLoader.getCommandRoot(),
|
|
30
|
+
platform,
|
|
31
|
+
});
|
|
32
|
+
const configuration = (0, getConfiguration_1.getConfiguration)({ autolinkingOptions });
|
|
33
|
+
const coreFeatures = [
|
|
34
|
+
...expoModulesResolveResults.reduce((acc, module) => {
|
|
35
|
+
if (hasCoreFeatures(module)) {
|
|
36
|
+
const features = module.coreFeatures ?? [];
|
|
37
|
+
for (const feature of features) {
|
|
38
|
+
acc.add(feature);
|
|
39
|
+
}
|
|
40
|
+
return acc;
|
|
41
|
+
}
|
|
42
|
+
return acc;
|
|
43
|
+
}, new Set()),
|
|
44
|
+
];
|
|
45
|
+
if (commandArguments.json) {
|
|
46
|
+
console.log(JSON.stringify({
|
|
47
|
+
extraDependencies,
|
|
48
|
+
coreFeatures,
|
|
49
|
+
modules: expoModulesResolveResults,
|
|
50
|
+
...(configuration ? { configuration } : {}),
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.log(require('util').inspect({
|
|
55
|
+
extraDependencies,
|
|
56
|
+
coreFeatures,
|
|
57
|
+
modules: expoModulesResolveResults,
|
|
58
|
+
...(configuration ? { configuration } : {}),
|
|
59
|
+
}, false, null, true));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=resolveCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveCommand.js","sourceRoot":"","sources":["../../src/commands/resolveCommand.ts"],"names":[],"mappings":";;AA+BA,wCAqEC;AAlGD,6DAI8B;AAC9B,4DAA8D;AAC9D,sEAAmE;AACnE,kEAGuC;AAQvC,SAAS,eAAe,CACtB,MAAwB;IAExB,OAAQ,MAAuC,CAAC,YAAY,KAAK,SAAS,CAAC;AAC7E,CAAC;AAMD,uFAAuF;AACvF,SAAgB,cAAc,CAAC,GAA8B;IAC3D,OAAO,IAAA,iDAA4B,EAAC,GAAG,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;SACzE,MAAM,CAAC,YAAY,EAAE,0CAA0C,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;SACnF,MAAM,CAAC,KAAK,EAAE,WAA4B,EAAE,gBAAkC,EAAE,EAAE;QACjF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,IAAI,OAAO,CAAC;QACtD,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC;YAC9D,GAAG,gBAAgB;YACnB,WAAW;SACZ,CAAC,CAAC;QAEH,MAAM,kBAAkB,GAAG,MAAM,wBAAwB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QACvF,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC,UAAU,EAAE,CAAC;QAE5D,MAAM,wBAAwB,GAAG,MAAM,IAAA,8BAAgB,EAAC;YACtD,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,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5C,EACD,KAAK,EACL,IAAI,EACJ,IAAI,CACL,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import commander from 'commander';\n\nimport {\n AutolinkingCommonArguments,\n createAutolinkingOptionsLoader,\n registerAutolinkingArguments,\n} from './autolinkingOptions';\nimport { findModulesAsync } from '../autolinking/findModules';\nimport { getConfiguration } from '../autolinking/getConfiguration';\nimport {\n resolveModulesAsync,\n resolveExtraBuildDependenciesAsync,\n} from '../autolinking/resolveModules';\nimport type {\n ModuleDescriptor,\n CommonNativeModuleDescriptor,\n ModuleDescriptorAndroid,\n ModuleDescriptorIos,\n} from '../types';\n\nfunction hasCoreFeatures(\n module: ModuleDescriptor\n): module is ModuleDescriptorAndroid | ModuleDescriptorIos {\n return (module as CommonNativeModuleDescriptor).coreFeatures !== undefined;\n}\n\ninterface ResolveArguments extends AutolinkingCommonArguments {\n json?: boolean | null;\n}\n\n/** Searches for available expo modules and resolves the results for given platform. */\nexport function resolveCommand(cli: commander.CommanderStatic) {\n return registerAutolinkingArguments(cli.command('resolve [searchPaths...]'))\n .option('-j, --json', 'Output results in the plain JSON format.', () => true, false)\n .action(async (searchPaths: string[] | null, commandArguments: ResolveArguments) => {\n const platform = commandArguments.platform ?? 'apple';\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader({\n ...commandArguments,\n searchPaths,\n });\n\n const autolinkingOptions = await autolinkingOptionsLoader.getPlatformOptions(platform);\n const appRoot = await autolinkingOptionsLoader.getAppRoot();\n\n const expoModulesSearchResults = await findModulesAsync({\n autolinkingOptions,\n appRoot,\n });\n\n const expoModulesResolveResults = await resolveModulesAsync(\n expoModulesSearchResults,\n autolinkingOptions\n );\n\n const extraDependencies = await resolveExtraBuildDependenciesAsync({\n commandRoot: autolinkingOptionsLoader.getCommandRoot(),\n platform,\n });\n\n const configuration = getConfiguration({ autolinkingOptions });\n\n const coreFeatures = [\n ...expoModulesResolveResults.reduce<Set<string>>((acc, module) => {\n if (hasCoreFeatures(module)) {\n const features = module.coreFeatures ?? [];\n for (const feature of features) {\n acc.add(feature);\n }\n return acc;\n }\n\n return acc;\n }, new Set()),\n ];\n\n if (commandArguments.json) {\n console.log(\n JSON.stringify({\n extraDependencies,\n coreFeatures,\n modules: expoModulesResolveResults,\n ...(configuration ? { configuration } : {}),\n })\n );\n } else {\n console.log(\n require('util').inspect(\n {\n extraDependencies,\n coreFeatures,\n modules: expoModulesResolveResults,\n ...(configuration ? { configuration } : {}),\n },\n false,\n null,\n true\n )\n );\n }\n });\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.searchCommand = searchCommand;
|
|
4
|
+
const autolinkingOptions_1 = require("./autolinkingOptions");
|
|
5
|
+
const findModules_1 = require("../autolinking/findModules");
|
|
6
|
+
function searchCommand(cli) {
|
|
7
|
+
return (0, autolinkingOptions_1.registerAutolinkingArguments)(cli.command('search [searchPaths...]'))
|
|
8
|
+
.option('-j, --json', 'Output results in the plain JSON format.', () => true, false)
|
|
9
|
+
.action(async (searchPaths, commandArguments) => {
|
|
10
|
+
const platform = commandArguments.platform ?? 'apple';
|
|
11
|
+
const autolinkingOptionsLoader = (0, autolinkingOptions_1.createAutolinkingOptionsLoader)({
|
|
12
|
+
...commandArguments,
|
|
13
|
+
searchPaths,
|
|
14
|
+
});
|
|
15
|
+
const expoModulesSearchResults = await (0, findModules_1.findModulesAsync)({
|
|
16
|
+
autolinkingOptions: await autolinkingOptionsLoader.getPlatformOptions(platform),
|
|
17
|
+
appRoot: await autolinkingOptionsLoader.getAppRoot(),
|
|
18
|
+
});
|
|
19
|
+
if (commandArguments.json) {
|
|
20
|
+
console.log(JSON.stringify(expoModulesSearchResults));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
console.log(require('util').inspect(expoModulesSearchResults, false, null, true));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=searchCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"searchCommand.js","sourceRoot":"","sources":["../../src/commands/searchCommand.ts"],"names":[],"mappings":";;AAaA,sCAqBC;AAhCD,6DAI8B;AAC9B,4DAA8D;AAM9D,SAAgB,aAAa,CAAC,GAA8B;IAC1D,OAAO,IAAA,iDAA4B,EAAC,GAAG,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;SACxE,MAAM,CAAC,YAAY,EAAE,0CAA0C,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;SACnF,MAAM,CAAC,KAAK,EAAE,WAA4B,EAAE,gBAAiC,EAAE,EAAE;QAChF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,IAAI,OAAO,CAAC;QACtD,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC;YAC9D,GAAG,gBAAgB;YACnB,WAAW;SACZ,CAAC,CAAC;QAEH,MAAM,wBAAwB,GAAG,MAAM,IAAA,8BAAgB,EAAC;YACtD,kBAAkB,EAAE,MAAM,wBAAwB,CAAC,kBAAkB,CAAC,QAAQ,CAAC;YAC/E,OAAO,EAAE,MAAM,wBAAwB,CAAC,UAAU,EAAE;SACrD,CAAC,CAAC;QAEH,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,wBAAwB,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACpF,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import commander from 'commander';\n\nimport {\n AutolinkingCommonArguments,\n createAutolinkingOptionsLoader,\n registerAutolinkingArguments,\n} from './autolinkingOptions';\nimport { findModulesAsync } from '../autolinking/findModules';\n\ninterface SearchArguments extends AutolinkingCommonArguments {\n json?: boolean | null;\n}\n\nexport function searchCommand(cli: commander.CommanderStatic) {\n return registerAutolinkingArguments(cli.command('search [searchPaths...]'))\n .option('-j, --json', 'Output results in the plain JSON format.', () => true, false)\n .action(async (searchPaths: string[] | null, commandArguments: SearchArguments) => {\n const platform = commandArguments.platform ?? 'apple';\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader({\n ...commandArguments,\n searchPaths,\n });\n\n const expoModulesSearchResults = await findModulesAsync({\n autolinkingOptions: await autolinkingOptionsLoader.getPlatformOptions(platform),\n appRoot: await autolinkingOptionsLoader.getAppRoot(),\n });\n\n if (commandArguments.json) {\n console.log(JSON.stringify(expoModulesSearchResults));\n } else {\n console.log(require('util').inspect(expoModulesSearchResults, false, null, true));\n }\n });\n}\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import commander from 'commander';
|
|
2
|
+
import { type ResolutionResult } from '../dependencies';
|
|
3
|
+
export declare function verifyCommand(cli: commander.CommanderStatic): commander.Command;
|
|
2
4
|
interface VerifyOptions {
|
|
3
|
-
|
|
5
|
+
appRoot: string;
|
|
4
6
|
verbose?: boolean;
|
|
5
7
|
json?: boolean;
|
|
6
8
|
}
|
|
@@ -3,15 +3,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.verifyCommand = verifyCommand;
|
|
6
7
|
exports.verifySearchResults = verifySearchResults;
|
|
7
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
9
|
const fs_1 = __importDefault(require("fs"));
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const autolinkingOptions_1 = require("./autolinkingOptions");
|
|
12
|
+
const dependencies_1 = require("../dependencies");
|
|
13
|
+
function verifyCommand(cli) {
|
|
14
|
+
return (0, autolinkingOptions_1.registerAutolinkingArguments)(cli.command('verify'))
|
|
15
|
+
.option('-v, --verbose', 'Output all results instead of just warnings.', () => true, false)
|
|
16
|
+
.option('-j, --json', 'Output results in the plain JSON format.', () => true, false)
|
|
17
|
+
.option('-p, --platform [platform]', 'The platform to validate native modules for. Available options: "android", "ios", "both"', 'both')
|
|
18
|
+
.action(async (commandArguments) => {
|
|
19
|
+
const platforms = commandArguments.platform === 'both' ? ['android', 'ios'] : [commandArguments.platform];
|
|
20
|
+
const autolinkingOptionsLoader = (0, autolinkingOptions_1.createAutolinkingOptionsLoader)(commandArguments);
|
|
21
|
+
const appRoot = await autolinkingOptionsLoader.getAppRoot();
|
|
22
|
+
const linker = (0, dependencies_1.makeCachedDependenciesLinker)({ projectRoot: appRoot });
|
|
23
|
+
const results = (0, dependencies_1.mergeResolutionResults)(await Promise.all(platforms.map((platform) => (0, dependencies_1.scanDependencyResolutionsForPlatform)(linker, platform))));
|
|
24
|
+
await verifySearchResults(results, {
|
|
25
|
+
appRoot,
|
|
26
|
+
verbose: !!commandArguments.verbose,
|
|
27
|
+
json: !!commandArguments.json,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
10
31
|
/**
|
|
11
32
|
* Verifies the search results by checking whether there are no duplicates.
|
|
12
33
|
*/
|
|
13
34
|
async function verifySearchResults(results, options) {
|
|
14
|
-
const {
|
|
35
|
+
const { appRoot } = options;
|
|
15
36
|
async function getHumanReadableDependency(dependency) {
|
|
16
37
|
let version = dependency.version || null;
|
|
17
38
|
if (!version) {
|
|
@@ -26,7 +47,7 @@ async function verifySearchResults(results, options) {
|
|
|
26
47
|
version = null;
|
|
27
48
|
}
|
|
28
49
|
}
|
|
29
|
-
const relative = path_1.default.relative(
|
|
50
|
+
const relative = path_1.default.relative(appRoot, dependency.originPath);
|
|
30
51
|
return version
|
|
31
52
|
? `${dependency.name}@${version} (at: ${relative})`
|
|
32
53
|
: `${dependency.name} at: ${relative}`;
|
|
@@ -98,4 +119,4 @@ async function verifySearchResults(results, options) {
|
|
|
98
119
|
console.log('✅ Everything is fine!');
|
|
99
120
|
}
|
|
100
121
|
}
|
|
101
|
-
//# sourceMappingURL=
|
|
122
|
+
//# sourceMappingURL=verifyCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyCommand.js","sourceRoot":"","sources":["../../src/commands/verifyCommand.ts"],"names":[],"mappings":";;;;;AAyBA,sCA0BC;AAkBD,kDAsGC;AA3KD,kDAA0B;AAE1B,4CAAoB;AACpB,gDAAwB;AAExB,6DAI8B;AAC9B,kDAQyB;AAOzB,SAAgB,aAAa,CAAC,GAA8B;IAC1D,OAAO,IAAA,iDAA4B,EAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SACvD,MAAM,CAAC,eAAe,EAAE,8CAA8C,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;SAC1F,MAAM,CAAC,YAAY,EAAE,0CAA0C,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC;SACnF,MAAM,CACL,2BAA2B,EAC3B,0FAA0F,EAC1F,MAAM,CACP;SACA,MAAM,CAAC,KAAK,EAAE,gBAAiC,EAAE,EAAE;QAClD,MAAM,SAAS,GACb,gBAAgB,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,QAAS,CAAC,CAAC;QAC3F,MAAM,wBAAwB,GAAG,IAAA,mDAA8B,EAAC,gBAAgB,CAAC,CAAC;QAClF,MAAM,OAAO,GAAG,MAAM,wBAAwB,CAAC,UAAU,EAAE,CAAC;QAC5D,MAAM,MAAM,GAAG,IAAA,2CAA4B,EAAC,EAAE,WAAW,EAA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C,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;gBAChD,MAAM,MAAM,GAAG,GAAG,KAAK,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC1D,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,IAAI,MAAM,0BAA0B,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;QAED,OAAO,CAAC,IAAI,CACV,qGAAqG;YACnG,4HAA4H,CAC/H,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACvC,CAAC;AACH,CAAC","sourcesContent":["import chalk from 'chalk';\nimport commander from 'commander';\nimport fs from 'fs';\nimport path from 'path';\n\nimport {\n AutolinkingCommonArguments,\n createAutolinkingOptionsLoader,\n registerAutolinkingArguments,\n} from './autolinkingOptions';\nimport {\n type BaseDependencyResolution,\n type DependencyResolution,\n type ResolutionResult,\n DependencyResolutionSource,\n makeCachedDependenciesLinker,\n mergeResolutionResults,\n scanDependencyResolutionsForPlatform,\n} from '../dependencies';\n\ninterface VerifyArguments extends AutolinkingCommonArguments {\n verbose?: boolean | null;\n json?: boolean | null;\n}\n\nexport function verifyCommand(cli: commander.CommanderStatic) {\n return registerAutolinkingArguments(cli.command('verify'))\n .option('-v, --verbose', 'Output all results instead of just warnings.', () => true, false)\n .option('-j, --json', 'Output results in the plain JSON format.', () => true, false)\n .option(\n '-p, --platform [platform]',\n 'The platform to validate native modules for. Available options: \"android\", \"ios\", \"both\"',\n 'both'\n )\n .action(async (commandArguments: VerifyArguments) => {\n const platforms =\n commandArguments.platform === 'both' ? ['android', 'ios'] : [commandArguments.platform!];\n const autolinkingOptionsLoader = createAutolinkingOptionsLoader(commandArguments);\n const appRoot = await autolinkingOptionsLoader.getAppRoot();\n const linker = makeCachedDependenciesLinker({ projectRoot: appRoot });\n const results = mergeResolutionResults(\n await Promise.all(\n platforms.map((platform) => scanDependencyResolutionsForPlatform(linker, platform))\n )\n );\n await verifySearchResults(results, {\n appRoot,\n verbose: !!commandArguments.verbose,\n json: !!commandArguments.json,\n });\n });\n}\n\ninterface VerifyOptions {\n appRoot: string;\n verbose?: boolean;\n json?: boolean;\n}\n\ninterface VerifyGroups {\n reactNativeProjectConfig: DependencyResolution[];\n searchPaths: DependencyResolution[];\n dependencies: DependencyResolution[];\n duplicates: DependencyResolution[];\n}\n\n/**\n * Verifies the search results by checking whether there are no duplicates.\n */\nexport async function verifySearchResults(\n results: ResolutionResult,\n options: VerifyOptions\n): Promise<void> {\n const { appRoot } = options;\n\n async function getHumanReadableDependency(dependency: BaseDependencyResolution): Promise<string> {\n let version = dependency.version || null;\n if (!version) {\n try {\n const pkgContents = await fs.promises.readFile(\n path.join(dependency.path, 'package.json'),\n 'utf8'\n );\n const pkg: unknown = JSON.parse(pkgContents);\n if (pkg && typeof pkg === 'object' && 'version' in pkg && typeof pkg.version === 'string') {\n version = pkg.version;\n }\n } catch (error) {\n version = null;\n }\n }\n const relative = path.relative(appRoot, dependency.originPath);\n return version\n ? `${dependency.name}@${version} (at: ${relative})`\n : `${dependency.name} at: ${relative}`;\n }\n\n const groups: VerifyGroups = {\n reactNativeProjectConfig: [],\n searchPaths: [],\n dependencies: [],\n duplicates: [],\n };\n\n for (const moduleName in results) {\n const revision = results[moduleName];\n if (!revision) {\n continue;\n } else if (revision.duplicates?.length) {\n groups.duplicates.push(revision);\n } else {\n switch (revision.source) {\n case DependencyResolutionSource.RN_CLI_LOCAL:\n groups.reactNativeProjectConfig.push(revision);\n break;\n case DependencyResolutionSource.SEARCH_PATH:\n groups.searchPaths.push(revision);\n break;\n case DependencyResolutionSource.RECURSIVE_RESOLUTION:\n groups.dependencies.push(revision);\n break;\n }\n }\n }\n\n if (options.json) {\n console.log(JSON.stringify(groups));\n return;\n }\n\n if (options.verbose) {\n if (groups.reactNativeProjectConfig.length) {\n console.log(\n `🔎 Found ${groups.reactNativeProjectConfig.length} modules from React Native project config`\n );\n for (const revision of groups.reactNativeProjectConfig) {\n console.log(` - ${await getHumanReadableDependency(revision)}`);\n }\n }\n\n if (groups.searchPaths.length) {\n console.log(`🔎 Found ${groups.searchPaths.length} modules in search paths`);\n for (const revision of groups.searchPaths) {\n console.log(` - ${await getHumanReadableDependency(revision)}`);\n }\n }\n\n console.log(`🔎 Found ${groups.dependencies.length} modules in dependencies`);\n for (const revision of groups.dependencies) {\n console.log(` - ${await getHumanReadableDependency(revision)}`);\n }\n }\n\n if (groups.duplicates.length) {\n for (const revision of groups.duplicates) {\n console.warn(`⚠️ Found duplicate installations for ${chalk.green(revision.name)}`);\n const revisions = [revision, ...(revision.duplicates ?? [])];\n for (let idx = 0; idx < revisions.length; idx++) {\n const prefix = idx !== revisions.length - 1 ? '├─' : '└─';\n const duplicate = revisions[idx];\n console.log(` ${prefix} ${await getHumanReadableDependency(duplicate)}`);\n }\n }\n\n console.warn(\n '⚠️ Multiple versions of the same module may introduce some side effects or compatibility issues.\\n' +\n `Resolve your dependency issues and deduplicate your dependencies. Learn more: https://expo.fyi/resolving-dependency-issues`\n );\n } else {\n console.log('✅ Everything is fine!');\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SupportedPlatform } from '../
|
|
1
|
+
import { PackageRevision, SupportedPlatform } from '../types';
|
|
2
2
|
import { type ResolutionResult } from './types';
|
|
3
3
|
import { RNConfigReactNativeProjectConfig } from '../reactNativeConfig';
|
|
4
4
|
export interface CachedDependenciesSearchOptions {
|
|
@@ -16,3 +16,4 @@ export declare function makeCachedDependenciesLinker(params: {
|
|
|
16
16
|
projectRoot: string;
|
|
17
17
|
}): CachedDependenciesLinker;
|
|
18
18
|
export declare function scanDependencyResolutionsForPlatform(linker: CachedDependenciesLinker, platform: SupportedPlatform, include?: string[]): Promise<ResolutionResult>;
|
|
19
|
+
export declare function scanExpoModuleResolutionsForPlatform(linker: CachedDependenciesLinker, platform: SupportedPlatform): Promise<Record<string, PackageRevision>>;
|