ionic-team / create-capacitor-plugin

Create a new Capacitor plugin ⚡️
Other
79 stars 11 forks source link

npm package name regex too restrictive #83

Open lee-current-health opened 1 year ago

lee-current-health commented 1 year ago

The --name validator regex is too restrictive and will not let valid package names pass validation.

Presume it was a legacy versus current package name issue.

https://github.com/npm/validate-npm-package-name has a list of valid package name defined as:

Naming Rules

Below is a list of rules that valid npm package name should conform to.

package name length should be greater than zero all the characters in the package name must be lowercase i.e., no uppercase or mixed case names are allowed package name can consist of hyphens package name must not contain any non-url-safe characters (since name ends up being part of a URL) package name should not start with . or _ package name should not contain any spaces package name should not contain any of the following characters: ~)('!* package name cannot be the same as a node.js/io.js core module nor a reserved/blacklisted name. For example, the following names are invalid: http stream node_modules favicon.ico package name length cannot exceed 214

I couldn't find this in the npm docs to reference.

Simplest change for my particular issue would be allowing the . in the name after the scope so that @scope/com.example.packageid passed the regex

^(@[a-z0-9-]+\/)?[a-z0-9-.]+$

mig8447 commented 1 year ago

I agree, it doesn't even support dashes, although I just noticed that this is a Java Package ID which don't support dashes