@infisical/cli 0.41.90 → 0.41.91
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/infisical-cli-0.41.91.tgz +0 -0
- package/package.json +1 -1
- package/src/index.cjs +151 -141
- package/infisical-cli-0.41.90.tgz +0 -0
|
Binary file
|
package/package.json
CHANGED
package/src/index.cjs
CHANGED
|
@@ -12,155 +12,165 @@ const supportedPlatforms = ["linux", "darwin", "win32", "freebsd", "windows"];
|
|
|
12
12
|
const outputDir = "bin";
|
|
13
13
|
|
|
14
14
|
const getPlatform = () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
let platform = process.platform;
|
|
16
|
+
|
|
17
|
+
if (platform === "win32") {
|
|
18
|
+
platform = "windows";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!supportedPlatforms.includes(platform)) {
|
|
22
|
+
console.error(
|
|
23
|
+
"Your platform doesn't seem to be of type darwin, linux or windows"
|
|
24
|
+
);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
return platform;
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
const getArchitecture = () => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
31
|
+
const architecture = process.arch;
|
|
32
|
+
let arch = "";
|
|
33
|
+
|
|
34
|
+
if (architecture === "x64" || architecture === "amd64") {
|
|
35
|
+
arch = "amd64";
|
|
36
|
+
} else if (architecture === "arm64") {
|
|
37
|
+
arch = "arm64";
|
|
38
|
+
} else if (architecture === "arm") {
|
|
39
|
+
// If the platform is Linux, we should find the exact ARM version, otherwise we default to armv7 which is the most common
|
|
40
|
+
if (process.platform === "linux" || process.platform === "freebsd") {
|
|
41
|
+
const output = childProcess.execSync("uname -m").toString().trim();
|
|
42
|
+
|
|
43
|
+
const armVersions = ["armv5", "armv6", "armv7"];
|
|
44
|
+
|
|
45
|
+
const armVersion = armVersions.find((version) =>
|
|
46
|
+
output.startsWith(version)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
if (armVersion) {
|
|
50
|
+
arch = armVersion;
|
|
51
|
+
} else {
|
|
52
|
+
arch = "armv7";
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
arch = "armv7";
|
|
56
|
+
}
|
|
57
|
+
} else if (architecture === "ia32") {
|
|
58
|
+
arch = "i386";
|
|
59
|
+
} else {
|
|
60
|
+
console.error(
|
|
61
|
+
"Your architecture doesn't seem to be supported. Your architecture is",
|
|
62
|
+
architecture
|
|
63
|
+
);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return arch;
|
|
61
68
|
};
|
|
62
69
|
|
|
63
70
|
async function extractZip(buffer, targetPath) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
yauzl.fromBuffer(buffer, { lazyEntries: true }, (err, zipfile) => {
|
|
73
|
+
if (err) return reject(err);
|
|
74
|
+
|
|
75
|
+
zipfile.readEntry();
|
|
76
|
+
zipfile.on("entry", (entry) => {
|
|
77
|
+
const isExecutable =
|
|
78
|
+
entry.fileName === "infisical" || entry.fileName === "infisical.exe";
|
|
79
|
+
|
|
80
|
+
if (/\/$/.test(entry.fileName) || !isExecutable) {
|
|
81
|
+
// Directory entry
|
|
82
|
+
zipfile.readEntry();
|
|
83
|
+
} else {
|
|
84
|
+
// File entry
|
|
85
|
+
zipfile.openReadStream(entry, (err, readStream) => {
|
|
86
|
+
if (err) return reject(err);
|
|
87
|
+
|
|
88
|
+
let fileName = entry.fileName;
|
|
89
|
+
|
|
90
|
+
if (entry.fileName.endsWith(".exe")) {
|
|
91
|
+
fileName = "infisical.exe";
|
|
92
|
+
} else if (entry.fileName.includes("infisical")) {
|
|
93
|
+
fileName = "infisical";
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const outputPath = path.join(targetPath, fileName);
|
|
97
|
+
const writeStream = fs.createWriteStream(outputPath);
|
|
98
|
+
|
|
99
|
+
readStream.pipe(writeStream);
|
|
100
|
+
writeStream.on("close", () => {
|
|
101
|
+
zipfile.readEntry();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
zipfile.on("end", resolve);
|
|
108
|
+
zipfile.on("error", reject);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
async function main() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
114
|
+
const PLATFORM = getPlatform();
|
|
115
|
+
const ARCH = getArchitecture();
|
|
116
|
+
const NUMERIC_RELEASE_VERSION = packageJSON.version;
|
|
117
|
+
const LATEST_RELEASE_VERSION = `v${NUMERIC_RELEASE_VERSION}`;
|
|
118
|
+
const EXTENSION = PLATFORM === "windows" ? "zip" : "tar.gz";
|
|
119
|
+
const downloadLink = `https://github.com/Infisical/cli/releases/download/${LATEST_RELEASE_VERSION}/cli_${NUMERIC_RELEASE_VERSION}_${PLATFORM}_${ARCH}.${EXTENSION}`;
|
|
120
|
+
|
|
121
|
+
// Ensure the output directory exists
|
|
122
|
+
if (!fs.existsSync(outputDir)) {
|
|
123
|
+
fs.mkdirSync(outputDir);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Download the latest CLI binary
|
|
127
|
+
try {
|
|
128
|
+
const response = await fetch(downloadLink, {
|
|
129
|
+
headers: {
|
|
130
|
+
Accept: "application/octet-stream",
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if (!response.ok) {
|
|
135
|
+
throw new Error(
|
|
136
|
+
`Failed to fetch: ${response.status} - ${response.statusText}`
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (EXTENSION === "zip") {
|
|
141
|
+
// For ZIP files, we need to buffer the whole thing first
|
|
142
|
+
const buffer = await response.arrayBuffer();
|
|
143
|
+
await extractZip(Buffer.from(buffer), outputDir);
|
|
144
|
+
} else {
|
|
145
|
+
// For tar.gz files, we stream
|
|
146
|
+
await new Promise((resolve, reject) => {
|
|
147
|
+
const outStream = stream.Readable.fromWeb(response.body)
|
|
148
|
+
.pipe(zlib.createGunzip())
|
|
149
|
+
.pipe(
|
|
150
|
+
tar.x({
|
|
151
|
+
C: path.join(outputDir),
|
|
152
|
+
filter: (path) => path === "infisical",
|
|
153
|
+
})
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
outStream.on("error", reject);
|
|
157
|
+
outStream.on("close", resolve);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Platform-specific tasks
|
|
162
|
+
if (PLATFORM === "windows") {
|
|
163
|
+
// We create an empty file called 'infisical'. This file has no functionality, except allowing NPM to correctly create the symlink.
|
|
164
|
+
// Reason why this doesn't work without the empty file, is because the files downloaded are a .ps1, .exe, and .cmd file. None of these match the binary name from the package.json['bin'] field.
|
|
165
|
+
// This is a bit hacky, but it assures that the symlink is correctly created.
|
|
166
|
+
fs.closeSync(fs.openSync(path.join(outputDir, "infisical"), "w"));
|
|
167
|
+
} else {
|
|
168
|
+
// Unix systems only need chmod
|
|
169
|
+
fs.chmodSync(path.join(outputDir, "infisical"), "755");
|
|
170
|
+
}
|
|
171
|
+
} catch (error) {
|
|
172
|
+
console.error("Error downloading or extracting Infisical CLI:", error);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
165
175
|
}
|
|
166
176
|
main();
|
|
Binary file
|