generated-signature 0.1.2 → 0.1.3
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/README.md +12 -4
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -186,7 +186,15 @@ Carries manual sections from an existing file into freshly generated text, match
|
|
|
186
186
|
|
|
187
187
|
### `commentStyle(filePath)`
|
|
188
188
|
|
|
189
|
-
**Returns** the line comment syntax for a file, as `CommentStyle` (`{ start: string, end?: string }`), looked up by extension or file name (`Dockerfile`, `.gitignore`, …). `null` if unknown, or for formats without comments like `.json`.
|
|
189
|
+
**Returns** the line comment syntax for a file, as `CommentStyle` (`{ start: string, end?: string }`), looked up by extension or file name (`Dockerfile`, `.gitignore`, …). `null` if unknown, or for formats without comments like `.json`. For any other file, pass `comment` instead of `filePath`.
|
|
190
|
+
|
|
191
|
+
| `CommentStyle` | Files |
|
|
192
|
+
|----------------|-------|
|
|
193
|
+
| `//` | `.c`, `.cc`, `.cjs`, `.cpp`, `.cs`, `.cts`, `.go`, `.h`, `.hpp`, `.java`, `.js`, `.json5`, `.jsonc`, `.jsx`, `.kt`, `.less`, `.mjs`, `.mts`, `.rs`, `.scss`, `.swift`, `.ts`, `.tsx` |
|
|
194
|
+
| `#` | `.bash`, `.cfg`, `.conf`, `.env`, `.ini`, `.pl`, `.properties`, `.py`, `.r`, `.rb`, `.sh`, `.toml`, `.yaml`, `.yml`, `.zsh`, and `.gitattributes`, `.gitignore`, `.npmignore`, `Dockerfile`, `Makefile` |
|
|
195
|
+
| `/* */` | `.css` |
|
|
196
|
+
| `<!-- -->` | `.htm`, `.html`, `.md`, `.mdx`, `.svg`, `.vue`, `.xml` |
|
|
197
|
+
| `--` | `.hs`, `.lua`, `.sql` |
|
|
190
198
|
|
|
191
199
|
---
|
|
192
200
|
|
|
@@ -211,7 +219,7 @@ A JSON file recording generated files that don't carry their own token, e.g. JSO
|
|
|
211
219
|
| Function | Description |
|
|
212
220
|
|----------|-------------|
|
|
213
221
|
| <a id="contenthashcontent"></a>`contentHash(content: string \| Uint8Array): string` | `v1:` and 32 hex characters of SHA-256. `\r\n` counts as `\n`, also in bytes. Manual sections are **not** excluded, so a file with manual sections should be signed inline. |
|
|
214
|
-
| `verifyManifestEntry(content, entry): VerifyResult` | `valid` or `invalid` for a `hash` entry; [`verify()`](#verifytext)'s result for an `inline` entry. |
|
|
222
|
+
| `verifyManifestEntry(content: string \| Uint8Array, entry): VerifyResult` | `valid` or `invalid` for a `hash` entry; [`verify()`](#verifytext)'s result for an `inline` entry. |
|
|
215
223
|
| `parseManifest(text): Manifest` | Parses and validates. Throws `GeneratedSignatureManifestError` if the text is not a valid manifest. |
|
|
216
224
|
| `serializeManifest(files): string` | Manifest text, with paths and inputs sorted so the output doesn't depend on write order. |
|
|
217
225
|
|
|
@@ -239,11 +247,11 @@ import generatedSignature from 'generated-signature/eslint';
|
|
|
239
247
|
export default [generatedSignature.configs.recommended];
|
|
240
248
|
```
|
|
241
249
|
|
|
242
|
-
`configs.recommended` registers the plugin (namespace `generated-signature`) and turns on every rule below as an error.
|
|
250
|
+
`configs.recommended` registers the plugin (namespace `generated-signature`) and turns on every rule below as an error. `eslint` is an optional peer dependency (`^10.13.0`), needed only for this entry point. To choose rules yourself, register the plugin: `{ plugins: { 'generated-signature': generatedSignature }, rules: { 'generated-signature/valid': 'warn' } }`.
|
|
243
251
|
|
|
244
252
|
### `generated-signature/valid`
|
|
245
253
|
|
|
246
|
-
Reports a file whose signature doesn't match (it was edited outside its manual sections), or whose token or manual sections are malformed. Unsigned files are ignored. There is no autofix: re-signing would just approve the edit. Regenerate the file instead, or move the change into a manual section.
|
|
254
|
+
Reports a file whose signature doesn't match (it was edited outside its manual sections; reported on the token), or whose token or manual sections are malformed (`Generated file is malformed: <reason>`, reported on the line at fault). Unsigned files are ignored. There is no autofix: re-signing would just approve the edit. Regenerate the file instead, or move the change into a manual section.
|
|
247
255
|
|
|
248
256
|
```ts
|
|
249
257
|
// @generated-signature v1:… Generated file. Do not edit outside of manual sections.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generated-signature",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Sign generated files so hand edits are detected, while keeping manual sections editable",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "git+https://github.com/JacobLey/leyman.git",
|
|
14
14
|
"directory": "tools/generated-signature/generated-signature"
|
|
15
15
|
},
|
|
16
|
-
"homepage": "https://github.
|
|
16
|
+
"homepage": "https://jacobley.github.io/leyman/packages/generated-signature/",
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/JacobLey/leyman/issues"
|
|
19
19
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"!dist/tsconfig.tsbuildinfo"
|
|
37
37
|
],
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"eslint": "^10.
|
|
39
|
+
"eslint": "^10.13.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependenciesMeta": {
|
|
42
42
|
"eslint": {
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"@leyman/eslint-config": "^0.0.1",
|
|
49
49
|
"@leyman/expect": "^0.0.1",
|
|
50
50
|
"@swc/cli": "^0.8.1",
|
|
51
|
-
"@swc/core": "^1.16.
|
|
51
|
+
"@swc/core": "^1.16.18",
|
|
52
52
|
"@types/mocha": "^10.0.10",
|
|
53
53
|
"@types/node": "^24.19.0",
|
|
54
54
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
55
55
|
"c8": "^12.0.0",
|
|
56
|
-
"eslint": "^10.
|
|
56
|
+
"eslint": "^10.13.0",
|
|
57
57
|
"expect-type": "^1.4.0",
|
|
58
|
-
"mocha": "^12.0.
|
|
59
|
-
"mocha-chain": "^1.0.
|
|
58
|
+
"mocha": "^12.0.3",
|
|
59
|
+
"mocha-chain": "^1.0.2",
|
|
60
60
|
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
61
61
|
},
|
|
62
62
|
"imports": {
|