@tarsilla/commit-wizard 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,91 @@
1
- # commit-wizard
1
+ # @tarsilla/commit-wizard
2
+
3
+ A custom configuration library for [commitizen](https://github.com/commitizen/cz-cli), [commitlint](https://github.com/conventional-changelog/commitlint), and [semantic-release](https://github.com/semantic-release/semantic-release).
4
+
5
+ ## Features
6
+
7
+ **@tarsilla/commit-wizard** provides a unified solution to enforce standardized commit messages and automate releases. It bundles tailored configurations for:
8
+ - **Commitizen** – interactive commit prompt
9
+ - **Commitlint** – commit message linting
10
+ - **Semantic-release** – automated release management
11
+
12
+ ## Installation
13
+
14
+ Install the package as a dev dependency:
15
+
16
+ ```sh
17
+ npm install --save-dev @tarsilla/commit-wizard
18
+ ```
19
+
20
+ or
21
+
22
+ ```sh
23
+ yarn add --dev @tarsilla/commit-wizard
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### Commitizen
29
+
30
+ Create a `.czrc` file in your project root with the following content:
31
+
32
+ ```json
33
+ {
34
+ "path": "@tarsilla/commit-wizard/commitizen"
35
+ }
36
+ ```
37
+
38
+ When you run `npx git-cz`, Commitizen will present you with an interactive prompt to format your commit messages.
39
+
40
+ ### Commitlint
41
+
42
+ Create a `commitlint.config.mjs` file in your project root with the following content:
43
+
44
+ ```js
45
+ export default {
46
+ extends: ['@tarsilla/commit-wizard/commitlint'],
47
+ };
48
+ ```
49
+
50
+ Commitlint enforces commit message conventions by using the conventional commits preset.
51
+ It is recommended to run commitlint during your commit process, ex. using husky (e.g. see [.husky/commit-msg](src/commitlint/commit-msg)).
52
+
53
+ ### Semantic-release
54
+
55
+ Create a `.releaserc.cjs` file in your project root with the following content:
56
+
57
+ ```js
58
+ module.exports = {
59
+ branches: ['main'],
60
+ repositoryUrl: 'path to your git repository',
61
+ plugins: ['@tarsilla/commit-wizard/semantic-release'],
62
+ };
63
+ ```
64
+
65
+ The semantic-release configuration automates version management and changelog generation.
66
+ It is recommended to configure CI/CD to run semantic-release, ex. using github actions (e.g. see [.github/workflows/npm-publish.yml](src/semantic-release/npm-publish.yml)).
67
+
68
+ ## Customization
69
+
70
+ You can override default settings by creating a `commit-wizard.config.json` file in your project root.
71
+ The plugin accepts an object of type `CommitWizardOptions`:
72
+
73
+ | Option | Type | Description | Default |
74
+ |----------|--------|--------------------------------------------------------------|-------------|
75
+ | maxLineLength | number | The maximum length of the commit message. If not provided, the plugin will run with the default settings. | 120 |
76
+
77
+
78
+ Example `commit-wizard.config.json`:
79
+ ```json
80
+ {
81
+ "maxLineLength": 100
82
+ }
83
+ ```
84
+
85
+ ## Contributing
86
+
87
+ Contributions are welcome! Please ensure your pull request adheres to the project's linting and testing guidelines.
88
+
89
+ ## License
90
+
91
+ Released under the [MIT License](LICENSE).
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/commitizen/prompter.ts","../../src/configLoader/configLoader.ts","../../src/commitizen/index.ts"],"sourcesContent":["import { Commitizen, Prompter, Question } from 'commitizen';\n\nimport Config from '../types/Config.js';\n\nexport type CommitAnswers = {\n type: string;\n scope: string;\n subject: string;\n confirmCommit: string;\n};\n\nfunction getCommitMessage({ answers }: { answers: CommitAnswers }) {\n const scopeText = answers.scope ? `(${answers.scope})` : '';\n if (answers.type === 'break') {\n const message = `feat${scopeText}!: ${answers.subject}`;\n return message;\n }\n const message = `${answers.type}${scopeText}: ${answers.subject}`;\n return message;\n}\n\nfunction getMaxSubject({ answers, maxLineLength }: { answers: CommitAnswers; maxLineLength: number }) {\n const scopeText = answers.scope ? `(${answers.scope})` : '';\n // +2 accounts for \": \" after type and scope.\n const prefixLength = (answers.type ? answers.type.length : 0) + scopeText.length + 2;\n const maxSubject = maxLineLength - prefixLength;\n return maxSubject;\n}\n\nfunction prompter({ maxLineLength }: Config): Prompter {\n return {\n prompter: function (cz: Commitizen, commit: (message: string) => void) {\n const questions: Question<CommitAnswers> = [\n {\n type: 'list',\n name: 'type',\n message: \"Select the type of change that you're committing:\",\n choices: [\n { value: 'feat', name: '🚀 feat: A new feature' },\n { value: 'fix', name: '🐛 fix: A bug fix' },\n { value: 'docs', name: '📚 docs: Documentation only changes' },\n {\n value: 'style',\n name: '🎨 style: Changes that do not affect the meaning of the code (white-space, formatting, etc)',\n },\n { value: 'refactor', name: '🔨 refactor: A code change that neither fixes a bug nor adds a feature' },\n { value: 'perf', name: '⚡️ perf: A code change that improves performance' },\n { value: 'test', name: '🔍 test: Adding missing tests or correcting existing tests' },\n { value: 'build', name: '📦 build: Changes that affect the build system or external dependencies' },\n { value: 'ci', name: '🤖 ci: Changes to our CI configuration files and scripts' },\n { value: 'chore', name: \"🧹 chore: Other changes that don't modify src or test files\" },\n { value: 'break', name: '💥 break: A change that breaks existing functionality' },\n { value: 'revert', name: '⏪ revert: Reverts a previous commit' },\n ],\n },\n {\n type: 'input',\n name: 'scope',\n message: 'What is the scope of this change (e.g. component or file name): (press enter to skip)',\n },\n {\n type: 'input',\n name: 'subject',\n message: (answers) => {\n const maxSubject = getMaxSubject({ answers, maxLineLength });\n return `Write a short, imperative tense description of the change (max ${maxSubject} chars):`;\n },\n validate: (input, answers) => {\n if (!input.trim()) {\n // \\u001b[31m is red\n return `\\u001b[31mSubject is required\\u001b[39m`;\n }\n const maxSubject = getMaxSubject({ answers: answers!, maxLineLength });\n if (input.length <= maxSubject) {\n return true;\n }\n // \\u001b[31m is red\n return `\\u001b[31mSubject length must be less than or equal to ${maxSubject} characters. Current length is ${input.length} characters.\\u001b[39m`;\n },\n transformer: (input, answers) => {\n const maxSubject = getMaxSubject({ answers, maxLineLength });\n const remaining = maxSubject - input.length;\n if (remaining < 0) {\n // Red if remaining < 0: \\u001b[31m is red, \\u001b[39m resets the color.\n return `\\n\\u001b[31m(${input.length}) ${input}\\u001b[39m`;\n }\n // Green if valid: \\u001b[32m is green, \\u001b[39m resets the color.\n return `\\n\\u001b[32m(${input.length}) ${input}\\u001b[39m`;\n },\n },\n {\n type: 'list',\n name: 'confirmCommit',\n choices: [\n { value: 'yes', name: 'Yes' },\n { value: 'no', name: 'Abort commit' },\n ],\n default: 0,\n message(answers) {\n const SEP = '--------------------------------------------------------';\n const message = getCommitMessage({ answers });\n console.info(`\\n${SEP}\\n\\n${message}\\n\\n${SEP}\\n`);\n return 'Are you sure you want to proceed with the commit above?';\n },\n },\n ];\n\n cz.prompt(questions).then((answers) => {\n if (answers.confirmCommit === 'no') {\n console.info('Commit aborted.');\n } else {\n const message = getCommitMessage({ answers });\n commit(message);\n }\n });\n },\n };\n}\n\nexport default prompter;\n","import fs from 'fs';\nimport path from 'path';\n\nimport Config from '../types/Config.js';\n\nconst config: Config = {\n maxLineLength: 120,\n};\nconst file = 'commit-wizard.config.json';\n\nfunction configLoader(): Config {\n const configPath = path.resolve(process.cwd(), file);\n\n if (!fs.existsSync(configPath)) {\n return config;\n }\n\n const loadedConfig = require(configPath);\n return { ...config, ...loadedConfig };\n}\n\nexport default configLoader;\n","import commitizenPrompter from './prompter.js';\nimport configLoader from '../configLoader/configLoader.js';\nimport Config from '../types/Config.js';\n\nconst loadedConfig: Config = configLoader();\nconst prompter = commitizenPrompter(loadedConfig);\n\nexport default prompter;\n"],"names":["getCommitMessage","answers","scopeText","scope","type","subject","getMaxSubject","maxLineLength","length","config","prompter","cz","commit","questions","name","message","choices","value","validate","input","trim","maxSubject","transformer","default","SEP","console","info","prompt","then","confirmCommit","commitizenPrompter","configPath","path","resolve","process","cwd","fs","existsSync","loadedConfig","require","configLoader"],"mappings":"sCAWA,SAASA,GAAiBC,QAAEA,IAC1B,MAAMC,EAAYD,EAAQE,MAAQ,IAAIF,EAAQE,SAAW,GACzD,GAAqB,UAAjBF,EAAQG,KAAkB,CAE5B,MADgB,OAAOF,OAAeD,EAAQI,SAEhD,CAEA,MADgB,GAAGJ,EAAQG,OAAOF,MAAcD,EAAQI,SAE1D,CAEA,SAASC,GAAcL,QAAEA,EAAOM,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M,OACtB,CAAEG,MAAO,KAAMH,KAAM,iBAEvBS,QAAS,EACTR,OAAAA,CAAQd,GACN,MAAMuB,EAAM,2DACNT,EAAUf,EAAiB,CAAEC,YAEnC,OADAwB,QAAQC,KAAK,KAAKF,QAAUT,QAAcS,OACnC,yDACT,IAIJb,EAAGgB,OAAOd,GAAWe,MAAM3B,IACzB,GAA8B,OAA1BA,EAAQ4B,cACVJ,QAAQC,KAAK,uBACR,CACL,MAAMX,EAAUf,EAAiB,CAAEC,YACnCW,EAAOG,EACT,IAEJ,EAEJ,CEhHiBe,CDKjB,WACE,MAAMC,EAAaC,EAAKC,QAAQC,QAAQC,MAH7B,6BAKX,IAAKC,EAAGC,WAAWN,GACjB,OAAOtB,EAGT,MAAM6B,EAAeC,QAAQR,GAC7B,MAAO,IAAKtB,KAAW6B,EACzB,CCf6BE"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/commitizen/prompter.ts","../../src/configLoader/configLoader.ts","../../src/commitizen/index.ts"],"sourcesContent":["import { Commitizen, Prompter, Question } from 'commitizen';\n\nimport CommitWizardOptions from '../types/CommitWizardOptions.js';\n\nexport type CommitAnswers = {\n type: string;\n scope: string;\n subject: string;\n confirmCommit: string;\n};\n\nfunction getCommitMessage({ answers }: { answers: CommitAnswers }) {\n const scopeText = answers.scope ? `(${answers.scope})` : '';\n if (answers.type === 'break') {\n const message = `feat${scopeText}!: ${answers.subject}`;\n return message;\n }\n const message = `${answers.type}${scopeText}: ${answers.subject}`;\n return message;\n}\n\nfunction getMaxSubject({ answers, maxLineLength }: { answers: CommitAnswers; maxLineLength: number }) {\n const scopeText = answers.scope ? `(${answers.scope})` : '';\n // +2 accounts for \": \" after type and scope.\n const prefixLength = (answers.type ? answers.type.length : 0) + scopeText.length + 2;\n const maxSubject = maxLineLength - prefixLength;\n return maxSubject;\n}\n\nfunction prompter({ maxLineLength }: CommitWizardOptions): Prompter {\n return {\n prompter: function (cz: Commitizen, commit: (message: string) => void) {\n const questions: Question<CommitAnswers> = [\n {\n type: 'list',\n name: 'type',\n message: \"Select the type of change that you're committing:\",\n choices: [\n { value: 'feat', name: '🚀 feat: A new feature' },\n { value: 'fix', name: '🐛 fix: A bug fix' },\n { value: 'docs', name: '📚 docs: Documentation only changes' },\n {\n value: 'style',\n name: '🎨 style: Changes that do not affect the meaning of the code (white-space, formatting, etc)',\n },\n { value: 'refactor', name: '🔨 refactor: A code change that neither fixes a bug nor adds a feature' },\n { value: 'perf', name: '⚡️ perf: A code change that improves performance' },\n { value: 'test', name: '🔍 test: Adding missing tests or correcting existing tests' },\n { value: 'build', name: '📦 build: Changes that affect the build system or external dependencies' },\n { value: 'ci', name: '🤖 ci: Changes to our CI configuration files and scripts' },\n { value: 'chore', name: \"🧹 chore: Other changes that don't modify src or test files\" },\n { value: 'break', name: '💥 break: A change that breaks existing functionality' },\n { value: 'revert', name: '⏪ revert: Reverts a previous commit' },\n ],\n },\n {\n type: 'input',\n name: 'scope',\n message: 'What is the scope of this change (e.g. component or file name): (press enter to skip)',\n },\n {\n type: 'input',\n name: 'subject',\n message: (answers) => {\n const maxSubject = getMaxSubject({ answers, maxLineLength });\n return `Write a short, imperative tense description of the change (max ${maxSubject} chars):`;\n },\n validate: (input, answers) => {\n if (!input.trim()) {\n // \\u001b[31m is red\n return `\\u001b[31mSubject is required\\u001b[39m`;\n }\n const maxSubject = getMaxSubject({ answers: answers!, maxLineLength });\n if (input.length <= maxSubject) {\n return true;\n }\n // \\u001b[31m is red\n return `\\u001b[31mSubject length must be less than or equal to ${maxSubject} characters. Current length is ${input.length} characters.\\u001b[39m`;\n },\n transformer: (input, answers) => {\n const maxSubject = getMaxSubject({ answers, maxLineLength });\n const remaining = maxSubject - input.length;\n if (remaining < 0) {\n // Red if remaining < 0: \\u001b[31m is red, \\u001b[39m resets the color.\n return `\\n\\u001b[31m(${input.length}) ${input}\\u001b[39m`;\n }\n // Green if valid: \\u001b[32m is green, \\u001b[39m resets the color.\n return `\\n\\u001b[32m(${input.length}) ${input}\\u001b[39m`;\n },\n },\n {\n type: 'list',\n name: 'confirmCommit',\n choices: [\n { value: 'yes', name: 'Yes' },\n { value: 'no', name: 'Abort commit' },\n ],\n default: 0,\n message(answers) {\n const SEP = '--------------------------------------------------------';\n const message = getCommitMessage({ answers });\n console.info(`\\n${SEP}\\n\\n${message}\\n\\n${SEP}\\n`);\n return 'Are you sure you want to proceed with the commit above?';\n },\n },\n ];\n\n cz.prompt(questions).then((answers) => {\n if (answers.confirmCommit === 'no') {\n console.info('Commit aborted.');\n } else {\n const message = getCommitMessage({ answers });\n commit(message);\n }\n });\n },\n };\n}\n\nexport default prompter;\n","import fs from 'fs';\nimport path from 'path';\n\nimport CommitWizardOptions from '../types/CommitWizardOptions.js';\n\nconst config: CommitWizardOptions = {\n maxLineLength: 120,\n};\nconst file = 'commit-wizard.config.json';\n\nfunction configLoader(): CommitWizardOptions {\n const configPath = path.resolve(process.cwd(), file);\n\n if (!fs.existsSync(configPath)) {\n return config;\n }\n\n const loadedConfig = require(configPath);\n return { ...config, ...loadedConfig };\n}\n\nexport default configLoader;\n","import commitizenPrompter from './prompter.js';\nimport configLoader from '../configLoader/configLoader.js';\nimport CommitWizardOptions from '../types/CommitWizardOptions.js';\n\nconst loadedConfig: CommitWizardOptions = configLoader();\nconst prompter = commitizenPrompter(loadedConfig);\n\nexport default prompter;\n"],"names":["getCommitMessage","answers","scopeText","scope","type","subject","getMaxSubject","maxLineLength","length","config","prompter","cz","commit","questions","name","message","choices","value","validate","input","trim","maxSubject","transformer","default","SEP","console","info","prompt","then","confirmCommit","commitizenPrompter","configPath","path","resolve","process","cwd","fs","existsSync","loadedConfig","require","configLoader"],"mappings":"sCAWA,SAASA,GAAiBC,QAAEA,IAC1B,MAAMC,EAAYD,EAAQE,MAAQ,IAAIF,EAAQE,SAAW,GACzD,GAAqB,UAAjBF,EAAQG,KAAkB,CAE5B,MADgB,OAAOF,OAAeD,EAAQI,SAEhD,CAEA,MADgB,GAAGJ,EAAQG,OAAOF,MAA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NU,KAAM,gBACNE,QAAS,CACP,CAAEC,MAAO,MAAOH,KAAM,OACtB,CAAEG,MAAO,KAAMH,KAAM,iBAEvBS,QAAS,EACTR,OAAAA,CAAQd,GACN,MAAMuB,EAAM,2DACNT,EAAUf,EAAiB,CAAEC,YAEnC,OADAwB,QAAQC,KAAK,KAAKF,QAAUT,QAAcS,OACnC,yDACT,IAIJb,EAAGgB,OAAOd,GAAWe,MAAM3B,IACzB,GAA8B,OAA1BA,EAAQ4B,cACVJ,QAAQC,KAAK,uBACR,CACL,MAAMX,EAAUf,EAAiB,CAAEC,YACnCW,EAAOG,EACT,IAEJ,EAEJ,CEhHiBe,CDKjB,WACE,MAAMC,EAAaC,EAAKC,QAAQC,QAAQC,MAH7B,6BAKX,IAAKC,EAAGC,WAAWN,GACjB,OAAOtB,EAGT,MAAM6B,EAAeC,QAAQR,GAC7B,MAAO,IAAKtB,KAAW6B,EACzB,CCf0CE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/configLoader/configLoader.ts","../../src/commitlint/index.ts","../../src/commitlint/userConfig.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport Config from '../types/Config.js';\n\nconst config: Config = {\n maxLineLength: 120,\n};\nconst file = 'commit-wizard.config.json';\n\nfunction configLoader(): Config {\n const configPath = path.resolve(process.cwd(), file);\n\n if (!fs.existsSync(configPath)) {\n return config;\n }\n\n const loadedConfig = require(configPath);\n return { ...config, ...loadedConfig };\n}\n\nexport default configLoader;\n","import { UserConfig } from '@commitlint/types';\n\nimport commitlintUserConfig from './userConfig.js';\nimport configLoader from '../configLoader/configLoader.js';\nimport Config from '../types/Config.js';\n\nconst loadedConfig: Config = configLoader();\nconst userConfig: UserConfig = commitlintUserConfig(loadedConfig);\n\nexport default userConfig;\n","import { UserConfig } from '@commitlint/types';\n\nimport Config from '../types/Config.js';\n\nfunction userConfig({ maxLineLength }: Config): UserConfig {\n return {\n extends: ['@commitlint/config-conventional'],\n parserPreset: {\n parserOpts: {\n headerPattern: /^(?<type>\\w+)(?<exclamation1>!?)(?:\\((?<scope>[^)]+)\\)(?<exclamation2>!?))?: (?<subject>.+)$/,\n headerCorrespondence: ['type', 'exclamation1', 'scope', 'exclamation2', 'subject'],\n },\n },\n rules: {\n 'header-max-length': [2, 'always', maxLineLength] as [number, 'always' | 'never', number],\n },\n };\n}\n\nexport default userConfig;\n"],"names":["config","maxLineLength","userConfig","extends","parserPreset","parserOpts","headerPattern","RegExp","headerCorrespondence","rules","commitlintUserConfig","configPath","path","resolve","process","cwd","fs","existsSync","loadedConfig","require","configLoader"],"mappings":"sCAKA,MAAMA,EAAiB,CACrBC,cAAe,KCAjB,MACMC,ECHN,UAAoBD,cAAEA,IACpB,MAAO,CACLE,QAAS,CAAC,mCACVC,aAAc,CACZC,WAAY,CACVC,cAAeC,OAAA,mGACfC,qBAAsB,CAAC,OAAQ,eAAgB,QAAS,eAAgB,aAG5EC,MAAO,CACL,oBAAqB,CAAC,EAAG,SAAUR,IAGzC,CDV+BS,CDG/B,WACE,MAAMC,EAAaC,EAAKC,QAAQC,QAAQC,MAH7B,6BAKX,IAAKC,EAAGC,WAAWN,GACjB,OAAOX,EAGT,MAAMkB,EAAeC,QAAQR,GAC7B,MAAO,IAAKX,KAAWkB,EACzB,CCb6BE"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/configLoader/configLoader.ts","../../src/commitlint/index.ts","../../src/commitlint/userConfig.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport CommitWizardOptions from '../types/CommitWizardOptions.js';\n\nconst config: CommitWizardOptions = {\n maxLineLength: 120,\n};\nconst file = 'commit-wizard.config.json';\n\nfunction configLoader(): CommitWizardOptions {\n const configPath = path.resolve(process.cwd(), file);\n\n if (!fs.existsSync(configPath)) {\n return config;\n }\n\n const loadedConfig = require(configPath);\n return { ...config, ...loadedConfig };\n}\n\nexport default configLoader;\n","import { UserConfig } from '@commitlint/types';\n\nimport commitlintUserConfig from './userConfig.js';\nimport configLoader from '../configLoader/configLoader.js';\nimport CommitWizardOptions from '../types/CommitWizardOptions.js';\n\nconst loadedConfig: CommitWizardOptions = configLoader();\nconst userConfig: UserConfig = commitlintUserConfig(loadedConfig);\n\nexport default userConfig;\n","import { UserConfig } from '@commitlint/types';\n\nimport CommitWizardOptions from '../types/CommitWizardOptions.js';\n\nfunction userConfig({ maxLineLength }: CommitWizardOptions): UserConfig {\n return {\n extends: ['@commitlint/config-conventional'],\n parserPreset: {\n parserOpts: {\n headerPattern: /^(?<type>\\w+)(?<exclamation1>!?)(?:\\((?<scope>[^)]+)\\)(?<exclamation2>!?))?: (?<subject>.+)$/,\n headerCorrespondence: ['type', 'exclamation1', 'scope', 'exclamation2', 'subject'],\n },\n },\n rules: {\n 'header-max-length': [2, 'always', maxLineLength] as [number, 'always' | 'never', number],\n },\n };\n}\n\nexport default userConfig;\n"],"names":["config","maxLineLength","userConfig","extends","parserPreset","parserOpts","headerPattern","RegExp","headerCorrespondence","rules","commitlintUserConfig","configPath","path","resolve","process","cwd","fs","existsSync","loadedConfig","require","configLoader"],"mappings":"sCAKA,MAAMA,EAA8B,CAClCC,cAAe,KCAjB,MACMC,ECHN,UAAoBD,cAAEA,IACpB,MAAO,CACLE,QAAS,CAAC,mCACVC,aAAc,CACZC,WAAY,CACVC,cAAeC,OAAA,mGACfC,qBAAsB,CAAC,OAAQ,eAAgB,QAAS,eAAgB,aAG5EC,MAAO,CACL,oBAAqB,CAAC,EAAG,SAAUR,IAGzC,CDV+BS,CDG/B,WACE,MAAMC,EAAaC,EAAKC,QAAQC,QAAQC,MAH7B,6BAKX,IAAKC,EAAGC,WAAWN,GACjB,OAAOX,EAGT,MAAMkB,EAAeC,QAAQR,GAC7B,MAAO,IAAKX,KAAWkB,EACzB,CCb0CE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarsilla/commit-wizard",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,8 +1,8 @@
1
1
  import commitizenPrompter from './prompter.js';
2
2
  import configLoader from '../configLoader/configLoader.js';
3
- import Config from '../types/Config.js';
3
+ import CommitWizardOptions from '../types/CommitWizardOptions.js';
4
4
 
5
- const loadedConfig: Config = configLoader();
5
+ const loadedConfig: CommitWizardOptions = configLoader();
6
6
  const prompter = commitizenPrompter(loadedConfig);
7
7
 
8
8
  export default prompter;
@@ -1,6 +1,6 @@
1
1
  import { Commitizen, Prompter, Question } from 'commitizen';
2
2
 
3
- import Config from '../types/Config.js';
3
+ import CommitWizardOptions from '../types/CommitWizardOptions.js';
4
4
 
5
5
  export type CommitAnswers = {
6
6
  type: string;
@@ -27,7 +27,7 @@ function getMaxSubject({ answers, maxLineLength }: { answers: CommitAnswers; max
27
27
  return maxSubject;
28
28
  }
29
29
 
30
- function prompter({ maxLineLength }: Config): Prompter {
30
+ function prompter({ maxLineLength }: CommitWizardOptions): Prompter {
31
31
  return {
32
32
  prompter: function (cz: Commitizen, commit: (message: string) => void) {
33
33
  const questions: Question<CommitAnswers> = [
@@ -0,0 +1 @@
1
+ npx --no -- commitlint --edit $1
@@ -2,9 +2,9 @@ import { UserConfig } from '@commitlint/types';
2
2
 
3
3
  import commitlintUserConfig from './userConfig.js';
4
4
  import configLoader from '../configLoader/configLoader.js';
5
- import Config from '../types/Config.js';
5
+ import CommitWizardOptions from '../types/CommitWizardOptions.js';
6
6
 
7
- const loadedConfig: Config = configLoader();
7
+ const loadedConfig: CommitWizardOptions = configLoader();
8
8
  const userConfig: UserConfig = commitlintUserConfig(loadedConfig);
9
9
 
10
10
  export default userConfig;
@@ -1,8 +1,8 @@
1
1
  import { UserConfig } from '@commitlint/types';
2
2
 
3
- import Config from '../types/Config.js';
3
+ import CommitWizardOptions from '../types/CommitWizardOptions.js';
4
4
 
5
- function userConfig({ maxLineLength }: Config): UserConfig {
5
+ function userConfig({ maxLineLength }: CommitWizardOptions): UserConfig {
6
6
  return {
7
7
  extends: ['@commitlint/config-conventional'],
8
8
  parserPreset: {
@@ -1,14 +1,14 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
 
4
- import Config from '../types/Config.js';
4
+ import CommitWizardOptions from '../types/CommitWizardOptions.js';
5
5
 
6
- const config: Config = {
6
+ const config: CommitWizardOptions = {
7
7
  maxLineLength: 120,
8
8
  };
9
9
  const file = 'commit-wizard.config.json';
10
10
 
11
- function configLoader(): Config {
11
+ function configLoader(): CommitWizardOptions {
12
12
  const configPath = path.resolve(process.cwd(), file);
13
13
 
14
14
  if (!fs.existsSync(configPath)) {
@@ -0,0 +1,42 @@
1
+ name: Publish to npm
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows: ["Code Analysis"]
6
+ types:
7
+ - completed
8
+
9
+ permissions:
10
+ contents: read # for checkout
11
+
12
+ jobs:
13
+ publish:
14
+ name: Publish
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ contents: write # to be able to publish a GitHub release
18
+ issues: write # to be able to comment on released issues
19
+ pull-requests: write # to be able to comment on released pull requests
20
+ id-token: write # to enable use of OIDC for npm provenance
21
+
22
+ steps:
23
+ - name: Checkout code
24
+ uses: actions/checkout@v4
25
+
26
+ - name: Setup Node.js
27
+ uses: actions/setup-node@v4
28
+ with:
29
+ node-version: '22.x'
30
+ registry-url: 'https://registry.npmjs.org'
31
+
32
+ - name: Install dependencies
33
+ run: npm ci
34
+
35
+ - name: Build
36
+ run: npm run build
37
+
38
+ - name: Publish to npm
39
+ env:
40
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
42
+ run: npx semantic-release
@@ -0,0 +1,5 @@
1
+ type CommitWizardOptions = {
2
+ maxLineLength: number;
3
+ };
4
+
5
+ export default CommitWizardOptions;
@@ -1,5 +0,0 @@
1
- type Config = {
2
- maxLineLength: number;
3
- };
4
-
5
- export default Config;