/
command.js
138 lines (131 loc) · 4.01 KB
/
command.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
"use strict";
/**
* @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module
*/
exports.command = "publish";
exports.describe = "Publish packages in the current project";
exports.builder = yargs => {
const cdVersionOptions = ["major", "minor", "patch", "premajor", "preminor", "prepatch", "prerelease"];
const cdVersionOptionString = `'${cdVersionOptions.slice(0, -1).join("', '")}', or '${
cdVersionOptions[cdVersionOptions.length - 1]
}'.`;
// TODO: share only relevant options with `lerna changed`
const opts = {
"allow-branch": {
describe: "Specify which branches to allow publishing from.",
type: "array",
},
canary: {
defaultDescription: "alpha",
describe: "Publish packages after every successful merge using the sha as part of the tag.",
alias: "c",
// NOTE: this type must remain undefined, as it is too overloaded to make sense
// type: "string",
},
"cd-version": {
describe: `Skip the version selection prompt and increment semver: ${cdVersionOptionString}`,
type: "string",
requiresArg: true,
coerce: choice => {
if (cdVersionOptions.indexOf(choice) === -1) {
throw new Error(`--cd-version must be one of: ${cdVersionOptionString}`);
}
return choice;
},
},
"conventional-commits": {
describe: "Use angular conventional-commit format to determine version bump and generate CHANGELOG.",
type: "boolean",
},
"changelog-preset": {
describe: "Use another conventional-changelog preset rather than angular.",
type: "string",
},
exact: {
describe: "Specify cross-dependency version numbers exactly rather than with a caret (^).",
type: "boolean",
},
"git-remote": {
defaultDescription: "origin",
describe: "Push git changes to the specified remote instead of 'origin'.",
type: "string",
requiresArg: true,
},
"ignore-changes": {
describe: "Ignore changes in files matched by glob(s).",
type: "array",
},
message: {
describe: "Use a custom commit message when creating the publish commit.",
alias: "m",
type: "string",
requiresArg: true,
},
amend: {
describe: "Amend the existing commit, instead of generating a new one.",
type: "boolean",
},
"npm-tag": {
describe: "Publish packages with the specified npm dist-tag",
type: "string",
requiresArg: true,
},
"npm-client": {
describe: "Executable used to publish dependencies (npm, yarn, pnpm, ...)",
type: "string",
requiresArg: true,
},
registry: {
describe: "Use the specified registry for all npm client operations.",
type: "string",
requiresArg: true,
},
preid: {
describe: "Specify the prerelease identifier (major.minor.patch-pre).",
type: "string",
requiresArg: true,
},
"repo-version": {
describe: "Specify repo version to publish.",
type: "string",
requiresArg: true,
},
"skip-git": {
describe: "Skip commiting, tagging, and pushing git changes.",
type: "boolean",
},
"skip-npm": {
describe: "Stop before actually publishing change to npm.",
type: "boolean",
},
"temp-tag": {
describe: "Create a temporary tag while publishing.",
type: "boolean",
},
yes: {
describe: "Skip all confirmation prompts.",
type: "boolean",
},
};
return yargs
.options(opts)
.group(Object.keys(opts), "Command Options:")
.option("ignore", {
// NOT the same as filter-options --ignore
hidden: true,
conflicts: "ignore-changes",
type: "array",
})
.check(argv => {
if (argv.ignore) {
/* eslint-disable no-param-reassign */
argv.ignoreChanges = argv.ignore;
delete argv.ignore;
/* eslint-enable no-param-reassign */
}
return argv;
});
};
exports.handler = function handler(argv) {
return require(".")(argv);
};