From 0ddea7c1c607204f8b05c5b62e95127f2604a4c4 Mon Sep 17 00:00:00 2001 From: Lorenzo Iovino Date: Sat, 20 Jan 2024 10:12:26 +0100 Subject: [PATCH] Add .bin/install.js Updated README.md --- .bin/install.js | 36 ++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++- README.md | 33 +++++++++++++++++++++++++++++++++ Readme.md | 19 ------------------- package.json | 9 ++++++--- 5 files changed, 77 insertions(+), 23 deletions(-) create mode 100644 .bin/install.js create mode 100644 README.md delete mode 100644 Readme.md diff --git a/.bin/install.js b/.bin/install.js new file mode 100644 index 0000000..6de3170 --- /dev/null +++ b/.bin/install.js @@ -0,0 +1,36 @@ +#!/usr/bin/env node + +import { execSync } from 'child_process'; + +const runCommand = command => { + try { + execSync(`${command}`, { stdio: 'inherit' }); + } catch (err) { + console.error(`Failed to execute ${command}`, err); + return false; + } + + return true; +}; + +const repoName = process.argv[2]; +const gitCheckoutCommand = `git clone --depth 1 https://github.com/thisloke/node-base ${repoName}`; +const installDepsCommand = `cd ${repoName} && npm install`; + +console.log(`Cloning the repository ${repoName}`); + +const checkedOut = runCommand(gitCheckoutCommand); + +if (!checkedOut) { + process.exit(-1); +} + +console.log(`Installing dependencies for ${repoName}`); + +const installedDeps = runCommand(installDepsCommand); + +if (!installedDeps) { + process.exit(-1); +} + +console.log("Ready to start!"); \ No newline at end of file diff --git a/.gitignore b/.gitignore index b7dab5e..a375727 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -build \ No newline at end of file +build +.idea \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d73c363 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +

+ node-base +

+ +

Very Simple nodejs boilerplate (with )

+ +![Angular](https://img.shields.io/badge/Node-21-green.svg) +![Contributions welcome](https://img.shields.io/badge/contributions-welcome-green.svg) +[![License](https://img.shields.io/badge/license-ISC-blue.svg)](https://opensource.org/licenses/MIT) + + +## Quick usage + +### 1) Get your copy +``` +npx github:thisloke/node-base my-project +``` + +### 2) Start development +``` + npm run build:watch + npm run test:watch +``` + +### 3) Build +``` + npm run build +``` + +### 4) Run +``` + npm run start +``` \ No newline at end of file diff --git a/Readme.md b/Readme.md deleted file mode 100644 index 0e6232f..0000000 --- a/Readme.md +++ /dev/null @@ -1,19 +0,0 @@ -# Very Simple node boilerplate - -## Quick usage - -### To start development -``` - npm run build:watch - npm run test:watch -``` - -### To build -``` - npm run build -``` - -### To start -``` - npm run start -``` \ No newline at end of file diff --git a/package.json b/package.json index 1cb77e4..0ddc62d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "base", + "name": "node-base", "version": "1.0.0", - "description": "", + "description": "Very Simple nodejs boilerplate (with TS)", "main": "index.js", "scripts": { "start": "node build/main.js", @@ -11,7 +11,10 @@ "test:watch": "node --import tsx --test --watch **/*.spec.ts", "test": "node --import tsx --test **/*.spec.ts" }, - "author": "", + "bin": { + "node-base": ".bin/install.js" + }, + "author": "Lorenzo Iovino", "license": "ISC", "devDependencies": { "@types/node": "^20.11.5",