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
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ VITE+ - The Unified Toolchain for the Web
• 5 config updates applied, 2 files had imports rewritten
• tsup config migrated to tsdown (`vp pack`)
→ Manual follow-up:
- Please manually merge packages/b/tsdown.config.ts into packages/b/vite.config.ts, see https://viteplus.dev/guide/migrate#tsdown
- Please manually merge packages/a/tsdown.config.ts into packages/a/vite.config.ts, see https://viteplus.dev/guide/migrate#tsdown
- Please manually merge packages/b/tsdown.config.ts into packages/b/vite.config.ts, see https://viteplus.dev/guide/migrate#tsdown
```

## `vpt stat-file packages/a/tsup.config.ts --assert-not file`
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,12 @@
"cross-spawn": "catalog:",
"detect-indent": "catalog:",
"detect-newline": "catalog:",
"glob": "catalog:",
"jsonc-parser": "catalog:",
"lint-staged": "catalog:",
"minimatch": "catalog:",
"nanotar": "catalog:",
"picocolors": "catalog:",
"tinyglobby": "catalog:",
"tsdown": "catalog:",
"validate-npm-package-name": "catalog:",
"verkit": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/__tests__/versions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { createRequire } from 'node:module';
import path from 'node:path';
import url from 'node:url';

import { globSync } from 'glob';
import { globSync } from 'tinyglobby';
import { describe, expect, it } from 'vitest';

const cliPkgDir = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '../..');
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/migration/__tests__/migrator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1494,7 +1494,7 @@ describe('migrateSetupVpVersion', () => {
it('updates exact v1 references in workflows and composite actions', () => {
const workflowsDir = path.join(tmpDir, '.github', 'workflows');
const actionDir = path.join(tmpDir, '.github', 'actions', 'setup');
fs.mkdirSync(path.join(workflowsDir, 'nested'), { recursive: true });
fs.mkdirSync(path.join(workflowsDir, 'nested.yml'), { recursive: true });
fs.mkdirSync(actionDir, { recursive: true });

const workflowPath = path.join(workflowsDir, 'ci.yml');
Expand All @@ -1517,7 +1517,7 @@ describe('migrateSetupVpVersion', () => {
actionPath,
'runs:\n using: composite\n steps:\n - uses : voidzero-dev/setup-vp@v1\n',
);
const nestedWorkflowPath = path.join(workflowsDir, 'nested', 'ignored.yml');
const nestedWorkflowPath = path.join(workflowsDir, 'nested.yml', 'ignored.yml');
fs.writeFileSync(nestedWorkflowPath, '- uses: voidzero-dev/setup-vp@v1\n');
const report = createMigrationReport();

Expand Down
7 changes: 4 additions & 3 deletions packages/cli/src/migration/migrator/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'node:fs';
import path from 'node:path';

import * as prompts from '@voidzero-dev/vite-plus-prompts';
import { globSync } from 'glob';
import { globSync } from 'tinyglobby';
import { normalize, normalizeRange } from 'verkit';
import { parse as parseYaml } from 'yaml';

Expand Down Expand Up @@ -149,8 +149,9 @@ function collectGithubActionFiles(projectPath: string): string[] {
const globOptions = {
cwd: path.join(projectPath, '.github'),
absolute: true,
nocase: true,
nodir: true,
caseSensitiveMatch: false,
Comment thread
liangmiQwQ marked this conversation as resolved.
// Otherwise a directory named like `ci.yml` also matches as `ci.yml/**`.
expandDirectories: false,
} as const;
const workflows = globSync('workflows/*.{yml,yaml}', globOptions);
const compositeActions = globSync('**/action.{yml,yaml}', {
Expand Down
17 changes: 12 additions & 5 deletions packages/cli/src/utils/__tests__/workspace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ describe('discoverWorkspacePackages', () => {
const names = packages.map((p) => p.name).toSorted();
expect(names).toEqual(['bar', 'foo']);
const foo = packages.find((p) => p.name === 'foo')!;
// pkg.path uses forward slashes on every platform (normalized from glob's
// native separators), so it compares cleanly against workspace patterns.
// pkg.path uses forward slashes on every platform, so it compares cleanly
// against workspace patterns.
expect(foo.path).toBe('packages/foo');
expect(foo.description).toBe('a foo');
expect(foo.version).toBe('1.0.0');
Expand All @@ -200,6 +200,13 @@ describe('discoverWorkspacePackages', () => {
const packages = discoverWorkspacePackages(['packages/*'], tmpDir);
expect(packages.map((p) => p.name)).toEqual(['a']);
});

it('skips packages excluded by negated patterns', () => {
writeJson(path.join(tmpDir, 'packages/a/package.json'), { name: 'a' });
writeJson(path.join(tmpDir, 'packages/excluded/package.json'), { name: 'excluded' });
const packages = discoverWorkspacePackages(['packages/*', '!packages/excluded'], tmpDir);
expect(packages.map((p) => p.name)).toEqual(['a']);
});
});

describe('updatePackageJsonWithDeps', () => {
Expand All @@ -222,14 +229,14 @@ describe('updatePackageJsonWithDeps', () => {
});

describe('findPackageJsonFilesFromPatterns', () => {
it('returns absolute paths for matching package.json files', () => {
it('returns absolute paths with forward slashes for matching package.json files', () => {
writeJson(path.join(tmpDir, 'packages/a/package.json'), { name: 'a' });
writeJson(path.join(tmpDir, 'packages/b/package.json'), { name: 'b' });
const result = findPackageJsonFilesFromPatterns(['packages/*'], tmpDir).toSorted();
expect(result).toEqual(
[
path.join(tmpDir, 'packages/a/package.json'),
path.join(tmpDir, 'packages/b/package.json'),
`${tmpDir.replaceAll('\\', '/')}/packages/a/package.json`,
`${tmpDir.replaceAll('\\', '/')}/packages/b/package.json`,
].toSorted(),
);
});
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/utils/workspace.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'node:fs';
import path from 'node:path';

import { globSync } from 'glob';
import { minimatch } from 'minimatch';
import { globSync } from 'tinyglobby';
import { Scalar, YAMLSeq } from 'yaml';

import { detectWorkspace as detectWorkspaceBinding } from '../../binding/index.js';
Expand Down Expand Up @@ -32,7 +32,7 @@ export function findPackageJsonFilesFromPatterns(patterns: string[], cwd: string
}
return globSync(
patterns.map((pattern) => `${pattern}/package.json`),
{ absolute: true, cwd },
{ absolute: true, cwd, expandDirectories: false },
);
}

Expand Down Expand Up @@ -134,6 +134,7 @@ export function discoverWorkspacePackages(
absolute: false,
cwd: rootDir,
ignore: ['**/node_modules/**'],
expandDirectories: false,
},
);
for (const packageJsonRelativePath of packageJsonRelativePaths) {
Expand All @@ -148,10 +149,9 @@ export function discoverWorkspacePackages(
}
packages.push({
name: pkg.name,
// glob returns native separators; normalize to forward slashes so the
// path compares cleanly against workspace-pattern-derived values like
// `parentDirs` on Windows (path.join accepts either separator).
path: path.dirname(packageJsonRelativePath).split(path.sep).join('/'),
// Keep tinyglobby's forward slashes so the path compares cleanly against
// workspace-pattern-derived values like `parentDirs` on Windows.
path: path.posix.dirname(packageJsonRelativePath),
description: pkg.description,
version: pkg.version,
});
Expand Down
9 changes: 6 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ catalog:
terser: ^5.44.1
tinybench: ^6.0.0
tinyexec: ^1.0.1
tinyglobby: ^0.2.15
tsdown: ^0.23.1
tsx: ^4.22.0
typescript: ^6.0.0
Expand Down
Loading