diff --git a/crates/houston/src/profile/mod.rs b/crates/houston/src/profile/mod.rs index 2d44a0948..e89ba1a5e 100644 --- a/crates/houston/src/profile/mod.rs +++ b/crates/houston/src/profile/mod.rs @@ -27,12 +27,12 @@ pub struct Opts { } impl Profile { - fn base_dir(config: &Config) -> Result { - Ok(config.home.join("profiles")) + fn base_dir(config: &Config) -> PathBuf { + config.home.join("profiles") } - fn dir(name: &str, config: &Config) -> Result { - Ok(Profile::base_dir(config)?.join(name)) + fn dir(name: &str, config: &Config) -> PathBuf { + Profile::base_dir(config).join(name) } /// Writes an api_key to the filesystem (`$APOLLO_CONFIG_HOME/profiles//.sensitive`). @@ -73,7 +73,7 @@ impl Profile { /// Loads and deserializes configuration from the file system for a /// specific profile. pub fn load(name: &str, config: &Config, opts: LoadOpts) -> Result { - if Profile::dir(name, config)?.exists() { + if Profile::dir(name, config).exists() { if opts.sensitive { let sensitive = Sensitive::load(name, config)?; return Ok(Profile { sensitive }); @@ -86,7 +86,7 @@ impl Profile { /// Deletes profile data from file system. pub fn delete(name: &str, config: &Config) -> Result<(), HoustonProblem> { - let dir = Profile::dir(name, config)?; + let dir = Profile::dir(name, config); tracing::debug!(dir = ?dir); Ok(fs::remove_dir_all(dir).map_err(|e| match e.kind() { std::io::ErrorKind::NotFound => HoustonProblem::ProfileNotFound(name.to_string()), @@ -96,7 +96,7 @@ impl Profile { /// Lists profiles based on directories in `$APOLLO_CONFIG_HOME/profiles` pub fn list(config: &Config) -> Result, HoustonProblem> { - let profiles_dir = Profile::base_dir(config)?; + let profiles_dir = Profile::base_dir(config); let mut profiles = vec![]; // if profiles dir doesn't exist return empty vec diff --git a/crates/houston/src/profile/sensitive.rs b/crates/houston/src/profile/sensitive.rs index dae44151a..23c2f62d3 100644 --- a/crates/houston/src/profile/sensitive.rs +++ b/crates/houston/src/profile/sensitive.rs @@ -12,13 +12,13 @@ pub struct Sensitive { } impl Sensitive { - fn path(profile_name: &str, config: &Config) -> Result { - Ok(Profile::dir(profile_name, config)?.join(".sensitive")) + fn path(profile_name: &str, config: &Config) -> PathBuf { + Profile::dir(profile_name, config).join(".sensitive") } /// Serializes to toml and saves to file system at `$APOLLO_CONFIG_HOME//.sensitive`. pub fn save(&self, profile_name: &str, config: &Config) -> Result<(), HoustonProblem> { - let path = Sensitive::path(profile_name, config)?; + let path = Sensitive::path(profile_name, config); let data = toml::to_string(self)?; if let Some(dirs) = &path.parent() { @@ -32,7 +32,7 @@ impl Sensitive { /// Opens and deserializes `$APOLLO_CONFIG_HOME//.sensitive`. pub fn load(profile_name: &str, config: &Config) -> Result { - let path = Sensitive::path(profile_name, config)?; + let path = Sensitive::path(profile_name, config); let data = fs::read_to_string(&path)?; tracing::debug!(path = ?path, data_len = ?data.len()); Ok(toml::from_str(&data)?) diff --git a/installers/npm/package-lock.json b/installers/npm/package-lock.json index 4d398512c..0b5ab1518 100644 --- a/installers/npm/package-lock.json +++ b/installers/npm/package-lock.json @@ -1,304 +1,8 @@ { "name": "@apollo/rover", "version": "0.0.1", - "lockfileVersion": 2, + "lockfileVersion": 1, "requires": true, - "packages": { - "": { - "name": "@apollo/rover", - "version": "0.0.1", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "binary-install": "^0.1.1", - "console.table": "^0.10.0" - }, - "bin": { - "rover": "run.js" - }, - "devDependencies": { - "prettier": "^2.2.1" - } - }, - "node_modules/axios": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", - "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", - "dependencies": { - "follow-redirects": "^1.10.0" - } - }, - "node_modules/balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, - "node_modules/binary-install": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/binary-install/-/binary-install-0.1.1.tgz", - "integrity": "sha512-DqED0D/6LrS+BHDkKn34vhRqOGjy5gTMgvYZsGK2TpNbdPuz4h+MRlNgGv5QBRd7pWq/jylM4eKNCizgAq3kNQ==", - "dependencies": { - "axios": "^0.21.1", - "rimraf": "^3.0.2", - "tar": "^6.1.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/chownr": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", - "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", - "engines": { - "node": ">=10" - } - }, - "node_modules/clone": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", - "optional": true, - "engines": { - "node": ">=0.8" - } - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "node_modules/console.table": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/console.table/-/console.table-0.10.0.tgz", - "integrity": "sha1-CRcCVYiHW+/XDPLv9L7yxuLXXQQ=", - "dependencies": { - "easy-table": "1.1.0" - }, - "engines": { - "node": "> 0.10" - } - }, - "node_modules/defaults": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", - "optional": true, - "dependencies": { - "clone": "^1.0.2" - } - }, - "node_modules/easy-table": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/easy-table/-/easy-table-1.1.0.tgz", - "integrity": "sha1-hvmrTBAvA3G3KXuSplHVgkvIy3M=", - "dependencies": { - "wcwidth": ">=1.0.1" - }, - "optionalDependencies": { - "wcwidth": ">=1.0.1" - } - }, - "node_modules/follow-redirects": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.2.tgz", - "integrity": "sha512-6mPTgLxYm3r6Bkkg0vNM0HTjfGrOEtsfbhagQvbxDEsEkpNhw582upBaoRZylzen6krEmxXJgt9Ju6HiI4O7BA==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/fs-minipass": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", - "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", - "dependencies": { - "minipass": "^3.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "node_modules/glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "node_modules/minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/minipass": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.3.tgz", - "integrity": "sha512-Mgd2GdMVzY+x3IJ+oHnVM+KG3lA5c8tnabyJKmHSaG2kAGpudxuOf8ToDkhumF7UzME7DecbQE9uOZhNm7PuJg==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/minizlib": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", - "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", - "dependencies": { - "minipass": "^3.0.0", - "yallist": "^4.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "bin": { - "mkdirp": "bin/cmd.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dependencies": { - "wrappy": "1" - } - }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/prettier": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz", - "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==", - "dev": true, - "bin": { - "prettier": "bin-prettier.js" - }, - "engines": { - "node": ">=10.13.0" - } - }, - "node_modules/rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/tar": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.0.tgz", - "integrity": "sha512-DUCttfhsnLCjwoDoFcI+B2iJgYa93vBnDUATYEeRx6sntCTdN01VnqsIuTlALXla/LWooNg0yEGeB+Y8WdFxGA==", - "dependencies": { - "chownr": "^2.0.0", - "fs-minipass": "^2.0.0", - "minipass": "^3.0.0", - "minizlib": "^2.1.1", - "mkdirp": "^1.0.3", - "yallist": "^4.0.0" - }, - "engines": { - "node": ">= 10" - } - }, - "node_modules/wcwidth": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", - "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=", - "optional": true, - "dependencies": { - "defaults": "^1.0.3" - } - }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - } - }, "dependencies": { "axios": { "version": "0.21.1", diff --git a/src/command/config/auth.rs b/src/command/config/auth.rs index 5821356b4..26c0fe19f 100644 --- a/src/command/config/auth.rs +++ b/src/command/config/auth.rs @@ -73,7 +73,7 @@ mod tests { fn it_can_set_default_api_key() { let config = get_config(None); - Profile::set_api_key(DEFAULT_PROFILE, &config, DEFAULT_KEY.into()).unwrap(); + Profile::set_api_key(DEFAULT_PROFILE, &config, DEFAULT_KEY).unwrap(); let result = Profile::get_api_key(DEFAULT_PROFILE, &config).unwrap(); assert_eq!(result, DEFAULT_KEY); } @@ -83,7 +83,7 @@ mod tests { fn it_can_set_custom_api_key() { let config = get_config(None); - Profile::set_api_key(CUSTOM_PROFILE, &config, CUSTOM_KEY.into()).unwrap(); + Profile::set_api_key(CUSTOM_PROFILE, &config, CUSTOM_KEY).unwrap(); let result = Profile::get_api_key(CUSTOM_PROFILE, &config).unwrap(); assert_eq!(result, CUSTOM_KEY); } diff --git a/tests/config/profile.rs b/tests/config/profile.rs index f7485d9f9..95b88774f 100644 --- a/tests/config/profile.rs +++ b/tests/config/profile.rs @@ -28,7 +28,7 @@ fn it_can_list_no_profiles() { fn it_can_list_one_profile() { let temp_dir = get_temp_dir(); let config = Config::new(Some(temp_dir.clone()).as_ref(), None).unwrap(); - Profile::set_api_key(CUSTOM_PROFILE, &config, CUSTOM_API_KEY.into()).unwrap(); + Profile::set_api_key(CUSTOM_PROFILE, &config, CUSTOM_API_KEY).unwrap(); let mut cmd = Command::cargo_bin("rover").unwrap(); let result = cmd