@mytmpvpn/mytmpvpn-cli 4.2.0 → 5.0.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/dist/mytmpvpn.js CHANGED
@@ -114,52 +114,36 @@ program.command('get-peanuts-balance')
114
114
  handleError(err, options.verbose);
115
115
  });
116
116
  });
117
- program.command('list-regions')
118
- .description('Returns the list of all regions where vpn can be created')
117
+ program.command('list-locations')
118
+ .description('Returns the list of all locations where vpn can be created')
119
119
  .action((_, command) => {
120
120
  const options = command.optsWithGlobals();
121
121
  const appConfig = appconfig.loadAppConfig(options.appConfig);
122
122
  // We don't need authenticated user to call this API
123
123
  const clientImpl = new client.MyTmpVpnClientImpl(appConfig.apiUrl);
124
- clientImpl.listRegions()
125
- .then(((regions) => {
126
- log.info(JSON.stringify(regions, null, 2));
127
- }))
128
- .catch((err) => handleError(err));
129
- });
130
- program.command('list-regions-detailed')
131
- .description('Returns the detailed list of all regions where vpn can be created')
132
- .action((_, command) => {
133
- const options = command.optsWithGlobals();
134
- const appConfig = appconfig.loadAppConfig(options.appConfig);
135
- // We don't need authenticated user to call this API
136
- const clientImpl = new client.MyTmpVpnClientImpl(appConfig.apiUrl);
137
- clientImpl.listRegionsDetailed()
138
- .then(((regions) => {
139
- log.info(JSON.stringify(regions, null, 2));
124
+ clientImpl.listLocations()
125
+ .then(((locations) => {
126
+ log.info(JSON.stringify(locations, null, 2));
140
127
  }))
141
128
  .catch((err) => handleError(err));
142
129
  });
143
130
  program.command('create')
144
131
  .description('Create a new vpn')
145
- .argument('<region>', 'region where the vpn should be created, as returned by list-regions')
132
+ .argument('<geonameId>', 'geonameId where the vpn should be created, as returned by list-locations')
146
133
  .option('--sync', 'wait for vpn creation completion')
147
- .addOption(new commander_1.Option('--type <type>', 'Type of VPN')
148
- .choices(vpnlib.getVpnConfigTypes())
149
- .default(vpnlib.VpnType.WireGuard))
150
134
  .option('--peanuts <nb>', 'Max number of peanuts to use (specify -1 for maximum)', '-1')
151
135
  .option('--deleteAfter seconds', 'Number of seconds after which the vpn will be terminated')
152
- .action((region, _, command) => {
136
+ .action((geonameId, _, command) => {
153
137
  const options = command.optsWithGlobals();
154
138
  const syncStr = options.sync ? "synchronously" : "asynchronously";
155
139
  const deleteAfter = options.deleteAfter ? options.deleteAfter : undefined;
156
- log.debug(`Creating new ${options.type} vpn into ${region} ${syncStr}`);
140
+ log.debug(`Creating new ${options.type} vpn into ${geonameId} ${syncStr}`);
157
141
  (0, mytmpvpn_client_1.getLoggedInClientFromFiles)({
158
142
  appConfigFile: options.appConfig,
159
143
  userConfigFile: options.userConfig,
160
144
  profileName: options.profile
161
145
  }).then(client => {
162
- client.createVpn(region, {
146
+ client.createVpn(Number.parseInt(geonameId), {
163
147
  type: options.type,
164
148
  maxPeanuts: options.peanuts, deleteAfter
165
149
  }).then(vpn => {
@@ -259,7 +243,7 @@ program.command('download-config')
259
243
  });
260
244
  program.command('list')
261
245
  .description('List all vpns')
262
- .option('--region <region>', 'region to list vpns from')
246
+ .option('--geonameId <geonameId>', 'geonameId to list vpns from')
263
247
  .option('--include-state [<state>, ...]', 'Comma separated list of states to include', Object.values(vpnlib.VpnState))
264
248
  .option('--exclude-state [<state>, ...]', 'Comma separated list of states to exclude from', [vpnlib.VpnState.Deleted])
265
249
  .action((_, command) => {
@@ -271,8 +255,8 @@ program.command('list')
271
255
  }).then(client => {
272
256
  client.listVpns(options.state)
273
257
  .then(vpns => {
274
- if (options.region) {
275
- vpns = vpns.filter((vpn) => vpn.region === options.region);
258
+ if (options.location) {
259
+ vpns = vpns.filter((vpn) => vpn.geonamesId === options.geonameId);
276
260
  }
277
261
  if (options.includeState) {
278
262
  vpns = vpns.filter((vpn) => options.includeState.includes(vpn.state));
@@ -399,11 +383,11 @@ Examples:
399
383
 
400
384
  # Then you can use the following command at will:
401
385
 
402
- # List available regions:
403
- $ mytmpvpn list-regions
386
+ # List available locations:
387
+ $ mytmpvpn list-locations
404
388
 
405
389
  # Create a new vpn in Paris:
406
- $ mytmpvpn create 'paris' --sync # This takes several minutes, please be patient or remove --sync
390
+ $ mytmpvpn create '2988507' --sync # This takes several minutes, please be patient or remove --sync
407
391
 
408
392
  # List all my vpns:
409
393
  $ mytmpvpn list
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mytmpvpn/mytmpvpn-cli",
3
- "version": "4.2.0",
3
+ "version": "5.0.0",
4
4
  "description": "MyTmpVpn CLI",
5
5
  "main": "./dist/mytmpvpn.js",
6
6
  "bin": {
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "license": "GNU GPL",
32
32
  "dependencies": {
33
- "@mytmpvpn/mytmpvpn-client": "^6.0.0",
34
- "@mytmpvpn/mytmpvpn-common": "^8.0.0",
33
+ "@mytmpvpn/mytmpvpn-client": "^9.0.0",
34
+ "@mytmpvpn/mytmpvpn-common": "^10.0.2",
35
35
  "@typescript-eslint/eslint-plugin": "^6.21.0",
36
36
  "commander": "^14.0.1",
37
37
  "eslint": "^8.57.1",
package/src/mytmpvpn.ts CHANGED
@@ -13,6 +13,7 @@ import { confirmUser, getLoggedInClientFromFiles, registerUser } from '@mytmpvpn
13
13
  import * as appconfig from '@mytmpvpn/mytmpvpn-client/appconfig'
14
14
  import * as userconfig from '@mytmpvpn/mytmpvpn-client/userconfig'
15
15
  import * as client from '@mytmpvpn/mytmpvpn-client/client'
16
+ import { ListLocationsResponse } from '@mytmpvpn/mytmpvpn-common/models/location'
16
17
 
17
18
  const program = new Command()
18
19
 
@@ -86,54 +87,37 @@ program.command('get-peanuts-balance')
86
87
  })
87
88
  })
88
89
 
89
- program.command('list-regions')
90
- .description('Returns the list of all regions where vpn can be created')
90
+ program.command('list-locations')
91
+ .description('Returns the list of all locations where vpn can be created')
91
92
  .action((_, command) => {
92
93
  const options = command.optsWithGlobals()
93
94
  const appConfig = appconfig.loadAppConfig(options.appConfig)
94
95
  // We don't need authenticated user to call this API
95
96
  const clientImpl = new client.MyTmpVpnClientImpl(appConfig.apiUrl)
96
- clientImpl.listRegions()
97
- .then(((regions: any) => {
98
- log.info(JSON.stringify(regions, null, 2))
99
- }))
100
- .catch((err: any) => handleError(err))
101
- })
102
-
103
- program.command('list-regions-detailed')
104
- .description('Returns the detailed list of all regions where vpn can be created')
105
- .action((_, command) => {
106
- const options = command.optsWithGlobals()
107
- const appConfig = appconfig.loadAppConfig(options.appConfig)
108
- // We don't need authenticated user to call this API
109
- const clientImpl = new client.MyTmpVpnClientImpl(appConfig.apiUrl)
110
- clientImpl.listRegionsDetailed()
111
- .then(((regions: any) => {
112
- log.info(JSON.stringify(regions, null, 2))
97
+ clientImpl.listLocations()
98
+ .then(((locations: ListLocationsResponse) => {
99
+ log.info(JSON.stringify(locations, null, 2))
113
100
  }))
114
101
  .catch((err: any) => handleError(err))
115
102
  })
116
103
 
117
104
  program.command('create')
118
105
  .description('Create a new vpn')
119
- .argument('<region>', 'region where the vpn should be created, as returned by list-regions')
106
+ .argument('<geonameId>', 'geonameId where the vpn should be created, as returned by list-locations')
120
107
  .option('--sync', 'wait for vpn creation completion')
121
- .addOption(new Option('--type <type>', 'Type of VPN')
122
- .choices(vpnlib.getVpnConfigTypes())
123
- .default(vpnlib.VpnType.WireGuard))
124
108
  .option('--peanuts <nb>', 'Max number of peanuts to use (specify -1 for maximum)', '-1')
125
109
  .option('--deleteAfter seconds', 'Number of seconds after which the vpn will be terminated')
126
- .action((region: string, _, command) => {
110
+ .action((geonameId: string, _, command) => {
127
111
  const options = command.optsWithGlobals()
128
112
  const syncStr = options.sync ? "synchronously" : "asynchronously"
129
113
  const deleteAfter = options.deleteAfter ? options.deleteAfter : undefined
130
- log.debug(`Creating new ${options.type} vpn into ${region} ${syncStr}`)
114
+ log.debug(`Creating new ${options.type} vpn into ${geonameId} ${syncStr}`)
131
115
  getLoggedInClientFromFiles({
132
116
  appConfigFile: options.appConfig,
133
117
  userConfigFile: options.userConfig,
134
118
  profileName: options.profile
135
119
  }).then(client => {
136
- client.createVpn(region, {
120
+ client.createVpn(Number.parseInt(geonameId), {
137
121
  type: options.type,
138
122
  maxPeanuts: options.peanuts, deleteAfter
139
123
  }).then(vpn => {
@@ -237,7 +221,7 @@ program.command('download-config')
237
221
 
238
222
  program.command('list')
239
223
  .description('List all vpns')
240
- .option('--region <region>', 'region to list vpns from')
224
+ .option('--geonameId <geonameId>', 'geonameId to list vpns from')
241
225
  .option('--include-state [<state>, ...]', 'Comma separated list of states to include', Object.values(vpnlib.VpnState))
242
226
  .option('--exclude-state [<state>, ...]', 'Comma separated list of states to exclude from', [vpnlib.VpnState.Deleted])
243
227
  .action((_, command) => {
@@ -249,8 +233,8 @@ program.command('list')
249
233
  }).then(client => {
250
234
  client.listVpns(options.state)
251
235
  .then(vpns => {
252
- if (options.region) {
253
- vpns = vpns.filter((vpn: vpnlib.Vpn) => vpn.region === options.region)
236
+ if (options.location) {
237
+ vpns = vpns.filter((vpn: vpnlib.Vpn) => vpn.geonamesId === options.geonameId)
254
238
  }
255
239
  if (options.includeState) {
256
240
  vpns = vpns.filter((vpn: vpnlib.Vpn) => options.includeState.includes(vpn.state))
@@ -382,11 +366,11 @@ Examples:
382
366
 
383
367
  # Then you can use the following command at will:
384
368
 
385
- # List available regions:
386
- $ mytmpvpn list-regions
369
+ # List available locations:
370
+ $ mytmpvpn list-locations
387
371
 
388
372
  # Create a new vpn in Paris:
389
- $ mytmpvpn create 'paris' --sync # This takes several minutes, please be patient or remove --sync
373
+ $ mytmpvpn create '2988507' --sync # This takes several minutes, please be patient or remove --sync
390
374
 
391
375
  # List all my vpns:
392
376
  $ mytmpvpn list