feat(plugins): include "@emigrate/" in the plugin search prefix list
This commit is contained in:
parent
acb0b4f195
commit
672fae1729
2 changed files with 22 additions and 6 deletions
5
.changeset/silent-boats-speak.md
Normal file
5
.changeset/silent-boats-speak.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@emigrate/plugin-tools': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Include "@emigrate/" in the plugin prefix list, i.e. when searching for the plugin "blaha" it will look for the packages "blaha", "@emigrate/blaha", "@emigrate/plugin-blaha" and "emigrate-plugin-blaha" and use the first of them that exists
|
||||||
|
|
@ -43,6 +43,9 @@ export const isEmigrateReporter = (plugin: any): plugin is EmigrateReporter => {
|
||||||
'onCollectedMigrations',
|
'onCollectedMigrations',
|
||||||
'onLockedMigrations',
|
'onLockedMigrations',
|
||||||
'onNewMigration',
|
'onNewMigration',
|
||||||
|
'onMigrationRemoveStart',
|
||||||
|
'onMigrationRemoveSuccess',
|
||||||
|
'onMigrationRemoveError',
|
||||||
'onMigrationStart',
|
'onMigrationStart',
|
||||||
'onMigrationSuccess',
|
'onMigrationSuccess',
|
||||||
'onMigrationError',
|
'onMigrationError',
|
||||||
|
|
@ -139,18 +142,22 @@ const getOrLoad = async <T>(potentials: Array<StringOrModule<unknown>>, check: (
|
||||||
};
|
};
|
||||||
|
|
||||||
const getImportFromEsm = async () => {
|
const getImportFromEsm = async () => {
|
||||||
let importFromEsm = await import('import-from-esm');
|
const importFromEsm = await import('import-from-esm');
|
||||||
|
|
||||||
// Because of "allowSyntheticDefaultImports" we need to do this ugly hack
|
// Because of "allowSyntheticDefaultImports" we need to do this ugly hack
|
||||||
if ((importFromEsm as any).default) {
|
if ((importFromEsm as any).default) {
|
||||||
importFromEsm = (importFromEsm as any).default as unknown as typeof importFromEsm;
|
return (importFromEsm as any).default as unknown as typeof importFromEsm;
|
||||||
}
|
}
|
||||||
|
|
||||||
return importFromEsm;
|
return importFromEsm;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const loadStorage = async (name: string): Promise<EmigrateStorage | undefined> => {
|
export const loadStorage = async (name: string): Promise<EmigrateStorage | undefined> => {
|
||||||
return load(name, ['@emigrate/storage-', 'emigrate-storage-', '@emigrate/plugin-storage-'], isEmigrateStorage);
|
return load(
|
||||||
|
name,
|
||||||
|
['@emigrate/', '@emigrate/storage-', 'emigrate-storage-', '@emigrate/plugin-storage-'],
|
||||||
|
isEmigrateStorage,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const loadReporter = async (name: string): Promise<EmigrateReporter | undefined> => {
|
export const loadReporter = async (name: string): Promise<EmigrateReporter | undefined> => {
|
||||||
|
|
@ -161,9 +168,13 @@ export const loadPlugin = async <T extends PluginType>(
|
||||||
type: T,
|
type: T,
|
||||||
plugin: string,
|
plugin: string,
|
||||||
): Promise<PluginFromType<T> | undefined> => {
|
): Promise<PluginFromType<T> | undefined> => {
|
||||||
return load(plugin, ['@emigrate/plugin-', 'emigrate-plugin-'], (value: unknown): value is PluginFromType<T> => {
|
return load(
|
||||||
return isPluginOfType(type, value);
|
plugin,
|
||||||
});
|
['@emigrate/', '@emigrate/plugin-', 'emigrate-plugin-'],
|
||||||
|
(value: unknown): value is PluginFromType<T> => {
|
||||||
|
return isPluginOfType(type, value);
|
||||||
|
},
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const load = async <T>(
|
const load = async <T>(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue