neatnode 3.1.3 ā 3.1.5
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 +1 -1
- package/src/actions/createProject.js +2 -2
- package/src/cli.js +12 -1
- package/src/utils/downloadRepoTemplate.js +11 -13
package/package.json
CHANGED
|
@@ -21,11 +21,11 @@ export async function createProject({ projectName, repoPath, includeCrud, crudNa
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (projectName !== ".") {
|
|
24
|
-
console.log("
|
|
24
|
+
console.log("Creating project folder...");
|
|
25
25
|
fs.mkdirSync(targetPath);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
console.log("
|
|
28
|
+
console.log("Downloading template...");
|
|
29
29
|
const localTemplatePath = await downloadTemplate(repoPath);
|
|
30
30
|
|
|
31
31
|
await copyTemplate(localTemplatePath, targetPath, {
|
package/src/cli.js
CHANGED
|
@@ -75,13 +75,24 @@ async function main() {
|
|
|
75
75
|
// STEP 5 ā Create Project (Remote download logic inside)
|
|
76
76
|
await createProject({
|
|
77
77
|
projectName,
|
|
78
|
-
repoPath: chosen.repoPath,
|
|
78
|
+
repoPath: chosen.repoPath,
|
|
79
79
|
includeCrud,
|
|
80
80
|
crudName,
|
|
81
81
|
language: langKey,
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
+
|
|
84
85
|
console.log(`\nā
Project "${projectName}" created successfully using "${chosen.name}".\n`);
|
|
86
|
+
|
|
87
|
+
console.log("Next steps:");
|
|
88
|
+
console.log(` cd ${projectName}`);
|
|
89
|
+
console.log(" npm install");
|
|
90
|
+
console.log(" npm run dev\n");
|
|
91
|
+
|
|
92
|
+
console.log("š Happy Coding!\n");
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
85
96
|
}
|
|
86
97
|
|
|
87
98
|
main().catch((err) => {
|
|
@@ -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
|
-
|
|
19
|
-
const
|
|
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
|
-
//
|
|
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
|
-
|