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
6 changes: 6 additions & 0 deletions .github/actions/build-upstream/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ runs:
fi
pnpm --filter rolldown build-node
pnpm --filter rolldown-vite build-types
pnpm --filter=@voidzero-dev/vite-plus-core build
pnpm --filter=@voidzero-dev/vite-plus-test build
CC=clang pnpm --filter=@voidzero-dev/vite-plus build --target ${{ inputs.target }} --use-napi-cross
env:
TARGET_CC: clang
Expand All @@ -35,6 +37,8 @@ runs:
fi
pnpm --filter rolldown build-node
pnpm --filter rolldown-vite build-types
pnpm --filter=@voidzero-dev/vite-plus-core build
pnpm --filter=@voidzero-dev/vite-plus-test build
TARGET_CFLAGS="-D_BSD_SOURCE" pnpm --filter=@voidzero-dev/vite-plus build --target ${{ inputs.target }} --use-napi-cross
env:
TARGET_CC: clang
Expand All @@ -49,4 +53,6 @@ runs:
fi
pnpm --filter rolldown build-node
pnpm --filter rolldown-vite build-types
pnpm --filter=@voidzero-dev/vite-plus-core build
pnpm --filter=@voidzero-dev/vite-plus-test build
pnpm --filter=@voidzero-dev/vite-plus build --target ${{ inputs.target }}
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
run: |
echo "//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}" >> ~/.npmrc
echo "@voidzero-dev:registry=https://npm.pkg.github.com/" >> ~/.npmrc
export VERSION=$(npm view --json @voidzero-dev/vite-plus | jq -r '.version')
npm pack "@voidzero-dev/vite-plus@${VERSION}"
tar -xzf voidzero-dev-vite-plus-${VERSION}.tgz
export VERSION=$(npm view --json @voidzero-dev/vite-plus-core | jq -r '.version')
npm pack "@voidzero-dev/vite-plus-core@${VERSION}"
tar -xzf voidzero-dev-vite-plus-core-${VERSION}.tgz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Expand Down
32 changes: 27 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,16 @@ jobs:
if-no-files-found: error
- name: Remove .node files before upload dist
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
run: rm ./packages/cli/dist/**/*.node
run: |
rm ./packages/core/dist/**/*.node

- name: Upload core dist
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
with:
name: core
path: ./packages/core/dist
if-no-files-found: error

- name: Upload cli dist
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
Expand Down Expand Up @@ -133,13 +142,19 @@ jobs:

- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: packages/cli/dist
path: packages/cli/binding
pattern: vite-plus-native-*
merge-multiple: true

- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: packages/cli/dist/rolldown/shared
path: packages/core/dist
pattern: core
merge-multiple: true

- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: packages/core/dist/rolldown/shared
pattern: rolldown-native-*
merge-multiple: true

Expand All @@ -151,8 +166,10 @@ jobs:

- name: Set npm packages version
run: |
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/global/package.json
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/core/package.json
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/test/package.json
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/cli/package.json
sed -i 's/"version": "0.0.0"/"version": "0.0.0-${{ github.sha }}"/' packages/global/package.json

# Setup node correctly for publishing to github registry
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
Expand All @@ -162,11 +179,16 @@ jobs:
scope: '@voidzero-dev'
package-manager-cache: false

- name: Build test
run: pnpm --filter=@voidzero-dev/vite-plus-test build

- run: npm install -g npm@latest # For trusted publishing support

- name: Publish
run: |
pnpm publish --filter=./packages/global --registry https://npm.pkg.github.com --no-git-checks
pnpm publish --filter=./packages/core --registry https://npm.pkg.github.com --no-git-checks
pnpm publish --filter=./packages/test --registry https://npm.pkg.github.com --no-git-checks
pnpm publish --filter=./packages/cli --registry https://npm.pkg.github.com --no-git-checks
pnpm publish --filter=./packages/global --registry https://npm.pkg.github.com --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"ignorePatterns": [
"packages/cli/binding/index.d.ts",
"packages/cli/binding/index.js"
],
"singleQuote": true
}
32 changes: 20 additions & 12 deletions bench/generate-monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class MonorepoGenerator {
const hasVitePlusConfig = Math.random() > 0.3;

// Select dependencies from packages created before this one
const dependencies = i === 0 ? [] : this.selectDependencies(i, allPackageNames.slice(0, i));
const dependencies =
i === 0 ? [] : this.selectDependencies(i, allPackageNames.slice(0, i));

this.packages.set(packageName, {
name: packageName,
Expand Down Expand Up @@ -181,9 +182,15 @@ class MonorepoGenerator {

// Create the scenario: A has build, B doesn't, C has build
const scriptName = this.getRandomElement(this.SCRIPT_NAMES);
pkgA.scripts[scriptName] = this.generateScriptCommand(scriptName, nameA);
pkgA.scripts[scriptName] = this.generateScriptCommand(
scriptName,
nameA,
);
delete pkgB.scripts[scriptName]; // B doesn't have the script
pkgC.scripts[scriptName] = this.generateScriptCommand(scriptName, nameC);
pkgC.scripts[scriptName] = this.generateScriptCommand(
scriptName,
nameC,
);
}
}
}
Expand All @@ -201,10 +208,13 @@ class MonorepoGenerator {
version: '1.0.0',
main: 'src/index.js',
scripts: pkg.scripts,
dependencies: pkg.dependencies.reduce((deps, dep) => {
deps[`@monorepo/${dep}`] = 'workspace:*';
return deps;
}, {} as Record<string, string>),
dependencies: pkg.dependencies.reduce(
(deps, dep) => {
deps[`@monorepo/${dep}`] = 'workspace:*';
return deps;
},
{} as Record<string, string>,
),
};

fs.writeFileSync(
Expand Down Expand Up @@ -352,11 +362,9 @@ module.exports = { ${pkg.name.replace('-', '_')} };
console.log('\nStatistics:');
console.log(`- Total packages: ${this.packages.size}`);
console.log(
`- Average dependencies per package: ${
(
totalDeps / this.packages.size
).toFixed(2)
}`,
`- Average dependencies per package: ${(
totalDeps / this.packages.size
).toFixed(2)}`,
);
console.log(`- Max dependencies in a package: ${maxDeps}`);
console.log(`- Packages with vite-plus.json: ${packagesWithVitePlus}`);
Expand Down
4 changes: 1 addition & 3 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ export default defineConfig({
description: 'Vite+',
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
],
nav: [{ text: 'Home', link: '/' }],

sidebar: [],

Expand Down
4 changes: 4 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"quotes": "preferSingle"
},
"excludes": [
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jsx",
"crates/fspy_detours_sys/detours",
"pnpm-lock.yaml",
"packages/cli/binding/index.d.ts",
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"install-global-cli": "npm install -g ./packages/global",
"typecheck": "tsc -b tsconfig.json",
"lint": "vite lint --type-aware --threads 4",
"test": "vite test run && pnpm --filter=@voidzero-dev/vite-plus test && pnpm -r snap-test",
"test": "vite test run && pnpm -r snap-test",
"prepare": "husky"
},
"devDependencies": {
Expand All @@ -27,14 +27,15 @@
"oxfmt": "catalog:",
"oxlint": "catalog:",
"typescript": "catalog:",
"vitest": "catalog:"
"vitest": "workspace:@voidzero-dev/vite-plus-test@*"
},
"lint-staged": {
"*.@(js|ts|tsx|yml|yaml|md|json|html|toml)": [
"*.@(yml|yaml|md|json|html|toml)": [
"dprint fmt --staged"
],
"*.@(js|ts|tsx)": [
"oxlint -- --fix"
"oxlint -- --fix",
"oxfmt"
],
"*.rs": [
"cargo fmt --"
Expand Down
21 changes: 16 additions & 5 deletions packages/cli/binding/__tests__/run-command.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,27 @@ test('should run command successfully', async () => {

// write file on the temp directory
test('should write file on the temp directory', async () => {
const tempDir = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')));
const tempDir = await fs.realpath(
await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')),
);
const result = await runCommand({
binName: 'node',
args: ['-e', `fs.writeFileSync("test.txt", "Hello, world!")`],
envs: {},
cwd: tempDir,
});
expect(result).toMatchSnapshot();
expect(await fs.readFile(path.join(tempDir, 'test.txt'), 'utf-8')).toBe('Hello, world!');
expect(await fs.readFile(path.join(tempDir, 'test.txt'), 'utf-8')).toBe(
'Hello, world!',
);
await fs.rm(tempDir, { recursive: true });
});

// read file on the temp directory
test('should read file on the temp directory', async () => {
const tempDir = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')));
const tempDir = await fs.realpath(
await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')),
);
await fs.writeFile(path.join(tempDir, 'test.txt'), 'Hello, world!');
const result = await runCommand({
binName: 'node',
Expand All @@ -46,10 +52,15 @@ test('should read file on the temp directory', async () => {

// write and read file on the temp directory
test('should write and read file on the temp directory', async () => {
const tempDir = await fs.realpath(await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')));
const tempDir = await fs.realpath(
await fs.mkdtemp(path.join(tmpdir(), 'vite-plus-test-')),
);
const result = await runCommand({
binName: 'node',
args: ['-e', `fs.writeFileSync("test.txt", "Hello, world!"); fs.readFileSync("test.txt", "utf-8")`],
args: [
'-e',
`fs.writeFileSync("test.txt", "Hello, world!"); fs.readFileSync("test.txt", "utf-8")`,
],
envs: {},
cwd: tempDir,
});
Expand Down
Loading
Loading