@limrun/api 0.22.2 → 0.23.1

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/exec-client.d.mts +5 -1
  3. package/exec-client.d.mts.map +1 -1
  4. package/exec-client.d.ts +5 -1
  5. package/exec-client.d.ts.map +1 -1
  6. package/exec-client.js +14 -7
  7. package/exec-client.js.map +1 -1
  8. package/exec-client.mjs +14 -7
  9. package/exec-client.mjs.map +1 -1
  10. package/folder-sync-ignore.d.mts +7 -0
  11. package/folder-sync-ignore.d.mts.map +1 -0
  12. package/folder-sync-ignore.d.ts +7 -0
  13. package/folder-sync-ignore.d.ts.map +1 -0
  14. package/folder-sync-ignore.js +56 -0
  15. package/folder-sync-ignore.js.map +1 -0
  16. package/folder-sync-ignore.mjs +52 -0
  17. package/folder-sync-ignore.mjs.map +1 -0
  18. package/folder-sync-watcher.d.mts +2 -0
  19. package/folder-sync-watcher.d.mts.map +1 -1
  20. package/folder-sync-watcher.d.ts +2 -0
  21. package/folder-sync-watcher.d.ts.map +1 -1
  22. package/folder-sync-watcher.js +10 -62
  23. package/folder-sync-watcher.js.map +1 -1
  24. package/folder-sync-watcher.mjs +10 -62
  25. package/folder-sync-watcher.mjs.map +1 -1
  26. package/folder-sync.d.mts +16 -16
  27. package/folder-sync.d.mts.map +1 -1
  28. package/folder-sync.d.ts +16 -16
  29. package/folder-sync.d.ts.map +1 -1
  30. package/folder-sync.js +22 -65
  31. package/folder-sync.js.map +1 -1
  32. package/folder-sync.mjs +21 -64
  33. package/folder-sync.mjs.map +1 -1
  34. package/ios-client.d.mts +24 -0
  35. package/ios-client.d.mts.map +1 -1
  36. package/ios-client.d.ts +24 -0
  37. package/ios-client.d.ts.map +1 -1
  38. package/ios-client.js +108 -8
  39. package/ios-client.js.map +1 -1
  40. package/ios-client.mjs +109 -9
  41. package/ios-client.mjs.map +1 -1
  42. package/package.json +11 -1
  43. package/sandbox-client.d.mts +20 -15
  44. package/sandbox-client.d.mts.map +1 -1
  45. package/sandbox-client.d.ts +20 -15
  46. package/sandbox-client.d.ts.map +1 -1
  47. package/sandbox-client.js +49 -40
  48. package/sandbox-client.js.map +1 -1
  49. package/sandbox-client.mjs +48 -40
  50. package/sandbox-client.mjs.map +1 -1
  51. package/src/exec-client.ts +14 -7
  52. package/src/folder-sync-ignore.ts +65 -0
  53. package/src/folder-sync-watcher.ts +11 -66
  54. package/src/folder-sync.ts +39 -89
  55. package/src/ios-client.ts +138 -9
  56. package/src/sandbox-client.ts +72 -62
  57. package/src/version.ts +1 -1
  58. package/version.d.mts +1 -1
  59. package/version.d.ts +1 -1
  60. package/version.js +1 -1
  61. package/version.mjs +1 -1
@@ -1,5 +1,9 @@
1
- import { syncApp as syncFolderImpl, type FolderSyncOptions } from './folder-sync';
1
+ import os from 'os';
2
+ import path from 'path';
3
+ import { syncFolder as syncFolderImpl, type FolderSyncOptions } from './folder-sync';
2
4
  import { exec, ExecChildProcess } from './exec-client';
5
+ import { createIgnoreFn } from './folder-sync-ignore';
6
+ import crypto from 'crypto';
3
7
 
4
8
  export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
5
9
 
@@ -27,32 +31,37 @@ export type SimulatorConfig = {
27
31
  */
28
32
  export type SyncOptions = {
29
33
  /**
30
- * Cache scoping key for delta basis caching. Defaults to 'xcode-sandbox'.
31
- * This is not sent to the server.
34
+ * If true, watch the folder and re-sync on any changes. Defaults to true.
32
35
  */
33
- cacheKey?: string;
34
- basisCacheDir?: string;
35
- maxPatchBytes?: number;
36
+ watch?: boolean;
36
37
  /**
37
- * If true, watch the folder and re-sync on any changes.
38
+ * Directory for the client-side folder-sync cache.
39
+ * Used to store the last-synced “basis” copies of files (and related sync metadata) so we can compute xdelta patches
40
+ * on subsequent syncs without re-downloading server state.
41
+ *
42
+ * Defaults to a temporary directory under the OS temp directory.
38
43
  */
39
- watch?: boolean;
40
- log?: (level: 'debug' | 'info' | 'warn' | 'error', msg: string) => void;
44
+ basisCacheDir?: string;
45
+ /** Max patch size (bytes) to send as delta before falling back to full upload. */
46
+ maxPatchBytes?: number;
47
+ /** If true, install the app after syncing. Defaults to true. */
48
+ install?: boolean;
41
49
  /**
42
- * Optional filter function to include/exclude files and directories.
50
+ * Optional predicate for ignoring files and directories during sync.
51
+ * Applied in addition to built-in sync and Xcode-specific ignore rules.
43
52
  * Called with the relative path from the sync root (using forward slashes).
44
53
  * For directories, the path ends with '/'.
45
- * Return true to include, false to exclude.
54
+ * Return true to ignore, false to keep.
46
55
  *
47
56
  * @example
48
- * // Exclude build folder
49
- * filter: (path) => !path.startsWith('build/')
57
+ * // Ignore build folder
58
+ * ignore: (path) => path.startsWith('build/')
50
59
  *
51
60
  * @example
52
- * // Only include source files
53
- * filter: (path) => path.startsWith('src/') || path.endsWith('.json')
61
+ * // Ignore anything outside src/ and JSON files
62
+ * ignore: (path) => !(path.startsWith('src/') || path.endsWith('.json'))
54
63
  */
55
- filter?: (relativePath: string) => boolean;
64
+ ignore?: (relativePath: string) => boolean;
56
65
  };
57
66
 
58
67
  /**
@@ -150,7 +159,7 @@ export async function createXCodeSandboxClient(
150
159
  },
151
160
  };
152
161
 
153
- const logFn = (level: 'debug' | 'info' | 'warn' | 'error', msg: string) => {
162
+ const log = (level: 'debug' | 'info' | 'warn' | 'error', msg: string) => {
154
163
  switch (level) {
155
164
  case 'debug':
156
165
  logger.debug(msg);
@@ -196,54 +205,55 @@ export async function createXCodeSandboxClient(
196
205
 
197
206
  return {
198
207
  async sync(localCodePath: string, opts?: SyncOptions): Promise<SyncResult> {
208
+ // Use folder name and hash of absolute path to scope basisCacheDir uniquely for each sync root
209
+ const resolvedPath = path.resolve(localCodePath);
210
+ const folderName = path.basename(resolvedPath);
211
+ const hash = crypto.createHash('sha1').update(resolvedPath).digest('hex').slice(0, 8);
212
+ const cacheKey = `limsync-cache-${folderName}-${hash}`;
213
+ const basisCacheDir = opts?.basisCacheDir ?? path.join(os.tmpdir(), cacheKey);
199
214
  const codeSyncOpts: FolderSyncOptions = {
200
215
  apiUrl: options.apiUrl,
201
216
  token: options.token,
202
- udid: opts?.cacheKey ?? 'xcode-sandbox',
203
- install: false,
204
- filter: (relativePath: string) => {
205
- if (
206
- relativePath.startsWith('build/') ||
207
- relativePath.startsWith('.build/') ||
208
- relativePath.startsWith('DerivedData/') ||
209
- relativePath.startsWith('Index.noindex/') ||
210
- relativePath.startsWith('ModuleCache.noindex/') ||
211
- relativePath.startsWith('.index-build/')
212
- ) {
217
+ udid: cacheKey,
218
+ install: opts?.install ?? true,
219
+ ignoreFn: await createIgnoreFn(localCodePath, {
220
+ basisCacheDir,
221
+ additional: (relativePath: string) => {
222
+ if (
223
+ relativePath.startsWith('build/') ||
224
+ relativePath.startsWith('.build/') ||
225
+ relativePath.startsWith('DerivedData/') ||
226
+ relativePath.startsWith('Index.noindex/') ||
227
+ relativePath.startsWith('ModuleCache.noindex/') ||
228
+ relativePath.startsWith('.index-build/')
229
+ ) {
230
+ return true;
231
+ }
232
+ if (
233
+ relativePath.startsWith('.swiftpm/') ||
234
+ relativePath.startsWith('Pods/') ||
235
+ relativePath.startsWith('Carthage/Build/')
236
+ ) {
237
+ return true;
238
+ }
239
+ if (relativePath.includes('/xcuserdata/')) {
240
+ return true;
241
+ }
242
+ if (relativePath.includes('.dSYM/')) {
243
+ return true;
244
+ }
245
+ // User-provided ignores
246
+ if (opts?.ignore?.(relativePath)) {
247
+ return true;
248
+ }
213
249
  return false;
214
- }
215
- if (
216
- relativePath.startsWith('.swiftpm/') ||
217
- relativePath.startsWith('Pods/') ||
218
- relativePath.startsWith('Carthage/Build/')
219
- ) {
220
- return false;
221
- }
222
- if (
223
- relativePath.startsWith('.git/') ||
224
- relativePath.startsWith('.limsync-cache/') ||
225
- relativePath === '.DS_Store' ||
226
- relativePath.endsWith('/.DS_Store')
227
- ) {
228
- return false;
229
- }
230
- if (relativePath.includes('/xcuserdata/')) {
231
- return false;
232
- }
233
- if (relativePath.includes('.dSYM/')) {
234
- return false;
235
- }
236
-
237
- // User-provided filter
238
- if (opts?.filter && !opts.filter(relativePath)) {
239
- return false;
240
- }
241
- return true;
242
- },
243
- ...(opts?.basisCacheDir ? { basisCacheDir: opts.basisCacheDir } : {}),
244
- ...(opts?.maxPatchBytes !== undefined ? { maxPatchBytes: opts.maxPatchBytes } : {}),
245
- ...(opts?.watch !== undefined ? { watch: opts.watch } : {}),
246
- log: opts?.log ?? logFn,
250
+ },
251
+ }),
252
+ basisCacheDir,
253
+ watch: opts?.watch ?? true,
254
+ maxPatchBytes: opts?.maxPatchBytes ?? 4 * 1024 * 1024,
255
+ launchMode: 'ForegroundIfRunning',
256
+ log,
247
257
  };
248
258
 
249
259
  const result = await syncFolderImpl(localCodePath, codeSyncOpts);
@@ -259,7 +269,7 @@ export async function createXCodeSandboxClient(
259
269
  {
260
270
  apiUrl: options.apiUrl,
261
271
  token: options.token,
262
- log: logFn,
272
+ log,
263
273
  },
264
274
  );
265
275
  },
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.22.2'; // x-release-please-version
1
+ export const VERSION = '0.23.1'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.22.2";
1
+ export declare const VERSION = "0.23.1";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.22.2";
1
+ export declare const VERSION = "0.23.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.22.2'; // x-release-please-version
4
+ exports.VERSION = '0.23.1'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.22.2'; // x-release-please-version
1
+ export const VERSION = '0.23.1'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map