farseer-cli 1.9.1 → 1.10.0

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 (71) hide show
  1. package/README.md +37 -33
  2. package/dist/commands/app.js +9 -35
  3. package/dist/commands/app.js.map +2 -2
  4. package/dist/commands/apps.js +3 -9
  5. package/dist/commands/apps.js.map +2 -2
  6. package/dist/commands/cells.js +3 -11
  7. package/dist/commands/cells.js.map +2 -2
  8. package/dist/commands/config.js +4 -4
  9. package/dist/commands/config.js.map +2 -2
  10. package/dist/commands/dashboards.js +3 -11
  11. package/dist/commands/dashboards.js.map +2 -2
  12. package/dist/commands/diff.js +3 -7
  13. package/dist/commands/diff.js.map +2 -2
  14. package/dist/commands/dimensions.js +9 -31
  15. package/dist/commands/dimensions.js.map +2 -2
  16. package/dist/commands/files.js +4 -9
  17. package/dist/commands/files.js.map +2 -2
  18. package/dist/commands/formula.js +2 -6
  19. package/dist/commands/formula.js.map +2 -2
  20. package/dist/commands/list.js +4 -9
  21. package/dist/commands/list.js.map +2 -2
  22. package/dist/commands/model.js +2 -8
  23. package/dist/commands/model.js.map +2 -2
  24. package/dist/commands/pull.js +16 -9
  25. package/dist/commands/pull.js.map +2 -2
  26. package/dist/commands/push.js +5 -9
  27. package/dist/commands/push.js.map +2 -2
  28. package/dist/commands/refresh.js +3 -8
  29. package/dist/commands/refresh.js.map +2 -2
  30. package/dist/commands/run.js +3 -6
  31. package/dist/commands/run.js.map +2 -2
  32. package/dist/commands/sheets.js +5 -21
  33. package/dist/commands/sheets.js.map +2 -2
  34. package/dist/commands/status.js +4 -9
  35. package/dist/commands/status.js.map +2 -2
  36. package/dist/commands/variables.js +8 -30
  37. package/dist/commands/variables.js.map +2 -2
  38. package/dist/commands/whoami.js +11 -0
  39. package/dist/commands/whoami.js.map +2 -2
  40. package/dist/index.js +22 -23
  41. package/dist/index.js.map +2 -2
  42. package/dist/mcp/resources/documentation.js +1 -1
  43. package/dist/mcp/resources/documentation.js.map +1 -1
  44. package/dist/mcp/server.js +1 -1
  45. package/dist/mcp/server.js.map +1 -1
  46. package/dist/mcp/tools/dataTools.js +1 -1
  47. package/dist/mcp/tools/dataTools.js.map +2 -2
  48. package/dist/mcp/utils/helpers.js.map +2 -2
  49. package/dist/mcp/utils/launchPin.js.map +2 -2
  50. package/dist/services/configService.js +0 -45
  51. package/dist/services/configService.js.map +2 -2
  52. package/dist/services/farseerFactory.js +79 -0
  53. package/dist/services/farseerFactory.js.map +3 -3
  54. package/dist/services/preflight.js +115 -0
  55. package/dist/services/preflight.js.map +7 -0
  56. package/dist/utils/fileValidation.js +1 -0
  57. package/dist/utils/fileValidation.js.map +2 -2
  58. package/dist/utils/helpers.js +42 -48
  59. package/dist/utils/helpers.js.map +2 -2
  60. package/dist/utils/workspace.js +1 -1
  61. package/dist/utils/workspace.js.map +2 -2
  62. package/docs/api-reference.md +3 -3
  63. package/docs/arquero-patterns.md +1 -1
  64. package/docs/cli-guide.md +14 -9
  65. package/docs/how-farseer-works.md +1 -1
  66. package/docs/import-workflows.md +3 -3
  67. package/docs/new-app-template.md +1 -1
  68. package/docs/query-formulas.md +1 -1
  69. package/package.json +1 -1
  70. package/dist/commands/checkout.js +0 -189
  71. package/dist/commands/checkout.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/helpers.ts"],
4
- "sourcesContent": ["import * as crypto from 'crypto';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport {\n getCredential,\n getCurrentTenant,\n getCurrentCheckout,\n getCurrentOrganisation,\n getTenantOrg,\n saveTenantOrgMapping,\n} from '../services/configService';\nimport { logger } from './logger';\n\nexport function calculateHash(content: string | Buffer): string {\n return crypto.createHash('md5').update(content).digest('hex');\n}\n\nexport function getAppsDir(): string {\n return path.join(process.cwd(), 'farseer-apps');\n}\n\nexport function getTenantDir(tenant: string): string {\n return path.join(getAppsDir(), tenant);\n}\n\nexport function getTenantFilesDir(tenant: string): string {\n return path.join(getTenantDir(tenant), 'files');\n}\n\n/**\n * Human-readable path string for log output. Renders the directory the\n * CLI actually scans, so users who copy-paste the displayed path land\n * on the right files.\n *\n * Earlier `status` hard-coded the literal `apps/<tenant>/files/` which\n * had drifted from the real `farseer-apps/<tenant>/files/` layout \u2014\n * users who followed the displayed path edited files the CLI never\n * looked at. Deriving from the same helper as the operation prevents\n * the strings from drifting again.\n *\n * Edge cases handled:\n * \u2022 If a `path.relative(cwd, absDir)` would point UP (`../`) or to\n * the cwd itself, we fall back to the absolute path \u2014 the user is\n * running the CLI from outside / at the synced directory, and\n * showing `\"../\"` or an empty relative string is more confusing\n * than the absolute form.\n * \u2022 macOS resolves `/tmp` \u2192 `/private/tmp` via `fs.realpathSync`,\n * which makes `path.relative` from cwd `/tmp/x` to absDir\n * `/private/tmp/x/...` emit `../../../...`. We resolve both sides\n * through `realpathSync` before comparing so the symlink doesn't\n * leak into the displayed path.\n */\nexport function displayLocalPath(absDir: string): string {\n // Resolve symlinks on both sides so /tmp vs /private/tmp on macOS\n // doesn't blow up the relative path with `../../../`.\n const resolvedCwd = safeRealpath(process.cwd());\n const resolvedDir = safeRealpath(absDir);\n const rel = path.relative(resolvedCwd, resolvedDir);\n // `..` prefix means absDir is OUTSIDE cwd. Falling back to the\n // absolute form is clearer than a deep `../` chain \u2014 and it stays\n // copy-pasteable. An empty string means cwd === absDir, which would\n // otherwise render as just `/`; show `./` instead so the trailing\n // slash convention stays consistent.\n if (rel === '') return './';\n if (rel.startsWith('..')) return resolvedDir + '/';\n return rel + '/';\n}\n\n/**\n * `fs.realpathSync` with a graceful fallback: returns the input\n * unchanged when the path doesn't exist or can't be resolved. Used by\n * `displayLocalPath` so we can render a still-to-be-created tenant\n * folder without throwing.\n */\nfunction safeRealpath(p: string): string {\n try {\n return fs.realpathSync(p);\n } catch {\n return p;\n }\n}\n\n// Legacy - for backwards compatibility with run command\nexport function getTenantSrcDir(tenant: string): string {\n return path.join(getTenantFilesDir(tenant), 'Scripts');\n}\n\nexport function getSyncFilePath(tenant: string): string {\n return path.join(getTenantDir(tenant), '.farseer-sync.json');\n}\n\nexport function getAuditLogPath(tenant: string): string {\n return path.join(getTenantDir(tenant), '.farseer-audit.log');\n}\n\nexport function getTenantAppsDir(tenant: string): string {\n return path.join(getTenantDir(tenant), 'apps');\n}\n\nexport function ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n}\n\n/**\n * Returns `fullPath` relative to `basePath`, always with POSIX separators.\n *\n * On Windows `path.relative` returns backslash-separated paths. Those flow\n * through `getAllFilesInDir` / `getAllFiles` and become KEYS in the sync\n * state, `localFileHashes`, `localPresenceSet`, etc. Remote keys come back\n * from the API as POSIX (`/`-separated), so without this normalisation the\n * key comparison fails and every file looks like a local-delete + remote-add\n * pair. Normalising once here means every caller \u2014 sync state, status\n * comparator, blocklist matcher \u2014 sees the same shape regardless of OS.\n */\nexport function getRelativePath(fullPath: string, basePath: string): string {\n return path.relative(basePath, fullPath).split(path.sep).join('/');\n}\n\n/**\n * Resolve `filePath` against `baseDir` and verify the resolved path stays\n * inside it. Anything that escapes (`..`, absolute paths, symlink-style\n * tricks once resolved) throws \u2014 callers that build paths from REMOTE\n * data must use this so a backend bug or compromised tenant returning\n * `../../etc/passwd` can't write or unlink outside the tenant's files\n * folder.\n *\n * Use everywhere we touch the filesystem with a path that came from\n * remote: pull's writes/unlinks, the merge_markers `.remote` sibling\n * write, push/wipe candidate iteration, etc.\n */\nexport function safeResolveWithinBase(baseDir: string, filePath: string): string {\n const resolvedBase = path.resolve(baseDir);\n const resolved = path.resolve(resolvedBase, filePath);\n // path.resolve normalises `..`; check the result is inside the base\n // directory (allow exact match for the base itself, but require a\n // separator suffix for descendants to avoid `/foo/bar` vs `/foo/barbaz`).\n if (resolved !== resolvedBase && !resolved.startsWith(resolvedBase + path.sep)) {\n throw new Error(\n `Path escapes base directory: '${filePath}' resolves to '${resolved}' (base: '${resolvedBase}')`,\n );\n }\n return resolved;\n}\n\n/**\n * Resolves a list of relative paths against `baseDir` and partitions\n * them into resolved-to-real-file vs. missing. Used by `push --only`\n * to validate the user's whitelist before any network call.\n *\n * \"Missing\" covers all the ways a path can fail to point at a real\n * file under the base:\n * - filename typo / wrong case / double slash\n * - file was deleted locally after the user typed the command\n * - traversal attempt (`../foo`) \u2014 safeResolveWithinBase throws, we\n * catch and treat it as missing rather than crashing the whole\n * pre-flight on the first offender. Without the catch, the user\n * would see one error and never get the consolidated \"here's\n * everything that didn't resolve\" output.\n *\n * Order is preserved in `missing` so the error message lists paths\n * in the same order the user wrote them.\n */\nexport function validateOnlyFilePaths(baseDir: string, paths: string[]): { missing: string[] } {\n const missing: string[] = [];\n for (const p of paths) {\n try {\n const fullPath = safeResolveWithinBase(baseDir, p);\n if (!fs.existsSync(fullPath) || !fs.statSync(fullPath).isFile()) {\n missing.push(p);\n }\n } catch {\n missing.push(p);\n }\n }\n return { missing };\n}\n\n/**\n * OS-generated metadata files / folders that should NEVER be synced.\n *\n * These accumulate locally without the user creating them and would otherwise\n * leak into the remote workspace (and trip backend filename validation).\n * Match against the basename of any path segment, including nested copies\n * (e.g. `Scripts/.DS_Store`, `__MACOSX/Apps/foo.ts`).\n *\n * Lives in helpers (not syncService) so the file-listing helper itself can\n * apply the filter \u2014 keeping it in syncService meant every call site had to\n * remember to `.filter((f) => !isOsMetadataFile(f))` and a single forgotten\n * one would silently leak `.DS_Store` (which is exactly how PR #1878 started).\n */\nconst OS_METADATA_BASENAMES = new Set([\n '.DS_Store', // macOS Finder\n '.AppleDouble', // macOS Time Machine / netatalk\n '.LSOverride', // macOS Launch Services\n '.Spotlight-V100', // macOS Spotlight\n '.Trashes', // macOS\n '.fseventsd', // macOS\n '.DocumentRevisions-V100', // macOS\n '.TemporaryItems', // macOS\n '.VolumeIcon.icns', // macOS\n '.com.apple.timemachine.donotpresent',\n 'Thumbs.db', // Windows Explorer\n 'Thumbs.db:encryptable',\n 'ehthumbs.db', // Windows Explorer\n 'ehthumbs_vista.db',\n 'desktop.ini', // Windows\n '$RECYCLE.BIN', // Windows\n '__MACOSX', // macOS zip artefact\n]);\n\n/**\n * Returns true when any segment of the path is an OS metadata file/folder\n * we always want to hide from sync \u2014 irrespective of `--all` or includes\n * config. Used as the bottom-line filter in `getAllFilesInDir` and applied\n * defensively to remote listings so old clients can't get metadata files\n * stuck on a tenant.\n */\nexport function isOsMetadataFile(filePath: string): boolean {\n const segments = filePath.split('/');\n for (const seg of segments) {\n if (OS_METADATA_BASENAMES.has(seg)) return true;\n // The `._<name>` prefix is reserved for macOS AppleDouble resource\n // forks (created by tar/zip/AFP when copying across HFS+ boundaries)\n // and is therefore aggressive: any user-named file starting with\n // `._` is silently dropped from sync. We accept this \u2014 collisions\n // are rare in practice and the alternative (uploading bookkeeping\n // junk) is the worse failure mode.\n if (seg.startsWith('._')) return true;\n }\n return false;\n}\n\n/**\n * Returns true when the path contains any segment starting with `.` that is\n * NOT covered by `isOsMetadataFile`. Things like `.env`, `.git/`, `.vscode/`\n * fall here. The CLI's `shouldIncludeFile` requires explicit opt-in for\n * these (via `--include-ext` / `--include-folder` / persistent sync-includes\n * config) \u2014 they are never picked up by `--all` alone, so a stray credential\n * file in `farseer-apps/<tenant>/files/` doesn't get pushed by accident.\n */\nexport function isHiddenFile(filePath: string): boolean {\n if (isOsMetadataFile(filePath)) return false; // those have their own rule\n const segments = filePath.split('/');\n return segments.some((seg) => seg.length > 0 && seg.startsWith('.'));\n}\n\nexport function getAllFiles(dirPath: string, basePath?: string): string[] {\n if (!fs.existsSync(dirPath)) {\n return [];\n }\n\n const base = basePath || dirPath;\n const files: string[] = [];\n\n const items = fs.readdirSync(dirPath, { withFileTypes: true });\n\n for (const item of items) {\n const fullPath = path.join(dirPath, item.name);\n\n if (item.isDirectory()) {\n files.push(...getAllFiles(fullPath, base));\n } else if (item.isFile() && isScriptFile(item.name)) {\n files.push(getRelativePath(fullPath, base));\n }\n }\n\n return files;\n}\n\n/**\n * Get all files in a directory recursively, with OS metadata stripped.\n *\n * The OS-metadata filter is the default behavior \u2014 every call site needs it,\n * and forgetting to add a `.filter((f) => !isOsMetadataFile(f))` at a new\n * call site is exactly how `.DS_Store` started leaking into pushes. Pass\n * `{ includeOsMetadata: true }` only when you have a specific reason to see\n * those files (e.g. a debug listing, audit dump). Hidden files are NOT\n * filtered here \u2014 that gate lives in `shouldIncludeFile` because the user\n * can opt in to specific dotfile patterns via the includes config.\n *\n * Pass `shouldSkipDir(relPath)` to short-circuit the walk into directories\n * the caller knows it will discard anyway. This is how callers actually\n * bound memory \u2014 without it a tenant containing `.git/` or `node_modules/`\n * still materialises every filename before any filter runs.\n */\nexport function getAllFilesInDir(\n dirPath: string,\n basePathOrOptions?: string | { includeOsMetadata?: boolean; shouldSkipDir?: (relPath: string) => boolean },\n optionsArg?: { includeOsMetadata?: boolean; shouldSkipDir?: (relPath: string) => boolean },\n): string[] {\n // Backwards-compat with the old (dirPath, basePath?) signature.\n const basePath = typeof basePathOrOptions === 'string' ? basePathOrOptions : undefined;\n const options = typeof basePathOrOptions === 'object' ? basePathOrOptions : (optionsArg ?? {});\n\n if (!fs.existsSync(dirPath)) return [];\n\n const base = basePath || dirPath;\n const files: string[] = [];\n const items = fs.readdirSync(dirPath, { withFileTypes: true });\n\n for (const item of items) {\n const fullPath = path.join(dirPath, item.name);\n\n if (item.isDirectory()) {\n const relPath = getRelativePath(fullPath, base);\n // Skip whole OS-metadata directories at recursion time \u2014 saves a\n // pointless walk into `__MACOSX/` etc. when we'd just discard\n // every entry afterwards.\n if (!options.includeOsMetadata && isOsMetadataFile(relPath)) {\n continue;\n }\n // Caller-supplied skip: lets sync callers prune hidden/`node_modules`\n // subtrees before we materialise their contents.\n if (options.shouldSkipDir && options.shouldSkipDir(relPath)) {\n continue;\n }\n files.push(...getAllFilesInDir(fullPath, base, options));\n } else if (item.isFile()) {\n const relPath = getRelativePath(fullPath, base);\n if (!options.includeOsMetadata && isOsMetadataFile(relPath)) continue;\n files.push(relPath);\n }\n }\n\n return files;\n}\n\nexport function isScriptFile(filename: string): boolean {\n const ext = path.extname(filename).toLowerCase();\n return ['.ts', '.js', '.mjs', '.cjs'].includes(ext);\n}\n\nexport function isTextFile(filename: string): boolean {\n const ext = path.extname(filename).toLowerCase().slice(1); // remove leading dot\n return ['ts', 'js', 'mjs', 'cjs', 'json', 'txt', 'md', 'csv', 'xml', 'html', 'css', 'yaml', 'yml'].includes(ext);\n}\n\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nexport function formatDate(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date;\n return d.toLocaleString();\n}\n\nexport function getCredentialsHint(tenant: string): string {\n return `Use: farseer login\n Or: farseer config set ${tenant} --api-key <key> --org <organisation>`;\n}\n\n/**\n * Resolve tenant from argument or checkout.\n * If tenant is provided, use it. Otherwise, use checked-out tenant.\n * Returns null if no tenant is available.\n */\nexport interface ResolvedCheckout {\n organisation: string;\n tenant: string;\n}\n\n/**\n * Resolve organisation and tenant from argument or checkout.\n * When only tenant is provided, assumes organisation = tenant.\n */\nexport function resolveOrgAndTenant(tenantArg?: string): ResolvedCheckout | null {\n if (tenantArg) {\n // When tenant is specified as arg, assume org = tenant\n // (User can use checkout for different org/tenant)\n return { organisation: tenantArg, tenant: tenantArg };\n }\n\n const checkout = getCurrentCheckout();\n if (checkout) {\n if (checkout.organisation === checkout.tenant) {\n logger.dim(`Using checked-out tenant: ${checkout.tenant}`);\n } else {\n logger.dim(`Using checked-out tenant: ${checkout.tenant} (org: ${checkout.organisation})`);\n }\n return checkout;\n }\n\n return null;\n}\n\nexport function resolveTenant(tenantArg?: string): string | null {\n const resolved = resolveOrgAndTenant(tenantArg);\n return resolved?.tenant || null;\n}\n\n/**\n * Resolve tenant or exit with error if not available.\n */\nexport function resolveTenantOrExit(tenantArg?: string): string {\n const tenant = resolveTenant(tenantArg);\n if (!tenant) {\n logger.error('No tenant specified.');\n logger.dim('Either specify a tenant: farseer <command> <tenant>');\n logger.dim('Or checkout a tenant: farseer checkout <tenant>');\n process.exit(1);\n }\n return tenant;\n}\n\n/**\n * Resolve organisation and tenant with support for org-tenant mapping.\n *\n * Usage patterns:\n * - <org> <tenant>: Explicit org and tenant, saves mapping for future use\n * - <tenant>: Look up org from saved mapping or use checkout\n * - (no args): Use current checkout\n *\n * @param arg1 - Organisation (if 2 args) or tenant (if 1 arg)\n * @param arg2 - Tenant (if 2 args)\n * @returns ResolvedCheckout or exits with error\n */\nexport function resolveTenantWithOrgMapping(arg1?: string, arg2?: string): ResolvedCheckout {\n // Case 1: Two arguments - <org> <tenant>\n if (arg1 && arg2) {\n const org = arg1;\n const tenant = arg2;\n\n // Save mapping for future use\n saveTenantOrgMapping(tenant, org);\n\n if (org === tenant) {\n logger.dim(`Using tenant: ${tenant}`);\n } else {\n logger.dim(`Using tenant: ${tenant} (org: ${org})`);\n }\n\n return { organisation: org, tenant };\n }\n\n // Case 2: One argument - <tenant>\n if (arg1) {\n const tenant = arg1;\n\n // Try to get org from saved mapping\n const savedOrg = getTenantOrg(tenant);\n if (savedOrg) {\n if (savedOrg === tenant) {\n logger.dim(`Using tenant: ${tenant} (from saved mapping)`);\n } else {\n logger.dim(`Using tenant: ${tenant} (org: ${savedOrg}, from saved mapping)`);\n }\n return { organisation: savedOrg, tenant };\n }\n\n // No saved mapping - show error with helpful message\n logger.error(`Organisation unknown for tenant \"${tenant}\".`);\n logger.dim('Please specify both organisation and tenant:');\n logger.dim(` farseer <command> <organisation> <tenant>`);\n logger.dim(` Example: farseer pull jgl tt-hotels-hr-dev`);\n logger.dim('');\n logger.dim('Or checkout the tenant first:');\n logger.dim(` farseer checkout <organisation> <tenant>`);\n process.exit(1);\n }\n\n // Case 3: No arguments - use current checkout\n const checkout = getCurrentCheckout();\n if (checkout) {\n if (checkout.organisation === checkout.tenant) {\n logger.dim(`Using checked-out tenant: ${checkout.tenant}`);\n } else {\n logger.dim(`Using checked-out tenant: ${checkout.tenant} (org: ${checkout.organisation})`);\n }\n return checkout;\n }\n\n // No checkout either\n logger.error('No tenant specified.');\n logger.dim('Either specify organisation and tenant: farseer <command> <org> <tenant>');\n logger.dim('Or checkout a tenant: farseer checkout <org> <tenant>');\n process.exit(1);\n}\n\n/**\n * Resolve organisation and tenant or exit with error.\n */\nexport function resolveOrgAndTenantOrExit(tenantArg?: string): ResolvedCheckout {\n const resolved = resolveOrgAndTenant(tenantArg);\n if (!resolved) {\n logger.error('No tenant specified.');\n logger.dim('Either specify a tenant: farseer <command> <tenant>');\n logger.dim('Or checkout a tenant: farseer checkout <tenant>');\n process.exit(1);\n }\n return resolved;\n}\n\n/**\n * Check if a string is a known tenant (has credentials configured).\n */\nexport function isKnownTenant(name: string): boolean {\n return !!getCredential(name);\n}\n\nexport interface ParsedAppArgs {\n organisation: string;\n tenant: string;\n appName: string;\n}\n\n/**\n * Parse variadic arguments to extract tenant and app name.\n * If first arg is a known tenant, use it as tenant and rest as app name.\n * Otherwise, use checked-out tenant and all args as app name.\n *\n * @param args Array of arguments (from variadic command)\n * @returns { organisation: string, tenant: string, appName: string }\n */\nexport function parseAppArgs(args: string[]): ParsedAppArgs {\n if (args.length === 0) {\n logger.error('App name is required.');\n process.exit(1);\n }\n\n // First arg looks like a tenant when either:\n // (a) we have API-key credentials saved for it, or\n // (b) we have a saved tenantOrgMapping entry for it (from a previous\n // `farseer pull <org> <tenant>` or `farseer checkout`).\n // In both cases we prefer the saved organisation over args[0] so\n // run/apps/etc. build the right URL when org != tenant.\n if (args.length >= 2) {\n const first = args[0];\n const knownViaCredential = isKnownTenant(first);\n const savedOrg = getTenantOrg(first);\n if (knownViaCredential || savedOrg) {\n return {\n organisation: savedOrg || first,\n tenant: first,\n appName: args.slice(1).join(' '),\n };\n }\n }\n\n // Use checked-out tenant, all args are app name\n const checkout = getCurrentCheckout();\n if (checkout) {\n if (checkout.organisation === checkout.tenant) {\n logger.dim(`Using checked-out tenant: ${checkout.tenant}`);\n } else {\n logger.dim(`Using checked-out tenant: ${checkout.tenant} (org: ${checkout.organisation})`);\n }\n return {\n organisation: checkout.organisation,\n tenant: checkout.tenant,\n appName: args.join(' '),\n };\n }\n\n // No checked-out tenant and first arg isn't a known tenant\n // Assume first arg is tenant (will fail later if invalid)\n if (args.length >= 2) {\n return {\n organisation: args[0],\n tenant: args[0],\n appName: args.slice(1).join(' '),\n };\n }\n\n // Only one arg and no checkout - could be tenant or app name\n logger.error('No tenant specified.');\n logger.dim('Either specify a tenant: farseer app show <tenant> <app-name>');\n logger.dim('Or checkout a tenant: farseer checkout <tenant>');\n process.exit(1);\n}\n\n// Credential injection/stripping for local development\n// Matches: const farseerClient = new farseer.FarseerClient();\n// and: const fClient = new farseer.FarseerClient();\n\ninterface CredentialConfig {\n basePath: string;\n tenantId: string;\n apiKey: string;\n}\n\n// Pattern to match empty FarseerClient() constructor (no /g flag to avoid lastIndex issues)\nconst EMPTY_CLIENT_PATTERNS = [\n /const farseerClient = new farseer\\.FarseerClient\\(\\s*\\);/,\n /const fClient = new farseer\\.FarseerClient\\(\\s*\\);/,\n];\n\n// Pattern to match FarseerClient with injected credentials (multiline, no /g flag)\nconst INJECTED_CLIENT_PATTERN =\n /const (farseerClient|fClient) = new farseer\\.FarseerClient\\(\\{[\\s\\S]*?basePath:[\\s\\S]*?headers:[\\s\\S]*?'X-TENANT-ID':[\\s\\S]*?'X-API-KEY':[\\s\\S]*?\\}\\);/;\n\nexport function injectCredentials(code: string, credential: CredentialConfig): string {\n const clientConfig = `{\n basePath: '${credential.basePath}',\n headers: {\n 'X-TENANT-ID': '${credential.tenantId}',\n 'X-API-KEY': '${credential.apiKey}',\n }\n }`;\n\n let modified = code;\n\n // Pattern 1: const farseerClient = new farseer.FarseerClient();\n modified = modified.replace(\n /const farseerClient = new farseer\\.FarseerClient\\(\\s*\\);/g,\n `const farseerClient = new farseer.FarseerClient(${clientConfig});`,\n );\n\n // Pattern 2: const fClient = new farseer.FarseerClient();\n modified = modified.replace(\n /const fClient = new farseer\\.FarseerClient\\(\\s*\\);/g,\n `const fClient = new farseer.FarseerClient(${clientConfig});`,\n );\n\n return modified;\n}\n\nexport function stripCredentials(code: string): string {\n // Replace injected credentials back to empty constructor\n let modified = code;\n\n // Match farseerClient with credentials\n modified = modified.replace(\n /const farseerClient = new farseer\\.FarseerClient\\(\\{[\\s\\S]*?basePath:[\\s\\S]*?headers:[\\s\\S]*?'X-TENANT-ID':[\\s\\S]*?'X-API-KEY':[\\s\\S]*?\\}\\);/g,\n 'const farseerClient = new farseer.FarseerClient();',\n );\n\n // Match fClient with credentials\n modified = modified.replace(\n /const fClient = new farseer\\.FarseerClient\\(\\{[\\s\\S]*?basePath:[\\s\\S]*?headers:[\\s\\S]*?'X-TENANT-ID':[\\s\\S]*?'X-API-KEY':[\\s\\S]*?\\}\\);/g,\n 'const fClient = new farseer.FarseerClient();',\n );\n\n return modified;\n}\n\nexport function hasInjectedCredentials(code: string): boolean {\n return INJECTED_CLIENT_PATTERN.test(code);\n}\n\nexport function hasEmptyFarseerClient(code: string): boolean {\n return EMPTY_CLIENT_PATTERNS.some((pattern) => pattern.test(code));\n}\n\n// Process all script files in a directory\nexport function injectCredentialsInDir(srcDir: string, credential: CredentialConfig): number {\n let count = 0;\n const files = getAllFiles(srcDir);\n\n for (const file of files) {\n const filePath = path.join(srcDir, file);\n const content = fs.readFileSync(filePath, 'utf-8');\n const modified = injectCredentials(content, credential);\n\n if (modified !== content) {\n fs.writeFileSync(filePath, modified);\n count++;\n }\n }\n\n return count;\n}\n\nexport function stripCredentialsInDir(srcDir: string): number {\n let count = 0;\n const files = getAllFiles(srcDir);\n\n for (const file of files) {\n const filePath = path.join(srcDir, file);\n const content = fs.readFileSync(filePath, 'utf-8');\n const modified = stripCredentials(content);\n\n if (modified !== content) {\n fs.writeFileSync(filePath, modified);\n count++;\n }\n }\n\n return count;\n}\n\n// Audit log helpers\nexport interface AuditLogEntry {\n operation: 'pulled' | 'pushed' | 'deleted';\n filePath: string;\n uploadTime?: string;\n uploaderEmail?: string;\n uploaderName?: string;\n}\n\n/**\n * Execute async operations with limited concurrency.\n * Processes items in chunks to avoid overwhelming the API.\n *\n * @param items Array of items to process\n * @param fetcher Async function to call for each item\n * @param concurrency Maximum number of concurrent requests (default: 15)\n * @returns Array of results in the same order as input items\n */\nexport async function fetchWithConcurrency<T, R>(\n items: T[],\n fetcher: (item: T, index: number) => Promise<R>,\n concurrency: number = 15,\n): Promise<R[]> {\n const results: R[] = [];\n\n for (let i = 0; i < items.length; i += concurrency) {\n const chunk = items.slice(i, i + concurrency);\n const chunkResults = await Promise.all(chunk.map((item, chunkIndex) => fetcher(item, i + chunkIndex)));\n results.push(...chunkResults);\n }\n\n return results;\n}\n\nexport function appendToAuditLog(tenant: string, entries: AuditLogEntry[]): void {\n if (entries.length === 0) {\n return;\n }\n\n const logPath = getAuditLogPath(tenant);\n const timestamp = new Date().toISOString();\n\n let logContent = '';\n for (const entry of entries) {\n const uploaderInfo = entry.uploaderName\n ? `${entry.uploaderName} (${entry.uploaderEmail})`\n : entry.uploaderEmail || 'Unknown';\n\n const uploadedAt = entry.uploadTime ? new Date(entry.uploadTime).toLocaleString() : 'Unknown';\n\n logContent += `${timestamp} | ${entry.operation} | ${entry.filePath} | Modified by: ${uploaderInfo} | Uploaded: ${uploadedAt}\\n`;\n }\n\n fs.appendFileSync(logPath, logContent, 'utf-8');\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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gB,SAAgC;AAC7E,MAAI,QAAQ,WAAW,GAAG;AACtB;AAAA,EACJ;AAEA,QAAM,UAAU,gBAAgB,MAAM;AACtC,QAAM,aAAY,oBAAI,KAAK,GAAE,YAAY;AAEzC,MAAI,aAAa;AACjB,aAAW,SAAS,SAAS;AACzB,UAAM,eAAe,MAAM,eACrB,GAAG,MAAM,YAAY,KAAK,MAAM,aAAa,MAC7C,MAAM,iBAAiB;AAE7B,UAAM,aAAa,MAAM,aAAa,IAAI,KAAK,MAAM,UAAU,EAAE,eAAe,IAAI;AAEpF,kBAAc,GAAG,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM,QAAQ,mBAAmB,YAAY,gBAAgB,UAAU;AAAA;AAAA,EAChI;AAEA,KAAG,eAAe,SAAS,YAAY,OAAO;AAClD;",
4
+ "sourcesContent": ["import * as crypto from 'crypto';\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport { getCredential, getTenantOrg } from '../services/configService';\nimport { logger } from './logger';\n\nexport function calculateHash(content: string | Buffer): string {\n return crypto.createHash('md5').update(content).digest('hex');\n}\n\nexport function getAppsDir(): string {\n return path.join(process.cwd(), 'farseer-apps');\n}\n\nexport function getTenantDir(tenant: string): string {\n return path.join(getAppsDir(), tenant);\n}\n\nexport function getTenantFilesDir(tenant: string): string {\n return path.join(getTenantDir(tenant), 'files');\n}\n\n/**\n * Human-readable path string for log output. Renders the directory the\n * CLI actually scans, so users who copy-paste the displayed path land\n * on the right files.\n *\n * Earlier `status` hard-coded the literal `apps/<tenant>/files/` which\n * had drifted from the real `farseer-apps/<tenant>/files/` layout \u2014\n * users who followed the displayed path edited files the CLI never\n * looked at. Deriving from the same helper as the operation prevents\n * the strings from drifting again.\n *\n * Edge cases handled:\n * \u2022 If a `path.relative(cwd, absDir)` would point UP (`../`) or to\n * the cwd itself, we fall back to the absolute path \u2014 the user is\n * running the CLI from outside / at the synced directory, and\n * showing `\"../\"` or an empty relative string is more confusing\n * than the absolute form.\n * \u2022 macOS resolves `/tmp` \u2192 `/private/tmp` via `fs.realpathSync`,\n * which makes `path.relative` from cwd `/tmp/x` to absDir\n * `/private/tmp/x/...` emit `../../../...`. We resolve both sides\n * through `realpathSync` before comparing so the symlink doesn't\n * leak into the displayed path.\n */\nexport function displayLocalPath(absDir: string): string {\n // Resolve symlinks on both sides so /tmp vs /private/tmp on macOS\n // doesn't blow up the relative path with `../../../`.\n const resolvedCwd = safeRealpath(process.cwd());\n const resolvedDir = safeRealpath(absDir);\n const rel = path.relative(resolvedCwd, resolvedDir);\n // `..` prefix means absDir is OUTSIDE cwd. Falling back to the\n // absolute form is clearer than a deep `../` chain \u2014 and it stays\n // copy-pasteable. An empty string means cwd === absDir, which would\n // otherwise render as just `/`; show `./` instead so the trailing\n // slash convention stays consistent.\n if (rel === '') return './';\n if (rel.startsWith('..')) return resolvedDir + '/';\n return rel + '/';\n}\n\n/**\n * `fs.realpathSync` with a graceful fallback: returns the input\n * unchanged when the path doesn't exist or can't be resolved. Used by\n * `displayLocalPath` so we can render a still-to-be-created tenant\n * folder without throwing.\n */\nfunction safeRealpath(p: string): string {\n try {\n return fs.realpathSync(p);\n } catch {\n return p;\n }\n}\n\n// Legacy - for backwards compatibility with run command\nexport function getTenantSrcDir(tenant: string): string {\n return path.join(getTenantFilesDir(tenant), 'Scripts');\n}\n\nexport function getSyncFilePath(tenant: string): string {\n return path.join(getTenantDir(tenant), '.farseer-sync.json');\n}\n\nexport function getAuditLogPath(tenant: string): string {\n return path.join(getTenantDir(tenant), '.farseer-audit.log');\n}\n\nexport function getTenantAppsDir(tenant: string): string {\n return path.join(getTenantDir(tenant), 'apps');\n}\n\nexport function ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n}\n\n/**\n * Returns `fullPath` relative to `basePath`, always with POSIX separators.\n *\n * On Windows `path.relative` returns backslash-separated paths. Those flow\n * through `getAllFilesInDir` / `getAllFiles` and become KEYS in the sync\n * state, `localFileHashes`, `localPresenceSet`, etc. Remote keys come back\n * from the API as POSIX (`/`-separated), so without this normalisation the\n * key comparison fails and every file looks like a local-delete + remote-add\n * pair. Normalising once here means every caller \u2014 sync state, status\n * comparator, blocklist matcher \u2014 sees the same shape regardless of OS.\n */\nexport function getRelativePath(fullPath: string, basePath: string): string {\n return path.relative(basePath, fullPath).split(path.sep).join('/');\n}\n\n/**\n * Resolve `filePath` against `baseDir` and verify the resolved path stays\n * inside it. Anything that escapes (`..`, absolute paths, symlink-style\n * tricks once resolved) throws \u2014 callers that build paths from REMOTE\n * data must use this so a backend bug or compromised tenant returning\n * `../../etc/passwd` can't write or unlink outside the tenant's files\n * folder.\n *\n * Use everywhere we touch the filesystem with a path that came from\n * remote: pull's writes/unlinks, the merge_markers `.remote` sibling\n * write, push/wipe candidate iteration, etc.\n */\nexport function safeResolveWithinBase(baseDir: string, filePath: string): string {\n const resolvedBase = path.resolve(baseDir);\n const resolved = path.resolve(resolvedBase, filePath);\n // path.resolve normalises `..`; check the result is inside the base\n // directory (allow exact match for the base itself, but require a\n // separator suffix for descendants to avoid `/foo/bar` vs `/foo/barbaz`).\n if (resolved !== resolvedBase && !resolved.startsWith(resolvedBase + path.sep)) {\n throw new Error(\n `Path escapes base directory: '${filePath}' resolves to '${resolved}' (base: '${resolvedBase}')`,\n );\n }\n return resolved;\n}\n\n/**\n * Resolves a list of relative paths against `baseDir` and partitions\n * them into resolved-to-real-file vs. missing. Used by `push --only`\n * to validate the user's whitelist before any network call.\n *\n * \"Missing\" covers all the ways a path can fail to point at a real\n * file under the base:\n * - filename typo / wrong case / double slash\n * - file was deleted locally after the user typed the command\n * - traversal attempt (`../foo`) \u2014 safeResolveWithinBase throws, we\n * catch and treat it as missing rather than crashing the whole\n * pre-flight on the first offender. Without the catch, the user\n * would see one error and never get the consolidated \"here's\n * everything that didn't resolve\" output.\n *\n * Order is preserved in `missing` so the error message lists paths\n * in the same order the user wrote them.\n */\nexport function validateOnlyFilePaths(baseDir: string, paths: string[]): { missing: string[] } {\n const missing: string[] = [];\n for (const p of paths) {\n try {\n const fullPath = safeResolveWithinBase(baseDir, p);\n if (!fs.existsSync(fullPath) || !fs.statSync(fullPath).isFile()) {\n missing.push(p);\n }\n } catch {\n missing.push(p);\n }\n }\n return { missing };\n}\n\n/**\n * OS-generated metadata files / folders that should NEVER be synced.\n *\n * These accumulate locally without the user creating them and would otherwise\n * leak into the remote workspace (and trip backend filename validation).\n * Match against the basename of any path segment, including nested copies\n * (e.g. `Scripts/.DS_Store`, `__MACOSX/Apps/foo.ts`).\n *\n * Lives in helpers (not syncService) so the file-listing helper itself can\n * apply the filter \u2014 keeping it in syncService meant every call site had to\n * remember to `.filter((f) => !isOsMetadataFile(f))` and a single forgotten\n * one would silently leak `.DS_Store` (which is exactly how PR #1878 started).\n */\nconst OS_METADATA_BASENAMES = new Set([\n '.DS_Store', // macOS Finder\n '.AppleDouble', // macOS Time Machine / netatalk\n '.LSOverride', // macOS Launch Services\n '.Spotlight-V100', // macOS Spotlight\n '.Trashes', // macOS\n '.fseventsd', // macOS\n '.DocumentRevisions-V100', // macOS\n '.TemporaryItems', // macOS\n '.VolumeIcon.icns', // macOS\n '.com.apple.timemachine.donotpresent',\n 'Thumbs.db', // Windows Explorer\n 'Thumbs.db:encryptable',\n 'ehthumbs.db', // Windows Explorer\n 'ehthumbs_vista.db',\n 'desktop.ini', // Windows\n '$RECYCLE.BIN', // Windows\n '__MACOSX', // macOS zip artefact\n]);\n\n/**\n * Returns true when any segment of the path is an OS metadata file/folder\n * we always want to hide from sync \u2014 irrespective of `--all` or includes\n * config. Used as the bottom-line filter in `getAllFilesInDir` and applied\n * defensively to remote listings so old clients can't get metadata files\n * stuck on a tenant.\n */\nexport function isOsMetadataFile(filePath: string): boolean {\n const segments = filePath.split('/');\n for (const seg of segments) {\n if (OS_METADATA_BASENAMES.has(seg)) return true;\n // The `._<name>` prefix is reserved for macOS AppleDouble resource\n // forks (created by tar/zip/AFP when copying across HFS+ boundaries)\n // and is therefore aggressive: any user-named file starting with\n // `._` is silently dropped from sync. We accept this \u2014 collisions\n // are rare in practice and the alternative (uploading bookkeeping\n // junk) is the worse failure mode.\n if (seg.startsWith('._')) return true;\n }\n return false;\n}\n\n/**\n * Returns true when the path contains any segment starting with `.` that is\n * NOT covered by `isOsMetadataFile`. Things like `.env`, `.git/`, `.vscode/`\n * fall here. The CLI's `shouldIncludeFile` requires explicit opt-in for\n * these (via `--include-ext` / `--include-folder` / persistent sync-includes\n * config) \u2014 they are never picked up by `--all` alone, so a stray credential\n * file in `farseer-apps/<tenant>/files/` doesn't get pushed by accident.\n */\nexport function isHiddenFile(filePath: string): boolean {\n if (isOsMetadataFile(filePath)) return false; // those have their own rule\n const segments = filePath.split('/');\n return segments.some((seg) => seg.length > 0 && seg.startsWith('.'));\n}\n\nexport function getAllFiles(dirPath: string, basePath?: string): string[] {\n if (!fs.existsSync(dirPath)) {\n return [];\n }\n\n const base = basePath || dirPath;\n const files: string[] = [];\n\n const items = fs.readdirSync(dirPath, { withFileTypes: true });\n\n for (const item of items) {\n const fullPath = path.join(dirPath, item.name);\n\n if (item.isDirectory()) {\n files.push(...getAllFiles(fullPath, base));\n } else if (item.isFile() && isScriptFile(item.name)) {\n files.push(getRelativePath(fullPath, base));\n }\n }\n\n return files;\n}\n\n/**\n * Get all files in a directory recursively, with OS metadata stripped.\n *\n * The OS-metadata filter is the default behavior \u2014 every call site needs it,\n * and forgetting to add a `.filter((f) => !isOsMetadataFile(f))` at a new\n * call site is exactly how `.DS_Store` started leaking into pushes. Pass\n * `{ includeOsMetadata: true }` only when you have a specific reason to see\n * those files (e.g. a debug listing, audit dump). Hidden files are NOT\n * filtered here \u2014 that gate lives in `shouldIncludeFile` because the user\n * can opt in to specific dotfile patterns via the includes config.\n *\n * Pass `shouldSkipDir(relPath)` to short-circuit the walk into directories\n * the caller knows it will discard anyway. This is how callers actually\n * bound memory \u2014 without it a tenant containing `.git/` or `node_modules/`\n * still materialises every filename before any filter runs.\n */\nexport function getAllFilesInDir(\n dirPath: string,\n basePathOrOptions?: string | { includeOsMetadata?: boolean; shouldSkipDir?: (relPath: string) => boolean },\n optionsArg?: { includeOsMetadata?: boolean; shouldSkipDir?: (relPath: string) => boolean },\n): string[] {\n // Backwards-compat with the old (dirPath, basePath?) signature.\n const basePath = typeof basePathOrOptions === 'string' ? basePathOrOptions : undefined;\n const options = typeof basePathOrOptions === 'object' ? basePathOrOptions : (optionsArg ?? {});\n\n if (!fs.existsSync(dirPath)) return [];\n\n const base = basePath || dirPath;\n const files: string[] = [];\n const items = fs.readdirSync(dirPath, { withFileTypes: true });\n\n for (const item of items) {\n const fullPath = path.join(dirPath, item.name);\n\n if (item.isDirectory()) {\n const relPath = getRelativePath(fullPath, base);\n // Skip whole OS-metadata directories at recursion time \u2014 saves a\n // pointless walk into `__MACOSX/` etc. when we'd just discard\n // every entry afterwards.\n if (!options.includeOsMetadata && isOsMetadataFile(relPath)) {\n continue;\n }\n // Caller-supplied skip: lets sync callers prune hidden/`node_modules`\n // subtrees before we materialise their contents.\n if (options.shouldSkipDir && options.shouldSkipDir(relPath)) {\n continue;\n }\n files.push(...getAllFilesInDir(fullPath, base, options));\n } else if (item.isFile()) {\n const relPath = getRelativePath(fullPath, base);\n if (!options.includeOsMetadata && isOsMetadataFile(relPath)) continue;\n files.push(relPath);\n }\n }\n\n return files;\n}\n\nexport function isScriptFile(filename: string): boolean {\n const ext = path.extname(filename).toLowerCase();\n return ['.ts', '.js', '.mjs', '.cjs'].includes(ext);\n}\n\nexport function isTextFile(filename: string): boolean {\n const ext = path.extname(filename).toLowerCase().slice(1); // remove leading dot\n return ['ts', 'js', 'mjs', 'cjs', 'json', 'txt', 'md', 'csv', 'xml', 'html', 'css', 'yaml', 'yml'].includes(ext);\n}\n\nexport function formatFileSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nexport function formatDate(date: Date | string): string {\n const d = typeof date === 'string' ? new Date(date) : date;\n return d.toLocaleString();\n}\n\nexport function getCredentialsHint(tenant: string): string {\n return `Use: farseer login\n Or: farseer config set ${tenant} --api-key <key> --org <organisation>`;\n}\n\n/**\n * Resolve tenant from argument or the FARSEER_TENANT env.\n * If tenant is provided, use it. Otherwise, use the env tenant.\n * Returns null if no tenant is available.\n */\nexport interface ResolvedCheckout {\n organisation: string;\n tenant: string;\n}\n\n/**\n * Per-shell target from the environment. There is no persisted global default\n * any more \u2014 a command takes its tenant from an explicit argument or from\n * FARSEER_TENANT in the calling shell, and errors if neither is set. Two shells\n * can therefore hold different tenants at once, and a bare command never\n * silently retargets to a stale machine-global checkout.\n *\n * Org resolves the same way the MCP launch path does (mcp/utils/launchPin.ts):\n * FARSEER_ORG > saved tenant->org mapping > the tenant name. So once a confirmed\n * `farseer pull <org> <tenant>` has recorded the mapping, `export FARSEER_TENANT=x`\n * alone is enough; only new org != tenant tenants also need FARSEER_ORG.\n */\nexport function getEnvCheckout(): ResolvedCheckout | null {\n const tenant = process.env.FARSEER_TENANT;\n if (!tenant) return null;\n const organisation = process.env.FARSEER_ORG || getTenantOrg(tenant) || tenant;\n if (organisation === tenant) {\n logger.dim(`Using tenant from FARSEER_TENANT: ${tenant}`);\n } else {\n logger.dim(`Using tenant from FARSEER_TENANT: ${tenant} (org: ${organisation})`);\n }\n return { organisation, tenant };\n}\n\n/**\n * Resolve organisation and tenant from argument or the FARSEER_TENANT env.\n * When only tenant is provided, assumes organisation = tenant.\n */\nexport function resolveOrgAndTenant(tenantArg?: string): ResolvedCheckout | null {\n if (tenantArg) {\n // When tenant is specified as arg, assume org = tenant\n // (org != tenant tenants are resolved via the mapping in the\n // richer resolveTenantWithOrgMapping path).\n return { organisation: tenantArg, tenant: tenantArg };\n }\n\n return getEnvCheckout();\n}\n\nexport function resolveTenant(tenantArg?: string): string | null {\n const resolved = resolveOrgAndTenant(tenantArg);\n return resolved?.tenant || null;\n}\n\n/**\n * Resolve tenant or exit with error if not available.\n */\nexport function resolveTenantOrExit(tenantArg?: string): string {\n const tenant = resolveTenant(tenantArg);\n if (!tenant) {\n logger.error('No tenant specified.');\n logger.dim('Pass it: farseer <command> <tenant>');\n logger.dim('Or set it (per shell): export FARSEER_TENANT=<tenant>');\n process.exit(1);\n }\n return tenant;\n}\n\n/**\n * Resolve organisation and tenant with support for org-tenant mapping.\n *\n * Usage patterns:\n * - <org> <tenant>: Explicit org and tenant\n * - <tenant>: Look up org from FARSEER_ORG or the saved mapping\n * - (no args): Fall back to FARSEER_TENANT/FARSEER_ORG from the shell\n *\n * Read-only by design: resolving a pair must not persist it. A typo'd org\n * (`farseer pull wrong-org my-tenant`) would otherwise be remembered as\n * my-tenant's org before anything confirmed it, and every later one-arg command\n * would inherit the wrong host \u2014 silently, since `*.farseer.io` is a wildcard.\n * The mapping is written by the preflight instead, and only for a pair the\n * organisation itself confirmed.\n *\n * @param arg1 - Organisation (if 2 args) or tenant (if 1 arg)\n * @param arg2 - Tenant (if 2 args)\n * @returns ResolvedCheckout or exits with error\n */\nexport function resolveTenantWithOrgMapping(arg1?: string, arg2?: string): ResolvedCheckout {\n // Case 1: Two arguments - <org> <tenant>\n if (arg1 && arg2) {\n const org = arg1;\n const tenant = arg2;\n\n if (org === tenant) {\n logger.dim(`Using tenant: ${tenant}`);\n } else {\n logger.dim(`Using tenant: ${tenant} (org: ${org})`);\n }\n\n return { organisation: org, tenant };\n }\n\n // Case 2: One argument - <tenant>\n if (arg1) {\n const tenant = arg1;\n\n // FARSEER_ORG pairs with FARSEER_TENANT (it's the org for the shell's\n // env tenant), so only honour it when this explicit tenant IS that env\n // tenant \u2014 otherwise a shell-level FARSEER_ORG would leak onto an\n // unrelated tenant and build the wrong host. Else use the saved mapping.\n const envOrg = tenant === process.env.FARSEER_TENANT ? process.env.FARSEER_ORG : undefined;\n const org = envOrg || getTenantOrg(tenant);\n if (org) {\n if (org === tenant) {\n logger.dim(`Using tenant: ${tenant}`);\n } else {\n logger.dim(`Using tenant: ${tenant} (org: ${org})`);\n }\n return { organisation: org, tenant };\n }\n\n // An API-key tenant needs no remembered org: the stored credential\n // carries its own base URL and the organisation is ignored on that path.\n // Only confirmed pairs get recorded now, so these tenants often have no\n // mapping at all \u2014 don't demand an org we would never use.\n if (getCredential(tenant)) {\n logger.dim(`Using tenant: ${tenant}`);\n return { organisation: tenant, tenant };\n }\n\n // Org for this tenant is unknown - fail loud rather than guess a host.\n logger.error(`Organisation unknown for tenant \"${tenant}\".`);\n logger.dim('Pass both: farseer <command> <organisation> <tenant>');\n logger.dim(`Or set them per shell: export FARSEER_TENANT=${tenant} FARSEER_ORG=<organisation>`);\n process.exit(1);\n }\n\n // Case 3: No arguments - fall back to FARSEER_TENANT from the shell.\n const envCheckout = getEnvCheckout();\n if (envCheckout) {\n return envCheckout;\n }\n\n // Nothing to go on - fail loud instead of guessing a tenant.\n logger.error('No tenant specified.');\n logger.dim('Pass it: farseer <command> <tenant>');\n logger.dim('Or set it (per shell): export FARSEER_TENANT=<tenant> (FARSEER_ORG=<org> if org differs)');\n process.exit(1);\n}\n\n/**\n * Resolve organisation and tenant or exit with error.\n */\nexport function resolveOrgAndTenantOrExit(tenantArg?: string): ResolvedCheckout {\n const resolved = resolveOrgAndTenant(tenantArg);\n if (!resolved) {\n logger.error('No tenant specified.');\n logger.dim('Pass it: farseer <command> <tenant>');\n logger.dim('Or set it (per shell): export FARSEER_TENANT=<tenant>');\n process.exit(1);\n }\n return resolved;\n}\n\n/**\n * Check if a string is a known tenant (has credentials configured).\n */\nexport function isKnownTenant(name: string): boolean {\n return !!getCredential(name);\n}\n\nexport interface ParsedAppArgs {\n organisation: string;\n tenant: string;\n appName: string;\n}\n\n/**\n * Parse variadic arguments to extract tenant and app name.\n * If first arg is a known tenant, use it as tenant and rest as app name.\n * Otherwise, use checked-out tenant and all args as app name.\n *\n * @param args Array of arguments (from variadic command)\n * @returns { organisation: string, tenant: string, appName: string }\n */\nexport function parseAppArgs(args: string[]): ParsedAppArgs {\n if (args.length === 0) {\n logger.error('App name is required.');\n process.exit(1);\n }\n\n // First arg looks like a tenant when either:\n // (a) we have API-key credentials saved for it, or\n // (b) we have a saved tenantOrgMapping entry for it (from a previous\n // `farseer pull <org> <tenant>`).\n // In both cases we prefer the saved organisation over args[0] so\n // run/apps/etc. build the right URL when org != tenant.\n if (args.length >= 2) {\n const first = args[0];\n const knownViaCredential = isKnownTenant(first);\n const savedOrg = getTenantOrg(first);\n if (knownViaCredential || savedOrg) {\n return {\n organisation: savedOrg || first,\n tenant: first,\n appName: args.slice(1).join(' '),\n };\n }\n }\n\n // Fall back to FARSEER_TENANT from the shell; all args are the app name.\n const envCheckout = getEnvCheckout();\n if (envCheckout) {\n return {\n organisation: envCheckout.organisation,\n tenant: envCheckout.tenant,\n appName: args.join(' '),\n };\n }\n\n // No env tenant and first arg isn't a known tenant\n // Assume first arg is tenant (will fail later if invalid)\n if (args.length >= 2) {\n return {\n organisation: args[0],\n tenant: args[0],\n appName: args.slice(1).join(' '),\n };\n }\n\n // Only one arg and no env tenant - could be tenant or app name\n logger.error('No tenant specified.');\n logger.dim('Pass it: farseer app show <tenant> <app-name>');\n logger.dim('Or set it (per shell): export FARSEER_TENANT=<tenant>');\n process.exit(1);\n}\n\n// Credential injection/stripping for local development\n// Matches: const farseerClient = new farseer.FarseerClient();\n// and: const fClient = new farseer.FarseerClient();\n\ninterface CredentialConfig {\n basePath: string;\n tenantId: string;\n apiKey: string;\n}\n\n// Pattern to match empty FarseerClient() constructor (no /g flag to avoid lastIndex issues)\nconst EMPTY_CLIENT_PATTERNS = [\n /const farseerClient = new farseer\\.FarseerClient\\(\\s*\\);/,\n /const fClient = new farseer\\.FarseerClient\\(\\s*\\);/,\n];\n\n// Pattern to match FarseerClient with injected credentials (multiline, no /g flag)\nconst INJECTED_CLIENT_PATTERN =\n /const (farseerClient|fClient) = new farseer\\.FarseerClient\\(\\{[\\s\\S]*?basePath:[\\s\\S]*?headers:[\\s\\S]*?'X-TENANT-ID':[\\s\\S]*?'X-API-KEY':[\\s\\S]*?\\}\\);/;\n\nexport function injectCredentials(code: string, credential: CredentialConfig): string {\n const clientConfig = `{\n basePath: '${credential.basePath}',\n headers: {\n 'X-TENANT-ID': '${credential.tenantId}',\n 'X-API-KEY': '${credential.apiKey}',\n }\n }`;\n\n let modified = code;\n\n // Pattern 1: const farseerClient = new farseer.FarseerClient();\n modified = modified.replace(\n /const farseerClient = new farseer\\.FarseerClient\\(\\s*\\);/g,\n `const farseerClient = new farseer.FarseerClient(${clientConfig});`,\n );\n\n // Pattern 2: const fClient = new farseer.FarseerClient();\n modified = modified.replace(\n /const fClient = new farseer\\.FarseerClient\\(\\s*\\);/g,\n `const fClient = new farseer.FarseerClient(${clientConfig});`,\n );\n\n return modified;\n}\n\nexport function stripCredentials(code: string): string {\n // Replace injected credentials back to empty constructor\n let modified = code;\n\n // Match farseerClient with credentials\n modified = modified.replace(\n /const farseerClient = new farseer\\.FarseerClient\\(\\{[\\s\\S]*?basePath:[\\s\\S]*?headers:[\\s\\S]*?'X-TENANT-ID':[\\s\\S]*?'X-API-KEY':[\\s\\S]*?\\}\\);/g,\n 'const farseerClient = new farseer.FarseerClient();',\n );\n\n // Match fClient with credentials\n modified = modified.replace(\n /const fClient = new farseer\\.FarseerClient\\(\\{[\\s\\S]*?basePath:[\\s\\S]*?headers:[\\s\\S]*?'X-TENANT-ID':[\\s\\S]*?'X-API-KEY':[\\s\\S]*?\\}\\);/g,\n 'const fClient = new farseer.FarseerClient();',\n );\n\n return modified;\n}\n\nexport function hasInjectedCredentials(code: string): boolean {\n return INJECTED_CLIENT_PATTERN.test(code);\n}\n\nexport function hasEmptyFarseerClient(code: string): boolean {\n return EMPTY_CLIENT_PATTERNS.some((pattern) => pattern.test(code));\n}\n\n// Process all script files in a directory\nexport function injectCredentialsInDir(srcDir: string, credential: CredentialConfig): number {\n let count = 0;\n const files = getAllFiles(srcDir);\n\n for (const file of files) {\n const filePath = path.join(srcDir, file);\n const content = fs.readFileSync(filePath, 'utf-8');\n const modified = injectCredentials(content, credential);\n\n if (modified !== content) {\n fs.writeFileSync(filePath, modified);\n count++;\n }\n }\n\n return count;\n}\n\nexport function stripCredentialsInDir(srcDir: string): number {\n let count = 0;\n const files = getAllFiles(srcDir);\n\n for (const file of files) {\n const filePath = path.join(srcDir, file);\n const content = fs.readFileSync(filePath, 'utf-8');\n const modified = stripCredentials(content);\n\n if (modified !== content) {\n fs.writeFileSync(filePath, modified);\n count++;\n }\n }\n\n return count;\n}\n\n// Audit log helpers\nexport interface AuditLogEntry {\n operation: 'pulled' | 'pushed' | 'deleted';\n filePath: string;\n uploadTime?: string;\n uploaderEmail?: string;\n uploaderName?: string;\n}\n\n/**\n * Execute async operations with limited concurrency.\n * Processes items in chunks to avoid overwhelming the API.\n *\n * @param items Array of items to process\n * @param fetcher Async function to call for each item\n * @param concurrency Maximum number of concurrent requests (default: 15)\n * @returns Array of results in the same order as input items\n */\nexport async function fetchWithConcurrency<T, R>(\n items: T[],\n fetcher: (item: T, index: number) => Promise<R>,\n concurrency: number = 15,\n): Promise<R[]> {\n const results: R[] = [];\n\n for (let i = 0; i < items.length; i += concurrency) {\n const chunk = items.slice(i, i + concurrency);\n const chunkResults = await Promise.all(chunk.map((item, chunkIndex) => fetcher(item, i + chunkIndex)));\n results.push(...chunkResults);\n }\n\n return results;\n}\n\nexport function appendToAuditLog(tenant: string, entries: AuditLogEntry[]): void {\n if (entries.length === 0) {\n return;\n }\n\n const logPath = getAuditLogPath(tenant);\n const timestamp = new Date().toISOString();\n\n let logContent = '';\n for (const entry of entries) {\n const uploaderInfo = entry.uploaderName\n ? `${entry.uploaderName} (${entry.uploaderEmail})`\n : entry.uploaderEmail || 'Unknown';\n\n const uploadedAt = entry.uploadTime ? new Date(entry.uploadTime).toLocaleString() : 'Unknown';\n\n logContent += `${timestamp} | ${entry.operation} | ${entry.filePath} | Modified by: ${uploaderInfo} | Uploaded: ${uploadedAt}\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QAAQ,MAAM,IAAI,UAAU,CAAC,CAAC;AACrG,YAAQ,KAAK,GAAG,YAAY;AAAA,EAChC;AAEA,SAAO;AACX;AAEO,SAAS,iBAAiB,QAAgB,SAAgC;AAC7E,MAAI,QAAQ,WAAW,GAAG;AACtB;AAAA,EACJ;AAEA,QAAM,UAAU,gBAAgB,MAAM;AACtC,QAAM,aAAY,oBAAI,KAAK,GAAE,YAAY;AAEzC,MAAI,aAAa;AACjB,aAAW,SAAS,SAAS;AACzB,UAAM,eAAe,MAAM,eACrB,GAAG,MAAM,YAAY,KAAK,MAAM,aAAa,MAC7C,MAAM,iBAAiB;AAE7B,UAAM,aAAa,MAAM,aAAa,IAAI,KAAK,MAAM,UAAU,EAAE,eAAe,IAAI;AAEpF,kBAAc,GAAG,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM,QAAQ,mBAAmB,YAAY,gBAAgB,UAAU;AAAA;AAAA,EAChI;AAEA,KAAG,eAAe,SAAS,YAAY,OAAO;AAClD;",
6
6
  "names": []
7
7
  }
@@ -62,7 +62,7 @@ ${e.pattern}
62
62
  const eol = existing.includes("\r\n") ? "\r\n" : "\n";
63
63
  const normalize = (s) => eol === "\n" ? s : s.replace(/\n/g, eol);
64
64
  const needsLeadingNewline = !existing.endsWith("\n");
65
- const appended = (needsLeadingNewline ? eol : "") + eol + "# farseer-cli \u2014 sync state (added by `farseer checkout`)." + eol + missing.map((e) => e.comment ? `${normalize(e.comment)}${eol}${e.pattern}` : e.pattern).join(eol) + eol;
65
+ const appended = (needsLeadingNewline ? eol : "") + eol + "# farseer-cli \u2014 sync state (added by `farseer pull`)." + eol + missing.map((e) => e.comment ? `${normalize(e.comment)}${eol}${e.pattern}` : e.pattern).join(eol) + eol;
66
66
  fs.appendFileSync(gitignorePath, appended, "utf-8");
67
67
  import_logger.logger.dim(`Appended ${missing.length} entr${missing.length === 1 ? "y" : "ies"} to .gitignore`);
68
68
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/workspace.ts"],
4
- "sourcesContent": ["import * as fs from 'fs';\nimport { logger } from './logger';\n\n// Entries that MUST appear in the tenant .gitignore for sync to work\n// correctly across machines. Order matters only for readability of a\n// freshly-created file; for the merge case (existing .gitignore missing\n// entries) we append missing entries in this order.\nconst REQUIRED_GITIGNORE_ENTRIES: { pattern: string; comment?: string }[] = [\n {\n pattern: '.farseer-sync.json',\n comment:\n '# Per-machine sync baseline \u2014 diff state, not user work.\\n' +\n '# Committing this causes spurious \"remote drifted\" reports on other machines.',\n },\n { pattern: '.farseer-audit.log', comment: '# Local audit / crash logs.' },\n { pattern: 'node_modules/', comment: '# Node tooling.' },\n];\n\n/**\n * Ensure the tenant .gitignore contains every per-machine entry. If the\n * file doesn't exist, write a fresh one with comments. If it exists but\n * is missing entries (common: pre-1.6.2 checkouts, or `npm init` created\n * a partial .gitignore listing only `node_modules/`), append the missing\n * patterns idempotently \u2014 match on exact-line so a re-run is a no-op.\n *\n * Called from every workspace-initializing path (checkout, direct pull)\n * so a workspace can never reach a state where `.farseer-sync.json` is\n * unignored. Living in `utils/` rather than `commands/` is what makes\n * that contract hold \u2014 if it lived next to `checkout` it had only one\n * caller and direct `pull` re-introduced the baseline-leak root cause.\n */\nexport function ensureGitignoreEntries(gitignorePath: string): void {\n if (!fs.existsSync(gitignorePath)) {\n const blocks = REQUIRED_GITIGNORE_ENTRIES.map((e) =>\n e.comment ? `${e.comment}\\n${e.pattern}\\n` : `${e.pattern}\\n`,\n );\n fs.writeFileSync(gitignorePath, blocks.join('\\n'), 'utf-8');\n logger.dim(`Created .gitignore`);\n return;\n }\n\n const existing = fs.readFileSync(gitignorePath, 'utf-8');\n const existingLines = new Set(\n existing\n .split('\\n')\n .map((l) => l.trim())\n .filter((l) => l.length > 0 && !l.startsWith('#')),\n );\n\n const missing = REQUIRED_GITIGNORE_ENTRIES.filter((e) => !existingLines.has(e.pattern));\n if (missing.length === 0) return;\n\n // Preserve the file's native line ending so we don't mix CRLF/LF on Windows checkouts.\n const eol = existing.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const normalize = (s: string): string => (eol === '\\n' ? s : s.replace(/\\n/g, eol));\n const needsLeadingNewline = !existing.endsWith('\\n');\n const appended =\n (needsLeadingNewline ? eol : '') +\n eol +\n '# farseer-cli \u2014 sync state (added by `farseer checkout`).' +\n eol +\n missing.map((e) => (e.comment ? `${normalize(e.comment)}${eol}${e.pattern}` : e.pattern)).join(eol) +\n eol;\n fs.appendFileSync(gitignorePath, appended, 'utf-8');\n logger.dim(`Appended ${missing.length} entr${missing.length === 1 ? 'y' : 'ies'} to .gitignore`);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,oBAAuB;AAMvB,MAAM,6BAAsE;AAAA,EACxE;AAAA,IACI,SAAS;AAAA,IACT,SACI;AAAA,EAER;AAAA,EACA,EAAE,SAAS,sBAAsB,SAAS,8BAA8B;AAAA,EACxE,EAAE,SAAS,iBAAiB,SAAS,kBAAkB;AAC3D;AAeO,SAAS,uBAAuB,eAA6B;AAChE,MAAI,CAAC,GAAG,WAAW,aAAa,GAAG;AAC/B,UAAM,SAAS,2BAA2B;AAAA,MAAI,CAAC,MAC3C,EAAE,UAAU,GAAG,EAAE,OAAO;AAAA,EAAK,EAAE,OAAO;AAAA,IAAO,GAAG,EAAE,OAAO;AAAA;AAAA,IAC7D;AACA,OAAG,cAAc,eAAe,OAAO,KAAK,IAAI,GAAG,OAAO;AAC1D,yBAAO,IAAI,oBAAoB;AAC/B;AAAA,EACJ;AAEA,QAAM,WAAW,GAAG,aAAa,eAAe,OAAO;AACvD,QAAM,gBAAgB,IAAI;AAAA,IACtB,SACK,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,CAAC,MAAM,EAAE,SAAS,KAAK,CAAC,EAAE,WAAW,GAAG,CAAC;AAAA,EACzD;AAEA,QAAM,UAAU,2BAA2B,OAAO,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,OAAO,CAAC;AACtF,MAAI,QAAQ,WAAW,EAAG;AAG1B,QAAM,MAAM,SAAS,SAAS,MAAM,IAAI,SAAS;AACjD,QAAM,YAAY,CAAC,MAAuB,QAAQ,OAAO,IAAI,EAAE,QAAQ,OAAO,GAAG;AACjF,QAAM,sBAAsB,CAAC,SAAS,SAAS,IAAI;AACnD,QAAM,YACD,sBAAsB,MAAM,MAC7B,MACA,mEACA,MACA,QAAQ,IAAI,CAAC,MAAO,EAAE,UAAU,GAAG,UAAU,EAAE,OAAO,CAAC,GAAG,GAAG,GAAG,EAAE,OAAO,KAAK,EAAE,OAAQ,EAAE,KAAK,GAAG,IAClG;AACJ,KAAG,eAAe,eAAe,UAAU,OAAO;AAClD,uBAAO,IAAI,YAAY,QAAQ,MAAM,QAAQ,QAAQ,WAAW,IAAI,MAAM,KAAK,gBAAgB;AACnG;",
4
+ "sourcesContent": ["import * as fs from 'fs';\nimport { logger } from './logger';\n\n// Entries that MUST appear in the tenant .gitignore for sync to work\n// correctly across machines. Order matters only for readability of a\n// freshly-created file; for the merge case (existing .gitignore missing\n// entries) we append missing entries in this order.\nconst REQUIRED_GITIGNORE_ENTRIES: { pattern: string; comment?: string }[] = [\n {\n pattern: '.farseer-sync.json',\n comment:\n '# Per-machine sync baseline \u2014 diff state, not user work.\\n' +\n '# Committing this causes spurious \"remote drifted\" reports on other machines.',\n },\n { pattern: '.farseer-audit.log', comment: '# Local audit / crash logs.' },\n { pattern: 'node_modules/', comment: '# Node tooling.' },\n];\n\n/**\n * Ensure the tenant .gitignore contains every per-machine entry. If the\n * file doesn't exist, write a fresh one with comments. If it exists but\n * is missing entries (common: pre-1.6.2 workspaces, or `npm init` created\n * a partial .gitignore listing only `node_modules/`), append the missing\n * patterns idempotently \u2014 match on exact-line so a re-run is a no-op.\n *\n * Called from the workspace-initializing path (`farseer pull`) so a\n * workspace can never reach a state where `.farseer-sync.json` is\n * unignored. Living in `utils/` rather than `commands/` keeps it\n * reusable, so any future init path picks it up too.\n */\nexport function ensureGitignoreEntries(gitignorePath: string): void {\n if (!fs.existsSync(gitignorePath)) {\n const blocks = REQUIRED_GITIGNORE_ENTRIES.map((e) =>\n e.comment ? `${e.comment}\\n${e.pattern}\\n` : `${e.pattern}\\n`,\n );\n fs.writeFileSync(gitignorePath, blocks.join('\\n'), 'utf-8');\n logger.dim(`Created .gitignore`);\n return;\n }\n\n const existing = fs.readFileSync(gitignorePath, 'utf-8');\n const existingLines = new Set(\n existing\n .split('\\n')\n .map((l) => l.trim())\n .filter((l) => l.length > 0 && !l.startsWith('#')),\n );\n\n const missing = REQUIRED_GITIGNORE_ENTRIES.filter((e) => !existingLines.has(e.pattern));\n if (missing.length === 0) return;\n\n // Preserve the file's native line ending so we don't mix CRLF/LF on Windows workspaces.\n const eol = existing.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const normalize = (s: string): string => (eol === '\\n' ? s : s.replace(/\\n/g, eol));\n const needsLeadingNewline = !existing.endsWith('\\n');\n const appended =\n (needsLeadingNewline ? eol : '') +\n eol +\n '# farseer-cli \u2014 sync state (added by `farseer pull`).' +\n eol +\n missing.map((e) => (e.comment ? `${normalize(e.comment)}${eol}${e.pattern}` : e.pattern)).join(eol) +\n eol;\n fs.appendFileSync(gitignorePath, appended, 'utf-8');\n logger.dim(`Appended ${missing.length} entr${missing.length === 1 ? 'y' : 'ies'} to .gitignore`);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,oBAAuB;AAMvB,MAAM,6BAAsE;AAAA,EACxE;AAAA,IACI,SAAS;AAAA,IACT,SACI;AAAA,EAER;AAAA,EACA,EAAE,SAAS,sBAAsB,SAAS,8BAA8B;AAAA,EACxE,EAAE,SAAS,iBAAiB,SAAS,kBAAkB;AAC3D;AAcO,SAAS,uBAAuB,eAA6B;AAChE,MAAI,CAAC,GAAG,WAAW,aAAa,GAAG;AAC/B,UAAM,SAAS,2BAA2B;AAAA,MAAI,CAAC,MAC3C,EAAE,UAAU,GAAG,EAAE,OAAO;AAAA,EAAK,EAAE,OAAO;AAAA,IAAO,GAAG,EAAE,OAAO;AAAA;AAAA,IAC7D;AACA,OAAG,cAAc,eAAe,OAAO,KAAK,IAAI,GAAG,OAAO;AAC1D,yBAAO,IAAI,oBAAoB;AAC/B;AAAA,EACJ;AAEA,QAAM,WAAW,GAAG,aAAa,eAAe,OAAO;AACvD,QAAM,gBAAgB,IAAI;AAAA,IACtB,SACK,MAAM,IAAI,EACV,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,CAAC,MAAM,EAAE,SAAS,KAAK,CAAC,EAAE,WAAW,GAAG,CAAC;AAAA,EACzD;AAEA,QAAM,UAAU,2BAA2B,OAAO,CAAC,MAAM,CAAC,cAAc,IAAI,EAAE,OAAO,CAAC;AACtF,MAAI,QAAQ,WAAW,EAAG;AAG1B,QAAM,MAAM,SAAS,SAAS,MAAM,IAAI,SAAS;AACjD,QAAM,YAAY,CAAC,MAAuB,QAAQ,OAAO,IAAI,EAAE,QAAQ,OAAO,GAAG;AACjF,QAAM,sBAAsB,CAAC,SAAS,SAAS,IAAI;AACnD,QAAM,YACD,sBAAsB,MAAM,MAC7B,MACA,+DACA,MACA,QAAQ,IAAI,CAAC,MAAO,EAAE,UAAU,GAAG,UAAU,EAAE,OAAO,CAAC,GAAG,GAAG,GAAG,EAAE,OAAO,KAAK,EAAE,OAAQ,EAAE,KAAK,GAAG,IAClG;AACJ,KAAG,eAAe,eAAe,UAAU,OAAO;AAClD,uBAAO,IAAI,YAAY,QAAQ,MAAM,QAAQ,QAAQ,WAAW,IAAI,MAAM,KAAK,gBAAgB;AACnG;",
6
6
  "names": []
7
7
  }
@@ -9,12 +9,12 @@
9
9
  **This is the primary method for retrieving variable data from Farseer.** Exports variable values using formula expressions.
10
10
 
11
11
  ```typescript
12
- import { ExportRequestFormatEnum } from 'farseer-client';
12
+ import { ExportFormat } from 'farseer-client';
13
13
  import * as aq from 'arquero';
14
14
 
15
15
  // Export variable data as CSV
16
16
  const blob = await client.export.exportFormula({
17
- format: ExportRequestFormatEnum.Csv,
17
+ format: ExportFormat.Csv,
18
18
  formula: 'sum("Revenue", "Y2024", "Plan")'
19
19
  });
20
20
 
@@ -345,7 +345,7 @@ await client.initTagMap();
345
345
 
346
346
  // Get variable DATA (not metadata!)
347
347
  const blob = await client.export.exportFormula({
348
- format: ExportRequestFormatEnum.Csv,
348
+ format: ExportFormat.Csv,
349
349
  formula: 'sum("Revenue", "Y2024", "Plan")'
350
350
  });
351
351
  const data = aq.fromCSV(await blob.text());
@@ -9,7 +9,7 @@ This document covers best practices for working with Arquero in farseer-client a
9
9
  ```typescript
10
10
  // Good - Using export.exportFormula
11
11
  const blob = await client.export.exportFormula({
12
- format: ExportRequestFormatEnum.Csv,
12
+ format: ExportFormat.Csv,
13
13
  formula: 'sum("Revenue", "Y2024")'
14
14
  });
15
15
  const data = aq.fromCSV(await blob.text());
package/docs/cli-guide.md CHANGED
@@ -16,19 +16,19 @@ farseer login
16
16
  farseer login --api-key
17
17
  ```
18
18
 
19
- ### 2. Checkout a Tenant
19
+ ### 2. Set Up a Tenant
20
20
 
21
21
  ```bash
22
22
  # First time: specify organisation and tenant
23
- farseer checkout myorg mytenant
23
+ farseer pull myorg mytenant
24
24
 
25
- # The CLI remembers the org-tenant mapping, so next time:
26
- farseer checkout mytenant
25
+ # The CLI remembers the org-tenant mapping, so next time just the tenant:
26
+ farseer pull mytenant
27
27
  ```
28
28
 
29
- Checkout sets a default tenant so you don't need to specify it in every command. It also verifies auth and pulls the latest files/apps.
29
+ The first pull verifies auth, confirms the org owns the tenant, scaffolds the workspace, and downloads the latest files/apps. Once the org confirms the tenant, it records the tenant→org mapping (so the tenant alone resolves the org afterwards). There is no global default — select the tenant for a shell with `export FARSEER_TENANT=mytenant` (or pass it per command).
30
30
 
31
- ### 3. Pull Files and Apps
31
+ ### 3. Pull Again Anytime
32
32
 
33
33
  ```bash
34
34
  # Pull workspace files (developer files: .ts, .js, .py, .yml, .yaml, .md, .json non-hidden, non-blocklisted) and app configs
@@ -168,11 +168,16 @@ farseer dimension details "Product" --members 20
168
168
 
169
169
  ## Tenant Resolution
170
170
 
171
- Most commands accept optional `[org] [tenant]` arguments. The CLI resolves tenant in this order:
171
+ Most commands accept optional `[org] [tenant]` arguments. The CLI resolves the tenant in this order — with no machine-global default, so it errors rather than guessing:
172
172
 
173
173
  1. **Explicit args**: `farseer pull myorg mytenant`
174
- 2. **Tenant with saved org mapping**: `farseer pull mytenant` (org remembered from checkout)
175
- 3. **Checked-out tenant**: `farseer pull` (uses current checkout)
174
+ 2. **Explicit tenant with saved org mapping**: `farseer pull mytenant` (org resolved from the mapping or `FARSEER_ORG`)
175
+ 3. **`FARSEER_TENANT` env**: `export FARSEER_TENANT=mytenant` then `farseer pull` (per-shell; add `FARSEER_ORG` if the org differs)
176
+ 4. **None set** → the command errors and tells you to pass a tenant or set `FARSEER_TENANT`
177
+
178
+ The tenant→org mapping in step 2 is recorded only once the organisation has been confirmed to own the tenant, so a mistyped org is never remembered as a tenant's home. Until then, pass both arguments or set `FARSEER_ORG`.
179
+
180
+ Because the target is per-shell (env), different terminals can work on different tenants simultaneously.
176
181
 
177
182
  ## Configuration
178
183
 
@@ -86,7 +86,7 @@ await client.initTagMap(); // Load metadata
86
86
 
87
87
  // Read data
88
88
  const blob = await client.export.exportFormula({
89
- format: farseer.ExportRequestFormatEnum.Csv,
89
+ format: farseer.ExportFormat.Csv,
90
90
  formula: 'sum("Revenue", "Y2025", "Plan")',
91
91
  });
92
92
 
@@ -119,7 +119,7 @@ Commits the import job and processes the data. Returns a report with success/fai
119
119
  ```typescript
120
120
  import * as aq from 'arquero';
121
121
  import { op } from 'arquero';
122
- import { ExportRequestFormatEnum } from 'farseer-client';
122
+ import { ExportFormat } from 'farseer-client';
123
123
 
124
124
  async function exportTransformImport(client: FarseerClient, year: string) {
125
125
  // 1. Calculate on-demand cells first
@@ -130,7 +130,7 @@ async function exportTransformImport(client: FarseerClient, year: string) {
130
130
 
131
131
  // 2. Export variable data
132
132
  const blob = await client.export.exportFormula({
133
- format: ExportRequestFormatEnum.Csv,
133
+ format: ExportFormat.Csv,
134
134
  formula: `sum("Revenue", "Y${year}", "Actual")`
135
135
  });
136
136
 
@@ -267,7 +267,7 @@ import { op } from 'arquero';
267
267
 
268
268
  // 1. Export variable data
269
269
  const blob = await client.export.exportFormula({
270
- format: ExportRequestFormatEnum.Csv,
270
+ format: ExportFormat.Csv,
271
271
  formula: 'sum("Revenue", "Y2024", "Actual")'
272
272
  });
273
273
 
@@ -128,7 +128,7 @@ async function main() {
128
128
 
129
129
  // Export variable data filtered by year and version
130
130
  const blob = await client.export.exportFormula({
131
- format: farseer.ExportRequestFormatEnum.Csv,
131
+ format: farseer.ExportFormat.Csv,
132
132
  formula: `sum("Revenue", "${year}", "${version}")`,
133
133
  });
134
134
 
@@ -6,7 +6,7 @@ The primary way to query data from Farseer is through `export.exportFormula()`:
6
6
 
7
7
  ```typescript
8
8
  const blob = await client.export.exportFormula({
9
- format: ExportRequestFormatEnum.Csv, // or Json, Xlsx
9
+ format: ExportFormat.Csv, // or Json, Xlsx
10
10
  formula: 'sum("Revenue", "Y2025", "Plan")',
11
11
  });
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "farseer-cli",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "description": "CLI tool for syncing Farseer App scripts between local folder and Farseer instances",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,189 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var checkout_exports = {};
30
- __export(checkout_exports, {
31
- ensureGitignoreEntries: () => import_workspace.ensureGitignoreEntries,
32
- registerCheckoutCommand: () => registerCheckoutCommand
33
- });
34
- module.exports = __toCommonJS(checkout_exports);
35
- var import_chalk = __toESM(require("chalk"));
36
- var import_logger = require("../utils/logger");
37
- var import_configService = require("../services/configService");
38
- var import_farseerFactory = require("../services/farseerFactory");
39
- var import_syncService = require("../services/syncService");
40
- var import_appSyncService = require("../services/appSyncService");
41
- var import_helpers = require("../utils/helpers");
42
- var import_cliOptions = require("../utils/cliOptions");
43
- var import_constants = require("../utils/constants");
44
- var import_workspace = require("../utils/workspace");
45
- var fs = __toESM(require("fs"));
46
- var path = __toESM(require("path"));
47
- function registerCheckoutCommand(program) {
48
- program.command("checkout [org] [tenant]").description("Set default tenant for commands (runs auth check and pull)").option("--no-pull", "Skip automatic pull").option("--clear", "Clear current checkout").option("--include-ext <ext>", "Include extra file extension for pull (repeatable)", import_cliOptions.collectValues, []).option("--include-folder <folder>", "Include all files in folder for pull (repeatable)", import_cliOptions.collectValues, []).action(async (first, second, options) => {
49
- if (options.clear) {
50
- (0, import_configService.clearCurrentTenant)();
51
- import_logger.logger.success("Checkout cleared. You now need to specify tenant for each command.");
52
- return;
53
- }
54
- if (!first) {
55
- const current = (0, import_configService.getCurrentCheckout)();
56
- if (current) {
57
- if (current.organisation === current.tenant) {
58
- import_logger.logger.info(`Currently checked out: ${import_chalk.default.bold(current.tenant)}`);
59
- } else {
60
- import_logger.logger.info(
61
- `Currently checked out: ${import_chalk.default.bold(current.tenant)} (org: ${import_chalk.default.bold(current.organisation)})`
62
- );
63
- }
64
- import_logger.logger.dim('Run "farseer checkout <tenant>" to switch tenants.');
65
- import_logger.logger.dim('Run "farseer checkout --clear" to clear checkout.');
66
- } else {
67
- import_logger.logger.info("No tenant currently checked out.");
68
- import_logger.logger.dim('Run "farseer checkout <tenant>" to set a default tenant.');
69
- import_logger.logger.dim('Run "farseer checkout <org> <tenant>" if organisation and tenant differ.');
70
- }
71
- return;
72
- }
73
- const organisation = second ? first : first;
74
- const tenant = second || first;
75
- import_logger.logger.info(`Checking out tenant: ${import_chalk.default.bold(tenant)} (org: ${import_chalk.default.bold(organisation)})...`);
76
- console.log();
77
- import_logger.logger.info("Verifying authentication...");
78
- const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
79
- if (!clientResult) {
80
- (0, import_farseerFactory.showLoginPrompt)(tenant);
81
- process.exit(1);
82
- }
83
- const authLabel = clientResult.authType === "apiKey" ? "API key" : "browser login";
84
- if (clientResult.authType === "jwt") {
85
- import_logger.logger.info("Verifying tenant belongs to organisation...");
86
- let orgInfo;
87
- try {
88
- orgInfo = await clientResult.client.getOrganizationInfo();
89
- } catch (error) {
90
- import_logger.logger.error(
91
- `Could not verify that tenant ${import_chalk.default.bold(tenant)} belongs to organisation ${import_chalk.default.bold(organisation)}.`
92
- );
93
- import_logger.logger.dim("Checkout aborted \u2014 refusing to set a tenant whose organisation cannot be confirmed.");
94
- if (error instanceof Error) {
95
- import_logger.logger.dim(error.message);
96
- }
97
- process.exit(1);
98
- }
99
- const orgTenantNames = orgInfo.tenants.map((t) => t.name);
100
- if (!orgTenantNames.includes(tenant)) {
101
- import_logger.logger.error(
102
- `Tenant ${import_chalk.default.bold(tenant)} is not registered under organisation ${import_chalk.default.bold(organisation)}.`
103
- );
104
- if (orgTenantNames.length > 0) {
105
- import_logger.logger.dim(`Tenants under ${import_chalk.default.bold(organisation)}: ${orgTenantNames.join(", ")}`);
106
- }
107
- import_logger.logger.dim("You likely specified the wrong organisation for this tenant. Checkout aborted.");
108
- process.exit(1);
109
- }
110
- }
111
- import_logger.logger.success(`Authenticated (using ${authLabel})`);
112
- (0, import_configService.setCurrentCheckout)(organisation, tenant);
113
- (0, import_configService.saveTenantOrgMapping)(tenant, organisation);
114
- if (options.pull) {
115
- console.log();
116
- import_logger.logger.info("Pulling latest files and apps...");
117
- const syncService = new import_syncService.SyncService(tenant, clientResult.client);
118
- const tenantDir = (0, import_helpers.getTenantDir)(tenant);
119
- (0, import_helpers.ensureDirectoryExists)(tenantDir);
120
- try {
121
- const packageJsonPath = path.join(tenantDir, "package.json");
122
- if (!fs.existsSync(packageJsonPath)) {
123
- createDefaultPackageJson(tenant, packageJsonPath);
124
- }
125
- const gitignorePath = path.join(tenantDir, ".gitignore");
126
- (0, import_workspace.ensureGitignoreEntries)(gitignorePath);
127
- const includeExtensions = (0, import_cliOptions.normalizeExtensions)(options.includeExt);
128
- const includeFolders = options.includeFolder;
129
- const result = await syncService.pull({
130
- all: false,
131
- includeExtensions: includeExtensions.length > 0 ? includeExtensions : void 0,
132
- includeFolders: includeFolders.length > 0 ? includeFolders : void 0
133
- });
134
- import_logger.logger.dim(
135
- `Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`
136
- );
137
- const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
138
- const appResult = await appSyncService.pull();
139
- import_logger.logger.dim(
140
- `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`
141
- );
142
- import_logger.logger.success("Pull complete!");
143
- } catch (error) {
144
- import_logger.logger.warning("Pull failed, but checkout is complete.");
145
- if (error instanceof Error) {
146
- import_logger.logger.dim(error.message);
147
- }
148
- }
149
- }
150
- console.log();
151
- import_logger.logger.success(`Tenant ${import_chalk.default.bold(tenant)} is now checked out.`);
152
- import_logger.logger.dim("You can now run commands without specifying the tenant:");
153
- import_logger.logger.dim(" farseer status");
154
- import_logger.logger.dim(" farseer model --variables");
155
- import_logger.logger.dim(" farseer apps");
156
- import_logger.logger.dim(" farseer push");
157
- });
158
- }
159
- function createDefaultPackageJson(tenant, packageJsonPath) {
160
- const packageJson = {
161
- name: `farseer-${tenant}`,
162
- version: "1.0.0",
163
- description: `Farseer scripts for ${tenant}`,
164
- type: "module",
165
- scripts: {
166
- build: "tsc"
167
- },
168
- dependencies: {
169
- "farseer-client": import_constants.FARSEER_CLIENT_URL,
170
- arquero: "^7.0.1",
171
- xlsx: "^0.18.5",
172
- xmldom: "^0.6.0"
173
- },
174
- devDependencies: {
175
- "@types/node": "^22.5.0",
176
- "@types/xmldom": "^0.1.34",
177
- "ts-node": "^10.9.2",
178
- typescript: "^5.5.4"
179
- }
180
- };
181
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
182
- import_logger.logger.dim(`Created package.json for ${tenant}`);
183
- }
184
- // Annotate the CommonJS export names for ESM import in node:
185
- 0 && (module.exports = {
186
- ensureGitignoreEntries,
187
- registerCheckoutCommand
188
- });
189
- //# sourceMappingURL=checkout.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/commands/checkout.ts"],
4
- "sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport {\n getCurrentCheckout,\n setCurrentCheckout,\n clearCurrentTenant,\n saveTenantOrgMapping,\n} from '../services/configService';\nimport { getFarseerClientWithFallback, showLoginPrompt } from '../services/farseerFactory';\nimport type { OrganizationInfo } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { getTenantDir, ensureDirectoryExists } from '../utils/helpers';\nimport { collectValues, normalizeExtensions } from '../utils/cliOptions';\nimport { FARSEER_CLIENT_URL } from '../utils/constants';\nimport { ensureGitignoreEntries } from '../utils/workspace';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\n// Re-export for tests that import from the original location and for\n// any downstream consumers that already pinned to this path.\nexport { ensureGitignoreEntries };\n\nexport function registerCheckoutCommand(program: Command): void {\n program\n .command('checkout [org] [tenant]')\n .description('Set default tenant for commands (runs auth check and pull)')\n .option('--no-pull', 'Skip automatic pull')\n .option('--clear', 'Clear current checkout')\n .option('--include-ext <ext>', 'Include extra file extension for pull (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder for pull (repeatable)', collectValues, [])\n .action(async (first, second, options) => {\n // Handle --clear flag\n if (options.clear) {\n clearCurrentTenant();\n logger.success('Checkout cleared. You now need to specify tenant for each command.');\n return;\n }\n\n // If no arguments specified, show current checkout status\n if (!first) {\n const current = getCurrentCheckout();\n if (current) {\n if (current.organisation === current.tenant) {\n logger.info(`Currently checked out: ${chalk.bold(current.tenant)}`);\n } else {\n logger.info(\n `Currently checked out: ${chalk.bold(current.tenant)} (org: ${chalk.bold(current.organisation)})`,\n );\n }\n logger.dim('Run \"farseer checkout <tenant>\" to switch tenants.');\n logger.dim('Run \"farseer checkout --clear\" to clear checkout.');\n } else {\n logger.info('No tenant currently checked out.');\n logger.dim('Run \"farseer checkout <tenant>\" to set a default tenant.');\n logger.dim('Run \"farseer checkout <org> <tenant>\" if organisation and tenant differ.');\n }\n return;\n }\n\n // Determine organisation and tenant\n // If two arguments: first=organisation, second=tenant\n // If one argument: organisation=tenant=first\n const organisation = second ? first : first;\n const tenant = second || first;\n\n logger.info(`Checking out tenant: ${chalk.bold(tenant)} (org: ${chalk.bold(organisation)})...`);\n console.log();\n\n // Step 1: Verify authentication\n logger.info('Verifying authentication...');\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const authLabel = clientResult.authType === 'apiKey' ? 'API key' : 'browser login';\n\n // Step 2: Confirm the org+tenant pair via /organization \u2014 JWT (browser\n // login) path only. That's the only path where the typed <org> routes\n // the request; the API-key path ignores <org> and resolves host+tenant\n // from the stored credential, and /organization is login-token-shaped\n // (filters by the JWT's roles), so the check is both unnecessary and\n // unanswerable there.\n if (clientResult.authType === 'jwt') {\n logger.info('Verifying tenant belongs to organisation...');\n let orgInfo: OrganizationInfo;\n try {\n orgInfo = await clientResult.client.getOrganizationInfo();\n } catch (error) {\n logger.error(\n `Could not verify that tenant ${chalk.bold(tenant)} belongs to organisation ${chalk.bold(organisation)}.`,\n );\n logger.dim('Checkout aborted \u2014 refusing to set a tenant whose organisation cannot be confirmed.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n\n const orgTenantNames = orgInfo.tenants.map((t) => t.name);\n if (!orgTenantNames.includes(tenant)) {\n logger.error(\n `Tenant ${chalk.bold(tenant)} is not registered under organisation ${chalk.bold(organisation)}.`,\n );\n if (orgTenantNames.length > 0) {\n logger.dim(`Tenants under ${chalk.bold(organisation)}: ${orgTenantNames.join(', ')}`);\n }\n logger.dim('You likely specified the wrong organisation for this tenant. Checkout aborted.');\n process.exit(1);\n }\n }\n\n // Auth and \u2014 on the JWT path \u2014 the org+tenant pairing are now both\n // confirmed. Emit the success only here so a mismatch aborts above\n // without first flashing a misleading \"Authenticated\" check.\n logger.success(`Authenticated (using ${authLabel})`);\n\n // Step 3: Set as current checkout and save org-tenant mapping\n setCurrentCheckout(organisation, tenant);\n saveTenantOrgMapping(tenant, organisation);\n\n // Step 4: Auto-pull (unless --no-pull)\n if (options.pull) {\n console.log();\n logger.info('Pulling latest files and apps...');\n\n const syncService = new SyncService(tenant, clientResult.client);\n const tenantDir = getTenantDir(tenant);\n ensureDirectoryExists(tenantDir);\n\n try {\n // Ensure package.json exists\n const packageJsonPath = path.join(tenantDir, 'package.json');\n if (!fs.existsSync(packageJsonPath)) {\n createDefaultPackageJson(tenant, packageJsonPath);\n }\n\n // Ensure .gitignore exists AND contains the per-machine\n // sync entries. Idempotent on the lines, not on the file\n // \u2014 pre-1.6.2 checkouts and `npm init`-seeded workspaces\n // already have a partial .gitignore (node_modules/) but\n // are missing `.farseer-sync.json`; just checking for\n // file existence leaves those workspaces leaking\n // baseline state into git.\n const gitignorePath = path.join(tenantDir, '.gitignore');\n ensureGitignoreEntries(gitignorePath);\n\n // Pull files (scripts + includes by default)\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n const result = await syncService.pull({\n all: false,\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n });\n logger.dim(\n `Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`,\n );\n\n // Pull apps\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n const appResult = await appSyncService.pull();\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n\n logger.success('Pull complete!');\n } catch (error) {\n logger.warning('Pull failed, but checkout is complete.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n }\n }\n\n // Final message\n console.log();\n logger.success(`Tenant ${chalk.bold(tenant)} is now checked out.`);\n logger.dim('You can now run commands without specifying the tenant:');\n logger.dim(' farseer status');\n logger.dim(' farseer model --variables');\n logger.dim(' farseer apps');\n logger.dim(' farseer push');\n });\n}\n\nfunction createDefaultPackageJson(tenant: string, packageJsonPath: string): void {\n const packageJson = {\n name: `farseer-${tenant}`,\n version: '1.0.0',\n description: `Farseer scripts for ${tenant}`,\n type: 'module',\n scripts: {\n build: 'tsc',\n },\n dependencies: {\n 'farseer-client': FARSEER_CLIENT_URL,\n arquero: '^7.0.1',\n xlsx: '^0.18.5',\n xmldom: '^0.6.0',\n },\n devDependencies: {\n '@types/node': '^22.5.0',\n '@types/xmldom': '^0.1.34',\n 'ts-node': '^10.9.2',\n typescript: '^5.5.4',\n },\n };\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');\n logger.dim(`Created package.json for ${tenant}`);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,2BAKO;AACP,4BAA8D;AAE9D,yBAA4B;AAC5B,4BAA+B;AAC/B,qBAAoD;AACpD,wBAAmD;AACnD,uBAAmC;AACnC,uBAAuC;AACvC,SAAoB;AACpB,WAAsB;AAMf,SAAS,wBAAwB,SAAwB;AAC5D,UACK,QAAQ,yBAAyB,EACjC,YAAY,4DAA4D,EACxE,OAAO,aAAa,qBAAqB,EACzC,OAAO,WAAW,wBAAwB,EAC1C,OAAO,uBAAuB,sDAAsD,iCAAe,CAAC,CAAC,EACrG,OAAO,6BAA6B,qDAAqD,iCAAe,CAAC,CAAC,EAC1G,OAAO,OAAO,OAAO,QAAQ,YAAY;AAEtC,QAAI,QAAQ,OAAO;AACf,mDAAmB;AACnB,2BAAO,QAAQ,oEAAoE;AACnF;AAAA,IACJ;AAGA,QAAI,CAAC,OAAO;AACR,YAAM,cAAU,yCAAmB;AACnC,UAAI,SAAS;AACT,YAAI,QAAQ,iBAAiB,QAAQ,QAAQ;AACzC,+BAAO,KAAK,0BAA0B,aAAAA,QAAM,KAAK,QAAQ,MAAM,CAAC,EAAE;AAAA,QACtE,OAAO;AACH,+BAAO;AAAA,YACH,0BAA0B,aAAAA,QAAM,KAAK,QAAQ,MAAM,CAAC,UAAU,aAAAA,QAAM,KAAK,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