diff --git a/packages/tools/README.md b/packages/tools/README.md index 1f5726d254..3b7f8ad36d 100644 --- a/packages/tools/README.md +++ b/packages/tools/README.md @@ -1,4 +1,14 @@ # tools for internal development use -- json-edit: A CLI tool to edit JSON files such as package.json in e2e tests -- json-sort: A CLI tool to sort JSON keys in a file +## Bins + +- json-edit: A CLI tool to edit JSON files such as package.json, used by the release workflow to stamp build versions + +## `tool` subcommands + +Run with `tool `: + +- sync-remote: Sync upstream dependency sources and catalog versions from `.upstream-versions.json` +- install-global-cli: Install the locally built `vp` global CLI into `~/.vite-plus` +- brand-vite: Apply Vite+ branding patches to the synced vite source (also runs at the end of sync-remote) +- local-npm-registry: Serve locally packed checkout packages behind a real registry HTTP interface for snapshot tests, ecosystem e2e, and local `vp migrate`/`vp create` iteration diff --git a/packages/tools/snap-tests/json-sort/array.json b/packages/tools/snap-tests/json-sort/array.json deleted file mode 100644 index c7522ca60d..0000000000 --- a/packages/tools/snap-tests/json-sort/array.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "name": "test", - "age": 18 - }, - { - "name": "abc", - "age": 20 - }, - { - "name": "def", - "age": 15 - }, - { - "name": "ghi", - "age": 18 - } -] diff --git a/packages/tools/snap-tests/json-sort/snap.txt b/packages/tools/snap-tests/json-sort/snap.txt deleted file mode 100644 index e8913e1bb5..0000000000 --- a/packages/tools/snap-tests/json-sort/snap.txt +++ /dev/null @@ -1,59 +0,0 @@ -> cat array.json # should show original array.json file -[ - { - "name": "test", - "age": 18 - }, - { - "name": "abc", - "age": 20 - }, - { - "name": "def", - "age": 15 - }, - { - "name": "ghi", - "age": 18 - } -] - -> tool json-sort array.json '_.name' && cat array.json # should sort array.json file by name -[ - { - "name": "abc", - "age": 20 - }, - { - "name": "def", - "age": 15 - }, - { - "name": "ghi", - "age": 18 - }, - { - "name": "test", - "age": 18 - } -] - -> tool json-sort array.json '_.age' && cat array.json # should sort array.json file by age -[ - { - "name": "def", - "age": 15 - }, - { - "name": "ghi", - "age": 18 - }, - { - "name": "test", - "age": 18 - }, - { - "name": "abc", - "age": 20 - } -] diff --git a/packages/tools/snap-tests/json-sort/steps.json b/packages/tools/snap-tests/json-sort/steps.json deleted file mode 100644 index 56950a4ad1..0000000000 --- a/packages/tools/snap-tests/json-sort/steps.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ignoredPlatforms": ["win32"], - "env": {}, - "commands": [ - "cat array.json # should show original array.json file", - "tool json-sort array.json '_.name' && cat array.json # should sort array.json file by name", - "tool json-sort array.json '_.age' && cat array.json # should sort array.json file by age" - ] -} diff --git a/packages/tools/snap-tests/replace-file-content/foo/example.toml b/packages/tools/snap-tests/replace-file-content/foo/example.toml deleted file mode 100644 index 08894361bc..0000000000 --- a/packages/tools/snap-tests/replace-file-content/foo/example.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "foo" -version = "0.0.0" -edition = "2024" - -[[bin]] -name = "vite" -path = "src/main.rs" - -[dependencies] -clap = { workspace = true, features = ["derive"] } -crossterm = { workspace = true } -napi = { workspace = true } -napi-derive = { workspace = true } diff --git a/packages/tools/snap-tests/replace-file-content/snap.txt b/packages/tools/snap-tests/replace-file-content/snap.txt deleted file mode 100644 index 7575397ed7..0000000000 --- a/packages/tools/snap-tests/replace-file-content/snap.txt +++ /dev/null @@ -1,31 +0,0 @@ -> cat foo/example.toml # should show original toml file -[package] -name = "foo" -version = "0.0.0" -edition = "2024" - -[[bin]] -name = "vite" -path = "src/main.rs" - -[dependencies] -clap = { workspace = true, features = ["derive"] } -crossterm = { workspace = true } -napi = { workspace = true } -napi-derive = { workspace = true } - -> tool replace-file-content foo/example.toml 'version = "0.0.0"' 'version = "1.0.0"' && cat foo/example.toml # should edit toml file -[package] -name = "foo" -version = "1.0.0" -edition = "2024" - -[[bin]] -name = "vite" -path = "src/main.rs" - -[dependencies] -clap = { workspace = true, features = ["derive"] } -crossterm = { workspace = true } -napi = { workspace = true } -napi-derive = { workspace = true } diff --git a/packages/tools/snap-tests/replace-file-content/steps.json b/packages/tools/snap-tests/replace-file-content/steps.json deleted file mode 100644 index a08732cdd6..0000000000 --- a/packages/tools/snap-tests/replace-file-content/steps.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "env": {}, - "commands": [ - "cat foo/example.toml # should show original toml file", - "tool replace-file-content foo/example.toml 'version = \"0.0.0\"' 'version = \"1.0.0\"' && cat foo/example.toml # should edit toml file" - ] -} diff --git a/packages/tools/src/index.ts b/packages/tools/src/index.ts index cde286f144..2eb8f417b3 100644 --- a/packages/tools/src/index.ts +++ b/packages/tools/src/index.ts @@ -1,18 +1,10 @@ const subcommand = process.argv[2]; switch (subcommand) { - case 'replace-file-content': - const { replaceFileContent } = await import('./replace-file-content.ts'); - replaceFileContent(); - break; case 'sync-remote': const { syncRemote } = await import('./sync-remote-deps.ts'); await syncRemote(); break; - case 'json-sort': - const { jsonSort } = await import('./json-sort.ts'); - jsonSort(); - break; case 'install-global-cli': const { installGlobalCli } = await import('./install-global-cli.ts'); installGlobalCli(); @@ -37,7 +29,7 @@ switch (subcommand) { default: console.error(`Unknown subcommand: ${subcommand}`); console.error( - 'Available subcommands: replace-file-content, sync-remote, json-sort, install-global-cli, brand-vite, local-npm-registry', + 'Available subcommands: sync-remote, install-global-cli, brand-vite, local-npm-registry', ); process.exit(1); } diff --git a/packages/tools/src/json-sort.ts b/packages/tools/src/json-sort.ts deleted file mode 100755 index b96da2e098..0000000000 --- a/packages/tools/src/json-sort.ts +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env node - -import assert from 'node:assert'; -import { readFileSync, writeFileSync } from 'node:fs'; -import { parseArgs } from 'node:util'; - -export function jsonSort() { - const { positionals } = parseArgs({ - allowPositionals: true, - args: process.argv.slice(3), - }); - - const filename = positionals[0]; - const script = positionals[1]; - - if (!filename || !script) { - console.error('Usage: tool json-sort