diff --git a/packages/cli/src/commands/build/build.js b/packages/cli/src/commands/build/build.js index b0ba80378..62f1a691a 100644 --- a/packages/cli/src/commands/build/build.js +++ b/packages/cli/src/commands/build/build.js @@ -15,6 +15,7 @@ */ import addCustomPluginsAsDeps from '../../utils/addCustomPluginsAsDeps.js'; +import copyPluginsFolder from '../../utils/copyPluginsFolder.js'; import getServer from '../../utils/getServer.js'; import installServer from '../../utils/installServer.js'; import mergePackageJson from '../../utils/mergePackageJson.js'; @@ -29,6 +30,7 @@ async function build({ context }) { context, serverDirectory: directory, }); + await copyPluginsFolder({ context }); await addCustomPluginsAsDeps({ context, directory }); await installServer({ context, directory }); await runLowdefyBuild({ context, directory }); diff --git a/packages/cli/src/utils/copyPluginsFolder.js b/packages/cli/src/utils/copyPluginsFolder.js new file mode 100644 index 000000000..893c95197 --- /dev/null +++ b/packages/cli/src/utils/copyPluginsFolder.js @@ -0,0 +1,31 @@ +/* + Copyright 2020-2021 Lowdefy, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import path from 'path'; +import fs from 'fs'; +import { copyDirectory } from '@lowdefy/node-utils'; + +async function copyPluginsFolder({ context }) { + if (context.directories.config === context.directories.server) return; + if (!fs.existsSync(path.resolve(context.directories.config, 'plugins'))) return; + + await copyDirectory( + path.resolve(context.directories.config, 'plugins'), + path.resolve(context.directories.server, 'plugins') + ); +} + +export default copyPluginsFolder;