jfrog-cli-v2 2.48.0 → 2.49.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/bin/{jfrog → _} RENAMED
File without changes
package/init.js CHANGED
@@ -1,66 +1,91 @@
1
1
  validateNpmVersion();
2
2
 
3
- var https = require('https');
4
- var http = require('http');
5
- var url = require('url');
6
- var fs = require('fs');
7
- var packageJson = require('./package.json');
8
- var fileName = getFileName();
9
- var filePath = "bin/" + fileName;
10
- var version = packageJson.version;
11
- var pkgName = "jfrog-cli-" + getArchitecture();
3
+ const {get} = require("https");
4
+ const {request} = require("http");
5
+ const {URL} = require("url");
6
+ const {createWriteStream, chmodSync} = require("fs");
7
+ const packageJson = require("./package.json");
8
+ const fileName = getFileName();
9
+ const filePath = "bin/" + fileName;
10
+ const version = packageJson.version;
11
+ const pkgName = "jfrog-cli-" + getArchitecture();
12
12
 
13
13
  downloadCli();
14
14
 
15
15
  function validateNpmVersion() {
16
16
  if (!isValidNpmVersion()) {
17
- throw new Error("JFrog CLI can be installed using npm version 5.0.0 or above.");
17
+ throw new Error(
18
+ "JFrog CLI can be installed using npm version 5.0.0 or above."
19
+ );
18
20
  }
19
21
  }
20
22
 
21
23
  function downloadWithProxy(myUrl) {
22
- var proxyparts = url.parse(process.env.https_proxy);
23
- var myUrlParts = url.parse(myUrl);
24
+ const proxyParts = new URL(process.env.https_proxy);
25
+ const myUrlParts = new URL(myUrl);
24
26
 
25
- http.request({
27
+ request({
26
28
  host: proxyparts.hostname,
27
29
  port: proxyparts.port,
28
- method: 'CONNECT',
29
- path: myUrlParts.hostname + ':443'
30
- }).on('connect', function(res, socket, head) {
31
- https.get({
32
- host: myUrlParts.hostname,
33
- socket: socket,
34
- path: myUrlParts.path,
35
- agent: false
36
- }, function(res) {
37
- if (res.statusCode == 301 || res.statusCode == 302) {
38
- downloadWithProxy(res.headers.location);
39
- } else if (res.statusCode == 200) {
40
- writeToFile(res);
41
- } else {
42
- console.log('Unexpected status code ' + res.statusCode + ' during JFrog CLI download');
43
- }
44
- }).on('error', function (err) {console.error(err);});
45
- }).end();
30
+ method: "CONNECT",
31
+ path: myUrlParts.hostname + ":443",
32
+ })
33
+ .on("connect", function (res, socket, head) {
34
+ get(
35
+ {
36
+ host: myUrlParts.hostname,
37
+ socket: socket,
38
+ path: myUrlParts.path,
39
+ agent: false,
40
+ },
41
+ function (res) {
42
+ if (res.statusCode === 301 || res.statusCode === 302) {
43
+ downloadWithProxy(res.headers.location);
44
+ } else if (res.statusCode === 200) {
45
+ writeToFile(res);
46
+ } else {
47
+ console.log(
48
+ "Unexpected status code " +
49
+ res.statusCode +
50
+ " during JFrog CLI download"
51
+ );
52
+ }
53
+ }
54
+ ).on("error", function (err) {
55
+ console.error(err);
56
+ });
57
+ })
58
+ .end();
46
59
  }
47
60
 
48
61
  function download(url) {
49
- https.get(url, function(res) {
50
- if (res.statusCode == 301 || res.statusCode == 302) {
62
+ get(url, function (res) {
63
+ if (res.statusCode === 301 || res.statusCode === 302) {
51
64
  download(res.headers.location);
52
- } else if (res.statusCode == 200) {
65
+ } else if (res.statusCode === 200) {
53
66
  writeToFile(res);
54
67
  } else {
55
- console.log('Unexpected status code ' + res.statusCode + ' during JFrog CLI download');
68
+ console.log(
69
+ "Unexpected status code " +
70
+ res.statusCode +
71
+ " during JFrog CLI download"
72
+ );
56
73
  }
57
- }).on('error', function (err) {console.error(err);});
74
+ }).on("error", function (err) {
75
+ console.error(err);
76
+ });
58
77
  }
59
78
 
60
79
  function downloadCli() {
61
- console.log("Downloading JFrog CLI " + version );
62
- var startUrl = 'https://releases.jfrog.io/artifactory/jfrog-cli/v2/' + version + '/' + pkgName + '/' + fileName;
63
- // We detect outbount proxy by looking at the environment variable
80
+ console.log("Downloading JFrog CLI " + version);
81
+ const startUrl =
82
+ "https://releases.jfrog.io/artifactory/jfrog-cli/v2/" +
83
+ version +
84
+ "/" +
85
+ pkgName +
86
+ "/" +
87
+ fileName;
88
+ // We detect outbound proxy by looking at the environment variable
64
89
  if (process.env.https_proxy && process.env.https_proxy.length > 0) {
65
90
  downloadWithProxy(startUrl);
66
91
  } else {
@@ -69,58 +94,61 @@ function downloadCli() {
69
94
  }
70
95
 
71
96
  function isValidNpmVersion() {
72
- var child_process = require('child_process');
73
- var npmVersionCmdOut = child_process.execSync("npm version -json");
74
- var npmVersion = JSON.parse(npmVersionCmdOut).npm;
97
+ const child_process = require("child_process");
98
+ const npmVersionCmdOut = child_process.execSync("npm version -json");
99
+ const npmVersion = JSON.parse(npmVersionCmdOut).npm;
75
100
  // Supported since version 5.0.0
76
101
  return parseInt(npmVersion.charAt(0)) > 4;
77
102
  }
78
103
 
79
104
  function writeToFile(response) {
80
- var file = fs.createWriteStream(filePath);
81
- response.on('data', function (chunk) {
82
- file.write(chunk);
83
- }).on('end', function () {
84
- file.end();
85
- if (!process.platform.startsWith("win")) {
86
- fs.chmodSync(filePath, 0555);
87
- }
88
- }).on('error', function (err) {
89
- console.error(err);
105
+ const file = createWriteStream(filePath);
106
+ response
107
+ .on("data", function (chunk) {
108
+ file.write(chunk);
109
+ })
110
+ .on("end", function () {
111
+ file.end();
112
+ if (!process.platform.startsWith("win")) {
113
+ chmodSync(filePath, 755);
114
+ }
115
+ })
116
+ .on("error", function (err) {
117
+ console.error(err);
90
118
  });
91
119
  }
92
120
 
93
121
  function getArchitecture() {
94
122
  const platform = process.platform;
95
- if (platform.startsWith('win')) {
123
+ if (platform.startsWith("win")) {
96
124
  // Windows architecture:
97
- return 'windows-amd64';
125
+ return "windows-amd64";
98
126
  }
99
127
  const arch = process.arch;
100
- if (platform.includes('darwin')) {
128
+ if (platform.includes("darwin")) {
101
129
  // macOS architecture:
102
- return arch === 'arm64' ? 'mac-arm64' : 'mac-386';
130
+ return arch === "arm64" ? "mac-arm64" : "mac-386";
103
131
  }
104
132
 
105
133
  // linux architecture:
106
134
  switch (arch) {
107
- case 'x64':
108
- return 'linux-amd64';
109
- case 'arm64':
110
- return 'linux-arm64';
111
- case 'arm':
112
- return 'linux-arm';
113
- case 's390x':
114
- return 'linux-s390x';
115
- case 'ppc64':
116
- return 'linux-ppc64';
135
+ case "x64":
136
+ return "linux-amd64";
137
+ case "arm64":
138
+ return "linux-arm64";
139
+ case "arm":
140
+ return "linux-arm";
141
+ case "s390x":
142
+ return "linux-s390x";
143
+ case "ppc64":
144
+ return "linux-ppc64";
117
145
  default:
118
- return 'linux-386';
146
+ return "linux-386";
119
147
  }
120
148
  }
121
149
 
122
150
  function getFileName() {
123
- var executable = "jfrog";
151
+ let executable = "jfrog";
124
152
  if (process.platform.startsWith("win")) {
125
153
  executable += ".exe";
126
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jfrog-cli-v2",
3
- "version": "2.48.0",
3
+ "version": "2.49.0",
4
4
  "description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
5
5
  "homepage": "https://github.com/jfrog/jfrog-cli",
6
6
  "preferGlobal": true,