Skip to content

Commit 2876c3a

Browse files
committed
convert repo to object arg, watch for composer changes
1 parent 0163e6c commit 2876c3a

20 files changed

+151
-102
lines changed

src/extension.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as vscode from "vscode";
44

55
import os from "os";
66
import { LanguageClient } from "vscode-languageclient/node";
7+
import { bladeSpacer } from "./blade/bladeSpacer";
78
import { initClient } from "./blade/client";
89
import { CodeActionProvider } from "./codeAction/codeActionProvider";
910
import { openFileCommand } from "./commands";
@@ -19,13 +20,15 @@ import { hoverProviders } from "./hover/HoverProvider";
1920
import { linkProviders } from "./link/LinkProvider";
2021
import { configAffected } from "./support/config";
2122
import { collectDebugInfo } from "./support/debug";
22-
import { disposeWatchers } from "./support/fileWatcher";
23+
import {
24+
disposeWatchers,
25+
watchForComposerChanges,
26+
} from "./support/fileWatcher";
2327
import { info } from "./support/logger";
2428
import { setParserBinaryPath } from "./support/parser";
2529
import { clearDefaultPhpCommand, initVendorWatchers } from "./support/php";
2630
import { hasWorkspace, projectPathExists } from "./support/project";
2731
import { cleanUpTemp } from "./support/util";
28-
import { bladeSpacer } from "./blade/bladeSpacer";
2932

3033
let client: LanguageClient;
3134

@@ -65,6 +68,7 @@ export function activate(context: vscode.ExtensionContext) {
6568
const LANGUAGES = [{ scheme: "file", language: "php" }, ...BLADE_LANGUAGES];
6669

6770
initVendorWatchers();
71+
watchForComposerChanges();
6872
setParserBinaryPath(context);
6973

7074
const TRIGGER_CHARACTERS = ["'", '"'];

src/repositories/appBinding.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ type AppBindingItem = {
99
};
1010
};
1111

12-
export const getAppBindings = repository<AppBindingItem>(
13-
() => {
12+
export const getAppBindings = repository<AppBindingItem>({
13+
load: () => {
1414
return runInLaravel<AppBindingItem>(template("app"), "App Bindings");
1515
},
16-
"app/Providers/{,*,**/*}.php",
17-
{},
18-
);
16+
pattern: "app/Providers/{,*,**/*}.php",
17+
itemsDefault: {},
18+
});

src/repositories/asset.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ const getFilesInDirectory = (dir: string, depth: number = 0): Item[] => {
5353
.flat();
5454
};
5555

56-
export const getAssets = repository<Item[]>(
57-
() =>
56+
export const getAssets = repository<Item[]>({
57+
load: () =>
5858
new Promise((resolve, reject) => {
5959
try {
6060
resolve(getFilesInDirectory("public"));
6161
} catch (exception) {
6262
reject(exception);
6363
}
6464
}),
65-
"public/**/*",
66-
[],
67-
);
65+
pattern: "public/**/*",
66+
itemsDefault: [],
67+
reloadOnComposerChanges: false,
68+
});

src/repositories/auth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const load = () => {
1616
return runInLaravel<AuthItems>(template("auth"), "Auth Data");
1717
};
1818

19-
export const getPolicies = repository<AuthItems>(
19+
export const getPolicies = repository<AuthItems>({
2020
load,
21-
"app/Providers/{,*,**/*}.php",
22-
{},
23-
);
21+
pattern: "app/Providers/{,*,**/*}.php",
22+
itemsDefault: {},
23+
});

src/repositories/bladeComponents.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ const load = () => {
2121
return runInLaravel<BladeComponents>(template("bladeComponents"));
2222
};
2323

24-
export const getBladeComponents = repository<BladeComponents>(
24+
export const getBladeComponents = repository<BladeComponents>({
2525
load,
26-
[
26+
pattern: [
2727
inAppDirs("{,**/}{view,views}/{*,**/*}"),
2828
"app/View/Components/{,*,**/*}.php",
2929
],
30-
{
30+
itemsDefault: {
3131
components: {},
3232
prefixes: [],
3333
},
34-
["create", "delete"],
35-
);
34+
fileWatcherEvents: ["create", "delete"],
35+
});

src/repositories/configs.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { repository } from ".";
22
import { Config } from "..";
33
import { runInLaravel, template } from "../support/php";
44

5-
export const getConfigs = repository<Config[]>(
6-
() => {
5+
export const getConfigs = repository<Config[]>({
6+
load: () => {
77
return runInLaravel<Config[]>(template("configs"), "Configs").then(
88
(result) =>
99
result.map((item) => {
@@ -16,6 +16,6 @@ export const getConfigs = repository<Config[]>(
1616
}),
1717
);
1818
},
19-
["config/{,*,**/*}.php", ".env"],
20-
[],
21-
);
19+
pattern: ["config/{,*,**/*}.php", ".env"],
20+
itemsDefault: [],
21+
});

src/repositories/controllers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ const collectControllers = (path: string): string[] => {
7575
return [...controllers];
7676
};
7777

78-
export const getControllers = repository<string[]>(
79-
() => {
78+
export const getControllers = repository<string[]>({
79+
load: () => {
8080
return new Promise((resolve) => {
8181
resolve(load());
8282
});
8383
},
84-
inAppDirs("{,**/}{Controllers}{.php,/*.php,/**/*.php}"),
85-
[],
86-
);
84+
pattern: inAppDirs("{,**/}{Controllers}{.php,/*.php,/**/*.php}"),
85+
itemsDefault: [],
86+
});

src/repositories/customBladeDirectives.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ interface CustomDirectiveItem {
66
hasParams: boolean;
77
}
88

9-
export const getCustomBladeDirectives = repository<CustomDirectiveItem[]>(
10-
() =>
9+
export const getCustomBladeDirectives = repository<CustomDirectiveItem[]>({
10+
load: () =>
1111
runInLaravel<CustomDirectiveItem[]>(
1212
template("bladeDirectives"),
1313
"Custom Blade Directives",
1414
),
15-
"app/{,*,**/*}Provider.php",
16-
[],
17-
);
15+
pattern: "app/{,*,**/*}Provider.php",
16+
itemsDefault: [],
17+
});

src/repositories/env-example.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ const load = () => {
4141
return items;
4242
};
4343

44-
export const getEnvExample = repository<EnvItem>(
45-
() =>
44+
export const getEnvExample = repository<EnvItem>({
45+
load: () =>
4646
new Promise<EnvItem>((resolve, reject) => {
4747
try {
4848
resolve(load());
4949
} catch (error) {
5050
reject(error);
5151
}
5252
}),
53-
filename,
54-
{},
55-
);
53+
pattern: filename,
54+
itemsDefault: {},
55+
reloadOnComposerChanges: false,
56+
});

src/repositories/env.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,16 @@ const load = () => {
4545
return items;
4646
};
4747

48-
export const getEnv = repository<EnvItem>(
49-
() =>
48+
export const getEnv = repository<EnvItem>({
49+
load: () =>
5050
new Promise<EnvItem>((resolve, reject) => {
5151
try {
5252
resolve(load());
5353
} catch (error) {
5454
reject(error);
5555
}
5656
}),
57-
".env",
58-
{},
59-
);
57+
pattern: ".env",
58+
itemsDefault: {},
59+
reloadOnComposerChanges: false,
60+
});

0 commit comments

Comments
 (0)