UNPKG

@boostercloud/cli

Version:

CLI of the Booster Framework, the next level of abstraction for cloud-native applications

45 lines (44 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.removeSandboxProject = exports.createSandboxProject = void 0; const fs_1 = require("fs"); const fs_extra_1 = require("fs-extra"); const path = require("path"); const copyFolder = (origin, destiny) => { (0, fs_1.readdirSync)(origin, { withFileTypes: true }).forEach((dirEnt) => { if (dirEnt.isFile()) { (0, fs_extra_1.copySync)(path.join(origin, dirEnt.name), path.join(destiny, dirEnt.name)); } if (dirEnt.isDirectory()) { (0, fs_1.mkdirSync)(path.join(destiny, dirEnt.name), { recursive: true }); copyFolder(path.join(origin, dirEnt.name), path.join(destiny, dirEnt.name)); } }); }; const createSandboxProject = (sandboxPath, assets) => { (0, fs_1.rmSync)(sandboxPath, { recursive: true, force: true }); (0, fs_1.mkdirSync)(sandboxPath, { recursive: true }); copyFolder('src', path.join(sandboxPath, 'src')); const projectFiles = ['package.json', 'package-lock.json', 'tsconfig.json']; projectFiles.forEach((file) => { if ((0, fs_extra_1.existsSync)(file)) { (0, fs_extra_1.copySync)(file, path.join(sandboxPath, file)); } }); if (assets) { assets.forEach((asset) => { if ((0, fs_1.statSync)(asset).isDirectory()) { copyFolder(asset, path.join(sandboxPath, asset)); } else { (0, fs_extra_1.copySync)(asset, path.join(sandboxPath, asset)); } }); } return sandboxPath; }; exports.createSandboxProject = createSandboxProject; const removeSandboxProject = (sandboxPath) => { (0, fs_1.rmSync)(sandboxPath, { recursive: true, force: true }); }; exports.removeSandboxProject = removeSandboxProject;