|
6 | 6 | */ |
7 | 7 | import { ACTION, CONVENTIONAL_TYPE } from "../lib/constants"; |
8 | 8 | import { splitPath } from "../lib/paths"; |
9 | | - |
10 | | -// Package-related can be for 'build'. |
11 | | -const PACKAGE_DIRS = [ |
12 | | - // Rust |
13 | | - ".cargo", |
14 | | -], |
15 | | - PACKAGE_NAMES = [ |
16 | | - // Python |
17 | | - "requirements.txt", |
18 | | - "requirements-dev.txt", |
19 | | - "dev-requirements.txt", |
20 | | - "requirements-test.txt", |
21 | | - "test-requirements.txt", |
22 | | - |
23 | | - "Pipfile", |
24 | | - "Pipefile.lock", |
25 | | - |
26 | | - // Make Python package installable and manage external packages. |
27 | | - "pyproject.toml", |
28 | | - "setup.py", |
29 | | - |
30 | | - // Ruby |
31 | | - "Gemfile", |
32 | | - "Gemfile.lock", |
33 | | - |
34 | | - // NPM (Exclude package.json since it can be used for metadata and not |
35 | | - // package always changes.) |
36 | | - "package-lock.json", |
37 | | - "shrinkwrap.json", |
38 | | - "yarn.lock", |
39 | | - |
40 | | - // PHP |
41 | | - "composer.json", |
42 | | - "composer.lock", |
43 | | - |
44 | | - // Go |
45 | | - "go.mod", |
46 | | - "go.sum", |
47 | | - |
48 | | - // Rust |
49 | | - "Cargo.toml", |
50 | | - "Cargo.lock", |
51 | | - |
52 | | - // Deno |
53 | | - "deps.ts", |
54 | | - "test_deps.ts", |
55 | | - "dev_deps.ts", |
56 | | - "import_map.json", |
57 | | - ]; |
58 | | - |
59 | | -// Build system (scripts, configurations or tools) and package dependencies. |
60 | | -const BUILD_NAMES = [ |
61 | | - // Docker |
62 | | - ".dockerignore", |
63 | | - "Dockerfile", |
64 | | - "docker-compose.yml", |
65 | | - |
66 | | - // Make |
67 | | - "GNUmakefile", |
68 | | - "makefile", |
69 | | - "Makefile", |
70 | | - |
71 | | - // Ruby Rake - based on rake CLI message. |
72 | | - "rakefile", |
73 | | - "Rakefile", |
74 | | - "rakefile.rb", |
75 | | - "Rakefile.rb", |
76 | | - |
77 | | - "package.json", // Not necessarily package-related but always build-related. |
78 | | - |
79 | | - // Java |
80 | | - "gradlew", |
81 | | - "grailsw", |
82 | | - "micronaut-cli.yml", |
83 | | -], |
84 | | - BUILD_EXTENSIONS = [ |
85 | | - // Ruby installation |
86 | | - ".gemspec", |
87 | | - |
88 | | - // Windows |
89 | | - ".bat", |
90 | | - |
91 | | - // Java |
92 | | - ".gradle", |
93 | | - ]; |
94 | | - |
95 | | -// This may be too broad or clash with other areas such as CI or package, unless |
96 | | -// used close to LAST in the entire flow. |
97 | | -// Note also that prettier and ESLint configs with various extensions are |
98 | | -// handled in isConfigRelated so don't have to be listed explictly. Though those |
99 | | -// strings should be moved out of the function. |
100 | | -const CONFIG_EXTENSIONS = [".yml", ".yaml", ".json", ".toml", ".ini", ".cfg"], |
101 | | - CONFIG_DIRS = [".vscode"], |
102 | | - CONFIG_NAMES = [ |
103 | | - // Node |
104 | | - ".npmignore", |
105 | | - ".npmrc", |
106 | | - |
107 | | - // Git |
108 | | - ".gitignore", |
109 | | - |
110 | | - // EditorConfig |
111 | | - ".editorconfig", |
112 | | - |
113 | | - // Python |
114 | | - ".pylintrc", |
115 | | - "setup.cfg", |
116 | | - |
117 | | - // Node |
118 | | - ".browserslistrc", |
119 | | - "browserslist", |
120 | | - "commitlint.config.js", |
121 | | - |
122 | | - // TypeScript |
123 | | - "tsconfig.json", |
124 | | - "tslint.json", |
125 | | - |
126 | | - // Dotenv |
127 | | - ".env", |
128 | | - ".env.dev", |
129 | | - ".env.prod", |
130 | | - ".env.tempate", |
131 | | - ]; |
132 | | - |
133 | | -const CI_DIRS = [".circleci", ".github/workflows"], |
134 | | - CI_NAMES = [ |
135 | | - "netlify.toml", |
136 | | - "travis.yml", |
137 | | - "tox.ini", |
138 | | - |
139 | | - ".vscodeignore", |
140 | | - |
141 | | - "codecov.yml", |
142 | | - ".codecov.yml", |
143 | | - ".codeclimate.yml", |
144 | | - |
145 | | - // Zeit |
146 | | - "now.json", |
147 | | - ".nowignore", |
148 | | - "vercel.json", |
149 | | - ".vercelignore", |
150 | | - ]; |
151 | | - |
152 | | -// This can be useful for multi-file changes e.g. "Create 5 scripts" |
153 | | -// It might be easier to leave out this list and assume everything is a script |
154 | | -// unless it is a doc, markdown file or config. |
155 | | -const SCRIPT_EXTENSIONS = [ |
156 | | - ".html", |
157 | | - |
158 | | - ".css", |
159 | | - ".less", |
160 | | - ".scss", |
161 | | - |
162 | | - ".js", |
163 | | - ".jsx", |
164 | | - ".ts", |
165 | | - ".tsx", |
166 | | - ".mjs", |
167 | | - |
168 | | - ".py", |
169 | | - |
170 | | - ".rb", |
171 | | - |
172 | | - ".java", |
173 | | - ".jar", |
174 | | - |
175 | | - ".c", |
176 | | - ".h", |
177 | | - |
178 | | - ".rs", |
179 | | - |
180 | | - ".go", |
181 | | - |
182 | | - ".php", |
183 | | -], |
184 | | - // For "Update 5 shell scripts" |
185 | | - SHELL_SCRIPT_EXTENSION = ".sh"; |
186 | | - |
187 | | -const LICENSE_NAMES = [ |
188 | | - "LICENSE", |
189 | | - "LICENSE.txt", |
190 | | - "License.txt", |
191 | | - "LICENSE-source", |
192 | | -]; |
193 | | - |
194 | | -// TODO: Use. |
195 | | -const DOCS_DIRS = [ |
196 | | - "docs", |
197 | | - ".github/ISSUE_TEMPLATE", |
198 | | - ".github/PULL_REQUEST_TEMPLATE", |
199 | | -]; |
200 | | -// Anything in `/docs` will be covered already so this is for the root and any |
201 | | -// subdirectories. Don't worry about .rst as those are already cover as always |
202 | | -// docs. While `.md` could be content for a static site or docs site. |
203 | | -const DOC_NAMES = [ |
204 | | - "README", |
205 | | - "README.md", |
206 | | - "README.txt", |
207 | | - |
208 | | - "installation.md", |
209 | | - "usage.md", |
210 | | - "development.md", |
211 | | - "deploy.md", |
212 | | - |
213 | | - // GitHub docs. |
214 | | - "SECURITY.md", |
215 | | - "CONTRIBUTING.md", |
216 | | - "CHANGELOG.md", |
217 | | - "RELEASES.md", |
218 | | - "FUNDING.md", |
219 | | - "PULL_REQUEST_TEMPLATE.md", |
220 | | - "ISSUE_TEMPLATE.md", |
221 | | - "CODE_OF_CONDUCT.md", |
222 | | - |
223 | | - "MAINTAINERS.txt", |
224 | | - "CODEOWNERS", |
225 | | - |
226 | | - // Images. |
227 | | - "sample.png", |
228 | | - "sample-1.png", |
229 | | - "sample-2.png", |
230 | | - "screenshot.png", |
231 | | - "preview.png", |
232 | | -].map(name => name.toLowerCase()); |
| 9 | +import { |
| 10 | + BUILD_EXTENSIONS, |
| 11 | + BUILD_NAMES, |
| 12 | + CI_DIRS, |
| 13 | + CI_NAMES, |
| 14 | + CONFIG_DIRS, |
| 15 | + CONFIG_EXTENSIONS, |
| 16 | + CONFIG_NAMES, |
| 17 | + DOC_NAMES, |
| 18 | + LICENSE_NAMES, |
| 19 | + PACKAGE_NAMES |
| 20 | +} from "./convCommitConstants"; |
233 | 21 |
|
234 | 22 | /** |
235 | 23 | * Evaluate conventional commit prefix for a given file. |
@@ -266,10 +54,10 @@ export class ConventionalCommit { |
266 | 54 | /** |
267 | 55 | * Check if doc-related. |
268 | 56 | * |
269 | | - * Return true for `.rst`, README files and anything in the docs directory. |
| 57 | + * Return true for `.rst`, README files, and anything in the docs directory. |
270 | 58 | * |
271 | | - * TODO: For static sites, not all .md files are docs but that could be configured with a global |
272 | | - * flag. Or recognize Jekyll config. |
| 59 | + * TODO: For static sites, not all `.md` files are docs but that could be |
| 60 | + * configured with a global flag. Or recognize presence of Jekyll config file. |
273 | 61 | */ |
274 | 62 | isDocsRelated(): boolean { |
275 | 63 | if (this.extension === ".rst") { |
@@ -297,14 +85,15 @@ export class ConventionalCommit { |
297 | 85 | } |
298 | 86 |
|
299 | 87 | isCIRelated(): boolean { |
300 | | - // Assume flat structure and don't check for nesting in subdirs of CI_DIRS. |
| 88 | + // Assume flat structure and don't check for nesting in subdirs of |
| 89 | + // `CI_DIRS`. |
301 | 90 | return CI_DIRS.includes(this.dirPath) || CI_NAMES.includes(this.name); |
302 | 91 | } |
303 | 92 |
|
304 | | - // Broadly match eslint configs with any extension e.g. .json or .yml |
| 93 | + // Broadly match eslint configs with any extension e.g. `.json` or `.yml`. |
305 | 94 | // See https://eslint.org/docs/user-guide/configuring |
306 | 95 | // Same for prettier configs https://prettier.io/docs/en/configuration.html |
307 | | - // And tslint* as JSON or YAML and webpack*. |
| 96 | + // And `tslint*` as JSON or YAML and `webpack*`. |
308 | 97 | // See https://github.com/vscode-icons/vscode-icons/blob/master/src/iconsManifest/supportedExtensions.ts |
309 | 98 | isConfigRelated(): boolean { |
310 | 99 | return ( |
|
0 commit comments