Skip to content

Commit 174ef75

Browse files
committed
fix(build): write merged LICENSE directly instead of LICENSE.md
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 1fe4cff commit 174ef75

File tree

5 files changed

+11
-23
lines changed

5 files changed

+11
-23
lines changed

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/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*.d.ts
22
*.d.cts
33
/LICENSE
4-
LICENSE.md
4+
/LICENSE.md
55
*.cjs
66
*.mjs
77
browser/

packages/test/build.ts

Lines changed: 3 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

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)