@bobfrankston/extractids 1.0.5 → 1.0.6
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/.claude/settings.local.json +11 -0
- package/CLAUDE.md +60 -0
- package/index.js +2 -1
- package/index.js.map +1 -1
- package/index.ts +3 -2
- package/package.json +4 -3
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
`extractids` is a TypeScript CLI utility that extracts HTML IDs and CSS class names to generate TypeScript type definitions. The tool scans `index.html` and all `.css` files in a project to create a `generated-types.ts` file with type-safe DOM and styling operations.
|
|
7
|
+
|
|
8
|
+
## Architecture
|
|
9
|
+
- **Single-file architecture**: Main functionality in `index.ts`
|
|
10
|
+
- **Entry point**: `index.js` (compiled from `index.ts`) serves as both CLI binary and main module
|
|
11
|
+
- **Type generation**: Produces `generated-types.ts` with `htmlIDs` and `cssClasses` union types
|
|
12
|
+
- **File scanning**: Uses cheerio for HTML parsing and regex for CSS class extraction
|
|
13
|
+
- **Watch mode**: Uses chokidar for file system watching
|
|
14
|
+
|
|
15
|
+
## Development Commands
|
|
16
|
+
|
|
17
|
+
### Build
|
|
18
|
+
```bash
|
|
19
|
+
tsc
|
|
20
|
+
```
|
|
21
|
+
Compiles TypeScript to JavaScript using the tsconfig.json configuration.
|
|
22
|
+
|
|
23
|
+
### Run locally
|
|
24
|
+
```bash
|
|
25
|
+
node index.js
|
|
26
|
+
# or with watch mode
|
|
27
|
+
node index.js -w
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Test the CLI
|
|
31
|
+
```bash
|
|
32
|
+
# Install globally for testing
|
|
33
|
+
npm install -g .
|
|
34
|
+
extractids
|
|
35
|
+
extractids -w
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Key Components
|
|
39
|
+
|
|
40
|
+
### Core Functions
|
|
41
|
+
- `getHtmlIDs(html)`: Parses HTML with cheerio to extract ID attributes
|
|
42
|
+
- `getCssClasses(css)`: Uses regex `/\.([a-zA-Z0-9_-]+)\s*[{,]/g` to extract CSS class names
|
|
43
|
+
- `globReadCssFiles()`: Recursively finds all `.css` files while ignoring `node_modules`
|
|
44
|
+
- `generateTypes()`: Creates TypeScript union types from extracted IDs and classes
|
|
45
|
+
- `updateTypesFile()`: Main orchestration function that combines all operations
|
|
46
|
+
|
|
47
|
+
### File Dependencies
|
|
48
|
+
- Expects `index.html` in the current working directory
|
|
49
|
+
- Scans all `.css` files recursively from current directory
|
|
50
|
+
- Outputs `generated-types.ts` in current directory
|
|
51
|
+
|
|
52
|
+
### CLI Options
|
|
53
|
+
- `-w` or `--watch`: Enables file system watching for automatic regeneration
|
|
54
|
+
- No arguments: Single-run mode that generates types once
|
|
55
|
+
|
|
56
|
+
## TypeScript Configuration
|
|
57
|
+
- Target: ESNext with NodeNext module resolution
|
|
58
|
+
- Source maps enabled for debugging
|
|
59
|
+
- Strict type checking with some relaxed settings (`strictNullChecks: false`)
|
|
60
|
+
- Includes all `.ts` files, excludes `node_modules`
|
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
// scripts/generateTypes.ts
|
|
2
3
|
import * as fs from 'node:fs';
|
|
3
4
|
import * as path from 'node:path';
|
|
@@ -80,7 +81,7 @@ if (watchMode) {
|
|
|
80
81
|
console.log('[extractids] Watcher is ready and running.');
|
|
81
82
|
});
|
|
82
83
|
watcher.on('error', (error) => {
|
|
83
|
-
console.error('[extractids] Watcher error:', error);
|
|
84
|
+
console.error('[extractids] Watcher error:', error.message);
|
|
84
85
|
});
|
|
85
86
|
// No need for setInterval; watcher should keep process alive
|
|
86
87
|
}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","s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,CAAC;IACxF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAS,EAAE,EAAE;QAC9B,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IACH,6DAA6D;AACjE,CAAC;KAAM,CAAC;IACJ,eAAe,EAAE,CAAC;AACtB,CAAC"}
|
package/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
// scripts/generateTypes.ts
|
|
2
3
|
import * as fs from 'node:fs';
|
|
3
4
|
import * as path from 'node:path';
|
|
@@ -89,8 +90,8 @@ if (watchMode) {
|
|
|
89
90
|
watcher.on('ready', () => {
|
|
90
91
|
console.log('[extractids] Watcher is ready and running.');
|
|
91
92
|
});
|
|
92
|
-
watcher.on('error', (error) => {
|
|
93
|
-
console.error('[extractids] Watcher error:', error);
|
|
93
|
+
watcher.on('error', (error:any) => {
|
|
94
|
+
console.error('[extractids] Watcher error:', error.message);
|
|
94
95
|
});
|
|
95
96
|
// No need for setInterval; watcher should keep process alive
|
|
96
97
|
} else {
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/extractids",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "Extracd html and css as types",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"extractids": "./index.js"
|
|
8
8
|
},
|
|
9
|
+
"module": "main.js",
|
|
9
10
|
"scripts": {
|
|
10
11
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
12
|
},
|
|
12
13
|
"keywords": [],
|
|
13
|
-
"author": "",
|
|
14
|
+
"author": "Bob Frankston",
|
|
14
15
|
"license": "ISC",
|
|
15
16
|
"type": "module",
|
|
16
17
|
"dependencies": {
|