forked from ampproject/amphtml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🏗 Shorter, uniform ignore lists (ampproject#36357)
Fixes ampproject#36354 ### `amp clean` - Uses `.gitignore` as source of truth - Finds paths recursively like `.gitignore` does: > #### [Pattern format][1] > [1]: https://git-scm.com/docs/gitignore#_pattern_format > > If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular `.gitignore` file itself. Otherwise the pattern may also match at any level below the `.gitignore` level. ### `amp check-ignore-list` - Ensures that `.gitignore`, `.eslintignore` and `.prettierignore` stay in sync - Runs during CI checks. ### `.*ignore` files - Use a shorter list to take advantage of recursive behavior - Added header to determine uniform section
- Loading branch information
1 parent
6feea0e
commit 530a457
Showing
8 changed files
with
168 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,32 @@ | ||
# Local cache directories | ||
# Keep this list in sync with .gitignore, .prettierignore, and build-system/tasks/clean.js | ||
.babel-cache | ||
.css-cache | ||
.jss-cache | ||
.pre-closure-cache | ||
# Files and directories explicitly ignored by eslint | ||
**/node_modules/** | ||
build-system/babel-plugins/**/fixtures/**/*.js | ||
build-system/babel-plugins/**/fixtures/**/*.mjs | ||
build-system/tasks/make-extension/template/**/* | ||
examples/amp-script/todomvc.ssr.js | ||
examples/amp-script/vue-todomvc.js | ||
extensions/amp-a4a/0.1/test/testdata/** | ||
src/purifier/noop.js | ||
testing/local-amp-chrome-extension/** | ||
third_party/** | ||
validator/** | ||
|
||
# [GLOBALLY IGNORED] | ||
# (Don't edit or remove the above comment!) | ||
# The rules below are synced between .gitignore and .prettierignore, and are | ||
# removed by `amp clean`. | ||
|
||
# Output directories | ||
# Keep this list in sync with .gitignore, .prettierignore, and build-system/tasks/clean.js | ||
.*cache | ||
.amp-dep-check | ||
build | ||
build-system/dist | ||
build-system/server/new-server/transforms/dist | ||
build-system/tasks/performance/cache | ||
build-system/tasks/performance/results.json | ||
dist | ||
dist.3p | ||
dist.tools | ||
export | ||
examples/storybook | ||
extensions/**/dist | ||
/release | ||
result-reports | ||
src/purifier/dist | ||
test/coverage | ||
test/coverage-e2e | ||
validator/**/dist | ||
validator/export | ||
|
||
# User configuration files | ||
# Keep this list in sync with .gitignore, .prettierignore, and build-system/tasks/clean.js | ||
build-system/global-configs/custom-config.json | ||
build-system/global-configs/custom-flavors-config.json | ||
|
||
# Files and directories explicitly ignored by eslint | ||
**/node_modules/** | ||
build-system/babel-plugins/**/fixtures/**/*.js | ||
build-system/babel-plugins/**/fixtures/**/*.mjs | ||
build-system/tasks/make-extension/template/**/* | ||
examples/amp-script/todomvc.ssr.js | ||
examples/amp-script/vue-todomvc.js | ||
extensions/amp-a4a/0.1/test/testdata/** | ||
src/purifier/noop.js | ||
testing/local-amp-chrome-extension/** | ||
third_party/** | ||
validator/** |
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 |
---|---|---|
@@ -1,37 +1,23 @@ | ||
# Local cache directories | ||
# Keep this list in sync with .gitignore, .eslintignore, and build-system/tasks/clean.js | ||
.babel-cache | ||
.css-cache | ||
.jss-cache | ||
.pre-closure-cache | ||
# Files and directories explicitly ignored | ||
**/package*.json | ||
**/node_modules/** | ||
|
||
# Output directories | ||
# Keep this list in sync with .gitignore, .eslintignore, and build-system/tasks/clean.js | ||
# [GLOBALLY IGNORED] | ||
# (Don't edit or remove the above comment!) | ||
# The rules below are synced between .gitignore and .prettierignore, and are | ||
# removed by `amp clean`. | ||
|
||
.*cache | ||
.amp-dep-check | ||
build | ||
build-system/dist | ||
build-system/server/new-server/transforms/dist | ||
build-system/tasks/performance/cache | ||
build-system/tasks/performance/results.json | ||
dist | ||
dist.3p | ||
dist.tools | ||
export | ||
examples/storybook | ||
extensions/**/dist | ||
/release | ||
result-reports | ||
src/purifier/dist | ||
test/coverage | ||
test/coverage-e2e | ||
validator/**/dist | ||
validator/export | ||
|
||
# User configuration files | ||
# Keep this list in sync with .gitignore, .eslintignore, and build-system/tasks/clean.js | ||
build-system/global-configs/custom-config.json | ||
build-system/global-configs/custom-flavors-config.json | ||
|
||
# Files and directories explicitly ignored by prettier | ||
**/package*.json | ||
**/node_modules/** |
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
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,44 @@ | ||
const {readFile} = require('fs-extra'); | ||
const {writeDiffOrFail} = require('../common/diff'); | ||
|
||
const ignoreFile = '.gitignore'; | ||
const syncIgnoreFiles = ['.prettierignore', '.eslintignore']; | ||
|
||
const ignoreListFiles = [ignoreFile, ...syncIgnoreFiles]; | ||
|
||
const header = '# [GLOBALLY IGNORED]'; | ||
|
||
/** | ||
* @param {string} source | ||
* @return {string[]} | ||
*/ | ||
function splitIgnoreListByHeader(source) { | ||
return source.split(header, 2); | ||
} | ||
|
||
/** | ||
* @return {!Promise} | ||
*/ | ||
async function checkIgnoreLists() { | ||
const [, below] = splitIgnoreListByHeader(await readFile(ignoreFile, 'utf8')); | ||
|
||
for (const file of syncIgnoreFiles) { | ||
const [above] = splitIgnoreListByHeader(await readFile(file, 'utf8')); | ||
const tentative = [above, below].join(header); | ||
await writeDiffOrFail('check-ignore-list', file, tentative); | ||
} | ||
} | ||
|
||
checkIgnoreLists.description = | ||
'Check ignore lists to make sure they are in sync'; | ||
|
||
checkIgnoreLists.flags = { | ||
'fix': `Fix files out of sync`, | ||
}; | ||
|
||
module.exports = { | ||
checkIgnoreLists, | ||
ignoreListFiles, | ||
ignoreFile, | ||
splitIgnoreListByHeader, | ||
}; |
Oops, something went wrong.