commitizen 4.2.6 → 4.3.1

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
@@ -58,13 +58,14 @@ npm install commitizen -g
58
58
  Next, initialize your project to use the cz-conventional-changelog adapter by typing:
59
59
 
60
60
  ```sh
61
+ # npm
61
62
  commitizen init cz-conventional-changelog --save-dev --save-exact
62
- ```
63
-
64
- Or if you are using Yarn:
65
63
 
66
- ```sh
64
+ # yarn
67
65
  commitizen init cz-conventional-changelog --yarn --dev --exact
66
+
67
+ # pnpm
68
+ commitizen init cz-conventional-changelog --pnpm --save-dev --save-exact
68
69
  ```
69
70
 
70
71
  Note that if you want to force install over the top of an old adapter, you can apply the `--force` argument. For more information on this, just run `commitizen help`.
@@ -278,6 +279,7 @@ We know that every project and build process has different requirements, so we'v
278
279
  - [cz-format-extension](https://github.com/tyankatsu0105/cz-format-extension)
279
280
  - [cz-emoji-conventional](https://www.npmjs.com/package/cz-emoji-conventional)
280
281
  - [cz-git](https://github.com/Zhengqbbb/cz-git)
282
+ - [cz-vinyl](https://github.com/Exlint/cz-vinyl)
281
283
 
282
284
  To create an adapter, just fork one of these great adapters and modify it to suit your needs. We pass you an instance of [Inquirer.js](https://github.com/SBoudrias/Inquirer.js/), but you can capture input using whatever means necessary. Just call the `commit` callback with a string and we'll be happy. Publish it to npm, and you'll be all set!
283
285
 
@@ -4,32 +4,28 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.bootstrap = bootstrap;
7
-
8
7
  var _commitizen = require("../commitizen");
9
-
10
8
  var _parsers = require("./parsers");
11
-
12
9
  let {
13
10
  parse
14
11
  } = _parsers.commitizen;
15
-
16
12
  /**
17
13
  * This is the main cli entry point.
18
14
  * environment may be used for debugging.
19
15
  */
20
16
  function bootstrap(environment = {}, argv = process.argv) {
21
17
  // Get cli args
22
- let rawGitArgs = argv.slice(2, argv.length); // Parse the args
18
+ let rawGitArgs = argv.slice(2, argv.length);
23
19
 
20
+ // Parse the args
24
21
  let parsedArgs = parse(rawGitArgs);
25
- let command = parsedArgs._[0]; // Do actions based on commands
22
+ let command = parsedArgs._[0];
26
23
 
24
+ // Do actions based on commands
27
25
  if (command === "init") {
28
26
  let adapterNpmName = parsedArgs._[1];
29
-
30
27
  if (adapterNpmName) {
31
28
  console.log(`Attempting to initialize using the npm package ${adapterNpmName}`);
32
-
33
29
  try {
34
30
  (0, _commitizen.init)(process.cwd(), adapterNpmName, parsedArgs);
35
31
  } catch (e) {
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.bootstrap = bootstrap;
7
-
8
7
  var _commitizen = require("../commitizen");
9
-
10
8
  var _strategies = require("./strategies");
11
-
12
9
  /**
13
10
  * This is the main cli entry point.
14
11
  * environment may be used for debugging.
@@ -16,10 +13,9 @@ var _strategies = require("./strategies");
16
13
  function bootstrap(environment = {}, argv = process.argv) {
17
14
  // Get cli args
18
15
  let rawGitArgs = argv.slice(2, argv.length);
16
+ let adapterConfig = environment.config || _commitizen.configLoader.load();
19
17
 
20
- let adapterConfig = environment.config || _commitizen.configLoader.load(); // Choose a strategy based on the existance the adapter config
21
-
22
-
18
+ // Choose a strategy based on the existance the adapter config
23
19
  if (typeof adapterConfig !== 'undefined') {
24
20
  // This tells commitizen we're in business
25
21
  (0, _strategies.gitCz)(rawGitArgs, environment, adapterConfig);
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.parse = parse;
7
-
8
7
  var _minimist = _interopRequireDefault(require("minimist"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  /**
13
10
  * Takes args, parses with minimist and some ugly vudoo, returns output
14
11
  *
@@ -6,48 +6,37 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.parse = parse;
7
7
  const reShortMessage = /^-([a-zA-Z]*)m(.*)$/;
8
8
  const reLongMessage = /^--message(=.*)?$/;
9
+
9
10
  /**
10
11
  * Strip message declaration from git arguments
11
12
  */
12
-
13
13
  function parse(rawGitArgs) {
14
14
  let result = [];
15
15
  let skipNext = false;
16
-
17
16
  for (const arg of rawGitArgs) {
18
17
  let match;
19
-
20
18
  if (skipNext) {
21
19
  skipNext = false;
22
20
  continue;
23
21
  }
24
-
25
22
  match = reShortMessage.exec(arg);
26
-
27
23
  if (match) {
28
24
  if (match[1]) {
29
25
  result.push(`-${match[1]}`);
30
26
  }
31
-
32
27
  if (!match[2]) {
33
28
  skipNext = true;
34
29
  }
35
-
36
30
  continue;
37
31
  }
38
-
39
32
  match = reLongMessage.exec(arg);
40
-
41
33
  if (match) {
42
34
  if (!match[1]) {
43
35
  skipNext = true;
44
36
  }
45
-
46
37
  continue;
47
38
  }
48
-
49
39
  result.push(arg);
50
40
  }
51
-
52
41
  return result;
53
42
  }
@@ -4,15 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.gitCz = exports.commitizen = void 0;
7
-
8
7
  var commitizen = _interopRequireWildcard(require("./parsers/commitizen"));
9
-
10
8
  exports.commitizen = commitizen;
11
-
12
9
  var gitCz = _interopRequireWildcard(require("./parsers/git-cz"));
13
-
14
10
  exports.gitCz = gitCz;
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -4,25 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _inquirer = _interopRequireDefault(require("inquirer"));
9
-
10
8
  var _findRoot = _interopRequireDefault(require("find-root"));
11
-
12
9
  var _util = require("../../common/util");
13
-
14
10
  var _parsers = require("../parsers");
15
-
16
11
  var _commitizen = require("../../commitizen");
17
-
18
12
  var gitStrategy = _interopRequireWildcard(require("./git"));
19
-
20
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
-
22
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
-
24
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
16
  // destructure for shorter apis
27
17
  let {
28
18
  parse
@@ -37,26 +27,27 @@ let {
37
27
  } = _commitizen.staging;
38
28
  var _default = gitCz;
39
29
  exports.default = _default;
40
-
41
30
  function gitCz(rawGitArgs, environment, adapterConfig) {
42
31
  // See if any override conditions exist.
32
+
43
33
  // In these very specific scenarios we may want to use a different
44
34
  // commit strategy than git-cz. For example, in the case of --amend
45
35
  let parsedCommitizenArgs = _parsers.commitizen.parse(rawGitArgs);
46
-
47
36
  if (parsedCommitizenArgs.amend) {
48
37
  // console.log('override --amend in place');
49
38
  gitStrategy.default(rawGitArgs, environment);
50
39
  return;
51
- } // Now, if we've made it past overrides, proceed with the git-cz strategy
40
+ }
52
41
 
42
+ // Now, if we've made it past overrides, proceed with the git-cz strategy
43
+ let parsedGitCzArgs = parse(rawGitArgs);
53
44
 
54
- let parsedGitCzArgs = parse(rawGitArgs); // Determine if we need to process this commit as a retry instead of a
45
+ // Determine if we need to process this commit as a retry instead of a
55
46
  // normal commit.
47
+ let retryLastCommit = rawGitArgs && rawGitArgs[0] === '--retry';
56
48
 
57
- let retryLastCommit = rawGitArgs && rawGitArgs[0] === '--retry'; // Determine if we need to process this commit using interactive hook mode
49
+ // Determine if we need to process this commit using interactive hook mode
58
50
  // for husky prepare-commit-message
59
-
60
51
  let hookMode = !(typeof parsedCommitizenArgs.hook === 'undefined');
61
52
  let resolvedAdapterConfigPath = resolveAdapterPath(adapterConfig.path);
62
53
  let resolvedAdapterRootPath = (0, _findRoot.default)(resolvedAdapterConfigPath);
@@ -66,12 +57,11 @@ function gitCz(rawGitArgs, environment, adapterConfig) {
66
57
  if (error) {
67
58
  throw error;
68
59
  }
69
-
70
60
  if (stagingIsClean && !parsedGitCzArgs.includes('--allow-empty')) {
71
61
  throw new Error('No files added to staging! Did you forget to run git add?');
72
- } // OH GOD IM SORRY FOR THIS SECTION
73
-
62
+ }
74
63
 
64
+ // OH GOD IM SORRY FOR THIS SECTION
75
65
  let adapterPackageJson = (0, _util.getParsedPackageJsonFromPath)(resolvedAdapterRootPath);
76
66
  let cliPackageJson = (0, _util.getParsedPackageJsonFromPath)(environment.cliPath);
77
67
  console.log(`cz-cli@${cliPackageJson.version}, ${adapterPackageJson.name}@${adapterPackageJson.version}\n`);
@@ -86,6 +76,7 @@ function gitCz(rawGitArgs, environment, adapterConfig) {
86
76
  if (error) {
87
77
  throw error;
88
78
  }
79
+ process.exit(0);
89
80
  });
90
81
  }, shouldStageAllFiles);
91
82
  }
@@ -4,26 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _child_process = _interopRequireDefault(require("child_process"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  var _default = git; // We don't have a config, so either we use raw args to try to commit
13
10
  // or if debug is enabled then we do a strict check for a config file.
14
-
15
11
  exports.default = _default;
16
-
17
12
  function git(rawGitArgs, environment) {
18
13
  if (environment.debug === true) {
19
14
  console.error('COMMITIZEN DEBUG: No cz friendly config was detected. I looked for .czrc, .cz.json, or czConfig in package.json.');
20
15
  } else {
21
16
  var vanillaGitArgs = ["commit"].concat(rawGitArgs);
22
-
23
17
  var child = _child_process.default.spawn('git', vanillaGitArgs, {
24
18
  stdio: 'inherit'
25
19
  });
26
-
27
20
  child.on('error', function (e, code) {
28
21
  console.error(e);
29
22
  throw e;
@@ -15,9 +15,6 @@ Object.defineProperty(exports, "gitCz", {
15
15
  return _gitCz.default;
16
16
  }
17
17
  });
18
-
19
18
  var _git = _interopRequireDefault(require("./strategies/git"));
20
-
21
19
  var _gitCz = _interopRequireDefault(require("./strategies/git-cz"));
22
-
23
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }