cloudron 4.14.0 → 4.14.1

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/cloudron CHANGED
@@ -27,6 +27,7 @@ function collectArgs(value, collected) {
27
27
  return collected;
28
28
  }
29
29
 
30
+ // TODO when updating to commander v8 we require https://github.com/tj/commander.js/pull/1670
30
31
  program.version(version)
31
32
  .option('--server <server>', 'Cloudron domain')
32
33
  .option('--token <token>', 'Cloudron token')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudron",
3
- "version": "4.14.0",
3
+ "version": "4.14.1",
4
4
  "license": "MIT",
5
5
  "description": "Cloudron Commandline Tool",
6
6
  "main": "main.js",
package/src/actions.js CHANGED
@@ -67,6 +67,10 @@ const NO_APP_FOUND_ERROR_STRING = 'Could not determine app. Use --app to specify
67
67
  // options for the request module
68
68
  function requestOptions(options) {
69
69
  const adminFqdn = options.parent.server || config.apiEndpoint();
70
+
71
+ // ensure config can return the correct section
72
+ config.setActive(adminFqdn);
73
+
70
74
  const token = options.parent.token || config.token();
71
75
  const rejectUnauthorized = !(options.parent.allowSelfsigned || options.parent.acceptSelfsigned || config.allowSelfsigned());
72
76
 
@@ -82,7 +86,7 @@ function createRequest(method, apiPath, options) {
82
86
  if (url.includes('?')) url += '&'; else url += '?';
83
87
  url += `access_token=${token}`;
84
88
  const request = superagent(method, url);
85
- if (rejectUnauthorized) request.disableTLSCerts();
89
+ if (!rejectUnauthorized) request.disableTLSCerts();
86
90
  request.ok(() => true);
87
91
  return request;
88
92
  }
@@ -364,11 +368,15 @@ async function login(adminFqdn, options) {
364
368
 
365
369
  config.setActive(adminFqdn);
366
370
 
371
+ const rejectUnauthorized = !(options.parent.allowSelfsigned || options.parent.acceptSelfsigned);
367
372
  let token = config.token();
368
373
  if (token) { // check if the token is not expired
369
- const [error, response] = await safe(superagent.get(`https://${adminFqdn}/api/v1/profile?access_token=${token}`)
374
+ const request = superagent.get(`https://${adminFqdn}/api/v1/profile?access_token=${token}`)
370
375
  .timeout(60000)
371
- .ok(() => true));
376
+ .ok(() => true);
377
+ if (!rejectUnauthorized) request.disableTLSCerts();
378
+
379
+ const [error, response] = await safe(request);
372
380
  if (error) return exit(error);
373
381
  if (response.status === 200) {
374
382
  console.log('Existing token still valid.');
@@ -381,7 +389,6 @@ async function login(adminFqdn, options) {
381
389
  if (!token) {
382
390
  const username = options.username || readlineSync.question('Username: ', {});
383
391
  const password = options.password || readlineSync.question('Password: ', { noEchoBack: true });
384
- const rejectUnauthorized = !(options.parent.allowSelfsigned || options.parent.acceptSelfsigned);
385
392
 
386
393
  const [error, result] = await safe(authenticate(adminFqdn, username, password, { rejectUnauthorized, askForTotpToken: false }));
387
394
  if (error) return exit(`Failed to login: ${error.message}`);
@@ -969,7 +976,7 @@ async function inspect(options) {
969
976
  for (const app of response.body.apps) {
970
977
  const response2 = await createRequest('GET', `/api/v1/apps/${app.id}`, options);
971
978
  if (response2.statusCode !== 200) return exit(`Failed to list app: ${requestError(response2)}`);
972
- response2.body.location = response2.body.subdomain; // LEGACY support
979
+ response2.body.location = response2.body.location || response2.body.subdomain; // LEGACY support
973
980
  apps.push(response2.body);
974
981
  }
975
982
 
@@ -367,6 +367,19 @@ function approveVersion(appstoreId, version) {
367
367
 
368
368
  console.log('Approved.');
369
369
  console.log('');
370
+
371
+ superagentEnd(function () {
372
+ return superagent.get(createUrl('/api/v1/developers/apps/' + appstoreId + '/versions/' + version)).query({ accessToken: config.appStoreToken() });
373
+ }, function (error, result) {
374
+ if (error && !error.response) exit(util.format('Failed to list apps: %s', error.message));
375
+ if (result.statusCode !== 200) exit(util.format('Failed to list apps: %s message: %s', result.statusCode, result.text));
376
+
377
+ console.log('Changelog for forum update: ' + result.body.manifest.forumUrl);
378
+ console.log('');
379
+ console.log('[' + version + ']');
380
+ console.log(result.body.manifest.changelog);
381
+ console.log('');
382
+ });
370
383
  });
371
384
  }
372
385
 
@@ -505,6 +518,7 @@ function approve(options) {
505
518
  if (!version) return exit('--appstore-id must be of the format id@version');
506
519
 
507
520
  console.log('Approving ' + id + '@' + version);
521
+
508
522
  approveVersion(id, version);
509
523
  });
510
524
  }