farseer-cli 1.7.3 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/commands/checkout.js +5 -0
- package/dist/commands/checkout.js.map +2 -2
- package/dist/commands/config.js +12 -6
- package/dist/commands/config.js.map +2 -2
- package/dist/commands/pull.js +7 -2
- package/dist/commands/pull.js.map +2 -2
- package/dist/commands/push.js +1 -1
- package/dist/commands/push.js.map +2 -2
- package/dist/commands/refresh.js +128 -0
- package/dist/commands/refresh.js.map +7 -0
- package/dist/commands/status.js +4 -1
- package/dist/commands/status.js.map +2 -2
- package/dist/index.js +14 -2
- package/dist/index.js.map +2 -2
- package/dist/mcp/tools/syncTools.js +59 -36
- package/dist/mcp/tools/syncTools.js.map +2 -2
- package/dist/services/farseerFactory.js +15 -0
- package/dist/services/farseerFactory.js.map +2 -2
- package/dist/services/syncService.js +47 -2
- package/dist/services/syncService.js.map +2 -2
- package/dist/utils/cliOptions.js +7 -2
- package/dist/utils/cliOptions.js.map +2 -2
- package/dist/utils/fileValidation.js +3 -2
- package/dist/utils/fileValidation.js.map +2 -2
- package/dist/utils/helpers.js +1 -1
- package/dist/utils/helpers.js.map +2 -2
- package/dist/utils/workspace.js +73 -0
- package/dist/utils/workspace.js.map +7 -0
- package/docs/cli-guide.md +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/push.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport { fileLogger } from '../utils/fileLogger';\nimport { getFarseerClientWithFallback, showLoginPrompt, ensureFreshToken } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport {\n getTenantFilesDir,\n resolveTenantWithOrgMapping,\n safeResolveWithinBase,\n validateOnlyFilePaths,\n displayLocalPath,\n} from '../utils/helpers';\nimport { formatClientError } from '../utils/errorFormatter';\nimport { ValidationFailure, partitionForUpload } from '../utils/fileValidation';\nimport { collectValues, normalizeExtensions } from '../utils/cliOptions';\nimport { reportIgnoredLocal } from '../utils/syncReporting';\nimport type { SyncStatus } from '../services/syncService';\nimport * as fs from 'fs';\n\n/**\n * Push semantics (in plain English, since this is the easiest part of the\n * CLI to misunderstand):\n *\n * farseer push\n * 1. Pre-flight: refuse local files that the backend will reject\n * (extension whitelist, name length, empty body). Print them and\n * exit non-zero so the user fixes them before we touch the network.\n * 2. Compare local vs remote (no remote download \u2014 we trust the\n * recorded sync baseline). If remote diverged from baseline,\n * refuse and ask the user to pull first.\n * 3. Show a diff (added / modified / deleted).\n * 4. Confirm.\n * 5. Upload modified files. Re-check each one against current remote\n * right before overwrite to avoid clobbering a concurrent edit.\n *\n * farseer push --force\n * Same as above, but:\n * \u2022 Skip step 2 (allow pushing over remote drift).\n * \u2022 Make remote mirror local: also delete any remote files that\n * have no local counterpart (not just ones you previously pulled).\n * Because --force is destructive, we always show the full plan\n * (including deletions of remote-only files) and require an explicit\n * \"yes\". `-y` won't bypass --force confirmation; you must answer the\n * prompt.\n */\nexport function registerPushCommand(program: Command): void {\n program\n .command('push [org] [tenant]')\n .description(\n 'Push local files to Farseer instance\\n\\nUsage: push <org> <tenant> OR push <tenant> (if org is known)',\n )\n .option(\n '--force',\n 'Force-mirror remote to local: overwrite remote drift AND delete remote files with no local counterpart (always asks for confirmation)',\n )\n .option('-y, --yes', 'Skip confirmation prompt for non-destructive pushes (ignored under --force)')\n .option(\n '--shallow',\n 'Skip the remote-content hash check in the pre-flight (faster on big tenants; trusts the last-pull baseline). Ignored under --force, where deep is required for correct mirror semantics.',\n )\n // Accept `--deep` as a no-op alias so 1.6.1-era scripts keep\n // working \u2014 deep is now the default; see status.ts for context.\n .option('--deep', '(Deprecated; now the default) Force the deep remote-content hash pre-flight')\n .option('--include-ext <ext>', 'Include extra file extension (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder (repeatable)', collectValues, [])\n .option(\n '--only <path>',\n 'Only push the listed file(s) (repeatable, paths relative to tenant files dir, e.g. Scripts/foo.ts). Other local edits are not touched; the drift check still fires on these paths if remote has changed them.',\n collectValues,\n [],\n )\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const filesDir = getTenantFilesDir(tenant);\n\n if (!fs.existsSync(filesDir)) {\n logger.error(`Local folder not found: ${displayLocalPath(filesDir)}`);\n logger.dim('Run \"farseer pull <tenant>\" first to initialize the folder.');\n process.exit(1);\n }\n\n const syncService = new SyncService(tenant, clientResult.client);\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n const onlyFiles = (options.only as string[]).map((p) => p.replace(/^\\/+/, ''));\n const syncFilterOptions = {\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n onlyFiles: onlyFiles.length > 0 ? onlyFiles : undefined,\n };\n\n // --only is a surgical-push escape hatch. Skip the apps path\n // entirely (which has its own drift logic that doesn't know\n // about file whitelists) and skip the remote-drift check \u2014\n // the user has narrowed the blast radius to a known set of\n // files, that's the whole point. Without this short-circuit\n // both the drift gate and apps push could touch things\n // outside the requested scope, defeating --only.\n const onlyMode = onlyFiles.length > 0;\n\n // Pre-flight: every --only path must resolve to a real file\n // under filesDir. Without this check, a typo (wrong case,\n // double slash, deleted file) silently produces \"Nothing to\n // push. Everything is in sync.\" \u2014 same exit code as a real\n // no-op, and the user assumes the push went through.\n // Traversal paths (`--only ../x`) join the same missing list\n // so the user gets one consolidated error.\n if (onlyMode) {\n const { missing } = validateOnlyFilePaths(filesDir, onlyFiles);\n if (missing.length > 0) {\n logger.error(`--only path(s) not found under ${filesDir}:`);\n for (const m of missing) console.log(chalk.red(` ${m}`));\n logger.dim('Paths are relative to the tenant files dir and case-sensitive.');\n process.exit(1);\n }\n }\n\n // Build a single status snapshot \u2014 same buckets the\n // `farseer status` command uses, so the user sees the same\n // categorisation in both places.\n //\n // Run a DEEP pre-flight by default. Shallow status can't see\n // remote-side content drift (it trusts our recorded baseline),\n // so without it we'd silently overwrite remote edits that\n // landed since the last pull. `--shallow` opts out for users\n // who explicitly want the faster path on large tenants.\n //\n // --force ALWAYS implies deep, overriding --shallow. Mirror\n // mode means \"make remote = local\" \u2014 we need to know the\n // current remote content to decide what to overwrite. A\n // shallow status would miss remote-side content drift and\n // silently no-op when local matches the baseline. Force +\n // shallow is a contradiction, so deep wins.\n const deep = !!options.force || !options.shallow;\n const status = await syncService.getStatus({\n ...syncFilterOptions,\n deep,\n });\n\n // Drift gate: non-force push must not silently overwrite\n // remote-side drift. Block here, after deep status has run,\n // so the user sees the actual remote drift paths and can\n // choose between pull (merge remote) or --force (mirror,\n // overwrite remote). All three remote-side buckets count as\n // drift \u2014 adds, deletes, and content edits.\n //\n // Suppressed under --only: that's an explicit narrow-scope\n // push and only fires the block if a remote-drift path\n // overlaps the requested set.\n if (!options.force) {\n const conflictingAdded = onlyMode\n ? status.addedRemotely.filter((p) => onlyFiles.includes(p))\n : status.addedRemotely;\n const conflictingDeleted = onlyMode\n ? status.deletedRemotely.filter((p) => onlyFiles.includes(p))\n : status.deletedRemotely;\n const conflictingModified = onlyMode\n ? status.modifiedRemotely.filter((p) => onlyFiles.includes(p))\n : status.modifiedRemotely;\n const totalConflicts = conflictingAdded.length + conflictingDeleted.length + conflictingModified.length;\n if (totalConflicts > 0) {\n logger.error(`Remote has changes for ${totalConflicts} file(s) since last pull:`);\n if (conflictingAdded.length > 0) {\n console.log(chalk.cyan(' New on remote (need to pull):'));\n for (const f of conflictingAdded) console.log(chalk.cyan(` + ${f}`));\n }\n if (conflictingDeleted.length > 0) {\n console.log(chalk.red(' Removed on remote (need to pull to clean local):'));\n for (const f of conflictingDeleted) console.log(chalk.red(` - ${f}`));\n }\n if (conflictingModified.length > 0) {\n console.log(chalk.yellow(' Modified on remote (need to pull to merge):'));\n for (const f of conflictingModified) console.log(chalk.yellow(` M ${f}`));\n }\n // Echo back the same scope flags the user passed so the\n // suggested pull command actually fetches the files\n // causing the drift. Without this, `farseer pull` runs\n // in default scope and the drift remains blocking.\n const scopeFlags: string[] = [];\n for (const ext of options.includeExt as string[]) scopeFlags.push(`--include-ext ${ext}`);\n for (const folder of options.includeFolder as string[])\n scopeFlags.push(`--include-folder \"${folder}\"`);\n const pullCmd = ['farseer pull', tenant, ...scopeFlags].filter(Boolean).join(' ');\n logger.dim(`Run \\`${pullCmd}\\` to merge remote changes, then push.`);\n logger.dim('Or use --force to mirror (overwrite remote with local).');\n process.exit(1);\n }\n }\n\n const plan = buildPushPlan(status, { force: !!options.force });\n const { filesToUpload, filesToDelete, remoteOnlyFiles, filesToRecreate, filesToOverwrite } = plan;\n\n // Apps are independent of the file pre-flight gate.\n // In --only mode we deliberately don't touch apps at all\n // (the user asked for a file-scoped push). Stub the app\n // status to \"nothing to do\" so downstream code can treat\n // the two modes uniformly.\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n const appStatus = onlyMode\n ? { newLocal: [], newRemote: [], modified: [], synced: [] }\n : await appSyncService.getStatus();\n\n const hasConflicts = status.conflicts.length > 0;\n const hasFileChanges =\n filesToUpload.length > 0 || filesToDelete.length > 0 || remoteOnlyFiles.length > 0 || hasConflicts;\n const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.modified.length > 0;\n\n if (!hasFileChanges && !hasAppChanges) {\n // Print the out-of-scope warning BEFORE the success line\n // so the \"within current scope\" qualifier reads as a\n // follow-up to the count the user just saw, not a\n // contradiction of a bare \"Nothing to push\" message.\n reportIgnoredLocal(status.ignoredLocal, status.ignoredLocalTotal);\n if (status.ignoredLocalTotal > 0) {\n logger.success('Everything is in sync within current scope.');\n logger.dim(\n `(${status.ignoredLocalTotal} file(s) outside scope were not compared \u2014 see warning above for details.)`,\n );\n } else {\n logger.success('Nothing to push. Everything is in sync.');\n }\n return;\n }\n\n console.log();\n logger.header(options.force ? 'Mirror plan (--force):' : 'Changes to push:');\n\n if (status.addedLocally.length > 0) {\n for (const file of status.addedLocally) console.log(chalk.green(` + ${file}`));\n }\n if (status.modifiedLocally.length > 0) {\n for (const file of status.modifiedLocally) console.log(chalk.yellow(` M ${file}`));\n }\n if (filesToDelete.length > 0) {\n for (const file of filesToDelete) console.log(chalk.red(` - ${file}`));\n }\n if (remoteOnlyFiles.length > 0) {\n console.log(chalk.red.bold('Remote-only files that will be DELETED on remote:'));\n for (const file of remoteOnlyFiles) console.log(chalk.red(` - ${file} (remote only)`));\n }\n if (filesToRecreate.length > 0) {\n console.log(chalk.green.bold('Files deleted on remote that will be RECREATED:'));\n for (const file of filesToRecreate) console.log(chalk.green(` + ${file} (re-uploading local copy)`));\n }\n if (filesToOverwrite.length > 0) {\n console.log(chalk.yellow.bold('Files where remote drifted \u2014 local will OVERWRITE:'));\n for (const file of filesToOverwrite)\n console.log(chalk.yellow(` M ${file} (remote content drift; local wins)`));\n }\n\n // Surface scope-skipped files BEFORE the confirmation prompt so\n // the user never confirms a push thinking it covers everything in\n // the workspace when in fact .md / .json / .py etc. were silently\n // excluded by the default whitelist.\n reportIgnoredLocal(status.ignoredLocal, status.ignoredLocalTotal);\n\n // Conflicts surface BEFORE the confirmation prompt so the user\n // never confirms a plan that secretly contains skipped files.\n // Without --force these will be skipped (and the user can re-run\n // with `farseer pull` to resolve); under --force the upload step\n // will overwrite local\u2192remote anyway, but the user still deserves\n // to see what's affected.\n if (hasConflicts) {\n const headerText = options.force\n ? 'Conflicts (will be force-overwritten on remote):'\n : 'Conflicts (will be SKIPPED \u2014 pull first to resolve):';\n console.log(chalk.red.bold(headerText));\n for (const conflict of status.conflicts) {\n console.log(chalk.red(` ! ${conflict.filePath}`));\n console.log(chalk.dim(` ${conflict.description}`));\n }\n }\n\n if (appStatus.newLocal.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appStatus.newLocal) console.log(chalk.green(` + ${app}`));\n }\n if (appStatus.modified.length > 0) {\n console.log(chalk.yellow('Modified apps:'));\n for (const app of appStatus.modified) console.log(chalk.yellow(` ~ ${app}`));\n }\n\n // Pre-flight in the preview, BEFORE the confirm prompt. README\n // promises rejections show up in the plan; running pre-flight\n // only inside syncService.push() pushed them to AFTER the user\n // had already said \"yes\". Cost: every upload candidate is read\n // twice (preview + push). For big tenants this is measurable\n // but predictability is the user-visible contract \u2014 they'd\n // rather know about a 256-char-name reject before pressing\n // ENTER on a 200-file mirror push.\n const previewCandidates = [...filesToUpload, ...filesToRecreate, ...filesToOverwrite];\n const previewRejections = previewPushPlan(filesDir, previewCandidates);\n if (previewRejections.length > 0) {\n console.log();\n console.log(chalk.red.bold('Files that pre-flight will reject (skipped from upload):'));\n for (const r of previewRejections) {\n console.log(chalk.red(` \u2717 ${r.filePath}`));\n console.log(chalk.dim(` ${r.detail}`));\n if (r.hint) console.log(chalk.dim(` ${r.hint}`));\n }\n }\n\n console.log();\n\n // filesToUpload already includes filesToRecreate under --force,\n // so don't double-count.\n const totalChanges =\n filesToUpload.length +\n filesToDelete.length +\n remoteOnlyFiles.length +\n appStatus.newLocal.length +\n appStatus.modified.length;\n\n // Step 3: Confirm. --force always confirms (cannot be skipped\n // with -y) because mirror mode includes destructive deletes.\n //\n // Spell out every bucket in the prompt itself, not just the\n // total. A 200-overwrite + 2-delete mirror with the old\n // \"Mirror N change(s) (including K remote deletion(s))\"\n // headline read like \"small change\" \u2014 the eye-catching K\n // hid the bigger blast radius. The plan above the prompt is\n // already explicit; the prompt-line should match it.\n const confirmMessage = options.force\n ? `Mirror to ${tenant}: ${remoteOnlyFiles.length} remote deletion(s), ` +\n `${filesToOverwrite.length} drift overwrite(s), ${filesToRecreate.length} recreation(s), ` +\n `${status.addedLocally.length} new upload(s), ${status.modifiedLocally.length} local edit(s), ` +\n `${filesToDelete.length} local-rm deletion(s). This is destructive.`\n : `Push ${totalChanges} change(s) to ${tenant}?`;\n\n if (options.force || !options.yes) {\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: confirmMessage,\n default: !options.force,\n },\n ]);\n\n if (!confirm.proceed) {\n logger.info('Push cancelled.');\n return;\n }\n }\n\n // Ensure token is fresh before push operations (may have expired during user input)\n await ensureFreshToken(clientResult.client);\n\n try {\n // Mirror the service's actual return type so every field is\n // present and non-optional. The earlier hand-rolled inline\n // type marked conflicts/rejected/failed as optional, which\n // forced `?.length ?? 0` defensiveness at every read site\n // even though the service always returns those arrays.\n let result: Awaited<ReturnType<SyncService['push']>> = {\n uploaded: [],\n updated: [],\n deleted: [],\n unchanged: [],\n conflicts: [],\n rejected: [],\n failed: [],\n ignoredLocal: [],\n ignoredLocalTotal: 0,\n ignoredLocalTotalByReason: { unsupportedExtension: 0, blocklistedFolder: 0 },\n };\n\n if (hasFileChanges) {\n logger.info(`Pushing files to ${tenant}...`);\n // Pass syncFilterOptions so mirror-mode deletes honour\n // --include-folder / --include-ext scope. Without this\n // the preview's \"remote-only DELETE\" line and the actual\n // mirror step diverged for non-default extensions.\n //\n // Hand `status.remoteHashes` (populated when deep status\n // ran above, i.e. under --force) into service.push so\n // the candidate-content fetch skips files we already\n // have hashes for. Without it, --force re-downloaded\n // every remote file a second time inside push().\n result = await syncService.push({\n force: options.force,\n mirror: options.force,\n ...syncFilterOptions,\n precomputedRemoteHashes: status.remoteHashes,\n });\n\n console.log();\n\n if (result.rejected.length > 0) {\n console.log(chalk.red.bold('Files skipped (backend would reject):'));\n renderRejections(result.rejected);\n }\n\n if (result.conflicts.length > 0) {\n console.log(chalk.red.bold(`${result.conflicts.length} conflict(s) detected:`));\n for (const conflict of result.conflicts) {\n console.log(chalk.red(` ! ${conflict.filePath}`));\n console.log(chalk.dim(` ${conflict.description}`));\n }\n console.log();\n logger.dim(`Resolve conflicts by pulling first: farseer pull ${tenant}`);\n logger.dim('Or use --force to push anyway (overwrites remote and mirrors deletions).');\n console.log();\n }\n\n if (result.uploaded.length > 0) {\n console.log(chalk.green('Uploaded files (new):'));\n for (const file of result.uploaded) console.log(chalk.green(` + ${file}`));\n console.log();\n }\n\n if (result.updated.length > 0) {\n console.log(chalk.yellow('Updated files:'));\n for (const file of result.updated) console.log(chalk.yellow(` M ${file}`));\n console.log();\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted files:'));\n for (const file of result.deleted) console.log(chalk.red(` - ${file}`));\n console.log();\n }\n\n if (result.failed.length > 0) {\n // Per-file errors that the backend rejected mid-flight\n // (5xx, validation we couldn't pre-flight, etc.).\n // Distinct from `rejected` (pre-flight) \u2014 these\n // already attempted the call. State for files that\n // succeeded before the failure has been saved.\n console.log(chalk.red.bold(`${result.failed.length} file(s) failed during push:`));\n for (const failure of result.failed) {\n console.log(chalk.red(` ! ${failure.filePath} (${failure.operation})`));\n console.log(chalk.dim(` ${failure.reason}`));\n }\n console.log();\n }\n }\n\n let appResult = {\n created: [] as string[],\n updated: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n };\n\n if (hasAppChanges) {\n logger.info(`Pushing apps to ${tenant}...`);\n appResult = await appSyncService.push();\n\n if (appResult.created.length > 0) {\n console.log(chalk.green('Created apps:'));\n for (const app of appResult.created) console.log(chalk.green(` + ${app}`));\n console.log();\n }\n\n if (appResult.updated.length > 0) {\n console.log(chalk.yellow('Updated apps:'));\n for (const app of appResult.updated) console.log(chalk.yellow(` ~ ${app}`));\n console.log();\n }\n\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps:'));\n for (const app of appResult.deleted) console.log(chalk.red(` - ${app}`));\n console.log();\n }\n }\n\n console.log();\n const fileSideEffects = result.uploaded.length + result.updated.length + result.deleted.length;\n const appSideEffects = appResult.created.length + appResult.updated.length + appResult.deleted.length;\n const conflictCount = result.conflicts.length;\n const rejectedCount = result.rejected.length;\n const failedCount = result.failed.length;\n if (fileSideEffects + appSideEffects === 0 && (conflictCount > 0 || rejectedCount > 0)) {\n // Nothing was actually pushed (every candidate hit a\n // conflict or pre-flight rejection). Surface as a\n // warning + EXIT 1 so CI and shell scripts can branch\n // \u2014 the bare \"Push complete!\" line was misleading.\n if (rejectedCount > 0 && conflictCount === 0) {\n logger.warning(`Push did nothing \u2014 ${rejectedCount} file(s) rejected by pre-flight.`);\n logger.dim('Fix the issues listed above and re-run `farseer push`.');\n } else if (conflictCount > 0 && rejectedCount === 0) {\n logger.warning(`Push did nothing \u2014 ${conflictCount} conflict(s) blocked the upload.`);\n logger.dim(`Resolve via 'farseer pull ${tenant}' or rerun with --force.`);\n } else {\n logger.warning(\n `Push did nothing \u2014 ${rejectedCount} file(s) rejected and ${conflictCount} conflict(s) blocked the upload.`,\n );\n }\n process.exit(1);\n }\n logger.success('Push complete!');\n logger.dim(`Files: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}`);\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}`,\n );\n if (rejectedCount > 0 || failedCount > 0) {\n // Partial success: at least some side effects landed\n // but some candidates were skipped (rejected pre-flight)\n // or failed mid-push (network/backend error). EXIT 1\n // (not 2 \u2014 the previous split was undocumented and most\n // CI scripts treat any non-zero as failure anyway).\n if (rejectedCount > 0 && failedCount > 0) {\n logger.warning(\n `${rejectedCount} file(s) skipped pre-flight, ${failedCount} failed mid-push \u2014 see above and rerun.`,\n );\n } else if (rejectedCount > 0) {\n logger.warning(`${rejectedCount} file(s) skipped (see above) \u2014 fix and rerun.`);\n } else {\n logger.warning(`${failedCount} file(s) failed during push (see above) \u2014 rerun to retry.`);\n }\n process.exit(1);\n }\n } catch (error) {\n fileLogger.error('push', error, { tenant, organisation });\n logger.error('Push failed.');\n logger.error(await formatClientError(error));\n const logPath = fileLogger.getLogPath();\n if (logPath) {\n logger.dim(`Debug log: ${logPath}`);\n }\n process.exit(1);\n }\n });\n}\n\n/**\n * Translate a SyncStatus + force flag into the buckets the push command\n * actually acts on. Pure: takes a status, returns lists. Lives at the\n * top level (not inside the action closure) so it can be exported and\n * unit-tested directly \u2014 the status engine has its own coverage, and\n * before this extraction the bucket logic was inline in the action and\n * only reachable via mocking commander + inquirer + fs.\n *\n * Default push: upload the added/modified locally, delete the locally-\n * removed. Remote-side activity is not in scope (drift check refuses\n * before we reach this).\n *\n * Force push (mirror): also re-upload files the remote has lost\n * (deletedRemotely \u2192 recreate) and files the remote has drifted away\n * from (modifiedRemotely \u2192 local wins, overwrite). Plus mirror-deletes\n * remote files that have no local counterpart (addedRemotely).\n */\nexport function buildPushPlan(\n status: SyncStatus,\n options: { force: boolean },\n): {\n filesToUpload: string[];\n filesToDelete: string[];\n remoteOnlyFiles: string[];\n filesToRecreate: string[];\n filesToOverwrite: string[];\n} {\n return {\n filesToUpload: [\n ...status.addedLocally,\n ...status.modifiedLocally,\n ...(options.force ? status.deletedRemotely : []),\n ...(options.force ? status.modifiedRemotely : []),\n ],\n filesToDelete: [...status.deletedLocally],\n remoteOnlyFiles: options.force ? [...status.addedRemotely] : [],\n filesToRecreate: options.force ? [...status.deletedRemotely] : [],\n filesToOverwrite: options.force ? [...status.modifiedRemotely] : [],\n };\n}\n\nfunction renderRejections(rejections: ValidationFailure[]): void {\n for (const r of rejections) {\n console.log(chalk.red(` x ${r.filePath}`));\n console.log(chalk.dim(` ${r.detail}`));\n if (r.hint) console.log(chalk.dim(` ${r.hint}`));\n }\n console.log();\n}\n\n/**\n * Run pre-flight against a list of upload candidates and return only the\n * rejections so the preview can show them BEFORE the confirm prompt. We\n * read each file once here; syncService.push() reads them again at upload\n * time. The duplicate read is the price of putting rejections into the\n * confirmation plan \u2014 without this, the user only learned about rejected\n * files after pressing ENTER, which contradicted the README.\n *\n * Files that fail to read (permission errors, race with deletion) get\n * skipped \u2014 push() will surface that as a real failure if the file\n * actually still mattered.\n */\nfunction previewPushPlan(filesDir: string, candidates: string[]): ValidationFailure[] {\n const validationInputs: { filePath: string; size: number; content: Buffer }[] = [];\n for (const filePath of candidates) {\n try {\n const fullPath = safeResolveWithinBase(filesDir, filePath);\n const content = fs.readFileSync(fullPath);\n validationInputs.push({ filePath, size: content.length, content });\n } catch {\n // Race: file disappeared between getStatus and the preview\n // read, or unreadable. Push() will see the same condition\n // and surface a real error. Don't pretend to know more here.\n continue;\n }\n }\n const { rejected } = partitionForUpload(validationInputs);\n return rejected;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,sBAAqB;AACrB,oBAAuB;AACvB,wBAA2B;AAC3B,4BAAgF;AAChF,yBAA4B;AAC5B,4BAA+B;AAC/B,qBAMO;AACP,4BAAkC;AAClC,4BAAsD;AACtD,wBAAmD;AACnD,2BAAmC;AAEnC,SAAoB;AA4Bb,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,qBAAqB,EAC7B;AAAA,IACG;AAAA,EACJ,EACC;AAAA,IACG;AAAA,IACA;AAAA,EACJ,EACC,OAAO,aAAa,6EAA6E,EACjG;AAAA,IACG;AAAA,IACA;AAAA,EACJ,EAGC,OAAO,UAAU,6EAA6E,EAC9F,OAAO,uBAAuB,6CAA6C,iCAAe,CAAC,CAAC,EAC5F,OAAO,6BAA6B,4CAA4C,iCAAe,CAAC,CAAC,EACjG;AAAA,IACG;AAAA,IACA;AAAA,IACA;AAAA,IACA,CAAC;AAAA,EACL,EACC,OAAO,OAAO,MAAM,MAAM,YAAY;AACnC,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,MAAM,IAAI;AACvE,UAAM,eAAe,UAAM,oDAA6B,cAAc,MAAM;AAE5E,QAAI,CAAC,cAAc;AACf,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,eAAW,kCAAkB,MAAM;AAEzC,QAAI,CAAC,GAAG,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I,CAAC;AAAA,EACtE;AACJ;AAEA,SAAS,iBAAiB,YAAuC;AAC7D,aAAW,KAAK,YAAY;AACxB,YAAQ,IAAI,aAAAA,QAAM,IAAI,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC1C,YAAQ,IAAI,aAAAA,QAAM,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;AACxC,QAAI,EAAE,KAAM,SAAQ,IAAI,aAAAA,QAAM,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC;AAAA,EACtD;AACA,UAAQ,IAAI;AAChB;AAcA,SAAS,gBAAgB,UAAkB,YAA2C;AAClF,QAAM,mBAA0E,CAAC;AACjF,aAAW,YAAY,YAAY;AAC/B,QAAI;AACA,YAAM,eAAW,sCAAsB,UAAU,QAAQ;AACzD,YAAM,UAAU,GAAG,aAAa,QAAQ;AACxC,uBAAiB,KAAK,EAAE,UAAU,MAAM,QAAQ,QAAQ,QAAQ,CAAC;AAAA,IACrE,QAAQ;AAIJ;AAAA,IACJ;AAAA,EACJ;AACA,QAAM,EAAE,SAAS,QAAI,0CAAmB,gBAAgB;AACxD,SAAO;AACX;",
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport { fileLogger } from '../utils/fileLogger';\nimport { getFarseerClientWithFallback, showLoginPrompt, ensureFreshToken } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport {\n getTenantFilesDir,\n resolveTenantWithOrgMapping,\n safeResolveWithinBase,\n validateOnlyFilePaths,\n displayLocalPath,\n} from '../utils/helpers';\nimport { formatClientError } from '../utils/errorFormatter';\nimport { ValidationFailure, partitionForUpload } from '../utils/fileValidation';\nimport { collectValues, normalizeExtensions, normalizeRelativePath } from '../utils/cliOptions';\nimport { reportIgnoredLocal } from '../utils/syncReporting';\nimport type { SyncStatus } from '../services/syncService';\nimport * as fs from 'fs';\n\n/**\n * Push semantics (in plain English, since this is the easiest part of the\n * CLI to misunderstand):\n *\n * farseer push\n * 1. Pre-flight: refuse local files that the backend will reject\n * (extension whitelist, name length, empty body). Print them and\n * exit non-zero so the user fixes them before we touch the network.\n * 2. Compare local vs remote (no remote download \u2014 we trust the\n * recorded sync baseline). If remote diverged from baseline,\n * refuse and ask the user to pull first.\n * 3. Show a diff (added / modified / deleted).\n * 4. Confirm.\n * 5. Upload modified files. Re-check each one against current remote\n * right before overwrite to avoid clobbering a concurrent edit.\n *\n * farseer push --force\n * Same as above, but:\n * \u2022 Skip step 2 (allow pushing over remote drift).\n * \u2022 Make remote mirror local: also delete any remote files that\n * have no local counterpart (not just ones you previously pulled).\n * Because --force is destructive, we always show the full plan\n * (including deletions of remote-only files) and require an explicit\n * \"yes\". `-y` won't bypass --force confirmation; you must answer the\n * prompt.\n */\nexport function registerPushCommand(program: Command): void {\n program\n .command('push [org] [tenant]')\n .description(\n 'Push local files to Farseer instance\\n\\nUsage: push <org> <tenant> OR push <tenant> (if org is known)',\n )\n .option(\n '--force',\n 'Force-mirror remote to local: overwrite remote drift AND delete remote files with no local counterpart (always asks for confirmation)',\n )\n .option('-y, --yes', 'Skip confirmation prompt for non-destructive pushes (ignored under --force)')\n .option(\n '--shallow',\n 'Skip the remote-content hash check in the pre-flight (faster on big tenants; trusts the last-pull baseline). Ignored under --force, where deep is required for correct mirror semantics.',\n )\n // Accept `--deep` as a no-op alias so 1.6.1-era scripts keep\n // working \u2014 deep is now the default; see status.ts for context.\n .option('--deep', '(Deprecated; now the default) Force the deep remote-content hash pre-flight')\n .option('--include-ext <ext>', 'Include extra file extension (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder (repeatable)', collectValues, [])\n .option(\n '--only <path>',\n 'Only push the listed file(s) (repeatable, paths relative to tenant files dir, e.g. Scripts/foo.ts). Other local edits are not touched; the drift check still fires on these paths if remote has changed them.',\n collectValues,\n [],\n )\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const filesDir = getTenantFilesDir(tenant);\n\n if (!fs.existsSync(filesDir)) {\n logger.error(`Local folder not found: ${displayLocalPath(filesDir)}`);\n logger.dim('Run \"farseer pull <tenant>\" first to initialize the folder.');\n process.exit(1);\n }\n\n const syncService = new SyncService(tenant, clientResult.client);\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n // POSIX-normalise: the sync engine canonicalises every candidate\n // to forward slashes before include/onlyFiles matching, so a\n // Windows user typing `--only Scripts\\foo.ts` would otherwise\n // miss the comparison and the file would silently fall out of\n // scope.\n const onlyFiles = (options.only as string[]).map(normalizeRelativePath);\n const syncFilterOptions = {\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n onlyFiles: onlyFiles.length > 0 ? onlyFiles : undefined,\n };\n\n // --only is a surgical-push escape hatch. Skip the apps path\n // entirely (which has its own drift logic that doesn't know\n // about file whitelists) and skip the remote-drift check \u2014\n // the user has narrowed the blast radius to a known set of\n // files, that's the whole point. Without this short-circuit\n // both the drift gate and apps push could touch things\n // outside the requested scope, defeating --only.\n const onlyMode = onlyFiles.length > 0;\n\n // Pre-flight: every --only path must resolve to a real file\n // under filesDir. Without this check, a typo (wrong case,\n // double slash, deleted file) silently produces \"Nothing to\n // push. Everything is in sync.\" \u2014 same exit code as a real\n // no-op, and the user assumes the push went through.\n // Traversal paths (`--only ../x`) join the same missing list\n // so the user gets one consolidated error.\n if (onlyMode) {\n const { missing } = validateOnlyFilePaths(filesDir, onlyFiles);\n if (missing.length > 0) {\n logger.error(`--only path(s) not found under ${filesDir}:`);\n for (const m of missing) console.log(chalk.red(` ${m}`));\n logger.dim('Paths are relative to the tenant files dir and case-sensitive.');\n process.exit(1);\n }\n }\n\n // Build a single status snapshot \u2014 same buckets the\n // `farseer status` command uses, so the user sees the same\n // categorisation in both places.\n //\n // Run a DEEP pre-flight by default. Shallow status can't see\n // remote-side content drift (it trusts our recorded baseline),\n // so without it we'd silently overwrite remote edits that\n // landed since the last pull. `--shallow` opts out for users\n // who explicitly want the faster path on large tenants.\n //\n // --force ALWAYS implies deep, overriding --shallow. Mirror\n // mode means \"make remote = local\" \u2014 we need to know the\n // current remote content to decide what to overwrite. A\n // shallow status would miss remote-side content drift and\n // silently no-op when local matches the baseline. Force +\n // shallow is a contradiction, so deep wins.\n const deep = !!options.force || !options.shallow;\n const status = await syncService.getStatus({\n ...syncFilterOptions,\n deep,\n });\n\n // Drift gate: non-force push must not silently overwrite\n // remote-side drift. Block here, after deep status has run,\n // so the user sees the actual remote drift paths and can\n // choose between pull (merge remote) or --force (mirror,\n // overwrite remote). All three remote-side buckets count as\n // drift \u2014 adds, deletes, and content edits.\n //\n // Suppressed under --only: that's an explicit narrow-scope\n // push and only fires the block if a remote-drift path\n // overlaps the requested set.\n if (!options.force) {\n const conflictingAdded = onlyMode\n ? status.addedRemotely.filter((p) => onlyFiles.includes(p))\n : status.addedRemotely;\n const conflictingDeleted = onlyMode\n ? status.deletedRemotely.filter((p) => onlyFiles.includes(p))\n : status.deletedRemotely;\n const conflictingModified = onlyMode\n ? status.modifiedRemotely.filter((p) => onlyFiles.includes(p))\n : status.modifiedRemotely;\n const totalConflicts = conflictingAdded.length + conflictingDeleted.length + conflictingModified.length;\n if (totalConflicts > 0) {\n logger.error(`Remote has changes for ${totalConflicts} file(s) since last pull:`);\n if (conflictingAdded.length > 0) {\n console.log(chalk.cyan(' New on remote (need to pull):'));\n for (const f of conflictingAdded) console.log(chalk.cyan(` + ${f}`));\n }\n if (conflictingDeleted.length > 0) {\n console.log(chalk.red(' Removed on remote (need to pull to clean local):'));\n for (const f of conflictingDeleted) console.log(chalk.red(` - ${f}`));\n }\n if (conflictingModified.length > 0) {\n console.log(chalk.yellow(' Modified on remote (need to pull to merge):'));\n for (const f of conflictingModified) console.log(chalk.yellow(` M ${f}`));\n }\n // Echo back the same scope flags the user passed so the\n // suggested pull command actually fetches the files\n // causing the drift. Without this, `farseer pull` runs\n // in default scope and the drift remains blocking.\n const scopeFlags: string[] = [];\n for (const ext of options.includeExt as string[]) scopeFlags.push(`--include-ext ${ext}`);\n for (const folder of options.includeFolder as string[])\n scopeFlags.push(`--include-folder \"${folder}\"`);\n const pullCmd = ['farseer pull', tenant, ...scopeFlags].filter(Boolean).join(' ');\n logger.dim(`Run \\`${pullCmd}\\` to merge remote changes, then push.`);\n logger.dim('Or use --force to mirror (overwrite remote with local).');\n process.exit(1);\n }\n }\n\n const plan = buildPushPlan(status, { force: !!options.force });\n const { filesToUpload, filesToDelete, remoteOnlyFiles, filesToRecreate, filesToOverwrite } = plan;\n\n // Apps are independent of the file pre-flight gate.\n // In --only mode we deliberately don't touch apps at all\n // (the user asked for a file-scoped push). Stub the app\n // status to \"nothing to do\" so downstream code can treat\n // the two modes uniformly.\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n const appStatus = onlyMode\n ? { newLocal: [], newRemote: [], modified: [], synced: [] }\n : await appSyncService.getStatus();\n\n const hasConflicts = status.conflicts.length > 0;\n const hasFileChanges =\n filesToUpload.length > 0 || filesToDelete.length > 0 || remoteOnlyFiles.length > 0 || hasConflicts;\n const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.modified.length > 0;\n\n if (!hasFileChanges && !hasAppChanges) {\n // Print the out-of-scope warning BEFORE the success line\n // so the \"within current scope\" qualifier reads as a\n // follow-up to the count the user just saw, not a\n // contradiction of a bare \"Nothing to push\" message.\n reportIgnoredLocal(status.ignoredLocal, status.ignoredLocalTotal);\n if (status.ignoredLocalTotal > 0) {\n logger.success('Everything is in sync within current scope.');\n logger.dim(\n `(${status.ignoredLocalTotal} file(s) outside scope were not compared \u2014 see warning above for details.)`,\n );\n } else {\n logger.success('Nothing to push. Everything is in sync.');\n }\n return;\n }\n\n console.log();\n logger.header(options.force ? 'Mirror plan (--force):' : 'Changes to push:');\n\n if (status.addedLocally.length > 0) {\n for (const file of status.addedLocally) console.log(chalk.green(` + ${file}`));\n }\n if (status.modifiedLocally.length > 0) {\n for (const file of status.modifiedLocally) console.log(chalk.yellow(` M ${file}`));\n }\n if (filesToDelete.length > 0) {\n for (const file of filesToDelete) console.log(chalk.red(` - ${file}`));\n }\n if (remoteOnlyFiles.length > 0) {\n console.log(chalk.red.bold('Remote-only files that will be DELETED on remote:'));\n for (const file of remoteOnlyFiles) console.log(chalk.red(` - ${file} (remote only)`));\n }\n if (filesToRecreate.length > 0) {\n console.log(chalk.green.bold('Files deleted on remote that will be RECREATED:'));\n for (const file of filesToRecreate) console.log(chalk.green(` + ${file} (re-uploading local copy)`));\n }\n if (filesToOverwrite.length > 0) {\n console.log(chalk.yellow.bold('Files where remote drifted \u2014 local will OVERWRITE:'));\n for (const file of filesToOverwrite)\n console.log(chalk.yellow(` M ${file} (remote content drift; local wins)`));\n }\n\n // Surface scope-skipped files BEFORE the confirmation prompt so\n // the user never confirms a push thinking it covers everything in\n // the workspace when in fact .md / .json / .py etc. were silently\n // excluded by the default whitelist.\n reportIgnoredLocal(status.ignoredLocal, status.ignoredLocalTotal);\n\n // Conflicts surface BEFORE the confirmation prompt so the user\n // never confirms a plan that secretly contains skipped files.\n // Without --force these will be skipped (and the user can re-run\n // with `farseer pull` to resolve); under --force the upload step\n // will overwrite local\u2192remote anyway, but the user still deserves\n // to see what's affected.\n if (hasConflicts) {\n const headerText = options.force\n ? 'Conflicts (will be force-overwritten on remote):'\n : 'Conflicts (will be SKIPPED \u2014 pull first to resolve):';\n console.log(chalk.red.bold(headerText));\n for (const conflict of status.conflicts) {\n console.log(chalk.red(` ! ${conflict.filePath}`));\n console.log(chalk.dim(` ${conflict.description}`));\n }\n }\n\n if (appStatus.newLocal.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appStatus.newLocal) console.log(chalk.green(` + ${app}`));\n }\n if (appStatus.modified.length > 0) {\n console.log(chalk.yellow('Modified apps:'));\n for (const app of appStatus.modified) console.log(chalk.yellow(` ~ ${app}`));\n }\n\n // Pre-flight in the preview, BEFORE the confirm prompt. README\n // promises rejections show up in the plan; running pre-flight\n // only inside syncService.push() pushed them to AFTER the user\n // had already said \"yes\". Cost: every upload candidate is read\n // twice (preview + push). For big tenants this is measurable\n // but predictability is the user-visible contract \u2014 they'd\n // rather know about a 256-char-name reject before pressing\n // ENTER on a 200-file mirror push.\n const previewCandidates = [...filesToUpload, ...filesToRecreate, ...filesToOverwrite];\n const previewRejections = previewPushPlan(filesDir, previewCandidates);\n if (previewRejections.length > 0) {\n console.log();\n console.log(chalk.red.bold('Files that pre-flight will reject (skipped from upload):'));\n for (const r of previewRejections) {\n console.log(chalk.red(` \u2717 ${r.filePath}`));\n console.log(chalk.dim(` ${r.detail}`));\n if (r.hint) console.log(chalk.dim(` ${r.hint}`));\n }\n }\n\n console.log();\n\n // filesToUpload already includes filesToRecreate under --force,\n // so don't double-count.\n const totalChanges =\n filesToUpload.length +\n filesToDelete.length +\n remoteOnlyFiles.length +\n appStatus.newLocal.length +\n appStatus.modified.length;\n\n // Step 3: Confirm. --force always confirms (cannot be skipped\n // with -y) because mirror mode includes destructive deletes.\n //\n // Spell out every bucket in the prompt itself, not just the\n // total. A 200-overwrite + 2-delete mirror with the old\n // \"Mirror N change(s) (including K remote deletion(s))\"\n // headline read like \"small change\" \u2014 the eye-catching K\n // hid the bigger blast radius. The plan above the prompt is\n // already explicit; the prompt-line should match it.\n const confirmMessage = options.force\n ? `Mirror to ${tenant}: ${remoteOnlyFiles.length} remote deletion(s), ` +\n `${filesToOverwrite.length} drift overwrite(s), ${filesToRecreate.length} recreation(s), ` +\n `${status.addedLocally.length} new upload(s), ${status.modifiedLocally.length} local edit(s), ` +\n `${filesToDelete.length} local-rm deletion(s). This is destructive.`\n : `Push ${totalChanges} change(s) to ${tenant}?`;\n\n if (options.force || !options.yes) {\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: confirmMessage,\n default: !options.force,\n },\n ]);\n\n if (!confirm.proceed) {\n logger.info('Push cancelled.');\n return;\n }\n }\n\n // Ensure token is fresh before push operations (may have expired during user input)\n await ensureFreshToken(clientResult.client);\n\n try {\n // Mirror the service's actual return type so every field is\n // present and non-optional. The earlier hand-rolled inline\n // type marked conflicts/rejected/failed as optional, which\n // forced `?.length ?? 0` defensiveness at every read site\n // even though the service always returns those arrays.\n let result: Awaited<ReturnType<SyncService['push']>> = {\n uploaded: [],\n updated: [],\n deleted: [],\n unchanged: [],\n conflicts: [],\n rejected: [],\n failed: [],\n ignoredLocal: [],\n ignoredLocalTotal: 0,\n ignoredLocalTotalByReason: { unsupportedExtension: 0, blocklistedFolder: 0 },\n };\n\n if (hasFileChanges) {\n logger.info(`Pushing files to ${tenant}...`);\n // Pass syncFilterOptions so mirror-mode deletes honour\n // --include-folder / --include-ext scope. Without this\n // the preview's \"remote-only DELETE\" line and the actual\n // mirror step diverged for non-default extensions.\n //\n // Hand `status.remoteHashes` (populated when deep status\n // ran above, i.e. under --force) into service.push so\n // the candidate-content fetch skips files we already\n // have hashes for. Without it, --force re-downloaded\n // every remote file a second time inside push().\n result = await syncService.push({\n force: options.force,\n mirror: options.force,\n ...syncFilterOptions,\n precomputedRemoteHashes: status.remoteHashes,\n });\n\n console.log();\n\n if (result.rejected.length > 0) {\n console.log(chalk.red.bold('Files skipped (backend would reject):'));\n renderRejections(result.rejected);\n }\n\n if (result.conflicts.length > 0) {\n console.log(chalk.red.bold(`${result.conflicts.length} conflict(s) detected:`));\n for (const conflict of result.conflicts) {\n console.log(chalk.red(` ! ${conflict.filePath}`));\n console.log(chalk.dim(` ${conflict.description}`));\n }\n console.log();\n logger.dim(`Resolve conflicts by pulling first: farseer pull ${tenant}`);\n logger.dim('Or use --force to push anyway (overwrites remote and mirrors deletions).');\n console.log();\n }\n\n if (result.uploaded.length > 0) {\n console.log(chalk.green('Uploaded files (new):'));\n for (const file of result.uploaded) console.log(chalk.green(` + ${file}`));\n console.log();\n }\n\n if (result.updated.length > 0) {\n console.log(chalk.yellow('Updated files:'));\n for (const file of result.updated) console.log(chalk.yellow(` M ${file}`));\n console.log();\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted files:'));\n for (const file of result.deleted) console.log(chalk.red(` - ${file}`));\n console.log();\n }\n\n if (result.failed.length > 0) {\n // Per-file errors that the backend rejected mid-flight\n // (5xx, validation we couldn't pre-flight, etc.).\n // Distinct from `rejected` (pre-flight) \u2014 these\n // already attempted the call. State for files that\n // succeeded before the failure has been saved.\n console.log(chalk.red.bold(`${result.failed.length} file(s) failed during push:`));\n for (const failure of result.failed) {\n console.log(chalk.red(` ! ${failure.filePath} (${failure.operation})`));\n console.log(chalk.dim(` ${failure.reason}`));\n }\n console.log();\n }\n }\n\n let appResult = {\n created: [] as string[],\n updated: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n };\n\n if (hasAppChanges) {\n logger.info(`Pushing apps to ${tenant}...`);\n appResult = await appSyncService.push();\n\n if (appResult.created.length > 0) {\n console.log(chalk.green('Created apps:'));\n for (const app of appResult.created) console.log(chalk.green(` + ${app}`));\n console.log();\n }\n\n if (appResult.updated.length > 0) {\n console.log(chalk.yellow('Updated apps:'));\n for (const app of appResult.updated) console.log(chalk.yellow(` ~ ${app}`));\n console.log();\n }\n\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps:'));\n for (const app of appResult.deleted) console.log(chalk.red(` - ${app}`));\n console.log();\n }\n }\n\n console.log();\n const fileSideEffects = result.uploaded.length + result.updated.length + result.deleted.length;\n const appSideEffects = appResult.created.length + appResult.updated.length + appResult.deleted.length;\n const conflictCount = result.conflicts.length;\n const rejectedCount = result.rejected.length;\n const failedCount = result.failed.length;\n if (fileSideEffects + appSideEffects === 0 && (conflictCount > 0 || rejectedCount > 0)) {\n // Nothing was actually pushed (every candidate hit a\n // conflict or pre-flight rejection). Surface as a\n // warning + EXIT 1 so CI and shell scripts can branch\n // \u2014 the bare \"Push complete!\" line was misleading.\n if (rejectedCount > 0 && conflictCount === 0) {\n logger.warning(`Push did nothing \u2014 ${rejectedCount} file(s) rejected by pre-flight.`);\n logger.dim('Fix the issues listed above and re-run `farseer push`.');\n } else if (conflictCount > 0 && rejectedCount === 0) {\n logger.warning(`Push did nothing \u2014 ${conflictCount} conflict(s) blocked the upload.`);\n logger.dim(`Resolve via 'farseer pull ${tenant}' or rerun with --force.`);\n } else {\n logger.warning(\n `Push did nothing \u2014 ${rejectedCount} file(s) rejected and ${conflictCount} conflict(s) blocked the upload.`,\n );\n }\n process.exit(1);\n }\n logger.success('Push complete!');\n logger.dim(`Files: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}`);\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}`,\n );\n if (rejectedCount > 0 || failedCount > 0) {\n // Partial success: at least some side effects landed\n // but some candidates were skipped (rejected pre-flight)\n // or failed mid-push (network/backend error). EXIT 1\n // (not 2 \u2014 the previous split was undocumented and most\n // CI scripts treat any non-zero as failure anyway).\n if (rejectedCount > 0 && failedCount > 0) {\n logger.warning(\n `${rejectedCount} file(s) skipped pre-flight, ${failedCount} failed mid-push \u2014 see above and rerun.`,\n );\n } else if (rejectedCount > 0) {\n logger.warning(`${rejectedCount} file(s) skipped (see above) \u2014 fix and rerun.`);\n } else {\n logger.warning(`${failedCount} file(s) failed during push (see above) \u2014 rerun to retry.`);\n }\n process.exit(1);\n }\n } catch (error) {\n fileLogger.error('push', error, { tenant, organisation });\n logger.error('Push failed.');\n logger.error(await formatClientError(error));\n const logPath = fileLogger.getLogPath();\n if (logPath) {\n logger.dim(`Debug log: ${logPath}`);\n }\n process.exit(1);\n }\n });\n}\n\n/**\n * Translate a SyncStatus + force flag into the buckets the push command\n * actually acts on. Pure: takes a status, returns lists. Lives at the\n * top level (not inside the action closure) so it can be exported and\n * unit-tested directly \u2014 the status engine has its own coverage, and\n * before this extraction the bucket logic was inline in the action and\n * only reachable via mocking commander + inquirer + fs.\n *\n * Default push: upload the added/modified locally, delete the locally-\n * removed. Remote-side activity is not in scope (drift check refuses\n * before we reach this).\n *\n * Force push (mirror): also re-upload files the remote has lost\n * (deletedRemotely \u2192 recreate) and files the remote has drifted away\n * from (modifiedRemotely \u2192 local wins, overwrite). Plus mirror-deletes\n * remote files that have no local counterpart (addedRemotely).\n */\nexport function buildPushPlan(\n status: SyncStatus,\n options: { force: boolean },\n): {\n filesToUpload: string[];\n filesToDelete: string[];\n remoteOnlyFiles: string[];\n filesToRecreate: string[];\n filesToOverwrite: string[];\n} {\n return {\n filesToUpload: [\n ...status.addedLocally,\n ...status.modifiedLocally,\n ...(options.force ? status.deletedRemotely : []),\n ...(options.force ? status.modifiedRemotely : []),\n ],\n filesToDelete: [...status.deletedLocally],\n remoteOnlyFiles: options.force ? [...status.addedRemotely] : [],\n filesToRecreate: options.force ? [...status.deletedRemotely] : [],\n filesToOverwrite: options.force ? [...status.modifiedRemotely] : [],\n };\n}\n\nfunction renderRejections(rejections: ValidationFailure[]): void {\n for (const r of rejections) {\n console.log(chalk.red(` x ${r.filePath}`));\n console.log(chalk.dim(` ${r.detail}`));\n if (r.hint) console.log(chalk.dim(` ${r.hint}`));\n }\n console.log();\n}\n\n/**\n * Run pre-flight against a list of upload candidates and return only the\n * rejections so the preview can show them BEFORE the confirm prompt. We\n * read each file once here; syncService.push() reads them again at upload\n * time. The duplicate read is the price of putting rejections into the\n * confirmation plan \u2014 without this, the user only learned about rejected\n * files after pressing ENTER, which contradicted the README.\n *\n * Files that fail to read (permission errors, race with deletion) get\n * skipped \u2014 push() will surface that as a real failure if the file\n * actually still mattered.\n */\nfunction previewPushPlan(filesDir: string, candidates: string[]): ValidationFailure[] {\n const validationInputs: { filePath: string; size: number; content: Buffer }[] = [];\n for (const filePath of candidates) {\n try {\n const fullPath = safeResolveWithinBase(filesDir, filePath);\n const content = fs.readFileSync(fullPath);\n validationInputs.push({ filePath, size: content.length, content });\n } catch {\n // Race: file disappeared between getStatus and the preview\n // read, or unreadable. Push() will see the same condition\n // and surface a real error. Don't pretend to know more here.\n continue;\n }\n }\n const { rejected } = partitionForUpload(validationInputs);\n return rejected;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,sBAAqB;AACrB,oBAAuB;AACvB,wBAA2B;AAC3B,4BAAgF;AAChF,yBAA4B;AAC5B,4BAA+B;AAC/B,qBAMO;AACP,4BAAkC;AAClC,4BAAsD;AACtD,wBAA0E;AAC1E,2BAAmC;AAEnC,SAAoB;AA4Bb,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,qBAAqB,EAC7B;AAAA,IACG;AAAA,EACJ,EACC;AAAA,IACG;AAAA,IACA;AAAA,EACJ,EACC,OAAO,aAAa,6EAA6E,EACjG;AAAA,IACG;AAAA,IACA;AAAA,EACJ,EAGC,OAAO,UAAU,6EAA6E,EAC9F,OAAO,uBAAuB,6CAA6C,iCAAe,CAAC,CAAC,EAC5F,OAAO,6BAA6B,4CAA4C,iCAAe,CAAC,CAAC,EACjG;AAAA,IACG;AAAA,IACA;AAAA,IACA;AAAA,IACA,CAAC;AAAA,EACL,EACC,OAAO,OAAO,MAAM,MAAM,YAAY;AACnC,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,MAAM,IAAI;AACvE,UAAM,eAAe,UAAM,oDAA6B,cAAc,MAAM;AAE5E,QAAI,CAAC,cAAc;AACf,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,eAAW,kCAAkB,MAAM;AAEzC,QAAI,CAAC,GAAG,WAAW,QAAQ,GAAG;AAC1B,2BAAO,MAAM,+BAA2B,iCAAiB,QAAQ,CAAC,EAAE;AACpE,2BAAO,IAAI,6DAA6D;AACxE,cAAQ,KAAK,CAAC;AAAA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AAAA,QAAM,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;AACxC,QAAI,EAAE,KAAM,SAAQ,IAAI,aAAAA,QAAM,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC;AAAA,EACtD;AACA,UAAQ,IAAI;AAChB;AAcA,SAAS,gBAAgB,UAAkB,YAA2C;AAClF,QAAM,mBAA0E,CAAC;AACjF,aAAW,YAAY,YAAY;AAC/B,QAAI;AACA,YAAM,eAAW,sCAAsB,UAAU,QAAQ;AACzD,YAAM,UAAU,GAAG,aAAa,QAAQ;AACxC,uBAAiB,KAAK,EAAE,UAAU,MAAM,QAAQ,QAAQ,QAAQ,CAAC;AAAA,IACrE,QAAQ;AAIJ;AAAA,IACJ;AAAA,EACJ;AACA,QAAM,EAAE,SAAS,QAAI,0CAAmB,gBAAgB;AACxD,SAAO;AACX;",
|
|
6
6
|
"names": ["chalk", "inquirer"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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 refresh_exports = {};
|
|
30
|
+
__export(refresh_exports, {
|
|
31
|
+
buildRefreshedState: () => buildRefreshedState,
|
|
32
|
+
registerRefreshCommand: () => registerRefreshCommand
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(refresh_exports);
|
|
35
|
+
var fs = __toESM(require("fs"));
|
|
36
|
+
var import_logger = require("../utils/logger");
|
|
37
|
+
var import_farseerFactory = require("../services/farseerFactory");
|
|
38
|
+
var import_syncService = require("../services/syncService");
|
|
39
|
+
var import_helpers = require("../utils/helpers");
|
|
40
|
+
var import_cliOptions = require("../utils/cliOptions");
|
|
41
|
+
var path = __toESM(require("path"));
|
|
42
|
+
function buildRefreshedState(args) {
|
|
43
|
+
const { filesDir, filesDirExists, localPaths, remoteHashes } = args;
|
|
44
|
+
const state = { lastSync: (args.now ?? (() => /* @__PURE__ */ new Date()))().toISOString(), files: {} };
|
|
45
|
+
let matched = 0;
|
|
46
|
+
let divergent = 0;
|
|
47
|
+
if (filesDirExists) {
|
|
48
|
+
for (const relPath of localPaths) {
|
|
49
|
+
const buf = fs.readFileSync((0, import_helpers.safeResolveWithinBase)(filesDir, relPath));
|
|
50
|
+
const localHash = (0, import_helpers.calculateHash)(buf);
|
|
51
|
+
const remoteHash = remoteHashes.get(relPath);
|
|
52
|
+
if (remoteHash !== void 0) {
|
|
53
|
+
if (localHash === remoteHash) {
|
|
54
|
+
state.files[relPath] = { localHash, remoteHash };
|
|
55
|
+
matched++;
|
|
56
|
+
} else {
|
|
57
|
+
divergent++;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const localOnly = localPaths.filter((p) => !remoteHashes.has(p)).length;
|
|
63
|
+
const remoteOnly = Array.from(remoteHashes.keys()).filter((p) => !localPaths.includes(p)).length;
|
|
64
|
+
return { matched, divergent, localOnly, remoteOnly, state };
|
|
65
|
+
}
|
|
66
|
+
function registerRefreshCommand(program) {
|
|
67
|
+
program.command("refresh [org] [tenant]").description("Rebuild the local sync baseline (.farseer-sync.json) from current on-disk + remote state").option(
|
|
68
|
+
"--all",
|
|
69
|
+
"Include all non-hidden, non-blocklisted files outside the default scope (matches pull/status)"
|
|
70
|
+
).option("--include-ext <ext>", "Include extra file extension (repeatable)", import_cliOptions.collectValues, []).option("--include-folder <folder>", "Include all files in folder (repeatable)", import_cliOptions.collectValues, []).action(async (arg1, arg2, options) => {
|
|
71
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(arg1, arg2);
|
|
72
|
+
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
73
|
+
if (!clientResult) {
|
|
74
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
const includeExtensions = (0, import_cliOptions.normalizeExtensions)(options.includeExt);
|
|
78
|
+
const includeFolders = options.includeFolder;
|
|
79
|
+
const filterOptions = {
|
|
80
|
+
all: options.all,
|
|
81
|
+
includeExtensions: includeExtensions.length > 0 ? includeExtensions : void 0,
|
|
82
|
+
includeFolders: includeFolders.length > 0 ? includeFolders : void 0
|
|
83
|
+
};
|
|
84
|
+
try {
|
|
85
|
+
const syncService = new import_syncService.SyncService(tenant, clientResult.client);
|
|
86
|
+
import_logger.logger.info("Hashing local files and fetching remote hashes...");
|
|
87
|
+
const status = await syncService.getStatus({ ...filterOptions, deep: true });
|
|
88
|
+
const filesDir = (0, import_helpers.getTenantFilesDir)(tenant);
|
|
89
|
+
const filesDirExists = fs.existsSync(filesDir);
|
|
90
|
+
if (!filesDirExists) {
|
|
91
|
+
import_logger.logger.warning(
|
|
92
|
+
`Local files directory not found: ${filesDir} \u2014 baseline will be empty and all remote files will be reported as new on next status.`
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const localPaths = filesDirExists ? (0, import_helpers.getAllFilesInDir)(filesDir).filter((f) => (0, import_syncService.shouldIncludeFile)(f, tenant, filterOptions)) : [];
|
|
96
|
+
const remoteHashes = status.remoteHashes ?? /* @__PURE__ */ new Map();
|
|
97
|
+
const summary = buildRefreshedState({
|
|
98
|
+
tenant,
|
|
99
|
+
filesDir,
|
|
100
|
+
filesDirExists,
|
|
101
|
+
localPaths,
|
|
102
|
+
remoteHashes
|
|
103
|
+
});
|
|
104
|
+
const syncFilePath = (0, import_helpers.getSyncFilePath)(tenant);
|
|
105
|
+
(0, import_helpers.ensureDirectoryExists)(path.dirname(syncFilePath));
|
|
106
|
+
const tmpPath = `${syncFilePath}.tmp`;
|
|
107
|
+
fs.writeFileSync(tmpPath, JSON.stringify(summary.state, null, 2), "utf-8");
|
|
108
|
+
fs.renameSync(tmpPath, syncFilePath);
|
|
109
|
+
import_logger.logger.success(
|
|
110
|
+
`Baseline rebuilt \u2014 ${summary.matched} matched, ${summary.divergent} divergent (will be reported as conflicts), ${summary.localOnly} local-only, ${summary.remoteOnly} remote-only.`
|
|
111
|
+
);
|
|
112
|
+
import_logger.logger.dim(
|
|
113
|
+
"Divergent, local-only, and remote-only entries are deliberately absent from the baseline; the next `farseer status` will report them as conflicts / added locally / added remotely so you can choose how to resolve them."
|
|
114
|
+
);
|
|
115
|
+
import_logger.logger.dim("Run `farseer status` to see the new diff.");
|
|
116
|
+
} catch (error) {
|
|
117
|
+
import_logger.logger.error("Refresh failed.");
|
|
118
|
+
if (error instanceof Error) import_logger.logger.dim(error.message);
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
buildRefreshedState,
|
|
126
|
+
registerRefreshCommand
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=refresh.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/refresh.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt } from '../services/farseerFactory';\nimport { SyncService, SyncState, shouldIncludeFile } from '../services/syncService';\nimport {\n calculateHash,\n ensureDirectoryExists,\n getAllFilesInDir,\n getSyncFilePath,\n getTenantFilesDir,\n resolveTenantWithOrgMapping,\n safeResolveWithinBase,\n} from '../utils/helpers';\nimport { collectValues, normalizeExtensions } from '../utils/cliOptions';\nimport * as path from 'path';\n\nexport interface RefreshSummary {\n matched: number;\n divergent: number;\n localOnly: number;\n remoteOnly: number;\n state: SyncState;\n}\n\n/**\n * Pure baseline-build step of `farseer refresh` \u2014 separated from the\n * commander wiring so tests exercise the EXACT production logic (and\n * mutation-testing the rule below actually breaks the test suite).\n *\n * Contract: only writes a baseline entry for both-sided files when\n * `localHash === remoteHash`. Divergent both-sided pairs are omitted\n * so the next `status` surfaces them as `conflict_both_new` rather\n * than silently picking local-as-truth (see `compareFiles`).\n */\nexport function buildRefreshedState(args: {\n tenant: string;\n filesDir: string;\n filesDirExists: boolean;\n localPaths: string[];\n remoteHashes: Map<string, string>;\n now?: () => Date;\n}): RefreshSummary {\n const { filesDir, filesDirExists, localPaths, remoteHashes } = args;\n const state: SyncState = { lastSync: (args.now ?? (() => new Date()))().toISOString(), files: {} };\n\n let matched = 0;\n let divergent = 0;\n\n if (filesDirExists) {\n for (const relPath of localPaths) {\n const buf = fs.readFileSync(safeResolveWithinBase(filesDir, relPath));\n const localHash = calculateHash(buf);\n const remoteHash = remoteHashes.get(relPath);\n if (remoteHash !== undefined) {\n if (localHash === remoteHash) {\n state.files[relPath] = { localHash, remoteHash };\n matched++;\n } else {\n divergent++;\n }\n }\n // Local-only: omitted \u2014 next status sees `!hadBaseline` and\n // emits `local_new`.\n }\n }\n // Remote-only: omitted \u2014 next status sees `!hadBaseline` and emits\n // `remote_new`.\n\n const localOnly = localPaths.filter((p) => !remoteHashes.has(p)).length;\n const remoteOnly = Array.from(remoteHashes.keys()).filter((p) => !localPaths.includes(p)).length;\n\n return { matched, divergent, localOnly, remoteOnly, state };\n}\n\n/**\n * `farseer refresh` \u2014 rebuild the local sync baseline (.farseer-sync.json)\n * to match the current on-disk + remote state.\n *\n * Operational escape hatch for when the baseline gets out of step:\n * - the workspace was checked into git and another machine's baseline\n * got committed (now reports phantom drift after a clone)\n * - manual edits to the sync file\n * - inherited workspace from another machine\n *\n * Mechanism: walk local files + fetch current remote hashes (via the\n * existing deep-mode getStatus), then write a fresh SyncState that\n * records each file's hash ONLY when it exists on both sides AND the\n * local and remote hashes already match (an actual in-sync pair).\n *\n * Files are LEFT OUT of the baseline in three cases \u2014 each maps to a\n * `!hadBaseline` branch in compareFiles that classifies the file\n * correctly on the next status:\n *\n * - Local-only file \u2192 `local_new` (NOT `remote_deleted`).\n * - Remote-only file \u2192 `remote_new` (NOT `local_deleted`).\n * - Both-sided but divergent hashes \u2192 `conflict_both_new` so the\n * user is forced to choose via pull/push, not silently overwritten.\n * If we instead recorded `{localHash, remoteHash}` for divergent\n * pairs, the next status would treat current state as matching\n * baseline \u2192 `local_modified` (via the `baselineDivergent` branch),\n * and `push -y` would happily overwrite the real remote edit.\n * Refresh has no way to know which side is \"the truth\" when\n * hashes already differ, so it refuses to bake either side in.\n *\n * Recording a synthetic baseline (empty-string or self-hash) trips the\n * `hadBaseline=true` path and flips the meaning \u2014 the exact failure\n * this command exists to cure.\n *\n * Difference from `pull --force`:\n * - `refresh` mutates only the baseline (.farseer-sync.json). Local\n * and remote files are untouched. Use it when the diff state is\n * wrong but the actual files are fine.\n * - `pull --force` discards local edits and mirrors remote into the\n * working tree. Destructive. Use it when local is wrong.\n */\nexport function registerRefreshCommand(program: Command): void {\n program\n .command('refresh [org] [tenant]')\n .description('Rebuild the local sync baseline (.farseer-sync.json) from current on-disk + remote state')\n .option(\n '--all',\n 'Include all non-hidden, non-blocklisted files outside the default scope (matches pull/status)',\n )\n .option('--include-ext <ext>', 'Include extra file extension (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder (repeatable)', collectValues, [])\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n const filterOptions = {\n all: options.all,\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n };\n\n try {\n const syncService = new SyncService(tenant, clientResult.client);\n logger.info('Hashing local files and fetching remote hashes...');\n\n // Fetch remote hashes first (deep). If this throws we keep\n // the existing baseline file untouched \u2014 see the atomic\n // write below for the symmetric guarantee on the write\n // side.\n const status = await syncService.getStatus({ ...filterOptions, deep: true });\n\n const filesDir = getTenantFilesDir(tenant);\n const filesDirExists = fs.existsSync(filesDir);\n if (!filesDirExists) {\n logger.warning(\n `Local files directory not found: ${filesDir} \u2014 baseline will be empty and all remote files will be reported as new on next status.`,\n );\n }\n const localPaths = filesDirExists\n ? getAllFilesInDir(filesDir).filter((f) => shouldIncludeFile(f, tenant, filterOptions))\n : [];\n const remoteHashes = status.remoteHashes ?? new Map<string, string>();\n\n const summary = buildRefreshedState({\n tenant,\n filesDir,\n filesDirExists,\n localPaths,\n remoteHashes,\n });\n\n // Atomic write: tmp + rename. rename(2) on POSIX is atomic\n // for the destination \u2014 a Ctrl-C between the fetch above\n // and a successful rename leaves the previous baseline\n // intact rather than nuking it and leaving the workspace\n // with NO baseline.\n const syncFilePath = getSyncFilePath(tenant);\n ensureDirectoryExists(path.dirname(syncFilePath));\n const tmpPath = `${syncFilePath}.tmp`;\n fs.writeFileSync(tmpPath, JSON.stringify(summary.state, null, 2), 'utf-8');\n fs.renameSync(tmpPath, syncFilePath);\n\n logger.success(\n `Baseline rebuilt \u2014 ${summary.matched} matched, ${summary.divergent} divergent (will be reported as conflicts), ${summary.localOnly} local-only, ${summary.remoteOnly} remote-only.`,\n );\n logger.dim(\n 'Divergent, local-only, and remote-only entries are deliberately absent from the baseline; the next `farseer status` will report them as conflicts / added locally / added remotely so you can choose how to resolve them.',\n );\n logger.dim('Run `farseer status` to see the new diff.');\n } catch (error) {\n logger.error('Refresh failed.');\n if (error instanceof Error) logger.dim(error.message);\n process.exit(1);\n }\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AACpB,oBAAuB;AACvB,4BAA8D;AAC9D,yBAA0D;AAC1D,qBAQO;AACP,wBAAmD;AACnD,WAAsB;AAoBf,SAAS,oBAAoB,MAOjB;AACf,QAAM,EAAE,UAAU,gBAAgB,YAAY,aAAa,IAAI;AAC/D,QAAM,QAAmB,EAAE,WAAW,KAAK,QAAQ,MAAM,oBAAI,KAAK,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,EAAE;AAEjG,MAAI,UAAU;AACd,MAAI,YAAY;AAEhB,MAAI,gBAAgB;AAChB,eAAW,WAAW,YAAY;AAC9B,YAAM,MAAM,GAAG,iBAAa,sCAAsB,UAAU,OAAO,CAAC;AACpE,YAAM,gBAAY,8BAAc,GAAG;AACnC,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AAU,EAAE,GAAG,eAAe,MAAM,KAAK,CAAC;AAE3E,YAAM,eAAW,kCAAkB,MAAM;AACzC,YAAM,iBAAiB,GAAG,WAAW,QAAQ;AAC7C,UAAI,CAAC,gBAAgB;AACjB,6BAAO;AAAA,UACH,oCAAoC,QAAQ;AAAA,QAChD;AAAA,MACJ;AACA,YAAM,aAAa,qBACb,iCAAiB,QAAQ,EAAE,OAAO,CAAC,UAAM,sCAAkB,GAAG,QAAQ,aAAa,CAAC,IACpF,CAAC;AACP,YAAM,eAAe,OAAO,gBAAgB,oBAAI,IAAoB;AAEpE,YAAM,UAAU,oBAAoB;AAAA,QAChC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACJ,CAAC;AAOD,YAAM,mBAAe,gCAAgB,MAAM;AAC3C,gDAAsB,KAAK,QAAQ,YAAY,CAAC;AAChD,YAAM,UAAU,GAAG,YAAY;AAC/B,SAAG,cAAc,SAAS,KAAK,UAAU,QAAQ,OAAO,MAAM,CAAC,GAAG,OAAO;AACzE,SAAG,WAAW,SAAS,YAAY;AAEnC,2BAAO;AAAA,QACH,2BAAsB,QAAQ,OAAO,aAAa,QAAQ,SAAS,+CAA+C,QAAQ,SAAS,gBAAgB,QAAQ,UAAU;AAAA,MACzK;AACA,2BAAO;AAAA,QACH;AAAA,MACJ;AACA,2BAAO,IAAI,2CAA2C;AAAA,IAC1D,SAAS,OAAO;AACZ,2BAAO,MAAM,iBAAiB;AAC9B,UAAI,iBAAiB,MAAO,sBAAO,IAAI,MAAM,OAAO;AACpD,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/commands/status.js
CHANGED
|
@@ -43,7 +43,10 @@ var fs = __toESM(require("fs"));
|
|
|
43
43
|
function registerStatusCommand(program) {
|
|
44
44
|
program.command("status [org] [tenant]").description(
|
|
45
45
|
"Show sync status between local and remote\n\nUsage: status <org> <tenant> OR status <tenant> (if org is known)"
|
|
46
|
-
).option(
|
|
46
|
+
).option(
|
|
47
|
+
"--all",
|
|
48
|
+
"Show status for every non-hidden, non-blocklisted file (default: developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist). Data files (.csv, .xlsx, .parquet, \u2026) are backend-accepted but excluded from default \u2014 opt in via --include-ext .csv or `farseer config include --ext .csv`."
|
|
49
|
+
).option(
|
|
47
50
|
"--shallow",
|
|
48
51
|
"Skip remote-content hashing (faster; trusts the last-sync baseline, will miss edits to existing remote files)"
|
|
49
52
|
).option("--deep", "(Deprecated; now the default) Hash remote content to detect remote-side edits").option("--include-ext <ext>", "Include extra file extension (repeatable)", import_cliOptions.collectValues, []).option("--include-folder <folder>", "Include all files in folder (repeatable)", import_cliOptions.collectValues, []).action(async (arg1, arg2, options) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/status.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { getTenantFilesDir, resolveTenantWithOrgMapping, displayLocalPath } from '../utils/helpers';\nimport { collectValues, normalizeExtensions } from '../utils/cliOptions';\nimport { reportIgnoredLocal } from '../utils/syncReporting';\nimport * as fs from 'fs';\n\nexport function registerStatusCommand(program: Command): void {\n program\n .command('status [org] [tenant]')\n .description(\n 'Show sync status between local and remote\\n\\nUsage: status <org> <tenant> OR status <tenant> (if org is known)',\n )\n .option('--all', 'Show status for all files (default: only scripts .ts, .js)')\n .option(\n '--shallow',\n 'Skip remote-content hashing (faster; trusts the last-sync baseline, will miss edits to existing remote files)',\n )\n // `--deep` was the opt-IN flag in 1.6.1 and earlier (default was\n // shallow). Deep is now the default, so the flag is a no-op \u2014 but\n // we still accept it so existing scripts that pass `--deep` keep\n // working. Same for push.\n .option('--deep', '(Deprecated; now the default) Hash remote content to detect remote-side edits')\n .option('--include-ext <ext>', 'Include extra file extension (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder (repeatable)', collectValues, [])\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const filesDir = getTenantFilesDir(tenant);\n const localPathDisplay = displayLocalPath(filesDir);\n\n if (!fs.existsSync(filesDir)) {\n logger.warning(`Local folder not found: ${localPathDisplay}`);\n logger.dim('Run \"farseer pull <tenant>\" to download files from the instance.');\n return;\n }\n\n logger.info(`Comparing local (${localPathDisplay}) with remote (Files/)...`);\n console.log();\n\n const syncService = new SyncService(tenant, clientResult.client);\n\n try {\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n // Deep is the default. `--shallow` opts out and reuses the\n // last-pulled baseline as the \"current remote hash\", which\n // cannot detect content edits to existing remote files \u2014\n // surfaced via `status.deepCompare = false` for honest\n // reporting downstream.\n const deep = !options.shallow;\n const status = await syncService.getStatus({\n all: options.all,\n deep,\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n });\n\n // Fetch app status before the early-return gate; otherwise\n // pure app drift (args diverged on remote, no file changes)\n // reports as \"Everything in sync\".\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n const appStatus = await appSyncService.getStatus();\n const hasAppChanges =\n appStatus.newLocal.length > 0 || appStatus.newRemote.length > 0 || appStatus.modified.length > 0;\n\n const hasChanges =\n status.modifiedLocally.length > 0 ||\n status.modifiedRemotely.length > 0 ||\n status.addedLocally.length > 0 ||\n status.addedRemotely.length > 0 ||\n status.deletedLocally.length > 0 ||\n status.deletedRemotely.length > 0 ||\n status.conflicts.length > 0 ||\n hasAppChanges;\n\n if (!hasChanges) {\n // Surface the out-of-scope warning BEFORE the success\n // line so the \"within current scope\" qualifier reads\n // as a follow-up to the count the user just saw, not\n // a contradiction of a bare \"Everything is in sync!\".\n reportIgnoredLocal(status.ignoredLocal, status.ignoredLocalTotal);\n if (status.deepCompare) {\n if (status.ignoredLocalTotal > 0) {\n logger.success('Everything is in sync within current scope.');\n logger.dim(\n `(${status.ignoredLocalTotal} file(s) outside scope were not compared \u2014 see warning above for details.)`,\n );\n } else {\n logger.success('Everything is in sync!');\n }\n } else {\n // Fast mode reuses the last-pulled baseline for remote\n // hashes \u2014 it CANNOT detect content edits to existing\n // remote files. Be honest about what was checked.\n logger.info('Local matches the last-pull baseline.');\n logger.dim(\n 'Remote-side content edits not checked (--shallow). Drop the flag to verify against remote.',\n );\n }\n logger.dim(`${status.inSync.length} file(s) synchronized.`);\n if (appStatus.synced.length > 0) {\n logger.dim(`${appStatus.synced.length} app(s) synchronized.`);\n }\n return;\n }\n\n if (\n status.addedLocally.length > 0 ||\n status.modifiedLocally.length > 0 ||\n status.deletedLocally.length > 0\n ) {\n console.log(chalk.bold('Local changes:'));\n for (const file of status.addedLocally) console.log(chalk.green(` + ${file}`));\n for (const file of status.modifiedLocally) console.log(chalk.yellow(` M ${file}`));\n for (const file of status.deletedLocally) console.log(chalk.red(` - ${file}`));\n console.log();\n }\n\n const syncState = syncService.loadSyncState();\n if (\n status.addedRemotely.length > 0 ||\n status.modifiedRemotely.length > 0 ||\n status.deletedRemotely.length > 0\n ) {\n console.log(chalk.bold('Remote changes:'));\n for (const file of status.addedRemotely) console.log(chalk.cyan(` + ${file}`));\n for (const file of status.modifiedRemotely) {\n // Modified-on-remote rows pick up `(by <name>)` when\n // the recorded sync metadata knows who last uploaded\n // the file. Falls back to email when only that's set.\n const metadata = syncState.files[file]?.metadata;\n const uploaderInfo = metadata?.uploaderName\n ? ` (by ${metadata.uploaderName})`\n : metadata?.uploaderEmail\n ? ` (by ${metadata.uploaderEmail})`\n : '';\n console.log(chalk.cyan(` M ${file}`) + chalk.dim(uploaderInfo));\n }\n for (const file of status.deletedRemotely) console.log(chalk.red(` - ${file}`));\n console.log();\n }\n\n if (status.conflicts.length > 0) {\n console.log(chalk.red.bold('Conflicts:'));\n for (const conflict of status.conflicts) {\n console.log(chalk.red(` ! ${conflict.filePath}`));\n console.log(chalk.dim(` ${conflict.description}`));\n }\n console.log();\n logger.dim(`Resolve conflicts during pull: farseer pull ${tenant}`);\n console.log();\n }\n\n // App diff (already fetched above so the early-return path\n // can short-circuit correctly). Render only \u2014 no extra API call.\n if (hasAppChanges) {\n console.log(chalk.bold('Apps:'));\n console.log();\n\n if (appStatus.newLocal.length > 0) {\n console.log(chalk.green('New local apps (to be created on remote):'));\n for (const app of appStatus.newLocal) {\n console.log(chalk.green(` + ${app}`));\n }\n console.log();\n }\n\n if (appStatus.newRemote.length > 0) {\n console.log(chalk.cyan('New remote apps (to be downloaded):'));\n for (const app of appStatus.newRemote) {\n console.log(chalk.cyan(` + ${app}`));\n }\n console.log();\n }\n\n if (appStatus.modified.length > 0) {\n console.log(chalk.yellow('Modified apps:'));\n for (const app of appStatus.modified) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n console.log();\n }\n\n if (appStatus.synced.length > 0) {\n logger.dim(`${appStatus.synced.length} app(s) in sync.`);\n }\n } else if (appStatus.synced.length > 0) {\n logger.dim(`${appStatus.synced.length} app(s) in sync.`);\n }\n\n console.log();\n reportIgnoredLocal(status.ignoredLocal, status.ignoredLocalTotal);\n if (!status.deepCompare) {\n // Fast mode skipped the remote-content hash check, so the\n // listing above may be incomplete \u2014 content edits to\n // existing remote files won't appear. Tell the user.\n logger.dim('--shallow: remote-content edits to existing files were NOT checked.');\n }\n logger.dim('Use \"farseer push <tenant>\" to upload local changes.');\n logger.dim('Use \"farseer pull <tenant>\" to download remote changes.');\n } catch (error) {\n logger.error('Failed to check status.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,4BAA8D;AAC9D,yBAA4B;AAC5B,4BAA+B;AAC/B,qBAAiF;AACjF,wBAAmD;AACnD,2BAAmC;AACnC,SAAoB;AAEb,SAAS,sBAAsB,SAAwB;AAC1D,UACK,QAAQ,uBAAuB,EAC/B;AAAA,IACG;AAAA,EACJ,EACC,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { getTenantFilesDir, resolveTenantWithOrgMapping, displayLocalPath } from '../utils/helpers';\nimport { collectValues, normalizeExtensions } from '../utils/cliOptions';\nimport { reportIgnoredLocal } from '../utils/syncReporting';\nimport * as fs from 'fs';\n\nexport function registerStatusCommand(program: Command): void {\n program\n .command('status [org] [tenant]')\n .description(\n 'Show sync status between local and remote\\n\\nUsage: status <org> <tenant> OR status <tenant> (if org is known)',\n )\n .option(\n '--all',\n 'Show status for every non-hidden, non-blocklisted file (default: developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist). Data files (.csv, .xlsx, .parquet, \u2026) are backend-accepted but excluded from default \u2014 opt in via --include-ext .csv or `farseer config include --ext .csv`.',\n )\n .option(\n '--shallow',\n 'Skip remote-content hashing (faster; trusts the last-sync baseline, will miss edits to existing remote files)',\n )\n // `--deep` was the opt-IN flag in 1.6.1 and earlier (default was\n // shallow). Deep is now the default, so the flag is a no-op \u2014 but\n // we still accept it so existing scripts that pass `--deep` keep\n // working. Same for push.\n .option('--deep', '(Deprecated; now the default) Hash remote content to detect remote-side edits')\n .option('--include-ext <ext>', 'Include extra file extension (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder (repeatable)', collectValues, [])\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const filesDir = getTenantFilesDir(tenant);\n const localPathDisplay = displayLocalPath(filesDir);\n\n if (!fs.existsSync(filesDir)) {\n logger.warning(`Local folder not found: ${localPathDisplay}`);\n logger.dim('Run \"farseer pull <tenant>\" to download files from the instance.');\n return;\n }\n\n logger.info(`Comparing local (${localPathDisplay}) with remote (Files/)...`);\n console.log();\n\n const syncService = new SyncService(tenant, clientResult.client);\n\n try {\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n // Deep is the default. `--shallow` opts out and reuses the\n // last-pulled baseline as the \"current remote hash\", which\n // cannot detect content edits to existing remote files \u2014\n // surfaced via `status.deepCompare = false` for honest\n // reporting downstream.\n const deep = !options.shallow;\n const status = await syncService.getStatus({\n all: options.all,\n deep,\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n });\n\n // Fetch app status before the early-return gate; otherwise\n // pure app drift (args diverged on remote, no file changes)\n // reports as \"Everything in sync\".\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n const appStatus = await appSyncService.getStatus();\n const hasAppChanges =\n appStatus.newLocal.length > 0 || appStatus.newRemote.length > 0 || appStatus.modified.length > 0;\n\n const hasChanges =\n status.modifiedLocally.length > 0 ||\n status.modifiedRemotely.length > 0 ||\n status.addedLocally.length > 0 ||\n status.addedRemotely.length > 0 ||\n status.deletedLocally.length > 0 ||\n status.deletedRemotely.length > 0 ||\n status.conflicts.length > 0 ||\n hasAppChanges;\n\n if (!hasChanges) {\n // Surface the out-of-scope warning BEFORE the success\n // line so the \"within current scope\" qualifier reads\n // as a follow-up to the count the user just saw, not\n // a contradiction of a bare \"Everything is in sync!\".\n reportIgnoredLocal(status.ignoredLocal, status.ignoredLocalTotal);\n if (status.deepCompare) {\n if (status.ignoredLocalTotal > 0) {\n logger.success('Everything is in sync within current scope.');\n logger.dim(\n `(${status.ignoredLocalTotal} file(s) outside scope were not compared \u2014 see warning above for details.)`,\n );\n } else {\n logger.success('Everything is in sync!');\n }\n } else {\n // Fast mode reuses the last-pulled baseline for remote\n // hashes \u2014 it CANNOT detect content edits to existing\n // remote files. Be honest about what was checked.\n logger.info('Local matches the last-pull baseline.');\n logger.dim(\n 'Remote-side content edits not checked (--shallow). Drop the flag to verify against remote.',\n );\n }\n logger.dim(`${status.inSync.length} file(s) synchronized.`);\n if (appStatus.synced.length > 0) {\n logger.dim(`${appStatus.synced.length} app(s) synchronized.`);\n }\n return;\n }\n\n if (\n status.addedLocally.length > 0 ||\n status.modifiedLocally.length > 0 ||\n status.deletedLocally.length > 0\n ) {\n console.log(chalk.bold('Local changes:'));\n for (const file of status.addedLocally) console.log(chalk.green(` + ${file}`));\n for (const file of status.modifiedLocally) console.log(chalk.yellow(` M ${file}`));\n for (const file of status.deletedLocally) console.log(chalk.red(` - ${file}`));\n console.log();\n }\n\n const syncState = syncService.loadSyncState();\n if (\n status.addedRemotely.length > 0 ||\n status.modifiedRemotely.length > 0 ||\n status.deletedRemotely.length > 0\n ) {\n console.log(chalk.bold('Remote changes:'));\n for (const file of status.addedRemotely) console.log(chalk.cyan(` + ${file}`));\n for (const file of status.modifiedRemotely) {\n // Modified-on-remote rows pick up `(by <name>)` when\n // the recorded sync metadata knows who last uploaded\n // the file. Falls back to email when only that's set.\n const metadata = syncState.files[file]?.metadata;\n const uploaderInfo = metadata?.uploaderName\n ? ` (by ${metadata.uploaderName})`\n : metadata?.uploaderEmail\n ? ` (by ${metadata.uploaderEmail})`\n : '';\n console.log(chalk.cyan(` M ${file}`) + chalk.dim(uploaderInfo));\n }\n for (const file of status.deletedRemotely) console.log(chalk.red(` - ${file}`));\n console.log();\n }\n\n if (status.conflicts.length > 0) {\n console.log(chalk.red.bold('Conflicts:'));\n for (const conflict of status.conflicts) {\n console.log(chalk.red(` ! ${conflict.filePath}`));\n console.log(chalk.dim(` ${conflict.description}`));\n }\n console.log();\n logger.dim(`Resolve conflicts during pull: farseer pull ${tenant}`);\n console.log();\n }\n\n // App diff (already fetched above so the early-return path\n // can short-circuit correctly). Render only \u2014 no extra API call.\n if (hasAppChanges) {\n console.log(chalk.bold('Apps:'));\n console.log();\n\n if (appStatus.newLocal.length > 0) {\n console.log(chalk.green('New local apps (to be created on remote):'));\n for (const app of appStatus.newLocal) {\n console.log(chalk.green(` + ${app}`));\n }\n console.log();\n }\n\n if (appStatus.newRemote.length > 0) {\n console.log(chalk.cyan('New remote apps (to be downloaded):'));\n for (const app of appStatus.newRemote) {\n console.log(chalk.cyan(` + ${app}`));\n }\n console.log();\n }\n\n if (appStatus.modified.length > 0) {\n console.log(chalk.yellow('Modified apps:'));\n for (const app of appStatus.modified) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n console.log();\n }\n\n if (appStatus.synced.length > 0) {\n logger.dim(`${appStatus.synced.length} app(s) in sync.`);\n }\n } else if (appStatus.synced.length > 0) {\n logger.dim(`${appStatus.synced.length} app(s) in sync.`);\n }\n\n console.log();\n reportIgnoredLocal(status.ignoredLocal, status.ignoredLocalTotal);\n if (!status.deepCompare) {\n // Fast mode skipped the remote-content hash check, so the\n // listing above may be incomplete \u2014 content edits to\n // existing remote files won't appear. Tell the user.\n logger.dim('--shallow: remote-content edits to existing files were NOT checked.');\n }\n logger.dim('Use \"farseer push <tenant>\" to upload local changes.');\n logger.dim('Use \"farseer pull <tenant>\" to download remote changes.');\n } catch (error) {\n logger.error('Failed to check status.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mB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AAA,MAC5B;AACA,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var import_status = require("./commands/status");
|
|
|
35
35
|
var import_diff = require("./commands/diff");
|
|
36
36
|
var import_pull = require("./commands/pull");
|
|
37
37
|
var import_push = require("./commands/push");
|
|
38
|
+
var import_refresh = require("./commands/refresh");
|
|
38
39
|
var import_run = require("./commands/run");
|
|
39
40
|
var import_install = require("./commands/install");
|
|
40
41
|
var import_whoami = require("./commands/whoami");
|
|
@@ -73,6 +74,13 @@ ${import_chalk.default.bold.underline("Tenant Resolution")}
|
|
|
73
74
|
${import_chalk.default.green("$")} farseer pull ${import_chalk.default.cyan("salvus-prodaja")} ${import_chalk.default.dim("After that: just <tenant> (org is remembered)")}
|
|
74
75
|
${import_chalk.default.green("$")} farseer push ${import_chalk.default.dim("Or omit entirely if checked out")}
|
|
75
76
|
|
|
77
|
+
${import_chalk.default.bold.underline("Workspace Layout")} ${import_chalk.default.dim("(created by farseer checkout)")}
|
|
78
|
+
${import_chalk.default.dim("farseer-apps/<tenant>/files/")} Your scripts and data \u2014 sync source
|
|
79
|
+
${import_chalk.default.dim("farseer-apps/<tenant>/apps/")} App configs (mirrored remote Apps)
|
|
80
|
+
${import_chalk.default.dim("farseer-apps/<tenant>/.farseer-sync.json")} Per-machine diff baseline (do not commit; gitignored)
|
|
81
|
+
${import_chalk.default.dim("farseer-apps/<tenant>/package.json")} Node deps for run / install
|
|
82
|
+
If the baseline drifts out of step, ${import_chalk.default.cyan("farseer refresh")} rebuilds it from a fresh remote hash fetch and current local files.
|
|
83
|
+
|
|
76
84
|
${import_chalk.default.bold.underline("Authentication")}
|
|
77
85
|
login Login via browser (OAuth)
|
|
78
86
|
logout [tenant] Logout and remove credentials
|
|
@@ -97,7 +105,7 @@ ${import_chalk.default.bold.underline("Configuration")} ${import_chalk.default.
|
|
|
97
105
|
|
|
98
106
|
${import_chalk.default.bold.underline("Sync Operations")} ${import_chalk.default.dim("(tenant optional if checked out)")}
|
|
99
107
|
pull [org] [tenant] Pull files and apps from remote
|
|
100
|
-
${import_chalk.default.dim("--all")} Download
|
|
108
|
+
${import_chalk.default.dim("--all")} Download every non-hidden, non-blocklisted file (default: developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist)
|
|
101
109
|
${import_chalk.default.dim("--force")} Mirror remote \u2192 local: overwrite local edits AND delete local-only (asks confirmation)
|
|
102
110
|
${import_chalk.default.dim("-y, --yes")} Skip confirm when local has uncommitted changes
|
|
103
111
|
${import_chalk.default.dim("--include-ext <ext>")} Include extra extension (repeatable)
|
|
@@ -109,11 +117,14 @@ ${import_chalk.default.bold.underline("Sync Operations")} ${import_chalk.defaul
|
|
|
109
117
|
${import_chalk.default.dim("--include-ext <ext>")} Include extra extension (repeatable)
|
|
110
118
|
${import_chalk.default.dim("--include-folder <folder>")} Include all files in folder (repeatable)
|
|
111
119
|
status [tenant] Show sync status (local vs remote)
|
|
112
|
-
${import_chalk.default.dim("--all")} Show
|
|
120
|
+
${import_chalk.default.dim("--all")} Show every non-hidden, non-blocklisted file (default: developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist)
|
|
113
121
|
${import_chalk.default.dim("--shallow")} Skip remote-content hash check (faster, but may miss remote edits)
|
|
114
122
|
${import_chalk.default.dim("--include-ext <ext>")} Include extra extension (repeatable)
|
|
115
123
|
${import_chalk.default.dim("--include-folder <folder>")} Include all files in folder (repeatable)
|
|
116
124
|
diff [tenant] [file] Show file differences
|
|
125
|
+
refresh [org] [tenant] Rebuild the local sync baseline (.farseer-sync.json)
|
|
126
|
+
${import_chalk.default.dim("--include-ext <ext>")} Include extra extension (repeatable)
|
|
127
|
+
${import_chalk.default.dim("--include-folder <folder>")} Include all files in folder (repeatable)
|
|
117
128
|
|
|
118
129
|
${import_chalk.default.bold.underline("App Management")} ${import_chalk.default.dim("(tenant optional if checked out)")}
|
|
119
130
|
app list [tenant] List all apps
|
|
@@ -235,6 +246,7 @@ ${import_chalk.default.bold.underline("Examples")}
|
|
|
235
246
|
(0, import_diff.registerDiffCommand)(program);
|
|
236
247
|
(0, import_pull.registerPullCommand)(program);
|
|
237
248
|
(0, import_push.registerPushCommand)(program);
|
|
249
|
+
(0, import_refresh.registerRefreshCommand)(program);
|
|
238
250
|
(0, import_run.registerRunCommand)(program);
|
|
239
251
|
(0, import_install.registerInstallCommand)(program);
|
|
240
252
|
(0, import_whoami.registerWhoamiCommand)(program);
|