farseer-cli 1.0.10 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/commands/app.js +348 -344
- package/dist/commands/app.js.map +7 -0
- package/dist/commands/apps.js +110 -82
- package/dist/commands/apps.js.map +7 -0
- package/dist/commands/cells.js +161 -0
- package/dist/commands/cells.js.map +7 -0
- package/dist/commands/checkout.js +140 -155
- package/dist/commands/checkout.js.map +7 -0
- package/dist/commands/config.js +128 -126
- package/dist/commands/config.js.map +7 -0
- package/dist/commands/dashboards.js +130 -0
- package/dist/commands/dashboards.js.map +7 -0
- package/dist/commands/diff.js +171 -193
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/dimensions.js +222 -119
- package/dist/commands/dimensions.js.map +7 -0
- package/dist/commands/files.js +96 -77
- package/dist/commands/files.js.map +7 -0
- package/dist/commands/formula.js +116 -0
- package/dist/commands/formula.js.map +7 -0
- package/dist/commands/install.js +74 -76
- package/dist/commands/install.js.map +7 -0
- package/dist/commands/list.js +91 -73
- package/dist/commands/list.js.map +7 -0
- package/dist/commands/login.js +137 -98
- package/dist/commands/login.js.map +7 -0
- package/dist/commands/logout.js +59 -41
- package/dist/commands/logout.js.map +7 -0
- package/dist/commands/mcp-server.js +36 -23
- package/dist/commands/mcp-server.js.map +7 -0
- package/dist/commands/model.js +186 -175
- package/dist/commands/model.js.map +7 -0
- package/dist/commands/pull.js +264 -274
- package/dist/commands/pull.js.map +7 -0
- package/dist/commands/push.js +209 -221
- package/dist/commands/push.js.map +7 -0
- package/dist/commands/run.js +276 -321
- package/dist/commands/run.js.map +7 -0
- package/dist/commands/sheets.js +200 -0
- package/dist/commands/sheets.js.map +7 -0
- package/dist/commands/status.js +149 -169
- package/dist/commands/status.js.map +7 -0
- package/dist/commands/variables.js +247 -188
- package/dist/commands/variables.js.map +7 -0
- package/dist/commands/whoami.js +65 -44
- package/dist/commands/whoami.js.map +7 -0
- package/dist/index.js +179 -115
- package/dist/index.js.map +7 -0
- package/dist/mcp/index.js +33 -16
- package/dist/mcp/index.js.map +7 -0
- package/dist/mcp/prompts/workflows.js +191 -145
- package/dist/mcp/prompts/workflows.js.map +7 -0
- package/dist/mcp/resources/documentation.js +158 -148
- package/dist/mcp/resources/documentation.js.map +7 -0
- package/dist/mcp/server.js +56 -33
- package/dist/mcp/server.js.map +7 -0
- package/dist/mcp/tools/appTools.js +309 -277
- package/dist/mcp/tools/appTools.js.map +7 -0
- package/dist/mcp/tools/authTools.js +130 -121
- package/dist/mcp/tools/authTools.js.map +7 -0
- package/dist/mcp/tools/cellTools.js +148 -0
- package/dist/mcp/tools/cellTools.js.map +7 -0
- package/dist/mcp/tools/dashboardTools.js +133 -0
- package/dist/mcp/tools/dashboardTools.js.map +7 -0
- package/dist/mcp/tools/dataTools.js +270 -267
- package/dist/mcp/tools/dataTools.js.map +7 -0
- package/dist/mcp/tools/modelTools.js +575 -229
- package/dist/mcp/tools/modelTools.js.map +7 -0
- package/dist/mcp/tools/runTools.js +201 -203
- package/dist/mcp/tools/runTools.js.map +7 -0
- package/dist/mcp/tools/sheetTools.js +240 -0
- package/dist/mcp/tools/sheetTools.js.map +7 -0
- package/dist/mcp/tools/syncTools.js +335 -314
- package/dist/mcp/tools/syncTools.js.map +7 -0
- package/dist/mcp/utils/helpers.js +117 -123
- package/dist/mcp/utils/helpers.js.map +7 -0
- package/dist/services/appSyncService.js +381 -437
- package/dist/services/appSyncService.js.map +7 -0
- package/dist/services/configService.js +154 -143
- package/dist/services/configService.js.map +7 -0
- package/dist/services/farseerApi.js +405 -400
- package/dist/services/farseerApi.js.map +7 -0
- package/dist/services/farseerFactory.js +208 -273
- package/dist/services/farseerFactory.js.map +7 -0
- package/dist/services/farseerService.js +453 -487
- package/dist/services/farseerService.js.map +7 -0
- package/dist/services/syncService.js +661 -731
- package/dist/services/syncService.js.map +7 -0
- package/dist/utils/constants.js +52 -19
- package/dist/utils/constants.js.map +7 -0
- package/dist/utils/entityResolver.js +78 -0
- package/dist/utils/entityResolver.js.map +7 -0
- package/dist/utils/helpers.js +331 -365
- package/dist/utils/helpers.js.map +7 -0
- package/dist/utils/logger.js +74 -42
- package/dist/utils/logger.js.map +7 -0
- package/package.json +3 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/config.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport {\n setCredential,\n removeCredential,\n listCredentials,\n generateBasePath,\n ApiKeyCredential,\n} from '../services/configService';\nimport { FarseerService } from '../services/farseerService';\nimport { getCredentialsHint } from '../utils/helpers';\n\nexport function registerConfigCommand(program: Command): void {\n const configCmd = program\n .command('config')\n .description('Manage Farseer CLI configuration')\n .addHelpText(\n 'after',\n `\nCommands:\n set <tenant> Set API key for a tenant\n remove <tenant> Remove credentials for a tenant\n list List all configured tenants\n show <tenant> Show full credentials (including API key)\n test <tenant> Test connection to a tenant\n\nExamples:\n $ farseer config set mycompany --api-key xxx\n $ farseer config set mycompany --api-key xxx --org myorg\n $ farseer config list\n $ farseer config test mycompany\n`,\n );\n\n configCmd\n .command('set <tenant>')\n .description('Set credentials for a tenant (use --org if org differs from tenant)')\n .requiredOption('--api-key <key>', 'API key for the tenant')\n .option('--org <organisation>', 'Organisation name if different from tenant (e.g., --org mycompany)')\n .option('--base-path <url>', 'Custom base path (overrides organisation)')\n .option('--no-test', 'Skip connection test')\n .action(async (tenant, options) => {\n const organisation = options.org || tenant;\n const basePath = options.basePath || generateBasePath(organisation);\n const apiKey = options.apiKey;\n\n const credential: ApiKeyCredential = {\n type: 'apiKey',\n tenantId: tenant,\n apiKey: apiKey,\n basePath: basePath,\n };\n\n if (options.test !== false) {\n logger.info('Testing connection...');\n const service = new FarseerService(credential);\n const isConnected = await service.testConnection();\n\n if (!isConnected) {\n logger.error('Connection failed. Please check your credentials.');\n logger.dim(`Tried to connect to: ${basePath}`);\n process.exit(1);\n }\n }\n\n setCredential(tenant, credential);\n logger.success(`Credentials saved for tenant: ${tenant}`);\n logger.table([\n { label: 'Tenant ID', value: tenant },\n { label: 'Base Path', value: basePath },\n { label: 'API Key', value: apiKey.substring(0, 8) + '...' },\n ]);\n });\n\n configCmd\n .command('remove <tenant>')\n .description('Remove credentials for a tenant')\n .action((tenant) => {\n const removed = removeCredential(tenant);\n if (removed) {\n logger.success(`Removed credentials for tenant: ${tenant}`);\n } else {\n logger.warning(`No credentials found for tenant: ${tenant}`);\n }\n });\n\n configCmd\n .command('list')\n .description('List all configured tenants')\n .action(() => {\n const credentials = listCredentials();\n const tenants = Object.keys(credentials);\n\n if (tenants.length === 0) {\n logger.info('No tenants configured.');\n logger.dim('Use \"farseer config set <tenant> --api-key <key>\" to add one.');\n return;\n }\n\n logger.header('Configured Tenants');\n\n for (const tenant of tenants) {\n const cred = credentials[tenant];\n console.log(` ${tenant}`);\n logger.dim(` Base: ${cred.basePath}`);\n logger.dim(` Key: ${cred.apiKey.substring(0, 8)}...`);\n console.log();\n }\n });\n\n configCmd\n .command('show <tenant>')\n .description('Show full credentials for a tenant (including API key)')\n .action((tenant) => {\n const credentials = listCredentials();\n const cred = credentials[tenant];\n\n if (!cred) {\n logger.error(`No credentials found for tenant: ${tenant}`);\n logger.dim(getCredentialsHint(tenant));\n process.exit(1);\n }\n\n logger.header(`Credentials for ${tenant}`);\n logger.table([\n { label: 'Tenant ID', value: tenant },\n { label: 'Base Path', value: cred.basePath },\n { label: 'API Key', value: cred.apiKey },\n ]);\n });\n\n configCmd\n .command('test <tenant>')\n .description('Test connection to a tenant')\n .action(async (tenant) => {\n const credentials = listCredentials();\n const cred = credentials[tenant];\n\n if (!cred) {\n logger.error(`No credentials found for tenant: ${tenant}`);\n logger.dim(getCredentialsHint(tenant));\n process.exit(1);\n }\n\n logger.info(`Testing connection to ${tenant}...`);\n\n const service = new FarseerService(cred);\n const isConnected = await service.testConnection();\n\n if (isConnected) {\n logger.success(`Connection successful!`);\n\n // Try to get files folder\n const filesFolder = await service.getFilesFolder();\n if (filesFolder) {\n logger.dim('Files folder found.');\n } else {\n logger.warning('Files folder not found. It will be created on first push.');\n }\n } else {\n logger.error('Connection failed.');\n process.exit(1);\n }\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,2BAMO;AACP,4BAA+B;AAC/B,qBAAmC;AAE5B,SAAS,sBAAsB,SAAwB;AAC1D,QAAM,YAAY,QACb,QAAQ,QAAQ,EAChB,YAAY,kCAAkC,EAC9C;AAAA,IACG;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcJ;AAEJ,YACK,QAAQ,cAAc,EACtB,YAAY,qEAAqE,EACjF,eAAe,mBAAmB,wBAAwB,EAC1D,OAAO,wBAAwB,oEAAoE,EACnG,OAAO,qBAAqB,2CAA2C,EACvE,OAAO,aAAa,sBAAsB,EAC1C,OAAO,OAAO,QAAQ,YAAY;AAC/B,UAAM,eAAe,QAAQ,OAAO;AACpC,UAAM,WAAW,QAAQ,gBAAY,uCAAiB,YAAY;AAClE,UAAM,SAAS,QAAQ;AAEvB,UAAM,aAA+B;AAAA,MACjC,MAAM;AAAA,MACN,UAAU;AAAA,MACV;AAAA,MACA;AAAA,IACJ;AAEA,QAAI,QAAQ,SAAS,OAAO;AACxB,2BAAO,KAAK,uBAAuB;AACnC,YAAM,UAAU,IAAI,qCAAe,UAAU;AAC7C,YAAM,cAAc,MAAM,QAAQ,eAAe;AAEjD,UAAI,CAAC,aAAa;AACd,6BAAO,MAAM,mDAAmD;AAChE,6BAAO,IAAI,wBAAwB,QAAQ,EAAE;AAC7C,gBAAQ,KAAK,CAAC;AAAA,MAClB;AAAA,IACJ;AAEA,4CAAc,QAAQ,UAAU;AAChC,yBAAO,QAAQ,iC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AAQ,KAAK,CAAC;AAAA,IAClB;AAEA,yBAAO,OAAO,mBAAmB,MAAM,EAAE;AACzC,yBAAO,MAAM;AAAA,MACT,EAAE,OAAO,aAAa,OAAO,OAAO;AAAA,MACpC,EAAE,OAAO,aAAa,OAAO,KAAK,SAAS;AAAA,MAC3C,EAAE,OAAO,WAAW,OAAO,KAAK,OAAO;AAAA,IAC3C,CAAC;AAAA,EACL,CAAC;AAEL,YACK,QAAQ,eAAe,EACvB,YAAY,6BAA6B,EACzC,OAAO,OAAO,WAAW;AACtB,UAAM,kBAAc,sCAAgB;AACpC,UAAM,OAAO,YAAY,MAAM;AAE/B,QAAI,CAAC,MAAM;AACP,2BAAO,MAAM,oCAAoC,MAAM,EAAE;AACzD,2BAAO,QAAI,mCAAmB,MAAM,CAAC;AACrC,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,yBAAO,KAAK,yBAAyB,MAAM,KAAK;AAEhD,UAAM,UAAU,IAAI,qCAAe,IAAI;AACvC,UAAM,cAAc,MAAM,QAAQ,eAAe;AAEjD,QAAI,aAAa;AACb,2BAAO,QAAQ,wBAAwB;AAGvC,YAAM,cAAc,MAAM,QAAQ,eAAe;AACjD,UAAI,aAAa;AACb,6BAAO,IAAI,qBAAqB;AAAA,MACpC,OAAO;AACH,6BAAO,QAAQ,2DAA2D;AAAA,MAC9E;AAAA,IACJ,OAAO;AACH,2BAAO,MAAM,oBAAoB;AACjC,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var dashboards_exports = {};
|
|
30
|
+
__export(dashboards_exports, {
|
|
31
|
+
registerDashboardsCommand: () => registerDashboardsCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(dashboards_exports);
|
|
34
|
+
var import_chalk = __toESM(require("chalk"));
|
|
35
|
+
var import_logger = require("../utils/logger");
|
|
36
|
+
var import_farseerFactory = require("../services/farseerFactory");
|
|
37
|
+
var import_helpers = require("../utils/helpers");
|
|
38
|
+
var import_entityResolver = require("../utils/entityResolver");
|
|
39
|
+
function registerDashboardsCommand(program) {
|
|
40
|
+
const dashboardsCmd = program.command("dashboards").description("List and inspect dashboards");
|
|
41
|
+
dashboardsCmd.command("list [org] [tenant]").description("List all dashboards").option("--json", "Output raw JSON").action(async (first, second, options) => {
|
|
42
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(first, second);
|
|
43
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
44
|
+
if (!nativeClient) {
|
|
45
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const dashboards = await nativeClient.dashboards.list();
|
|
50
|
+
if (options.json) {
|
|
51
|
+
const result = dashboards.map((d) => ({
|
|
52
|
+
id: d.id,
|
|
53
|
+
name: d.name,
|
|
54
|
+
tileCount: d.tiles?.length || 0
|
|
55
|
+
}));
|
|
56
|
+
console.log(JSON.stringify(result, null, 2));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
import_logger.logger.header(`Dashboards (${dashboards.length})`);
|
|
60
|
+
if (dashboards.length === 0) {
|
|
61
|
+
import_logger.logger.dim(" No dashboards found.");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
for (const d of dashboards) {
|
|
65
|
+
console.log(
|
|
66
|
+
` ${import_chalk.default.dim(String(d.id).padEnd(8))} ${import_chalk.default.bold(d.name)} ${import_chalk.default.dim(`(${d.tiles?.length || 0} tiles)`)}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
} catch (error) {
|
|
70
|
+
handleDashboardError(error, tenant);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
dashboardsCmd.command("show <nameOrId> [org] [tenant]").description("Show dashboard details").option("--json", "Output raw JSON").option("--tiles", "Show tile details").action(async (nameOrId, first, second, options) => {
|
|
74
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(first, second);
|
|
75
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
76
|
+
if (!nativeClient) {
|
|
77
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const resolved = await (0, import_entityResolver.resolveDashboardId)(nativeClient, nameOrId);
|
|
82
|
+
if (!resolved) {
|
|
83
|
+
import_logger.logger.error(`Dashboard "${nameOrId}" not found.`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
}
|
|
86
|
+
const dashboard = await nativeClient.dashboards.get(resolved.id);
|
|
87
|
+
if (options.json) {
|
|
88
|
+
console.log(JSON.stringify(dashboard, null, 2));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
import_logger.logger.header(`Dashboard: ${dashboard.name}`);
|
|
92
|
+
console.log(` ID: ${dashboard.id}`);
|
|
93
|
+
console.log(` Tiles: ${dashboard.tiles?.length || 0}`);
|
|
94
|
+
if (options.tiles && dashboard.tiles && dashboard.tiles.length > 0) {
|
|
95
|
+
console.log();
|
|
96
|
+
console.log(" Tile Details:");
|
|
97
|
+
for (const tile of dashboard.tiles) {
|
|
98
|
+
const tileAny = tile;
|
|
99
|
+
console.log(
|
|
100
|
+
` ${import_chalk.default.dim(String(tileAny.id).padEnd(8))} ${import_chalk.default.bold(tileAny.name || "Unnamed")}`
|
|
101
|
+
);
|
|
102
|
+
if (tileAny.type) {
|
|
103
|
+
console.log(` Type: ${tileAny.type}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
handleDashboardError(error, tenant);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function handleDashboardError(error, tenant) {
|
|
113
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
114
|
+
if ((0, import_farseerFactory.isAuthError)(error)) {
|
|
115
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
116
|
+
} else if (errorMessage.includes("404")) {
|
|
117
|
+
import_logger.logger.error("Dashboard not found or tenant not accessible.");
|
|
118
|
+
} else if (errorMessage.includes("ENOTFOUND") || errorMessage.includes("ECONNREFUSED")) {
|
|
119
|
+
import_logger.logger.error("Failed to connect to Farseer.");
|
|
120
|
+
} else {
|
|
121
|
+
import_logger.logger.error("Dashboard operation failed.");
|
|
122
|
+
import_logger.logger.dim(errorMessage);
|
|
123
|
+
}
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
+
0 && (module.exports = {
|
|
128
|
+
registerDashboardsCommand
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=dashboards.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/dashboards.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { getNativeFarseerClient, showLoginPrompt, isAuthError } from '../services/farseerFactory';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\nimport { resolveDashboardId } from '../utils/entityResolver';\n\nexport function registerDashboardsCommand(program: Command): void {\n const dashboardsCmd = program.command('dashboards').description('List and inspect dashboards');\n\n // farseer dashboards list [org] [tenant]\n dashboardsCmd\n .command('list [org] [tenant]')\n .description('List all dashboards')\n .option('--json', 'Output raw JSON')\n .action(async (first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n const dashboards = await nativeClient.dashboards.list();\n\n if (options.json) {\n const result = dashboards.map((d) => ({\n id: d.id,\n name: d.name,\n tileCount: d.tiles?.length || 0,\n }));\n console.log(JSON.stringify(result, null, 2));\n return;\n }\n\n logger.header(`Dashboards (${dashboards.length})`);\n if (dashboards.length === 0) {\n logger.dim(' No dashboards found.');\n return;\n }\n for (const d of dashboards) {\n console.log(\n ` ${chalk.dim(String(d.id).padEnd(8))} ${chalk.bold(d.name)} ${chalk.dim(`(${d.tiles?.length || 0} tiles)`)}`,\n );\n }\n } catch (error) {\n handleDashboardError(error, tenant);\n }\n });\n\n // farseer dashboards show <nameOrId> [org] [tenant]\n dashboardsCmd\n .command('show <nameOrId> [org] [tenant]')\n .description('Show dashboard details')\n .option('--json', 'Output raw JSON')\n .option('--tiles', 'Show tile details')\n .action(async (nameOrId, first, second, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(first, second);\n const nativeClient = await getNativeFarseerClient(organisation, tenant);\n\n if (!nativeClient) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n try {\n const resolved = await resolveDashboardId(nativeClient, nameOrId);\n if (!resolved) {\n logger.error(`Dashboard \"${nameOrId}\" not found.`);\n process.exit(1);\n }\n\n const dashboard = await nativeClient.dashboards.get(resolved.id);\n\n if (options.json) {\n console.log(JSON.stringify(dashboard, null, 2));\n return;\n }\n\n logger.header(`Dashboard: ${dashboard.name}`);\n console.log(` ID: ${dashboard.id}`);\n console.log(` Tiles: ${dashboard.tiles?.length || 0}`);\n\n if (options.tiles && dashboard.tiles && dashboard.tiles.length > 0) {\n console.log();\n console.log(' Tile Details:');\n for (const tile of dashboard.tiles) {\n const tileAny = tile as any;\n console.log(\n ` ${chalk.dim(String(tileAny.id).padEnd(8))} ${chalk.bold(tileAny.name || 'Unnamed')}`,\n );\n if (tileAny.type) {\n console.log(` Type: ${tileAny.type}`);\n }\n }\n }\n } catch (error) {\n handleDashboardError(error, tenant);\n }\n });\n}\n\nfunction handleDashboardError(error: unknown, tenant: string): void {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n if (isAuthError(error)) {\n showLoginPrompt(tenant);\n } else if (errorMessage.includes('404')) {\n logger.error('Dashboard not found or tenant not accessible.');\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n } else {\n logger.error('Dashboard operation fail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AAI,QAAQ,MAAM;AACd,oBAAQ,IAAI,eAAe,QAAQ,IAAI,EAAE;AAAA,UAC7C;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ,SAAS,OAAO;AACZ,2BAAqB,OAAO,MAAM;AAAA,IACtC;AAAA,EACJ,CAAC;AACT;AAEA,SAAS,qBAAqB,OAAgB,QAAsB;AAChE,QAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAE1E,UAAI,mCAAY,KAAK,GAAG;AACpB,+CAAgB,MAAM;AAAA,EAC1B,WAAW,aAAa,SAAS,KAAK,GAAG;AACrC,yBAAO,MAAM,+CAA+C;AAAA,EAChE,WAAW,aAAa,SAAS,WAAW,KAAK,aAAa,SAAS,cAAc,GAAG;AACpF,yBAAO,MAAM,+BAA+B;AAAA,EAChD,OAAO;AACH,yBAAO,MAAM,6BAA6B;AAC1C,yBAAO,IAAI,YAAY;AAAA,EAC3B;AACA,UAAQ,KAAK,CAAC;AAClB;",
|
|
6
|
+
"names": ["chalk"]
|
|
7
|
+
}
|
package/dist/commands/diff.js
CHANGED
|
@@ -1,210 +1,188 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
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 };
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
37
19
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var diff_exports = {};
|
|
30
|
+
__export(diff_exports, {
|
|
31
|
+
registerDiffCommand: () => registerDiffCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(diff_exports);
|
|
34
|
+
var import_chalk = __toESM(require("chalk"));
|
|
35
|
+
var Diff = __toESM(require("diff"));
|
|
36
|
+
var import_logger = require("../utils/logger");
|
|
37
|
+
var import_farseerFactory = require("../services/farseerFactory");
|
|
38
|
+
var import_syncService = require("../services/syncService");
|
|
39
|
+
var import_helpers = require("../utils/helpers");
|
|
40
|
+
var fs = __toESM(require("fs"));
|
|
47
41
|
function registerDiffCommand(program) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const filesDir = (0, helpers_1.getTenantFilesDir)(tenant);
|
|
84
|
-
const syncService = new syncService_1.SyncService(tenant, clientResult.client);
|
|
85
|
-
if (actualFile) {
|
|
86
|
-
// Show diff for specific file
|
|
87
|
-
await showFileDiff(syncService, actualFile, options.remote);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
// Show diff for all changed files
|
|
91
|
-
await showAllDiffs(syncService, filesDir);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
42
|
+
program.command("diff [arg1] [arg2] [file]").description(
|
|
43
|
+
"Show differences between local and remote files\n\nUsage: diff <org> <tenant> [file] OR diff <tenant> [file] (if org is known)"
|
|
44
|
+
).option("--remote", "Show remote version of file(s)").action(async (arg1, arg2, file, options) => {
|
|
45
|
+
let organisation;
|
|
46
|
+
let tenant;
|
|
47
|
+
let actualFile;
|
|
48
|
+
if (arg2 && (arg2.includes("/") || arg2.includes("."))) {
|
|
49
|
+
const resolved = (0, import_helpers.resolveTenantWithOrgMapping)(arg1, void 0);
|
|
50
|
+
organisation = resolved.organisation;
|
|
51
|
+
tenant = resolved.tenant;
|
|
52
|
+
actualFile = arg2;
|
|
53
|
+
} else if (arg2) {
|
|
54
|
+
const resolved = (0, import_helpers.resolveTenantWithOrgMapping)(arg1, arg2);
|
|
55
|
+
organisation = resolved.organisation;
|
|
56
|
+
tenant = resolved.tenant;
|
|
57
|
+
actualFile = file;
|
|
58
|
+
} else {
|
|
59
|
+
const resolved = (0, import_helpers.resolveTenantWithOrgMapping)(arg1, void 0);
|
|
60
|
+
organisation = resolved.organisation;
|
|
61
|
+
tenant = resolved.tenant;
|
|
62
|
+
actualFile = void 0;
|
|
63
|
+
}
|
|
64
|
+
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
65
|
+
if (!clientResult) {
|
|
66
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
const filesDir = (0, import_helpers.getTenantFilesDir)(tenant);
|
|
70
|
+
const syncService = new import_syncService.SyncService(tenant, clientResult.client);
|
|
71
|
+
if (actualFile) {
|
|
72
|
+
await showFileDiff(syncService, actualFile, options.remote);
|
|
73
|
+
} else {
|
|
74
|
+
await showAllDiffs(syncService, filesDir);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
94
77
|
}
|
|
95
78
|
async function showFileDiff(syncService, filePath, showRemote) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (!localContent && !remoteContent) {
|
|
110
|
-
logger_1.logger.warning('File does not exist locally or remotely.');
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (!localContent) {
|
|
114
|
-
logger_1.logger.info('File only exists on remote (not downloaded).');
|
|
115
|
-
console.log();
|
|
116
|
-
console.log(chalk_1.default.green('--- Remote content ---'));
|
|
117
|
-
console.log(remoteContent);
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (!remoteContent) {
|
|
121
|
-
logger_1.logger.info('File only exists locally (new file).');
|
|
122
|
-
console.log();
|
|
123
|
-
console.log(chalk_1.default.yellow('--- Local content ---'));
|
|
124
|
-
console.log(localContent);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (localContent === remoteContent) {
|
|
128
|
-
logger_1.logger.success('Files are identical.');
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
printDiff(filePath, remoteContent, localContent);
|
|
79
|
+
import_logger.logger.info(`Fetching diff for: ${filePath}`);
|
|
80
|
+
console.log();
|
|
81
|
+
try {
|
|
82
|
+
const { localContent, remoteContent } = await syncService.getFileDiff(filePath);
|
|
83
|
+
if (showRemote) {
|
|
84
|
+
if (remoteContent) {
|
|
85
|
+
console.log(remoteContent);
|
|
86
|
+
} else {
|
|
87
|
+
import_logger.logger.warning("File does not exist on remote.");
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
132
90
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
91
|
+
if (!localContent && !remoteContent) {
|
|
92
|
+
import_logger.logger.warning("File does not exist locally or remotely.");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!localContent) {
|
|
96
|
+
import_logger.logger.info("File only exists on remote (not downloaded).");
|
|
97
|
+
console.log();
|
|
98
|
+
console.log(import_chalk.default.green("--- Remote content ---"));
|
|
99
|
+
console.log(remoteContent);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (!remoteContent) {
|
|
103
|
+
import_logger.logger.info("File only exists locally (new file).");
|
|
104
|
+
console.log();
|
|
105
|
+
console.log(import_chalk.default.yellow("--- Local content ---"));
|
|
106
|
+
console.log(localContent);
|
|
107
|
+
return;
|
|
139
108
|
}
|
|
109
|
+
if (localContent === remoteContent) {
|
|
110
|
+
import_logger.logger.success("Files are identical.");
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
printDiff(filePath, remoteContent, localContent);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
import_logger.logger.error("Failed to get diff.");
|
|
116
|
+
if (error instanceof Error) {
|
|
117
|
+
import_logger.logger.dim(error.message);
|
|
118
|
+
}
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
140
121
|
}
|
|
141
122
|
async function showAllDiffs(syncService, filesDir) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
123
|
+
if (!fs.existsSync(filesDir)) {
|
|
124
|
+
import_logger.logger.warning('Local folder not found. Run "farseer pull" first.');
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
import_logger.logger.info("Fetching status...");
|
|
128
|
+
try {
|
|
129
|
+
const status = await syncService.getStatus();
|
|
130
|
+
const conflictFiles = (status.conflicts || []).map((c) => c.filePath);
|
|
131
|
+
const changedFiles = [
|
|
132
|
+
...status.modifiedLocally,
|
|
133
|
+
...status.modifiedRemotely.filter((f) => !status.modifiedLocally.includes(f)),
|
|
134
|
+
...conflictFiles.filter((f) => !status.modifiedLocally.includes(f) && !status.modifiedRemotely.includes(f))
|
|
135
|
+
];
|
|
136
|
+
if (changedFiles.length === 0) {
|
|
137
|
+
import_logger.logger.success("No differences found.");
|
|
138
|
+
return;
|
|
145
139
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
console.log();
|
|
161
|
-
console.log(chalk_1.default.bold(`=== ${file} ===`));
|
|
162
|
-
console.log();
|
|
163
|
-
const { localContent, remoteContent } = await syncService.getFileDiff(file);
|
|
164
|
-
if (!localContent && remoteContent) {
|
|
165
|
-
console.log(chalk_1.default.red('File only exists on remote (deleted locally or new on remote).'));
|
|
166
|
-
}
|
|
167
|
-
else if (localContent && !remoteContent) {
|
|
168
|
-
console.log(chalk_1.default.green('File only exists locally (new file or deleted on remote).'));
|
|
169
|
-
}
|
|
170
|
-
else if (localContent && remoteContent) {
|
|
171
|
-
if (localContent === remoteContent) {
|
|
172
|
-
console.log(chalk_1.default.green('Files are identical.'));
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
printDiff(file, remoteContent, localContent);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
140
|
+
for (const file of changedFiles) {
|
|
141
|
+
console.log();
|
|
142
|
+
console.log(import_chalk.default.bold(`=== ${file} ===`));
|
|
143
|
+
console.log();
|
|
144
|
+
const { localContent, remoteContent } = await syncService.getFileDiff(file);
|
|
145
|
+
if (!localContent && remoteContent) {
|
|
146
|
+
console.log(import_chalk.default.red("File only exists on remote (deleted locally or new on remote)."));
|
|
147
|
+
} else if (localContent && !remoteContent) {
|
|
148
|
+
console.log(import_chalk.default.green("File only exists locally (new file or deleted on remote)."));
|
|
149
|
+
} else if (localContent && remoteContent) {
|
|
150
|
+
if (localContent === remoteContent) {
|
|
151
|
+
console.log(import_chalk.default.green("Files are identical."));
|
|
152
|
+
} else {
|
|
153
|
+
printDiff(file, remoteContent, localContent);
|
|
178
154
|
}
|
|
179
|
-
|
|
180
|
-
logger_1.logger.dim(`${changedFiles.length} file(s) with differences.`);
|
|
155
|
+
}
|
|
181
156
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
157
|
+
console.log();
|
|
158
|
+
import_logger.logger.dim(`${changedFiles.length} file(s) with differences.`);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
import_logger.logger.error("Failed to get diffs.");
|
|
161
|
+
if (error instanceof Error) {
|
|
162
|
+
import_logger.logger.dim(error.message);
|
|
188
163
|
}
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
189
166
|
}
|
|
190
167
|
function printDiff(fileName, oldContent, newContent) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
console.log(chalk_1.default.cyan(line));
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
console.log(line);
|
|
208
|
-
}
|
|
168
|
+
const diff = Diff.createPatch(fileName, oldContent, newContent, "remote", "local");
|
|
169
|
+
const lines = diff.split("\n");
|
|
170
|
+
for (const line of lines) {
|
|
171
|
+
if (line.startsWith("+++") || line.startsWith("---")) {
|
|
172
|
+
console.log(import_chalk.default.bold(line));
|
|
173
|
+
} else if (line.startsWith("+")) {
|
|
174
|
+
console.log(import_chalk.default.green(line));
|
|
175
|
+
} else if (line.startsWith("-")) {
|
|
176
|
+
console.log(import_chalk.default.red(line));
|
|
177
|
+
} else if (line.startsWith("@@")) {
|
|
178
|
+
console.log(import_chalk.default.cyan(line));
|
|
179
|
+
} else {
|
|
180
|
+
console.log(line);
|
|
209
181
|
}
|
|
182
|
+
}
|
|
210
183
|
}
|
|
184
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
185
|
+
0 && (module.exports = {
|
|
186
|
+
registerDiffCommand
|
|
187
|
+
});
|
|
188
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/diff.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport * as Diff from 'diff';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { getTenantFilesDir, resolveTenantWithOrgMapping } from '../utils/helpers';\nimport * as fs from 'fs';\n\nexport function registerDiffCommand(program: Command): void {\n program\n .command('diff [arg1] [arg2] [file]')\n .description(\n 'Show differences between local and remote files\\n\\nUsage: diff <org> <tenant> [file] OR diff <tenant> [file] (if org is known)',\n )\n .option('--remote', 'Show remote version of file(s)')\n .action(async (arg1, arg2, file, options) => {\n // Resolve org/tenant based on number of args\n let organisation: string;\n let tenant: string;\n let actualFile: string | undefined;\n\n // If arg2 looks like a file path (has extension or slash), treat as: diff <tenant> <file>\n if (arg2 && (arg2.includes('/') || arg2.includes('.'))) {\n const resolved = resolveTenantWithOrgMapping(arg1, undefined);\n organisation = resolved.organisation;\n tenant = resolved.tenant;\n actualFile = arg2;\n } else if (arg2) {\n // Two non-file args: diff <org> <tenant> [file]\n const resolved = resolveTenantWithOrgMapping(arg1, arg2);\n organisation = resolved.organisation;\n tenant = resolved.tenant;\n actualFile = file;\n } else {\n // One arg: diff <tenant> [file] or diff [file] (if checked out)\n const resolved = resolveTenantWithOrgMapping(arg1, undefined);\n organisation = resolved.organisation;\n tenant = resolved.tenant;\n actualFile = undefined;\n }\n\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const filesDir = getTenantFilesDir(tenant);\n const syncService = new SyncService(tenant, clientResult.client);\n\n if (actualFile) {\n // Show diff for specific file\n await showFileDiff(syncService, actualFile, options.remote);\n } else {\n // Show diff for all changed files\n await showAllDiffs(syncService, filesDir);\n }\n });\n}\n\nasync function showFileDiff(syncService: SyncService, filePath: string, showRemote: boolean): Promise<void> {\n logger.info(`Fetching diff for: ${filePath}`);\n console.log();\n\n try {\n const { localContent, remoteContent } = await syncService.getFileDiff(filePath);\n\n if (showRemote) {\n if (remoteContent) {\n console.log(remoteContent);\n } else {\n logger.warning('File does not exist on remote.');\n }\n return;\n }\n\n if (!localContent && !remoteContent) {\n logger.warning('File does not exist locally or remotely.');\n return;\n }\n\n if (!localContent) {\n logger.info('File only exists on remote (not downloaded).');\n console.log();\n console.log(chalk.green('--- Remote content ---'));\n console.log(remoteContent);\n return;\n }\n\n if (!remoteContent) {\n logger.info('File only exists locally (new file).');\n console.log();\n console.log(chalk.yellow('--- Local content ---'));\n console.log(localContent);\n return;\n }\n\n if (localContent === remoteContent) {\n logger.success('Files are identical.');\n return;\n }\n\n printDiff(filePath, remoteContent, localContent);\n } catch (error) {\n logger.error('Failed to get diff.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n}\n\nasync function showAllDiffs(syncService: SyncService, filesDir: string): Promise<void> {\n if (!fs.existsSync(filesDir)) {\n logger.warning('Local folder not found. Run \"farseer pull\" first.');\n return;\n }\n\n logger.info('Fetching status...');\n\n try {\n const status = await syncService.getStatus();\n\n const conflictFiles = (status.conflicts || []).map((c) => c.filePath);\n const changedFiles = [\n ...status.modifiedLocally,\n ...status.modifiedRemotely.filter((f) => !status.modifiedLocally.includes(f)),\n ...conflictFiles.filter((f) => !status.modifiedLocally.includes(f) && !status.modifiedRemotely.includes(f)),\n ];\n\n if (changedFiles.length === 0) {\n logger.success('No differences found.');\n return;\n }\n\n for (const file of changedFiles) {\n console.log();\n console.log(chalk.bold(`=== ${file} ===`));\n console.log();\n\n const { localContent, remoteContent } = await syncService.getFileDiff(file);\n\n if (!localContent && remoteContent) {\n console.log(chalk.red('File only exists on remote (deleted locally or new on remote).'));\n } else if (localContent && !remoteContent) {\n console.log(chalk.green('File only exists locally (new file or deleted on remote).'));\n } else if (localContent && remoteContent) {\n if (localContent === remoteContent) {\n console.log(chalk.green('Files are identical.'));\n } else {\n printDiff(file, remoteContent, localContent);\n }\n }\n }\n\n console.log();\n logger.dim(`${changedFiles.length} file(s) with differences.`);\n } catch (error) {\n logger.error('Failed to get diffs.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n}\n\nfunction printDiff(fileName: string, oldContent: string, newContent: string): void {\n const diff = Diff.createPatch(fileName, oldContent, newContent, 'remote', 'local');\n\n const lines = diff.split('\\n');\n\n for (const line of lines) {\n if (line.startsWith('+++') || line.startsWith('---')) {\n console.log(chalk.bold(line));\n } else if (line.startsWith('+')) {\n console.log(chalk.green(line));\n } else if (line.startsWith('-')) {\n console.log(chalk.red(line));\n } else if (line.startsWith('@@')) {\n console.log(chalk.cyan(line));\n } else {\n console.log(line);\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,WAAsB;AACtB,oBAAuB;AACvB,4BAA8D;AAC9D,yBAA4B;AAC5B,qBAA+D;AAC/D,SAAoB;AAEb,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,2BAA2B,EACnC;AAAA,IACG;AAAA,EACJ,EACC,OAAO,YAAY,gCAAgC,EACnD,OAAO,OAAO,MAAM,MAAM,MAAM,YAAY;AAEzC,QAAI;AACJ,QAAI;AACJ,QAAI;AAGJ,QAAI,SAAS,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,GAAG,IAAI;AACpD,YAAM,eAAW,4CAA4B,MAAM,MAAS;AAC5D,qBAAe,SAAS;AACxB,eAAS,SAAS;AAClB,mBAAa;AAAA,IACjB,WAAW,MAAM;AAEb,YAAM,eAAW,4CAA4B,MAAM,IAAI;AACvD,qBAAe,SAAS;AACxB,eAAS,SAAS;A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