moontraze 2.0.3 → 2.0.4
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 +68 -8
- package/package.json +1 -1
package/bin/moontraze.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { Command } = require('commander');
|
|
3
3
|
const chalk = require('chalk');
|
|
4
|
-
const path = require('path');
|
|
5
4
|
const { login } = require('../lib/auth');
|
|
6
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
getConfig,
|
|
7
|
+
getProject,
|
|
8
|
+
setProject,
|
|
9
|
+
GLOBAL_FILE,
|
|
10
|
+
} = require('../lib/config');
|
|
7
11
|
const { deploy } = require('../lib/deploy');
|
|
8
12
|
const { selfUpdate, INSTALL_DIR } = require('../lib/selfUpdate');
|
|
9
13
|
const { uninstall } = require('../lib/uninstall');
|
|
@@ -11,12 +15,14 @@ const { MOONTRAZE_HOME } = require('../lib/paths');
|
|
|
11
15
|
|
|
12
16
|
const program = new Command();
|
|
13
17
|
|
|
14
|
-
// Moon CLI se aata hai
|
|
18
|
+
// Moon CLI se aata hai
|
|
15
19
|
const platformName = process.env.MOON_PLATFORM || 'moontraze';
|
|
16
|
-
const apiUrl =
|
|
17
|
-
|
|
20
|
+
const apiUrl =
|
|
21
|
+
process.env.MOON_API || getConfig().apiUrl || 'https://api.moontraze.com';
|
|
22
|
+
const domain =
|
|
23
|
+
process.env.MOON_DOMAIN || getConfig().domain || 'moontraze.com';
|
|
18
24
|
|
|
19
|
-
let version = '
|
|
25
|
+
let version = '2.0.1';
|
|
20
26
|
try {
|
|
21
27
|
version = require('../package.json').version || version;
|
|
22
28
|
} catch (_) {}
|
|
@@ -114,7 +120,11 @@ program
|
|
|
114
120
|
.option('-y, --yes', 'Confirm uninstall')
|
|
115
121
|
.action((opts) => {
|
|
116
122
|
if (!opts.yes) {
|
|
117
|
-
console.log(
|
|
123
|
+
console.log(
|
|
124
|
+
chalk.yellow(
|
|
125
|
+
'This will remove Moontraze CLI and local data from your system.'
|
|
126
|
+
)
|
|
127
|
+
);
|
|
118
128
|
console.log(chalk.gray(` Target: ${MOONTRAZE_HOME}`));
|
|
119
129
|
console.log(chalk.gray(' Also removes old ~/.moontraze if present.'));
|
|
120
130
|
console.log(chalk.gray(' Global Moon CLI is NOT deleted.'));
|
|
@@ -135,4 +145,54 @@ program
|
|
|
135
145
|
async function runDeploy(opts) {
|
|
136
146
|
try {
|
|
137
147
|
await deploy({
|
|
138
|
-
prod:
|
|
148
|
+
prod: !!(opts.prod || opts.production),
|
|
149
|
+
projectName: opts.project || opts.name,
|
|
150
|
+
apiUrl,
|
|
151
|
+
domain,
|
|
152
|
+
});
|
|
153
|
+
} catch (e) {
|
|
154
|
+
console.error(chalk.red('\nDeploy failed:'), e.message);
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
program
|
|
160
|
+
.command('deploy')
|
|
161
|
+
.description('Deploy current folder')
|
|
162
|
+
.option('--prod', 'Production redeploy')
|
|
163
|
+
.option('--production', 'Alias for --prod')
|
|
164
|
+
.option('-p, --project <name>', 'Project name (or use link)')
|
|
165
|
+
.action(runDeploy);
|
|
166
|
+
|
|
167
|
+
program
|
|
168
|
+
.option('--prod', 'Deploy to production')
|
|
169
|
+
.option('--production', 'Deploy to production')
|
|
170
|
+
.option('-p, --project <name>', 'Project name')
|
|
171
|
+
.action(async (opts, cmd) => {
|
|
172
|
+
if (cmd.args && cmd.args.length) return;
|
|
173
|
+
if (opts.prod || opts.production || opts.project) {
|
|
174
|
+
await runDeploy(opts);
|
|
175
|
+
} else {
|
|
176
|
+
program.help();
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
program.addHelpText(
|
|
181
|
+
'after',
|
|
182
|
+
`
|
|
183
|
+
Examples:
|
|
184
|
+
moon ${platformName} login
|
|
185
|
+
moon ${platformName} link my-site
|
|
186
|
+
moon ${platformName} list
|
|
187
|
+
moon ${platformName} deploy --prod
|
|
188
|
+
moon ${platformName} update
|
|
189
|
+
moon ${platformName} uninstall --yes
|
|
190
|
+
npx moontraze login
|
|
191
|
+
npx moontraze deploy --prod
|
|
192
|
+
`
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
program.parseAsync(process.argv).catch((e) => {
|
|
196
|
+
console.error(chalk.red(e.message));
|
|
197
|
+
process.exit(1);
|
|
198
|
+
});
|