@chevtek/cli
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -58,3 +58,9 @@ "use strict"; | ||
var rmdir = util_1.default.promisify(rimraf_1.default); | ||
var exec = util_1.default.promisify(child_process_1.default.exec); | ||
var spawn = function (command, args, cwd) { | ||
return new Promise(function (resolve, reject) { | ||
var cmd = child_process_1.default.spawn(command, args, { cwd: cwd, stdio: "inherit" }); | ||
cmd.on("error", reject); | ||
cmd.on("close", resolve); | ||
}); | ||
}; | ||
var format = function (source) { | ||
@@ -128,3 +134,3 @@ return prettier_1.default.format(source, { parser: "typescript" }); | ||
_a.sent(); | ||
return [4 /*yield*/, exec("npm install -D npm-run-all wait-on rimraf", { cwd: dir })]; | ||
return [4 /*yield*/, spawn("npm", ["install", "-D", "npm-run-all", "wait-on", "rimraf"], dir)]; | ||
case 2: | ||
@@ -175,10 +181,15 @@ _a.sent(); | ||
_a.sent(); | ||
return [4 /*yield*/, exec("npm install dotenv koa mongoose koa-static", { | ||
cwd: serverDir | ||
})]; | ||
return [4 /*yield*/, spawn("npm", ["install", "dotenv", "koa", "mongoose", "koa-static"], serverDir)]; | ||
case 3: | ||
_a.sent(); | ||
return [4 /*yield*/, exec("npm install -D typescript @types/node @types/koa @types/mongoose @types/koa-static ts-node-dev", { | ||
cwd: serverDir | ||
})]; | ||
return [4 /*yield*/, spawn("npm", [ | ||
"install", | ||
"-D", | ||
"typescript", | ||
"ts-node-dev", | ||
"@types/node", | ||
"@types/koa", | ||
"@types/koa-static", | ||
"@types/mongoose" | ||
], serverDir)]; | ||
case 4: | ||
@@ -216,5 +227,3 @@ _a.sent(); | ||
log("Created \"client\" directory."); | ||
return [4 /*yield*/, exec("npx create-react-app --template typescript .", { | ||
cwd: clientDir | ||
})]; | ||
return [4 /*yield*/, spawn("npx", ["create-react-app", "--template", "typescript", "."], clientDir)]; | ||
case 2: | ||
@@ -259,6 +268,3 @@ _c.sent(); | ||
err_1 = _a.sent(); | ||
if (err_1.errno === 34) { | ||
return [2 /*return*/, false]; | ||
} | ||
throw err_1; | ||
return [2 /*return*/, false]; | ||
case 3: return [2 /*return*/]; | ||
@@ -265,0 +271,0 @@ } |
@@ -18,3 +18,8 @@ import fs from "fs"; | ||
const rmdir = util.promisify(rimraf); | ||
const exec = util.promisify(childProcess.exec); | ||
const spawn = (command: string, args: string[], cwd?: string) => | ||
new Promise((resolve, reject) => { | ||
const cmd = childProcess.spawn(command, args, { cwd, stdio: "inherit" }); | ||
cmd.on("error", reject); | ||
cmd.on("close", resolve); | ||
}); | ||
const format = (source: string) => | ||
@@ -71,3 +76,7 @@ prettier.format(source, { parser: "typescript" }); | ||
); | ||
await exec("npm install -D npm-run-all wait-on rimraf", { cwd: dir }); | ||
await spawn( | ||
"npm", | ||
["install", "-D", "npm-run-all", "wait-on", "rimraf"], | ||
dir | ||
); | ||
log(`Created root package.json file.`); | ||
@@ -106,11 +115,21 @@ } | ||
); | ||
await exec("npm install dotenv koa mongoose koa-static", { | ||
cwd: serverDir | ||
}); | ||
await exec( | ||
"npm install -D typescript @types/node @types/koa @types/mongoose @types/koa-static ts-node-dev", | ||
{ | ||
cwd: serverDir | ||
} | ||
await spawn( | ||
"npm", | ||
["install", "dotenv", "koa", "mongoose", "koa-static"], | ||
serverDir | ||
); | ||
await spawn( | ||
"npm", | ||
[ | ||
"install", | ||
"-D", | ||
"typescript", | ||
"ts-node-dev", | ||
"@types/node", | ||
"@types/koa", | ||
"@types/koa-static", | ||
"@types/mongoose" | ||
], | ||
serverDir | ||
); | ||
await Promise.all([ | ||
@@ -182,5 +201,7 @@ writeFile( | ||
log(`Created "client" directory.`); | ||
await exec("npx create-react-app --template typescript .", { | ||
cwd: clientDir | ||
}); | ||
await spawn( | ||
"npx", | ||
["create-react-app", "--template", "typescript", "."], | ||
clientDir | ||
); | ||
log(`Created react app.`); | ||
@@ -208,7 +229,4 @@ await rmdir(path.join(clientDir, ".git")); | ||
} catch (err) { | ||
if (err.errno === 34) { | ||
return false; | ||
} | ||
throw err; | ||
return false; | ||
} | ||
} |
{ | ||
"name": "@chevtek/cli", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "bin": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34409
713