beachball 2.65.2 → 2.65.4
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 +4 -0
- package/lib/changefile/getAllChangedPackages.d.ts +18 -0
- package/lib/changefile/getAllChangedPackages.d.ts.map +1 -0
- package/lib/changefile/getAllChangedPackages.js +78 -0
- package/lib/changefile/getAllChangedPackages.js.map +1 -0
- package/lib/changefile/getCatalogChangedPackages.d.ts +19 -0
- package/lib/changefile/getCatalogChangedPackages.d.ts.map +1 -0
- package/lib/changefile/getCatalogChangedPackages.js +84 -0
- package/lib/changefile/getCatalogChangedPackages.js.map +1 -0
- package/lib/changefile/getChangedPackages.d.ts +12 -14
- package/lib/changefile/getChangedPackages.d.ts.map +1 -1
- package/lib/changefile/getChangedPackages.js +56 -109
- package/lib/changefile/getChangedPackages.js.map +1 -1
- package/lib/changefile/isPackageIncluded.d.ts +18 -0
- package/lib/changefile/isPackageIncluded.d.ts.map +1 -0
- package/lib/changefile/isPackageIncluded.js +33 -0
- package/lib/changefile/isPackageIncluded.js.map +1 -0
- package/lib/changefile/writeChangeFiles.d.ts.map +1 -1
- package/lib/changefile/writeChangeFiles.js +6 -10
- package/lib/changefile/writeChangeFiles.js.map +1 -1
- package/lib/commands/configGet.js +3 -3
- package/lib/commands/configGet.js.map +1 -1
- package/lib/commands/configList.js +2 -2
- package/lib/commands/configList.js.map +1 -1
- package/lib/commands/publish.d.ts.map +1 -1
- package/lib/commands/publish.js +5 -0
- package/lib/commands/publish.js.map +1 -1
- package/lib/git/ensureSharedHistory.d.ts +8 -2
- package/lib/git/ensureSharedHistory.d.ts.map +1 -1
- package/lib/git/ensureSharedHistory.js +40 -23
- package/lib/git/ensureSharedHistory.js.map +1 -1
- package/lib/git/fetch.d.ts +16 -4
- package/lib/git/fetch.d.ts.map +1 -1
- package/lib/git/fetch.js +21 -9
- package/lib/git/fetch.js.map +1 -1
- package/lib/monorepo/diffCatalogs.d.ts +14 -0
- package/lib/monorepo/diffCatalogs.d.ts.map +1 -0
- package/lib/monorepo/diffCatalogs.js +47 -0
- package/lib/monorepo/diffCatalogs.js.map +1 -0
- package/lib/monorepo/filterIgnoredFiles.d.ts +1 -1
- package/lib/monorepo/filterIgnoredFiles.d.ts.map +1 -1
- package/lib/monorepo/filterIgnoredFiles.js +11 -5
- package/lib/monorepo/filterIgnoredFiles.js.map +1 -1
- package/lib/packageManager/npmAuthEnvPassthrough.d.ts +32 -0
- package/lib/packageManager/npmAuthEnvPassthrough.d.ts.map +1 -0
- package/lib/packageManager/npmAuthEnvPassthrough.js +90 -0
- package/lib/packageManager/npmAuthEnvPassthrough.js.map +1 -0
- package/lib/packageManager/packageManager.d.ts.map +1 -1
- package/lib/packageManager/packageManager.js +2 -19
- package/lib/packageManager/packageManager.js.map +1 -1
- package/lib/types/BeachballOptions.d.ts +1 -0
- package/lib/types/BeachballOptions.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -110,6 +110,10 @@ beachball publish -r http://localhost:4873 -t beta
|
|
|
110
110
|
|
|
111
111
|
In large monorepos, the process of fetching versions for sync or before publishing can be time-consuming due to the high number of packages. To optimize performance, you can override the concurrency for fetching from the registry by setting `options.npmReadConcurrency` (default: 5). You can also increase concurrency for hook calls and publish operations via `options.concurrency` (default: 1; respects topological order).
|
|
112
112
|
|
|
113
|
+
### Optimizing for large monorepos
|
|
114
|
+
|
|
115
|
+
If you have a large to very large monorepo, there are several configuration options and strategies that can help improve Beachball's performance. For details, see the [large repos guide](https://microsoft.github.io/beachball/concepts/large-repos.html).
|
|
116
|
+
|
|
113
117
|
### API surface
|
|
114
118
|
|
|
115
119
|
Beachball **does not** have a public API beyond the provided [options](https://microsoft.github.io/beachball/overview/configuration.html). Usage of private APIs is not supported and may break at any time.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BeachballOptions } from '../types/BeachballOptions';
|
|
2
|
+
import type { PackageInfos, ScopedPackages } from '../types/PackageInfo';
|
|
3
|
+
/**
|
|
4
|
+
* Gets all the changed package names, regardless of the change files.
|
|
5
|
+
*
|
|
6
|
+
* PRE: Assumes shared git history has already been fetched, probably by `getChangedPackages`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getAllChangedPackages(params: {
|
|
9
|
+
options: Pick<BeachballOptions, 'path' | 'changeDir' | 'ignorePatterns' | 'verbose'>;
|
|
10
|
+
packageInfos: PackageInfos;
|
|
11
|
+
scopedPackages: ScopedPackages;
|
|
12
|
+
/**
|
|
13
|
+
* Paths of all committed and staged files in the current branch as returned by git,
|
|
14
|
+
* relative to `options.path` with forward slashes.
|
|
15
|
+
*/
|
|
16
|
+
allChangedFiles: Set<string>;
|
|
17
|
+
}): string[];
|
|
18
|
+
//# sourceMappingURL=getAllChangedPackages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllChangedPackages.d.ts","sourceRoot":"","sources":["../../src/changefile/getAllChangedPackages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAe,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtF;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,GAAG,gBAAgB,GAAG,SAAS,CAAC,CAAC;IACrF,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,EAAE,cAAc,CAAC;IAC/B;;;OAGG;IACH,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC9B,GAAG,MAAM,EAAE,CAwDX"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getAllChangedPackages = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const filterIgnoredFiles_1 = require("../monorepo/filterIgnoredFiles");
|
|
9
|
+
const isPackageIncluded_1 = require("./isPackageIncluded");
|
|
10
|
+
const count = (n, str) => `${n} ${str}${n === 1 ? '' : 's'}`;
|
|
11
|
+
/**
|
|
12
|
+
* Gets all the changed package names, regardless of the change files.
|
|
13
|
+
*
|
|
14
|
+
* PRE: Assumes shared git history has already been fetched, probably by `getChangedPackages`.
|
|
15
|
+
*/
|
|
16
|
+
function getAllChangedPackages(params) {
|
|
17
|
+
const { options, packageInfos, scopedPackages, allChangedFiles } = params;
|
|
18
|
+
const { path: cwd, changeDir } = options;
|
|
19
|
+
const { verboseLog, logIgnored, logIncluded } = (0, isPackageIncluded_1.getIncludedLoggers)(options);
|
|
20
|
+
if (!allChangedFiles.size) {
|
|
21
|
+
verboseLog('Found no changed files in current branch');
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
verboseLog(`Found ${count(allChangedFiles.size, 'changed file')} in current branch (before filtering)`);
|
|
25
|
+
// Filter out changed files which are ignored by ignorePatterns.
|
|
26
|
+
// Also ignore the CHANGELOG files and change files because they're generated by beachball.
|
|
27
|
+
const nonIgnoredChanges = (0, filterIgnoredFiles_1.filterIgnoredFiles)({
|
|
28
|
+
filePaths: allChangedFiles,
|
|
29
|
+
ignorePatterns: [...(options.ignorePatterns || []), `${changeDir}/*.json`, 'CHANGELOG.{md,json}'],
|
|
30
|
+
logIgnored,
|
|
31
|
+
});
|
|
32
|
+
if (!nonIgnoredChanges.length) {
|
|
33
|
+
verboseLog('All files were ignored');
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
// Determine which package each changed file came from (using packageInfos[x].packageJsonPath),
|
|
37
|
+
// and whether that package is in scope and not private
|
|
38
|
+
const includedPackages = new Set();
|
|
39
|
+
let fileCount = 0;
|
|
40
|
+
const packageInfosByPath = {};
|
|
41
|
+
for (const info of Object.values(packageInfos)) {
|
|
42
|
+
packageInfosByPath[path_1.default.normalize(path_1.default.dirname(info.packageJsonPath))] = info;
|
|
43
|
+
}
|
|
44
|
+
for (const moddedFile of nonIgnoredChanges) {
|
|
45
|
+
const packageInfo = getMatchingPackageInfo(moddedFile, cwd, packageInfosByPath);
|
|
46
|
+
if (!packageInfo) {
|
|
47
|
+
logIgnored(moddedFile, 'not in a package');
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const { isIncluded, reason } = (0, isPackageIncluded_1.isPackageIncluded)(packageInfo, scopedPackages);
|
|
51
|
+
if (!isIncluded) {
|
|
52
|
+
logIgnored(moddedFile, reason);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
includedPackages.add(packageInfo.name);
|
|
56
|
+
fileCount++;
|
|
57
|
+
logIncluded(moddedFile);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
verboseLog(`Found ${count(fileCount, 'file')} in ${count(includedPackages.size, 'package')} that should be published`);
|
|
61
|
+
return [...includedPackages];
|
|
62
|
+
}
|
|
63
|
+
exports.getAllChangedPackages = getAllChangedPackages;
|
|
64
|
+
function getMatchingPackageInfo(file, cwd, packageInfosByPath) {
|
|
65
|
+
// Normalize all the paths before comparing (the packageInfosByPath entries should also be normalized)
|
|
66
|
+
// to ensure that this doesn't break on Windows if any input paths have forward slashes
|
|
67
|
+
cwd = path_1.default.normalize(cwd);
|
|
68
|
+
const absFile = path_1.default.normalize(path_1.default.join(cwd, file));
|
|
69
|
+
let absDir = '';
|
|
70
|
+
do {
|
|
71
|
+
absDir = path_1.default.dirname(absDir || absFile);
|
|
72
|
+
if (packageInfosByPath[absDir]) {
|
|
73
|
+
return packageInfosByPath[absDir];
|
|
74
|
+
}
|
|
75
|
+
} while (absDir !== cwd);
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=getAllChangedPackages.js.map
|
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C,CAAC;IAC1B,MAAM,OAAO,GAAG,cAAI,CAAC,SAAS,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;IACrD,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,GAAG;QACD,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,CAAC;QACzC,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE;YAC9B,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC;SACnC;KACF,QAAQ,MAAM,KAAK,GAAG,EAAE;IAEzB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BeachballOptions } from '../types/BeachballOptions';
|
|
2
|
+
import { type PackageInfos, type ScopedPackages } from '../types/PackageInfo';
|
|
3
|
+
/**
|
|
4
|
+
* Get the packages that were changed due to catalog version modifications.
|
|
5
|
+
*
|
|
6
|
+
* PRE: Assumes shared git history has already been fetched, probably by `getChangedPackages`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCatalogChangedPackages(params: {
|
|
9
|
+
packageInfos: PackageInfos;
|
|
10
|
+
scopedPackages: ScopedPackages;
|
|
11
|
+
options: Pick<BeachballOptions, 'branch' | 'path' | 'verbose'>;
|
|
12
|
+
/**
|
|
13
|
+
* All changed file paths in the current branch, relative to `options.path` with forward slashes.
|
|
14
|
+
* This is only used to determine if the file which might have catalog info has changed (to avoid
|
|
15
|
+
* reading it from git history in the most common case where it hasn't changed).
|
|
16
|
+
*/
|
|
17
|
+
allChangedFiles: Set<string>;
|
|
18
|
+
}): string[];
|
|
19
|
+
//# sourceMappingURL=getCatalogChangedPackages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCatalogChangedPackages.d.ts","sourceRoot":"","sources":["../../src/changefile/getCatalogChangedPackages.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,KAAK,YAAY,EAA0B,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtG;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE;IAChD,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IAC/D;;;;OAIG;IACH,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC9B,GAAG,MAAM,EAAE,CA+EX"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getCatalogChangedPackages = void 0;
|
|
7
|
+
const workspace_tools_1 = require("workspace-tools");
|
|
8
|
+
const PackageInfo_1 = require("../types/PackageInfo");
|
|
9
|
+
const isPackageIncluded_1 = require("./isPackageIncluded");
|
|
10
|
+
const diffCatalogs_1 = require("../monorepo/diffCatalogs");
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
/**
|
|
13
|
+
* Get the packages that were changed due to catalog version modifications.
|
|
14
|
+
*
|
|
15
|
+
* PRE: Assumes shared git history has already been fetched, probably by `getChangedPackages`.
|
|
16
|
+
*/
|
|
17
|
+
function getCatalogChangedPackages(params) {
|
|
18
|
+
const { options, packageInfos, scopedPackages, allChangedFiles } = params;
|
|
19
|
+
const { branch, path: cwd } = options;
|
|
20
|
+
const { verboseLog, logIncluded } = (0, isPackageIncluded_1.getIncludedLoggers)(options);
|
|
21
|
+
const currentCatalogs = (0, workspace_tools_1.getCatalogs)(cwd);
|
|
22
|
+
const catalogFilePath = currentCatalogs && (0, workspace_tools_1.getCatalogFilePath)(cwd);
|
|
23
|
+
// If there are catalogs, convert the file path to relative with forward slashes for comparison
|
|
24
|
+
// with git output. (Do the slash conversion to be safe, but realistically this should be either
|
|
25
|
+
// .yarnrc.yml, package.json, or pnpm-workspace.yaml directly under cwd.)
|
|
26
|
+
const relCatalogFilePath = catalogFilePath && path_1.default.relative(cwd, catalogFilePath.filePath).replace(/\\/g, '/');
|
|
27
|
+
// If the repo doesn't define catalogs or the catalog file hasn't changed, return early
|
|
28
|
+
// (skip the git operation to read the file from history, since this can be expensive in
|
|
29
|
+
// very large repos, and the change command is run frequently by developers)
|
|
30
|
+
if (!relCatalogFilePath || !currentCatalogs || !allChangedFiles.has(relCatalogFilePath)) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
verboseLog('Checking for changes to catalog: dependencies...');
|
|
34
|
+
// Get the old catalog file content from the branch we're comparing against
|
|
35
|
+
const oldCatalogFileContent = (0, workspace_tools_1.getFileFromRef)({ ref: branch, filePath: relCatalogFilePath, cwd });
|
|
36
|
+
const oldCatalogs = oldCatalogFileContent
|
|
37
|
+
? (0, workspace_tools_1.parseCatalogContent)(oldCatalogFileContent, catalogFilePath.manager)
|
|
38
|
+
: undefined;
|
|
39
|
+
// Calculate the diff before going into packages, so we only check everything in the less-common
|
|
40
|
+
// case that a catalog version has changed
|
|
41
|
+
const catalogsDiff = oldCatalogs ? (0, diffCatalogs_1.diffCatalogs)({ before: oldCatalogs, after: currentCatalogs }) : currentCatalogs;
|
|
42
|
+
if (!catalogsDiff) {
|
|
43
|
+
verboseLog('No catalog: changes found');
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
const changedPackages = [];
|
|
47
|
+
const changedCatalogDepNames = [
|
|
48
|
+
Object.keys(catalogsDiff.default || {}),
|
|
49
|
+
Object.values(catalogsDiff.named || {}).map(catalog => Object.keys(catalog)),
|
|
50
|
+
].flat(2);
|
|
51
|
+
for (const pkg of Object.values(packageInfos)) {
|
|
52
|
+
// Skip logging exclude reasons for catalog references
|
|
53
|
+
if (!(0, isPackageIncluded_1.isPackageIncluded)(pkg, scopedPackages).isIncluded)
|
|
54
|
+
continue;
|
|
55
|
+
const changedDeps = [];
|
|
56
|
+
for (const depType of PackageInfo_1.consideredDependencies) {
|
|
57
|
+
const deps = pkg[depType];
|
|
58
|
+
if (!deps)
|
|
59
|
+
continue;
|
|
60
|
+
for (const [name, version] of Object.entries(deps)) {
|
|
61
|
+
// If this dep name might be one of the changed catalog dependencies, check if the version
|
|
62
|
+
// specified in this package can be resolved from the catalog diff. If so, it's a change.
|
|
63
|
+
// (it's possible some package could specify a non-catalog version of the same dep)
|
|
64
|
+
if (changedCatalogDepNames.includes(name) &&
|
|
65
|
+
(0, workspace_tools_1.getCatalogVersion)({ name, version, catalogs: catalogsDiff, allowNotFound: true })) {
|
|
66
|
+
changedDeps.push(name);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (changedDeps.length) {
|
|
71
|
+
if (!changedPackages.length) {
|
|
72
|
+
verboseLog('catalog: dependencies referenced by the following packages have changed:');
|
|
73
|
+
}
|
|
74
|
+
changedPackages.push(pkg.name);
|
|
75
|
+
logIncluded(`${pkg.name}: ${changedDeps.join(', ')}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!changedPackages.length) {
|
|
79
|
+
verboseLog('No changes found to catalog: dependencies of in-scope published packages');
|
|
80
|
+
}
|
|
81
|
+
return changedPackages;
|
|
82
|
+
}
|
|
83
|
+
exports.getCatalogChangedPackages = getCatalogChangedPackages;
|
|
84
|
+
//# sourceMappingURL=getCatalogChangedPackages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCatalogChangedPackages.js","sourceRoot":"","sources":["../../src/changefile/getCatalogChangedPackages.ts"],"names":[],"mappings":";;;;;;AAAA,qDAMyB;AAEzB,sDAAsG;AACtG,2DAA4E;AAC5E,2DAAwD;AACxD,gDAAwB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ED,IAAI,WAAW,CAAC,MAAM,EAAE;YACtB,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;gBAC3B,UAAU,CAAC,0EAA0E,CAAC,CAAC;aACxF;YACD,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC/B,WAAW,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACvD;KACF;IAED,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;QAC3B,UAAU,CAAC,0EAA0E,CAAC,CAAC;KACxF;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AAzFD,8DAyFC"}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import type { BeachballOptions } from '../types/BeachballOptions';
|
|
2
|
-
import type { PackageInfos,
|
|
2
|
+
import type { PackageInfos, ScopedPackages } from '../types/PackageInfo';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Gets all the changed packages which **do not already have a change file** and are in scope.
|
|
5
|
+
* This includes all packages which should change due to catalog version changes.
|
|
6
|
+
* This is only used by the `change` and `check` commands, not the bump/publish process.
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export declare function isPackageIncluded(packageInfo: PackageInfo | undefined, scopedPackages: ScopedPackages): {
|
|
10
|
-
isIncluded: boolean;
|
|
11
|
-
reason: string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Gets all the changed packages which do not already have a change file and are in scope.
|
|
15
|
-
* Exceptions:
|
|
8
|
+
* Special cases:
|
|
16
9
|
* - If `options.package` is provided, use that as-is (skipping all git operations).
|
|
17
|
-
* - If `options.all` is true,
|
|
18
|
-
*
|
|
10
|
+
* - If `options.all` is true, gets all the packages in scope regardless of whether they've changed
|
|
11
|
+
* (skipping git diff of files), omitting packages that already have change files.
|
|
12
|
+
*
|
|
13
|
+
* Usually (without `options.package`) this has the side effect of calling `ensureSharedHistory` to
|
|
14
|
+
* verify that enough git history is available to check for changes between `HEAD` and
|
|
15
|
+
* `options.branch` (only an issue for shallow clones), and deepens the history if needed.
|
|
16
|
+
* Unless `options.fetch` is `false`, it will also fetch from the remote.
|
|
19
17
|
*/
|
|
20
18
|
export declare function getChangedPackages(options: BeachballOptions, packageInfos: PackageInfos, scopedPackages: ScopedPackages): string[];
|
|
21
19
|
//# sourceMappingURL=getChangedPackages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getChangedPackages.d.ts","sourceRoot":"","sources":["../../src/changefile/getChangedPackages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"getChangedPackages.d.ts","sourceRoot":"","sources":["../../src/changefile/getChangedPackages.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQzE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,gBAAgB,EACzB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,GAC7B,MAAM,EAAE,CAgGV"}
|
|
@@ -3,129 +3,73 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getChangedPackages =
|
|
6
|
+
exports.getChangedPackages = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const paths_1 = require("../paths");
|
|
10
9
|
const workspace_tools_1 = require("workspace-tools");
|
|
11
|
-
const
|
|
10
|
+
const paths_1 = require("../paths");
|
|
12
11
|
const readJson_1 = require("../object/readJson");
|
|
13
12
|
const bulletedList_1 = require("../logging/bulletedList");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// to ensure that this doesn't break on Windows if any input paths have forward slashes
|
|
19
|
-
cwd = path_1.default.normalize(cwd);
|
|
20
|
-
const absFile = path_1.default.normalize(path_1.default.join(cwd, file));
|
|
21
|
-
let absDir = '';
|
|
22
|
-
do {
|
|
23
|
-
absDir = path_1.default.dirname(absDir || absFile);
|
|
24
|
-
if (packageInfosByPath[absDir]) {
|
|
25
|
-
return packageInfosByPath[absDir];
|
|
26
|
-
}
|
|
27
|
-
} while (absDir !== cwd);
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
13
|
+
const getAllChangedPackages_1 = require("./getAllChangedPackages");
|
|
14
|
+
const getCatalogChangedPackages_1 = require("./getCatalogChangedPackages");
|
|
15
|
+
const isPackageIncluded_1 = require("./isPackageIncluded");
|
|
16
|
+
const ensureSharedHistory_1 = require("../git/ensureSharedHistory");
|
|
30
17
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
18
|
+
* Gets all the changed packages which **do not already have a change file** and are in scope.
|
|
19
|
+
* This includes all packages which should change due to catalog version changes.
|
|
20
|
+
* This is only used by the `change` and `check` commands, not the bump/publish process.
|
|
33
21
|
*
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
function isPackageIncluded(packageInfo, scopedPackages) {
|
|
37
|
-
const reason = !packageInfo
|
|
38
|
-
? 'no corresponding package found'
|
|
39
|
-
: packageInfo.private
|
|
40
|
-
? `${packageInfo.name} is private`
|
|
41
|
-
: // This is a package-only option (can't be set at repo level or via CLI)
|
|
42
|
-
packageInfo.packageOptions?.shouldPublish === false
|
|
43
|
-
? `${packageInfo.name} has beachball.shouldPublish=false`
|
|
44
|
-
: !scopedPackages.has(packageInfo.name)
|
|
45
|
-
? `${packageInfo.name} is out of scope`
|
|
46
|
-
: ''; // not ignored
|
|
47
|
-
return { isIncluded: !reason, reason };
|
|
48
|
-
}
|
|
49
|
-
exports.isPackageIncluded = isPackageIncluded;
|
|
50
|
-
/**
|
|
51
|
-
* Gets all the changed package names, regardless of the change files.
|
|
52
|
-
* If `options.all` is set, returns all the packages in scope, regardless of whether they've changed.
|
|
53
|
-
*/
|
|
54
|
-
function getAllChangedPackages(options, packageInfos, scopedPackages) {
|
|
55
|
-
const { branch, path: cwd, verbose, all, changeDir } = options;
|
|
56
|
-
const verboseLog = (msg) => verbose && console.log(msg);
|
|
57
|
-
const logIgnored = (file, reason) => verboseLog(` - ~~${file}~~ (${reason})`);
|
|
58
|
-
const logIncluded = (file) => verboseLog(` - ${file}`);
|
|
59
|
-
// If --all is set, return all the packages in scope rather than looking at which files changed
|
|
60
|
-
if (all) {
|
|
61
|
-
verboseLog('--all option was provided, so including all packages that are in scope (regardless of changes)');
|
|
62
|
-
return Object.values(packageInfos)
|
|
63
|
-
.filter(pkg => {
|
|
64
|
-
const { isIncluded, reason } = isPackageIncluded(pkg, scopedPackages);
|
|
65
|
-
verboseLog(isIncluded ? ` - ${pkg.name}` : ` - ~~${pkg.name}~~ (${reason.replace(`${pkg.name} `, '')})`);
|
|
66
|
-
return isIncluded;
|
|
67
|
-
})
|
|
68
|
-
.map(pkg => pkg.name);
|
|
69
|
-
}
|
|
70
|
-
console.log(`Checking for changes against "${options.branch}"`);
|
|
71
|
-
(0, ensureSharedHistory_1.ensureSharedHistory)(options);
|
|
72
|
-
const changes = [...((0, workspace_tools_1.getBranchChanges)({ branch, cwd }) || []), ...((0, workspace_tools_1.getStagedChanges)({ cwd }) || [])];
|
|
73
|
-
verboseLog(`Found ${count(changes.length, 'changed file')} in current branch (before filtering)`);
|
|
74
|
-
if (!changes.length) {
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
// Filter out changed files which are ignored by ignorePatterns.
|
|
78
|
-
// Also ignore the CHANGELOG files and change files because they're generated by beachball.
|
|
79
|
-
const nonIgnoredChanges = (0, filterIgnoredFiles_1.filterIgnoredFiles)({
|
|
80
|
-
filePaths: changes,
|
|
81
|
-
ignorePatterns: [...(options.ignorePatterns || []), `${changeDir}/*.json`, 'CHANGELOG.{md,json}'],
|
|
82
|
-
logIgnored,
|
|
83
|
-
});
|
|
84
|
-
if (!nonIgnoredChanges.length) {
|
|
85
|
-
verboseLog('All files were ignored');
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
// Determine which package each changed file came from (using packageInfos[x].packageJsonPath),
|
|
89
|
-
// and whether that package is in scope and not private
|
|
90
|
-
const includedPackages = new Set();
|
|
91
|
-
let fileCount = 0;
|
|
92
|
-
const packageInfosByPath = {};
|
|
93
|
-
for (const info of Object.values(packageInfos)) {
|
|
94
|
-
packageInfosByPath[path_1.default.normalize(path_1.default.dirname(info.packageJsonPath))] = info;
|
|
95
|
-
}
|
|
96
|
-
for (const moddedFile of nonIgnoredChanges) {
|
|
97
|
-
const packageInfo = getMatchingPackageInfo(moddedFile, cwd, packageInfosByPath);
|
|
98
|
-
if (!packageInfo)
|
|
99
|
-
continue;
|
|
100
|
-
const { isIncluded, reason } = isPackageIncluded(packageInfo, scopedPackages);
|
|
101
|
-
if (!isIncluded) {
|
|
102
|
-
logIgnored(moddedFile, reason);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
includedPackages.add(packageInfo.name);
|
|
106
|
-
fileCount++;
|
|
107
|
-
logIncluded(moddedFile);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
verboseLog(`Found ${count(fileCount, 'file')} in ${count(includedPackages.size, 'package')} that should be published`);
|
|
111
|
-
return [...includedPackages];
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Gets all the changed packages which do not already have a change file and are in scope.
|
|
115
|
-
* Exceptions:
|
|
22
|
+
* Special cases:
|
|
116
23
|
* - If `options.package` is provided, use that as-is (skipping all git operations).
|
|
117
|
-
* - If `options.all` is true,
|
|
118
|
-
*
|
|
24
|
+
* - If `options.all` is true, gets all the packages in scope regardless of whether they've changed
|
|
25
|
+
* (skipping git diff of files), omitting packages that already have change files.
|
|
26
|
+
*
|
|
27
|
+
* Usually (without `options.package`) this has the side effect of calling `ensureSharedHistory` to
|
|
28
|
+
* verify that enough git history is available to check for changes between `HEAD` and
|
|
29
|
+
* `options.branch` (only an issue for shallow clones), and deepens the history if needed.
|
|
30
|
+
* Unless `options.fetch` is `false`, it will also fetch from the remote.
|
|
119
31
|
*/
|
|
120
32
|
function getChangedPackages(options, packageInfos, scopedPackages) {
|
|
121
33
|
const { branch } = options;
|
|
34
|
+
const { verboseLog, logIncluded, logIgnored } = (0, isPackageIncluded_1.getIncludedLoggers)(options);
|
|
122
35
|
if (options.package) {
|
|
123
36
|
return typeof options.package === 'string' ? [options.package] : [...options.package];
|
|
124
37
|
}
|
|
125
|
-
|
|
38
|
+
console.log(`Checking for changes against "${branch}"`);
|
|
39
|
+
// Ensure the current branch and target branch have a common shared commit. This has the side
|
|
40
|
+
// effect of fetching from the remote (unless disabled), which should be done even if there's
|
|
41
|
+
// already shared history (and even with --all) for accurate added change file checks later.
|
|
42
|
+
(0, ensureSharedHistory_1.ensureSharedHistory)(options);
|
|
43
|
+
let changedPackages;
|
|
44
|
+
let stagedFiles;
|
|
45
|
+
if (options.all) {
|
|
46
|
+
// If --all is set, return all the packages in scope rather than looking at which files changed
|
|
47
|
+
verboseLog('--all option was provided, so including all packages that are in scope (regardless of changes)');
|
|
48
|
+
changedPackages = new Set(Object.values(packageInfos)
|
|
49
|
+
.filter(pkg => {
|
|
50
|
+
const { isIncluded, reason } = (0, isPackageIncluded_1.isPackageIncluded)(pkg, scopedPackages);
|
|
51
|
+
isIncluded ? logIncluded(pkg.name) : logIgnored(pkg.name, reason.replace(`${pkg.name} `, ''));
|
|
52
|
+
return isIncluded;
|
|
53
|
+
})
|
|
54
|
+
.map(pkg => pkg.name));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
stagedFiles = (0, workspace_tools_1.getStagedChanges)({ cwd: options.path }) || [];
|
|
58
|
+
const committedFiles = (0, workspace_tools_1.getBranchChanges)({ branch, cwd: options.path }) || [];
|
|
59
|
+
// dedupe with a Set in case a file was already committed and has more changes staged
|
|
60
|
+
const allChangedFiles = new Set([...committedFiles, ...stagedFiles]);
|
|
61
|
+
const directChangedPackages = (0, getAllChangedPackages_1.getAllChangedPackages)({ options, packageInfos, scopedPackages, allChangedFiles });
|
|
62
|
+
const catalogChangedPackages = (0, getCatalogChangedPackages_1.getCatalogChangedPackages)({
|
|
63
|
+
options,
|
|
64
|
+
packageInfos,
|
|
65
|
+
scopedPackages,
|
|
66
|
+
allChangedFiles,
|
|
67
|
+
});
|
|
68
|
+
changedPackages = new Set([...directChangedPackages, ...catalogChangedPackages]);
|
|
69
|
+
}
|
|
126
70
|
const changePath = (0, paths_1.getChangePath)(options);
|
|
127
71
|
if (!fs_1.default.existsSync(changePath)) {
|
|
128
|
-
return changedPackages;
|
|
72
|
+
return [...changedPackages];
|
|
129
73
|
}
|
|
130
74
|
// TODO: this should probably reuse the result of readChangeFiles, but they use slightly different args...
|
|
131
75
|
const committedChangeFiles = (0, workspace_tools_1.getChangesBetweenRefs)({
|
|
@@ -137,7 +81,9 @@ function getChangedPackages(options, packageInfos, scopedPackages) {
|
|
|
137
81
|
throwOnError: false,
|
|
138
82
|
});
|
|
139
83
|
// Also consider staged change files (not yet committed) so that `check` respects them
|
|
140
|
-
const
|
|
84
|
+
const relChangeDir = path_1.default.relative(options.path, changePath).replace(/\\/g, '/') + '/';
|
|
85
|
+
const stagedChangeFiles = (stagedFiles?.filter(f => f.startsWith(relChangeDir)).map(f => f.replace(relChangeDir, '')) ||
|
|
86
|
+
(0, workspace_tools_1.getStagedChanges)({ cwd: changePath })).filter(f => f.endsWith('.json'));
|
|
141
87
|
const changeFiles = [...new Set([...committedChangeFiles, ...stagedChangeFiles])];
|
|
142
88
|
const changeFilePackageSet = new Set();
|
|
143
89
|
// Loop through the change files, building up a set of packages that we can skip
|
|
@@ -149,6 +95,7 @@ function getChangedPackages(options, packageInfos, scopedPackages) {
|
|
|
149
95
|
for (const change of changes) {
|
|
150
96
|
if (change.packageName) {
|
|
151
97
|
changeFilePackageSet.add(change.packageName);
|
|
98
|
+
changedPackages.delete(change.packageName);
|
|
152
99
|
}
|
|
153
100
|
}
|
|
154
101
|
}
|
|
@@ -160,7 +107,7 @@ function getChangedPackages(options, packageInfos, scopedPackages) {
|
|
|
160
107
|
console.log('Your local repository already has change files for these packages:\n' +
|
|
161
108
|
(0, bulletedList_1.bulletedList)([...changeFilePackageSet].sort()));
|
|
162
109
|
}
|
|
163
|
-
return changedPackages
|
|
110
|
+
return [...changedPackages];
|
|
164
111
|
}
|
|
165
112
|
exports.getChangedPackages = getChangedPackages;
|
|
166
113
|
//# sourceMappingURL=getChangedPackages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getChangedPackages.js","sourceRoot":"","sources":["../../src/changefile/getChangedPackages.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;
|
|
1
|
+
{"version":3,"file":"getChangedPackages.js","sourceRoot":"","sources":["../../src/changefile/getChangedPackages.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,qDAA4F;AAE5F,oCAAyC;AAGzC,iDAA8C;AAC9C,0DAAuD;AACvD,mEAAgE;AAChE,2EAAwE;AACxE,2DAA4E;AAC5E,oEAAiE;AAEjE;;;;;;;;;;;;;;GAcG;AACH,SAAgB,kBAAkB,CAChC,OAAyB,EACzB,YAA0B,EAC1B,cAA8B;IAE9B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAA,sCAAkB,EAAC,OAAO,CAAC,CAAC;IAE5E,IAAI,OAAO,CAAC,O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
|
1
|
+
import type { BeachballOptions } from '../types/BeachballOptions';
|
|
2
|
+
import type { PackageInfo, ScopedPackages } from '../types/PackageInfo';
|
|
3
|
+
/**
|
|
4
|
+
* Determines whether the package is included in the list of potentially-changed published packages,
|
|
5
|
+
* based on private flags and scopedPackages.
|
|
6
|
+
*
|
|
7
|
+
* (All the reasons except nonexistent include the package name.)
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPackageIncluded(packageInfo: PackageInfo | undefined, scopedPackages: ScopedPackages): {
|
|
10
|
+
isIncluded: boolean;
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function getIncludedLoggers(options: Pick<BeachballOptions, 'verbose'>): {
|
|
14
|
+
verboseLog: (msg: string) => void;
|
|
15
|
+
logIgnored: (name: string, reason: string) => void;
|
|
16
|
+
logIncluded: (name: string) => void;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=isPackageIncluded.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPackageIncluded.d.ts","sourceRoot":"","sources":["../../src/changefile/isPackageIncluded.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,cAAc,EAAE,cAAc,GAC7B;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAazC;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG;IAC9E,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC,CAOA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIncludedLoggers = exports.isPackageIncluded = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Determines whether the package is included in the list of potentially-changed published packages,
|
|
6
|
+
* based on private flags and scopedPackages.
|
|
7
|
+
*
|
|
8
|
+
* (All the reasons except nonexistent include the package name.)
|
|
9
|
+
*/
|
|
10
|
+
function isPackageIncluded(packageInfo, scopedPackages) {
|
|
11
|
+
const reason = !packageInfo
|
|
12
|
+
? 'no corresponding package found'
|
|
13
|
+
: packageInfo.private
|
|
14
|
+
? `${packageInfo.name} is private`
|
|
15
|
+
: // This is a package-only option (can't be set at repo level or via CLI)
|
|
16
|
+
packageInfo.packageOptions?.shouldPublish === false
|
|
17
|
+
? `${packageInfo.name} has beachball.shouldPublish=false`
|
|
18
|
+
: !scopedPackages.has(packageInfo.name)
|
|
19
|
+
? `${packageInfo.name} is out of scope`
|
|
20
|
+
: ''; // not ignored
|
|
21
|
+
return { isIncluded: !reason, reason };
|
|
22
|
+
}
|
|
23
|
+
exports.isPackageIncluded = isPackageIncluded;
|
|
24
|
+
function getIncludedLoggers(options) {
|
|
25
|
+
const verboseLog = (msg) => options.verbose && console.log(msg);
|
|
26
|
+
return {
|
|
27
|
+
verboseLog,
|
|
28
|
+
logIgnored: (name, reason) => verboseLog(` - ~~${name}~~ (${reason})`),
|
|
29
|
+
logIncluded: name => verboseLog(` - ${name}`),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.getIncludedLoggers = getIncludedLoggers;
|
|
33
|
+
//# sourceMappingURL=isPackageIncluded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isPackageIncluded.js","sourceRoot":"","sources":["../../src/changefile/isPackageIncluded.ts"],"names":[],"mappings":";;;AAGA;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,WAAoC,EACpC,cAA8B;IAE9B,MAAM,MAAM,GAAG,CAAC,WAAW;QACzB,CAAC,CAAC,gCAAgC;QAClC,CAAC,CAAC,WAAW,CAAC,OAAO;YACrB,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,aAAa;YAClC,CAAC,CAAC,wEAAwE;gBAC1E,WAAW,CAAC,cAAc,EAAE,aAAa,KAAK,KAAK;oBACnD,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,oCAAoC;oBACzD,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC;wBACvC,CAAC,CAAC,GAAG,WAAW,CAAC,IAAI,kBAAkB;wBACvC,CAAC,CAAC,EAAE,CAAC,CAAC,cAAc;IAEtB,OAAO,EAAE,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;AACzC,CAAC;AAhBD,8CAgBC;AAED,SAAgB,kBAAkB,CAAC,OAA0C;IAK3E,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxE,OAAO;QACL,UAAU;QACV,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,IAAI,OAAO,MAAM,GAAG,CAAC;QACvE,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC;KAC/C,CAAC;AACJ,CAAC;AAXD,gDAWC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeChangeFiles.d.ts","sourceRoot":"","sources":["../../src/changefile/writeChangeFiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAM1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAGlE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,cAAc,EAAE,EACzB,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,cAAc,GAAG,WAAW,GAAG,QAAQ,CAAC,GAChF,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"writeChangeFiles.d.ts","sourceRoot":"","sources":["../../src/changefile/writeChangeFiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAM1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAGlE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,cAAc,EAAE,EACzB,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,cAAc,GAAG,WAAW,GAAG,QAAQ,CAAC,GAChF,MAAM,EAAE,CA4CV"}
|
|
@@ -17,7 +17,6 @@ const writeJson_1 = require("../object/writeJson");
|
|
|
17
17
|
function writeChangeFiles(changes, options) {
|
|
18
18
|
const { path: cwd, groupChanges, commit: commitChangeFiles } = options;
|
|
19
19
|
const changePath = (0, paths_1.getChangePath)(options);
|
|
20
|
-
const branchName = (0, workspace_tools_1.getBranchName)({ cwd });
|
|
21
20
|
if (!Object.keys(changes).length) {
|
|
22
21
|
return [];
|
|
23
22
|
}
|
|
@@ -39,15 +38,12 @@ function writeChangeFiles(changes, options) {
|
|
|
39
38
|
return changeFile;
|
|
40
39
|
});
|
|
41
40
|
}
|
|
42
|
-
// Stage and maybe commit
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const commitOptions = ['--only', path_1.default.join(changePath, '*.json')];
|
|
49
|
-
(0, workspace_tools_1.commit)({ message: 'Change files', cwd, options: commitOptions });
|
|
50
|
-
}
|
|
41
|
+
// Stage and maybe commit
|
|
42
|
+
(0, workspace_tools_1.stage)({ patterns: changeFiles, cwd });
|
|
43
|
+
if (commitChangeFiles) {
|
|
44
|
+
// only commit change files, ignore other staged files/changes
|
|
45
|
+
const commitOptions = ['--only', path_1.default.join(changePath, '*.json')];
|
|
46
|
+
(0, workspace_tools_1.commit)({ message: 'Change files', cwd, options: commitOptions });
|
|
51
47
|
}
|
|
52
48
|
console.log(`git ${commitChangeFiles ? 'committed' : 'staged'} these change files: ${changeFiles
|
|
53
49
|
.map(f => `\n - ${f}`)
|