Repository navigation
Description
Description
Description
Problem
Currently, when running third-party scaffolding CLIs (create-void, create-vue, create-vite, etc.) or custom generators via vp create, there is no official, reliable way for the templates to determine whether they were invoked via vp create or directly on their own (such as via pnpm create <pkg> or npm create <pkg>).
While Vite+ sets several environment variables for child processes, none of them are sufficient for identifying vp create.
VP_USER_AGENT=vp/<version>(feat(cli): advertise VP_USER_AGENT to child processes #1958): This is set commonly across allvp/vpr/vpxsubcommands and does not include the subcommand name, making it impossible to distinguish betweenvp createandvp dlx/vp exec/vp run.VP_PACKAGE_MANAGER(packages/cli/src/create/templates/remote.ts): This is an internal implementation detail used to pass the package manager selection tovp dlx, and is not an official contract for detection purposes.VP_CREATE_INTERACTIVE(packages/cli/src/create/discovery.ts): This is only set for local Bingo generators.
As a result, templates are forced to rely on heuristics that depend on internal implementation details, such as checking a combination of VP_USER_AGENT and VP_PACKAGE_MANAGER, which makes them fragile.
Use Cases and Motivation
By providing VP_CREATE=1 as a public contract, templates and initializers can safely optimize behaviors such as:
- Default Toolchain Selection:
In initializers that support multiple toolchains (Vite / Vite+, etc.), whenVP_CREATE=1is present, they can default to Vite+ configurations unless an explicit flag is provided (e.g.,--toolchain vite). - Avoiding Redundant Post-Scaffold Processing:
IfVP_CREATE=1is detected, templates can suppress redundantinstallexecutions, writing conflicting package manager configurations, duplicate prompts, and misleading completion messages. - Consistency Across All Template Types:
A unified execution context determination becomes possible across built-in templates, bundled templates, local generators, and remote (create-*) templates.
If consensus is reached, I would like to submit a pull request to implement this feature.
Suggested solution
Proposed Specification
When vp create executes a template or generator command, it sets the environment variable VP_CREATE=1 for the child process.
- Target: All template / generator processes launched from
vp create(builtin,bundled,generator, andremote) - Value:
'1'(conforming to the naming and value conventions of existing variables such asVP_FORCE_MIGRATE=1,VP_SKIP_INSTALL=1, andVP_CLI_TEST=1) - Even if
VP_CREATEis already set in the parent process, it is explicitly set to'1'within the execution context ofvp create.
Implementation Direction
Add VP_CREATE: '1' to the base environment variables envs constructed within discoverTemplate() in packages/cli/src/create/discovery.ts.
Alternative
No response
Additional context
No response
Validations
- Read the Contributing Guidelines.
- Confirm this request is for Vite+ itself and not for Vite, Vitest, tsdown, Rolldown, or Oxc.
- Check that there isn't already an issue requesting the same feature.
Metadata
Metadata
Assignees
Type
Fields
Priority
Start date
Target date
Effort
Activity
voidzero-bot commentedon Nov 27, 2026
feat(create)), not a bug report, so there is no incorrect behavior to reproduce. The feature's factual premise was nevertheless empirically confirmed: noVP_CREATEvariable reaches template child processes on currentmain.vp createconfirmed the described gap.VP_USER_AGENTplusVP_PACKAGE_MANAGER) currently work as a fragile workaround, so there is no urgent user-facing breakage.vp createnever setsVP_CREATEfor template/generator child processes in any template type (builtin,bundled,generator, orremote), which matches the issue's analysis exactly. The base environment for all template types is built in one place —discoverTemplate()inpackages/cli/src/create/discovery.ts(currently{ ...process.env }plus aPATHprepend) — and none of the existingVP_*variables is a reliablevp create-specific signal:VP_USER_AGENTis identical across allvpsubcommands,VP_PACKAGE_MANAGERis an internal handoff tovp dlx,VP_CREATE_INTERACTIVEonly covers local Bingo generators, andVP_RAW_SUBCOMMANDonly exists when the global Rust CLI delegates (it is absent when the local JS CLI runs directly, e.g. vianpx vite-plus).I wasn't able to find a fix, but I identified some areas that may be relevant. The single
envsconstruction point indiscoverTemplate()(packages/cli/src/create/discovery.ts) is exactly where the requestedVP_CREATE: '1'would need to be added to cover all four template types, andpackages/cli/src/create/templates/remote.tslayers extras (likeVP_PACKAGE_MANAGER) on top of those base envs.packages/cli/src/create/__tests__/discovery.spec.ts(which already assertsVP_CREATE_INTERACTIVE) is the natural place for coverage.Full Triage Report
Triage Report — Issue #3589
Title: feat(create): set
VP_CREATE=1when running templates and generatorsAuthor: yuikisaito
Issue type: Feature request (label:
pending triage, requested asfeat(create))Step: reproduce
Date: 2026-11-27
1. Issue Summary
The reporter requests that
vp createexportVP_CREATE=1to every template / generator child process (builtin,bundled,generator/bingo, andremote/create-*), so templates can reliably detect that they were invoked throughvp create(as opposed topnpm create,npm create,vp dlx, etc.). They claim that no existing variable serves this purpose today, and propose addingVP_CREATE: '1'to the baseenvsbuilt indiscoverTemplate()inpackages/cli/src/create/discovery.ts.Expected (requested) behavior: template/generator child processes see
VP_CREATE=1in their environment.Actual behavior (claimed): no
VP_CREATEvariable is set; the availableVP_*variables (VP_USER_AGENT,VP_PACKAGE_MANAGER,VP_CREATE_INTERACTIVE) are either common to allvpsubcommands, internal implementation details, or only set for local Bingo generators.2. Environment
/home/runner/work/vite-plus/vite-plus(branchtriagebot/fix-3589)vp(global Rust CLI on PATH): v1.8.0, localvite-plusv1.8.0 (vite 8.3.8, rolldown 1.2.19, vitest 5.1.1, tsrs 7.1.0-beta.tsrs5)3. Source Inspection
grep -rn "VP_CREATE"overpackages/cli/srcandcrates/: the onlyVP_CREATE*matches areVP_CREATE_INTERACTIVE(set only for local Bingo generators,packages/cli/src/create/discovery.ts:192). NoVP_CREATEis set anywhere.discoverTemplate()(packages/cli/src/create/discovery.ts:95-103) builds the baseenvsas{ ...process.env }plus the download package-manager bin prefix prepended toPATH(prependToPathToEnvs), then returns it unchanged forbuiltin,bundled, GitHub/degit-remote, local (node-run) and npm-remotetemplate types. Confirms the reporter's implementation analysis: adding the variable there would cover all four types.packages/cli/src/create/templates/remote.ts:88-93: remotecreate-*templates additionally receiveVP_PACKAGE_MANAGER— an internal handoff tovp dlx(not a detection contract, exactly as the issue states).VP_RAW_SUBCOMMAND(crates/vp_global_cli/src/js_executor.rs:389) is set only by the global Rust CLI when delegating to the local JS CLI; it is an internal handoff variable, and it is absent when the localvite-plusJS CLI is invoked directly (package.json scripts /npx vite-plus). So even the observableVP_RAW_SUBCOMMAND=createis not a usable contract for templates.4. Reproduction
Reproduction path:
/tmp/vite-plus-triage/gh-3589/repro— a minimal monorepo with a local template package declared viacreate.templatesthat dumps allVP_*variables it sees.Files:
package.json({ "name": "gh-3589-repro", "private": true })pnpm-workspace.yaml(packages: ["tools/*"])vite.config.tswithcreate.templates: [{ name: 'env-probe', template: './tools/env-probe', description: 'prints VP_* env vars' }]tools/env-probe/package.json(bin: ./bin/probe.js)tools/env-probe/bin/probe.js— writes theVP_*subset ofprocess.envpluscwdto/tmp/vite-plus-triage/gh-3589/probe-result.jsonand prints it.Commands attempted
vp create env-probe --no-interactive(globalvpon PATH delegating to the local JS CLI) — template ran; probe output:{ "cwd": ".../repro/tools", "vp": { "VP_CLI_BIN": "~/.vite-plus/local-dev-.../bin/vp", "VP_PATH_INJECTED_TOOLS": "node", "VP_RAW_SUBCOMMAND": "create", "VP_USER_AGENT": "vp/1.8.0" } }No
VP_CREATEis present.vp createsubsequently failed with "Command exited with code 2" because the probe intentionally writes no scaffoldedpackage.json(project-dir detection fails) — expected for this probe and unrelated to the reported gap.Control 1 — same command through the local JS CLI directly (
node $VITE_PLUS_REPO/packages/cli/dist/bin.js create env-probe --no-interactive), i.e. the path taken by package.json scripts /npx vite-plus:{ "vp": { "VP_USER_AGENT": "vp/1.8.0" } }Confirms:
VP_USER_AGENTis generic (no subcommand info), and evenVP_RAW_SUBCOMMANDdisappears without the global CLI — so it cannot serve as a detection contract either.Control 2 — baseline:
node tools/env-probe/bin/probe.jswith novpinvolved:{ "vp": {} }(clean shell has noVP_*variables), ruling out that the observed variables come from the runner shell.5. Result
Not reproducible as a bug / skipped — this is a feature request (
not-actionablefor the reproduce stage per the triage skill: it is not a bug report but a well-specified new-functionality request).That said, the feature's factual premise was empirically confirmed on the current checkout: template/generator child processes launched by
vp createreceive noVP_CREATEvariable in any template type, and none of the existingVP_*variables provides a reliable, documentedvp create-specific signal:VP_USER_AGENTis set for allvpsubcommands (observed identical for the create run; no subcommand component),VP_RAW_SUBCOMMANDexists only when the global Rust CLI delegates (absent on the direct-JS-CLI path) and is an internal handoff,VP_PACKAGE_MANAGERis an internalvp dlxhandoff,VP_CREATE_INTERACTIVEonly covers local Bingo generators.6. Observations Useful for Diagnosis (no fix proposed here)
envsconstruction point for all template types is indiscoverTemplate()(packages/cli/src/create/discovery.ts), matching the issue's proposed implementation direction;remote.tsmerges extra vars on top of these baseenvs.packages/cli/src/create/__tests__/discovery.spec.ts(e.g.expect(templateInfo.envs.VP_CREATE_INTERACTIVE).toBe('1')) is the natural place to add coverage forVP_CREATE.'1'matchesVP_SKIP_INSTALL=1/VP_FORCE_MIGRATE=1/VP_CLI_TEST=1as stated in the issue.vite-plus(packages/cli), independent of the globalvpCLI.This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.
liangmiQwQ commentedon Nov 28, 2026
@yuikisaito Thanks for this suggestion!
When adding #1958, we actually have considered about that child processes can't determine whether it is
vp dlxorvp create. We eventually assumed that if users already usevp dlxto launch a template CLI, it's also most likely to create a Vite+ project. So we didn't introduce a separate mechanisms here.However, your use cases do make sense to me. Personally, I'm also exploring a
VP_COMMANDenv var, that makes users know which command is running when loading config. I haven't figured out an exact plan, but it would be great if this could cover your use cases as well.