Skip to content

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
@netlify
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);
}

@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
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