sela-core 1.0.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 +93 -0
- package/bin/sela.js +3 -0
- package/dist/cli/ErrorHandler.d.ts +10 -0
- package/dist/cli/ErrorHandler.d.ts.map +1 -0
- package/dist/cli/ErrorHandler.js +70 -0
- package/dist/cli/commands/bulk.d.ts +3 -0
- package/dist/cli/commands/bulk.d.ts.map +1 -0
- package/dist/cli/commands/bulk.js +140 -0
- package/dist/cli/commands/find.d.ts +3 -0
- package/dist/cli/commands/find.d.ts.map +1 -0
- package/dist/cli/commands/find.js +51 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +133 -0
- package/dist/cli/commands/list.d.ts +3 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +56 -0
- package/dist/cli/commands/refactor.d.ts +3 -0
- package/dist/cli/commands/refactor.d.ts.map +1 -0
- package/dist/cli/commands/refactor.js +30 -0
- package/dist/cli/commands/status.d.ts +3 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +51 -0
- package/dist/cli/commands/sync.d.ts +3 -0
- package/dist/cli/commands/sync.d.ts.map +1 -0
- package/dist/cli/commands/sync.js +123 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +42 -0
- package/dist/cli/ui/DnaTable.d.ts +3 -0
- package/dist/cli/ui/DnaTable.d.ts.map +1 -0
- package/dist/cli/ui/DnaTable.js +70 -0
- package/dist/cli/ui/LocatorPicker.d.ts +8 -0
- package/dist/cli/ui/LocatorPicker.d.ts.map +1 -0
- package/dist/cli/ui/LocatorPicker.js +33 -0
- package/dist/cli/ui/ProgressReporter.d.ts +11 -0
- package/dist/cli/ui/ProgressReporter.d.ts.map +1 -0
- package/dist/cli/ui/ProgressReporter.js +33 -0
- package/dist/cli/ui/RefactorWizard.d.ts +26 -0
- package/dist/cli/ui/RefactorWizard.d.ts.map +1 -0
- package/dist/cli/ui/RefactorWizard.js +269 -0
- package/dist/config/ConfigLoader.d.ts +15 -0
- package/dist/config/ConfigLoader.d.ts.map +1 -0
- package/dist/config/ConfigLoader.js +174 -0
- package/dist/config/SelaConfig.d.ts +67 -0
- package/dist/config/SelaConfig.d.ts.map +1 -0
- package/dist/config/SelaConfig.js +57 -0
- package/dist/config/defineConfig.d.ts +3 -0
- package/dist/config/defineConfig.d.ts.map +1 -0
- package/dist/config/defineConfig.js +9 -0
- package/dist/engine/FixwrightEngine.d.ts +24 -0
- package/dist/engine/FixwrightEngine.d.ts.map +1 -0
- package/dist/engine/FixwrightEngine.js +403 -0
- package/dist/engine/HealingRegistry.d.ts +40 -0
- package/dist/engine/HealingRegistry.d.ts.map +1 -0
- package/dist/engine/HealingRegistry.js +98 -0
- package/dist/engine/singleton.d.ts +3 -0
- package/dist/engine/singleton.d.ts.map +1 -0
- package/dist/engine/singleton.js +5 -0
- package/dist/fixtures/expectProxy.d.ts +12 -0
- package/dist/fixtures/expectProxy.d.ts.map +1 -0
- package/dist/fixtures/expectProxy.js +228 -0
- package/dist/fixtures/index.d.ts +6 -0
- package/dist/fixtures/index.d.ts.map +1 -0
- package/dist/fixtures/index.js +688 -0
- package/dist/fixtures/moduleExpect.d.ts +2 -0
- package/dist/fixtures/moduleExpect.d.ts.map +1 -0
- package/dist/fixtures/moduleExpect.js +46 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/services/ASTSourceUpdater.d.ts +79 -0
- package/dist/services/ASTSourceUpdater.d.ts.map +1 -0
- package/dist/services/ASTSourceUpdater.js +3177 -0
- package/dist/services/ArgumentTypeAnalyzer.d.ts +26 -0
- package/dist/services/ArgumentTypeAnalyzer.d.ts.map +1 -0
- package/dist/services/ArgumentTypeAnalyzer.js +92 -0
- package/dist/services/BlastRadiusAnalyzer.d.ts +15 -0
- package/dist/services/BlastRadiusAnalyzer.d.ts.map +1 -0
- package/dist/services/BlastRadiusAnalyzer.js +103 -0
- package/dist/services/ChainValidator.d.ts +76 -0
- package/dist/services/ChainValidator.d.ts.map +1 -0
- package/dist/services/ChainValidator.js +569 -0
- package/dist/services/CrossFileHealer.d.ts +6 -0
- package/dist/services/CrossFileHealer.d.ts.map +1 -0
- package/dist/services/CrossFileHealer.js +134 -0
- package/dist/services/DefinitionTracer.d.ts +41 -0
- package/dist/services/DefinitionTracer.d.ts.map +1 -0
- package/dist/services/DefinitionTracer.js +350 -0
- package/dist/services/DnaEditorService.d.ts +31 -0
- package/dist/services/DnaEditorService.d.ts.map +1 -0
- package/dist/services/DnaEditorService.js +198 -0
- package/dist/services/DnaIndexService.d.ts +24 -0
- package/dist/services/DnaIndexService.d.ts.map +1 -0
- package/dist/services/DnaIndexService.js +131 -0
- package/dist/services/HealingAdvisory.d.ts +22 -0
- package/dist/services/HealingAdvisory.d.ts.map +1 -0
- package/dist/services/HealingAdvisory.js +42 -0
- package/dist/services/HealthReportService.d.ts +10 -0
- package/dist/services/HealthReportService.d.ts.map +1 -0
- package/dist/services/HealthReportService.js +84 -0
- package/dist/services/InitializerUpdater.d.ts +16 -0
- package/dist/services/InitializerUpdater.d.ts.map +1 -0
- package/dist/services/InitializerUpdater.js +37 -0
- package/dist/services/IntentAuditor.d.ts +39 -0
- package/dist/services/IntentAuditor.d.ts.map +1 -0
- package/dist/services/IntentAuditor.js +302 -0
- package/dist/services/LLMService.d.ts +100 -0
- package/dist/services/LLMService.d.ts.map +1 -0
- package/dist/services/LLMService.js +439 -0
- package/dist/services/SafetyGuard.d.ts +65 -0
- package/dist/services/SafetyGuard.d.ts.map +1 -0
- package/dist/services/SafetyGuard.js +524 -0
- package/dist/services/SnapshotService.d.ts +11 -0
- package/dist/services/SnapshotService.d.ts.map +1 -0
- package/dist/services/SnapshotService.js +349 -0
- package/dist/services/SourceLinkService.d.ts +26 -0
- package/dist/services/SourceLinkService.d.ts.map +1 -0
- package/dist/services/SourceLinkService.js +156 -0
- package/dist/services/SourceUpdater.d.ts +45 -0
- package/dist/services/SourceUpdater.d.ts.map +1 -0
- package/dist/services/SourceUpdater.js +1021 -0
- package/dist/services/TemplateDiffService.d.ts +25 -0
- package/dist/services/TemplateDiffService.d.ts.map +1 -0
- package/dist/services/TemplateDiffService.js +331 -0
- package/dist/services/types.d.ts +59 -0
- package/dist/services/types.d.ts.map +1 -0
- package/dist/services/types.js +2 -0
- package/dist/storage/SnapshotManager.d.ts +5 -0
- package/dist/storage/SnapshotManager.d.ts.map +1 -0
- package/dist/storage/SnapshotManager.js +31 -0
- package/dist/types/index.d.ts +95 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/utils/DOMUtils.d.ts +33 -0
- package/dist/utils/DOMUtils.d.ts.map +1 -0
- package/dist/utils/DOMUtils.js +179 -0
- package/dist/utils/StackUtils.d.ts +11 -0
- package/dist/utils/StackUtils.d.ts.map +1 -0
- package/dist/utils/StackUtils.js +120 -0
- package/dist/vendor/enquirer.d.ts +33 -0
- package/dist/vendor/enquirer.d.ts.map +1 -0
- package/dist/vendor/enquirer.js +11 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Fixwright
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
* [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
|
|
14
|
+
* [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
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://gitlab.com/fixwright/Fixwright.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
* [Set up project integrations](https://gitlab.com/fixwright/Fixwright/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
|
|
30
|
+
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
|
|
31
|
+
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
|
|
32
|
+
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
|
|
33
|
+
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
|
|
40
|
+
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
|
|
41
|
+
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
|
|
42
|
+
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
|
|
43
|
+
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
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
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
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
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
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
|
+
## Visuals
|
|
65
|
+
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
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
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
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
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
|
+
|
|
73
|
+
## Support
|
|
74
|
+
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
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
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.
|
|
83
|
+
|
|
84
|
+
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
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
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.
|
package/bin/sela.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type CliErrorCode = 'CONFIG_NOT_FOUND' | 'SNAPSHOT_DIR_MISSING' | 'DNA_NOT_FOUND' | 'SOURCE_FILE_MISSING' | 'VALIDATION_FAILED' | 'AST_ERROR' | 'UNKNOWN';
|
|
2
|
+
export interface CliError {
|
|
3
|
+
code: CliErrorCode;
|
|
4
|
+
message: string;
|
|
5
|
+
detail?: string;
|
|
6
|
+
exitCode: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function handleError(err: unknown): never;
|
|
9
|
+
export declare function registerGlobalHandlers(): void;
|
|
10
|
+
//# sourceMappingURL=ErrorHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorHandler.d.ts","sourceRoot":"","sources":["../../src/cli/ErrorHandler.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,sBAAsB,GACtB,eAAe,GACf,qBAAqB,GACrB,mBAAmB,GACnB,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAqDD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAY/C;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAG7C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handleError = handleError;
|
|
7
|
+
exports.registerGlobalHandlers = registerGlobalHandlers;
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const commander_1 = require("commander");
|
|
10
|
+
const EXIT_CODES = {
|
|
11
|
+
CONFIG_NOT_FOUND: 2,
|
|
12
|
+
SNAPSHOT_DIR_MISSING: 2,
|
|
13
|
+
DNA_NOT_FOUND: 3,
|
|
14
|
+
SOURCE_FILE_MISSING: 3,
|
|
15
|
+
VALIDATION_FAILED: 4,
|
|
16
|
+
AST_ERROR: 5,
|
|
17
|
+
UNKNOWN: 1,
|
|
18
|
+
};
|
|
19
|
+
const KNOWN_CODES = new Set([
|
|
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
|
+
]);
|
|
28
|
+
function isKnownCode(val) {
|
|
29
|
+
return typeof val === 'string' && KNOWN_CODES.has(val);
|
|
30
|
+
}
|
|
31
|
+
function classify(err) {
|
|
32
|
+
if (err instanceof commander_1.CommanderError) {
|
|
33
|
+
return {
|
|
34
|
+
code: 'UNKNOWN',
|
|
35
|
+
message: err.message,
|
|
36
|
+
exitCode: err.exitCode ?? EXIT_CODES.UNKNOWN,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (err instanceof Error) {
|
|
40
|
+
const typed = err;
|
|
41
|
+
const code = isKnownCode(typed.code) ? typed.code : 'UNKNOWN';
|
|
42
|
+
return {
|
|
43
|
+
code,
|
|
44
|
+
message: err.message,
|
|
45
|
+
detail: typed.detail,
|
|
46
|
+
exitCode: EXIT_CODES[code],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
code: 'UNKNOWN',
|
|
51
|
+
message: String(err),
|
|
52
|
+
exitCode: EXIT_CODES.UNKNOWN,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function handleError(err) {
|
|
56
|
+
// Commander uses exitCode 0 for --help/--version — not real errors
|
|
57
|
+
if (err instanceof commander_1.CommanderError && err.exitCode === 0) {
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
const cliErr = classify(err);
|
|
61
|
+
process.stderr.write(`${chalk_1.default.red(`[${cliErr.code}]`)} ${cliErr.message}\n`);
|
|
62
|
+
if (cliErr.detail) {
|
|
63
|
+
process.stderr.write(chalk_1.default.dim(` ${cliErr.detail}\n`));
|
|
64
|
+
}
|
|
65
|
+
process.exit(cliErr.exitCode);
|
|
66
|
+
}
|
|
67
|
+
function registerGlobalHandlers() {
|
|
68
|
+
process.on('uncaughtException', handleError);
|
|
69
|
+
process.on('unhandledRejection', handleError);
|
|
70
|
+
}
|
|
@@ -0,0 +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;AA4DzC,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA4GrD"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerBulkUpdate = registerBulkUpdate;
|
|
7
|
+
const enquirer_js_1 = require("../../vendor/enquirer.js");
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
10
|
+
const ConfigLoader_js_1 = require("../../config/ConfigLoader.js");
|
|
11
|
+
const DnaIndexService_js_1 = require("../../services/DnaIndexService.js");
|
|
12
|
+
const DnaEditorService_js_1 = require("../../services/DnaEditorService.js");
|
|
13
|
+
const SourceLinkService_js_1 = require("../../services/SourceLinkService.js");
|
|
14
|
+
const ProgressReporter_js_1 = require("../ui/ProgressReporter.js");
|
|
15
|
+
function renderTargets(targets) {
|
|
16
|
+
const table = new cli_table3_1.default({
|
|
17
|
+
head: [chalk_1.default.bold('Key'), chalk_1.default.bold('Source File'), chalk_1.default.bold('Selector')],
|
|
18
|
+
colWidths: [12, 48, 44],
|
|
19
|
+
style: { head: [], border: ['dim'] },
|
|
20
|
+
});
|
|
21
|
+
for (const r of targets) {
|
|
22
|
+
table.push([chalk_1.default.dim(r.key.slice(0, 9)), r.sourceFile || chalk_1.default.dim('—'), chalk_1.default.yellow(r.selector)]);
|
|
23
|
+
}
|
|
24
|
+
process.stdout.write(table.toString() + '\n');
|
|
25
|
+
}
|
|
26
|
+
function renderResults(results) {
|
|
27
|
+
process.stdout.write('\n');
|
|
28
|
+
const passed = results.filter((r) => r.success);
|
|
29
|
+
const failed = results.filter((r) => !r.success);
|
|
30
|
+
for (const r of passed) {
|
|
31
|
+
const src = r.sourceUpdated ? chalk_1.default.dim(' + source') : '';
|
|
32
|
+
process.stdout.write(` ${chalk_1.default.green('✓')} ${chalk_1.default.dim(r.key.slice(0, 9))}${src}\n`);
|
|
33
|
+
}
|
|
34
|
+
for (const r of failed) {
|
|
35
|
+
process.stdout.write(` ${chalk_1.default.red('✗')} ${chalk_1.default.dim(r.key.slice(0, 9))} ${chalk_1.default.red(r.reason)}\n`);
|
|
36
|
+
}
|
|
37
|
+
process.stdout.write(`\n ${chalk_1.default.bold(String(passed.length))} updated` +
|
|
38
|
+
(failed.length ? ` ${chalk_1.default.red(String(failed.length) + ' failed')}` : '') +
|
|
39
|
+
'\n\n');
|
|
40
|
+
}
|
|
41
|
+
function registerBulkUpdate(dna) {
|
|
42
|
+
dna
|
|
43
|
+
.command('bulk-update')
|
|
44
|
+
.description('Replace a selector across all matching DNAs')
|
|
45
|
+
.requiredOption('--old <selector>', 'Selector to replace')
|
|
46
|
+
.requiredOption('--new <selector>', 'Replacement selector')
|
|
47
|
+
.option('--dry-run', 'Show affected DNAs without writing')
|
|
48
|
+
.option('--no-source', 'Skip .spec.ts updates')
|
|
49
|
+
.option('--confirm', 'Auto-confirm without interactive prompt')
|
|
50
|
+
.option('--json', 'Emit JSON result instead of formatted output')
|
|
51
|
+
.option('--dir <path>', 'Override snapshot directory')
|
|
52
|
+
.action(async (opts) => {
|
|
53
|
+
const config = ConfigLoader_js_1.ConfigLoader.getInstance();
|
|
54
|
+
const snapshotDir = opts.dir ?? config.dnaStoragePath;
|
|
55
|
+
const progress = new ProgressReporter_js_1.ProgressReporter(opts.json);
|
|
56
|
+
const dnaIndex = new DnaIndexService_js_1.DnaIndexService();
|
|
57
|
+
await progress.run('Scanning DNA snapshots…', () => dnaIndex.buildIndex(snapshotDir));
|
|
58
|
+
const targets = dnaIndex.findBySelector(opts.old);
|
|
59
|
+
if (targets.length === 0) {
|
|
60
|
+
if (opts.json) {
|
|
61
|
+
process.stdout.write(JSON.stringify({ matched: 0, results: [] }, null, 2) + '\n');
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
process.stdout.write(`No DNA records match selector: ${chalk_1.default.yellow(opts.old)}\n`);
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (!opts.json) {
|
|
69
|
+
process.stdout.write(`\n ${chalk_1.default.bold(String(targets.length))} DNA${targets.length > 1 ? 's' : ''} match ` +
|
|
70
|
+
`${chalk_1.default.yellow(opts.old)} → ${chalk_1.default.green(opts.new)}\n\n`);
|
|
71
|
+
renderTargets(targets);
|
|
72
|
+
}
|
|
73
|
+
// ── dry-run: stop here ────────────────────────────────────────────────
|
|
74
|
+
if (opts.dryRun) {
|
|
75
|
+
if (opts.json) {
|
|
76
|
+
process.stdout.write(JSON.stringify({ dryRun: true, matched: targets.length, targets: targets.map((t) => t.key) }, null, 2) + '\n');
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
process.stdout.write(chalk_1.default.dim('\n [dry-run] No files written.\n\n'));
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// ── confirm (skip in --json mode — requires --confirm flag) ──────────
|
|
84
|
+
if (!opts.confirm && !opts.json) {
|
|
85
|
+
const prompt = new enquirer_js_1.Confirm({
|
|
86
|
+
name: 'ok',
|
|
87
|
+
message: `Update ${targets.length} DNA file${targets.length > 1 ? 's' : ''}?`,
|
|
88
|
+
});
|
|
89
|
+
const yes = (await prompt.run());
|
|
90
|
+
if (!yes) {
|
|
91
|
+
process.stdout.write(chalk_1.default.dim('Aborted.\n'));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (!opts.confirm && opts.json) {
|
|
96
|
+
// In JSON/CI mode without --confirm, abort safely rather than hanging on a prompt.
|
|
97
|
+
process.stderr.write('bulk-update: pass --confirm to skip interactive prompt in --json mode\n');
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
// ── write sequentially (backup safety) ───────────────────────────────
|
|
101
|
+
const editor = new DnaEditorService_js_1.DnaEditorService(snapshotDir);
|
|
102
|
+
const sourceLink = opts.source ? new SourceLinkService_js_1.SourceLinkService() : null;
|
|
103
|
+
const results = [];
|
|
104
|
+
await progress.run(`Updating ${targets.length} DNA file${targets.length > 1 ? 's' : ''}…`, async () => {
|
|
105
|
+
for (const record of targets) {
|
|
106
|
+
const result = { key: record.key, success: false, reason: '' };
|
|
107
|
+
try {
|
|
108
|
+
await editor.write(record.key, { selector: opts.new });
|
|
109
|
+
result.success = true;
|
|
110
|
+
if (sourceLink && record.sourceFile && record.sourceLine > 0) {
|
|
111
|
+
const patch = {
|
|
112
|
+
key: record.key,
|
|
113
|
+
field: 'selector',
|
|
114
|
+
oldValue: opts.old,
|
|
115
|
+
newValue: opts.new,
|
|
116
|
+
applySourceUpdate: true,
|
|
117
|
+
locatorIndex: 0,
|
|
118
|
+
};
|
|
119
|
+
const astResult = await sourceLink.applySourceUpdate(record, patch);
|
|
120
|
+
result.sourceUpdated = astResult.success;
|
|
121
|
+
if (!astResult.success) {
|
|
122
|
+
result.reason = `DNA ok; source: ${astResult.reason}`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
result.success = false;
|
|
128
|
+
result.reason = err instanceof Error ? err.message : String(err);
|
|
129
|
+
}
|
|
130
|
+
results.push(result);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
if (opts.json) {
|
|
134
|
+
process.stdout.write(JSON.stringify({ matched: targets.length, results }, null, 2) + '\n');
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
renderResults(results);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6BzC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqCnD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerFind = registerFind;
|
|
4
|
+
const ConfigLoader_js_1 = require("../../config/ConfigLoader.js");
|
|
5
|
+
const DnaIndexService_js_1 = require("../../services/DnaIndexService.js");
|
|
6
|
+
const DnaTable_js_1 = require("../ui/DnaTable.js");
|
|
7
|
+
const ProgressReporter_js_1 = require("../ui/ProgressReporter.js");
|
|
8
|
+
function search(svc, pattern, field) {
|
|
9
|
+
switch (field) {
|
|
10
|
+
case 'selector': return svc.findBySelector(pattern);
|
|
11
|
+
case 'text': return svc.findByText(pattern);
|
|
12
|
+
case 'file': return svc.findBySourceFile(pattern);
|
|
13
|
+
default: {
|
|
14
|
+
const err = new Error(`Unknown --field value: "${field}". Must be selector | text | file`);
|
|
15
|
+
err.code = 'UNKNOWN';
|
|
16
|
+
throw err;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function registerFind(program) {
|
|
21
|
+
program
|
|
22
|
+
.command('find <pattern>')
|
|
23
|
+
.description('Search DNA records by selector, visible text, or source file')
|
|
24
|
+
.option('--field <selector|text|file>', 'Field to search (default: selector)', 'selector')
|
|
25
|
+
.option('--json', 'Emit JSON array')
|
|
26
|
+
.option('--limit <n>', 'Max rows (default: 50)', '50')
|
|
27
|
+
.option('--dir <path>', 'Override snapshot directory')
|
|
28
|
+
.action(async (pattern, opts) => {
|
|
29
|
+
const config = ConfigLoader_js_1.ConfigLoader.getInstance();
|
|
30
|
+
const snapshotDir = opts.dir ?? config.dnaStoragePath;
|
|
31
|
+
const progress = new ProgressReporter_js_1.ProgressReporter(opts.json);
|
|
32
|
+
const svc = new DnaIndexService_js_1.DnaIndexService();
|
|
33
|
+
await progress.run('Scanning DNA snapshots…', () => svc.buildIndex(snapshotDir));
|
|
34
|
+
const limit = Math.max(1, parseInt(opts.limit, 10) || 50);
|
|
35
|
+
let records = search(svc, pattern, opts.field);
|
|
36
|
+
const total = records.length;
|
|
37
|
+
records = records.slice(0, limit);
|
|
38
|
+
if (opts.json) {
|
|
39
|
+
process.stdout.write(JSON.stringify(records, null, 2) + '\n');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (records.length === 0) {
|
|
43
|
+
process.stdout.write(`No DNA records match ${opts.field}:${JSON.stringify(pattern)}\n`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
process.stdout.write((0, DnaTable_js_1.renderTable)(records) + '\n');
|
|
47
|
+
if (total > limit) {
|
|
48
|
+
process.stderr.write(`Showing ${limit} of ${total} matches. Use --limit to see more.\n`);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +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;AA0BpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQnD"}
|
|
@@ -0,0 +1,133 @@
|
|
|
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.registerInit = registerInit;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const CONFIG_TEMPLATE_TS = `import { defineConfig } from 'sela';
|
|
40
|
+
|
|
41
|
+
export default defineConfig({
|
|
42
|
+
healingPolicy: 'balanced',
|
|
43
|
+
updateStrategy: 'inPlace',
|
|
44
|
+
autoCommit: false,
|
|
45
|
+
dnaStoragePath: 'sela-snapshots',
|
|
46
|
+
});
|
|
47
|
+
`;
|
|
48
|
+
const CONFIG_TEMPLATE_JS = `const { defineConfig } = require('sela');
|
|
49
|
+
|
|
50
|
+
module.exports = defineConfig({
|
|
51
|
+
healingPolicy: 'balanced',
|
|
52
|
+
updateStrategy: 'inPlace',
|
|
53
|
+
autoCommit: false,
|
|
54
|
+
dnaStoragePath: 'sela-snapshots',
|
|
55
|
+
});
|
|
56
|
+
`;
|
|
57
|
+
const REQUIRED_ENV_VARS = ['ANTHROPIC_API_KEY'];
|
|
58
|
+
function registerInit(program) {
|
|
59
|
+
program
|
|
60
|
+
.command('init')
|
|
61
|
+
.description('Initialize Sela in the current project')
|
|
62
|
+
.option('--update-imports', 'Swap @playwright/test imports to sela in spec files')
|
|
63
|
+
.action(async (opts) => {
|
|
64
|
+
await runInit(opts);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async function runInit(opts) {
|
|
68
|
+
const cwd = process.cwd();
|
|
69
|
+
const isTs = fs.existsSync(path.join(cwd, 'tsconfig.json'));
|
|
70
|
+
const configFile = isTs ? 'sela.config.ts' : 'sela.config.js';
|
|
71
|
+
const configPath = path.join(cwd, configFile);
|
|
72
|
+
console.error(`\n🚀 Initializing Sela`);
|
|
73
|
+
console.error(` Project type : ${isTs ? 'TypeScript' : 'JavaScript'}`);
|
|
74
|
+
console.error(` Directory : ${cwd}\n`);
|
|
75
|
+
// ── Config file ──────────────────────────────────────────────────
|
|
76
|
+
if (fs.existsSync(configPath)) {
|
|
77
|
+
console.error(`✅ ${configFile} already exists — skipping`);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
fs.writeFileSync(configPath, isTs ? CONFIG_TEMPLATE_TS : CONFIG_TEMPLATE_JS, 'utf8');
|
|
81
|
+
console.error(`✅ Created ${configFile}`);
|
|
82
|
+
}
|
|
83
|
+
// ── Environment variables ────────────────────────────────────────
|
|
84
|
+
const missing = REQUIRED_ENV_VARS.filter((k) => !process.env[k]);
|
|
85
|
+
if (missing.length > 0) {
|
|
86
|
+
console.error(`\n⚠️ Missing environment variables:`);
|
|
87
|
+
for (const k of missing)
|
|
88
|
+
console.error(` - ${k}`);
|
|
89
|
+
console.error(`\n Add them to .env or your shell profile before running tests.\n`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.error(`✅ Environment variables OK`);
|
|
93
|
+
}
|
|
94
|
+
// ── Optional import swap ─────────────────────────────────────────
|
|
95
|
+
if (opts.updateImports) {
|
|
96
|
+
const swapped = swapImports(cwd, isTs);
|
|
97
|
+
console.error(`✅ Updated imports in ${swapped} spec file(s)`);
|
|
98
|
+
}
|
|
99
|
+
console.error(`\n📖 Replace imports in your spec files:`);
|
|
100
|
+
console.error(` from: import { test, expect } from '@playwright/test'`);
|
|
101
|
+
console.error(` to: import { test, expect } from 'sela'\n`);
|
|
102
|
+
}
|
|
103
|
+
function walkDir(dir, exts) {
|
|
104
|
+
const results = [];
|
|
105
|
+
const ignore = new Set(['node_modules', 'dist', '.git']);
|
|
106
|
+
function walk(current) {
|
|
107
|
+
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
|
|
108
|
+
if (entry.isDirectory()) {
|
|
109
|
+
if (!ignore.has(entry.name))
|
|
110
|
+
walk(path.join(current, entry.name));
|
|
111
|
+
}
|
|
112
|
+
else if (exts.some((e) => entry.name.endsWith(e))) {
|
|
113
|
+
results.push(path.join(current, entry.name));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
walk(dir);
|
|
118
|
+
return results;
|
|
119
|
+
}
|
|
120
|
+
function swapImports(cwd, isTs) {
|
|
121
|
+
const exts = isTs ? ['.spec.ts', '.test.ts'] : ['.spec.js', '.test.js'];
|
|
122
|
+
const files = walkDir(cwd, exts);
|
|
123
|
+
let swapped = 0;
|
|
124
|
+
for (const filePath of files) {
|
|
125
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
126
|
+
const updated = content.replace(/from\s+['"]@playwright\/test['"]/g, `from 'sela'`);
|
|
127
|
+
if (updated !== content) {
|
|
128
|
+
fs.writeFileSync(filePath, updated, 'utf8');
|
|
129
|
+
swapped++;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return swapped;
|
|
133
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoCzC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuCnD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerList = registerList;
|
|
4
|
+
const ConfigLoader_js_1 = require("../../config/ConfigLoader.js");
|
|
5
|
+
const DnaIndexService_js_1 = require("../../services/DnaIndexService.js");
|
|
6
|
+
const DnaTable_js_1 = require("../ui/DnaTable.js");
|
|
7
|
+
const ProgressReporter_js_1 = require("../ui/ProgressReporter.js");
|
|
8
|
+
function applyFilters(svc, opts) {
|
|
9
|
+
let records = svc.getIndex().records;
|
|
10
|
+
if (opts.filter) {
|
|
11
|
+
const filtered = new Set(svc.findBySelector(opts.filter).map((r) => r.key));
|
|
12
|
+
records = records.filter((r) => filtered.has(r.key));
|
|
13
|
+
}
|
|
14
|
+
if (opts.source) {
|
|
15
|
+
const filtered = new Set(svc.findBySourceFile(opts.source).map((r) => r.key));
|
|
16
|
+
records = records.filter((r) => filtered.has(r.key));
|
|
17
|
+
}
|
|
18
|
+
if (opts.orphaned) {
|
|
19
|
+
records = records.filter((r) => r.isOrphaned);
|
|
20
|
+
}
|
|
21
|
+
return records;
|
|
22
|
+
}
|
|
23
|
+
function registerList(program) {
|
|
24
|
+
program
|
|
25
|
+
.command('list')
|
|
26
|
+
.description('List DNA records')
|
|
27
|
+
.option('--filter <pattern>', 'Filter by selector substring or /regex/')
|
|
28
|
+
.option('--source <file>', 'Filter by source file path')
|
|
29
|
+
.option('--orphaned', 'Show only orphaned DNAs')
|
|
30
|
+
.option('--json', 'Emit JSON array')
|
|
31
|
+
.option('--limit <n>', 'Max rows (default: 50)', '50')
|
|
32
|
+
.option('--dir <path>', 'Override snapshot directory')
|
|
33
|
+
.action(async (opts) => {
|
|
34
|
+
const config = ConfigLoader_js_1.ConfigLoader.getInstance();
|
|
35
|
+
const snapshotDir = opts.dir ?? config.dnaStoragePath;
|
|
36
|
+
const progress = new ProgressReporter_js_1.ProgressReporter(opts.json);
|
|
37
|
+
const svc = new DnaIndexService_js_1.DnaIndexService();
|
|
38
|
+
await progress.run('Scanning DNA snapshots…', () => svc.buildIndex(snapshotDir));
|
|
39
|
+
const limit = Math.max(1, parseInt(opts.limit, 10) || 50);
|
|
40
|
+
let records = applyFilters(svc, opts);
|
|
41
|
+
const total = records.length;
|
|
42
|
+
records = records.slice(0, limit);
|
|
43
|
+
if (opts.json) {
|
|
44
|
+
process.stdout.write(JSON.stringify(records, null, 2) + '\n');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (records.length === 0) {
|
|
48
|
+
process.stdout.write('No DNA records match the given filters.\n');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
process.stdout.write((0, DnaTable_js_1.renderTable)(records) + '\n');
|
|
52
|
+
if (total > limit) {
|
|
53
|
+
process.stderr.write(`Showing ${limit} of ${total} records. Use --limit to see more.\n`);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refactor.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/refactor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAczC,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CA0BnD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerRefactor = registerRefactor;
|
|
4
|
+
const ConfigLoader_js_1 = require("../../config/ConfigLoader.js");
|
|
5
|
+
const DnaIndexService_js_1 = require("../../services/DnaIndexService.js");
|
|
6
|
+
const DnaEditorService_js_1 = require("../../services/DnaEditorService.js");
|
|
7
|
+
const SourceLinkService_js_1 = require("../../services/SourceLinkService.js");
|
|
8
|
+
const RefactorWizard_js_1 = require("../ui/RefactorWizard.js");
|
|
9
|
+
const ProgressReporter_js_1 = require("../ui/ProgressReporter.js");
|
|
10
|
+
function registerRefactor(dna) {
|
|
11
|
+
dna
|
|
12
|
+
.command('refactor [key]')
|
|
13
|
+
.description('Interactive refactor wizard for a DNA record')
|
|
14
|
+
.option('--no-source', 'Skip source file update')
|
|
15
|
+
.option('--dry-run', 'Preview changes without writing')
|
|
16
|
+
.option('--dir <path>', 'Override snapshot directory')
|
|
17
|
+
.action(async (key, opts) => {
|
|
18
|
+
const config = ConfigLoader_js_1.ConfigLoader.getInstance();
|
|
19
|
+
const snapshotDir = opts.dir ?? config.dnaStoragePath;
|
|
20
|
+
const progress = new ProgressReporter_js_1.ProgressReporter(false); // wizard is always interactive
|
|
21
|
+
const dnaIndex = new DnaIndexService_js_1.DnaIndexService();
|
|
22
|
+
await progress.run('Scanning DNA snapshots…', () => dnaIndex.buildIndex(snapshotDir));
|
|
23
|
+
const wizard = new RefactorWizard_js_1.RefactorWizard({
|
|
24
|
+
dnaIndex,
|
|
25
|
+
dnaEditor: new DnaEditorService_js_1.DnaEditorService(snapshotDir),
|
|
26
|
+
sourceLink: new SourceLinkService_js_1.SourceLinkService(),
|
|
27
|
+
}, { noSource: !opts.source, dryRun: opts.dryRun });
|
|
28
|
+
await wizard.run(key);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkCzC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6BrD"}
|