-
-
Notifications
You must be signed in to change notification settings - Fork 611
feat(auto-install)!: ESM only. Update Node and Rollup minimum versions #1936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
charliecreates
wants to merge
19
commits into
master
Choose a base branch
from
ai-1935-charlie-esm-update-of-auto-install
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
aa02b21
feat(auto-install)!: ESM only; tsc build; migrate tests to Vitest per…
CharlieHelps 1696370
chore(repo): regenerate pnpm lockfile via pnpm i
CharlieHelps 18b6809
test(auto-install): make yarn tests resilient to Corepack by pre-crea…
CharlieHelps 0ddefc2
test(auto-install): skip tests on Node <20.19 to align with engines; …
CharlieHelps 5d7540a
chore(repo): restore pnpm-lock.yaml to pre-change state
CharlieHelps 2e02b83
test(auto-install): dynamically import plugin and use fileURLToPath; …
CharlieHelps 562b002
chore(repo): restore pnpm-lock.yaml (lockfile v9) from 1696370
CharlieHelps ea6c46a
chore(auto-install): narrow Rollup peer range to ^4
CharlieHelps c969a11
test(auto-install): mirror alias package setup; map ~package to dist …
CharlieHelps 6f6c22c
chore(repo): restore pnpm-lock.yaml (v9) and keep fixture lockfiles l…
CharlieHelps 83671a6
test(auto-install): extend timeout and tune npm env for npm* tests to…
CharlieHelps 218488a
test(auto-install): scope npm env tweaks to test body and restore via…
CharlieHelps 4e8942a
refactor(auto-install): restore defaults pattern for option handling
CharlieHelps c0f09d3
test(auto-install): make npm/pnpm bare tests robust on Windows by usi…
CharlieHelps 655a13c
fix(auto-install): use 'pnpm add' for installing new deps
CharlieHelps 772aa32
refactor(auto-install): restore const defaults (incl. commands); allo…
CharlieHelps b211bee
refactor(auto-install): compute pkgFile after merge; keep defaults in…
CharlieHelps 64ea687
refactor(auto-install): derive validManagers from options.commands keys
CharlieHelps 2775eef
chore(auto-install): remove over-strict 'satisfies' on options; simpl…
CharlieHelps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import fs from 'node:fs'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| import del from 'del'; | ||
| import { it, afterAll } from 'vitest'; | ||
| import { rollup } from 'rollup'; | ||
| import nodeResolve from '@rollup/plugin-node-resolve'; | ||
|
|
||
| // Dynamically import the plugin within gated tests to avoid Node <20 execution | ||
|
|
||
| const DIR = fileURLToPath(new URL('.', import.meta.url)); | ||
| const cwd = path.join(DIR, 'fixtures/npm-bare'); | ||
| const file = path.join(cwd, 'output/bundle.js'); | ||
| const input = path.join(cwd, '../input.js'); | ||
| const pkgFile = path.join(cwd, 'package.json'); | ||
|
|
||
| // Helper to temporarily disable slow npm features during the test | ||
| function stubNpmQuietEnv() { | ||
| const keys = [ | ||
| 'npm_config_audit', | ||
| 'npm_config_fund', | ||
| 'npm_config_progress', | ||
| 'npm_config_update_notifier', | ||
| 'npm_config_loglevel' | ||
| ] as const; | ||
| const prev: Record<string, string | undefined> = {}; | ||
| for (const k of keys) prev[k] = process.env[k]; | ||
| process.env.npm_config_audit = 'false'; | ||
| process.env.npm_config_fund = 'false'; | ||
| process.env.npm_config_progress = 'false'; | ||
| process.env.npm_config_update_notifier = 'false'; | ||
| process.env.npm_config_loglevel = 'error'; | ||
| return () => { | ||
| for (const k of keys) { | ||
| const v = prev[k]; | ||
| if (v == null) delete (process.env as any)[k]; | ||
| else (process.env as any)[k] = v; | ||
| } | ||
| }; | ||
| } | ||
| const [NODE_MAJOR, NODE_MINOR] = process.versions.node.split('.').map(Number); | ||
| const RUN_ON_THIS_NODE = NODE_MAJOR > 20 || (NODE_MAJOR === 20 && NODE_MINOR >= 19); | ||
|
|
||
| // npm installs can be slower than pnpm/yarn on CI; allow extra time. | ||
| it.runIf(RUN_ON_THIS_NODE)( | ||
| 'npm, bare', | ||
| async () => { | ||
| const restoreEnv = stubNpmQuietEnv(); | ||
| const prevCwd = process.cwd(); | ||
| process.chdir(cwd); | ||
| try { | ||
| const { default: autoInstall } = await import('~package'); | ||
| const bundle = await rollup({ | ||
| input, | ||
| // @ts-expect-error - rollup() ignores output here but tests kept it historically | ||
| output: { file, format: 'es' }, | ||
| plugins: [autoInstall({ pkgFile, manager: 'npm' }), nodeResolve()] | ||
| }); | ||
| await bundle.close(); | ||
|
|
||
| const json = JSON.parse(fs.readFileSync(pkgFile, 'utf-8')); | ||
| if (!json.dependencies || !json.dependencies['node-noop']) { | ||
| throw new Error('Expected node-noop to be added to dependencies'); | ||
| } | ||
| } finally { | ||
| process.chdir(prevCwd); | ||
| restoreEnv(); | ||
| } | ||
| }, | ||
| 60000 | ||
| ); | ||
|
|
||
| afterAll(async () => { | ||
| await del(['node_modules', 'package.json', 'package-lock.json']); | ||
| }); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.