This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created withRunOnce * update * added internal object * Update Config.ts * Update history.ts * Update core-plugins-test.ts * Update core-plugins-test.ts
- Loading branch information
Showing
7 changed files
with
187 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 54 additions & 1 deletion
55
packages/config-plugins/src/plugins/__tests__/core-plugins-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ExpoConfig } from '@expo/config-types'; | ||
import chalk from 'chalk'; | ||
|
||
import { ConfigPlugin, ModPlatform } from '../Plugin.types'; | ||
import * as WarningAggregator from './warnings'; | ||
|
||
export function wrapWithWithDeprecationWarning<T>({ | ||
plugin, | ||
platform, | ||
packageName, | ||
unversionedName, | ||
updateUrl, | ||
shouldWarn, | ||
}: { | ||
plugin: ConfigPlugin<T>; | ||
updateUrl: string; | ||
platform: ModPlatform; | ||
packageName: string; | ||
unversionedName: string; | ||
shouldWarn: (config: ExpoConfig) => boolean; | ||
}): ConfigPlugin<T> { | ||
return (config, props) => { | ||
// Only warn if the user intends to enable an API for their app, otherwise there will be a flood of messages for every API. | ||
if (shouldWarn(config)) { | ||
WarningAggregator.addWarningForPlatform( | ||
platform, | ||
'deprecated-plugin', | ||
`Unversioned "${unversionedName}" plugin is deprecated, please update your Expo config to using the versioned plugin "${packageName}". Guide ${chalk.underline( | ||
updateUrl | ||
)}` | ||
); | ||
} | ||
return plugin(config, props); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ExpoConfig } from '@expo/config-types'; | ||
|
||
import { ModPlatform } from '../Plugin.types'; | ||
|
||
export type PluginHistoryItem = { | ||
name: string; | ||
version: string; | ||
platform?: ModPlatform; | ||
}; | ||
|
||
export function getHistoryItem( | ||
config: Pick<ExpoConfig, '_internal'>, | ||
name: string | ||
): PluginHistoryItem | null { | ||
return config._internal?.pluginHistory?.[name] ?? null; | ||
} | ||
|
||
export function addHistoryItem( | ||
config: ExpoConfig, | ||
item: Omit<PluginHistoryItem, 'version'> & { version?: string } | ||
): ExpoConfig { | ||
if (!config._internal) { | ||
config._internal = {}; | ||
} | ||
if (!config._internal.pluginHistory) { | ||
config._internal.pluginHistory = {}; | ||
} | ||
|
||
if (!item.version) { | ||
item.version = 'UNVERSIONED'; | ||
} | ||
|
||
config._internal.pluginHistory[item.name] = item; | ||
|
||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters