sfdx-git-delta 7.1.0 → 7.3.0
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 +27 -5
- package/lib/adapter/GitAdapter.d.ts +26 -12
- package/lib/adapter/GitAdapter.js +162 -175
- package/lib/adapter/GitAdapter.js.map +1 -1
- package/lib/adapter/ioExecutor.d.ts +6 -7
- package/lib/adapter/ioExecutor.js +22 -22
- package/lib/adapter/ioExecutor.js.map +1 -1
- package/lib/adapter/pathMatching.d.ts +9 -0
- package/lib/adapter/pathMatching.js +83 -0
- package/lib/adapter/pathMatching.js.map +1 -0
- package/lib/adapter/treeIndex.d.ts +7 -4
- package/lib/adapter/treeIndex.js +34 -0
- package/lib/adapter/treeIndex.js.map +1 -1
- package/lib/adapter/treeReader.d.ts +8 -0
- package/lib/adapter/treeReader.js +22 -0
- package/lib/adapter/treeReader.js.map +1 -0
- package/lib/commands/sgd/source/delta.d.ts +1 -0
- package/lib/commands/sgd/source/delta.js +5 -0
- package/lib/commands/sgd/source/delta.js.map +1 -1
- package/lib/main.d.ts +2 -2
- package/lib/main.js +84 -37
- package/lib/main.js.map +1 -1
- package/lib/post-processor/baseProcessor.d.ts +11 -8
- package/lib/post-processor/baseProcessor.js +8 -8
- package/lib/post-processor/baseProcessor.js.map +1 -1
- package/lib/post-processor/changesManifestProcessor.d.ts +3 -2
- package/lib/post-processor/changesManifestProcessor.js +5 -4
- package/lib/post-processor/changesManifestProcessor.js.map +1 -1
- package/lib/post-processor/flowTranslationProcessor.d.ts +6 -8
- package/lib/post-processor/flowTranslationProcessor.js +18 -20
- package/lib/post-processor/flowTranslationProcessor.js.map +1 -1
- package/lib/post-processor/includeProcessor.d.ts +6 -6
- package/lib/post-processor/includeProcessor.js +8 -7
- package/lib/post-processor/includeProcessor.js.map +1 -1
- package/lib/post-processor/packageGenerator.d.ts +3 -2
- package/lib/post-processor/packageGenerator.js +5 -4
- package/lib/post-processor/packageGenerator.js.map +1 -1
- package/lib/post-processor/postProcessorManager.d.ts +5 -8
- package/lib/post-processor/postProcessorManager.js +24 -32
- package/lib/post-processor/postProcessorManager.js.map +1 -1
- package/lib/service/botHandler.d.ts +1 -2
- package/lib/service/botHandler.js +17 -10
- package/lib/service/botHandler.js.map +1 -1
- package/lib/service/containedDecomposedHandler.d.ts +4 -5
- package/lib/service/containedDecomposedHandler.js +14 -13
- package/lib/service/containedDecomposedHandler.js.map +1 -1
- package/lib/service/customFieldHandler.d.ts +1 -2
- package/lib/service/customFieldHandler.js +7 -6
- package/lib/service/customFieldHandler.js.map +1 -1
- package/lib/service/customLabelHandler.d.ts +1 -2
- package/lib/service/customLabelHandler.js +3 -3
- package/lib/service/customLabelHandler.js.map +1 -1
- package/lib/service/customObjectHandler.d.ts +3 -4
- package/lib/service/customObjectHandler.js +11 -10
- package/lib/service/customObjectHandler.js.map +1 -1
- package/lib/service/decomposedHandler.d.ts +3 -4
- package/lib/service/decomposedHandler.js +5 -4
- package/lib/service/decomposedHandler.js.map +1 -1
- package/lib/service/diffLineInterpreter.d.ts +3 -5
- package/lib/service/diffLineInterpreter.js +17 -16
- package/lib/service/diffLineInterpreter.js.map +1 -1
- package/lib/service/flowHandler.d.ts +1 -2
- package/lib/service/flowHandler.js +9 -4
- package/lib/service/flowHandler.js.map +1 -1
- package/lib/service/inFileHandler.d.ts +8 -9
- package/lib/service/inFileHandler.js +25 -25
- package/lib/service/inFileHandler.js.map +1 -1
- package/lib/service/inFolderHandler.d.ts +4 -5
- package/lib/service/inFolderHandler.js +7 -6
- package/lib/service/inFolderHandler.js.map +1 -1
- package/lib/service/inResourceHandler.d.ts +4 -5
- package/lib/service/inResourceHandler.js +11 -9
- package/lib/service/inResourceHandler.js.map +1 -1
- package/lib/service/objectTranslationHandler.d.ts +1 -2
- package/lib/service/objectTranslationHandler.js +6 -5
- package/lib/service/objectTranslationHandler.js.map +1 -1
- package/lib/service/reportingFolderHandler.d.ts +6 -7
- package/lib/service/reportingFolderHandler.js +6 -6
- package/lib/service/reportingFolderHandler.js.map +1 -1
- package/lib/service/sharedFolderHandler.d.ts +4 -5
- package/lib/service/sharedFolderHandler.js +6 -6
- package/lib/service/sharedFolderHandler.js.map +1 -1
- package/lib/service/standardHandler.d.ts +8 -10
- package/lib/service/standardHandler.js +34 -36
- package/lib/service/standardHandler.js.map +1 -1
- package/lib/service/typeHandlerFactory.d.ts +7 -5
- package/lib/service/typeHandlerFactory.js +13 -12
- package/lib/service/typeHandlerFactory.js.map +1 -1
- package/lib/types/config.d.ts +6 -1
- package/lib/types/handlerResult.d.ts +7 -7
- package/lib/types/handlerResult.js +10 -1
- package/lib/types/handlerResult.js.map +1 -1
- package/lib/types/runContext.d.ts +21 -0
- package/lib/types/runContext.js +12 -0
- package/lib/types/runContext.js.map +1 -0
- package/lib/types/work.d.ts +1 -1
- package/lib/utils/arrayUtils.d.ts +1 -1
- package/lib/utils/arrayUtils.js.map +1 -1
- package/lib/utils/bundleRollup.d.ts +6 -0
- package/lib/utils/bundleRollup.js +62 -0
- package/lib/utils/bundleRollup.js.map +1 -0
- package/lib/utils/changeSet.d.ts +12 -15
- package/lib/utils/changeSet.js +23 -120
- package/lib/utils/changeSet.js.map +1 -1
- package/lib/utils/changesAssembly.d.ts +8 -0
- package/lib/utils/changesAssembly.js +21 -0
- package/lib/utils/changesAssembly.js.map +1 -0
- package/lib/utils/configValidator.d.ts +8 -6
- package/lib/utils/configValidator.js +56 -13
- package/lib/utils/configValidator.js.map +1 -1
- package/lib/utils/fsHelper.d.ts +5 -3
- package/lib/utils/fsHelper.js +12 -9
- package/lib/utils/fsHelper.js.map +1 -1
- package/lib/utils/messageSanitizer.d.ts +1 -0
- package/lib/utils/messageSanitizer.js +48 -0
- package/lib/utils/messageSanitizer.js.map +1 -0
- package/lib/utils/metadataBoundaryResolver.d.ts +7 -5
- package/lib/utils/metadataBoundaryResolver.js +18 -21
- package/lib/utils/metadataBoundaryResolver.js.map +1 -1
- package/lib/utils/pathspec.d.ts +15 -0
- package/lib/utils/pathspec.js +71 -0
- package/lib/utils/pathspec.js.map +1 -0
- package/lib/utils/renameResolver.d.ts +6 -7
- package/lib/utils/renameResolver.js +10 -9
- package/lib/utils/renameResolver.js.map +1 -1
- package/lib/utils/repoGitDiff.d.ts +3 -0
- package/lib/utils/repoGitDiff.js +30 -1
- package/lib/utils/repoGitDiff.js.map +1 -1
- package/messages/delta.md +38 -0
- package/oclif.manifest.json +10 -3
- package/package.json +23 -22
- package/lib/post-processor/bundleRollupProcessor.d.ts +0 -7
- package/lib/post-processor/bundleRollupProcessor.js +0 -81
- package/lib/post-processor/bundleRollupProcessor.js.map +0 -1
|
@@ -17,16 +17,24 @@ import { pathExists, sanitizePath } from './fsUtils.js';
|
|
|
17
17
|
import { log } from './LoggingDecorator.js';
|
|
18
18
|
import { Logger, lazy } from './LoggingService.js';
|
|
19
19
|
import { MessageService } from './MessageService.js';
|
|
20
|
+
import { sanitizeForMessage } from './messageSanitizer.js';
|
|
20
21
|
const SHA_KEYS = ['from', 'to'];
|
|
22
|
+
const SOURCE_DIR_REJECTION_MESSAGE_KEYS = {
|
|
23
|
+
empty: 'error.SourceDirIsEmpty',
|
|
24
|
+
magic: 'error.SourceDirUsesPathspecMagic',
|
|
25
|
+
wildcard: 'error.SourceDirContainsWildcard',
|
|
26
|
+
absolute: 'error.SourceDirIsAbsolute',
|
|
27
|
+
escapes: 'error.SourceDirEscapesRepository',
|
|
28
|
+
};
|
|
21
29
|
export default class ConfigValidator {
|
|
22
|
-
work;
|
|
23
30
|
config;
|
|
31
|
+
sourceRejections;
|
|
24
32
|
gitAdapter;
|
|
25
33
|
message;
|
|
26
|
-
constructor(
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.gitAdapter = GitAdapter.getInstance(
|
|
34
|
+
constructor(config, sourceRejections = []) {
|
|
35
|
+
this.config = config;
|
|
36
|
+
this.sourceRejections = sourceRejections;
|
|
37
|
+
this.gitAdapter = GitAdapter.getInstance(config);
|
|
30
38
|
this.message = new MessageService();
|
|
31
39
|
}
|
|
32
40
|
async _validateGitSha() {
|
|
@@ -42,15 +50,28 @@ export default class ConfigValidator {
|
|
|
42
50
|
lazy `_validateGitSha: '${shaParameter}' = '${shaValue}' is not a valid git SHA: ${() => getErrorMessage(error)}`);
|
|
43
51
|
errors.push(this.message.getMessage('error.ParameterIsNotGitSHA', [
|
|
44
52
|
shaParameter,
|
|
45
|
-
shaValue,
|
|
53
|
+
sanitizeForMessage(shaValue),
|
|
46
54
|
]));
|
|
47
55
|
}
|
|
48
56
|
}));
|
|
49
57
|
return errors;
|
|
50
58
|
}
|
|
59
|
+
_validateSource() {
|
|
60
|
+
return this.sourceRejections.map(rejection => this.message.getMessage(SOURCE_DIR_REJECTION_MESSAGE_KEYS[rejection.reason], [sanitizeForMessage(rejection.value)]));
|
|
61
|
+
}
|
|
51
62
|
async validateConfig() {
|
|
63
|
+
const requestedFrom = this.config.from;
|
|
64
|
+
const requestedTo = this.config.to;
|
|
52
65
|
this._sanitizeConfig();
|
|
53
|
-
|
|
66
|
+
// Short-circuits before any git object is read: _validateGitSha below
|
|
67
|
+
// calls parseRev, which opens the repository. A bad --source-dir is
|
|
68
|
+
// the actionable error and the one that today produces a silent empty
|
|
69
|
+
// manifest, so it is reported alone even if the SHAs are also invalid.
|
|
70
|
+
const sourceErrors = this._validateSource();
|
|
71
|
+
if (sourceErrors.length > 0) {
|
|
72
|
+
throw new ConfigError(sourceErrors.join(', '));
|
|
73
|
+
}
|
|
74
|
+
const [defaultWarnings, repoExists, gitErrors, changesManifestErrors] = await Promise.all([
|
|
54
75
|
this._handleDefault(),
|
|
55
76
|
pathExists(join(this.config.repo, GIT_FOLDER)),
|
|
56
77
|
this._validateGitSha(),
|
|
@@ -65,7 +86,28 @@ export default class ConfigValidator {
|
|
|
65
86
|
if (errors.length > 0) {
|
|
66
87
|
throw new ConfigError(errors.join(', '));
|
|
67
88
|
}
|
|
68
|
-
|
|
89
|
+
// Runs after the SHA validation above so a typo in either ref surfaces
|
|
90
|
+
// as the precise ParameterIsNotGitSHA message instead of the vaguer
|
|
91
|
+
// MergeBaseNotFound.
|
|
92
|
+
await this._resolveMergeBase(requestedFrom, requestedTo);
|
|
93
|
+
return defaultWarnings;
|
|
94
|
+
}
|
|
95
|
+
// --merge-base resolves --from to the merge base of --from and --to (git
|
|
96
|
+
// three-dot semantics) in place. requestedFrom/requestedTo are the
|
|
97
|
+
// user-typed refs, captured before _validateGitSha overwrites
|
|
98
|
+
// this.config.from/to with resolved SHAs — the error the user sees must
|
|
99
|
+
// name what they typed, not a 40-character hash.
|
|
100
|
+
async _resolveMergeBase(requestedFrom, requestedTo) {
|
|
101
|
+
if (!this.config.mergeBase)
|
|
102
|
+
return;
|
|
103
|
+
const base = await this.gitAdapter.getMergeBase(this.config.from, this.config.to);
|
|
104
|
+
if (!base) {
|
|
105
|
+
throw new ConfigError(this.message.getMessage('error.MergeBaseNotFound', [
|
|
106
|
+
sanitizeForMessage(requestedFrom),
|
|
107
|
+
sanitizeForMessage(requestedTo),
|
|
108
|
+
]));
|
|
109
|
+
}
|
|
110
|
+
this.config.from = base;
|
|
69
111
|
}
|
|
70
112
|
// oclif cannot natively validate --changes-manifest (it uses a string flag
|
|
71
113
|
// to allow the bare form). Replicate meaningful checks: if the path already
|
|
@@ -103,7 +145,7 @@ export default class ConfigValidator {
|
|
|
103
145
|
}
|
|
104
146
|
async _handleDefault() {
|
|
105
147
|
await this._getApiVersion();
|
|
106
|
-
await this._apiVersionDefault();
|
|
148
|
+
return await this._apiVersionDefault();
|
|
107
149
|
}
|
|
108
150
|
async _getApiVersion() {
|
|
109
151
|
if (this.config.apiVersion !== undefined)
|
|
@@ -127,13 +169,14 @@ export default class ConfigValidator {
|
|
|
127
169
|
const latestVersion = await this._resolveLatestSupportedVersion();
|
|
128
170
|
// Stryker disable next-line ConditionalExpression -- equivalent: undefined signals the lookup failed while a usable apiVersion is already set; flipping the guard would fall through to clamp against an undefined ceiling, which the offline test surface forbids
|
|
129
171
|
if (latestVersion === undefined)
|
|
130
|
-
return;
|
|
172
|
+
return [];
|
|
173
|
+
const warnings = [];
|
|
131
174
|
// Stryker disable ConditionalExpression,LogicalOperator -- equivalent: this triple-AND gate ensures we only override a numeric, defined, above-latest apiVersion; flipping individual conditions to true falls into the override branch when apiVersion is undefined or NaN, but the second `if (apiVersion === undefined || isNaN())` block immediately resets to latestVersion, producing the same observable apiVersion in both arms (only the warning content differs, which the test surface doesn't disambiguate)
|
|
132
175
|
if (this.config.apiVersion !== undefined &&
|
|
133
176
|
!isNaN(this.config.apiVersion) &&
|
|
134
177
|
this.config.apiVersion > latestVersion) {
|
|
135
178
|
// Stryker restore ConditionalExpression,LogicalOperator
|
|
136
|
-
|
|
179
|
+
warnings.push(new Error(this.message.getMessage('warning.ApiVersionOverridden', [
|
|
137
180
|
String(this.config.apiVersion),
|
|
138
181
|
String(latestVersion),
|
|
139
182
|
])));
|
|
@@ -142,10 +185,11 @@ export default class ConfigValidator {
|
|
|
142
185
|
// Stryker disable next-line ConditionalExpression -- equivalent: defaulting fallback when apiVersion is unset/NaN; flipping to false skips the default and the apiVersion stays as-is, but the only test fixtures with apiVersion already set hit the early-return at _getApiVersion start, so the default branch is unreachable for those test cases
|
|
143
186
|
if (this.config.apiVersion === undefined || isNaN(this.config.apiVersion)) {
|
|
144
187
|
this.config.apiVersion = latestVersion;
|
|
145
|
-
|
|
188
|
+
warnings.push(new Error(this.message.getMessage('warning.ApiVersionDefaulted', [
|
|
146
189
|
String(latestVersion),
|
|
147
190
|
])));
|
|
148
191
|
}
|
|
192
|
+
return warnings;
|
|
149
193
|
}
|
|
150
194
|
// Resolves the latest supported API version, falling back gracefully when the
|
|
151
195
|
// appexchange lookup is unreachable (offline/firewalled environments).
|
|
@@ -171,7 +215,6 @@ export default class ConfigValidator {
|
|
|
171
215
|
}
|
|
172
216
|
_sanitizeConfig() {
|
|
173
217
|
this.config.repo = sanitizePath(this.config.repo);
|
|
174
|
-
this.config.source = this.config.source.map(source => sanitizePath(source));
|
|
175
218
|
this.config.output = sanitizePath(this.config.output);
|
|
176
219
|
this.config.ignore = sanitizePath(this.config.ignore);
|
|
177
220
|
this.config.ignoreDestructive = sanitizePath(this.config.ignoreDestructive);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configValidator.js","sourceRoot":"","sources":["../../src/utils/configValidator.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;AACZ,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,UAAU,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"configValidator.js","sourceRoot":"","sources":["../../src/utils/configValidator.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;AACZ,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,OAAO,UAAU,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAA;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,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AC3E,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACvD,IAAI,CAAC,MAAM,CAAC,kBAAkB,GAAG,YAAY,CAC3C,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAC/B,CAAA;QACD,IAAI,CAAC,MAAM,CAAC,8BAA8B,GAAG,YAAY,CACvD,IAAI,CAAC,MAAM,CAAC,8BAA8B,CAC3C,CAAA;QACD,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAA;IACzE,CAAC;CACF;AAlNc;IADZ,GAAG;qDA0CH"}
|
package/lib/utils/fsHelper.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { Config } from '../types/config.js';
|
|
2
2
|
import type { FileGitRef } from '../types/git.js';
|
|
3
|
+
import type { RunContext } from '../types/runContext.js';
|
|
3
4
|
export declare const resetWrittenFiles: () => void;
|
|
4
5
|
export declare const readPathFromGit: (forRef: FileGitRef, config: Config) => Promise<string>;
|
|
5
|
-
export declare const pathExists: (path: string,
|
|
6
|
-
export declare const readDirs: (paths: string | string[],
|
|
7
|
-
export declare const
|
|
6
|
+
export declare const pathExists: (path: string, ctx: RunContext) => Promise<boolean>;
|
|
7
|
+
export declare const readDirs: (paths: string | string[], ctx: RunContext) => Promise<string[]>;
|
|
8
|
+
export declare const grepContentUnder: (pattern: string, path: string | string[], config: Config) => Promise<string[]>;
|
|
9
|
+
export declare const grepContentMatching: (pattern: string, pathspecs: string | string[], config: Config) => Promise<string[]>;
|
|
8
10
|
export declare const contentIncludes: (pattern: string, path: string, config: Config) => Promise<boolean>;
|
|
9
11
|
export declare const writeFile: (path: string, content: string, config: Config) => Promise<void>;
|
package/lib/utils/fsHelper.js
CHANGED
|
@@ -22,20 +22,23 @@ export const readPathFromGit = async (forRef, config) => {
|
|
|
22
22
|
}
|
|
23
23
|
return utf8Data;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
// Both read the run-owned tree reader for `config.to` — supplied by the
|
|
26
|
+
// caller (ultimately main.ts) rather than rebuilt here, so there is no
|
|
27
|
+
// scope for this lookup to disagree with whatever scope the index was
|
|
28
|
+
// actually built under. A revision nobody built an index for (or an index
|
|
29
|
+
// build that failed) degrades to false/[] rather than indexing lazily.
|
|
30
|
+
export const pathExists = async (path, ctx) => ctx.trees.pathExists(ctx.config.to, path);
|
|
31
|
+
export const readDirs = async (paths, ctx) => ctx.trees.filesUnder(ctx.config.to, paths);
|
|
32
|
+
export const grepContentUnder = async (pattern, path, config) => {
|
|
26
33
|
const gitAdapter = GitAdapter.getInstance(config);
|
|
27
|
-
return await gitAdapter.
|
|
34
|
+
return await gitAdapter.grepUnderPaths(pattern, path, config.to);
|
|
28
35
|
};
|
|
29
|
-
export const
|
|
36
|
+
export const grepContentMatching = async (pattern, pathspecs, config) => {
|
|
30
37
|
const gitAdapter = GitAdapter.getInstance(config);
|
|
31
|
-
return await gitAdapter.
|
|
32
|
-
};
|
|
33
|
-
export const grepContent = async (pattern, path, config) => {
|
|
34
|
-
const gitAdapter = GitAdapter.getInstance(config);
|
|
35
|
-
return await gitAdapter.gitGrep(pattern, path);
|
|
38
|
+
return await gitAdapter.grepMatchingPathspecs(pattern, pathspecs, config.to);
|
|
36
39
|
};
|
|
37
40
|
export const contentIncludes = async (pattern, path, config) => {
|
|
38
|
-
const results = await
|
|
41
|
+
const results = await grepContentUnder(pattern, path, config);
|
|
39
42
|
return results.length > 0;
|
|
40
43
|
};
|
|
41
44
|
export const writeFile = async (path, content, config) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fsHelper.js","sourceRoot":"","sources":["../../src/utils/fsHelper.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,OAAO,UAAU,MAAM,0BAA0B,CAAA;
|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YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAEtB,MAAM,YAAY,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAA;IACpD,IAAI,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,OAAM;IACR,CAAC;IACD,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;AACtD,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const sanitizeForMessage: (value: string) => string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// Untrusted values (a raw --source-dir value, an accepted source scope) get
|
|
3
|
+
// echoed back verbatim into error/warning messages. Neither is guaranteed
|
|
4
|
+
// printable: an ANSI escape sequence survives into a terminal, a newline is
|
|
5
|
+
// a legal git path character that would forge an extra log line, and a
|
|
6
|
+
// bidi override (Cf, e.g. U+202E) or line/paragraph separator (U+2028,
|
|
7
|
+
// U+2029) can reverse or restructure the rendered line in a bidi-aware
|
|
8
|
+
// viewer (terminals, the GitHub Actions log viewer, browsers) — a Trojan
|
|
9
|
+
// Source-style attack. Strip all of these before the value reaches a
|
|
10
|
+
// message string, and cap the length so a single value cannot blow out the
|
|
11
|
+
// message.
|
|
12
|
+
const CONTROL_CHARS_REGEX = /[\p{Cc}\p{Cf}\u2028\u2029]/gu;
|
|
13
|
+
const BACKSLASH_REGEX = /\\/g;
|
|
14
|
+
const MAX_MESSAGE_VALUE_LENGTH = 200;
|
|
15
|
+
const TRUNCATION_MARKER = '…';
|
|
16
|
+
// A fixed-width \xHH / \xHHHH escape is ambiguous: a 2-digit escape
|
|
17
|
+
// followed by two literal hex digits reads identically to a 4-digit one
|
|
18
|
+
// (e.g. escaping U+0006 next to a literal "00" and escaping U+0600 both
|
|
19
|
+
// produce "\x0600"), and astral format characters need a 5th digit anyway,
|
|
20
|
+
// so padding can never make every width uniform. The `\u{...}` delimited
|
|
21
|
+
// form is unambiguous at any width — the closing brace is the only valid
|
|
22
|
+
// terminator — and is itself valid ECMAScript escape syntax.
|
|
23
|
+
const escapeControlChar = (char) => {
|
|
24
|
+
// The regex only ever hands back a non-empty matched substring, so
|
|
25
|
+
// codePointAt(0) is guaranteed to resolve.
|
|
26
|
+
const codePoint = char.codePointAt(0);
|
|
27
|
+
return `\\u{${codePoint.toString(16)}}`;
|
|
28
|
+
};
|
|
29
|
+
export const sanitizeForMessage = (value) => {
|
|
30
|
+
// Truncate on code points (not UTF-16 code units) before escaping: a
|
|
31
|
+
// surrogate pair must never be split, and escaping only the already-
|
|
32
|
+
// capped substring guarantees every emitted \u{...} escape is complete —
|
|
33
|
+
// slicing an already-escaped string can otherwise cut mid-escape.
|
|
34
|
+
const codePoints = Array.from(value);
|
|
35
|
+
const isTruncated = codePoints.length > MAX_MESSAGE_VALUE_LENGTH;
|
|
36
|
+
const capped = isTruncated
|
|
37
|
+
? codePoints.slice(0, MAX_MESSAGE_VALUE_LENGTH).join('')
|
|
38
|
+
: value;
|
|
39
|
+
// Escape literal backslashes first so a real control-char escape (which
|
|
40
|
+
// is introduced afterwards) can never be confused with one that was
|
|
41
|
+
// already present in the input — otherwise 'a\u{a}' and an actual
|
|
42
|
+
// newline would sanitize to the same string.
|
|
43
|
+
const escaped = capped
|
|
44
|
+
.replace(BACKSLASH_REGEX, '\\\\')
|
|
45
|
+
.replace(CONTROL_CHARS_REGEX, escapeControlChar);
|
|
46
|
+
return isTruncated ? `${escaped}${TRUNCATION_MARKER}` : escaped;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=messageSanitizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageSanitizer.js","sourceRoot":"","sources":["../../src/utils/messageSanitizer.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,4EAA4E;AAC5E,0EAA0E;AAC1E,4EAA4E;AAC5E,u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AAiB,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;AACjE,CAAC,CAAA"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { MetadataRepository } from '../metadata/MetadataRepository.js';
|
|
1
|
+
import type { TreeReader } from '../adapter/treeReader.js';
|
|
2
|
+
import type { MetadataRepository } from '../metadata/MetadataRepository.js';
|
|
3
3
|
import type { Metadata } from '../types/metadata.js';
|
|
4
|
+
import type { RunContext } from '../types/runContext.js';
|
|
4
5
|
import { MetadataElement } from './metadataElement.js';
|
|
5
6
|
export declare class MetadataBoundaryResolver {
|
|
6
|
-
protected readonly
|
|
7
|
-
protected readonly gitAdapter: GitAdapter;
|
|
7
|
+
protected readonly ctx: RunContext;
|
|
8
8
|
protected readonly dirCache: Map<string, string[]>;
|
|
9
|
-
constructor(
|
|
9
|
+
constructor(ctx: RunContext);
|
|
10
|
+
protected get metadata(): MetadataRepository;
|
|
11
|
+
protected get trees(): TreeReader;
|
|
10
12
|
createElement(path: string, metadataDef: Metadata, revision: string): Promise<MetadataElement>;
|
|
11
13
|
protected scanAndCreateElement(path: string, metadataDef: Metadata, revision: string): Promise<MetadataElement>;
|
|
12
14
|
protected isNameInPath(parts: string[], componentName: string): boolean;
|
|
@@ -11,16 +11,20 @@ import { METAFILE_SUFFIX } from '../constant/metadataConstants.js';
|
|
|
11
11
|
import { log } from './LoggingDecorator.js';
|
|
12
12
|
import { MetadataElement } from './metadataElement.js';
|
|
13
13
|
export class MetadataBoundaryResolver {
|
|
14
|
-
|
|
15
|
-
gitAdapter;
|
|
14
|
+
ctx;
|
|
16
15
|
dirCache;
|
|
17
|
-
constructor(
|
|
18
|
-
this.
|
|
19
|
-
this.gitAdapter = gitAdapter;
|
|
16
|
+
constructor(ctx) {
|
|
17
|
+
this.ctx = ctx;
|
|
20
18
|
this.dirCache = new Map();
|
|
21
19
|
}
|
|
20
|
+
get metadata() {
|
|
21
|
+
return this.ctx.metadata;
|
|
22
|
+
}
|
|
23
|
+
get trees() {
|
|
24
|
+
return this.ctx.trees;
|
|
25
|
+
}
|
|
22
26
|
async createElement(path, metadataDef, revision) {
|
|
23
|
-
const element = MetadataElement.fromPath(path, metadataDef, this.
|
|
27
|
+
const element = MetadataElement.fromPath(path, metadataDef, this.metadata);
|
|
24
28
|
if (element && element.pathAfterType.length <= 1)
|
|
25
29
|
return element;
|
|
26
30
|
if (element && !metadataDef.suffix)
|
|
@@ -32,7 +36,7 @@ export class MetadataBoundaryResolver {
|
|
|
32
36
|
if (componentName === element.pathAfterType[0]) {
|
|
33
37
|
return element;
|
|
34
38
|
}
|
|
35
|
-
return MetadataElement.fromScan(path, metadataDef, this.
|
|
39
|
+
return MetadataElement.fromScan(path, metadataDef, this.metadata, componentName);
|
|
36
40
|
}
|
|
37
41
|
return element;
|
|
38
42
|
}
|
|
@@ -43,14 +47,7 @@ export class MetadataBoundaryResolver {
|
|
|
43
47
|
const dirIndex = parts.lastIndexOf(metadataDef.directoryName);
|
|
44
48
|
if (dirIndex >= 0 && metadataDef.suffix) {
|
|
45
49
|
const typeDir = parts.slice(0, dirIndex + 1).join(PATH_SEP);
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
allFiles = await this.gitAdapter.getFilesPath(typeDir, revision);
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
// Stryker disable next-line ArrayDeclaration -- equivalent: catch fallback to empty list; an injected non-empty default would feed the componentNames Set with bogus entries that the next-loop's componentNames.has check rejects (the test fixtures provide concrete pathAfterType values that don't match the injected sentinel)
|
|
52
|
-
allFiles = [];
|
|
53
|
-
}
|
|
50
|
+
const allFiles = this.trees.filesUnder(revision, typeDir);
|
|
54
51
|
const metaSuffix = `.${metadataDef.suffix}${METAFILE_SUFFIX}`;
|
|
55
52
|
const componentNames = new Set();
|
|
56
53
|
for (const file of allFiles) {
|
|
@@ -63,10 +60,10 @@ export class MetadataBoundaryResolver {
|
|
|
63
60
|
// Stryker disable next-line UpdateOperator -- equivalent: reverse-iterate from the second-to-last segment back to root; flipping i++ to i++ means the loop never enters (i starts at length-2, which is < length but i++ goes up while guard is i >= 0 which is always true) — but in practice the test paths have length 1-2 so the loop body executes 0-1 times, observably the same in either direction
|
|
64
61
|
for (let i = pathAfterType.length - 2; i >= 0; i--) {
|
|
65
62
|
if (componentNames.has(pathAfterType[i])) {
|
|
66
|
-
return MetadataElement.fromScan(path, metadataDef, this.
|
|
63
|
+
return MetadataElement.fromScan(path, metadataDef, this.metadata, pathAfterType[i]);
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
|
-
return MetadataElement.fromScan(path, metadataDef, this.
|
|
66
|
+
return MetadataElement.fromScan(path, metadataDef, this.metadata, parse(path).name);
|
|
70
67
|
}
|
|
71
68
|
let currentDir = dirname(path);
|
|
72
69
|
// Stryker disable next-line ConditionalExpression,LogicalOperator,BlockStatement,StringLiteral -- equivalent: directory walk termination; this loop walks up from the file's dirname to the repo root, emptying the body skips the walk and falls through to the post-loop fallback (which produces a generic MetadataElement); the test surface only exercises the walk path for nested directory metadata, and the fallback path is also tested
|
|
@@ -74,23 +71,23 @@ export class MetadataBoundaryResolver {
|
|
|
74
71
|
const cacheKey = `${revision}:${currentDir}`;
|
|
75
72
|
let siblings = this.dirCache.get(cacheKey);
|
|
76
73
|
if (siblings === undefined) {
|
|
77
|
-
siblings =
|
|
74
|
+
siblings = this.trees.children(revision, currentDir);
|
|
78
75
|
this.dirCache.set(cacheKey, siblings);
|
|
79
76
|
}
|
|
80
77
|
const componentName = this.findComponentName(siblings, parts);
|
|
81
78
|
if (componentName) {
|
|
82
|
-
return MetadataElement.fromScan(path, metadataDef, this.
|
|
79
|
+
return MetadataElement.fromScan(path, metadataDef, this.metadata, componentName);
|
|
83
80
|
}
|
|
84
81
|
currentDir = dirname(currentDir);
|
|
85
82
|
}
|
|
86
|
-
return MetadataElement.fromScan(path, metadataDef, this.
|
|
83
|
+
return MetadataElement.fromScan(path, metadataDef, this.metadata, parse(path).name);
|
|
87
84
|
}
|
|
88
85
|
isNameInPath(parts, componentName) {
|
|
89
86
|
return parts.some(part => part === componentName || part.startsWith(`${componentName}.`));
|
|
90
87
|
}
|
|
91
88
|
findComponentName(siblings, parts) {
|
|
92
89
|
for (const sibling of siblings) {
|
|
93
|
-
const siblingMetadata = this.
|
|
90
|
+
const siblingMetadata = this.metadata.get(sibling);
|
|
94
91
|
if (siblingMetadata?.suffix &&
|
|
95
92
|
sibling.includes(`.${siblingMetadata.suffix}`)) {
|
|
96
93
|
const name = this.extractName(sibling, siblingMetadata.suffix);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadataBoundaryResolver.js","sourceRoot":"","sources":["../../src/utils/metadataBoundaryResolver.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;AACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"metadataBoundaryResolver.js","sourceRoot":"","sources":["../../src/utils/metadataBoundaryResolver.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;AACZ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAGhD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAIlE,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,OAAO,wBAAwB;IAGJ,GAAG;IAFf,QAAQ,CAAuB;IAElD,YAA+B,GAAe;mBAAf,GAAG;QAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAA;IAC3B,CAAC;IAED,IAAc,QAAQ;QACpB,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C,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,aAAa,GAAG,CAAC,CACvE,CAAA;IACH,CAAC;IAES,iBAAiB,CACzB,QAAkB,EAClB,KAAe;QAEf,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YAClD,IACE,eAAe,EAAE,MAAM;gBACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC,EAC9C,CAAC;gBACD,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;gBAC9D,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;oBACnC,OAAO,IAAI,CAAA;gBACb,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAES,WAAW,CAAC,QAAgB,EAAE,MAAc;QACpD,OAAO,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAnIc;IADZ,GAAG;6DA4BH"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const PATHSPEC_BRAND: unique symbol;
|
|
2
|
+
export type Pathspec = string & {
|
|
3
|
+
readonly [PATHSPEC_BRAND]: true;
|
|
4
|
+
};
|
|
5
|
+
export type SourceDirRejectionReason = 'empty' | 'magic' | 'wildcard' | 'absolute' | 'escapes';
|
|
6
|
+
export type SourceDirRejection = Readonly<{
|
|
7
|
+
value: string;
|
|
8
|
+
reason: SourceDirRejectionReason;
|
|
9
|
+
}>;
|
|
10
|
+
export type ParsedSourceDirs = Readonly<{
|
|
11
|
+
pathspecs: Pathspec[];
|
|
12
|
+
rejections: SourceDirRejection[];
|
|
13
|
+
}>;
|
|
14
|
+
export declare const parseSourceDirs: (raw: string[]) => ParsedSourceDirs;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { isAbsolute } from 'node:path/posix';
|
|
3
|
+
import { sanitizePath, treatPathSep } from './fsUtils.js';
|
|
4
|
+
// Git pathspec magic prefix: ':(exclude)', ':!', ':(glob)', ':/', ':^' …
|
|
5
|
+
const MAGIC_PREFIX = ':';
|
|
6
|
+
const WILDCARD_CHARS_REGEX = /[*?[]/;
|
|
7
|
+
// Windows drive letter followed by a separator, e.g. 'C:/x' or 'C:\x'.
|
|
8
|
+
// `path.posix.isAbsolute` does not flag these once treatPathSep has run.
|
|
9
|
+
const WINDOWS_DRIVE_REGEX = /^[A-Za-z]:[\\/]/;
|
|
10
|
+
const TRAILING_SLASHES_REGEX = /\/+$/;
|
|
11
|
+
const PATH_SEGMENT_SEP = '/';
|
|
12
|
+
const PARENT_SEGMENT = '..';
|
|
13
|
+
// normalize('.') === '.', normalize('./') === './', normalize('././') === './'
|
|
14
|
+
const ROOT_PATHSPECS = new Set(['.', './']);
|
|
15
|
+
const WHOLE_REPOSITORY = '.';
|
|
16
|
+
const reject = (reason) => ({
|
|
17
|
+
ok: false,
|
|
18
|
+
reason,
|
|
19
|
+
});
|
|
20
|
+
const accept = (value) => ({
|
|
21
|
+
ok: true,
|
|
22
|
+
value: value,
|
|
23
|
+
});
|
|
24
|
+
// Steps 1-5 run on the raw value, before normalisation destroys the evidence
|
|
25
|
+
// they test for: a leading ':', a Windows drive letter, or a '..' segment
|
|
26
|
+
// all survive treatPathSep/normalize as an innocuous-looking literal —
|
|
27
|
+
// normalize('force-app/..') cancels straight down to '.', which is why the
|
|
28
|
+
// '..' check must see the segment before normalize resolves it away.
|
|
29
|
+
const hasParentSegment = (raw) => treatPathSep(raw).split(PATH_SEGMENT_SEP).includes(PARENT_SEGMENT);
|
|
30
|
+
const rejectRawValue = (raw) => {
|
|
31
|
+
if (raw === '')
|
|
32
|
+
return 'empty';
|
|
33
|
+
if (raw.startsWith(MAGIC_PREFIX))
|
|
34
|
+
return 'magic';
|
|
35
|
+
if (WILDCARD_CHARS_REGEX.test(raw))
|
|
36
|
+
return 'wildcard';
|
|
37
|
+
if (WINDOWS_DRIVE_REGEX.test(raw))
|
|
38
|
+
return 'absolute';
|
|
39
|
+
if (hasParentSegment(raw))
|
|
40
|
+
return 'escapes';
|
|
41
|
+
return undefined;
|
|
42
|
+
};
|
|
43
|
+
const canonicalise = (raw) => {
|
|
44
|
+
const rawRejection = rejectRawValue(raw);
|
|
45
|
+
if (rawRejection)
|
|
46
|
+
return reject(rawRejection);
|
|
47
|
+
const value = sanitizePath(raw);
|
|
48
|
+
if (isAbsolute(value))
|
|
49
|
+
return reject('absolute');
|
|
50
|
+
if (ROOT_PATHSPECS.has(value))
|
|
51
|
+
return accept(WHOLE_REPOSITORY);
|
|
52
|
+
return accept(value.replace(TRAILING_SLASHES_REGEX, ''));
|
|
53
|
+
};
|
|
54
|
+
export const parseSourceDirs = (raw) => {
|
|
55
|
+
const pathspecs = [];
|
|
56
|
+
const rejections = [];
|
|
57
|
+
const seen = new Set();
|
|
58
|
+
for (const value of raw) {
|
|
59
|
+
const result = canonicalise(value);
|
|
60
|
+
if (!result.ok) {
|
|
61
|
+
rejections.push({ value, reason: result.reason });
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (seen.has(result.value))
|
|
65
|
+
continue;
|
|
66
|
+
seen.add(result.value);
|
|
67
|
+
pathspecs.push(result.value);
|
|
68
|
+
}
|
|
69
|
+
return { pathspecs, rejections };
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=pathspec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathspec.js","sourceRoot":"","sources":["../../src/utils/pathspec.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EAAE,UAA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,MAAM,CAAC,KAAK,CAAC,CAAA;QACtB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,CAAA;AAClC,CAAC,CAAA"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type ChangeSet from './changeSet.js';
|
|
1
|
+
import type { RunContext } from '../types/runContext.js';
|
|
2
|
+
import type { RenameTriple } from './changeSet.js';
|
|
4
3
|
import type { RenamePathPair } from './repoGitDiff.js';
|
|
5
4
|
/**
|
|
6
5
|
* Turns the `{ fromPath, toPath }` pairs git emitted for `-M` renames into
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
6
|
+
* `RenameTriple` values by re-using the handler machinery to resolve each
|
|
7
|
+
* side to its Salesforce (type, member).
|
|
9
8
|
*
|
|
10
9
|
* Pairs where metadata resolution fails (ignored path, unknown type) or where
|
|
11
10
|
* the from/to side land on the same component are skipped — those reduce to
|
|
@@ -13,7 +12,7 @@ import type { RenamePathPair } from './repoGitDiff.js';
|
|
|
13
12
|
*/
|
|
14
13
|
export default class RenameResolver {
|
|
15
14
|
private readonly factory;
|
|
16
|
-
constructor(
|
|
17
|
-
|
|
15
|
+
constructor(ctx: RunContext);
|
|
16
|
+
resolve(pairs: readonly RenamePathPair[]): Promise<readonly RenameTriple[]>;
|
|
18
17
|
private _resolve;
|
|
19
18
|
}
|
|
@@ -13,8 +13,8 @@ import { log } from './LoggingDecorator.js';
|
|
|
13
13
|
import { Logger, lazy } from './LoggingService.js';
|
|
14
14
|
/**
|
|
15
15
|
* Turns the `{ fromPath, toPath }` pairs git emitted for `-M` renames into
|
|
16
|
-
* `
|
|
17
|
-
*
|
|
16
|
+
* `RenameTriple` values by re-using the handler machinery to resolve each
|
|
17
|
+
* side to its Salesforce (type, member).
|
|
18
18
|
*
|
|
19
19
|
* Pairs where metadata resolution fails (ignored path, unknown type) or where
|
|
20
20
|
* the from/to side land on the same component are skipped — those reduce to
|
|
@@ -22,16 +22,17 @@ import { Logger, lazy } from './LoggingService.js';
|
|
|
22
22
|
*/
|
|
23
23
|
export default class RenameResolver {
|
|
24
24
|
factory;
|
|
25
|
-
constructor(
|
|
26
|
-
this.factory = new TypeHandlerFactory(
|
|
25
|
+
constructor(ctx) {
|
|
26
|
+
this.factory = new TypeHandlerFactory(ctx);
|
|
27
27
|
}
|
|
28
|
-
async
|
|
28
|
+
async resolve(pairs) {
|
|
29
|
+
const triples = [];
|
|
29
30
|
for (const pair of pairs) {
|
|
30
31
|
const resolved = await this._resolve(pair);
|
|
31
|
-
if (resolved)
|
|
32
|
-
|
|
33
|
-
}
|
|
32
|
+
if (resolved)
|
|
33
|
+
triples.push(resolved);
|
|
34
34
|
}
|
|
35
|
+
return triples;
|
|
35
36
|
}
|
|
36
37
|
async _resolve(pair) {
|
|
37
38
|
try {
|
|
@@ -56,5 +57,5 @@ export default class RenameResolver {
|
|
|
56
57
|
}
|
|
57
58
|
__decorate([
|
|
58
59
|
log
|
|
59
|
-
], RenameResolver.prototype, "
|
|
60
|
+
], RenameResolver.prototype, "resolve", null);
|
|
60
61
|
//# sourceMappingURL=renameResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renameResolver.js","sourceRoot":"","sources":["../../src/utils/renameResolver.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;AAEZ,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"renameResolver.js","sourceRoot":"","sources":["../../src/utils/renameResolver.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;AAEZ,OAAO,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BA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A;YACtC,gOAAgO;YAChO,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,MAAM;gBAAE,OAAO,IAAI,CAAA;YAC1C,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAA;QAC9D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI;YACT,0IAA0I;YAC1I,IAAI,CAAA,qCAAqC,IAAI,CAAC,QAAQ,OAAO,IAAI,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAC5G,CAAA;YACD,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;CACF;AAnCc;IADZ,GAAG;6CAUH"}
|
|
@@ -10,6 +10,7 @@ export default class RepoGitDiff {
|
|
|
10
10
|
protected readonly metadata: MetadataRepository;
|
|
11
11
|
protected readonly gitAdapter: GitAdapter;
|
|
12
12
|
private renamePairs;
|
|
13
|
+
private readonly diffScopeVerdict;
|
|
13
14
|
constructor(config: Config, metadata: MetadataRepository);
|
|
14
15
|
/**
|
|
15
16
|
* Streams the filtered, rename-expanded diff lines. Yields A/M lines as
|
|
@@ -23,6 +24,8 @@ export default class RepoGitDiff {
|
|
|
23
24
|
*/
|
|
24
25
|
getLines(): AsyncGenerator<string>;
|
|
25
26
|
getRenamePairs(): readonly RenamePathPair[];
|
|
27
|
+
getUnmatchedSourceScopes(): readonly string[];
|
|
26
28
|
protected _expandRename(line: string): Iterable<string>;
|
|
27
29
|
protected _extractComparisonName(line: string): string;
|
|
30
|
+
private diffSpec;
|
|
28
31
|
}
|