Skip to content

Commit 543b3a0

Browse files
committed
Remove reliance on .sln file
1 parent 8364b47 commit 543b3a0

22 files changed

+156
-87
lines changed

README.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,13 @@ A VS Code extension to manage Entity Framework migrations.
1616

1717
- [dotnet sdk](https://dotnet.microsoft.com/download)
1818
- [efcore tools](https://learn.microsoft.com/en-us/ef/core/cli/dotnet)
19-
- A solution (`.sln`) file with projects
2019
- [Microsoft.EntityFrameworkCore.Design](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Design) must be installed in one of the projects
2120

2221
## Extension Settings
2322

2423
This extension contributes the following settings:
2524

26-
- `entityframework.env`: Custom environment variables, for example:
27-
```json
28-
{
29-
"entityframework.env": {
30-
"ASPNETCORE_ENVIRONMENT": "LocalDev",
31-
"TenantId": "12345"
32-
}
33-
}
34-
```
3525
- `entityframework.commands`: Custom commands, for example:
36-
3726
```json
3827
{
3928
"entityframework.commands": {
@@ -88,10 +77,24 @@ This extension contributes the following settings:
8877
}
8978
}
9079
```
80+
- `entityframework.env`: Custom environment variables, for example:
81+
```json
82+
{
83+
"entityframework.env": {
84+
"ASPNETCORE_ENVIRONMENT": "LocalDev",
85+
"TenantId": "12345"
86+
}
87+
}
88+
```
9189

9290
## Performance
9391

94-
The EF tools execute application code at design time to get information about the project, thus performance can be slow on large projects.
92+
The EF tools execute application code at design time to get information about the project, thus performance on large projects can be slow.
93+
94+
## Support
95+
96+
- 👉 [Submit a bug report](https://github.com/badsyntax/vscode-entity-framework/issues/new?assignees=badsyntax&labels=bug&template=bug_report.md&title=)
97+
- 👉 [Submit a feature request](https://github.com/badsyntax/vscode-entity-framework/issues/new?assignees=badsyntax&labels=enhancement&template=feature_request.md&title=)
9598

9699
## License
97100

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"Other"
3030
],
3131
"activationEvents": [
32-
"workspaceContains:**/*.sln"
32+
"workspaceContains:**/*.csproj"
3333
],
3434
"license": "SEE LICENSE IN LICENSE.md",
3535
"bugs": {

src/actions/GenerateScriptAction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as vscode from 'vscode';
22

3-
import { extractDataFromStdOut } from '../cli/ef';
3+
import { getDataFromStdOut } from '../cli/ef';
44
import { getCommandsConfig } from '../config/config';
55
import type { TerminalProvider } from '../terminal/TerminalProvider';
66
import { TerminalAction } from './TerminalAction';
@@ -24,7 +24,7 @@ export class GenerateScriptAction extends TerminalAction {
2424
}
2525

2626
public async run() {
27-
const output = extractDataFromStdOut(await super.run());
27+
const output = getDataFromStdOut(await super.run());
2828
const uri = vscode.Uri.parse('ef-script:' + output);
2929
const doc = await vscode.workspace.openTextDocument(uri);
3030
await vscode.languages.setTextDocumentLanguage(doc, 'sql');

src/cli/ef.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,32 @@ import { promisify } from 'node:util';
33
import { getEnvConfig } from '../config/config';
44

55
const execAsync = promisify(exec);
6+
const NEWLINE_SEPARATOR = /\r\n|\r|\n/;
7+
const STDOUT_PREFIX = /^[a-z]+: /;
68

7-
export function extractDataFromStdOut(output: string): string {
9+
export function removePrefixFromStdOut(output: string): string {
810
return output
9-
.split(/\r\n|\r|\n/)
10-
.filter(line => line.startsWith('data: '))
11-
.map(line => line.replace('data: ', ''))
11+
.split(NEWLINE_SEPARATOR)
12+
.map(line => line.replace(STDOUT_PREFIX, ''))
1213
.join('\n');
1314
}
1415

15-
export function removePrefixFromStdOut(output: string): string {
16-
return output
17-
.split(/\r\n|\r|\n/)
18-
.map(line => line.replace(/^[a-z]+: /, ''))
19-
.join('\n');
16+
export function getDataFromStdOut(output: string): string {
17+
return removePrefixFromStdOut(
18+
output
19+
.split(NEWLINE_SEPARATOR)
20+
.filter(line => line.startsWith('data:'))
21+
.join('\n'),
22+
);
2023
}
2124

2225
export function getErrorsFromStdOut(output: string): string {
23-
return output
24-
.split(/\r\n|\r|\n/)
25-
.filter(line => line.startsWith('error:'))
26-
.map(line => line.replace(/^[a-z]+: /, ''))
27-
.join('\n');
26+
return removePrefixFromStdOut(
27+
output
28+
.split(NEWLINE_SEPARATOR)
29+
.filter(line => line.startsWith('error:'))
30+
.join('\n'),
31+
);
2832
}
2933

3034
export async function execEF(

src/commands/AddMigrationCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class AddMigrationCommand extends Command {
1919
}
2020
return new AddMigrationAction(
2121
this.terminalProvider,
22-
this.item.solutionFile.workspaceRoot,
22+
this.item.workspaceRoot,
2323
this.item.label,
2424
this.item.project,
2525
).run();

src/commands/GenerateScriptCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class GenerateScriptCommand extends Command {
1919
}
2020
return new GenerateScriptAction(
2121
this.terminalProvider,
22-
this.item.solutionFile.workspaceRoot,
22+
this.item.workspaceRoot,
2323
this.item.label,
2424
this.item.project,
2525
).run();

src/commands/RemoveMigrationCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class RemoveMigrationCommand extends Command {
1919
}
2020
return new RemoveMigrationAction(
2121
this.terminalProvider,
22-
this.item.solutionFile.workspaceRoot,
22+
this.item.workspaceRoot,
2323
this.item.dbContext,
2424
this.item.project,
2525
).run();

src/commands/RunMigrationCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class RunMigrationCommand extends Command {
1919
}
2020
return new RunMigrationAction(
2121
this.terminalProvider,
22-
this.item.solutionFile.workspaceRoot,
22+
this.item.workspaceRoot,
2323
this.item.dbContext,
2424
this.item.project,
2525
this.item.migration.id,

src/commands/UndoMigrationCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class UndoMigrationCommand extends Command {
2222
return;
2323
}
2424
const cacheId = DbContextTreeItem.getCacheId(
25-
this.item.solutionFile.workspaceRoot,
25+
this.item.workspaceRoot,
2626
this.item.project,
2727
this.item.dbContext,
2828
);
@@ -33,7 +33,7 @@ export class UndoMigrationCommand extends Command {
3333
index === 0 ? '0' : migrations[index - 1].migration.id;
3434
return new RunMigrationAction(
3535
this.terminalProvider,
36-
this.item.solutionFile.workspaceRoot,
36+
this.item.workspaceRoot,
3737
this.item.dbContext,
3838
this.item.project,
3939
migrationId,

src/constants/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export const EXTENSION_NAMESPACE = 'entityframework';
2+
3+
export const TERMINAL_NAME = 'ef-migrations';

0 commit comments

Comments
 (0)