mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
23b4ac97bd
* Fix missing header name breaking sidebar render * Global command to generate theme from JSON object * Update packages/insomnia-app/app/ui/redux/modules/global.js Co-Authored-By: Opender Singh <opender94@gmail.com> Co-authored-by: Opender Singh <opender94@gmail.com>
39 lines
816 B
JavaScript
39 lines
816 B
JavaScript
// @flow
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import mkdirp from 'mkdirp';
|
|
import rimraf from 'rimraf';
|
|
import { PLUGIN_PATH } from '../common/constants';
|
|
|
|
export async function createPlugin(
|
|
moduleName: string,
|
|
version: string,
|
|
mainJs: string,
|
|
): Promise<void> {
|
|
const pluginDir = path.join(PLUGIN_PATH, moduleName);
|
|
|
|
rimraf.sync(pluginDir);
|
|
mkdirp.sync(pluginDir);
|
|
|
|
// Write package.json
|
|
fs.writeFileSync(
|
|
path.join(pluginDir, 'package.json'),
|
|
JSON.stringify(
|
|
{
|
|
name: moduleName,
|
|
version,
|
|
private: true,
|
|
insomnia: {
|
|
name: moduleName.replace(/^insomnia-plugin-/, ''),
|
|
},
|
|
main: 'main.js',
|
|
},
|
|
null,
|
|
2,
|
|
),
|
|
);
|
|
|
|
// Write main JS file
|
|
fs.writeFileSync(path.join(pluginDir, 'main.js'), mainJs);
|
|
}
|