Skip to content

Commit f1f6016

Browse files
authored
fix(build): write merged LICENSE directly instead of LICENSE.md (#1281)
The core and test packages were generating the full bundled-deps license to LICENSE.md, then syncLicenseFromRoot() overwrote the plain LICENSE with just the root MIT header. Since npm surfaces LICENSE (not .md) by default, the merged content was invisible on npm/unpkg. Now generateLicenseFile() writes directly to LICENSE and the redundant syncLicenseFromRoot() is removed, matching how the CLI package already handles it.
1 parent 511c587 commit f1f6016

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ jobs:
160160
path: ./packages/cli/skills
161161
if-no-files-found: error
162162

163+
- name: Upload LICENSE files
164+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
165+
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
166+
with:
167+
name: licenses
168+
path: |
169+
./packages/core/LICENSE
170+
./packages/cli/LICENSE
171+
if-no-files-found: error
172+
163173
Release:
164174
runs-on: ubuntu-latest
165175
needs: [prepare, build-rust]
@@ -212,6 +222,13 @@ jobs:
212222
pattern: core
213223
merge-multiple: true
214224

225+
- name: Download LICENSE files
226+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
227+
with:
228+
path: packages
229+
pattern: licenses
230+
merge-multiple: true
231+
215232
- uses: ./.github/actions/download-rolldown-binaries
216233
with:
217234
github-token: ${{ github.token }}

packages/core/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
/LICENSE
2-
/LICENSE.md

packages/core/build.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ await bundleVitepress();
5555
generateLicenseFile({
5656
title: 'Vite-Plus core license',
5757
packageName: 'Vite-Plus',
58-
outputPath: join(projectDir, 'LICENSE.md'),
58+
outputPath: join(projectDir, 'LICENSE'),
5959
coreLicensePath: join(projectDir, '..', '..', 'LICENSE'),
6060
bundledPaths: [join(projectDir, 'dist')],
6161
resolveFrom: [
@@ -84,11 +84,10 @@ generateLicenseFile({
8484
},
8585
],
8686
});
87-
if (!existsSync(join(projectDir, 'LICENSE.md'))) {
88-
throw new Error('LICENSE.md was not generated during build');
87+
if (!existsSync(join(projectDir, 'LICENSE'))) {
88+
throw new Error('LICENSE was not generated during build');
8989
}
9090
await mergePackageJson();
91-
await syncLicenseFromRoot();
9291

9392
async function buildVite() {
9493
const newViteRolldownConfig = viteRolldownConfig.map((config) => {
@@ -670,9 +669,3 @@ async function mergePackageJson() {
670669
}
671670
await writeFile(destPkgPath, code);
672671
}
673-
674-
async function syncLicenseFromRoot() {
675-
const rootLicensePath = join(projectDir, '..', '..', 'LICENSE');
676-
const packageLicensePath = join(projectDir, 'LICENSE');
677-
await copyFile(rootLicensePath, packageLicensePath);
678-
}

packages/test/build.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ await mergePackageJson(pluginExports);
231231
generateLicenseFile({
232232
title: 'Vite-Plus test license',
233233
packageName: 'Vite-Plus',
234-
outputPath: join(projectDir, 'LICENSE.md'),
234+
outputPath: join(projectDir, 'LICENSE'),
235235
coreLicensePath: join(projectDir, '..', '..', 'LICENSE'),
236236
bundledPaths: [distDir],
237237
resolveFrom: [projectDir, join(projectDir, '..', '..')],
@@ -242,10 +242,9 @@ generateLicenseFile({
242242
})),
243243
],
244244
});
245-
if (!existsSync(join(projectDir, 'LICENSE.md'))) {
246-
throw new Error('LICENSE.md was not generated during build');
245+
if (!existsSync(join(projectDir, 'LICENSE'))) {
246+
throw new Error('LICENSE was not generated during build');
247247
}
248-
await syncLicenseFromRoot();
249248
await validateExternalDeps();
250249

251250
async function mergePackageJson(pluginExports: Array<{ exportPath: string; shimFile: string }>) {
@@ -434,12 +433,6 @@ async function mergePackageJson(pluginExports: Array<{ exportPath: string; shimF
434433
await writeFile(destPackageJsonPath, code);
435434
}
436435

437-
async function syncLicenseFromRoot() {
438-
const rootLicensePath = join(projectDir, '..', '..', 'LICENSE');
439-
const packageLicensePath = join(projectDir, 'LICENSE');
440-
await copyFile(rootLicensePath, packageLicensePath);
441-
}
442-
443436
async function bundleVitest() {
444437
const vitestDestDir = projectDir;
445438

@@ -451,6 +444,7 @@ async function bundleVitest() {
451444
join(vitestSourceDir, 'node_modules/**'),
452445
join(vitestSourceDir, 'package.json'),
453446
join(vitestSourceDir, 'README.md'),
447+
join(vitestSourceDir, 'LICENSE.md'),
454448
],
455449
});
456450

scripts/generate-license.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ export function generateLicenseFile(options: GenerateLicenseFileOptions) {
203203

204204
if (existingContent !== licenseFileContent) {
205205
fs.writeFileSync(options.outputPath, licenseFileContent);
206-
console.error('\x1b[33m\nLICENSE.md updated. You should commit the updated file.\n\x1b[0m');
206+
const outputFileName = path.basename(options.outputPath);
207+
console.error(
208+
`\x1b[33m\n${outputFileName} updated. You should commit the updated file.\n\x1b[0m`,
209+
);
207210
}
208211
}
209212

0 commit comments

Comments
 (0)