Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app/example/test/specs/app.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("App", () => {
throw new Error("Could not find 'react-native'");
}

/** @type {Required<Pick<Manifest, "version">>} */
/** @type {Manifest} */
const { version } = readJSONFile(rnPath);
return version.replace("-nightly-", "-nightly\n");
})();
Expand Down
2 changes: 1 addition & 1 deletion packages/app/ios/app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function findReactNativePath(
* @returns {number}
*/
function readPackageVersion(p, fs = nodefs) {
/** @type {Required<Pick<Manifest, "version">>} */
/** @type {Manifest} */
const manifest = readJSONFile(path.join(p, "package.json"), fs);
return toVersionNumber(manifest["version"]);
}
Expand Down
13 changes: 7 additions & 6 deletions packages/app/scripts/internal/set-react-version.mts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function fetchPackageInfo(pkg: string, version: string): Promise<Manifest> {
return fetch(npmRegistryBaseURL + pkg + "/" + foundVersion);
})
.then((res) => res?.json() ?? ({} as Manifest))
.then(({ version, dependencies = {}, peerDependencies = {} }) => {
return { version, dependencies, peerDependencies };
.then(({ name, version, dependencies = {}, peerDependencies = {} }) => {
return { name, version, dependencies, peerDependencies };
});
}

Expand Down Expand Up @@ -244,22 +244,23 @@ async function getProfile(
}

default: {
const remove = { name: undefined, version: undefined };
const versions = {
core: fetchPackageInfo("react-native", v),
macos: coreOnly
? Promise.resolve({ version: undefined })
? Promise.resolve(remove)
: fetchPackageInfo("react-native-macos", v),
visionos: coreOnly
? Promise.resolve({ version: undefined })
? Promise.resolve(remove)
: fetchPackageInfo(visionos.id, v),
windows: coreOnly
? Promise.resolve({ version: undefined })
? Promise.resolve(remove)
: fetchPackageInfo("react-native-windows", v),
};
const reactNative = await versions.core;
const commonDeps = await resolveCommonDependencies(v, reactNative);

const getVersion = ({ version }: Manifest) => version;
const getVersion = ({ version }: Partial<Manifest>) => version;
return {
...commonDeps,
"react-native": reactNative.version,
Expand Down
25 changes: 14 additions & 11 deletions packages/app/scripts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,22 +331,25 @@ export type Docs = {
* set-react-version.mjs *
*************************/

export type Manifest = Partial<{
export type Manifest = {
name: string;
version: string;
repository: {
type: "git";
url: string;
};
dependencies: Record<string, string>;
peerDependencies: Record<string, string>;
devDependencies: Record<string, string | undefined>;
resolutions: Record<string, string | undefined>;
defaultPlatformPackages: Record<
repository?:
| string
| {
type: "git";
url: string;
directory?: string;
};
dependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
devDependencies?: Record<string, string | undefined>;
resolutions?: Record<string, string | undefined>;
defaultPlatformPackages?: Record<
string,
{ id: PlatformPackage; template: string }
>;
}>;
};

/***************************
* testing/test-matrix.mts *
Expand Down
Loading