Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate the version change of Express #1643

Merged
merged 4 commits into from
Oct 22, 2024

Conversation

bjohansebas
Copy link
Member

This script automates the process of changing the version number in the documentation, see #1504.

To ensure the workflow functions correctly, please review #1606

@bjohansebas bjohansebas requested a review from a team October 5, 2024 17:09
Copy link

netlify bot commented Oct 5, 2024

Deploy Preview for expressjscom-preview ready!

Name Link
🔨 Latest commit 3a82775
🔍 Latest deploy log https://app.netlify.com/sites/expressjscom-preview/deploys/670ec561e2df5f0008924649
😎 Deploy Preview https://deploy-preview-1643--expressjscom-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@UlisesGascon UlisesGascon requested a review from jonchurch October 6, 2024 14:34
Copy link
Member

@IamLizu IamLizu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bjohansebas 👋

Great job on automating this 💯, I am generally 👍 on this. However, would you be open to something like this? Perhaps we should make consistent use of await.

I have also added error-handling just to feel safe.

import { readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';

const NPMURL = 'https://registry.npmjs.org/express'

const response = await (await fetch(NPMURL)).json();
const { next, latest } = response['dist-tags']

try {
  const filePath = path.resolve(path.join('_data', 'express.yml'));
  let content = await readFile(filePath, 'utf8');
  
  content = content.replace(/current_version: ".*"/, `current_version: "${latest}"`);
  content = content.replace(/next_version: ".*"/, `next_version: "${next}"`);
  
  await writeFile(filePath, content, 'utf8');
} catch (error) {
  console.error('Error updating versions in _data/express.yml:', error);
}

get-express-version.mjs Outdated Show resolved Hide resolved
get-express-version.mjs Outdated Show resolved Hide resolved
get-express-version.mjs Outdated Show resolved Hide resolved
@bjohansebas bjohansebas force-pushed the create-version-script branch from 3d59273 to be5705f Compare October 15, 2024 19:18
@bjohansebas
Copy link
Member Author

Thanks @IamLizu for the suggestions.

@bjohansebas bjohansebas merged commit 2cde7b5 into expressjs:gh-pages Oct 22, 2024
9 checks passed
chrisdel101 pushed a commit to chrisdel101/expressjs.com that referenced this pull request Nov 3, 2024
* create get-express-version script

* improve script and catch error

* update title
@bjohansebas bjohansebas deleted the create-version-script branch November 19, 2024 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants