farseer-cli 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/app.js +349 -0
- package/dist/commands/app.js.map +7 -0
- package/dist/commands/apps.js +111 -0
- package/dist/commands/apps.js.map +7 -0
- package/dist/commands/checkout.js +142 -0
- package/dist/commands/checkout.js.map +7 -0
- package/dist/commands/config.js +139 -0
- package/dist/commands/config.js.map +7 -0
- package/dist/commands/diff.js +185 -0
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/dimensions.js +145 -0
- package/dist/commands/dimensions.js.map +7 -0
- package/dist/commands/files.js +99 -0
- package/dist/commands/files.js.map +7 -0
- package/dist/commands/install.js +79 -0
- package/dist/commands/install.js.map +7 -0
- package/dist/commands/list.js +92 -0
- package/dist/commands/list.js.map +7 -0
- package/dist/commands/login.js +134 -0
- package/dist/commands/login.js.map +7 -0
- package/dist/commands/logout.js +59 -0
- package/dist/commands/logout.js.map +7 -0
- package/dist/commands/mcp-server.js +41 -0
- package/dist/commands/mcp-server.js.map +7 -0
- package/dist/commands/model.js +189 -0
- package/dist/commands/model.js.map +7 -0
- package/dist/commands/pull.js +258 -0
- package/dist/commands/pull.js.map +7 -0
- package/dist/commands/push.js +213 -0
- package/dist/commands/push.js.map +7 -0
- package/dist/commands/run.js +288 -0
- package/dist/commands/run.js.map +7 -0
- package/dist/commands/status.js +155 -0
- package/dist/commands/status.js.map +7 -0
- package/dist/commands/variables.js +176 -0
- package/dist/commands/variables.js.map +7 -0
- package/dist/commands/whoami.js +63 -0
- package/dist/commands/whoami.js.map +7 -0
- package/dist/index.js +165 -0
- package/dist/index.js.map +7 -0
- package/dist/mcp/index.js +35 -0
- package/dist/mcp/index.js.map +7 -0
- package/dist/mcp/prompts/workflows.js +448 -0
- package/dist/mcp/prompts/workflows.js.map +7 -0
- package/dist/mcp/resources/documentation.js +167 -0
- package/dist/mcp/resources/documentation.js.map +7 -0
- package/dist/mcp/server.js +52 -0
- package/dist/mcp/server.js.map +7 -0
- package/dist/mcp/tools/appTools.js +377 -0
- package/dist/mcp/tools/appTools.js.map +7 -0
- package/dist/mcp/tools/authTools.js +159 -0
- package/dist/mcp/tools/authTools.js.map +7 -0
- package/dist/mcp/tools/dataTools.js +362 -0
- package/dist/mcp/tools/dataTools.js.map +7 -0
- package/dist/mcp/tools/modelTools.js +325 -0
- package/dist/mcp/tools/modelTools.js.map +7 -0
- package/dist/mcp/tools/runTools.js +233 -0
- package/dist/mcp/tools/runTools.js.map +7 -0
- package/dist/mcp/tools/syncTools.js +409 -0
- package/dist/mcp/tools/syncTools.js.map +7 -0
- package/dist/mcp/utils/helpers.js +135 -0
- package/dist/mcp/utils/helpers.js.map +7 -0
- package/dist/services/appSyncService.js +399 -0
- package/dist/services/appSyncService.js.map +7 -0
- package/dist/services/configService.js +196 -0
- package/dist/services/configService.js.map +7 -0
- package/dist/services/farseerApi.js +426 -0
- package/dist/services/farseerApi.js.map +7 -0
- package/dist/services/farseerFactory.js +231 -0
- package/dist/services/farseerFactory.js.map +7 -0
- package/dist/services/farseerService.js +614 -0
- package/dist/services/farseerService.js.map +7 -0
- package/dist/services/syncService.js +689 -0
- package/dist/services/syncService.js.map +7 -0
- package/dist/utils/constants.js +46 -0
- package/dist/utils/constants.js.map +7 -0
- package/dist/utils/helpers.js +413 -0
- package/dist/utils/helpers.js.map +7 -0
- package/dist/utils/logger.js +76 -0
- package/dist/utils/logger.js.map +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/pull.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt } from '../services/farseerFactory';\nimport { SyncService, ConflictResolutions } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { getTenantDir, ensureDirectoryExists, resolveTenantWithOrgMapping, appendToAuditLog, AuditLogEntry } from '../utils/helpers';\n\nexport function registerPullCommand(program: Command): void {\n program\n .command('pull [org] [tenant]')\n .description('Pull files from Farseer instance to local\\n\\nUsage: pull <org> <tenant> OR pull <tenant> (if org is known)')\n .option('--all', 'Pull all files (default: only scripts .ts, .js)')\n .option('--force', 'Force pull, overwriting local changes on conflicts')\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const syncService = new SyncService(tenant, clientResult.client);\n\n // Step 1: Ensure tenant folder exists\n const tenantDir = getTenantDir(tenant);\n ensureDirectoryExists(tenantDir);\n\n // Create default package.json if it doesn't exist\n await createDefaultPackageJson(tenantDir, tenant);\n\n // Step 2: Pull files from Farseer\n console.log();\n console.log(chalk.bold('\u2550\u2550\u2550 Files \u2550\u2550\u2550'));\n logger.info(`Pulling files from ${tenant}...`);\n\n try {\n let result = await syncService.pull({ all: options.all, force: options.force });\n\n // Handle conflicts interactively\n if (result.conflicts.length > 0 && !options.force) {\n console.log();\n console.log(chalk.red.bold(`${result.conflicts.length} conflict(s) detected:`));\n console.log();\n\n for (const conflict of result.conflicts) {\n console.log(chalk.red(` ! ${conflict.filePath}`));\n console.log(chalk.dim(` ${conflict.description}`));\n }\n console.log();\n\n const resolutions: ConflictResolutions = {};\n\n for (const conflict of result.conflicts) {\n let choices: { name: string; value: string }[];\n\n if (conflict.type === 'local_modified_remote_deleted') {\n choices = [\n { name: 'Keep local (keep your modified file)', value: 'keep_local' },\n { name: 'Accept deletion (delete local file)', value: 'keep_remote' },\n ];\n } else if (conflict.type === 'local_deleted_remote_modified') {\n choices = [\n { name: 'Keep deleted (don\\'t restore file)', value: 'keep_local' },\n { name: 'Restore remote version', value: 'keep_remote' },\n ];\n } else {\n choices = [\n { name: 'Keep local version', value: 'keep_local' },\n { name: 'Use remote version (overwrite local)', value: 'keep_remote' },\n { name: 'Keep both (save remote as .remote file)', value: 'keep_both' },\n ];\n }\n\n const answer = await inquirer.prompt([{\n type: 'list',\n name: 'resolution',\n message: `${conflict.filePath} - ${conflict.description}`,\n choices,\n }]);\n\n resolutions[conflict.filePath] = answer.resolution;\n }\n\n // Re-pull with resolutions\n result = await syncService.pull({ all: options.all, conflictResolutions: resolutions });\n }\n\n if (result.downloaded.length > 0) {\n console.log(chalk.green('Downloaded:'));\n for (const file of result.downloaded) {\n console.log(chalk.green(` + ${file}`));\n }\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted (removed from remote):'));\n for (const file of result.deleted) {\n console.log(chalk.red(` - ${file}`));\n }\n }\n\n if (result.conflictFilesWritten.length > 0) {\n console.log(chalk.yellow('Conflict files created:'));\n for (const file of result.conflictFilesWritten) {\n console.log(chalk.yellow(` ~ ${file}`));\n }\n }\n\n logger.dim(`Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`);\n\n // Create audit log entries for downloaded files\n if (result.downloaded.length > 0) {\n const syncState = syncService.loadSyncState();\n const auditEntries: AuditLogEntry[] = result.downloaded.map(filePath => ({\n operation: 'pulled' as const,\n filePath,\n uploadTime: syncState.files[filePath]?.metadata?.uploadTime,\n uploaderEmail: syncState.files[filePath]?.metadata?.uploaderEmail,\n uploaderName: syncState.files[filePath]?.metadata?.uploaderName,\n }));\n\n appendToAuditLog(tenant, auditEntries);\n }\n\n let hasChanges = result.downloaded.length > 0 || result.deleted.length > 0;\n\n // Step 3: Pull apps\n let appResult = { created: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\n\n console.log();\n console.log(chalk.bold('\u2550\u2550\u2550 Apps \u2550\u2550\u2550'));\n logger.info(`Pulling apps from ${tenant}...`);\n\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appResult = await appSyncService.pull();\n\n if (appResult.created.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appResult.created) {\n console.log(chalk.green(` + ${app}`));\n }\n }\n\n if (appResult.updated.length > 0) {\n console.log(chalk.yellow('Updated apps:'));\n for (const app of appResult.updated) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n }\n\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps (removed from remote):'));\n for (const app of appResult.deleted) {\n console.log(chalk.red(` - ${app}`));\n }\n }\n\n logger.dim(`Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`);\n\n hasChanges = hasChanges || appResult.created.length > 0 || appResult.updated.length > 0 || appResult.deleted.length > 0;\n\n if (!hasChanges) {\n logger.success('Already up to date.');\n return;\n }\n\n console.log();\n console.log(chalk.bold('\u2550\u2550\u2550 Summary \u2550\u2550\u2550'));\n logger.success('Pull complete!');\n logger.dim(`Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`);\n logger.dim(`Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`);\n } catch (error) {\n logger.error('Pull failed.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n\nasync function createDefaultPackageJson(tenantDir: string, tenant: string): Promise<void> {\n const fs = await import('fs');\n const path = await import('path');\n\n const packageJsonPath = path.join(tenantDir, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n return;\n }\n\n const packageJson = {\n name: `farseer-scripts-${tenant}`,\n version: '1.0.0',\n description: `Farseer App scripts for ${tenant}`,\n main: 'src/index.ts',\n scripts: {},\n keywords: ['farseer', 'scripts', tenant],\n author: 'Farseer',\n license: 'ISC',\n dependencies: {\n '@google-cloud/bigquery': '^7.9.0',\n '@google-cloud/storage': '^7.12.1',\n '@googleapis/sheets': '^5.0.5',\n '@sendgrid/mail': '^7.7.0',\n '@types/node-forge': '^1.3.11',\n '@xmldom/xmldom': '^0.9.8',\n 'arquero': '^5.4.1',\n 'axios': '^1.10.0',\n 'axios-retry': '^3.9.1',\n 'basic-ftp': '^5.0.5',\n 'client-oauth2': '^4.3.3',\n 'csv-parser': '^3.0.0',\n 'dotenv': '^16.4.5',\n 'draft-js': '^0.11.7',\n 'exceljs': '^4.4.0',\n 'farseer-client': 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client/release-1.4.5.tar',\n 'farseer-client-axios': 'https://storage.googleapis.com/farseer-remote-jobs-results/farseer-client-axios/6898c0cb-5dca-4b2f-b325-119efc7f099e/v1.0.1.tar',\n 'fast-xml-parser': '^4.5.0',\n 'form-data': '^4.0.0',\n 'googleapis': '^144.0.0',\n 'heapdump': '^0.3.15',\n 'image-size': '^1.1.1',\n 'jszip': '^3.10.1',\n 'lossless-json': '^4.0.1',\n 'mssql': '^10.0.4',\n 'node-fetch': '^2.7.0',\n 'node-forge': '^1.3.1',\n 'node-sp-auth': '^3.0.8',\n 'numeral': '^2.0.6',\n 'oracledb': '^6.6.0',\n 'papaparse': '^5.5.1',\n 'pdfkit': '^0.14.0',\n 'pdfmake': '^0.2.20',\n 'soap': '^1.1.11',\n 'ssh2-sftp-client': '^11.0.0',\n 'strong-soap': '^4.1.13',\n 'ts-node': '^10.9.2',\n 'typescript': '^5.5.4',\n 'undici': '^6.19.8',\n 'uuid': '^11.1.0',\n 'winston': '^3.17.0',\n 'xlsx': 'https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz',\n 'xml-crypto': '^6.1.2',\n },\n devDependencies: {\n '@types/draft-js': '^0.11.18',\n '@types/heapdump': '^0.3.4',\n '@types/mssql': '^9.1.5',\n '@types/node': '^18.19.50',\n '@types/node-fetch': '^2.6.11',\n '@types/numeral': '^2.0.5',\n '@types/oracledb': '^6.5.3',\n '@types/papaparse': '^5.3.15',\n '@types/pdfmake': '^0.2.11',\n '@types/soap': '^0.18.0',\n '@types/ssh2-sftp-client': '^9.0.4',\n '@types/tough-cookie': '^4.0.5',\n '@types/uuid': '^10.0.0',\n '@types/xmldom': '^0.1.34',\n 'ts-node': '^10.9.2',\n 'typescript': '^5.5.4',\n },\n };\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');\n logger.dim(`Created package.json for ${tenant}`);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,sBAAqB;AACrB,oBAAuB;AACvB,4BAA8D;AAC9D,yBAAiD;AACjD,4BAA+B;AAC/B,qBAAkH;AAE3G,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,qBAAqB,EAC7B,YAAY,4GAA4G,EACxH,OAAO,SAAS,iDAAiD,EACjE,OAAO,WAAW,oDAAoD,EACtE,OAAO,OAAO,MAAM,MAAM,YAAY;AACnC,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,MAAM,IAAI;AACvE,UAAM,eAAe,UAAM,oDAA6B,cAAc,MAAM;AAE5E,QAAI,CAAC,cAAc;AACf,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,cAAc,IAAI,+BAAY,QAAQ,aAAa,MAAM;AAG/D,UAAM,gBAAY,6BAAa,MAAM;AACrC,8CAAsB,SAAS;AAG/B,UAAM,yBAAyB,WAAW,MAAM;AAGhD,YAAQ,IAAI;AACZ,YAAQ,IAAI,aAAAA,QAAM,KAAK,6CAAe,CAAC;AACvC,yBAAO,KAAK,sBAAsB,MAAM,KAAK;AAE7C,QAAI;AACA,UAAI,SAAS,MAAM,YAAY,KAAK,EAAE,KAAK,QAAQ,KAAK,OAAO,QAAQ,MAAM,CAAC;AAG9E,UAAI,OAAO,UAAU,SAAS,KAAK,CAAC,QAAQ,OAAO;AAC/C,gBAAQ,IAAI;AACZ,gBAAQ,IAAI,aAAAA,QAAM,IAAI,KAAK,GAAG,OAAO,UAAU,MAAM,wBAAwB,CA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AA,MACd,gBAAgB;AAAA,MAChB,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,UAAU;AAAA,MACV,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,oBAAoB;AAAA,MACpB,eAAe;AAAA,MACf,WAAW;AAAA,MACX,cAAc;AAAA,MACd,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,cAAc;AAAA,IAClB;AAAA,IACA,iBAAiB;AAAA,MACb,mBAAmB;AAAA,MACnB,mBAAmB;AAAA,MACnB,gBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,qBAAqB;AAAA,MACrB,kBAAkB;AAAA,MAClB,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,kBAAkB;AAAA,MAClB,eAAe;AAAA,MACf,2BAA2B;AAAA,MAC3B,uBAAuB;AAAA,MACvB,eAAe;AAAA,MACf,iBAAiB;AAAA,MACjB,WAAW;AAAA,MACX,cAAc;AAAA,IAClB;AAAA,EACJ;AAEA,KAAG,cAAc,iBAAiB,KAAK,UAAU,aAAa,MAAM,CAAC,GAAG,OAAO;AAC/E,uBAAO,IAAI,4BAA4B,MAAM,EAAE;AACnD;",
|
|
6
|
+
"names": ["chalk", "inquirer"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var push_exports = {};
|
|
29
|
+
__export(push_exports, {
|
|
30
|
+
registerPushCommand: () => registerPushCommand
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(push_exports);
|
|
33
|
+
var import_chalk = __toESM(require("chalk"));
|
|
34
|
+
var import_inquirer = __toESM(require("inquirer"));
|
|
35
|
+
var import_logger = require("../utils/logger");
|
|
36
|
+
var import_farseerFactory = require("../services/farseerFactory");
|
|
37
|
+
var import_syncService = require("../services/syncService");
|
|
38
|
+
var import_appSyncService = require("../services/appSyncService");
|
|
39
|
+
var import_helpers = require("../utils/helpers");
|
|
40
|
+
var fs = __toESM(require("fs"));
|
|
41
|
+
function registerPushCommand(program) {
|
|
42
|
+
program.command("push [org] [tenant]").description("Push local files to Farseer instance\n\nUsage: push <org> <tenant> OR push <tenant> (if org is known)").option("--force", "Force push even if remote has changes").option("-y, --yes", "Skip confirmation prompt (auto-confirm)").action(async (arg1, arg2, options) => {
|
|
43
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(arg1, arg2);
|
|
44
|
+
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
45
|
+
if (!clientResult) {
|
|
46
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const filesDir = (0, import_helpers.getTenantFilesDir)(tenant);
|
|
50
|
+
if (!fs.existsSync(filesDir)) {
|
|
51
|
+
import_logger.logger.error(`Local folder not found: farseer-apps/${tenant}/files/`);
|
|
52
|
+
import_logger.logger.dim('Run "farseer pull <tenant>" first to initialize the folder.');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
const syncService = new import_syncService.SyncService(tenant, clientResult.client);
|
|
56
|
+
if (!options.force) {
|
|
57
|
+
import_logger.logger.info("Checking for remote changes...");
|
|
58
|
+
const hasRemoteChanges = await syncService.checkRemoteChanges();
|
|
59
|
+
if (hasRemoteChanges) {
|
|
60
|
+
import_logger.logger.error("Remote has changes that are not synced locally.");
|
|
61
|
+
import_logger.logger.dim(`Run 'farseer pull ${tenant}' first, then try pushing again.`);
|
|
62
|
+
import_logger.logger.dim("Or use --force to push anyway (will overwrite remote changes).");
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
import_logger.logger.dim("Remote is in sync.");
|
|
66
|
+
}
|
|
67
|
+
const status = await syncService.getStatusFast();
|
|
68
|
+
const filesToPush = [
|
|
69
|
+
...status.modifiedLocally,
|
|
70
|
+
...status.onlyLocal
|
|
71
|
+
];
|
|
72
|
+
const filesToDelete = status.modifiedRemotely.filter(
|
|
73
|
+
(f) => !fs.existsSync(`${filesDir}/${f}`)
|
|
74
|
+
);
|
|
75
|
+
let appStatus = { newLocal: [], modified: [], newRemote: [], synced: [] };
|
|
76
|
+
const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
|
|
77
|
+
appStatus = await appSyncService.getStatus();
|
|
78
|
+
const hasFileChanges = filesToPush.length > 0 || filesToDelete.length > 0;
|
|
79
|
+
const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.modified.length > 0;
|
|
80
|
+
if (!hasFileChanges && !hasAppChanges) {
|
|
81
|
+
import_logger.logger.success("Nothing to push. Everything is in sync.");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
console.log();
|
|
85
|
+
import_logger.logger.header("Changes to push:");
|
|
86
|
+
if (filesToPush.length > 0) {
|
|
87
|
+
for (const file of filesToPush) {
|
|
88
|
+
const isNew = status.onlyLocal.includes(file);
|
|
89
|
+
if (isNew) {
|
|
90
|
+
console.log(import_chalk.default.green(` + ${file}`));
|
|
91
|
+
} else {
|
|
92
|
+
console.log(import_chalk.default.yellow(` M ${file}`));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (filesToDelete.length > 0) {
|
|
97
|
+
for (const file of filesToDelete) {
|
|
98
|
+
console.log(import_chalk.default.red(` - ${file}`));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (appStatus.newLocal.length > 0) {
|
|
102
|
+
console.log(import_chalk.default.green("New apps:"));
|
|
103
|
+
for (const app of appStatus.newLocal) {
|
|
104
|
+
console.log(import_chalk.default.green(` + ${app}`));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (appStatus.modified.length > 0) {
|
|
108
|
+
console.log(import_chalk.default.yellow("Modified apps:"));
|
|
109
|
+
for (const app of appStatus.modified) {
|
|
110
|
+
console.log(import_chalk.default.yellow(` ~ ${app}`));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
console.log();
|
|
114
|
+
const totalChanges = filesToPush.length + filesToDelete.length + appStatus.newLocal.length + appStatus.modified.length;
|
|
115
|
+
if (!options.yes) {
|
|
116
|
+
const confirm = await import_inquirer.default.prompt([
|
|
117
|
+
{
|
|
118
|
+
type: "confirm",
|
|
119
|
+
name: "proceed",
|
|
120
|
+
message: `Push ${totalChanges} change(s) to ${tenant}?`,
|
|
121
|
+
default: true
|
|
122
|
+
}
|
|
123
|
+
]);
|
|
124
|
+
if (!confirm.proceed) {
|
|
125
|
+
import_logger.logger.info("Push cancelled.");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
await (0, import_farseerFactory.ensureFreshToken)(clientResult.client);
|
|
130
|
+
try {
|
|
131
|
+
let result = { uploaded: [], updated: [], deleted: [], unchanged: [] };
|
|
132
|
+
if (hasFileChanges) {
|
|
133
|
+
import_logger.logger.info(`Pushing files to ${tenant}...`);
|
|
134
|
+
result = await syncService.push({ force: options.force });
|
|
135
|
+
console.log();
|
|
136
|
+
if (result.conflicts && result.conflicts.length > 0) {
|
|
137
|
+
console.log(import_chalk.default.red.bold(`${result.conflicts.length} conflict(s) detected:`));
|
|
138
|
+
console.log();
|
|
139
|
+
for (const conflict of result.conflicts) {
|
|
140
|
+
console.log(import_chalk.default.red(` ! ${conflict.filePath}`));
|
|
141
|
+
console.log(import_chalk.default.dim(` ${conflict.description}`));
|
|
142
|
+
}
|
|
143
|
+
console.log();
|
|
144
|
+
import_logger.logger.dim(`Resolve conflicts by pulling first: farseer pull ${tenant}`);
|
|
145
|
+
import_logger.logger.dim("Or use --force to push anyway (may overwrite remote changes).");
|
|
146
|
+
console.log();
|
|
147
|
+
}
|
|
148
|
+
if (result.uploaded.length > 0) {
|
|
149
|
+
console.log(import_chalk.default.green("Uploaded files (new):"));
|
|
150
|
+
for (const file of result.uploaded) {
|
|
151
|
+
console.log(import_chalk.default.green(` + ${file}`));
|
|
152
|
+
}
|
|
153
|
+
console.log();
|
|
154
|
+
}
|
|
155
|
+
if (result.updated.length > 0) {
|
|
156
|
+
console.log(import_chalk.default.yellow("Updated files:"));
|
|
157
|
+
for (const file of result.updated) {
|
|
158
|
+
console.log(import_chalk.default.yellow(` M ${file}`));
|
|
159
|
+
}
|
|
160
|
+
console.log();
|
|
161
|
+
}
|
|
162
|
+
if (result.deleted.length > 0) {
|
|
163
|
+
console.log(import_chalk.default.red("Deleted files:"));
|
|
164
|
+
for (const file of result.deleted) {
|
|
165
|
+
console.log(import_chalk.default.red(` - ${file}`));
|
|
166
|
+
}
|
|
167
|
+
console.log();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
let appResult = { created: [], updated: [], deleted: [], unchanged: [] };
|
|
171
|
+
if (hasAppChanges) {
|
|
172
|
+
import_logger.logger.info(`Pushing apps to ${tenant}...`);
|
|
173
|
+
appResult = await appSyncService.push();
|
|
174
|
+
if (appResult.created.length > 0) {
|
|
175
|
+
console.log(import_chalk.default.green("Created apps:"));
|
|
176
|
+
for (const app of appResult.created) {
|
|
177
|
+
console.log(import_chalk.default.green(` + ${app}`));
|
|
178
|
+
}
|
|
179
|
+
console.log();
|
|
180
|
+
}
|
|
181
|
+
if (appResult.updated.length > 0) {
|
|
182
|
+
console.log(import_chalk.default.yellow("Updated apps:"));
|
|
183
|
+
for (const app of appResult.updated) {
|
|
184
|
+
console.log(import_chalk.default.yellow(` ~ ${app}`));
|
|
185
|
+
}
|
|
186
|
+
console.log();
|
|
187
|
+
}
|
|
188
|
+
if (appResult.deleted.length > 0) {
|
|
189
|
+
console.log(import_chalk.default.red("Deleted apps:"));
|
|
190
|
+
for (const app of appResult.deleted) {
|
|
191
|
+
console.log(import_chalk.default.red(` - ${app}`));
|
|
192
|
+
}
|
|
193
|
+
console.log();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
console.log();
|
|
197
|
+
import_logger.logger.success("Push complete!");
|
|
198
|
+
import_logger.logger.dim(`Files: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}`);
|
|
199
|
+
import_logger.logger.dim(`Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}`);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
import_logger.logger.error("Push failed.");
|
|
202
|
+
if (error instanceof Error) {
|
|
203
|
+
import_logger.logger.dim(error.message);
|
|
204
|
+
}
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
210
|
+
0 && (module.exports = {
|
|
211
|
+
registerPushCommand
|
|
212
|
+
});
|
|
213
|
+
//# sourceMappingURL=push.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/push.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt, ensureFreshToken } from '../services/farseerFactory';\nimport { SyncService } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport { getTenantFilesDir, resolveTenantWithOrgMapping } from '../utils/helpers';\nimport * as fs from 'fs';\n\nexport function registerPushCommand(program: Command): void {\n program\n .command('push [org] [tenant]')\n .description('Push local files to Farseer instance\\n\\nUsage: push <org> <tenant> OR push <tenant> (if org is known)')\n .option('--force', 'Force push even if remote has changes')\n .option('-y, --yes', 'Skip confirmation prompt (auto-confirm)')\n .action(async (arg1, arg2, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(arg1, arg2);\n const clientResult = await getFarseerClientWithFallback(organisation, tenant);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const filesDir = getTenantFilesDir(tenant);\n\n if (!fs.existsSync(filesDir)) {\n logger.error(`Local folder not found: farseer-apps/${tenant}/files/`);\n logger.dim('Run \"farseer pull <tenant>\" first to initialize the folder.');\n process.exit(1);\n }\n\n const syncService = new SyncService(tenant, clientResult.client);\n\n // Step 1: Check if remote has unpulled changes\n if (!options.force) {\n logger.info('Checking for remote changes...');\n\n const hasRemoteChanges = await syncService.checkRemoteChanges();\n\n if (hasRemoteChanges) {\n logger.error('Remote has changes that are not synced locally.');\n logger.dim(`Run 'farseer pull ${tenant}' first, then try pushing again.`);\n logger.dim('Or use --force to push anyway (will overwrite remote changes).');\n process.exit(1);\n }\n\n logger.dim('Remote is in sync.');\n }\n\n // Step 2: Show what will be pushed (using fast status check that doesn't download remote content)\n const status = await syncService.getStatusFast();\n\n const filesToPush = [\n ...status.modifiedLocally,\n ...status.onlyLocal,\n ];\n\n const filesToDelete = status.modifiedRemotely.filter((f) =>\n !fs.existsSync(`${filesDir}/${f}`)\n );\n\n // Check app changes too\n let appStatus = { newLocal: [] as string[], modified: [] as string[], newRemote: [] as string[], synced: [] as string[] };\n const appSyncService = new AppSyncService(tenant, clientResult.client);\n appStatus = await appSyncService.getStatus();\n\n const hasFileChanges = filesToPush.length > 0 || filesToDelete.length > 0;\n const hasAppChanges = appStatus.newLocal.length > 0 || appStatus.modified.length > 0;\n\n if (!hasFileChanges && !hasAppChanges) {\n logger.success('Nothing to push. Everything is in sync.');\n return;\n }\n\n console.log();\n logger.header('Changes to push:');\n\n if (filesToPush.length > 0) {\n for (const file of filesToPush) {\n const isNew = status.onlyLocal.includes(file);\n if (isNew) {\n console.log(chalk.green(` + ${file}`));\n } else {\n console.log(chalk.yellow(` M ${file}`));\n }\n }\n }\n\n if (filesToDelete.length > 0) {\n for (const file of filesToDelete) {\n console.log(chalk.red(` - ${file}`));\n }\n }\n\n // Show app changes\n if (appStatus.newLocal.length > 0) {\n console.log(chalk.green('New apps:'));\n for (const app of appStatus.newLocal) {\n console.log(chalk.green(` + ${app}`));\n }\n }\n\n if (appStatus.modified.length > 0) {\n console.log(chalk.yellow('Modified apps:'));\n for (const app of appStatus.modified) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n }\n\n console.log();\n\n const totalChanges = filesToPush.length + filesToDelete.length + appStatus.newLocal.length + appStatus.modified.length;\n\n // Step 3: Confirm push (skip if --yes flag is set)\n if (!options.yes) {\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: `Push ${totalChanges} change(s) to ${tenant}?`,\n default: true,\n },\n ]);\n\n if (!confirm.proceed) {\n logger.info('Push cancelled.');\n return;\n }\n }\n\n // Ensure token is fresh before push operations (may have expired during user input)\n await ensureFreshToken(clientResult.client);\n\n try {\n // Step 4: Push files only if there are file changes\n let result: { uploaded: string[]; updated: string[]; deleted: string[]; unchanged: string[]; conflicts?: import('../services/syncService').SyncConflict[] } = { uploaded: [], updated: [], deleted: [], unchanged: [] };\n\n if (hasFileChanges) {\n logger.info(`Pushing files to ${tenant}...`);\n result = await syncService.push({ force: options.force });\n\n console.log();\n\n if (result.conflicts && result.conflicts.length > 0) {\n console.log(chalk.red.bold(`${result.conflicts.length} conflict(s) detected:`));\n console.log();\n for (const conflict of result.conflicts) {\n console.log(chalk.red(` ! ${conflict.filePath}`));\n console.log(chalk.dim(` ${conflict.description}`));\n }\n console.log();\n logger.dim(`Resolve conflicts by pulling first: farseer pull ${tenant}`);\n logger.dim('Or use --force to push anyway (may overwrite remote changes).');\n console.log();\n }\n\n if (result.uploaded.length > 0) {\n console.log(chalk.green('Uploaded files (new):'));\n for (const file of result.uploaded) {\n console.log(chalk.green(` + ${file}`));\n }\n console.log();\n }\n\n if (result.updated.length > 0) {\n console.log(chalk.yellow('Updated files:'));\n for (const file of result.updated) {\n console.log(chalk.yellow(` M ${file}`));\n }\n console.log();\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted files:'));\n for (const file of result.deleted) {\n console.log(chalk.red(` - ${file}`));\n }\n console.log();\n }\n }\n\n // Step 5: Push apps only if there are app changes\n let appResult = { created: [] as string[], updated: [] as string[], deleted: [] as string[], unchanged: [] as string[] };\n\n if (hasAppChanges) {\n logger.info(`Pushing apps to ${tenant}...`);\n appResult = await appSyncService.push();\n\n if (appResult.created.length > 0) {\n console.log(chalk.green('Created apps:'));\n for (const app of appResult.created) {\n console.log(chalk.green(` + ${app}`));\n }\n console.log();\n }\n\n if (appResult.updated.length > 0) {\n console.log(chalk.yellow('Updated apps:'));\n for (const app of appResult.updated) {\n console.log(chalk.yellow(` ~ ${app}`));\n }\n console.log();\n }\n\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps:'));\n for (const app of appResult.deleted) {\n console.log(chalk.red(` - ${app}`));\n }\n console.log();\n }\n }\n\n console.log();\n logger.success('Push complete!');\n logger.dim(`Files: +${result.uploaded.length} ~${result.updated.length} -${result.deleted.length}`);\n logger.dim(`Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length}`);\n } catch (error) {\n logger.error('Push failed.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,sBAAqB;AACrB,oBAAuB;AACvB,4BAAgF;AAChF,yBAA4B;AAC5B,4BAA+B;AAC/B,qBAA+D;AAC/D,SAAoB;AAEb,SAAS,oBAAoB,SAAwB;AACxD,UACK,QAAQ,qBAAqB,EAC7B,YAAY,uGAAuG,EACnH,OAAO,WAAW,uCAAuC,EACzD,OAAO,aAAa,yCAAyC,EAC7D,OAAO,OAAO,MAAM,MAAM,YAAY;AACnC,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,MAAM,IAAI;AACvE,UAAM,eAAe,UAAM,oDAA6B,cAAc,MAAM;AAE5E,QAAI,CAAC,cAAc;AACf,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,eAAW,kCAAkB,MAAM;AAEzC,QAAI,CAAC,GAAG,WAAW,QAAQ,GAAG;AAC1B,2BAAO,MAAM,wCAAwC,MAAM,SAAS;AACpE,2BAAO,IAAI,6DAA6D;AACxE,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,cAAc,IAAI,+BAAY,QAAQ,aAAa,MAAM;AAG/D,QAAI,CAAC,QAAQ,OAAO;AAChB,2BAAO,KAAK,gCAAgC;AAE5C,YAAM,mBAAm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;",
|
|
6
|
+
"names": ["chalk", "inquirer"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var run_exports = {};
|
|
29
|
+
__export(run_exports, {
|
|
30
|
+
registerRunCommand: () => registerRunCommand
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(run_exports);
|
|
33
|
+
var import_logger = require("../utils/logger");
|
|
34
|
+
var import_configService = require("../services/configService");
|
|
35
|
+
var import_farseerService = require("../services/farseerService");
|
|
36
|
+
var import_farseerFactory = require("../services/farseerFactory");
|
|
37
|
+
var import_helpers = require("../utils/helpers");
|
|
38
|
+
var fs = __toESM(require("fs"));
|
|
39
|
+
var path = __toESM(require("path"));
|
|
40
|
+
var import_child_process = require("child_process");
|
|
41
|
+
function findScriptRecursively(baseDir, scriptName) {
|
|
42
|
+
if (!fs.existsSync(baseDir)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const search = (dir, relativePath = "") => {
|
|
46
|
+
const items = fs.readdirSync(dir, { withFileTypes: true });
|
|
47
|
+
for (const item of items) {
|
|
48
|
+
const itemRelPath = relativePath ? `${relativePath}/${item.name}` : item.name;
|
|
49
|
+
if (item.isFile() && item.name === scriptName) {
|
|
50
|
+
return itemRelPath;
|
|
51
|
+
}
|
|
52
|
+
if (item.isDirectory()) {
|
|
53
|
+
const found = search(path.join(dir, item.name), itemRelPath);
|
|
54
|
+
if (found) return found;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
};
|
|
59
|
+
return search(baseDir);
|
|
60
|
+
}
|
|
61
|
+
async function getRunCredentials(tenant, tenantId) {
|
|
62
|
+
const credential = (0, import_configService.getCredential)(tenant);
|
|
63
|
+
if (credential) {
|
|
64
|
+
return {
|
|
65
|
+
tenantId: credential.tenantId,
|
|
66
|
+
apiKey: credential.apiKey,
|
|
67
|
+
basePath: credential.basePath
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const auth = (0, import_configService.getUserAuth)();
|
|
71
|
+
if (!auth) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
if (!(0, import_configService.isUserAuthValid)()) {
|
|
75
|
+
import_logger.logger.dim("Token expired, refreshing...");
|
|
76
|
+
const refreshed = await (0, import_farseerService.refreshAccessToken)(auth.refreshToken, auth.realm || "master");
|
|
77
|
+
if (!refreshed) {
|
|
78
|
+
import_logger.logger.warning("Could not refresh token. Please login again with: farseer login");
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
(0, import_configService.setUserAuth)({
|
|
82
|
+
accessToken: refreshed.accessToken,
|
|
83
|
+
refreshToken: refreshed.refreshToken,
|
|
84
|
+
expiresAt: new Date(Date.now() + refreshed.expiresIn * 1e3).toISOString(),
|
|
85
|
+
realm: auth.realm
|
|
86
|
+
});
|
|
87
|
+
import_logger.logger.success("Token refreshed");
|
|
88
|
+
}
|
|
89
|
+
const updatedAuth = (0, import_configService.getUserAuth)();
|
|
90
|
+
if (!updatedAuth) return null;
|
|
91
|
+
return {
|
|
92
|
+
tenantId: tenantId || tenant,
|
|
93
|
+
accessToken: updatedAuth.accessToken,
|
|
94
|
+
basePath: (0, import_configService.generateBasePath)(tenant)
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function collectArgs(value, previous) {
|
|
98
|
+
return previous.concat([value]);
|
|
99
|
+
}
|
|
100
|
+
function registerRunCommand(program) {
|
|
101
|
+
program.command("run <args...>").description("Run an app locally with injected credentials").option("--tenant-id <id>", "Tenant ID for env variables (defaults to tenant name)").option("--arg <value>", 'Pass argument in format "Name=Value" (can be used multiple times)', collectArgs, []).action(async (args, options) => {
|
|
102
|
+
const { tenant, appName } = (0, import_helpers.parseAppArgs)(args);
|
|
103
|
+
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(tenant, options.tenantId);
|
|
104
|
+
if (!clientResult) {
|
|
105
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
const api = clientResult.client;
|
|
109
|
+
import_logger.logger.info(`Loading app: ${appName}...`);
|
|
110
|
+
const app = await api.getAppByName(appName);
|
|
111
|
+
if (!app) {
|
|
112
|
+
import_logger.logger.error(`App not found: ${appName}`);
|
|
113
|
+
import_logger.logger.dim("List available apps with: farseer apps " + tenant);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
if (!app.mainScriptFileId || app.scriptFiles.length === 0) {
|
|
117
|
+
import_logger.logger.error(`App "${appName}" has no scripts configured.`);
|
|
118
|
+
import_logger.logger.dim('Configure the app with: farseer app configure "' + appName + '" --entrypoint <script>');
|
|
119
|
+
process.exit(1);
|
|
120
|
+
}
|
|
121
|
+
const mainScript = app.scriptFiles.find((s) => s.id === app.mainScriptFileId);
|
|
122
|
+
if (!mainScript) {
|
|
123
|
+
import_logger.logger.error(`Entrypoint script not found for app "${appName}".`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
let scriptName = mainScript.name;
|
|
127
|
+
if (scriptName.toLowerCase().startsWith("scripts/")) {
|
|
128
|
+
scriptName = scriptName.substring("scripts/".length);
|
|
129
|
+
}
|
|
130
|
+
const credentials = await getRunCredentials(tenant, options.tenantId);
|
|
131
|
+
if (!credentials) {
|
|
132
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
const tenantDir = (0, import_helpers.getTenantDir)(tenant);
|
|
136
|
+
const srcDir = (0, import_helpers.getTenantSrcDir)(tenant);
|
|
137
|
+
const filesDir = (0, import_helpers.getTenantFilesDir)(tenant);
|
|
138
|
+
let scriptPath = path.resolve(srcDir, scriptName);
|
|
139
|
+
let relativeScriptPath = `files/Scripts/${scriptName}`;
|
|
140
|
+
if (!fs.existsSync(scriptPath)) {
|
|
141
|
+
const foundPath = findScriptRecursively(filesDir, path.basename(scriptName));
|
|
142
|
+
if (foundPath) {
|
|
143
|
+
scriptPath = path.resolve(filesDir, foundPath);
|
|
144
|
+
relativeScriptPath = `files/${foundPath}`;
|
|
145
|
+
import_logger.logger.dim(`Found script at: ${foundPath}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (!fs.existsSync(scriptPath)) {
|
|
149
|
+
import_logger.logger.error(`Script not found locally: ${scriptPath}`);
|
|
150
|
+
import_logger.logger.dim('Run "farseer pull ' + tenant + '" to download scripts first.');
|
|
151
|
+
process.exit(1);
|
|
152
|
+
}
|
|
153
|
+
const nodeModulesPath = path.join(tenantDir, "node_modules");
|
|
154
|
+
if (!fs.existsSync(nodeModulesPath)) {
|
|
155
|
+
import_logger.logger.error(`Dependencies not installed for ${tenant}`);
|
|
156
|
+
import_logger.logger.dim(`Run: farseer install ${tenant}`);
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
const appArgs = {};
|
|
160
|
+
for (const arg of app.expectedArguments) {
|
|
161
|
+
appArgs[arg.name] = arg.defaultValue;
|
|
162
|
+
}
|
|
163
|
+
for (const argStr of options.arg) {
|
|
164
|
+
const eqIndex = argStr.indexOf("=");
|
|
165
|
+
if (eqIndex === -1) {
|
|
166
|
+
import_logger.logger.error(`Invalid argument format: ${argStr}`);
|
|
167
|
+
import_logger.logger.dim('Use format: --arg "Name=Value"');
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
const name = argStr.substring(0, eqIndex);
|
|
171
|
+
const value = argStr.substring(eqIndex + 1);
|
|
172
|
+
appArgs[name] = value;
|
|
173
|
+
}
|
|
174
|
+
const authType = credentials.apiKey ? "API key" : "access token";
|
|
175
|
+
import_logger.logger.info(`Running app "${app.name}" (${scriptName}) for tenant ${tenant} (using ${authType})...`);
|
|
176
|
+
if (Object.keys(appArgs).length > 0) {
|
|
177
|
+
import_logger.logger.dim("Arguments:");
|
|
178
|
+
for (const [key, value] of Object.entries(appArgs)) {
|
|
179
|
+
import_logger.logger.dim(` ${key}: ${value}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
console.log();
|
|
183
|
+
const envVars = {
|
|
184
|
+
...process.env,
|
|
185
|
+
TENANT_ID: credentials.tenantId,
|
|
186
|
+
FARSEER_URL: credentials.basePath
|
|
187
|
+
};
|
|
188
|
+
if (credentials.apiKey) {
|
|
189
|
+
envVars.FARSEER_API_KEY = credentials.apiKey;
|
|
190
|
+
}
|
|
191
|
+
if (credentials.accessToken) {
|
|
192
|
+
envVars.FARSEER_ACCESS_TOKEN = credentials.accessToken;
|
|
193
|
+
}
|
|
194
|
+
const cmdArgs = [];
|
|
195
|
+
for (const arg of app.expectedArguments) {
|
|
196
|
+
cmdArgs.push(appArgs[arg.name] ?? arg.defaultValue);
|
|
197
|
+
}
|
|
198
|
+
const quotedScriptPath = `"${relativeScriptPath}"`;
|
|
199
|
+
const child = (0, import_child_process.spawn)("npx", ["tsx", quotedScriptPath, ...cmdArgs], {
|
|
200
|
+
stdio: "inherit",
|
|
201
|
+
cwd: tenantDir,
|
|
202
|
+
shell: true,
|
|
203
|
+
env: envVars
|
|
204
|
+
});
|
|
205
|
+
child.on("close", (code) => {
|
|
206
|
+
if (code !== 0) {
|
|
207
|
+
import_logger.logger.error(`Script exited with code ${code}`);
|
|
208
|
+
process.exit(code || 1);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
child.on("error", (err) => {
|
|
212
|
+
import_logger.logger.error(`Failed to run script: ${err.message}`);
|
|
213
|
+
import_logger.logger.dim("Make sure tsx is installed: npm install -g tsx");
|
|
214
|
+
process.exit(1);
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
program.command("run-script <args...>").description("Run a script directly (without app wrapper)").option("--tenant-id <id>", "Tenant ID for env variables (defaults to tenant name)").action(async (args, options) => {
|
|
218
|
+
let { tenant, appName: script } = (0, import_helpers.parseAppArgs)(args);
|
|
219
|
+
const credentials = await getRunCredentials(tenant, options.tenantId);
|
|
220
|
+
if (!credentials) {
|
|
221
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
222
|
+
process.exit(1);
|
|
223
|
+
}
|
|
224
|
+
if (script.toLowerCase().startsWith("scripts/")) {
|
|
225
|
+
script = script.substring("scripts/".length);
|
|
226
|
+
}
|
|
227
|
+
const tenantDir = (0, import_helpers.getTenantDir)(tenant);
|
|
228
|
+
const srcDir = (0, import_helpers.getTenantSrcDir)(tenant);
|
|
229
|
+
const filesDir = (0, import_helpers.getTenantFilesDir)(tenant);
|
|
230
|
+
let scriptPath = path.resolve(srcDir, script);
|
|
231
|
+
let relativeScriptPath = `files/Scripts/${script}`;
|
|
232
|
+
if (!fs.existsSync(scriptPath)) {
|
|
233
|
+
const foundPath = findScriptRecursively(filesDir, path.basename(script));
|
|
234
|
+
if (foundPath) {
|
|
235
|
+
scriptPath = path.resolve(filesDir, foundPath);
|
|
236
|
+
relativeScriptPath = `files/${foundPath}`;
|
|
237
|
+
import_logger.logger.dim(`Found script at: ${foundPath}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (!fs.existsSync(scriptPath)) {
|
|
241
|
+
import_logger.logger.error(`Script not found: ${scriptPath}`);
|
|
242
|
+
process.exit(1);
|
|
243
|
+
}
|
|
244
|
+
const nodeModulesPath = path.join(tenantDir, "node_modules");
|
|
245
|
+
if (!fs.existsSync(nodeModulesPath)) {
|
|
246
|
+
import_logger.logger.error(`Dependencies not installed for ${tenant}`);
|
|
247
|
+
import_logger.logger.dim(`Run: farseer install ${tenant}`);
|
|
248
|
+
process.exit(1);
|
|
249
|
+
}
|
|
250
|
+
const authType = credentials.apiKey ? "API key" : "access token";
|
|
251
|
+
import_logger.logger.info(`Running ${script} for tenant ${tenant} (using ${authType})...`);
|
|
252
|
+
console.log();
|
|
253
|
+
const envVars = {
|
|
254
|
+
...process.env,
|
|
255
|
+
TENANT_ID: credentials.tenantId,
|
|
256
|
+
FARSEER_URL: credentials.basePath
|
|
257
|
+
};
|
|
258
|
+
if (credentials.apiKey) {
|
|
259
|
+
envVars.FARSEER_API_KEY = credentials.apiKey;
|
|
260
|
+
}
|
|
261
|
+
if (credentials.accessToken) {
|
|
262
|
+
envVars.FARSEER_ACCESS_TOKEN = credentials.accessToken;
|
|
263
|
+
}
|
|
264
|
+
const quotedScriptPath = `"${relativeScriptPath}"`;
|
|
265
|
+
const child = (0, import_child_process.spawn)("npx", ["tsx", quotedScriptPath], {
|
|
266
|
+
stdio: "inherit",
|
|
267
|
+
cwd: tenantDir,
|
|
268
|
+
shell: true,
|
|
269
|
+
env: envVars
|
|
270
|
+
});
|
|
271
|
+
child.on("close", (code) => {
|
|
272
|
+
if (code !== 0) {
|
|
273
|
+
import_logger.logger.error(`Script exited with code ${code}`);
|
|
274
|
+
process.exit(code || 1);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
child.on("error", (err) => {
|
|
278
|
+
import_logger.logger.error(`Failed to run script: ${err.message}`);
|
|
279
|
+
import_logger.logger.dim("Make sure tsx is installed: npm install -g tsx");
|
|
280
|
+
process.exit(1);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
285
|
+
0 && (module.exports = {
|
|
286
|
+
registerRunCommand
|
|
287
|
+
});
|
|
288
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/run.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport { getCredential, getUserAuth, isUserAuthValid, setUserAuth, generateBasePath } from '../services/configService';\nimport { refreshAccessToken } from '../services/farseerService';\nimport { getFarseerClientWithFallback, showLoginPrompt, IFarseerClient } from '../services/farseerFactory';\nimport { getTenantDir, getTenantSrcDir, getTenantFilesDir, parseAppArgs } from '../utils/helpers';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { spawn } from 'child_process';\n\n/**\n * Find a script file recursively in a directory.\n * Returns the relative path from baseDir if found, null otherwise.\n */\nfunction findScriptRecursively(baseDir: string, scriptName: string): string | null {\n if (!fs.existsSync(baseDir)) {\n return null;\n }\n\n const search = (dir: string, relativePath: string = ''): string | null => {\n const items = fs.readdirSync(dir, { withFileTypes: true });\n\n for (const item of items) {\n const itemRelPath = relativePath ? `${relativePath}/${item.name}` : item.name;\n\n if (item.isFile() && item.name === scriptName) {\n return itemRelPath;\n }\n\n if (item.isDirectory()) {\n const found = search(path.join(dir, item.name), itemRelPath);\n if (found) return found;\n }\n }\n\n return null;\n };\n\n return search(baseDir);\n}\n\ninterface RunCredentials {\n tenantId: string;\n apiKey?: string;\n accessToken?: string;\n basePath: string;\n}\n\nasync function getRunCredentials(tenant: string, tenantId?: string): Promise<RunCredentials | null> {\n // First try API key config\n const credential = getCredential(tenant);\n if (credential) {\n return {\n tenantId: credential.tenantId,\n apiKey: credential.apiKey,\n basePath: credential.basePath,\n };\n }\n\n // Try user auth (browser login)\n const auth = getUserAuth();\n if (!auth) {\n return null;\n }\n\n // Check if token needs refresh\n if (!isUserAuthValid()) {\n logger.dim('Token expired, refreshing...');\n const refreshed = await refreshAccessToken(auth.refreshToken, auth.realm || 'master');\n if (!refreshed) {\n logger.warning('Could not refresh token. Please login again with: farseer login');\n return null;\n }\n // Save refreshed token\n setUserAuth({\n accessToken: refreshed.accessToken,\n refreshToken: refreshed.refreshToken,\n expiresAt: new Date(Date.now() + refreshed.expiresIn * 1000).toISOString(),\n realm: auth.realm,\n });\n logger.success('Token refreshed');\n }\n\n const updatedAuth = getUserAuth();\n if (!updatedAuth) return null;\n\n // Use tenant name as organisation for basePath, tenantId for TENANT_ID env var\n return {\n tenantId: tenantId || tenant,\n accessToken: updatedAuth.accessToken,\n basePath: generateBasePath(tenant),\n };\n}\n\n// Helper to collect multiple --arg options\nfunction collectArgs(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n\nexport function registerRunCommand(program: Command): void {\n program\n .command('run <args...>')\n .description('Run an app locally with injected credentials')\n .option('--tenant-id <id>', 'Tenant ID for env variables (defaults to tenant name)')\n .option('--arg <value>', 'Pass argument in format \"Name=Value\" (can be used multiple times)', collectArgs, [])\n .action(async (args: string[], options) => {\n const { tenant, appName } = parseAppArgs(args);\n // First, get the app details to find the entrypoint script\n const clientResult = await getFarseerClientWithFallback(tenant, options.tenantId);\n\n if (!clientResult) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api: IFarseerClient = clientResult.client;\n\n // Find the app\n logger.info(`Loading app: ${appName}...`);\n const app = await api.getAppByName(appName);\n\n if (!app) {\n logger.error(`App not found: ${appName}`);\n logger.dim('List available apps with: farseer apps ' + tenant);\n process.exit(1);\n }\n\n if (!app.mainScriptFileId || app.scriptFiles.length === 0) {\n logger.error(`App \"${appName}\" has no scripts configured.`);\n logger.dim('Configure the app with: farseer app configure \"' + appName + '\" --entrypoint <script>');\n process.exit(1);\n }\n\n // Find the entrypoint script name\n const mainScript = app.scriptFiles.find(s => s.id === app.mainScriptFileId);\n if (!mainScript) {\n logger.error(`Entrypoint script not found for app \"${appName}\".`);\n process.exit(1);\n }\n\n // Normalize script name - handle both \"test.ts\" and \"Scripts/test.ts\" formats\n let scriptName = mainScript.name;\n if (scriptName.toLowerCase().startsWith('scripts/')) {\n scriptName = scriptName.substring('scripts/'.length);\n }\n\n // Get credentials for running\n const credentials = await getRunCredentials(tenant, options.tenantId);\n\n if (!credentials) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const tenantDir = getTenantDir(tenant);\n const srcDir = getTenantSrcDir(tenant);\n const filesDir = getTenantFilesDir(tenant);\n\n // Script path is relative to files/Scripts/ folder\n // First try direct path, then search recursively if not found\n let scriptPath = path.resolve(srcDir, scriptName);\n let relativeScriptPath = `files/Scripts/${scriptName}`;\n\n if (!fs.existsSync(scriptPath)) {\n // Try to find the script recursively in the files directory\n const foundPath = findScriptRecursively(filesDir, path.basename(scriptName));\n if (foundPath) {\n scriptPath = path.resolve(filesDir, foundPath);\n relativeScriptPath = `files/${foundPath}`;\n logger.dim(`Found script at: ${foundPath}`);\n }\n }\n\n if (!fs.existsSync(scriptPath)) {\n logger.error(`Script not found locally: ${scriptPath}`);\n logger.dim('Run \"farseer pull ' + tenant + '\" to download scripts first.');\n process.exit(1);\n }\n\n // Check if node_modules exists\n const nodeModulesPath = path.join(tenantDir, 'node_modules');\n if (!fs.existsSync(nodeModulesPath)) {\n logger.error(`Dependencies not installed for ${tenant}`);\n logger.dim(`Run: farseer install ${tenant}`);\n process.exit(1);\n }\n\n // Parse arguments\n const appArgs: Record<string, string> = {};\n\n // Start with default values from app config\n for (const arg of app.expectedArguments) {\n appArgs[arg.name] = arg.defaultValue;\n }\n\n // Override with provided arguments\n for (const argStr of options.arg) {\n const eqIndex = argStr.indexOf('=');\n if (eqIndex === -1) {\n logger.error(`Invalid argument format: ${argStr}`);\n logger.dim('Use format: --arg \"Name=Value\"');\n process.exit(1);\n }\n const name = argStr.substring(0, eqIndex);\n const value = argStr.substring(eqIndex + 1);\n appArgs[name] = value;\n }\n\n const authType = credentials.apiKey ? 'API key' : 'access token';\n logger.info(`Running app \"${app.name}\" (${scriptName}) for tenant ${tenant} (using ${authType})...`);\n\n // Show arguments being used\n if (Object.keys(appArgs).length > 0) {\n logger.dim('Arguments:');\n for (const [key, value] of Object.entries(appArgs)) {\n logger.dim(` ${key}: ${value}`);\n }\n }\n console.log();\n\n // Build environment variables based on auth type\n const envVars: Record<string, string> = {\n ...process.env as Record<string, string>,\n TENANT_ID: credentials.tenantId,\n FARSEER_URL: credentials.basePath,\n };\n\n if (credentials.apiKey) {\n envVars.FARSEER_API_KEY = credentials.apiKey;\n }\n if (credentials.accessToken) {\n envVars.FARSEER_ACCESS_TOKEN = credentials.accessToken;\n }\n\n // Build command line arguments from app arguments (in order)\n const cmdArgs: string[] = [];\n for (const arg of app.expectedArguments) {\n cmdArgs.push(appArgs[arg.name] ?? arg.defaultValue);\n }\n\n // Run with credentials injected via environment variables, arguments via command line\n // Quote the script path to handle spaces in folder names\n const quotedScriptPath = `\"${relativeScriptPath}\"`;\n const child = spawn('npx', ['tsx', quotedScriptPath, ...cmdArgs], {\n stdio: 'inherit',\n cwd: tenantDir,\n shell: true,\n env: envVars,\n });\n\n child.on('close', (code) => {\n if (code !== 0) {\n logger.error(`Script exited with code ${code}`);\n process.exit(code || 1);\n }\n });\n\n child.on('error', (err) => {\n logger.error(`Failed to run script: ${err.message}`);\n logger.dim('Make sure tsx is installed: npm install -g tsx');\n process.exit(1);\n });\n });\n\n // Keep the old script-based run as a separate command\n program\n .command('run-script <args...>')\n .description('Run a script directly (without app wrapper)')\n .option('--tenant-id <id>', 'Tenant ID for env variables (defaults to tenant name)')\n .action(async (args: string[], options) => {\n let { tenant, appName: script } = parseAppArgs(args);\n const credentials = await getRunCredentials(tenant, options.tenantId);\n\n if (!credentials) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n // Normalize script path - strip Scripts/ prefix if present\n if (script.toLowerCase().startsWith('scripts/')) {\n script = script.substring('scripts/'.length);\n }\n\n const tenantDir = getTenantDir(tenant);\n const srcDir = getTenantSrcDir(tenant);\n const filesDir = getTenantFilesDir(tenant);\n\n // Script path is relative to files/Scripts/ folder\n // First try direct path, then search recursively if not found\n let scriptPath = path.resolve(srcDir, script);\n let relativeScriptPath = `files/Scripts/${script}`;\n\n if (!fs.existsSync(scriptPath)) {\n // Try to find the script recursively in the files directory\n const foundPath = findScriptRecursively(filesDir, path.basename(script));\n if (foundPath) {\n scriptPath = path.resolve(filesDir, foundPath);\n relativeScriptPath = `files/${foundPath}`;\n logger.dim(`Found script at: ${foundPath}`);\n }\n }\n\n if (!fs.existsSync(scriptPath)) {\n logger.error(`Script not found: ${scriptPath}`);\n process.exit(1);\n }\n\n // Check if node_modules exists\n const nodeModulesPath = path.join(tenantDir, 'node_modules');\n if (!fs.existsSync(nodeModulesPath)) {\n logger.error(`Dependencies not installed for ${tenant}`);\n logger.dim(`Run: farseer install ${tenant}`);\n process.exit(1);\n }\n\n const authType = credentials.apiKey ? 'API key' : 'access token';\n logger.info(`Running ${script} for tenant ${tenant} (using ${authType})...`);\n console.log();\n\n // Build environment variables based on auth type\n const envVars: Record<string, string> = {\n ...process.env as Record<string, string>,\n TENANT_ID: credentials.tenantId,\n FARSEER_URL: credentials.basePath,\n };\n\n if (credentials.apiKey) {\n envVars.FARSEER_API_KEY = credentials.apiKey;\n }\n if (credentials.accessToken) {\n envVars.FARSEER_ACCESS_TOKEN = credentials.accessToken;\n }\n\n // Run with credentials injected via environment variables\n // Quote the script path to handle spaces in folder names\n const quotedScriptPath = `\"${relativeScriptPath}\"`;\n const child = spawn('npx', ['tsx', quotedScriptPath], {\n stdio: 'inherit',\n cwd: tenantDir,\n shell: true,\n env: envVars,\n });\n\n child.on('close', (code) => {\n if (code !== 0) {\n logger.error(`Script exited with code ${code}`);\n process.exit(code || 1);\n }\n });\n\n child.on('error', (err) => {\n logger.error(`Failed to run script: ${err.message}`);\n logger.dim('Make sure tsx is installed: npm install -g tsx');\n process.exit(1);\n });\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,2BAA2F;AAC3F,4BAAmC;AACnC,4BAA8E;AAC9E,qBAA+E;AAC/E,SAAoB;AACpB,WAAsB;AACtB,2BAAsB;AAMtB,SAAS,sBAAsB,SAAiB,YAAmC;AAC/E,MAAI,CAAC,GAAG,WAAW,OAAO,GAAG;AACzB,WAAO;AAAA,EACX;AAEA,QAAM,SAAS,CAAC,KAAa,eAAuB,OAAsB;AACtE,UAAM,QAAQ,GAAG,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC;AAEzD,eAAW,QAAQ,OAAO;AACtB,YAAM,cAAc,eAAe,GAAG,YAAY,IAAI,KAAK,IAAI,KAAK,KAAK;AAEzE,UAAI,KAAK,OAAO,KAAK,KAAK,SAAS,YAAY;AAC3C,eAAO;AAAA,MACX;AAEA,UAAI,KAAK,YAAY,GAAG;AACpB,cAAM,QAAQ,OAAO,KAAK,KAAK,KAAK,KAAK,IAAI,GAAG,WAAW;AAC3D,YAAI,MAAO,QAAO;AAAA,MACtB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AAEA,SAAO,OAAO,OAAO;AACzB;AASA,e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