repopo 0.3.2 → 0.4.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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # repopo
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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)_
8
+
9
+ ### Patch Changes
10
+
11
+ <details><summary>Updated 2 dependencies</summary>
12
+
13
+ <small>
14
+
15
+ [`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)
16
+
17
+ </small>
18
+
19
+ - `@tylerbu/cli-api@0.7.0`
20
+ - `sort-tsconfig@0.2.0`
21
+
22
+ </details>
23
+
3
24
  ## 0.3.2
4
25
 
5
26
  ### Patch Changes
@@ -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
- - fs-extra@11.2.0
6
+ - jsonfile@6.1.0
7
7
 
8
- This package contains the following license and notice below:
8
+ This package contains the following license:
9
9
 
10
10
  (The MIT License)
11
11
 
12
- Copyright (c) 2011-2017 JP Richardson
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
- - @fluidframework/build-tools@0.41.0
30
+ - @rushstack/node-core-library@5.9.0
31
31
 
32
- This package contains the following license and notice below:
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.52.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,16 +88,39 @@ SOFTWARE.
55
88
 
56
89
  -----------
57
90
 
58
- The following npm packages may be included in this product:
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
59
98
 
60
- - @oclif/core@4.0.12
61
- - @oclif/plugin-help@6.2.6
99
+ Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov
62
100
 
63
- These packages each contain the following license and notice below:
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
+ - sort-package-json@2.14.0
118
+
119
+ This package contains the following license:
64
120
 
65
121
  MIT License
66
122
 
67
- Copyright (c) 2018 Salesforce.com
123
+ Copyright (c) 2015 Keith Cirkel
68
124
 
69
125
  Permission is hereby granted, free of charge, to any person obtaining a copy
70
126
  of this software and associated documentation files (the "Software"), to deal
@@ -86,15 +142,16 @@ SOFTWARE.
86
142
 
87
143
  -----------
88
144
 
89
- The following npm package may be included in this product:
145
+ The following npm packages may be included in this product:
90
146
 
91
- - sort-tsconfig@0.0.1
147
+ - @oclif/core@4.2.3
148
+ - @oclif/plugin-help@6.2.21
92
149
 
93
- This package contains the following license and notice below:
150
+ These packages each contain the following license:
94
151
 
95
152
  MIT License
96
153
 
97
- Copyright (c) 2023 Tyler Butler <tyler@tylerbutler.com>
154
+ Copyright (c) 2018 Salesforce.com
98
155
 
99
156
  Permission is hereby granted, free of charge, to any person obtaining a copy
100
157
  of this software and associated documentation files (the "Software"), to deal
@@ -118,31 +175,13 @@ SOFTWARE.
118
175
 
119
176
  The following npm package may be included in this product:
120
177
 
121
- - chalk@5.3.0
178
+ - sort-tsconfig@0.2.0
122
179
 
123
- This package contains the following license and notice below:
180
+ This package contains the following license:
124
181
 
125
182
  MIT License
126
183
 
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
140
-
141
- This package contains the following license and notice below:
142
-
143
- MIT License
144
-
145
- Copyright (c) Tyler Butler <tyler@tylerbutler.com>
184
+ Copyright (c) 2023 Tyler Butler <tyler@tylerbutler.com>
146
185
 
147
186
  Permission is hereby granted, free of charge, to any person obtaining a copy
148
187
  of this software and associated documentation files (the "Software"), to deal
@@ -166,13 +205,13 @@ SOFTWARE.
166
205
 
167
206
  The following npm package may be included in this product:
168
207
 
169
- - cosmiconfig@9.0.0
208
+ - pathe@2.0.3
170
209
 
171
- This package contains the following license and notice below:
210
+ This package contains the following license:
172
211
 
173
- The MIT License (MIT)
212
+ MIT License
174
213
 
175
- Copyright (c) 2015 David Clark
214
+ Copyright (c) Pooya Parsa <pooya@pi0.io> - Daniel Roe <daniel@roe.dev>
176
215
 
177
216
  Permission is hereby granted, free of charge, to any person obtaining a copy
178
217
  of this software and associated documentation files (the "Software"), to deal
@@ -192,6 +231,55 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
192
231
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
193
232
  SOFTWARE.
194
233
 
234
+ ---
235
+
236
+ Copyright Joyent, Inc. and other Node contributors.
237
+
238
+ Permission is hereby granted, free of charge, to any person obtaining a
239
+ copy of this software and associated documentation files (the
240
+ "Software"), to deal in the Software without restriction, including
241
+ without limitation the rights to use, copy, modify, merge, publish,
242
+ distribute, sublicense, and/or sell copies of the Software, and to permit
243
+ persons to whom the Software is furnished to do so, subject to the
244
+ following conditions:
245
+
246
+ The above copyright notice and this permission notice shall be included
247
+ in all copies or substantial portions of the Software.
248
+
249
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
250
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
251
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
252
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
253
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
254
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
255
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
256
+
257
+ ---
258
+
259
+ Bundled zeptomatch (https://github.com/fabiospampinato/zeptomatch)
260
+
261
+ The MIT License (MIT)
262
+
263
+ Copyright (c) 2023-present Fabio Spampinato
264
+
265
+ Permission is hereby granted, free of charge, to any person obtaining a
266
+ copy of this software and associated documentation files (the "Software"),
267
+ to deal in the Software without restriction, including without limitation
268
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
269
+ and/or sell copies of the Software, and to permit persons to whom the
270
+ Software is furnished to do so, subject to the following conditions:
271
+
272
+ The above copyright notice and this permission notice shall be included in
273
+ all copies or substantial portions of the Software.
274
+
275
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
276
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
277
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
278
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
279
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
280
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
281
+ DEALINGS IN THE SOFTWARE.
282
+
195
283
  -----------
196
284
 
197
285
  This file was generated with the generate-license-file npm package!
@@ -1 +1 @@
1
- {"version":3,"file":"baseCommand.d.ts","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAA2B,MAAM,kBAAkB,CAAC;AAEvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,KAAK,sBAAsB,EAAgB,MAAM,WAAW,CAAC;AACtE,OAAO,EAAmB,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,a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EG;IACH,YAAY,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,QAAQ,EAAE,UAAU,EAAE,CAAC;IAEvB;;OAEG;IACH,uBAAuB,EAAE,qBAAqB,CAAC;IAE/C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,sBAAsB,CAAC;CAClC;AAED;;GAEG;AACH,8BAAsB,iBAAiB,CACtC,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,UAAU,CAAC,IAAI,CAAC;IAC7B,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CAC/B,CACA,SAAQ,UAAU,CAAC,CAAC,EAAE,YAAY,CAAC;IACpC,gBAAyB,KAAK;gCAlCF,wBAAwB,wCAExC,wBAGP;;;;MAiDM;IAEX,OAAO,CAAC,OAAO,CAAmC;IAElD,SAAS,CAAC,UAAU,IAAI,oBAAoB;IAOtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAoD3C;AAED,MAAM,MAAM,qBAAqB,GAAG,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC"}
@@ -36,7 +36,7 @@ export class BaseRepopoCommand extends GitCommand {
36
36
  async init() {
37
37
  await super.init();
38
38
  const { flags } = this;
39
- const config = await this.loadConfig();
39
+ const config = this.commandConfig;
40
40
  let policies = config?.policies ?? DefaultPolicies;
41
41
  policies =
42
42
  policies.filter((h) => {
@@ -1 +1 @@
1
- {"version":3,"file":"baseCommand.js","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGvE,OAAO,EAA+B,YAAY,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,eAAe,EAAoC,MAAM,aAAa,CAAC;AAEhF,MAAM,k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,CAAC;QACxD,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,kCAAkC,SAAS,EAAE,CAAC,CAAC;QAC1D,CAAC;QAED,IAAI,CAAC,OAAO,GAAG;YACd,SAAS;YACT,YAAY;YACZ,QAAQ;YACR,uBAAuB;YACvB,OAAO;YACP,SAAS,EAAE,YAAY,EAAE;SACzB,CAAC;IACH,CAAC;;AAKF,SAAS,QAAQ,CAAC,KAAsB;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { Flags } from \"@oclif/core\";\nimport { GitCommand, RegExpFlag, findGitRoot } from \"@tylerbu/cli-api\";\n\nimport type { PolicyConfig } from \"./config.js\";\nimport { type PolicyHandlerPerfStats, newPerfStats } from \"./perf.js\";\nimport { DefaultPolicies, type PolicyName, type RepoPolicy } from \"./policy.js\";\n\nconst DEFAULT_PATH_REGEX = /.?/;\n\n/**\n * A convenience interface used to pass commonly used parameters between functions.\n */\nexport interface PolicyCommandContext {\n\t/**\n\t * A regular expression used to filter selected files.\n\t */\n\tpathRegex: RegExp;\n\n\t/**\n\t * A list of regular expressions used to exclude files from all handlers.\n\t */\n\texcludeFiles: RegExp[];\n\n\t/**\n\t * A list of handlers to apply to selected files.\n\t */\n\tpolicies: RepoPolicy[];\n\n\t/**\n\t * A per-handler list of regular expressions used to exclude files from specific handlers.\n\t */\n\texcludePoliciesForFiles: ExcludedPolicyFileMap;\n\n\t/**\n\t * Path to the root of the git repo.\n\t */\n\tgitRoot: string;\n\n\t/**\n\t * Performance information for each handler.\n\t */\n\tperfStats: PolicyHandlerPerfStats;\n}\n\n/**\n * This command lists all the policies configured to run.\n */\nexport abstract class BaseRepopoCommand<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof GitCommand.args;\n\t\tflags: typeof GitCommand.flags;\n\t},\n> extends GitCommand<T, PolicyConfig> {\n\tstatic override readonly flags = {\n\t\tpolicy: RegExpFlag({\n\t\t\tdescription:\n\t\t\t\t\"Filter policies to apply by <regex>. Only policies with a name matching the regex will be applied.\",\n\t\t\trequired: false,\n\t\t\tchar: \"d\",\n\t\t}),\n\t\texcludePolicy: Flags.string({\n\t\t\tchar: \"D\",\n\t\t\tdescription:\n\t\t\t\t\"Exclude policies by name. Can be specified multiple times to exclude multiple policies.\",\n\t\t\texclusive: [\"policy\"],\n\t\t\tmultiple: true,\n\t\t}),\n\t\tpath: RegExpFlag({\n\t\t\tdescription: \"Filter file paths by <regex>.\",\n\t\t\trequired: false,\n\t\t\tchar: \"p\",\n\t\t}),\n\t\t...GitCommand.flags,\n\t} as const;\n\n\tprivate context: PolicyCommandContext | undefined;\n\n\tprotected getContext(): PolicyCommandContext {\n\t\tif (this.context === undefined) {\n\t\t\tthrow new Error(\"context undefined\");\n\t\t}\n\t\treturn this.context;\n\t}\n\n\tpublic override async init(): Promise<void> {\n\t\tawait super.init();\n\t\tconst { flags } = this;\n\t\tconst config = await this.loadConfig();\n\t\tlet policies = config?.policies ?? DefaultPolicies;\n\t\tpolicies =\n\t\t\tpolicies.filter((h) => {\n\t\t\t\tif (\n\t\t\t\t\tflags.excludePolicy === undefined ||\n\t\t\t\t\tflags.excludePolicy.length === 0\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconst shouldRun = flags.excludePolicy?.includes(h.name) === false;\n\t\t\t\tif (!shouldRun) {\n\t\t\t\t\tthis.info(`Disabled policy: ${h.name}`);\n\t\t\t\t}\n\t\t\t\treturn shouldRun;\n\t\t\t}) ?? [];\n\t\tif (flags.policy !== undefined) {\n\t\t\tthis.info(`Filtering handlers by regex: ${flags.policy}`);\n\t\t\tpolicies = policies.filter((h) => flags.policy?.test(h.name));\n\t\t}\n\n\t\tconst excludeFiles: RegExp[] =\n\t\t\tconfig?.excludeFiles?.map((e) => toRegExp(e)) ?? [];\n\t\tconst excludePoliciesForFilesRaw = config?.excludePoliciesForFiles;\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) => toRegExp(e));\n\t\t\t\texcludePoliciesForFiles.set(policyName, regexes);\n\t\t\t}\n\t\t}\n\t\tconst gitRoot = await findGitRoot();\n\n\t\tconst pathRegex = this.flags.path ?? DEFAULT_PATH_REGEX;\n\t\tif (this.flags.path !== undefined) {\n\t\t\tthis.info(`Filtering file paths by regex: ${pathRegex}`);\n\t\t}\n\n\t\tthis.context = {\n\t\t\tpathRegex,\n\t\t\texcludeFiles,\n\t\t\tpolicies,\n\t\t\texcludePoliciesForFiles,\n\t\t\tgitRoot,\n\t\t\tperfStats: newPerfStats(),\n\t\t};\n\t}\n}\n\nexport type ExcludedPolicyFileMap = Map<PolicyName, RegExp[]>;\n\nfunction toRegExp(input: string | RegExp): RegExp {\n\tif (typeof input === \"string\") {\n\t\treturn new RegExp(input, \"i\");\n\t}\n\treturn input;\n}\n"]}
1
+ {"version":3,"file":"baseCommand.js","sourceRoot":"","sources":["../src/baseCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGvE,OAAO,EAA+B,YAAY,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,eAAe,EAAoC,MAAM,aAAa,CAAC;AAEhF,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAqChC;;GAEG;AACH,MAAM,OAAgB,iBAKpB,SAAQ,UAA2B;IACpC,MAAM,CAAmB,KAAK,GAAG;QACh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C,CAAC;QAC1D,CAAC;QAED,IAAI,CAAC,OAAO,GAAG;YACd,SAAS;YACT,YAAY;YACZ,QAAQ;YACR,uBAAuB;YACvB,OAAO;YACP,SAAS,EAAE,YAAY,EAAE;SACzB,CAAC;IACH,CAAC;;AAKF,SAAS,QAAQ,CAAC,KAAsB;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { Flags } from \"@oclif/core\";\nimport { GitCommand, RegExpFlag, findGitRoot } from \"@tylerbu/cli-api\";\n\nimport type { PolicyConfig } from \"./config.js\";\nimport { type PolicyHandlerPerfStats, newPerfStats } from \"./perf.js\";\nimport { DefaultPolicies, type PolicyName, type RepoPolicy } from \"./policy.js\";\n\nconst DEFAULT_PATH_REGEX = /.?/;\n\n/**\n * A convenience interface used to pass commonly used parameters between functions.\n */\nexport interface PolicyCommandContext {\n\t/**\n\t * A regular expression used to filter selected files.\n\t */\n\tpathRegex: RegExp;\n\n\t/**\n\t * A list of regular expressions used to exclude files from all handlers.\n\t */\n\texcludeFiles: RegExp[];\n\n\t/**\n\t * A list of handlers to apply to selected files.\n\t */\n\tpolicies: RepoPolicy[];\n\n\t/**\n\t * A per-handler list of regular expressions used to exclude files from specific handlers.\n\t */\n\texcludePoliciesForFiles: ExcludedPolicyFileMap;\n\n\t/**\n\t * Path to the root of the git repo.\n\t */\n\tgitRoot: string;\n\n\t/**\n\t * Performance information for each handler.\n\t */\n\tperfStats: PolicyHandlerPerfStats;\n}\n\n/**\n * This command lists all the policies configured to run.\n */\nexport abstract class BaseRepopoCommand<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof GitCommand.args;\n\t\tflags: typeof GitCommand.flags;\n\t},\n> extends GitCommand<T, PolicyConfig> {\n\tstatic override readonly flags = {\n\t\tpolicy: RegExpFlag({\n\t\t\tdescription:\n\t\t\t\t\"Filter policies to apply by <regex>. Only policies with a name matching the regex will be applied.\",\n\t\t\trequired: false,\n\t\t\tchar: \"d\",\n\t\t}),\n\t\texcludePolicy: Flags.string({\n\t\t\tchar: \"D\",\n\t\t\tdescription:\n\t\t\t\t\"Exclude policies by name. Can be specified multiple times to exclude multiple policies.\",\n\t\t\texclusive: [\"policy\"],\n\t\t\tmultiple: true,\n\t\t}),\n\t\tpath: RegExpFlag({\n\t\t\tdescription: \"Filter file paths by <regex>.\",\n\t\t\trequired: false,\n\t\t\tchar: \"p\",\n\t\t}),\n\t\t...GitCommand.flags,\n\t} as const;\n\n\tprivate context: PolicyCommandContext | undefined;\n\n\tprotected getContext(): PolicyCommandContext {\n\t\tif (this.context === undefined) {\n\t\t\tthrow new Error(\"context undefined\");\n\t\t}\n\t\treturn this.context;\n\t}\n\n\tpublic override async init(): Promise<void> {\n\t\tawait super.init();\n\t\tconst { flags } = this;\n\t\tconst config = this.commandConfig;\n\t\tlet policies = config?.policies ?? DefaultPolicies;\n\t\tpolicies =\n\t\t\tpolicies.filter((h) => {\n\t\t\t\tif (\n\t\t\t\t\tflags.excludePolicy === undefined ||\n\t\t\t\t\tflags.excludePolicy.length === 0\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconst shouldRun = flags.excludePolicy?.includes(h.name) === false;\n\t\t\t\tif (!shouldRun) {\n\t\t\t\t\tthis.info(`Disabled policy: ${h.name}`);\n\t\t\t\t}\n\t\t\t\treturn shouldRun;\n\t\t\t}) ?? [];\n\t\tif (flags.policy !== undefined) {\n\t\t\tthis.info(`Filtering handlers by regex: ${flags.policy}`);\n\t\t\tpolicies = policies.filter((h) => flags.policy?.test(h.name));\n\t\t}\n\n\t\tconst excludeFiles: RegExp[] =\n\t\t\tconfig?.excludeFiles?.map((e) => toRegExp(e)) ?? [];\n\t\tconst excludePoliciesForFilesRaw = config?.excludePoliciesForFiles;\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) => toRegExp(e));\n\t\t\t\texcludePoliciesForFiles.set(policyName, regexes);\n\t\t\t}\n\t\t}\n\t\tconst gitRoot = await findGitRoot();\n\n\t\tconst pathRegex = this.flags.path ?? DEFAULT_PATH_REGEX;\n\t\tif (this.flags.path !== undefined) {\n\t\t\tthis.info(`Filtering file paths by regex: ${pathRegex}`);\n\t\t}\n\n\t\tthis.context = {\n\t\t\tpathRegex,\n\t\t\texcludeFiles,\n\t\t\tpolicies,\n\t\t\texcludePoliciesForFiles,\n\t\t\tgitRoot,\n\t\t\tperfStats: newPerfStats(),\n\t\t};\n\t}\n}\n\nexport type ExcludedPolicyFileMap = Map<PolicyName, RegExp[]>;\n\nfunction toRegExp(input: string | RegExp): RegExp {\n\tif (typeof input === \"string\") {\n\t\treturn new RegExp(input, \"i\");\n\t}\n\treturn input;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,iBAAiB,EAEjB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;;;GAQG;AACH,qBAAa,WAAW,CACvB,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,OAAO,WAAW,CAAC,KAAK,CAAC;CAChC,CACA,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC7B,gBAAyB,OAAO,iEAC+B;IAE/D,gBAAyB,KAAK;gCAhBE,wBAAwB,wCAAyC,wBAEhG;;;;;;MA0BU;IAEX,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,KAAK,CAAK;IAEF,aAAa,sCAAuB;IAE9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQrB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAuC5B,aAAa;IAc3B;;;;OAIG;YACW,eAAe;IA0G7B;;;OAGG;YACW,kBAAkB;CA0BhC"}
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,iBAAiB,EAEjB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;;;GAQG;AACH,qBAAa,WAAW,CACvB,CAAC,SAAS,OAAO,iBAAiB,GAAG;IACpC,IAAI,EAAE,OAAO,WAAW,CAAC,IAAI,CAAC;IAC9B,KAAK,EAAE,OAAO,WAAW,CAAC,KAAK,CAAC;CAChC,CACA,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAC7B,gBAAyB,OAAO,iEAC+B;IAE/D,gBAAyB,KAAK;gCAhBf,wBAAwB,wCAAwC,wBAAwB;;;;;;MA4B5F;IAEX,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,KAAK,CAAK;IAEF,aAAa,sCAAuB;IAE9B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQrB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;YAuC5B,aAAa;IAc3B;;;;OAIG;YACW,eAAe;IA0G7B;;;OAGG;YACW,kBAAkB;CA0BhC"}
@@ -1,8 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import { EOL as newline } from "node:os";
3
- import path from "node:path";
4
3
  import { Flags } from "@oclif/core";
5
4
  import { StringBuilder } from "@rushstack/node-core-library";
5
+ import path from "pathe";
6
6
  import chalk from "picocolors";
7
7
  import { BaseRepopoCommand, } from "../baseCommand.js";
8
8
  import { DefaultPolicyConfig } from "../config.js";
@@ -43,7 +43,7 @@ export class CheckPolicy extends BaseRepopoCommand {
43
43
  }
44
44
  async run() {
45
45
  // list the handlers then exit
46
- const config = await this.loadConfig();
46
+ const config = this.commandConfig;
47
47
  const policies = config?.policies ?? [];
48
48
  this.verbose(`${policies.length} policies loaded.`);
49
49
  for (const h of policies) {
@@ -91,7 +91,7 @@ export class CheckPolicy extends BaseRepopoCommand {
91
91
  // Use the repo-relative path so that regexes that specify string start (^) will match repo paths.
92
92
  // Replace \ in result with / in case OS is Windows.
93
93
  const relPath = path.relative(gitRoot, file).replace(/\\/g, "/");
94
- const config = await this.loadConfig();
94
+ const config = this.commandConfig;
95
95
  await Promise.all(policies
96
96
  .filter((handler) => handler.match.test(relPath))
97
97
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
@@ -1 +1 @@
1
- {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,OAAO,EACN,iBAAiB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,OAAO,WAKX,SAAQ,iBAAoB;IAC7B,MAAM,CAAmB,OAAO,GAC/B,6DAA6D,CAAC;IAE/D,MAAM,CAAmB,KAAK,GAAG;QAChC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;YAClB,OAAO,EAAE,CAAC,SAAS,CAAC;YACpB,WAAW,EAAE,yBAAyB;YACtC,QAAQ,EAAE,KAAK;YACf,IAAI,EAAE,GAAG;SACT,CAAC;QACF,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AgB,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;;AAGF,KAAK,UAAU,SAAS;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE1B,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,IAAI,IAAI,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,CAAC,EAAE,CAAC,CAAC;QACb,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport { EOL as newline } from \"node:os\";\nimport path from \"node:path\";\nimport { Flags } from \"@oclif/core\";\nimport { StringBuilder } from \"@rushstack/node-core-library\";\nimport chalk from \"picocolors\";\n\nimport {\n\tBaseRepopoCommand,\n\ttype PolicyCommandContext,\n} from \"../baseCommand.js\";\nimport { DefaultPolicyConfig } from \"../config.js\";\nimport { logStats, runWithPerf } from \"../perf.js\";\nimport { isPolicyFixResult } from \"../policy.js\";\n\n/**\n * This tool enforces policies across the code base via a series of handler functions. The handler functions are\n * associated with a regular expression, and all files matching that expression are passed to the handler function.\n *\n * By default, the list of files to check comes from `git ls-files. You can also pipe in file names from stdin. For\n * example:\n *\n * `git ls-files -co --exclude-standard --full-name | repopo check --stdin --verbose`\n */\nexport class CheckPolicy<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof CheckPolicy.args;\n\t\tflags: typeof CheckPolicy.flags;\n\t},\n> extends BaseRepopoCommand<T> {\n\tstatic override readonly summary =\n\t\t\"Checks and applies policies to the files in the repository.\";\n\n\tstatic override readonly flags = {\n\t\tfix: Flags.boolean({\n\t\t\taliases: [\"resolve\"],\n\t\t\tdescription: \"Fix errors if possible.\",\n\t\t\trequired: false,\n\t\t\tchar: \"f\",\n\t\t}),\n\t\tstdin: Flags.boolean({\n\t\t\tdescription: \"Read list of files from stdin.\",\n\t\t\trequired: false,\n\t\t}),\n\t\t...BaseRepopoCommand.flags,\n\t} as const;\n\n\tprivate processed = 0;\n\tprivate count = 0;\n\n\tpublic override defaultConfig = DefaultPolicyConfig;\n\n\tpublic override async init(): Promise<void> {\n\t\tawait super.init();\n\n\t\tif (this.flags.fix) {\n\t\t\tthis.info(\"Resolving errors if possible.\");\n\t\t}\n\t}\n\n\tpublic override async run(): Promise<void> {\n\t\t// list the handlers then exit\n\t\tconst config = await this.loadConfig();\n\t\tconst policies = config?.policies ?? [];\n\t\tthis.verbose(`${policies.length} policies loaded.`);\n\t\tfor (const h of policies) {\n\t\t\tthis.verbose(h.name);\n\t\t}\n\n\t\tconst filePathsToCheck: string[] = [];\n\n\t\tif (this.flags.stdin) {\n\t\t\tconst stdInput = await readStdin();\n\n\t\t\tif (stdInput !== undefined) {\n\t\t\t\tfilePathsToCheck.push(...stdInput.split(\"\\n\"));\n\t\t\t}\n\t\t} else {\n\t\t\tconst gitFiles =\n\t\t\t\t(await this.git.raw(\n\t\t\t\t\t\"ls-files\",\n\t\t\t\t\t\"-co\",\n\t\t\t\t\t\"--exclude-standard\",\n\t\t\t\t\t\"--full-name\",\n\t\t\t\t)) ?? \"\";\n\n\t\t\tfilePathsToCheck.push(...gitFiles.split(\"\\n\"));\n\t\t}\n\n\t\ttry {\n\t\t\tconst context = this.getContext();\n\t\t\tawait this.executePolicy(filePathsToCheck, context);\n\t\t} catch (error) {\n\t\t\tthis.error(`Command context was undefined - fatal error: ${error}`, {\n\t\t\t\texit: 100,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async executePolicy(\n\t\tpathsToCheck: string[],\n\t\tcommandContext: PolicyCommandContext,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tfor (const pathToCheck of pathsToCheck) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tawait this.checkOrExcludeFile(pathToCheck, commandContext);\n\t\t\t}\n\t\t} finally {\n\t\t\tlogStats(commandContext.perfStats, this);\n\t\t}\n\t}\n\n\t/**\n\t * Routes files to their handlers and resolvers by regex testing their full paths. If a file fails a policy that has a\n\t * resolver, the resolver will be invoked as well. Synchronizes the output, exit codes, and resolve\n\t * decision for all handlers.\n\t */\n\tprivate async routeToHandlers(\n\t\tfile: string,\n\t\tcommandContext: PolicyCommandContext,\n\t): Promise<void> {\n\t\tconst { policies, excludePoliciesForFiles, gitRoot, perfStats } =\n\t\t\tcommandContext;\n\n\t\t// Use the repo-relative path so that regexes that specify string start (^) will match repo paths.\n\t\t// Replace \\ in result with / in case OS is Windows.\n\t\tconst relPath = path.relative(gitRoot, file).replace(/\\\\/g, \"/\");\n\t\tconst config = await this.loadConfig();\n\n\t\tawait Promise.all(\n\t\t\tpolicies\n\t\t\t\t.filter((handler) => handler.match.test(relPath))\n\t\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>\n\t\t\t\t.map(async (policy): Promise<void> => {\n\t\t\t\t\t// doing exclusion per handler\n\t\t\t\t\tconst exclusions = excludePoliciesForFiles.get(policy.name);\n\t\t\t\t\tif (\n\t\t\t\t\t\texclusions !== undefined &&\n\t\t\t\t\t\t!exclusions.every((regex) => !regex.test(relPath))\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.verbose(`Excluded from '${policy.name}' policy: ${relPath}`);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = await runWithPerf(\n\t\t\t\t\t\tpolicy.name,\n\t\t\t\t\t\t\"handle\",\n\t\t\t\t\t\tperfStats,\n\t\t\t\t\t\tasync () =>\n\t\t\t\t\t\t\tpolicy.handler({\n\t\t\t\t\t\t\t\tfile: relPath,\n\t\t\t\t\t\t\t\troot: gitRoot,\n\t\t\t\t\t\t\t\tresolve: this.flags.fix,\n\t\t\t\t\t\t\t\tconfig: config?.policySettings?.[policy.name],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (result === true) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst messages = new StringBuilder();\n\t\t\t\t\tif (isPolicyFixResult(result)) {\n\t\t\t\t\t\tif (result.resolved) {\n\t\t\t\t\t\t\tmessages.append(\n\t\t\t\t\t\t\t\t`Resolved ${policy.name} policy failure for file: ${result.file}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmessages.append(\n\t\t\t\t\t\t\t\t`Error when trying to fix ${policy.name} policy failure in ${result.file}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// result must be a PolicyFailureResult; check if there is a standalone resolver.\n\t\t\t\t\t\tconst { resolver } = policy;\n\n\t\t\t\t\t\tif (this.flags.fix && resolver !== undefined) {\n\t\t\t\t\t\t\t// Resolve the failure\n\t\t\t\t\t\t\tmessages.append(`${newline}attempting to resolve: ${relPath}`);\n\t\t\t\t\t\t\tconst resolveResult = await runWithPerf(\n\t\t\t\t\t\t\t\tpolicy.name,\n\t\t\t\t\t\t\t\t\"resolve\",\n\t\t\t\t\t\t\t\tperfStats,\n\t\t\t\t\t\t\t\tasync () => resolver({ file: relPath, root: gitRoot }),\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tresolveResult.errorMessage !== undefined &&\n\t\t\t\t\t\t\t\tresolveResult.errorMessage !== \"\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tmessages.append(newline + resolveResult.errorMessage);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!resolveResult.resolved) {\n\t\t\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// No resolver, or fix is false, so we're in the full failure case.\n\t\t\t\t\t\t\tconst autoFixable = result.autoFixable\n\t\t\t\t\t\t\t\t? chalk.green(\" (autofixable)\")\n\t\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\t\t\tmessages.append(\n\t\t\t\t\t\t\t\t`'${policy.name}' policy failure${autoFixable}: ${result.file}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tmessages.append(\n\t\t\t\t\t\t\t\tresult.errorMessage === undefined\n\t\t\t\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t\t\t\t: `${newline}${result.errorMessage}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ((process.exitCode ?? 0) === 0) {\n\t\t\t\t\t\tthis.info(messages.toString());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.warning(messages.toString());\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Given a string that represents a path to a file in the repo, determines if the file should be checked, and if so,\n\t * routes the file to the appropriate handlers.\n\t */\n\tprivate async checkOrExcludeFile(\n\t\tinputPath: string,\n\t\tcommandContext: PolicyCommandContext,\n\t): Promise<void> {\n\t\tconst { excludeFiles: exclusions, gitRoot, pathRegex } = commandContext;\n\n\t\tconst filePath = path.join(gitRoot, inputPath).trim().replace(/\\\\/g, \"/\");\n\n\t\tif (!(pathRegex.test(inputPath) && fs.existsSync(filePath))) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.count++;\n\t\tif (!exclusions.every((value) => !value.test(inputPath))) {\n\t\t\tthis.verbose(`Excluded all handlers: ${inputPath}`);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.routeToHandlers(filePath, commandContext);\n\t\t} catch (error: unknown) {\n\t\t\tthrow new Error(`Error routing ${filePath} to handler: ${error}`);\n\t\t}\n\n\t\tthis.processed++;\n\t}\n}\n\nasync function readStdin(): Promise<string> {\n\treturn new Promise((resolve) => {\n\t\tconst stdin = process.stdin;\n\t\tstdin.setEncoding(\"utf8\");\n\n\t\tlet data = \"\";\n\t\tstdin.on(\"data\", (chunk) => {\n\t\t\tdata += chunk;\n\t\t});\n\n\t\tstdin.on(\"end\", () => {\n\t\t\tresolve(data);\n\t\t});\n\n\t\tif (stdin.isTTY) {\n\t\t\tresolve(\"\");\n\t\t}\n\t});\n}\n"]}
1
+ {"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,GAAG,IAAI,OAAO,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,OAAO,EACN,iBAAiB,GAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,OAAO,WAKX,SAAQ,iBAAoB;IAC7B,MAAM,CAAmB,OAAO,GAC/B,6DAA6D,CAAC;IAE/D,MAAM,CAAmB,KAAK,GAAG;QAChC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC;YAClB,OAAO,EAAE,CAAC,SAAS,CAAC;YAC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,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,iBAAiB,QAAQ,gBAAgB,KAAK,EAAE,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;IAClB,CAAC;;AAGF,KAAK,UAAU,SAAS;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAE1B,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,IAAI,IAAI,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACjB,OAAO,CAAC,EAAE,CAAC,CAAC;QACb,CAAC;IACF,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport { EOL as newline } from \"node:os\";\nimport { Flags } from \"@oclif/core\";\nimport { StringBuilder } from \"@rushstack/node-core-library\";\nimport path from \"pathe\";\nimport chalk from \"picocolors\";\n\nimport {\n\tBaseRepopoCommand,\n\ttype PolicyCommandContext,\n} from \"../baseCommand.js\";\nimport { DefaultPolicyConfig } from \"../config.js\";\nimport { logStats, runWithPerf } from \"../perf.js\";\nimport { isPolicyFixResult } from \"../policy.js\";\n\n/**\n * This tool enforces policies across the code base via a series of handler functions. The handler functions are\n * associated with a regular expression, and all files matching that expression are passed to the handler function.\n *\n * By default, the list of files to check comes from `git ls-files. You can also pipe in file names from stdin. For\n * example:\n *\n * `git ls-files -co --exclude-standard --full-name | repopo check --stdin --verbose`\n */\nexport class CheckPolicy<\n\tT extends typeof BaseRepopoCommand & {\n\t\targs: typeof CheckPolicy.args;\n\t\tflags: typeof CheckPolicy.flags;\n\t},\n> extends BaseRepopoCommand<T> {\n\tstatic override readonly summary =\n\t\t\"Checks and applies policies to the files in the repository.\";\n\n\tstatic override readonly flags = {\n\t\tfix: Flags.boolean({\n\t\t\taliases: [\"resolve\"],\n\t\t\tdescription: \"Fix errors if possible.\",\n\t\t\trequired: false,\n\t\t\tchar: \"f\",\n\t\t}),\n\t\tstdin: Flags.boolean({\n\t\t\tdescription: \"Read list of files from stdin.\",\n\t\t\trequired: false,\n\t\t}),\n\t\t...BaseRepopoCommand.flags,\n\t} as const;\n\n\tprivate processed = 0;\n\tprivate count = 0;\n\n\tpublic override defaultConfig = DefaultPolicyConfig;\n\n\tpublic override async init(): Promise<void> {\n\t\tawait super.init();\n\n\t\tif (this.flags.fix) {\n\t\t\tthis.info(\"Resolving errors if possible.\");\n\t\t}\n\t}\n\n\tpublic override async run(): Promise<void> {\n\t\t// list the handlers then exit\n\t\tconst config = this.commandConfig;\n\t\tconst policies = config?.policies ?? [];\n\t\tthis.verbose(`${policies.length} policies loaded.`);\n\t\tfor (const h of policies) {\n\t\t\tthis.verbose(h.name);\n\t\t}\n\n\t\tconst filePathsToCheck: string[] = [];\n\n\t\tif (this.flags.stdin) {\n\t\t\tconst stdInput = await readStdin();\n\n\t\t\tif (stdInput !== undefined) {\n\t\t\t\tfilePathsToCheck.push(...stdInput.split(\"\\n\"));\n\t\t\t}\n\t\t} else {\n\t\t\tconst gitFiles =\n\t\t\t\t(await this.git.raw(\n\t\t\t\t\t\"ls-files\",\n\t\t\t\t\t\"-co\",\n\t\t\t\t\t\"--exclude-standard\",\n\t\t\t\t\t\"--full-name\",\n\t\t\t\t)) ?? \"\";\n\n\t\t\tfilePathsToCheck.push(...gitFiles.split(\"\\n\"));\n\t\t}\n\n\t\ttry {\n\t\t\tconst context = this.getContext();\n\t\t\tawait this.executePolicy(filePathsToCheck, context);\n\t\t} catch (error) {\n\t\t\tthis.error(`Command context was undefined - fatal error: ${error}`, {\n\t\t\t\texit: 100,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate async executePolicy(\n\t\tpathsToCheck: string[],\n\t\tcommandContext: PolicyCommandContext,\n\t): Promise<void> {\n\t\ttry {\n\t\t\tfor (const pathToCheck of pathsToCheck) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tawait this.checkOrExcludeFile(pathToCheck, commandContext);\n\t\t\t}\n\t\t} finally {\n\t\t\tlogStats(commandContext.perfStats, this);\n\t\t}\n\t}\n\n\t/**\n\t * Routes files to their handlers and resolvers by regex testing their full paths. If a file fails a policy that has a\n\t * resolver, the resolver will be invoked as well. Synchronizes the output, exit codes, and resolve\n\t * decision for all handlers.\n\t */\n\tprivate async routeToHandlers(\n\t\tfile: string,\n\t\tcommandContext: PolicyCommandContext,\n\t): Promise<void> {\n\t\tconst { policies, excludePoliciesForFiles, gitRoot, perfStats } =\n\t\t\tcommandContext;\n\n\t\t// Use the repo-relative path so that regexes that specify string start (^) will match repo paths.\n\t\t// Replace \\ in result with / in case OS is Windows.\n\t\tconst relPath = path.relative(gitRoot, file).replace(/\\\\/g, \"/\");\n\t\tconst config = this.commandConfig;\n\n\t\tawait Promise.all(\n\t\t\tpolicies\n\t\t\t\t.filter((handler) => handler.match.test(relPath))\n\t\t\t\t// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>\n\t\t\t\t.map(async (policy): Promise<void> => {\n\t\t\t\t\t// doing exclusion per handler\n\t\t\t\t\tconst exclusions = excludePoliciesForFiles.get(policy.name);\n\t\t\t\t\tif (\n\t\t\t\t\t\texclusions !== undefined &&\n\t\t\t\t\t\t!exclusions.every((regex) => !regex.test(relPath))\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.verbose(`Excluded from '${policy.name}' policy: ${relPath}`);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst result = await runWithPerf(\n\t\t\t\t\t\tpolicy.name,\n\t\t\t\t\t\t\"handle\",\n\t\t\t\t\t\tperfStats,\n\t\t\t\t\t\tasync () =>\n\t\t\t\t\t\t\tpolicy.handler({\n\t\t\t\t\t\t\t\tfile: relPath,\n\t\t\t\t\t\t\t\troot: gitRoot,\n\t\t\t\t\t\t\t\tresolve: this.flags.fix,\n\t\t\t\t\t\t\t\tconfig: config?.policySettings?.[policy.name],\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (result === true) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst messages = new StringBuilder();\n\t\t\t\t\tif (isPolicyFixResult(result)) {\n\t\t\t\t\t\tif (result.resolved) {\n\t\t\t\t\t\t\tmessages.append(\n\t\t\t\t\t\t\t\t`Resolved ${policy.name} policy failure for file: ${result.file}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmessages.append(\n\t\t\t\t\t\t\t\t`Error when trying to fix ${policy.name} policy failure in ${result.file}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// result must be a PolicyFailureResult; check if there is a standalone resolver.\n\t\t\t\t\t\tconst { resolver } = policy;\n\n\t\t\t\t\t\tif (this.flags.fix && resolver !== undefined) {\n\t\t\t\t\t\t\t// Resolve the failure\n\t\t\t\t\t\t\tmessages.append(`${newline}attempting to resolve: ${relPath}`);\n\t\t\t\t\t\t\tconst resolveResult = await runWithPerf(\n\t\t\t\t\t\t\t\tpolicy.name,\n\t\t\t\t\t\t\t\t\"resolve\",\n\t\t\t\t\t\t\t\tperfStats,\n\t\t\t\t\t\t\t\tasync () => resolver({ file: relPath, root: gitRoot }),\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tresolveResult.errorMessage !== undefined &&\n\t\t\t\t\t\t\t\tresolveResult.errorMessage !== \"\"\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tmessages.append(newline + resolveResult.errorMessage);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!resolveResult.resolved) {\n\t\t\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// No resolver, or fix is false, so we're in the full failure case.\n\t\t\t\t\t\t\tconst autoFixable = result.autoFixable\n\t\t\t\t\t\t\t\t? chalk.green(\" (autofixable)\")\n\t\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\t\t\tmessages.append(\n\t\t\t\t\t\t\t\t`'${policy.name}' policy failure${autoFixable}: ${result.file}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tmessages.append(\n\t\t\t\t\t\t\t\tresult.errorMessage === undefined\n\t\t\t\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t\t\t\t: `${newline}${result.errorMessage}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ((process.exitCode ?? 0) === 0) {\n\t\t\t\t\t\tthis.info(messages.toString());\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.warning(messages.toString());\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * Given a string that represents a path to a file in the repo, determines if the file should be checked, and if so,\n\t * routes the file to the appropriate handlers.\n\t */\n\tprivate async checkOrExcludeFile(\n\t\tinputPath: string,\n\t\tcommandContext: PolicyCommandContext,\n\t): Promise<void> {\n\t\tconst { excludeFiles: exclusions, gitRoot, pathRegex } = commandContext;\n\n\t\tconst filePath = path.join(gitRoot, inputPath).trim().replace(/\\\\/g, \"/\");\n\n\t\tif (!(pathRegex.test(inputPath) && fs.existsSync(filePath))) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.count++;\n\t\tif (!exclusions.every((value) => !value.test(inputPath))) {\n\t\t\tthis.verbose(`Excluded all handlers: ${inputPath}`);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.routeToHandlers(filePath, commandContext);\n\t\t} catch (error: unknown) {\n\t\t\tthrow new Error(`Error routing ${filePath} to handler: ${error}`);\n\t\t}\n\n\t\tthis.processed++;\n\t}\n}\n\nasync function readStdin(): Promise<string> {\n\treturn new Promise((resolve) => {\n\t\tconst stdin = process.stdin;\n\t\tstdin.setEncoding(\"utf8\");\n\n\t\tlet data = \"\";\n\t\tstdin.on(\"data\", (chunk) => {\n\t\t\tdata += chunk;\n\t\t});\n\n\t\tstdin.on(\"end\", () => {\n\t\t\tresolve(data);\n\t\t});\n\n\t\tif (stdin.isTTY) {\n\t\t\tresolve(\"\");\n\t\t}\n\t});\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import assert from "node:assert/strict";
2
- import path from "node:path";
3
- import { updatePackageJsonFile } from "@fluidframework/build-tools";
2
+ import { updatePackageJsonFile } from "@fluid-tools/build-infrastructure";
3
+ import path from "pathe";
4
4
  import jsonfile from "jsonfile";
5
5
  const { readFile: readJson } = jsonfile;
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PackageJsonRepoDirectoryProperty.js","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAGpE,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;AAIxC;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAe;IAC3D,IAAI,EAAE,kCAAkC;IACxC,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,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AAC;YACnB,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport path from \"node:path\";\nimport { updatePackageJsonFile } from \"@fluidframework/build-tools\";\nimport type { PackageJson } from \"type-fest\";\n\nimport jsonfile from \"jsonfile\";\nconst { readFile: readJson } = jsonfile;\n\nimport type { PolicyFailure, PolicyFixResult, RepoPolicy } from \"../policy.js\";\n\n/**\n * A RepoPolicy that checks that the repository.directory property in package.json is set correctly. If the repository\n * field is a string instead of an object the package will be ignored.\n */\nexport const PackageJsonRepoDirectoryProperty: RepoPolicy = {\n\tname: \"PackageJsonRepoDirectoryProperty\",\n\tmatch: /(^|\\/)package\\.json/i,\n\thandler: async ({ file, root, resolve }) => {\n\t\tconst failResult: PolicyFailure = {\n\t\t\tname: PackageJsonRepoDirectoryProperty.name,\n\t\t\tfile,\n\t\t\tautoFixable: true,\n\t\t};\n\n\t\tconst fixResult: PolicyFixResult = {\n\t\t\t...failResult,\n\t\t\tresolved: false,\n\t\t};\n\n\t\tconst pkg = (await readJson(file)) as PackageJson;\n\t\tconst pkgDir = path.dirname(file);\n\t\tconst relativePkgDir = path.relative(root, pkgDir);\n\n\t\tif (typeof pkg.repository === \"object\") {\n\t\t\tif (pkg.repository.directory !== relativePkgDir) {\n\t\t\t\tif (resolve) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tupdatePackageJsonFile(file, (json) => {\n\t\t\t\t\t\t\tassert(typeof json.repository === \"object\");\n\t\t\t\t\t\t\tjson.repository.directory = relativePkgDir;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfixResult.resolved = true;\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tfixResult.resolved = false;\n\t\t\t\t\t\tfixResult.errorMessage = `${(error as Error).message}\\n${\n\t\t\t\t\t\t\t(error as Error).stack\n\t\t\t\t\t\t}`;\n\t\t\t\t\t}\n\t\t\t\t\treturn fixResult;\n\t\t\t\t}\n\t\t\t\tfailResult.errorMessage = `repository.directory value is wrong. Expected '${relativePkgDir}', got '${pkg.repository.directory}'`;\n\t\t\t\treturn failResult;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t},\n};\n"]}
1
+ {"version":3,"file":"PackageJsonRepoDirectoryProperty.js","sourceRoot":"","sources":["../../src/policies/PackageJsonRepoDirectoryProperty.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,IAAI,MAAM,OAAO,CAAC;AAGzB,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;AAIxC;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAe;IAC3D,IAAI,EAAE,kCAAkC;IACxC,KAAK,EAAE,sBAAsB;IAC7B,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1C,MAAM,UAAU,GAAkB;YACjC,IAAI,EAAE,gCAAgC,CAAC,IAAI;YAC3C,IAAI;YACJ,WAAW,EAAE,IAAI;SACjB,CAAC;QAEF,MAAM,SAAS,GAAoB;YAClC,GAAG,UAAU;YACb,QAAQ,EAAE,KAAK;SACf,CAAC;QAEF,MAAM,GAAG,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAgB,CAAC;QAClD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEnD,IAAI,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;YACxC,IAAI,GAAG,CAAC,UAAU,CAAC,SAAS,KAAK,cAAc,EAAE,CAAC;gBACjD,IAAI,OAAO,EAAE,CAAC;oBACb,IAAI,CAAC;wBACJ,qBAAqB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE;4BACpC,MAAM,CAAC,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC;4BAC5C,IAAI,CAAC,UAAU,CAAC,SAAS,GAAG,cAAc,CAAC;wBAC5C,CAAC,CAAC,CAAC;wBACH,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;oBAC3B,CAAC;oBAAC,OAAO,KAAc,EAAE,CAAC;wBACzB,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC;wBAC3B,SAAS,CAAC,YAAY,GAAG,GAAI,KAAe,CAAC,OAAO,KAClD,KAAe,CAAC,KAClB,EAAE,CAAC;oBACJ,CAAC;oBACD,OAAO,SAAS,CAAC;gBAClB,CAAC;gBACD,UAAU,CAAC,YAAY,GAAG,kDAAkD,cAAc,WAAW,GAAG,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC;gBACjI,OAAO,UAAU,CAAC;YACnB,CAAC;QACF,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC","sourcesContent":["import assert from \"node:assert/strict\";\nimport { updatePackageJsonFile } from \"@fluid-tools/build-infrastructure\";\nimport path from \"pathe\";\nimport type { PackageJson } from \"type-fest\";\n\nimport jsonfile from \"jsonfile\";\nconst { readFile: readJson } = jsonfile;\n\nimport type { PolicyFailure, PolicyFixResult, RepoPolicy } from \"../policy.js\";\n\n/**\n * A RepoPolicy that checks that the repository.directory property in package.json is set correctly. If the repository\n * field is a string instead of an object the package will be ignored.\n */\nexport const PackageJsonRepoDirectoryProperty: RepoPolicy = {\n\tname: \"PackageJsonRepoDirectoryProperty\",\n\tmatch: /(^|\\/)package\\.json/i,\n\thandler: async ({ file, root, resolve }) => {\n\t\tconst failResult: PolicyFailure = {\n\t\t\tname: PackageJsonRepoDirectoryProperty.name,\n\t\t\tfile,\n\t\t\tautoFixable: true,\n\t\t};\n\n\t\tconst fixResult: PolicyFixResult = {\n\t\t\t...failResult,\n\t\t\tresolved: false,\n\t\t};\n\n\t\tconst pkg = (await readJson(file)) as PackageJson;\n\t\tconst pkgDir = path.dirname(file);\n\t\tconst relativePkgDir = path.relative(root, pkgDir);\n\n\t\tif (typeof pkg.repository === \"object\") {\n\t\t\tif (pkg.repository.directory !== relativePkgDir) {\n\t\t\t\tif (resolve) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tupdatePackageJsonFile(file, (json) => {\n\t\t\t\t\t\t\tassert(typeof json.repository === \"object\");\n\t\t\t\t\t\t\tjson.repository.directory = relativePkgDir;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfixResult.resolved = true;\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tfixResult.resolved = false;\n\t\t\t\t\t\tfixResult.errorMessage = `${(error as Error).message}\\n${\n\t\t\t\t\t\t\t(error as Error).stack\n\t\t\t\t\t\t}`;\n\t\t\t\t\t}\n\t\t\t\t\treturn fixResult;\n\t\t\t\t}\n\t\t\t\tfailResult.errorMessage = `repository.directory value is wrong. Expected '${relativePkgDir}', got '${pkg.repository.directory}'`;\n\t\t\t\treturn failResult;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t},\n};\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.9"
8
+ "packageVersion": "7.50.0"
9
9
  }
10
10
  ]
11
11
  }
@@ -133,5 +133,5 @@
133
133
  ]
134
134
  }
135
135
  },
136
- "version": "0.3.2"
136
+ "version": "0.4.0"
137
137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repopo",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Enforce policies on all or some of the files in a git repository.",
5
5
  "keywords": [
6
6
  "policy",
@@ -45,35 +45,35 @@
45
45
  "repositoryPrefix": "<%- repo %>/blob/main/packages/repopo/<%- commandPath %>"
46
46
  },
47
47
  "dependencies": {
48
- "@fluidframework/build-tools": "^0.51.0",
49
- "@oclif/core": "^4.0.19",
50
- "@oclif/plugin-help": "^6.2.10",
48
+ "@fluid-tools/build-infrastructure": "^0.52.0",
49
+ "@oclif/core": "^4.2.3",
50
+ "@oclif/plugin-help": "^6.2.21",
51
51
  "@rushstack/node-core-library": "^5.7.0",
52
- "cosmiconfig": "^9.0.0",
53
52
  "jsonfile": "^6.1.0",
53
+ "pathe": "^2.0.3",
54
54
  "picocolors": "^1.1.0",
55
- "sort-package-json": "2.10.0",
56
- "@tylerbu/cli-api": "^0.6.1",
57
- "sort-tsconfig": "^0.1.4"
55
+ "sort-package-json": "2.14.0",
56
+ "@tylerbu/cli-api": "^0.7.0",
57
+ "sort-tsconfig": "^0.2.0"
58
58
  },
59
59
  "devDependencies": {
60
- "@biomejs/biome": "1.8.3",
61
- "@microsoft/api-extractor": "^7.43.4",
62
- "@oclif/plugin-command-snapshot": "^5.2.14",
63
- "@oclif/test": "^4.0.9",
60
+ "@biomejs/biome": "1.9.4",
61
+ "@microsoft/api-extractor": "^7.50.0",
62
+ "@oclif/plugin-command-snapshot": "^5.2.26",
63
+ "@oclif/test": "^4.1.7",
64
64
  "@types/jsonfile": "^6.1.4",
65
65
  "@types/node": "^20.12.7",
66
66
  "@types/tmp": "^0.2.6",
67
- "lefthook": "^1.6.11",
68
- "oclif": "^4.14.26",
69
- "rimraf": "^6.0.0",
70
- "serve": "^14.2.3",
71
- "start-server-and-test": "^2.0.3",
67
+ "generate-license-file": "^3.7.0",
68
+ "oclif": "^4.17.13",
69
+ "rimraf": "^6.0.1",
70
+ "serve": "^14.2.4",
71
+ "start-server-and-test": "^2.0.10",
72
72
  "tmp-promise": "^3.0.3",
73
73
  "ts-node": "^10.9.2",
74
- "type-fest": "^4.18.2",
74
+ "type-fest": "^4.34.1",
75
75
  "typescript": "~5.5.4",
76
- "vitest": "^2.0.0"
76
+ "vitest": "^3.0.5"
77
77
  },
78
78
  "engines": {
79
79
  "node": ">=18.0.0"
@@ -91,6 +91,8 @@
91
91
  "compile": "tsc --project ./tsconfig.json",
92
92
  "format": "biome check . --linter-enabled=false --write",
93
93
  "full": "fluid-build . --task full",
94
+ "generate": "concurrently npm:generate:*",
95
+ "generate:license-file": "generate-license-file -c ../../.generatelicensefile.cjs",
94
96
  "lint": "biome lint .",
95
97
  "lint:fix": "biome lint . --write",
96
98
  "manifest": "oclif manifest",