Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
A more engineered, highly customizable, standard output format commitizen adapter.
What is commitizen: A Node.js-based
git commit
command-line tool that assists in generating standardized and standardized commit messages.
What is an adapter: Replace the interactive plugin for the commitizen command line tool.
tip: It is recommended to global installation
commitizen cz-git
, that you can quickly use thecz
orgit cz
command to start.
npm install -g commitizen cz-git
Just three simple steps:
npm install -D cz-git
# or
yarn add -D cz-git
config
Specify the adapter used, and add a startup command.
npm commit
or yarn commit
to test the startup.{
"scripts": {
"commit": "git cz"
},
"config": {
"commitizen": {
"path": "node_modules/cz-git"
}
}
}
Method 1: (recommended) cz-git is linked with commitlint to provide verification information, so it can be written in commitlint configuration file.
E.g: (⇒ Configuration Template)
// .commitlintrc.js
/** @type {import('cz-git').UserConfig} */
module.exports = {
rule: {
...
},
prompt: {
useEmoji: true
//option...
}
}
Method 2: Add custom configuration under config.commitizen under package.json, but excessive configuration items will lead to bloated package.json, which is suitable for simple customization. E.g:
{
"scripts": {
"commit": "git cz"
},
"config": {
"commitizen": {
"path": "node_modules/cz-git",
"useEmoji": true
}
}
}
The advantage of global installation is that you can use
cz
orgit cz
command to start command line tools under any project to generate standardized commit messages
Just three simple steps:
npm install -g cz-git commitizen
echo '{ "path": "cz-git" }' > ~/.czrc
Method 1: Edit the ~/.czrc
file to add configuration in the form of json, for example:
{
"path": "cz-git",
"useEmoji": true
}
Method 2: Cooperate with commitlint to create a configuration file under the path of $HOME
(↓ Configuration Template)
// .commitlintrc.js
/** @type {import('cz-git').UserConfig} */
module.exports = {
rules: {
// @see: https://commitlint.js.org/#/reference-rules
},
prompt: {
messages: {
type: "Select the type of change that you're committing:",
scope: "Denote the SCOPE of this change (optional):",
customScope: "Denote the SCOPE of this change:",
subject: "Write a SHORT, IMPERATIVE tense description of the change:\n",
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):",
customFooterPrefixs: "Input ISSUES Prefix:",
footer: "List any ISSUES by this change. E.g.: #31, #34, #I972S:\n",
confirmCommit: "Are you sure you want to proceed with the commit above ?"
},
types: [
{ value: "feat", name: "feat: A new feature", emoji: ":sparkles:" },
{ value: "fix", name: "fix: A bug fix", emoji: ":bug:" },
{ value: "docs", name: "docs: Documentation only changes", emoji: ":memo:" },
{ value: "style", name: "style: Changes that do not affect the meaning of the code", emoji: ":lipstick:" },
{ value: "refactor", name: "refactor: A code change that neither fixes a bug nor adds a feature", emoji: ":recycle:" },
{ value: "perf", name: "perf: A code change that improves performance", emoji: ":zap:" },
{ value: "test", name: "test: Adding missing tests or correcting existing tests", emoji: ":white_check_mark:" },
{ value: "build", name: "build: Changes that affect the build system or external dependencies", emoji: ":building_construction:" },
{ value: "ci", name: "ci: Changes to our CI configuration files and scripts", emoji: ":green_heart:" },
{ value: "chore", name: "chore: Other changes that don't modify src or test files", emoji: ":hammer:" },
{ value: "revert", name: "revert: Reverts a previous commit", emoji: ":rewind:" }
],
useEmoji: false,
scopes: [],
allowCustomScopes: true,
allowEmptyScopes: true,
customScopesAlign: "bottom",
customScopesAlias: "custom",
emptyScopesAlias: "empty",
allowBreakingChanges: ['feat', 'fix'],
upperCaseSubject: false,
breaklineChar: "|",
skipQuestions: [],
issuePrefixs: [{ value: "closed", name: "closed: ISSUES has been processed" }],
customIssuePrefixsAlign: "top",
emptyIssuePrefixsAlias: "skip",
customIssuePrefixsAlias: "custom",
confirmColorize: true,
maxHeaderLength: Infinity,
maxSubjectLength: Infinity,
minSubjectLength: 0,
scopeOverrides: undefined,
defaultBody: "",
defaultIssues: "",
defaultScope: "",
defaultSubject: ""
}
};
// .commitlintrc.js
/** @type {import('cz-git').UserConfig} */
module.exports = {
rules: {
// @see: https://commitlint.js.org/#/reference-rules
},
prompt: {
messages: {
type: "Select the type of change that you're committing:",
scope: "Denote the SCOPE of this change (optional):",
customScope: "Denote the SCOPE of this change:",
subject: "Write a SHORT, IMPERATIVE tense description of the change:\n",
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):",
customFooterPrefixs: "Input ISSUES Prefix:",
footer: "List any ISSUES by this change. E.g.: #31, #34, #I972S:\n",
confirmCommit: "Are you sure you want to proceed with the commit above ?"
},
types: [
{ value: "feat", name: "feat: ✨ A new feature", emoji: ":sparkles:" },
{ value: "fix", name: "fix: 🐛 A bug fix", emoji: ":bug:" },
{ value: "docs", name: "docs: 📝 Documentation only changes", emoji: ":memo:" },
{ value: "style", name: "style: 💄 Changes that do not affect the meaning of the code", emoji: ":lipstick:" },
{ value: "refactor", name: "refactor: ♻️ A code change that neither fixes a bug nor adds a feature", emoji: ":recycle:" },
{ value: "perf", name: "perf: ⚡️ A code change that improves performance", emoji: ":zap:" },
{ value: "test", name: "test: ✅ Adding missing tests or correcting existing tests", emoji: ":white_check_mark:" },
{ value: "build", name: "build: 🏗️ Changes that affect the build system or external dependencies", emoji: ":building_construction:" },
{ value: "ci", name: "ci: 💚 Changes to our CI configuration files and scripts", emoji: ":green_heart:" },
{ value: "chore", name: "chore: 🔨 Other changes that don't modify src or test files", emoji: ":hammer:" },
{ value: "revert", name: "revert: ⏪️ Reverts a previous commit", emoji: ":rewind:" }
],
useEmoji: true,
scopes: [],
allowCustomScopes: true,
allowEmptyScopes: true,
customScopesAlign: "bottom",
customScopesAlias: "custom",
emptyScopesAlias: "empty",
allowBreakingChanges: ['feat', 'fix'],
upperCaseSubject: false,
breaklineChar: "|",
skipQuestions: [],
issuePrefixs: [{ value: "closed", name: "closed: ISSUES has been processed" }],
customIssuePrefixsAlign: "top",
emptyIssuePrefixsAlias: "skip",
customIssuePrefixsAlias: "custom",
confirmColorize: true,
maxHeaderLength: Infinity,
maxSubjectLength: Infinity,
minSubjectLength: 0,
scopeOverrides: undefined,
defaultBody: "",
defaultIssues: "",
defaultScope: "",
defaultSubject: ""
}
};
tip: It is recommended to use JavaScript for configuration files in the project. You can combine
fs
andpath
to select scopes for generating dynamic modules.
// .czrc | package.json | .commitlintrc(need "prompt" key)
{
"messages": {
"type": "Select the type of change that you're committing:",
"scope": "Denote the SCOPE of this change (optional):",
"customScope": "Denote the SCOPE of this change:",
"subject": "Write a SHORT, IMPERATIVE tense description of the change:\n",
"body": "Provide a LONGER description of the change (optional). Use \"|\" to break new line:\n",
"breaking": "List any BREAKING CHANGES (optional). Use \"|\" to break new line:\n",
"footerPrefixsSelect": "Select the ISSUES type of changeList by this change (optional):",
"customFooterPrefixs": "Input ISSUES Prefix:",
"footer": "List any ISSUES by this change. E.g.: #31, #34, #I972S:\n",
"confirmCommit": "Are you sure you want to proceed with the commit above ?"
},
"types": [
{ "value": "feat", "name": "feat: A new feature", "emoji": ":sparkles:" },
{ "value": "fix", "name": "fix: A bug fix", "emoji": ":bug:" },
{ "value": "docs", "name": "docs: Documentation only changes", "emoji": ":memo:" },
{ "value": "style", "name": "style: Changes that do not affect the meaning of the code", "emoji": ":lipstick:" },
{ "value": "refactor", "name": "refactor: A code change that neither fixes a bug nor adds a feature", "emoji": ":recycle:" },
{ "value": "perf", "name": "perf: A code change that improves performance", "emoji": ":zap:" },
{ "value": "test", "name": "test: Adding missing tests or correcting existing tests", "emoji": ":white_check_mark:" },
{ "value": "build", "name": "build: Changes that affect the build system or external dependencies", "emoji": ":building_construction:" },
{ "value": "ci", "name": "ci: Changes to our CI configuration files and scripts", "emoji": ":green_heart:" },
{ "value": "chore", "name": "chore: Other changes that don't modify src or test files", "emoji": ":hammer:" },
{ "value": "revert", "name": "revert: Reverts a previous commit", "emoji": ":rewind:" }
],
"useEmoji": false,
"scopes": [],
"allowCustomScopes": true,
"allowEmptyScopes": true,
"customScopesAlign": "bottom",
"customScopesAlias": "custom",
"emptyScopesAlias": "empty",
"allowBreakingChanges": ["feat", "fix"],
"upperCaseSubject": false,
"breaklineChar": "|",
"skipQuestions": [],
"issuePrefixs": [{ "value": "closed", "name": "closed: ISSUES has been processed" }],
"customIssuePrefixsAlign": "top",
"emptyIssuePrefixsAlias": "skip",
"customIssuePrefixsAlias": "custom",
"confirmColorize": true,
"minSubjectLength": 0,
"defaultBody": "",
"defaultIssues": "",
"defaultScope": "",
"defaultSubject": ""
}
warning: Defining configuration with TypeScript is deprecated as this affects command line tool startup speed
And using the js configuration file to add the@type
annotation can be a good way to provide code hints at configuration time
// .commitlintrc.ts
import type { UserConfig } from "cz-git"
const config: UserConfig = {
rules: {
// @see: https://commitlint.js.org/#/reference-rules
},
prompt: {
messages: {
type: "Select the type of change that you're committing:",
scope: "Denote the SCOPE of this change (optional):",
customScope: "Denote the SCOPE of this change:",
subject: "Write a SHORT, IMPERATIVE tense description of the change:\n",
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):",
customFooterPrefixs: "Input ISSUES Prefix:",
footer: "List any ISSUES by this change. E.g.: #31, #34, #I972S:\n",
confirmCommit: "Are you sure you want to proceed with the commit above ?"
},
types: [
{ value: "feat", name: "feat: A new feature", emoji: ":sparkles:" },
{ value: "fix", name: "fix: A bug fix", emoji: ":bug:" },
{ value: "docs", name: "docs: Documentation only changes", emoji: ":memo:" },
{ value: "style", name: "style: Changes that do not affect the meaning of the code", emoji: ":lipstick:" },
{ value: "refactor", name: "refactor: A code change that neither fixes a bug nor adds a feature", emoji: ":recycle:" },
{ value: "perf", name: "perf: A code change that improves performance", emoji: ":zap:" },
{ value: "test", name: "test: Adding missing tests or correcting existing tests", emoji: ":white_check_mark:" },
{ value: "build", name: "build: Changes that affect the build system or external dependencies", emoji: ":building_construction:" },
{ value: "ci", name: "ci: Changes to our CI configuration files and scripts", emoji: ":green_heart:" },
{ value: "chore", name: "chore: Other changes that don't modify src or test files", emoji: ":hammer:" },
{ value: "revert", name: "revert: Reverts a previous commit", emoji: ":rewind:" }
],
useEmoji: false,
scopes: [],
allowCustomScopes: true,
allowEmptyScopes: true,
customScopesAlign: "bottom",
customScopesAlias: "custom",
emptyScopesAlias: "empty",
allowBreakingChanges: ['feat', 'fix'],
upperCaseSubject: false,
breaklineChar: "|",
skipQuestions: [],
issuePrefixs: [{ value: "closed", name: "closed: ISSUES has been processed" }],
customIssuePrefixsAlign: "top",
emptyIssuePrefixsAlias: "skip",
customIssuePrefixsAlias: "custom",
confirmColorize: true,
maxHeaderLength: Infinity,
maxSubjectLength: Infinity,
minSubjectLength: 0,
scopeOverrides: undefined,
defaultBody: "",
defaultIssues: "",
defaultScope: "",
defaultSubject: ""
}
};
export default config
messages: { type: "Select the type of change that you're committing:" }
Array<{ name: string; value: string; emoji?: string }>
types: [{value: 'feat', name: 'feat: A new feature', emoji: ':sparkles:'}]
tip: If you want to use Emoji, you need enable
userEmoji
configuration item.
And need to add Emoji Code, you can find the corresponding characters in: https://gitmoji.dev/ to supplementemoji
.
"top" | "bottom" | "top-bottom" | "bottom-top"
"bottom"
string
custom
string
empty
"top" | "bottom" | "top-bottom" | "bottom-top"
"top"
string
custom
string
skip
boolean
true
string
""
string
""
string
""
string
""
tip: JavaScript logic can be written to utilize callbacks to return default values for relevant inputs
e.g :defaultSubject: ()=> {return ...}
string[] | Array<{ name: string, value?: string }>
[]
tip: If you define a
scope-enum
using the commitlint rule, it will be imported automatically.
If you need to manage multiple packages for a better experience, for example use: pnpm | lerna.js to manage monorepo you can Use thepath
andfs
modules to dynamically define the scopes (scopes) display in the commit message
// .commitlintrc.js
const fs = require('fs')
const path = require('path')
const packages = fs.readdirSync(path.resolve(__dirname, 'packages'))
module.exports = {
prompt: { scopes: [...packages] }
}
Of course, if you want to add description information to the module-wide customization to display on the command line, you can use name and value to define.
e.g:scopes: [{value: "theme", name: "theme : page theme"}]
{ [type: string]: string[] | Array<{ name: string, value?: string }> } | undefined
undefined
scopeOverrides: { "test": ['e2eTest, 'unitTest'] }
type
tip : If you define
scopeOverrides
then define genericscopes
boolean
true
commitlint
and want to turn off custom options in select.tip: It will automatically detect whether the definition of the commitlint rule
scope-enum
is strict, and it will not be displayed automatically.
boolean
true
string[]
['feat', 'fix']
boolean
false
string
"|"
Array<"scope" | "body" | "breaking" | "footerPrefix" | "footer">
[]
Array<{ value: string, name: string }>
[{ value: "closed", name: "closed: ISSUES has been processed" }]
number
Infinity
tip: If you use commitlint, it will automatically read
header-max-length
and set it to give a prompt on the command line
number
Infinity
tip: If using commitlint will automatically read
subject-max-length
and set it to give a prompt on the command line.
number
0
tip: If commitlint is used, it will automatically read
subject-min-length
and set it to give a prompt on the command line
npm prefix -g
to check whether the path of npm global download is in the root directoryMIT Copyright (c) 2022-present Qiubin Zheng zhengqbbb@gmail.com (https://github.com/Zhengqbbb)
I just do my best to make thing well, Could you give a star ⭐ to encourage me ?
FAQs
A better customizable and git support commitizen adapter
The npm package cz-git receives a total of 19,626 weekly downloads. As such, cz-git popularity was classified as popular.
We found that cz-git demonstrated a healthy version release cadence and project activity because the last version was released less than 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.