style: lint

This commit is contained in:
Neko Ayaka
2026-08-26 19:49:58 +08:00
parent e60a04a4ec
commit 98f40d7d0b
1625 changed files with 75216 additions and 75203 deletions
@@ -2,40 +2,6 @@
import { readFile, writeFile } from 'node:fs/promises'
export async function packageJSONForVSCode(name: string) {
const json = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf-8'))
const originalName = json.name
const originalVersion = json.version
if (json.name !== name) {
json.name = name
await writeFile(new URL('../package.json', import.meta.url), `${JSON.stringify(json, null, 2)}\n`, 'utf-8')
}
const numericVersion = encodeNumericVersion(originalVersion)
if (json.version !== numericVersion.version) {
json.version = numericVersion.version
await writeFile(new URL('../package.json', import.meta.url), `${JSON.stringify(json, null, 2)}\n`, 'utf-8')
}
return {
json,
originalName,
originalVersion,
name,
version: numericVersion.version,
isPreview: numericVersion.preview,
restore: async () => {
json.name = originalName
json.version = originalVersion
await writeFile(new URL('../package.json', import.meta.url), `${JSON.stringify(json, null, 2)}\n`, 'utf-8')
},
}
}
// NOTICE: VSCE rejects prerelease identifiers, so we encode stage+sequence into a numeric-only patch bucket:
// encodedPatch = patch*10000 + stageBucket + sequence.
// stageBucket: alpha=1000, beta=2000, rc=3000, stable=9000.
@@ -62,7 +28,7 @@ export function encodeNumericVersion(version: string) {
stable: 9_000,
} as const
const { stage, sequence } = parsePrerelease(prerelease)
const { sequence, stage } = parsePrerelease(prerelease)
const maxSequence = (multiplier - 1) - stageBuckets[stage]
if (sequence > maxSequence) {
throw new Error(`Prerelease sequence overflow for ${stage}: ${sequence} exceeds limit ${maxSequence}`)
@@ -75,14 +41,48 @@ export function encodeNumericVersion(version: string) {
const encoded = `${major}.${minor}.${encodedPatch}`
return {
version: encoded,
preview: stage !== 'stable',
version: encoded,
}
}
export async function packageJSONForVSCode(name: string) {
const json = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf-8'))
const originalName = json.name
const originalVersion = json.version
if (json.name !== name) {
json.name = name
await writeFile(new URL('../package.json', import.meta.url), `${JSON.stringify(json, null, 2)}\n`, 'utf-8')
}
const numericVersion = encodeNumericVersion(originalVersion)
if (json.version !== numericVersion.version) {
json.version = numericVersion.version
await writeFile(new URL('../package.json', import.meta.url), `${JSON.stringify(json, null, 2)}\n`, 'utf-8')
}
return {
isPreview: numericVersion.preview,
json,
name,
originalName,
originalVersion,
restore: async () => {
json.name = originalName
json.version = originalVersion
await writeFile(new URL('../package.json', import.meta.url), `${JSON.stringify(json, null, 2)}\n`, 'utf-8')
},
version: numericVersion.version,
}
}
function parsePrerelease(prerelease?: string) {
if (!prerelease) {
return { stage: 'stable' as const, sequence: 0 }
return { sequence: 0, stage: 'stable' as const }
}
const [stageRaw, sequenceRaw] = prerelease.split('.')
@@ -90,5 +90,5 @@ function parsePrerelease(prerelease?: string) {
const sequenceParsed = Number.parseInt(sequenceRaw ?? '', 10)
const sequence = Number.isFinite(sequenceParsed) ? sequenceParsed : 0
return { stage, sequence }
return { sequence, stage }
}