nestcraftx 0.2.5 → 0.2.6
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/CLI_USAGE.fr.md +331 -331
- package/CLI_USAGE.md +364 -364
- package/LICENSE +21 -21
- package/bin/nestcraft.js +84 -64
- package/commands/demo.js +333 -330
- package/commands/generate.js +93 -0
- package/commands/generateConf.js +91 -0
- package/commands/info.js +48 -48
- package/commands/new.js +338 -335
- package/commands/start.js +19 -19
- package/commands/test.js +7 -7
- package/package.json +1 -1
- package/utils/cliParser.js +133 -76
- package/utils/colors.js +62 -62
- package/utils/configs/configureDocker.js +120 -120
- package/utils/configs/setupCleanArchitecture.js +15 -13
- package/utils/configs/setupLightArchitecture.js +15 -9
- package/utils/file-utils/saveProjectConfig.js +36 -0
- package/utils/fullModeInput.js +607 -607
- package/utils/generators/application/dtoUpdater.js +54 -0
- package/utils/generators/cleanModuleGenerator.js +475 -0
- package/utils/generators/database/setupDatabase.js +31 -0
- package/utils/generators/domain/entityUpdater.js +78 -0
- package/utils/generators/infrastructure/mapperUpdater.js +65 -0
- package/utils/generators/lightModuleGenerator.js +131 -0
- package/utils/generators/relation/relation.engine.js +64 -0
- package/utils/interactive/askEntityInputs.js +165 -0
- package/utils/loggers/logError.js +7 -7
- package/utils/loggers/logInfo.js +7 -7
- package/utils/loggers/logSuccess.js +7 -7
- package/utils/loggers/logWarning.js +7 -7
- package/utils/setups/orms/typeOrmSetup.js +630 -630
- package/utils/setups/setupAuth.js +28 -15
- package/utils/setups/setupDatabase.js +75 -75
- package/utils/setups/setupPrisma.js +802 -630
- package/utils/shell.js +32 -32
- package/utils/spinner.js +57 -57
- package/utils/systemCheck.js +124 -124
- package/utils/userInput.js +421 -421
- package/utils/utils.js +27 -27
package/utils/shell.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const { execSync } = require("child_process");
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
const { logError } = require("./loggers/logError");
|
|
4
|
-
const { spinner } = require("./spinner");
|
|
5
|
-
|
|
6
|
-
async function runCommand(command, errorMessage, spinnerText = null) {
|
|
7
|
-
const spin = spinnerText ? spinner(spinnerText) : null;
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
if (spin) spin.start();
|
|
11
|
-
execSync(command, { stdio: spinnerText ? "pipe" : "inherit" });
|
|
12
|
-
if (spin) spin.succeed(spinnerText);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
if (spin) spin.fail(errorMessage);
|
|
15
|
-
logError(errorMessage);
|
|
16
|
-
fs.appendFileSync(
|
|
17
|
-
"setup.log",
|
|
18
|
-
`[Erreur] ${errorMessage}: ${error.message}\n
|
|
19
|
-
);
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async function runCommandSilent(command) {
|
|
25
|
-
try {
|
|
26
|
-
return execSync(command, { stdio: "pipe" }).toString();
|
|
27
|
-
} catch (error) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = { runCommand, runCommandSilent };
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const { logError } = require("./loggers/logError");
|
|
4
|
+
const { spinner } = require("./spinner");
|
|
5
|
+
|
|
6
|
+
async function runCommand(command, errorMessage, spinnerText = null) {
|
|
7
|
+
const spin = spinnerText ? spinner(spinnerText) : null;
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
if (spin) spin.start();
|
|
11
|
+
execSync(command, { stdio: spinnerText ? "pipe" : "inherit" });
|
|
12
|
+
if (spin) spin.succeed(spinnerText);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (spin) spin.fail(errorMessage);
|
|
15
|
+
logError(errorMessage);
|
|
16
|
+
fs.appendFileSync(
|
|
17
|
+
"setup.log",
|
|
18
|
+
`[Erreur] ${errorMessage}: ${error.message}\n`,
|
|
19
|
+
);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function runCommandSilent(command) {
|
|
25
|
+
try {
|
|
26
|
+
return execSync(command, { stdio: "pipe" }).toString();
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = { runCommand, runCommandSilent };
|
package/utils/spinner.js
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
const { info, success, error: errorColor } = require('./colors');
|
|
2
|
-
|
|
3
|
-
class Spinner {
|
|
4
|
-
constructor(text = 'Loading...') {
|
|
5
|
-
this.text = text;
|
|
6
|
-
this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
7
|
-
this.currentFrame = 0;
|
|
8
|
-
this.intervalId = null;
|
|
9
|
-
this.isSpinning = false;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
start() {
|
|
13
|
-
if (this.isSpinning) return;
|
|
14
|
-
|
|
15
|
-
this.isSpinning = true;
|
|
16
|
-
this.currentFrame = 0;
|
|
17
|
-
|
|
18
|
-
process.stdout.write('\n');
|
|
19
|
-
|
|
20
|
-
this.intervalId = setInterval(() => {
|
|
21
|
-
const frame = this.frames[this.currentFrame];
|
|
22
|
-
process.stdout.write(`\r${info(frame)} ${this.text}`);
|
|
23
|
-
this.currentFrame = (this.currentFrame + 1) % this.frames.length;
|
|
24
|
-
}, 80);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
stop() {
|
|
28
|
-
if (!this.isSpinning) return;
|
|
29
|
-
|
|
30
|
-
this.isSpinning = false;
|
|
31
|
-
if (this.intervalId) {
|
|
32
|
-
clearInterval(this.intervalId);
|
|
33
|
-
this.intervalId = null;
|
|
34
|
-
}
|
|
35
|
-
process.stdout.write('\r' + ' '.repeat(this.text.length + 10) + '\r');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
succeed(text) {
|
|
39
|
-
this.stop();
|
|
40
|
-
console.log(success('✓') + ` ${text || this.text}`);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
fail(text) {
|
|
44
|
-
this.stop();
|
|
45
|
-
console.log(errorColor('✗') + ` ${text || this.text}`);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
update(text) {
|
|
49
|
-
this.text = text;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function spinner(text) {
|
|
54
|
-
return new Spinner(text);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = { Spinner, spinner };
|
|
1
|
+
const { info, success, error: errorColor } = require('./colors');
|
|
2
|
+
|
|
3
|
+
class Spinner {
|
|
4
|
+
constructor(text = 'Loading...') {
|
|
5
|
+
this.text = text;
|
|
6
|
+
this.frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
7
|
+
this.currentFrame = 0;
|
|
8
|
+
this.intervalId = null;
|
|
9
|
+
this.isSpinning = false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
start() {
|
|
13
|
+
if (this.isSpinning) return;
|
|
14
|
+
|
|
15
|
+
this.isSpinning = true;
|
|
16
|
+
this.currentFrame = 0;
|
|
17
|
+
|
|
18
|
+
process.stdout.write('\n');
|
|
19
|
+
|
|
20
|
+
this.intervalId = setInterval(() => {
|
|
21
|
+
const frame = this.frames[this.currentFrame];
|
|
22
|
+
process.stdout.write(`\r${info(frame)} ${this.text}`);
|
|
23
|
+
this.currentFrame = (this.currentFrame + 1) % this.frames.length;
|
|
24
|
+
}, 80);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
stop() {
|
|
28
|
+
if (!this.isSpinning) return;
|
|
29
|
+
|
|
30
|
+
this.isSpinning = false;
|
|
31
|
+
if (this.intervalId) {
|
|
32
|
+
clearInterval(this.intervalId);
|
|
33
|
+
this.intervalId = null;
|
|
34
|
+
}
|
|
35
|
+
process.stdout.write('\r' + ' '.repeat(this.text.length + 10) + '\r');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
succeed(text) {
|
|
39
|
+
this.stop();
|
|
40
|
+
console.log(success('✓') + ` ${text || this.text}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fail(text) {
|
|
44
|
+
this.stop();
|
|
45
|
+
console.log(errorColor('✗') + ` ${text || this.text}`);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
update(text) {
|
|
49
|
+
this.text = text;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function spinner(text) {
|
|
54
|
+
return new Spinner(text);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = { Spinner, spinner };
|
package/utils/systemCheck.js
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
const { execSync } = require("child_process");
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
|
|
4
|
-
function checkCommand(cmd) {
|
|
5
|
-
try {
|
|
6
|
-
execSync(`${cmd} --version`, { stdio: "pipe" });
|
|
7
|
-
return true;
|
|
8
|
-
} catch {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function getVersion(cmd) {
|
|
14
|
-
try {
|
|
15
|
-
const output = execSync(`${cmd} --version`, {
|
|
16
|
-
encoding: "utf8",
|
|
17
|
-
stdio: "pipe",
|
|
18
|
-
});
|
|
19
|
-
return output.trim().split("\n")[0];
|
|
20
|
-
} catch {
|
|
21
|
-
return "not installed";
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function checkSystemRequirements() {
|
|
26
|
-
const checks = {
|
|
27
|
-
node: {
|
|
28
|
-
installed: checkCommand("node"),
|
|
29
|
-
version: getVersion("node"),
|
|
30
|
-
},
|
|
31
|
-
npm: {
|
|
32
|
-
installed: checkCommand("npm"),
|
|
33
|
-
version: getVersion("npm"),
|
|
34
|
-
},
|
|
35
|
-
nestCli: {
|
|
36
|
-
installed: checkCommand("nest"),
|
|
37
|
-
version: getVersion("nest"),
|
|
38
|
-
},
|
|
39
|
-
git: {
|
|
40
|
-
installed: checkCommand("git"),
|
|
41
|
-
version: getVersion("git"),
|
|
42
|
-
},
|
|
43
|
-
docker: {
|
|
44
|
-
installed: checkCommand("docker"),
|
|
45
|
-
version: getVersion("docker"),
|
|
46
|
-
},
|
|
47
|
-
npx: {
|
|
48
|
-
installed: checkCommand("npx"),
|
|
49
|
-
version: "npx available",
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const envExists = fs.existsSync(".env");
|
|
54
|
-
|
|
55
|
-
let postgresStatus = "not detected locally";
|
|
56
|
-
if (envExists) {
|
|
57
|
-
try {
|
|
58
|
-
const envContent = fs.readFileSync(".env", "utf8");
|
|
59
|
-
if (
|
|
60
|
-
envContent.includes("POSTGRES_") ||
|
|
61
|
-
envContent.includes("DATABASE_URL")
|
|
62
|
-
) {
|
|
63
|
-
postgresStatus = "configured in .env";
|
|
64
|
-
}
|
|
65
|
-
} catch {}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
checks.postgres = {
|
|
69
|
-
installed: false,
|
|
70
|
-
version: postgresStatus,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return checks;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function displaySystemCheck() {
|
|
77
|
-
console.log("\n🔍 NestCraftX System Check");
|
|
78
|
-
console.log("--------------------------------");
|
|
79
|
-
|
|
80
|
-
const checks = checkSystemRequirements();
|
|
81
|
-
let successCount = 0;
|
|
82
|
-
let totalCount = 0;
|
|
83
|
-
|
|
84
|
-
Object.entries(checks).forEach(([name, info]) => {
|
|
85
|
-
totalCount++;
|
|
86
|
-
const displayName =
|
|
87
|
-
name.charAt(0).toUpperCase() + name.slice(1).replace(/([A-Z])/g, " $1");
|
|
88
|
-
|
|
89
|
-
if (info.installed || info.version.includes("configured")) {
|
|
90
|
-
console.log(`✅ ${displayName}: ${info.version}`);
|
|
91
|
-
successCount++;
|
|
92
|
-
} else {
|
|
93
|
-
console.log(`⚠️ ${displayName}: ${info.version}`);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
console.log("--------------------------------");
|
|
98
|
-
|
|
99
|
-
const status =
|
|
100
|
-
successCount === totalCount
|
|
101
|
-
? "✅ Ready"
|
|
102
|
-
: successCount >= totalCount - 2
|
|
103
|
-
? "⚠️ Almost Ready"
|
|
104
|
-
: "❌ Missing Requirements";
|
|
105
|
-
|
|
106
|
-
console.log(`System status: ${status} (${successCount}/${totalCount} OK)`);
|
|
107
|
-
|
|
108
|
-
if (successCount < totalCount) {
|
|
109
|
-
console.log("\n💡 Tips:");
|
|
110
|
-
if (!checks.nestCli.installed) {
|
|
111
|
-
console.log(" - Install Nest CLI: npm install -g @nestjs/cli");
|
|
112
|
-
}
|
|
113
|
-
if (!checks.docker.installed) {
|
|
114
|
-
console.log(" - Install Docker: https://docs.docker.com/get-docker/");
|
|
115
|
-
}
|
|
116
|
-
if (!checks.git.installed) {
|
|
117
|
-
console.log(" - Install Git: https://git-scm.com/downloads");
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
console.log("");
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
module.exports = { checkSystemRequirements, displaySystemCheck };
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
|
|
4
|
+
function checkCommand(cmd) {
|
|
5
|
+
try {
|
|
6
|
+
execSync(`${cmd} --version`, { stdio: "pipe" });
|
|
7
|
+
return true;
|
|
8
|
+
} catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getVersion(cmd) {
|
|
14
|
+
try {
|
|
15
|
+
const output = execSync(`${cmd} --version`, {
|
|
16
|
+
encoding: "utf8",
|
|
17
|
+
stdio: "pipe",
|
|
18
|
+
});
|
|
19
|
+
return output.trim().split("\n")[0];
|
|
20
|
+
} catch {
|
|
21
|
+
return "not installed";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function checkSystemRequirements() {
|
|
26
|
+
const checks = {
|
|
27
|
+
node: {
|
|
28
|
+
installed: checkCommand("node"),
|
|
29
|
+
version: getVersion("node"),
|
|
30
|
+
},
|
|
31
|
+
npm: {
|
|
32
|
+
installed: checkCommand("npm"),
|
|
33
|
+
version: getVersion("npm"),
|
|
34
|
+
},
|
|
35
|
+
nestCli: {
|
|
36
|
+
installed: checkCommand("nest"),
|
|
37
|
+
version: getVersion("nest"),
|
|
38
|
+
},
|
|
39
|
+
git: {
|
|
40
|
+
installed: checkCommand("git"),
|
|
41
|
+
version: getVersion("git"),
|
|
42
|
+
},
|
|
43
|
+
docker: {
|
|
44
|
+
installed: checkCommand("docker"),
|
|
45
|
+
version: getVersion("docker"),
|
|
46
|
+
},
|
|
47
|
+
npx: {
|
|
48
|
+
installed: checkCommand("npx"),
|
|
49
|
+
version: "npx available",
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const envExists = fs.existsSync(".env");
|
|
54
|
+
|
|
55
|
+
let postgresStatus = "not detected locally";
|
|
56
|
+
if (envExists) {
|
|
57
|
+
try {
|
|
58
|
+
const envContent = fs.readFileSync(".env", "utf8");
|
|
59
|
+
if (
|
|
60
|
+
envContent.includes("POSTGRES_") ||
|
|
61
|
+
envContent.includes("DATABASE_URL")
|
|
62
|
+
) {
|
|
63
|
+
postgresStatus = "configured in .env";
|
|
64
|
+
}
|
|
65
|
+
} catch {}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
checks.postgres = {
|
|
69
|
+
installed: false,
|
|
70
|
+
version: postgresStatus,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return checks;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function displaySystemCheck() {
|
|
77
|
+
console.log("\n🔍 NestCraftX System Check");
|
|
78
|
+
console.log("--------------------------------");
|
|
79
|
+
|
|
80
|
+
const checks = checkSystemRequirements();
|
|
81
|
+
let successCount = 0;
|
|
82
|
+
let totalCount = 0;
|
|
83
|
+
|
|
84
|
+
Object.entries(checks).forEach(([name, info]) => {
|
|
85
|
+
totalCount++;
|
|
86
|
+
const displayName =
|
|
87
|
+
name.charAt(0).toUpperCase() + name.slice(1).replace(/([A-Z])/g, " $1");
|
|
88
|
+
|
|
89
|
+
if (info.installed || info.version.includes("configured")) {
|
|
90
|
+
console.log(`✅ ${displayName}: ${info.version}`);
|
|
91
|
+
successCount++;
|
|
92
|
+
} else {
|
|
93
|
+
console.log(`⚠️ ${displayName}: ${info.version}`);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
console.log("--------------------------------");
|
|
98
|
+
|
|
99
|
+
const status =
|
|
100
|
+
successCount === totalCount
|
|
101
|
+
? "✅ Ready"
|
|
102
|
+
: successCount >= totalCount - 2
|
|
103
|
+
? "⚠️ Almost Ready"
|
|
104
|
+
: "❌ Missing Requirements";
|
|
105
|
+
|
|
106
|
+
console.log(`System status: ${status} (${successCount}/${totalCount} OK)`);
|
|
107
|
+
|
|
108
|
+
if (successCount < totalCount) {
|
|
109
|
+
console.log("\n💡 Tips:");
|
|
110
|
+
if (!checks.nestCli.installed) {
|
|
111
|
+
console.log(" - Install Nest CLI: npm install -g @nestjs/cli");
|
|
112
|
+
}
|
|
113
|
+
if (!checks.docker.installed) {
|
|
114
|
+
console.log(" - Install Docker: https://docs.docker.com/get-docker/");
|
|
115
|
+
}
|
|
116
|
+
if (!checks.git.installed) {
|
|
117
|
+
console.log(" - Install Git: https://git-scm.com/downloads");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
console.log("");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
module.exports = { checkSystemRequirements, displaySystemCheck };
|