farseer-cli 1.0.8 → 1.0.10

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 (41) hide show
  1. package/dist/commands/app.js +377 -0
  2. package/dist/commands/apps.js +91 -0
  3. package/dist/commands/checkout.js +164 -0
  4. package/dist/commands/config.js +141 -0
  5. package/dist/commands/diff.js +210 -0
  6. package/dist/commands/dimensions.js +130 -0
  7. package/dist/commands/files.js +88 -0
  8. package/dist/commands/install.js +82 -0
  9. package/dist/commands/list.js +77 -0
  10. package/dist/commands/login.js +109 -0
  11. package/dist/commands/logout.js +44 -0
  12. package/dist/commands/mcp-server.js +26 -0
  13. package/dist/commands/model.js +181 -0
  14. package/dist/commands/pull.js +286 -0
  15. package/dist/commands/push.js +235 -0
  16. package/dist/commands/run.js +336 -0
  17. package/dist/commands/status.js +178 -0
  18. package/dist/commands/variables.js +200 -0
  19. package/dist/commands/whoami.js +47 -0
  20. package/dist/index.js +163 -0
  21. package/dist/mcp/index.js +19 -0
  22. package/dist/mcp/prompts/workflows.js +403 -0
  23. package/dist/mcp/resources/documentation.js +158 -0
  24. package/dist/mcp/server.js +36 -0
  25. package/dist/mcp/tools/appTools.js +348 -0
  26. package/dist/mcp/tools/authTools.js +152 -0
  27. package/dist/mcp/tools/dataTools.js +358 -0
  28. package/dist/mcp/tools/modelTools.js +293 -0
  29. package/dist/mcp/tools/runTools.js +239 -0
  30. package/dist/mcp/tools/syncTools.js +383 -0
  31. package/dist/mcp/utils/helpers.js +142 -0
  32. package/dist/services/appSyncService.js +458 -0
  33. package/dist/services/configService.js +186 -0
  34. package/dist/services/farseerApi.js +426 -0
  35. package/dist/services/farseerFactory.js +297 -0
  36. package/dist/services/farseerService.js +647 -0
  37. package/dist/services/syncService.js +764 -0
  38. package/dist/utils/constants.js +21 -0
  39. package/dist/utils/helpers.js +446 -0
  40. package/dist/utils/logger.js +45 -0
  41. package/package.json +8 -1
@@ -0,0 +1,336 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.registerRunCommand = registerRunCommand;
37
+ const logger_1 = require("../utils/logger");
38
+ const configService_1 = require("../services/configService");
39
+ const farseerService_1 = require("../services/farseerService");
40
+ const farseerFactory_1 = require("../services/farseerFactory");
41
+ const helpers_1 = require("../utils/helpers");
42
+ const fs = __importStar(require("fs"));
43
+ const path = __importStar(require("path"));
44
+ const child_process_1 = require("child_process");
45
+ /**
46
+ * Find a script file recursively in a directory.
47
+ * Returns the relative path from baseDir if found, null otherwise.
48
+ */
49
+ function findScriptRecursively(baseDir, scriptName) {
50
+ if (!fs.existsSync(baseDir)) {
51
+ return null;
52
+ }
53
+ const search = (dir, relativePath = '') => {
54
+ const items = fs.readdirSync(dir, { withFileTypes: true });
55
+ for (const item of items) {
56
+ const itemRelPath = relativePath ? `${relativePath}/${item.name}` : item.name;
57
+ if (item.isFile() && item.name === scriptName) {
58
+ return itemRelPath;
59
+ }
60
+ if (item.isDirectory()) {
61
+ const found = search(path.join(dir, item.name), itemRelPath);
62
+ if (found)
63
+ return found;
64
+ }
65
+ }
66
+ return null;
67
+ };
68
+ return search(baseDir);
69
+ }
70
+ async function getRunCredentials(tenant, tenantId) {
71
+ // First try API key config
72
+ const credential = (0, configService_1.getCredential)(tenant);
73
+ if (credential) {
74
+ return {
75
+ tenantId: credential.tenantId,
76
+ apiKey: credential.apiKey,
77
+ basePath: credential.basePath,
78
+ };
79
+ }
80
+ // Try user auth (browser login)
81
+ const auth = (0, configService_1.getUserAuth)();
82
+ if (!auth) {
83
+ return null;
84
+ }
85
+ // Check if token needs refresh
86
+ if (!(0, configService_1.isUserAuthValid)()) {
87
+ logger_1.logger.dim('Token expired, refreshing...');
88
+ const refreshed = await (0, farseerService_1.refreshAccessToken)(auth.refreshToken, auth.realm || 'master');
89
+ if (!refreshed) {
90
+ logger_1.logger.warning('Could not refresh token. Please login again with: farseer login');
91
+ return null;
92
+ }
93
+ // Save refreshed token
94
+ (0, configService_1.setUserAuth)({
95
+ accessToken: refreshed.accessToken,
96
+ refreshToken: refreshed.refreshToken,
97
+ expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),
98
+ realm: auth.realm,
99
+ });
100
+ logger_1.logger.success('Token refreshed');
101
+ }
102
+ const updatedAuth = (0, configService_1.getUserAuth)();
103
+ if (!updatedAuth)
104
+ return null;
105
+ // Use tenant name as organisation for basePath, tenantId for TENANT_ID env var
106
+ return {
107
+ tenantId: tenantId || tenant,
108
+ accessToken: updatedAuth.accessToken,
109
+ basePath: (0, configService_1.generateBasePath)(tenant),
110
+ };
111
+ }
112
+ // Helper to collect multiple --arg options
113
+ function collectArgs(value, previous) {
114
+ return previous.concat([value]);
115
+ }
116
+ function registerRunCommand(program) {
117
+ program
118
+ .command('run <args...>')
119
+ .description('Run an app locally with injected credentials')
120
+ .option('--tenant-id <id>', 'Tenant ID for env variables (defaults to tenant name)')
121
+ .option('--arg <value>', 'Pass argument in format "Name=Value" (can be used multiple times)', collectArgs, [])
122
+ .action(async (args, options) => {
123
+ const { tenant, appName } = (0, helpers_1.parseAppArgs)(args);
124
+ // First, get the app details to find the entrypoint script
125
+ const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(tenant, options.tenantId);
126
+ if (!clientResult) {
127
+ (0, farseerFactory_1.showLoginPrompt)(tenant);
128
+ process.exit(1);
129
+ }
130
+ const api = clientResult.client;
131
+ // Find the app
132
+ logger_1.logger.info(`Loading app: ${appName}...`);
133
+ const app = await api.getAppByName(appName);
134
+ if (!app) {
135
+ logger_1.logger.error(`App not found: ${appName}`);
136
+ logger_1.logger.dim('List available apps with: farseer apps ' + tenant);
137
+ process.exit(1);
138
+ }
139
+ const runScripts = app.scriptFiles ?? [];
140
+ if (!app.mainScriptFileId || runScripts.length === 0) {
141
+ logger_1.logger.error(`App "${appName}" has no scripts configured.`);
142
+ logger_1.logger.dim('Configure the app with: farseer app configure "' + appName + '" --entrypoint <script>');
143
+ process.exit(1);
144
+ }
145
+ // Find the entrypoint script name
146
+ const mainScript = runScripts.find((s) => s.id === app.mainScriptFileId);
147
+ if (!mainScript) {
148
+ logger_1.logger.error(`Entrypoint script not found for app "${appName}".`);
149
+ process.exit(1);
150
+ }
151
+ // Normalize script name - handle both "test.ts" and "Scripts/test.ts" formats
152
+ let scriptName = mainScript.name;
153
+ if (scriptName.toLowerCase().startsWith('scripts/')) {
154
+ scriptName = scriptName.substring('scripts/'.length);
155
+ }
156
+ // Get credentials for running
157
+ const credentials = await getRunCredentials(tenant, options.tenantId);
158
+ if (!credentials) {
159
+ (0, farseerFactory_1.showLoginPrompt)(tenant);
160
+ process.exit(1);
161
+ }
162
+ const tenantDir = (0, helpers_1.getTenantDir)(tenant);
163
+ const srcDir = (0, helpers_1.getTenantSrcDir)(tenant);
164
+ const filesDir = (0, helpers_1.getTenantFilesDir)(tenant);
165
+ // Script path is relative to files/Scripts/ folder
166
+ // First try direct path, then search recursively if not found
167
+ let scriptPath = path.resolve(srcDir, scriptName);
168
+ let relativeScriptPath = `files/Scripts/${scriptName}`;
169
+ if (!fs.existsSync(scriptPath)) {
170
+ // Try to find the script recursively in the files directory
171
+ const foundPath = findScriptRecursively(filesDir, path.basename(scriptName));
172
+ if (foundPath) {
173
+ scriptPath = path.resolve(filesDir, foundPath);
174
+ relativeScriptPath = `files/${foundPath}`;
175
+ logger_1.logger.dim(`Found script at: ${foundPath}`);
176
+ }
177
+ }
178
+ if (!fs.existsSync(scriptPath)) {
179
+ logger_1.logger.error(`Script not found locally: ${scriptPath}`);
180
+ logger_1.logger.dim('Run "farseer pull ' + tenant + '" to download scripts first.');
181
+ process.exit(1);
182
+ }
183
+ // Check if node_modules exists
184
+ const nodeModulesPath = path.join(tenantDir, 'node_modules');
185
+ if (!fs.existsSync(nodeModulesPath)) {
186
+ logger_1.logger.error(`Dependencies not installed for ${tenant}`);
187
+ logger_1.logger.dim(`Run: farseer install ${tenant}`);
188
+ process.exit(1);
189
+ }
190
+ // Parse arguments
191
+ const appArgs = {};
192
+ // Start with default values from app config
193
+ for (const arg of app.expectedArguments) {
194
+ appArgs[arg.name] = arg.defaultValue;
195
+ }
196
+ // Override with provided arguments
197
+ for (const argStr of options.arg) {
198
+ const eqIndex = argStr.indexOf('=');
199
+ if (eqIndex === -1) {
200
+ logger_1.logger.error(`Invalid argument format: ${argStr}`);
201
+ logger_1.logger.dim('Use format: --arg "Name=Value"');
202
+ process.exit(1);
203
+ }
204
+ const name = argStr.substring(0, eqIndex);
205
+ const value = argStr.substring(eqIndex + 1);
206
+ appArgs[name] = value;
207
+ }
208
+ const authType = credentials.apiKey ? 'API key' : 'access token';
209
+ logger_1.logger.info(`Running app "${app.name}" (${scriptName}) for tenant ${tenant} (using ${authType})...`);
210
+ // Show arguments being used
211
+ if (Object.keys(appArgs).length > 0) {
212
+ logger_1.logger.dim('Arguments:');
213
+ for (const [key, value] of Object.entries(appArgs)) {
214
+ logger_1.logger.dim(` ${key}: ${value}`);
215
+ }
216
+ }
217
+ console.log();
218
+ // Build environment variables based on auth type
219
+ const envVars = {
220
+ ...process.env,
221
+ TENANT_ID: credentials.tenantId,
222
+ FARSEER_URL: credentials.basePath,
223
+ };
224
+ if (credentials.apiKey) {
225
+ envVars.FARSEER_API_KEY = credentials.apiKey;
226
+ }
227
+ if (credentials.accessToken) {
228
+ envVars.FARSEER_ACCESS_TOKEN = credentials.accessToken;
229
+ }
230
+ // Build command line arguments from app arguments (in order)
231
+ const cmdArgs = [];
232
+ for (const arg of app.expectedArguments) {
233
+ cmdArgs.push(appArgs[arg.name] ?? arg.defaultValue);
234
+ }
235
+ // Run with credentials injected via environment variables, arguments via command line
236
+ // Quote the script path to handle spaces in folder names
237
+ const quotedScriptPath = `"${relativeScriptPath}"`;
238
+ const child = (0, child_process_1.spawn)('npx', ['tsx', quotedScriptPath, ...cmdArgs], {
239
+ stdio: 'inherit',
240
+ cwd: tenantDir,
241
+ shell: true,
242
+ env: envVars,
243
+ });
244
+ child.on('close', (code) => {
245
+ if (code !== 0) {
246
+ logger_1.logger.error(`Script exited with code ${code}`);
247
+ process.exit(code || 1);
248
+ }
249
+ });
250
+ child.on('error', (err) => {
251
+ logger_1.logger.error(`Failed to run script: ${err.message}`);
252
+ logger_1.logger.dim('Make sure tsx is installed: npm install -g tsx');
253
+ process.exit(1);
254
+ });
255
+ });
256
+ // Keep the old script-based run as a separate command
257
+ program
258
+ .command('run-script <args...>')
259
+ .description('Run a script directly (without app wrapper)')
260
+ .option('--tenant-id <id>', 'Tenant ID for env variables (defaults to tenant name)')
261
+ .action(async (args, options) => {
262
+ const { tenant, appName } = (0, helpers_1.parseAppArgs)(args);
263
+ let script = appName;
264
+ const credentials = await getRunCredentials(tenant, options.tenantId);
265
+ if (!credentials) {
266
+ (0, farseerFactory_1.showLoginPrompt)(tenant);
267
+ process.exit(1);
268
+ }
269
+ // Normalize script path - strip Scripts/ prefix if present
270
+ if (script.toLowerCase().startsWith('scripts/')) {
271
+ script = script.substring('scripts/'.length);
272
+ }
273
+ const tenantDir = (0, helpers_1.getTenantDir)(tenant);
274
+ const srcDir = (0, helpers_1.getTenantSrcDir)(tenant);
275
+ const filesDir = (0, helpers_1.getTenantFilesDir)(tenant);
276
+ // Script path is relative to files/Scripts/ folder
277
+ // First try direct path, then search recursively if not found
278
+ let scriptPath = path.resolve(srcDir, script);
279
+ let relativeScriptPath = `files/Scripts/${script}`;
280
+ if (!fs.existsSync(scriptPath)) {
281
+ // Try to find the script recursively in the files directory
282
+ const foundPath = findScriptRecursively(filesDir, path.basename(script));
283
+ if (foundPath) {
284
+ scriptPath = path.resolve(filesDir, foundPath);
285
+ relativeScriptPath = `files/${foundPath}`;
286
+ logger_1.logger.dim(`Found script at: ${foundPath}`);
287
+ }
288
+ }
289
+ if (!fs.existsSync(scriptPath)) {
290
+ logger_1.logger.error(`Script not found: ${scriptPath}`);
291
+ process.exit(1);
292
+ }
293
+ // Check if node_modules exists
294
+ const nodeModulesPath = path.join(tenantDir, 'node_modules');
295
+ if (!fs.existsSync(nodeModulesPath)) {
296
+ logger_1.logger.error(`Dependencies not installed for ${tenant}`);
297
+ logger_1.logger.dim(`Run: farseer install ${tenant}`);
298
+ process.exit(1);
299
+ }
300
+ const authType = credentials.apiKey ? 'API key' : 'access token';
301
+ logger_1.logger.info(`Running ${script} for tenant ${tenant} (using ${authType})...`);
302
+ console.log();
303
+ // Build environment variables based on auth type
304
+ const envVars = {
305
+ ...process.env,
306
+ TENANT_ID: credentials.tenantId,
307
+ FARSEER_URL: credentials.basePath,
308
+ };
309
+ if (credentials.apiKey) {
310
+ envVars.FARSEER_API_KEY = credentials.apiKey;
311
+ }
312
+ if (credentials.accessToken) {
313
+ envVars.FARSEER_ACCESS_TOKEN = credentials.accessToken;
314
+ }
315
+ // Run with credentials injected via environment variables
316
+ // Quote the script path to handle spaces in folder names
317
+ const quotedScriptPath = `"${relativeScriptPath}"`;
318
+ const child = (0, child_process_1.spawn)('npx', ['tsx', quotedScriptPath], {
319
+ stdio: 'inherit',
320
+ cwd: tenantDir,
321
+ shell: true,
322
+ env: envVars,
323
+ });
324
+ child.on('close', (code) => {
325
+ if (code !== 0) {
326
+ logger_1.logger.error(`Script exited with code ${code}`);
327
+ process.exit(code || 1);
328
+ }
329
+ });
330
+ child.on('error', (err) => {
331
+ logger_1.logger.error(`Failed to run script: ${err.message}`);
332
+ logger_1.logger.dim('Make sure tsx is installed: npm install -g tsx');
333
+ process.exit(1);
334
+ });
335
+ });
336
+ }
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.registerStatusCommand = registerStatusCommand;
40
+ const chalk_1 = __importDefault(require("chalk"));
41
+ const logger_1 = require("../utils/logger");
42
+ const farseerFactory_1 = require("../services/farseerFactory");
43
+ const syncService_1 = require("../services/syncService");
44
+ const appSyncService_1 = require("../services/appSyncService");
45
+ const helpers_1 = require("../utils/helpers");
46
+ const fs = __importStar(require("fs"));
47
+ function registerStatusCommand(program) {
48
+ program
49
+ .command('status [org] [tenant]')
50
+ .description('Show sync status between local and remote\n\nUsage: status <org> <tenant> OR status <tenant> (if org is known)')
51
+ .option('--all', 'Show status for all files (default: only scripts .ts, .js)')
52
+ .action(async (arg1, arg2, options) => {
53
+ const { organisation, tenant } = (0, helpers_1.resolveTenantWithOrgMapping)(arg1, arg2);
54
+ const clientResult = await (0, farseerFactory_1.getFarseerClientWithFallback)(organisation, tenant);
55
+ if (!clientResult) {
56
+ (0, farseerFactory_1.showLoginPrompt)(tenant);
57
+ process.exit(1);
58
+ }
59
+ const filesDir = (0, helpers_1.getTenantFilesDir)(tenant);
60
+ if (!fs.existsSync(filesDir)) {
61
+ logger_1.logger.warning(`Local folder not found: apps/${tenant}/files/`);
62
+ logger_1.logger.dim('Run "farseer pull <tenant>" to download files from the instance.');
63
+ return;
64
+ }
65
+ logger_1.logger.info(`Comparing local (apps/${tenant}/files/) with remote (Files/)...`);
66
+ console.log();
67
+ const syncService = new syncService_1.SyncService(tenant, clientResult.client);
68
+ try {
69
+ const status = await syncService.getStatus({ all: options.all });
70
+ const hasChanges = status.modifiedLocally.length > 0 ||
71
+ status.modifiedRemotely.length > 0 ||
72
+ status.onlyLocal.length > 0 ||
73
+ status.onlyRemote.length > 0 ||
74
+ (status.conflicts && status.conflicts.length > 0);
75
+ if (!hasChanges) {
76
+ logger_1.logger.success('Everything is in sync!');
77
+ logger_1.logger.dim(`${status.inSync.length} file(s) synchronized.`);
78
+ return;
79
+ }
80
+ // Modified locally
81
+ if (status.modifiedLocally.length > 0) {
82
+ console.log(chalk_1.default.yellow('Modified locally:'));
83
+ for (const file of status.modifiedLocally) {
84
+ console.log(chalk_1.default.yellow(` M ${file}`));
85
+ }
86
+ console.log();
87
+ }
88
+ // Modified remotely
89
+ if (status.modifiedRemotely.length > 0) {
90
+ console.log(chalk_1.default.cyan('Modified on remote:'));
91
+ const syncState = syncService.loadSyncState();
92
+ for (const file of status.modifiedRemotely) {
93
+ const metadata = syncState.files[file]?.metadata;
94
+ const uploaderInfo = metadata?.uploaderName
95
+ ? ` (by ${metadata.uploaderName})`
96
+ : metadata?.uploaderEmail
97
+ ? ` (by ${metadata.uploaderEmail})`
98
+ : '';
99
+ console.log(chalk_1.default.cyan(` M ${file}`) + chalk_1.default.dim(uploaderInfo));
100
+ }
101
+ console.log();
102
+ }
103
+ // Only local (new files)
104
+ if (status.onlyLocal.length > 0) {
105
+ console.log(chalk_1.default.green('Only local (new):'));
106
+ for (const file of status.onlyLocal) {
107
+ console.log(chalk_1.default.green(` + ${file}`));
108
+ }
109
+ console.log();
110
+ }
111
+ // Only remote (not downloaded)
112
+ if (status.onlyRemote.length > 0) {
113
+ console.log(chalk_1.default.red('Only on remote:'));
114
+ for (const file of status.onlyRemote) {
115
+ console.log(chalk_1.default.red(` - ${file}`));
116
+ }
117
+ console.log();
118
+ }
119
+ // Conflicts
120
+ if (status.conflicts && status.conflicts.length > 0) {
121
+ console.log(chalk_1.default.red.bold('CONFLICTS:'));
122
+ for (const conflict of status.conflicts) {
123
+ console.log(chalk_1.default.red(` ! ${conflict.filePath}`));
124
+ console.log(chalk_1.default.dim(` ${conflict.description}`));
125
+ }
126
+ console.log();
127
+ logger_1.logger.dim(`Resolve conflicts during pull: farseer pull ${tenant}`);
128
+ console.log();
129
+ }
130
+ // Apps status (works with both JWT and API key)
131
+ const appSyncService = new appSyncService_1.AppSyncService(tenant, clientResult.client);
132
+ const appStatus = await appSyncService.getStatus();
133
+ const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.newRemote.length > 0 || appStatus.modified.length > 0;
134
+ if (hasAppChanges) {
135
+ console.log(chalk_1.default.bold('Apps:'));
136
+ console.log();
137
+ if (appStatus.newLocal.length > 0) {
138
+ console.log(chalk_1.default.green('New local apps (to be created on remote):'));
139
+ for (const app of appStatus.newLocal) {
140
+ console.log(chalk_1.default.green(` + ${app}`));
141
+ }
142
+ console.log();
143
+ }
144
+ if (appStatus.newRemote.length > 0) {
145
+ console.log(chalk_1.default.cyan('New remote apps (to be downloaded):'));
146
+ for (const app of appStatus.newRemote) {
147
+ console.log(chalk_1.default.cyan(` + ${app}`));
148
+ }
149
+ console.log();
150
+ }
151
+ if (appStatus.modified.length > 0) {
152
+ console.log(chalk_1.default.yellow('Modified apps:'));
153
+ for (const app of appStatus.modified) {
154
+ console.log(chalk_1.default.yellow(` ~ ${app}`));
155
+ }
156
+ console.log();
157
+ }
158
+ if (appStatus.synced.length > 0) {
159
+ logger_1.logger.dim(`${appStatus.synced.length} app(s) in sync.`);
160
+ }
161
+ }
162
+ else if (appStatus.synced.length > 0) {
163
+ logger_1.logger.dim(`${appStatus.synced.length} app(s) in sync.`);
164
+ }
165
+ // Summary
166
+ console.log();
167
+ logger_1.logger.dim('Use "farseer push <tenant>" to upload local changes.');
168
+ logger_1.logger.dim('Use "farseer pull <tenant>" to download remote changes.');
169
+ }
170
+ catch (error) {
171
+ logger_1.logger.error('Failed to check status.');
172
+ if (error instanceof Error) {
173
+ logger_1.logger.dim(error.message);
174
+ }
175
+ process.exit(1);
176
+ }
177
+ });
178
+ }