Upgrade some dependencies (#871)
* 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` * fixmaster
parent
3c0f17cadd
commit
19cb859b5d
|
@ -1,11 +1,8 @@
|
|||
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',
|
||||
{
|
||||
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',
|
||||
|
@ -26,19 +23,27 @@ async function bumpVersion() {
|
|||
},
|
||||
],
|
||||
}),
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
let { results } = await res.json()
|
||||
|
||||
/** @type {string[]} */
|
||||
let versions = results[0].extensions[0].versions.map(({ version }) => version)
|
||||
let latest = latestSemver(versions)
|
||||
let parts = latest.split('.')
|
||||
|
||||
assert(Number(parts[1]) % 2 === 1)
|
||||
// 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)
|
||||
|
||||
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')
|
||||
}
|
||||
// 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)
|
||||
|
||||
bumpVersion()
|
||||
// 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()
|
||||
|
|
|
@ -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: [
|
||||
{
|
||||
|
@ -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()
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"version": "independent",
|
||||
"packages": ["packages/*"]
|
||||
}
|
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
|
@ -1,14 +1,16 @@
|
|||
{
|
||||
"name": "root",
|
||||
"name": "tailwindcss-intellisense",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"bootstrap": "lerna bootstrap --hoist",
|
||||
"clean": "find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
],
|
||||
"devDependencies": {
|
||||
"esbuild": "0.14.11",
|
||||
"latest-semver": "^4.0.0",
|
||||
"lerna": "^3.22.1",
|
||||
"mri": "1.2.0"
|
||||
"@npmcli/package-json": "^5.0.0",
|
||||
"semver": "^7.5.4"
|
||||
},
|
||||
"prettier": {
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"printWidth": 100
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,7 +14,7 @@
|
|||
"homepage": "https://github.com/tailwindlabs/tailwindcss-intellisense/tree/HEAD/packages/tailwindcss-language-server#readme",
|
||||
"scripts": {
|
||||
"build": "npm run clean && npm run _esbuild && npm run hashbang",
|
||||
"_esbuild": "node ../../esbuild.js src/server.ts --outfile=bin/tailwindcss-language-server --external=pnpapi --external=lightningcss --external=@tailwindcss/oxide --minify",
|
||||
"_esbuild": "node ../../esbuild.mjs src/server.ts --outfile=bin/tailwindcss-language-server --minify",
|
||||
"clean": "rimraf bin",
|
||||
"hashbang": "node scripts/hashbang.mjs",
|
||||
"create-notices-file": "node scripts/createNoticesFile.mjs",
|
||||
|
@ -42,6 +42,8 @@
|
|||
"@types/debounce": "1.2.0",
|
||||
"@types/node": "14.14.34",
|
||||
"@types/vscode": "1.65.0",
|
||||
"browserslist": "^4.22.1",
|
||||
"bun-types": "^1.0.6",
|
||||
"chokidar": "3.5.1",
|
||||
"color-name": "1.1.4",
|
||||
"culori": "0.20.1",
|
||||
|
@ -50,12 +52,14 @@
|
|||
"dlv": "1.1.3",
|
||||
"dset": "3.1.2",
|
||||
"enhanced-resolve-301": "0.0.1",
|
||||
"esbuild": "^0.19.5",
|
||||
"fast-glob": "3.2.4",
|
||||
"find-up": "5.0.0",
|
||||
"is-builtin-module": "3.2.1",
|
||||
"klona": "2.0.4",
|
||||
"license-checker": "25.0.1",
|
||||
"minimatch": "5.1.4",
|
||||
"minimist": "^1.2.8",
|
||||
"normalize-path": "3.0.0",
|
||||
"pkg-up": "3.1.0",
|
||||
"postcss": "8.4.31",
|
||||
|
@ -66,6 +70,7 @@
|
|||
"rimraf": "3.0.2",
|
||||
"stack-trace": "0.0.10",
|
||||
"tailwindcss": "3.3.0",
|
||||
"tailwindcss-language-service": "*",
|
||||
"typescript": "4.6.4",
|
||||
"vitest": "0.34.2",
|
||||
"vscode-css-languageservice": "6.2.9",
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/// <reference types="bun-types" />
|
||||
import { parse } from 'postcss'
|
||||
import extractClassNames from './extractClassNames'
|
||||
|
||||
test('ex: 1', async () => {
|
||||
let result = await extractClassNames(parse('.foo {}'))
|
||||
|
||||
expect(result.classNames).toHaveProperty('foo')
|
||||
expect(result.classNames['foo']).toEqual({
|
||||
__info: {
|
||||
__rule: true,
|
||||
__source: undefined,
|
||||
__pseudo: [],
|
||||
__scope: null,
|
||||
__context: [],
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('ex: 2', async () => {
|
||||
let result = await extractClassNames(parse('.foo.bar {}'))
|
||||
|
||||
expect(result.classNames).toHaveProperty('foo')
|
||||
expect(result.classNames).toHaveProperty('bar')
|
||||
expect(result.classNames['foo']).toEqual({
|
||||
__info: {
|
||||
__rule: true,
|
||||
__source: undefined,
|
||||
__pseudo: [],
|
||||
__scope: null,
|
||||
__context: [],
|
||||
},
|
||||
})
|
||||
expect(result.classNames['bar']).toEqual({
|
||||
__info: {
|
||||
__rule: true,
|
||||
__source: undefined,
|
||||
__pseudo: [],
|
||||
__scope: '.foo',
|
||||
__context: [],
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('ex: 3', async () => {
|
||||
let result = await extractClassNames(parse('.foo:where(.bar:is(.baz:has(> .klass))) {}'))
|
||||
|
||||
expect(result.classNames).toHaveProperty('foo')
|
||||
expect(result.classNames).not.toHaveProperty('bar')
|
||||
expect(result.classNames).not.toHaveProperty('baz')
|
||||
expect(result.classNames).not.toHaveProperty('klass')
|
||||
expect(result.classNames['foo']).toEqual({
|
||||
__info: {
|
||||
__rule: true,
|
||||
__source: undefined,
|
||||
__pseudo: [':where(.bar:is(.baz:has(> .klass)))'],
|
||||
__scope: null,
|
||||
__context: [],
|
||||
},
|
||||
})
|
||||
})
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "v2",
|
||||
"name": "v2-jit",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,16 +7,14 @@
|
|||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"start": "tsdx watch",
|
||||
"build": "tsdx build",
|
||||
"test": "tsdx test",
|
||||
"lint": "tsdx lint",
|
||||
"start": "node ./scripts/build.mjs --watch",
|
||||
"build": "node ./scripts/build.mjs",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@csstools/media-query-list-parser": "2.0.4",
|
||||
"@csstools/css-parser-algorithms": "2.1.1",
|
||||
"@csstools/css-tokenizer": "2.1.1",
|
||||
"@csstools/media-query-list-parser": "2.0.4",
|
||||
"@types/culori": "^2.0.0",
|
||||
"@types/moo": "0.5.3",
|
||||
"@types/semver": "7.3.10",
|
||||
|
@ -41,8 +39,8 @@
|
|||
"vscode-languageserver-textdocument": "1.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.19.5",
|
||||
"prettier": "2.3.0",
|
||||
"tsdx": "0.14.1",
|
||||
"tslib": "2.2.0",
|
||||
"typescript": "4.6.4"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
import esbuild from 'esbuild'
|
||||
import path from 'node:path'
|
||||
import minimist from 'minimist'
|
||||
|
||||
const __dirname = new URL('.', import.meta.url).pathname
|
||||
|
||||
const args = minimist(process.argv.slice(2), {
|
||||
boolean: ['watch', 'minify'],
|
||||
})
|
||||
|
||||
console.log('- Preparing')
|
||||
let builds = await Promise.all([
|
||||
esbuild.context({
|
||||
entryPoints: [path.resolve(__dirname, '../src/index.ts')],
|
||||
bundle: true,
|
||||
platform: 'node',
|
||||
external: [],
|
||||
outdir: 'dist',
|
||||
minify: args.minify,
|
||||
|
||||
format: 'cjs',
|
||||
}),
|
||||
|
||||
esbuild.context({
|
||||
entryPoints: [path.resolve(__dirname, '../src/index.ts')],
|
||||
bundle: true,
|
||||
platform: 'node',
|
||||
external: [],
|
||||
outdir: 'dist',
|
||||
minify: args.minify,
|
||||
|
||||
format: 'esm',
|
||||
}),
|
||||
])
|
||||
|
||||
console.log('- Building')
|
||||
await Promise.all(builds.map((build) => build.rebuild()))
|
||||
|
||||
if (args.watch) {
|
||||
console.log('- Watching')
|
||||
await Promise.all(builds.map((build) => build.watch()))
|
||||
} else {
|
||||
console.log('- Cleaning up')
|
||||
await Promise.all(builds.map((build) => build.dispose()))
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@
|
|||
"description": "Intelligent Tailwind CSS tooling for VS Code",
|
||||
"author": "Brad Cornes <hello@bradley.dev>",
|
||||
"license": "MIT",
|
||||
"version": "0.10.1",
|
||||
"version": "0.10.2",
|
||||
"homepage": "https://github.com/tailwindlabs/tailwindcss-intellisense",
|
||||
"bugs": {
|
||||
"url": "https://github.com/tailwindlabs/tailwindcss-intellisense/issues",
|
||||
|
@ -325,28 +325,31 @@
|
|||
}
|
||||
},
|
||||
"scripts": {
|
||||
"_esbuild": "node ../../esbuild.js src/extension.ts src/server.ts src/cssServer.ts --outdir=dist --external=pnpapi --external=vscode --external=lightningcss --external=@tailwindcss/oxide",
|
||||
"_esbuild": "node ../../esbuild.mjs src/extension.ts src/server.ts src/cssServer.ts --outdir=dist",
|
||||
"dev": "concurrently --raw --kill-others \"npm run watch\" \"npm run check -- --watch\"",
|
||||
"watch": "npm run clean && npm run _esbuild -- --watch",
|
||||
"build": "npm run check && npm run clean && npm run _esbuild -- --minify && move-file dist/server.js dist/tailwindServer.js && move-file dist/cssServer.js dist/tailwindModeServer.js",
|
||||
"package": "vsce package",
|
||||
"publish": "vsce publish",
|
||||
"package": "vsce package --no-dependencies",
|
||||
"publish": "vsce publish --no-dependencies",
|
||||
"copy:notices": "cp ../tailwindcss-language-server/ThirdPartyNotices.txt ./dist/ThirdPartyNotices.txt",
|
||||
"vscode:prepublish": "npm run build && npm run copy:notices",
|
||||
"clean": "rimraf dist",
|
||||
"check": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/language-server": "*",
|
||||
"@types/braces": "3.0.1",
|
||||
"@types/vscode": "1.65.0",
|
||||
"@vscode/vsce": "2.21.1",
|
||||
"braces": "3.0.2",
|
||||
"color-name": "1.1.4",
|
||||
"concurrently": "7.0.0",
|
||||
"esbuild": "^0.19.5",
|
||||
"minimatch": "5.1.4",
|
||||
"minimist": "^1.2.8",
|
||||
"move-file-cli": "3.0.0",
|
||||
"normalize-path": "3.0.0",
|
||||
"rimraf": "3.0.2",
|
||||
"vsce": "2.15.0",
|
||||
"vscode-languageclient": "8.0.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue