@bobfrankston/extractids 1.0.16 → 1.0.18

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.
@@ -7,7 +7,9 @@
7
7
  "Bash(tsc:*)",
8
8
  "Bash(node:*)",
9
9
  "Bash(extractids:*)",
10
- "Bash(npmglobalize)"
10
+ "Bash(npmglobalize)",
11
+ "Bash(npm install:*)",
12
+ "Bash(npx tsc:*)"
11
13
  ],
12
14
  "deny": [],
13
15
  "ask": []
package/index.js CHANGED
@@ -61,7 +61,8 @@ function generateTypes(ids, classes) {
61
61
  : `export type cssClasses = never;\n`;
62
62
  return `${idType}\n\n${queryType}\n\n${classType}`;
63
63
  }
64
- function updateTypesFile(specifiedHtmlFile) {
64
+ const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
65
+ async function updateTypesFile(specifiedHtmlFile) {
65
66
  let htmlFile;
66
67
  if (specifiedHtmlFile) {
67
68
  // Use the specified file if provided
@@ -82,10 +83,21 @@ function updateTypesFile(specifiedHtmlFile) {
82
83
  return;
83
84
  }
84
85
  }
85
- const html = fs.readFileSync(htmlFile, 'utf8');
86
+ let html = fs.readFileSync(htmlFile, 'utf8');
86
87
  if (!html || html.length < 10) {
87
- console.error(`[extractids ${timestamp()}] WARNING: ${htmlFile} read returned ${html.length} bytes possible transient read failure, skipping update`);
88
- return;
88
+ // Retry up to 3 times with 500ms delay for transient read failures
89
+ for (let attempt = 1; attempt <= 3; attempt++) {
90
+ console.warn(`[extractids ${timestamp()}] WARNING: ${htmlFile} read returned ${html.length} bytes — retry ${attempt}/3 in 500ms`);
91
+ await sleep(500);
92
+ html = fs.readFileSync(htmlFile, 'utf8');
93
+ if (html && html.length >= 10)
94
+ break;
95
+ }
96
+ if (!html || html.length < 10) {
97
+ console.error(`[extractids ${timestamp()}] ERROR: ${htmlFile} still ${html.length} bytes after 3 retries — skipping update`);
98
+ return;
99
+ }
100
+ console.log(`[extractids ${timestamp()}] Retry succeeded — ${htmlFile} now ${html.length} bytes`);
89
101
  }
90
102
  const ids = getHtmlIDs(html);
91
103
  if (ids.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/extractids",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Extracd html and css as types",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -9,7 +9,8 @@
9
9
  "module": "main.js",
10
10
  "scripts": {
11
11
  "test": "echo \"Error: no test specified\" && exit 1",
12
- "release": "npmglobalize"
12
+ "release": "npmglobalize",
13
+ "build": "tsc"
13
14
  },
14
15
  "keywords": [],
15
16
  "author": "Bob Frankston",