un-cli 0.0.80 → 0.0.81

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/cmd.txt CHANGED
@@ -1,2 +1,3 @@
1
1
  reconcile --version U136967.MigrateTransm
2
+ update subnetworks --all
2
3
  exit
package/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { AdminLog } from "./adminlog.mjs"
7
7
  import logger from "./logger.mjs"
8
8
  import fetch from "node-fetch"
9
9
  //update version
10
- let version = "0.0.80";
10
+ let version = "0.0.81";
11
11
  const GENERATE_TOKEN_TIME_MIN = 30;
12
12
 
13
13
  let rl = null;
@@ -27,7 +27,8 @@ function parseInput(){
27
27
  "--gdbversion",
28
28
  "--file",
29
29
  "--verify",
30
- "--server"
30
+ "--server",
31
+ "--proxy"
31
32
  ]
32
33
 
33
34
  //null marked parmaters are required
@@ -40,7 +41,8 @@ function parseInput(){
40
41
  "gdbversion": "SDE.DEFAULT",
41
42
  "file": "",
42
43
  "verify": "true",
43
- "server": undefined
44
+ "server": undefined,
45
+ "proxy": undefined
44
46
  }
45
47
 
46
48
  for (let i = 0; i < process.argv.length ; i++){
@@ -53,7 +55,7 @@ function parseInput(){
53
55
 
54
56
  if (Object.values(params).includes(null))
55
57
  {
56
- logger.info ("HELP: uncli --portal https://unportal.domain.com/portal --service servicename --user username --password password [--gdbversion* user.version --server https://federatedserver.domain.com/server --file commandfile* --verify true|false]")
58
+ logger.info ("HELP: uncli --portal https://unportal.domain.com/portal --service servicename --user username --password password [--gdbversion* user.version --server https://federatedserver.domain.com/server --file commandfile* --verify true|false] --proxy http://proxyurl:port")
57
59
  logger.info("--file commandfile is optional and you can pass a path to a file with a list of command to execute. ")
58
60
  logger.info("--gdbversion is optional and allows the UN to be opened in that version. When not specified sde.DEFAULT is used.")
59
61
  logger.info("--server is optional except when there are more than one federated server sites to the portal. If the portal only has one server it will be selected.")
@@ -176,6 +178,9 @@ const inputs = {
176
178
  "export subnetworks --deleted": "Export all subnetworks with ACK that are deleted ",
177
179
  "updateisconnected": "Run update is connected ",
178
180
  "versions": "List all versions available to the current logged in user.",
181
+ "reconcile --version <version name>": "Reconcile the input version synchronously",
182
+ "reconcile --all": "Reconcile all versions available to the current user synchronously",
183
+ "reconcile --all --async": "Reconcile all versions available to the current user asynchronously",
179
184
  "count": "Lists the number of rows in all feature layers and tables.",
180
185
  "count --system": "Lists the number of rows in system layers.",
181
186
  "connect --service": "Connects to the another service",
@@ -1519,7 +1524,16 @@ export async function run (){
1519
1524
  parameters = await parseInput( )
1520
1525
  //set certificate verification
1521
1526
  const verifyCert = parameters["verify"] === 'true' ? 1 : 0;
1527
+ const proxy = parameters["proxy"]
1522
1528
  process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = verifyCert;
1529
+
1530
+ if (proxy){
1531
+ logger.info(`Using proxy ${proxy}`);
1532
+ process.env['HTTPS_PROXY'] = proxy;
1533
+ }
1534
+
1535
+
1536
+
1523
1537
  setTimeout( async ()=> await regenerateToken(parameters) , 1000*60*GENERATE_TOKEN_TIME_MIN)
1524
1538
  await connect(parameters)
1525
1539
  }
package/makerequest.mjs CHANGED
@@ -1,6 +1,5 @@
1
-
2
-
3
1
 
2
+
4
3
  export function makeRequest (opts) {
5
4
 
6
5
  return new Promise(async function (resolve, reject) {
@@ -23,26 +22,43 @@ export function makeRequest (opts) {
23
22
 
24
23
  if (opts.headers)
25
24
  Object.keys(opts.headers).forEach( key => headers[key] = opts.headers[key] )
26
-
27
- //console.log(opts)
28
-
25
+
26
+ let jsonRes
27
+ let agent;
29
28
  let f;
29
+
30
30
  try {
31
-
31
+
32
32
  let nodeFetch = await import ("node-fetch");
33
33
  f = nodeFetch.default;
34
34
  }
35
35
  catch(ex) {
36
36
  f = fetch;
37
+ }
38
+ //set a proxy if one exists
39
+
40
+ if (process.env['HTTPS_PROXY'])
41
+ {
42
+ try {
43
+ const HttpsProxyAgent = await import ('https-proxy-agent')
44
+ agent = new HttpsProxyAgent.HttpsProxyAgent(process.env['HTTPS_PROXY'])
45
+ }
46
+ catch (ex){
47
+ agent = undefined;
48
+ }
49
+
50
+ }
51
+
52
+ const options = {
53
+ "method" : opts.method,
54
+ "headers": headers,
55
+ "body": params
37
56
  }
38
-
39
- let jsonRes
40
-
41
- const result = await f(opts.url, {
42
- "method" : opts.method,
43
- "headers": headers,
44
- "body": params
45
- });
57
+
58
+ if (agent)
59
+ options.agent = agent;
60
+
61
+ const result = await f(opts.url,options);
46
62
 
47
63
  jsonRes = await result.json();
48
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "un-cli",
3
- "version": "0.0.80",
3
+ "version": "0.0.81",
4
4
  "description": "Command line interface for working with ArcGIS Utility Network Extension",
5
5
  "main": "index.mjs",
6
6
  "bin": {
@@ -17,6 +17,7 @@
17
17
  "author": "Hussein Nasser",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
+ "https-proxy-agent": "^7.0.6",
20
21
  "node-fetch": "^2.6.0"
21
22
  }
22
23
  }
package/un.mjs CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node --experimental-modules
2
-
3
- import {run} from "./index.mjs"
1
+ #!/usr/bin/env node --experimental-modules
2
+
3
+ import {run} from "./index.mjs"
4
4
  run();