Skip to content

Commit

Permalink
[config][cli] Remove classic manifest types (expo#24054)
Browse files Browse the repository at this point in the history
  • Loading branch information
wschurman authored Aug 23, 2023
1 parent b51b513 commit 9ba03fb
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 679 deletions.
6 changes: 2 additions & 4 deletions docs/pages/archive/expo-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ Alias: `expo r`
| `--max-workers [num]` | Maximum number of tasks to allow Metro to spawn. |
| `--no-dev` | Turn development mode off |
| `--minify` | Minify code |
| `--https` | To start webpack with https protocol |
| `--force-manifest-type [manifest-type]` | Override auto detection of manifest type |
| `--https` | To start webpack with https protocol | |
| `-p, --port [port]` | Port to start the native Metro bundler on (does not apply to web or tunnel). Default: 19000 |
| `--dev-client` | Experimental: Starts the bundler for use with the expo-development-client |
| `--scheme [scheme]` | Custom URI protocol to use with a development build |
Expand All @@ -176,8 +175,7 @@ Alias: `expo web`
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `--no-dev` | Turn development mode off |
| `--minify` | Minify code |
| `--https` | To start webpack with https protocol |
| `--force-manifest-type [manifest-type]` | Override auto detection of manifest type |
| `--https` | To start webpack with https protocol | |
| `-p, --port [port]` | Port to start the webpack bundler on. Default: 19006 |
| `-s, --send-to [dest]` | An email address to send a link to |
| `--dev-client` | Experimental: Starts the bundler for use with the expo-development-client |
Expand Down
3 changes: 0 additions & 3 deletions guides/releasing/Quality Assurance.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ Unversioned QA: Test in native-component-list.
- Go to `apps/test-suite`.
- Update its `sdkVersion` in `app.json`. Use `UNVERSIONED` for unversioned QA and the new SDK version for versioned QA.
- Run `expo start` and test each module.
- Run `expo start --force-manifest-type=expo-updates` and sanity check one or two modules (mainly just checking that project opens).

### 4. Inspecting native-component-list examples

- Go to `apps/native-component-list`.
- Update its `sdkVersion` in `app.json`. Use `UNVERSIONED` for unversioned QA and the new SDK version for versioned QA.
- Run `expo start` and check every example, including React Native components.
- Run `expo start --force-manifest-type=expo-updates` and sanity check one or two examples (mainly just checking that project opens).

### 5. Smoke test Expo Home

Expand All @@ -67,7 +65,6 @@ Unversioned QA: Test in native-component-list.
- Run `expo init -t blank@sdk-x` for each supported SDK version.
- Run `expo start` and ensure the project loads without crashing.
- Run `expo start --force-manifest-type=expo-updates` and ensure the project loads without crashing.

## Development builds

Expand Down
2 changes: 2 additions & 0 deletions packages/@expo/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### 🛠 Breaking changes

- Remove classic manifest types. ([#24054](https://github.com/expo/expo/pull/24054) by [@wschurman](https://github.com/wschurman))

### 🎉 New features

- Forward exact Metro server error during static rendering. ([#23909](https://github.com/expo/expo/pull/23909) by [@EvanBacon](https://github.com/EvanBacon))
Expand Down
1 change: 0 additions & 1 deletion packages/@expo/cli/e2e/__tests__/start-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ it('runs `npx expo start --help`', async () => {
--scheme <scheme> Custom URI protocol to use when launching an app
-p, --port <number> Port to start the dev server on (does not apply to web or tunnel). Default: 8081
--force-manifest-type <string> Override auto detection of manifest type. Options: expo-updates, classic
--private-key-path <path> Path to private key for code signing. Default: "private-key.pem" in the same directory as the certificate specified by the expo-updates configuration in app.json.
-h, --help Usage info
"
Expand Down
25 changes: 0 additions & 25 deletions packages/@expo/cli/src/api/__tests__/signManifest-test.ts

This file was deleted.

25 changes: 0 additions & 25 deletions packages/@expo/cli/src/api/signManifest.ts

This file was deleted.

12 changes: 6 additions & 6 deletions packages/@expo/cli/src/export/exportAssets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExpoAppManifest } from '@expo/config';
import { ExpoConfig } from '@expo/config';
import { ModPlatform } from '@expo/config-plugins';
import fs from 'fs';
import minimatch from 'minimatch';
Expand All @@ -17,11 +17,11 @@ const debug = require('debug')('expo:export:exportAssets') as typeof console.log
*
* @modifies {exp}
*/
export async function resolveAssetBundlePatternsAsync(
export async function resolveAssetBundlePatternsAsync<T extends ExpoConfig>(
projectRoot: string,
exp: Pick<ExpoAppManifest, 'bundledAssets' | 'assetBundlePatterns'>,
exp: T,
assets: Asset[]
) {
): Promise<Omit<T, 'assetBundlePatterns'> & { bundledAssets?: string[] }> {
if (!exp.assetBundlePatterns?.length || !assets.length) {
delete exp.assetBundlePatterns;
return exp;
Expand Down Expand Up @@ -52,7 +52,7 @@ export async function resolveAssetBundlePatternsAsync(

// The assets returned by the RN packager has duplicates so make sure we
// only bundle each once.
exp.bundledAssets = [...new Set(allBundledAssets)];
(exp as any).bundledAssets = [...new Set(allBundledAssets)];
delete exp.assetBundlePatterns;

return exp;
Expand Down Expand Up @@ -81,7 +81,7 @@ export async function exportAssetsAsync(
outputDir,
bundles,
}: {
exp: ExpoAppManifest;
exp: ExpoConfig;
bundles: Partial<Record<ModPlatform, BundleOutput>>;
outputDir: string;
}
Expand Down
8 changes: 5 additions & 3 deletions packages/@expo/cli/src/export/getPublicExpoManifest.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ExpoAppManifest, getConfig } from '@expo/config';
import { ExpoConfig, getConfig } from '@expo/config';

import { getResolvedLocalesAsync } from './getResolvedLocales';
import { LocaleMap, getResolvedLocalesAsync } from './getResolvedLocales';
import { env } from '../utils/env';
import { CommandError } from '../utils/errors';

/** Get the public Expo manifest from the local project config. */
export async function getPublicExpoManifestAsync(projectRoot: string): Promise<ExpoAppManifest> {
export async function getPublicExpoManifestAsync(
projectRoot: string
): Promise<ExpoConfig & { locales: LocaleMap; sdkVersion: string }> {
// Read the config in public mode which strips the `hooks`.
const { exp } = getConfig(projectRoot, {
isPublicConfig: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/@expo/cli/src/export/getResolvedLocales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'path';

import { CommandError } from '../utils/errors';

type LocaleMap = Record<string, JSONObject>;
export type LocaleMap = Record<string, JSONObject>;

// Similar to how we resolve locales in `@expo/config-plugins`
export async function getResolvedLocalesAsync(
Expand Down
2 changes: 0 additions & 2 deletions packages/@expo/cli/src/start/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const expoStart: Command = async (argv) => {
'--no-dev': Boolean,
'--minify': Boolean,
'--https': Boolean,
'--force-manifest-type': String,
'--private-key-path': String,
'--port': Number,
'--dev-client': Boolean,
Expand Down Expand Up @@ -76,7 +75,6 @@ export const expoStart: Command = async (argv) => {
`--scheme <scheme> Custom URI protocol to use when launching an app`,
chalk`-p, --port <number> Port to start the dev server on (does not apply to web or tunnel). {dim Default: 8081}`,
``,
chalk`--force-manifest-type <string> Override auto detection of manifest type. {dim Options: expo-updates, classic}`,
chalk`--private-key-path <path> Path to private key for code signing. {dim Default: "private-key.pem" in the same directory as the certificate specified by the expo-updates configuration in app.json.}`,
`-h, --help Usage info`,
].join('\n')
Expand Down
6 changes: 0 additions & 6 deletions packages/@expo/cli/src/start/resolveOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AbortCommandError, CommandError } from '../utils/errors';
import { resolvePortAsync } from '../utils/port';

export type Options = {
forceManifestType: 'classic' | 'expo-updates';
privateKeyPath: string | null;
android: boolean;
web: boolean;
Expand All @@ -24,10 +23,6 @@ export type Options = {
};

export async function resolveOptionsAsync(projectRoot: string, args: any): Promise<Options> {
const forceManifestType = args['--force-manifest-type'];
if (forceManifestType) {
assert.match(forceManifestType, /^(classic|expo-updates)$/);
}
if (args['--dev-client'] && args['--go']) {
throw new CommandError('BAD_ARGS', 'Cannot use both --dev-client and --go together.');
}
Expand Down Expand Up @@ -59,7 +54,6 @@ export async function resolveOptionsAsync(projectRoot: string, args: any): Promi
});

return {
forceManifestType,
privateKeyPath: args['--private-key-path'] ?? null,

android: !!args['--android'],
Expand Down
21 changes: 3 additions & 18 deletions packages/@expo/cli/src/start/server/BundlerDevServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export interface BundlerStartOptions {
devClient?: boolean;
/** Should run dev servers with clean caches. */
resetDevServer?: boolean;
/** Which manifest type to serve. */
forceManifestType?: 'expo-updates' | 'classic';
/** Code signing private key path (defaults to same directory as certificate) */
privateKeyPath?: string;

Expand Down Expand Up @@ -81,15 +79,6 @@ const PLATFORM_MANAGERS = {
.AndroidPlatformManager as typeof import('../platforms/android/AndroidPlatformManager').AndroidPlatformManager,
};

const MIDDLEWARES = {
classic: () =>
require('./middleware/ClassicManifestMiddleware')
.ClassicManifestMiddleware as typeof import('./middleware/ClassicManifestMiddleware').ClassicManifestMiddleware,
'expo-updates': () =>
require('./middleware/ExpoGoManifestHandlerMiddleware')
.ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware,
};

export abstract class BundlerDevServer {
/** Name of the bundler. */
abstract get name(): string;
Expand Down Expand Up @@ -122,14 +111,10 @@ export abstract class BundlerDevServer {

/** Get the manifest middleware function. */
protected async getManifestMiddlewareAsync(
options: Pick<
BundlerStartOptions,
'minify' | 'mode' | 'forceManifestType' | 'privateKeyPath'
> = {}
options: Pick<BundlerStartOptions, 'minify' | 'mode' | 'privateKeyPath'> = {}
) {
const manifestType = options.forceManifestType || 'classic';
assert(manifestType in MIDDLEWARES, `Manifest middleware for type '${manifestType}' not found`);
const Middleware = MIDDLEWARES[manifestType]();
const Middleware = require('./middleware/ExpoGoManifestHandlerMiddleware')
.ExpoGoManifestHandlerMiddleware as typeof import('./middleware/ExpoGoManifestHandlerMiddleware').ExpoGoManifestHandlerMiddleware;

const urlCreator = this.getUrlCreator();
const middleware = new Middleware(this.projectRoot, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,6 @@ describe('getNativeRuntimeUrl', () => {

describe('getManifestMiddlewareAsync', () => {
const server = new MockBundlerDevServer('/', getPlatformBundlers({}));
it(`asserts invalid manifest type`, async () => {
await expect(
server['getManifestMiddlewareAsync']({
// @ts-expect-error
forceManifestType: 'foobar',
})
).rejects.toThrow(/Manifest middleware for type 'foobar' not found/);
});
it(`asserts server is not running`, async () => {
await expect(server['getManifestMiddlewareAsync']()).rejects.toThrow(
/Dev server instance not found/
Expand Down
Loading

0 comments on commit 9ba03fb

Please sign in to comment.