-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
feat(build): emit license #18546
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
Merged
Merged
feat(build): emit license #18546
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
51e3d13
refactor: set defaults
bluwy e96e888
feat: initial implementation
bluwy 3b244fd
Merge branch 'main' into emit-license
bluwy 5e435fd
chore: add docs and tests
bluwy 744eea4
chore: remove
bluwy ac5b6ea
chore: update docs
bluwy 0f85972
Merge branch 'main' into emit-license
bluwy ffc0a88
refactor: use object
bluwy 006065e
chore: fix name
bluwy b075fb7
docs: add banner info
bluwy 59af0d6
Merge branch 'main' into emit-license
sapphi-red 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
47 changes: 47 additions & 0 deletions
47
packages/vite/src/node/__tests__/plugins/__snapshots__/license.spec.ts.snap
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,47 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`json 1`] = ` | ||
| "[ | ||
| { | ||
| "name": "@vitejs/test-dep-licence-cc0", | ||
| "version": "0.0.0", | ||
| "identifier": "CC0-1.0", | ||
| "text": "CC0 1.0 Universal\\n\\n..." | ||
| }, | ||
| { | ||
| "name": "@vitejs/test-dep-license-mit", | ||
| "version": "0.0.0", | ||
| "identifier": "MIT", | ||
| "text": "MIT License\\n\\nCopyright (c) ..." | ||
| }, | ||
| { | ||
| "name": "@vitejs/test-dep-nested-license-isc", | ||
| "version": "0.0.0", | ||
| "identifier": "ISC", | ||
| "text": "Copyright (c) ..." | ||
| } | ||
| ]" | ||
| `; | ||
|
|
||
| exports[`markdown 1`] = ` | ||
| "# Licenses | ||
|
|
||
| The app bundles dependencies which contains the following licenses: | ||
|
|
||
| ## @vitejs/test-dep-licence-cc0 - 0.0.0 (CC0-1.0) | ||
|
|
||
| CC0 1.0 Universal | ||
|
|
||
| ... | ||
|
|
||
| ## @vitejs/test-dep-license-mit - 0.0.0 (MIT) | ||
|
|
||
| MIT License | ||
|
|
||
| Copyright (c) ... | ||
|
|
||
| ## @vitejs/test-dep-nested-license-isc - 0.0.0 (ISC) | ||
|
|
||
| Copyright (c) ... | ||
| " | ||
| `; |
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
1 change: 1 addition & 0 deletions
1
packages/vite/src/node/__tests__/plugins/fixtures/license/dep-licence-cc0/index.js
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 @@ | ||
| export default 'ok' |
3 changes: 3 additions & 0 deletions
3
packages/vite/src/node/__tests__/plugins/fixtures/license/dep-licence-cc0/licence
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,3 @@ | ||
| CC0 1.0 Universal | ||
|
|
||
| ... |
7 changes: 7 additions & 0 deletions
7
packages/vite/src/node/__tests__/plugins/fixtures/license/dep-licence-cc0/package.json
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,7 @@ | ||
| { | ||
| "name": "@vitejs/test-dep-licence-cc0", | ||
| "private": true, | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "license": "CC0-1.0" | ||
| } |
3 changes: 3 additions & 0 deletions
3
packages/vite/src/node/__tests__/plugins/fixtures/license/dep-license-mit/index.js
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,3 @@ | ||
| import nestedDep from '@vitejs/test-dep-nested-licence-isc' | ||
|
|
||
| export default 'ok' + nestedDep | ||
3 changes: 3 additions & 0 deletions
3
packages/vite/src/node/__tests__/plugins/fixtures/license/dep-license-mit/license
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,3 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) ... |
10 changes: 10 additions & 0 deletions
10
packages/vite/src/node/__tests__/plugins/fixtures/license/dep-license-mit/package.json
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,10 @@ | ||
| { | ||
| "name": "@vitejs/test-dep-license-mit", | ||
| "private": true, | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "license": "MIT", | ||
| "dependencies": { | ||
| "@vitejs/test-dep-nested-licence-isc": "file:../dep-nested-license-isc" | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
packages/vite/src/node/__tests__/plugins/fixtures/license/dep-nested-license-isc/LICENSE
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 @@ | ||
| Copyright (c) ... |
1 change: 1 addition & 0 deletions
1
packages/vite/src/node/__tests__/plugins/fixtures/license/dep-nested-license-isc/index.js
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 @@ | ||
| export default 'ok' |
7 changes: 7 additions & 0 deletions
7
...ages/vite/src/node/__tests__/plugins/fixtures/license/dep-nested-license-isc/package.json
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,7 @@ | ||
| { | ||
| "name": "@vitejs/test-dep-nested-license-isc", | ||
| "private": true, | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "license": "ISC" | ||
| } |
5 changes: 5 additions & 0 deletions
5
packages/vite/src/node/__tests__/plugins/fixtures/license/index.html
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,5 @@ | ||
| <script type="module"> | ||
| import dep1 from '@vitejs/test-dep-licence-cc0' | ||
| import dep2 from '@vitejs/test-dep-license-mit' | ||
| console.log(dep1, dep2) | ||
| </script> |
10 changes: 10 additions & 0 deletions
10
packages/vite/src/node/__tests__/plugins/fixtures/license/package.json
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,10 @@ | ||
| { | ||
| "name": "@vitejs/test-license", | ||
| "private": true, | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "dependencies": { | ||
| "@vitejs/test-dep-license-mit": "file:./dep-license-mit", | ||
| "@vitejs/test-dep-licence-cc0": "file:./dep-licence-cc0" | ||
| } | ||
| } |
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,36 @@ | ||
| import { fileURLToPath } from 'node:url' | ||
| import type { OutputAsset, RollupOutput } from 'rollup' | ||
| import { expect, test } from 'vitest' | ||
| import { build } from '../../build' | ||
|
|
||
| test('markdown', async () => { | ||
| const result = (await build({ | ||
| root: fileURLToPath(new URL('./fixtures/license', import.meta.url)), | ||
| logLevel: 'silent', | ||
| build: { | ||
| write: false, | ||
| license: true, | ||
| }, | ||
| })) as RollupOutput | ||
| const licenseAsset = result.output.find( | ||
| (asset) => asset.fileName === '.vite/license.md', | ||
| ) as OutputAsset | undefined | ||
| expect(licenseAsset).toBeDefined() | ||
| expect(licenseAsset?.source).toMatchSnapshot() | ||
| }) | ||
|
|
||
| test('json', async () => { | ||
| const result = (await build({ | ||
| root: fileURLToPath(new URL('./fixtures/license', import.meta.url)), | ||
| logLevel: 'silent', | ||
| build: { | ||
| write: false, | ||
| license: '.vite/license.json', | ||
| }, | ||
| })) as RollupOutput | ||
| const licenseAsset = result.output.find( | ||
| (asset) => asset.fileName === '.vite/license.json', | ||
| ) as OutputAsset | undefined | ||
| expect(licenseAsset).toBeDefined() | ||
| expect(licenseAsset?.source).toMatchSnapshot() | ||
| }) |
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 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 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
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.