Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/deploy-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ inputs:
runs:
using: 'composite'
steps:
# docs/vite.config.ts uses the task cache format of this release. Once a
# release requires task cache settings under `cache`, remove this pin and
# the one in build-docs-fork-preview.yml, and update docs/vite.config.ts.
- uses: voidzero-dev/setup-vp@3754dd7dbdb32bd8f6d28b6043de13ad3a75f21f # v1.21.1
with:
version: 1.0.0-rc.0
cache: true
working-directory: docs
cache-dependency-path: docs/pnpm-lock.yaml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build-docs-fork-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ jobs:
# Build the same commit that workflow_run.head_sha identifies.
ref: ${{ github.event.pull_request.head.sha }}

# Keep in sync with the pin in .github/actions/deploy-docs/action.yml.
- uses: voidzero-dev/setup-vp@3754dd7dbdb32bd8f6d28b6043de13ad3a75f21f # v1.21.1
with:
version: 1.0.0-rc.0
working-directory: docs
cache: false

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'vite-plus';

const shared = { env: ['NODE_ENV'] };

export default defineConfig({
run: {
tasks: {
build: { ...shared, command: 'vp build', input: ['src/**'] },
dev: { command: 'vp dev', cache: false, env: ['PORT'] },
check: { command: 'vp check', env: ['CI'] },
},
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "migration-task-cache-fields",
"devDependencies": {
"vite-plus": "0.2.0"
},
"devEngines": {
"packageManager": {
"name": "npm",
"version": "11.16.0",
"onFail": "download"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[[case]]
name = "migration_task_cache_fields"
vp = "global"
comment = "Move task cache settings under cache on an existing Vite+ project without --full, then keep them on a second migration."
steps = [
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
]

[[case]]
name = "migration_task_cache_fields_manual"
vp = "global"
comment = "Warn about tasks whose cache settings cannot be moved safely, move the rest, and keep warning without migrating again."
steps = [
{ argv = ["vpt", "cp", "manual.config.txt", "vite.config.ts"], snapshot = false },
{ argv = ["vp", "migrate", "--no-interactive"] },
{ argv = ["vpt", "print-file", "vite.config.ts"] },
{ argv = ["vp", "migrate", "--no-interactive"] },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# migration_task_cache_fields

Move task cache settings under cache on an existing Vite+ project without --full, then keep them on a second migration.

## `vp migrate --no-interactive`

```
VITE+ - The Unified Toolchain for the Web

◇ Updated . to Vite+ <version>
• Node <version> npm <version>
• Dependencies:
vite-plus 0.2.0 → <version>
vite → <version>
• 1 config update applied
• Task cache settings moved under `cache`
• Package manager settings configured
```

## `vpt print-file vite.config.ts`

```
import { defineConfig } from 'vite-plus';

export default defineConfig({
run: {
tasks: {
build: {
command: 'vp build',
cache: {
// Rebuild when the deploy target changes.
env: ['DEPLOY_TARGET'],
untrackedEnv: ['CI'],
input: [{ auto: true }, '!dist/**'],
output: ['dist/**'], // restored on cache hits
},
},
typecheck: {
command: 'tsc --noEmit',
cache: {
env: ['TSC_MODE'],
},
},
lint: {
command: 'vp lint',
cache: {
env: ['LINT_LEVEL'],
input: ['src/**'],
},
},
},
},
});
```

## `vp migrate --no-interactive`

```
VITE+ - The Unified Toolchain for the Web

This project is already using Vite+! Happy coding!
```

## `vpt print-file vite.config.ts`

```
import { defineConfig } from 'vite-plus';

export default defineConfig({
run: {
tasks: {
build: {
command: 'vp build',
cache: {
// Rebuild when the deploy target changes.
env: ['DEPLOY_TARGET'],
untrackedEnv: ['CI'],
input: [{ auto: true }, '!dist/**'],
output: ['dist/**'], // restored on cache hits
},
},
typecheck: {
command: 'tsc --noEmit',
cache: {
env: ['TSC_MODE'],
},
},
lint: {
command: 'vp lint',
cache: {
env: ['LINT_LEVEL'],
input: ['src/**'],
},
},
},
},
});
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# migration_task_cache_fields_manual

Warn about tasks whose cache settings cannot be moved safely, move the rest, and keep warning without migrating again.

## `vpt cp manual.config.txt vite.config.ts`


## `vp migrate --no-interactive`

```
VITE+ - The Unified Toolchain for the Web

◇ Updated . to Vite+ <version>
• Node <version> npm <version>
• Dependencies:
vite-plus 0.2.0 → <version>
vite → <version>
• 1 config update applied
• Task cache settings moved under `cache`
• Package manager settings configured
! Warnings:
- vite.config.ts: Move `env`, `untrackedEnv`, `input`, and `output` under `cache` manually in tasks `build`, `dev`; they were left unchanged. See https://viteplus.dev/config/run#cache
```

## `vpt print-file vite.config.ts`

```
import { defineConfig } from 'vite-plus';

const shared = { env: ['NODE_ENV'] };

export default defineConfig({
run: {
tasks: {
build: { ...shared, command: 'vp build', input: ['src/**'] },
dev: { command: 'vp dev', cache: false, env: ['PORT'] },
check: { command: 'vp check', cache: { env: ['CI'] } },
},
},
});
```

## `vp migrate --no-interactive`

```
VITE+ - The Unified Toolchain for the Web

vite.config.ts: Move `env`, `untrackedEnv`, `input`, and `output` under `cache` manually in tasks `build`, `dev`; they were left unchanged. See https://viteplus.dev/config/run#cache
This project is already using Vite+! Happy coding!
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineConfig } from 'vite-plus';

export default defineConfig({
run: {
tasks: {
build: {
command: 'vp build',
// Rebuild when the deploy target changes.
env: ['DEPLOY_TARGET'],
untrackedEnv: ['CI'],
input: [{ auto: true }, '!dist/**'],
output: ['dist/**'], // restored on cache hits
},
typecheck: {
command: 'tsc --noEmit',
cache: true,
env: ['TSC_MODE'],
},
lint: {
command: 'vp lint',
cache: {
env: ['LINT_LEVEL'],
},
input: ['src/**'],
},
},
},
});
2 changes: 2 additions & 0 deletions crates/vp_migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod package;
mod prettier;
mod script_rewrite;
mod source_analysis;
mod task_cache;
mod vite_config;

pub use file_walker::{WalkResult, find_ts_files, is_directory_gitignored};
Expand All @@ -24,6 +25,7 @@ pub use import_rewriter::{
};
pub use package::{rewrite_eslint, rewrite_prettier, rewrite_scripts};
pub use source_analysis::analyze_migration_source;
pub use task_cache::{TaskCacheMigrationResult, migrate_task_cache_config};
pub use vite_config::{
MergeResult, has_config_key, merge_json_config, merge_tsdown_config, remove_config_key,
upsert_json_config, wrap_lazy_plugins,
Expand Down
Loading
Loading