@rock-js/tools 0.10.1 → 0.11.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/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/build-cache/getBinaryPath.d.ts +2 -1
- package/dist/src/lib/build-cache/getBinaryPath.js +9 -6
- package/dist/src/lib/build-cache/getBinaryPath.js.map +1 -1
- package/dist/src/lib/fingerprint/ignorePaths.d.ts +3 -0
- package/dist/src/lib/fingerprint/ignorePaths.js +56 -0
- package/dist/src/lib/fingerprint/ignorePaths.js.map +1 -0
- package/dist/src/lib/fingerprint/index.d.ts +3 -7
- package/dist/src/lib/fingerprint/index.js +60 -93
- package/dist/src/lib/fingerprint/index.js.map +1 -1
- package/dist/src/lib/getReactNativeVersion.d.ts +1 -0
- package/dist/src/lib/getReactNativeVersion.js +13 -0
- package/dist/src/lib/getReactNativeVersion.js.map +1 -0
- package/package.json +13 -4
- package/dist/src/lib/fingerprint/processExtraSources.d.ts +0 -9
- package/dist/src/lib/fingerprint/processExtraSources.js +0 -76
- package/dist/src/lib/fingerprint/processExtraSources.js.map +0 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -18,3 +18,4 @@ export { color, colorLink } from './lib/color.js';
|
|
|
18
18
|
export { runHermes } from './lib/hermes.js';
|
|
19
19
|
export { fetchCachedBuild, handleDownloadResponse, handleUploadResponse, } from './lib/build-cache/fetchCachedBuild.js';
|
|
20
20
|
export { getInfoPlist } from './lib/getInfoPlist.js';
|
|
21
|
+
export { getReactNativeVersion } from './lib/getReactNativeVersion.js';
|
package/dist/src/index.js
CHANGED
|
@@ -18,4 +18,5 @@ export { color, colorLink } from './lib/color.js';
|
|
|
18
18
|
export { runHermes } from './lib/hermes.js';
|
|
19
19
|
export { fetchCachedBuild, handleDownloadResponse, handleUploadResponse, } from './lib/build-cache/fetchCachedBuild.js';
|
|
20
20
|
export { getInfoPlist } from './lib/getInfoPlist.js';
|
|
21
|
+
export { getReactNativeVersion } from './lib/getReactNativeVersion.js';
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type FingerprintSources } from '../fingerprint/index.js';
|
|
2
2
|
import type { RemoteBuildCache } from './common.js';
|
|
3
|
-
export declare function getBinaryPath({ artifactName, binaryPathFlag, localFlag, remoteCacheProvider, fingerprintOptions, sourceDir, }: {
|
|
3
|
+
export declare function getBinaryPath({ artifactName, binaryPathFlag, localFlag, remoteCacheProvider, fingerprintOptions, sourceDir, platformName, }: {
|
|
4
4
|
artifactName: string;
|
|
5
5
|
binaryPathFlag?: string;
|
|
6
6
|
localFlag?: boolean;
|
|
7
7
|
remoteCacheProvider: null | (() => RemoteBuildCache) | undefined;
|
|
8
8
|
fingerprintOptions: FingerprintSources;
|
|
9
9
|
sourceDir: string;
|
|
10
|
+
platformName: string;
|
|
10
11
|
}): Promise<string | undefined>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
1
2
|
import { color, colorLink } from '../color.js';
|
|
2
|
-
import {
|
|
3
|
+
import { getAllIgnorePaths } from '../fingerprint/ignorePaths.js';
|
|
3
4
|
import logger from '../logger.js';
|
|
5
|
+
import { getProjectRoot } from '../project.js';
|
|
4
6
|
import { spawn } from '../spawn.js';
|
|
5
7
|
import { fetchCachedBuild } from './fetchCachedBuild.js';
|
|
6
8
|
import { getLocalBuildCacheBinaryPath } from './localBuildCache.js';
|
|
7
|
-
export async function getBinaryPath({ artifactName, binaryPathFlag, localFlag, remoteCacheProvider, fingerprintOptions, sourceDir, }) {
|
|
9
|
+
export async function getBinaryPath({ artifactName, binaryPathFlag, localFlag, remoteCacheProvider, fingerprintOptions, sourceDir, platformName, }) {
|
|
8
10
|
// 1. First check if the binary path is provided
|
|
9
11
|
let binaryPath = binaryPathFlag;
|
|
10
12
|
// 2. If not, check if the local build is requested
|
|
@@ -28,14 +30,14 @@ export async function getBinaryPath({ artifactName, binaryPathFlag, localFlag, r
|
|
|
28
30
|
logger.warn(`Remote Cache: Failed to fetch cached build for ${color.bold(artifactName)}.
|
|
29
31
|
Cause: ${message}${cause ? `\n${cause.toString()}` : ''}
|
|
30
32
|
Read more: ${colorLink('https://rockjs.dev/docs/configuration#remote-cache-configuration')}`);
|
|
31
|
-
await warnIgnoredFiles(fingerprintOptions, sourceDir);
|
|
33
|
+
await warnIgnoredFiles(fingerprintOptions, platformName, sourceDir);
|
|
32
34
|
logger.debug('Remote cache failure error:', error);
|
|
33
35
|
logger.info('Continuing with local build');
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
return binaryPath;
|
|
37
39
|
}
|
|
38
|
-
async function warnIgnoredFiles(fingerprintOptions, sourceDir) {
|
|
40
|
+
async function warnIgnoredFiles(fingerprintOptions, platformName, sourceDir) {
|
|
39
41
|
// @todo unify git helpers from create-app
|
|
40
42
|
try {
|
|
41
43
|
await spawn('git', ['rev-parse', '--is-inside-work-tree'], {
|
|
@@ -47,10 +49,11 @@ async function warnIgnoredFiles(fingerprintOptions, sourceDir) {
|
|
|
47
49
|
// Not a git repository, skip the git clean check
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
52
|
+
const projectRoot = getProjectRoot();
|
|
50
53
|
const ignorePaths = [
|
|
51
54
|
...(fingerprintOptions?.ignorePaths ?? []),
|
|
52
|
-
|
|
53
|
-
...
|
|
55
|
+
// git expects relative paths
|
|
56
|
+
...getAllIgnorePaths(platformName, path.relative(projectRoot, sourceDir)),
|
|
54
57
|
];
|
|
55
58
|
const { output } = await spawn('git', [
|
|
56
59
|
'clean',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBinaryPath.js","sourceRoot":"","sources":["../../../../src/lib/build-cache/getBinaryPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,
|
|
1
|
+
{"version":3,"file":"getBinaryPath.js","sourceRoot":"","sources":["../../../../src/lib/build-cache/getBinaryPath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,MAAM,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,MA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;mCAC7B,KAAK,CAAC,IAAI,CACvC,yBAAyB,CAC1B,OAAO,SAAS,CAAC,iBAAiB,CAAC;aAC3B,SAAS,CAChB,qEAAqE,CACtE,EAAE,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// export const FINGERPRINT_IGNORE_FILENAME = '.fingerprintignore'. TODO: should we include this?
|
|
2
|
+
function getAndroidIgnorePaths(sourceDir) {
|
|
3
|
+
return [
|
|
4
|
+
`${sourceDir}/app/.gradle`,
|
|
5
|
+
`${sourceDir}/build`,
|
|
6
|
+
`${sourceDir}/**/build`,
|
|
7
|
+
`${sourceDir}/**/.cxx`,
|
|
8
|
+
`${sourceDir}/.kotlin`,
|
|
9
|
+
`${sourceDir}/local.properties`,
|
|
10
|
+
`${sourceDir}/.idea`,
|
|
11
|
+
`${sourceDir}/.gradle`,
|
|
12
|
+
`${sourceDir}/gradlew.bat`, // Often has different line endings, thus we have to ignore it
|
|
13
|
+
// Android annotations - revisit
|
|
14
|
+
'**/android-annotation/build',
|
|
15
|
+
'**/android-annotation/.cxx',
|
|
16
|
+
'**/android-annotation/.gradle',
|
|
17
|
+
'**/android-annotation-processor/build',
|
|
18
|
+
'**/android-annotation-processor/.cxx',
|
|
19
|
+
'**/android-annotation-processor/.gradle',
|
|
20
|
+
// Android gradle plugins
|
|
21
|
+
'**/*-gradle-plugin/build',
|
|
22
|
+
'**/*-gradle-plugin/.cxx',
|
|
23
|
+
'**/*-gradle-plugin/.gradle',
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
function getIOSIgnorePaths(sourceDir) {
|
|
27
|
+
return [
|
|
28
|
+
`${sourceDir}/build`,
|
|
29
|
+
`${sourceDir}/.xcode.env.local`,
|
|
30
|
+
`${sourceDir}/**/project.xcworkspace`,
|
|
31
|
+
`${sourceDir}/*.xcworkspace/xcuserdata`,
|
|
32
|
+
`${sourceDir}/DerivedData`,
|
|
33
|
+
`${sourceDir}/Pods`,
|
|
34
|
+
`${sourceDir}/tmp.xcconfig`, // added by react-native-config,
|
|
35
|
+
`${sourceDir}/**/*.xcworkspace`,
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
export function getDefaultIgnorePaths() {
|
|
39
|
+
return ['**/.DS_Store'];
|
|
40
|
+
}
|
|
41
|
+
export function getPlatformDirIgnorePaths(platform, sourceDir) {
|
|
42
|
+
if (platform === 'android') {
|
|
43
|
+
return getAndroidIgnorePaths(sourceDir);
|
|
44
|
+
}
|
|
45
|
+
else if (platform === 'ios') {
|
|
46
|
+
return getIOSIgnorePaths(sourceDir);
|
|
47
|
+
}
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
export function getAllIgnorePaths(platform, sourceDir) {
|
|
51
|
+
return [
|
|
52
|
+
...getDefaultIgnorePaths(),
|
|
53
|
+
...getPlatformDirIgnorePaths(platform, sourceDir),
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=ignorePaths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignorePaths.js","sourceRoot":"","sources":["../../../../src/lib/fingerprint/ignorePaths.ts"],"names":[],"mappings":"AAAA,iGAAiG;AAEjG,SAAS,qBAAqB,CAAC,SAAiB;IAC9C,OAAO;QACL,GAAG,SAAS,cAAc;QAC1B,GAAG,SAAS,QAAQ;QACpB,GAAG,SAAS,WAAW;QACvB,GAAG,SAAS,UAAU;QACtB,GAAG,SAAS,UAAU;QACtB,GAAG,SAAS,mBAAmB;QAC/B,GAAG,SAAS,QAAQ;QACpB,GAAG,SAAS,UAAU;QACtB,GAAG,SAAS,cAAc,EAAE,8DAA8D;QAE1F,gCAAgC;QAChC,6BAA6B;QAC7B,4BAA4B;QAC5B,+BAA+B;QAC/B,uCAAuC;QACvC,sCAAsC;QACtC,yCAAyC;QAEzC,yBAAyB;QACzB,0BAA0B;QAC1B,yBAAyB;QACzB,4BAA4B;KAC7B,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,SAAiB;IAC1C,OAAO;QACL,GAAG,SAAS,QAAQ;QACpB,GAAG,SAAS,mBAAmB;QAC/B,GAAG,SAAS,yBAAyB;QACrC,GAAG,SAAS,2BAA2B;QACvC,GAAG,SAAS,cAAc;QAC1B,GAAG,SAAS,OAAO;QACnB,GAAG,SAAS,eAAe,EAAE,gCAAgC;QAC7D,GAAG,SAAS,mBAAmB;KAChC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,OAAO,CAAC,cAAc,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,QAAgB,EAAE,SAAiB;IAC3E,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;SAAM,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QAC9B,OAAO,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAgB,EAAE,SAAiB;IACnE,OAAO;QACL,GAAG,qBAAqB,EAAE;QAC1B,GAAG,yBAAyB,CAAC,QAAQ,EAAE,SAAS,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export { DEFAULT_IGNORE_PATHS as EXPO_DEFAULT_IGNORE_PATHS } from '@expo/fingerprint';
|
|
3
|
-
export declare const DEFAULT_IGNORE_PATHS: string[];
|
|
1
|
+
import { type FingerprintResult } from 'fs-fingerprint';
|
|
4
2
|
export type FingerprintSources = {
|
|
5
3
|
extraSources: string[];
|
|
6
4
|
ignorePaths: string[];
|
|
5
|
+
env: string[];
|
|
7
6
|
};
|
|
8
7
|
export type FingerprintOptions = {
|
|
9
8
|
platform: 'ios' | 'android';
|
|
10
9
|
extraSources: string[];
|
|
11
10
|
ignorePaths: string[];
|
|
12
|
-
|
|
13
|
-
export type FingerprintResult = {
|
|
14
|
-
hash: string;
|
|
15
|
-
sources: FingerprintSource[];
|
|
11
|
+
env: string[];
|
|
16
12
|
};
|
|
17
13
|
/**
|
|
18
14
|
* Calculates the fingerprint of the native parts project of the project.
|
|
@@ -1,126 +1,93 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import logger from '../logger.js';
|
|
3
|
+
import { calculateFingerprint } from 'fs-fingerprint';
|
|
4
|
+
import { getReactNativeVersion, logger } from '../../index.js';
|
|
6
5
|
import { spawn } from '../spawn.js';
|
|
7
|
-
import {
|
|
8
|
-
export { DEFAULT_IGNORE_PATHS as EXPO_DEFAULT_IGNORE_PATHS } from '@expo/fingerprint';
|
|
9
|
-
const HASH_ALGORITHM = 'sha1';
|
|
10
|
-
const EXCLUDED_SOURCES = [
|
|
11
|
-
'expoAutolinkingConfig:ios',
|
|
12
|
-
'expoAutolinkingConfig:android',
|
|
13
|
-
];
|
|
14
|
-
export const DEFAULT_IGNORE_PATHS = [
|
|
15
|
-
'android/build',
|
|
16
|
-
'android/**/build',
|
|
17
|
-
'android/**/.cxx',
|
|
18
|
-
'android/.kotlin/**',
|
|
19
|
-
'ios/DerivedData',
|
|
20
|
-
'ios/Pods',
|
|
21
|
-
'ios/tmp.xcconfig', // added by react-native-config
|
|
22
|
-
'ios/**/*.xcworkspace',
|
|
23
|
-
'node_modules',
|
|
24
|
-
'android/local.properties',
|
|
25
|
-
'android/.idea',
|
|
26
|
-
'android/.gradle',
|
|
27
|
-
];
|
|
6
|
+
import { getDefaultIgnorePaths, getPlatformDirIgnorePaths, } from './ignorePaths.js';
|
|
28
7
|
/**
|
|
29
8
|
* Calculates the fingerprint of the native parts project of the project.
|
|
30
9
|
*/
|
|
31
10
|
export async function nativeFingerprint(projectRoot, options) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
11
|
+
let autolinkingConfig;
|
|
12
|
+
try {
|
|
13
|
+
// Use stdout to avoid deprecation warnings
|
|
14
|
+
const { stdout: autolinkingConfigString } = await spawn('rock', ['config', '-p', options.platform], { cwd: projectRoot, stdio: 'pipe' });
|
|
15
|
+
autolinkingConfig = JSON.parse(autolinkingConfigString);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
throw new Error('Failed to read autolinking config');
|
|
19
|
+
}
|
|
20
|
+
const packageJSONPath = path.join(projectRoot, 'package.json');
|
|
21
|
+
const packageJSON = await readPackageJSON(packageJSONPath);
|
|
22
|
+
const scripts = packageJSON['scripts'];
|
|
23
|
+
const platforms = Object.keys(autolinkingConfig.project).map((key) => {
|
|
24
|
+
return {
|
|
25
|
+
platform: key,
|
|
26
|
+
sourceDir: path.relative(projectRoot, autolinkingConfig.project[key].sourceDir),
|
|
27
|
+
};
|
|
39
28
|
});
|
|
40
|
-
|
|
41
|
-
platforms
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
if (platforms.length === 0) {
|
|
30
|
+
throw new Error('No platforms found in autolinking project config');
|
|
31
|
+
}
|
|
32
|
+
const fingerprint = await calculateFingerprint(projectRoot, {
|
|
33
|
+
ignoreFilePath: '.gitignore',
|
|
34
|
+
include: [
|
|
35
|
+
...platforms.map((platform) => platform.sourceDir),
|
|
36
|
+
...options.extraSources.map((source) => path.isAbsolute(source) ? path.relative(projectRoot, source) : source),
|
|
37
|
+
],
|
|
38
|
+
extraInputs: [
|
|
39
|
+
{ key: 'scripts', json: scripts },
|
|
40
|
+
{
|
|
41
|
+
key: 'autolinkingSources',
|
|
42
|
+
json: parseAutolinkingSources(autolinkingConfig),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: 'reactNativeVersion',
|
|
46
|
+
json: { version: getReactNativeVersion(projectRoot) },
|
|
47
|
+
},
|
|
48
|
+
...(options.env.length > 0 ? [{ key: 'env', json: options.env }] : []),
|
|
49
|
+
],
|
|
50
|
+
exclude: [
|
|
51
|
+
...getDefaultIgnorePaths(),
|
|
52
|
+
...platforms.flatMap(({ platform, sourceDir }) => getPlatformDirIgnorePaths(platform, sourceDir)),
|
|
53
|
+
...(options.ignorePaths ?? []),
|
|
45
54
|
],
|
|
46
|
-
ignorePaths: [...DEFAULT_IGNORE_PATHS, ...(options.ignorePaths ?? [])],
|
|
47
55
|
});
|
|
48
|
-
|
|
49
|
-
const sources = fingerprint.sources.filter((source) => 'id' in source ? !EXCLUDED_SOURCES.includes(source.id) : true);
|
|
50
|
-
const hash = await hashSources(sources);
|
|
51
|
-
return { hash, sources };
|
|
56
|
+
return fingerprint;
|
|
52
57
|
}
|
|
53
|
-
async
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
input += `${createSourceId(source)}-${source.hash}\n`;
|
|
58
|
-
}
|
|
58
|
+
const readPackageJSON = async (packageJSONPath) => {
|
|
59
|
+
try {
|
|
60
|
+
const packageJSONContent = await fs.readFile(packageJSONPath, 'utf-8');
|
|
61
|
+
return JSON.parse(packageJSONContent);
|
|
59
62
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return hasher.digest('hex');
|
|
63
|
-
}
|
|
64
|
-
function createSourceId(source) {
|
|
65
|
-
switch (source.type) {
|
|
66
|
-
case 'contents':
|
|
67
|
-
return source.id;
|
|
68
|
-
case 'file':
|
|
69
|
-
return source.filePath;
|
|
70
|
-
case 'dir':
|
|
71
|
-
return source.filePath;
|
|
72
|
-
default:
|
|
73
|
-
// @ts-expect-error: we intentionally want to detect invalid types
|
|
74
|
-
throw new RockError(`Unsupported source type: ${source.type}`);
|
|
63
|
+
catch {
|
|
64
|
+
throw new Error(`Failed to read package.json at: ${packageJSONPath}`);
|
|
75
65
|
}
|
|
76
|
-
}
|
|
66
|
+
};
|
|
77
67
|
function toPosixPath(filePath) {
|
|
78
68
|
return filePath.replace(/\\/g, '/');
|
|
79
69
|
}
|
|
80
|
-
function parseAutolinkingSources(
|
|
81
|
-
const results = [];
|
|
70
|
+
function parseAutolinkingSources(config) {
|
|
82
71
|
const { root } = config;
|
|
83
|
-
const autolinkingConfig = {};
|
|
84
72
|
for (const [depName, depData] of Object.entries(config.dependencies)) {
|
|
85
73
|
try {
|
|
86
74
|
stripAutolinkingAbsolutePaths(depData, root);
|
|
87
|
-
const filePath = toPosixPath(depData.root);
|
|
88
|
-
results.push({ type: 'dir', filePath, reasons });
|
|
89
|
-
autolinkingConfig[depName] = depData;
|
|
90
75
|
}
|
|
91
76
|
catch (e) {
|
|
92
77
|
logger.debug(`Error adding react-native core autolinking - ${depName}.\n${e}`);
|
|
93
78
|
}
|
|
94
79
|
}
|
|
95
|
-
|
|
96
|
-
type: 'contents',
|
|
97
|
-
id: contentsId,
|
|
98
|
-
contents: JSON.stringify(autolinkingConfig),
|
|
99
|
-
reasons,
|
|
100
|
-
});
|
|
101
|
-
return results;
|
|
80
|
+
return config.dependencies;
|
|
102
81
|
}
|
|
103
82
|
function stripAutolinkingAbsolutePaths(dependency, root) {
|
|
104
83
|
const dependencyRoot = dependency.root;
|
|
105
|
-
const
|
|
84
|
+
const posixDependencyRoot = toPosixPath(dependencyRoot);
|
|
106
85
|
dependency.root = toPosixPath(path.relative(root, dependencyRoot));
|
|
107
86
|
for (const platformData of Object.values(dependency.platforms)) {
|
|
108
87
|
for (const [key, value] of Object.entries(platformData ?? {})) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// CMake paths on Windows are serving in slashes,
|
|
113
|
-
// we have to check startsWith with the same slashes.
|
|
114
|
-
// @todo revisit windows logic
|
|
115
|
-
newValue = value?.startsWith?.(cmakeDepRoot)
|
|
116
|
-
? toPosixPath(path.relative(root, value))
|
|
117
|
-
: value;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
newValue = value?.startsWith?.(dependencyRoot)
|
|
121
|
-
? toPosixPath(path.relative(root, value))
|
|
122
|
-
: value;
|
|
123
|
-
}
|
|
88
|
+
const newValue = value?.startsWith?.(posixDependencyRoot)
|
|
89
|
+
? toPosixPath(path.relative(root, value))
|
|
90
|
+
: value;
|
|
124
91
|
platformData[key] = newValue;
|
|
125
92
|
}
|
|
126
93
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/fingerprint/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/fingerprint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAA0B,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAe1B;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,WAAmB,EACnB,OAA2B;IAE3B,IAAI,iBAAiB,CAAC;IAEtB,IAAI,CAAC;QACH,2CAA2C;QAC3C,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,KAAK,CACrD,MAAM,EACN,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,EAClC,EAAE,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,CACpC,CAAC;QAEF,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACvD,CAAC;IA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IAAI,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,CACV,gDAAgD,OAAO,MAAM,CAAC,EAAE,CACjE,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,YAAY,CAAC;AAC7B,CAAC;AAED,SAAS,6BAA6B,CAAC,UAAe,EAAE,IAAY;IAClE,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CAAC;IACvC,MAAM,mBAAmB,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC;IAExD,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;IACnE,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,MAAM,CAAM,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACpE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAM,YAAY,IAAI,EAAE,CAAC,EAAE,CAAC;YACnE,MAAM,QAAQ,GAAG,KAAK,EAAE,UAAU,EAAE,CAAC,mBAAmB,CAAC;gBACvD,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBACzC,CAAC,CAAC,KAAK,CAAC;YACV,YAAY,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;QAC/B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getReactNativeVersion(root: string): any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
export function getReactNativeVersion(root) {
|
|
5
|
+
try {
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
return JSON.parse(fs.readFileSync(path.join(require.resolve('react-native', { paths: [root] }), '..', 'package.json'), 'utf-8')).version;
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return 'unknown';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=getReactNativeVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getReactNativeVersion.js","sourceRoot":"","sources":["../../../src/lib/getReactNativeVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CACf,EAAE,CAAC,YAAY,CACb,IAAI,CAAC,IAAI,CACP,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAClD,IAAI,EACJ,cAAc,CACf,EACD,OAAO,CACR,CACF,CAAC,OAAO,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rock-js/tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/src/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@clack/prompts": "^0.11.0",
|
|
21
|
-
"@expo/fingerprint": "^0.11.6",
|
|
22
21
|
"@types/adm-zip": "^0.5.7",
|
|
23
22
|
"adm-zip": "^0.5.16",
|
|
24
23
|
"appdirsjs": "^1.2.7",
|
|
25
24
|
"fast-glob": "^3.3.2",
|
|
25
|
+
"fs-fingerprint": "^0.7.0",
|
|
26
26
|
"is-unicode-supported": "^2.1.0",
|
|
27
27
|
"nano-spawn": "^0.2.0",
|
|
28
28
|
"picocolors": "^1.1.1",
|
|
@@ -31,9 +31,18 @@
|
|
|
31
31
|
"tslib": "^2.3.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@rock-js/test-helpers": "^0.
|
|
34
|
+
"@rock-js/test-helpers": "^0.11.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/callstack/rock.git",
|
|
42
|
+
"directory": "packages/tools"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://rockjs.dev",
|
|
45
|
+
"bugs": "https://github.com/callstack/rock/issues",
|
|
46
|
+
"license": "MIT",
|
|
47
|
+
"author": "Callstack <incubator@callstack.com>"
|
|
39
48
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { HashSourceContents, HashSourceDir } from '@expo/fingerprint';
|
|
2
|
-
/**
|
|
3
|
-
* Processes extra source files and directories for fingerprinting.
|
|
4
|
-
* @param extraSources Array of file paths, directory paths, or glob patterns
|
|
5
|
-
* @param projectRoot Root directory of the project
|
|
6
|
-
* @param ignorePaths Optional array of paths to ignore
|
|
7
|
-
* @returns Array of processed sources with their contents or directory information
|
|
8
|
-
*/
|
|
9
|
-
export declare function processExtraSources(extraSources: string[], projectRoot: string, ignorePaths?: string[]): (HashSourceDir | HashSourceContents)[];
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import glob from 'fast-glob';
|
|
4
|
-
import logger from '../logger.js';
|
|
5
|
-
/**
|
|
6
|
-
* Processes extra source files and directories for fingerprinting.
|
|
7
|
-
* @param extraSources Array of file paths, directory paths, or glob patterns
|
|
8
|
-
* @param projectRoot Root directory of the project
|
|
9
|
-
* @param ignorePaths Optional array of paths to ignore
|
|
10
|
-
* @returns Array of processed sources with their contents or directory information
|
|
11
|
-
*/
|
|
12
|
-
export function processExtraSources(extraSources, projectRoot, ignorePaths) {
|
|
13
|
-
const processedSources = [];
|
|
14
|
-
for (const source of extraSources) {
|
|
15
|
-
try {
|
|
16
|
-
const isGlobPattern = glob.isDynamicPattern(source);
|
|
17
|
-
if (isGlobPattern) {
|
|
18
|
-
const matches = glob.sync(source, {
|
|
19
|
-
cwd: projectRoot,
|
|
20
|
-
ignore: ignorePaths ?? [],
|
|
21
|
-
});
|
|
22
|
-
for (const match of matches) {
|
|
23
|
-
const absolutePath = path.join(projectRoot, match);
|
|
24
|
-
if (fs.existsSync(absolutePath)) {
|
|
25
|
-
const stats = fs.statSync(absolutePath);
|
|
26
|
-
if (stats.isDirectory()) {
|
|
27
|
-
processedSources.push({
|
|
28
|
-
type: 'dir',
|
|
29
|
-
filePath: absolutePath,
|
|
30
|
-
reasons: ['custom-user-config'],
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
processedSources.push({
|
|
35
|
-
type: 'contents',
|
|
36
|
-
id: absolutePath,
|
|
37
|
-
contents: fs.readFileSync(absolutePath, 'utf-8'),
|
|
38
|
-
reasons: ['custom-user-config'],
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
const absolutePath = path.isAbsolute(source)
|
|
46
|
-
? source
|
|
47
|
-
: path.join(projectRoot, source);
|
|
48
|
-
if (!fs.existsSync(absolutePath)) {
|
|
49
|
-
logger.warn(`Extra source "${absolutePath}" does not exist, skipping...`);
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
const stats = fs.statSync(absolutePath);
|
|
53
|
-
const relativePath = path.relative(projectRoot, absolutePath);
|
|
54
|
-
if (stats.isDirectory()) {
|
|
55
|
-
processedSources.push({
|
|
56
|
-
type: 'dir',
|
|
57
|
-
filePath: relativePath,
|
|
58
|
-
reasons: ['custom-user-config'],
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
processedSources.push({
|
|
63
|
-
type: 'contents',
|
|
64
|
-
id: relativePath,
|
|
65
|
-
contents: fs.readFileSync(absolutePath, 'utf-8'),
|
|
66
|
-
reasons: ['custom-user-config'],
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
logger.debug(`Error processing extra source "${source}": ${error}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return processedSources;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=processExtraSources.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processExtraSources.js","sourceRoot":"","sources":["../../../../src/lib/fingerprint/processExtraSources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,cAAc,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,YAAsB,EACtB,WAAmB,EACnB,WAAsB;IAEtB,MAAM,gBAAgB,GAA8C,EAAE,CAAC;IAEvE,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;YACpD,IAAI,aAAa,EAAE,CAAC;gBAClB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;oBAChC,GAAG,EAAE,WAAW;oBAChB,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