@apollo/rover 0.39.1 → 0.41.0-rc.2

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/README.md CHANGED
@@ -83,6 +83,8 @@ Commands:
83
83
  Commands for fetching offline licenses
84
84
  client
85
85
  Client workflow commands
86
+ graph-artifact
87
+ Graph artifact commands
86
88
  help
87
89
  Print this message or the help of the given subcommand(s)
88
90
 
@@ -97,7 +99,7 @@ Options:
97
99
  [possible values: plain, json]
98
100
 
99
101
  -o, --output <OUTPUT_FILE>
100
- Specify a file to write Rover's output to
102
+ Specify a file to write Rover's console output to instead of stdout
101
103
 
102
104
  --insecure-accept-invalid-certs
103
105
  Accept invalid certificates when performing HTTPS requests.
@@ -114,12 +116,14 @@ Options:
114
116
  If hostname verification is not used, any valid certificate for any site will be trusted for use from any other. This introduces a significant vulnerability to man-in-the-middle attacks.
115
117
 
116
118
  --client-timeout <CLIENT_TIMEOUT>
117
- Configure the timeout length (in seconds) when performing HTTP(S) requests
119
+ Configure the timeout length (in seconds) when performing HTTP(S) requests.
118
120
 
119
- [default: 30]
121
+ Defaults to 30s for standard operations and 300s for plugin downloads.
120
122
 
121
123
  --skip-update-check
122
- Skip checking for newer versions of rover
124
+ Skip checking for newer versions of rover.
125
+
126
+ Set the `APOLLO_ROVER_SKIP_UPDATE` environment variable (to `1` or `true`) to disable all of Rover's auto-updating at once — both this self-update check and the `supergraph`/`router` plugin auto-updates (`--skip-update`).
123
127
 
124
128
  -h, --help
125
129
  Print help (see a summary with '-h')
@@ -171,7 +175,7 @@ This repo is organized as a [`cargo` workspace], containing several related proj
171
175
 
172
176
  ## Installation Methods
173
177
 
174
- As of Rover 0.39.0, all the platforms listed below enforce immutable release tags. This means that you can reference a GitHub release, Docker image, or NPM release version directly by SemVer and be
178
+ As of Rover v0.39.1, all the platforms listed below enforce immutable release tags. This means that you can reference a GitHub release, Docker image, or NPM release version directly by SemVer and be
175
179
  guaranteed that the artifact will not change. Note that the `curl | sh` method, while ultimately referencing immutable GitHub release binaries, still first downloads a shell script from a webservice
176
180
  that does not provide that same guarantee of immutability. Security conscious installers should verify the downloaded shell script matches
177
181
  [the pinned artifact for its respective Rover version](https://github.com/apollographql-gh-actions/install-rover) or use one of the immutable installation methods described below.
@@ -186,7 +190,7 @@ curl -sSL https://rover.apollo.dev/nix/latest | sh
186
190
 
187
191
  To install a specific version of Rover (note the `v` prefixing the version number):
188
192
 
189
- > Note: If you're installing Rover in a CI environment, we highly recommend using an [immutable Docker image of Rover](#docker-images)). As an alternative for GitHub Actions users, we vend a [GitHub Action](https://github.com/marketplace/actions/install-apollo-rover-cli) which pins an immutable instance of the download script and installs the native binary.
193
+ > Note: If you're installing Rover in a CI environment, Apollo highly recommends using an [immutable Docker image of Rover](#docker-images)). As an alternative for GitHub Actions users, Apollo vends a [GitHub Action](https://github.com/marketplace/actions/install-apollo-rover-cli) which pins an immutable instance of the download script and installs the native binary.
190
194
 
191
195
  ```bash
192
196
  curl -sSL https://rover.apollo.dev/nix/v0.10.0 | sh
@@ -204,7 +208,7 @@ iwr 'https://rover.apollo.dev/win/latest' | iex
204
208
 
205
209
  To install a specific version of Rover (note the `v` prefixing the version number):
206
210
 
207
- > Note: If you are installing Rover in a Windows CI environment, you need to put Docker into Linux mode to use the [recommended immutable Docker images](#docker-images)). As an alternative for GitHub Actions users, we vend a [GitHub Action](https://github.com/marketplace/actions/install-apollo-rover-cli) to do so which pins an immutable instance of the download script and installs the native binary.
211
+ > Note: If you are installing Rover in a Windows CI environment, you need to put Docker into Linux mode to use the [recommended immutable Docker images](#docker-images)). As an alternative for GitHub Actions users, Apollo vends a [GitHub Action](https://github.com/marketplace/actions/install-apollo-rover-cli) to do so which pins an immutable instance of the download script and installs the native binary.
208
212
 
209
213
 
210
214
  ```bash
@@ -213,22 +217,22 @@ iwr 'https://rover.apollo.dev/win/v0.10.0' | iex
213
217
 
214
218
  #### Docker images
215
219
 
216
- Starting with version 0.39.0, Rover vends immutable Linux Docker images that pre-build Rover as an entry point for consumption in CI environments
220
+ Starting with version 0.39.1, Rover vends immutable Linux Docker images that pre-build Rover as an entry point for consumption in CI environments
217
221
  or to run Rover on platforms that Rover does not build natively for. Each release verison tag is enforced as immutable at the platform level for
218
222
  your convenience so that you can pin to the Rover version you want without needing to deal with the indirection of SHA pinning.
219
223
 
220
224
  Install directly from Dockerhub:
221
225
 
222
226
  ```bash
223
- docker pull apollograph/rover:0.39.0
224
- docker run apollograph/rover:0.39.0 <<args>>
227
+ docker pull apollograph/rover:0.39.1
228
+ docker run apollograph/rover:0.39.1 <<args>>
225
229
  ```
226
230
 
227
231
  or via ghcr.io:
228
232
 
229
233
  ```bash
230
- docker pull ghcr.io/apollographql/rover:0.39.0
231
- docker run ghcr.io/apollographql/rover:0.39.0 <<args>>
234
+ docker pull ghcr.io/apollographql/rover:0.39.1
235
+ docker run ghcr.io/apollographql/rover:0.39.1 <<args>>
232
236
  ```
233
237
 
234
238
  All CI platforms that support referencing images from those respective image repositories can do so directly as well.
@@ -238,7 +242,7 @@ All CI platforms that support referencing images from those respective image rep
238
242
  Rover vends a number of GitHub actions for convenient invocation of common Rover commands in your CI pipeline. They can be found on
239
243
  [GitHub's actions marketplace](https://github.com/marketplace?query=apollographql-gh-actions+Rover&type=actions).
240
244
 
241
- As of Rover 0.39.0, each Rover release corresponds to an immutable action tag of `<action>@rover-<version>`. This allows you to specify
245
+ As of Rover v0.39.1, each Rover release corresponds to an immutable action tag of `<action>@rover-<version>`. This allows you to specify
242
246
  the exact version of Rover for your CI actions without needing to rely on SHA pinning to guarantee action immutability. These actions
243
247
  leverage Rover's Docker image under the hood to sandbox the Rover invocation and only expose it to the `APOLLO_*` environment variable
244
248
  surface.
@@ -251,8 +255,8 @@ Their source code is mastered in this repository under the `actions` directory.
251
255
  #### npm installer
252
256
 
253
257
  Rover is distributed on npm for easy integration with your JavaScript projects. Rover's Node dependency will follow LTS versions where possible unless security concerns justify an earlier upgrade.
254
- While this installation method is provided for convenience in projects that are already in the Node ecosystem, we do not recommend it as an installation method otherwise as it exposes your
255
- installation to NPM's surface area of potential supply-chain attacks. We have attempted to minimize the dependency surface of Rover's NPM installation script, but it still represents nonzero risk.
258
+ While this installation method is provided for convenience in projects that are already in the Node ecosystem, Apollo does not recommend it as an installation method otherwise as it exposes your
259
+ installation to NPM's surface area of potential supply-chain attacks. Apollo has attempted to minimize the dependency surface of Rover's NPM installation script, but it still represents nonzero risk.
256
260
 
257
261
  ##### devDependency install
258
262
 
@@ -262,7 +266,7 @@ Note that installing rover directly via `npx install` bypasses lockfiles (includ
262
266
 
263
267
  #### Homebrew
264
268
 
265
- While we recommend using one of the other installation methods above, we do have a homebrew recipe `brew install rover`. The code for this recipe is in the [homebrew-core repo](https://github.com/Homebrew/homebrew-core/blob/master/Formula/r/rover.rb).
269
+ While Apollo recommends using one of the other installation methods above, we do have a homebrew recipe `brew install rover`. The code for this recipe is in the [homebrew-core repo](https://github.com/Homebrew/homebrew-core/blob/master/Formula/r/rover.rb).
266
270
 
267
271
  #### Manual binary download
268
272
 
package/bin/rover.js ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ 'use strict'
3
+
4
+ function isMusl() {
5
+ try {
6
+ return require('fs').readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
7
+ } catch {}
8
+ try {
9
+ const orig = process.report.excludeNetwork
10
+ process.report.excludeNetwork = true
11
+ const report = process.report.getReport()
12
+ process.report.excludeNetwork = orig
13
+ if (report.header?.glibcVersionRuntime) return false
14
+ return report.sharedObjects.some((f) => f.includes('libc.musl-') || f.includes('ld-musl-'))
15
+ } catch {}
16
+ }
17
+
18
+ const PLATFORMS = {
19
+ darwin: {
20
+ arm64: '@apollo/rover-darwin-arm64/rover',
21
+ x64: '@apollo/rover-darwin-x64/rover',
22
+ },
23
+ linux: {
24
+ arm64: '@apollo/rover-linux-arm64/rover',
25
+ x64: '@apollo/rover-linux-x64/rover',
26
+ },
27
+ 'linux-musl': {
28
+ x64: '@apollo/rover-linux-x64-musl/rover',
29
+ },
30
+ win32: {
31
+ x64: '@apollo/rover-win32-x64/rover.exe',
32
+ },
33
+ }
34
+
35
+ const key = process.platform === 'linux' && isMusl() ? 'linux-musl' : process.platform
36
+ const binPath = PLATFORMS[key]?.[process.arch]
37
+
38
+ if (!binPath) {
39
+ console.error(`Unsupported platform: ${process.platform} ${process.arch}`)
40
+ process.exit(1)
41
+ }
42
+
43
+ const bin = require.resolve(binPath)
44
+ process.env.APOLLO_NODE_MODULES_BIN_DIR = require('path').dirname(bin)
45
+ const result = require('child_process').spawnSync(bin, process.argv.slice(2), { stdio: 'inherit' })
46
+ if (result.error) {
47
+ throw result.error
48
+ }
49
+ process.exitCode = result.status ?? 1
package/package.json CHANGED
@@ -1,22 +1,7 @@
1
1
  {
2
2
  "name": "@apollo/rover",
3
- "version": "0.39.1",
4
- "description": "The new Apollo CLI",
5
- "main": "index.js",
6
- "bin": {
7
- "rover": "run.js"
8
- },
9
- "scripts": {
10
- "prepack": "cp ../../README.md . && cp ../../LICENSE .",
11
- "postinstall": "node ./install.js",
12
- "fmt": "prettier --write **/*.js",
13
- "fmt:check": "prettier --check **/*.js",
14
- "test": "jest"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/apollographql/rover.git"
19
- },
3
+ "version": "0.41.0-rc.2",
4
+ "description": "Rover is a tool for working with the Apollo GraphQL Registry.",
20
5
  "keywords": [
21
6
  "rover",
22
7
  "graphql",
@@ -26,23 +11,28 @@
26
11
  "tooling",
27
12
  "tools"
28
13
  ],
29
- "author": "Apollo Developers <opensource@apollographql.com>",
14
+ "homepage": "https://github.com/apollographql/rover#readme",
30
15
  "license": "MIT",
31
- "bugs": {
32
- "url": "https://github.com/apollographql/rover/issues"
16
+ "author": "Apollo Developers <opensource@apollographql.com>",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/apollographql/rover.git"
20
+ },
21
+ "bin": {
22
+ "rover": "bin/rover.js"
33
23
  },
34
24
  "engines": {
35
25
  "node": ">=22.14.0"
36
26
  },
37
- "homepage": "https://github.com/apollographql/rover#readme",
38
- "dependencies": {
39
- "detect-libc": "2.1.2",
40
- "tar": "^7.0.0",
41
- "undici": "^7.0.0"
27
+ "optionalDependencies": {
28
+ "@apollo/rover-darwin-arm64": "0.41.0-rc.2",
29
+ "@apollo/rover-darwin-x64": "0.41.0-rc.2",
30
+ "@apollo/rover-linux-arm64": "0.41.0-rc.2",
31
+ "@apollo/rover-linux-x64": "0.41.0-rc.2",
32
+ "@apollo/rover-linux-x64-musl": "0.41.0-rc.2",
33
+ "@apollo/rover-win32-x64": "0.41.0-rc.2"
42
34
  },
43
- "devDependencies": {
44
- "jest": "30.4.2",
45
- "jest-junit": "17.0.0",
46
- "prettier": "3.8.3"
35
+ "bugs": {
36
+ "url": "https://github.com/apollographql/rover/issues"
47
37
  }
48
- }
38
+ }
package/binary.js DELETED
@@ -1,383 +0,0 @@
1
- "use strict";
2
-
3
- const libc = require("detect-libc");
4
- const os = require("os");
5
- const tar = require("tar");
6
- const { Console } = require("node:console");
7
- const { existsSync, mkdirSync, rmSync } = require("fs");
8
- const { join } = require("path");
9
- const { spawnSync } = require("child_process");
10
- const { Readable } = require("stream");
11
- const { ProxyAgent, fetch } = require("undici");
12
-
13
- const error = (msg) => {
14
- console.error(msg);
15
- process.exit(1);
16
- };
17
-
18
- const { version } = require("./package.json");
19
- const fs = require("fs");
20
- const name = `rover`;
21
-
22
- const supportedPlatforms = [
23
- {
24
- TYPE: "Windows_NT",
25
- ARCHITECTURE: "x64",
26
- RUST_TARGET: "x86_64-pc-windows-msvc",
27
- BINARY_NAME: `${name}-${version}.exe`,
28
- RAW_NAME: `${name}.exe`,
29
- },
30
- {
31
- TYPE: "Linux",
32
- ARCHITECTURE: "x64",
33
- RUST_TARGET: "x86_64-unknown-linux-gnu",
34
- BINARY_NAME: `${name}-${version}`,
35
- RAW_NAME: `${name}`,
36
- },
37
- {
38
- TYPE: "Linux",
39
- ARCHITECTURE: "arm64",
40
- RUST_TARGET: "aarch64-unknown-linux-gnu",
41
- BINARY_NAME: `${name}-${version}`,
42
- RAW_NAME: `${name}`,
43
- },
44
- {
45
- TYPE: "Darwin",
46
- ARCHITECTURE: "x64",
47
- RUST_TARGET: "x86_64-apple-darwin",
48
- BINARY_NAME: `${name}-${version}`,
49
- RAW_NAME: `${name}`,
50
- },
51
- {
52
- TYPE: "Darwin",
53
- ARCHITECTURE: "arm64",
54
- RUST_TARGET: "aarch64-apple-darwin",
55
- BINARY_NAME: `${name}-${version}`,
56
- RAW_NAME: `${name}`,
57
- },
58
- ];
59
-
60
- const getPlatform = (type = os.type(), architecture = os.arch()) => {
61
- for (let supportedPlatform of supportedPlatforms) {
62
- if (
63
- type === supportedPlatform.TYPE &&
64
- architecture === supportedPlatform.ARCHITECTURE
65
- ) {
66
- if (supportedPlatform.TYPE === "Linux") {
67
- let musl_warning =
68
- "Downloading musl binary that does not include `rover supergraph compose`.";
69
- if (libc.isNonGlibcLinuxSync()) {
70
- console.warn(
71
- "This operating system does not support dynamic linking to glibc.",
72
- );
73
- console.warn(musl_warning);
74
- supportedPlatform.RUST_TARGET = "x86_64-unknown-linux-musl";
75
- } else {
76
- let libc_version = libc.versionSync();
77
- let split_libc_version = libc_version.split(".");
78
- let libc_major_version = split_libc_version[0];
79
- let libc_minor_version = split_libc_version[1];
80
- let min_major_version = 2;
81
- let min_minor_version = 17;
82
- if (
83
- libc_major_version < min_major_version ||
84
- libc_minor_version < min_minor_version
85
- ) {
86
- console.warn(
87
- `This operating system needs glibc >= ${min_major_version}.${min_minor_version}, but only has ${libc_version} installed.`,
88
- );
89
- console.warn(musl_warning);
90
- supportedPlatform.RUST_TARGET = "x86_64-unknown-linux-musl";
91
- }
92
- }
93
- }
94
- return supportedPlatform;
95
- }
96
- }
97
-
98
- const stderr = new Console(process.stderr);
99
- stderr.log(
100
- `Platform with type "${type}" and architecture "${architecture}" is not supported by ${name}.`,
101
- );
102
- stderr.table(supportedPlatforms);
103
- process.exit(1);
104
- };
105
-
106
- const DEFAULT_PORTS = { "http:": 80, "https:": 443 };
107
-
108
- /*! Copyright (c) 2014-present Matt Zabriskie & Collaborators - MIT License */
109
- const parseNoProxyEntry = (entry) => {
110
- let entryHost = entry;
111
- let entryPort = 0;
112
-
113
- if (entryHost.charAt(0) === "[") {
114
- const bracketIndex = entryHost.indexOf("]");
115
- if (bracketIndex !== -1) {
116
- const host = entryHost.slice(1, bracketIndex);
117
- const rest = entryHost.slice(bracketIndex + 1);
118
- if (rest.charAt(0) === ":" && /^\d+$/.test(rest.slice(1))) {
119
- entryPort = Number.parseInt(rest.slice(1), 10);
120
- }
121
- return [host, entryPort];
122
- }
123
- }
124
-
125
- const firstColon = entryHost.indexOf(":");
126
- const lastColon = entryHost.lastIndexOf(":");
127
- if (
128
- firstColon !== -1 &&
129
- firstColon === lastColon &&
130
- /^\d+$/.test(entryHost.slice(lastColon + 1))
131
- ) {
132
- entryPort = Number.parseInt(entryHost.slice(lastColon + 1), 10);
133
- entryHost = entryHost.slice(0, lastColon);
134
- }
135
-
136
- return [entryHost, entryPort];
137
- };
138
-
139
- /*! Copyright (c) 2014-present Matt Zabriskie & Collaborators - MIT License */
140
- const normalizeNoProxyHost = (hostname) => {
141
- if (!hostname) return hostname;
142
- if (
143
- hostname.charAt(0) === "[" &&
144
- hostname.charAt(hostname.length - 1) === "]"
145
- ) {
146
- hostname = hostname.slice(1, -1);
147
- }
148
- return hostname.replace(/\.+$/, "");
149
- };
150
-
151
- /*! Copyright (c) 2014-present Matt Zabriskie & Collaborators - MIT License */
152
- const shouldBypassProxy = (requestURL) => {
153
- const noProxy = (
154
- process.env.no_proxy ||
155
- process.env.NO_PROXY ||
156
- ""
157
- ).toLowerCase();
158
-
159
- if (!noProxy) return false;
160
- if (noProxy === "*") return true;
161
-
162
- const port =
163
- Number.parseInt(requestURL.port, 10) ||
164
- DEFAULT_PORTS[requestURL.protocol] ||
165
- 0;
166
- const hostname = normalizeNoProxyHost(requestURL.hostname.toLowerCase());
167
-
168
- return noProxy.split(/[\s,]+/).some((entry) => {
169
- if (!entry) return false;
170
-
171
- let [entryHost, entryPort] = parseNoProxyEntry(entry);
172
- entryHost = normalizeNoProxyHost(entryHost);
173
- if (!entryHost) return false;
174
-
175
- if (entryPort && entryPort !== port) return false;
176
-
177
- if (entryHost.charAt(0) === "*") {
178
- entryHost = entryHost.slice(1);
179
- }
180
-
181
- if (entryHost.charAt(0) === ".") {
182
- return hostname.endsWith(entryHost);
183
- }
184
-
185
- return hostname === entryHost;
186
- });
187
- };
188
-
189
- const getProxyEnv = (requestURL) => {
190
- if (shouldBypassProxy(requestURL)) return null;
191
-
192
- if (requestURL.protocol === "http:") {
193
- return process.env.HTTP_PROXY || process.env.http_proxy || null;
194
- }
195
-
196
- if (requestURL.protocol === "https:") {
197
- return process.env.HTTPS_PROXY || process.env.https_proxy || null;
198
- }
199
-
200
- return null;
201
- };
202
-
203
- /*! Copyright (c) 2019 Avery Harnish - MIT License */
204
- class Binary {
205
- constructor(name, raw_name, url, installDirectory) {
206
- let errors = [];
207
- if (typeof url !== "string") {
208
- errors.push("url must be a string");
209
- } else {
210
- try {
211
- new URL(url);
212
- } catch (e) {
213
- errors.push(e);
214
- }
215
- }
216
- if (name && typeof name !== "string") {
217
- errors.push("name must be a string");
218
- }
219
-
220
- if (!name) {
221
- errors.push("You must specify the name of your binary");
222
- }
223
- if (errors.length > 0) {
224
- let errorMsg =
225
- "One or more of the parameters you passed to the Binary constructor are invalid:\n";
226
- errors.forEach((error) => {
227
- errorMsg += error;
228
- });
229
- errorMsg +=
230
- '\n\nCorrect usage: new Binary("my-binary", "https://example.com/binary/download.tar.gz")';
231
- error(errorMsg);
232
- }
233
- this.url = url;
234
- this.name = name;
235
- this.raw_name = raw_name;
236
- this.installDirectory = installDirectory;
237
-
238
- if (!existsSync(this.installDirectory)) {
239
- mkdirSync(this.installDirectory, { recursive: true });
240
- }
241
-
242
- this.binaryPath = join(this.installDirectory, this.name);
243
- }
244
-
245
- exists() {
246
- return existsSync(this.binaryPath);
247
- }
248
-
249
- install(suppressLogs = false) {
250
- if (this.exists()) {
251
- if (!suppressLogs) {
252
- console.error(
253
- `${this.name} is already installed, skipping installation.`,
254
- );
255
- }
256
- return Promise.resolve();
257
- }
258
-
259
- if (existsSync(this.installDirectory)) {
260
- rmSync(this.installDirectory, { recursive: true });
261
- }
262
-
263
- mkdirSync(this.installDirectory, { recursive: true });
264
-
265
- if (!suppressLogs) {
266
- console.error(`Downloading release from ${this.url}`);
267
- }
268
-
269
- const proxyUrl = getProxyEnv(new URL(this.url));
270
-
271
- const agent = proxyUrl ? new ProxyAgent(proxyUrl) : null;
272
- const fetchPromise = fetch(this.url, agent ? { dispatcher: agent } : {});
273
-
274
- return fetchPromise
275
- .then((res) => {
276
- if (!res.ok) {
277
- throw new Error(
278
- `Failed to download binary: HTTP ${res.status} ${res.statusText}`,
279
- );
280
- }
281
- return new Promise((resolve, reject) => {
282
- const sink = Readable.fromWeb(res.body).pipe(
283
- tar.x({ strip: 1, C: this.installDirectory }),
284
- );
285
- sink.on("finish", () => resolve());
286
- sink.on("error", (err) => reject(err));
287
- });
288
- })
289
- .then(() => {
290
- fs.renameSync(
291
- join(this.installDirectory, this.raw_name),
292
- this.binaryPath,
293
- );
294
- if (!suppressLogs) {
295
- console.error(`${this.name} has been installed!`);
296
- }
297
- })
298
- .finally(() => agent && agent.close())
299
- .catch((e) => {
300
- error(`Error fetching release: ${e.message}`);
301
- });
302
- }
303
-
304
- run() {
305
- const promise = !this.exists() ? this.install(true) : Promise.resolve();
306
-
307
- promise
308
- .then(() => {
309
- const [, , ...args] = process.argv;
310
-
311
- const options = { cwd: process.cwd(), stdio: "inherit" };
312
-
313
- const result = spawnSync(this.binaryPath, args, options);
314
-
315
- if (result.error) {
316
- error(result.error);
317
- }
318
-
319
- process.exit(result.status);
320
- })
321
- .catch((e) => {
322
- error(e.message);
323
- process.exit(1);
324
- });
325
- }
326
- }
327
-
328
- const getBinary = (overrideInstallDirectory, platform = getPlatform()) => {
329
- const download_host =
330
- process.env.npm_config_apollo_rover_download_host ||
331
- process.env.APOLLO_ROVER_DOWNLOAD_HOST ||
332
- "https://rover.apollo.dev";
333
- // the url for this binary is constructed from values in `package.json`
334
- // https://rover.apollo.dev/tar/rover/x86_64-unknown-linux-gnu/vx.x.x
335
- const url = `${download_host}/tar/${name}/${platform.RUST_TARGET}/v${version}`;
336
- const { dirname } = require("path");
337
- const appDir = dirname(require.main.filename);
338
- let installDirectory = join(appDir, "binary");
339
- if (overrideInstallDirectory != null && overrideInstallDirectory !== "") {
340
- installDirectory = overrideInstallDirectory;
341
- }
342
- let binary = new Binary(
343
- platform.BINARY_NAME,
344
- platform.RAW_NAME,
345
- url,
346
- installDirectory,
347
- );
348
-
349
- // setting this allows us to extract supergraph plugins to the proper directory
350
- // the variable itself is read in Rust code
351
- process.env.APOLLO_NODE_MODULES_BIN_DIR = binary.installDirectory;
352
- return binary;
353
- };
354
-
355
- const install = (suppressLogs = false) => {
356
- const binary = getBinary();
357
- // these messages are duplicated in `src/command/install/mod.rs`
358
- // for the curl installer.
359
- if (!suppressLogs) {
360
- console.error(
361
- "If you would like to disable Rover's anonymized usage collection, you can set APOLLO_TELEMETRY_DISABLED=true",
362
- );
363
- console.error(
364
- "You can check out our documentation at https://go.apollo.dev/r/docs.",
365
- );
366
- }
367
-
368
- return binary.install(suppressLogs);
369
- };
370
-
371
- const run = () => {
372
- const binary = getBinary();
373
- binary.run();
374
- };
375
-
376
- module.exports = {
377
- install,
378
- run,
379
- getBinary,
380
- getPlatform,
381
- getProxyEnv,
382
- shouldBypassProxy,
383
- };
package/install.js DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { install } = require("./binary");
4
- install();
package/run.js DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { run, install: maybeInstall } = require("./binary");
4
- maybeInstall(true).then(run);