@xylabs/readme-gen 5.0.82 → 5.0.84
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
CHANGED
|
@@ -37,6 +37,9 @@ Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
|
37
37
|
function generateReadmeFiles(): Promise<void>;
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
+
Generates README.md files for all workspace packages using a shared template.
|
|
41
|
+
Fills each README with package metadata, an optional body, and auto-generated TypeDoc reference.
|
|
42
|
+
|
|
40
43
|
## Returns
|
|
41
44
|
|
|
42
45
|
`Promise`\<`void`\>
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Generates README.md files for all workspace packages using a shared template.
|
|
4
|
+
* Fills each README with package metadata, an optional body, and auto-generated TypeDoc reference.
|
|
5
|
+
*/
|
|
2
6
|
export declare function generateReadmeFiles(): Promise<void>;
|
|
3
7
|
//# sourceMappingURL=generateReadmeFiles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateReadmeFiles.d.ts","sourceRoot":"","sources":["../../src/generateReadmeFiles.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"generateReadmeFiles.d.ts","sourceRoot":"","sources":["../../src/generateReadmeFiles.ts"],"names":[],"mappings":";AAoDA;;;GAGG;AACH,wBAAsB,mBAAmB,kBAuBxC"}
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/generateReadmeFiles.ts","../../src/generateTypeDoc.ts"],"sourcesContent":["#!/usr/bin/env node\n/* eslint-disable no-console */\n\n// generate-readmes.mjs\nimport { readFile, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport { yarnWorkspaces } from '@xylabs/ts-scripts-yarn3'\n\nimport { generateTypeDoc } from './generateTypeDoc.ts'\n\nconst dirName = () => path.dirname(fileURLToPath(import.meta.url))\nconst templatePath = () => path.join(dirName(), 'README.template.md')\n\nfunction fillTemplate(template: string, data: { [key: string]: string }) {\n const additionalData: { [key: string]: string } = { ...data, safeName: data.name.replaceAll('/', '__').replaceAll('@', '') }\n return template.replaceAll(/{{(.*?)}}/g, (_, key) => additionalData[(key as string).trim()] ?? '')\n}\n\nasync function tryLoadReadmeBody(location: string) {\n try {\n return await readFile(path.join(location, 'README.body.md'), 'utf8')\n } catch {\n return\n }\n}\n\nasync function tryLoadReadmeReference(location: string) {\n try {\n return await readFile(path.join(location, 'README.reference.md'), 'utf8')\n } catch {\n return\n }\n}\n\nexport async function generateReadmeFiles() {\n const template = await readFile(templatePath(), 'utf8')\n const pkgs = yarnWorkspaces()\n\n for (const { location } of pkgs) {\n try {\n if (location.includes('wallet-chrome')) {\n continue\n }\n const pkgJsonPath = path.join(location, 'package.json')\n const pkg = JSON.parse(await readFile(pkgJsonPath, 'utf8'))\n const body = await tryLoadReadmeBody(location) ?? ''\n const reference = await tryLoadReadmeReference(location) ?? await generateTypeDoc(location, ['src/index*.ts'])\n const readmeContent = fillTemplate(template, {\n ...pkg, body, reference,\n })\n await writeFile(path.join(location, 'README.md'), readmeContent)\n console.log(`✅ Created README.md for ${pkg.name}`)\n } catch (ex) {\n const error = ex as Error\n console.warn(`⚠️ Skipped ${location}:`, error.message)\n }\n }\n}\n","/* eslint-disable no-console */\nimport { execSync } from 'node:child_process'\nimport {\n existsSync, mkdirSync, readdirSync,\n readFileSync,\n} from 'node:fs'\nimport { rm, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Generates inline TypeDoc markdown documentation\n * @param {string} packageLocation - The package location path\n * @param {string} sourceGlob - The glob pattern for source files\n * @returns {Promise<string>} A markdown string containing Reference\n */\nexport async function generateTypeDoc(packageLocation: string, entryPoints: string[]) {\n const __dirname = path.dirname(fileURLToPath(import.meta.url))\n const tempDir = path.join(__dirname, '.temp-typedoc')\n\n console.log(`Generating TypeDoc for package at: ${packageLocation}`)\n for (const ep of entryPoints) {\n console.log(` - Entry point: ${path.resolve(packageLocation, ep)}`)\n }\n\n try {\n // Create temp directory if it doesn't exist\n if (!existsSync(tempDir)) {\n mkdirSync(tempDir, { recursive: true })\n }\n\n // Create a minimal TypeDoc config for markdown generation\n const typedocConfig = {\n entryPoints: entryPoints.map(ep => path.resolve(packageLocation, ep)),\n entryPointStrategy: 'expand',\n out: tempDir,\n plugin: ['typedoc-plugin-markdown'],\n readme: 'none',\n theme: 'markdown',\n useCodeBlocks: true,\n hidePageTitle: true,\n githubPages: false,\n hideGenerator: true,\n hideBreadcrumbs: true,\n disableSources: true,\n skipErrorChecking: true,\n excludeExternals: true,\n excludeInternal: true,\n excludePrivate: true,\n sort: ['source-order'],\n }\n\n // Create temporary typedoc.json file\n const typedocJsonPath = path.join(tempDir, 'typedoc.json')\n await writeFile(typedocJsonPath, JSON.stringify(typedocConfig, null, 2))\n\n // Run TypeDoc with the config\n try {\n console.log(`Generating docs for: ${packageLocation}`)\n execSync(`npx typedoc --options ${typedocJsonPath}`, {\n cwd: process.cwd(),\n stdio: ['ignore', 'pipe', 'pipe'],\n })\n } catch (ex) {\n const error = ex as Error\n console.error(`TypeDoc error: ${error.message}`)\n return '## Reference\\n\\nReference generation failed.'\n }\n\n // Combine all markdown files into a single document\n return consolidateMarkdown(tempDir)\n } catch (ex) {\n const error = ex as Error\n console.warn(`⚠️ Error generating TypeDoc for ${packageLocation}:`, error.message)\n return '## Reference\\n\\nReference generation failed.'\n } finally {\n // Clean up the temp directory\n try {\n await rm(tempDir, { recursive: true, force: true })\n } catch (ex) {\n const error = ex as Error\n console.warn('⚠️ Failed to clean up temp directory:', error.message)\n }\n }\n}\n\n/**\n * Consolidates all markdown files in the TypeDoc output directory into a single markdown string\n * @param {string} tempDir - The temporary directory containing TypeDoc output\n * @returns {string} - Consolidated markdown content\n */\nfunction consolidateMarkdown(tempDir: string) {\n // Start with the main README content\n let consolidated = '## Reference\\n\\n'\n\n // Read main README.md first (if it exists)\n const mainReadmePath = path.join(tempDir, 'README.md')\n if (existsSync(mainReadmePath)) {\n const mainContent = readFileSync(mainReadmePath, 'utf8')\n .replace(/^---(.|\\n)*?---\\n/, '') // Remove front matter\n .replace(/^# .+\\n/, '') // Remove top-level header\n .replaceAll(/\\]\\((.+?)\\.md\\)/g, '](#$1)') // Fix internal links to use anchors\n\n consolidated += mainContent + '\\n\\n'\n }\n\n // Function to process a directory recursively\n function processDirectory(dir: string, level = 0): string {\n const indent = ' '.repeat(level)\n let content = ''\n\n try {\n const items = readdirSync(dir, { withFileTypes: true })\n\n // Process files first\n for (const item of items) {\n const itemPath = path.join(dir, item.name)\n\n // Skip directories for now (process them later)\n if (item.isDirectory()) continue\n\n // Skip README.md (already processed) and files that aren't markdown\n if (item.name === 'README.md' || !item.name.endsWith('.md')) continue\n\n // Read file content\n const fileContent = readFileSync(itemPath, 'utf8')\n .replace(/^---(.|\\n)*?---\\n/, '') // Remove front matter\n\n // Get the module name from filename (without extension)\n const moduleName = item.name.replace('.md', '')\n\n // Create a header with anchor\n content += `\\n\\n${indent}### <a id=\"${moduleName}\"></a>${moduleName}\\n\\n`\n\n // Add file content with fixed links\n content += fileContent\n .replace(/^# .+\\n/, '') // Remove top-level header\n .replaceAll(/\\]\\((.+?)\\.md\\)/g, '](#$1)') // Fix internal links to use anchors\n }\n\n // Process subdirectories\n for (const item of items) {\n if (item.isDirectory()) {\n const subDirPath = path.join(dir, item.name)\n // Skip spec directories\n if (item.name === 'spec' || item.name.includes('.spec')) continue\n\n // Create a header for the directory\n content += `\\n\\n${indent}### ${item.name}\\n`\n\n // Process the subdirectory\n content += processDirectory(subDirPath, level + 1)\n }\n }\n } catch (ex) {\n const error = ex as Error\n console.warn(`⚠️ Error processing directory ${dir}:`, error.message)\n }\n\n return content\n }\n\n // Process all files in the tempDir\n consolidated += processDirectory(tempDir)\n\n // Clean up the markdown (fix duplicate headers, etc.)\n consolidated = consolidated\n .replaceAll(/\\n\\n\\n+/g, '\\n\\n') // Remove excess newlines\n .replaceAll(/^#### /gm, '### ') // Adjust heading levels\n .replaceAll(/^##### /gm, '#### ') // Adjust heading levels\n .replaceAll(/^###### /gm, '##### ') // Adjust heading levels\n\n return consolidated\n}\n"],"mappings":";AAIA,SAAS,UAAU,aAAAA,kBAAiB;AACpC,OAAOC,WAAU;AACjB,SAAS,iBAAAC,sBAAqB;AAE9B,SAAS,sBAAsB;;;ACP/B,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EAAY;AAAA,EAAW;AAAA,EACvB;AAAA,OACK;AACP,SAAS,IAAI,iBAAiB;AAC9B,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAQ9B,eAAsB,gBAAgB,iBAAyB,aAAuB;AACpF,QAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC7D,QAAM,UAAU,KAAK,KAAK,WAAW,eAAe;AAEpD,UAAQ,IAAI,sCAAsC,eAAe,EAAE;AACnE,aAAW,MAAM,aAAa;AAC5B,YAAQ,IAAI,oBAAoB,KAAK,QAAQ,iBAAiB,EAAE,CAAC,EAAE;AAAA,EACrE;AAEA,MAAI;AAEF,QAAI,CAAC,WAAW,OAAO,GAAG;AACxB,gBAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,IACxC;AAGA,UAAM,gBAAgB;AAAA,MACpB,aAAa,YAAY,IAAI,QAAM,KAAK,QAAQ,iBAAiB,EAAE,CAAC;AAAA,MACpE,oBAAoB;AAAA,MACpB,KAAK;AAAA,MACL,QAAQ,CAAC,yBAAyB;AAAA,MAClC,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,eAAe;AAAA,MACf,eAAe;AAAA,MACf,aAAa;AAAA,MACb,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,iBAAiB;A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":3,"sources":["../../src/generateReadmeFiles.ts","../../src/generateTypeDoc.ts"],"sourcesContent":["#!/usr/bin/env node\n/* eslint-disable no-console */\n\n// generate-readmes.mjs\nimport { readFile, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport { yarnWorkspaces } from '@xylabs/ts-scripts-yarn3'\n\nimport { generateTypeDoc } from './generateTypeDoc.ts'\n\nconst dirName = () => path.dirname(fileURLToPath(import.meta.url))\nconst templatePath = () => path.join(dirName(), 'README.template.md')\n\n/**\n * Replaces `{{key}}` placeholders in a template string with values from the data object.\n * @param template - The template string containing `{{key}}` placeholders\n * @param data - A key-value map of replacement values\n * @returns The template with all placeholders replaced\n */\nfunction fillTemplate(template: string, data: { [key: string]: string }) {\n const additionalData: { [key: string]: string } = { ...data, safeName: data.name.replaceAll('/', '__').replaceAll('@', '') }\n return template.replaceAll(/{{(.*?)}}/g, (_, key) => additionalData[(key as string).trim()] ?? '')\n}\n\n/**\n * Attempts to load a `README.body.md` file from the given package location.\n * @param location - The package directory path\n * @returns The file contents, or undefined if the file does not exist\n */\nasync function tryLoadReadmeBody(location: string) {\n try {\n return await readFile(path.join(location, 'README.body.md'), 'utf8')\n } catch {\n return\n }\n}\n\n/**\n * Attempts to load a `README.reference.md` file from the given package location.\n * @param location - The package directory path\n * @returns The file contents, or undefined if the file does not exist\n */\nasync function tryLoadReadmeReference(location: string) {\n try {\n return await readFile(path.join(location, 'README.reference.md'), 'utf8')\n } catch {\n return\n }\n}\n\n/**\n * Generates README.md files for all workspace packages using a shared template.\n * Fills each README with package metadata, an optional body, and auto-generated TypeDoc reference.\n */\nexport async function generateReadmeFiles() {\n const template = await readFile(templatePath(), 'utf8')\n const pkgs = yarnWorkspaces()\n\n for (const { location } of pkgs) {\n try {\n if (location.includes('wallet-chrome')) {\n continue\n }\n const pkgJsonPath = path.join(location, 'package.json')\n const pkg = JSON.parse(await readFile(pkgJsonPath, 'utf8'))\n const body = await tryLoadReadmeBody(location) ?? ''\n const reference = await tryLoadReadmeReference(location) ?? await generateTypeDoc(location, ['src/index*.ts'])\n const readmeContent = fillTemplate(template, {\n ...pkg, body, reference,\n })\n await writeFile(path.join(location, 'README.md'), readmeContent)\n console.log(`✅ Created README.md for ${pkg.name}`)\n } catch (ex) {\n const error = ex as Error\n console.warn(`⚠️ Skipped ${location}:`, error.message)\n }\n }\n}\n","/* eslint-disable no-console */\nimport { execSync } from 'node:child_process'\nimport {\n existsSync, mkdirSync, readdirSync,\n readFileSync,\n} from 'node:fs'\nimport { rm, writeFile } from 'node:fs/promises'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\n/**\n * Generates inline TypeDoc markdown documentation\n * @param {string} packageLocation - The package location path\n * @param {string} sourceGlob - The glob pattern for source files\n * @returns {Promise<string>} A markdown string containing Reference\n */\nexport async function generateTypeDoc(packageLocation: string, entryPoints: string[]) {\n const __dirname = path.dirname(fileURLToPath(import.meta.url))\n const tempDir = path.join(__dirname, '.temp-typedoc')\n\n console.log(`Generating TypeDoc for package at: ${packageLocation}`)\n for (const ep of entryPoints) {\n console.log(` - Entry point: ${path.resolve(packageLocation, ep)}`)\n }\n\n try {\n // Create temp directory if it doesn't exist\n if (!existsSync(tempDir)) {\n mkdirSync(tempDir, { recursive: true })\n }\n\n // Create a minimal TypeDoc config for markdown generation\n const typedocConfig = {\n entryPoints: entryPoints.map(ep => path.resolve(packageLocation, ep)),\n entryPointStrategy: 'expand',\n out: tempDir,\n plugin: ['typedoc-plugin-markdown'],\n readme: 'none',\n theme: 'markdown',\n useCodeBlocks: true,\n hidePageTitle: true,\n githubPages: false,\n hideGenerator: true,\n hideBreadcrumbs: true,\n disableSources: true,\n skipErrorChecking: true,\n excludeExternals: true,\n excludeInternal: true,\n excludePrivate: true,\n sort: ['source-order'],\n }\n\n // Create temporary typedoc.json file\n const typedocJsonPath = path.join(tempDir, 'typedoc.json')\n await writeFile(typedocJsonPath, JSON.stringify(typedocConfig, null, 2))\n\n // Run TypeDoc with the config\n try {\n console.log(`Generating docs for: ${packageLocation}`)\n execSync(`npx typedoc --options ${typedocJsonPath}`, {\n cwd: process.cwd(),\n stdio: ['ignore', 'pipe', 'pipe'],\n })\n } catch (ex) {\n const error = ex as Error\n console.error(`TypeDoc error: ${error.message}`)\n return '## Reference\\n\\nReference generation failed.'\n }\n\n // Combine all markdown files into a single document\n return consolidateMarkdown(tempDir)\n } catch (ex) {\n const error = ex as Error\n console.warn(`⚠️ Error generating TypeDoc for ${packageLocation}:`, error.message)\n return '## Reference\\n\\nReference generation failed.'\n } finally {\n // Clean up the temp directory\n try {\n await rm(tempDir, { recursive: true, force: true })\n } catch (ex) {\n const error = ex as Error\n console.warn('⚠️ Failed to clean up temp directory:', error.message)\n }\n }\n}\n\n/**\n * Consolidates all markdown files in the TypeDoc output directory into a single markdown string\n * @param {string} tempDir - The temporary directory containing TypeDoc output\n * @returns {string} - Consolidated markdown content\n */\nfunction consolidateMarkdown(tempDir: string) {\n // Start with the main README content\n let consolidated = '## Reference\\n\\n'\n\n // Read main README.md first (if it exists)\n const mainReadmePath = path.join(tempDir, 'README.md')\n if (existsSync(mainReadmePath)) {\n const mainContent = readFileSync(mainReadmePath, 'utf8')\n .replace(/^---(.|\\n)*?---\\n/, '') // Remove front matter\n .replace(/^# .+\\n/, '') // Remove top-level header\n .replaceAll(/\\]\\((.+?)\\.md\\)/g, '](#$1)') // Fix internal links to use anchors\n\n consolidated += mainContent + '\\n\\n'\n }\n\n // Function to process a directory recursively\n function processDirectory(dir: string, level = 0): string {\n const indent = ' '.repeat(level)\n let content = ''\n\n try {\n const items = readdirSync(dir, { withFileTypes: true })\n\n // Process files first\n for (const item of items) {\n const itemPath = path.join(dir, item.name)\n\n // Skip directories for now (process them later)\n if (item.isDirectory()) continue\n\n // Skip README.md (already processed) and files that aren't markdown\n if (item.name === 'README.md' || !item.name.endsWith('.md')) continue\n\n // Read file content\n const fileContent = readFileSync(itemPath, 'utf8')\n .replace(/^---(.|\\n)*?---\\n/, '') // Remove front matter\n\n // Get the module name from filename (without extension)\n const moduleName = item.name.replace('.md', '')\n\n // Create a header with anchor\n content += `\\n\\n${indent}### <a id=\"${moduleName}\"></a>${moduleName}\\n\\n`\n\n // Add file content with fixed links\n content += fileContent\n .replace(/^# .+\\n/, '') // Remove top-level header\n .replaceAll(/\\]\\((.+?)\\.md\\)/g, '](#$1)') // Fix internal links to use anchors\n }\n\n // Process subdirectories\n for (const item of items) {\n if (item.isDirectory()) {\n const subDirPath = path.join(dir, item.name)\n // Skip spec directories\n if (item.name === 'spec' || item.name.includes('.spec')) continue\n\n // Create a header for the directory\n content += `\\n\\n${indent}### ${item.name}\\n`\n\n // Process the subdirectory\n content += processDirectory(subDirPath, level + 1)\n }\n }\n } catch (ex) {\n const error = ex as Error\n console.warn(`⚠️ Error processing directory ${dir}:`, error.message)\n }\n\n return content\n }\n\n // Process all files in the tempDir\n consolidated += processDirectory(tempDir)\n\n // Clean up the markdown (fix duplicate headers, etc.)\n consolidated = consolidated\n .replaceAll(/\\n\\n\\n+/g, '\\n\\n') // Remove excess newlines\n .replaceAll(/^#### /gm, '### ') // Adjust heading levels\n .replaceAll(/^##### /gm, '#### ') // Adjust heading levels\n .replaceAll(/^###### /gm, '##### ') // Adjust heading levels\n\n return consolidated\n}\n"],"mappings":";AAIA,SAAS,UAAU,aAAAA,kBAAiB;AACpC,OAAOC,WAAU;AACjB,SAAS,iBAAAC,sBAAqB;AAE9B,SAAS,sBAAsB;;;ACP/B,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EAAY;AAAA,EAAW;AAAA,EACvB;AAAA,OACK;AACP,SAAS,IAAI,iBAAiB;AAC9B,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAQ9B,eAAsB,gBAAgB,iBAAyB,aAAuB;AACpF,QAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC7D,QAAM,UAAU,KAAK,KAAK,WAAW,eAAe;AAEpD,UAAQ,IAAI,sCAA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AAK,KAAK,UAAU,cAAc;AACtD,YAAM,MAAM,KAAK,MAAM,MAAM,SAAS,aAAa,MAAM,CAAC;AAC1D,YAAM,OAAO,MAAM,kBAAkB,QAAQ,KAAK;AAClD,YAAM,YAAY,MAAM,uBAAuB,QAAQ,KAAK,MAAM,gBAAgB,UAAU,CAAC,eAAe,CAAC;AAC7G,YAAM,gBAAgB,aAAa,UAAU;AAAA,QAC3C,GAAG;AAAA,QAAK;AAAA,QAAM;AAAA,MAChB,CAAC;AACD,YAAME,WAAUF,MAAK,KAAK,UAAU,WAAW,GAAG,aAAa;AAC/D,cAAQ,IAAI,gCAA2B,IAAI,IAAI,EAAE;AAAA,IACnD,SAAS,IAAI;AACX,YAAM,QAAQ;AACd,cAAQ,KAAK,wBAAc,QAAQ,KAAK,MAAM,OAAO;AAAA,IACvD;AAAA,EACF;AACF;","names":["writeFile","path","fileURLToPath","path","fileURLToPath","writeFile"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/readme-gen",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.84",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"readme",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"!**/*.test.*"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@xylabs/ts-scripts-yarn3": "~7.4.
|
|
47
|
+
"@xylabs/ts-scripts-yarn3": "~7.4.13"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@xylabs/tsconfig": "~7.4.
|
|
50
|
+
"@xylabs/tsconfig": "~7.4.13",
|
|
51
51
|
"typescript": "~5.9.3",
|
|
52
52
|
"vitest": "^4.0.18"
|
|
53
53
|
},
|