Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@molt/types
Advanced tools
⛑ Advanced Types for parsing CLI flags and more.
npm add @molt/types
FlagName
The FlagName
namespace provides a Parse
type and some other utility types. Parse
turns an expression of CLI flags into structured object type data at the type level.
--
/-
fooBar
/foo-bar
.parse
// Errors
FlagName.Parse<''>
// Error: You must specify at least one name for your flag.
FlagName.Parse<'--foo-bar', { reservedNames: 'foo-bar'; usedNames: undefined }>
FlagName.Parse<'--foo-bar', { reservedNames: 'fooBar'; usedNames: undefined }>
// Error: The name "foo-bar" cannot be used because it is reserved.
FlagName.Parse<'--fooBar', { reservedNames: 'foo-bar'; usedNames: undefined }>
// Error: The name "fooBar" cannot be used because it is reserved.
FlagName.Parse<'-a', { usedNames: 'a'; reservedNames: undefined }>
// Error: The name "a" cannot be used because it is already used for another flag.
FlagName.Parse<'--v'>
//Error: A long flag must be two (2) or more characters but you have: '--v
FlagName.Parse<'-foo'>
// Error: A short flag must be exactly one (1) character but you have: '-foo'.
FlagName.Parse<'--foo --foo'>
// Error: Your alias "foo" is a duplicate.
import { FlagName } from '@molt/types'
const defineFlag = <Name>(
name: FlagName.Errors.$Is<FlagName.Parse<Name>> extends true ? FlagName.Parse<Name> : Name
) => {
// ...
}
defineFlag(``) // Static type error
defineFlag(`-`) // Static type error
defineFlag(`--`) // Static type error
defineFlag(`--a`) // Static type error
defineFlag(`-ab`) // Static type error
defineFlag(`--foo --foo`) // Static type error
defineFlag(`--foo-bar --fooBar`) // Static type error
defineFlag(`--version -`) // Static type error
defineFlag(`-v -v`) // Static type error
defineFlag(`--version`) // ok
defineFlag(`--version --ver`) // ok
defineFlag(`--version --ver -v`) // ok
defineFlag(`-v`) // ok
FAQs
Advanced Types for parsing CLI flags and more.
The npm package @molt/types receives a total of 57,197 weekly downloads. As such, @molt/types popularity was classified as popular.
We found that @molt/types demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.