cloud-ide-cide 2.0.38 → 2.0.39
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/cli.js +27 -0
- package/deployer/node/upload-api.js +21 -0
- package/package.json +1 -1
- package/uploadProject.js +6 -0
package/cli.js
CHANGED
|
@@ -361,6 +361,33 @@ program
|
|
|
361
361
|
});
|
|
362
362
|
});
|
|
363
363
|
|
|
364
|
+
/* app — remote app management (status/start/stop/restart) via upload listener */
|
|
365
|
+
program
|
|
366
|
+
.command('app')
|
|
367
|
+
.description('Manage deployed apps remotely: status, start, stop, restart')
|
|
368
|
+
.option('--status', 'Check if the deployed app is running')
|
|
369
|
+
.option('--start', 'Start the deployed app')
|
|
370
|
+
.option('--stop', 'Stop the deployed app')
|
|
371
|
+
.option('--restart', 'Restart the deployed app (stop + start)')
|
|
372
|
+
.option('-p, --packages <spec>', 'Project number from the list (e.g. 1)')
|
|
373
|
+
.option('-s, --server <spec>', 'Server number or name (e.g. 1 or "Production")')
|
|
374
|
+
.addHelpText('after', `
|
|
375
|
+
Examples:
|
|
376
|
+
cide app --status Check if app is running on the server
|
|
377
|
+
cide app --start Start the app
|
|
378
|
+
cide app --stop Stop the app
|
|
379
|
+
cide app --restart Restart the app
|
|
380
|
+
cide app --status -p 1 -s 1 Non-interactive: pick project & server by number
|
|
381
|
+
`)
|
|
382
|
+
.action((opts) => {
|
|
383
|
+
checkUserLoggedIn(() => {
|
|
384
|
+
require('./appManager')(opts).catch((err) => {
|
|
385
|
+
console.error(err);
|
|
386
|
+
process.exitCode = 1;
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
|
|
364
391
|
program
|
|
365
392
|
.command('shell')
|
|
366
393
|
.description('Start the interactive CloudIDE workspace shell (git, build, publish, server, npm, …)')
|
|
@@ -216,6 +216,17 @@ async function installAndStart(appCode) {
|
|
|
216
216
|
return { steps, npmOutput, ...result };
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
+
function readAppPort(appCode) {
|
|
220
|
+
const envPath = path.join(SERVER_ROOT, appCode, '.env');
|
|
221
|
+
try {
|
|
222
|
+
const content = fs.readFileSync(envPath, 'utf8');
|
|
223
|
+
const match = content.match(/^PORT\s*=\s*(\d+)/m);
|
|
224
|
+
return match ? match[1] : null;
|
|
225
|
+
} catch {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
219
230
|
// ── Auth middleware ───────────────────────────────────────────────────────────
|
|
220
231
|
function authGuard(req, res, next) {
|
|
221
232
|
if (!TOKEN) {
|
|
@@ -268,6 +279,12 @@ app.post('/upload', authGuard, upload.single('file'), async (req, res) => {
|
|
|
268
279
|
// ── Install dependencies & start the app ─────────────────────────────
|
|
269
280
|
const appResult = await installAndStart(appCode);
|
|
270
281
|
|
|
282
|
+
// ── Build the full running URL ───────────────────────────────────────
|
|
283
|
+
const appPort = readAppPort(appCode);
|
|
284
|
+
const host = req.hostname || req.headers.host?.replace(/:\d+$/, '') || 'localhost';
|
|
285
|
+
const protocol = req.protocol || 'http';
|
|
286
|
+
const appUrl = appPort ? `${protocol}://${host}:${appPort}` : null;
|
|
287
|
+
|
|
271
288
|
// ── Track state ──────────────────────────────────────────────────────
|
|
272
289
|
const deployments = loadDeployments();
|
|
273
290
|
const previousVersion = deployments.apps?.[appCode]?.current?.version || null;
|
|
@@ -278,6 +295,8 @@ app.post('/upload', authGuard, upload.single('file'), async (req, res) => {
|
|
|
278
295
|
appDir,
|
|
279
296
|
releaseZip: releaseZipPath,
|
|
280
297
|
appPid: appResult.pid || null,
|
|
298
|
+
appUrl,
|
|
299
|
+
appPort,
|
|
281
300
|
deployedAt: new Date().toISOString(),
|
|
282
301
|
action: 'upload',
|
|
283
302
|
message: deployMsg,
|
|
@@ -301,6 +320,8 @@ app.post('/upload', authGuard, upload.single('file'), async (req, res) => {
|
|
|
301
320
|
releaseVersion: version,
|
|
302
321
|
previousVersion,
|
|
303
322
|
appDir,
|
|
323
|
+
appUrl,
|
|
324
|
+
appPort,
|
|
304
325
|
releaseZip: releaseZipPath,
|
|
305
326
|
appProcess: appResult,
|
|
306
327
|
completedAt: new Date().toISOString(),
|
package/package.json
CHANGED
package/uploadProject.js
CHANGED
|
@@ -715,6 +715,7 @@ async function uploadProject(opts = {}) {
|
|
|
715
715
|
console.log(` App : ${result.appCode}`);
|
|
716
716
|
console.log(` Server : ${label}`);
|
|
717
717
|
if (result.previousVersion) console.log(` Previous : ${result.previousVersion}`);
|
|
718
|
+
if (result.appUrl) console.log(` Running : ${result.appUrl}`);
|
|
718
719
|
if (result.appDir) console.log(` Path : ${result.appDir}`);
|
|
719
720
|
else if (result.releasePath) console.log(` Path : ${result.releasePath}`);
|
|
720
721
|
if (result.appProcess) {
|
|
@@ -757,6 +758,11 @@ async function uploadProject(opts = {}) {
|
|
|
757
758
|
module.exports = uploadProject;
|
|
758
759
|
module.exports.discoverUploadableProjects = discoverUploadableProjects;
|
|
759
760
|
module.exports.printProjectList = printProjectList;
|
|
761
|
+
module.exports.selectProject = selectProject;
|
|
762
|
+
module.exports.selectServer = selectServer;
|
|
763
|
+
module.exports.resolveEndpoint = resolveEndpoint;
|
|
764
|
+
module.exports.getToken = getToken;
|
|
765
|
+
module.exports.getAuthHeaders = getAuthHeaders;
|
|
760
766
|
module.exports.findEnvFile = findEnvFile;
|
|
761
767
|
module.exports.findHostManagerFile = findHostManagerFile;
|
|
762
768
|
module.exports.parseExistingEnv = parseExistingEnv;
|