repopo 0.3.2 → 0.5.0
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/CHANGELOG.md +65 -0
- package/README.md +37 -18
- package/THIRD-PARTY-LICENSES.txt +134 -36
- package/esm/api.d.ts +2 -0
- package/esm/api.d.ts.map +1 -0
- package/esm/api.js +2 -0
- package/esm/api.js.map +1 -0
- package/esm/baseCommand.d.ts +13 -43
- package/esm/baseCommand.d.ts.map +1 -1
- package/esm/baseCommand.js +27 -62
- package/esm/baseCommand.js.map +1 -1
- package/esm/commands/check.d.ts +2 -8
- package/esm/commands/check.d.ts.map +1 -1
- package/esm/commands/check.js +81 -89
- package/esm/commands/check.js.map +1 -1
- package/esm/commands/list.d.ts +1 -2
- package/esm/commands/list.d.ts.map +1 -1
- package/esm/commands/list.js +5 -6
- package/esm/commands/list.js.map +1 -1
- package/esm/config.d.ts +10 -5
- package/esm/config.d.ts.map +1 -1
- package/esm/config.js.map +1 -1
- package/esm/context.d.ts +29 -0
- package/esm/context.d.ts.map +1 -0
- package/esm/context.js +2 -0
- package/esm/context.js.map +1 -0
- package/esm/index.d.ts +11 -4
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +8 -0
- package/esm/index.js.map +1 -1
- package/esm/perf.d.ts.map +1 -1
- package/esm/perf.js +1 -5
- package/esm/perf.js.map +1 -1
- package/esm/policies/HtmlFileHeaders.d.ts +8 -0
- package/esm/policies/HtmlFileHeaders.d.ts.map +1 -0
- package/esm/policies/HtmlFileHeaders.js +17 -0
- package/esm/policies/HtmlFileHeaders.js.map +1 -0
- package/esm/policies/JsTsFileHeaders.d.ts +8 -0
- package/esm/policies/JsTsFileHeaders.d.ts.map +1 -0
- package/esm/policies/JsTsFileHeaders.js +24 -0
- package/esm/policies/JsTsFileHeaders.js.map +1 -0
- package/esm/policies/NoJsFileExtensions.d.ts +2 -0
- package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
- package/esm/policies/NoJsFileExtensions.js +2 -0
- package/esm/policies/NoJsFileExtensions.js.map +1 -1
- package/esm/policies/PackageJsonProperties.d.ts +6 -8
- package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
- package/esm/policies/PackageJsonProperties.js +37 -40
- package/esm/policies/PackageJsonProperties.js.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts +3 -2
- package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
- package/esm/policies/PackageJsonRepoDirectoryProperty.js +42 -39
- package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
- package/esm/policies/PackageJsonSorted.d.ts +7 -0
- package/esm/policies/PackageJsonSorted.d.ts.map +1 -0
- package/esm/policies/PackageJsonSorted.js +45 -0
- package/esm/policies/PackageJsonSorted.js.map +1 -0
- package/esm/policies/PackageScripts.d.ts +7 -0
- package/esm/policies/PackageScripts.d.ts.map +1 -0
- package/esm/policies/PackageScripts.js +25 -0
- package/esm/policies/PackageScripts.js.map +1 -0
- package/esm/policies/constants.d.ts +5 -0
- package/esm/policies/constants.d.ts.map +1 -0
- package/esm/policies/constants.js +5 -0
- package/esm/policies/constants.js.map +1 -0
- package/esm/policies.d.ts +7 -0
- package/esm/policies.d.ts.map +1 -0
- package/esm/policies.js +7 -0
- package/esm/policies.js.map +1 -0
- package/esm/policy.d.ts +31 -13
- package/esm/policy.d.ts.map +1 -1
- package/esm/policy.js +8 -20
- package/esm/policy.js.map +1 -1
- package/esm/policyGenerators/generateFileHeaderPolicy.d.ts +45 -0
- package/esm/policyGenerators/generateFileHeaderPolicy.d.ts.map +1 -0
- package/esm/policyGenerators/generateFileHeaderPolicy.js +61 -0
- package/esm/policyGenerators/generateFileHeaderPolicy.js.map +1 -0
- package/esm/policyGenerators/generatePackagePolicy.d.ts +9 -0
- package/esm/policyGenerators/generatePackagePolicy.d.ts.map +1 -0
- package/esm/policyGenerators/generatePackagePolicy.js +20 -0
- package/esm/policyGenerators/generatePackagePolicy.js.map +1 -0
- package/esm/tsdoc-metadata.json +1 -1
- package/oclif.manifest.json +45 -53
- package/package.json +43 -23
- package/esm/policies/PackageJsonSortedPolicy.d.ts +0 -6
- package/esm/policies/PackageJsonSortedPolicy.d.ts.map +0 -1
- package/esm/policies/PackageJsonSortedPolicy.js +0 -49
- package/esm/policies/PackageJsonSortedPolicy.js.map +0 -1
- package/esm/policies/SortTsconfigs.d.ts +0 -10
- package/esm/policies/SortTsconfigs.d.ts.map +0 -1
- package/esm/policies/SortTsconfigs.js +0 -33
- package/esm/policies/SortTsconfigs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# repopo
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Export all default policies _[`#213`](https://github.com/tylerbutler/tools-monorepo/pull/213) [`3fc530b`](https://github.com/tylerbutler/tools-monorepo/commit/3fc530bad66259339547b3d8ec12b9265daea9a5) [@tylerbutler](https://github.com/tylerbutler)_
|
|
8
|
+
|
|
9
|
+
repopo now exports all included policies individually so users can opt in and out of them in their config.
|
|
10
|
+
|
|
11
|
+
- New policies _[`#31`](https://github.com/tylerbutler/tools-monorepo/pull/31) [`c97a565`](https://github.com/tylerbutler/tools-monorepo/commit/c97a56518d9726667531aa71de9445fed8d56b96) [@tylerbutler](https://github.com/tylerbutler)_
|
|
12
|
+
|
|
13
|
+
- JsTsFileHeaders
|
|
14
|
+
- HtmlFileHeaders
|
|
15
|
+
- PackageScripts
|
|
16
|
+
|
|
17
|
+
- API changes: _[`#120`](https://github.com/tylerbutler/tools-monorepo/pull/120) [`1108950`](https://github.com/tylerbutler/tools-monorepo/commit/1108950a7732dcc3ac9b8da10bd014bfec6c45b7) [@tylerbutler](https://github.com/tylerbutler)_
|
|
18
|
+
|
|
19
|
+
- **Breaking change**: `PolicyConfig` was renamed to `RepopoConfig`.
|
|
20
|
+
- **Breaking change**: Removed several flags from the check command.
|
|
21
|
+
|
|
22
|
+
Other changes:
|
|
23
|
+
|
|
24
|
+
- Refactor check command for clarity (more to do)
|
|
25
|
+
|
|
26
|
+
- Functions to more easily create package.json handlers _[`#190`](https://github.com/tylerbutler/tools-monorepo/pull/190) [`84c4185`](https://github.com/tylerbutler/tools-monorepo/commit/84c4185e76186c3489a4b70e3a3015ba289df139) [@tylerbutler](https://github.com/tylerbutler)_
|
|
27
|
+
|
|
28
|
+
repopo now provides functions that can be used to generate policies for common files like package.json.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Update dependencies _[`#217`](https://github.com/tylerbutler/tools-monorepo/pull/217) [`dcec014`](https://github.com/tylerbutler/tools-monorepo/commit/dcec014dfb70e5804a7535b5b8b9a3406f3e623d) [@tylerbutler](https://github.com/tylerbutler)_
|
|
33
|
+
|
|
34
|
+
<details><summary>Updated 2 dependencies</summary>
|
|
35
|
+
|
|
36
|
+
<small>
|
|
37
|
+
|
|
38
|
+
[`dcec014`](https://github.com/tylerbutler/tools-monorepo/commit/dcec014dfb70e5804a7535b5b8b9a3406f3e623d)
|
|
39
|
+
|
|
40
|
+
</small>
|
|
41
|
+
|
|
42
|
+
- `@tylerbu/fundamentals@0.2.1`
|
|
43
|
+
- `@tylerbu/cli-api@0.7.1`
|
|
44
|
+
|
|
45
|
+
</details>
|
|
46
|
+
|
|
47
|
+
## 0.4.0
|
|
48
|
+
|
|
49
|
+
### Minor Changes
|
|
50
|
+
|
|
51
|
+
- Improve cross-platform path handling _[`#176`](https://github.com/tylerbutler/tools-monorepo/pull/176) [`2d095c7`](https://github.com/tylerbutler/tools-monorepo/commit/2d095c7828037fc58147d0aa487b736dbd345472) [@tylerbutler](https://github.com/tylerbutler)_
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
<details><summary>Updated 2 dependencies</summary>
|
|
56
|
+
|
|
57
|
+
<small>
|
|
58
|
+
|
|
59
|
+
[`a4b7624`](https://github.com/tylerbutler/tools-monorepo/commit/a4b7624cceea2f7246391c2d54329010cbb145ff) [`e27ae36`](https://github.com/tylerbutler/tools-monorepo/commit/e27ae3682d093eb61c2cb31de787ec378287db4f) [`ede1957`](https://github.com/tylerbutler/tools-monorepo/commit/ede19579ffc630f6e176046c6e11e170849a0d48) [`33b9c01`](https://github.com/tylerbutler/tools-monorepo/commit/33b9c01ed2d5d0c4bdb32262f549531650c48ad0) [`2d095c7`](https://github.com/tylerbutler/tools-monorepo/commit/2d095c7828037fc58147d0aa487b736dbd345472)
|
|
60
|
+
|
|
61
|
+
</small>
|
|
62
|
+
|
|
63
|
+
- `@tylerbu/cli-api@0.7.0`
|
|
64
|
+
- `sort-tsconfig@0.2.0`
|
|
65
|
+
|
|
66
|
+
</details>
|
|
67
|
+
|
|
3
68
|
## 0.3.2
|
|
4
69
|
|
|
5
70
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -7,12 +7,13 @@ file in your git repo, with a straightforward way to write your own policies.
|
|
|
7
7
|
* [repopo - police the files in your git repo with extensible policies](#repopo---police-the-files-in-your-git-repo-with-extensible-policies)
|
|
8
8
|
* [Configuring policies](#configuring-policies)
|
|
9
9
|
* [Included policies](#included-policies)
|
|
10
|
-
* [
|
|
10
|
+
* [Policy generators](#policy-generators)
|
|
11
|
+
* [CLI Usage](#cli-usage)
|
|
11
12
|
<!-- tocstop -->
|
|
12
13
|
|
|
13
14
|
# Configuring policies
|
|
14
15
|
|
|
15
|
-
Repopo and its policies can be configured in a repopo.config.ts (or
|
|
16
|
+
Repopo and its policies can be configured in a `repopo.config.ts` (or `.cjs`, or `.mjs`) file in the root of the repo. Using a
|
|
16
17
|
TypeScript configuration file is recommended.
|
|
17
18
|
|
|
18
19
|
The policy config must export a default object of the type `PolicyConfig`.
|
|
@@ -36,6 +37,14 @@ policy settings as the value.
|
|
|
36
37
|
|
|
37
38
|
repopo includes the following policies. All of the included policies are enabled by default.
|
|
38
39
|
|
|
40
|
+
## HtmlFileHeaders and JsTsFileHeaders
|
|
41
|
+
|
|
42
|
+
These policies set a common file header for JavaScript/TypeScript and HTML files.
|
|
43
|
+
|
|
44
|
+
### Configuration
|
|
45
|
+
|
|
46
|
+
TODO
|
|
47
|
+
|
|
39
48
|
## NoJsFileExtensions
|
|
40
49
|
|
|
41
50
|
The NoJsFileExtensions policy checks for JavaScript source files that just use the .js file extension. Such files may be
|
|
@@ -61,6 +70,10 @@ const config: PolicyConfig = {
|
|
|
61
70
|
license: "MIT",
|
|
62
71
|
author: "Tyler Butler <tyler@tylerbutler.com>",
|
|
63
72
|
bugs: "https://github.com/tylerbutler/tools-monorepo/issues",
|
|
73
|
+
repository: {
|
|
74
|
+
type: "git",
|
|
75
|
+
url: "git+https://github.com/tylerbutler/tools-monorepo.git",
|
|
76
|
+
}
|
|
64
77
|
}
|
|
65
78
|
}
|
|
66
79
|
}
|
|
@@ -72,7 +85,17 @@ const config: PolicyConfig = {
|
|
|
72
85
|
A RepoPolicy that checks that the `repository.directory` property in package.json is set correctly. If the repository
|
|
73
86
|
field is a string instead of an object the package will be ignored.
|
|
74
87
|
|
|
75
|
-
#
|
|
88
|
+
# Policy generators
|
|
89
|
+
|
|
90
|
+
There are some filetypes that often have policies applied to them, like package.json. You can use the policy generator
|
|
91
|
+
functions to generate policies for those filetypes. Using the generators is not required; they simply reduce the amount
|
|
92
|
+
of boilerplate code you have to write for a policy.
|
|
93
|
+
|
|
94
|
+
## generatePackagePolicy
|
|
95
|
+
|
|
96
|
+
Use `generatePackagePolicy` to generate policies for package.json files.
|
|
97
|
+
|
|
98
|
+
# CLI Usage
|
|
76
99
|
|
|
77
100
|
<!-- commands -->
|
|
78
101
|
* [`repopo check`](#repopo-check)
|
|
@@ -84,16 +107,15 @@ Checks and applies policies to the files in the repository.
|
|
|
84
107
|
|
|
85
108
|
```
|
|
86
109
|
USAGE
|
|
87
|
-
$ repopo check [-
|
|
110
|
+
$ repopo check [-v | --quiet] [-f] [--stdin]
|
|
88
111
|
|
|
89
112
|
FLAGS
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
--stdin Read list of files from stdin.
|
|
113
|
+
-f, --fix Fix errors if possible.
|
|
114
|
+
--stdin Read list of files from stdin.
|
|
115
|
+
|
|
116
|
+
LOGGING FLAGS
|
|
117
|
+
-v, --verbose Enable verbose logging.
|
|
118
|
+
--quiet Disable all logging.
|
|
97
119
|
```
|
|
98
120
|
|
|
99
121
|
_See code: [src/commands/check.ts](https://github.com/tylerbutler/tools-monorepo/blob/main/packages/repopo/src/commands/check.ts)_
|
|
@@ -104,14 +126,11 @@ Lists the policies configured to run.
|
|
|
104
126
|
|
|
105
127
|
```
|
|
106
128
|
USAGE
|
|
107
|
-
$ repopo list [-
|
|
129
|
+
$ repopo list [-v | --quiet]
|
|
108
130
|
|
|
109
|
-
FLAGS
|
|
110
|
-
-
|
|
111
|
-
|
|
112
|
-
-d, --policy=<value> Filter policies to apply by <regex>. Only policies with a name matching the regex will
|
|
113
|
-
be applied.
|
|
114
|
-
-p, --path=<value> Filter file paths by <regex>.
|
|
131
|
+
LOGGING FLAGS
|
|
132
|
+
-v, --verbose Enable verbose logging.
|
|
133
|
+
--quiet Disable all logging.
|
|
115
134
|
```
|
|
116
135
|
|
|
117
136
|
_See code: [src/commands/list.ts](https://github.com/tylerbutler/tools-monorepo/blob/main/packages/repopo/src/commands/list.ts)_
|
package/THIRD-PARTY-LICENSES.txt
CHANGED
|
@@ -3,13 +3,13 @@ https://www.npmjs.com/package/generate-license-file
|
|
|
3
3
|
|
|
4
4
|
The following npm package may be included in this product:
|
|
5
5
|
|
|
6
|
-
-
|
|
6
|
+
- jsonfile@6.1.0
|
|
7
7
|
|
|
8
|
-
This package contains the following license
|
|
8
|
+
This package contains the following license:
|
|
9
9
|
|
|
10
10
|
(The MIT License)
|
|
11
11
|
|
|
12
|
-
Copyright (c)
|
|
12
|
+
Copyright (c) 2012-2015, JP Richardson <jprichardson@gmail.com>
|
|
13
13
|
|
|
14
14
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
|
15
15
|
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
|
@@ -27,9 +27,42 @@ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHE
|
|
|
27
27
|
|
|
28
28
|
The following npm package may be included in this product:
|
|
29
29
|
|
|
30
|
-
- @
|
|
30
|
+
- @rushstack/node-core-library@5.13.0
|
|
31
31
|
|
|
32
|
-
This package contains the following license
|
|
32
|
+
This package contains the following license:
|
|
33
|
+
|
|
34
|
+
@rushstack/node-core-library
|
|
35
|
+
|
|
36
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
37
|
+
|
|
38
|
+
MIT License
|
|
39
|
+
|
|
40
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
41
|
+
a copy of this software and associated documentation files (the
|
|
42
|
+
"Software"), to deal in the Software without restriction, including
|
|
43
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
44
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
45
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
46
|
+
the following conditions:
|
|
47
|
+
|
|
48
|
+
The above copyright notice and this permission notice shall be
|
|
49
|
+
included in all copies or substantial portions of the Software.
|
|
50
|
+
|
|
51
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
52
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
53
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
54
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
55
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
56
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
57
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
58
|
+
|
|
59
|
+
-----------
|
|
60
|
+
|
|
61
|
+
The following npm package may be included in this product:
|
|
62
|
+
|
|
63
|
+
- @fluid-tools/build-infrastructure@0.56.0
|
|
64
|
+
|
|
65
|
+
This package contains the following license:
|
|
33
66
|
|
|
34
67
|
Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
35
68
|
|
|
@@ -55,12 +88,46 @@ SOFTWARE.
|
|
|
55
88
|
|
|
56
89
|
-----------
|
|
57
90
|
|
|
91
|
+
The following npm package may be included in this product:
|
|
92
|
+
|
|
93
|
+
- picocolors@1.1.1
|
|
94
|
+
|
|
95
|
+
This package contains the following license:
|
|
96
|
+
|
|
97
|
+
ISC License
|
|
98
|
+
|
|
99
|
+
Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov
|
|
100
|
+
|
|
101
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
102
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
103
|
+
copyright notice and this permission notice appear in all copies.
|
|
104
|
+
|
|
105
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
106
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
107
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
108
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
109
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
110
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
111
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
112
|
+
|
|
113
|
+
-----------
|
|
114
|
+
|
|
115
|
+
The following npm package may be included in this product:
|
|
116
|
+
|
|
117
|
+
- simple-git@3.27.0
|
|
118
|
+
|
|
119
|
+
This package contains the following license:
|
|
120
|
+
|
|
121
|
+
MIT
|
|
122
|
+
|
|
123
|
+
-----------
|
|
124
|
+
|
|
58
125
|
The following npm packages may be included in this product:
|
|
59
126
|
|
|
60
|
-
- @oclif/core@4.
|
|
61
|
-
- @oclif/plugin-help@6.2.
|
|
127
|
+
- @oclif/core@4.2.10
|
|
128
|
+
- @oclif/plugin-help@6.2.27
|
|
62
129
|
|
|
63
|
-
These packages each contain the following license
|
|
130
|
+
These packages each contain the following license:
|
|
64
131
|
|
|
65
132
|
MIT License
|
|
66
133
|
|
|
@@ -88,13 +155,13 @@ SOFTWARE.
|
|
|
88
155
|
|
|
89
156
|
The following npm package may be included in this product:
|
|
90
157
|
|
|
91
|
-
-
|
|
158
|
+
- microdiff@1.5.0
|
|
92
159
|
|
|
93
|
-
This package contains the following license
|
|
160
|
+
This package contains the following license:
|
|
94
161
|
|
|
95
162
|
MIT License
|
|
96
163
|
|
|
97
|
-
Copyright (c)
|
|
164
|
+
Copyright (c) 2021 AsyncBanana
|
|
98
165
|
|
|
99
166
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
100
167
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -118,31 +185,13 @@ SOFTWARE.
|
|
|
118
185
|
|
|
119
186
|
The following npm package may be included in this product:
|
|
120
187
|
|
|
121
|
-
-
|
|
122
|
-
|
|
123
|
-
This package contains the following license and notice below:
|
|
124
|
-
|
|
125
|
-
MIT License
|
|
126
|
-
|
|
127
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
128
|
-
|
|
129
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
130
|
-
|
|
131
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
132
|
-
|
|
133
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
134
|
-
|
|
135
|
-
-----------
|
|
136
|
-
|
|
137
|
-
The following npm package may be included in this product:
|
|
138
|
-
|
|
139
|
-
- @tylerbu/cli-api@0.2.0
|
|
188
|
+
- defu@6.1.4
|
|
140
189
|
|
|
141
|
-
This package contains the following license
|
|
190
|
+
This package contains the following license:
|
|
142
191
|
|
|
143
192
|
MIT License
|
|
144
193
|
|
|
145
|
-
Copyright (c)
|
|
194
|
+
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
|
146
195
|
|
|
147
196
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
148
197
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -166,13 +215,13 @@ SOFTWARE.
|
|
|
166
215
|
|
|
167
216
|
The following npm package may be included in this product:
|
|
168
217
|
|
|
169
|
-
-
|
|
218
|
+
- pathe@2.0.3
|
|
170
219
|
|
|
171
|
-
This package contains the following license
|
|
220
|
+
This package contains the following license:
|
|
172
221
|
|
|
173
|
-
|
|
222
|
+
MIT License
|
|
174
223
|
|
|
175
|
-
Copyright (c)
|
|
224
|
+
Copyright (c) Pooya Parsa <pooya@pi0.io> - Daniel Roe <daniel@roe.dev>
|
|
176
225
|
|
|
177
226
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
178
227
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -192,6 +241,55 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
192
241
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
193
242
|
SOFTWARE.
|
|
194
243
|
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
Copyright Joyent, Inc. and other Node contributors.
|
|
247
|
+
|
|
248
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
249
|
+
copy of this software and associated documentation files (the
|
|
250
|
+
"Software"), to deal in the Software without restriction, including
|
|
251
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
252
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
253
|
+
persons to whom the Software is furnished to do so, subject to the
|
|
254
|
+
following conditions:
|
|
255
|
+
|
|
256
|
+
The above copyright notice and this permission notice shall be included
|
|
257
|
+
in all copies or substantial portions of the Software.
|
|
258
|
+
|
|
259
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
260
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
261
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
262
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
263
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
264
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
265
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
Bundled zeptomatch (https://github.com/fabiospampinato/zeptomatch)
|
|
270
|
+
|
|
271
|
+
The MIT License (MIT)
|
|
272
|
+
|
|
273
|
+
Copyright (c) 2023-present Fabio Spampinato
|
|
274
|
+
|
|
275
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
276
|
+
copy of this software and associated documentation files (the "Software"),
|
|
277
|
+
to deal in the Software without restriction, including without limitation
|
|
278
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
279
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
|
280
|
+
Software is furnished to do so, subject to the following conditions:
|
|
281
|
+
|
|
282
|
+
The above copyright notice and this permission notice shall be included in
|
|
283
|
+
all copies or substantial portions of the Software.
|
|
284
|
+
|
|
285
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
286
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
287
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
288
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
289
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
290
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
291
|
+
DEALINGS IN THE SOFTWARE.
|
|
292
|
+
|
|
195
293
|
-----------
|
|
196
294
|
|
|
197
295
|
This file was generated with the generate-license-file npm package!
|
package/esm/api.d.ts
ADDED
package/esm/api.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":""}
|
package/esm/api.js
ADDED
package/esm/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"","sourcesContent":[""]}
|
package/esm/baseCommand.d.ts
CHANGED
|
@@ -1,52 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
3
|
-
import { type
|
|
4
|
-
import
|
|
1
|
+
import { CommandWithConfig, type CommandWithContext, type RequiresGit } from "@tylerbu/cli-api";
|
|
2
|
+
import { type SimpleGit } from "simple-git";
|
|
3
|
+
import { type RepopoConfig } from "./config.js";
|
|
4
|
+
import type { RepopoCommandContext } from "./context.js";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export interface PolicyCommandContext {
|
|
9
|
-
/**
|
|
10
|
-
* A regular expression used to filter selected files.
|
|
11
|
-
*/
|
|
12
|
-
pathRegex: RegExp;
|
|
13
|
-
/**
|
|
14
|
-
* A list of regular expressions used to exclude files from all handlers.
|
|
15
|
-
*/
|
|
16
|
-
excludeFiles: RegExp[];
|
|
17
|
-
/**
|
|
18
|
-
* A list of handlers to apply to selected files.
|
|
19
|
-
*/
|
|
20
|
-
policies: RepoPolicy[];
|
|
21
|
-
/**
|
|
22
|
-
* A per-handler list of regular expressions used to exclude files from specific handlers.
|
|
23
|
-
*/
|
|
24
|
-
excludePoliciesForFiles: ExcludedPolicyFileMap;
|
|
25
|
-
/**
|
|
26
|
-
* Path to the root of the git repo.
|
|
27
|
-
*/
|
|
28
|
-
gitRoot: string;
|
|
29
|
-
/**
|
|
30
|
-
* Performance information for each handler.
|
|
31
|
-
*/
|
|
32
|
-
perfStats: PolicyHandlerPerfStats;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* This command lists all the policies configured to run.
|
|
6
|
+
* This class is the base for all repopo commands. It contains common flags and config loading.
|
|
36
7
|
*/
|
|
37
8
|
export declare abstract class BaseRepopoCommand<T extends typeof BaseRepopoCommand & {
|
|
38
|
-
args: typeof
|
|
39
|
-
flags: typeof
|
|
40
|
-
}> extends
|
|
9
|
+
args: typeof CommandWithConfig.args;
|
|
10
|
+
flags: typeof CommandWithConfig.flags;
|
|
11
|
+
}> extends CommandWithConfig<T, RepopoConfig> implements CommandWithContext<RepopoCommandContext>, RequiresGit {
|
|
12
|
+
protected defaultConfig: RepopoConfig;
|
|
41
13
|
static readonly flags: {
|
|
42
14
|
readonly config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
43
|
-
readonly policy: import("@oclif/core/interfaces").OptionFlag<RegExp | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
44
|
-
readonly excludePolicy: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
45
|
-
readonly path: import("@oclif/core/interfaces").OptionFlag<RegExp | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
46
15
|
};
|
|
47
|
-
private
|
|
48
|
-
|
|
16
|
+
private _git;
|
|
17
|
+
get git(): SimpleGit;
|
|
49
18
|
init(): Promise<void>;
|
|
19
|
+
private _context;
|
|
20
|
+
getContext(): Promise<RepopoCommandContext>;
|
|
50
21
|
}
|
|
51
|
-
export type ExcludedPolicyFileMap = Map<PolicyName, RegExp[]>;
|
|
52
22
|
//# sourceMappingURL=baseCommand.d.ts.map
|
package/esm/baseCommand.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseCommand.d.ts","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"baseCommand.d.ts","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,YAAY,CAAC;AACvD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAyB,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAIhF;;GAEG;AACH,8BAAsB,iBAAiB,CACrC,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,iBAAiB,CAAC,IAAI,CAAC;IACpC,KAAK,EAAE,OAAO,iBAAiB,CAAC,KAAK,CAAC;CACtC,CAEF,SAAQ,iBAAiB,CAAC,CAAC,EAAE,YAAY,CACzC,YAAW,kBAAkB,CAAC,oBAAoB,CAAC,EAAE,WAAW;IAEhE,UAAmB,aAAa,eAAuB;IAEvD,gBAAyB,KAAK;gCAXK,wBACjB,wCACD,wBAChB;MAUU;IAEX,OAAO,CAAC,IAAI,CAAwB;IACpC,IAAW,GAAG,IAAI,SAAS,CAK1B;IAEqB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B3C,OAAO,CAAC,QAAQ,CAAmC;IAGtC,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC;CAMxD"}
|
package/esm/baseCommand.js
CHANGED
|
@@ -1,87 +1,52 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CommandWithConfig, } from "@tylerbu/cli-api";
|
|
2
|
+
import { findGitRootSync } from "@tylerbu/fundamentals/git";
|
|
3
|
+
import { simpleGit } from "simple-git";
|
|
4
|
+
import { DefaultPolicyConfig } from "./config.js";
|
|
3
5
|
import { newPerfStats } from "./perf.js";
|
|
4
6
|
import { DefaultPolicies } from "./policy.js";
|
|
5
|
-
const DEFAULT_PATH_REGEX = /.?/;
|
|
6
7
|
/**
|
|
7
|
-
* This
|
|
8
|
+
* This class is the base for all repopo commands. It contains common flags and config loading.
|
|
8
9
|
*/
|
|
9
|
-
export class BaseRepopoCommand extends
|
|
10
|
+
export class BaseRepopoCommand extends CommandWithConfig {
|
|
11
|
+
defaultConfig = DefaultPolicyConfig;
|
|
10
12
|
static flags = {
|
|
11
|
-
|
|
12
|
-
description: "Filter policies to apply by <regex>. Only policies with a name matching the regex will be applied.",
|
|
13
|
-
required: false,
|
|
14
|
-
char: "d",
|
|
15
|
-
}),
|
|
16
|
-
excludePolicy: Flags.string({
|
|
17
|
-
char: "D",
|
|
18
|
-
description: "Exclude policies by name. Can be specified multiple times to exclude multiple policies.",
|
|
19
|
-
exclusive: ["policy"],
|
|
20
|
-
multiple: true,
|
|
21
|
-
}),
|
|
22
|
-
path: RegExpFlag({
|
|
23
|
-
description: "Filter file paths by <regex>.",
|
|
24
|
-
required: false,
|
|
25
|
-
char: "p",
|
|
26
|
-
}),
|
|
27
|
-
...GitCommand.flags,
|
|
13
|
+
...CommandWithConfig.flags,
|
|
28
14
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (this.
|
|
32
|
-
throw new Error("
|
|
15
|
+
_git;
|
|
16
|
+
get git() {
|
|
17
|
+
if (this._git === undefined) {
|
|
18
|
+
throw new Error("git property is undefined");
|
|
33
19
|
}
|
|
34
|
-
return this.
|
|
20
|
+
return this._git;
|
|
35
21
|
}
|
|
36
22
|
async init() {
|
|
37
23
|
await super.init();
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
let policies = config?.policies ?? DefaultPolicies;
|
|
41
|
-
policies =
|
|
42
|
-
policies.filter((h) => {
|
|
43
|
-
if (flags.excludePolicy === undefined ||
|
|
44
|
-
flags.excludePolicy.length === 0) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
const shouldRun = flags.excludePolicy?.includes(h.name) === false;
|
|
48
|
-
if (!shouldRun) {
|
|
49
|
-
this.info(`Disabled policy: ${h.name}`);
|
|
50
|
-
}
|
|
51
|
-
return shouldRun;
|
|
52
|
-
}) ?? [];
|
|
53
|
-
if (flags.policy !== undefined) {
|
|
54
|
-
this.info(`Filtering handlers by regex: ${flags.policy}`);
|
|
55
|
-
policies = policies.filter((h) => flags.policy?.test(h.name));
|
|
56
|
-
}
|
|
57
|
-
const excludeFiles = config?.excludeFiles?.map((e) => toRegExp(e)) ?? [];
|
|
58
|
-
const excludePoliciesForFilesRaw = config?.excludePoliciesForFiles;
|
|
24
|
+
const excludeFiles = this.commandConfig?.excludeFiles?.map((e) => new RegExp(e, "i")) ?? [];
|
|
25
|
+
const excludePoliciesForFilesRaw = this.commandConfig?.excludePoliciesForFiles;
|
|
59
26
|
const excludePoliciesForFiles = new Map();
|
|
60
27
|
if (excludePoliciesForFilesRaw) {
|
|
61
28
|
for (const [policyName, filters] of Object.entries(excludePoliciesForFilesRaw)) {
|
|
62
|
-
const regexes = filters.map((e) =>
|
|
29
|
+
const regexes = filters.map((e) => new RegExp(e, "i"));
|
|
63
30
|
excludePoliciesForFiles.set(policyName, regexes);
|
|
64
31
|
}
|
|
65
32
|
}
|
|
66
|
-
const gitRoot =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.info(`Filtering file paths by regex: ${pathRegex}`);
|
|
70
|
-
}
|
|
71
|
-
this.context = {
|
|
72
|
-
pathRegex,
|
|
33
|
+
const gitRoot = findGitRootSync();
|
|
34
|
+
this._git = simpleGit({ baseDir: gitRoot });
|
|
35
|
+
this._context = {
|
|
73
36
|
excludeFiles,
|
|
74
|
-
policies,
|
|
37
|
+
policies: this.commandConfig?.policies ?? DefaultPolicies,
|
|
75
38
|
excludePoliciesForFiles,
|
|
76
39
|
gitRoot,
|
|
77
40
|
perfStats: newPerfStats(),
|
|
78
41
|
};
|
|
79
42
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
43
|
+
_context;
|
|
44
|
+
// biome-ignore lint/suspicious/useAwait: interface defines this as async
|
|
45
|
+
async getContext() {
|
|
46
|
+
if (this._context === undefined) {
|
|
47
|
+
throw new Error("Context not initialized.");
|
|
48
|
+
}
|
|
49
|
+
return this._context;
|
|
84
50
|
}
|
|
85
|
-
return input;
|
|
86
51
|
}
|
|
87
52
|
//# sourceMappingURL=baseCommand.js.map
|
package/esm/baseCommand.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseCommand.js","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"baseCommand.js","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,iBAAiB,GAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAkB,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAqB,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,OAAgB,iBAMrB,SAAQ,iBAAkC;IAGvB,aAAa,GAAG,mBAAmB,CAAC;IAEvD,MAAM,CAAmB,KAAK,GAAG;QAChC,GAAG,iBAAiB,CAAC,KAAK;KACjB,CAAC;IAEH,IAAI,CAAwB;IACpC,IAAW,GAAG;QACb,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEe,KAAK,CAAC,IAAI;QACzB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAEnB,MAAM,YAAY,GACjB,IAAI,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAExE,MAAM,0BAA0B,GAC/B,IAAI,CAAC,aAAa,EAAE,uBAAuB,CAAC;QAE7C,MAAM,uBAAuB,GAA0B,IAAI,GAAG,EAAE,CAAC;QACjE,IAAI,0BAA0B,EAAE,CAAC;YAChC,KAAK,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CACjD,0BAA0B,CAC1B,EAAE,CAAC;gBACH,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;gBACvD,uBAAuB,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAClD,CAAC;QACF,CAAC;QAED,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG;YACf,YAAY;YACZ,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,IAAI,eAAe;YACzD,uBAAuB;YACvB,OAAO;YACP,SAAS,EAAE,YAAY,EAAE;SACzB,CAAC;IACH,CAAC;IAEO,QAAQ,CAAmC;IAEnD,yEAAyE;IAClE,KAAK,CAAC,UAAU;QACtB,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC","sourcesContent":["import {\n\tCommandWithConfig,\n\ttype CommandWithContext,\n\ttype RequiresGit,\n} from \"@tylerbu/cli-api\";\nimport { findGitRootSync } from \"@tylerbu/fundamentals/git\";\nimport { type SimpleGit, simpleGit } from \"simple-git\";\nimport { DefaultPolicyConfig, type RepopoConfig } from \"./config.js\";\nimport type { ExcludedPolicyFileMap, RepopoCommandContext } from \"./context.js\";\nimport { newPerfStats } from \"./perf.js\";\nimport { DefaultPolicies } from \"./policy.js\";\n\n/**\n * This class is the base for all repopo commands. It contains common flags and config loading.\n */\nexport abstract class BaseRepopoCommand<\n\t\tT extends typeof BaseRepopoCommand & {\n\t\t\targs: typeof CommandWithConfig.args;\n\t\t\tflags: typeof CommandWithConfig.flags;\n\t\t},\n\t>\n\textends CommandWithConfig<T, RepopoConfig>\n\timplements CommandWithContext<RepopoCommandContext>, RequiresGit\n{\n\tprotected override defaultConfig = DefaultPolicyConfig;\n\n\tstatic override readonly flags = {\n\t\t...CommandWithConfig.flags,\n\t} as const;\n\n\tprivate _git: SimpleGit | undefined;\n\tpublic get git(): SimpleGit {\n\t\tif (this._git === undefined) {\n\t\t\tthrow new Error(\"git property is undefined\");\n\t\t}\n\t\treturn this._git;\n\t}\n\n\tpublic override async init(): Promise<void> {\n\t\tawait super.init();\n\n\t\tconst excludeFiles: RegExp[] =\n\t\t\tthis.commandConfig?.excludeFiles?.map((e) => new RegExp(e, \"i\")) ?? [];\n\n\t\tconst excludePoliciesForFilesRaw =\n\t\t\tthis.commandConfig?.excludePoliciesForFiles;\n\n\t\tconst excludePoliciesForFiles: ExcludedPolicyFileMap = new Map();\n\t\tif (excludePoliciesForFilesRaw) {\n\t\t\tfor (const [policyName, filters] of Object.entries(\n\t\t\t\texcludePoliciesForFilesRaw,\n\t\t\t)) {\n\t\t\t\tconst regexes = filters.map((e) => new RegExp(e, \"i\"));\n\t\t\t\texcludePoliciesForFiles.set(policyName, regexes);\n\t\t\t}\n\t\t}\n\n\t\tconst gitRoot = findGitRootSync();\n\t\tthis._git = simpleGit({ baseDir: gitRoot });\n\t\tthis._context = {\n\t\t\texcludeFiles,\n\t\t\tpolicies: this.commandConfig?.policies ?? DefaultPolicies,\n\t\t\texcludePoliciesForFiles,\n\t\t\tgitRoot,\n\t\t\tperfStats: newPerfStats(),\n\t\t};\n\t}\n\n\tprivate _context: RepopoCommandContext | undefined;\n\n\t// biome-ignore lint/suspicious/useAwait: interface defines this as async\n\tpublic async getContext(): Promise<RepopoCommandContext> {\n\t\tif (this._context === undefined) {\n\t\t\tthrow new Error(\"Context not initialized.\");\n\t\t}\n\t\treturn this._context;\n\t}\n}\n"]}
|