Files
flipper/desktop/scripts/build-plugin.ts
Anton Nikolaev 228d09d572 Script for resolving plugin directory by its package name
Summary:
Changed "build-plugin" script to allow triggering release by plugin name (required to enable triggering releases by button in Marketplace):
1) Added new script to resolve plugin dir by name
2) Allow passing either plugin dir or name to "build-plugin" script

Reviewed By: passy

Differential Revision: D22354643

fbshipit-source-id: b7aca57acefc81ca0b6d9c7f359f63d8f0599e39
2020-07-02 02:48:19 -07:00

34 lines
1.1 KiB
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {pluginsDir, rootDir, distDir} from './paths';
import path from 'path';
import fs from 'fs-extra';
import {execSync} from 'child_process';
import {resolvePluginDir} from './workspaces';
(async function buildPlugin() {
const pluginName = process.argv[2];
const pluginDir = await resolvePluginDir(pluginName);
const outputFileArg = process.argv.length > 3 ? process.argv[3] : null;
const outputFile = outputFileArg
? path.resolve(outputFileArg)
: path.join(
distDir,
'plugins',
path.relative(pluginsDir, pluginDir) + '.tgz',
);
await fs.ensureDir(path.dirname(outputFile));
await fs.remove(outputFile);
const bundleCmd = `yarn flipper-pkg bundle "${pluginDir}" --production`;
const packCmd = `yarn pack --cwd "${pluginDir}" --filename ${outputFile}`;
execSync(bundleCmd, {cwd: rootDir, stdio: 'inherit'});
execSync(packCmd, {cwd: rootDir, stdio: 'inherit'});
})();