From f2ad87c88267218cea09888377ee78c8bc158706 Mon Sep 17 00:00:00 2001 From: Ante Budimir Date: Fri, 7 Mar 2025 11:10:27 +0200 Subject: [PATCH] =?UTF-8?q?feat=20=F0=9F=94=A8:=20add=20script=20for=20ver?= =?UTF-8?q?sioning=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 6 ++---- scripts/update-version.mjs | 33 +++++++++++++++++++++++++++++++++ src/index.ts | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 scripts/update-version.mjs diff --git a/package.json b/package.json index 41cd597..91bf912 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@antebudimir/eslint-plugin-vanilla-extract", - "version": "1.2.0", + "version": "1.3.0", "description": "ESLint plugin for enforcing CSS ordering in vanilla-extract styles", "author": "Ante Budimir", "license": "MIT", @@ -47,9 +47,7 @@ "prepublishOnly": "pnpm run lint && pnpm run build", "publish": "pnpm publish --access public", "typecheck": "tsc --noEmit", - "version:major": "pnpm version major --no-git-tag-version", - "version:minor": "pnpm version minor --no-git-tag-version", - "version:patch": "pnpm version patch --no-git-tag-version" + "version:update": "node scripts/update-version.mjs" }, "engines": { "node": ">=18.18.0" diff --git a/scripts/update-version.mjs b/scripts/update-version.mjs new file mode 100644 index 0000000..8de9074 --- /dev/null +++ b/scripts/update-version.mjs @@ -0,0 +1,33 @@ +import { execSync } from 'child_process'; +import { promises as fs } from 'fs'; +import path from 'path'; +import { argv, env } from 'process'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const packageJsonPath = path.resolve(__dirname, '../package.json'); +const indexTsPath = path.resolve(__dirname, '../src/index.ts'); + +const versionType = argv[2] || env.VERSION_TYPE; + +if (!['major', 'minor', 'patch'].includes(versionType)) { + console.error('Invalid version type. Use major, minor, or patch.'); + process.exit(1); +} + +execSync(`pnpm version ${versionType} --no-git-tag-version`, { stdio: 'inherit' }); + +const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8')); +const newVersion = packageJson.version; + +// Read src/index.ts +let indexTsContent = await fs.readFile(indexTsPath, 'utf-8'); + +// Replace the version string in src/index.ts +indexTsContent = indexTsContent.replace(/version: '(\d+\.\d+\.\d+)'/, `version: '${newVersion}'`); + +// Write the updated content back to src/index.ts +await fs.writeFile(indexTsPath, indexTsContent); + +console.log(`Updated src/index.ts to version ${newVersion}`); diff --git a/src/index.ts b/src/index.ts index 3cf2372..6c8a4df 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ import customOrderRule from './css-rules/custom-order/rule-definition.js'; export const vanillaExtract = { meta: { name: '@antebudimir/eslint-plugin-vanilla-extract', - version: '1.2.0', + version: '1.3.0', }, rules: { 'alphabetical-order': alphabeticalOrderRule,