neatnode 3.1.3 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neatnode",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "description": "Plug & Play Node.js backend starter templates — build REST APIs, socket servers, and more in seconds.",
5
5
  "bin": {
6
6
  "neatnode": "./bin/index.js"
@@ -21,11 +21,11 @@ export async function createProject({ projectName, repoPath, includeCrud, crudNa
21
21
  }
22
22
 
23
23
  if (projectName !== ".") {
24
- console.log("📁 Creating project folder...");
24
+ console.log("Creating project folder...");
25
25
  fs.mkdirSync(targetPath);
26
26
  }
27
27
 
28
- console.log("⬇️ Downloading template...");
28
+ console.log("Downloading template...");
29
29
  const localTemplatePath = await downloadTemplate(repoPath);
30
30
 
31
31
  await copyTemplate(localTemplatePath, targetPath, {
@@ -2,23 +2,26 @@ import axios from "axios";
2
2
  import extract from "extract-zip";
3
3
  import fs from "fs";
4
4
  import path from "path";
5
+ import os from "os";
5
6
  import { fileURLToPath } from "url";
6
7
 
7
8
  const __filename = fileURLToPath(import.meta.url);
8
9
  const __dirname = path.dirname(__filename);
9
10
 
10
- // your repo
11
11
  const owner = "aakash-gupta02";
12
12
  const repo = "NeatNode";
13
13
 
14
- // GitHub codeload URL
15
14
  const zipUrl = `https://codeload.github.com/${owner}/${repo}/zip/refs/heads/main`;
16
15
 
17
16
  export async function downloadTemplate(repoPath) {
18
- const tempZip = path.join(__dirname, "repo.zip");
19
- const tempExtractDir = path.join(__dirname, "repo-extract");
20
- const tempFinalDir = path.join(__dirname, "template-final");
17
+ // SAFE TEMP DIRECTORY
18
+ const tmpBase = fs.mkdtempSync(path.join(os.tmpdir(), "neatnode-"));
21
19
 
20
+ const tempZip = path.join(tmpBase, "repo.zip");
21
+ const tempExtractDir = path.join(tmpBase, "repo-extract");
22
+ const tempFinalDir = path.join(tmpBase, "template-final");
23
+
24
+ // download zip
22
25
  const response = await axios({
23
26
  url: zipUrl,
24
27
  responseType: "arraybuffer",
@@ -26,22 +29,17 @@ export async function downloadTemplate(repoPath) {
26
29
 
27
30
  fs.writeFileSync(tempZip, response.data);
28
31
 
32
+ // unzip
29
33
  await extract(tempZip, { dir: tempExtractDir });
30
34
 
31
35
  const extractedRoot = path.join(tempExtractDir, `${repo}-main`);
32
36
  const srcTemplatePath = path.join(extractedRoot, repoPath);
33
37
 
34
- // ensure final directory exists
35
- fs.rmSync(tempFinalDir, { recursive: true, force: true });
38
+ // copy template
36
39
  fs.mkdirSync(tempFinalDir, { recursive: true });
37
-
38
40
  fs.cpSync(srcTemplatePath, tempFinalDir, { recursive: true });
39
41
 
40
- // cleanup zip + extract folder
41
- fs.rmSync(tempZip);
42
- fs.rmSync(tempExtractDir, { recursive: true, force: true });
43
-
44
42
  console.log("✔ Template downloaded & extracted");
43
+
45
44
  return tempFinalDir;
46
45
  }
47
-