Skip to content

Commit

Permalink
Upgrade some dependencies (#871)
Browse files Browse the repository at this point in the history
* Switch to NPM workspaces

* Add bun types for testing

* Remove some dependencies

* Cleanup code

* Upgrade esbuild

* Hardcode externals

They’re the same between the packages except for vscode but including an external that’s not ultimately required isn’t an error.

* Reorganize package json

* Replace TSDX with esbuild

* wip

* Simplify script

* Move esbuild into individual packages

* Bump vsce

* Fix packaging

* fixup

* Swap mri for minimist

It’s the same API but maintained

* Update lockfiles

* Add logs

* Bump version

* Update lockfile

* Add test for `extractClassNames`

* fix
  • Loading branch information
thecrypticace authored Oct 20, 2023
1 parent 3c0f17c commit 19cb859
Show file tree
Hide file tree
Showing 14 changed files with 13,353 additions and 71,564 deletions.
83 changes: 44 additions & 39 deletions .github/workflows/bump-version.mjs
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
import latestSemver from 'latest-semver'
import * as fs from 'fs/promises'
import assert from 'assert'
import PackageJson from '@npmcli/package-json'
import assert from 'node:assert'
import semver from 'semver'

async function bumpVersion() {
let res = await fetch(
'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery',
{
method: 'POST',
headers: {
accept: 'application/json;api-version=7.2-preview.1;excludeUrls=true',
'content-type': 'application/json',
let res = await fetch('https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery', {
method: 'POST',
headers: {
accept: 'application/json;api-version=7.2-preview.1;excludeUrls=true',
'content-type': 'application/json',
},
body: JSON.stringify({
assetTypes: null,
flags: 2151,
filters: [
{
criteria: [{ filterType: 7, value: 'bradlc.vscode-tailwindcss' }],
direction: 2,
pageSize: 100,
pageNumber: 1,
sortBy: 0,
sortOrder: 0,
pagingToken: null,
},
body: JSON.stringify({
assetTypes: null,
flags: 2151,
filters: [
{
criteria: [{ filterType: 7, value: 'bradlc.vscode-tailwindcss' }],
direction: 2,
pageSize: 100,
pageNumber: 1,
sortBy: 0,
sortOrder: 0,
pagingToken: null,
},
],
}),
}
)
let { results } = await res.json()
let versions = results[0].extensions[0].versions.map(({ version }) => version)
let latest = latestSemver(versions)
let parts = latest.split('.')
],
}),
})

assert(Number(parts[1]) % 2 === 1)
let { results } = await res.json()

let nextVersion = `${parts[0]}.${parts[1]}.${Number(parts[2]) + 1}`
let pkgFilename = 'packages/vscode-tailwindcss/package.json'
let pkg = JSON.parse(await fs.readFile(pkgFilename, 'utf8'))
await fs.writeFile(pkgFilename, JSON.stringify({ ...pkg, version: nextVersion }, null, 2), 'utf8')
}
/** @type {string[]} */
let versions = results[0].extensions[0].versions.map(({ version }) => version)

bumpVersion()
// Determine the latest version of the extension
let latest = versions
.map((v) => semver.parse(v, { includePrerelease: true, loose: false }))
.filter((v) => v !== null)
.filter((v) => v.prerelease.length === 0)
.sort((a, b) => b.compare(a) || b.compareBuild(a))
.at(0)

// Require the minor version to be odd. This is done because
// the VSCode Marketplace suggests using odd numbers for
// pre-release builds and even ones for release builds
assert(latest && latest.minor % 2 === 1)

// Bump the patch version in `package.json`
let nextVersion = latest.inc('patch').format()
let pkg = await PackageJson.load('packages/vscode-tailwindcss/package.json')
await pkg.update({ version: nextVersion }).save()
31 changes: 21 additions & 10 deletions esbuild.js → esbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
const esbuild = require('esbuild')
const path = require('path')
const fs = require('fs')
const mri = require('mri')
import esbuild from 'esbuild'
import fs from 'fs'
import { createRequire } from 'module'
import minimist from 'minimist'

const resolve = (...args) => path.resolve(__dirname, ...args)
const require = createRequire(import.meta.url)

const args = mri(process.argv.slice(2), {
const args = minimist(process.argv.slice(2), {
boolean: ['watch', 'minify'],
string: ['outfile', 'outdir', 'external'],
string: ['outfile', 'outdir'],
})

esbuild.build({
console.log('- Preparing')
let ctx = await esbuild.context({
entryPoints: args._,
bundle: true,
platform: 'node',
external: [].concat(args.external),
external: ['pnpapi', 'vscode', 'lightningcss', '@tailwindcss/oxide'],
format: 'cjs',
outdir: args.outdir,
outfile: args.outfile,
watch: args.watch,
minify: args.minify,
plugins: [
{
Expand Down Expand Up @@ -74,3 +74,14 @@ esbuild.build({
},
],
})

console.log('- Building')
await ctx.rebuild()

if (args.watch) {
console.log('- Watching')
await ctx.watch()
} else {
console.log('- Cleaning up')
await ctx.dispose()
}
4 changes: 0 additions & 4 deletions lerna.json

This file was deleted.

Loading

0 comments on commit 19cb859

Please sign in to comment.