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.
Files changed (3) hide show
  1. package/README.md +82 -29
  2. package/index.js +78 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,60 +1,113 @@
1
1
  # NexForge CLI 🚀
2
2
 
3
- Welcome to the NexForge Command Line Interface. This tool allows you to deploy your local projects directly to the NexForge platform without pushing to GitHub.
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
- ## Getting Started
6
+ ## Installation
6
7
 
7
- If you are developing this CLI locally you can link it so it's available globally on your computer
8
+ You can install the CLI globally via NPM:
8
9
 
9
10
  ```bash
10
- npm link
11
+ npm install -g nexforge-cli
11
12
  ```
12
13
 
13
- Now you can use the `nexforge` command from anywhere!
14
+ ## Available Commands
14
15
 
15
- ## Commands
16
+ Here is the complete list of commands available in the NexForge CLI:
16
17
 
17
- ### 1. Login
18
- Authenticate yourself with your NexForge Project ID.
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
- This saves your configuration in your home directory `~/.nexforge/config.json`.
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
- ### 2. Deploy
25
- Package your current directory and upload it to NexForge.
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 deploy
35
+ nexforge init
28
36
  ```
29
- This command automatically zips your project (ignoring `node_modules` and `.env`) and sends it to the deployment queue.
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
- ### 3. Rollback
32
- Revert your live site to the previous stable deployment.
42
+ ---
43
+
44
+ ### 🚀 3. `nexforge deploy`
45
+ **Description:** Package and deploy your current directory to NexForge.
46
+ **Usage:**
33
47
  ```bash
34
- nexforge rollback
48
+ nexforge deploy
35
49
  ```
36
- *Note: This feature is currently in active development.*
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
- ## 📦 How to Publish to NPM
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
- Once you are satisfied with this CLI and want to share it with the world you can publish it to the NPM registry. This allows anyone to install it by running `npm install -g nexforge-cli`.
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
- ### Step 1: Create an NPM Account
45
- If you don't have one go to [npmjs.com](https://www.npmjs.com/) and create an account.
84
+ ---
46
85
 
47
- ### Step 2: Login via Terminal
48
- Run the following command in your terminal and enter your NPM credentials
86
+ ### ⏪ 6. `nexforge rollback`
87
+ **Description:** Instantly revert your live website to a previous stable deployment.
88
+ **Usage:**
49
89
  ```bash
50
- npm login
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
- ### Step 3: Publish
54
- Ensure your `package.json` has a unique name (e.g. `nexforge-cli`). Then simply run
99
+ ### ✏️ 7. `nexforge rename`
100
+ **Description:** Rename the subdomain of your project.
101
+ **Usage:**
55
102
  ```bash
56
- npm publish
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexforge-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Custom Deployment CLI for NexForge",
5
5
  "main": "index.js",
6
6
  "bin": {