clever-tools 3.0.2 → 3.1.0

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.
@@ -38,6 +38,7 @@ async function addLinkedApplication (appData, alias, ignoreParentConfig) {
38
38
  app_id: appData.id,
39
39
  org_id: appData.ownerId,
40
40
  deploy_url: appData.deployment.httpUrl || appData.deployment.url,
41
+ git_ssh_url: appData.deployment.url,
41
42
  name: appData.name,
42
43
  alias: alias || slugify(appData.name),
43
44
  };
@@ -63,7 +64,6 @@ async function removeLinkedApplication (alias) {
63
64
  };
64
65
 
65
66
  function findApp (config, alias) {
66
-
67
67
  if (_.isEmpty(config.apps)) {
68
68
  throw new Error('There are no applications linked. You can add one with `clever link`');
69
69
  }
@@ -82,6 +82,18 @@ function findApp (config, alias) {
82
82
  return findDefaultApp(config);
83
83
  }
84
84
 
85
+ function checkAlreadyLinked (apps, name, alias) {
86
+ const appAliasExists = apps.some((app) => app.alias != null && app.alias === alias);
87
+ if (appAliasExists) {
88
+ throw new Error(`An application is already linked with the alias '${alias}'`);
89
+ }
90
+
91
+ const appNameExists = apps.some((app) => app.name === name);
92
+ if (appNameExists) {
93
+ throw new Error(`An application is already linked with the name '${name}'`);
94
+ }
95
+ }
96
+
85
97
  function findDefaultApp (config) {
86
98
  if (_.isEmpty(config.apps)) {
87
99
  throw new Error('There are no applications linked. You can add one with `clever link`');
@@ -163,6 +175,7 @@ module.exports = {
163
175
  loadApplicationConf,
164
176
  addLinkedApplication,
165
177
  removeLinkedApplication,
178
+ checkAlreadyLinked,
166
179
  findApp,
167
180
  getAppDetails,
168
181
  getMostNaturalName,
@@ -14,11 +14,13 @@ const User = require('./user.js');
14
14
  const { sendToApi } = require('../models/send-to-api.js');
15
15
 
16
16
  function listAvailableTypes () {
17
- return autocomplete.words(['docker', 'elixir', 'go', 'gradle', 'haskell', 'jar', 'maven', 'node', 'php', 'play1', 'play2', 'python', 'ruby', 'rust', 'sbt', 'static-apache', 'war']);
17
+ return autocomplete.words(['docker', 'elixir', 'go', 'gradle', 'haskell', 'jar', 'maven', 'meteor', 'node', 'php', 'play1', 'play2', 'python', 'ruby', 'rust', 'sbt', 'static-apache', 'war']);
18
18
  };
19
19
 
20
+ const AVAILABLE_ZONES = ['par', 'rbx', 'rbxhds', 'scw', 'jed', 'mtl', 'sgp', 'syd', 'wsw'];
21
+
20
22
  function listAvailableZones () {
21
- return autocomplete.words(['par', 'mtl']);
23
+ return autocomplete.words(AVAILABLE_ZONES);
22
24
  };
23
25
 
24
26
  function listAvailableAliases () {
@@ -241,6 +243,7 @@ module.exports = {
241
243
  listAvailableAliases,
242
244
  listAvailableFlavors,
243
245
  listAvailableTypes,
246
+ AVAILABLE_ZONES,
244
247
  listAvailableZones,
245
248
  listDependencies,
246
249
  __mergeScalabilityParameters: mergeScalabilityParameters,
@@ -11,7 +11,7 @@ async function getBest (appId, orgaId) {
11
11
  return getFavouriteDomain({ id: orgaId, appId }).then(sendToApi)
12
12
  .catch(async (e) => {
13
13
 
14
- if (e.status !== 404) {
14
+ if (e.response.status !== 404) {
15
15
  throw e;
16
16
  }
17
17
 
package/src/models/git.js CHANGED
@@ -5,7 +5,7 @@ const path = require('path');
5
5
 
6
6
  const _ = require('lodash');
7
7
  const git = require('isomorphic-git');
8
- const http = require('isomorphic-git/http/node');
8
+ const http = require('./isomorphic-http-with-agent.js');
9
9
  const { autocomplete } = require('cliparse');
10
10
 
11
11
  const slugify = require('slugify');
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ const isomotphicHttp = require('isomorphic-git/http/node');
4
+ const https = require('https');
5
+
6
+ // We use our own HTTP plugin, so we can customize the agent used for requests and configure a long timeout (default is 5 seconds).
7
+
8
+ const agent = new https.Agent({
9
+ keepAlive: true,
10
+ timeout: 10 * 60 * 1000,
11
+ });
12
+
13
+ function request (params) {
14
+ return isomotphicHttp.request({ ...params, agent });
15
+ }
16
+
17
+ module.exports = {
18
+ request,
19
+ };