lim 0.14.4 → 0.14.6
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/dist/base-command.d.ts +3 -0
- package/dist/base-command.d.ts.map +1 -1
- package/dist/base-command.js +18 -4
- package/dist/base-command.js.map +1 -1
- package/dist/commands/android/connect.d.ts +1 -0
- package/dist/commands/android/connect.d.ts.map +1 -1
- package/dist/commands/android/create.d.ts +1 -0
- package/dist/commands/android/create.d.ts.map +1 -1
- package/dist/commands/android/delete.d.ts +1 -0
- package/dist/commands/android/delete.d.ts.map +1 -1
- package/dist/commands/android/element-tree.d.ts +1 -0
- package/dist/commands/android/element-tree.d.ts.map +1 -1
- package/dist/commands/android/find-element.d.ts +1 -0
- package/dist/commands/android/find-element.d.ts.map +1 -1
- package/dist/commands/android/get.d.ts +1 -0
- package/dist/commands/android/get.d.ts.map +1 -1
- package/dist/commands/android/install-app.d.ts +1 -0
- package/dist/commands/android/install-app.d.ts.map +1 -1
- package/dist/commands/android/list.d.ts +1 -0
- package/dist/commands/android/list.d.ts.map +1 -1
- package/dist/commands/android/open-url.d.ts +1 -0
- package/dist/commands/android/open-url.d.ts.map +1 -1
- package/dist/commands/android/press-key.d.ts +1 -0
- package/dist/commands/android/press-key.d.ts.map +1 -1
- package/dist/commands/android/record.d.ts +1 -0
- package/dist/commands/android/record.d.ts.map +1 -1
- package/dist/commands/android/screenshot.d.ts +1 -0
- package/dist/commands/android/screenshot.d.ts.map +1 -1
- package/dist/commands/android/scroll.d.ts +1 -0
- package/dist/commands/android/scroll.d.ts.map +1 -1
- package/dist/commands/android/set-wifi-bandwidth.d.ts +1 -0
- package/dist/commands/android/set-wifi-bandwidth.d.ts.map +1 -1
- package/dist/commands/android/tap-element.d.ts +1 -0
- package/dist/commands/android/tap-element.d.ts.map +1 -1
- package/dist/commands/android/tap.d.ts +1 -0
- package/dist/commands/android/tap.d.ts.map +1 -1
- package/dist/commands/android/type.d.ts +1 -0
- package/dist/commands/android/type.d.ts.map +1 -1
- package/dist/commands/asset/delete.d.ts +1 -0
- package/dist/commands/asset/delete.d.ts.map +1 -1
- package/dist/commands/asset/list.d.ts +1 -0
- package/dist/commands/asset/list.d.ts.map +1 -1
- package/dist/commands/asset/pull.d.ts +1 -0
- package/dist/commands/asset/pull.d.ts.map +1 -1
- package/dist/commands/asset/push.d.ts +1 -0
- package/dist/commands/asset/push.d.ts.map +1 -1
- package/dist/commands/ios/app-log.d.ts +1 -0
- package/dist/commands/ios/app-log.d.ts.map +1 -1
- package/dist/commands/ios/cp.d.ts +1 -0
- package/dist/commands/ios/cp.d.ts.map +1 -1
- package/dist/commands/ios/create.d.ts +1 -0
- package/dist/commands/ios/create.d.ts.map +1 -1
- package/dist/commands/ios/delete.d.ts +1 -0
- package/dist/commands/ios/delete.d.ts.map +1 -1
- package/dist/commands/ios/element-tree.d.ts +1 -0
- package/dist/commands/ios/element-tree.d.ts.map +1 -1
- package/dist/commands/ios/get.d.ts +1 -0
- package/dist/commands/ios/get.d.ts.map +1 -1
- package/dist/commands/ios/info.d.ts +1 -0
- package/dist/commands/ios/info.d.ts.map +1 -1
- package/dist/commands/ios/install-app.d.ts +1 -0
- package/dist/commands/ios/install-app.d.ts.map +1 -1
- package/dist/commands/ios/launch-app.d.ts +1 -0
- package/dist/commands/ios/launch-app.d.ts.map +1 -1
- package/dist/commands/ios/list-apps.d.ts +1 -0
- package/dist/commands/ios/list-apps.d.ts.map +1 -1
- package/dist/commands/ios/list.d.ts +1 -0
- package/dist/commands/ios/list.d.ts.map +1 -1
- package/dist/commands/ios/lsof.d.ts +1 -0
- package/dist/commands/ios/lsof.d.ts.map +1 -1
- package/dist/commands/ios/open-url.d.ts +1 -0
- package/dist/commands/ios/open-url.d.ts.map +1 -1
- package/dist/commands/ios/perform.d.ts +1 -0
- package/dist/commands/ios/perform.d.ts.map +1 -1
- package/dist/commands/ios/press-key.d.ts +1 -0
- package/dist/commands/ios/press-key.d.ts.map +1 -1
- package/dist/commands/ios/record.d.ts +1 -0
- package/dist/commands/ios/record.d.ts.map +1 -1
- package/dist/commands/ios/reverse.d.ts +1 -0
- package/dist/commands/ios/reverse.d.ts.map +1 -1
- package/dist/commands/ios/screenshot.d.ts +1 -0
- package/dist/commands/ios/screenshot.d.ts.map +1 -1
- package/dist/commands/ios/scroll.d.ts +1 -0
- package/dist/commands/ios/scroll.d.ts.map +1 -1
- package/dist/commands/ios/simctl.d.ts +1 -0
- package/dist/commands/ios/simctl.d.ts.map +1 -1
- package/dist/commands/ios/sync.d.ts +1 -0
- package/dist/commands/ios/sync.d.ts.map +1 -1
- package/dist/commands/ios/syslog.d.ts +1 -0
- package/dist/commands/ios/syslog.d.ts.map +1 -1
- package/dist/commands/ios/tap-element.d.ts +1 -0
- package/dist/commands/ios/tap-element.d.ts.map +1 -1
- package/dist/commands/ios/tap.d.ts +1 -0
- package/dist/commands/ios/tap.d.ts.map +1 -1
- package/dist/commands/ios/terminate-app.d.ts +1 -0
- package/dist/commands/ios/terminate-app.d.ts.map +1 -1
- package/dist/commands/ios/toggle-keyboard.d.ts +1 -0
- package/dist/commands/ios/toggle-keyboard.d.ts.map +1 -1
- package/dist/commands/ios/type.d.ts +1 -0
- package/dist/commands/ios/type.d.ts.map +1 -1
- package/dist/commands/ios/xcodebuild.d.ts +1 -0
- package/dist/commands/ios/xcodebuild.d.ts.map +1 -1
- package/dist/commands/ios/xcrun.d.ts +1 -0
- package/dist/commands/ios/xcrun.d.ts.map +1 -1
- package/dist/commands/login.d.ts +1 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/logout.d.ts +1 -0
- package/dist/commands/logout.d.ts.map +1 -1
- package/dist/commands/session/start.d.ts +1 -0
- package/dist/commands/session/start.d.ts.map +1 -1
- package/dist/commands/session/status.d.ts +1 -0
- package/dist/commands/session/status.d.ts.map +1 -1
- package/dist/commands/session/stop.d.ts +1 -0
- package/dist/commands/session/stop.d.ts.map +1 -1
- package/dist/commands/set-workspace-dir.d.ts +15 -0
- package/dist/commands/set-workspace-dir.d.ts.map +1 -0
- package/dist/commands/set-workspace-dir.js +60 -0
- package/dist/commands/set-workspace-dir.js.map +1 -0
- package/dist/commands/xcode/attach-simulator.d.ts +1 -0
- package/dist/commands/xcode/attach-simulator.d.ts.map +1 -1
- package/dist/commands/xcode/create.d.ts +1 -0
- package/dist/commands/xcode/create.d.ts.map +1 -1
- package/dist/commands/xcode/delete.d.ts +1 -0
- package/dist/commands/xcode/delete.d.ts.map +1 -1
- package/dist/commands/xcode/get.d.ts +1 -0
- package/dist/commands/xcode/get.d.ts.map +1 -1
- package/dist/commands/xcode/list.d.ts +1 -0
- package/dist/commands/xcode/list.d.ts.map +1 -1
- package/dist/commands/xcode/rbe/install.d.ts +2 -0
- package/dist/commands/xcode/rbe/install.d.ts.map +1 -1
- package/dist/commands/xcode/rbe/install.js +14 -4
- package/dist/commands/xcode/rbe/install.js.map +1 -1
- package/dist/commands/xcode/rbe.d.ts +5 -0
- package/dist/commands/xcode/rbe.d.ts.map +1 -1
- package/dist/commands/xcode/rbe.js +122 -13
- package/dist/commands/xcode/rbe.js.map +1 -1
- package/dist/commands/xcode/sync.d.ts +1 -0
- package/dist/commands/xcode/sync.d.ts.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +324 -105
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/rbe-bep-watcher.d.ts +41 -0
- package/dist/lib/rbe-bep-watcher.d.ts.map +1 -0
- package/dist/lib/rbe-bep-watcher.js +267 -0
- package/dist/lib/rbe-bep-watcher.js.map +1 -0
- package/dist/lib/rbe-session.d.ts +13 -0
- package/dist/lib/rbe-session.d.ts.map +1 -1
- package/dist/lib/rbe-session.js +15 -0
- package/dist/lib/rbe-session.js.map +1 -1
- package/dist/lib/rbe-workspace.d.ts +14 -1
- package/dist/lib/rbe-workspace.d.ts.map +1 -1
- package/dist/lib/rbe-workspace.js +25 -5
- package/dist/lib/rbe-workspace.js.map +1 -1
- package/dist/lib/scope.d.ts +38 -0
- package/dist/lib/scope.d.ts.map +1 -0
- package/dist/lib/scope.js +125 -0
- package/dist/lib/scope.js.map +1 -0
- package/dist/lib/workspace.d.ts +25 -0
- package/dist/lib/workspace.d.ts.map +1 -0
- package/dist/lib/workspace.js +111 -0
- package/dist/lib/workspace.js.map +1 -0
- package/package.json +4 -3
|
@@ -0,0 +1,125 @@
|
|
|
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.GLOBAL_SCOPE_KEY = void 0;
|
|
7
|
+
exports.isGlobalScopeKey = isGlobalScopeKey;
|
|
8
|
+
exports.setScopeOverride = setScopeOverride;
|
|
9
|
+
exports.getScopeKey = getScopeKey;
|
|
10
|
+
exports.resetScopeCacheForTests = resetScopeCacheForTests;
|
|
11
|
+
const fs_1 = __importDefault(require("fs"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const workspace_1 = require("./workspace");
|
|
15
|
+
/**
|
|
16
|
+
* A "scope" (surfaced to users as a "workspace") isolates the most-recently-used
|
|
17
|
+
* instance per directory so that separate git worktrees / clones (and the
|
|
18
|
+
* parallel AI agents working in them) each get their own last-instance binding
|
|
19
|
+
* instead of all sharing one slot.
|
|
20
|
+
*
|
|
21
|
+
* Resolution order (first match wins), memoized for the lifetime of the process:
|
|
22
|
+
* 1. an explicit in-process override set from the global `--workspace` flag,
|
|
23
|
+
* 2. the LIM_WORKSPACE environment variable,
|
|
24
|
+
* 3. the most specific of: a `lim set-workspace-dir` assignment (cwd or an
|
|
25
|
+
* ancestor) and the current git repo/worktree root,
|
|
26
|
+
* 4. GLOBAL_SCOPE_KEY when neither applies.
|
|
27
|
+
*
|
|
28
|
+
* These require zero setup. Any command run inside a git repo (a clone or a
|
|
29
|
+
* linked worktree) resolves to that root and is isolated from every other
|
|
30
|
+
* checkout. A `set-workspace-dir` assignment governs its directory and
|
|
31
|
+
* everything beneath it, EXCEPT a nested git worktree/clone whose root is deeper
|
|
32
|
+
* than the assignment keeps its own isolation (most-specific boundary wins).
|
|
33
|
+
* Anything else shares a single global slot, preserving the convenient "use my
|
|
34
|
+
* most recent instance anywhere" behavior for casual, non-repo usage.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Shared scope used for invocations that are not inside any git repo. It is a
|
|
38
|
+
* non-path sentinel so it can never collide with a real directory scope key.
|
|
39
|
+
*/
|
|
40
|
+
exports.GLOBAL_SCOPE_KEY = '__lim_global__';
|
|
41
|
+
/** Whether a resolved scope key is the shared non-repo global slot. */
|
|
42
|
+
function isGlobalScopeKey(key) {
|
|
43
|
+
return key === exports.GLOBAL_SCOPE_KEY;
|
|
44
|
+
}
|
|
45
|
+
let override;
|
|
46
|
+
let cachedDefault;
|
|
47
|
+
/**
|
|
48
|
+
* Override the scope key for this process (used by the global `--workspace` flag).
|
|
49
|
+
* Passing an empty/undefined value clears the override.
|
|
50
|
+
*/
|
|
51
|
+
function setScopeOverride(key) {
|
|
52
|
+
const trimmed = key?.trim();
|
|
53
|
+
override = trimmed ? normalizeScopeKey(trimmed, true) : undefined;
|
|
54
|
+
}
|
|
55
|
+
/** Resolve the active scope key. Memoizes only the assignment/git/global fallback. */
|
|
56
|
+
function getScopeKey() {
|
|
57
|
+
if (override)
|
|
58
|
+
return override;
|
|
59
|
+
const env = process.env['LIM_WORKSPACE']?.trim();
|
|
60
|
+
if (env)
|
|
61
|
+
return normalizeScopeKey(env, true);
|
|
62
|
+
if (cachedDefault === undefined) {
|
|
63
|
+
cachedDefault = computeDefaultScopeKey();
|
|
64
|
+
}
|
|
65
|
+
return cachedDefault;
|
|
66
|
+
}
|
|
67
|
+
/** Reset memoized state. Intended for tests only. */
|
|
68
|
+
function resetScopeCacheForTests() {
|
|
69
|
+
override = undefined;
|
|
70
|
+
cachedDefault = undefined;
|
|
71
|
+
}
|
|
72
|
+
function computeDefaultScopeKey() {
|
|
73
|
+
const cwd = process.cwd();
|
|
74
|
+
const match = (0, workspace_1.lookupWorkspaceMatch)(cwd);
|
|
75
|
+
const top = gitWorktreeRoot();
|
|
76
|
+
const gitRoot = top ? normalizeScopeKey(top, false) : undefined;
|
|
77
|
+
if (match && gitRoot) {
|
|
78
|
+
// Both boundaries cover the cwd. The more specific (deeper) one wins, so a
|
|
79
|
+
// nested git worktree/clone keeps its own isolation even under a broad
|
|
80
|
+
// parent assignment, while an assignment at or below the git root still
|
|
81
|
+
// overrides git auto-detection.
|
|
82
|
+
return isStrictDescendant(gitRoot, match.dir) ? gitRoot : match.name;
|
|
83
|
+
}
|
|
84
|
+
if (match)
|
|
85
|
+
return match.name;
|
|
86
|
+
if (gitRoot)
|
|
87
|
+
return gitRoot;
|
|
88
|
+
// Outside any repo and with no assignment, share the global slot.
|
|
89
|
+
return exports.GLOBAL_SCOPE_KEY;
|
|
90
|
+
}
|
|
91
|
+
/** Whether `child` is a strict subdirectory of `parent` (both normalized absolute paths). */
|
|
92
|
+
function isStrictDescendant(child, parent) {
|
|
93
|
+
if (child === parent)
|
|
94
|
+
return false;
|
|
95
|
+
const base = parent.endsWith(path_1.default.sep) ? parent : parent + path_1.default.sep;
|
|
96
|
+
return child.startsWith(base);
|
|
97
|
+
}
|
|
98
|
+
function gitWorktreeRoot() {
|
|
99
|
+
try {
|
|
100
|
+
const out = (0, child_process_1.execFileSync)('git', ['rev-parse', '--show-toplevel'], {
|
|
101
|
+
cwd: process.cwd(),
|
|
102
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
103
|
+
encoding: 'utf-8',
|
|
104
|
+
}).trim();
|
|
105
|
+
return out || undefined;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Normalize a scope key. Real filesystem paths are canonicalized through
|
|
113
|
+
* `realpath` so symlinks and sibling worktrees resolve to stable, distinct
|
|
114
|
+
* keys. Explicit overrides that are not real paths (e.g. an arbitrary label)
|
|
115
|
+
* are kept verbatim so they stay stable regardless of the working directory.
|
|
116
|
+
*/
|
|
117
|
+
function normalizeScopeKey(input, allowLiteral) {
|
|
118
|
+
try {
|
|
119
|
+
return fs_1.default.realpathSync.native(input);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return allowLiteral ? input : path_1.default.resolve(input);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../src/lib/scope.ts"],"names":[],"mappings":";;;;;;AAkCA,4CAEC;AASD,4CAGC;AAGD,kCAUC;AAGD,0DAGC;AAnED,4CAAoB;AACpB,gDAAwB;AACxB,iDAA6C;AAC7C,2CAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;GAGG;AACU,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD,uEAAuE;AACvE,SAAgB,gBAAgB,CAAC,GAAW;IAC1C,OAAO,GAAG,KAAK,wBAAgB,CAAC;AAClC,CAAC;AAED,IAAI,QAA4B,CAAC;AACjC,IAAI,aAAiC,CAAC;AAEtC;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,GAAuB;IACtD,MAAM,OAAO,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC;IAC5B,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC;AAED,sFAAsF;AACtF,SAAgB,WAAW;IACzB,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAE9B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,IAAI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AAC,CAAC,CAAC,MAAM,GAAG,cAAI,CAAC,GAAG,CAAC;IACpE,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,eAAe;IACtB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAA,4BAAY,EAAC,KAAK,EAAE,CAAC,WAAW,EAAE,iBAAiB,CAAC,EAAE;YAChE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;YAClB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;YACnC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,GAAG,IAAI,SAAS,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,KAAa,EAAE,YAAqB;IAC7D,IAAI,CAAC;QACH,OAAO,YAAE,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Canonicalize a directory path (realpath when it exists, else resolve). */
|
|
2
|
+
export declare function normalizeDir(dir: string): string;
|
|
3
|
+
/** Bind a directory to a workspace name. */
|
|
4
|
+
export declare function assignWorkspaceDir(dir: string, name: string): void;
|
|
5
|
+
/** Remove a directory's workspace binding. Returns whether anything was removed. */
|
|
6
|
+
export declare function unassignWorkspaceDir(dir: string): boolean;
|
|
7
|
+
/** A directory's nearest workspace assignment: the directory that holds it and the name. */
|
|
8
|
+
export interface WorkspaceMatch {
|
|
9
|
+
/** Normalized directory the assignment is attached to (cwd or an ancestor). */
|
|
10
|
+
dir: string;
|
|
11
|
+
/** Assigned workspace name. */
|
|
12
|
+
name: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the nearest workspace assignment for `dir`, walking up parent
|
|
16
|
+
* directories so a subdirectory inherits its closest ancestor's assignment
|
|
17
|
+
* (mirroring how a git worktree root applies to everything beneath it). Returns
|
|
18
|
+
* both the matched directory and name so callers can reason about specificity.
|
|
19
|
+
*/
|
|
20
|
+
export declare function lookupWorkspaceMatch(dir: string): WorkspaceMatch | undefined;
|
|
21
|
+
/** Convenience wrapper returning only the workspace name. */
|
|
22
|
+
export declare function lookupWorkspaceForDir(dir: string): string | undefined;
|
|
23
|
+
/** All directory -> workspace assignments. */
|
|
24
|
+
export declare function listWorkspaceDirs(): Record<string, string>;
|
|
25
|
+
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/lib/workspace.ts"],"names":[],"mappings":"AAsDA,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED,4CAA4C;AAC5C,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAIlE;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAOzD;AAED,4FAA4F;AAC5F,MAAM,WAAW,cAAc;IAC7B,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAW5E;AAED,6DAA6D;AAC7D,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErE;AAED,8CAA8C;AAC9C,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE1D"}
|
|
@@ -0,0 +1,111 @@
|
|
|
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.normalizeDir = normalizeDir;
|
|
7
|
+
exports.assignWorkspaceDir = assignWorkspaceDir;
|
|
8
|
+
exports.unassignWorkspaceDir = unassignWorkspaceDir;
|
|
9
|
+
exports.lookupWorkspaceMatch = lookupWorkspaceMatch;
|
|
10
|
+
exports.lookupWorkspaceForDir = lookupWorkspaceForDir;
|
|
11
|
+
exports.listWorkspaceDirs = listWorkspaceDirs;
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const os_1 = __importDefault(require("os"));
|
|
15
|
+
/**
|
|
16
|
+
* Persistent "directory -> workspace name" assignments created by
|
|
17
|
+
* `lim set-workspace-dir`. This lets a plain directory (one that is not a git
|
|
18
|
+
* repo or worktree) opt into an isolated workspace, or lets several directories
|
|
19
|
+
* deliberately share one workspace by assigning them the same name.
|
|
20
|
+
*
|
|
21
|
+
* Kept in its own module (no dependency on config.ts) so scope.ts can consult it
|
|
22
|
+
* during scope resolution without creating an import cycle.
|
|
23
|
+
*/
|
|
24
|
+
const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.lim');
|
|
25
|
+
const WORKSPACE_DIRS_FILE = path_1.default.join(CONFIG_DIR, 'workspace-dirs.json');
|
|
26
|
+
const SCHEMA_VERSION = 1;
|
|
27
|
+
function ensureConfigDir() {
|
|
28
|
+
if (!fs_1.default.existsSync(CONFIG_DIR)) {
|
|
29
|
+
fs_1.default.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function readFileRaw() {
|
|
33
|
+
if (!fs_1.default.existsSync(WORKSPACE_DIRS_FILE))
|
|
34
|
+
return { version: SCHEMA_VERSION, dirs: {} };
|
|
35
|
+
try {
|
|
36
|
+
const parsed = JSON.parse(fs_1.default.readFileSync(WORKSPACE_DIRS_FILE, 'utf-8'));
|
|
37
|
+
if (parsed && typeof parsed === 'object' && parsed.dirs && typeof parsed.dirs === 'object') {
|
|
38
|
+
const dirs = {};
|
|
39
|
+
for (const [key, value] of Object.entries(parsed.dirs)) {
|
|
40
|
+
if (typeof value === 'string')
|
|
41
|
+
dirs[key] = value;
|
|
42
|
+
}
|
|
43
|
+
return { version: SCHEMA_VERSION, dirs };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Corrupt file; treat as empty.
|
|
48
|
+
}
|
|
49
|
+
return { version: SCHEMA_VERSION, dirs: {} };
|
|
50
|
+
}
|
|
51
|
+
function writeFileAtomic(file) {
|
|
52
|
+
ensureConfigDir();
|
|
53
|
+
const tmp = `${WORKSPACE_DIRS_FILE}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
54
|
+
fs_1.default.writeFileSync(tmp, JSON.stringify(file, null, 2), { mode: 0o600 });
|
|
55
|
+
fs_1.default.renameSync(tmp, WORKSPACE_DIRS_FILE);
|
|
56
|
+
}
|
|
57
|
+
/** Canonicalize a directory path (realpath when it exists, else resolve). */
|
|
58
|
+
function normalizeDir(dir) {
|
|
59
|
+
try {
|
|
60
|
+
return fs_1.default.realpathSync.native(dir);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return path_1.default.resolve(dir);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Bind a directory to a workspace name. */
|
|
67
|
+
function assignWorkspaceDir(dir, name) {
|
|
68
|
+
const file = readFileRaw();
|
|
69
|
+
file.dirs[normalizeDir(dir)] = name;
|
|
70
|
+
writeFileAtomic(file);
|
|
71
|
+
}
|
|
72
|
+
/** Remove a directory's workspace binding. Returns whether anything was removed. */
|
|
73
|
+
function unassignWorkspaceDir(dir) {
|
|
74
|
+
const file = readFileRaw();
|
|
75
|
+
const key = normalizeDir(dir);
|
|
76
|
+
if (!(key in file.dirs))
|
|
77
|
+
return false;
|
|
78
|
+
delete file.dirs[key];
|
|
79
|
+
writeFileAtomic(file);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolve the nearest workspace assignment for `dir`, walking up parent
|
|
84
|
+
* directories so a subdirectory inherits its closest ancestor's assignment
|
|
85
|
+
* (mirroring how a git worktree root applies to everything beneath it). Returns
|
|
86
|
+
* both the matched directory and name so callers can reason about specificity.
|
|
87
|
+
*/
|
|
88
|
+
function lookupWorkspaceMatch(dir) {
|
|
89
|
+
const file = readFileRaw();
|
|
90
|
+
if (Object.keys(file.dirs).length === 0)
|
|
91
|
+
return undefined;
|
|
92
|
+
let current = normalizeDir(dir);
|
|
93
|
+
for (;;) {
|
|
94
|
+
const name = file.dirs[current];
|
|
95
|
+
if (name)
|
|
96
|
+
return { dir: current, name };
|
|
97
|
+
const parent = path_1.default.dirname(current);
|
|
98
|
+
if (parent === current)
|
|
99
|
+
return undefined;
|
|
100
|
+
current = parent;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/** Convenience wrapper returning only the workspace name. */
|
|
104
|
+
function lookupWorkspaceForDir(dir) {
|
|
105
|
+
return lookupWorkspaceMatch(dir)?.name;
|
|
106
|
+
}
|
|
107
|
+
/** All directory -> workspace assignments. */
|
|
108
|
+
function listWorkspaceDirs() {
|
|
109
|
+
return readFileRaw().dirs;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/lib/workspace.ts"],"names":[],"mappings":";;;;;AAuDA,oCAMC;AAGD,gDAIC;AAGD,oDAOC;AA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C;IAC9B,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACtC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,eAAe,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,IAAI,CAAC;AACd,CAAC;AAUD;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,GAAW;IAC9C,MAAM,IAAI,GAAG,WAAW,EAAE,CAAC;IAC3B,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1D,IAAI,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAChC,SAAS,CAAC;QACR,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,IAAI;YAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,OAAO;YAAE,OAAO,SAAS,CAAC;QACzC,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;AACH,CAAC;AAED,6DAA6D;AAC7D,SAAgB,qBAAqB,CAAC,GAAW;IAC/C,OAAO,oBAAoB,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;AACzC,CAAC;AAED,8CAA8C;AAC9C,SAAgB,iBAAiB;IAC/B,OAAO,WAAW,EAAE,CAAC,IAAI,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lim",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.6",
|
|
4
4
|
"description": "Use remote XCode, iOS Simulator, Android Emulator and more to build and test apps from Linux, Windows or macOS.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lim": "./bin/run.js"
|
|
@@ -17,14 +17,15 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"scripts": {
|
|
20
|
+
"prebuild": "yarn --cwd ../.. build",
|
|
20
21
|
"build": "rm -rf dist && tsc",
|
|
21
22
|
"dev": "node bin/dev.js",
|
|
22
|
-
"prepublishOnly": "npm run build",
|
|
23
|
+
"prepublishOnly": "tsc --noEmit -p tsconfig.publish.json && npm run build",
|
|
23
24
|
"lint": "eslint src/",
|
|
24
25
|
"test": "jest"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@limrun/api": "^0.31.
|
|
28
|
+
"@limrun/api": "^0.31.4",
|
|
28
29
|
"@oclif/core": "^4",
|
|
29
30
|
"cli-progress": "^3.12.0",
|
|
30
31
|
"cli-table3": "^0.6.5",
|