farseer-cli 1.0.10 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +422 -399
- 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 +467 -486
- 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,116 @@
|
|
|
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 formula_exports = {};
|
|
30
|
+
__export(formula_exports, {
|
|
31
|
+
registerFormulaCommand: () => registerFormulaCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(formula_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
|
+
function registerFormulaCommand(program) {
|
|
39
|
+
const formulaCmd = program.command("formula").description("Evaluate formulas");
|
|
40
|
+
formulaCmd.command("eval <expression> [org] [tenant]").description("Evaluate a formula expression").option(
|
|
41
|
+
"--filter <table=member>",
|
|
42
|
+
"Dimension filter (repeatable)",
|
|
43
|
+
(val, acc) => {
|
|
44
|
+
acc.push(val);
|
|
45
|
+
return acc;
|
|
46
|
+
},
|
|
47
|
+
[]
|
|
48
|
+
).option("--json", "Output raw JSON").action(async (expression, first, second, options) => {
|
|
49
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(first, second);
|
|
50
|
+
const nativeClient = await (0, import_farseerFactory.getNativeFarseerClient)(organisation, tenant);
|
|
51
|
+
if (!nativeClient) {
|
|
52
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const filters = (options.filter || []).map((f) => {
|
|
57
|
+
const eqIndex = f.indexOf("=");
|
|
58
|
+
if (eqIndex === -1) {
|
|
59
|
+
import_logger.logger.error(`Invalid filter format: "${f}". Expected "Table=Member".`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
return [f.substring(0, eqIndex), f.substring(eqIndex + 1)];
|
|
63
|
+
});
|
|
64
|
+
const evaluateRequest = {
|
|
65
|
+
filters,
|
|
66
|
+
cellQueries: [{ type: "VARIABLE", formula: expression }]
|
|
67
|
+
};
|
|
68
|
+
const results = await nativeClient.evaluator.evaluate(evaluateRequest);
|
|
69
|
+
if (options.json) {
|
|
70
|
+
console.log(JSON.stringify(results, null, 2));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
import_logger.logger.header(`Formula: ${expression}`);
|
|
74
|
+
if (filters.length > 0) {
|
|
75
|
+
console.log(` Filters: ${filters.map((f) => `${f[0]}=${f[1]}`).join(", ")}`);
|
|
76
|
+
}
|
|
77
|
+
console.log();
|
|
78
|
+
if (Array.isArray(results) && results.length > 0) {
|
|
79
|
+
for (const cell of results) {
|
|
80
|
+
const flags = [];
|
|
81
|
+
if (cell.readonly) flags.push("readonly");
|
|
82
|
+
if (cell.calculated) flags.push("calculated");
|
|
83
|
+
if (cell.frozen) flags.push("frozen");
|
|
84
|
+
const flagStr = flags.length > 0 ? import_chalk.default.dim(` [${flags.join(", ")}]`) : "";
|
|
85
|
+
console.log(` Value: ${import_chalk.default.bold(String(cell.value ?? "null"))}${flagStr}`);
|
|
86
|
+
if (cell.goal !== void 0) {
|
|
87
|
+
console.log(` Goal: ${cell.goal}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
import_logger.logger.dim(" No results.");
|
|
92
|
+
}
|
|
93
|
+
} catch (error) {
|
|
94
|
+
handleFormulaError(error, tenant);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function handleFormulaError(error, tenant) {
|
|
99
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
100
|
+
if ((0, import_farseerFactory.isAuthError)(error)) {
|
|
101
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
102
|
+
} else if (errorMessage.includes("404")) {
|
|
103
|
+
import_logger.logger.error("Formula evaluation endpoint not found.");
|
|
104
|
+
} else if (errorMessage.includes("ENOTFOUND") || errorMessage.includes("ECONNREFUSED")) {
|
|
105
|
+
import_logger.logger.error("Failed to connect to Farseer.");
|
|
106
|
+
} else {
|
|
107
|
+
import_logger.logger.error("Formula evaluation failed.");
|
|
108
|
+
import_logger.logger.dim(errorMessage);
|
|
109
|
+
}
|
|
110
|
+
process.exit(1);
|
|
111
|
+
}
|
|
112
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
+
0 && (module.exports = {
|
|
114
|
+
registerFormulaCommand
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=formula.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/formula.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';\n\nexport function registerFormulaCommand(program: Command): void {\n const formulaCmd = program.command('formula').description('Evaluate formulas');\n\n // farseer formula eval <expression> [org] [tenant]\n formulaCmd\n .command('eval <expression> [org] [tenant]')\n .description('Evaluate a formula expression')\n .option(\n '--filter <table=member>',\n 'Dimension filter (repeatable)',\n (val: string, acc: string[]) => {\n acc.push(val);\n return acc;\n },\n [] as string[],\n )\n .option('--json', 'Output raw JSON')\n .action(async (expression, 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 filters: Array<Array<string>> = (options.filter || []).map((f: string) => {\n const eqIndex = f.indexOf('=');\n if (eqIndex === -1) {\n logger.error(`Invalid filter format: \"${f}\". Expected \"Table=Member\".`);\n process.exit(1);\n }\n return [f.substring(0, eqIndex), f.substring(eqIndex + 1)];\n });\n\n const evaluateRequest = {\n filters,\n cellQueries: [{ type: 'VARIABLE' as const, formula: expression }],\n };\n\n const results = await nativeClient.evaluator.evaluate(evaluateRequest);\n\n if (options.json) {\n console.log(JSON.stringify(results, null, 2));\n return;\n }\n\n logger.header(`Formula: ${expression}`);\n if (filters.length > 0) {\n console.log(` Filters: ${filters.map((f) => `${f[0]}=${f[1]}`).join(', ')}`);\n }\n console.log();\n\n if (Array.isArray(results) && results.length > 0) {\n for (const cell of results) {\n const flags = [];\n if (cell.readonly) flags.push('readonly');\n if (cell.calculated) flags.push('calculated');\n if (cell.frozen) flags.push('frozen');\n const flagStr = flags.length > 0 ? chalk.dim(` [${flags.join(', ')}]`) : '';\n\n console.log(` Value: ${chalk.bold(String(cell.value ?? 'null'))}${flagStr}`);\n if (cell.goal !== undefined) {\n console.log(` Goal: ${cell.goal}`);\n }\n }\n } else {\n logger.dim(' No results.');\n }\n } catch (error) {\n handleFormulaError(error, tenant);\n }\n });\n}\n\nfunction handleFormulaError(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('Formula evaluation endpoint not found.');\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n } else {\n logger.error('Formula evaluation failed.');\n logger.dim(errorMessage);\n }\n process.exit(1);\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["chalk"]
|
|
7
|
+
}
|
package/dist/commands/install.js
CHANGED
|
@@ -1,82 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 install_exports = {};
|
|
30
|
+
__export(install_exports, {
|
|
31
|
+
registerInstallCommand: () => registerInstallCommand
|
|
17
32
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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.registerInstallCommand = registerInstallCommand;
|
|
37
|
-
const logger_1 = require("../utils/logger");
|
|
38
|
-
const helpers_1 = require("../utils/helpers");
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const child_process_1 = require("child_process");
|
|
33
|
+
module.exports = __toCommonJS(install_exports);
|
|
34
|
+
var import_logger = require("../utils/logger");
|
|
35
|
+
var import_helpers = require("../utils/helpers");
|
|
36
|
+
var fs = __toESM(require("fs"));
|
|
37
|
+
var import_child_process = require("child_process");
|
|
41
38
|
function registerInstallCommand(program) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
39
|
+
program.command("install [tenant]").description("Install npm dependencies for a tenant (runs npm install)").action(async (tenantArg) => {
|
|
40
|
+
const tenant = (0, import_helpers.resolveTenantOrExit)(tenantArg);
|
|
41
|
+
const tenantDir = (0, import_helpers.getTenantDir)(tenant);
|
|
42
|
+
if (!fs.existsSync(tenantDir)) {
|
|
43
|
+
import_logger.logger.error(`Tenant folder not found: farseer-apps/${tenant}/`);
|
|
44
|
+
import_logger.logger.dim('Run "farseer pull <tenant>" first to initialize the folder.');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const packageJsonPath = `${tenantDir}/package.json`;
|
|
48
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
49
|
+
import_logger.logger.error(`No package.json found in farseer-apps/${tenant}/`);
|
|
50
|
+
import_logger.logger.dim('Create a package.json first or run "npm init" in that folder.');
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
import_logger.logger.info(`Installing dependencies for ${tenant}...`);
|
|
54
|
+
import_logger.logger.dim(`Running: npm install in farseer-apps/${tenant}/`);
|
|
55
|
+
console.log();
|
|
56
|
+
const child = (0, import_child_process.spawn)("npm", ["install"], {
|
|
57
|
+
stdio: "inherit",
|
|
58
|
+
cwd: tenantDir,
|
|
59
|
+
shell: true
|
|
60
|
+
});
|
|
61
|
+
child.on("close", (code) => {
|
|
62
|
+
if (code === 0) {
|
|
61
63
|
console.log();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
logger_1.logger.error(`npm install exited with code ${code}`);
|
|
74
|
-
process.exit(code || 1);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
child.on('error', (err) => {
|
|
78
|
-
logger_1.logger.error(`Failed to run npm install: ${err.message}`);
|
|
79
|
-
process.exit(1);
|
|
80
|
-
});
|
|
64
|
+
import_logger.logger.success("Dependencies installed successfully!");
|
|
65
|
+
} else {
|
|
66
|
+
import_logger.logger.error(`npm install exited with code ${code}`);
|
|
67
|
+
process.exit(code || 1);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
child.on("error", (err) => {
|
|
71
|
+
import_logger.logger.error(`Failed to run npm install: ${err.message}`);
|
|
72
|
+
process.exit(1);
|
|
81
73
|
});
|
|
74
|
+
});
|
|
82
75
|
}
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
registerInstallCommand
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/install.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport { getTenantDir, resolveTenantOrExit } from '../utils/helpers';\nimport * as fs from 'fs';\nimport { spawn } from 'child_process';\n\nexport function registerInstallCommand(program: Command): void {\n program\n .command('install [tenant]')\n .description('Install npm dependencies for a tenant (runs npm install)')\n .action(async (tenantArg) => {\n const tenant = resolveTenantOrExit(tenantArg);\n const tenantDir = getTenantDir(tenant);\n\n if (!fs.existsSync(tenantDir)) {\n logger.error(`Tenant folder not found: farseer-apps/${tenant}/`);\n logger.dim('Run \"farseer pull <tenant>\" first to initialize the folder.');\n process.exit(1);\n }\n\n const packageJsonPath = `${tenantDir}/package.json`;\n\n if (!fs.existsSync(packageJsonPath)) {\n logger.error(`No package.json found in farseer-apps/${tenant}/`);\n logger.dim('Create a package.json first or run \"npm init\" in that folder.');\n process.exit(1);\n }\n\n logger.info(`Installing dependencies for ${tenant}...`);\n logger.dim(`Running: npm install in farseer-apps/${tenant}/`);\n console.log();\n\n const child = spawn('npm', ['install'], {\n stdio: 'inherit',\n cwd: tenantDir,\n shell: true,\n });\n\n child.on('close', (code) => {\n if (code === 0) {\n console.log();\n logger.success('Dependencies installed successfully!');\n } else {\n logger.error(`npm install exited with code ${code}`);\n process.exit(code || 1);\n }\n });\n\n child.on('error', (err) => {\n logger.error(`Failed to run npm install: ${err.message}`);\n process.exit(1);\n });\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,qBAAkD;AAClD,SAAoB;AACpB,2BAAsB;AAEf,SAAS,uBAAuB,SAAwB;AAC3D,UACK,QAAQ,kBAAkB,EAC1B,YAAY,0DAA0D,EACtE,OAAO,OAAO,cAAc;AACzB,UAAM,aAAS,oCAAoB,SAAS;AAC5C,UAAM,gBAAY,6BAAa,MAAM;AAErC,QAAI,CAAC,GAAG,WAAW,SAAS,GAAG;AAC3B,2BAAO,MAAM,yCAAyC,MAAM,GAAG;AAC/D,2BAAO,IAAI,6DAA6D;AACxE,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,kBAAkB,GAAG,SAAS;AAEpC,QAAI,CAAC,GAAG,WAAW,eAAe,GAAG;AACjC,2BAAO,MAAM,yCAAyC,MAAM,GAAG;AAC/D,2BAAO,IAAI,+DAA+D;AAC1E,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,yBAAO,KAAK,+BAA+B,MAAM,KAAK;AACtD,yBAAO,IAAI,wCAAwC,MAAM,GAAG;AAC5D,YAAQ,IAAI;AAEZ,UAAM,YAAQ,4BAAM,OAAO,CAAC,SAAS,GAAG;AAAA,MACpC,OAAO;AAAA,MACP,KAAK;AAAA,MACL,OAAO;AAAA,IACX,CAAC;AAED,UAAM,GAAG,SAAS,CAAC,SAAS;AACxB,UAAI,SAAS,GAAG;AACZ,gBAAQ,IAAI;AACZ,6BAAO,QAAQ,sCAAsC;AAAA,MACzD,OAAO;AACH,6BAAO,MAAM,gCAAgC,IAAI,EAAE;AACnD,gBAAQ,KAAK,QAAQ,CAAC;AAAA,MAC1B;AAAA,IACJ,CAAC;AAED,UAAM,GAAG,SAAS,CAAC,QAAQ;AACvB,2BAAO,MAAM,8BAA8B,IAAI,OAAO,EAAE;AACxD,cAAQ,KAAK,CAAC;AAAA,IAClB,CAAC;AAAA,EACL,CAAC;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/commands/list.js
CHANGED
|
@@ -1,77 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var list_exports = {};
|
|
20
|
+
__export(list_exports, {
|
|
21
|
+
registerListCommand: () => registerListCommand
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(list_exports);
|
|
24
|
+
var import_logger = require("../utils/logger");
|
|
25
|
+
var import_farseerFactory = require("../services/farseerFactory");
|
|
26
|
+
var import_helpers = require("../utils/helpers");
|
|
7
27
|
function registerListCommand(program) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
program.command("list [arg1] [arg2]").description('[DEPRECATED] Use "farseer files list" instead').option("--all", "List all files (default: only scripts .ts, .js)").action(async (arg1, arg2, options) => {
|
|
29
|
+
import_logger.logger.warning('Deprecation: "farseer list" is deprecated. Use "farseer files list" instead.');
|
|
30
|
+
console.log();
|
|
31
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(arg1, arg2);
|
|
32
|
+
const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
33
|
+
if (!result) {
|
|
34
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
const authLabel = result.authType === "apiKey" ? "API key" : "browser login";
|
|
38
|
+
import_logger.logger.info(`Fetching files from ${tenant} (using ${authLabel})...`);
|
|
39
|
+
let files;
|
|
40
|
+
try {
|
|
41
|
+
files = await result.client.listFiles();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if ((0, import_farseerFactory.isAuthError)(error)) {
|
|
44
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
45
|
+
} else {
|
|
46
|
+
import_logger.logger.error("Failed to list files.");
|
|
47
|
+
if (error instanceof Error) {
|
|
48
|
+
import_logger.logger.dim(error.message);
|
|
20
49
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
// Sort directories
|
|
63
|
-
const dirs = Object.keys(grouped).sort();
|
|
64
|
-
for (const dir of dirs) {
|
|
65
|
-
if (dir) {
|
|
66
|
-
console.log(` ${dir}`);
|
|
67
|
-
}
|
|
68
|
-
const dirFiles = grouped[dir].sort();
|
|
69
|
-
for (const file of dirFiles) {
|
|
70
|
-
const prefix = dir ? ' ' : ' ';
|
|
71
|
-
console.log(`${prefix}${file}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
console.log();
|
|
75
|
-
logger_1.logger.dim(`Total: ${files.length} file(s)`);
|
|
76
|
-
});
|
|
50
|
+
}
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
if (!options.all) {
|
|
54
|
+
files = files.filter(
|
|
55
|
+
(f) => import_farseerFactory.DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext))
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
if (files.length === 0) {
|
|
59
|
+
import_logger.logger.warning("No files found in Files/");
|
|
60
|
+
import_logger.logger.dim(
|
|
61
|
+
options.all ? "The folder might be empty or does not exist." : "No script files (.ts, .js) found. Use --all to see all files."
|
|
62
|
+
);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
import_logger.logger.header(`Files on ${tenant} (Files/)`);
|
|
66
|
+
const grouped = {};
|
|
67
|
+
for (const file of files) {
|
|
68
|
+
const parts = file.path.split("/");
|
|
69
|
+
const fileName = parts.pop();
|
|
70
|
+
const dir = parts.length > 0 ? parts.join("/") + "/" : "";
|
|
71
|
+
if (!grouped[dir]) {
|
|
72
|
+
grouped[dir] = [];
|
|
73
|
+
}
|
|
74
|
+
grouped[dir].push(fileName);
|
|
75
|
+
}
|
|
76
|
+
const dirs = Object.keys(grouped).sort();
|
|
77
|
+
for (const dir of dirs) {
|
|
78
|
+
if (dir) {
|
|
79
|
+
console.log(` ${dir}`);
|
|
80
|
+
}
|
|
81
|
+
const dirFiles = grouped[dir].sort();
|
|
82
|
+
for (const file of dirFiles) {
|
|
83
|
+
const prefix = dir ? " " : " ";
|
|
84
|
+
console.log(`${prefix}${file}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
console.log();
|
|
88
|
+
import_logger.logger.dim(`Total: ${files.length} file(s)`);
|
|
89
|
+
});
|
|
77
90
|
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
registerListCommand
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/list.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport {\n getFarseerClientWithFallback,\n showLoginPrompt,\n isAuthError,\n DEFAULT_SCRIPT_EXTENSIONS,\n} from '../services/farseerFactory';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\n\nexport function registerListCommand(program: Command): void {\n program\n .command('list [arg1] [arg2]')\n .description('[DEPRECATED] Use \"farseer files list\" instead')\n .option('--all', 'List all files (default: only scripts .ts, .js)')\n .action(async (arg1, arg2, options) => {\n logger.warning('Deprecation: \"farseer list\" is deprecated. Use \"farseer files list\" instead.');\n console.log();\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const authLabel = result.authType === 'apiKey' ? 'API key' : 'browser login';\n logger.info(`Fetching files from ${tenant} (using ${authLabel})...`);\n\n let files;\n try {\n files = await result.client.listFiles();\n } catch (error) {\n if (isAuthError(error)) {\n showLoginPrompt(tenant);\n } else {\n logger.error('Failed to list files.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n }\n process.exit(1);\n }\n\n // Filter to scripts only unless --all is specified\n if (!options.all) {\n files = files.filter((f) =>\n DEFAULT_SCRIPT_EXTENSIONS.some((ext) => f.name.toLowerCase().endsWith(ext)),\n );\n }\n\n if (files.length === 0) {\n logger.warning('No files found in Files/');\n logger.dim(\n options.all\n ? 'The folder might be empty or does not exist.'\n : 'No script files (.ts, .js) found. Use --all to see all files.',\n );\n return;\n }\n\n logger.header(`Files on ${tenant} (Files/)`);\n\n // Group by directory\n const grouped: Record<string, string[]> = {};\n\n for (const file of files) {\n const parts = file.path.split('/');\n const fileName = parts.pop()!;\n const dir = parts.length > 0 ? parts.join('/') + '/' : '';\n\n if (!grouped[dir]) {\n grouped[dir] = [];\n }\n grouped[dir].push(fileName);\n }\n\n // Sort directories\n const dirs = Object.keys(grouped).sort();\n\n for (const dir of dirs) {\n if (dir) {\n console.log(` ${dir}`);\n }\n\n const dirFiles = grouped[dir].sort();\n for (const file of dirFiles) {\n const prefix = dir ? ' ' : ' ';\n console.log(`${prefix}${file}`);\n }\n }\n\n console.log();\n logger.dim(`Total: ${files.length} file(s)`);\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,4BAKO;AACP,qBAA4C;AAErC,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,oBAAoB,EAC5B,YAAY,+CAA+C,EAC3D,OAAO,SAAS,iDAAiD,EACjE,OAAO,OAAO,MAAM,MAAM,YAAY;AACnC,yBAAO,QAAQ,8EAA8E;AAC7F,YAAQ,IAAI;AACZ,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,MAAM,IAAI;AACvE,UAAM,SAAS,UAAM,oDAA6B,cAAc,MAAM;AAEtE,QAAI,CAAC,QAAQ;AACT,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,YAAY,OAAO,aAAa,WAAW,YAAY;AAC7D,yBAAO,KAAK,uBAAuB,MAAM,WAAW,SAAS,MAAM;AAEnE,QAAI;AACJ,QAAI;AACA,cAAQ,MAAM,OAAO,OAAO,UAAU;AAAA,IAC1C,SAAS,OAAO;AACZ,cAAI,mCAAY,KAAK,GAAG;AACpB,mDAAgB,MAAM;AAAA,MAC1B,OAAO;AACH,6BAAO,MAAM,uBAAuB;AACpC,YAAI,iBAAiB,OAAO;AACxB,+BAAO,IAAI,MAAM,OAAO;AAAA,QAC5B;AAAA,MACJ;AACA,cAAQ,KAAK,CAAC;AAAA,IAClB;AAGA,QAAI,CAAC,QAAQ,KAAK;AACd,cAAQ,MAAM;AAAA,QAAO,CAAC,MAClB,gDAA0B,KAAK,CAAC,QAAQ,EAAE,KAAK,YAAY,EAAE,SAAS,GAAG,CAAC;AAAA,MAC9E;AAAA,IACJ;AAEA,QAAI,MAAM,WAAW,GAAG;AACpB,2BAAO,QAAQ,0BAA0B;AACzC,2BAAO;AAAA,QACH,QAAQ,MACF,iDACA;AAAA,MACV;AACA;AAAA,IACJ;AAEA,yBAAO,OAAO,YAAY,MAAM,WAAW;AAG3C,UAAM,UAAoC,CAAC;AAE3C,eAAW,QAAQ,OAAO;AACtB,YAAM,QAAQ,KAAK,KAAK,MAAM,GAAG;AACjC,YAAM,WAAW,MAAM,IAAI;AAC3B,YAAM,MAAM,MAAM,SAAS,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM;AAEvD,UAAI,CAAC,QAAQ,GAAG,GAAG;AACf,gBAAQ,GAAG,IAAI,CAAC;AAAA,MACpB;AACA,cAAQ,GAAG,EAAE,KAAK,QAAQ;AAAA,IAC9B;AAGA,UAAM,OAAO,OAAO,KAAK,OAAO,EAAE,KAAK;AAEvC,eAAW,OAAO,MAAM;AACpB,UAAI,KAAK;AACL,gBAAQ,IAAI,KAAK,GAAG,EAAE;AAAA,MAC1B;AAEA,YAAM,WAAW,QAAQ,GAAG,EAAE,KAAK;AACnC,iBAAW,QAAQ,UAAU;AACzB,cAAM,SAAS,MAAM,SAAS;AAC9B,gBAAQ,IAAI,GAAG,MAAM,GAAG,IAAI,EAAE;AAAA,MAClC;AAAA,IACJ;AAEA,YAAQ,IAAI;AACZ,yBAAO,IAAI,UAAU,MAAM,MAAM,UAAU;AAAA,EAC/C,CAAC;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|