moontraze 2.0.0 → 2.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/bin/moontraze.js +28 -53
- package/lib/uninstall.js +68 -0
- package/package.json +2 -1
package/bin/moontraze.js
CHANGED
|
@@ -6,15 +6,16 @@ const { login } = require('../lib/auth');
|
|
|
6
6
|
const { getConfig, setConfig, getProject, setProject, GLOBAL_FILE } = require('../lib/config');
|
|
7
7
|
const { deploy } = require('../lib/deploy');
|
|
8
8
|
const { selfUpdate, INSTALL_DIR } = require('../lib/selfUpdate');
|
|
9
|
+
const { uninstall } = require('../lib/uninstall');
|
|
10
|
+
const { MOONTRAZE_HOME } = require('../lib/paths');
|
|
9
11
|
|
|
10
12
|
const program = new Command();
|
|
11
13
|
|
|
12
|
-
// Moon CLI se aata hai
|
|
14
|
+
// Moon CLI se aata hai (bahut important)
|
|
13
15
|
const platformName = process.env.MOON_PLATFORM || 'moontraze';
|
|
14
16
|
const apiUrl = process.env.MOON_API || getConfig().apiUrl || 'https://api.moontraze.com';
|
|
15
17
|
const domain = process.env.MOON_DOMAIN || getConfig().domain || 'moontraze.com';
|
|
16
18
|
|
|
17
|
-
// version package.json se (update ke baad naya version dikhe)
|
|
18
19
|
let version = '1.0.6';
|
|
19
20
|
try {
|
|
20
21
|
version = require('../package.json').version || version;
|
|
@@ -106,58 +107,32 @@ program
|
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
109
|
|
|
109
|
-
// ----------
|
|
110
|
-
async function runDeploy(opts) {
|
|
111
|
-
try {
|
|
112
|
-
await deploy({
|
|
113
|
-
prod: !!(opts.prod || opts.production),
|
|
114
|
-
projectName: opts.project || opts.name,
|
|
115
|
-
apiUrl,
|
|
116
|
-
domain,
|
|
117
|
-
});
|
|
118
|
-
} catch (e) {
|
|
119
|
-
console.error(chalk.red('\nDeploy failed:'), e.message);
|
|
120
|
-
process.exit(1);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
program
|
|
125
|
-
.command('deploy')
|
|
126
|
-
.description('Deploy current folder')
|
|
127
|
-
.option('--prod', 'Production redeploy')
|
|
128
|
-
.option('--production', 'Alias for --prod')
|
|
129
|
-
.option('-p, --project <name>', 'Project name (or use link)')
|
|
130
|
-
.action(runDeploy);
|
|
131
|
-
|
|
110
|
+
// ---------- uninstall ----------
|
|
132
111
|
program
|
|
133
|
-
.
|
|
134
|
-
.
|
|
135
|
-
.option('-
|
|
136
|
-
.action(
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
112
|
+
.command('uninstall')
|
|
113
|
+
.description('Remove Moontraze CLI and data from this system')
|
|
114
|
+
.option('-y, --yes', 'Confirm uninstall')
|
|
115
|
+
.action((opts) => {
|
|
116
|
+
if (!opts.yes) {
|
|
117
|
+
console.log(chalk.yellow('This will remove Moontraze CLI and local data from your system.'));
|
|
118
|
+
console.log(chalk.gray(` Target: ${MOONTRAZE_HOME}`));
|
|
119
|
+
console.log(chalk.gray(' Also removes old ~/.moontraze if present.'));
|
|
120
|
+
console.log(chalk.gray(' Global Moon CLI is NOT deleted.'));
|
|
121
|
+
console.log('');
|
|
122
|
+
console.log(chalk.cyan('Run: moon moontraze uninstall --yes'));
|
|
123
|
+
console.log(chalk.cyan(' or: npx moontraze uninstall --yes'));
|
|
124
|
+
process.exit(0);
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
uninstall({ yes: true });
|
|
128
|
+
} catch (e) {
|
|
129
|
+
console.error(chalk.red('Uninstall failed:'), e.message);
|
|
130
|
+
process.exit(1);
|
|
142
131
|
}
|
|
143
132
|
});
|
|
144
133
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
moon ${platformName} link my-site
|
|
151
|
-
moon ${platformName} list
|
|
152
|
-
moon ${platformName} deploy --prod
|
|
153
|
-
moon ${platformName} update
|
|
154
|
-
moon ${platformName} --prod
|
|
155
|
-
npx moontraze login
|
|
156
|
-
npx moontraze deploy --prod
|
|
157
|
-
`
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
program.parseAsync(process.argv).catch((e) => {
|
|
161
|
-
console.error(chalk.red(e.message));
|
|
162
|
-
process.exit(1);
|
|
163
|
-
});
|
|
134
|
+
// ---------- deploy ----------
|
|
135
|
+
async function runDeploy(opts) {
|
|
136
|
+
try {
|
|
137
|
+
await deploy({
|
|
138
|
+
prod: !
|
package/lib/uninstall.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const { MOONTRAZE_HOME, MOONTRAZE_CLI, MOON_HOME } = require('./paths');
|
|
6
|
+
|
|
7
|
+
const OLD_HOME = path.join(os.homedir(), '.moontraze');
|
|
8
|
+
|
|
9
|
+
function rmDir(dir) {
|
|
10
|
+
if (!fs.existsSync(dir)) return false;
|
|
11
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Moontraze platform uninstall
|
|
17
|
+
* - removes MOONTRAZE_HOME (cli + config/token)
|
|
18
|
+
* - removes old ~/.moontraze
|
|
19
|
+
* - removes "moontraze" entry from global Moon config (agar ho)
|
|
20
|
+
* Does NOT uninstall global Moon CLI
|
|
21
|
+
*/
|
|
22
|
+
function uninstall({ yes = false } = {}) {
|
|
23
|
+
console.log(chalk.cyan('Uninstalling Moontraze CLI...'));
|
|
24
|
+
console.log(chalk.gray(` Data dir: ${MOONTRAZE_HOME}`));
|
|
25
|
+
console.log(chalk.gray(` CLI dir: ${MOONTRAZE_CLI}`));
|
|
26
|
+
|
|
27
|
+
let removed = false;
|
|
28
|
+
|
|
29
|
+
if (rmDir(MOONTRAZE_HOME)) {
|
|
30
|
+
console.log(chalk.green(`✓ Removed ${MOONTRAZE_HOME}`));
|
|
31
|
+
removed = true;
|
|
32
|
+
}
|
|
33
|
+
if (rmDir(OLD_HOME)) {
|
|
34
|
+
console.log(chalk.green(`✓ Removed old ${OLD_HOME}`));
|
|
35
|
+
removed = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// global moon config se moontraze platform entry hatao
|
|
39
|
+
const moonCfg = path.join(MOON_HOME, 'config.json');
|
|
40
|
+
if (fs.existsSync(moonCfg)) {
|
|
41
|
+
try {
|
|
42
|
+
const cfg = JSON.parse(fs.readFileSync(moonCfg, 'utf8'));
|
|
43
|
+
if (cfg.platforms && cfg.platforms.moontraze) {
|
|
44
|
+
delete cfg.platforms.moontraze;
|
|
45
|
+
if (cfg.defaultPlatform === 'moontraze') {
|
|
46
|
+
const keys = Object.keys(cfg.platforms);
|
|
47
|
+
cfg.defaultPlatform = keys.length ? keys[0] : null;
|
|
48
|
+
}
|
|
49
|
+
fs.writeFileSync(moonCfg, JSON.stringify(cfg, null, 2));
|
|
50
|
+
console.log(chalk.green('✓ Removed moontraze from global moon platforms'));
|
|
51
|
+
}
|
|
52
|
+
} catch (_) {}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!removed) {
|
|
56
|
+
console.log(chalk.yellow('Nothing found to remove (already uninstalled?).'));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log('');
|
|
60
|
+
console.log(chalk.green('Moontraze uninstalled.'));
|
|
61
|
+
console.log(chalk.gray('Global Moon CLI is still installed (if present).'));
|
|
62
|
+
console.log(chalk.gray('Open a NEW terminal if needed.'));
|
|
63
|
+
console.log('');
|
|
64
|
+
|
|
65
|
+
return { removed };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = { uninstall };
|