nexforge-cli 1.0.8 → 1.0.10

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/README.md CHANGED
@@ -162,4 +162,51 @@ nexforge rename
162
162
 
163
163
  ---
164
164
 
165
+ ### ℹ️ 9. `nexforge info`
166
+
167
+ **Description:** View your current project's status and details.
168
+ **Usage:**
169
+
170
+ ```bash
171
+ nexforge info
172
+ ```
173
+
174
+ **Details:**
175
+
176
+ - Fetches and displays your project name, framework, custom domains, live URL, and latest deployment status directly in the terminal.
177
+
178
+ ---
179
+
180
+ ### 🌐 10. `nexforge domains`
181
+
182
+ **Description:** Manage custom domains for your project.
183
+ **Usage:**
184
+
185
+ ```bash
186
+ nexforge domains add <your-domain.com>
187
+ nexforge domains ls
188
+ ```
189
+
190
+ **Details:**
191
+
192
+ - `add`: Links a new custom domain to your project without opening the dashboard.
193
+ - `ls`: Lists all custom domains currently linked to your project.
194
+
195
+ ---
196
+
197
+ ### 🌍 11. `nexforge open`
198
+
199
+ **Description:** Opens your live project in your default web browser.
200
+ **Usage:**
201
+
202
+ ```bash
203
+ nexforge open
204
+ ```
205
+
206
+ **Details:**
207
+
208
+ - Fetches your project's live URL and instantly opens it in your host OS browser.
209
+
210
+ ---
211
+
165
212
  ### Built With ❤️ by Manav Sharma
package/index.js CHANGED
@@ -15,6 +15,9 @@ require("./src/commands/logs")(program)
15
15
  require("./src/commands/rollback")(program)
16
16
  require("./src/commands/rename")(program)
17
17
  require("./src/commands/create")(program)
18
+ require("./src/commands/info")(program)
19
+ require("./src/commands/domains")(program)
20
+ require("./src/commands/open")(program)
18
21
 
19
22
  // Parse the arguments passed by the user in the terminal
20
23
  program.parse(process.argv)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexforge-cli",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Custom Deployment CLI for NexForge",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -42,6 +42,8 @@ const FRONTEND_DEPS = {
42
42
  "lenis": "^1.3.23",
43
43
  "lucide-react": "^1.21.0",
44
44
  "react-icons": "^5.6.0",
45
+ "react-redux": "^9.1.1",
46
+ "@reduxjs/toolkit": "^2.2.3",
45
47
  "react-toastify": "^11.1.0",
46
48
  "recharts": "^3.8.1",
47
49
  "socket.io-client": "^4.8.3",
@@ -0,0 +1,76 @@
1
+ const fs = require("fs")
2
+ const path = require("path")
3
+ const axios = require("axios")
4
+ const chalk = require("chalk")
5
+ const ora = require("ora")
6
+ const { getNexforgeConfig } = require("../config")
7
+
8
+ module.exports = (program) => {
9
+ program
10
+ .command("domains <action> [domainName]")
11
+ .description("Manage custom domains (actions: add, ls)")
12
+ .action(async (action, domainName) => {
13
+ if (action !== "add" && action !== "ls") {
14
+ console.error(chalk.red("Invalid action. Use 'nexforge domains add <domain>' or 'nexforge domains ls'"))
15
+ return
16
+ }
17
+
18
+ const spinner = ora(action === "add" ? "Adding domain..." : "Fetching domains...").start()
19
+
20
+ try {
21
+ const config = getNexforgeConfig()
22
+
23
+ // Check if project is linked
24
+ const projectFilePath = path.join(process.cwd(), ".nexforge")
25
+ if (!fs.existsSync(projectFilePath)) {
26
+ spinner.fail("No NexForge project found in this directory.")
27
+ return
28
+ }
29
+
30
+ const { projectId } = JSON.parse(fs.readFileSync(projectFilePath, "utf8"))
31
+ const API_BASE_URL = process.env.NEXFORGE_API_URL || "https://api.nexforge.me/api"
32
+
33
+ if (action === "ls") {
34
+ const response = await axios.get(`${API_BASE_URL}/cli/domains/${projectId}`, {
35
+ headers: { Authorization: `Bearer ${config.token}` },
36
+ })
37
+ spinner.stop()
38
+
39
+ const { domains } = response.data
40
+ if (!domains || domains.length === 0) {
41
+ console.log(chalk.gray("No custom domains linked to this project."))
42
+ return
43
+ }
44
+
45
+ console.log(chalk.bold.cyan("\n🌐 Linked Domains\n"))
46
+ domains.forEach(d => {
47
+ console.log(` - ${chalk.white(d.name)}`)
48
+ })
49
+ console.log("\n")
50
+ }
51
+
52
+ if (action === "add") {
53
+ if (!domainName) {
54
+ spinner.fail("Please specify a domain name. Example: nexforge domains add myapp.com")
55
+ return
56
+ }
57
+
58
+ const response = await axios.post(`${API_BASE_URL}/cli/domains/${projectId}`,
59
+ { domain: domainName },
60
+ { headers: { Authorization: `Bearer ${config.token}` } }
61
+ )
62
+
63
+ spinner.succeed(chalk.green(`Domain ${chalk.bold(response.data.domain)} added successfully!`))
64
+ console.log(chalk.gray("Note: Ensure you point your DNS A Record to NexForge servers."))
65
+ }
66
+
67
+ } catch (error) {
68
+ spinner.fail("Failed to process domains command")
69
+ if (error.response) {
70
+ console.error(chalk.red(`Error: ${error.response.data.error || error.response.data.message || error.response.statusText}`))
71
+ } else {
72
+ console.error(chalk.red(error.message))
73
+ }
74
+ }
75
+ })
76
+ }
@@ -0,0 +1,60 @@
1
+ const fs = require("fs")
2
+ const path = require("path")
3
+ const axios = require("axios")
4
+ const chalk = require("chalk")
5
+ const ora = require("ora")
6
+ const { getNexforgeConfig } = require("../config")
7
+
8
+ module.exports = (program) => {
9
+ program
10
+ .command("info")
11
+ .description("View project info and status")
12
+ .action(async () => {
13
+ const spinner = ora("Fetching project info...").start()
14
+ try {
15
+ const config = getNexforgeConfig()
16
+
17
+ // Check if project is linked
18
+ const projectFilePath = path.join(process.cwd(), ".nexforge")
19
+ if (!fs.existsSync(projectFilePath)) {
20
+ spinner.fail("No NexForge project found in this directory.")
21
+ console.log(chalk.yellow("Hint: Run 'nexforge init' to link or create a project."))
22
+ return
23
+ }
24
+
25
+ const { projectId } = JSON.parse(fs.readFileSync(projectFilePath, "utf8"))
26
+
27
+ const API_BASE_URL = process.env.NEXFORGE_API_URL || "https://api.nexforge.me/api"
28
+
29
+ const response = await axios.get(`${API_BASE_URL}/cli/info/${projectId}`, {
30
+ headers: {
31
+ Authorization: `Bearer ${config.token}`,
32
+ },
33
+ })
34
+
35
+ spinner.stop()
36
+ const { project } = response.data
37
+
38
+ console.log(chalk.bold.cyan("\n📊 NexForge Project Info\n"))
39
+ console.log(`${chalk.gray("Name:")} ${chalk.white(project.projectName)}`)
40
+ console.log(`${chalk.gray("Framework:")} ${chalk.white(project.framework)}`)
41
+ console.log(`${chalk.gray("ID:")} ${chalk.white(project._id)}`)
42
+ console.log(`${chalk.gray("Status:")} ${project.latestDeploymentStatus === "SUCCESS" ? chalk.green("● Online") : chalk.yellow("● " + project.latestDeploymentStatus)}`)
43
+ console.log(`${chalk.gray("Live URL:")} ${chalk.blue.underline(project.liveUrl)}`)
44
+
45
+ if (project.domains && project.domains.length > 0) {
46
+ console.log(`\n${chalk.gray("Custom Domains:")}`)
47
+ project.domains.forEach(d => console.log(` - ${chalk.blue.underline("https://" + d)}`))
48
+ }
49
+ console.log("\n")
50
+
51
+ } catch (error) {
52
+ spinner.fail("Failed to fetch project info")
53
+ if (error.response) {
54
+ console.error(chalk.red(`Error: ${error.response.data.error || error.response.statusText}`))
55
+ } else {
56
+ console.error(chalk.red(error.message))
57
+ }
58
+ }
59
+ })
60
+ }
@@ -0,0 +1,56 @@
1
+ const fs = require("fs")
2
+ const path = require("path")
3
+ const axios = require("axios")
4
+ const chalk = require("chalk")
5
+ const ora = require("ora")
6
+ const { exec } = require("child_process")
7
+ const { getNexforgeConfig } = require("../config")
8
+
9
+ module.exports = (program) => {
10
+ program
11
+ .command("open")
12
+ .description("Open the live project in your browser")
13
+ .action(async () => {
14
+ const spinner = ora("Opening project in browser...").start()
15
+ try {
16
+ const config = getNexforgeConfig()
17
+
18
+ // Check if project is linked
19
+ const projectFilePath = path.join(process.cwd(), ".nexforge")
20
+ if (!fs.existsSync(projectFilePath)) {
21
+ spinner.fail("No NexForge project found in this directory.")
22
+ return
23
+ }
24
+
25
+ const { projectId } = JSON.parse(fs.readFileSync(projectFilePath, "utf8"))
26
+ const API_BASE_URL = process.env.NEXFORGE_API_URL || "https://api.nexforge.me/api"
27
+
28
+ const response = await axios.get(`${API_BASE_URL}/cli/info/${projectId}`, {
29
+ headers: {
30
+ Authorization: `Bearer ${config.token}`,
31
+ },
32
+ })
33
+
34
+ const { project } = response.data
35
+ const url = project.liveUrl
36
+
37
+ spinner.succeed(`Opening ${chalk.blue.underline(url)}`)
38
+
39
+ // Cross-platform open command
40
+ const startCmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'start' : 'xdg-open'
41
+ exec(`${startCmd} ${url}`, (err) => {
42
+ if (err) {
43
+ console.error(chalk.red(`Failed to open browser automatically. Please visit: ${url}`))
44
+ }
45
+ })
46
+
47
+ } catch (error) {
48
+ spinner.fail("Failed to open project")
49
+ if (error.response) {
50
+ console.error(chalk.red(`Error: ${error.response.data.error || error.response.statusText}`))
51
+ } else {
52
+ console.error(chalk.red(error.message))
53
+ }
54
+ }
55
+ })
56
+ }