2021-09-08 12:06:37 -05:00
|
|
|
import fs from 'fs-extra';
|
2021-10-29 10:33:05 -05:00
|
|
|
import os from 'os';
|
|
|
|
import path from 'path';
|
2019-12-15 11:06:28 -05:00
|
|
|
|
2020-12-21 04:22:06 -05:00
|
|
|
export function createProject(projectName: string) {
|
|
|
|
// @ts-ignore
|
|
|
|
const tempRootFolder = global.__namespace.getItem('dir-suite-root');
|
|
|
|
const verdaccioInstall = path.join(tempRootFolder, projectName);
|
|
|
|
fs.mkdirSync(verdaccioInstall);
|
|
|
|
|
|
|
|
return verdaccioInstall;
|
|
|
|
}
|
2019-12-15 11:06:28 -05:00
|
|
|
export function copyConfigFile(rootFolder, configTemplate): string {
|
2021-03-14 02:42:46 -05:00
|
|
|
const configPath = path.join(rootFolder, 'verdaccio.yaml');
|
2021-09-08 12:06:37 -05:00
|
|
|
copyTo(path.join(__dirname, configTemplate), configPath);
|
2019-12-15 11:06:28 -05:00
|
|
|
|
2021-03-14 02:42:46 -05:00
|
|
|
return configPath;
|
2019-12-15 11:06:28 -05:00
|
|
|
}
|
2021-09-08 12:06:37 -05:00
|
|
|
|
|
|
|
export function createTempFolder(prefix: string) {
|
|
|
|
return fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), prefix));
|
|
|
|
}
|
|
|
|
|
|
|
|
export function copyTo(from, to) {
|
|
|
|
fs.copyFileSync(from, to);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function cleanUpTemp(tmpFolder) {
|
|
|
|
fs.rmdirSync(tmpFolder, { recursive: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
export const SETUP_VERDACCIO_PORT = `6001`;
|