Skip to content

feat: warn users about missing LICENSE - #628

Merged
João Moreno (joaomoreno) merged 7 commits into
microsoft:mainfrom
Andrewnt219:603-warn-missing-license
Oct 13, 2021
Merged

João Moreno (joaomoreno) merged 7 commits into
microsoft:mainfrom
Andrewnt219:603-warn-missing-license

Conversation

@Andrewnt219

@Andrewnt219 Andrew Nguyen (Andrewnt219) commented Oct 8, 2021 •

Copy link
Copy Markdown
Contributor

Motivation

Fixes #603

When the code fails to automatically detect a LICENSE file, it now warns the users if they want to continue.

Test Plan

Run vsce package without a LICENSE should generate a warning message.

# No LICENSE. 
# No 'SEE LICENSE IN term.md'

PS C:\helloworld> vsce package
Executing prepublish script 'npm run vscode:prepublish'...

> helloworld@0.0.1 vscode:prepublish
> npm run compile


> helloworld@0.0.1 compile
> tsc -p ./

 WARNING LICENSE.md or LICENSE.txt not found
Do you want to continue? [Y/N]

# No LICENSE. 
# Has 'SEE LICENSE IN term.md'

PS C:\helloworld> vsce package
Executing prepublish script 'npm run vscode:prepublish'...

> helloworld@0.0.1 vscode:prepublish
> npm run compile


> helloworld@0.0.1 compile
> tsc -p ./

 WARNING  term.md not found
Do you want to continue? [Y/N]

# Has LICENSE. 
# Has 'SEE LICENSE IN term.md'

PS C:\helloworld> vsce package
Executing prepublish script 'npm run vscode:prepublish'...

> helloworld@0.0.1 vscode:prepublish
> npm run compile


> helloworld@0.0.1 compile
> tsc -p ./

 WARNING  term.md not found
Do you want to continue? [Y/N]

@joaomoreno João Moreno (joaomoreno) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have read through the README, but I don't know how I can set up dev environment to reporuce the case.

Yeah, the current steps seems to be broken. I've fixed those in main.

Comment thread src/package.ts Outdated
Comment thread src/package.ts Outdated
Comment thread src/package.ts Outdated
@Andrewnt219
Andrew Nguyen (Andrewnt219) marked this pull request as draft October 12, 2021 03:54
@Andrewnt219
Andrew Nguyen (Andrewnt219) marked this pull request as ready for review October 12, 2021 03:57
@Andrewnt219

Andrew Nguyen (Andrewnt219) commented Oct 12, 2021 •

Copy link
Copy Markdown
Contributor Author

João Moreno (@joaomoreno) I have resolved those issues you mentioned.

Just a bit uncertain about the LICENSE name. Do you want me to extract that matching logic into a private method of LicenseProcessor, and use that in both the construct and onEnd? Or just keep it that way?

@joaomoreno

Copy link
Copy Markdown
Contributor

Yeah I would store that into a private expectedLicenseName: string property, in the ctor, so we don't have to compute it again.

@Andrewnt219

Copy link
Copy Markdown
Contributor Author

Done. You can refer to the Test Plan for sample console output.

Comment thread src/package.ts Outdated
@Andrewnt219

Andrew Nguyen (Andrewnt219) commented Oct 12, 2021 •

Copy link
Copy Markdown
Contributor Author

Somehow, the last commit removed some brackets from the method onFile above it, which made some tests failed. I fixed it.

Co-authored-by: João Moreno <mail@joaomoreno.com>
@Andrewnt219

Andrew Nguyen (Andrewnt219) commented Oct 12, 2021 •

Copy link
Copy Markdown
Contributor Author

ah, it is because of the dot in LICENSE.md or LICENSE.txt. I'll revert the regex of default back to the original.

Fixed test [toVsixManifest] should automatically detect license files:
Comment thread src/package.ts Outdated
Comment thread src/package.ts Outdated

@joaomoreno João Moreno (joaomoreno) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few more commits on top.

Comment thread src/package.ts Outdated
Comment thread src/package.ts Outdated
@joaomoreno
João Moreno (joaomoreno) merged commit 588ad79 into microsoft:main Oct 13, 2021
@joaomoreno

Copy link
Copy Markdown
Contributor

Thanks!

@Andrewnt219

Copy link
Copy Markdown
Contributor Author

João Moreno (@joaomoreno) No problem. I'd also be really happy if you can label this PR as hacktoberfest-accepted 😀.

@lnicola

Laurențiu Nicola (lnicola) commented Dec 3, 2021 •

Copy link
Copy Markdown

I'm not sure how this is supposed to work, but if the license is already defined as a SPDX string in package.json, the (previous) code still looked for a file on disk. Is that intentional?

@joaomoreno

João Moreno (joaomoreno) commented Dec 6, 2021 •

Copy link
Copy Markdown
Contributor

Laurențiu Nicola (@lnicola) The SPDX string only changes the licence file name to look for. It will always look for a license file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent / Warn about missing LICENSE

3 participants