From 22de3d65eecfebcf8f6e9f1367f8735d8a538d5a Mon Sep 17 00:00:00 2001 From: Daniel Heras Quesada Date: Tue, 22 Oct 2024 00:23:28 +0200 Subject: [PATCH] first commit --- .gitignore | 5 +++++ LICENCE.txt | 13 +++++++++++++ bin/index.js | 41 +++++++++++++++++++++++++++++++++++++++++ package-lock.json | 28 ++++++++++++++++++++++++++++ package.json | 27 +++++++++++++++++++++++++++ 5 files changed, 114 insertions(+) create mode 100644 .gitignore create mode 100644 LICENCE.txt create mode 100755 bin/index.js create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..005c580 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +node_modules +build +npm-debug.log +.env +.DS_Store diff --git a/LICENCE.txt b/LICENCE.txt new file mode 100644 index 0000000..8b1a9d8 --- /dev/null +++ b/LICENCE.txt @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar + +Everyone is permitted to copy and distribute verbatim or modified +copies of this license document, and changing it is allowed as long +as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/bin/index.js b/bin/index.js new file mode 100755 index 0000000..4477ab1 --- /dev/null +++ b/bin/index.js @@ -0,0 +1,41 @@ +#! /usr/bin/env node +const path = require("node:path"); +const { execSync } = require("child_process"); +const readlineSync = require("readline-sync"); + +const variants = ["NestJS", "ExpressJS"]; +const variant_branch_mapping = { NestJS: "nestjs", ExpressJS: "express" }; + +console.log("\x1b[34mBackend framework variants:\x1b[0m"); + +const variant = readlineSync.keyInSelect( + variants, + "\x1b[34m>\x1b[0m Choose backend framework", +); + +if (variant < 0) { + console.log("\x1b[31mBye!\x1b[0m"); + return; +} else { + const project_name = readlineSync.question( + "\x1b[34m>\x1b[0m Project name (empty for default): \x1b[0m", + ); + + const git_command = + "git clone -b " + + variant_branch_mapping[variants[variant]] + + " https://github.com/dqnid/full-stack-archetype.git " + + project_name; + + console.log("\x1b[34mCloning the repo...\x1b[0m"); + console.log("\x1b[34m-------------------\x1b[0m"); + + execSync(git_command, { + stdio: [0, 1, 2], // stdin, stdout, stderr + cwd: path.resolve(""), + }); + + console.log("\x1b[32m-----\x1b[0m"); + console.log("\x1b[32mDone!\x1b[0m"); + console.log("\x1b[32m-----\x1b[0m"); +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..eac44e9 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "@dqnid/arch-bootstrap", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@dqnid/arch-bootstrap", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + }, + "bin": { + "arch-bootstrap": "bin/index.js" + } + }, + "node_modules/readline-sync": { + "version": "1.4.10", + "resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.10.tgz", + "integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw==", + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..e5a76cd --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "@dqnid/arch-bootstrap", + "version": "1.0.0", + "description": "NPX archetype bootstrap utility", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "bin": { + "@dqnid/arch-bootstrap": "bin/index.js" + }, + "keywords": [ + "npx", + "npm", + "node", + "nextjs", + "nestjs", + "express", + "mysql", + "docker" + ], + "author": "Daniel Heras Quesada", + "license": "ISC", + "dependencies": { + "readline-sync": "^1.4.10" + } +}