@expo/fingerprint 0.0.10 → 0.1.0

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 ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## Unpublished
4
+
5
+ ### 🛠 Breaking changes
6
+
7
+ ### 🎉 New features
8
+
9
+ ### 🐛 Bug fixes
10
+
11
+ ### 💡 Others
12
+
13
+ ## 0.1.0 — 2023-08-29
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - The fingerprint result is changed since this version. ([24097](https://github.com/expo/expo/pull/24097) by [@kudo](https://github.com/kudo))
18
+
19
+ ### 🎉 New features
20
+
21
+ - Added `diffFingerprints()` to support diff for two fingerprints. ([24097](https://github.com/expo/expo/pull/24097) by [@kudo](https://github.com/kudo))
22
+
23
+ ### 🐛 Bug fixes
24
+
25
+ - Fixed non-deterministic hash if packages hoisted from monorepo. ([24097](https://github.com/expo/expo/pull/24097) by [@kudo](https://github.com/kudo))
@@ -11,3 +11,7 @@ export declare function createProjectHashAsync(projectRoot: string, options?: Op
11
11
  * Differentiate given `fingerprint` with the current project fingerprint state
12
12
  */
13
13
  export declare function diffFingerprintChangesAsync(fingerprint: Fingerprint, projectRoot: string, options?: Options): Promise<FingerprintSource[]>;
14
+ /**
15
+ * Differentiate two fingerprints
16
+ */
17
+ export declare function diffFingerprints(fingerprint1: Fingerprint, fingerprint2: Fingerprint): FingerprintSource[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.diffFingerprintChangesAsync = exports.createProjectHashAsync = exports.createFingerprintAsync = void 0;
3
+ exports.diffFingerprints = exports.diffFingerprintChangesAsync = exports.createProjectHashAsync = exports.createFingerprintAsync = void 0;
4
4
  const Dedup_1 = require("./Dedup");
5
5
  const Options_1 = require("./Options");
6
6
  const Sort_1 = require("./Sort");
@@ -33,10 +33,16 @@ async function diffFingerprintChangesAsync(fingerprint, projectRoot, options) {
33
33
  if (fingerprint.hash === newFingerprint.hash) {
34
34
  return [];
35
35
  }
36
- const result = newFingerprint.sources.filter((newItem) => {
37
- return !fingerprint.sources.find((item) => item.type === newItem.type && item.hash === newItem.hash);
38
- });
39
- return result;
36
+ return diffFingerprints(fingerprint, newFingerprint);
40
37
  }
41
38
  exports.diffFingerprintChangesAsync = diffFingerprintChangesAsync;
39
+ /**
40
+ * Differentiate two fingerprints
41
+ */
42
+ function diffFingerprints(fingerprint1, fingerprint2) {
43
+ return fingerprint2.sources.filter((newItem) => {
44
+ return !fingerprint1.sources.find((item) => item.type === newItem.type && item.hash === newItem.hash);
45
+ });
46
+ }
47
+ exports.diffFingerprints = diffFingerprints;
42
48
  //# sourceMappingURL=Fingerprint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Fingerprint.js","sourceRoot":"","sources":["../src/Fingerprint.ts"],"names":[],"mappings":";;;AAAA,mCAAuC;AAEvC,uCAA6C;AAC7C,iCAAqC;AACrC,sCAAgE;AAChE,+CAAwD;AAExD;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,OAAiB;IAEjB,MAAM,IAAI,GAAG,IAAA,0BAAgB,EAAC,OAAO,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,MAAM,IAAA,6BAAmB,EAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAC7D,MAAM,iBAAiB,GAAG,IAAA,kBAAW,EAAC,IAAA,oBAAY,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;IAC1E,MAAM,WAAW,GAAG,MAAM,IAAA,wCAAiC,EAAC,iBAAiB,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IAClG,OAAO,WAAW,CAAC;AACrB,CAAC;AATD,wDASC;AAED;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,OAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC,WAAW,EAAE,OA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ClG,OAAO,WAAW,CAAC;AACrB,CAAC;AATD,wDASC;AAED;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,OAAiB;IAEjB,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACvE,OAAO,WAAW,CAAC,IAAI,CAAC;AAC1B,CAAC;AAND,wDAMC;AAED;;GAEG;AACI,KAAK,UAAU,2BAA2B,CAC/C,WAAwB,EACxB,WAAmB,EACnB,OAAiB;IAEjB,MAAM,cAAc,GAAG,MAAM,sBAAsB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC1E,IAAI,WAAW,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,EAAE;QAC5C,OAAO,EAAE,CAAC;KACX;IACD,OAAO,gBAAgB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AACvD,CAAC;AAVD,kEAUC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,YAAyB,EACzB,YAAyB;IAEzB,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7C,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAC/B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,CACnE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AATD,4CASC"}
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getRncliAutolinkingSourcesAsync = exports.getGitIgnoreSourcesAsync = exports.getPackageJsonScriptSourcesAsync = exports.getBareIosSourcesAsync = exports.getBareAndroidSourcesAsync = void 0;
7
7
  const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
8
+ const assert_1 = __importDefault(require("assert"));
8
9
  const chalk_1 = __importDefault(require("chalk"));
9
10
  const path_1 = __importDefault(require("path"));
10
11
  const resolve_from_1 = __importDefault(require("resolve-from"));
@@ -71,22 +72,20 @@ async function getRncliAutolinkingSourcesAsync(projectRoot, options) {
71
72
  const config = JSON.parse(stdout);
72
73
  const { root } = config;
73
74
  const reasons = ['bareRncliAutolinking'];
74
- for (const depData of Object.values(config.dependencies)) {
75
- const filePath = path_1.default.relative(root, depData.root);
76
- results.push({ type: 'dir', filePath, reasons });
75
+ const autolinkingConfig = {};
76
+ for (const [depName, depData] of Object.entries(config.dependencies)) {
77
+ stripRncliAutolinkingAbsolutePaths(depData, root);
78
+ const filePath = depData.root;
77
79
  debug(`Adding react-native-cli autolinking dir - ${chalk_1.default.dim(filePath)}`);
78
- for (const platform of options.platforms) {
79
- const platformData = getRncliPlatformData(depData, root, platform);
80
- if (platformData) {
81
- results.push({
82
- type: 'contents',
83
- id: `rncliAutolinkingConfig:${depData.name}:${platform}`,
84
- contents: platformData,
85
- reasons,
86
- });
87
- }
88
- }
80
+ results.push({ type: 'dir', filePath, reasons });
81
+ autolinkingConfig[depName] = depData;
89
82
  }
83
+ results.push({
84
+ type: 'contents',
85
+ id: 'rncliAutolinkingConfig',
86
+ contents: JSON.stringify(autolinkingConfig),
87
+ reasons,
88
+ });
90
89
  return results;
91
90
  }
92
91
  catch {
@@ -94,15 +93,14 @@ async function getRncliAutolinkingSourcesAsync(projectRoot, options) {
94
93
  }
95
94
  }
96
95
  exports.getRncliAutolinkingSourcesAsync = getRncliAutolinkingSourcesAsync;
97
- function getRncliPlatformData(dependency, root, platform) {
98
- const platformData = dependency.platforms[platform];
99
- if (!platformData) {
100
- return '';
101
- }
102
- const json = {};
103
- for (const [key, value] of Object.entries(platformData)) {
104
- json[key] = value?.startsWith?.(root) ? path_1.default.relative(root, value) : value;
96
+ function stripRncliAutolinkingAbsolutePaths(dependency, root) {
97
+ (0, assert_1.default)(dependency.root);
98
+ const dependencyRoot = dependency.root;
99
+ dependency.root = path_1.default.relative(root, dependencyRoot);
100
+ for (const platformData of Object.values(dependency.platforms)) {
101
+ for (const [key, value] of Object.entries(platformData)) {
102
+ platformData[key] = value.startsWith?.(dependencyRoot) ? path_1.default.relative(root, value) : value;
103
+ }
105
104
  }
106
- return JSON.stringify(json);
107
105
  }
108
106
  //# sourceMappingURL=Bare.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Bare.js","sourceRoot":"","sources":["../../src/sourcer/Bare.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2C;AAC3C,kDAA0B;AAC1B,gDAAwB;AACxB,gEAAuC;AAEvC,mCAAsD;AAGtD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,+BAA+B,CAAC,CAAC;AAEzD,KAAK,UAAU,0BAA0B,CAC9C,WAAmB,EACnB,OAA0B;IAE1B,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACzC,MAAM,MAAM,GAAG,MAAM,IAAA,mCAA2B,EAAC,WAAW,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;QAC1F,IAAI,MAAM,IAAI,IAAI,EAAE;YAClB,KAAK,CAAC,4BAA4B,eAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YAC1D,OAAO,CAAC,MAAM,CAAC,CAAC;SACjB;KACF;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAZD,gEAYC;AAEM,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,OAA0B;IAE1B,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACrC,MAAM,MAAM,GAAG,MAAM,IAAA,mCAA2B,EAAC,WAAW,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;QACtF,IAAI,MAAM,IAAI,IAAI,EAAE;YAClB,KAAK,CAAC,4BAA4B,eAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACtD,O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,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;SACtC;QAED,OAAO,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,UAAU;YAChB,EAAE,EAAE,wBAAwB;YAC5B,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC;YAC3C,OAAO;SACR,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;KAChB;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AA9BD,0EA8BC;AAED,SAAS,kCAAkC,CAAC,UAAe,EAAE,IAAY;IACvE,IAAA,gBAAM,EAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxB,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IACvC,UAAU,CAAC,IAAI,GAAG,cAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IACtD,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,CAAM,UAAU,CAAC,SAAS,CAAC,EAAE;QACnE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAM,YAAY,CAAC,EAAE;YAC5D,YAAY,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;SAC7F;KACF;AACH,CAAC"}
@@ -181,16 +181,8 @@ exports[`getHashSourcesAsync - managed project should match snapshot 1`] = `
181
181
  "type": "dir",
182
182
  },
183
183
  {
184
- "contents": "{"sourceDir":"node_modules/expo/android","packageImportPath":"import expo.modules.ExpoModulesPackage;","packageInstance":"new ExpoModulesPackage()","buildTypes":[],"componentDescriptors":[],"androidMkPath":"node_modules/expo/android/build/generated/source/codegen/jni/Android.mk","cmakeListsPath":"node_modules/expo/android/build/generated/source/codegen/jni/CMakeLists.txt"}",
185
- "id": "rncliAutolinkingConfig:expo:android",
186
- "reasons": [
187
- "bareRncliAutolinking",
188
- ],
189
- "type": "contents",
190
- },
191
- {
192
- "contents": "{"podspecPath":"node_modules/expo/Expo.podspec","configurations":[],"scriptPhases":[]}",
193
- "id": "rncliAutolinkingConfig:expo:ios",
184
+ "contents": "{"expo":{"root":"node_modules/expo","name":"expo","platforms":{"ios":{"podspecPath":"node_modules/expo/Expo.podspec","configurations":[],"scriptPhases":[]},"android":{"sourceDir":"node_modules/expo/android","packageImportPath":"import expo.modules.ExpoModulesPackage;","packageInstance":"new ExpoModulesPackage()","buildTypes":[],"componentDescriptors":[],"androidMkPath":"node_modules/expo/android/build/generated/source/codegen/jni/Android.mk","cmakeListsPath":"node_modules/expo/android/build/generated/source/codegen/jni/CMakeLists.txt"}}}}",
185
+ "id": "rncliAutolinkingConfig",
194
186
  "reasons": [
195
187
  "bareRncliAutolinking",
196
188
  ],
@@ -110,18 +110,9 @@ describe('managed project test', () => {
110
110
  "type": "dir",
111
111
  },
112
112
  {
113
- "contents": "{"sourceDir":"node_modules/@react-native-community/netinfo/android","packageImportPath":"import com.reactnativecommunity.netinfo.NetInfoPackage;","packageInstance":"new NetInfoPackage()","buildTypes":[],"componentDescriptors":[],"cmakeListsPath":"node_modules/@react-native-community/netinfo/android/build/generated/source/codegen/jni/CMakeLists.txt"}",
114
- "hash": "7612d745a76df00c1a8781735858c16030b3cc53",
115
- "id": "rncliAutolinkingConfig:@react-native-community/netinfo:android",
116
- "reasons": [
117
- "bareRncliAutolinking",
118
- ],
119
- "type": "contents",
120
- },
121
- {
122
- "contents": "{"podspecPath":"node_modules/@react-native-community/netinfo/react-native-netinfo.podspec","configurations":[],"scriptPhases":[]}",
123
- "hash": "40eebce5caf94df11096238a5a2ca648ea9f242e",
124
- "id": "rncliAutolinkingConfig:@react-native-community/netinfo:ios",
113
+ "contents": "{"@react-native-community/netinfo":{"root":"node_modules/@react-native-community/netinfo","name":"@react-native-community/netinfo","platforms":{"ios":{"podspecPath":"node_modules/@react-native-community/netinfo/react-native-netinfo.podspec","configurations":[],"scriptPhases":[]},"android":{"sourceDir":"node_modules/@react-native-community/netinfo/android","packageImportPath":"import com.reactnativecommunity.netinfo.NetInfoPackage;","packageInstance":"new NetInfoPackage()","buildTypes":[],"componentDescriptors":[],"cmakeListsPath":"node_modules/@react-native-community/netinfo/android/build/generated/source/codegen/jni/CMakeLists.txt"}}},"expo":{"root":"node_modules/expo","name":"expo","platforms":{"ios":{"podspecPath":"node_modules/expo/Expo.podspec","configurations":[],"scriptPhases":[]},"android":{"sourceDir":"node_modules/expo/android","packageImportPath":"import expo.modules.ExpoModulesPackage;","packageInstance":"new ExpoModulesPackage()","buildTypes":[],"componentDescriptors":[],"cmakeListsPath":"node_modules/expo/android/build/generated/source/codegen/jni/CMakeLists.txt"}}}}",
114
+ "hash": "ac75722bd87eb0189440be83faa2249079da5839",
115
+ "id": "rncliAutolinkingConfig",
125
116
  "reasons": [
126
117
  "bareRncliAutolinking",
127
118
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/fingerprint",
3
- "version": "0.0.10",
3
+ "version": "0.1.0",
4
4
  "description": "A library to generate a fingerprint from a React Native project",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -48,5 +48,5 @@
48
48
  "glob": "^7.1.7",
49
49
  "temp-dir": "^2.0.0"
50
50
  },
51
- "gitHead": "30c46ba88d14ce545497241993ca53a87d77271c"
51
+ "gitHead": "1f5e9f77f22e5d6a464d34194236684a45fcf322"
52
52
  }
@@ -42,10 +42,19 @@ export async function diffFingerprintChangesAsync(
42
42
  if (fingerprint.hash === newFingerprint.hash) {
43
43
  return [];
44
44
  }
45
- const result: FingerprintSource[] = newFingerprint.sources.filter((newItem) => {
46
- return !fingerprint.sources.find(
45
+ return diffFingerprints(fingerprint, newFingerprint);
46
+ }
47
+
48
+ /**
49
+ * Differentiate two fingerprints
50
+ */
51
+ export function diffFingerprints(
52
+ fingerprint1: Fingerprint,
53
+ fingerprint2: Fingerprint
54
+ ): FingerprintSource[] {
55
+ return fingerprint2.sources.filter((newItem) => {
56
+ return !fingerprint1.sources.find(
47
57
  (item) => item.type === newItem.type && item.hash === newItem.hash
48
58
  );
49
59
  });
50
- return result;
51
60
  }
@@ -1,10 +1,11 @@
1
1
  import spawnAsync from '@expo/spawn-async';
2
+ import assert from 'assert';
2
3
  import chalk from 'chalk';
3
4
  import path from 'path';
4
5
  import resolveFrom from 'resolve-from';
5
6
 
6
7
  import { getFileBasedHashSourceAsync } from './Utils';
7
- import type { HashSource, NormalizedOptions, Platform } from '../Fingerprint.types';
8
+ import type { HashSource, NormalizedOptions } from '../Fingerprint.types';
8
9
 
9
10
  const debug = require('debug')('expo:fingerprint:sourcer:Bare');
10
11
 
@@ -80,36 +81,35 @@ export async function getRncliAutolinkingSourcesAsync(
80
81
  const config = JSON.parse(stdout);
81
82
  const { root } = config;
82
83
  const reasons = ['bareRncliAutolinking'];
83
- for (const depData of Object.values<any>(config.dependencies)) {
84
- const filePath = path.relative(root, depData.root);
85
- results.push({ type: 'dir', filePath, reasons });
84
+ const autolinkingConfig: Record<string, any> = {};
85
+ for (const [depName, depData] of Object.entries<any>(config.dependencies)) {
86
+ stripRncliAutolinkingAbsolutePaths(depData, root);
87
+ const filePath = depData.root;
86
88
  debug(`Adding react-native-cli autolinking dir - ${chalk.dim(filePath)}`);
87
- for (const platform of options.platforms) {
88
- const platformData = getRncliPlatformData(depData, root, platform);
89
- if (platformData) {
90
- results.push({
91
- type: 'contents',
92
- id: `rncliAutolinkingConfig:${depData.name}:${platform}`,
93
- contents: platformData,
94
- reasons,
95
- });
96
- }
97
- }
89
+ results.push({ type: 'dir', filePath, reasons });
90
+
91
+ autolinkingConfig[depName] = depData;
98
92
  }
93
+
94
+ results.push({
95
+ type: 'contents',
96
+ id: 'rncliAutolinkingConfig',
97
+ contents: JSON.stringify(autolinkingConfig),
98
+ reasons,
99
+ });
99
100
  return results;
100
101
  } catch {
101
102
  return [];
102
103
  }
103
104
  }
104
105
 
105
- function getRncliPlatformData(dependency: any, root: string, platform: Platform): string {
106
- const platformData = dependency.platforms[platform];
107
- if (!platformData) {
108
- return '';
109
- }
110
- const json: Record<string, string> = {};
111
- for (const [key, value] of Object.entries<any>(platformData)) {
112
- json[key] = value?.startsWith?.(root) ? path.relative(root, value) : value;
106
+ function stripRncliAutolinkingAbsolutePaths(dependency: any, root: string): void {
107
+ assert(dependency.root);
108
+ const dependencyRoot = dependency.root;
109
+ dependency.root = path.relative(root, dependencyRoot);
110
+ for (const platformData of Object.values<any>(dependency.platforms)) {
111
+ for (const [key, value] of Object.entries<any>(platformData)) {
112
+ platformData[key] = value.startsWith?.(dependencyRoot) ? path.relative(root, value) : value;
113
+ }
113
114
  }
114
- return JSON.stringify(json);
115
115
  }
@@ -47,13 +47,36 @@ describe(getRncliAutolinkingSourcesAsync, () => {
47
47
  signal: null,
48
48
  output: [fixture, ''],
49
49
  });
50
- const sources = await getRncliAutolinkingSourcesAsync('/app', normalizeOptions());
50
+ const sources = await getRncliAutolinkingSourcesAsync('/root/apps/demo', normalizeOptions());
51
51
  expect(sources).toContainEqual(
52
52
  expect.objectContaining({
53
53
  type: 'dir',
54
- filePath: 'node_modules/react-native-reanimated',
54
+ filePath: '../../node_modules/react-native-reanimated',
55
55
  })
56
56
  );
57
57
  expect(sources).toMatchSnapshot();
58
58
  });
59
+
60
+ it('should not contain absolute paths', async () => {
61
+ const mockSpawnAsync = spawnAsync as jest.MockedFunction<typeof spawnAsync>;
62
+ const fixture = fs.readFileSync(
63
+ path.join(__dirname, 'fixtures', 'RncliAutoLinking.json'),
64
+ 'utf8'
65
+ );
66
+ mockSpawnAsync.mockResolvedValue({
67
+ stdout: fixture,
68
+ stderr: '',
69
+ status: 0,
70
+ signal: null,
71
+ output: [fixture, ''],
72
+ });
73
+ const sources = await getRncliAutolinkingSourcesAsync('/root/apps/demo', normalizeOptions());
74
+ for (const source of sources) {
75
+ if (source.type === 'dir' || source.type === 'file') {
76
+ expect(source.filePath).not.toMatch(/^\/root/);
77
+ } else {
78
+ expect(source.contents).not.toMatch(/"\/root\//);
79
+ }
80
+ }
81
+ });
59
82
  });
@@ -3,23 +3,15 @@
3
3
  exports[`getRncliAutolinkingSourcesAsync should contain rn-cli autolinking projects 1`] = `
4
4
  [
5
5
  {
6
- "filePath": "node_modules/react-native-reanimated",
6
+ "filePath": "../../node_modules/react-native-reanimated",
7
7
  "reasons": [
8
8
  "bareRncliAutolinking",
9
9
  ],
10
10
  "type": "dir",
11
11
  },
12
12
  {
13
- "contents": "{"sourceDir":"node_modules/react-native-reanimated/android","packageImportPath":"import com.swmansion.reanimated.ReanimatedPackage;","packageInstance":"new ReanimatedPackage()","buildTypes":[],"componentDescriptors":[],"androidMkPath":"node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/Android.mk","cmakeListsPath":"node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/CMakeLists.txt"}",
14
- "id": "rncliAutolinkingConfig:react-native-reanimated:android",
15
- "reasons": [
16
- "bareRncliAutolinking",
17
- ],
18
- "type": "contents",
19
- },
20
- {
21
- "contents": "{"podspecPath":"node_modules/react-native-reanimated/RNReanimated.podspec","configurations":[],"scriptPhases":[]}",
22
- "id": "rncliAutolinkingConfig:react-native-reanimated:ios",
13
+ "contents": "{"react-native-reanimated":{"root":"../../node_modules/react-native-reanimated","name":"react-native-reanimated","platforms":{"ios":{"podspecPath":"../../node_modules/react-native-reanimated/RNReanimated.podspec","configurations":[],"scriptPhases":[]},"android":{"sourceDir":"../../node_modules/react-native-reanimated/android","packageImportPath":"import com.swmansion.reanimated.ReanimatedPackage;","packageInstance":"new ReanimatedPackage()","buildTypes":[],"componentDescriptors":[],"androidMkPath":"../../node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/Android.mk","cmakeListsPath":"../../node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/CMakeLists.txt"}}}}",
14
+ "id": "rncliAutolinkingConfig",
23
15
  "reasons": [
24
16
  "bareRncliAutolinking",
25
17
  ],
@@ -1,24 +1,24 @@
1
1
  {
2
- "root": "/app",
3
- "reactNativePath": "/app/node_modules/react-native",
2
+ "root": "/root/apps/demo",
3
+ "reactNativePath": "/root/node_modules/react-native",
4
4
  "dependencies": {
5
5
  "react-native-reanimated": {
6
- "root": "/app/node_modules/react-native-reanimated",
6
+ "root": "/root/node_modules/react-native-reanimated",
7
7
  "name": "react-native-reanimated",
8
8
  "platforms": {
9
9
  "ios": {
10
- "podspecPath": "/app/node_modules/react-native-reanimated/RNReanimated.podspec",
10
+ "podspecPath": "/root/node_modules/react-native-reanimated/RNReanimated.podspec",
11
11
  "configurations": [],
12
12
  "scriptPhases": []
13
13
  },
14
14
  "android": {
15
- "sourceDir": "/app/node_modules/react-native-reanimated/android",
15
+ "sourceDir": "/root/node_modules/react-native-reanimated/android",
16
16
  "packageImportPath": "import com.swmansion.reanimated.ReanimatedPackage;",
17
17
  "packageInstance": "new ReanimatedPackage()",
18
18
  "buildTypes": [],
19
19
  "componentDescriptors": [],
20
- "androidMkPath": "/app/node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/Android.mk",
21
- "cmakeListsPath": "/app/node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/CMakeLists.txt"
20
+ "androidMkPath": "/root/node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/Android.mk",
21
+ "cmakeListsPath": "/root/node_modules/react-native-reanimated/android/build/generated/source/codegen/jni/CMakeLists.txt"
22
22
  }
23
23
  }
24
24
  }
@@ -150,14 +150,14 @@
150
150
  },
151
151
  "project": {
152
152
  "ios": {
153
- "sourceDir": "/app/ios",
153
+ "sourceDir": "/root/apps/demo/ios",
154
154
  "xcodeProject": {
155
155
  "name": "RN070.xcworkspace",
156
156
  "isWorkspace": true
157
157
  }
158
158
  },
159
159
  "android": {
160
- "sourceDir": "/app/android",
160
+ "sourceDir": "/root/apps/demo/android",
161
161
  "appName": "app",
162
162
  "packageName": "com.rn070"
163
163
  }