farseer-cli 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/push.js +1 -1
- package/dist/commands/push.js.map +2 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +2 -2
- package/dist/mcp/server.js +2 -1
- package/dist/mcp/server.js.map +2 -2
- package/dist/services/syncService.js +89 -22
- package/dist/services/syncService.js.map +2 -2
- package/dist/utils/constants.js +3 -0
- package/dist/utils/constants.js.map +2 -2
- package/dist/utils/helpers.js +8 -1
- package/dist/utils/helpers.js.map +2 -2
- package/package.json +1 -1
- package/dist/commands/app.d.ts +0 -2
- package/dist/commands/apps.d.ts +0 -2
- package/dist/commands/checkout.d.ts +0 -2
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/diff.d.ts +0 -2
- package/dist/commands/install.d.ts +0 -2
- package/dist/commands/list.d.ts +0 -2
- package/dist/commands/login.d.ts +0 -2
- package/dist/commands/logout.d.ts +0 -2
- package/dist/commands/mcp-server.d.ts +0 -8
- package/dist/commands/model.d.ts +0 -2
- package/dist/commands/pull.d.ts +0 -2
- package/dist/commands/push.d.ts +0 -2
- package/dist/commands/run.d.ts +0 -2
- package/dist/commands/setup.d.ts +0 -2
- package/dist/commands/setup.js +0 -137
- package/dist/commands/status.d.ts +0 -2
- package/dist/commands/unsetup.d.ts +0 -2
- package/dist/commands/unsetup.js +0 -122
- package/dist/commands/whoami.d.ts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/mcp/index.d.ts +0 -7
- package/dist/mcp/prompts/workflows.d.ts +0 -7
- package/dist/mcp/resources/documentation.d.ts +0 -8
- package/dist/mcp/server.d.ts +0 -7
- package/dist/mcp/tools/appTools.d.ts +0 -7
- package/dist/mcp/tools/authTools.d.ts +0 -7
- package/dist/mcp/tools/modelTools.d.ts +0 -7
- package/dist/mcp/tools/runTools.d.ts +0 -7
- package/dist/mcp/tools/syncTools.d.ts +0 -7
- package/dist/mcp/utils/helpers.d.ts +0 -69
- package/dist/services/appSyncService.d.ts +0 -75
- package/dist/services/configService.d.ts +0 -39
- package/dist/services/farseerApi.d.ts +0 -166
- package/dist/services/farseerFactory.d.ts +0 -88
- package/dist/services/farseerService.d.ts +0 -96
- package/dist/services/gitService.d.ts +0 -31
- package/dist/services/syncService.d.ts +0 -44
- package/dist/utils/constants.d.ts +0 -7
- package/dist/utils/helpers.d.ts +0 -69
- package/dist/utils/logger.d.ts +0 -14
package/dist/commands/push.js
CHANGED
|
@@ -89,7 +89,7 @@ function registerPushCommand(program) {
|
|
|
89
89
|
}
|
|
90
90
|
import_logger.logger.dim("Remote is in sync.");
|
|
91
91
|
}
|
|
92
|
-
const status = await syncService.
|
|
92
|
+
const status = await syncService.getStatusFast();
|
|
93
93
|
const filesToPush = [
|
|
94
94
|
...status.modifiedLocally,
|
|
95
95
|
...status.onlyLocal
|
|
@@ -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 { getFarseerClientWithFallback, showLoginPrompt, ensureFreshToken } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { GitService } from '../services/gitService';\nimport { getTenantFilesDir, resolveTenantWithOrgMapping, isInRemotejobsRepo } from '../utils/helpers';\nimport { CLI_GIT_AUTHOR } from '../utils/constants';\nimport * as fs from 'fs';\n\nexport function registerPushCommand(program: Command): void {\n program\n .command('push [arg1] [arg2]')\n .description('Push local files to Farseer instance\\n\\nUsage: push <org> <tenant> OR push <tenant> (if org is known)')\n .option('--git', 'Enable git operations (commit & push) - internal use only')\n .option('-m, --message <message>', 'Commit message (required when using --git)')\n .option('--force', 'Force push even if remote has changes')\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: apps/${tenant}/files/`);\n logger.dim('Run \"farseer pull <tenant>\" first to initialize the folder.');\n process.exit(1);\n }\n\n // Git operations are opt-in with --git flag (internal developer feature)\n const inRemotejobsRepo = isInRemotejobsRepo();\n const gitDisabledByEnv = !!process.env.FARSEER_NO_GIT;\n\n // Git enabled ONLY if:\n // 1. User explicitly requested it (--git flag)\n // 2. We're in remotejobs repo (safety check)\n // 3. FARSEER_NO_GIT env var is not set\n const gitEnabled = options.git === true && inRemotejobsRepo && !gitDisabledByEnv;\n\n // Show error if --git requested but not in remotejobs repo\n if (options.git === true && !inRemotejobsRepo) {\n logger.error('Git operations are only available in remotejobs repository.');\n process.exit(1);\n }\n\n // Validate message is provided when using git\n if (gitEnabled && !options.message) {\n logger.error('Commit message is required when using git.');\n logger.dim('Use: farseer push <tenant> --git -m \"Your message\"');\n process.exit(1);\n }\n\n const gitService = new GitService();\n const syncService = new SyncService(tenant, clientResult.client);\n\n // Step 1: Git pull to ensure we're up to date\n if (gitEnabled) {\n logger.info('Pulling latest changes from git...');\n const gitPullResult = await gitService.pull();\n\n if (!gitPullResult.success) {\n logger.error('Git pull failed.');\n logger.dim(gitPullResult.message);\n process.exit(1);\n }\n\n logger.dim(gitPullResult.message);\n }\n\n // Step 2: Check if remote has unpulled changes\n if (!options.force) {\n logger.info('Checking for remote changes...');\n\n const hasRemoteChanges = await syncService.checkRemoteChanges();\n\n if (hasRemoteChanges) {\n logger.error('Remote has changes that are not synced locally.');\n logger.dim(`Run 'farseer pull ${tenant}' first, then try pushing again.`);\n logger.dim('Or use --force to push anyway (will overwrite remote changes).');\n process.exit(1);\n }\n\n logger.dim('Remote is in sync.');\n }\n\n // Step 3: Show what will be pushed\n const status = await syncService.getStatus();\n\n const filesToPush = [\n ...status.modifiedLocally,\n ...status.onlyLocal,\n ];\n\n const filesToDelete = status.modifiedRemotely.filter((f) =>\n !fs.existsSync(`${filesDir}/${f}`)\n );\n\n // Check app changes too (works with both JWT and API key)\n let appStatus = { newLocal: [] as string[], modified: [] as string[], newRemote: [] as string[], synced: [] as string[] };\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appStatus = await appSyncService.getStatus();\n\n const hasFileChanges = filesToPush.length > 0 || filesToDelete.length > 0;\n const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.modified.length > 0;\n\n if (!hasFileChanges && !hasAppChanges) {\n logger.success('Nothing to push. Everything is in sync.');\n return;\n }\n\n console.log();\n logger.header('Changes to push:');\n\n if (filesToPush.length > 0) {\n for (const file of filesToPush) {\n const isNew = status.onlyLocal.includes(file);\n if (isNew) {\n console.log(chalk.green(` + ${file}`));\n } else {\n console.log(chalk.yellow(` M ${file}`));\n }\n }\n }\n\n if (filesToDelete.length > 0) {\n for (const file of filesToDelete) {\n console.log(chalk.red(` - ${file}`));\n }\n }\n\n // Show app changes\n if (appStatus.newLocal.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appStatus.newLocal) {\n console.log(chalk.green(` + ${app}`));\n }\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 }\n\n console.log();\n\n const totalChanges = filesToPush.length + filesToDelete.length + appStatus.newLocal.length + appStatus.modified.length;\n\n // Step 4: Confirm push\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: `Push ${totalChanges} change(s) to ${tenant}?`,\n default: true,\n },\n ]);\n\n if (!confirm.proceed) {\n logger.info('Push cancelled.');\n return;\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 // Step 5: Push files only if there are file changes\n let result = { uploaded: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\n\n if (hasFileChanges) {\n logger.info(`Pushing files to ${tenant}...`);\n result = await syncService.push();\n\n console.log();\n\n if (result.uploaded.length > 0) {\n console.log(chalk.green('Uploaded files (new):'));\n for (const file of result.uploaded) {\n console.log(chalk.green(` + ${file}`));\n }\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) {\n console.log(chalk.yellow(` M ${file}`));\n }\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) {\n console.log(chalk.red(` - ${file}`));\n }\n console.log();\n }\n }\n\n // Step 6: Push apps only if there are app changes\n let appResult = { created: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\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) {\n console.log(chalk.green(` + ${app}`));\n }\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) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\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) {\n console.log(chalk.red(` - ${app}`));\n }\n console.log();\n }\n }\n\n // Step 7: Git commit & push\n if (gitEnabled) {\n logger.info('Committing changes to git...');\n\n const appsPath = `apps/${tenant}`;\n await gitService.add([appsPath]);\n\n const commitMessage = `[${tenant}] ${options.message}\n\nFiles: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}\nApps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}\n\n\uD83E\uDD16 Generated with Farseer CLI`;\n\n const commitResult = await gitService.commit(commitMessage, CLI_GIT_AUTHOR);\n\n if (commitResult.success) {\n logger.dim(`Committed: ${commitResult.commitHash}`);\n\n logger.info('Pushing to git remote...');\n const pushResult = await gitService.push();\n\n if (pushResult.success) {\n logger.dim(pushResult.message);\n } else {\n logger.warning('Failed to push to git remote.');\n logger.dim(pushResult.message);\n logger.dim('You may need to push manually.');\n }\n } else {\n logger.warning('Failed to commit changes.');\n logger.dim(commitResult.message);\n }\n }\n\n console.log();\n logger.success('Push complete!');\n logger.dim(`Files: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}`);\n logger.dim(`Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}`);\n } catch (error) {\n logger.error('Push failed.');\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,sBAAqB;AACrB,oBAAuB;AACvB,4BAAgF;AAChF,yBAA4B;AAC5B,4BAA+B;AAC/B,wBAA2B;AAC3B,qBAAmF;AACnF,uBAA+B;AAC/B,SAAoB;AAEb,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,oBAAoB,EAC5B,YAAY,uGAAuG,EACnH,OAAO,SAAS,2DAA2D,EAC3E,OAAO,2BAA2B,4CAA4C,EAC9E,OAAO,WAAW,uCAAuC,EACzD,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,gCAAgC,MAAM,SAAS;AAC5D,2BAAO,IAAI,6DAA6D;AACxE,cAAQ,KAAK,CAAC;AAAA,IAClB;AAGA,UAAM,uBAAmB,mCAAmB;AAC5C,UAAM,mBAAmB,CAAC,CAAC,QAAQ,IAAI;AAMvC,UAAM,aAAa,QAAQ,QAAQ,QAAQ,oBAAoB,CAAC;AAGhE,QAAI,QAAQ,QAAQ,QAAQ,CAAC,kBAAkB;AAC3C,2BAAO,MAAM,6DAA6D;AAC1E,cAAQ,KAAK,CAAC;AAAA,IAClB;AAGA,QAAI,cAAc,CAAC,QAAQ,SAAS;AAChC,2BAAO,MAAM,4CAA4C;AACzD,2BAAO,IAAI,oDAAoD;AAC/D,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,aAAa,IAAI,6BAAW;AAClC,UAAM,cAAc,IAAI,+BAAY,QAAQ,aAAa,MAAM;AAG/D,QAAI,YAAY;AACZ,2BAAO,KAAK,oCAAoC;AAChD,YAAM,gBAAgB,MAAM,WAAW,KAAK;AAE5C,UAAI,CAAC,cAAc,SAAS;AACxB,6BAAO,MAAM,kBAAkB;AAC/B,6BAAO,IAAI,cAAc,OAAO;AAChC,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAEA,2BAAO,IAAI,cAAc,OAAO;AAAA,IACpC;AAGA,QAAI,CAAC,QAAQ,OAAO;AAChB,2BAAO,KAAK,gCAAgC;AAE5C,YAAM,mBAAmB,MAAM,YAAY,mBAAmB;AAE9D,UAAI,kBAAkB;AAClB,6BAAO,MAAM,iDAAiD;AAC9D,6BAAO,IAAI,qBAAqB,MAAM,kCAAkC;AACxE,6BAAO,IAAI,gEAAgE;AAC3E,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAEA,2BAAO,IAAI,oBAAoB;AAAA,IACnC;AAGA,UAAM,SAAS,MAAM,YAAY,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt, ensureFreshToken } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { GitService } from '../services/gitService';\nimport { getTenantFilesDir, resolveTenantWithOrgMapping, isInRemotejobsRepo } from '../utils/helpers';\nimport { CLI_GIT_AUTHOR } from '../utils/constants';\nimport * as fs from 'fs';\n\nexport function registerPushCommand(program: Command): void {\n program\n .command('push [arg1] [arg2]')\n .description('Push local files to Farseer instance\\n\\nUsage: push <org> <tenant> OR push <tenant> (if org is known)')\n .option('--git', 'Enable git operations (commit & push) - internal use only')\n .option('-m, --message <message>', 'Commit message (required when using --git)')\n .option('--force', 'Force push even if remote has changes')\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: apps/${tenant}/files/`);\n logger.dim('Run \"farseer pull <tenant>\" first to initialize the folder.');\n process.exit(1);\n }\n\n // Git operations are opt-in with --git flag (internal developer feature)\n const inRemotejobsRepo = isInRemotejobsRepo();\n const gitDisabledByEnv = !!process.env.FARSEER_NO_GIT;\n\n // Git enabled ONLY if:\n // 1. User explicitly requested it (--git flag)\n // 2. We're in remotejobs repo (safety check)\n // 3. FARSEER_NO_GIT env var is not set\n const gitEnabled = options.git === true && inRemotejobsRepo && !gitDisabledByEnv;\n\n // Show error if --git requested but not in remotejobs repo\n if (options.git === true && !inRemotejobsRepo) {\n logger.error('Git operations are only available in remotejobs repository.');\n process.exit(1);\n }\n\n // Validate message is provided when using git\n if (gitEnabled && !options.message) {\n logger.error('Commit message is required when using git.');\n logger.dim('Use: farseer push <tenant> --git -m \"Your message\"');\n process.exit(1);\n }\n\n const gitService = new GitService();\n const syncService = new SyncService(tenant, clientResult.client);\n\n // Step 1: Git pull to ensure we're up to date\n if (gitEnabled) {\n logger.info('Pulling latest changes from git...');\n const gitPullResult = await gitService.pull();\n\n if (!gitPullResult.success) {\n logger.error('Git pull failed.');\n logger.dim(gitPullResult.message);\n process.exit(1);\n }\n\n logger.dim(gitPullResult.message);\n }\n\n // Step 2: Check if remote has unpulled changes\n if (!options.force) {\n logger.info('Checking for remote changes...');\n\n const hasRemoteChanges = await syncService.checkRemoteChanges();\n\n if (hasRemoteChanges) {\n logger.error('Remote has changes that are not synced locally.');\n logger.dim(`Run 'farseer pull ${tenant}' first, then try pushing again.`);\n logger.dim('Or use --force to push anyway (will overwrite remote changes).');\n process.exit(1);\n }\n\n logger.dim('Remote is in sync.');\n }\n\n // Step 3: Show what will be pushed (using fast status check that doesn't download remote content)\n const status = await syncService.getStatusFast();\n\n const filesToPush = [\n ...status.modifiedLocally,\n ...status.onlyLocal,\n ];\n\n const filesToDelete = status.modifiedRemotely.filter((f) =>\n !fs.existsSync(`${filesDir}/${f}`)\n );\n\n // Check app changes too (works with both JWT and API key)\n let appStatus = { newLocal: [] as string[], modified: [] as string[], newRemote: [] as string[], synced: [] as string[] };\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appStatus = await appSyncService.getStatus();\n\n const hasFileChanges = filesToPush.length > 0 || filesToDelete.length > 0;\n const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.modified.length > 0;\n\n if (!hasFileChanges && !hasAppChanges) {\n logger.success('Nothing to push. Everything is in sync.');\n return;\n }\n\n console.log();\n logger.header('Changes to push:');\n\n if (filesToPush.length > 0) {\n for (const file of filesToPush) {\n const isNew = status.onlyLocal.includes(file);\n if (isNew) {\n console.log(chalk.green(` + ${file}`));\n } else {\n console.log(chalk.yellow(` M ${file}`));\n }\n }\n }\n\n if (filesToDelete.length > 0) {\n for (const file of filesToDelete) {\n console.log(chalk.red(` - ${file}`));\n }\n }\n\n // Show app changes\n if (appStatus.newLocal.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appStatus.newLocal) {\n console.log(chalk.green(` + ${app}`));\n }\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 }\n\n console.log();\n\n const totalChanges = filesToPush.length + filesToDelete.length + appStatus.newLocal.length + appStatus.modified.length;\n\n // Step 4: Confirm push\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: `Push ${totalChanges} change(s) to ${tenant}?`,\n default: true,\n },\n ]);\n\n if (!confirm.proceed) {\n logger.info('Push cancelled.');\n return;\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 // Step 5: Push files only if there are file changes\n let result = { uploaded: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\n\n if (hasFileChanges) {\n logger.info(`Pushing files to ${tenant}...`);\n result = await syncService.push();\n\n console.log();\n\n if (result.uploaded.length > 0) {\n console.log(chalk.green('Uploaded files (new):'));\n for (const file of result.uploaded) {\n console.log(chalk.green(` + ${file}`));\n }\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) {\n console.log(chalk.yellow(` M ${file}`));\n }\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) {\n console.log(chalk.red(` - ${file}`));\n }\n console.log();\n }\n }\n\n // Step 6: Push apps only if there are app changes\n let appResult = { created: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\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) {\n console.log(chalk.green(` + ${app}`));\n }\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) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\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) {\n console.log(chalk.red(` - ${app}`));\n }\n console.log();\n }\n }\n\n // Step 7: Git commit & push\n if (gitEnabled) {\n logger.info('Committing changes to git...');\n\n const appsPath = `apps/${tenant}`;\n await gitService.add([appsPath]);\n\n const commitMessage = `[${tenant}] ${options.message}\n\nFiles: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}\nApps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}\n\n\uD83E\uDD16 Generated with Farseer CLI`;\n\n const commitResult = await gitService.commit(commitMessage, CLI_GIT_AUTHOR);\n\n if (commitResult.success) {\n logger.dim(`Committed: ${commitResult.commitHash}`);\n\n logger.info('Pushing to git remote...');\n const pushResult = await gitService.push();\n\n if (pushResult.success) {\n logger.dim(pushResult.message);\n } else {\n logger.warning('Failed to push to git remote.');\n logger.dim(pushResult.message);\n logger.dim('You may need to push manually.');\n }\n } else {\n logger.warning('Failed to commit changes.');\n logger.dim(commitResult.message);\n }\n }\n\n console.log();\n logger.success('Push complete!');\n logger.dim(`Files: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}`);\n logger.dim(`Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}`);\n } catch (error) {\n logger.error('Push failed.');\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,sBAAqB;AACrB,oBAAuB;AACvB,4BAAgF;AAChF,yBAA4B;AAC5B,4BAA+B;AAC/B,wBAA2B;AAC3B,qBAAmF;AACnF,uBAA+B;AAC/B,SAAoB;AAEb,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,oBAAoB,EAC5B,YAAY,uGAAuG,EACnH,OAAO,SAAS,2DAA2D,EAC3E,OAAO,2BAA2B,4CAA4C,EAC9E,OAAO,WAA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IAAI,UAAU,UAAU,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,KAAK,UAAU,QAAQ,MAAM,EAAE;AAAA,IAC7G,SAAS,OAAO;AACZ,2BAAO,MAAM,cAAc;AAC3B,UAAI,iBAAiB,OAAO;AACxB,6BAAO,IAAI,MAAM,OAAO;AAAA,MAC5B;AACA,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;",
|
|
6
6
|
"names": ["chalk", "inquirer"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
var import_commander = require("commander");
|
|
25
25
|
var import_chalk = __toESM(require("chalk"));
|
|
26
|
+
var import_constants = require("./utils/constants");
|
|
26
27
|
var import_login = require("./commands/login");
|
|
27
28
|
var import_logout = require("./commands/logout");
|
|
28
29
|
var import_config = require("./commands/config");
|
|
@@ -51,7 +52,7 @@ program.configureHelp({
|
|
|
51
52
|
visibleCommands: () => []
|
|
52
53
|
// Hide all commands from default list
|
|
53
54
|
});
|
|
54
|
-
program.name("farseer").description("CLI tool for syncing Farseer App scripts between local repository and Farseer instances").version(
|
|
55
|
+
program.name("farseer").description("CLI tool for syncing Farseer App scripts between local repository and Farseer instances").version(import_constants.CLI_VERSION).addHelpText("after", `
|
|
55
56
|
${import_chalk.default.bold.underline("Authentication")}
|
|
56
57
|
login Login via browser (OAuth) or use --api-key
|
|
57
58
|
logout [tenant] Logout and remove credentials
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["#!/usr/bin/env node\n\n// Suppress punycode deprecation warning (comes from dependencies like axios)\nconst originalEmit = process.emit;\n// @ts-expect-error - overriding process.emit\nprocess.emit = function (name: string, data: unknown, ...args: unknown[]) {\n if (name === 'warning' && typeof data === 'object' && data !== null && 'name' in data && data.name === 'DeprecationWarning' && 'message' in data && typeof data.message === 'string' && data.message.includes('punycode')) {\n return false;\n }\n // @ts-expect-error - calling original emit\n return originalEmit.apply(process, [name, data, ...args]);\n};\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport { registerLoginCommand } from './commands/login';\nimport { registerLogoutCommand } from './commands/logout';\nimport { registerConfigCommand } from './commands/config';\nimport { registerListCommand } from './commands/list';\nimport { registerFilesCommand } from './commands/files';\nimport { registerStatusCommand } from './commands/status';\nimport { registerDiffCommand } from './commands/diff';\nimport { registerPullCommand } from './commands/pull';\nimport { registerPushCommand } from './commands/push';\nimport { registerRunCommand } from './commands/run';\nimport { registerInstallCommand } from './commands/install';\nimport { registerWhoamiCommand } from './commands/whoami';\nimport { registerAppCommand } from './commands/app';\nimport { registerModelCommand } from './commands/model';\nimport { registerCheckoutCommand } from './commands/checkout';\nimport { registerMcpServerCommand } from './commands/mcp-server';\n\nconst program = new Command();\n\n// Configure help to hide default command list (we show our own custom list)\nprogram.configureHelp({\n visibleCommands: () => [], // Hide all commands from default list\n});\n\nprogram\n .name('farseer')\n .description('CLI tool for syncing Farseer App scripts between local repository and Farseer instances')\n .version(
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAaA,uBAAwB;AACxB,mBAAkB;AAClB,mBAAqC;AACrC,oBAAsC;AACtC,oBAAsC;AACtC,kBAAoC;AACpC,mBAAqC;AACrC,oBAAsC;AACtC,kBAAoC;AACpC,kBAAoC;AACpC,kBAAoC;AACpC,iBAAmC;AACnC,qBAAuC;AACvC,oBAAsC;AACtC,iBAAmC;AACnC,mBAAqC;AACrC,sBAAwC;AACxC,wBAAyC;
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\n// Suppress punycode deprecation warning (comes from dependencies like axios)\nconst originalEmit = process.emit;\n// @ts-expect-error - overriding process.emit\nprocess.emit = function (name: string, data: unknown, ...args: unknown[]) {\n if (name === 'warning' && typeof data === 'object' && data !== null && 'name' in data && data.name === 'DeprecationWarning' && 'message' in data && typeof data.message === 'string' && data.message.includes('punycode')) {\n return false;\n }\n // @ts-expect-error - calling original emit\n return originalEmit.apply(process, [name, data, ...args]);\n};\n\nimport { Command } from 'commander';\nimport chalk from 'chalk';\nimport { CLI_VERSION } from './utils/constants';\nimport { registerLoginCommand } from './commands/login';\nimport { registerLogoutCommand } from './commands/logout';\nimport { registerConfigCommand } from './commands/config';\nimport { registerListCommand } from './commands/list';\nimport { registerFilesCommand } from './commands/files';\nimport { registerStatusCommand } from './commands/status';\nimport { registerDiffCommand } from './commands/diff';\nimport { registerPullCommand } from './commands/pull';\nimport { registerPushCommand } from './commands/push';\nimport { registerRunCommand } from './commands/run';\nimport { registerInstallCommand } from './commands/install';\nimport { registerWhoamiCommand } from './commands/whoami';\nimport { registerAppCommand } from './commands/app';\nimport { registerModelCommand } from './commands/model';\nimport { registerCheckoutCommand } from './commands/checkout';\nimport { registerMcpServerCommand } from './commands/mcp-server';\n\nconst program = new Command();\n\n// Configure help to hide default command list (we show our own custom list)\nprogram.configureHelp({\n visibleCommands: () => [], // Hide all commands from default list\n});\n\nprogram\n .name('farseer')\n .description('CLI tool for syncing Farseer App scripts between local repository and Farseer instances')\n .version(CLI_VERSION)\n .addHelpText('after', `\n${chalk.bold.underline('Authentication')}\n login Login via browser (OAuth) or use --api-key\n logout [tenant] Logout and remove credentials\n whoami Show login status and configured tenants\n checkout [tenant] Set default tenant (verifies auth & pulls)\n ${chalk.dim('--no-pull')} Skip automatic pull\n\n${chalk.bold.underline('Configuration')} ${chalk.dim('(farseer config <command>)')}\n config set <tenant> Set API key for a tenant\n ${chalk.dim('--api-key <key>')} API key (required)\n ${chalk.dim('--org <name>')} Organisation if different from tenant\n config remove <tenant> Remove credentials\n config list List all configured tenants\n config show <tenant> Show full credentials (incl. API key)\n config test <tenant> Test connection to tenant\n\n${chalk.bold.underline('Sync Operations')} ${chalk.dim('(tenant optional if checked out)')}\n pull [tenant] Pull files and apps from remote\n ${chalk.dim('--no-git')} Skip git operations\n ${chalk.dim('--all')} Download all files (not just .ts/.js)\n push [tenant] Push local changes to remote\n ${chalk.dim('-m, --message <msg>')} Commit message (required)\n ${chalk.dim('--no-git')} Skip git operations\n status [tenant] Show sync status (local vs remote)\n ${chalk.dim('--all')} Show all files (not just .ts/.js)\n diff [tenant] [file] Show file differences\n\n${chalk.bold.underline('App Management')} ${chalk.dim('(tenant optional if checked out)')}\n app list [tenant] List all apps\n ${chalk.dim('--details')} Show details for each app\n app show [tenant] <name> Show app details\n app create [tenant] <name> Create new app\n app configure [tenant] <name> Configure app\n ${chalk.dim('--entrypoint <script>')} Set main script\n ${chalk.dim('--scripts <list>')} Comma-separated scripts\n ${chalk.dim('--add-arg <Name=Value>')} Add argument (repeatable)\n ${chalk.dim('--description <text>')} Set description\n app delete [tenant] <name> Delete app (requires --force)\n\n${chalk.bold.underline('Running & Development')} ${chalk.dim('(tenant optional if checked out)')}\n run [tenant] <app> Run app locally with injected credentials\n ${chalk.dim('--arg <Name=Value>')} Override argument (repeatable)\n run-script [tenant] <file> Run script directly (no app wrapper)\n install [tenant] Install npm dependencies (npm install)\n\n${chalk.bold.underline('Model Inspection')} ${chalk.dim('(tenant optional if checked out)')}\n model [tenant] Show model structure (dimensions, variables)\n ${chalk.dim('--variables')} List all variables\n ${chalk.dim('--tables')} List all dimension tables\n ${chalk.dim('--variable <name>')} Show dimensions for variable\n\n${chalk.bold.underline('File Management')} ${chalk.dim('(farseer files <command>)')}\n files list [tenant] List files on remote\n ${chalk.dim('--all')} Show all files (not just scripts)\n\n${chalk.bold.underline('Examples')}\n ${chalk.green('$')} farseer login ${chalk.dim('Login via browser')}\n ${chalk.green('$')} farseer config set myco --api-key xxx ${chalk.dim('Add tenant with API key')}\n ${chalk.green('$')} farseer pull mycompany --no-git ${chalk.dim('Download scripts & apps')}\n ${chalk.green('$')} farseer push mycompany -m \"Fix bug\" ${chalk.dim('Upload changes')}\n ${chalk.green('$')} farseer run mycompany \"My App\" ${chalk.dim('Run app locally')}\n ${chalk.green('$')} farseer model mycompany --variables ${chalk.dim('List all variables')}\n`);\n\n// Register all commands (hidden from default help, shown in custom help above)\nregisterLoginCommand(program);\nregisterLogoutCommand(program);\nregisterCheckoutCommand(program);\nregisterConfigCommand(program);\nregisterListCommand(program);\nregisterFilesCommand(program);\nregisterAppCommand(program);\nregisterModelCommand(program);\nregisterStatusCommand(program);\nregisterDiffCommand(program);\nregisterPullCommand(program);\nregisterPushCommand(program);\nregisterRunCommand(program);\nregisterInstallCommand(program);\nregisterWhoamiCommand(program);\nregisterMcpServerCommand(program);\n\n// Parse arguments\nprogram.parse();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAaA,uBAAwB;AACxB,mBAAkB;AAClB,uBAA4B;AAC5B,mBAAqC;AACrC,oBAAsC;AACtC,oBAAsC;AACtC,kBAAoC;AACpC,mBAAqC;AACrC,oBAAsC;AACtC,kBAAoC;AACpC,kBAAoC;AACpC,kBAAoC;AACpC,iBAAmC;AACnC,qBAAuC;AACvC,oBAAsC;AACtC,iBAAmC;AACnC,mBAAqC;AACrC,sBAAwC;AACxC,wBAAyC;AA5BzC,MAAM,eAAe,QAAQ;AAE7B,QAAQ,OAAO,SAAU,MAAc,SAAkB,MAAiB;AACtE,MAAI,SAAS,aAAa,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU,QAAQ,KAAK,SAAS,wBAAwB,aAAa,QAAQ,OAAO,KAAK,YAAY,YAAY,KAAK,QAAQ,SAAS,UAAU,GAAG;AACvN,WAAO;AAAA,EACX;AAEA,SAAO,aAAa,MAAM,SAAS,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;AAC5D;AAsBA,MAAM,UAAU,IAAI,yBAAQ;AAG5B,QAAQ,cAAc;AAAA,EAClB,iBAAiB,MAAM,CAAC;AAAA;AAC5B,CAAC;AAED,QACK,KAAK,SAAS,EACd,YAAY,yFAAy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A,IAC7B,iCAAoB,OAAO;AAAA,IAC3B,iCAAoB,OAAO;AAAA,IAC3B,iCAAoB,OAAO;AAAA,IAC3B,+BAAmB,OAAO;AAAA,IAC1B,uCAAuB,OAAO;AAAA,IAC9B,qCAAsB,OAAO;AAAA,IAC7B,4CAAyB,OAAO;AAGhC,QAAQ,MAAM;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/dist/mcp/server.js
CHANGED
|
@@ -21,6 +21,7 @@ __export(server_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(server_exports);
|
|
23
23
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
24
|
+
var import_constants = require("../utils/constants");
|
|
24
25
|
var import_authTools = require("./tools/authTools");
|
|
25
26
|
var import_syncTools = require("./tools/syncTools");
|
|
26
27
|
var import_appTools = require("./tools/appTools");
|
|
@@ -31,7 +32,7 @@ var import_workflows = require("./prompts/workflows");
|
|
|
31
32
|
function createMcpServer() {
|
|
32
33
|
const server = new import_mcp.McpServer({
|
|
33
34
|
name: "farseer-cli",
|
|
34
|
-
version:
|
|
35
|
+
version: import_constants.CLI_VERSION
|
|
35
36
|
});
|
|
36
37
|
(0, import_authTools.registerAuthTools)(server);
|
|
37
38
|
(0, import_syncTools.registerSyncTools)(server);
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/mcp/server.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * MCP Server Configuration\n *\n * Creates and configures the Farseer MCP server with all tools, resources, and prompts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { registerAuthTools } from './tools/authTools';\nimport { registerSyncTools } from './tools/syncTools';\nimport { registerAppTools } from './tools/appTools';\nimport { registerModelTools } from './tools/modelTools';\nimport { registerRunTools } from './tools/runTools';\nimport { registerDocumentationResources } from './resources/documentation';\nimport { registerWorkflowPrompts } from './prompts/workflows';\n\nexport function createMcpServer(): McpServer {\n const server = new McpServer({\n name: 'farseer-cli',\n version:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,iBAA0B;AAC1B,uBAAkC;AAClC,uBAAkC;AAClC,sBAAiC;AACjC,wBAAmC;AACnC,sBAAiC;AACjC,2BAA+C;AAC/C,uBAAwC;AAEjC,SAAS,kBAA6B;AACzC,QAAM,SAAS,IAAI,qBAAU;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,EACb,CAAC;AAGD,0CAAkB,MAAM;AACxB,0CAAkB,MAAM;AACxB,wCAAiB,MAAM;AACvB,4CAAmB,MAAM;AACzB,wCAAiB,MAAM;AAGvB,2DAA+B,MAAM;AAGrC,gDAAwB,MAAM;AAE9B,SAAO;AACX;",
|
|
4
|
+
"sourcesContent": ["/**\n * MCP Server Configuration\n *\n * Creates and configures the Farseer MCP server with all tools, resources, and prompts.\n */\n\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { CLI_VERSION } from '../utils/constants';\nimport { registerAuthTools } from './tools/authTools';\nimport { registerSyncTools } from './tools/syncTools';\nimport { registerAppTools } from './tools/appTools';\nimport { registerModelTools } from './tools/modelTools';\nimport { registerRunTools } from './tools/runTools';\nimport { registerDocumentationResources } from './resources/documentation';\nimport { registerWorkflowPrompts } from './prompts/workflows';\n\nexport function createMcpServer(): McpServer {\n const server = new McpServer({\n name: 'farseer-cli',\n version: CLI_VERSION,\n });\n\n // Register all tools\n registerAuthTools(server);\n registerSyncTools(server);\n registerAppTools(server);\n registerModelTools(server);\n registerRunTools(server);\n\n // Register resources (documentation)\n registerDocumentationResources(server);\n\n // Register prompts (workflow templates)\n registerWorkflowPrompts(server);\n\n return server;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,iBAA0B;AAC1B,uBAA4B;AAC5B,uBAAkC;AAClC,uBAAkC;AAClC,sBAAiC;AACjC,wBAAmC;AACnC,sBAAiC;AACjC,2BAA+C;AAC/C,uBAAwC;AAEjC,SAAS,kBAA6B;AACzC,QAAM,SAAS,IAAI,qBAAU;AAAA,IACzB,MAAM;AAAA,IACN,SAAS;AAAA,EACb,CAAC;AAGD,0CAAkB,MAAM;AACxB,0CAAkB,MAAM;AACxB,wCAAiB,MAAM;AACvB,4CAAmB,MAAM;AACzB,wCAAiB,MAAM;AAGvB,2DAA+B,MAAM;AAGrC,gDAAwB,MAAM;AAE9B,SAAO;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -63,6 +63,65 @@ class SyncService {
|
|
|
63
63
|
(0, import_helpers.ensureDirectoryExists)(path.dirname(syncFilePath));
|
|
64
64
|
fs.writeFileSync(syncFilePath, JSON.stringify(state, null, 2), "utf-8");
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Fast status check that uses sync state instead of downloading remote file content.
|
|
68
|
+
* This is much faster than getStatus() but may miss changes made by others since last pull.
|
|
69
|
+
* Use this for push operations where we trust the sync state.
|
|
70
|
+
*/
|
|
71
|
+
async getStatusFast(options) {
|
|
72
|
+
const syncState = this.loadSyncState();
|
|
73
|
+
const filesDir = (0, import_helpers.getTenantFilesDir)(this.tenant);
|
|
74
|
+
let localFiles = (0, import_helpers.getAllFilesInDir)(filesDir);
|
|
75
|
+
if (!options?.all) {
|
|
76
|
+
localFiles = localFiles.filter(
|
|
77
|
+
(f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.toLowerCase().endsWith(ext))
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
let remoteFiles = await this.farseerClient.listFiles();
|
|
81
|
+
if (!options?.all) {
|
|
82
|
+
remoteFiles = remoteFiles.filter(
|
|
83
|
+
(f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext))
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const remoteFilePaths = new Set(remoteFiles.map((f) => f.path));
|
|
87
|
+
const status = {
|
|
88
|
+
modifiedLocally: [],
|
|
89
|
+
modifiedRemotely: [],
|
|
90
|
+
onlyLocal: [],
|
|
91
|
+
onlyRemote: [],
|
|
92
|
+
inSync: []
|
|
93
|
+
};
|
|
94
|
+
for (const localFile of localFiles) {
|
|
95
|
+
const localPath = path.join(filesDir, localFile);
|
|
96
|
+
const content = fs.readFileSync(localPath);
|
|
97
|
+
const localHash = (0, import_helpers.calculateHash)(content);
|
|
98
|
+
const syncInfo = syncState.files[localFile];
|
|
99
|
+
if (remoteFilePaths.has(localFile)) {
|
|
100
|
+
if (syncInfo && localHash === syncInfo.localHash) {
|
|
101
|
+
status.inSync.push(localFile);
|
|
102
|
+
} else {
|
|
103
|
+
status.modifiedLocally.push(localFile);
|
|
104
|
+
}
|
|
105
|
+
} else {
|
|
106
|
+
if (syncInfo && syncInfo.remoteHash) {
|
|
107
|
+
status.modifiedRemotely.push(localFile);
|
|
108
|
+
} else {
|
|
109
|
+
status.onlyLocal.push(localFile);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const remoteFile of remoteFiles) {
|
|
114
|
+
if (!localFiles.includes(remoteFile.path)) {
|
|
115
|
+
const syncInfo = syncState.files[remoteFile.path];
|
|
116
|
+
if (syncInfo && syncInfo.localHash) {
|
|
117
|
+
status.modifiedLocally.push(remoteFile.path);
|
|
118
|
+
} else {
|
|
119
|
+
status.onlyRemote.push(remoteFile.path);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return status;
|
|
124
|
+
}
|
|
66
125
|
async getStatus(options) {
|
|
67
126
|
const syncState = this.loadSyncState();
|
|
68
127
|
const filesDir = (0, import_helpers.getTenantFilesDir)(this.tenant);
|
|
@@ -234,32 +293,48 @@ class SyncService {
|
|
|
234
293
|
remoteFileMap.set(file.path, file);
|
|
235
294
|
}
|
|
236
295
|
const localFiles = (0, import_helpers.getAllFilesInDir)(filesDir);
|
|
296
|
+
const filesToUpload = [];
|
|
297
|
+
const filesToUpdate = [];
|
|
298
|
+
const filesUnchanged = [];
|
|
237
299
|
for (const localFile of localFiles) {
|
|
238
300
|
const localPath = path.join(filesDir, localFile);
|
|
239
301
|
const content = fs.readFileSync(localPath);
|
|
240
302
|
const localHash = (0, import_helpers.calculateHash)(content);
|
|
241
303
|
const remoteFile = remoteFileMap.get(localFile);
|
|
304
|
+
const syncInfo = syncState.files[localFile];
|
|
242
305
|
if (remoteFile) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (localHash !== remoteHash) {
|
|
246
|
-
await this.farseerClient.updateFile(remoteFile.reference, content, path.basename(localFile));
|
|
247
|
-
result.updated.push(localFile);
|
|
306
|
+
if (syncInfo && localHash === syncInfo.localHash) {
|
|
307
|
+
filesUnchanged.push(localFile);
|
|
248
308
|
} else {
|
|
249
|
-
|
|
309
|
+
filesToUpdate.push({ localFile, remoteFile, content, localHash });
|
|
250
310
|
}
|
|
251
311
|
} else {
|
|
252
|
-
|
|
253
|
-
const fileName = pathParts.pop();
|
|
254
|
-
const folderPath = ["Files", ...pathParts];
|
|
255
|
-
await this.farseerClient.createFile(content, fileName, folderPath);
|
|
256
|
-
result.uploaded.push(localFile);
|
|
312
|
+
filesToUpload.push(localFile);
|
|
257
313
|
}
|
|
314
|
+
}
|
|
315
|
+
for (const localFile of filesToUpload) {
|
|
316
|
+
const localPath = path.join(filesDir, localFile);
|
|
317
|
+
const content = fs.readFileSync(localPath);
|
|
318
|
+
const localHash = (0, import_helpers.calculateHash)(content);
|
|
319
|
+
const pathParts = localFile.split("/");
|
|
320
|
+
const fileName = pathParts.pop();
|
|
321
|
+
const folderPath = ["Files", ...pathParts];
|
|
322
|
+
await this.farseerClient.createFile(content, fileName, folderPath);
|
|
323
|
+
result.uploaded.push(localFile);
|
|
324
|
+
syncState.files[localFile] = {
|
|
325
|
+
localHash,
|
|
326
|
+
remoteHash: localHash
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
for (const { localFile, remoteFile, content, localHash } of filesToUpdate) {
|
|
330
|
+
await this.farseerClient.updateFile(remoteFile.reference, content, path.basename(localFile));
|
|
331
|
+
result.updated.push(localFile);
|
|
258
332
|
syncState.files[localFile] = {
|
|
259
333
|
localHash,
|
|
260
334
|
remoteHash: localHash
|
|
261
335
|
};
|
|
262
336
|
}
|
|
337
|
+
result.unchanged = filesUnchanged;
|
|
263
338
|
const localFileSet = new Set(localFiles);
|
|
264
339
|
for (const [remotePath, remoteFile] of remoteFileMap) {
|
|
265
340
|
if (!localFileSet.has(remotePath)) {
|
|
@@ -281,17 +356,9 @@ class SyncService {
|
|
|
281
356
|
remoteFiles = remoteFiles.filter(
|
|
282
357
|
(f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext))
|
|
283
358
|
);
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const content = await this.farseerClient.getFileContentAsBuffer(file.reference);
|
|
288
|
-
return { path: file.path, hash: (0, import_helpers.calculateHash)(content) };
|
|
289
|
-
},
|
|
290
|
-
15
|
|
291
|
-
);
|
|
292
|
-
for (const { path: filePath, hash: remoteHash } of fileContents) {
|
|
293
|
-
const syncInfo = syncState.files[filePath];
|
|
294
|
-
if (!syncInfo || syncInfo.remoteHash !== remoteHash) {
|
|
359
|
+
for (const file of remoteFiles) {
|
|
360
|
+
const syncInfo = syncState.files[file.path];
|
|
361
|
+
if (!syncInfo) {
|
|
295
362
|
return true;
|
|
296
363
|
}
|
|
297
364
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/syncService.ts"],
|
|
4
|
-
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { IFarseerClient, RemoteFile, DEFAULT_SCRIPT_EXTENSIONS } from './farseerFactory';\nimport { calculateHash, getTenantFilesDir, getSyncFilePath, ensureDirectoryExists, getAllFilesInDir, fetchWithConcurrency } from '../utils/helpers';\nimport { logger } from '../utils/logger';\n\nexport interface SyncFileInfo {\n localHash: string;\n remoteHash: string;\n metadata?: {\n uploadTime?: string;\n uploaderEmail?: string;\n uploaderName?: string;\n lastFetched?: string;\n };\n}\n\nexport interface SyncState {\n lastSync: string;\n files: Record<string, SyncFileInfo>;\n}\n\nexport interface SyncStatus {\n modifiedLocally: string[];\n modifiedRemotely: string[];\n onlyLocal: string[];\n onlyRemote: string[];\n inSync: string[];\n}\n\nexport class SyncService {\n private tenant: string;\n private farseerClient: IFarseerClient;\n\n constructor(tenant: string, farseerClient: IFarseerClient) {\n this.tenant = tenant;\n this.farseerClient = farseerClient;\n }\n\n loadSyncState(): SyncState {\n const syncFilePath = getSyncFilePath(this.tenant);\n\n if (!fs.existsSync(syncFilePath)) {\n return {\n lastSync: '',\n files: {},\n };\n }\n\n try {\n const content = fs.readFileSync(syncFilePath, 'utf-8');\n return JSON.parse(content) as SyncState;\n } catch {\n return {\n lastSync: '',\n files: {},\n };\n }\n }\n\n saveSyncState(state: SyncState): void {\n const syncFilePath = getSyncFilePath(this.tenant);\n ensureDirectoryExists(path.dirname(syncFilePath));\n fs.writeFileSync(syncFilePath, JSON.stringify(state, null, 2), 'utf-8');\n }\n\n async getStatus(options?: { all?: boolean }): Promise<SyncStatus> {\n const syncState = this.loadSyncState();\n const filesDir = getTenantFilesDir(this.tenant);\n\n // Get local files\n let localFiles = getAllFilesInDir(filesDir);\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n localFiles = localFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.toLowerCase().endsWith(ext))\n );\n }\n\n const localFileHashes: Record<string, string> = {};\n\n for (const file of localFiles) {\n const fullPath = path.join(filesDir, file);\n const content = fs.readFileSync(fullPath);\n localFileHashes[file] = calculateHash(content);\n }\n\n // Get remote files\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n }\n\n const remoteFileHashes: Record<string, string> = {};\n\n // Fetch file contents in parallel with concurrency limit\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n return { path: file.path, hash: calculateHash(content) };\n },\n 15\n );\n\n for (const { path, hash } of fileContents) {\n remoteFileHashes[path] = hash;\n }\n\n const status: SyncStatus = {\n modifiedLocally: [],\n modifiedRemotely: [],\n onlyLocal: [],\n onlyRemote: [],\n inSync: [],\n };\n\n const allFiles = new Set([...Object.keys(localFileHashes), ...Object.keys(remoteFileHashes)]);\n\n for (const file of allFiles) {\n const localHash = localFileHashes[file];\n const remoteHash = remoteFileHashes[file];\n const syncInfo = syncState.files[file];\n\n if (localHash && remoteHash) {\n // File exists both locally and remotely\n if (localHash === remoteHash) {\n status.inSync.push(file);\n } else if (syncInfo) {\n // We have sync state to compare\n const localChanged = localHash !== syncInfo.localHash;\n const remoteChanged = remoteHash !== syncInfo.remoteHash;\n\n if (localChanged && remoteChanged) {\n // Both changed - conflict (treat as modified locally for now)\n status.modifiedLocally.push(file);\n status.modifiedRemotely.push(file);\n } else if (localChanged) {\n status.modifiedLocally.push(file);\n } else if (remoteChanged) {\n status.modifiedRemotely.push(file);\n } else {\n status.inSync.push(file);\n }\n } else {\n // No sync state - files are different, treat as conflict\n status.modifiedLocally.push(file);\n }\n } else if (localHash && !remoteHash) {\n // Only exists locally\n if (syncInfo && syncInfo.remoteHash) {\n // Was synced before, deleted on remote\n status.modifiedRemotely.push(file);\n } else {\n status.onlyLocal.push(file);\n }\n } else if (!localHash && remoteHash) {\n // Only exists remotely\n if (syncInfo && syncInfo.localHash) {\n // Was synced before, deleted locally\n status.modifiedLocally.push(file);\n } else {\n status.onlyRemote.push(file);\n }\n }\n }\n\n return status;\n }\n\n async pull(options?: { all?: boolean }): Promise<{\n downloaded: string[];\n deleted: string[];\n unchanged: string[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n ensureDirectoryExists(filesDir);\n\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n }\n\n // Batch fetch metadata for all files\n remoteFiles = await this.fetchMetadataForFiles(remoteFiles);\n\n const result = {\n downloaded: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n };\n\n const remoteFilePaths = new Set(remoteFiles.map(f => f.path));\n\n // Download file contents in parallel with concurrency limit\n logger.dim(`Fetching ${remoteFiles.length} files in parallel...`);\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file, index) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n // Show progress every 10 files\n if ((index + 1) % 10 === 0 || index === remoteFiles.length - 1) {\n process.stdout.write(`\\r Progress: ${index + 1}/${remoteFiles.length} files`);\n }\n return { file, content };\n },\n 15\n );\n // Clear progress line\n if (remoteFiles.length > 0) {\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n }\n\n // Process downloaded files\n for (const { file, content } of fileContents) {\n const localPath = path.join(filesDir, file.path);\n const remoteHash = calculateHash(content);\n\n let needsUpdate = true;\n\n if (fs.existsSync(localPath)) {\n const localContent = fs.readFileSync(localPath);\n const localHash = calculateHash(localContent);\n\n if (localHash === remoteHash) {\n needsUpdate = false;\n result.unchanged.push(file.path);\n }\n }\n\n if (needsUpdate) {\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, content);\n result.downloaded.push(file.path);\n }\n\n // Update sync state with metadata\n syncState.files[file.path] = {\n localHash: remoteHash,\n remoteHash: remoteHash,\n metadata: file.metadata ? {\n uploadTime: file.metadata.uploadTime,\n uploaderEmail: file.metadata.uploader?.email,\n uploaderName: file.metadata.uploader\n ? `${file.metadata.uploader.firstName} ${file.metadata.uploader.lastName}`.trim()\n : undefined,\n lastFetched: new Date().toISOString(),\n } : undefined,\n };\n }\n\n // Check for files that were deleted on remote\n const localFiles = getAllFilesInDir(filesDir);\n for (const localFile of localFiles) {\n if (!remoteFilePaths.has(localFile)) {\n // File exists locally but not on remote\n const syncInfo = syncState.files[localFile];\n if (syncInfo) {\n // Was synced before, now deleted on remote - delete locally\n const localPath = path.join(filesDir, localFile);\n fs.unlinkSync(localPath);\n result.deleted.push(localFile);\n delete syncState.files[localFile];\n }\n // If no sync info, it's a new local file - don't delete\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n async push(): Promise<{\n uploaded: string[];\n updated: string[];\n deleted: string[];\n unchanged: string[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const syncState = this.loadSyncState();\n\n const result = {\n uploaded: [] as string[],\n updated: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n };\n\n // Get current remote files\n const remoteFiles = await this.farseerClient.listFiles();\n const remoteFileMap = new Map<string, RemoteFile>();\n for (const file of remoteFiles) {\n remoteFileMap.set(file.path, file);\n }\n\n // Get local files\n const localFiles = getAllFilesInDir(filesDir);\n\n // Upload/update local files\n for (const localFile of localFiles) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n const localHash = calculateHash(content);\n\n const remoteFile = remoteFileMap.get(localFile);\n\n if (remoteFile) {\n // File exists on remote - check if update needed\n const remoteContent = await this.farseerClient.getFileContentAsBuffer(remoteFile.reference);\n const remoteHash = calculateHash(remoteContent);\n\n if (localHash !== remoteHash) {\n await this.farseerClient.updateFile(remoteFile.reference, content, path.basename(localFile));\n result.updated.push(localFile);\n } else {\n result.unchanged.push(localFile);\n }\n } else {\n // File doesn't exist on remote - create it\n const pathParts = localFile.split('/');\n const fileName = pathParts.pop()!;\n const folderPath = ['Files', ...pathParts];\n\n await this.farseerClient.createFile(content, fileName, folderPath);\n result.uploaded.push(localFile);\n }\n\n // Update sync state\n syncState.files[localFile] = {\n localHash: localHash,\n remoteHash: localHash,\n };\n }\n\n // Delete files on remote that were deleted locally\n const localFileSet = new Set(localFiles);\n for (const [remotePath, remoteFile] of remoteFileMap) {\n if (!localFileSet.has(remotePath)) {\n const syncInfo = syncState.files[remotePath];\n if (syncInfo) {\n // Was synced before, now deleted locally - delete on remote\n await this.farseerClient.deleteFile(remoteFile.reference);\n result.deleted.push(remotePath);\n delete syncState.files[remotePath];\n }\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n async checkRemoteChanges(): Promise<boolean> {\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only (same as pull/status) to avoid false positives\n // from non-script files like .json, .png, etc.\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n\n // Fetch file contents in parallel to check for changes\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n return { path: file.path, hash: calculateHash(content) };\n },\n 15\n );\n\n for (const { path: filePath, hash: remoteHash } of fileContents) {\n const syncInfo = syncState.files[filePath];\n\n if (!syncInfo || syncInfo.remoteHash !== remoteHash) {\n return true; // Remote has changes\n }\n }\n\n // Check for deleted files on remote (only for script files in sync state)\n for (const filePath of Object.keys(syncState.files)) {\n // Only check script files\n const isScript = DEFAULT_SCRIPT_EXTENSIONS.some(ext => filePath.toLowerCase().endsWith(ext));\n if (!isScript) continue;\n\n const exists = remoteFiles.some(f => f.path === filePath);\n if (!exists && syncState.files[filePath].remoteHash) {\n return true; // File was deleted on remote\n }\n }\n\n return false;\n }\n\n async getFileDiff(filePath: string): Promise<{\n localContent: string | null;\n remoteContent: string | null;\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const localPath = path.join(filesDir, filePath);\n\n let localContent: string | null = null;\n let remoteContent: string | null = null;\n\n if (fs.existsSync(localPath)) {\n // For diff, read as text (diff only makes sense for text files)\n localContent = fs.readFileSync(localPath, 'utf-8');\n }\n\n const remoteFile = await this.farseerClient.getFileByPath(filePath);\n if (remoteFile) {\n remoteContent = await this.farseerClient.getFileContent(remoteFile.reference);\n }\n\n return { localContent, remoteContent };\n }\n\n /**\n * Batch fetch metadata for multiple files in parallel.\n * Fetches metadata in batches of 10 to avoid overwhelming the API.\n * Non-critical operation - failures are silently ignored.\n */\n private async fetchMetadataForFiles(files: RemoteFile[]): Promise<RemoteFile[]> {\n const batchSize = 10;\n\n for (let i = 0; i < files.length; i += batchSize) {\n const batch = files.slice(i, i + batchSize);\n\n await Promise.all(batch.map(async (file) => {\n try {\n const metadata = await this.farseerClient.getFileMetadata(file.reference);\n if (metadata) {\n file.metadata = metadata;\n }\n } catch {\n // Silently ignore metadata fetch errors - non-critical\n }\n }));\n }\n\n return files;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,4BAAsE;AACtE,qBAAiI;AACjI,oBAAuB;AA0BhB,MAAM,YAAY;AAAA,EAIrB,YAAY,QAAgB,eAA+B;AACvD,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACzB;AAAA,EAEA,gBAA2B;AACvB,UAAM,mBAAe,gCAAgB,KAAK,MAAM;AAEhD,QAAI,CAAC,GAAG,WAAW,YAAY,GAAG;AAC9B,aAAO;AAAA,QACH,UAAU;AAAA,QACV,OAAO,CAAC;AAAA,MACZ;AAAA,IACJ;AAEA,QAAI;AACA,YAAM,UAAU,GAAG,aAAa,cAAc,OAAO;AACrD,aAAO,KAAK,MAAM,OA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C,UAAM,YAAY,KAAK,cAAc;AAErC,UAAM,SAAS;AAAA,MACX,UAAU,CAAC;AAAA,MACX,SAAS,CAAC;AAAA,MACV,SAAS,CAAC;AAAA,MACV,WAAW,CAAC;AAAA,IAChB;AAGA,UAAM,cAAc,MAAM,KAAK,cAAc,UAAU;AACvD,UAAM,gBAAgB,oBAAI,IAAwB;AAClD,eAAW,QAAQ,aAAa;AAC5B,oBAAc,IAAI,KAAK,MAAM,IAAI;AAAA,IACrC;AAGA,UAAM,iBAAa,iCAAiB,QAAQ;AAG5C,eAAW,aAAa,YAAY;AAChC,YAAM,YAAY,KAAK,KAAK,UAAU,SAAS;AAC/C,YAAM,UAAU,GAAG,aAAa,SAAS;AACzC,YAAM,gBAAY,8BAAc,OAAO;AAEvC,YAAM,aAAa,cAAc,IAAI,SAAS;
|
|
4
|
+
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { IFarseerClient, RemoteFile, DEFAULT_SCRIPT_EXTENSIONS } from './farseerFactory';\nimport { calculateHash, getTenantFilesDir, getSyncFilePath, ensureDirectoryExists, getAllFilesInDir, fetchWithConcurrency } from '../utils/helpers';\nimport { logger } from '../utils/logger';\n\nexport interface SyncFileInfo {\n localHash: string;\n remoteHash: string;\n metadata?: {\n uploadTime?: string;\n uploaderEmail?: string;\n uploaderName?: string;\n lastFetched?: string;\n };\n}\n\nexport interface SyncState {\n lastSync: string;\n files: Record<string, SyncFileInfo>;\n}\n\nexport interface SyncStatus {\n modifiedLocally: string[];\n modifiedRemotely: string[];\n onlyLocal: string[];\n onlyRemote: string[];\n inSync: string[];\n}\n\nexport class SyncService {\n private tenant: string;\n private farseerClient: IFarseerClient;\n\n constructor(tenant: string, farseerClient: IFarseerClient) {\n this.tenant = tenant;\n this.farseerClient = farseerClient;\n }\n\n loadSyncState(): SyncState {\n const syncFilePath = getSyncFilePath(this.tenant);\n\n if (!fs.existsSync(syncFilePath)) {\n return {\n lastSync: '',\n files: {},\n };\n }\n\n try {\n const content = fs.readFileSync(syncFilePath, 'utf-8');\n return JSON.parse(content) as SyncState;\n } catch {\n return {\n lastSync: '',\n files: {},\n };\n }\n }\n\n saveSyncState(state: SyncState): void {\n const syncFilePath = getSyncFilePath(this.tenant);\n ensureDirectoryExists(path.dirname(syncFilePath));\n fs.writeFileSync(syncFilePath, JSON.stringify(state, null, 2), 'utf-8');\n }\n\n /**\n * Fast status check that uses sync state instead of downloading remote file content.\n * This is much faster than getStatus() but may miss changes made by others since last pull.\n * Use this for push operations where we trust the sync state.\n */\n async getStatusFast(options?: { all?: boolean }): Promise<SyncStatus> {\n const syncState = this.loadSyncState();\n const filesDir = getTenantFilesDir(this.tenant);\n\n // Get local files\n let localFiles = getAllFilesInDir(filesDir);\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n localFiles = localFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.toLowerCase().endsWith(ext))\n );\n }\n\n // Get remote file list only (no content download)\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n }\n\n const remoteFilePaths = new Set(remoteFiles.map(f => f.path));\n\n const status: SyncStatus = {\n modifiedLocally: [],\n modifiedRemotely: [],\n onlyLocal: [],\n onlyRemote: [],\n inSync: [],\n };\n\n // Check local files\n for (const localFile of localFiles) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n const localHash = calculateHash(content);\n const syncInfo = syncState.files[localFile];\n\n if (remoteFilePaths.has(localFile)) {\n // File exists both locally and remotely\n if (syncInfo && localHash === syncInfo.localHash) {\n // Local file hasn't changed since last sync\n status.inSync.push(localFile);\n } else {\n // Local file changed (or no sync info)\n status.modifiedLocally.push(localFile);\n }\n } else {\n // File only exists locally\n if (syncInfo && syncInfo.remoteHash) {\n // Was synced before, deleted on remote\n status.modifiedRemotely.push(localFile);\n } else {\n status.onlyLocal.push(localFile);\n }\n }\n }\n\n // Check remote files that don't exist locally\n for (const remoteFile of remoteFiles) {\n if (!localFiles.includes(remoteFile.path)) {\n const syncInfo = syncState.files[remoteFile.path];\n if (syncInfo && syncInfo.localHash) {\n // Was synced before, deleted locally\n status.modifiedLocally.push(remoteFile.path);\n } else {\n status.onlyRemote.push(remoteFile.path);\n }\n }\n }\n\n return status;\n }\n\n async getStatus(options?: { all?: boolean }): Promise<SyncStatus> {\n const syncState = this.loadSyncState();\n const filesDir = getTenantFilesDir(this.tenant);\n\n // Get local files\n let localFiles = getAllFilesInDir(filesDir);\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n localFiles = localFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.toLowerCase().endsWith(ext))\n );\n }\n\n const localFileHashes: Record<string, string> = {};\n\n for (const file of localFiles) {\n const fullPath = path.join(filesDir, file);\n const content = fs.readFileSync(fullPath);\n localFileHashes[file] = calculateHash(content);\n }\n\n // Get remote files\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n }\n\n const remoteFileHashes: Record<string, string> = {};\n\n // Fetch file contents in parallel with concurrency limit\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n return { path: file.path, hash: calculateHash(content) };\n },\n 15\n );\n\n for (const { path, hash } of fileContents) {\n remoteFileHashes[path] = hash;\n }\n\n const status: SyncStatus = {\n modifiedLocally: [],\n modifiedRemotely: [],\n onlyLocal: [],\n onlyRemote: [],\n inSync: [],\n };\n\n const allFiles = new Set([...Object.keys(localFileHashes), ...Object.keys(remoteFileHashes)]);\n\n for (const file of allFiles) {\n const localHash = localFileHashes[file];\n const remoteHash = remoteFileHashes[file];\n const syncInfo = syncState.files[file];\n\n if (localHash && remoteHash) {\n // File exists both locally and remotely\n if (localHash === remoteHash) {\n status.inSync.push(file);\n } else if (syncInfo) {\n // We have sync state to compare\n const localChanged = localHash !== syncInfo.localHash;\n const remoteChanged = remoteHash !== syncInfo.remoteHash;\n\n if (localChanged && remoteChanged) {\n // Both changed - conflict (treat as modified locally for now)\n status.modifiedLocally.push(file);\n status.modifiedRemotely.push(file);\n } else if (localChanged) {\n status.modifiedLocally.push(file);\n } else if (remoteChanged) {\n status.modifiedRemotely.push(file);\n } else {\n status.inSync.push(file);\n }\n } else {\n // No sync state - files are different, treat as conflict\n status.modifiedLocally.push(file);\n }\n } else if (localHash && !remoteHash) {\n // Only exists locally\n if (syncInfo && syncInfo.remoteHash) {\n // Was synced before, deleted on remote\n status.modifiedRemotely.push(file);\n } else {\n status.onlyLocal.push(file);\n }\n } else if (!localHash && remoteHash) {\n // Only exists remotely\n if (syncInfo && syncInfo.localHash) {\n // Was synced before, deleted locally\n status.modifiedLocally.push(file);\n } else {\n status.onlyRemote.push(file);\n }\n }\n }\n\n return status;\n }\n\n async pull(options?: { all?: boolean }): Promise<{\n downloaded: string[];\n deleted: string[];\n unchanged: string[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n ensureDirectoryExists(filesDir);\n\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only unless --all is specified\n if (!options?.all) {\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n }\n\n // Batch fetch metadata for all files\n remoteFiles = await this.fetchMetadataForFiles(remoteFiles);\n\n const result = {\n downloaded: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n };\n\n const remoteFilePaths = new Set(remoteFiles.map(f => f.path));\n\n // Download file contents in parallel with concurrency limit\n logger.dim(`Fetching ${remoteFiles.length} files in parallel...`);\n const fileContents = await fetchWithConcurrency(\n remoteFiles,\n async (file, index) => {\n const content = await this.farseerClient.getFileContentAsBuffer(file.reference);\n // Show progress every 10 files\n if ((index + 1) % 10 === 0 || index === remoteFiles.length - 1) {\n process.stdout.write(`\\r Progress: ${index + 1}/${remoteFiles.length} files`);\n }\n return { file, content };\n },\n 15\n );\n // Clear progress line\n if (remoteFiles.length > 0) {\n process.stdout.write('\\r' + ' '.repeat(50) + '\\r');\n }\n\n // Process downloaded files\n for (const { file, content } of fileContents) {\n const localPath = path.join(filesDir, file.path);\n const remoteHash = calculateHash(content);\n\n let needsUpdate = true;\n\n if (fs.existsSync(localPath)) {\n const localContent = fs.readFileSync(localPath);\n const localHash = calculateHash(localContent);\n\n if (localHash === remoteHash) {\n needsUpdate = false;\n result.unchanged.push(file.path);\n }\n }\n\n if (needsUpdate) {\n ensureDirectoryExists(path.dirname(localPath));\n fs.writeFileSync(localPath, content);\n result.downloaded.push(file.path);\n }\n\n // Update sync state with metadata\n syncState.files[file.path] = {\n localHash: remoteHash,\n remoteHash: remoteHash,\n metadata: file.metadata ? {\n uploadTime: file.metadata.uploadTime,\n uploaderEmail: file.metadata.uploader?.email,\n uploaderName: file.metadata.uploader\n ? `${file.metadata.uploader.firstName} ${file.metadata.uploader.lastName}`.trim()\n : undefined,\n lastFetched: new Date().toISOString(),\n } : undefined,\n };\n }\n\n // Check for files that were deleted on remote\n const localFiles = getAllFilesInDir(filesDir);\n for (const localFile of localFiles) {\n if (!remoteFilePaths.has(localFile)) {\n // File exists locally but not on remote\n const syncInfo = syncState.files[localFile];\n if (syncInfo) {\n // Was synced before, now deleted on remote - delete locally\n const localPath = path.join(filesDir, localFile);\n fs.unlinkSync(localPath);\n result.deleted.push(localFile);\n delete syncState.files[localFile];\n }\n // If no sync info, it's a new local file - don't delete\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n async push(): Promise<{\n uploaded: string[];\n updated: string[];\n deleted: string[];\n unchanged: string[];\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const syncState = this.loadSyncState();\n\n const result = {\n uploaded: [] as string[],\n updated: [] as string[],\n deleted: [] as string[],\n unchanged: [] as string[],\n };\n\n // Get current remote files (just the list, not content)\n const remoteFiles = await this.farseerClient.listFiles();\n const remoteFileMap = new Map<string, RemoteFile>();\n for (const file of remoteFiles) {\n remoteFileMap.set(file.path, file);\n }\n\n // Get local files\n const localFiles = getAllFilesInDir(filesDir);\n\n // Determine which files need to be pushed by comparing with sync state\n const filesToUpload: string[] = [];\n const filesToUpdate: { localFile: string; remoteFile: RemoteFile; content: Buffer; localHash: string }[] = [];\n const filesUnchanged: string[] = [];\n\n for (const localFile of localFiles) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n const localHash = calculateHash(content);\n\n const remoteFile = remoteFileMap.get(localFile);\n const syncInfo = syncState.files[localFile];\n\n if (remoteFile) {\n // File exists on remote - check if local changed since last sync\n if (syncInfo && localHash === syncInfo.localHash) {\n // Local file hasn't changed since last sync - skip\n filesUnchanged.push(localFile);\n } else {\n // Local file changed - needs update\n filesToUpdate.push({ localFile, remoteFile, content, localHash });\n }\n } else {\n // File doesn't exist on remote - needs upload\n filesToUpload.push(localFile);\n }\n }\n\n // Upload new files\n for (const localFile of filesToUpload) {\n const localPath = path.join(filesDir, localFile);\n const content = fs.readFileSync(localPath);\n const localHash = calculateHash(content);\n\n const pathParts = localFile.split('/');\n const fileName = pathParts.pop()!;\n const folderPath = ['Files', ...pathParts];\n\n await this.farseerClient.createFile(content, fileName, folderPath);\n result.uploaded.push(localFile);\n\n syncState.files[localFile] = {\n localHash: localHash,\n remoteHash: localHash,\n };\n }\n\n // Update changed files\n for (const { localFile, remoteFile, content, localHash } of filesToUpdate) {\n await this.farseerClient.updateFile(remoteFile.reference, content, path.basename(localFile));\n result.updated.push(localFile);\n\n syncState.files[localFile] = {\n localHash: localHash,\n remoteHash: localHash,\n };\n }\n\n // Mark unchanged files\n result.unchanged = filesUnchanged;\n\n // Delete files on remote that were deleted locally\n const localFileSet = new Set(localFiles);\n for (const [remotePath, remoteFile] of remoteFileMap) {\n if (!localFileSet.has(remotePath)) {\n const syncInfo = syncState.files[remotePath];\n if (syncInfo) {\n // Was synced before, now deleted locally - delete on remote\n await this.farseerClient.deleteFile(remoteFile.reference);\n result.deleted.push(remotePath);\n delete syncState.files[remotePath];\n }\n }\n }\n\n syncState.lastSync = new Date().toISOString();\n this.saveSyncState(syncState);\n\n return result;\n }\n\n async checkRemoteChanges(): Promise<boolean> {\n const syncState = this.loadSyncState();\n let remoteFiles = await this.farseerClient.listFiles();\n\n // Filter to scripts only (same as pull/status) to avoid false positives\n // from non-script files like .json, .png, etc.\n remoteFiles = remoteFiles.filter(f =>\n DEFAULT_SCRIPT_EXTENSIONS.some(ext => f.name.toLowerCase().endsWith(ext))\n );\n\n // Quick check: new files on remote that we don't have in sync state\n for (const file of remoteFiles) {\n const syncInfo = syncState.files[file.path];\n if (!syncInfo) {\n return true; // New file on remote\n }\n }\n\n // Quick check: files deleted on remote that we have in sync state\n for (const filePath of Object.keys(syncState.files)) {\n // Only check script files\n const isScript = DEFAULT_SCRIPT_EXTENSIONS.some(ext => filePath.toLowerCase().endsWith(ext));\n if (!isScript) continue;\n\n const exists = remoteFiles.some(f => f.path === filePath);\n if (!exists && syncState.files[filePath].remoteHash) {\n return true; // File was deleted on remote\n }\n }\n\n // Note: We don't check for content changes here anymore for performance.\n // After a pull, sync state is accurate. Content changes by others\n // between pull and push are a rare edge case - user should pull first.\n return false;\n }\n\n async getFileDiff(filePath: string): Promise<{\n localContent: string | null;\n remoteContent: string | null;\n }> {\n const filesDir = getTenantFilesDir(this.tenant);\n const localPath = path.join(filesDir, filePath);\n\n let localContent: string | null = null;\n let remoteContent: string | null = null;\n\n if (fs.existsSync(localPath)) {\n // For diff, read as text (diff only makes sense for text files)\n localContent = fs.readFileSync(localPath, 'utf-8');\n }\n\n const remoteFile = await this.farseerClient.getFileByPath(filePath);\n if (remoteFile) {\n remoteContent = await this.farseerClient.getFileContent(remoteFile.reference);\n }\n\n return { localContent, remoteContent };\n }\n\n /**\n * Batch fetch metadata for multiple files in parallel.\n * Fetches metadata in batches of 10 to avoid overwhelming the API.\n * Non-critical operation - failures are silently ignored.\n */\n private async fetchMetadataForFiles(files: RemoteFile[]): Promise<RemoteFile[]> {\n const batchSize = 10;\n\n for (let i = 0; i < files.length; i += batchSize) {\n const batch = files.slice(i, i + batchSize);\n\n await Promise.all(batch.map(async (file) => {\n try {\n const metadata = await this.farseerClient.getFileMetadata(file.reference);\n if (metadata) {\n file.metadata = metadata;\n }\n } catch {\n // Silently ignore metadata fetch errors - non-critical\n }\n }));\n }\n\n return files;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,4BAAsE;AACtE,qBAAiI;AACjI,oBAAuB;AA0BhB,MAAM,YAAY;AAAA,EAIrB,YAAY,QAAgB,eAA+B;AACvD,SAAK,SAAS;AACd,SAAK,gBAAgB;AAAA,EACzB;AAAA,EAEA,gBAA2B;AACvB,UAAM,mBAAe,gCAAgB,KAAK,MAAM;AAEhD,QAAI,CAAC,GAAG,WAAW,YAAY,GAAG;AAC9B,aAAO;AAAA,QACH,UAAU;AAAA,QACV,OAAO,CAAC;AAAA,MACZ;AAAA,IACJ;AAEA,QAAI;AACA,YAAM,UAAU,GAAG,aAAa,cAAc,OAAO;AACrD,aAAO,KAAK,MAAM,OAAO;AAAA,IAC7B,QAAQ;AACJ,aAAO;AAAA,QACH,UAAU;AAAA,QACV,OAAO,CAAC;AAAA,MACZ;AAAA,IACJ;AAAA,EACJ;AAAA,EAEA,cAAc,OAAwB;AAClC,UAAM,mBAAe,gCAAgB,KAAK,MAAM;AAChD,8CAAsB,KAAK,QAAQ,YAAY,CAAC;AAChD,OAAG,cAAc,cAAc,KAAK,UAAU,OAAO,MAAM,CA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G,CAAC;AAC3F,UAAI,CAAC,SAAU;AAEf,YAAM,SAAS,YAAY,KAAK,OAAK,EAAE,SAAS,QAAQ;AACxD,UAAI,CAAC,UAAU,UAAU,MAAM,QAAQ,EAAE,YAAY;AACjD,eAAO;AAAA,MACX;AAAA,IACJ;AAKA,WAAO;AAAA,EACX;AAAA,EAEA,MAAM,YAAY,UAGf;AACC,UAAM,eAAW,kCAAkB,KAAK,MAAM;AAC9C,UAAM,YAAY,KAAK,KAAK,UAAU,QAAQ;AAE9C,QAAI,eAA8B;AAClC,QAAI,gBAA+B;AAEnC,QAAI,GAAG,WAAW,SAAS,GAAG;AAE1B,qBAAe,GAAG,aAAa,WAAW,OAAO;AAAA,IACrD;AAEA,UAAM,aAAa,MAAM,KAAK,cAAc,cAAc,QAAQ;AAClE,QAAI,YAAY;AACZ,sBAAgB,MAAM,KAAK,cAAc,eAAe,WAAW,SAAS;AAAA,IAChF;AAEA,WAAO,EAAE,cAAc,cAAc;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAc,sBAAsB,OAA4C;AAC5E,UAAM,YAAY;AAElB,aAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,WAAW;AAC9C,YAAM,QAAQ,MAAM,MAAM,GAAG,IAAI,SAAS;AAE1C,YAAM,QAAQ,IAAI,MAAM,IAAI,OAAO,SAAS;AACxC,YAAI;AACA,gBAAM,WAAW,MAAM,KAAK,cAAc,gBAAgB,KAAK,SAAS;AACxE,cAAI,UAAU;AACV,iBAAK,WAAW;AAAA,UACpB;AAAA,QACJ,QAAQ;AAAA,QAER;AAAA,MACJ,CAAC,CAAC;AAAA,IACN;AAEA,WAAO;AAAA,EACX;AACJ;",
|
|
6
6
|
"names": ["path"]
|
|
7
7
|
}
|
package/dist/utils/constants.js
CHANGED
|
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var constants_exports = {};
|
|
19
19
|
__export(constants_exports, {
|
|
20
20
|
CLI_GIT_AUTHOR: () => CLI_GIT_AUTHOR,
|
|
21
|
+
CLI_VERSION: () => CLI_VERSION,
|
|
21
22
|
FARSEER_CLIENT_AXIOS_URL: () => FARSEER_CLIENT_AXIOS_URL,
|
|
22
23
|
FARSEER_CLIENT_URL: () => FARSEER_CLIENT_URL,
|
|
23
24
|
KEYCLOAK_CLIENT_ID: () => KEYCLOAK_CLIENT_ID,
|
|
@@ -26,6 +27,7 @@ __export(constants_exports, {
|
|
|
26
27
|
SCRIPT_EXTENSIONS: () => SCRIPT_EXTENSIONS
|
|
27
28
|
});
|
|
28
29
|
module.exports = __toCommonJS(constants_exports);
|
|
30
|
+
const CLI_VERSION = "1.0.4";
|
|
29
31
|
const FARSEER_CLIENT_URL = "https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar";
|
|
30
32
|
const FARSEER_CLIENT_AXIOS_URL = "https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar";
|
|
31
33
|
const KEYCLOAK_TOKEN_URL = "https://login.farseer.io/auth/realms/master/protocol/openid-connect/token";
|
|
@@ -36,6 +38,7 @@ const CLI_GIT_AUTHOR = "Farseer CLI <cli@farseer.io>";
|
|
|
36
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
39
|
0 && (module.exports = {
|
|
38
40
|
CLI_GIT_AUTHOR,
|
|
41
|
+
CLI_VERSION,
|
|
39
42
|
FARSEER_CLIENT_AXIOS_URL,
|
|
40
43
|
FARSEER_CLIENT_URL,
|
|
41
44
|
KEYCLOAK_CLIENT_ID,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/constants.ts"],
|
|
4
|
-
"sourcesContent": ["// Farseer client package URLs - update these when new versions are released\nexport const FARSEER_CLIENT_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar';\nexport const FARSEER_CLIENT_AXIOS_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar';\n\n// Keycloak auth configuration\nexport const KEYCLOAK_TOKEN_URL = 'https://login.farseer.io/auth/realms/master/protocol/openid-connect/token';\nexport const KEYCLOAK_CLIENT_ID = 'security-admin-console';\n\n// Default paths\nexport const SCRIPTS_FOLDER_PATH = ['Files', 'Scripts'];\n\n// Supported script file extensions\nexport const SCRIPT_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];\n\n// Git commit author for CLI-generated commits\nexport const CLI_GIT_AUTHOR = 'Farseer CLI <cli@farseer.io>';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;AAGjC,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAG3B,MAAM,sBAAsB,CAAC,SAAS,SAAS;AAG/C,MAAM,oBAAoB,CAAC,OAAO,OAAO,QAAQ,MAAM;AAGvD,MAAM,iBAAiB;",
|
|
4
|
+
"sourcesContent": ["// CLI version - update this when publishing new version\nexport const CLI_VERSION = '1.0.4';\n\n// Farseer client package URLs - update these when new versions are released\nexport const FARSEER_CLIENT_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar';\nexport const FARSEER_CLIENT_AXIOS_URL = 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar';\n\n// Keycloak auth configuration\nexport const KEYCLOAK_TOKEN_URL = 'https://login.farseer.io/auth/realms/master/protocol/openid-connect/token';\nexport const KEYCLOAK_CLIENT_ID = 'security-admin-console';\n\n// Default paths\nexport const SCRIPTS_FOLDER_PATH = ['Files', 'Scripts'];\n\n// Supported script file extensions\nexport const SCRIPT_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];\n\n// Git commit author for CLI-generated commits\nexport const CLI_GIT_AUTHOR = 'Farseer CLI <cli@farseer.io>';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,MAAM,cAAc;AAGpB,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;AAGjC,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAG3B,MAAM,sBAAsB,CAAC,SAAS,SAAS;AAG/C,MAAM,oBAAoB,CAAC,OAAO,OAAO,QAAQ,MAAM;AAGvD,MAAM,iBAAiB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/utils/helpers.js
CHANGED
|
@@ -71,7 +71,14 @@ function calculateHash(content) {
|
|
|
71
71
|
return crypto.createHash("md5").update(content).digest("hex");
|
|
72
72
|
}
|
|
73
73
|
function getAppsDir() {
|
|
74
|
-
|
|
74
|
+
let dir = process.cwd();
|
|
75
|
+
while (dir !== path.dirname(dir)) {
|
|
76
|
+
if (fs.existsSync(path.join(dir, ".git"))) {
|
|
77
|
+
return path.join(dir, "farseer-apps");
|
|
78
|
+
}
|
|
79
|
+
dir = path.dirname(dir);
|
|
80
|
+
}
|
|
81
|
+
return path.join(process.cwd(), "farseer-apps");
|
|
75
82
|
}
|
|
76
83
|
function getTenantDir(tenant) {
|
|
77
84
|
return path.join(getAppsDir(), tenant);
|