nexforge-cli 1.0.2 → 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 +14 -0
- package/index.js +78 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,4 +96,18 @@ nexforge rollback
|
|
|
96
96
|
|
|
97
97
|
---
|
|
98
98
|
|
|
99
|
+
### ✏️ 7. `nexforge rename`
|
|
100
|
+
**Description:** Rename the subdomain of your project.
|
|
101
|
+
**Usage:**
|
|
102
|
+
```bash
|
|
103
|
+
nexforge rename
|
|
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
|
+
|
|
99
112
|
### Built With ❤️ by Manav Sharma
|
|
113
|
+
|
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)
|