@infisical/cli 0.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/.eslintrc.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "env": {
3
+ "es6": true,
4
+ "node": true
5
+ },
6
+ "parserOptions": {
7
+ "ecmaVersion": "latest"
8
+ }
9
+ }
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ <h1 align="center">Infisical</h1>
2
+ <p align="center">
3
+ <p align="center"><b>The open-source secret management platform</b>: Sync secrets/configs across your team/infrastructure and prevent secret leaks.</p>
4
+ </p>
5
+
6
+ <h4 align="center">
7
+ <a href="https://infisical.com/slack">Slack</a> |
8
+ <a href="https://infisical.com/">Infisical Cloud</a> |
9
+ <a href="https://infisical.com/docs/self-hosting/overview">Self-Hosting</a> |
10
+ <a href="https://infisical.com/docs/documentation/getting-started/introduction">Docs</a> |
11
+ <a href="https://www.infisical.com">Website</a> |
12
+ <a href="https://infisical.com/careers">Hiring (Remote/SF)</a>
13
+ </h4>
14
+
15
+
16
+ <h4 align="center">
17
+ <a href="https://github.com/Infisical/infisical/blob/main/LICENSE">
18
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Infisical is released under the MIT license." />
19
+ </a>
20
+ <a href="https://github.com/infisical/infisical/blob/main/CONTRIBUTING.md">
21
+ <img src="https://img.shields.io/badge/PRs-Welcome-brightgreen" alt="PRs welcome!" />
22
+ </a>
23
+ <a href="https://github.com/Infisical/infisical/issues">
24
+ <img src="https://img.shields.io/github/commit-activity/m/infisical/infisical" alt="git commit activity" />
25
+ </a>
26
+ <a href="https://cloudsmith.io/~infisical/repos/">
27
+ <img src="https://img.shields.io/badge/Downloads-6.95M-orange" alt="Cloudsmith downloads" />
28
+ </a>
29
+ <a href="https://infisical.com/slack">
30
+ <img src="https://img.shields.io/badge/chat-on%20Slack-blueviolet" alt="Slack community channel" />
31
+ </a>
32
+ <a href="https://twitter.com/infisical">
33
+ <img src="https://img.shields.io/twitter/follow/infisical?label=Follow" alt="Infisical Twitter" />
34
+ </a>
35
+ </h4>
36
+
37
+ ### Introduction
38
+
39
+ **[Infisical](https://infisical.com)** is the open source secret management platform that teams use to centralize their application configuration and secrets like API keys and database credentials as well as manage their internal PKI.
40
+
41
+ We're on a mission to make security tooling more accessible to everyone, not just security teams, and that means redesigning the entire developer experience from ground up.
42
+
43
+
44
+ ### Installation
45
+
46
+ The Infisical CLI NPM package serves as a new installation method in addition to our [existing installation methods](https://infisical.com/docs/cli/overview).
47
+
48
+ After installing the CLI with the command below, you'll be able to use the infisical CLI across your machine.
49
+
50
+ ```bash
51
+ $ npm install -g @infisical/cli
52
+ ```
53
+
54
+ Full example:
55
+ ```bash
56
+ # Install the Infisical CLI
57
+ $ npm install -g @infisical/cli
58
+
59
+ # Authenticate with the Infisical CLI
60
+ $ infisical login
61
+
62
+ # Initialize your Infisical CLI
63
+ $ infisical init
64
+
65
+ # List your secrets with Infisical CLI
66
+ $ infisical secrets
67
+ ```
68
+
69
+
70
+ ### Documentation
71
+ Our full CLI documentation can be found [here](https://infisical.com/docs/cli/usage).
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@infisical/cli",
3
+ "private": false,
4
+ "version": "0.0.0",
5
+ "keywords": [
6
+ "infisical",
7
+ "cli",
8
+ "command-line"
9
+ ],
10
+ "bin": {
11
+ "infisical": "bin/infisical"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/Infisical/infisical.git"
16
+ },
17
+ "author": "Infisical Inc, <daniel@infisical.com>",
18
+ "scripts": {
19
+ "postinstall": "node src/index.cjs"
20
+ },
21
+ "dependencies": {
22
+ "tar": "^6.2.0"
23
+ }
24
+ }
package/src/index.cjs ADDED
@@ -0,0 +1,103 @@
1
+ const childProcess = require("child_process");
2
+ const fs = require("fs");
3
+ const stream = require("node:stream");
4
+ const tar = require("tar");
5
+ const path = require("path");
6
+ const zlib = require("zlib");
7
+ const packageJSON = require("../package.json");
8
+
9
+ const supportedPlatforms = ["linux", "darwin", "win32", "freebsd"];
10
+ const outputDir = "bin";
11
+
12
+ const getPlatform = () => {
13
+ const platform = process.platform;
14
+ if (!supportedPlatforms.includes(platform)) {
15
+ console.error("Your platform doesn't seem to be of type darwin, linux or windows");
16
+ process.exit(1);
17
+ }
18
+ return platform;
19
+ };
20
+
21
+ const getArchitecture = () => {
22
+ const architecture = process.arch;
23
+ let arch = "";
24
+
25
+ if (architecture === "x64" || architecture === "amd64") {
26
+ arch = "amd64";
27
+ } else if (architecture === "arm64") {
28
+ arch = "arm64";
29
+ } else if (architecture === "arm") {
30
+ // If the platform is Linux, we should find the exact ARM version, otherwise we default to armv7 which is the most common
31
+ if (process.platform === "linux" || process.platform === "freebsd") {
32
+ const output = childProcess.execSync("uname -m").toString().trim();
33
+
34
+ const armVersions = ["armv5", "armv6", "armv7"];
35
+
36
+ const armVersion = armVersions.find(version => output.startsWith(version));
37
+
38
+ if (armVersion) {
39
+ arch = armVersion;
40
+ } else {
41
+ arch = "armv7";
42
+ }
43
+ } else {
44
+ arch = "armv7";
45
+ }
46
+ } else if (architecture === "ia32") {
47
+ arch = "i386";
48
+ } else {
49
+ console.error("Your architecture doesn't seem to be supported. Your architecture is", architecture);
50
+ process.exit(1);
51
+ }
52
+
53
+ return arch;
54
+ };
55
+
56
+ async function main() {
57
+ const PLATFORM = getPlatform();
58
+ const ARCH = getArchitecture();
59
+ const NUMERIC_RELEASE_VERSION = packageJSON.version;
60
+ const LATEST_RELEASE_VERSION = `v${NUMERIC_RELEASE_VERSION}`;
61
+ const downloadLink = `https://github.com/Infisical/infisical/releases/download/infisical-cli/${LATEST_RELEASE_VERSION}/infisical_${NUMERIC_RELEASE_VERSION}_${PLATFORM}_${ARCH}.tar.gz`;
62
+
63
+ // Ensure the output directory exists
64
+ if (!fs.existsSync(outputDir)) {
65
+ fs.mkdirSync(outputDir);
66
+ }
67
+
68
+ // Download the latest CLI binary
69
+ try {
70
+ const response = await fetch(downloadLink, {
71
+ headers: {
72
+ Accept: "application/octet-stream"
73
+ }
74
+ });
75
+
76
+ if (!response.ok) {
77
+ throw new Error(`Failed to fetch: ${response.status} - ${response.statusText}`);
78
+ }
79
+
80
+ await new Promise((resolve, reject) => {
81
+ const outStream = stream.Readable.fromWeb(response.body)
82
+ .pipe(zlib.createGunzip())
83
+ .pipe(
84
+ tar.x({
85
+ C: path.join(outputDir),
86
+ filter: path => path === "infisical"
87
+ })
88
+ );
89
+
90
+ outStream.on("error", reject);
91
+ outStream.on("close", resolve);
92
+ });
93
+
94
+ // Give the binary execute permissions if we're not on Windows
95
+ if (PLATFORM !== "win32") {
96
+ fs.chmodSync(path.join(outputDir, "infisical"), "755");
97
+ }
98
+ } catch (error) {
99
+ console.error("Error downloading or extracting Infisical CLI:", error);
100
+ process.exit(1);
101
+ }
102
+ }
103
+ main();