-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support updating config ignores (#248)
* feat: support updating config ignores * feat: use 2 spaces for YAML indenting * docs: add section about new flag * test: add case for updating configs with nested configs * fix: ensure that config updating output is consistently ordered * feat: account for existing ignores in configs * fix: color config file paths consistently * test: don't fail if we can't clean up test config files * test: add case when there are a lot of different files and a single config
- Loading branch information
Showing
10 changed files
with
904 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
94 changes: 94 additions & 0 deletions
94
fixtures/locks-insecure-nested/nested/my-composer-lock.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
{ | ||
"_readme": [ | ||
"This file locks the dependencies of your project to a known state", | ||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | ||
"This file is @generated automatically" | ||
], | ||
"content-hash": "36f1605a5dac03350d3c7d40eafc8477", | ||
"packages": [ | ||
{ | ||
"name": "guzzlehttp/psr7", | ||
"version": "1.8.2", | ||
"source": { | ||
"type": "git", | ||
"url": "https://github.com/guzzle/psr7.git", | ||
"reference": "dc960a912984efb74d0a90222870c72c87f10c91" | ||
}, | ||
"dist": { | ||
"type": "zip", | ||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/dc960a912984efb74d0a90222870c72c87f10c91", | ||
"reference": "dc960a912984efb74d0a90222870c72c87f10c91", | ||
"shasum": "" | ||
}, | ||
"require": { | ||
"php": ">=5.4.0", | ||
"psr/http-message": "~1.0", | ||
"ralouphie/getallheaders": "^2.0.5 || ^3.0.0" | ||
}, | ||
"provide": { | ||
"psr/http-message-implementation": "1.0" | ||
}, | ||
"require-dev": { | ||
"ext-zlib": "*", | ||
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10" | ||
}, | ||
"suggest": { | ||
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" | ||
}, | ||
"type": "library", | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.7-dev" | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"GuzzleHttp\\Psr7\\": "src/" | ||
}, | ||
"files": ["src/functions_include.php"] | ||
}, | ||
"notification-url": "https://packagist.org/downloads/", | ||
"license": ["MIT"], | ||
"authors": [ | ||
{ | ||
"name": "Michael Dowling", | ||
"email": "[email protected]", | ||
"homepage": "https://github.com/mtdowling" | ||
}, | ||
{ | ||
"name": "Tobias Schultze", | ||
"homepage": "https://github.com/Tobion" | ||
} | ||
], | ||
"description": "PSR-7 message implementation that also provides common utility methods", | ||
"keywords": [ | ||
"http", | ||
"message", | ||
"psr-7", | ||
"request", | ||
"response", | ||
"stream", | ||
"uri", | ||
"url" | ||
], | ||
"time": "2021-04-26T09:17:50+00:00" | ||
} | ||
], | ||
"packages-dev": [], | ||
"aliases": [], | ||
"minimum-stability": "dev", | ||
"stability-flags": { | ||
"cwp/cwp-recipe-cms": 0, | ||
"cwp/cwp-recipe-core": 0, | ||
"innoweb/silverstripe-mailchimp-signup": 20, | ||
"silverstripe/recipe-blog": 0, | ||
"silverstripe/redirectedurls": 20 | ||
}, | ||
"prefer-stable": true, | ||
"prefer-lowest": false, | ||
"platform": { | ||
"php": ">=7.4.0" | ||
}, | ||
"platform-dev": [], | ||
"plugin-api-version": "1.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package configer | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
func UpdateWithIgnores(pathToConfig string, ignores []string) error { | ||
raw, err := load(pathToConfig) | ||
|
||
if err != nil { | ||
return fmt.Errorf("%w", err) | ||
} | ||
|
||
raw.Ignore = ignores | ||
|
||
f, err := os.OpenFile(pathToConfig, os.O_TRUNC|os.O_WRONLY, os.ModePerm) | ||
|
||
if err != nil { | ||
return fmt.Errorf("%w", err) | ||
} | ||
|
||
encoder := yaml.NewEncoder(f) | ||
encoder.SetIndent(2) | ||
err = encoder.Encode(raw) | ||
|
||
if err != nil { | ||
return fmt.Errorf("%w", err) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.