Skip to content

Commit

Permalink
fix(tools): adapt to glob now being promised instead of callback
Browse files Browse the repository at this point in the history
  • Loading branch information
GerkinDev committed Apr 8, 2023
1 parent 8725955 commit 1c48303
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yaml
Expand Up @@ -8,7 +8,7 @@ body:
attributes:
label: Plugin
description: What plugin are you encountering a problem with ?
options: ["@knodes/typedoc-plugin-code-blocks", "@knodes/typedoc-plugin-pages", "@knodes/typedoc-pluginutils", Unspecified] # !FORMAT options: [${...plugins}, Unspecified]
options: ["@knodes/typedoc-pluginutils", "@knodes/typedoc-plugin-pages", "@knodes/typedoc-plugin-code-blocks", Unspecified] # !FORMAT options: [${...plugins}, Unspecified]
validations:
required: true
- type: input
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-request.yaml
Expand Up @@ -8,7 +8,7 @@ body:
attributes:
label: Plugin
description: What plugin is concerned ?
options: ["@knodes/typedoc-plugin-code-blocks", "@knodes/typedoc-plugin-pages", "@knodes/typedoc-pluginutils", Unspecified] # !FORMAT options: [${...plugins}, Unspecified]
options: ["@knodes/typedoc-pluginutils", "@knodes/typedoc-plugin-pages", "@knodes/typedoc-plugin-code-blocks", Unspecified] # !FORMAT options: [${...plugins}, Unspecified]
validations:
required: true
- type: textarea
Expand Down
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -64,10 +64,10 @@
"@commitlint/cli": "^17.0.2",
"@commitlint/config-conventional": "^17.0.2",
"@knodes/eslint-config": "^1.6.5",
"@knodes/typedoc-plugin-code-blocks": "file:./packages/plugin-code-blocks",
"@knodes/typedoc-plugin-pages": "file:./packages/plugin-pages",
"@knodes/typedoc-plugintestbed": "file:./packages/plugintestbed",
"@knodes/typedoc-pluginutils": "file:./packages/pluginutils",
"@knodes/typedoc-plugin-code-blocks": "file:packages/plugin-code-blocks",
"@knodes/typedoc-plugin-pages": "file:packages/plugin-pages",
"@knodes/typedoc-plugintestbed": "file:packages/plugintestbed",
"@knodes/typedoc-pluginutils": "file:packages/pluginutils",
"@testing-library/jest-dom": "^5.16.4",
"@types/concurrently": "^7.0.0",
"@types/diff": "^5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/pluginutils/package.json
Expand Up @@ -24,7 +24,6 @@
"utils"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"default": "./dist/index.js",
Expand All @@ -46,6 +45,7 @@
"prepublishOnly": "npm run build:clean && npm run build",
"test": "jest --config jest.config.js"
},
"types": "dist/index.d.ts",
"dependencies": {
"lodash": "^4.17.21",
"fastest-levenshtein": "^1.0.16",
Expand Down
5 changes: 3 additions & 2 deletions tools/sync-proto-modules/issue-template.js
@@ -1,9 +1,10 @@
const { readFile } = require( 'fs/promises' );

const { glob } = require( 'glob' );
const { minVersion } = require( 'semver' );

const { syncFile, postProcessYaml } = require( './utils' );
const { resolveRoot, globAsync } = require( '../utils' );
const { resolveRoot } = require( '../utils' );
const DIR = resolveRoot( './.github/ISSUE_TEMPLATE' );

/**
Expand All @@ -12,7 +13,7 @@ const DIR = resolveRoot( './.github/ISSUE_TEMPLATE' );
*/
module.exports.issueTemplate = async checkOnly => ( {
tearDown: async ( _, projects ) => {
await Promise.all( ( await globAsync( '*.yaml', { cwd: DIR } ) ).map( async f => {
await Promise.all( ( await glob( '*.yaml', { cwd: DIR } ) ).map( async f => {
const path = resolveRoot( DIR, f );
const yaml = await readFile( path, 'utf-8' );
const yamlFormatted = postProcessYaml( yaml, {
Expand Down
4 changes: 2 additions & 2 deletions tools/sync-proto-modules/readme.js
@@ -1,7 +1,7 @@
const { yellow } = require( 'chalk' );
const { glob } = require( 'glob' );

const { tryReadFile, getDocsUrl, readProjectPackageJson, syncFile } = require( './utils' );
const { globAsync } = require( '../utils' );

class Readme {
constructor( checkOnly ){
Expand All @@ -10,7 +10,7 @@ class Readme {
}

async run( _proto, { path: projectPath } ){
const readmeFiles = await globAsync( `${projectPath}/@(readme|README).@(md|MD)` );
const readmeFiles = await glob( `${projectPath}/@(readme|README).@(md|MD)` );
if( readmeFiles.length > 1 ){
throw new Error( 'Multiple README files' );
}
Expand Down
4 changes: 2 additions & 2 deletions tools/sync-proto-modules/sync-fs.js
Expand Up @@ -5,10 +5,10 @@ const { readFile, mkdir, access, copyFile, unlink, writeFile } = require( 'fs/pr
const { resolve, join } = require( 'path' );

const { bold } = require( 'chalk' );
const { glob } = require( 'glob' );
const { memoize, partition, isString } = require( 'lodash' );

const { tryReadFile } = require( './utils' );
const { globAsync } = require( '../utils' );

const checksum = async file => createHash( 'md5' )
.update( ( await readFile( file, 'utf-8' ) ).replace( /\r?\n/g, '\n' ), 'utf-8' )
Expand Down Expand Up @@ -37,7 +37,7 @@ const readCache = memoize( async () => {
} );

const protoFs = memoize( async ( proto, handlers ) => {
const filesDirs = ( await globAsync( '**', { cwd: proto, ignore: [ '**/node_modules/**' ], mark: true, dot: true } ) )
const filesDirs = ( await glob( '**', { cwd: proto, ignore: [ '**/node_modules/**' ], mark: true, dot: true } ) )
.filter( fd => !( handlers.some( h => h.handleFile?.( fd ) ?? false ) ) );
const [ dirs, files ] = partition( filesDirs, p => p.endsWith( '/' ) );
return { dirs, files };
Expand Down
7 changes: 4 additions & 3 deletions tools/typedoc-patcher.js
Expand Up @@ -4,9 +4,10 @@ const { readFile, access, open } = require( 'fs/promises' );
const { resolve, dirname, relative } = require( 'path' );

const { red, bold, green } = require( 'chalk' );
const { glob } = require( 'glob' );
const { memoize } = require( 'lodash' );

const { spawn, globAsync, createStash, commonPath, selectProjects, captureStream, getStagedFiles } = require( './utils' );
const { spawn, createStash, commonPath, selectProjects, captureStream, getStagedFiles } = require( './utils' );

const getPatchName = f => `${f}.patch`;
const assertWritable = memoize( async filePath => {
Expand Down Expand Up @@ -87,7 +88,7 @@ const generatePattern = () => {
if( stash ){
await createStash( 'typedoc-patcher: diff' );
}
const generatedFiles = await globAsync( pattern, { ignore: [ '**/dist/**', '**/node_modules/**', getPatchName( generatedPattern ) ] } );
const generatedFiles = await glob( pattern, { ignore: [ '**/dist/**', '**/node_modules/**', getPatchName( generatedPattern ) ] } );
if( generatedFiles.length === 0 ) {
console.log( 'No patches generated.' );
return;
Expand Down Expand Up @@ -121,7 +122,7 @@ const generatePattern = () => {
if( stash ){
await createStash( 'typedoc-patcher: apply' );
}
const patchFiles = await globAsync( getPatchName( pattern ), { ignore: [ '**/dist/**', '**/node_modules/**' ] } );
const patchFiles = await glob( getPatchName( pattern ), { ignore: [ '**/dist/**', '**/node_modules/**' ] } );
if( patchFiles.length === 0 ) {
console.log( 'No patches applied.' );
return;
Expand Down
3 changes: 0 additions & 3 deletions tools/utils.js
Expand Up @@ -7,9 +7,6 @@ const glob = require( 'glob' );
const { once, isArray, omitBy, isNil } = require( 'lodash' );
const { normalizePath } = require( 'typedoc' );

const globAsync = promisify( glob );
module.exports.globAsync = globAsync;

const exec = promisify( _exec );
module.exports.exec = exec;

Expand Down

0 comments on commit 1c48303

Please sign in to comment.