farseer-cli 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +102 -30
  2. package/dist/commands/checkout.js +3 -8
  3. package/dist/commands/checkout.js.map +2 -2
  4. package/dist/commands/pull.js +159 -46
  5. package/dist/commands/pull.js.map +2 -2
  6. package/dist/commands/push.js +185 -75
  7. package/dist/commands/push.js.map +2 -2
  8. package/dist/commands/run.js +31 -30
  9. package/dist/commands/run.js.map +2 -2
  10. package/dist/commands/status.js +26 -33
  11. package/dist/commands/status.js.map +2 -2
  12. package/dist/index.js +5 -3
  13. package/dist/index.js.map +2 -2
  14. package/dist/mcp/tools/appTools.js +6 -20
  15. package/dist/mcp/tools/appTools.js.map +2 -2
  16. package/dist/mcp/tools/authTools.js +2 -1
  17. package/dist/mcp/tools/authTools.js.map +2 -2
  18. package/dist/mcp/tools/cellTools.js +2 -10
  19. package/dist/mcp/tools/cellTools.js.map +2 -2
  20. package/dist/mcp/tools/dashboardTools.js +12 -23
  21. package/dist/mcp/tools/dashboardTools.js.map +2 -2
  22. package/dist/mcp/tools/dataTools.js +5 -16
  23. package/dist/mcp/tools/dataTools.js.map +2 -2
  24. package/dist/mcp/tools/folderTools.js +3 -11
  25. package/dist/mcp/tools/folderTools.js.map +2 -2
  26. package/dist/mcp/tools/modelTools.js +14 -40
  27. package/dist/mcp/tools/modelTools.js.map +2 -2
  28. package/dist/mcp/tools/runTools.js +3 -8
  29. package/dist/mcp/tools/runTools.js.map +2 -2
  30. package/dist/mcp/tools/sheetTools.js +11 -22
  31. package/dist/mcp/tools/sheetTools.js.map +2 -2
  32. package/dist/mcp/tools/syncTools.js +132 -47
  33. package/dist/mcp/tools/syncTools.js.map +2 -2
  34. package/dist/mcp/utils/helpers.js +2 -2
  35. package/dist/mcp/utils/helpers.js.map +2 -2
  36. package/dist/services/appSyncService.js +3 -2
  37. package/dist/services/appSyncService.js.map +2 -2
  38. package/dist/services/farseerApi.js +13 -36
  39. package/dist/services/farseerApi.js.map +2 -2
  40. package/dist/services/farseerFactory.js +1 -1
  41. package/dist/services/farseerFactory.js.map +2 -2
  42. package/dist/services/farseerService.js +22 -14
  43. package/dist/services/farseerService.js.map +2 -2
  44. package/dist/services/syncService.js +322 -182
  45. package/dist/services/syncService.js.map +3 -3
  46. package/dist/utils/cliOptions.js +36 -0
  47. package/dist/utils/cliOptions.js.map +7 -0
  48. package/dist/utils/errorFormatter.js +152 -0
  49. package/dist/utils/errorFormatter.js.map +7 -0
  50. package/dist/utils/fileLogger.js +13 -0
  51. package/dist/utils/fileLogger.js.map +2 -2
  52. package/dist/utils/fileValidation.js +180 -0
  53. package/dist/utils/fileValidation.js.map +7 -0
  54. package/dist/utils/helpers.js +85 -14
  55. package/dist/utils/helpers.js.map +2 -2
  56. package/docs/cli-guide.md +49 -4
  57. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/commands/pull.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 } from '../services/farseerFactory';\nimport { SyncService, ConflictResolutions } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport {\n getTenantDir,\n ensureDirectoryExists,\n resolveTenantWithOrgMapping,\n appendToAuditLog,\n AuditLogEntry,\n} from '../utils/helpers';\n\nexport function registerPullCommand(program: Command): void {\n program\n .command('pull [org] [tenant]')\n .description(\n 'Pull files from Farseer instance to local\\n\\nUsage: pull <org> <tenant> OR pull <tenant> (if org is known)',\n )\n .option('--all', 'Pull all files (default: only scripts .ts, .js)')\n .option('--force', 'Force pull, overwriting local changes on conflicts')\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 syncService = new SyncService(tenant, clientResult.client);\n\n // Step 1: Ensure tenant folder exists\n const tenantDir = getTenantDir(tenant);\n ensureDirectoryExists(tenantDir);\n\n // Create default package.json if it doesn't exist\n await createDefaultPackageJson(tenantDir, tenant);\n\n // Step 2: Pull files from Farseer\n console.log();\n console.log(chalk.bold('\u2550\u2550\u2550 Files \u2550\u2550\u2550'));\n logger.info(`Pulling files from ${tenant}...`);\n\n try {\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n const syncOptions = {\n all: options.all,\n force: options.force,\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n };\n let result = await syncService.pull(syncOptions);\n\n // Handle conflicts interactively\n if (result.conflicts.length > 0 && !options.force) {\n console.log();\n console.log(chalk.red.bold(`${result.conflicts.length} conflict(s) detected:`));\n console.log();\n\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\n const resolutions: ConflictResolutions = {};\n\n for (const conflict of result.conflicts) {\n let choices: { name: string; value: string }[];\n\n if (conflict.type === 'local_modified_remote_deleted') {\n choices = [\n { name: 'Keep local (keep your modified file)', value: 'keep_local' },\n { name: 'Accept deletion (delete local file)', value: 'keep_remote' },\n ];\n } else if (conflict.type === 'local_deleted_remote_modified') {\n choices = [\n { name: \"Keep deleted (don't restore file)\", value: 'keep_local' },\n { name: 'Restore remote version', value: 'keep_remote' },\n ];\n } else {\n choices = [\n { name: 'Keep local version', value: 'keep_local' },\n { name: 'Use remote version (overwrite local)', value: 'keep_remote' },\n { name: 'Keep both (save remote as .remote file)', value: 'keep_both' },\n ];\n }\n\n const answer = await inquirer.prompt([\n {\n type: 'list',\n name: 'resolution',\n message: `${conflict.filePath} - ${conflict.description}`,\n choices,\n },\n ]);\n\n resolutions[conflict.filePath] = answer.resolution;\n }\n\n // Re-pull with resolutions\n result = await syncService.pull({ ...syncOptions, conflictResolutions: resolutions });\n }\n\n if (result.downloaded.length > 0) {\n console.log(chalk.green('Downloaded:'));\n for (const file of result.downloaded) {\n console.log(chalk.green(` + ${file}`));\n }\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted (removed from remote):'));\n for (const file of result.deleted) {\n console.log(chalk.red(` - ${file}`));\n }\n }\n\n if (result.conflictFilesWritten.length > 0) {\n console.log(chalk.yellow('Conflict files created:'));\n for (const file of result.conflictFilesWritten) {\n console.log(chalk.yellow(` ~ ${file}`));\n }\n }\n\n logger.dim(\n `Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`,\n );\n\n // Create audit log entries for downloaded files\n if (result.downloaded.length > 0) {\n const syncState = syncService.loadSyncState();\n const auditEntries: AuditLogEntry[] = result.downloaded.map((filePath) => ({\n operation: 'pulled' as const,\n filePath,\n uploadTime: syncState.files[filePath]?.metadata?.uploadTime,\n uploaderEmail: syncState.files[filePath]?.metadata?.uploaderEmail,\n uploaderName: syncState.files[filePath]?.metadata?.uploaderName,\n }));\n\n appendToAuditLog(tenant, auditEntries);\n }\n\n let hasChanges = result.downloaded.length > 0 || result.deleted.length > 0;\n\n // Step 3: Pull apps\n let appResult = {\n created: [] as string[],\n updated: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n };\n\n console.log();\n console.log(chalk.bold('\u2550\u2550\u2550 Apps \u2550\u2550\u2550'));\n logger.info(`Pulling apps from ${tenant}...`);\n\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appResult = await appSyncService.pull();\n\n if (appResult.created.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appResult.created) {\n console.log(chalk.green(` + ${app}`));\n }\n }\n\n if (appResult.updated.length > 0) {\n console.log(chalk.yellow('Updated apps:'));\n for (const app of appResult.updated) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n }\n\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps (removed from remote):'));\n for (const app of appResult.deleted) {\n console.log(chalk.red(` - ${app}`));\n }\n }\n\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n\n hasChanges =\n hasChanges ||\n appResult.created.length > 0 ||\n appResult.updated.length > 0 ||\n appResult.deleted.length > 0;\n\n if (!hasChanges) {\n logger.success('Already up to date.');\n return;\n }\n\n console.log();\n console.log(chalk.bold('\u2550\u2550\u2550 Summary \u2550\u2550\u2550'));\n logger.success('Pull complete!');\n logger.dim(\n `Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`,\n );\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n } catch (error) {\n fileLogger.error('pull', error);\n logger.error('Pull failed.');\n if (error instanceof Error) {\n logger.error(error.message);\n }\n const logPath = fileLogger.getLogPath();\n if (logPath) {\n logger.dim(`Debug log: ${logPath}`);\n }\n process.exit(1);\n }\n });\n}\n\nasync function createDefaultPackageJson(tenantDir: string, tenant: string): Promise<void> {\n const fs = await import('fs');\n const path = await import('path');\n\n const packageJsonPath = path.join(tenantDir, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n return;\n }\n\n const packageJson = {\n name: `farseer-scripts-${tenant}`,\n version: '1.0.0',\n description: `Farseer App scripts for ${tenant}`,\n main: 'src/index.ts',\n scripts: {},\n keywords: ['farseer', 'scripts', tenant],\n author: 'Farseer',\n license: 'ISC',\n dependencies: {\n '@google-cloud/bigquery': '^7.9.0',\n '@google-cloud/storage': '^7.12.1',\n '@googleapis/sheets': '^5.0.5',\n '@sendgrid/mail': '^7.7.0',\n '@types/node-forge': '^1.3.11',\n '@xmldom/xmldom': '^0.9.8',\n arquero: '^5.4.1',\n axios: '^1.10.0',\n 'axios-retry': '^3.9.1',\n 'basic-ftp': '^5.0.5',\n 'client-oauth2': '^4.3.3',\n 'csv-parser': '^3.0.0',\n dotenv: '^16.4.5',\n 'draft-js': '^0.11.7',\n exceljs: '^4.4.0',\n 'farseer-client':\n 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar',\n 'farseer-client-axios':\n 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar',\n 'fast-xml-parser': '^4.5.0',\n 'form-data': '^4.0.0',\n googleapis: '^144.0.0',\n heapdump: '^0.3.15',\n 'image-size': '^1.1.1',\n jszip: '^3.10.1',\n 'lossless-json': '^4.0.1',\n mssql: '^10.0.4',\n 'node-fetch': '^2.7.0',\n 'node-forge': '^1.3.1',\n 'node-sp-auth': '^3.0.8',\n numeral: '^2.0.6',\n oracledb: '^6.6.0',\n papaparse: '^5.5.1',\n pdfkit: '^0.14.0',\n pdfmake: '^0.2.20',\n soap: '^1.1.11',\n 'ssh2-sftp-client': '^11.0.0',\n 'strong-soap': '^4.1.13',\n 'ts-node': '^10.9.2',\n typescript: '^5.5.4',\n undici: '^6.19.8',\n uuid: '^11.1.0',\n winston: '^3.17.0',\n xlsx: 'https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz',\n 'xml-crypto': '^6.1.2',\n },\n devDependencies: {\n '@types/draft-js': '^0.11.18',\n '@types/heapdump': '^0.3.4',\n '@types/mssql': '^9.1.5',\n '@types/node': '^18.19.50',\n '@types/node-fetch': '^2.6.11',\n '@types/numeral': '^2.0.5',\n '@types/oracledb': '^6.5.3',\n '@types/papaparse': '^5.3.15',\n '@types/pdfmake': '^0.2.11',\n '@types/soap': '^0.18.0',\n '@types/ssh2-sftp-client': '^9.0.4',\n '@types/tough-cookie': '^4.0.5',\n '@types/uuid': '^10.0.0',\n '@types/xmldom': '^0.1.34',\n 'ts-node': '^10.9.2',\n typescript: '^5.5.4',\n },\n };\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');\n logger.dim(`Created package.json for ${tenant}`);\n}\n\nfunction collectValues(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n\nfunction normalizeExtensions(exts: string[]): string[] {\n return exts.map((ext) => (ext.startsWith('.') ? ext.toLowerCase() : `.${ext.toLowerCase()}`));\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,sBAAqB;AACrB,oBAAuB;AACvB,wBAA2B;AAC3B,4BAA8D;AAC9D,yBAAiD;AACjD,4BAA+B;AAC/B,qBAMO;AAEA,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,qBAAqB,EAC7B;AAAA,IACG;AAAA,EACJ,EACC,OAAO,SAAS,iDAAiD,EACjE,OAAO,WAAW,oDAAoD,EACtE,OAAO,uBAAuB,6CAA6C,eAAe,CAAC,CAAC,EAC5F,OAAO,6BAA6B,4CAA4C,eAAe,CAAC,CAAC,EACjG,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,cAAc,IAAI,+BAAY,QAAQ,aAAa,MAAM;AAG/D,UAAM,gBAAY,6BAAa,MAAM;AACrC,8CAAsB,SAAS;AAG/B,UAAM,yBAAyB,WAAW,MAAM;AAGhD,YAAQ,IAAI;AACZ,YAAQ,IAAI,aAAAA,QAAM,KAAK,6CAAe,CAAC;AACvC,yBAAO,KAAK,sBAAsB,MAAM,KAA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MACf,iBAAiB;AAAA,MACjB,WAAW;AAAA,MACX,YAAY;AAAA,IAChB;AAAA,EACJ;AAEA,KAAG,cAAc,iBAAiB,KAAK,UAAU,aAAa,MAAM,CAAC,GAAG,OAAO;AAC/E,uBAAO,IAAI,4BAA4B,MAAM,EAAE;AACnD;AAEA,SAAS,cAAc,OAAe,UAA8B;AAChE,SAAO,SAAS,OAAO,CAAC,KAAK,CAAC;AAClC;AAEA,SAAS,oBAAoB,MAA0B;AACnD,SAAO,KAAK,IAAI,CAAC,QAAS,IAAI,WAAW,GAAG,IAAI,IAAI,YAAY,IAAI,IAAI,IAAI,YAAY,CAAC,EAAG;AAChG;",
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 } from '../services/farseerFactory';\nimport { SyncService, ConflictResolutions, SyncStatus } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport {\n getTenantDir,\n getTenantFilesDir,\n ensureDirectoryExists,\n resolveTenantWithOrgMapping,\n appendToAuditLog,\n AuditLogEntry,\n safeResolveWithinBase,\n} from '../utils/helpers';\nimport { formatClientError } from '../utils/errorFormatter';\nimport { isLikelyTextFile } from '../utils/fileValidation';\nimport { collectValues, normalizeExtensions } from '../utils/cliOptions';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\n/**\n * Pull semantics:\n *\n * farseer pull\n * 1. Show local-vs-remote diff. If you have unsynced local edits the\n * command stops here and asks for confirmation before doing\n * anything (we don't merge silently).\n * 2. Apply remote-side changes (downloads, deletions, modifications).\n * Per-file conflicts are resolved interactively.\n *\n * farseer pull --force\n * Hard reset to remote. After it runs, the working tree mirrors what's\n * on remote: any file that exists locally but not on remote is deleted,\n * remote versions overwrite local edits, deletions are accepted. Always\n * asks for confirmation because the operation is destructive.\n */\nexport function registerPullCommand(program: Command): void {\n program\n .command('pull [org] [tenant]')\n .description(\n 'Pull files from Farseer instance to local\\n\\nUsage: pull <org> <tenant> OR pull <tenant> (if org is known)',\n )\n .option('--all', 'Pull all files (default: only scripts .ts, .js)')\n .option(\n '--force',\n 'Hard reset local to remote within the current sync scope: overwrite local edits, delete local-only files. Files outside scope (e.g. previously-pulled .csv on a default --force run without --include-ext .csv) are NOT touched. Always asks for confirmation.',\n )\n .option('-y, --yes', 'Skip confirmation when local has uncommitted changes (ignored under --force)')\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 syncService = new SyncService(tenant, clientResult.client);\n\n const tenantDir = getTenantDir(tenant);\n ensureDirectoryExists(tenantDir);\n\n await createDefaultPackageJson(tenantDir, tenant);\n\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n const filterOptions = {\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n };\n const syncOptions = {\n all: options.all,\n force: options.force,\n ...filterOptions,\n };\n\n // Step 1: Inspect current state. We do this BEFORE mutating\n // anything so the user can decide whether to bail.\n const filesDir = getTenantFilesDir(tenant);\n const folderInitialised = fs.existsSync(filesDir);\n let preStatus: SyncStatus | null = null;\n let preStatusError: Error | null = null;\n if (folderInitialised) {\n try {\n preStatus = await syncService.getStatus({ ...filterOptions, all: options.all, deep: false });\n } catch (error) {\n preStatusError = error as Error;\n logger.dim(`Could not compute pre-pull status: ${preStatusError.message}`);\n }\n }\n\n const localChanges = preStatus\n ? preStatus.addedLocally.length +\n preStatus.modifiedLocally.length +\n preStatus.deletedLocally.length +\n preStatus.conflicts.length\n : 0;\n\n // Step 2: Decide whether to confirm. The matrix:\n // --force \u2192 always confirm (destructive reset).\n // uncommitted changes + not -y \u2192 confirm (avoid silent merge).\n // clean tree \u2192 just go.\n if (options.force) {\n console.log();\n console.log(chalk.red.bold('--force will hard-reset local to match remote.'));\n if (preStatus) {\n summarisePreStatus(preStatus);\n } else if (preStatusError) {\n // Without a local diff we'd be confirming a destructive\n // mirror operation blind. Refuse rather than press on \u2014\n // the cost of failing here is one re-run; the cost of\n // pressing on is silent loss of in-progress files.\n console.log(\n chalk.red(\n 'Cannot show what will be lost \u2014 pre-pull status failed (see line above). Refusing to --force without visibility.',\n ),\n );\n logger.dim('Re-run after the underlying issue clears, or use a non-force pull to merge.');\n process.exit(1);\n } else {\n // Folder isn't initialised yet \u2014 first --force pull on a\n // brand-new tenant. Nothing local to lose; proceed.\n logger.dim('No local files yet \u2014 nothing to discard.');\n }\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: `Discard local changes and reset ${tenant} to remote?`,\n default: false,\n },\n ]);\n if (!confirm.proceed) {\n logger.info('Pull cancelled.');\n return;\n }\n } else if (localChanges > 0 && !options.yes) {\n console.log();\n logger.warning(`Local has ${localChanges} unsynced change(s).`);\n summarisePreStatus(preStatus!);\n logger.dim('Pull will keep your edits and merge remote-side changes around them.');\n logger.dim('To wipe local and reset to remote: re-run with --force.');\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: `Continue pulling into a dirty working tree?`,\n default: true,\n },\n ]);\n if (!confirm.proceed) {\n logger.info('Pull cancelled.');\n return;\n }\n }\n\n console.log();\n console.log(chalk.bold('\u2550\u2550\u2550 Files \u2550\u2550\u2550'));\n logger.info(`Pulling files from ${tenant}...`);\n\n try {\n let result = await syncService.pull(syncOptions);\n\n // Conflicts: prompt per file (only when not --force).\n if (result.conflicts.length > 0 && !options.force) {\n console.log();\n console.log(chalk.red.bold(`${result.conflicts.length} conflict(s) detected:`));\n console.log();\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\n const resolutions: ConflictResolutions = {};\n for (const conflict of result.conflicts) {\n let choices: { name: string; value: string }[];\n if (conflict.type === 'local_modified_remote_deleted') {\n choices = [\n { name: 'Keep local (keep your modified file)', value: 'keep_local' },\n { name: 'Accept deletion (delete local file)', value: 'keep_remote' },\n ];\n } else if (conflict.type === 'local_deleted_remote_modified') {\n choices = [\n { name: \"Keep deleted (don't restore file)\", value: 'keep_local' },\n { name: 'Restore remote version', value: 'keep_remote' },\n ];\n } else {\n choices = [\n { name: 'Keep local version', value: 'keep_local' },\n { name: 'Use remote version (overwrite local)', value: 'keep_remote' },\n { name: 'Keep both (save remote as .remote file)', value: 'keep_both' },\n ];\n // Only offer git-style merge for files we know\n // are text. Binary blobs would just get\n // corrupted by UTF-8 splicing. The service has\n // a defensive fallback for binary anyway, but\n // not showing the option avoids the confusing\n // \"I picked merge_markers but got keep_both\"\n // experience.\n if (isLikelyTextFile(conflict.filePath)) {\n choices.push({\n name: 'Merge with markers (git-style \u2014 edit file, then push to finish)',\n value: 'merge_markers',\n });\n }\n }\n const answer = await inquirer.prompt([\n {\n type: 'list',\n name: 'resolution',\n message: `${conflict.filePath} - ${conflict.description}`,\n choices,\n },\n ]);\n resolutions[conflict.filePath] = answer.resolution;\n }\n result = await syncService.pull({ ...syncOptions, conflictResolutions: resolutions });\n }\n\n if (result.downloaded.length > 0) {\n console.log(chalk.green('Downloaded:'));\n for (const file of result.downloaded) console.log(chalk.green(` + ${file}`));\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted (removed from remote):'));\n for (const file of result.deleted) console.log(chalk.red(` - ${file}`));\n }\n\n if (result.conflictFilesWritten.length > 0) {\n console.log(chalk.yellow('Conflict files created:'));\n for (const file of result.conflictFilesWritten) console.log(chalk.yellow(` ~ ${file}`));\n if (result.conflictFilesWritten.some((f) => f.includes('(merge markers)'))) {\n console.log();\n logger.dim('Files marked with \"(merge markers)\" contain git-style <<<<<<</=======/>>>>>>>');\n logger.dim('blocks. Open them, pick which version to keep, remove the marker lines,');\n logger.dim(`then run \\`farseer push ${tenant}\\` to upload the resolved version.`);\n }\n }\n\n logger.dim(\n `Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`,\n );\n\n // --force extra: also delete any local-only files. The\n // service-level pull keeps `local_new` files unchanged\n // (it's the right default for a non-destructive pull),\n // but --force at the command layer means \"mirror remote\",\n // so remove those locally.\n let extraLocalDeletes: string[] = [];\n if (options.force) {\n // Forward `--all` so `pull --force --all` wipes every\n // local-only file, not just the default-scope scripts.\n extraLocalDeletes = await wipeLocalOnly(syncService, filesDir, {\n ...filterOptions,\n all: options.all,\n });\n if (extraLocalDeletes.length > 0) {\n console.log(chalk.red('Local-only files removed (mirror remote):'));\n for (const file of extraLocalDeletes) console.log(chalk.red(` - ${file}`));\n }\n }\n\n // Audit log\n if (result.downloaded.length > 0) {\n const syncState = syncService.loadSyncState();\n const auditEntries: AuditLogEntry[] = result.downloaded.map((filePath) => ({\n operation: 'pulled' as const,\n filePath,\n uploadTime: syncState.files[filePath]?.metadata?.uploadTime,\n uploaderEmail: syncState.files[filePath]?.metadata?.uploaderEmail,\n uploaderName: syncState.files[filePath]?.metadata?.uploaderName,\n }));\n appendToAuditLog(tenant, auditEntries);\n }\n\n let hasChanges =\n result.downloaded.length > 0 || result.deleted.length > 0 || extraLocalDeletes.length > 0;\n\n console.log();\n console.log(chalk.bold('\u2550\u2550\u2550 Apps \u2550\u2550\u2550'));\n logger.info(`Pulling apps from ${tenant}...`);\n\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n const appResult = await appSyncService.pull();\n\n if (appResult.created.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appResult.created) console.log(chalk.green(` + ${app}`));\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 }\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps (removed from remote):'));\n for (const app of appResult.deleted) console.log(chalk.red(` - ${app}`));\n }\n\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n\n hasChanges =\n hasChanges ||\n appResult.created.length > 0 ||\n appResult.updated.length > 0 ||\n appResult.deleted.length > 0;\n\n if (!hasChanges) {\n logger.success('Already up to date.');\n return;\n }\n\n console.log();\n console.log(chalk.bold('\u2550\u2550\u2550 Summary \u2550\u2550\u2550'));\n logger.success('Pull complete!');\n logger.dim(\n `Files: +${result.downloaded.length} -${result.deleted.length} ${\n extraLocalDeletes.length > 0 ? `(${extraLocalDeletes.length} local-only removed) ` : ''\n }(${result.unchanged.length} unchanged)`,\n );\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n } catch (error) {\n fileLogger.error('pull', error);\n logger.error('Pull 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 * Print actual paths (not just counts) so the user can see what local\n * changes a `pull --force` is about to overwrite. Counts alone hid the\n * destructive blast radius: under `--force --all` someone could lose\n * dozens of in-progress files without knowing which ones. Cap at\n * MAX_PATHS_PER_SECTION per section to avoid scrollback floods on huge\n * trees \u2014 anything beyond that collapses into \"+ N more\".\n */\nfunction summarisePreStatus(status: SyncStatus): void {\n const MAX_PATHS_PER_SECTION = 20;\n const renderSection = (label: string, paths: string[], color: (s: string) => string) => {\n if (paths.length === 0) return;\n console.log(color(` ${label} (${paths.length}):`));\n const visible = paths.slice(0, MAX_PATHS_PER_SECTION);\n for (const p of visible) console.log(color(` ${p}`));\n if (paths.length > MAX_PATHS_PER_SECTION) {\n console.log(chalk.dim(` ... and ${paths.length - MAX_PATHS_PER_SECTION} more`));\n }\n };\n renderSection('+ new local file(s)', status.addedLocally, chalk.green);\n renderSection('M locally modified file(s)', status.modifiedLocally, chalk.yellow);\n renderSection('- locally deleted file(s)', status.deletedLocally, chalk.red);\n if (status.conflicts.length > 0) {\n const conflictPaths = status.conflicts.map((c) => c.filePath);\n renderSection('! conflict(s)', conflictPaths, chalk.red.bold);\n }\n console.log();\n}\n\n/**\n * Hard-reset helper for `pull --force`. Removes local files that have no\n * remote counterpart (the regular pull keeps them \u2014 see service comment).\n * Cleans up the syncState entry too so the next status doesn't show ghosts.\n */\nasync function wipeLocalOnly(\n syncService: SyncService,\n filesDir: string,\n filterOptions: { all?: boolean; includeExtensions?: string[]; includeFolders?: string[] },\n): Promise<string[]> {\n // `all` matters: under `pull --force --all` the user expects every\n // local-only file (not just default scripts) to be wiped. Without it\n // getStatus filters down to .ts/.js and the wipe loop never sees\n // .csv/.xlsx/etc.\n const status = await syncService.getStatus({ ...filterOptions, deep: false });\n const removed: string[] = [];\n const failed: { file: string; reason: string }[] = [];\n const syncState = syncService.loadSyncState();\n for (const file of status.addedLocally) {\n const fullPath = safeResolveWithinBase(filesDir, file);\n if (fs.existsSync(fullPath)) {\n // Wrap each unlink so a single permission error / file lock\n // doesn't strand the rest of the wipe. syncState is saved\n // incrementally as each unlink succeeds so a mid-run failure\n // leaves a consistent record for the next run, and the failed\n // list is surfaced at the end for manual cleanup.\n try {\n fs.unlinkSync(fullPath);\n removed.push(file);\n delete syncState.files[file];\n syncService.saveSyncState(syncState);\n } catch (err) {\n failed.push({ file, reason: err instanceof Error ? err.message : String(err) });\n }\n } else {\n // File was already gone \u2014 just drop the syncState entry.\n delete syncState.files[file];\n syncService.saveSyncState(syncState);\n }\n }\n if (failed.length > 0) {\n logger.warning(`${failed.length} local-only file(s) could not be removed:`);\n for (const f of failed) logger.dim(` ${f.file} \u2014 ${f.reason}`);\n }\n return removed;\n}\n\nasync function createDefaultPackageJson(tenantDir: string, tenant: string): Promise<void> {\n const packageJsonPath = path.join(tenantDir, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n return;\n }\n\n const packageJson = {\n name: `farseer-scripts-${tenant}`,\n version: '1.0.0',\n description: `Farseer App scripts for ${tenant}`,\n main: 'src/index.ts',\n scripts: {},\n keywords: ['farseer', 'scripts', tenant],\n author: 'Farseer',\n license: 'ISC',\n dependencies: {\n '@google-cloud/bigquery': '^7.9.0',\n '@google-cloud/storage': '^7.12.1',\n '@googleapis/sheets': '^5.0.5',\n '@sendgrid/mail': '^7.7.0',\n '@types/node-forge': '^1.3.11',\n '@xmldom/xmldom': '^0.9.8',\n arquero: '^5.4.1',\n axios: '^1.10.0',\n 'axios-retry': '^3.9.1',\n 'basic-ftp': '^5.0.5',\n 'client-oauth2': '^4.3.3',\n 'csv-parser': '^3.0.0',\n dotenv: '^16.4.5',\n 'draft-js': '^0.11.7',\n exceljs: '^4.4.0',\n 'farseer-client':\n 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar',\n 'farseer-client-axios':\n 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar',\n 'fast-xml-parser': '^4.5.0',\n 'form-data': '^4.0.0',\n googleapis: '^144.0.0',\n heapdump: '^0.3.15',\n 'image-size': '^1.1.1',\n jszip: '^3.10.1',\n 'lossless-json': '^4.0.1',\n mssql: '^10.0.4',\n 'node-fetch': '^2.7.0',\n 'node-forge': '^1.3.1',\n 'node-sp-auth': '^3.0.8',\n numeral: '^2.0.6',\n oracledb: '^6.6.0',\n papaparse: '^5.5.1',\n pdfkit: '^0.14.0',\n pdfmake: '^0.2.20',\n soap: '^1.1.11',\n 'ssh2-sftp-client': '^11.0.0',\n 'strong-soap': '^4.1.13',\n 'ts-node': '^10.9.2',\n typescript: '^5.5.4',\n undici: '^6.19.8',\n uuid: '^11.1.0',\n winston: '^3.17.0',\n xlsx: 'https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz',\n 'xml-crypto': '^6.1.2',\n },\n devDependencies: {\n '@types/draft-js': '^0.11.18',\n '@types/heapdump': '^0.3.4',\n '@types/mssql': '^9.1.5',\n '@types/node': '^18.19.50',\n '@types/node-fetch': '^2.6.11',\n '@types/numeral': '^2.0.5',\n '@types/oracledb': '^6.5.3',\n '@types/papaparse': '^5.3.15',\n '@types/pdfmake': '^0.2.11',\n '@types/soap': '^0.18.0',\n '@types/ssh2-sftp-client': '^9.0.4',\n '@types/tough-cookie': '^4.0.5',\n '@types/uuid': '^10.0.0',\n '@types/xmldom': '^0.1.34',\n 'ts-node': '^10.9.2',\n typescript: '^5.5.4',\n },\n };\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');\n logger.dim(`Created package.json for ${tenant}`);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,sBAAqB;AACrB,oBAAuB;AACvB,wBAA2B;AAC3B,4BAA8D;AAC9D,yBAA6D;AAC7D,4BAA+B;AAC/B,qBAQO;AACP,4BAAkC;AAClC,4BAAiC;AACjC,wBAAmD;AACnD,SAAoB;AACpB,WAAsB;AAkBf,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,qBAAqB,EAC7B;AAAA,IACG;AAAA,EACJ,EACC,OAAO,SAAS,iDAAiD,EACjE;AAAA,IACG;AAAA,IACA;AAAA,EACJ,EACC,OAAO,aAAa,8EAA8E,EAClG,OAAO,uBAAuB,6CAA6C,iCAAe,CAAC,CAAC,EAC5F,OAAO,6BAA6B,4CAA4C,iCAAe,CAAC,CAAC,EACjG,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,i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ACrB,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,kBAAkB;AAAA,MAClB,eAAe;AAAA,MACf,2BAA2B;AAAA,MAC3B,uBAAuB;AAAA,MACvB,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,WAAW;AAAA,MACX,YAAY;AAAA,IAChB;AAAA,EACJ;AAEA,KAAG,cAAc,iBAAiB,KAAK,UAAU,aAAa,MAAM,CAAC,GAAG,OAAO;AAC/E,uBAAO,IAAI,4BAA4B,MAAM,EAAE;AACnD;",
6
6
  "names": ["chalk", "inquirer"]
7
7
  }
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var push_exports = {};
30
30
  __export(push_exports, {
31
+ buildPushPlan: () => buildPushPlan,
31
32
  registerPushCommand: () => registerPushCommand
32
33
  });
33
34
  module.exports = __toCommonJS(push_exports);
@@ -39,11 +40,17 @@ var import_farseerFactory = require("../services/farseerFactory");
39
40
  var import_syncService = require("../services/syncService");
40
41
  var import_appSyncService = require("../services/appSyncService");
41
42
  var import_helpers = require("../utils/helpers");
43
+ var import_errorFormatter = require("../utils/errorFormatter");
44
+ var import_fileValidation = require("../utils/fileValidation");
45
+ var import_cliOptions = require("../utils/cliOptions");
42
46
  var fs = __toESM(require("fs"));
43
47
  function registerPushCommand(program) {
44
48
  program.command("push [org] [tenant]").description(
45
49
  "Push local files to Farseer instance\n\nUsage: push <org> <tenant> OR push <tenant> (if org is known)"
46
- ).option("--force", "Force push even if remote has changes").option("-y, --yes", "Skip confirmation prompt (auto-confirm)").option("--include-ext <ext>", "Include extra file extension (repeatable)", collectValues, []).option("--include-folder <folder>", "Include all files in folder (repeatable)", collectValues, []).action(async (arg1, arg2, options) => {
50
+ ).option(
51
+ "--force",
52
+ "Force-mirror remote to local: overwrite remote drift AND delete remote files with no local counterpart (always asks for confirmation)"
53
+ ).option("-y, --yes", "Skip confirmation prompt for non-destructive pushes (ignored under --force)").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) => {
47
54
  const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(arg1, arg2);
48
55
  const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
49
56
  if (!clientResult) {
@@ -57,7 +64,7 @@ function registerPushCommand(program) {
57
64
  process.exit(1);
58
65
  }
59
66
  const syncService = new import_syncService.SyncService(tenant, clientResult.client);
60
- const includeExtensions = normalizeExtensions(options.includeExt);
67
+ const includeExtensions = (0, import_cliOptions.normalizeExtensions)(options.includeExt);
61
68
  const includeFolders = options.includeFolder;
62
69
  const syncFilterOptions = {
63
70
  includeExtensions: includeExtensions.length > 0 ? includeExtensions : void 0,
@@ -65,70 +72,106 @@ function registerPushCommand(program) {
65
72
  };
66
73
  if (!options.force) {
67
74
  import_logger.logger.info("Checking for remote changes...");
68
- const hasRemoteChanges = await syncService.checkRemoteChanges(syncFilterOptions);
69
- if (hasRemoteChanges) {
70
- import_logger.logger.error("Remote has changes that are not synced locally.");
71
- import_logger.logger.dim(`Run 'farseer pull ${tenant}' first, then try pushing again.`);
72
- import_logger.logger.dim("Or use --force to push anyway (will overwrite remote changes).");
75
+ const driftResult = await syncService.checkRemoteChanges(syncFilterOptions);
76
+ if (driftResult.drift) {
77
+ import_logger.logger.error(
78
+ `Remote has ${driftResult.addedRemotely.length + driftResult.deletedRemotely.length} change(s) within your sync scope that aren't recorded locally.`
79
+ );
80
+ if (driftResult.addedRemotely.length > 0) {
81
+ console.log(import_chalk.default.cyan(" New on remote (need to pull):"));
82
+ for (const f of driftResult.addedRemotely) console.log(import_chalk.default.cyan(` + ${f}`));
83
+ }
84
+ if (driftResult.deletedRemotely.length > 0) {
85
+ console.log(import_chalk.default.red(" Removed on remote (need to pull to clean local):"));
86
+ for (const f of driftResult.deletedRemotely) console.log(import_chalk.default.red(` - ${f}`));
87
+ }
88
+ const scopeFlags = [];
89
+ for (const ext of options.includeExt) scopeFlags.push(`--include-ext ${ext}`);
90
+ for (const folder of options.includeFolder)
91
+ scopeFlags.push(`--include-folder "${folder}"`);
92
+ const pullCmd = ["farseer pull", tenant, ...scopeFlags].filter(Boolean).join(" ");
93
+ import_logger.logger.dim(`Run \`${pullCmd}\` first, then try pushing again.`);
94
+ import_logger.logger.dim("Or use --force to overwrite remote (this will also mirror deletions).");
73
95
  process.exit(1);
74
96
  }
75
- import_logger.logger.dim("Remote is in sync.");
76
- }
77
- const status = await syncService.getStatusFast(syncFilterOptions);
78
- const filesToPush = [...status.modifiedLocally, ...status.onlyLocal];
79
- const filesToDelete = status.modifiedRemotely.filter((f) => !fs.existsSync(`${filesDir}/${f}`));
80
- let appStatus = {
81
- newLocal: [],
82
- modified: [],
83
- newRemote: [],
84
- synced: []
85
- };
97
+ import_logger.logger.dim("Remote is in sync with local baseline.");
98
+ }
99
+ const status = await syncService.getStatus({
100
+ ...syncFilterOptions,
101
+ deep: !!options.force
102
+ });
103
+ const plan = buildPushPlan(status, { force: !!options.force });
104
+ const { filesToUpload, filesToDelete, remoteOnlyFiles, filesToRecreate, filesToOverwrite } = plan;
86
105
  const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
87
- appStatus = await appSyncService.getStatus();
88
- const hasFileChanges = filesToPush.length > 0 || filesToDelete.length > 0;
106
+ const appStatus = await appSyncService.getStatus();
107
+ const hasConflicts = status.conflicts.length > 0;
108
+ const hasFileChanges = filesToUpload.length > 0 || filesToDelete.length > 0 || remoteOnlyFiles.length > 0 || hasConflicts;
89
109
  const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.modified.length > 0;
90
110
  if (!hasFileChanges && !hasAppChanges) {
91
111
  import_logger.logger.success("Nothing to push. Everything is in sync.");
92
112
  return;
93
113
  }
94
114
  console.log();
95
- import_logger.logger.header("Changes to push:");
96
- if (filesToPush.length > 0) {
97
- for (const file of filesToPush) {
98
- const isNew = status.onlyLocal.includes(file);
99
- if (isNew) {
100
- console.log(import_chalk.default.green(` + ${file}`));
101
- } else {
102
- console.log(import_chalk.default.yellow(` M ${file}`));
103
- }
104
- }
115
+ import_logger.logger.header(options.force ? "Mirror plan (--force):" : "Changes to push:");
116
+ if (status.addedLocally.length > 0) {
117
+ for (const file of status.addedLocally) console.log(import_chalk.default.green(` + ${file}`));
118
+ }
119
+ if (status.modifiedLocally.length > 0) {
120
+ for (const file of status.modifiedLocally) console.log(import_chalk.default.yellow(` M ${file}`));
105
121
  }
106
122
  if (filesToDelete.length > 0) {
107
- for (const file of filesToDelete) {
108
- console.log(import_chalk.default.red(` - ${file}`));
123
+ for (const file of filesToDelete) console.log(import_chalk.default.red(` - ${file}`));
124
+ }
125
+ if (remoteOnlyFiles.length > 0) {
126
+ console.log(import_chalk.default.red.bold("Remote-only files that will be DELETED on remote:"));
127
+ for (const file of remoteOnlyFiles) console.log(import_chalk.default.red(` - ${file} (remote only)`));
128
+ }
129
+ if (filesToRecreate.length > 0) {
130
+ console.log(import_chalk.default.green.bold("Files deleted on remote that will be RECREATED:"));
131
+ for (const file of filesToRecreate) console.log(import_chalk.default.green(` + ${file} (re-uploading local copy)`));
132
+ }
133
+ if (filesToOverwrite.length > 0) {
134
+ console.log(import_chalk.default.yellow.bold("Files where remote drifted \u2014 local will OVERWRITE:"));
135
+ for (const file of filesToOverwrite)
136
+ console.log(import_chalk.default.yellow(` M ${file} (remote content drift; local wins)`));
137
+ }
138
+ if (hasConflicts) {
139
+ const headerText = options.force ? "Conflicts (will be force-overwritten on remote):" : "Conflicts (will be SKIPPED \u2014 pull first to resolve):";
140
+ console.log(import_chalk.default.red.bold(headerText));
141
+ for (const conflict of status.conflicts) {
142
+ console.log(import_chalk.default.red(` ! ${conflict.filePath}`));
143
+ console.log(import_chalk.default.dim(` ${conflict.description}`));
109
144
  }
110
145
  }
111
146
  if (appStatus.newLocal.length > 0) {
112
147
  console.log(import_chalk.default.green("New apps:"));
113
- for (const app of appStatus.newLocal) {
114
- console.log(import_chalk.default.green(` + ${app}`));
115
- }
148
+ for (const app of appStatus.newLocal) console.log(import_chalk.default.green(` + ${app}`));
116
149
  }
117
150
  if (appStatus.modified.length > 0) {
118
151
  console.log(import_chalk.default.yellow("Modified apps:"));
119
- for (const app of appStatus.modified) {
120
- console.log(import_chalk.default.yellow(` ~ ${app}`));
152
+ for (const app of appStatus.modified) console.log(import_chalk.default.yellow(` ~ ${app}`));
153
+ }
154
+ const previewCandidates = [...filesToUpload, ...filesToRecreate, ...filesToOverwrite];
155
+ const previewRejections = previewPushPlan(filesDir, previewCandidates);
156
+ if (previewRejections.length > 0) {
157
+ console.log();
158
+ console.log(import_chalk.default.red.bold("Files that pre-flight will reject (skipped from upload):"));
159
+ for (const r of previewRejections) {
160
+ console.log(import_chalk.default.red(` \u2717 ${r.filePath}`));
161
+ console.log(import_chalk.default.dim(` ${r.detail}`));
162
+ if (r.hint) console.log(import_chalk.default.dim(` ${r.hint}`));
121
163
  }
122
164
  }
123
165
  console.log();
124
- const totalChanges = filesToPush.length + filesToDelete.length + appStatus.newLocal.length + appStatus.modified.length;
125
- if (!options.yes) {
166
+ const totalChanges = filesToUpload.length + filesToDelete.length + remoteOnlyFiles.length + appStatus.newLocal.length + appStatus.modified.length;
167
+ const confirmMessage = options.force ? `Mirror to ${tenant}: ${remoteOnlyFiles.length} remote deletion(s), ${filesToOverwrite.length} drift overwrite(s), ${filesToRecreate.length} recreation(s), ${status.addedLocally.length} new upload(s), ${status.modifiedLocally.length} local edit(s), ${filesToDelete.length} local-rm deletion(s). This is destructive.` : `Push ${totalChanges} change(s) to ${tenant}?`;
168
+ if (options.force || !options.yes) {
126
169
  const confirm = await import_inquirer.default.prompt([
127
170
  {
128
171
  type: "confirm",
129
172
  name: "proceed",
130
- message: `Push ${totalChanges} change(s) to ${tenant}?`,
131
- default: true
173
+ message: confirmMessage,
174
+ default: !options.force
132
175
  }
133
176
  ]);
134
177
  if (!confirm.proceed) {
@@ -138,41 +181,59 @@ function registerPushCommand(program) {
138
181
  }
139
182
  await (0, import_farseerFactory.ensureFreshToken)(clientResult.client);
140
183
  try {
141
- let result = { uploaded: [], updated: [], deleted: [], unchanged: [] };
184
+ let result = {
185
+ uploaded: [],
186
+ updated: [],
187
+ deleted: [],
188
+ unchanged: [],
189
+ conflicts: [],
190
+ rejected: [],
191
+ failed: []
192
+ };
142
193
  if (hasFileChanges) {
143
194
  import_logger.logger.info(`Pushing files to ${tenant}...`);
144
- result = await syncService.push({ force: options.force });
195
+ result = await syncService.push({
196
+ force: options.force,
197
+ mirror: options.force,
198
+ ...syncFilterOptions,
199
+ precomputedRemoteHashes: status.remoteHashes
200
+ });
145
201
  console.log();
146
- if (result.conflicts && result.conflicts.length > 0) {
202
+ if (result.rejected.length > 0) {
203
+ console.log(import_chalk.default.red.bold("Files skipped (backend would reject):"));
204
+ renderRejections(result.rejected);
205
+ }
206
+ if (result.conflicts.length > 0) {
147
207
  console.log(import_chalk.default.red.bold(`${result.conflicts.length} conflict(s) detected:`));
148
- console.log();
149
208
  for (const conflict of result.conflicts) {
150
209
  console.log(import_chalk.default.red(` ! ${conflict.filePath}`));
151
210
  console.log(import_chalk.default.dim(` ${conflict.description}`));
152
211
  }
153
212
  console.log();
154
213
  import_logger.logger.dim(`Resolve conflicts by pulling first: farseer pull ${tenant}`);
155
- import_logger.logger.dim("Or use --force to push anyway (may overwrite remote changes).");
214
+ import_logger.logger.dim("Or use --force to push anyway (overwrites remote and mirrors deletions).");
156
215
  console.log();
157
216
  }
158
217
  if (result.uploaded.length > 0) {
159
218
  console.log(import_chalk.default.green("Uploaded files (new):"));
160
- for (const file of result.uploaded) {
161
- console.log(import_chalk.default.green(` + ${file}`));
162
- }
219
+ for (const file of result.uploaded) console.log(import_chalk.default.green(` + ${file}`));
163
220
  console.log();
164
221
  }
165
222
  if (result.updated.length > 0) {
166
223
  console.log(import_chalk.default.yellow("Updated files:"));
167
- for (const file of result.updated) {
168
- console.log(import_chalk.default.yellow(` M ${file}`));
169
- }
224
+ for (const file of result.updated) console.log(import_chalk.default.yellow(` M ${file}`));
170
225
  console.log();
171
226
  }
172
227
  if (result.deleted.length > 0) {
173
228
  console.log(import_chalk.default.red("Deleted files:"));
174
- for (const file of result.deleted) {
175
- console.log(import_chalk.default.red(` - ${file}`));
229
+ for (const file of result.deleted) console.log(import_chalk.default.red(` - ${file}`));
230
+ console.log();
231
+ }
232
+ if (result.failed.length > 0) {
233
+ console.log(import_chalk.default.red.bold(`${result.failed.length} file(s) failed during push:`));
234
+ for (const failure of result.failed) {
235
+ console.log(import_chalk.default.red(` ! ${failure.filePath} (${failure.operation})`));
236
+ console.log(import_chalk.default.dim(` ${failure.reason}`));
176
237
  }
177
238
  console.log();
178
239
  }
@@ -188,43 +249,61 @@ function registerPushCommand(program) {
188
249
  appResult = await appSyncService.push();
189
250
  if (appResult.created.length > 0) {
190
251
  console.log(import_chalk.default.green("Created apps:"));
191
- for (const app of appResult.created) {
192
- console.log(import_chalk.default.green(` + ${app}`));
193
- }
252
+ for (const app of appResult.created) console.log(import_chalk.default.green(` + ${app}`));
194
253
  console.log();
195
254
  }
196
255
  if (appResult.updated.length > 0) {
197
256
  console.log(import_chalk.default.yellow("Updated apps:"));
198
- for (const app of appResult.updated) {
199
- console.log(import_chalk.default.yellow(` ~ ${app}`));
200
- }
257
+ for (const app of appResult.updated) console.log(import_chalk.default.yellow(` ~ ${app}`));
201
258
  console.log();
202
259
  }
203
260
  if (appResult.deleted.length > 0) {
204
261
  console.log(import_chalk.default.red("Deleted apps:"));
205
- for (const app of appResult.deleted) {
206
- console.log(import_chalk.default.red(` - ${app}`));
207
- }
262
+ for (const app of appResult.deleted) console.log(import_chalk.default.red(` - ${app}`));
208
263
  console.log();
209
264
  }
210
265
  }
211
266
  console.log();
267
+ const fileSideEffects = result.uploaded.length + result.updated.length + result.deleted.length;
268
+ const appSideEffects = appResult.created.length + appResult.updated.length + appResult.deleted.length;
269
+ const conflictCount = result.conflicts.length;
270
+ const rejectedCount = result.rejected.length;
271
+ const failedCount = result.failed.length;
272
+ if (fileSideEffects + appSideEffects === 0 && (conflictCount > 0 || rejectedCount > 0)) {
273
+ if (rejectedCount > 0 && conflictCount === 0) {
274
+ import_logger.logger.warning(`Push did nothing \u2014 ${rejectedCount} file(s) rejected by pre-flight.`);
275
+ import_logger.logger.dim("Fix the issues listed above and re-run `farseer push`.");
276
+ } else if (conflictCount > 0 && rejectedCount === 0) {
277
+ import_logger.logger.warning(`Push did nothing \u2014 ${conflictCount} conflict(s) blocked the upload.`);
278
+ import_logger.logger.dim(`Resolve via 'farseer pull ${tenant}' or rerun with --force.`);
279
+ } else {
280
+ import_logger.logger.warning(
281
+ `Push did nothing \u2014 ${rejectedCount} file(s) rejected and ${conflictCount} conflict(s) blocked the upload.`
282
+ );
283
+ }
284
+ process.exit(1);
285
+ }
212
286
  import_logger.logger.success("Push complete!");
213
287
  import_logger.logger.dim(`Files: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}`);
214
288
  import_logger.logger.dim(
215
289
  `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}`
216
290
  );
291
+ if (rejectedCount > 0 || failedCount > 0) {
292
+ if (rejectedCount > 0 && failedCount > 0) {
293
+ import_logger.logger.warning(
294
+ `${rejectedCount} file(s) skipped pre-flight, ${failedCount} failed mid-push \u2014 see above and rerun.`
295
+ );
296
+ } else if (rejectedCount > 0) {
297
+ import_logger.logger.warning(`${rejectedCount} file(s) skipped (see above) \u2014 fix and rerun.`);
298
+ } else {
299
+ import_logger.logger.warning(`${failedCount} file(s) failed during push (see above) \u2014 rerun to retry.`);
300
+ }
301
+ process.exit(1);
302
+ }
217
303
  } catch (error) {
218
304
  import_fileLogger.fileLogger.error("push", error, { tenant, organisation });
219
305
  import_logger.logger.error("Push failed.");
220
- if (error instanceof Error) {
221
- import_logger.logger.error(error.message);
222
- if (error.cause) {
223
- import_logger.logger.dim(String(error.cause));
224
- }
225
- } else {
226
- import_logger.logger.dim(String(error));
227
- }
306
+ import_logger.logger.error(await (0, import_errorFormatter.formatClientError)(error));
228
307
  const logPath = import_fileLogger.fileLogger.getLogPath();
229
308
  if (logPath) {
230
309
  import_logger.logger.dim(`Debug log: ${logPath}`);
@@ -233,14 +312,45 @@ function registerPushCommand(program) {
233
312
  }
234
313
  });
235
314
  }
236
- function collectValues(value, previous) {
237
- return previous.concat([value]);
315
+ function buildPushPlan(status, options) {
316
+ return {
317
+ filesToUpload: [
318
+ ...status.addedLocally,
319
+ ...status.modifiedLocally,
320
+ ...options.force ? status.deletedRemotely : [],
321
+ ...options.force ? status.modifiedRemotely : []
322
+ ],
323
+ filesToDelete: [...status.deletedLocally],
324
+ remoteOnlyFiles: options.force ? [...status.addedRemotely] : [],
325
+ filesToRecreate: options.force ? [...status.deletedRemotely] : [],
326
+ filesToOverwrite: options.force ? [...status.modifiedRemotely] : []
327
+ };
238
328
  }
239
- function normalizeExtensions(exts) {
240
- return exts.map((ext) => ext.startsWith(".") ? ext.toLowerCase() : `.${ext.toLowerCase()}`);
329
+ function renderRejections(rejections) {
330
+ for (const r of rejections) {
331
+ console.log(import_chalk.default.red(` x ${r.filePath}`));
332
+ console.log(import_chalk.default.dim(` ${r.detail}`));
333
+ if (r.hint) console.log(import_chalk.default.dim(` ${r.hint}`));
334
+ }
335
+ console.log();
336
+ }
337
+ function previewPushPlan(filesDir, candidates) {
338
+ const validationInputs = [];
339
+ for (const filePath of candidates) {
340
+ try {
341
+ const fullPath = (0, import_helpers.safeResolveWithinBase)(filesDir, filePath);
342
+ const content = fs.readFileSync(fullPath);
343
+ validationInputs.push({ filePath, size: content.length, content });
344
+ } catch {
345
+ continue;
346
+ }
347
+ }
348
+ const { rejected } = (0, import_fileValidation.partitionForUpload)(validationInputs);
349
+ return rejected;
241
350
  }
242
351
  // Annotate the CommonJS export names for ESM import in node:
243
352
  0 && (module.exports = {
353
+ buildPushPlan,
244
354
  registerPushCommand
245
355
  });
246
356
  //# sourceMappingURL=push.js.map