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 → _} +0 -0
- package/init.js +96 -68
- package/package.json +1 -1
package/bin/{jfrog → _}
RENAMED
|
File without changes
|
package/init.js
CHANGED
|
@@ -1,66 +1,91 @@
|
|
|
1
1
|
validateNpmVersion();
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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(
|
|
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
|
-
|
|
23
|
-
|
|
24
|
+
const proxyParts = new URL(process.env.https_proxy);
|
|
25
|
+
const myUrlParts = new URL(myUrl);
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
request({
|
|
26
28
|
host: proxyparts.hostname,
|
|
27
29
|
port: proxyparts.port,
|
|
28
|
-
method:
|
|
29
|
-
path: myUrlParts.hostname +
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
50
|
-
if (res.statusCode
|
|
62
|
+
get(url, function (res) {
|
|
63
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
51
64
|
download(res.headers.location);
|
|
52
|
-
} else if (res.statusCode
|
|
65
|
+
} else if (res.statusCode === 200) {
|
|
53
66
|
writeToFile(res);
|
|
54
67
|
} else {
|
|
55
|
-
console.log(
|
|
68
|
+
console.log(
|
|
69
|
+
"Unexpected status code " +
|
|
70
|
+
res.statusCode +
|
|
71
|
+
" during JFrog CLI download"
|
|
72
|
+
);
|
|
56
73
|
}
|
|
57
|
-
}).on(
|
|
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
|
-
|
|
63
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
81
|
-
response
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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(
|
|
123
|
+
if (platform.startsWith("win")) {
|
|
96
124
|
// Windows architecture:
|
|
97
|
-
return
|
|
125
|
+
return "windows-amd64";
|
|
98
126
|
}
|
|
99
127
|
const arch = process.arch;
|
|
100
|
-
if (platform.includes(
|
|
128
|
+
if (platform.includes("darwin")) {
|
|
101
129
|
// macOS architecture:
|
|
102
|
-
return arch ===
|
|
130
|
+
return arch === "arm64" ? "mac-arm64" : "mac-386";
|
|
103
131
|
}
|
|
104
132
|
|
|
105
133
|
// linux architecture:
|
|
106
134
|
switch (arch) {
|
|
107
|
-
case
|
|
108
|
-
return
|
|
109
|
-
case
|
|
110
|
-
return
|
|
111
|
-
case
|
|
112
|
-
return
|
|
113
|
-
case
|
|
114
|
-
return
|
|
115
|
-
case
|
|
116
|
-
return
|
|
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
|
|
146
|
+
return "linux-386";
|
|
119
147
|
}
|
|
120
148
|
}
|
|
121
149
|
|
|
122
150
|
function getFileName() {
|
|
123
|
-
|
|
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.
|
|
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,
|