sf-decomposer 4.0.1 → 4.1.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 +18 -3
- package/lib/helpers/constants.d.ts +1 -0
- package/lib/helpers/constants.js +1 -0
- package/lib/helpers/constants.js.map +1 -1
- package/lib/hooks/prerun.js +2 -9
- package/lib/hooks/prerun.js.map +1 -1
- package/lib/hooks/scopedPostRetrieve.js +2 -9
- package/lib/hooks/scopedPostRetrieve.js.map +1 -1
- package/lib/metadata/getPackageDirectories.js +2 -9
- package/lib/metadata/getPackageDirectories.js.map +1 -1
- package/lib/service/decomposeFileHandler.js +12 -7
- package/lib/service/decomposeFileHandler.js.map +1 -1
- package/lib/service/getRepoRoot.d.ts +1 -0
- package/lib/service/getRepoRoot.js +14 -0
- package/lib/service/getRepoRoot.js.map +1 -0
- package/oclif.lock +1341 -2038
- package/oclif.manifest.json +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/sf-decomposer) [](https://npmjs.org/package/sf-decomposer) [](https://raw.githubusercontent.com/mcarvin8/sf-decomposer/main/LICENSE.md)
|
|
4
4
|
|
|
5
|
-
The `sf-decomposer` is a Salesforce plugin to read the original metadata files (XML) and create smaller, more manageable files for version control. The inverse function (`recompose`) will recreate metadata files for deployments.
|
|
5
|
+
The `sf-decomposer` is a Salesforce plugin to read the original metadata files (XML) and create smaller, more manageable files for version control. The inverse function (`recompose`) will recreate metadata files for deployments. This plugin is intended for users who deploy their Salesforce codebase from a git repository that follows the Salesforce DX Project Configuration (`sfdx-project.json` file).
|
|
6
6
|
|
|
7
7
|
This plugin requires [git](https://git-scm.com/downloads) to be installed and that it can be called using the command `git`.
|
|
8
8
|
|
|
@@ -16,6 +16,7 @@ The decomposed file format can be XML, JSON, or YAML. Based on testing, XML and
|
|
|
16
16
|
|
|
17
17
|
**DISCLAIMERS:**
|
|
18
18
|
|
|
19
|
+
- Due to a bug with running in sub-directories, **you must run this plugin from the root folder of your git repository.**
|
|
19
20
|
- You must update the `.forceignore` to have the Salesforce CLI ignore the decomposed files created by this plugin. See section `Ignore Files`. Updates to the `.gitignore` are optional and can be updated based on what you want staged in your repo.
|
|
20
21
|
- It is highly recommended that you extensively test this plugin in a sandbox environment on the metadata types you wish to use this tool for.
|
|
21
22
|
- Do not change your production/QA pipelines until you have tested this and are happy with the results.
|
|
@@ -34,7 +35,7 @@ The `sf-decomposer` supports 2 commands:
|
|
|
34
35
|
- `sf decomposer decompose`
|
|
35
36
|
- `sf decomposer recompose`
|
|
36
37
|
|
|
37
|
-
Both commands need to be ran
|
|
38
|
+
Both commands need to be ran in the root folder of your Salesforce DX git repository. This plugin will read the `sfdx-project.json` file and it will process all package directories listed in the file.
|
|
38
39
|
|
|
39
40
|
## `sf decomposer decompose`
|
|
40
41
|
|
|
@@ -227,13 +228,27 @@ General debugging statements in the log file will look like:
|
|
|
227
228
|
|
|
228
229
|
Recommend adding the `disassemble.log` to your `.gitignore` file.
|
|
229
230
|
|
|
231
|
+
## Ignore Files when Decomposing
|
|
232
|
+
|
|
233
|
+
If you wish, you can create an ignore file in the root of your repository named `.xmldisassemblerignore` to ignore specific XMLs when running the decompose command.
|
|
234
|
+
|
|
235
|
+
The ignore file should follow [.gitignore spec 2.22.1](https://git-scm.com/docs/gitignore).
|
|
236
|
+
|
|
237
|
+
When the decompose command is ran with the `--debug` flag and it processes a file that matches an entry in `.xmldisassemblerignore`, a warning will be printed to the `disassemble.log`:
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
[2024-05-22T09:32:12.078] [WARN] default - File ignored by .xmldisassemblerignore: C:\Users\matth\Documents\sf-decomposer\test\baselines\bots\Assessment_Bot\v1.botVersion-meta.xml
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
The ignore file is not read by the recompose command.
|
|
244
|
+
|
|
230
245
|
## Hooks
|
|
231
246
|
|
|
232
247
|
A post-retrieve hook (for the decompose command) and a pre-run hook (for the recompose command) have been configured if you elect to use them.
|
|
233
248
|
|
|
234
249
|
The post-retrieve hook will automatically decompose the desired metadata types after every Salesforce CLI retrieval (`sf project retrieve start` command).
|
|
235
250
|
|
|
236
|
-
The pre-run hook will automatically recompose the desired metadata types before every Salesforce CLI deployment/validation (`sf project deploy start` and `sf project deploy validate` commands).
|
|
251
|
+
The pre-run hook will automatically recompose the desired metadata types before every Salesforce CLI deployment/validation (`sf project deploy start` and `sf project deploy validate` commands). **You must run the Salesforce CLI commands from the root folder of your repository in order for the hooks to execute correctly.**
|
|
237
252
|
|
|
238
253
|
Both hooks require you to create this file in the root of your repo: `.sfdecomposer.config.json`
|
|
239
254
|
|
|
@@ -3,3 +3,4 @@ export declare const CUSTOM_LABELS_FILE = "CustomLabels.labels-meta.xml";
|
|
|
3
3
|
export declare const DEFAULT_UNIQUE_ID_ELEMENTS: string;
|
|
4
4
|
export declare const LOG_FILE = "disassemble.log";
|
|
5
5
|
export declare const DECOMPOSED_FILE_TYPES: string[];
|
|
6
|
+
export declare const IGNORE_FILE = ".xmldisassemblerignore";
|
package/lib/helpers/constants.js
CHANGED
|
@@ -4,4 +4,5 @@ export const CUSTOM_LABELS_FILE = 'CustomLabels.labels-meta.xml';
|
|
|
4
4
|
export const DEFAULT_UNIQUE_ID_ELEMENTS = 'fullName,name';
|
|
5
5
|
export const LOG_FILE = 'disassemble.log';
|
|
6
6
|
export const DECOMPOSED_FILE_TYPES = ['xml', 'json', 'yaml'];
|
|
7
|
+
export const IGNORE_FILE = '.xmldisassemblerignore';
|
|
7
8
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/helpers/constants.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAC1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AACjE,MAAM,CAAC,MAAM,0BAA0B,GAAW,eAAe,CAAC;AAClE,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/helpers/constants.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AAC1D,MAAM,CAAC,MAAM,kBAAkB,GAAG,8BAA8B,CAAC;AACjE,MAAM,CAAC,MAAM,0BAA0B,GAAW,eAAe,CAAC;AAClE,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAC;AAC1C,MAAM,CAAC,MAAM,qBAAqB,GAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,WAAW,GAAG,wBAAwB,CAAC"}
|
package/lib/hooks/prerun.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
|
-
import { simpleGit } from 'simple-git';
|
|
5
4
|
import DecomposerRecompose from '../commands/decomposer/recompose.js';
|
|
5
|
+
import { getRepoRoot } from '../service/getRepoRoot.js';
|
|
6
6
|
export const prerun = async function (options) {
|
|
7
7
|
if (['project:deploy:validate', 'project:deploy:start'].includes(options.Command.id)) {
|
|
8
8
|
let configFile;
|
|
9
|
-
const
|
|
10
|
-
baseDir: process.cwd(),
|
|
11
|
-
binary: 'git',
|
|
12
|
-
maxConcurrentProcesses: 6,
|
|
13
|
-
trimmed: true,
|
|
14
|
-
};
|
|
15
|
-
const git = simpleGit(gitOptions);
|
|
16
|
-
const repoRoot = (await git.revparse('--show-toplevel')).trim();
|
|
9
|
+
const repoRoot = await getRepoRoot();
|
|
17
10
|
const configPath = resolve(repoRoot, '.sfdecomposer.config.json');
|
|
18
11
|
try {
|
|
19
12
|
const jsonString = await readFile(configPath, 'utf-8');
|
package/lib/hooks/prerun.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../src/hooks/prerun.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,mBAAmB,MAAM,qCAAqC,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,CAAC,MAAM,MAAM,GAAmB,KAAK,WAAW,OAAO;IAC3D,IAAI,CAAC,yBAAyB,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QACrF,IAAI,UAAsB,CAAC;QAC3B,MAAM,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC;QACrC,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;QAElE,IAAI,CAAC;YACH,MAAM,UAAU,GAAW,MAAM,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAC/D,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAe,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAW,UAAU,CAAC,gBAAgB,IAAI,GAAG,CAAC;QACjE,MAAM,MAAM,GAAW,UAAU,CAAC,gBAAgB,IAAI,KAAK,CAAC;QAC5D,MAAM,SAAS,GAAY,UAAU,CAAC,SAAS,IAAI,KAAK,CAAC;QAEzD,IAAI,aAAa,CAAC,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,MAAM,kBAAkB,GAAa,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE9D,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,KAAK,MAAM,YAAY,IAAI,kBAAkB,EAAE,CAAC;YAC9C,MAAM,qBAAqB,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC7D,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YACpC,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC1C,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,SAAS,EAAE,CAAC;YACd,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAClC,CAAC;QACD,MAAM,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { resolve } from 'node:path';
|
|
4
|
-
import { simpleGit } from 'simple-git';
|
|
5
4
|
import DecomposerDecompose from '../commands/decomposer/decompose.js';
|
|
5
|
+
import { getRepoRoot } from '../service/getRepoRoot.js';
|
|
6
6
|
export const scopedPostRetrieve = async function (options) {
|
|
7
7
|
if (!options.result?.retrieveResult.response.status) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
let configFile;
|
|
11
|
-
const
|
|
12
|
-
baseDir: process.cwd(),
|
|
13
|
-
binary: 'git',
|
|
14
|
-
maxConcurrentProcesses: 6,
|
|
15
|
-
trimmed: true,
|
|
16
|
-
};
|
|
17
|
-
const git = simpleGit(gitOptions);
|
|
18
|
-
const repoRoot = (await git.revparse('--show-toplevel')).trim();
|
|
11
|
+
const repoRoot = await getRepoRoot();
|
|
19
12
|
const configPath = resolve(repoRoot, '.sfdecomposer.config.json');
|
|
20
13
|
try {
|
|
21
14
|
const jsonString = await readFile(configPath, 'utf-8');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scopedPostRetrieve.js","sourceRoot":"","sources":["../../src/hooks/scopedPostRetrieve.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"scopedPostRetrieve.js","sourceRoot":"","sources":["../../src/hooks/scopedPostRetrieve.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,mBAAmB,MAAM,qCAAqC,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAYxD,MAAM,CAAC,MAAM,kBAAkB,GAAiB,KAAK,WAAW,OAAO;IACrE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpD,OAAO;IACT,CAAC;IACD,IAAI,UAAsB,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,WAAW,EAAE,CAAC;IACrC,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;IAElE,IAAI,CAAC;QACH,MAAM,UAAU,GAAW,MAAM,QAAQ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3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import { resolve, join } from 'node:path';
|
|
5
5
|
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
6
|
-
import { simpleGit } from 'simple-git';
|
|
7
6
|
import { SFDX_PROJECT_FILE_NAME } from '../helpers/constants.js';
|
|
7
|
+
import { getRepoRoot } from '../service/getRepoRoot.js';
|
|
8
8
|
export async function getPackageDirectories(metaDirectory) {
|
|
9
|
-
const
|
|
10
|
-
baseDir: process.cwd(),
|
|
11
|
-
binary: 'git',
|
|
12
|
-
maxConcurrentProcesses: 6,
|
|
13
|
-
trimmed: true,
|
|
14
|
-
};
|
|
15
|
-
const git = simpleGit(options);
|
|
16
|
-
const repoRoot = (await git.revparse('--show-toplevel')).trim();
|
|
9
|
+
const repoRoot = await getRepoRoot();
|
|
17
10
|
const dxConfigPath = resolve(repoRoot, SFDX_PROJECT_FILE_NAME);
|
|
18
11
|
if (!existsSync(dxConfigPath)) {
|
|
19
12
|
throw Error(`Salesforce DX Config File does not exist in this path: ${dxConfigPath}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageDirectories.js","sourceRoot":"","sources":["../../src/metadata/getPackageDirectories.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"getPackageDirectories.js","sourceRoot":"","sources":["../../src/metadata/getPackageDirectories.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,qCAAqC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,Q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AAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACzC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACrD,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YACnE,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;YAC5D,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* eslint-disable no-await-in-loop */
|
|
3
|
-
import { resolve, join } from 'node:path';
|
|
3
|
+
import { resolve, relative, join } from 'node:path';
|
|
4
4
|
import { readdir, stat, rm } from 'node:fs/promises';
|
|
5
5
|
import { DisassembleXMLFileHandler, setLogLevel } from 'xml-disassembler';
|
|
6
6
|
import { XmlToYamlDisassembler } from 'xml2yaml-disassembler';
|
|
7
7
|
import { XmlToJsonDisassembler } from 'xml2json-disassembler';
|
|
8
|
-
import { CUSTOM_LABELS_FILE } from '../helpers/constants.js';
|
|
8
|
+
import { CUSTOM_LABELS_FILE, IGNORE_FILE } from '../helpers/constants.js';
|
|
9
9
|
import { moveFiles } from './moveFiles.js';
|
|
10
|
+
import { getRepoRoot } from './getRepoRoot.js';
|
|
10
11
|
export async function decomposeFileHandler(metaAttributes, prepurge, postpurge, debug, format) {
|
|
11
12
|
const { metadataPaths, metaSuffix, strictDirectoryName, folderType, uniqueIdElements } = metaAttributes;
|
|
12
13
|
if (debug)
|
|
@@ -19,8 +20,9 @@ export async function decomposeFileHandler(metaAttributes, prepurge, postpurge,
|
|
|
19
20
|
// do not use the prePurge flag in the xml-disassembler package for labels due to file moving
|
|
20
21
|
if (prepurge)
|
|
21
22
|
await prePurgeLabels(metadataPath);
|
|
22
|
-
const
|
|
23
|
-
|
|
23
|
+
const absoluteLabelFilePath = resolve(metadataPath, CUSTOM_LABELS_FILE);
|
|
24
|
+
const relativeLabelFilePath = relative(process.cwd(), absoluteLabelFilePath);
|
|
25
|
+
await disassembleHandler(relativeLabelFilePath, uniqueIdElements, false, postpurge, format);
|
|
24
26
|
// move labels from the directory they are created in
|
|
25
27
|
await moveLabels(metadataPath);
|
|
26
28
|
}
|
|
@@ -29,7 +31,7 @@ export async function decomposeFileHandler(metaAttributes, prepurge, postpurge,
|
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
|
-
async function disassembleHandler(filePath, uniqueIdElements,
|
|
34
|
+
async function disassembleHandler(filePath, uniqueIdElements, prePurge, postPurge, format) {
|
|
33
35
|
let handler;
|
|
34
36
|
if (format === 'yaml') {
|
|
35
37
|
handler = new XmlToYamlDisassembler();
|
|
@@ -40,11 +42,14 @@ async function disassembleHandler(filePath, uniqueIdElements, prepurge, postpurg
|
|
|
40
42
|
else {
|
|
41
43
|
handler = new DisassembleXMLFileHandler();
|
|
42
44
|
}
|
|
45
|
+
const repoRoot = await getRepoRoot();
|
|
46
|
+
const ignorePath = resolve(repoRoot, IGNORE_FILE);
|
|
43
47
|
await handler.disassemble({
|
|
44
48
|
filePath,
|
|
45
49
|
uniqueIdElements,
|
|
46
|
-
prePurge
|
|
47
|
-
postPurge
|
|
50
|
+
prePurge,
|
|
51
|
+
postPurge,
|
|
52
|
+
ignorePath,
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
async function prePurgeLabels(metadataPath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decomposeFileHandler.js","sourceRoot":"","sources":["../../src/service/decomposeFileHandler.ts"],"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0 +1 @@
|
|
|
1
|
+
export declare function getRepoRoot(): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { simpleGit } from 'simple-git';
|
|
3
|
+
export async function getRepoRoot() {
|
|
4
|
+
const gitOptions = {
|
|
5
|
+
baseDir: process.cwd(),
|
|
6
|
+
binary: 'git',
|
|
7
|
+
maxConcurrentProcesses: 6,
|
|
8
|
+
trimmed: true,
|
|
9
|
+
};
|
|
10
|
+
const git = simpleGit(gitOptions);
|
|
11
|
+
const repoRoot = (await git.revparse('--show-toplevel')).trim();
|
|
12
|
+
return repoRoot;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=getRepoRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRepoRoot.js","sourceRoot":"","sources":["../../src/service/getRepoRoot.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,SAAS,EAA+B,MAAM,YAAY,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,UAAU,GAA8B;QAC5C,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;QACtB,MAAM,EAAE,KAAK;QACb,sBAAsB,EAAE,CAAC;QACzB,OAAO,EAAE,IAAI;KACd,CAAC;IAEF,MAAM,GAAG,GAAc,SAAS,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAChE,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|