repopo 0.7.0 → 0.8.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +187 -6
  2. package/THIRD-PARTY-LICENSES.txt +149 -3
  3. package/esm/adapters/fluidFramework.d.ts +103 -0
  4. package/esm/adapters/fluidFramework.d.ts.map +1 -0
  5. package/esm/adapters/fluidFramework.js +119 -0
  6. package/esm/adapters/fluidFramework.js.map +1 -0
  7. package/esm/baseCommand.d.ts +1 -0
  8. package/esm/baseCommand.d.ts.map +1 -1
  9. package/esm/baseCommand.js +2 -1
  10. package/esm/baseCommand.js.map +1 -1
  11. package/esm/commands/check.d.ts.map +1 -1
  12. package/esm/commands/check.js +9 -8
  13. package/esm/commands/check.js.map +1 -1
  14. package/esm/index.d.ts +1 -0
  15. package/esm/index.d.ts.map +1 -1
  16. package/esm/index.js +1 -0
  17. package/esm/index.js.map +1 -1
  18. package/esm/perf.d.ts +4 -1
  19. package/esm/perf.d.ts.map +1 -1
  20. package/esm/perf.js +3 -2
  21. package/esm/perf.js.map +1 -1
  22. package/esm/policies/LicenseFileExists.d.ts.map +1 -1
  23. package/esm/policies/LicenseFileExists.js +3 -1
  24. package/esm/policies/LicenseFileExists.js.map +1 -1
  25. package/esm/policies/NoJsFileExtensions.d.ts.map +1 -1
  26. package/esm/policies/NoJsFileExtensions.js +4 -1
  27. package/esm/policies/NoJsFileExtensions.js.map +1 -1
  28. package/esm/policies/NoLargeBinaryFiles.d.ts.map +1 -1
  29. package/esm/policies/NoLargeBinaryFiles.js +3 -1
  30. package/esm/policies/NoLargeBinaryFiles.js.map +1 -1
  31. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts +37 -0
  32. package/esm/policies/NoPrivateWorkspaceDependencies.d.ts.map +1 -0
  33. package/esm/policies/NoPrivateWorkspaceDependencies.js +137 -0
  34. package/esm/policies/NoPrivateWorkspaceDependencies.js.map +1 -0
  35. package/esm/policies/PackageAllowedScopes.d.ts +88 -0
  36. package/esm/policies/PackageAllowedScopes.d.ts.map +1 -0
  37. package/esm/policies/PackageAllowedScopes.js +113 -0
  38. package/esm/policies/PackageAllowedScopes.js.map +1 -0
  39. package/esm/policies/PackageEsmType.d.ts +100 -0
  40. package/esm/policies/PackageEsmType.d.ts.map +1 -0
  41. package/esm/policies/PackageEsmType.js +257 -0
  42. package/esm/policies/PackageEsmType.js.map +1 -0
  43. package/esm/policies/PackageFolderName.d.ts +97 -0
  44. package/esm/policies/PackageFolderName.d.ts.map +1 -0
  45. package/esm/policies/PackageFolderName.js +104 -0
  46. package/esm/policies/PackageFolderName.js.map +1 -0
  47. package/esm/policies/PackageJsonProperties.d.ts.map +1 -1
  48. package/esm/policies/PackageJsonProperties.js +2 -1
  49. package/esm/policies/PackageJsonProperties.js.map +1 -1
  50. package/esm/policies/PackageJsonRepoDirectoryProperty.d.ts.map +1 -1
  51. package/esm/policies/PackageJsonRepoDirectoryProperty.js +4 -3
  52. package/esm/policies/PackageJsonRepoDirectoryProperty.js.map +1 -1
  53. package/esm/policies/PackageJsonSorted.d.ts.map +1 -1
  54. package/esm/policies/PackageJsonSorted.js +11 -3
  55. package/esm/policies/PackageJsonSorted.js.map +1 -1
  56. package/esm/policies/PackageLicense.d.ts +61 -0
  57. package/esm/policies/PackageLicense.d.ts.map +1 -0
  58. package/esm/policies/PackageLicense.js +131 -0
  59. package/esm/policies/PackageLicense.js.map +1 -0
  60. package/esm/policies/PackagePrivateField.d.ts +124 -0
  61. package/esm/policies/PackagePrivateField.d.ts.map +1 -0
  62. package/esm/policies/PackagePrivateField.js +155 -0
  63. package/esm/policies/PackagePrivateField.js.map +1 -0
  64. package/esm/policies/PackageReadme.d.ts +77 -0
  65. package/esm/policies/PackageReadme.d.ts.map +1 -0
  66. package/esm/policies/PackageReadme.js +209 -0
  67. package/esm/policies/PackageReadme.js.map +1 -0
  68. package/esm/policies/PackageScripts.d.ts +180 -2
  69. package/esm/policies/PackageScripts.d.ts.map +1 -1
  70. package/esm/policies/PackageScripts.js +349 -29
  71. package/esm/policies/PackageScripts.js.map +1 -1
  72. package/esm/policies/PackageTestScripts.d.ts +100 -0
  73. package/esm/policies/PackageTestScripts.d.ts.map +1 -0
  74. package/esm/policies/PackageTestScripts.js +149 -0
  75. package/esm/policies/PackageTestScripts.js.map +1 -0
  76. package/esm/policies/RequiredGitignorePatterns.d.ts.map +1 -1
  77. package/esm/policies/RequiredGitignorePatterns.js +10 -4
  78. package/esm/policies/RequiredGitignorePatterns.js.map +1 -1
  79. package/esm/policies.d.ts +9 -1
  80. package/esm/policies.d.ts.map +1 -1
  81. package/esm/policies.js +10 -1
  82. package/esm/policies.js.map +1 -1
  83. package/esm/policy.d.ts +5 -1
  84. package/esm/policy.d.ts.map +1 -1
  85. package/esm/policy.js.map +1 -1
  86. package/esm/policyDefiners/defineFileHeaderPolicy.d.ts.map +1 -1
  87. package/esm/policyDefiners/defineFileHeaderPolicy.js +2 -1
  88. package/esm/policyDefiners/defineFileHeaderPolicy.js.map +1 -1
  89. package/esm/policyDefiners/definePackagePolicy.d.ts.map +1 -1
  90. package/esm/policyDefiners/definePackagePolicy.js +2 -1
  91. package/esm/policyDefiners/definePackagePolicy.js.map +1 -1
  92. package/esm/tsdoc-metadata.json +1 -1
  93. package/esm/utils/indentation.d.ts +73 -0
  94. package/esm/utils/indentation.d.ts.map +1 -0
  95. package/esm/utils/indentation.js +97 -0
  96. package/esm/utils/indentation.js.map +1 -0
  97. package/esm/utils/packageName.d.ts +71 -0
  98. package/esm/utils/packageName.d.ts.map +1 -0
  99. package/esm/utils/packageName.js +79 -0
  100. package/esm/utils/packageName.js.map +1 -0
  101. package/oclif.manifest.json +1 -1
  102. package/package.json +30 -15
package/CHANGELOG.md CHANGED
@@ -1,5 +1,192 @@
1
1
  # repopo
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - **BREAKING CHANGE**: Change `PolicyFailure.errorMessage` to `errorMessages` array. _[`#552`](https://github.com/tylerbutler/tools-monorepo/pull/552) [`6b6317a`](https://github.com/tylerbutler/tools-monorepo/commit/6b6317a7be0a050dc0665a9af7b187afb1bb4b31) [@tylerbutler](https://github.com/tylerbutler)_
8
+
9
+ The `PolicyFailure` interface now uses `errorMessages: string[]` instead of `errorMessage?: string`. This allows policies to report multiple error messages per failure and provides clearer semantics.
10
+
11
+ Additionally, a new optional `manualFix?: string` property has been added to provide user guidance on how to resolve policy failures manually.
12
+
13
+ Migration:
14
+ - Change `errorMessage: "message"` to `errorMessages: ["message"]`
15
+ - For multiple messages, use `errorMessages: ["msg1", "msg2"]`
16
+ - When checking failures, use `errorMessages.join("\n")` instead of `errorMessage`
17
+
18
+ - Add NoPrivateWorkspaceDependencies policy that prevents publishable packages from depending on private workspace packages via the `workspace:` protocol. This catches configuration issues where a public npm package would fail to install because its workspace dependencies aren't published. _[`#534`](https://github.com/tylerbutler/tools-monorepo/pull/534) [`b7e4d4b`](https://github.com/tylerbutler/tools-monorepo/commit/b7e4d4b374cae228d246b16c668ba6e55c08f3dc) [@tylerbutler](https://github.com/tylerbutler)_
19
+
20
+ The policy:
21
+ - Detects workspace dependencies using the `workspace:` protocol
22
+ - Checks if those dependencies are marked as private
23
+ - Reports violations for publishable packages that depend on private packages
24
+ - Supports configurable `checkDevDependencies` option (default: false)
25
+ - Uses workspace configuration (pnpm-workspace.yaml or package.json workspaces) for package discovery
26
+
27
+ - Make sort-tsconfig and sort-package-json peer dependencies _[`#395`](https://github.com/tylerbutler/tools-monorepo/pull/395) [`ee059d0`](https://github.com/tylerbutler/tools-monorepo/commit/ee059d02161494c14eb6131aaf32624902fd65e4) [@tylerbutler](https://github.com/tylerbutler)_
28
+
29
+ Moves `sort-tsconfig` and `sort-package-json` from dependencies to peerDependencies, allowing consumers to control versions and reducing bundle size.
30
+
31
+ - Add multiple new policies and enhance existing PackageScripts policy _[`#535`](https://github.com/tylerbutler/tools-monorepo/pull/535) [`79e19e8`](https://github.com/tylerbutler/tools-monorepo/commit/79e19e892a5b1193650cab21a4d38187c700fb01) [@tylerbutler](https://github.com/tylerbutler)_
32
+
33
+ ## New Policies
34
+
35
+ ### PackageAllowedScopes
36
+
37
+ Validates that packages use only approved npm scopes or package names, preventing accidental
38
+ introduction of new scopes and maintaining naming consistency.
39
+
40
+ ### PackageLicense
41
+
42
+ Ensures each package has a LICENSE file that matches the root repository LICENSE. Supports
43
+ auto-fixing by copying the root LICENSE to packages. By default, skips private packages.
44
+
45
+ ### PackageReadme
46
+
47
+ Validates that packages have README.md files with proper content:
48
+ - Ensures README exists
49
+ - Validates title matches package name
50
+ - Can require specific content (e.g., trademark notices)
51
+ - Supports auto-fixing by creating or updating README files
52
+
53
+ ## Enhanced PackageScripts Policy
54
+
55
+ Added powerful new validation options with a cleaner, more intuitive configuration API.
56
+
57
+ ### must (enhanced)
58
+
59
+ The `must` array now accepts either strings (script must exist, no auto-fix) or objects with
60
+ inline default values (script must exist, auto-fixable with the default):
61
+
62
+ ```typescript
63
+ must: [
64
+ "test", // Must exist, no auto-fix available
65
+ { build: "tsc" }, // Must exist, auto-fix adds "tsc" if missing
66
+ { lint: "biome lint ." }, // Must exist, auto-fix adds "biome lint ." if missing
67
+ ];
68
+ ```
69
+
70
+ Existing scripts with different content will pass validation - only the existence is enforced.
71
+
72
+ ### exact (new)
73
+
74
+ Scripts that must exist AND have exact content. Both missing and mismatched scripts are
75
+ auto-fixable:
76
+
77
+ ```typescript
78
+ exact: {
79
+ clean: "rimraf dist esm",
80
+ format: "biome format --write .",
81
+ }
82
+ ```
83
+
84
+ ### conditionalRequired (enhanced)
85
+
86
+ Enforce that certain scripts must exist when other scripts are present. The `requires` field
87
+ now accepts the same format as `must` - strings or objects with inline defaults for auto-fix:
88
+
89
+ ```typescript
90
+ // With inline default - auto-fixable
91
+ conditionalRequired: [
92
+ { ifPresent: "build", requires: [{ clean: "rimraf dist" }] },
93
+ ];
94
+
95
+ // Mixed: "test" required without default, "clean" with default
96
+ conditionalRequired: [
97
+ { ifPresent: "build", requires: ["test", { clean: "rimraf dist" }] },
98
+ ];
99
+ ```
100
+
101
+ ### scriptMustContain
102
+
103
+ Validate that script bodies contain required substrings:
104
+
105
+ ```typescript
106
+ scriptMustContain: [{ script: "clean", mustContain: ["rimraf"] }];
107
+ ```
108
+
109
+ ## Usage Examples
110
+
111
+ ```typescript
112
+ import { makePolicy, type RepopoConfig } from "repopo";
113
+ import {
114
+ PackageAllowedScopes,
115
+ PackageLicense,
116
+ PackageReadme,
117
+ PackageScripts,
118
+ } from "repopo/policies";
119
+
120
+ const config: RepopoConfig = {
121
+ policies: [
122
+ makePolicy(PackageAllowedScopes, {
123
+ allowedScopes: ["@myorg", "@internal"],
124
+ }),
125
+ makePolicy(PackageLicense),
126
+ makePolicy(PackageReadme, {
127
+ requiredContent: "## Trademark",
128
+ }),
129
+ makePolicy(PackageScripts, {
130
+ // Scripts that must exist
131
+ must: [
132
+ "test", // Must exist, no auto-fix
133
+ { build: "tsc" }, // Must exist, auto-fix available
134
+ { lint: "biome lint ." }, // Must exist, auto-fix available
135
+ ],
136
+ // Scripts that must exist AND match exactly
137
+ exact: {
138
+ clean: "rimraf dist esm",
139
+ format: "biome format --write .",
140
+ },
141
+ // If "build" exists, "clean" must also exist (with inline auto-fix default)
142
+ conditionalRequired: [
143
+ { ifPresent: "build", requires: [{ clean: "rimraf dist" }] },
144
+ ],
145
+ // Validate script content contains required substrings
146
+ scriptMustContain: [{ script: "build", mustContain: ["tsc"] }],
147
+ // Only one of these can exist
148
+ mutuallyExclusive: [["lint:eslint", "lint:biome"]],
149
+ }),
150
+ ],
151
+ };
152
+ ```
153
+
154
+ ### Patch Changes
155
+
156
+ - Update to use new cli-api logger API _[`#395`](https://github.com/tylerbutler/tools-monorepo/pull/395) [`ee059d0`](https://github.com/tylerbutler/tools-monorepo/commit/ee059d02161494c14eb6131aaf32624902fd65e4) [@tylerbutler](https://github.com/tylerbutler)_
157
+
158
+ Updates commands to use the new logger API from @tylerbu/cli-api:
159
+ - Replace `errorLog()` calls with `logError()`
160
+ - Use standalone `logIndent()` function where needed
161
+
162
+ <details><summary>Updated 1 dependency</summary>
163
+
164
+ <small>
165
+
166
+ [`ee059d0`](https://github.com/tylerbutler/tools-monorepo/commit/ee059d02161494c14eb6131aaf32624902fd65e4)
167
+
168
+ </small>
169
+
170
+ - `@tylerbu/cli-api@0.10.0`
171
+
172
+ </details>
173
+
174
+ ## 0.7.1
175
+
176
+ ### Patch Changes
177
+
178
+ <details><summary>Updated 1 dependency</summary>
179
+
180
+ <small>
181
+
182
+ [`8832369`](https://github.com/tylerbutler/tools-monorepo/commit/8832369318b6efee8adae1636f3629639b0d76ac)
183
+
184
+ </small>
185
+
186
+ - `@tylerbu/cli-api@0.9.0`
187
+
188
+ </details>
189
+
3
190
  ## 0.7.0
4
191
 
5
192
  ### Minor Changes
@@ -7,7 +194,6 @@
7
194
  - Add configurable PackageScripts policy _[`#376`](https://github.com/tylerbutler/tools-monorepo/pull/376) [`c17462a`](https://github.com/tylerbutler/tools-monorepo/commit/c17462a8af35a8bfbb528f29825a0ef177923946) [@tylerbutler](https://github.com/tylerbutler)_
8
195
 
9
196
  Enhances the `PackageScripts` policy with flexible configuration options to enforce package.json script requirements across your repository. The policy now supports two validation modes:
10
-
11
197
  1. **Required Scripts (`must`)**: Specify scripts that must be present in all package.json files
12
198
  2. **Mutually Exclusive Scripts (`mutuallyExclusive`)**: Define groups of scripts where exactly one from each group must exist
13
199
 
@@ -23,7 +209,6 @@
23
209
  ```
24
210
 
25
211
  The policy validates that:
26
-
27
212
  - All scripts in the `must` array are present
28
213
  - For each group in `mutuallyExclusive`, exactly one script from that group exists (not zero, not multiple)
29
214
 
@@ -32,7 +217,6 @@
32
217
  - New built-in policies _[`#308`](https://github.com/tylerbutler/tools-monorepo/pull/308) [`1856d58`](https://github.com/tylerbutler/tools-monorepo/commit/1856d582fb92692447b02c89cdb45dcd3c5f7370) [@tylerbutler](https://github.com/tylerbutler)_
33
218
 
34
219
  Added three new policies for repository quality and safety:
35
-
36
220
  - **LicenseFileExists**: Ensures a LICENSE file exists in the repository root (essential for open source projects)
37
221
  - **NoLargeBinaryFiles**: Prevents large binary files from being committed (default 10MB max, suggests Git LFS for large assets)
38
222
  - **RequiredGitignorePatterns**: Validates .gitignore contains required patterns to prevent committing sensitive files, dependencies, and build artifacts (auto-fixable)
@@ -96,18 +280,15 @@
96
280
  repopo now exports all included policies individually so users can opt in and out of them in their config.
97
281
 
98
282
  - 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)_
99
-
100
283
  - JsTsFileHeaders
101
284
  - HtmlFileHeaders
102
285
  - PackageScripts
103
286
 
104
287
  - 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)_
105
-
106
288
  - **Breaking change**: `PolicyConfig` was renamed to `RepopoConfig`.
107
289
  - **Breaking change**: Removed several flags from the check command.
108
290
 
109
291
  Other changes:
110
-
111
292
  - Refactor check command for clarity (more to do)
112
293
 
113
294
  - 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,7 +27,7 @@ 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
- - @rushstack/node-core-library@5.18.0
30
+ - @rushstack/node-core-library@5.19.0
31
31
 
32
32
  This package contains the following license:
33
33
 
@@ -60,7 +60,37 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
60
60
 
61
61
  The following npm package may be included in this product:
62
62
 
63
- - @fluid-tools/build-infrastructure@0.60.0
63
+ - resolve-workspace-root@2.0.0
64
+
65
+ This package contains the following license:
66
+
67
+ # The MIT License (MIT)
68
+
69
+ Copyright (c) 2024-present Cedric van Putten <me@cedric.dev>
70
+
71
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
72
+ > of this software and associated documentation files (the "Software"), to deal
73
+ > in the Software without restriction, including without limitation the rights
74
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
75
+ > copies of the Software, and to permit persons to whom the Software is
76
+ > furnished to do so, subject to the following conditions:
77
+ >
78
+ > The above copyright notice and this permission notice shall be included in
79
+ > all copies or substantial portions of the Software.
80
+ >
81
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
83
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
84
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
85
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
86
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
87
+ > THE SOFTWARE.
88
+
89
+ -----------
90
+
91
+ The following npm package may be included in this product:
92
+
93
+ - @fluid-tools/build-infrastructure@0.63.0
64
94
 
65
95
  This package contains the following license:
66
96
 
@@ -125,7 +155,7 @@ MIT
125
155
  The following npm packages may be included in this product:
126
156
 
127
157
  - @oclif/core@4.8.0
128
- - @oclif/plugin-help@6.2.35
158
+ - @oclif/plugin-help@6.2.36
129
159
 
130
160
  These packages each contain the following license:
131
161
 
@@ -183,6 +213,36 @@ SOFTWARE.
183
213
 
184
214
  -----------
185
215
 
216
+ The following npm package may be included in this product:
217
+
218
+ - tinyglobby@0.2.15
219
+
220
+ This package contains the following license:
221
+
222
+ MIT License
223
+
224
+ Copyright (c) 2024 Madeline Gurriarán
225
+
226
+ Permission is hereby granted, free of charge, to any person obtaining a copy
227
+ of this software and associated documentation files (the "Software"), to deal
228
+ in the Software without restriction, including without limitation the rights
229
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
230
+ copies of the Software, and to permit persons to whom the Software is
231
+ furnished to do so, subject to the following conditions:
232
+
233
+ The above copyright notice and this permission notice shall be included in all
234
+ copies or substantial portions of the Software.
235
+
236
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
237
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
238
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
239
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
240
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
241
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
242
+ SOFTWARE.
243
+
244
+ -----------
245
+
186
246
  The following npm package may be included in this product:
187
247
 
188
248
  - defu@6.1.4
@@ -213,6 +273,62 @@ SOFTWARE.
213
273
 
214
274
  -----------
215
275
 
276
+ The following npm package may be included in this product:
277
+
278
+ - consola@3.4.2
279
+
280
+ This package contains the following license:
281
+
282
+ MIT License
283
+
284
+ Copyright (c) Pooya Parsa <pooya@pi0.io>
285
+
286
+ Permission is hereby granted, free of charge, to any person obtaining a copy
287
+ of this software and associated documentation files (the "Software"), to deal
288
+ in the Software without restriction, including without limitation the rights
289
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
290
+ copies of the Software, and to permit persons to whom the Software is
291
+ furnished to do so, subject to the following conditions:
292
+
293
+ The above copyright notice and this permission notice shall be included in all
294
+ copies or substantial portions of the Software.
295
+
296
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
297
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
298
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
299
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
300
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
301
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
302
+ SOFTWARE.
303
+
304
+ ---
305
+
306
+ Prompt support is based on https://github.com/bombshell-dev/clack
307
+
308
+ MIT License
309
+
310
+ Copyright (c) Nate Moore
311
+
312
+ 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:
313
+
314
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
315
+
316
+ 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.
317
+
318
+ ---
319
+
320
+ Color support is based on https://github.com/jorgebucaran/colorette
321
+
322
+ Copyright © Jorge Bucaran <https://jorgebucaran.com>
323
+
324
+ 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:
325
+
326
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
327
+
328
+ 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.
329
+
330
+ -----------
331
+
216
332
  The following npm package may be included in this product:
217
333
 
218
334
  - pathe@2.0.3
@@ -292,5 +408,35 @@ DEALINGS IN THE SOFTWARE.
292
408
 
293
409
  -----------
294
410
 
411
+ The following npm package may be included in this product:
412
+
413
+ - picomatch@4.0.3
414
+
415
+ This package contains the following license:
416
+
417
+ The MIT License (MIT)
418
+
419
+ Copyright (c) 2017-present, Jon Schlinkert.
420
+
421
+ Permission is hereby granted, free of charge, to any person obtaining a copy
422
+ of this software and associated documentation files (the "Software"), to deal
423
+ in the Software without restriction, including without limitation the rights
424
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
425
+ copies of the Software, and to permit persons to whom the Software is
426
+ furnished to do so, subject to the following conditions:
427
+
428
+ The above copyright notice and this permission notice shall be included in
429
+ all copies or substantial portions of the Software.
430
+
431
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
432
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
433
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
434
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
435
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
436
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
437
+ THE SOFTWARE.
438
+
439
+ -----------
440
+
295
441
  This file was generated with the generate-license-file npm package!
296
442
  https://www.npmjs.com/package/generate-license-file
@@ -0,0 +1,103 @@
1
+ import type { PolicyDefinition } from "../policy.js";
2
+ /**
3
+ * A FluidFramework build-tools policy handler interface.
4
+ *
5
+ * This interface matches the `Handler` interface from `@fluidframework/build-tools`.
6
+ *
7
+ * @alpha
8
+ */
9
+ export interface FluidHandler {
10
+ /**
11
+ * The name of the handler, used for filtering and display.
12
+ */
13
+ name: string;
14
+ /**
15
+ * A regex pattern that determines which files this handler applies to.
16
+ */
17
+ match: RegExp;
18
+ /**
19
+ * The handler function that checks a file against the policy.
20
+ *
21
+ * @param file - Absolute path to the file.
22
+ * @param root - Path to the repo root.
23
+ * @returns `undefined` if the check passes, otherwise an error message string.
24
+ */
25
+ handler: (file: string, root: string) => Promise<string | undefined>;
26
+ /**
27
+ * Optional resolver function that attempts to fix policy violations.
28
+ *
29
+ * @param file - Absolute path to the file.
30
+ * @param root - Path to the repo root.
31
+ * @returns An object indicating whether the fix was successful.
32
+ */
33
+ resolver?: (file: string, root: string) => Promise<{
34
+ resolved: boolean;
35
+ message?: string;
36
+ }> | {
37
+ resolved: boolean;
38
+ message?: string;
39
+ };
40
+ }
41
+ /**
42
+ * Options for converting FluidFramework handlers to repopo policies.
43
+ *
44
+ * @alpha
45
+ */
46
+ export interface FluidAdapterOptions {
47
+ /**
48
+ * Optional prefix to add to policy names. Useful for namespacing Fluid policies.
49
+ *
50
+ * @example "Fluid:" would result in "Fluid:my-handler-name"
51
+ */
52
+ namePrefix?: string;
53
+ }
54
+ /**
55
+ * Converts FluidFramework handlers to repopo PolicyDefinitions.
56
+ *
57
+ * This adapter bridges the gap between FluidFramework's build-tools policy system
58
+ * and repopo's policy system, allowing you to reuse existing Fluid policies in repopo.
59
+ *
60
+ * @remarks
61
+ *
62
+ * Key differences handled by this adapter:
63
+ *
64
+ * - **Handler signature**: Fluid uses `(file, root) => string | undefined`,
65
+ * repopo uses `(args) => PolicyHandlerResult`
66
+ *
67
+ * - **File paths**: Fluid passes absolute paths, repopo passes repo-relative paths.
68
+ * The adapter converts between the two.
69
+ *
70
+ * - **Return types**: Fluid returns `string | undefined` (error message or success),
71
+ * repopo returns `true | PolicyFailure | PolicyFixResult`
72
+ *
73
+ * For a single handler, wrap it in an array: `fromFluidHandlers([handler])`.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * import { fromFluidHandlers, makePolicy } from "repopo";
78
+ * import { copyrightFileHeaderHandlers, fluidCaseHandler } from "@fluidframework/build-tools";
79
+ *
80
+ * // Convert multiple handlers with a namespace prefix
81
+ * const FluidCopyrightPolicies = fromFluidHandlers(copyrightFileHeaderHandlers, {
82
+ * namePrefix: "Fluid:",
83
+ * });
84
+ *
85
+ * // For a single handler, wrap it in an array
86
+ * const [FluidCasePolicy] = fromFluidHandlers([fluidCaseHandler]);
87
+ *
88
+ * const config: RepopoConfig = {
89
+ * policies: [
90
+ * ...FluidCopyrightPolicies.map(p => makePolicy(p)),
91
+ * makePolicy(FluidCasePolicy),
92
+ * ],
93
+ * };
94
+ * ```
95
+ *
96
+ * @param fluidHandlers - An array of FluidFramework Handler objects to convert.
97
+ * @param options - Optional configuration applied to all conversions.
98
+ * @returns An array of repopo PolicyDefinitions.
99
+ *
100
+ * @alpha
101
+ */
102
+ export declare function fromFluidHandlers(fluidHandlers: FluidHandler[], options?: FluidAdapterOptions): PolicyDefinition[];
103
+ //# sourceMappingURL=fluidFramework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fluidFramework.d.ts","sourceRoot":"","sources":["../../src/adapters/fluidFramework.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,gBAAgB,EAIhB,MAAM,cAAc,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAErE;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,KAEV,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAChD;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3C;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAwFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,wBAAgB,iBAAiB,CAChC,aAAa,EAAE,YAAY,EAAE,EAC7B,OAAO,CAAC,EAAE,mBAAmB,GAC3B,gBAAgB,EAAE,CAEpB"}
@@ -0,0 +1,119 @@
1
+ import path from "pathe";
2
+ import { makePolicyDefinition } from "../makePolicy.js";
3
+ /**
4
+ * Converts a FluidFramework handler to a repopo PolicyDefinition.
5
+ *
6
+ * This is an internal function used by {@link fromFluidHandlers}.
7
+ *
8
+ * @param fluidHandler - A FluidFramework Handler object to convert.
9
+ * @param options - Optional configuration for the conversion.
10
+ * @returns A repopo PolicyDefinition that wraps the Fluid handler.
11
+ *
12
+ * @internal
13
+ */
14
+ function fromFluidHandler(fluidHandler, options) {
15
+ const { namePrefix = "" } = options ?? {};
16
+ const policyName = `${namePrefix}${fluidHandler.name}`;
17
+ const handler = async ({ file, root, resolve }) => {
18
+ // Fluid handlers expect absolute paths
19
+ const absolutePath = path.join(root, file);
20
+ const errorMessage = await fluidHandler.handler(absolutePath, root);
21
+ if (errorMessage === undefined) {
22
+ return true;
23
+ }
24
+ // Check if resolver exists to determine if auto-fixable
25
+ const autoFixable = fluidHandler.resolver !== undefined;
26
+ // If resolve is requested and we have a resolver, try to fix
27
+ if (resolve && fluidHandler.resolver !== undefined) {
28
+ const resolveResult = await fluidHandler.resolver(absolutePath, root);
29
+ return {
30
+ name: policyName,
31
+ file,
32
+ errorMessages: [resolveResult.message ?? errorMessage],
33
+ autoFixable: true,
34
+ resolved: resolveResult.resolved,
35
+ };
36
+ }
37
+ return {
38
+ name: policyName,
39
+ file,
40
+ errorMessages: [errorMessage],
41
+ autoFixable,
42
+ };
43
+ };
44
+ // Create standalone resolver if Fluid handler has one
45
+ let resolver;
46
+ if (fluidHandler.resolver !== undefined) {
47
+ resolver = async ({ file, root }) => {
48
+ const absolutePath = path.join(root, file);
49
+ // First get the error message for context
50
+ const errorMessage = await fluidHandler.handler(absolutePath, root);
51
+ // biome-ignore lint/style/noNonNullAssertion: we checked this is defined above
52
+ const resolveResult = await fluidHandler.resolver(absolutePath, root);
53
+ return {
54
+ name: policyName,
55
+ file,
56
+ errorMessages: [
57
+ resolveResult.message ?? errorMessage ?? "Unknown error",
58
+ ],
59
+ autoFixable: true,
60
+ resolved: resolveResult.resolved,
61
+ };
62
+ };
63
+ }
64
+ return makePolicyDefinition(policyName, fluidHandler.match, handler, undefined, // no config
65
+ undefined, // no description
66
+ resolver);
67
+ }
68
+ /**
69
+ * Converts FluidFramework handlers to repopo PolicyDefinitions.
70
+ *
71
+ * This adapter bridges the gap between FluidFramework's build-tools policy system
72
+ * and repopo's policy system, allowing you to reuse existing Fluid policies in repopo.
73
+ *
74
+ * @remarks
75
+ *
76
+ * Key differences handled by this adapter:
77
+ *
78
+ * - **Handler signature**: Fluid uses `(file, root) => string | undefined`,
79
+ * repopo uses `(args) => PolicyHandlerResult`
80
+ *
81
+ * - **File paths**: Fluid passes absolute paths, repopo passes repo-relative paths.
82
+ * The adapter converts between the two.
83
+ *
84
+ * - **Return types**: Fluid returns `string | undefined` (error message or success),
85
+ * repopo returns `true | PolicyFailure | PolicyFixResult`
86
+ *
87
+ * For a single handler, wrap it in an array: `fromFluidHandlers([handler])`.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { fromFluidHandlers, makePolicy } from "repopo";
92
+ * import { copyrightFileHeaderHandlers, fluidCaseHandler } from "@fluidframework/build-tools";
93
+ *
94
+ * // Convert multiple handlers with a namespace prefix
95
+ * const FluidCopyrightPolicies = fromFluidHandlers(copyrightFileHeaderHandlers, {
96
+ * namePrefix: "Fluid:",
97
+ * });
98
+ *
99
+ * // For a single handler, wrap it in an array
100
+ * const [FluidCasePolicy] = fromFluidHandlers([fluidCaseHandler]);
101
+ *
102
+ * const config: RepopoConfig = {
103
+ * policies: [
104
+ * ...FluidCopyrightPolicies.map(p => makePolicy(p)),
105
+ * makePolicy(FluidCasePolicy),
106
+ * ],
107
+ * };
108
+ * ```
109
+ *
110
+ * @param fluidHandlers - An array of FluidFramework Handler objects to convert.
111
+ * @param options - Optional configuration applied to all conversions.
112
+ * @returns An array of repopo PolicyDefinitions.
113
+ *
114
+ * @alpha
115
+ */
116
+ export function fromFluidHandlers(fluidHandlers, options) {
117
+ return fluidHandlers.map((h) => fromFluidHandler(h, options));
118
+ }
119
+ //# sourceMappingURL=fluidFramework.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fluidFramework.js","sourceRoot":"","sources":["../../src/adapters/fluidFramework.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAgExD;;;;;;;;;;GAUG;AACH,SAAS,gBAAgB,CACxB,YAA0B,EAC1B,OAA6B;IAE7B,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,GAAG,UAAU,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;IAEvD,MAAM,OAAO,GAAkB,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAChE,uCAAuC;QACvC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE3C,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAEpE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC;QACb,CAAC;QAED,wDAAwD;QACxD,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,KAAK,SAAS,CAAC;QAExD,6DAA6D;QAC7D,IAAI,OAAO,IAAI,YAAY,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACpD,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAEtE,OAAO;gBACN,IAAI,EAAE,UAAU;gBAChB,IAAI;gBACJ,aAAa,EAAE,CAAC,aAAa,CAAC,OAAO,IAAI,YAAY,CAAC;gBACtD,WAAW,EAAE,IAAI;gBACjB,QAAQ,EAAE,aAAa,CAAC,QAAQ;aACN,CAAC;QAC7B,CAAC;QAED,OAAO;YACN,IAAI,EAAE,UAAU;YAChB,IAAI;YACJ,aAAa,EAAE,CAAC,YAAY,CAAC;YAC7B,WAAW;SACX,CAAC;IACH,CAAC,CAAC;IAEF,sDAAsD;IACtD,IAAI,QAA8C,CAAC;IACnD,IAAI,YAAY,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACzC,QAAQ,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE;YACnC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAE3C,0CAA0C;YAC1C,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAEpE,+EAA+E;YAC/E,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,QAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;YAEvE,OAAO;gBACN,IAAI,EAAE,UAAU;gBAChB,IAAI;gBACJ,aAAa,EAAE;oBACd,aAAa,CAAC,OAAO,IAAI,YAAY,IAAI,eAAe;iBACxD;gBACD,WAAW,EAAE,IAAI;gBACjB,QAAQ,EAAE,aAAa,CAAC,QAAQ;aAChC,CAAC;QACH,CAAC,CAAC;IACH,CAAC;IAED,OAAO,oBAAoB,CAC1B,UAAU,EACV,YAAY,CAAC,KAAK,EAClB,OAAO,EACP,SAAS,EAAE,YAAY;IACvB,SAAS,EAAE,iBAAiB;IAC5B,QAAQ,CACR,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,UAAU,iBAAiB,CAChC,aAA6B,EAC7B,OAA6B;IAE7B,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["import path from \"pathe\";\nimport { makePolicyDefinition } from \"../makePolicy.js\";\nimport type {\n\tPolicyDefinition,\n\tPolicyFixResult,\n\tPolicyHandler,\n\tPolicyStandaloneResolver,\n} from \"../policy.js\";\n\n/**\n * A FluidFramework build-tools policy handler interface.\n *\n * This interface matches the `Handler` interface from `@fluidframework/build-tools`.\n *\n * @alpha\n */\nexport interface FluidHandler {\n\t/**\n\t * The name of the handler, used for filtering and display.\n\t */\n\tname: string;\n\n\t/**\n\t * A regex pattern that determines which files this handler applies to.\n\t */\n\tmatch: RegExp;\n\n\t/**\n\t * The handler function that checks a file against the policy.\n\t *\n\t * @param file - Absolute path to the file.\n\t * @param root - Path to the repo root.\n\t * @returns `undefined` if the check passes, otherwise an error message string.\n\t */\n\thandler: (file: string, root: string) => Promise<string | undefined>;\n\n\t/**\n\t * Optional resolver function that attempts to fix policy violations.\n\t *\n\t * @param file - Absolute path to the file.\n\t * @param root - Path to the repo root.\n\t * @returns An object indicating whether the fix was successful.\n\t */\n\tresolver?: (\n\t\tfile: string,\n\t\troot: string,\n\t) =>\n\t\t| Promise<{ resolved: boolean; message?: string }>\n\t\t| { resolved: boolean; message?: string };\n}\n\n/**\n * Options for converting FluidFramework handlers to repopo policies.\n *\n * @alpha\n */\nexport interface FluidAdapterOptions {\n\t/**\n\t * Optional prefix to add to policy names. Useful for namespacing Fluid policies.\n\t *\n\t * @example \"Fluid:\" would result in \"Fluid:my-handler-name\"\n\t */\n\tnamePrefix?: string;\n}\n\n/**\n * Converts a FluidFramework handler to a repopo PolicyDefinition.\n *\n * This is an internal function used by {@link fromFluidHandlers}.\n *\n * @param fluidHandler - A FluidFramework Handler object to convert.\n * @param options - Optional configuration for the conversion.\n * @returns A repopo PolicyDefinition that wraps the Fluid handler.\n *\n * @internal\n */\nfunction fromFluidHandler(\n\tfluidHandler: FluidHandler,\n\toptions?: FluidAdapterOptions,\n): PolicyDefinition {\n\tconst { namePrefix = \"\" } = options ?? {};\n\tconst policyName = `${namePrefix}${fluidHandler.name}`;\n\n\tconst handler: PolicyHandler = async ({ file, root, resolve }) => {\n\t\t// Fluid handlers expect absolute paths\n\t\tconst absolutePath = path.join(root, file);\n\n\t\tconst errorMessage = await fluidHandler.handler(absolutePath, root);\n\n\t\tif (errorMessage === undefined) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Check if resolver exists to determine if auto-fixable\n\t\tconst autoFixable = fluidHandler.resolver !== undefined;\n\n\t\t// If resolve is requested and we have a resolver, try to fix\n\t\tif (resolve && fluidHandler.resolver !== undefined) {\n\t\t\tconst resolveResult = await fluidHandler.resolver(absolutePath, root);\n\n\t\t\treturn {\n\t\t\t\tname: policyName,\n\t\t\t\tfile,\n\t\t\t\terrorMessages: [resolveResult.message ?? errorMessage],\n\t\t\t\tautoFixable: true,\n\t\t\t\tresolved: resolveResult.resolved,\n\t\t\t} satisfies PolicyFixResult;\n\t\t}\n\n\t\treturn {\n\t\t\tname: policyName,\n\t\t\tfile,\n\t\t\terrorMessages: [errorMessage],\n\t\t\tautoFixable,\n\t\t};\n\t};\n\n\t// Create standalone resolver if Fluid handler has one\n\tlet resolver: PolicyStandaloneResolver | undefined;\n\tif (fluidHandler.resolver !== undefined) {\n\t\tresolver = async ({ file, root }) => {\n\t\t\tconst absolutePath = path.join(root, file);\n\n\t\t\t// First get the error message for context\n\t\t\tconst errorMessage = await fluidHandler.handler(absolutePath, root);\n\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: we checked this is defined above\n\t\t\tconst resolveResult = await fluidHandler.resolver!(absolutePath, root);\n\n\t\t\treturn {\n\t\t\t\tname: policyName,\n\t\t\t\tfile,\n\t\t\t\terrorMessages: [\n\t\t\t\t\tresolveResult.message ?? errorMessage ?? \"Unknown error\",\n\t\t\t\t],\n\t\t\t\tautoFixable: true,\n\t\t\t\tresolved: resolveResult.resolved,\n\t\t\t};\n\t\t};\n\t}\n\n\treturn makePolicyDefinition(\n\t\tpolicyName,\n\t\tfluidHandler.match,\n\t\thandler,\n\t\tundefined, // no config\n\t\tundefined, // no description\n\t\tresolver,\n\t);\n}\n\n/**\n * Converts FluidFramework handlers to repopo PolicyDefinitions.\n *\n * This adapter bridges the gap between FluidFramework's build-tools policy system\n * and repopo's policy system, allowing you to reuse existing Fluid policies in repopo.\n *\n * @remarks\n *\n * Key differences handled by this adapter:\n *\n * - **Handler signature**: Fluid uses `(file, root) => string | undefined`,\n * repopo uses `(args) => PolicyHandlerResult`\n *\n * - **File paths**: Fluid passes absolute paths, repopo passes repo-relative paths.\n * The adapter converts between the two.\n *\n * - **Return types**: Fluid returns `string | undefined` (error message or success),\n * repopo returns `true | PolicyFailure | PolicyFixResult`\n *\n * For a single handler, wrap it in an array: `fromFluidHandlers([handler])`.\n *\n * @example\n * ```typescript\n * import { fromFluidHandlers, makePolicy } from \"repopo\";\n * import { copyrightFileHeaderHandlers, fluidCaseHandler } from \"@fluidframework/build-tools\";\n *\n * // Convert multiple handlers with a namespace prefix\n * const FluidCopyrightPolicies = fromFluidHandlers(copyrightFileHeaderHandlers, {\n * namePrefix: \"Fluid:\",\n * });\n *\n * // For a single handler, wrap it in an array\n * const [FluidCasePolicy] = fromFluidHandlers([fluidCaseHandler]);\n *\n * const config: RepopoConfig = {\n * policies: [\n * ...FluidCopyrightPolicies.map(p => makePolicy(p)),\n * makePolicy(FluidCasePolicy),\n * ],\n * };\n * ```\n *\n * @param fluidHandlers - An array of FluidFramework Handler objects to convert.\n * @param options - Optional configuration applied to all conversions.\n * @returns An array of repopo PolicyDefinitions.\n *\n * @alpha\n */\nexport function fromFluidHandlers(\n\tfluidHandlers: FluidHandler[],\n\toptions?: FluidAdapterOptions,\n): PolicyDefinition[] {\n\treturn fluidHandlers.map((h) => fromFluidHandler(h, options));\n}\n"]}
@@ -10,6 +10,7 @@ export declare abstract class BaseRepopoCommand<T extends typeof BaseRepopoComma
10
10
  flags: typeof CommandWithConfig.flags;
11
11
  }> extends CommandWithConfig<T, RepopoConfig> implements CommandWithContext<RepopoCommandContext>, RequiresGit {
12
12
  protected defaultConfig: RepopoConfig;
13
+ protected _logger: import("@tylerbu/cli-api").Logger;
13
14
  static readonly flags: {
14
15
  readonly config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
16
  };