From 8501d5fd5289e46adb63978bf867bde8dbed5b96 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Sat, 10 Jun 2023 07:34:42 +0000 Subject: [PATCH 01/11] chore(release): 39.0.10 [skip ci] ## [39.0.10](https://github.com/ipfs/aegir/compare/v39.0.9...v39.0.10) (2023-06-10) ### Trivial Changes * fix linting ([#1305](https://github.com/ipfs/aegir/issues/1305)) ([17c0331](https://github.com/ipfs/aegir/commit/17c0331c9ebed841ccb00cb3ffb442f0e0c87549)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41d699b48..25123baa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [39.0.10](https://github.com/ipfs/aegir/compare/v39.0.9...v39.0.10) (2023-06-10) + + +### Trivial Changes + +* fix linting ([#1305](https://github.com/ipfs/aegir/issues/1305)) ([17c0331](https://github.com/ipfs/aegir/commit/17c0331c9ebed841ccb00cb3ffb442f0e0c87549)) + ## [39.0.9](https://github.com/ipfs/aegir/compare/v39.0.8...v39.0.9) (2023-05-26) diff --git a/package.json b/package.json index 48a2ef017..192fb6d65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aegir", - "version": "39.0.9", + "version": "39.0.10", "description": "JavaScript project management", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/aegir#readme", From 369453f7543488d43e72721c48320d6d8d59b705 Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 14 Jun 2023 11:14:41 +0000 Subject: [PATCH 02/11] chore: Update .github/workflows/stale.yml [skip ci] --- .github/workflows/stale.yml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 6f6d895d1..668bd07d4 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -6,21 +6,4 @@ on: jobs: stale: - - runs-on: ubuntu-latest - permissions: - issues: write - pull-requests: write - - steps: - - uses: actions/stale@v3 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.' - close-issue-message: 'This issue was closed because it is missing author input.' - stale-issue-label: 'kind/stale' - any-of-labels: 'need/author-input' - exempt-issue-labels: 'need/triage,need/community-input,need/maintainer-input,need/maintainers-input,need/analysis,status/blocked,status/in-progress,status/ready,status/deferred,status/inactive' - days-before-issue-stale: 6 - days-before-issue-close: 7 - enable-statistics: true + uses: pl-strflt/.github/.github/workflows/reusable-stale-issue.yml@v0.3 From a95aec346270472fe635e508476a1eb844e80cfe Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Tue, 27 Jun 2023 20:04:49 +0200 Subject: [PATCH 03/11] fix: handle invalid workspace entries (#1316) Test that workspace entries are directories and have package.json files before processing them. --- src/check-project/index.js | 14 +++++++++++++- src/utils.js | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/check-project/index.js b/src/check-project/index.js index b62f7efd5..5db27cc5b 100755 --- a/src/check-project/index.js +++ b/src/check-project/index.js @@ -113,7 +113,19 @@ async function processMonorepo (projectDir, manifest, branchName, repoUrl) { cwd: projectDir, absolute: true })) { - const pkg = fs.readJSONSync(path.join(subProjectDir, 'package.json')) + const stat = await fs.stat(subProjectDir) + + if (!stat.isDirectory()) { + continue + } + + const manfest = path.join(subProjectDir, 'package.json') + + if (!fs.existsSync(manfest)) { + continue + } + + const pkg = fs.readJSONSync(manfest) const homePage = `${repoUrl}/tree/master${subProjectDir.substring(projectDir.length)}` console.info('Found monorepo project', pkg.name) diff --git a/src/utils.js b/src/utils.js index b3508ec07..de37374cf 100644 --- a/src/utils.js +++ b/src/utils.js @@ -371,7 +371,19 @@ async function parseProjects (projectDir, workspaces) { cwd: projectDir, absolute: true })) { - const pkg = fs.readJSONSync(path.join(subProjectDir, 'package.json')) + const stat = await fs.stat(subProjectDir) + + if (!stat.isDirectory()) { + continue + } + + const manfest = path.join(subProjectDir, 'package.json') + + if (!fs.existsSync(manfest)) { + continue + } + + const pkg = fs.readJSONSync(manfest) projects[pkg.name] = { manifest: pkg, From a99488806dae1bc64e6710219812884c26d226cc Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 27 Jun 2023 18:15:06 +0000 Subject: [PATCH 04/11] chore(release): 39.0.11 [skip ci] ## [39.0.11](https://github.com/ipfs/aegir/compare/v39.0.10...v39.0.11) (2023-06-27) ### Bug Fixes * handle invalid workspace entries ([#1316](https://github.com/ipfs/aegir/issues/1316)) ([a95aec3](https://github.com/ipfs/aegir/commit/a95aec346270472fe635e508476a1eb844e80cfe)) ### Trivial Changes * Update .github/workflows/stale.yml [skip ci] ([369453f](https://github.com/ipfs/aegir/commit/369453f7543488d43e72721c48320d6d8d59b705)) --- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25123baa7..27833a4d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## [39.0.11](https://github.com/ipfs/aegir/compare/v39.0.10...v39.0.11) (2023-06-27) + + +### Bug Fixes + +* handle invalid workspace entries ([#1316](https://github.com/ipfs/aegir/issues/1316)) ([a95aec3](https://github.com/ipfs/aegir/commit/a95aec346270472fe635e508476a1eb844e80cfe)) + + +### Trivial Changes + +* Update .github/workflows/stale.yml [skip ci] ([369453f](https://github.com/ipfs/aegir/commit/369453f7543488d43e72721c48320d6d8d59b705)) + ## [39.0.10](https://github.com/ipfs/aegir/compare/v39.0.9...v39.0.10) (2023-06-10) diff --git a/package.json b/package.json index 192fb6d65..1d47feed3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aegir", - "version": "39.0.10", + "version": "39.0.11", "description": "JavaScript project management", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/aegir#readme", From 4c3ab552b63017c896429cca9398592d703eeafc Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 28 Jun 2023 09:25:29 +0200 Subject: [PATCH 05/11] fix: allow specifying ci file in check-project (#1317) Not all projects use js-test-and-release.yml as their main CI file so allow specifying something different. --- src/check-project/check-monorepo-readme.js | 5 +- src/check-project/check-readme.js | 5 +- src/check-project/index.js | 46 +++++++++++++----- src/check-project/manifests/untyped-esm.js | 56 ++++++++++++++++++++++ src/check-project/readme/header.js | 23 ++++----- 5 files changed, 108 insertions(+), 27 deletions(-) create mode 100644 src/check-project/manifests/untyped-esm.js diff --git a/src/check-project/check-monorepo-readme.js b/src/check-project/check-monorepo-readme.js index df8eaa392..e501c5093 100644 --- a/src/check-project/check-monorepo-readme.js +++ b/src/check-project/check-monorepo-readme.js @@ -17,8 +17,9 @@ import { * @param {string} repoUrl * @param {string} defaultBranch * @param {string[]} projectDirs + * @param {string} ciFile */ -export async function checkMonorepoReadme (projectDir, repoUrl, defaultBranch, projectDirs) { +export async function checkMonorepoReadme (projectDir, repoUrl, defaultBranch, projectDirs, ciFile) { const repoParts = repoUrl.split('/') const repoName = repoParts.pop() const repoOwner = repoParts.pop() @@ -47,7 +48,7 @@ export async function checkMonorepoReadme (projectDir, repoUrl, defaultBranch, p const file = parseMarkdown(readmeContents) // create basic readme with heading, CI link, etc - const readme = parseMarkdown(HEADER(pkg, repoOwner, repoName, defaultBranch)) + const readme = parseMarkdown(HEADER(pkg, repoOwner, repoName, defaultBranch, ciFile)) // remove existing header, CI link, etc /** @type {import('mdast').Root} */ diff --git a/src/check-project/check-readme.js b/src/check-project/check-readme.js index 53c7b2917..0fb946b0d 100644 --- a/src/check-project/check-readme.js +++ b/src/check-project/check-readme.js @@ -16,9 +16,10 @@ import { * @param {string} projectDir * @param {string} repoUrl * @param {string} defaultBranch + * @param {string} ciFile * @param {any} [rootManifest] */ -export async function checkReadme (projectDir, repoUrl, defaultBranch, rootManifest) { +export async function checkReadme (projectDir, repoUrl, defaultBranch, ciFile, rootManifest) { const repoParts = repoUrl.split('/') const repoName = repoParts.pop() const repoOwner = repoParts.pop() @@ -47,7 +48,7 @@ export async function checkReadme (projectDir, repoUrl, defaultBranch, rootManif const file = parseMarkdown(readmeContents) // create basic readme with heading, CI link, etc - const readme = parseMarkdown(HEADER(pkg, repoOwner, repoName, defaultBranch)) + const readme = parseMarkdown(HEADER(pkg, repoOwner, repoName, defaultBranch, ciFile)) // remove existing header, CI link, etc /** @type {import('mdast').Root} */ diff --git a/src/check-project/index.js b/src/check-project/index.js index 5db27cc5b..9dfb42240 100755 --- a/src/check-project/index.js +++ b/src/check-project/index.js @@ -22,6 +22,7 @@ import { typedCJSManifest } from './manifests/typed-cjs.js' import { typedESMManifest } from './manifests/typed-esm.js' import { typescriptManifest } from './manifests/typescript.js' import { untypedCJSManifest } from './manifests/untyped-cjs.js' +import { untypedESMManifest } from './manifests/untyped-esm.js' import { sortManifest, ensureFileHasContents, @@ -98,8 +99,9 @@ async function getConfig (projectDir) { * @param {any} manifest * @param {string} branchName * @param {string} repoUrl + * @param {string} ciFile */ -async function processMonorepo (projectDir, manifest, branchName, repoUrl) { +async function processMonorepo (projectDir, manifest, branchName, repoUrl, ciFile) { const workspaces = manifest.workspaces if (!workspaces || !Array.isArray(workspaces)) { @@ -130,7 +132,7 @@ async function processMonorepo (projectDir, manifest, branchName, repoUrl) { console.info('Found monorepo project', pkg.name) - await processModule(subProjectDir, pkg, branchName, repoUrl, homePage, manifest) + await processModule(subProjectDir, pkg, branchName, repoUrl, homePage, ciFile, manifest) projectDirs.push(subProjectDir) } @@ -148,7 +150,7 @@ async function processMonorepo (projectDir, manifest, branchName, repoUrl) { })) await checkLicenseFiles(projectDir) await checkBuildFiles(projectDir, branchName, repoUrl) - await checkMonorepoReadme(projectDir, repoUrl, branchName, projectDirs) + await checkMonorepoReadme(projectDir, repoUrl, branchName, projectDirs, ciFile) await checkMonorepoFiles(projectDir) } @@ -306,9 +308,10 @@ function addReferences (deps, references, refs) { * @param {any} manifest * @param {string} branchName * @param {string} repoUrl + * @param {string} ciFile */ -async function processProject (projectDir, manifest, branchName, repoUrl) { - await processModule(projectDir, manifest, branchName, repoUrl) +async function processProject (projectDir, manifest, branchName, repoUrl, ciFile) { + await processModule(projectDir, manifest, branchName, repoUrl, repoUrl, ciFile) await checkBuildFiles(projectDir, branchName, repoUrl) } @@ -326,9 +329,10 @@ function isAegirProject (manifest) { * @param {string} branchName * @param {string} repoUrl * @param {string} homePage + * @param {string} ciFile * @param {any} [rootManifest] */ -async function processModule (projectDir, manifest, branchName, repoUrl, homePage = repoUrl, rootManifest) { +async function processModule (projectDir, manifest, branchName, repoUrl, homePage = repoUrl, ciFile, rootManifest) { if (!isAegirProject(manifest) && manifest.name !== 'aegir') { throw new Error(`"${projectDir}" is not an aegir project`) } @@ -351,7 +355,10 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag // 3. CJS, no types let typedCJS = cjs && hasMain && types - // 3. CJS, no types + // 4. ESM, no types + let untypedESM = esm && hasMain + + // 5. CJS, no types let untypedCJS = cjs && hasMain let proposedManifest = {} @@ -361,10 +368,10 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag const { projectType } = await prompt.get({ properties: { projectType: { - description: 'Project type: typescript | typedESM | typedCJS | untypedCJS', + description: 'Project type: typescript | typedESM | typedCJS | untypedESM | untypedCJS', required: true, conform: (value) => { - return ['typescript', 'typedESM', 'typedCJS', 'untypedCJS'].includes(value) + return ['typescript', 'typedESM', 'typedCJS', 'untypedESM', 'untypedCJS'].includes(value) }, default: 'typescript' } @@ -377,6 +384,8 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag typedESM = true } else if (projectType === 'typedCJS') { typedCJS = true + } else if (projectType === 'untypedESM') { + untypedESM = true } else if (projectType === 'untypedCJS') { untypedCJS = true } else { @@ -393,6 +402,9 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag } else if (typedCJS) { console.info('Typed CJS project detected') proposedManifest = await typedCJSManifest(manifest, branchName, repoUrl, homePage) + } else if (untypedESM) { + console.info('Untyped ESM project detected') + proposedManifest = await untypedESMManifest(manifest, branchName, repoUrl, homePage) } else if (untypedCJS) { console.info('Untyped CJS project detected') proposedManifest = await untypedCJSManifest(manifest, branchName, repoUrl, homePage) @@ -411,7 +423,7 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag } await checkLicenseFiles(projectDir) - await checkReadme(projectDir, repoUrl, branchName, rootManifest) + await checkReadme(projectDir, repoUrl, branchName, ciFile, rootManifest) } export default new Listr([ @@ -424,11 +436,21 @@ export default new Listr([ const manifest = fs.readJSONSync(path.join(projectDir, 'package.json')) const monorepo = manifest.workspaces != null + const ciFile = (await prompt.get({ + properties: { + ciFile: { + description: 'ciFile', + required: true, + default: 'js-test-and-release.yml' + } + } + })).ciFile.toString() + if (monorepo) { console.info('monorepo project detected') - await processMonorepo(projectDir, manifest, branchName, repoUrl) + await processMonorepo(projectDir, manifest, branchName, repoUrl, ciFile) } else { - await processProject(projectDir, manifest, branchName, repoUrl) + await processProject(projectDir, manifest, branchName, repoUrl, ciFile) } } } diff --git a/src/check-project/manifests/untyped-esm.js b/src/check-project/manifests/untyped-esm.js new file mode 100644 index 000000000..e1547c726 --- /dev/null +++ b/src/check-project/manifests/untyped-esm.js @@ -0,0 +1,56 @@ +import mergeOptions from 'merge-options' +import { semanticReleaseConfig } from '../semantic-release-config.js' +import { + sortFields, + constructManifest +} from '../utils.js' + +const merge = mergeOptions.bind({ ignoreUndefined: true }) + +/** + * @param {any} manifest + * @param {string} branchName + * @param {string} repoUrl + * @param {string} [homePage] + */ +export async function untypedESMManifest (manifest, branchName, repoUrl, homePage = repoUrl) { + let proposedManifest = constructManifest(manifest, { + type: 'module', + files: [ + 'src', + 'dist', + '!dist/test', + '!**/*.tsbuildinfo' + ], + exports: { + '.': { + types: './dist/src/index.d.ts', + import: './src/index.js' + } + }, + eslintConfig: merge({ + extends: 'ipfs', + parserOptions: { + sourceType: 'module' + } + }, manifest.eslintConfig), + release: (manifest.scripts?.release?.includes('semantic-release') || manifest.scripts?.release?.includes('aegir release')) ? semanticReleaseConfig(branchName) : undefined + }, repoUrl, homePage) + + const rest = { + ...sortFields(manifest) + } + + for (const key of Object.keys(proposedManifest)) { + delete rest[key] + } + + proposedManifest = { + ...proposedManifest, + ...rest, + contributors: undefined, + leadMaintainer: undefined + } + + return proposedManifest +} diff --git a/src/check-project/readme/header.js b/src/check-project/readme/header.js index 36acb106d..3159763c0 100644 --- a/src/check-project/readme/header.js +++ b/src/check-project/readme/header.js @@ -1,27 +1,27 @@ /** - * @type {Record string>} + * @type {Record string>} */ const BADGES = { - libp2p: (repoOwner, repoName, defaultBranch) => ` + libp2p: (repoOwner, repoName, defaultBranch, ciFile) => ` [![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) [![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) [![codecov](https://img.shields.io/codecov/c/github/${repoOwner}/${repoName}.svg?style=flat-square)](https://codecov.io/gh/${repoOwner}/${repoName}) -[![CI](https://img.shields.io/github/actions/workflow/status/${repoOwner}/${repoName}/js-test-and-release.yml?branch=${defaultBranch}&style=flat-square)](https://github.com/${repoOwner}/${repoName}/actions/workflows/js-test-and-release.yml?query=branch%3A${defaultBranch}) +[![CI](https://img.shields.io/github/actions/workflow/status/${repoOwner}/${repoName}/${ciFile}?branch=${defaultBranch}&style=flat-square)](https://github.com/${repoOwner}/${repoName}/actions/workflows/${ciFile}?query=branch%3A${defaultBranch}) `, - ipfs: (repoOwner, repoName, defaultBranch) => ` + ipfs: (repoOwner, repoName, defaultBranch, ciFile) => ` [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) [![codecov](https://img.shields.io/codecov/c/github/${repoOwner}/${repoName}.svg?style=flat-square)](https://codecov.io/gh/${repoOwner}/${repoName}) -[![CI](https://img.shields.io/github/actions/workflow/status/${repoOwner}/${repoName}/js-test-and-release.yml?branch=${defaultBranch}&style=flat-square)](https://github.com/${repoOwner}/${repoName}/actions/workflows/js-test-and-release.yml?query=branch%3A${defaultBranch}) +[![CI](https://img.shields.io/github/actions/workflow/status/${repoOwner}/${repoName}/${ciFile}?branch=${defaultBranch}&style=flat-square)](https://github.com/${repoOwner}/${repoName}/actions/workflows/${ciFile}?query=branch%3A${defaultBranch}) `, - multiformats: (repoOwner, repoName, defaultBranch) => ` + multiformats: (repoOwner, repoName, defaultBranch, ciFile) => ` [![multiformats.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://multiformats.io) [![codecov](https://img.shields.io/codecov/c/github/${repoOwner}/${repoName}.svg?style=flat-square)](https://codecov.io/gh/${repoOwner}/${repoName}) -[![CI](https://img.shields.io/github/actions/workflow/status/${repoOwner}/${repoName}/js-test-and-release.yml?branch=${defaultBranch}&style=flat-square)](https://github.com/${repoOwner}/${repoName}/actions/workflows/js-test-and-release.yml?query=branch%3A${defaultBranch}) +[![CI](https://img.shields.io/github/actions/workflow/status/${repoOwner}/${repoName}/${ciFile}?branch=${defaultBranch}&style=flat-square)](https://github.com/${repoOwner}/${repoName}/actions/workflows/${ciFile}?query=branch%3A${defaultBranch}) `, - default: (repoOwner, repoName, defaultBranch) => ` + default: (repoOwner, repoName, defaultBranch, ciFile) => ` [![codecov](https://img.shields.io/codecov/c/github/${repoOwner}/${repoName}.svg?style=flat-square)](https://codecov.io/gh/${repoOwner}/${repoName}) -[![CI](https://img.shields.io/github/actions/workflow/status/${repoOwner}/${repoName}/js-test-and-release.yml?branch=${defaultBranch}&style=flat-square)](https://github.com/${repoOwner}/${repoName}/actions/workflows/js-test-and-release.yml?query=branch%3A${defaultBranch}) +[![CI](https://img.shields.io/github/actions/workflow/status/${repoOwner}/${repoName}/${ciFile}?branch=${defaultBranch}&style=flat-square)](https://github.com/${repoOwner}/${repoName}/actions/workflows/${ciFile}?query=branch%3A${defaultBranch}) ` } @@ -30,12 +30,13 @@ const BADGES = { * @param {string} repoOwner * @param {string} repoName * @param {string} defaultBranch + * @param {string} ciFile */ -export const HEADER = (pkg, repoOwner, repoName, defaultBranch) => { +export const HEADER = (pkg, repoOwner, repoName, defaultBranch, ciFile) => { return ` # ${pkg.name} -${(BADGES[repoOwner] ?? BADGES.default)(repoOwner, repoName, defaultBranch).trim()} +${(BADGES[repoOwner] ?? BADGES.default)(repoOwner, repoName, defaultBranch, ciFile).trim()} > ${pkg.description} From 4aac80c99399b76f7293f152d05e5b1d60020f67 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 28 Jun 2023 07:37:09 +0000 Subject: [PATCH 06/11] chore(release): 39.0.12 [skip ci] ## [39.0.12](https://github.com/ipfs/aegir/compare/v39.0.11...v39.0.12) (2023-06-28) ### Bug Fixes * allow specifying ci file in check-project ([#1317](https://github.com/ipfs/aegir/issues/1317)) ([4c3ab55](https://github.com/ipfs/aegir/commit/4c3ab552b63017c896429cca9398592d703eeafc)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27833a4d3..edceb1e7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [39.0.12](https://github.com/ipfs/aegir/compare/v39.0.11...v39.0.12) (2023-06-28) + + +### Bug Fixes + +* allow specifying ci file in check-project ([#1317](https://github.com/ipfs/aegir/issues/1317)) ([4c3ab55](https://github.com/ipfs/aegir/commit/4c3ab552b63017c896429cca9398592d703eeafc)) + ## [39.0.11](https://github.com/ipfs/aegir/compare/v39.0.10...v39.0.11) (2023-06-27) diff --git a/package.json b/package.json index 1d47feed3..669f455ee 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aegir", - "version": "39.0.11", + "version": "39.0.12", "description": "JavaScript project management", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/aegir#readme", From 8f4ab172b7f46381e08d3c709e576197396c5331 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 28 Jun 2023 10:39:49 +0200 Subject: [PATCH 07/11] fix: when generating api doc link, check typedoc entry point (#1318) If a package is in a monorepo and it has no typedoc entry point no API doc link should be generated. --- src/check-project/readme/api-docs.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/check-project/readme/api-docs.js b/src/check-project/readme/api-docs.js index 1f928508b..fd18376e4 100644 --- a/src/check-project/readme/api-docs.js +++ b/src/check-project/readme/api-docs.js @@ -3,6 +3,12 @@ * @param {*} [parentManifest] */ export const APIDOCS = (pkg, parentManifest) => { + // monorepo project - test for typedoc entry point + if (parentManifest != null && pkg.typedoc?.entryPoint == null) { + return '' + } + + // test for docs script in monorepo root or package const scripts = parentManifest?.scripts ?? pkg.scripts ?? {} if (scripts.docs == null) { From 4cac5d3e60e3a8f99131f6c1d2a7d761b950c054 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 28 Jun 2023 08:47:44 +0000 Subject: [PATCH 08/11] chore(release): 39.0.13 [skip ci] ## [39.0.13](https://github.com/ipfs/aegir/compare/v39.0.12...v39.0.13) (2023-06-28) ### Bug Fixes * when generating api doc link, check typedoc entry point ([#1318](https://github.com/ipfs/aegir/issues/1318)) ([8f4ab17](https://github.com/ipfs/aegir/commit/8f4ab172b7f46381e08d3c709e576197396c5331)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edceb1e7d..721967555 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [39.0.13](https://github.com/ipfs/aegir/compare/v39.0.12...v39.0.13) (2023-06-28) + + +### Bug Fixes + +* when generating api doc link, check typedoc entry point ([#1318](https://github.com/ipfs/aegir/issues/1318)) ([8f4ab17](https://github.com/ipfs/aegir/commit/8f4ab172b7f46381e08d3c709e576197396c5331)) + ## [39.0.12](https://github.com/ipfs/aegir/compare/v39.0.11...v39.0.12) (2023-06-28) diff --git a/package.json b/package.json index 669f455ee..500645936 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aegir", - "version": "39.0.12", + "version": "39.0.13", "description": "JavaScript project management", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/aegir#readme", From 48cc1413972451fc58749b3cf4d91719d74e518c Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 28 Jun 2023 08:51:30 +0000 Subject: [PATCH 09/11] chore: Update .github/workflows/stale.yml [skip ci] --- .github/workflows/stale.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 668bd07d4..16d65d721 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -2,7 +2,11 @@ name: Close and mark stale issue on: schedule: - - cron: '0 0 * * *' + - cron: '0 0 * * *' + +permissions: + issues: write + pull-requests: write jobs: stale: From 4ef4b62f215316a24b58dac67c840c0dbd149d01 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Wed, 19 Jul 2023 13:56:46 +0100 Subject: [PATCH 10/11] deps!: upgrade typescript and typedoc (#1337) Upgrades all deps including typescript, typedoc, semantic release and markdown deps. BREAKING CHANGE: update typescript to `5.1.6, typedoc to `0.24.8` and eslint-config-ipfs to `5.0.0` --- .gitignore | 6 +- package.json | 64 +++++------ src/check-project/check-typedoc-files.js | 33 ++++++ src/check-project/index.js | 2 + src/check-project/readme/utils.js | 14 +-- src/config/tsconfig.aegir.json | 2 +- src/docs.js | 6 +- ...exer-plugin.cjs => type-indexer-plugin.js} | 103 ++++++++++++------ .../{typedoc-plugin.cjs => typedoc-plugin.js} | 13 +-- ....cjs => unknown-symbol-resolver-plugin.js} | 68 ++++++------ src/utils.js | 42 +++++-- test/fixtures/js+ts/tsconfig.json | 2 +- .../packages/a-workspace-project/package.json | 5 +- .../packages/a-workspace-project/src/types.ts | 1 - .../a-workspace-project/tsconfig.json | 2 +- .../packages/a-workspace-project/typedoc.json | 3 + .../another-workspace-project/package.json | 5 +- .../src/dir/index.js | 7 ++ .../another-workspace-project/src/index.js | 2 + .../another-workspace-project/src/types.ts | 1 - .../another-workspace-project/tsconfig.json | 2 +- .../another-workspace-project/typedoc.json | 3 + .../projects/a-ts-project/src/a-module.ts | 1 - .../projects/a-ts-project/src/dir/index.ts | 3 + .../projects/a-ts-project/src/index.ts | 2 + .../projects/a-ts-project/tsconfig.json | 2 +- .../projects/an-esm-project/src/dir/index.js | 7 ++ .../projects/an-esm-project/src/index.js | 2 + .../projects/an-esm-project/src/types.ts | 1 - .../projects/an-esm-project/tsconfig.json | 2 +- 30 files changed, 254 insertions(+), 152 deletions(-) create mode 100644 src/check-project/check-typedoc-files.js rename src/docs/{type-indexer-plugin.cjs => type-indexer-plugin.js} (59%) rename src/docs/{typedoc-plugin.cjs => typedoc-plugin.js} (83%) rename src/docs/{unknown-symbol-resolver-plugin.cjs => unknown-symbol-resolver-plugin.js} (59%) create mode 100644 test/fixtures/projects/a-monorepo/packages/a-workspace-project/typedoc.json create mode 100644 test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/dir/index.js create mode 100644 test/fixtures/projects/a-monorepo/packages/another-workspace-project/typedoc.json create mode 100644 test/fixtures/projects/a-ts-project/src/dir/index.ts create mode 100644 test/fixtures/projects/an-esm-project/src/dir/index.js diff --git a/.gitignore b/.gitignore index 53cf8c17e..2e34a630b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,8 @@ package-lock.json yarn.lock +# only the root node_modules folder since some of the test fixtures have them /node_modules -/actions/bundle-size/node_modules -/coverage -/dist -/docs +dist .docs .nyc_output *.log diff --git a/package.json b/package.json index 500645936..dbbda450f 100644 --- a/package.json +++ b/package.json @@ -229,39 +229,39 @@ "@electron/get": "^2.0.0", "@polka/send-type": "^0.5.2", "@semantic-release/changelog": "^6.0.1", - "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/commit-analyzer": "^10.0.1", "@semantic-release/git": "^10.0.1", - "@semantic-release/github": "https://registry.npmjs.org/@achingbrain/semantic-release-github/-/semantic-release-github-0.0.2.tgz", - "@semantic-release/npm": "^9.0.2", - "@semantic-release/release-notes-generator": "^10.0.3", + "@semantic-release/github": "^9.0.3", + "@semantic-release/npm": "^10.0.4", + "@semantic-release/release-notes-generator": "^11.0.4", "@types/chai": "^4.2.16", "@types/chai-as-promised": "^7.1.3", "@types/chai-string": "^1.4.2", "@types/chai-subset": "^1.3.3", "@types/mocha": "^10.0.0", - "@types/node": "^18.11.15", + "@types/node": "^20.4.2", "@typescript-eslint/eslint-plugin": "^5.18.0", "buffer": "^6.0.3", "bytes": "^3.1.0", - "c8": "^7.7.0", + "c8": "^8.0.0", "chai": "^4.3.4", "chai-as-promised": "^7.1.1", "chai-bites": "^0.1.2", "chai-parentheses": "^0.0.2", "chai-string": "^1.5.0", "chai-subset": "^1.6.0", - "conventional-changelog-conventionalcommits": "^5.0.0", + "conventional-changelog-conventionalcommits": "^6.1.0", "cors": "^2.8.5", "depcheck": "^1.4.3", "diff": "^5.1.0", "electron-mocha-main": "^11.0.3", "env-paths": "^3.0.0", - "esbuild": "^0.17.9", + "esbuild": "^0.18.12", "eslint": "^8.31.0", - "eslint-config-ipfs": "^4.0.2", + "eslint-config-ipfs": "^5.0.0", "eslint-plugin-etc": "^2.0.2", "eslint-plugin-import": "^2.18.0", - "eslint-plugin-jsdoc": "^43.1.1", + "eslint-plugin-jsdoc": "^46.4.3", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^6.1.1", "execa": "^7.0.0", @@ -272,48 +272,48 @@ "kleur": "^4.1.4", "lilconfig": "^2.0.5", "listr": "~0.14.2", - "mdast-util-from-markdown": "^1.2.0", - "mdast-util-gfm": "^2.0.1", - "mdast-util-gfm-footnote": "^1.0.1", - "mdast-util-gfm-strikethrough": "^1.0.1", - "mdast-util-gfm-table": "^1.0.4", - "mdast-util-gfm-task-list-item": "^1.0.1", - "mdast-util-to-markdown": "^1.3.0", - "mdast-util-toc": "^6.1.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-gfm": "^3.0.0", + "mdast-util-gfm-footnote": "^2.0.0", + "mdast-util-gfm-strikethrough": "^2.0.0", + "mdast-util-gfm-table": "^2.0.0", + "mdast-util-gfm-task-list-item": "^2.0.0", + "mdast-util-to-markdown": "^2.0.0", + "mdast-util-toc": "^7.0.0", "merge-options": "^3.0.4", - "micromark-extension-gfm": "^2.0.1", - "micromark-extension-gfm-footnote": "^1.0.4", - "micromark-extension-gfm-strikethrough": "^1.0.4", - "micromark-extension-gfm-table": "^1.0.5", - "micromark-extension-gfm-task-list-item": "^1.0.3", + "micromark-extension-gfm": "^3.0.0", + "micromark-extension-gfm-footnote": "^2.0.0", + "micromark-extension-gfm-strikethrough": "^2.0.0", + "micromark-extension-gfm-table": "^2.0.0", + "micromark-extension-gfm-task-list-item": "^2.0.1", "minimatch": "^9.0.0", "mocha": "^10.0.0", - "npm-package-json-lint": "^6.3.0", + "npm-package-json-lint": "^7.0.0", "nyc": "^15.1.0", "p-map": "^6.0.0", "p-retry": "^5.1.2", "pascalcase": "^2.0.0", "path": "^0.12.7", - "playwright-test": "^8.1.0", + "playwright-test": "^12.1.1", "polka": "^0.5.2", "premove": "^4.0.0", "prompt": "^1.2.2", "proper-lockfile": "^4.1.2", "react-native-test-runner": "^5.0.0", - "read-pkg-up": "^9.1.0", + "read-pkg-up": "^10.0.0", "rimraf": "^5.0.0", - "semantic-release": "^20.1.3", + "semantic-release": "^21.0.7", "semantic-release-monorepo": "^7.0.5", "semver": "^7.3.8", "source-map-support": "^0.5.20", "strip-bom": "^5.0.0", "strip-json-comments": "^5.0.0", "tempy": "^3.0.0", - "typedoc": "^0.23.21", + "typedoc": "^0.24.8", "typedoc-plugin-mdn-links": "^3.0.3", - "typedoc-plugin-missing-exports": "^1.0.0", - "typescript": "^4.6.3", - "typescript-docs-verifier": "2.4.0", + "typedoc-plugin-missing-exports": "^2.0.0", + "typescript": "^5.1.6", + "typescript-docs-verifier": "^2.5.0", "uint8arrays": "^4.0.2", "undici": "^5.0.0", "update-notifier": "^6.0.2", @@ -337,7 +337,7 @@ "@types/semver": "^7.3.4", "@types/update-notifier": "^6.0.1", "@types/yargs": "^17.0.0", - "electron": "^24.1.2" + "electron": "^25.3.0" }, "browser": { "fs": false, diff --git a/src/check-project/check-typedoc-files.js b/src/check-project/check-typedoc-files.js new file mode 100644 index 000000000..892a59afd --- /dev/null +++ b/src/check-project/check-typedoc-files.js @@ -0,0 +1,33 @@ +/* eslint-disable no-console */ + +import path from 'path' +import fs from 'fs-extra' +import { + ensureFileHasContents +} from './utils.js' + +/** + * @param {string} projectDir + * @param {boolean} isTypescriptProject + */ +export async function checkTypedocFiles (projectDir, isTypescriptProject) { + console.info('Check typedoc files') + + const pkg = fs.readJSONSync(path.join(projectDir, 'package.json')) + const entryPoints = Object.values(pkg.exports) + .map(e => { + const path = e.import + + if (isTypescriptProject) { + return path + .replace('dist/src', 'src') + .replace('.js', '.ts') + } + + return path + }) + + await ensureFileHasContents(JSON.stringify({ + entryPoints + }, null, 2), 'typedoc.json') +} diff --git a/src/check-project/index.js b/src/check-project/index.js index 9dfb42240..332e7f7a0 100755 --- a/src/check-project/index.js +++ b/src/check-project/index.js @@ -17,6 +17,7 @@ import { checkLicenseFiles } from './check-licence-files.js' import { checkMonorepoFiles } from './check-monorepo-files.js' import { checkMonorepoReadme } from './check-monorepo-readme.js' import { checkReadme } from './check-readme.js' +import { checkTypedocFiles } from './check-typedoc-files.js' import { monorepoManifest } from './manifests/monorepo.js' import { typedCJSManifest } from './manifests/typed-cjs.js' import { typedESMManifest } from './manifests/typed-esm.js' @@ -424,6 +425,7 @@ async function processModule (projectDir, manifest, branchName, repoUrl, homePag await checkLicenseFiles(projectDir) await checkReadme(projectDir, repoUrl, branchName, ciFile, rootManifest) + await checkTypedocFiles(projectDir, typescript) } export default new Listr([ diff --git a/src/check-project/readme/utils.js b/src/check-project/readme/utils.js index e202438bc..4f11c09b9 100644 --- a/src/check-project/readme/utils.js +++ b/src/check-project/readme/utils.js @@ -18,17 +18,17 @@ export function parseMarkdown (md) { return fromMarkdown(md, { extensions: [ gfm(), - gfmTable, + gfmTable(), gfmFootnote(), gfmStrikethrough(), - gfmTaskListItem + gfmTaskListItem() ], mdastExtensions: [ gfmFromMarkdown(), - gfmTableFromMarkdown, + gfmTableFromMarkdown(), gfmFootnoteFromMarkdown(), - gfmStrikethroughFromMarkdown, - gfmTaskListItemFromMarkdown + gfmStrikethroughFromMarkdown(), + gfmTaskListItemFromMarkdown() ] }) } @@ -43,8 +43,8 @@ export function writeMarkdown (tree) { gfmToMarkdown(), gfmTableToMarkdown(), gfmFootnoteToMarkdown(), - gfmStrikethroughToMarkdown, - gfmTaskListItemToMarkdown + gfmStrikethroughToMarkdown(), + gfmTaskListItemToMarkdown() ], bullet: '-', listItemIndent: 'one' diff --git a/src/config/tsconfig.aegir.json b/src/config/tsconfig.aegir.json index 277005b3e..7b6dc9e06 100644 --- a/src/config/tsconfig.aegir.json +++ b/src/config/tsconfig.aegir.json @@ -27,7 +27,7 @@ "noUnusedLocals": true, "noUnusedParameters": false, // advanced - "importsNotUsedAsValues": "error", + "verbatimModuleSyntax": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "stripInternal": true, diff --git a/src/docs.js b/src/docs.js index c9149a29a..da0a3706b 100644 --- a/src/docs.js +++ b/src/docs.js @@ -49,11 +49,11 @@ const docs = async (ctx, task) => { '--gitRevision', 'master', '--plugin', - fromAegir('src/docs/typedoc-plugin.cjs'), + fromAegir('src/docs/typedoc-plugin.js'), '--plugin', - fromAegir('src/docs/unknown-symbol-resolver-plugin.cjs'), + fromAegir('src/docs/unknown-symbol-resolver-plugin.js'), '--plugin', - fromAegir('src/docs/type-indexer-plugin.cjs'), + fromAegir('src/docs/type-indexer-plugin.js'), '--plugin', 'typedoc-plugin-mdn-links', '--plugin', diff --git a/src/docs/type-indexer-plugin.cjs b/src/docs/type-indexer-plugin.js similarity index 59% rename from src/docs/type-indexer-plugin.cjs rename to src/docs/type-indexer-plugin.js index 630c81c36..81380f7ef 100644 --- a/src/docs/type-indexer-plugin.cjs +++ b/src/docs/type-indexer-plugin.js @@ -1,17 +1,18 @@ -const fs = require('fs') -const { RendererEvent } = require('typedoc') -const path = require('path') +import fs from 'fs' +import path from 'path' +import { RendererEvent, ReflectionKind } from 'typedoc' +import { parseProjects } from '../utils.js' /** * The types of models we want to store documentation URLs for */ const MODELS = [ - 'Interface', - 'Function', - 'Type alias', - 'Variable', - 'Class', - 'Enumeration' + ReflectionKind.Interface, + ReflectionKind.Function, + ReflectionKind.TypeAlias, + ReflectionKind.Variable, + ReflectionKind.Class, + ReflectionKind.Enum ] /** @@ -20,6 +21,8 @@ const MODELS = [ * @property {Record} Documentation.typedocs * @property {string[]} Documentation.exported * @property {string} [Documentation.outputDir] + * + * @typedef {import('../utils.js').Project} Project */ /** @@ -27,15 +30,23 @@ const MODELS = [ * current project that contains URLs that map exported symbol names to published * typedoc pages. * - * See `unknown-symbol-resolver-plugin.cjs` for how it is consumed. + * See `unknown-symbol-resolver-plugin.js` for how it is consumed. * * @param {import("typedoc/dist/lib/application").Application} Application */ -function load (Application) { +export function load (Application) { const manifestPath = `${process.cwd()}/package.json` - const manifest = require(manifestPath) + const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8')) const isMonorepo = Boolean(manifest.workspaces) + // workaround for https://github.com/TypeStrong/typedoc/issues/2338 + /** @type {Record} */ + let projects = {} + + if (isMonorepo) { + projects = parseProjects(process.cwd(), manifest.workspaces) + } + /** @type {string} */ let ghPages @@ -54,6 +65,7 @@ function load (Application) { */ const onRendererBegin = event => { if (!event.urls) { + Application.logger.warn('No urls found in RendererEvent') return } @@ -62,14 +74,45 @@ function load (Application) { for (const urlMapping of event.urls) { if (!urlMapping.model.sources || urlMapping.model.sources.length === 0) { + Application.logger.info(`No sources found in URLMapping for variant "${urlMapping.model.variant}"`) + continue + } + + if (!MODELS.includes(urlMapping.model.kind)) { + Application.logger.info(`Skipping model "${urlMapping.model.variant}" as it is not in the list of model types we are interested in`) continue } - if (!MODELS.includes(urlMapping.model.kindString)) { + if (urlMapping.model.sources == null || urlMapping.model.sources.length === 0) { + Application.logger.info(`Skipping model "${urlMapping.model.variant}" as it has no url mapping sources`) continue } - const context = findContext(urlMapping, isMonorepo) + const source = urlMapping.model.sources[0] + + // workaround for https://github.com/TypeStrong/typedoc/issues/2338 + if (!path.isAbsolute(source.fullFileName)) { + const project = urlMapping.model.parent + const projectDir = projects[project.name]?.dir + + if (!projectDir) { + Application.logger.warn(`Full file name "${source.fullFileName}" was not absolute but could not find containing project - see https://github.com/TypeStrong/typedoc/issues/2338`) + continue + } else { + const fullFileName = `${projectDir}/src/${source.fullFileName}` + + if (fs.existsSync(fullFileName)) { + Application.logger.info(`Full file name of source was not absolute, overriding ${source.fullFileName} -> ${fullFileName} - see https://github.com/TypeStrong/typedoc/issues/2338`) + + source.fullFileName = fullFileName + } else { + Application.logger.warn(`Full file name "${source.fullFileName}" was not absolute, found containing project but could not locate source file in project - see https://github.com/TypeStrong/typedoc/issues/2338`) + continue + } + } + } + + const context = findContext(source, isMonorepo) // set up manifest to contain typedoc urls if (typedocs[context.manifestPath] == null) { @@ -83,11 +126,11 @@ function load (Application) { } // cannot differentiate between types with duplicate names in the same module https://github.com/TypeStrong/typedoc/issues/2125 - if (typedocs[context.manifestPath].typedocs[urlMapping.model.originalName] != null) { - Application.logger.warn(`Duplicate exported type name ${urlMapping.model.originalName} defined in ${urlMapping.model.sources[0].fullFileName}`) + if (typedocs[context.manifestPath].typedocs[urlMapping.model.name] != null) { + Application.logger.warn(`Duplicate exported type name ${urlMapping.model.name} defined in ${urlMapping.model.sources[0].fullFileName}`) } else { // store reference to generate doc url - typedocs[context.manifestPath].typedocs[urlMapping.model.originalName] = `${ghPages}${urlMapping.url}` + typedocs[context.manifestPath].typedocs[urlMapping.model.name] = `${ghPages}${urlMapping.url}` } } @@ -103,16 +146,18 @@ function load (Application) { recursive: true }) fs.writeFileSync(`${context.outputDir}/typedoc-urls.json`, JSON.stringify(context.typedocs, null, 2)) + + Application.logger.info(`Wrote typedoc URLs to ${context.outputDir}/typedoc-urls.json`) }) + + if (Object.keys(typedocs).length === 0) { + Application.logger.warn('No typedoc-urls.json written!') + } } Application.renderer.on(RendererEvent.BEGIN, onRendererBegin) } -module.exports = { - load -} - /** * @typedef {object} ProjectContext * @property {string} [ProjectContext.outputDir] @@ -123,31 +168,25 @@ module.exports = { * For a given UrlMapping, find the nearest package.json file * and work out if a `typedoc-urls.json` should be generated. * - * @param {import("typedoc/dist/lib/output/models/UrlMapping").UrlMapping} mapping + * @param {import("typedoc/dist/lib/models/sources/file").SourceReference} source * @param {boolean} isMonorepo * @returns {ProjectContext} */ -function findContext (mapping, isMonorepo) { - const sources = mapping.model.sources - - if (sources == null || sources.length === 0 || sources[0].fullFileName == null) { - throw new Error('UrlMapping had no sources') - } - - const absolutePathSegments = sources[0].fullFileName.split('/') +function findContext (source, isMonorepo) { + const absolutePathSegments = source.fullFileName.split('/') while (absolutePathSegments.length) { // remove last path segment absolutePathSegments.pop() - let manifestPath = makeAbsolute(path.join(...absolutePathSegments, 'package.json')) + const manifestPath = makeAbsolute(path.join(...absolutePathSegments, 'package.json')) /** @type {string | undefined} */ let outputDir = makeAbsolute(path.join(...(isMonorepo ? absolutePathSegments : process.cwd().split('/')), 'dist')) // this can occur when a symbol from a dependency is exported, if this is // the case do not try to write a `typedoc-urls.json` file - if (sources[0].fullFileName.includes('node_modules')) { + if (source.fullFileName.includes('node_modules')) { outputDir = undefined } diff --git a/src/docs/typedoc-plugin.cjs b/src/docs/typedoc-plugin.js similarity index 83% rename from src/docs/typedoc-plugin.cjs rename to src/docs/typedoc-plugin.js index e784b78af..5d966fd84 100644 --- a/src/docs/typedoc-plugin.cjs +++ b/src/docs/typedoc-plugin.js @@ -1,11 +1,11 @@ -const { Converter } = require('typedoc') -const path = require('path') -const fs = require('fs') +import fs from 'fs' +import path from 'path' +import { Converter } from 'typedoc' /** * @param {import("typedoc/dist/lib/application").Application} Application */ -const plugin = function (Application) { +export function load (Application) { const app = Application.owner const pkg = path.join(process.cwd(), 'package.json') /** @type {any} */ @@ -23,7 +23,6 @@ const plugin = function (Application) { * @param {import("typescript").Node} node */ const cb = (context, reflection, node) => { - if (pkgJson && reflection.name === 'export=') { let name if (node) { @@ -36,7 +35,3 @@ const plugin = function (Application) { app.converter.on(Converter.EVENT_CREATE_DECLARATION, cb) } - -module.exports = { - load: plugin -} diff --git a/src/docs/unknown-symbol-resolver-plugin.cjs b/src/docs/unknown-symbol-resolver-plugin.js similarity index 59% rename from src/docs/unknown-symbol-resolver-plugin.cjs rename to src/docs/unknown-symbol-resolver-plugin.js index a9bed8e6d..d3b21ab75 100644 --- a/src/docs/unknown-symbol-resolver-plugin.cjs +++ b/src/docs/unknown-symbol-resolver-plugin.js @@ -1,5 +1,5 @@ -const fs = require('fs') -const path = require('path') +import fs from 'fs' +import path from 'path' /** @type {Record>} */ const knownSymbols = { @@ -8,10 +8,10 @@ const knownSymbols = { 'Chai.Assertion': 'https://www.chaijs.com/api/assert/' }, '@types/node': { - 'EventEmitter': 'https://nodejs.org/dist/latest-v19.x/docs/api/events.html#class-eventemitter', - 'Server': 'https://nodejs.org/dist/latest-v19.x/docs/api/net.html#class-netserver', - 'IncomingMessage': 'https://nodejs.org/dist/latest-v19.x/docs/api/http.html#class-httpincomingmessage', - 'ServerResponse': 'https://nodejs.org/dist/latest-v19.x/docs/api/http.html#class-httpserverresponse', + EventEmitter: 'https://nodejs.org/dist/latest-v19.x/docs/api/events.html#class-eventemitter', + Server: 'https://nodejs.org/dist/latest-v19.x/docs/api/net.html#class-netserver', + IncomingMessage: 'https://nodejs.org/dist/latest-v19.x/docs/api/http.html#class-httpincomingmessage', + ServerResponse: 'https://nodejs.org/dist/latest-v19.x/docs/api/http.html#class-httpserverresponse', 'global.NodeJS.ReadStream': 'https://nodejs.org/dist/latest-v19.x/docs/api/tty.html#class-ttyreadstream', 'global.NodeJS.WriteStream': 'https://nodejs.org/dist/latest-v19.x/docs/api/tty.html#class-ttywritestream', 'global.NodeJS.ProcessEnv': 'https://nodejs.org/dist/latest-v19.x/docs/api/process.html#processenv', @@ -20,8 +20,8 @@ const knownSymbols = { 'internal.Transform': 'https://nodejs.org/dist/latest-v19.x/docs/api/stream.html#class-streamtransform', 'internal.Writable': 'https://nodejs.org/dist/latest-v19.x/docs/api/stream.html#class-streamwritable' }, - 'esbuild': { - 'BuildOptions': 'https://esbuild.github.io/api/#build-api' + esbuild: { + BuildOptions: 'https://esbuild.github.io/api/#build-api' } } @@ -37,43 +37,39 @@ const ignoreModules = [ * * @param {import("typedoc/dist/lib/application").Application} Application */ -function load(Application) { +export function load (Application) { Application.converter.addUnknownSymbolResolver((ref) => { - const moduleName = ref.moduleSource - const symbolName = calculateName(ref.symbolReference?.path) + const moduleName = ref.moduleSource + const symbolName = calculateName(ref.symbolReference?.path) - if (moduleName == null || symbolName == null) { - // can't resolve symbol - return - } - - if (ignoreModules.includes(moduleName)) { - return - } + if (moduleName == null || symbolName == null) { + // can't resolve symbol + return + } - const moduleDocs = knownSymbols[moduleName] + if (ignoreModules.includes(moduleName)) { + return + } - // do we know about this module - if (moduleDocs != null && moduleDocs[symbolName] != null) { - return moduleDocs[symbolName] - } + const moduleDocs = knownSymbols[moduleName] - // try to load docs from package.json - if the manifest declares a - // `docs` key use that to look up links to typedocs - const typedocs = loadTypedocUrls(moduleName) + // do we know about this module + if (moduleDocs != null && moduleDocs[symbolName] != null) { + return moduleDocs[symbolName] + } - if (typedocs[symbolName] != null) { - return typedocs[symbolName] - } + // try to load docs from package.json - if the manifest declares a + // `docs` key use that to look up links to typedocs + const typedocs = loadTypedocUrls(moduleName) - Application.logger.warn(`Unknown symbol ${symbolName} from module ${moduleName}`) + if (typedocs[symbolName] != null) { + return typedocs[symbolName] + } - return `https://www.npmjs.com/package/${moduleName}` - }) -} + Application.logger.warn(`Unknown symbol ${symbolName} from module ${moduleName}`) -module.exports = { - load + return `https://www.npmjs.com/package/${moduleName}` + }) } /** diff --git a/src/utils.js b/src/utils.js index de37374cf..9e5334474 100644 --- a/src/utils.js +++ b/src/utils.js @@ -362,16 +362,16 @@ export async function everyMonorepoProject (projectDir, fn) { * @param {string} projectDir * @param {string[]} workspaces */ -async function parseProjects (projectDir, workspaces) { +export function parseProjects (projectDir, workspaces) { /** @type {Record} */ const projects = {} for (const workspace of workspaces) { - for await (const subProjectDir of glob('.', workspace, { + for (const subProjectDir of glob('.', workspace, { cwd: projectDir, absolute: true })) { - const stat = await fs.stat(subProjectDir) + const stat = fs.statSync(subProjectDir) if (!stat.isDirectory()) { continue @@ -471,21 +471,21 @@ function checkForCircularDependencies (projects) { * @property {boolean} [absolute] If true produces absolute paths (default: false) * @property {boolean} [nodir] If true yields file paths and skip directories (default: false) * - * Async iterable filename pattern matcher + * Iterable filename pattern matcher * * @param {string} dir * @param {string} pattern * @param {GlobOptions & import('minimatch').MinimatchOptions} [options] - * @returns {AsyncGenerator} + * @returns {Generator} */ -export async function * glob (dir, pattern, options = {}) { +export function * glob (dir, pattern, options = {}) { const absoluteDir = path.resolve(dir) const relativeDir = path.relative(options.cwd ?? process.cwd(), dir) - const stats = await fs.stat(absoluteDir) + const stats = fs.statSync(absoluteDir) if (stats.isDirectory()) { - for await (const entry of _glob(absoluteDir, '', pattern, options)) { + for (const entry of _glob(absoluteDir, '', pattern, options)) { yield entry } @@ -502,10 +502,30 @@ export async function * glob (dir, pattern, options = {}) { * @param {string} dir * @param {string} pattern * @param {GlobOptions & import('minimatch').MinimatchOptions} options - * @returns {AsyncGenerator} + * @returns {Generator} */ -async function * _glob (base, dir, pattern, options) { - for await (const entry of await fs.opendir(path.join(base, dir))) { +function * _glob (base, dir, pattern, options) { + const p = path.join(base, dir) + + if (!fs.existsSync(p)) { + return + } + + const stats = fs.statSync(p) + + if (!stats.isDirectory()) { + return + } + + const d = fs.opendirSync(p) + + while (true) { + const entry = d.readSync() + + if (entry == null) { + break + } + const relativeEntryPath = path.join(dir, entry.name) const absoluteEntryPath = path.join(base, dir, entry.name) diff --git a/test/fixtures/js+ts/tsconfig.json b/test/fixtures/js+ts/tsconfig.json index 94fff3042..ac19351e4 100644 --- a/test/fixtures/js+ts/tsconfig.json +++ b/test/fixtures/js+ts/tsconfig.json @@ -27,7 +27,7 @@ "noUnusedLocals": true, "noUnusedParameters": false, // advanced - "importsNotUsedAsValues": "error", + "verbatimModuleSyntax": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "stripInternal": true, diff --git a/test/fixtures/projects/a-monorepo/packages/a-workspace-project/package.json b/test/fixtures/projects/a-monorepo/packages/a-workspace-project/package.json index 1f998e586..c6f6dbc04 100644 --- a/test/fixtures/projects/a-monorepo/packages/a-workspace-project/package.json +++ b/test/fixtures/projects/a-monorepo/packages/a-workspace-project/package.json @@ -10,8 +10,5 @@ }, "type": "module", "author": "", - "license": "ISC", - "typedoc": { - "entryPoint": "./src/index.js" - } + "license": "ISC" } diff --git a/test/fixtures/projects/a-monorepo/packages/a-workspace-project/src/types.ts b/test/fixtures/projects/a-monorepo/packages/a-workspace-project/src/types.ts index 2b2ea6dc5..a0f8b6be4 100644 --- a/test/fixtures/projects/a-monorepo/packages/a-workspace-project/src/types.ts +++ b/test/fixtures/projects/a-monorepo/packages/a-workspace-project/src/types.ts @@ -1,4 +1,3 @@ - export interface ExportedButNotInExports { aMethod: () => void } diff --git a/test/fixtures/projects/a-monorepo/packages/a-workspace-project/tsconfig.json b/test/fixtures/projects/a-monorepo/packages/a-workspace-project/tsconfig.json index 4c965e69f..6ddff411a 100644 --- a/test/fixtures/projects/a-monorepo/packages/a-workspace-project/tsconfig.json +++ b/test/fixtures/projects/a-monorepo/packages/a-workspace-project/tsconfig.json @@ -27,7 +27,7 @@ "noUnusedLocals": true, "noUnusedParameters": false, // advanced - "importsNotUsedAsValues": "error", + "verbatimModuleSyntax": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "stripInternal": true, diff --git a/test/fixtures/projects/a-monorepo/packages/a-workspace-project/typedoc.json b/test/fixtures/projects/a-monorepo/packages/a-workspace-project/typedoc.json new file mode 100644 index 000000000..c7d830493 --- /dev/null +++ b/test/fixtures/projects/a-monorepo/packages/a-workspace-project/typedoc.json @@ -0,0 +1,3 @@ +{ + "entryPoints": ["./src/index.js"] +} \ No newline at end of file diff --git a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/package.json b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/package.json index 96d160f47..0cd372fcb 100644 --- a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/package.json +++ b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/package.json @@ -10,8 +10,5 @@ }, "type": "module", "author": "", - "license": "ISC", - "typedoc": { - "entryPoint": "./src/index.js" - } + "license": "ISC" } diff --git a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/dir/index.js b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/dir/index.js new file mode 100644 index 000000000..50c309ccb --- /dev/null +++ b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/dir/index.js @@ -0,0 +1,7 @@ +/** + * @param {string} arg + * @returns {boolean} + */ +export function garply (arg) { + return true +} diff --git a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/index.js b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/index.js index 58dc564eb..7147f8a99 100644 --- a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/index.js +++ b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/index.js @@ -14,3 +14,5 @@ export const useHerp = () => { export const useDerp = () => { } + +export { garply } from './dir/index.js' diff --git a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/types.ts b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/types.ts index 2b2ea6dc5..a0f8b6be4 100644 --- a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/types.ts +++ b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/src/types.ts @@ -1,4 +1,3 @@ - export interface ExportedButNotInExports { aMethod: () => void } diff --git a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/tsconfig.json b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/tsconfig.json index 4c965e69f..6ddff411a 100644 --- a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/tsconfig.json +++ b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/tsconfig.json @@ -27,7 +27,7 @@ "noUnusedLocals": true, "noUnusedParameters": false, // advanced - "importsNotUsedAsValues": "error", + "verbatimModuleSyntax": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "stripInternal": true, diff --git a/test/fixtures/projects/a-monorepo/packages/another-workspace-project/typedoc.json b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/typedoc.json new file mode 100644 index 000000000..c7d830493 --- /dev/null +++ b/test/fixtures/projects/a-monorepo/packages/another-workspace-project/typedoc.json @@ -0,0 +1,3 @@ +{ + "entryPoints": ["./src/index.js"] +} \ No newline at end of file diff --git a/test/fixtures/projects/a-ts-project/src/a-module.ts b/test/fixtures/projects/a-ts-project/src/a-module.ts index e61412a0c..9213777e3 100644 --- a/test/fixtures/projects/a-ts-project/src/a-module.ts +++ b/test/fixtures/projects/a-ts-project/src/a-module.ts @@ -1,4 +1,3 @@ - export interface ExportedButNotInExports { aMethod: () => void } diff --git a/test/fixtures/projects/a-ts-project/src/dir/index.ts b/test/fixtures/projects/a-ts-project/src/dir/index.ts new file mode 100644 index 000000000..c2b642f2c --- /dev/null +++ b/test/fixtures/projects/a-ts-project/src/dir/index.ts @@ -0,0 +1,3 @@ +export function garply (arg: string): boolean { + return true +} diff --git a/test/fixtures/projects/a-ts-project/src/index.ts b/test/fixtures/projects/a-ts-project/src/index.ts index 029f1c3a9..68870c473 100644 --- a/test/fixtures/projects/a-ts-project/src/index.ts +++ b/test/fixtures/projects/a-ts-project/src/index.ts @@ -3,6 +3,8 @@ import derp from 'an-esm-dep' import type { UsedButNotExported } from './a-module.js' import type { EventEmitter } from 'events' +export { garply } from './dir/index.js' + export const useHerp = (): void => { herp() } diff --git a/test/fixtures/projects/a-ts-project/tsconfig.json b/test/fixtures/projects/a-ts-project/tsconfig.json index 94fff3042..ac19351e4 100644 --- a/test/fixtures/projects/a-ts-project/tsconfig.json +++ b/test/fixtures/projects/a-ts-project/tsconfig.json @@ -27,7 +27,7 @@ "noUnusedLocals": true, "noUnusedParameters": false, // advanced - "importsNotUsedAsValues": "error", + "verbatimModuleSyntax": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "stripInternal": true, diff --git a/test/fixtures/projects/an-esm-project/src/dir/index.js b/test/fixtures/projects/an-esm-project/src/dir/index.js new file mode 100644 index 000000000..50c309ccb --- /dev/null +++ b/test/fixtures/projects/an-esm-project/src/dir/index.js @@ -0,0 +1,7 @@ +/** + * @param {string} arg + * @returns {boolean} + */ +export function garply (arg) { + return true +} diff --git a/test/fixtures/projects/an-esm-project/src/index.js b/test/fixtures/projects/an-esm-project/src/index.js index 87284c643..b25f813e3 100644 --- a/test/fixtures/projects/an-esm-project/src/index.js +++ b/test/fixtures/projects/an-esm-project/src/index.js @@ -1,6 +1,8 @@ import herp from 'a-cjs-dep' import derp from 'an-esm-dep' +export { garply } from './dir/index.js' + /** * @typedef {import('./types').ExportedButNotInExports} ExportedButNotInExports */ diff --git a/test/fixtures/projects/an-esm-project/src/types.ts b/test/fixtures/projects/an-esm-project/src/types.ts index e61412a0c..9213777e3 100644 --- a/test/fixtures/projects/an-esm-project/src/types.ts +++ b/test/fixtures/projects/an-esm-project/src/types.ts @@ -1,4 +1,3 @@ - export interface ExportedButNotInExports { aMethod: () => void } diff --git a/test/fixtures/projects/an-esm-project/tsconfig.json b/test/fixtures/projects/an-esm-project/tsconfig.json index 4c965e69f..6ddff411a 100644 --- a/test/fixtures/projects/an-esm-project/tsconfig.json +++ b/test/fixtures/projects/an-esm-project/tsconfig.json @@ -27,7 +27,7 @@ "noUnusedLocals": true, "noUnusedParameters": false, // advanced - "importsNotUsedAsValues": "error", + "verbatimModuleSyntax": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, "stripInternal": true, From 4373c3806eccc4228844edf5d7360c8dd006d678 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 19 Jul 2023 13:08:15 +0000 Subject: [PATCH 11/11] chore(release): 40.0.0 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## [40.0.0](https://github.com/ipfs/aegir/compare/v39.0.13...v40.0.0) (2023-07-19) ### ⚠ BREAKING CHANGES * update typescript to `5.1.6, typedoc to `0.24.8` and eslint-config-ipfs to `5.0.0` ### Trivial Changes * Update .github/workflows/stale.yml [skip ci] ([48cc141](https://github.com/ipfs/aegir/commit/48cc1413972451fc58749b3cf4d91719d74e518c)) ### Dependencies * upgrade typescript and typedoc ([#1337](https://github.com/ipfs/aegir/issues/1337)) ([4ef4b62](https://github.com/ipfs/aegir/commit/4ef4b62f215316a24b58dac67c840c0dbd149d01)) --- CHANGELOG.md | 16 ++++++++++++++++ package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 721967555..a9fc00532 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## [40.0.0](https://github.com/ipfs/aegir/compare/v39.0.13...v40.0.0) (2023-07-19) + + +### ⚠ BREAKING CHANGES + +* update typescript to `5.1.6, typedoc to `0.24.8` and eslint-config-ipfs to `5.0.0` + +### Trivial Changes + +* Update .github/workflows/stale.yml [skip ci] ([48cc141](https://github.com/ipfs/aegir/commit/48cc1413972451fc58749b3cf4d91719d74e518c)) + + +### Dependencies + +* upgrade typescript and typedoc ([#1337](https://github.com/ipfs/aegir/issues/1337)) ([4ef4b62](https://github.com/ipfs/aegir/commit/4ef4b62f215316a24b58dac67c840c0dbd149d01)) + ## [39.0.13](https://github.com/ipfs/aegir/compare/v39.0.12...v39.0.13) (2023-06-28) diff --git a/package.json b/package.json index dbbda450f..4e0a7df24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aegir", - "version": "39.0.13", + "version": "40.0.0", "description": "JavaScript project management", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/aegir#readme",