create-wasmgroundup
Advanced tools
Comparing version 2.0.3 to 2.1.0
49
index.js
@@ -6,5 +6,15 @@ #!/usr/bin/env node | ||
import { readFileSync } from "node:fs"; | ||
import prompts from "prompts"; | ||
const usage = "Usage: create-wasmgroundup dest_dir"; | ||
const usage = "Usage: create-wasmgroundup <dest_dir>"; | ||
const userAgent = process.env.npm_config_user_agent ?? ""; | ||
const pkgMan = /pnpm/.test(userAgent) | ||
? "pnpm" | ||
: /yarn/.test(userAgent) | ||
? "yarn" | ||
: /bun/.test(userAgent) | ||
? "bun" | ||
: "npm"; | ||
function bail(message) { | ||
@@ -15,6 +25,3 @@ process.stderr.write(`error: ${message}\n`); | ||
const destDir = process.argv[2]; | ||
if (!destDir) bail(`no destination directory specified\n\n${usage}`); | ||
(async function main() { | ||
async function cloneTemplate(destDir) { | ||
const emitter = degit("https://github.com/wasmgroundup/reader-template", { | ||
@@ -36,5 +43,28 @@ cache: false, | ||
} | ||
process.chdir(destDir); | ||
console.log('Running "npm install" in the destination directory...'); | ||
spawnSync("npm", ["install", "--silent"], { | ||
} | ||
(async function main() { | ||
let targetDir = process.argv[2]; | ||
const defaultProjectName = !targetDir ? "wasmgroundup" : targetDir; | ||
let result = {}; | ||
try { | ||
result = await prompts([ | ||
{ | ||
name: "projectName", | ||
type: targetDir ? null : "text", | ||
message: "Project name", | ||
initial: defaultProjectName, | ||
onState: (state) => | ||
(targetDir = String(state.value).trim() || defaultProjectName), | ||
}, | ||
]); | ||
} catch (cancelled) { | ||
console.log(cancelled.message); | ||
process.exit(1); | ||
} | ||
await cloneTemplate(targetDir); | ||
process.chdir(targetDir); | ||
console.log(`Running '${pkgMan} install' in the destination directory...`); | ||
spawnSync(pkgMan, ["install", "--silent"], { | ||
stdio: "inherit", | ||
@@ -47,4 +77,5 @@ shell: true, | ||
console.log( | ||
`\nYou're all set! You can do ${"`"}cd ${destDir}${"`"} to get started.`, | ||
`\nYou're all set! You can do ${"`"}cd ${targetDir}${"`"} to get started.`, | ||
); | ||
process.exit(0); | ||
})(); |
{ | ||
"name": "create-wasmgroundup", | ||
"type": "module", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -23,3 +23,4 @@ "bin": { | ||
"dependencies": { | ||
"degit": "^2.8.4" | ||
"degit": "^2.8.4", | ||
"prompts": "^2.4.2" | ||
}, | ||
@@ -26,0 +27,0 @@ "devDependencies": { |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
3690
67
2
2
+ Addedprompts@^2.4.2
+ Addedkleur@3.0.3(transitive)
+ Addedprompts@2.4.2(transitive)
+ Addedsisteransi@1.0.5(transitive)