@mytmpvpn/mytmpvpn-cli 1.1.0 → 1.5.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.
package/.eslintignore ADDED
@@ -0,0 +1,4 @@
1
+ # .estlintignore file
2
+ dist
3
+ build
4
+ node_modules/
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # mytmpvpn-cli
2
2
 
3
- Command Line Interface for the [`MyTmpVpn`](https://gitlab.com/mytmpvpn) project.
3
+ Command Line Interface for the [`MyTmpVpn`](https://gitlab.com/mytmpvpn) project.
4
4
 
5
5
  ## Getting started
6
-
6
+
7
7
  ### Pre-requisite && how to build?
8
8
 
9
9
  1. Install npm: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
@@ -17,36 +17,46 @@ Command Line Interface for the [`MyTmpVpn`](https://gitlab.com/mytmpvpn) project
17
17
  1. Go to the `mytmpvpn-cli` project and build everything: `cd mytmpvpn-cli; npm run build-all`
18
18
 
19
19
  From there you should be able to:
20
- 1. execute the mytmpvpn CLI: `npx mytmpvpn`
21
- 1. Develop inside each project.
20
+
21
+ 1. execute the mytmpvpn CLI: `npx mytmpvpn`
22
+ 1. Develop inside each project.
22
23
 
23
24
  ## TODO: write down remaining sections
24
25
 
25
26
  ## Name
27
+
26
28
  Choose a self-explaining name for your project.
27
29
 
28
30
  ## Description
31
+
29
32
  Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
30
33
 
31
34
  ## Badges
35
+
32
36
  On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
33
37
 
34
38
  ## Visuals
39
+
35
40
  Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
36
41
 
37
42
  ## Installation
43
+
38
44
  Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
39
45
 
40
46
  ## Usage
47
+
41
48
  Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
42
49
 
43
50
  ## Support
51
+
44
52
  Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
45
53
 
46
54
  ## Roadmap
55
+
47
56
  If you have ideas for releases in the future, it is a good idea to list them in the README.
48
57
 
49
58
  ## Contributing
59
+
50
60
  State if you are open to contributions and what your requirements are for accepting them.
51
61
 
52
62
  For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
@@ -54,10 +64,13 @@ For people who want to make changes to your project, it's helpful to have some d
54
64
  You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
55
65
 
56
66
  ## Authors and acknowledgment
67
+
57
68
  Show your appreciation to those who have contributed to the project.
58
69
 
59
70
  ## License
71
+
60
72
  For open source projects, say how it is licensed.
61
73
 
62
74
  ## Project status
75
+
63
76
  If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
package/dist/mytmpvpn.js CHANGED
@@ -13,7 +13,7 @@ const peanuts = require("@mytmpvpn/mytmpvpn-common/models/peanuts");
13
13
  const appconfig_1 = require("@mytmpvpn/mytmpvpn-client/appconfig");
14
14
  const userconfig_1 = require("@mytmpvpn/mytmpvpn-client/userconfig");
15
15
  const auth = require("@mytmpvpn/mytmpvpn-client/auth");
16
- const mytmpvpn_client_1 = require("@mytmpvpn/mytmpvpn-client/mytmpvpn-client");
16
+ const client_1 = require("@mytmpvpn/mytmpvpn-client/client");
17
17
  const program = new commander_1.Command();
18
18
  function handleError(error, verbose = false) {
19
19
  if (error.response) {
@@ -56,7 +56,7 @@ program.command('list-peanuts-packs')
56
56
  const options = command.optsWithGlobals();
57
57
  const appConfig = (0, appconfig_1.loadAppConfig)(options.appConfig);
58
58
  // We don't need authenticated user to call this API
59
- const client = new mytmpvpn_client_1.MyTmpVpnClient(appConfig.apiUrl);
59
+ const client = new client_1.MyTmpVpnClient(appConfig.apiUrl);
60
60
  client.listPeanutsPacks()
61
61
  .then(((packs) => {
62
62
  log.info(JSON.stringify(packs, null, 2));
@@ -86,13 +86,26 @@ program.command('list-regions')
86
86
  const options = command.optsWithGlobals();
87
87
  const appConfig = (0, appconfig_1.loadAppConfig)(options.appConfig);
88
88
  // We don't need authenticated user to call this API
89
- const client = new mytmpvpn_client_1.MyTmpVpnClient(appConfig.apiUrl);
89
+ const client = new client_1.MyTmpVpnClient(appConfig.apiUrl);
90
90
  client.listRegions()
91
91
  .then(((regions) => {
92
92
  log.info(JSON.stringify(regions, null, 2));
93
93
  }))
94
94
  .catch((err) => handleError(err));
95
95
  });
96
+ program.command('list-regions-detailed')
97
+ .description('Returns the detailed list of all regions where vpn can be created')
98
+ .action((_, command) => {
99
+ const options = command.optsWithGlobals();
100
+ const appConfig = (0, appconfig_1.loadAppConfig)(options.appConfig);
101
+ // We don't need authenticated user to call this API
102
+ const client = new client_1.MyTmpVpnClient(appConfig.apiUrl);
103
+ client.listRegionsDetailed()
104
+ .then(((regions) => {
105
+ log.info(JSON.stringify(regions, null, 2));
106
+ }))
107
+ .catch((err) => handleError(err));
108
+ });
96
109
  program.command('create')
97
110
  .description('Create a new vpn')
98
111
  .argument('<region>', 'region where the vpn should be created, as returned by list-regions')
@@ -183,7 +196,7 @@ program.command('download-config')
183
196
  handleError(err);
184
197
  return;
185
198
  }
186
- client.getVpnConfig(vpnId, fs.createWriteStream(fullpath))
199
+ client.writeVpnConfigTo(vpnId, fs.createWriteStream(fullpath))
187
200
  .then(() => log.info(fullpath))
188
201
  .catch(err => handleError(err));
189
202
  });
@@ -303,7 +316,7 @@ Examples:
303
316
  # Before doing anything, you need to register to the MyTmpVpn service:
304
317
 
305
318
  $ mytmpvpn register 'your@email.com' 'StrongPassword' # Min: 8 characters with digit, lower, upper and symbols
306
- $ mytmpvpn confirm-registration 'code' # The code you've received by email
319
+ $ mytmpvpn confirm-registration 'your@email.com' 'code' # The code you've received by email
307
320
 
308
321
  # You then need to buy some peanuts, the list of peanuts packs can be fetched using:
309
322
 
@@ -321,7 +334,7 @@ Examples:
321
334
  $ mytmpvpn list-regions
322
335
 
323
336
  # Create a new vpn in Paris:
324
- $ mytmpvpn --sync create 'paris' # This takes several minutes, please be patient or remove --sync
337
+ $ mytmpvpn create 'paris' --sync # This takes several minutes, please be patient or remove --sync
325
338
 
326
339
  # List all my vpns:
327
340
  $ mytmpvpn list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mytmpvpn/mytmpvpn-cli",
3
- "version": "1.1.0",
3
+ "version": "1.5.0",
4
4
  "description": "MyTmpVpn CLI",
5
5
  "main": "./dist/mytmpvpn.js",
6
6
  "bin": {
@@ -23,12 +23,12 @@
23
23
  "email": "pierre.vigneras@gmail.com",
24
24
  "url": "https://www.linkedin.com/in/pierrevigneras/"
25
25
  },
26
- "license": "GNU AGPL",
26
+ "license": "GNU GPL",
27
27
  "dependencies": {
28
28
  "commander": "^9.4.1",
29
29
  "loglevel": "^1.8.1",
30
- "@mytmpvpn/mytmpvpn-client": "^1.0.0",
31
- "@mytmpvpn/mytmpvpn-common": "^1.1.0"
30
+ "@mytmpvpn/mytmpvpn-client": "^1.6.2",
31
+ "@mytmpvpn/mytmpvpn-common": "^1.4.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/jest": "^29.2.2",
package/src/mytmpvpn.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  // https://github.com/netlify/cli/issues/4608 -- but it hangs the process: https://github.com/nodejs/node/issues/21960
4
4
  import * as fs from 'fs'
5
5
  import * as path from 'path'
6
- import { Argument, Command, Option } from 'commander'
6
+ import { Command, Option } from 'commander'
7
7
  import * as log from 'loglevel'
8
8
  log.setDefaultLevel("info")
9
9
 
@@ -12,7 +12,7 @@ import * as peanuts from '@mytmpvpn/mytmpvpn-common/models/peanuts'
12
12
  import { getDefaultAppConfigFile, loadAppConfig } from '@mytmpvpn/mytmpvpn-client/appconfig'
13
13
  import { getDefaultUserConfigFile, getDefaultUserProfile, getDefaultUserConfigDir, loadUserConfig, UserConfig } from '@mytmpvpn/mytmpvpn-client/userconfig'
14
14
  import * as auth from '@mytmpvpn/mytmpvpn-client/auth'
15
- import { MyTmpVpnClient } from '@mytmpvpn/mytmpvpn-client/mytmpvpn-client'
15
+ import { MyTmpVpnClient } from '@mytmpvpn/mytmpvpn-client/client'
16
16
 
17
17
  const program = new Command()
18
18
 
@@ -83,7 +83,7 @@ program.command('get-peanuts-balance')
83
83
  })
84
84
  })
85
85
 
86
- program.command('list-regions')
86
+ program.command('list-regions')
87
87
  .description('Returns the list of all regions where vpn can be created')
88
88
  .action((_, command) => {
89
89
  const options = command.optsWithGlobals()
@@ -97,6 +97,19 @@ program.command('get-peanuts-balance')
97
97
  .catch((err) => handleError(err))
98
98
  })
99
99
 
100
+ program.command('list-regions-detailed')
101
+ .description('Returns the detailed list of all regions where vpn can be created')
102
+ .action((_, command) => {
103
+ const options = command.optsWithGlobals()
104
+ const appConfig = loadAppConfig(options.appConfig)
105
+ // We don't need authenticated user to call this API
106
+ const client = new MyTmpVpnClient(appConfig.apiUrl)
107
+ client.listRegionsDetailed()
108
+ .then(((regions: any) => {
109
+ log.info(JSON.stringify(regions, null, 2))
110
+ }))
111
+ .catch((err) => handleError(err))
112
+ })
100
113
 
101
114
  program.command('create')
102
115
  .description('Create a new vpn')
@@ -192,7 +205,7 @@ program.command('download-config')
192
205
  handleError(err)
193
206
  return
194
207
  }
195
- client.getVpnConfig(vpnId, fs.createWriteStream(fullpath))
208
+ client.writeVpnConfigTo(vpnId, fs.createWriteStream(fullpath))
196
209
  .then(() => log.info(fullpath))
197
210
  .catch(err => handleError(err))
198
211
  })
@@ -316,7 +329,7 @@ Examples:
316
329
  # Before doing anything, you need to register to the MyTmpVpn service:
317
330
 
318
331
  $ mytmpvpn register 'your@email.com' 'StrongPassword' # Min: 8 characters with digit, lower, upper and symbols
319
- $ mytmpvpn confirm-registration 'code' # The code you've received by email
332
+ $ mytmpvpn confirm-registration 'your@email.com' 'code' # The code you've received by email
320
333
 
321
334
  # You then need to buy some peanuts, the list of peanuts packs can be fetched using:
322
335
 
@@ -334,7 +347,7 @@ Examples:
334
347
  $ mytmpvpn list-regions
335
348
 
336
349
  # Create a new vpn in Paris:
337
- $ mytmpvpn --sync create 'paris' # This takes several minutes, please be patient or remove --sync
350
+ $ mytmpvpn create 'paris' --sync # This takes several minutes, please be patient or remove --sync
338
351
 
339
352
  # List all my vpns:
340
353
  $ mytmpvpn list