@rigkit/provider-vscode 0.1.8

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.
@@ -0,0 +1,20 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { findConfigUp, resolveRigkitProject } from "./project.ts";
3
+
4
+ describe("VS Code Rigkit project resolution", () => {
5
+ test("finds rig.config.ts by searching upward", () => {
6
+ const existing = new Set([
7
+ "/repo/rig.config.ts",
8
+ ]);
9
+
10
+ expect(findConfigUp("/repo/packages/app", (path) => existing.has(path))).toBe("/repo/rig.config.ts");
11
+ expect(resolveRigkitProject("/repo/packages/app", (path) => existing.has(path))).toEqual({
12
+ projectDir: "/repo",
13
+ configPath: "/repo/rig.config.ts",
14
+ });
15
+ });
16
+
17
+ test("returns undefined when no config exists", () => {
18
+ expect(findConfigUp("/repo/packages/app", () => false)).toBeUndefined();
19
+ });
20
+ });
package/src/project.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { existsSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+
4
+ export type RigkitProject = {
5
+ projectDir: string;
6
+ configPath: string;
7
+ };
8
+
9
+ export function resolveRigkitProject(startDir: string, fileExists: (path: string) => boolean = existsSync): RigkitProject {
10
+ const configPath = findConfigUp(startDir, fileExists);
11
+ if (!configPath) {
12
+ throw new Error(`No rig.config.ts found from ${startDir}`);
13
+ }
14
+ return {
15
+ projectDir: dirname(configPath),
16
+ configPath,
17
+ };
18
+ }
19
+
20
+ export function findConfigUp(startDir: string, fileExists: (path: string) => boolean = existsSync): string | undefined {
21
+ let current = resolve(startDir);
22
+ for (;;) {
23
+ const candidate = join(current, "rig.config.ts");
24
+ if (fileExists(candidate)) return candidate;
25
+ const parent = dirname(current);
26
+ if (parent === current) return undefined;
27
+ current = parent;
28
+ }
29
+ }
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const RIGKIT_PROVIDER_VSCODE_VERSION = "0.1.8";
@@ -0,0 +1,126 @@
1
+ declare module "vscode" {
2
+ export type Event<T> = (listener: (event: T) => unknown) => Disposable;
3
+
4
+ export interface Disposable {
5
+ dispose(): unknown;
6
+ }
7
+
8
+ export class EventEmitter<T> implements Disposable {
9
+ readonly event: Event<T>;
10
+ fire(data: T): void;
11
+ dispose(): void;
12
+ }
13
+
14
+ export class Uri {
15
+ readonly fsPath: string;
16
+ static file(path: string): Uri;
17
+ static parse(value: string): Uri;
18
+ toString(): string;
19
+ }
20
+
21
+ export class ThemeIcon {
22
+ constructor(id: string);
23
+ }
24
+
25
+ export enum TreeItemCollapsibleState {
26
+ None = 0,
27
+ Collapsed = 1,
28
+ Expanded = 2
29
+ }
30
+
31
+ export class TreeItem {
32
+ label?: string;
33
+ description?: string;
34
+ tooltip?: string;
35
+ iconPath?: ThemeIcon;
36
+ contextValue?: string;
37
+ command?: Command;
38
+ constructor(label: string, collapsibleState?: TreeItemCollapsibleState);
39
+ }
40
+
41
+ export interface Command {
42
+ command: string;
43
+ title: string;
44
+ arguments?: unknown[];
45
+ }
46
+
47
+ export interface TreeDataProvider<T> {
48
+ readonly onDidChangeTreeData?: Event<T | undefined | null | void>;
49
+ getTreeItem(element: T): TreeItem | Thenable<TreeItem>;
50
+ getChildren(element?: T): ProviderResult<T[]>;
51
+ }
52
+
53
+ export type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;
54
+
55
+ export interface WorkspaceFolder {
56
+ readonly uri: Uri;
57
+ readonly name: string;
58
+ }
59
+
60
+ export interface WorkspaceConfiguration {
61
+ get<T>(key: string, defaultValue: T): T;
62
+ }
63
+
64
+ export interface ExtensionContext {
65
+ readonly subscriptions: Disposable[];
66
+ }
67
+
68
+ export enum ProgressLocation {
69
+ Notification = 15,
70
+ Window = 10
71
+ }
72
+
73
+ export interface ProgressOptions {
74
+ location: ProgressLocation;
75
+ title?: string;
76
+ }
77
+
78
+ export interface QuickPickItem {
79
+ label: string;
80
+ description?: string;
81
+ detail?: string;
82
+ }
83
+
84
+ export interface InputBoxOptions {
85
+ title?: string;
86
+ prompt?: string;
87
+ value?: string;
88
+ ignoreFocusOut?: boolean;
89
+ }
90
+
91
+ export interface Terminal {
92
+ sendText(text: string): void;
93
+ show(preserveFocus?: boolean): void;
94
+ }
95
+
96
+ export const window: {
97
+ showInformationMessage(message: string, ...items: string[]): Thenable<string | undefined>;
98
+ showWarningMessage(message: string, ...items: string[]): Thenable<string | undefined>;
99
+ showErrorMessage(message: string, ...items: string[]): Thenable<string | undefined>;
100
+ showInputBox(options?: InputBoxOptions): Thenable<string | undefined>;
101
+ showQuickPick<T extends QuickPickItem>(items: readonly T[], options?: { title?: string; placeHolder?: string; ignoreFocusOut?: boolean }): Thenable<T | undefined>;
102
+ registerTreeDataProvider<T>(viewId: string, provider: TreeDataProvider<T>): Disposable;
103
+ withProgress<R>(options: ProgressOptions, task: () => Thenable<R>): Thenable<R>;
104
+ createOutputChannel(name: string): OutputChannel;
105
+ createTerminal(options: { name: string; cwd?: string; env?: Record<string, string | undefined> }): Terminal;
106
+ };
107
+
108
+ export interface OutputChannel extends Disposable {
109
+ appendLine(value: string): void;
110
+ show(preserveFocus?: boolean): void;
111
+ }
112
+
113
+ export const workspace: {
114
+ readonly workspaceFolders?: readonly WorkspaceFolder[];
115
+ getConfiguration(section?: string): WorkspaceConfiguration;
116
+ };
117
+
118
+ export const commands: {
119
+ registerCommand(command: string, callback: (...args: any[]) => unknown): Disposable;
120
+ executeCommand<T = unknown>(command: string, ...args: unknown[]): Thenable<T>;
121
+ };
122
+
123
+ export const env: {
124
+ openExternal(target: Uri): Thenable<boolean>;
125
+ };
126
+ }