|
|
@@ -7,6 +7,8 @@ import fs from 'graceful-fs';
|
|
|
import normalize from 'normalize-path';
|
|
|
import swig from 'swig-templates';
|
|
|
|
|
|
+import { PluginDefinitionV4 } from '@growi/core';
|
|
|
+
|
|
|
import PluginUtils from '../src/server/plugins/plugin-utils';
|
|
|
import loggerFactory from '../src/utils/logger';
|
|
|
import { resolveFromRoot } from '../src/utils/project-dir-utils';
|
|
|
@@ -23,26 +25,32 @@ const OUT = resolveFromRoot('tmp/plugins/plugin-definitions.js');
|
|
|
const pluginNames: string[] = pluginUtils.listPluginNames();
|
|
|
logger.info('Detected plugins: ', pluginNames);
|
|
|
|
|
|
-// get definitions
|
|
|
-const definitions = pluginNames
|
|
|
- .map((name) => {
|
|
|
- return pluginUtils.generatePluginDefinition(name, true);
|
|
|
- })
|
|
|
- .map((definition) => {
|
|
|
- if (definition == null) {
|
|
|
- return null;
|
|
|
+async function main(): Promise<void> {
|
|
|
+
|
|
|
+ // get definitions
|
|
|
+ const definitions: PluginDefinitionV4[] = [];
|
|
|
+ for (const pluginName of pluginNames) {
|
|
|
+ // eslint-disable-next-line no-await-in-loop
|
|
|
+ const definition = await pluginUtils.generatePluginDefinition(pluginName, true);
|
|
|
+ if (definition != null) {
|
|
|
+ definitions.push(definition);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ definitions.map((definition) => {
|
|
|
// convert backslash to slash
|
|
|
definition.entries = definition.entries.map((entryPath) => {
|
|
|
return normalize(entryPath);
|
|
|
});
|
|
|
return definition;
|
|
|
- })
|
|
|
- .filter(definition => definition != null);
|
|
|
+ });
|
|
|
+
|
|
|
+ const compiledTemplate = swig.compileFile(TEMPLATE);
|
|
|
+ const code = compiledTemplate({ definitions });
|
|
|
+
|
|
|
+ // write
|
|
|
+ fs.writeFileSync(OUT, code);
|
|
|
|
|
|
-const compiledTemplate = swig.compileFile(TEMPLATE);
|
|
|
-const code = compiledTemplate({ definitions });
|
|
|
+}
|
|
|
|
|
|
-// write
|
|
|
-fs.writeFileSync(OUT, code);
|
|
|
+main();
|