Output unpacked plugin dir in addition to tar from "build-plugin" command
Summary: "plugin-build" command will produce dir with unpacked plugin sources in addition to tar package. This is required because for publishing to Marketplace we need to retrieve few files from the output package, like "readme.md" and "package.json" and it's better to have it already unpacked rather than pack and then unpack to get these files. Reviewed By: passy Differential Revision: D28409930 fbshipit-source-id: 51c8eeb848a72850a2f126eb91a563d52851ed41
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5afd38165d
commit
b5d8f6c63d
@@ -48,6 +48,11 @@ const argv = yargs
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
alias: 'o',
|
alias: 'o',
|
||||||
},
|
},
|
||||||
|
'output-unpacked': {
|
||||||
|
description: 'Where to save the unpacked plugin package',
|
||||||
|
type: 'string',
|
||||||
|
alias: 'ou',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.help()
|
.help()
|
||||||
.strict()
|
.strict()
|
||||||
@@ -58,6 +63,7 @@ async function buildPlugin() {
|
|||||||
const previousChecksum = argv.checksum;
|
const previousChecksum = argv.checksum;
|
||||||
const pluginDir = await resolvePluginDir(pluginName);
|
const pluginDir = await resolvePluginDir(pluginName);
|
||||||
const outputFileArg = argv.output;
|
const outputFileArg = argv.output;
|
||||||
|
const outputUnpackedArg = argv['output-unpacked'];
|
||||||
const minFlipperVersion = argv['min-flipper-version'];
|
const minFlipperVersion = argv['min-flipper-version'];
|
||||||
const packageJsonPath = path.join(pluginDir, 'package.json');
|
const packageJsonPath = path.join(pluginDir, 'package.json');
|
||||||
await runBuild(pluginDir, false);
|
await runBuild(pluginDir, false);
|
||||||
@@ -71,6 +77,9 @@ async function buildPlugin() {
|
|||||||
'plugins',
|
'plugins',
|
||||||
path.relative(pluginsDir, pluginDir) + '.tgz',
|
path.relative(pluginsDir, pluginDir) + '.tgz',
|
||||||
);
|
);
|
||||||
|
const outputUnpackedDir = outputUnpackedArg
|
||||||
|
? path.resolve(outputUnpackedArg)
|
||||||
|
: path.join(distDir, 'plugins', path.relative(pluginsDir, pluginDir));
|
||||||
await fs.ensureDir(path.dirname(outputFile));
|
await fs.ensureDir(path.dirname(outputFile));
|
||||||
await fs.remove(outputFile);
|
await fs.remove(outputFile);
|
||||||
const {name: tmpDir} = tmp.dirSync();
|
const {name: tmpDir} = tmp.dirSync();
|
||||||
@@ -84,12 +93,13 @@ async function buildPlugin() {
|
|||||||
}
|
}
|
||||||
packageJson.engines.flipper = minFlipperVersion;
|
packageJson.engines.flipper = minFlipperVersion;
|
||||||
}
|
}
|
||||||
if (argv.version) {
|
|
||||||
packageJson.version = argv.version;
|
packageJson.version = argv.version;
|
||||||
}
|
|
||||||
await fs.writeJson(packageJsonPath, packageJson, {spaces: 2});
|
await fs.writeJson(packageJsonPath, packageJson, {spaces: 2});
|
||||||
const packCmd = `yarn pack --cwd "${pluginDir}" --filename ${outputFile}`;
|
const packCmd = `yarn pack --cwd "${pluginDir}" --filename ${outputFile}`;
|
||||||
execSync(packCmd, {cwd: rootDir, stdio: 'inherit'});
|
execSync(packCmd, {cwd: rootDir, stdio: 'inherit'});
|
||||||
|
await fs.remove(outputUnpackedDir);
|
||||||
|
await fs.copy(pluginDir, outputUnpackedDir, {overwrite: true});
|
||||||
|
console.log(`Unpacked package saved to ${outputUnpackedDir}`);
|
||||||
} finally {
|
} finally {
|
||||||
await fs.move(packageJsonBackupPath, packageJsonPath, {overwrite: true});
|
await fs.move(packageJsonBackupPath, packageJsonPath, {overwrite: true});
|
||||||
await fs.remove(tmpDir);
|
await fs.remove(tmpDir);
|
||||||
|
|||||||
Reference in New Issue
Block a user