UNPKG

@applicaster/zapplicaster-cli

Version:

CLI Tool for the zapp app and Quick Brick project

45 lines (33 loc) 1.26 kB
const R = require("ramda"); const path = require("path"); const { writeJsonToFile } = require("../../file"); const logger = require("../../logger"); const PACKAGE_DOT_JSON = "package.json"; const QUICK_BRICK_WORKSPACE_NAME = "quick-brick"; const CORE_PLUGINS_PATH = "packages/quick-brick-core-plugins"; async function updateCorePluginsIfNeeded(configuration) { const { name: workspaceName } = require( path.join(process.cwd(), PACKAGE_DOT_JSON) ); if (workspaceName !== QUICK_BRICK_WORKSPACE_NAME) { return; } const { version, pluginPackageJson } = configuration; const { name } = pluginPackageJson; const corePluginsPackageJson = require( path.join(process.cwd(), CORE_PLUGINS_PATH, PACKAGE_DOT_JSON) ); const { dependencies } = corePluginsPackageJson; const isPluginCore = R.contains(name, R.keys(dependencies)); if (isPluginCore) { corePluginsPackageJson.dependencies[name] = version; await writeJsonToFile( path.join(process.cwd(), CORE_PLUGINS_PATH, PACKAGE_DOT_JSON), corePluginsPackageJson ); logger.log(`Core Plugins updated with ${name}@${version}`); } else { logger.log(`${name} is not a core plugin, skipping update`); } } module.exports = { updateCorePluginsIfNeeded };