|
|
@@ -43,33 +43,18 @@ export class PluginService {
|
|
|
console.log('downloadZipFile error', err);
|
|
|
}
|
|
|
|
|
|
- // TODO: detect plugins
|
|
|
// save plugin metadata
|
|
|
const ghRepositoryName = ghUrl.split('/').slice(-1)[0];
|
|
|
- const installedPath = path.join(downloadDir, `${ghRepositoryName}-master`, 'meta.json');
|
|
|
- await this.savePluginMetaData(installedPath);
|
|
|
+ const installedPath = path.join(downloadDir, `${ghRepositoryName}-main`);
|
|
|
+ const plugins = await PluginService.detectPlugins(origin, installedPath);
|
|
|
+ await this.savePluginMetaData(plugins);
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- async savePluginMetaData(installedPath: string): Promise<void> {
|
|
|
- const metaData = this.getPluginMetaData(installedPath);
|
|
|
+ async savePluginMetaData(plugins: GrowiPlugin[]): Promise<void> {
|
|
|
const GrowiPlugin = mongoose.model('GrowiPlugin');
|
|
|
-
|
|
|
- await GrowiPlugin.insertMany({
|
|
|
- isEnabled: true,
|
|
|
- installedPath,
|
|
|
- meta: {
|
|
|
- name: metaData.name,
|
|
|
- types: metaData.types,
|
|
|
- author: metaData.author,
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private getPluginMetaData(installedPath: string): GrowiPluginMeta {
|
|
|
- const metaDataJSON = JSON.parse(fs.readFileSync(installedPath, 'utf-8'));
|
|
|
- return metaDataJSON;
|
|
|
+ await GrowiPlugin.insertMany(plugins);
|
|
|
}
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
@@ -101,7 +86,6 @@ export class PluginService {
|
|
|
if (growiPlugin.types == null) {
|
|
|
throw new Error('\'growiPlugin\' section must have a \'types\' property.');
|
|
|
}
|
|
|
-
|
|
|
const plugin = {
|
|
|
isEnabled: true,
|
|
|
installedPath,
|