create-bridge-app
Advanced tools
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
| return new (P || (P = Promise))(function (resolve, reject) { | ||
| function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
| function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
| step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
| }); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.renameFolder = void 0; | ||
| const fs = __importStar(require("fs")); | ||
| const util = __importStar(require("util")); | ||
| const path = __importStar(require("path")); | ||
| const readdir = util.promisify(fs.readdir); | ||
| const mkdir = util.promisify(fs.mkdir); | ||
| const rmdir = util.promisify(fs.rmdir); | ||
| const readFile = util.promisify(fs.readFile); | ||
| const writeFile = util.promisify(fs.writeFile); | ||
| function copy(src, dest) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| const filenames = yield readdir(src); | ||
| yield mkdir(dest); | ||
| for (const filename of filenames) { | ||
| const srcPath = path.join(src, filename); | ||
| const destPath = path.join(dest, filename); | ||
| const stat = yield fs.promises.stat(srcPath); | ||
| if (stat.isDirectory()) { | ||
| yield copy(srcPath, destPath); | ||
| } | ||
| else { | ||
| const data = yield readFile(srcPath); | ||
| yield writeFile(destPath, data); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
| function renameFolder(oldPath, newPath) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| try { | ||
| yield fs.promises.rename(oldPath, newPath); | ||
| // console.log(`Successfully renamed '${oldPath}' to '${newPath}'`); | ||
| } | ||
| catch (err) { | ||
| yield copy(oldPath, newPath); | ||
| yield rmdir(oldPath); | ||
| } | ||
| }); | ||
| } | ||
| exports.renameFolder = renameFolder; |
+4
-29
@@ -20,2 +20,3 @@ #!/usr/bin/env node | ||
| const child_process_1 = require("child_process"); | ||
| const renameSync_1 = require("./renameSync"); | ||
| const launch = () => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -52,33 +53,7 @@ const slugRegex = /^[a-zA-Z0-9-]+$/; | ||
| fs_1.default.mkdirSync(projectName); | ||
| const oldPath = path_1.default.join(tempRepoPath, `examples/${template}`); | ||
| const newPath = projectName; | ||
| // const oldPath = path.join(tempRepoPath, `examples/${template}`); | ||
| // const newPath = projectName; | ||
| // fs.copyFileSync(path.join(tempRepoPath, `examples/${template}`), projectName); | ||
| // fs.unlinkSync(`examples/${template}`); | ||
| fs_1.default.rename(oldPath, newPath, (err) => { | ||
| if (err) { | ||
| if (err.code === 'EPERM') { | ||
| copy(); | ||
| } | ||
| else { | ||
| console.error(err); | ||
| } | ||
| return; | ||
| } | ||
| console.log(`Successfully renamed '${oldPath}' to '${newPath}'`); | ||
| }); | ||
| function copy() { | ||
| const readStream = fs_1.default.createReadStream(oldPath); | ||
| const writeStream = fs_1.default.createWriteStream(newPath); | ||
| readStream.on('error', console.error); | ||
| writeStream.on('error', console.error); | ||
| readStream.on('close', () => { | ||
| fs_1.default.rmdir(oldPath, (err) => { | ||
| if (err) | ||
| return console.error(err); | ||
| console.log(`Successfully renamed '${oldPath}' to '${newPath}'`); | ||
| }); | ||
| }); | ||
| readStream.pipe(writeStream); | ||
| } | ||
| // fs.renameSync(path.join(tempRepoPath, `examples/${template}`), projectName); | ||
| (0, renameSync_1.renameFolder)(path_1.default.join(tempRepoPath, `examples/${template}`), projectName); | ||
| const packageJSONPath = path_1.default.join(projectName, 'package.json'); | ||
@@ -85,0 +60,0 @@ fs_1.default.readFile(packageJSONPath, 'utf-8', (err, data) => { |
+1
-1
| { | ||
| "name": "create-bridge-app", | ||
| "version": "1.0.31", | ||
| "version": "1.0.32", | ||
| "description": "Create Bridge-powered Express app with one command", | ||
@@ -5,0 +5,0 @@ "author": "Bridge Team <support@bridge.codes>", |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
14504
19.52%8
14.29%280
21.21%4
33.33%