Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/execa-9.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Oct 11, 2024
2 parents 48d26c2 + 1521c8b commit 00c3267
Show file tree
Hide file tree
Showing 26 changed files with 617 additions and 266 deletions.
4 changes: 2 additions & 2 deletions .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export default {
'buffer',
'c8',
'conventional-changelog-conventionalcommits',
'electron-mocha-main',
'electron-mocha',
'mocha',
'npm-package-json-lint',
'nyc',
'path',
'playwright-test',
'react-native-test-runner',
'semantic-release',
'@anolilab/multi-semantic-release',
'semantic-release-monorepo',
'source-map-support',
'typedoc-plugin-mdn-links',
'typedoc-plugin-missing-exports',
Expand Down
210 changes: 190 additions & 20 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $ npm i aegir

### Browser `<script>` tag

Loading this module through a script tag will make it's exports available as `Aegir` in the global namespace.
Loading this module through a script tag will make its exports available as `Aegir` in the global namespace.

```html
<script src="https://unpkg.com/aegir/dist/index.min.js"></script>
Expand Down
6 changes: 5 additions & 1 deletion actions/docker-login/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ inputs:
docker-username:
description: 'Docker username'
required: false
docker-registry:
description: 'Docker registry'
default: 'ghcr.io'
required: false
runs:
using: composite
steps:
- run: |
if [[ -n "${{ inputs.docker-token }}" ]] && [[ -n "${{ inputs.docker-username }}" ]]; then
echo "${{ inputs.docker-token }}" | docker login -u "${{ inputs.docker-username }}" --password-stdin
echo "${{ inputs.docker-token }}" | docker login -u "${{ inputs.docker-username }}" --password-stdin ${{ inputs.docker-registry }}
fi
shell: bash
2 changes: 0 additions & 2 deletions md/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

Electron supports ESM but [electron-mocha does not](https://github.com/jprichardson/electron-mocha/pull/187). It's capable of supporting it in the main thread but since Chrome does not provide any way to intercept calls to `import` it's unlikely to work with the renderer thread for the foreseeable future.

We currently use a [fork of electron-mocha](https://www.npmjs.com/package/electron-mocha-main) that allows running ESM tests on the main thread but we have no support for running them on the renderer thread until the issues with Chrome and intercepting `import` above are resolved.

## Examples

TODO: List examples when merged (`ipfs-unixfs`, `uint8arrays`)
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aegir",
"version": "42.2.11",
"version": "44.1.2",
"description": "JavaScript project management",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/ipfs/aegir#readme",
Expand Down Expand Up @@ -222,25 +222,24 @@
"release": "node src/index.js release --no-bundle"
},
"dependencies": {
"@anolilab/multi-semantic-release": "^1.0.3",
"@electron/get": "^3.0.0",
"@polka/send-type": "^0.5.2",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^12.0.0",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^10.0.3",
"@semantic-release/github": "^11.0.0",
"@semantic-release/npm": "^12.0.0",
"@semantic-release/release-notes-generator": "^13.0.0",
"@semantic-release/release-notes-generator": "^14.0.0",
"@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": "^20.4.2",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"buffer": "^6.0.3",
"bytes": "^3.1.0",
"c8": "^9.0.0",
"c8": "^10.1.2",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"chai-bites": "^0.1.2",
Expand All @@ -250,19 +249,20 @@
"conventional-changelog-conventionalcommits": "^8.0.0",
"cors": "^2.8.5",
"depcheck": "^1.4.3",
"diff": "^5.1.0",
"electron-mocha-main": "^11.0.3",
"diff": "^7.0.0",
"electron-mocha": "^13.0.0",
"env-paths": "^3.0.0",
"esbuild": "^0.21.1",
"esbuild": "^0.24.0",
"eslint": "^8.31.0",
"eslint-config-ipfs": "^6.0.0",
"eslint-config-ipfs": "^7.0.0",
"eslint-plugin-etc": "^2.0.2",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-jsdoc": "^48.0.2",
"eslint-plugin-jsdoc": "^48.9.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"execa": "^9.1.0",
"extract-zip": "^2.0.1",
"fast-glob": "^3.3.2",
"fs-extra": "^11.1.0",
"gh-pages": "^6.0.0",
"globby": "^14.0.0",
Expand All @@ -283,10 +283,9 @@
"micromark-extension-gfm-strikethrough": "^2.0.0",
"micromark-extension-gfm-table": "^2.0.0",
"micromark-extension-gfm-task-list-item": "^2.0.1",
"fast-glob": "^3.3.2",
"mocha": "^10.0.0",
"npm-package-json-lint": "^7.0.0",
"nyc": "^15.1.0",
"npm-package-json-lint": "^8.0.0",
"nyc": "^17.0.0",
"p-map": "^7.0.1",
"p-queue": "^8.0.1",
"p-retry": "^6.0.0",
Expand All @@ -298,8 +297,9 @@
"proper-lockfile": "^4.1.2",
"react-native-test-runner": "^5.0.0",
"read-pkg-up": "^11.0.0",
"rimraf": "^5.0.0",
"semantic-release": "^23.0.0",
"rimraf": "^6.0.1",
"semantic-release": "^24.0.0",
"semantic-release-monorepo": "^8.0.2",
"semver": "^7.3.8",
"source-map-support": "^0.5.20",
"strip-bom": "^5.0.0",
Expand Down Expand Up @@ -331,7 +331,7 @@
"@types/semver": "^7.3.4",
"@types/strong-log-transformer": "^1.0.2",
"@types/yargs": "^17.0.0",
"electron": "^27.0.2",
"electron": "^32.2.0",
"uint8arrays": "^5.0.1",
"undici": "^6.2.1"
},
Expand Down
135 changes: 135 additions & 0 deletions src/align-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/* eslint-disable no-console */

import path from 'path'
import { execa } from 'execa'
import fs from 'fs-extra'
import Listr from 'listr'
import { calculateSiblingVersion } from './check-project/utils.js'
import { isMonorepoRoot, getSubprojectDirectories, pkg } from './utils.js'

/**
* @typedef {import("./types.js").GlobalOptions} GlobalOptions
* @typedef {import("./types.js").ReleaseOptions} ReleaseOptions
* @typedef {import("listr").ListrTaskWrapper} Task
*/

const tasks = new Listr([
{
title: 'align sibling dependency versions',
enabled: () => isMonorepoRoot(),
/**
* @param {GlobalOptions & ReleaseOptions} ctx
*/
task: async (ctx) => {
if (!process.env.CI) {
console.info('⚠ This run was not triggered in a known CI environment, running in dry-run mode.') // eslint-disable-line no-console
return
}

const rootDir = process.cwd()
const workspaces = pkg.workspaces

if (!workspaces || !Array.isArray(workspaces)) {
throw new Error('No monorepo workspaces found')
}

const {
siblingVersions,
packageDirs
} = await calculateSiblingVersions(rootDir, workspaces)

// check these dependency types for monorepo siblings
const dependencyTypes = [
'dependencies',
'devDependencies',
'peerDependencies',
'optionalDependencies'
]

// align the versions of siblings in each package
for (const packageDir of packageDirs) {
const manifestPath = path.join(packageDir, 'package.json')
const manifest = fs.readJSONSync(path.join(packageDir, 'package.json'))

console.info('check project', manifest.name)

for (const type of dependencyTypes) {
for (const [dep, version] of Object.entries(siblingVersions)) {
if (manifest[type] != null && manifest[type][dep] != null && manifest[type][dep] !== version) {
console.info('Update', type, dep, manifest[type][dep], '->', version) // eslint-disable-line no-console
manifest[type][dep] = version
}
}
}

fs.writeJSONSync(manifestPath, manifest, {
spaces: 2
})
}

// all done, commit changes and push to remote
const status = await execa('git', ['status', '--porcelain'], {
cwd: rootDir
})

if (status.stdout === '') {
// no changes, nothing to do
return
}

if (!process.env.CI) {
// do not push to remote repo if in dry-run mode
return
}

// When running on CI, set the commits author and commiter info and prevent the `git` CLI to prompt for username/password.
// Borrowed from `semantic-release`
process.env.GIT_AUTHOR_NAME = ctx.siblingDepUpdateName
process.env.GIT_AUTHOR_EMAIL = ctx.siblingDepUpdateEmail
process.env.GIT_COMMITTER_NAME = ctx.siblingDepUpdateName
process.env.GIT_COMMITTER_EMAIL = ctx.siblingDepUpdateEmail
process.env.GIT_ASKPASS = 'echo'
process.env.GIT_TERMINAL_PROMPT = '0'

console.info(`Commit with message "${ctx.siblingDepUpdateMessage}"`) // eslint-disable-line no-console

await execa('git', ['add', '-A'], {
cwd: rootDir
})
await execa('git', ['commit', '-m', ctx.siblingDepUpdateMessage], {
cwd: rootDir
})
console.info('Push to remote') // eslint-disable-line no-console
await execa('git', ['push'], {
cwd: rootDir
})
}
}
], { renderer: 'verbose' })

/**
* @param {string} rootDir
* @param {string[]} workspaces
*/
async function calculateSiblingVersions (rootDir, workspaces) {
const packageDirs = []

/** @type {Record<string, string>} */
const siblingVersions = {}

for (const subProjectDir of await getSubprojectDirectories(rootDir, workspaces)) {
const pkg = JSON.parse(fs.readFileSync(path.join(subProjectDir, 'package.json'), {
encoding: 'utf-8'
}))

siblingVersions[pkg.name] = calculateSiblingVersion(pkg.version)
packageDirs.push(subProjectDir)
}

return {
packageDirs,
siblingVersions
}
}

export default tasks
2 changes: 1 addition & 1 deletion src/check-project/check-monorepo-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export async function checkMonorepoReadme (projectDir, repoUrl, webRoot, default
apiDocs = parseMarkdown(APIDOCS(pkg))
}

const structure = parseMarkdown(STRUCTURE(projectDir, projectDirs))
const structure = parseMarkdown(STRUCTURE(projectDir, projectDirs, webRoot))

readme.children = [
...header,
Expand Down
Loading

0 comments on commit 00c3267

Please sign in to comment.