nexforge-cli 1.0.1 → 1.0.3
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 +82 -29
- package/index.js +78 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,60 +1,113 @@
|
|
|
1
1
|
# NexForge CLI 🚀
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The official Command Line Interface for **NexForge** - Your custom Platform as a Service (PaaS).
|
|
4
|
+
Deploy, manage, and scale your applications directly from your terminal with zero friction!
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Installation
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
You can install the CLI globally via NPM:
|
|
8
9
|
|
|
9
10
|
```bash
|
|
10
|
-
npm
|
|
11
|
+
npm install -g nexforge-cli
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
## Available Commands
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
Here is the complete list of commands available in the NexForge CLI:
|
|
16
17
|
|
|
17
|
-
### 1.
|
|
18
|
-
Authenticate
|
|
18
|
+
### 🔐 1. `nexforge login`
|
|
19
|
+
**Description:** Authenticate your local machine with your NexForge account.
|
|
20
|
+
**Usage:**
|
|
19
21
|
```bash
|
|
20
22
|
nexforge login
|
|
21
23
|
```
|
|
22
|
-
|
|
24
|
+
**Details:**
|
|
25
|
+
- Prompts you for your personal **CLI Token** (which you can generate from your NexForge Dashboard Settings).
|
|
26
|
+
- Prompts you for your **Project ID**.
|
|
27
|
+
- Saves your credentials securely in `~/.nexforge/config.json`.
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### ✨ 2. `nexforge init`
|
|
32
|
+
**Description:** Initialize a new NexForge project right from your terminal without opening the browser.
|
|
33
|
+
**Usage:**
|
|
26
34
|
```bash
|
|
27
|
-
nexforge
|
|
35
|
+
nexforge init
|
|
28
36
|
```
|
|
29
|
-
|
|
37
|
+
**Details:**
|
|
38
|
+
- Asks for your **Project Name**.
|
|
39
|
+
- Asks for the **Framework** you are using (e.g., React, Vue, Express, Node.js).
|
|
40
|
+
- Automatically registers the project on NexForge servers and links your current directory to the new Project ID.
|
|
30
41
|
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
### 🚀 3. `nexforge deploy`
|
|
45
|
+
**Description:** Package and deploy your current directory to NexForge.
|
|
46
|
+
**Usage:**
|
|
33
47
|
```bash
|
|
34
|
-
nexforge
|
|
48
|
+
nexforge deploy
|
|
35
49
|
```
|
|
36
|
-
|
|
50
|
+
**Details:**
|
|
51
|
+
- Instantly zips your source code (ignoring `node_modules`, `.git`, and `.env`).
|
|
52
|
+
- Uploads the code to NexForge backend servers.
|
|
53
|
+
- Automatically connects to the live **WebSocket log stream** so you can watch your build progress in real-time.
|
|
54
|
+
- Returns your live deployment URL upon success.
|
|
37
55
|
|
|
38
56
|
---
|
|
39
57
|
|
|
40
|
-
|
|
58
|
+
### 🌐 4. `nexforge env`
|
|
59
|
+
**Description:** Manage your environment variables securely.
|
|
60
|
+
|
|
61
|
+
#### Push Variables
|
|
62
|
+
```bash
|
|
63
|
+
nexforge env push
|
|
64
|
+
```
|
|
65
|
+
- Reads your local `.env` file and securely pushes all variables to your NexForge project.
|
|
66
|
+
|
|
67
|
+
#### Pull Variables
|
|
68
|
+
```bash
|
|
69
|
+
nexforge env pull
|
|
70
|
+
```
|
|
71
|
+
- Fetches all environment variables from your live NexForge project and saves them into a local `.env` file.
|
|
72
|
+
|
|
73
|
+
---
|
|
41
74
|
|
|
42
|
-
|
|
75
|
+
### 📜 5. `nexforge logs`
|
|
76
|
+
**Description:** Stream live build and deployment logs for your project.
|
|
77
|
+
**Usage:**
|
|
78
|
+
```bash
|
|
79
|
+
nexforge logs
|
|
80
|
+
```
|
|
81
|
+
**Details:**
|
|
82
|
+
- Connects to the NexForge WebSocket server and streams real-time logs for any ongoing deployment pipelines.
|
|
43
83
|
|
|
44
|
-
|
|
45
|
-
If you don't have one go to [npmjs.com](https://www.npmjs.com/) and create an account.
|
|
84
|
+
---
|
|
46
85
|
|
|
47
|
-
###
|
|
48
|
-
|
|
86
|
+
### ⏪ 6. `nexforge rollback`
|
|
87
|
+
**Description:** Instantly revert your live website to a previous stable deployment.
|
|
88
|
+
**Usage:**
|
|
49
89
|
```bash
|
|
50
|
-
|
|
90
|
+
nexforge rollback
|
|
51
91
|
```
|
|
92
|
+
**Details:**
|
|
93
|
+
- Fetches a list of your recent successful and failed deployments.
|
|
94
|
+
- Prompts you to select a version.
|
|
95
|
+
- Instantly updates the symbolic links on the server to serve the older version with **zero downtime** and **no rebuild required**.
|
|
96
|
+
|
|
97
|
+
---
|
|
52
98
|
|
|
53
|
-
###
|
|
54
|
-
|
|
99
|
+
### ✏️ 7. `nexforge rename`
|
|
100
|
+
**Description:** Rename the subdomain of your project.
|
|
101
|
+
**Usage:**
|
|
55
102
|
```bash
|
|
56
|
-
|
|
103
|
+
nexforge rename
|
|
57
104
|
```
|
|
105
|
+
**Details:**
|
|
106
|
+
- Asks for your new preferred subdomain.
|
|
107
|
+
- Validates availability on the NexForge servers.
|
|
108
|
+
- Instantly updates your live URL to the new subdomain.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### Built With ❤️ by Manav Sharma
|
|
58
113
|
|
|
59
|
-
If everything is successful your package is now live on NPM!
|
|
60
|
-
Every time you make updates to the code you need to bump the version number in `package.json` (e.g. `"version": "1.0.1"`) before running `npm publish` again.
|
package/index.js
CHANGED
|
@@ -453,5 +453,83 @@ program
|
|
|
453
453
|
}
|
|
454
454
|
})
|
|
455
455
|
|
|
456
|
+
// change name of subdomain
|
|
457
|
+
program
|
|
458
|
+
.command("rename")
|
|
459
|
+
.description("Rename the subdomain of your project")
|
|
460
|
+
.action(async () => {
|
|
461
|
+
const readline = require("readline").createInterface({
|
|
462
|
+
input: process.stdin,
|
|
463
|
+
output: process.stdout
|
|
464
|
+
})
|
|
465
|
+
|
|
466
|
+
console.log(chalk.cyan("✨ Let's rename your project subdomain!"))
|
|
467
|
+
|
|
468
|
+
let defaultProjectId = ""
|
|
469
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
470
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"))
|
|
471
|
+
defaultProjectId = config.projectId || ""
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
const promptText = defaultProjectId
|
|
475
|
+
? `What is your project ID? (${defaultProjectId}) `
|
|
476
|
+
: "What is your project ID? "
|
|
477
|
+
|
|
478
|
+
readline.question(promptText, async (inputProjectId) => {
|
|
479
|
+
const projectId = inputProjectId.trim() || defaultProjectId
|
|
480
|
+
|
|
481
|
+
if (!projectId) {
|
|
482
|
+
console.log(chalk.red("Project ID cannot be empty!"))
|
|
483
|
+
readline.close()
|
|
484
|
+
return
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
readline.question("What is your new subdomain? ", async (newSubdomain) => {
|
|
488
|
+
if (!newSubdomain) {
|
|
489
|
+
console.log(chalk.red("Subdomain cannot be empty!"))
|
|
490
|
+
readline.close()
|
|
491
|
+
return
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const spinner = ora("Renaming project subdomain...").start()
|
|
495
|
+
|
|
496
|
+
try {
|
|
497
|
+
const response = await axios.post(`${API_BASE_URL}/cli/rename/${projectId}`, {
|
|
498
|
+
newSubdomain
|
|
499
|
+
})
|
|
500
|
+
|
|
501
|
+
const { projectId } = response.data
|
|
502
|
+
|
|
503
|
+
// Ensure the config directory exists before saving
|
|
504
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
505
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true })
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// We preserve the existing CLI Token if it exists, and just update the projectId
|
|
509
|
+
let currentConfig = {}
|
|
510
|
+
if (fs.existsSync(CONFIG_FILE)) {
|
|
511
|
+
currentConfig = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"))
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify({ ...currentConfig, projectId }))
|
|
515
|
+
|
|
516
|
+
spinner.succeed(chalk.green("🎉 Project subdomain renamed successfully!"))
|
|
517
|
+
console.log(chalk.cyan(`Project ID: ${projectId} has been saved locally.`))
|
|
518
|
+
console.log(chalk.yellow(`You can now run \`nexforge deploy\` to push your code.`))
|
|
519
|
+
|
|
520
|
+
} catch (error) {
|
|
521
|
+
spinner.fail(chalk.red("Failed to rename project subdomain!"))
|
|
522
|
+
if (error.response && error.response.data) {
|
|
523
|
+
console.log(chalk.red(`Server Error: ${JSON.stringify(error.response.data)}`))
|
|
524
|
+
} else {
|
|
525
|
+
console.error(error.message)
|
|
526
|
+
}
|
|
527
|
+
} finally {
|
|
528
|
+
readline.close()
|
|
529
|
+
}
|
|
530
|
+
})
|
|
531
|
+
})
|
|
532
|
+
})
|
|
533
|
+
|
|
456
534
|
// Parse the arguments passed by the user in the terminal
|
|
457
535
|
program.parse(process.argv)
|