From 94b94ec0c8422d35616feac2ab224c9bf453322f Mon Sep 17 00:00:00 2001 From: Artemy Date: Wed, 19 Jul 2023 15:50:35 +0300 Subject: [PATCH] feat: logging --- index.js | 26 +++++++++++++++++++++++--- package-lock.json | 7 +++++-- package.json | 2 +- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 4a78faf..a4c2b3d 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,14 @@ const config = { packages: { - dev: ["@types/node", "ts-node", "typescript"], + dev: [ + "@types/node", + "ts-node", + "typescript", + "eslint", + "@typescript-eslint/parser", + "@typescript-eslint/eslint-plugin", + ], dep: ["dotenv"], }, }; @@ -12,20 +19,30 @@ const fs = require("fs"); const path = require("path"); //check if package.json exists +console.log("Check if package.json exists"); if (!fs.existsSync("package.json")) { + console.log("package.json does not exist, creating..."); spawn.sync("npm", ["init", "-y"], { stdio: "inherit" }); +} else { + console.log("package.json exists, skipping..."); } //install packages -spawn.sync("npm", ["i", "-D", ...config.dev.packages]); -spawn.sync("npm", ["i", ...config.dep.packages]); +console.log("Install packages"); +spawn.sync("npm", ["i", "-D", ...config.packages.dev], { stdio: "inherit" }); +spawn.sync("npm", ["i", ...config.packages.dep], { stdio: "inherit" }); +console.log("Packages installed"); //copy files +console.log("Copy files"); fs.cpSync(path.join(__dirname, "files"), "./", { recursive: true }); +console.log("Files copied"); //modify package.json +console.log("Modify package.json"); + const package = JSON.parse(fs.readFileSync("package.json", "utf-8")); package.main = "dist/app.js"; @@ -34,3 +51,6 @@ package.scripts.dev = "ts-node src/app.ts"; package.scripts.start = "node dist/app.js"; fs.writeFileSync("package.json", JSON.stringify(package, null, 2)); + +console.log("package.json modified"); +console.log("Done"); diff --git a/package-lock.json b/package-lock.json index 9ae9239..ff437ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,18 @@ { "name": "@artegoser/create-ts-prod", - "version": "1.0.0", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@artegoser/create-ts-prod", - "version": "1.0.0", + "version": "1.0.2", "license": "MIT", "dependencies": { "cross-spawn": "^7.0.3" + }, + "bin": { + "create-ts-prod": "index.js" } }, "node_modules/cross-spawn": { diff --git a/package.json b/package.json index bdb59d6..eed943a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@artegoser/create-ts-prod", - "version": "1.0.0", + "version": "1.1.0", "description": "Boilerplate for TypeScript projects", "main": "index.js", "bin": {