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
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import assert from 'node:assert';
import path from 'path';
import fs from 'fs-extra';
import type { ExampleApp } from '../input';

export async function getDependencyVersionsFromExampleApp(
folder: string,
exampleAppType: ExampleApp
) {
const examplePackageJson = await fs.readJSON(
path.join(folder, 'example', 'package.json')
);

const react: string = examplePackageJson.dependencies?.react;
assert(
react !== undefined,
"The generated example app doesn't have React installed."
);
const reactNative: string = examplePackageJson.dependencies?.['react-native'];
assert(
reactNative !== undefined,
"The generated example app doesn't have React Native installed."
);

const devDependencies: Record<string, string> = {
react,
'react-native': reactNative,
};

if (exampleAppType === 'vanilla') {
// React Native doesn't provide the community CLI as a dependency.
// We have to get read the version from the example app and put to the root package json
const exampleCommunityCLIVersion =
examplePackageJson.devDependencies['@react-native-community/cli'];
assert(
exampleCommunityCLIVersion !== undefined,
"The generated example app doesn't have community CLI installed"
);

devDependencies['@react-native-community/cli'] = exampleCommunityCLIVersion;
}

return {
devDependencies,
};
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import fs from 'fs-extra';
import path from 'path';
import https from 'https';
import { spawn } from './spawn';
import sortObjectKeys from './sortObjectKeys';

export type ExampleType = 'vanilla' | 'test-app' | 'expo' | 'none';
import { spawn } from '../utils/spawn';
import sortObjectKeys from '../utils/sortObjectKeys';
import type { ExampleApp } from '../input';

const FILES_TO_DELETE = [
'__tests__',
Expand Down Expand Up @@ -50,7 +49,7 @@ export default async function generateExampleApp({
bobVersion,
reactNativeVersion = 'latest',
}: {
type: ExampleType;
type: ExampleApp;
dest: string;
arch: 'new' | 'mixed' | 'legacy';
project: {
Expand Down
Loading
Loading