sela-core 1.0.7 → 1.0.9
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 -17
- package/dist/cli/ErrorHandler.d.ts +1 -1
- package/dist/cli/ErrorHandler.js +14 -14
- package/dist/cli/commands/bulk.d.ts +1 -1
- package/dist/cli/commands/bulk.d.ts.map +1 -1
- package/dist/cli/commands/bulk.js +51 -33
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +26 -18
- package/dist/cli/commands/merge.d.ts +13 -0
- package/dist/cli/commands/merge.d.ts.map +1 -0
- package/dist/cli/commands/merge.js +119 -0
- package/dist/cli/commands/showReport.d.ts +1 -1
- package/dist/cli/commands/showReport.d.ts.map +1 -1
- package/dist/cli/commands/showReport.js +12 -10
- package/dist/cli/commands/status.d.ts +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +8 -8
- package/dist/cli/commands/sync.d.ts +1 -1
- package/dist/cli/commands/sync.d.ts.map +1 -1
- package/dist/cli/commands/sync.js +38 -30
- package/dist/cli/index.js +12 -9
- package/dist/cli/ui/DnaTable.d.ts +1 -1
- package/dist/cli/ui/DnaTable.d.ts.map +1 -1
- package/dist/cli/ui/DnaTable.js +23 -16
- package/dist/cli/ui/RefactorWizard.d.ts +3 -3
- package/dist/cli/ui/RefactorWizard.d.ts.map +1 -1
- package/dist/cli/ui/RefactorWizard.js +108 -82
- package/dist/config/ConfigLoader.d.ts +2 -2
- package/dist/config/ConfigLoader.d.ts.map +1 -1
- package/dist/config/ConfigLoader.js +15 -15
- package/dist/config/DryRunGuard.d.ts +1 -1
- package/dist/config/DryRunGuard.js +7 -7
- package/dist/config/SelaConfig.d.ts +13 -17
- package/dist/config/SelaConfig.d.ts.map +1 -1
- package/dist/config/SelaConfig.js +32 -26
- package/dist/engine/HealingRegistry.d.ts +1 -1
- package/dist/engine/HealingRegistry.js +3 -3
- package/dist/engine/SelaEngine.d.ts +1 -1
- package/dist/engine/SelaEngine.d.ts.map +1 -1
- package/dist/engine/SelaEngine.js +117 -51
- package/dist/errors/SelaError.d.ts +8 -1
- package/dist/errors/SelaError.d.ts.map +1 -1
- package/dist/errors/SelaError.js +14 -7
- package/dist/fixtures/expectProxy.d.ts +2 -2
- package/dist/fixtures/expectProxy.js +16 -16
- package/dist/fixtures/index.d.ts +18 -2
- package/dist/fixtures/index.d.ts.map +1 -1
- package/dist/fixtures/index.js +47 -27
- package/dist/fixtures/moduleExpect.js +7 -7
- package/dist/fixtures/proxyTag.d.ts +1 -1
- package/dist/fixtures/proxyTag.js +4 -4
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/reporter/SelaReporter.d.ts +45 -12
- package/dist/reporter/SelaReporter.d.ts.map +1 -1
- package/dist/reporter/SelaReporter.js +139 -39
- package/dist/services/ASTSourceUpdater.d.ts +48 -3
- package/dist/services/ASTSourceUpdater.d.ts.map +1 -1
- package/dist/services/ASTSourceUpdater.js +283 -105
- package/dist/services/AnchorResolver.d.ts +157 -0
- package/dist/services/AnchorResolver.d.ts.map +1 -0
- package/dist/services/AnchorResolver.js +289 -0
- package/dist/services/ArgumentTypeAnalyzer.js +7 -7
- package/dist/services/BlastRadiusAnalyzer.d.ts.map +1 -1
- package/dist/services/BlastRadiusAnalyzer.js +5 -2
- package/dist/services/ChainValidator.js +22 -22
- package/dist/services/CrossFileHealer.js +7 -7
- package/dist/services/DecisionEngine.d.ts +51 -0
- package/dist/services/DecisionEngine.d.ts.map +1 -0
- package/dist/services/DecisionEngine.js +260 -0
- package/dist/services/DefinitionTracer.d.ts +1 -1
- package/dist/services/DefinitionTracer.d.ts.map +1 -1
- package/dist/services/DefinitionTracer.js +28 -13
- package/dist/services/DnaEditorService.d.ts +2 -2
- package/dist/services/DnaEditorService.d.ts.map +1 -1
- package/dist/services/DnaEditorService.js +81 -62
- package/dist/services/DnaIndexService.d.ts +1 -1
- package/dist/services/DnaIndexService.d.ts.map +1 -1
- package/dist/services/DnaIndexService.js +14 -14
- package/dist/services/HealReportService.d.ts +31 -55
- package/dist/services/HealReportService.d.ts.map +1 -1
- package/dist/services/HealReportService.js +864 -1240
- package/dist/services/HealingAdvisory.d.ts +9 -1
- package/dist/services/HealingAdvisory.d.ts.map +1 -1
- package/dist/services/HealingAdvisory.js +9 -1
- package/dist/services/HealingCacheService.d.ts +8 -8
- package/dist/services/HealingCacheService.d.ts.map +1 -1
- package/dist/services/HealingCacheService.js +24 -24
- package/dist/services/HealthReportService.d.ts +1 -1
- package/dist/services/HealthReportService.d.ts.map +1 -1
- package/dist/services/HealthReportService.js +25 -25
- package/dist/services/InitializerUpdater.d.ts.map +1 -1
- package/dist/services/InitializerUpdater.js +12 -2
- package/dist/services/IntentAuditor.d.ts.map +1 -1
- package/dist/services/IntentAuditor.js +32 -21
- package/dist/services/InteractiveReview.d.ts +8 -17
- package/dist/services/InteractiveReview.d.ts.map +1 -1
- package/dist/services/InteractiveReview.js +34 -124
- package/dist/services/LLMService.d.ts +1 -1
- package/dist/services/LLMService.js +16 -16
- package/dist/services/MutationApplier.d.ts +55 -0
- package/dist/services/MutationApplier.d.ts.map +1 -0
- package/dist/services/MutationApplier.js +322 -0
- package/dist/services/PRAutomationService.d.ts +2 -2
- package/dist/services/PRAutomationService.d.ts.map +1 -1
- package/dist/services/PRAutomationService.js +43 -39
- package/dist/services/PendingPromptLedger.d.ts +9 -2
- package/dist/services/PendingPromptLedger.d.ts.map +1 -1
- package/dist/services/PendingPromptLedger.js +31 -6
- package/dist/services/ReportGenerator.d.ts +116 -30
- package/dist/services/ReportGenerator.d.ts.map +1 -1
- package/dist/services/ReportGenerator.js +149 -62
- package/dist/services/ReportMergeService.d.ts +95 -0
- package/dist/services/ReportMergeService.d.ts.map +1 -0
- package/dist/services/ReportMergeService.js +0 -0
- package/dist/services/SafetyGuard.d.ts +4 -7
- package/dist/services/SafetyGuard.d.ts.map +1 -1
- package/dist/services/SafetyGuard.js +29 -106
- package/dist/services/SelectorSanitizer.d.ts +52 -0
- package/dist/services/SelectorSanitizer.d.ts.map +1 -0
- package/dist/services/SelectorSanitizer.js +318 -0
- package/dist/services/SnapshotService.js +6 -6
- package/dist/services/SourceLinkService.d.ts +2 -2
- package/dist/services/SourceLinkService.d.ts.map +1 -1
- package/dist/services/SourceLinkService.js +31 -22
- package/dist/services/SourceUpdater.d.ts +1 -1
- package/dist/services/SourceUpdater.d.ts.map +1 -1
- package/dist/services/SourceUpdater.js +44 -26
- package/dist/services/TemplateDiffService.d.ts.map +1 -1
- package/dist/services/TemplateDiffService.js +18 -15
- package/dist/services/TraceBackEngine.d.ts +67 -0
- package/dist/services/TraceBackEngine.d.ts.map +1 -0
- package/dist/services/TraceBackEngine.js +672 -0
- package/dist/services/WorkspaceSnapshotService.d.ts +6 -6
- package/dist/services/WorkspaceSnapshotService.d.ts.map +1 -1
- package/dist/services/WorkspaceSnapshotService.js +10 -12
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/DOMUtils.d.ts +18 -2
- package/dist/utils/DOMUtils.d.ts.map +1 -1
- package/dist/utils/DOMUtils.js +335 -49
- package/dist/utils/IsolatedDiff.d.ts +2 -2
- package/dist/utils/IsolatedDiff.d.ts.map +1 -1
- package/dist/utils/IsolatedDiff.js +13 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# Sela
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
3
|
## Getting started
|
|
6
4
|
|
|
7
5
|
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
@@ -10,39 +8,39 @@ Already a pro? Just edit this README.md and make it your own. Want to make it ea
|
|
|
10
8
|
|
|
11
9
|
## Add your files
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
- [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
|
|
12
|
+
- [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
15
13
|
|
|
16
14
|
```
|
|
17
15
|
cd existing_repo
|
|
18
|
-
git remote add origin https://gitlab.com/
|
|
16
|
+
git remote add origin https://gitlab.com/sela/Sela.git
|
|
19
17
|
git branch -M main
|
|
20
18
|
git push -uf origin main
|
|
21
19
|
```
|
|
22
20
|
|
|
23
21
|
## Integrate with your tools
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
- [Set up project integrations](https://gitlab.com/sela/Sela/-/settings/integrations)
|
|
26
24
|
|
|
27
25
|
## Collaborate with your team
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
- [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
|
|
28
|
+
- [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
|
|
29
|
+
- [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
|
|
30
|
+
- [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
|
|
31
|
+
- [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
34
32
|
|
|
35
33
|
## Test and Deploy
|
|
36
34
|
|
|
37
35
|
Use the built-in continuous integration in GitLab.
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
- [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
|
|
38
|
+
- [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
|
|
39
|
+
- [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
|
|
40
|
+
- [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
|
|
41
|
+
- [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
|
|
44
42
|
|
|
45
|
-
|
|
43
|
+
---
|
|
46
44
|
|
|
47
45
|
# Editing this README
|
|
48
46
|
|
|
@@ -53,30 +51,39 @@ When you're ready to make this README your own, just edit this file and use the
|
|
|
53
51
|
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
52
|
|
|
55
53
|
## Name
|
|
54
|
+
|
|
56
55
|
Choose a self-explaining name for your project.
|
|
57
56
|
|
|
58
57
|
## Description
|
|
58
|
+
|
|
59
59
|
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
60
|
|
|
61
61
|
## Badges
|
|
62
|
+
|
|
62
63
|
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
64
|
|
|
64
65
|
## Visuals
|
|
66
|
+
|
|
65
67
|
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
68
|
|
|
67
69
|
## Installation
|
|
70
|
+
|
|
68
71
|
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
72
|
|
|
70
73
|
## Usage
|
|
74
|
+
|
|
71
75
|
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
76
|
|
|
73
77
|
## Support
|
|
78
|
+
|
|
74
79
|
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
80
|
|
|
76
81
|
## Roadmap
|
|
82
|
+
|
|
77
83
|
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
84
|
|
|
79
85
|
## Contributing
|
|
86
|
+
|
|
80
87
|
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
88
|
|
|
82
89
|
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
@@ -84,10 +91,13 @@ For people who want to make changes to your project, it's helpful to have some d
|
|
|
84
91
|
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
92
|
|
|
86
93
|
## Authors and acknowledgment
|
|
94
|
+
|
|
87
95
|
Show your appreciation to those who have contributed to the project.
|
|
88
96
|
|
|
89
97
|
## License
|
|
98
|
+
|
|
90
99
|
For open source projects, say how it is licensed.
|
|
91
100
|
|
|
92
101
|
## Project status
|
|
102
|
+
|
|
93
103
|
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type CliErrorCode =
|
|
1
|
+
export type CliErrorCode = "CONFIG_NOT_FOUND" | "SNAPSHOT_DIR_MISSING" | "DNA_NOT_FOUND" | "SOURCE_FILE_MISSING" | "VALIDATION_FAILED" | "AST_ERROR" | "UNKNOWN";
|
|
2
2
|
export interface CliError {
|
|
3
3
|
code: CliErrorCode;
|
|
4
4
|
message: string;
|
package/dist/cli/ErrorHandler.js
CHANGED
|
@@ -17,28 +17,28 @@ const EXIT_CODES = {
|
|
|
17
17
|
UNKNOWN: 1,
|
|
18
18
|
};
|
|
19
19
|
const KNOWN_CODES = new Set([
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
"CONFIG_NOT_FOUND",
|
|
21
|
+
"SNAPSHOT_DIR_MISSING",
|
|
22
|
+
"DNA_NOT_FOUND",
|
|
23
|
+
"SOURCE_FILE_MISSING",
|
|
24
|
+
"VALIDATION_FAILED",
|
|
25
|
+
"AST_ERROR",
|
|
26
|
+
"UNKNOWN",
|
|
27
27
|
]);
|
|
28
28
|
function isKnownCode(val) {
|
|
29
|
-
return typeof val ===
|
|
29
|
+
return typeof val === "string" && KNOWN_CODES.has(val);
|
|
30
30
|
}
|
|
31
31
|
function classify(err) {
|
|
32
32
|
if (err instanceof commander_1.CommanderError) {
|
|
33
33
|
return {
|
|
34
|
-
code:
|
|
34
|
+
code: "UNKNOWN",
|
|
35
35
|
message: err.message,
|
|
36
36
|
exitCode: err.exitCode ?? EXIT_CODES.UNKNOWN,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
if (err instanceof Error) {
|
|
40
40
|
const typed = err;
|
|
41
|
-
const code = isKnownCode(typed.code) ? typed.code :
|
|
41
|
+
const code = isKnownCode(typed.code) ? typed.code : "UNKNOWN";
|
|
42
42
|
return {
|
|
43
43
|
code,
|
|
44
44
|
message: err.message,
|
|
@@ -47,13 +47,13 @@ function classify(err) {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
return {
|
|
50
|
-
code:
|
|
50
|
+
code: "UNKNOWN",
|
|
51
51
|
message: String(err),
|
|
52
52
|
exitCode: EXIT_CODES.UNKNOWN,
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
function handleError(err) {
|
|
56
|
-
// Commander uses exitCode 0 for --help/--version
|
|
56
|
+
// Commander uses exitCode 0 for --help/--version - not real errors
|
|
57
57
|
if (err instanceof commander_1.CommanderError && err.exitCode === 0) {
|
|
58
58
|
process.exit(0);
|
|
59
59
|
}
|
|
@@ -65,6 +65,6 @@ function handleError(err) {
|
|
|
65
65
|
process.exit(cliErr.exitCode);
|
|
66
66
|
}
|
|
67
67
|
function registerGlobalHandlers() {
|
|
68
|
-
process.on(
|
|
69
|
-
process.on(
|
|
68
|
+
process.on("uncaughtException", handleError);
|
|
69
|
+
process.on("unhandledRejection", handleError);
|
|
70
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulk.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/bulk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"bulk.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/bulk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0EzC,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA0IrD"}
|
|
@@ -14,51 +14,61 @@ const SourceLinkService_js_1 = require("../../services/SourceLinkService.js");
|
|
|
14
14
|
const ProgressReporter_js_1 = require("../ui/ProgressReporter.js");
|
|
15
15
|
function renderTargets(targets) {
|
|
16
16
|
const table = new cli_table3_1.default({
|
|
17
|
-
head: [
|
|
17
|
+
head: [
|
|
18
|
+
chalk_1.default.bold("Key"),
|
|
19
|
+
chalk_1.default.bold("Source File"),
|
|
20
|
+
chalk_1.default.bold("Selector"),
|
|
21
|
+
],
|
|
18
22
|
colWidths: [12, 48, 44],
|
|
19
|
-
style: { head: [], border: [
|
|
23
|
+
style: { head: [], border: ["dim"] },
|
|
20
24
|
});
|
|
21
25
|
for (const r of targets) {
|
|
22
|
-
table.push([
|
|
26
|
+
table.push([
|
|
27
|
+
chalk_1.default.dim(r.key.slice(0, 9)),
|
|
28
|
+
r.sourceFile || chalk_1.default.dim("-"),
|
|
29
|
+
chalk_1.default.yellow(r.selector),
|
|
30
|
+
]);
|
|
23
31
|
}
|
|
24
|
-
process.stdout.write(table.toString() +
|
|
32
|
+
process.stdout.write(table.toString() + "\n");
|
|
25
33
|
}
|
|
26
34
|
function renderResults(results) {
|
|
27
|
-
process.stdout.write(
|
|
35
|
+
process.stdout.write("\n");
|
|
28
36
|
const passed = results.filter((r) => r.success);
|
|
29
37
|
const failed = results.filter((r) => !r.success);
|
|
30
38
|
for (const r of passed) {
|
|
31
|
-
const src = r.sourceUpdated ? chalk_1.default.dim(
|
|
32
|
-
process.stdout.write(` ${chalk_1.default.green(
|
|
39
|
+
const src = r.sourceUpdated ? chalk_1.default.dim(" + source") : "";
|
|
40
|
+
process.stdout.write(` ${chalk_1.default.green("✓")} ${chalk_1.default.dim(r.key.slice(0, 9))}${src}\n`);
|
|
33
41
|
}
|
|
34
42
|
for (const r of failed) {
|
|
35
|
-
process.stdout.write(` ${chalk_1.default.red(
|
|
43
|
+
process.stdout.write(` ${chalk_1.default.red("✗")} ${chalk_1.default.dim(r.key.slice(0, 9))} ${chalk_1.default.red(r.reason)}\n`);
|
|
36
44
|
}
|
|
37
45
|
process.stdout.write(`\n ${chalk_1.default.bold(String(passed.length))} updated` +
|
|
38
|
-
(failed.length
|
|
39
|
-
|
|
46
|
+
(failed.length
|
|
47
|
+
? ` ${chalk_1.default.red(String(failed.length) + " failed")}`
|
|
48
|
+
: "") +
|
|
49
|
+
"\n\n");
|
|
40
50
|
}
|
|
41
51
|
function registerBulkUpdate(dna) {
|
|
42
52
|
dna
|
|
43
|
-
.command(
|
|
44
|
-
.description(
|
|
45
|
-
.requiredOption(
|
|
46
|
-
.requiredOption(
|
|
47
|
-
.option(
|
|
48
|
-
.option(
|
|
49
|
-
.option(
|
|
50
|
-
.option(
|
|
51
|
-
.option(
|
|
53
|
+
.command("bulk-update")
|
|
54
|
+
.description("Replace a selector across all matching DNAs")
|
|
55
|
+
.requiredOption("--old <selector>", "Selector to replace")
|
|
56
|
+
.requiredOption("--new <selector>", "Replacement selector")
|
|
57
|
+
.option("--dry-run", "Show affected DNAs without writing")
|
|
58
|
+
.option("--no-source", "Skip .spec.ts updates")
|
|
59
|
+
.option("--confirm", "Auto-confirm without interactive prompt")
|
|
60
|
+
.option("--json", "Emit JSON result instead of formatted output")
|
|
61
|
+
.option("--dir <path>", "Override snapshot directory")
|
|
52
62
|
.action(async (opts) => {
|
|
53
63
|
const config = ConfigLoader_js_1.ConfigLoader.getInstance();
|
|
54
64
|
const snapshotDir = opts.dir ?? config.dnaStoragePath;
|
|
55
65
|
const progress = new ProgressReporter_js_1.ProgressReporter(opts.json);
|
|
56
66
|
const dnaIndex = new DnaIndexService_js_1.DnaIndexService();
|
|
57
|
-
await progress.run(
|
|
67
|
+
await progress.run("Scanning DNA snapshots…", () => dnaIndex.buildIndex(snapshotDir));
|
|
58
68
|
const targets = dnaIndex.findBySelector(opts.old);
|
|
59
69
|
if (targets.length === 0) {
|
|
60
70
|
if (opts.json) {
|
|
61
|
-
process.stdout.write(JSON.stringify({ matched: 0, results: [] }, null, 2) +
|
|
71
|
+
process.stdout.write(JSON.stringify({ matched: 0, results: [] }, null, 2) + "\n");
|
|
62
72
|
}
|
|
63
73
|
else {
|
|
64
74
|
process.stdout.write(`No DNA records match selector: ${chalk_1.default.yellow(opts.old)}\n`);
|
|
@@ -66,51 +76,59 @@ function registerBulkUpdate(dna) {
|
|
|
66
76
|
return;
|
|
67
77
|
}
|
|
68
78
|
if (!opts.json) {
|
|
69
|
-
process.stdout.write(`\n ${chalk_1.default.bold(String(targets.length))} DNA${targets.length > 1 ?
|
|
79
|
+
process.stdout.write(`\n ${chalk_1.default.bold(String(targets.length))} DNA${targets.length > 1 ? "s" : ""} match ` +
|
|
70
80
|
`${chalk_1.default.yellow(opts.old)} → ${chalk_1.default.green(opts.new)}\n\n`);
|
|
71
81
|
renderTargets(targets);
|
|
72
82
|
}
|
|
73
83
|
// ── dry-run: stop here ────────────────────────────────────────────────
|
|
74
84
|
if (opts.dryRun) {
|
|
75
85
|
if (opts.json) {
|
|
76
|
-
process.stdout.write(JSON.stringify({
|
|
86
|
+
process.stdout.write(JSON.stringify({
|
|
87
|
+
dryRun: true,
|
|
88
|
+
matched: targets.length,
|
|
89
|
+
targets: targets.map((t) => t.key),
|
|
90
|
+
}, null, 2) + "\n");
|
|
77
91
|
}
|
|
78
92
|
else {
|
|
79
|
-
process.stdout.write(chalk_1.default.dim(
|
|
93
|
+
process.stdout.write(chalk_1.default.dim("\n [dry-run] No files written.\n\n"));
|
|
80
94
|
}
|
|
81
95
|
return;
|
|
82
96
|
}
|
|
83
|
-
// ── confirm (skip in --json mode
|
|
97
|
+
// ── confirm (skip in --json mode - requires --confirm flag) ──────────
|
|
84
98
|
if (!opts.confirm && !opts.json) {
|
|
85
99
|
const prompt = new enquirer_js_1.Confirm({
|
|
86
|
-
name:
|
|
87
|
-
message: `Update ${targets.length} DNA file${targets.length > 1 ?
|
|
100
|
+
name: "ok",
|
|
101
|
+
message: `Update ${targets.length} DNA file${targets.length > 1 ? "s" : ""}?`,
|
|
88
102
|
});
|
|
89
103
|
const yes = (await prompt.run());
|
|
90
104
|
if (!yes) {
|
|
91
|
-
process.stdout.write(chalk_1.default.dim(
|
|
105
|
+
process.stdout.write(chalk_1.default.dim("Aborted.\n"));
|
|
92
106
|
return;
|
|
93
107
|
}
|
|
94
108
|
}
|
|
95
109
|
else if (!opts.confirm && opts.json) {
|
|
96
110
|
// In JSON/CI mode without --confirm, abort safely rather than hanging on a prompt.
|
|
97
|
-
process.stderr.write(
|
|
111
|
+
process.stderr.write("bulk-update: pass --confirm to skip interactive prompt in --json mode\n");
|
|
98
112
|
process.exit(1);
|
|
99
113
|
}
|
|
100
114
|
// ── write sequentially (backup safety) ───────────────────────────────
|
|
101
115
|
const editor = new DnaEditorService_js_1.DnaEditorService(snapshotDir);
|
|
102
116
|
const sourceLink = opts.source ? new SourceLinkService_js_1.SourceLinkService() : null;
|
|
103
117
|
const results = [];
|
|
104
|
-
await progress.run(`Updating ${targets.length} DNA file${targets.length > 1 ?
|
|
118
|
+
await progress.run(`Updating ${targets.length} DNA file${targets.length > 1 ? "s" : ""}…`, async () => {
|
|
105
119
|
for (const record of targets) {
|
|
106
|
-
const result = {
|
|
120
|
+
const result = {
|
|
121
|
+
key: record.key,
|
|
122
|
+
success: false,
|
|
123
|
+
reason: "",
|
|
124
|
+
};
|
|
107
125
|
try {
|
|
108
126
|
await editor.write(record.key, { selector: opts.new });
|
|
109
127
|
result.success = true;
|
|
110
128
|
if (sourceLink && record.sourceFile && record.sourceLine > 0) {
|
|
111
129
|
const patch = {
|
|
112
130
|
key: record.key,
|
|
113
|
-
field:
|
|
131
|
+
field: "selector",
|
|
114
132
|
oldValue: opts.old,
|
|
115
133
|
newValue: opts.new,
|
|
116
134
|
applySourceUpdate: true,
|
|
@@ -131,7 +149,7 @@ function registerBulkUpdate(dna) {
|
|
|
131
149
|
}
|
|
132
150
|
});
|
|
133
151
|
if (opts.json) {
|
|
134
|
-
process.stdout.write(JSON.stringify({ matched: targets.length, results }, null, 2) +
|
|
152
|
+
process.stdout.write(JSON.stringify({ matched: targets.length, results }, null, 2) + "\n");
|
|
135
153
|
}
|
|
136
154
|
else {
|
|
137
155
|
renderResults(results);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4BpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4BpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAWnD"}
|
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.registerInit = registerInit;
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
|
-
const PACKAGE_NAME =
|
|
39
|
+
const PACKAGE_NAME = "sela-core";
|
|
40
40
|
const CONFIG_TEMPLATE_TS = `import { defineConfig } from '${PACKAGE_NAME}';
|
|
41
41
|
|
|
42
42
|
export default defineConfig({
|
|
@@ -55,30 +55,30 @@ module.exports = defineConfig({
|
|
|
55
55
|
dnaStoragePath: 'sela-snapshots',
|
|
56
56
|
});
|
|
57
57
|
`;
|
|
58
|
-
const REQUIRED_ENV_VARS = [
|
|
58
|
+
const REQUIRED_ENV_VARS = ["ANTHROPIC_API_KEY"];
|
|
59
59
|
function registerInit(program) {
|
|
60
60
|
program
|
|
61
|
-
.command(
|
|
62
|
-
.description(
|
|
63
|
-
.option(
|
|
61
|
+
.command("init")
|
|
62
|
+
.description("Initialize Sela in the current project")
|
|
63
|
+
.option("--no-update-imports", "Skip swapping @playwright/test imports to sela-core")
|
|
64
64
|
.action(async (opts) => {
|
|
65
65
|
await runInit(opts);
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
async function runInit(opts) {
|
|
69
69
|
const cwd = process.cwd();
|
|
70
|
-
const isTs = fs.existsSync(path.join(cwd,
|
|
71
|
-
const configFile = isTs ?
|
|
70
|
+
const isTs = fs.existsSync(path.join(cwd, "tsconfig.json"));
|
|
71
|
+
const configFile = isTs ? "sela.config.ts" : "sela.config.js";
|
|
72
72
|
const configPath = path.join(cwd, configFile);
|
|
73
73
|
console.error(`\n🚀 Initializing Sela`);
|
|
74
|
-
console.error(` Project type : ${isTs ?
|
|
74
|
+
console.error(` Project type : ${isTs ? "TypeScript" : "JavaScript"}`);
|
|
75
75
|
console.error(` Directory : ${cwd}\n`);
|
|
76
76
|
// ── Config file ──────────────────────────────────────────────────
|
|
77
77
|
if (fs.existsSync(configPath)) {
|
|
78
|
-
console.error(`✅ ${configFile} already exists
|
|
78
|
+
console.error(`✅ ${configFile} already exists - skipping`);
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
|
-
fs.writeFileSync(configPath, isTs ? CONFIG_TEMPLATE_TS : CONFIG_TEMPLATE_JS,
|
|
81
|
+
fs.writeFileSync(configPath, isTs ? CONFIG_TEMPLATE_TS : CONFIG_TEMPLATE_JS, "utf8");
|
|
82
82
|
console.error(`✅ Created ${configFile}`);
|
|
83
83
|
}
|
|
84
84
|
// ── Environment variables ────────────────────────────────────────
|
|
@@ -107,21 +107,29 @@ async function runInit(opts) {
|
|
|
107
107
|
console.error(` import { test, expect } from '${PACKAGE_NAME}'\n`);
|
|
108
108
|
}
|
|
109
109
|
function loadDotEnv(cwd) {
|
|
110
|
-
const envPath = path.join(cwd,
|
|
110
|
+
const envPath = path.join(cwd, ".env");
|
|
111
111
|
if (!fs.existsSync(envPath))
|
|
112
112
|
return;
|
|
113
113
|
try {
|
|
114
114
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
115
|
-
const dotenv = require(
|
|
115
|
+
const dotenv = require("dotenv");
|
|
116
116
|
dotenv.config({ path: envPath });
|
|
117
117
|
}
|
|
118
118
|
catch {
|
|
119
|
-
// dotenv missing
|
|
119
|
+
// dotenv missing - skip silently
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
function walkDir(dir, exts) {
|
|
123
123
|
const results = [];
|
|
124
|
-
const ignore = new Set([
|
|
124
|
+
const ignore = new Set([
|
|
125
|
+
"node_modules",
|
|
126
|
+
"dist",
|
|
127
|
+
".git",
|
|
128
|
+
"sela-snapshots",
|
|
129
|
+
"sela-snapshots",
|
|
130
|
+
"test-results",
|
|
131
|
+
"playwright-report",
|
|
132
|
+
]);
|
|
125
133
|
function walk(current) {
|
|
126
134
|
if (!fs.existsSync(current))
|
|
127
135
|
return;
|
|
@@ -140,16 +148,16 @@ function walkDir(dir, exts) {
|
|
|
140
148
|
}
|
|
141
149
|
function swapImports(cwd, isTs) {
|
|
142
150
|
const exts = isTs
|
|
143
|
-
? [
|
|
144
|
-
: [
|
|
151
|
+
? [".spec.ts", ".test.ts", ".spec.js", ".test.js"]
|
|
152
|
+
: [".spec.js", ".test.js"];
|
|
145
153
|
const files = walkDir(cwd, exts);
|
|
146
154
|
let swapped = 0;
|
|
147
155
|
const importRegex = /(from\s+|require\s*\(\s*)(['"])@playwright\/test\2/g;
|
|
148
156
|
for (const filePath of files) {
|
|
149
|
-
const content = fs.readFileSync(filePath,
|
|
157
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
150
158
|
const updated = content.replace(importRegex, (_m, prefix, quote) => `${prefix}${quote}${PACKAGE_NAME}${quote}`);
|
|
151
159
|
if (updated !== content) {
|
|
152
|
-
fs.writeFileSync(filePath, updated,
|
|
160
|
+
fs.writeFileSync(filePath, updated, "utf8");
|
|
153
161
|
swapped++;
|
|
154
162
|
}
|
|
155
163
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* `sela merge [files...]`
|
|
4
|
+
*
|
|
5
|
+
* Aggregates per-shard `sela-report.json` files (uploaded as CI artifacts)
|
|
6
|
+
* into ONE coherent `.sela-history.json` + `sela-report.html` + `sela-report.json`.
|
|
7
|
+
*
|
|
8
|
+
* Resolution order for the shard files:
|
|
9
|
+
* 1. Explicit positional paths (shells on Linux runners expand globs here).
|
|
10
|
+
* 2. Otherwise scan `--shard-dir` for filenames matching `--shard-glob`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerMerge(program: Command): void;
|
|
13
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/merge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgBzC;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8FpD"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.registerMerge = registerMerge;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const ReportMergeService_js_1 = require("../../services/ReportMergeService.js");
|
|
39
|
+
const SelaError_js_1 = require("../../errors/SelaError.js");
|
|
40
|
+
/**
|
|
41
|
+
* `sela merge [files...]`
|
|
42
|
+
*
|
|
43
|
+
* Aggregates per-shard `sela-report.json` files (uploaded as CI artifacts)
|
|
44
|
+
* into ONE coherent `.sela-history.json` + `sela-report.html` + `sela-report.json`.
|
|
45
|
+
*
|
|
46
|
+
* Resolution order for the shard files:
|
|
47
|
+
* 1. Explicit positional paths (shells on Linux runners expand globs here).
|
|
48
|
+
* 2. Otherwise scan `--shard-dir` for filenames matching `--shard-glob`.
|
|
49
|
+
*/
|
|
50
|
+
function registerMerge(program) {
|
|
51
|
+
program
|
|
52
|
+
.command("merge")
|
|
53
|
+
.argument("[files...]", "Explicit shard report JSON files (sela-report.json shape). " +
|
|
54
|
+
"When omitted, --shard-dir is scanned with --shard-glob.")
|
|
55
|
+
.description("Merge sharded Sela reports into a single history + HTML report (CI fan-in)")
|
|
56
|
+
.option("--dir <path>", "Output dir for the merged report + rolling history (and where the prior .sela-history.json lives)", process.cwd())
|
|
57
|
+
.option("--shard-dir <path>", "Directory to scan for shard reports when no explicit files are given", process.cwd())
|
|
58
|
+
.option("--shard-glob <pattern>", "Filename glob (single * wildcard) used when scanning --shard-dir", "sela-shard-*.json")
|
|
59
|
+
.option("--run-id <id>", "Single dedup id for the merged history row (defaults to GITHUB_RUN_ID / CI_PIPELINE_ID)")
|
|
60
|
+
.option("--expected-shards <n>", "Number of shards launched; a smaller readable count flags a partial merge")
|
|
61
|
+
.action(async (files, opts) => {
|
|
62
|
+
const targetDir = path.resolve(opts.dir ?? process.cwd());
|
|
63
|
+
const shardDir = path.resolve(opts.shardDir ?? process.cwd());
|
|
64
|
+
const shardFiles = files && files.length > 0
|
|
65
|
+
? files.map((f) => path.resolve(f))
|
|
66
|
+
: ReportMergeService_js_1.ReportMergeService.discoverShardFiles(shardDir, opts.shardGlob ?? "sela-shard-*.json");
|
|
67
|
+
if (shardFiles.length === 0) {
|
|
68
|
+
process.stderr.write(`[sela] No shard reports found ` +
|
|
69
|
+
`(looked in ${shardDir} for "${opts.shardGlob ?? "sela-shard-*.json"}").\n` +
|
|
70
|
+
` A merged report with a healed:0 history row will still be written ` +
|
|
71
|
+
`to keep the trend cadence intact.\n`);
|
|
72
|
+
}
|
|
73
|
+
const expectedShards = parseExpectedShards(opts.expectedShards);
|
|
74
|
+
let result;
|
|
75
|
+
try {
|
|
76
|
+
result = ReportMergeService_js_1.ReportMergeService.merge({
|
|
77
|
+
shardFiles,
|
|
78
|
+
targetDir,
|
|
79
|
+
runId: opts.runId,
|
|
80
|
+
expectedShards,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
// A corrupt prior history (HISTORY_CORRUPT) is the one hard-fail: we
|
|
85
|
+
// must not silently overwrite a durable rolling window.
|
|
86
|
+
if ((0, SelaError_js_1.isSelaError)(err)) {
|
|
87
|
+
process.stderr.write(`[sela] merge aborted: ${err.message}\n`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
91
|
+
process.stderr.write(`[sela] merge failed: ${msg}\n`);
|
|
92
|
+
}
|
|
93
|
+
process.exit(1);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
process.stdout.write(`[sela] Merged report written: ${result.htmlPath}\n` +
|
|
97
|
+
` shards: ${result.shardsRead}` +
|
|
98
|
+
(result.shardsExpected != null ? `/${result.shardsExpected}` : "") +
|
|
99
|
+
` events: ${result.uniqueEvents}` +
|
|
100
|
+
(result.duplicatesDropped > 0
|
|
101
|
+
? ` (${result.duplicatesDropped} dup dropped)`
|
|
102
|
+
: "") +
|
|
103
|
+
` history: ${result.data.historical_runs.length} run(s)\n`);
|
|
104
|
+
// Partial merges are surfaced but DO NOT fail the job (aggregate-and-flag).
|
|
105
|
+
if (result.partial) {
|
|
106
|
+
process.exitCode = 0;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Parse `--expected-shards`. Ignores non-positive / non-numeric input so a
|
|
112
|
+
* bad flag degrades to "no expectation" rather than crashing the fan-in.
|
|
113
|
+
*/
|
|
114
|
+
function parseExpectedShards(raw) {
|
|
115
|
+
if (raw == null)
|
|
116
|
+
return undefined;
|
|
117
|
+
const n = Number.parseInt(raw, 10);
|
|
118
|
+
return Number.isFinite(n) && n > 0 ? n : undefined;
|
|
119
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"showReport.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/showReport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"showReport.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/showReport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyCzD"}
|