@railway/cli 2.1.0 → 3.0.5

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Railway Corp.
3
+ Copyright (c) 2023 Railway Corp.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,57 +1,52 @@
1
1
  # Railway CLI
2
2
 
3
- ![Build](https://github.com/railwayapp/cli/workflows/Build/badge.svg)
3
+ [![CI](https://github.com/railwayapp/cli/actions/workflows/ci.yml/badge.svg)](https://github.com/railwayapp/cliv3/actions/workflows/ci.yml)
4
4
 
5
- This is the command line interface for [Railway](https://railway.app). Use it to connect your code to Railways infrastructure without needing to worry about environment variables or configuration.
5
+ This is the command line interface for [Railway](https://railway.app). Use it to connect your code to Railway's infrastructure without needing to worry about environment variables or configuration.
6
6
 
7
7
  [View the docs](https://docs.railway.app/develop/cli)
8
8
 
9
- ## Installation
9
+ The Railway command line interface (CLI) connects your code to your Railway project from the command line.
10
10
 
11
- The Railway CLI is available through [Homebrew](https://brew.sh/), [NPM](https://www.npmjs.com/package/@railway/cli), curl, or as a [Nixpkg](https://nixos.org).
11
+ The Railway CLI allows you to
12
12
 
13
- ### Brew
13
+ - Create new Railway projects from the terminal
14
+ - Link to an existing Railway project
15
+ - Pull down environment variables for your project locally to run
16
+ - Create services and databases right from the comfort of your fingertips
17
+ ## Status
18
+ Currently pre-release. We are looking for feedback and suggestions. Please join our [Discord](https://discord.gg/railway) to provide feedback.
14
19
 
15
- ```shell
16
- brew install railway
20
+ ## Installation
21
+ ### Cargo
22
+ ```bash
23
+ cargo install railwayapp --locked
17
24
  ```
25
+ ### Homebrew
18
26
 
19
- ### NPM
20
-
21
- ```shell
22
- npm i -g @railway/cli
27
+ ```bash
28
+ brew tap railwayapp/tap
29
+ brew install rlwy
23
30
  ```
24
31
 
25
- ### Yarn
26
-
27
- ```shell
28
- yarn global add @railway/cli
32
+ ### NPM
33
+ ```bash
34
+ npm install -g @railway/cli
29
35
  ```
30
-
31
- ### curl
32
-
33
- ```shell
34
- curl -fsSL https://railway.app/install.sh | sh
36
+ ### Bash
37
+ ```bash
38
+ curl -fsSL https://cli.new | sh
35
39
  ```
36
40
 
37
- ### Nixpkg
38
- Note: This installation method is not supported by Railway and is maintained by the community.
39
- ```shell
40
- # On NixOS
41
- nix-env -iA nixos.railway
42
- # On non-NixOS
43
- nix-env -iA nixpkgs.railway
44
- ```
45
41
 
46
42
  ### From source
47
43
  See [CONTRIBUTING.md](https://github.com/railwayapp/cli/blob/master/CONTRIBUTING.md) for information on setting up this repo locally.
48
44
 
49
45
  ## Documentation
50
-
51
46
  [View the full documentation](https://docs.railway.app)
52
47
 
53
48
  ## Feedback
54
49
 
55
- We would love to hear your feedback or suggestions. The best way to reach us is on [Discord](https://discord.gg/xAm2w6g).
50
+ We would love to hear your feedback or suggestions. The best way to reach us is on [Discord](https://discord.gg/railway).
56
51
 
57
52
  We also welcome pull requests into this repo. See [CONTRIBUTING.md](https://github.com/railwayapp/cli/blob/master/CONTRIBUTING.md) for information on setting up this repo locally.
package/bin/railway.js CHANGED
@@ -8,10 +8,9 @@ const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
9
9
 
10
10
  try {
11
- execFileSync(path.resolve(`${__dirname}/railway`), process.argv.slice(2), {
12
- stdio: "inherit",
13
- });
11
+ execFileSync(path.resolve(`${__dirname}/railway`), process.argv.slice(2), {
12
+ stdio: "inherit",
13
+ });
14
14
  } catch (e) {
15
- exit(1)
15
+ exit(1);
16
16
  }
17
-
@@ -2,46 +2,27 @@
2
2
  * Global configuration
3
3
  */
4
4
  export const CONFIG = {
5
- /**
6
- * The name of the binary
7
- * @type {string}
8
- */
9
- name: "railway",
5
+ /**
6
+ * The name of the binary
7
+ * @type {string}
8
+ */
9
+ name: "railway",
10
10
 
11
- /**
12
- * Where to save the unzipped files
13
- * @type {string}
14
- */
15
- path: "./bin",
11
+ /**
12
+ * Where to save the unzipped files
13
+ * @type {string}
14
+ */
15
+ path: "./bin",
16
16
 
17
- /**
18
- * The URL to download the binary form
19
- *
20
- * - `{{arch}}` is one of the Golang achitectures listed below
21
- * - `{{bin_name}}` is the name declared above
22
- * - `{{platform}}` is one of the Golang platforms listed below
23
- * - `{{version}}` is the version number as `0.0.0` (taken from package.json)
24
- *
25
- * @type {string}
26
- */
27
- url: "https://github.com/railwayapp/cli/releases/download/v{{version}}/{{bin_name}}_{{version}}_{{platform}}_{{arch}}.tar.gz",
28
- };
29
-
30
- /**
31
- * Mapping from Node's `process.arch` to Golang's `$GOARCH`
32
- */
33
- export const ARCH_MAPPING = {
34
- ia32: "386",
35
- x64: "amd64",
36
- arm64: "arm64",
37
- };
38
-
39
- /**
40
- * Mapping between Node's `process.platform` to Golang's
41
- */
42
- export const PLATFORM_MAPPING = {
43
- darwin: "darwin",
44
- linux: "linux",
45
- win32: "windows",
46
- // freebsd: "freebsd",
17
+ /**
18
+ * The URL to download the binary form
19
+ *
20
+ * - `{{arch}}` is one of the Golang achitectures listed below
21
+ * - `{{bin_name}}` is the name declared above
22
+ * - `{{platform}}` is one of the Golang platforms listed below
23
+ * - `{{version}}` is the version number as `0.0.0` (taken from package.json)
24
+ *
25
+ * @type {string}
26
+ */
27
+ url: "https://github.com/railwayapp/cli/releases/download/v{{version}}/{{bin_name}}-v{{version}}-{{triple}}.tar.gz",
47
28
  };
@@ -1,56 +1,47 @@
1
+ import triples from "@napi-rs/triples";
1
2
  import { createWriteStream } from "fs";
2
3
  import * as fs from "fs/promises";
3
4
  import fetch from "node-fetch";
4
5
  import { pipeline } from "stream/promises";
5
6
  import tar from "tar";
6
- import { execSync } from "child_process";
7
7
 
8
- import { ARCH_MAPPING, CONFIG, PLATFORM_MAPPING } from "./config.js";
8
+ import { CONFIG } from "./config.js";
9
9
 
10
10
  async function install() {
11
- if (process.platform === "android") {
12
- console.log("Installing, this may take a few minutes...");
13
- const cmd =
14
- "pkg upgrade && pkg install golang git -y && git clone https://github.com/railwayapp/cli.git && cd cli/ && go build -o $PREFIX/bin/railway";
15
- execSync(cmd, { encoding: "utf-8" });
16
- console.log("Installation successful!");
17
- return;
18
- }
19
- const packageJson = await fs.readFile("package.json").then(JSON.parse);
20
- let version = packageJson.version;
21
-
22
- if (typeof version !== "string") {
23
- throw new Error("Missing version in package.json");
24
- }
25
-
26
- if (version[0] === "v") version = version.slice(1);
27
-
28
- // Fetch Static Config
29
- let { name: binName, path: binPath, url } = CONFIG;
30
-
31
- url = url.replace(/{{arch}}/g, ARCH_MAPPING[process.arch]);
32
- url = url.replace(/{{platform}}/g, PLATFORM_MAPPING[process.platform]);
33
- url = url.replace(/{{version}}/g, version);
34
- url = url.replace(/{{bin_name}}/g, binName);
35
-
36
- const response = await fetch(url);
37
- if (!response.ok) {
38
- throw new Error("Failed fetching the binary: " + response.statusText);
39
- }
40
-
41
- const tarFile = "downloaded.tar.gz";
42
-
43
- await fs.mkdir(binPath, { recursive: true });
44
- await pipeline(response.body, createWriteStream(tarFile));
45
- await tar.x({ file: tarFile, cwd: binPath });
46
- await fs.rm(tarFile);
11
+ const packageJson = await fs.readFile("package.json").then(JSON.parse);
12
+ let version = packageJson.version;
13
+
14
+ if (typeof version !== "string") {
15
+ throw new Error("Missing version in package.json");
16
+ }
17
+
18
+ if (version[0] === "v") version = version.slice(1);
19
+
20
+ // Fetch Static Config
21
+ let { name: binName, path: binPath, url } = CONFIG;
22
+ let triple = triples.platformArchTriples[process.platform][process.arch][0];
23
+ url = url.replace(/{{triple}}/g, triple.raw);
24
+ url = url.replace(/{{version}}/g, version);
25
+ url = url.replace(/{{bin_name}}/g, binName);
26
+ console.log(url);
27
+ const response = await fetch(url);
28
+ if (!response.ok) {
29
+ throw new Error("Failed fetching the binary: " + response.statusText);
30
+ }
31
+
32
+ const tarFile = "downloaded.tar.gz";
33
+
34
+ await fs.mkdir(binPath, { recursive: true });
35
+ await pipeline(response.body, createWriteStream(tarFile));
36
+ await tar.x({ file: tarFile, cwd: binPath });
37
+ await fs.rm(tarFile);
47
38
  }
48
39
 
49
40
  install()
50
- .then(async () => {
51
- process.exit(0);
52
- })
53
- .catch(async (err) => {
54
- console.error(err);
55
- process.exit(1);
56
- });
41
+ .then(async () => {
42
+ process.exit(0);
43
+ })
44
+ .catch(async (err) => {
45
+ console.error(err);
46
+ process.exit(1);
47
+ });
package/package.json CHANGED
@@ -1,29 +1,30 @@
1
1
  {
2
- "name": "@railway/cli",
3
- "version": "2.1.0",
4
- "description": "Develop and deploy code with zero configuration",
5
- "type": "module",
6
- "author": "Jake Runzer",
7
- "license": "ISC",
8
- "homepage": "https://github.com/railwayapp/cli/blob/master/README.md",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/railwayapp/cli.git"
12
- },
13
- "engines": {
14
- "node": ">=16.0.0"
15
- },
16
- "scripts": {
17
- "postinstall": "node ./npm-install/postinstall.js"
18
- },
19
- "bin": {
20
- "railway": "bin/railway.js"
21
- },
22
- "files": [
23
- "npm-install"
24
- ],
25
- "dependencies": {
26
- "node-fetch": "^3.1.0",
27
- "tar": "^6.1.11"
28
- }
2
+ "name": "@railway/cli",
3
+ "version": "3.0.5",
4
+ "description": "Develop and deploy code with zero configuration",
5
+ "type": "module",
6
+ "author": "Jake Runzer",
7
+ "license": "ISC",
8
+ "homepage": "https://github.com/railwayapp/cli/blob/master/README.md",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/railwayapp/cli.git"
12
+ },
13
+ "engines": {
14
+ "node": ">=16.0.0"
15
+ },
16
+ "scripts": {
17
+ "postinstall": "node ./npm-install/postinstall.js"
18
+ },
19
+ "bin": {
20
+ "railway": "bin/railway.js"
21
+ },
22
+ "files": [
23
+ "npm-install"
24
+ ],
25
+ "dependencies": {
26
+ "@napi-rs/triples": "^1.1.0",
27
+ "node-fetch": "^3.1.0",
28
+ "tar": "^6.1.11"
29
+ }
29
30
  }