/
@changesets+cli+2.26.1.patch
184 lines (170 loc) · 7.06 KB
/
@changesets+cli+2.26.1.patch
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
diff --git a/node_modules/@changesets/cli/dist/cli.cjs.dev.js b/node_modules/@changesets/cli/dist/cli.cjs.dev.js
index 73ab02a..70bb64b 100644
--- a/node_modules/@changesets/cli/dist/cli.cjs.dev.js
+++ b/node_modules/@changesets/cli/dist/cli.cjs.dev.js
@@ -101,7 +101,7 @@ function _objectSpread2(target) {
return target;
}
-const pkgPath = path__default['default'].dirname(require.resolve("@changesets/cli/package.json")); // Modify base branch to "main" without changing defaultWrittenConfig since it also serves as a fallback
+// const pkgPath = path__default['default'].dirname(require.resolve("@changesets/cli/package.json")); // Modify base branch to "main" without changing defaultWrittenConfig since it also serves as a fallback
// for config files that don't specify a base branch. Changing that to main would be a breaking change.
const defaultConfig = `${JSON.stringify(_objectSpread2(_objectSpread2({}, config.defaultWrittenConfig), {}, {
@@ -127,7 +127,7 @@ async function init(cwd) {
logger.warn("It looks like you already have changesets initialized. You should be able to run changeset commands no problems.");
}
} else {
- await fs__default['default'].copy(path__default['default'].resolve(pkgPath, "./default-files"), changesetBase);
+ // await fs__default['default'].copy(path__default['default'].resolve(pkgPath, "./default-files"), changesetBase);
await fs__default['default'].writeFile(path__default['default'].resolve(changesetBase, "config.json"), defaultConfig);
logger.log(chalk__default['default']`Thanks for choosing {green changesets} to help manage your versioning and publishing\n`);
logger.log("You should be set up to start using changesets now!\n");
@@ -335,6 +335,62 @@ function formatPkgNameAndVersion(pkgName, version) {
async function createChangeset(changedPackages, allPackages) {
const releases = [];
+// PATCH: verify that CLI is run in a supported repository
+ const SUPPORTED_PRIMER_PACKAGES = [
+ "@primer/react",
+ "@primer/view-components",
+ ];
+ const pkgPath = require(path__default["default"].join(
+ process.cwd(),
+ "package.json"
+ ));
+ let pkg;
+ try {
+ pkg = require(path__default["default"].join(process.cwd(), "package.json"));
+ } catch {
+ throw new Error(
+ `This CLI must be run in a Primer package repository. No package.json found at ${pkgPath}`
+ );
+ }
+
+ const primerPackages = [];
+
+ if (pkg.name === "@primer/react") {
+ const componentsPath = path__default["default"].join(
+ process.cwd(),
+ "generated/components.json"
+ );
+ logger.log(
+ `Loading components information for ${pkg.name} from ${componentsPath}`
+ );
+ const { components } = require(componentsPath);
+ primerPackages.push(
+ ...Object.values(components).map((component) => component.name)
+ );
+ } else if (pkg.name === "@primer/view-components") {
+ const componentsPath = path__default["default"].join(
+ process.cwd(),
+ "static/info_arch.json"
+ );
+
+ logger.log(
+ `Loading components information for ${pkg.name} from ${componentsPath}`
+ );
+
+ const components = require(componentsPath);
+ primerPackages.push(
+ ...Object.values(components).map((component) => component.fully_qualified_name)
+ );
+ } else {
+ if (!SUPPORTED_PRIMER_PACKAGES.includes(pkg.name)) {
+ throw new Error(
+ `This CLI is only supported in the following packages: ${SUPPORTED_PRIMER_PACKAGES.join(
+ ", "
+ )}`
+ );
+ }
+ }
+
if (allPackages.length > 1) {
const packagesToRelease = await getPackagesToRelease(changedPackages, allPackages);
let pkgJsonsByName = getPkgJsonsByName(allPackages);
@@ -458,10 +514,21 @@ async function createChangeset(changedPackages, allPackages) {
}
}
+ logger.log(
+ chalk__default["default"].gray(
+ " (select packages with <space>, type to filter, confirm with <enter>)"
+ )
+ );
+ const selectedPrimerPackages = await askCheckboxPlus(
+ `Which Primer packages have been affected by this change?`,
+ primerPackages
+ );
+
return {
confirmed: false,
summary,
- releases
+ selectedPrimerPackages,
+ releases,
};
}
@@ -531,7 +598,8 @@ async function add(cwd, {
});
const changedPackagesName = changedPackages.filter(pkg => isListablePackage(config, pkg.packageJson)).map(pkg => pkg.packageJson.name);
newChangeset = await createChangeset(changedPackagesName, listablePackages);
- printConfirmationMessage(newChangeset, listablePackages.length > 1);
+ // printConfirmationMessage(newChangeset, listablePackages.length > 1);
+ newChangeset.confirmed = true
if (!newChangeset.confirmed) {
newChangeset = _objectSpread2(_objectSpread2({}, newChangeset), {}, {
@@ -542,6 +610,15 @@ async function add(cwd, {
if (newChangeset.confirmed) {
const changesetID = await writeChangeset__default['default'](newChangeset, cwd);
+
+ // PATCH - add changed modules to changeset summary
+ const changesetPath = path__default['default'].resolve(changesetBase, `${changesetID}.md`);
+ let content = await fs__default['default'].readFile(changesetPath, 'utf8')
+
+ content += `\nChanged components: ${newChangeset.selectedPrimerPackages.join(", ") || "_none_"}\n`
+
+ await fs__default['default'].writeFile(changesetPath, content)
+
const [{
getAddMessage
}, commitOpts] = getCommitFunctions(config.commit, cwd);
@@ -565,7 +642,7 @@ async function add(cwd, {
logger.log(chalk__default['default'].green("If you want to modify or expand on the changeset summary, you can find it here"));
}
- const changesetPath = path__default['default'].resolve(changesetBase, `${changesetID}.md`);
+
logger.info(chalk__default['default'].blue(changesetPath));
if (open) {
@@ -1565,7 +1642,9 @@ const {
}
});
+
const cwd = process.cwd();
+
run$2(input, flags, cwd).catch(err => {
if (err instanceof errors.InternalError) {
logger.error("The following error is an internal unexpected error, these should never happen.");
@@ -1578,8 +1657,8 @@ ${util.format("", err).replace(process.cwd(), "<cwd>")}
## Versions
-- @changesets/cli@${// eslint-disable-next-line import/no-extraneous-dependencies
- require("@changesets/cli/package.json").version}
+- primer-changesets-cli@${// eslint-disable-next-line import/no-extraneous-dependencies
+ require(".").version}
- node@${process.version}
## Extra details
diff --git a/node_modules/@changesets/cli/dist/cli.cjs.js b/node_modules/@changesets/cli/dist/cli.cjs.js
index 47258e0..a37beff 100644
--- a/node_modules/@changesets/cli/dist/cli.cjs.js
+++ b/node_modules/@changesets/cli/dist/cli.cjs.js
@@ -1,7 +1,9 @@
'use strict';
-if (process.env.NODE_ENV === "production") {
- module.exports = require("./cli.cjs.prod.js");
-} else {
- module.exports = require("./cli.cjs.dev.js");
-}
+// if (process.env.NODE_ENV === "production") {
+// module.exports = require("./cli.cjs.prod.js");
+// } else {
+// module.exports = require("./cli.cjs.dev.js");
+// }
+
+module.exports = require("./cli.cjs.dev.js");
\ No newline at end of file