farseer-cli 1.14.1 → 1.14.2
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/config.js +4 -3
- package/dist/commands/config.js.map +2 -2
- package/dist/commands/install.js +5 -0
- package/dist/commands/install.js.map +2 -2
- package/dist/commands/login.js +2 -2
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/pull.js +2 -1
- package/dist/commands/pull.js.map +2 -2
- package/dist/commands/run.js +9 -0
- package/dist/commands/run.js.map +2 -2
- package/dist/index.js +7 -2
- package/dist/index.js.map +2 -2
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/authTools.js +5 -3
- package/dist/mcp/tools/authTools.js.map +2 -2
- package/dist/mcp/tools/cellTools.js +3 -2
- package/dist/mcp/tools/cellTools.js.map +2 -2
- package/dist/mcp/tools/dashboardTools.js +23 -18
- package/dist/mcp/tools/dashboardTools.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +14 -12
- package/dist/mcp/tools/dataTools.js.map +2 -2
- package/dist/mcp/tools/folderTools.js +5 -4
- package/dist/mcp/tools/folderTools.js.map +2 -2
- package/dist/mcp/tools/modelTools.js +27 -17
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/pipelineContract.js +5 -2
- package/dist/mcp/tools/pipelineContract.js.map +2 -2
- package/dist/mcp/tools/runTools.js +8 -3
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +21 -17
- package/dist/mcp/tools/sheetTools.js.map +2 -2
- package/dist/mcp/tools/syncTools.js +11 -5
- package/dist/mcp/tools/syncTools.js.map +2 -2
- package/dist/mcp/utils/registerTool.js +32 -0
- package/dist/mcp/utils/registerTool.js.map +7 -0
- package/dist/pipeline/generated-reference.json +3 -3
- package/dist/pipeline/operations.js +4 -1
- package/dist/pipeline/operations.js.map +2 -2
- package/dist/pipeline/query.js +58 -40
- package/dist/pipeline/query.js.map +2 -2
- package/dist/pipeline/queryDownloads.js +72 -0
- package/dist/pipeline/queryDownloads.js.map +7 -0
- package/dist/pipeline/queryWorker.js +8 -31
- package/dist/pipeline/queryWorker.js.map +2 -2
- package/dist/pipeline/readiness.js +15 -8
- package/dist/pipeline/readiness.js.map +2 -2
- package/dist/pipeline/reference.js +2 -1
- package/dist/pipeline/reference.js.map +2 -2
- package/dist/pipeline/runtime.js +4 -3
- package/dist/pipeline/runtime.js.map +2 -2
- package/dist/pipeline/service.js +110 -50
- package/dist/pipeline/service.js.map +2 -2
- package/dist/services/appSyncService.js.map +1 -1
- package/dist/services/configService.js +11 -4
- package/dist/services/configService.js.map +2 -2
- package/dist/services/farseerService.js +23 -0
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/modelExport.js.map +1 -1
- package/dist/utils/agentSandbox.js +35 -0
- package/dist/utils/agentSandbox.js.map +7 -0
- package/docs/pipeline-client-guide.md +2 -2
- package/package.json +1 -1
- package/skills/pipeline-authoring/SKILL.md +4 -4
package/dist/commands/config.js
CHANGED
|
@@ -49,7 +49,8 @@ Examples:
|
|
|
49
49
|
);
|
|
50
50
|
configCmd.command("set <tenant>").description("Set credentials for a tenant (use --org if org differs from tenant)").requiredOption("--api-key <key>", "API key for the tenant").option("--org <organisation>", "Organisation name if different from tenant (e.g., --org mycompany)").option("--base-path <url>", "Custom base path (overrides organisation)").option("--no-test", "Skip connection test").action(async (tenant, options) => {
|
|
51
51
|
const organisation = options.org || tenant;
|
|
52
|
-
const basePath = options.basePath || (0, import_configService.
|
|
52
|
+
const basePath = options.basePath || (0, import_configService.storedBasePath)(organisation);
|
|
53
|
+
const requestPath = options.basePath || (0, import_configService.generateBasePath)(organisation);
|
|
53
54
|
const apiKey = options.apiKey;
|
|
54
55
|
const credential = {
|
|
55
56
|
type: "apiKey",
|
|
@@ -59,10 +60,10 @@ Examples:
|
|
|
59
60
|
};
|
|
60
61
|
if (options.test !== false) {
|
|
61
62
|
import_logger.logger.info("Testing connection...");
|
|
62
|
-
const service = (0, import_credentials.buildClient)({ kind: "apiKey", credential });
|
|
63
|
+
const service = (0, import_credentials.buildClient)({ kind: "apiKey", credential: { ...credential, basePath: requestPath } });
|
|
63
64
|
const connection = await service.checkConnection();
|
|
64
65
|
if (!connection.ok) {
|
|
65
|
-
import_logger.logger.error((0, import_helpers.connectionFailureMessage)(connection.reason,
|
|
66
|
+
import_logger.logger.error((0, import_helpers.connectionFailureMessage)(connection.reason, requestPath, tenant));
|
|
66
67
|
import_logger.logger.dim(connection.message);
|
|
67
68
|
process.exit(1);
|
|
68
69
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/config.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport {\n setCredential,\n removeCredential,\n listCredentials,\n generateBasePath,\n ApiKeyCredential,\n getSyncIncludes,\n setSyncIncludes,\n SyncIncludes,\n} from '../services/configService';\nimport { buildClient } from '../services/credentials';\nimport { connectionFailureMessage, getCredentialsHint, getEnvCheckout } from '../utils/helpers';\nimport { formatClientError } from '../utils/errorFormatter';\n\nexport function registerConfigCommand(program: Command): void {\n const configCmd = program\n .command('config')\n .description('Manage Farseer CLI configuration')\n .addHelpText(\n 'after',\n `\nCommands:\n set <tenant> Set API key for a tenant\n remove <tenant> Remove credentials for a tenant\n list List all configured tenants\n show <tenant> Show full credentials (including API key)\n test <tenant> Test connection to a tenant\n include Manage extra file types to sync (beyond developer files (.ts, .js, .py, .yml, .yaml, .md, .json) non-hidden, non-blocklisted)\n\nExamples:\n $ farseer config set mycompany --api-key xxx\n $ farseer config set mycompany --api-key xxx --org myorg\n $ farseer config list\n $ farseer config test mycompany\n $ farseer config include --ext .json --folder Config\n $ farseer config include --clear\n`,\n );\n\n configCmd\n .command('set <tenant>')\n .description('Set credentials for a tenant (use --org if org differs from tenant)')\n .requiredOption('--api-key <key>', 'API key for the tenant')\n .option('--org <organisation>', 'Organisation name if different from tenant (e.g., --org mycompany)')\n .option('--base-path <url>', 'Custom base path (overrides organisation)')\n .option('--no-test', 'Skip connection test')\n .action(async (tenant, options) => {\n const organisation = options.org || tenant;\n const basePath = options.basePath || generateBasePath(organisation);\n const apiKey = options.apiKey;\n\n const credential: ApiKeyCredential = {\n type: 'apiKey',\n tenantId: tenant,\n apiKey: apiKey,\n basePath: basePath,\n };\n\n if (options.test !== false) {\n logger.info('Testing connection...');\n const service = buildClient({ kind: 'apiKey', credential });\n const connection = await service.checkConnection();\n\n if (!connection.ok) {\n logger.error(connectionFailureMessage(connection.reason, basePath, tenant));\n logger.dim(connection.message);\n process.exit(1);\n }\n }\n\n setCredential(tenant, credential);\n logger.success(`Credentials saved for tenant: ${tenant}`);\n logger.table([\n { label: 'Tenant ID', value: tenant },\n { label: 'Base Path', value: basePath },\n { label: 'API Key', value: apiKey.substring(0, 8) + '...' },\n ]);\n });\n\n configCmd\n .command('remove <tenant>')\n .description('Remove credentials for a tenant')\n .action((tenant) => {\n const removed = removeCredential(tenant);\n if (removed) {\n logger.success(`Removed credentials for tenant: ${tenant}`);\n } else {\n logger.warning(`No credentials found for tenant: ${tenant}`);\n }\n });\n\n configCmd\n .command('list')\n .description('List all configured tenants')\n .action(() => {\n const credentials = listCredentials();\n const tenants = Object.keys(credentials);\n\n if (tenants.length === 0) {\n logger.info('No tenants configured.');\n logger.dim('Use \"farseer config set <tenant> --api-key <key>\" to add one.');\n return;\n }\n\n logger.header('Configured Tenants');\n\n for (const tenant of tenants) {\n const cred = credentials[tenant];\n console.log(` ${tenant}`);\n logger.dim(` Base: ${cred.basePath}`);\n logger.dim(` Key: ${cred.apiKey.substring(0, 8)}...`);\n console.log();\n }\n });\n\n configCmd\n .command('show <tenant>')\n .description('Show full credentials for a tenant (including API key)')\n .action((tenant) => {\n const credentials = listCredentials();\n const cred = credentials[tenant];\n\n if (!cred) {\n logger.error(`No credentials found for tenant: ${tenant}`);\n logger.dim(getCredentialsHint(tenant));\n process.exit(1);\n }\n\n logger.header(`Credentials for ${tenant}`);\n logger.table([\n { label: 'Tenant ID', value: tenant },\n { label: 'Base Path', value: cred.basePath },\n { label: 'API Key', value: cred.apiKey },\n ]);\n });\n\n configCmd\n .command('test <tenant>')\n .description('Test connection to a tenant')\n .action(async (tenant) => {\n const credentials = listCredentials();\n const cred = credentials[tenant];\n\n if (!cred) {\n logger.error(`No credentials found for tenant: ${tenant}`);\n logger.dim(getCredentialsHint(tenant));\n process.exit(1);\n }\n\n logger.info(`Testing connection to ${tenant}...`);\n\n const service = buildClient({ kind: 'apiKey', credential: cred });\n const connection = await service.checkConnection();\n\n if (connection.ok) {\n logger.success(`Connection successful!`);\n\n // A failed listing is not an absent folder, and it has to be caught\n // here: an escaped rejection is written to the log file and never\n // shown, so the command would exit 0 reporting success.\n try {\n const filesFolder = await service.getFilesFolder();\n if (filesFolder) {\n logger.dim('Files folder found.');\n } else {\n logger.warning('Files folder not found. It will be created on first push.');\n }\n } catch (error) {\n logger.error('Connected, but could not read the tenant root.');\n logger.dim(await formatClientError(error));\n process.exit(1);\n }\n } else {\n logger.error(connectionFailureMessage(connection.reason, cred.basePath, tenant));\n logger.dim(connection.message);\n process.exit(1);\n }\n });\n\n configCmd\n .command('include')\n .description(\n 'Manage extra file types to sync (beyond developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist). Data files (.csv, .xlsx, .parquet, \u2026) are backend-accepted but excluded from default \u2014 opt in via --ext .csv.',\n )\n .option('--ext <extension>', 'Add extra file extension (repeatable, e.g., --ext .json)', collect, [])\n .option('--folder <path>', 'Add folder to sync all files from (repeatable)', collect, [])\n .option('--remove-ext <extension>', 'Remove an extension from includes', collect, [])\n .option('--remove-folder <path>', 'Remove a folder from includes', collect, [])\n .option('--clear', 'Remove all sync includes for current tenant')\n .option('--tenant <tenant>', 'Tenant to configure (defaults to FARSEER_TENANT)')\n .action((options) => {\n // Via getEnvCheckout (not the raw env) so the resolved target gets\n // echoed like every other command \u2014 this writes per-tenant config,\n // so it shouldn't be the one command that never names its tenant.\n const tenant = options.tenant || getEnvCheckout()?.tenant;\n if (!tenant) {\n logger.error('No tenant specified.');\n logger.dim('Use --tenant <name>, or set it for this shell: export FARSEER_TENANT=<tenant>');\n process.exit(1);\n }\n\n const hasModification =\n options.ext.length > 0 ||\n options.folder.length > 0 ||\n options.removeExt.length > 0 ||\n options.removeFolder.length > 0 ||\n options.clear;\n\n // If no flags: show current includes\n if (!hasModification) {\n const includes = getSyncIncludes(tenant);\n if (!includes) {\n logger.info(`No sync includes configured for ${tenant}.`);\n logger.dim(\n 'Default sync: developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist (node_modules/, dist/, \u2026). Data files (.csv, .xlsx, .parquet, \u2026) are backend-accepted but excluded \u2014 opt in via --ext.',\n );\n logger.dim('');\n logger.dim('Add extra extensions: farseer config include --ext .csv --ext .parquet');\n logger.dim('Add extra folders: farseer config include --folder dist --folder \".vscode\"');\n return;\n }\n\n logger.header(`Sync includes for ${tenant}`);\n if (includes.extensions && includes.extensions.length > 0) {\n console.log(` Extensions: ${includes.extensions.join(', ')}`);\n }\n if (includes.folders && includes.folders.length > 0) {\n console.log(` Folders: ${includes.folders.join(', ')}`);\n }\n logger.dim('');\n logger.dim(\n 'These are synced in addition to the default scope (developer files (.ts, .js, .py, .yml, .yaml, .md, .json) non-hidden, non-blocklisted).',\n );\n return;\n }\n\n // Handle --clear\n if (options.clear) {\n setSyncIncludes(tenant, {});\n logger.success(`Cleared all sync includes for ${tenant}.`);\n return;\n }\n\n // Load current includes\n const current = getSyncIncludes(tenant) || {};\n const extensions = new Set(current.extensions || []);\n const folders = new Set(current.folders || []);\n\n // Add extensions (normalize: ensure leading dot, lowercase)\n for (const ext of options.ext as string[]) {\n const normalized = ext.startsWith('.') ? ext.toLowerCase() : `.${ext.toLowerCase()}`;\n extensions.add(normalized);\n }\n\n // Add folders\n for (const folder of options.folder as string[]) {\n folders.add(folder);\n }\n\n // Remove extensions\n for (const ext of options.removeExt as string[]) {\n const normalized = ext.startsWith('.') ? ext.toLowerCase() : `.${ext.toLowerCase()}`;\n extensions.delete(normalized);\n }\n\n // Remove folders\n for (const folder of options.removeFolder as string[]) {\n folders.delete(folder);\n }\n\n const updated: SyncIncludes = {\n extensions: extensions.size > 0 ? [...extensions] : undefined,\n folders: folders.size > 0 ? [...folders] : undefined,\n };\n\n setSyncIncludes(tenant, updated);\n\n // Show result\n const includes = getSyncIncludes(tenant);\n if (!includes) {\n logger.success(`Sync includes cleared for ${tenant}.`);\n } else {\n logger.success(`Updated sync includes for ${tenant}:`);\n if (includes.extensions && includes.extensions.length > 0) {\n console.log(` Extensions: ${includes.extensions.join(', ')}`);\n }\n if (includes.folders && includes.folders.length > 0) {\n console.log(` Folders: ${includes.folders.join(', ')}`);\n }\n }\n });\n}\n\nfunction collect(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport {\n setCredential,\n removeCredential,\n listCredentials,\n generateBasePath,\n storedBasePath,\n ApiKeyCredential,\n getSyncIncludes,\n setSyncIncludes,\n SyncIncludes,\n} from '../services/configService';\nimport { buildClient } from '../services/credentials';\nimport { connectionFailureMessage, getCredentialsHint, getEnvCheckout } from '../utils/helpers';\nimport { formatClientError } from '../utils/errorFormatter';\n\nexport function registerConfigCommand(program: Command): void {\n const configCmd = program\n .command('config')\n .description('Manage Farseer CLI configuration')\n .addHelpText(\n 'after',\n `\nCommands:\n set <tenant> Set API key for a tenant\n remove <tenant> Remove credentials for a tenant\n list List all configured tenants\n show <tenant> Show full credentials (including API key)\n test <tenant> Test connection to a tenant\n include Manage extra file types to sync (beyond developer files (.ts, .js, .py, .yml, .yaml, .md, .json) non-hidden, non-blocklisted)\n\nExamples:\n $ farseer config set mycompany --api-key xxx\n $ farseer config set mycompany --api-key xxx --org myorg\n $ farseer config list\n $ farseer config test mycompany\n $ farseer config include --ext .json --folder Config\n $ farseer config include --clear\n`,\n );\n\n configCmd\n .command('set <tenant>')\n .description('Set credentials for a tenant (use --org if org differs from tenant)')\n .requiredOption('--api-key <key>', 'API key for the tenant')\n .option('--org <organisation>', 'Organisation name if different from tenant (e.g., --org mycompany)')\n .option('--base-path <url>', 'Custom base path (overrides organisation)')\n .option('--no-test', 'Skip connection test')\n .action(async (tenant, options) => {\n const organisation = options.org || tenant;\n const basePath = options.basePath || storedBasePath(organisation);\n const requestPath = options.basePath || generateBasePath(organisation);\n const apiKey = options.apiKey;\n\n const credential: ApiKeyCredential = {\n type: 'apiKey',\n tenantId: tenant,\n apiKey: apiKey,\n basePath: basePath,\n };\n\n if (options.test !== false) {\n logger.info('Testing connection...');\n const service = buildClient({ kind: 'apiKey', credential: { ...credential, basePath: requestPath } });\n const connection = await service.checkConnection();\n\n if (!connection.ok) {\n logger.error(connectionFailureMessage(connection.reason, requestPath, tenant));\n logger.dim(connection.message);\n process.exit(1);\n }\n }\n\n setCredential(tenant, credential);\n logger.success(`Credentials saved for tenant: ${tenant}`);\n logger.table([\n { label: 'Tenant ID', value: tenant },\n { label: 'Base Path', value: basePath },\n { label: 'API Key', value: apiKey.substring(0, 8) + '...' },\n ]);\n });\n\n configCmd\n .command('remove <tenant>')\n .description('Remove credentials for a tenant')\n .action((tenant) => {\n const removed = removeCredential(tenant);\n if (removed) {\n logger.success(`Removed credentials for tenant: ${tenant}`);\n } else {\n logger.warning(`No credentials found for tenant: ${tenant}`);\n }\n });\n\n configCmd\n .command('list')\n .description('List all configured tenants')\n .action(() => {\n const credentials = listCredentials();\n const tenants = Object.keys(credentials);\n\n if (tenants.length === 0) {\n logger.info('No tenants configured.');\n logger.dim('Use \"farseer config set <tenant> --api-key <key>\" to add one.');\n return;\n }\n\n logger.header('Configured Tenants');\n\n for (const tenant of tenants) {\n const cred = credentials[tenant];\n console.log(` ${tenant}`);\n logger.dim(` Base: ${cred.basePath}`);\n logger.dim(` Key: ${cred.apiKey.substring(0, 8)}...`);\n console.log();\n }\n });\n\n configCmd\n .command('show <tenant>')\n .description('Show full credentials for a tenant (including API key)')\n .action((tenant) => {\n const credentials = listCredentials();\n const cred = credentials[tenant];\n\n if (!cred) {\n logger.error(`No credentials found for tenant: ${tenant}`);\n logger.dim(getCredentialsHint(tenant));\n process.exit(1);\n }\n\n logger.header(`Credentials for ${tenant}`);\n logger.table([\n { label: 'Tenant ID', value: tenant },\n { label: 'Base Path', value: cred.basePath },\n { label: 'API Key', value: cred.apiKey },\n ]);\n });\n\n configCmd\n .command('test <tenant>')\n .description('Test connection to a tenant')\n .action(async (tenant) => {\n const credentials = listCredentials();\n const cred = credentials[tenant];\n\n if (!cred) {\n logger.error(`No credentials found for tenant: ${tenant}`);\n logger.dim(getCredentialsHint(tenant));\n process.exit(1);\n }\n\n logger.info(`Testing connection to ${tenant}...`);\n\n const service = buildClient({ kind: 'apiKey', credential: cred });\n const connection = await service.checkConnection();\n\n if (connection.ok) {\n logger.success(`Connection successful!`);\n\n // A failed listing is not an absent folder, and it has to be caught\n // here: an escaped rejection is written to the log file and never\n // shown, so the command would exit 0 reporting success.\n try {\n const filesFolder = await service.getFilesFolder();\n if (filesFolder) {\n logger.dim('Files folder found.');\n } else {\n logger.warning('Files folder not found. It will be created on first push.');\n }\n } catch (error) {\n logger.error('Connected, but could not read the tenant root.');\n logger.dim(await formatClientError(error));\n process.exit(1);\n }\n } else {\n logger.error(connectionFailureMessage(connection.reason, cred.basePath, tenant));\n logger.dim(connection.message);\n process.exit(1);\n }\n });\n\n configCmd\n .command('include')\n .description(\n 'Manage extra file types to sync (beyond developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist). Data files (.csv, .xlsx, .parquet, \u2026) are backend-accepted but excluded from default \u2014 opt in via --ext .csv.',\n )\n .option('--ext <extension>', 'Add extra file extension (repeatable, e.g., --ext .json)', collect, [])\n .option('--folder <path>', 'Add folder to sync all files from (repeatable)', collect, [])\n .option('--remove-ext <extension>', 'Remove an extension from includes', collect, [])\n .option('--remove-folder <path>', 'Remove a folder from includes', collect, [])\n .option('--clear', 'Remove all sync includes for current tenant')\n .option('--tenant <tenant>', 'Tenant to configure (defaults to FARSEER_TENANT)')\n .action((options) => {\n // Via getEnvCheckout (not the raw env) so the resolved target gets\n // echoed like every other command \u2014 this writes per-tenant config,\n // so it shouldn't be the one command that never names its tenant.\n const tenant = options.tenant || getEnvCheckout()?.tenant;\n if (!tenant) {\n logger.error('No tenant specified.');\n logger.dim('Use --tenant <name>, or set it for this shell: export FARSEER_TENANT=<tenant>');\n process.exit(1);\n }\n\n const hasModification =\n options.ext.length > 0 ||\n options.folder.length > 0 ||\n options.removeExt.length > 0 ||\n options.removeFolder.length > 0 ||\n options.clear;\n\n // If no flags: show current includes\n if (!hasModification) {\n const includes = getSyncIncludes(tenant);\n if (!includes) {\n logger.info(`No sync includes configured for ${tenant}.`);\n logger.dim(\n 'Default sync: developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist (node_modules/, dist/, \u2026). Data files (.csv, .xlsx, .parquet, \u2026) are backend-accepted but excluded \u2014 opt in via --ext.',\n );\n logger.dim('');\n logger.dim('Add extra extensions: farseer config include --ext .csv --ext .parquet');\n logger.dim('Add extra folders: farseer config include --folder dist --folder \".vscode\"');\n return;\n }\n\n logger.header(`Sync includes for ${tenant}`);\n if (includes.extensions && includes.extensions.length > 0) {\n console.log(` Extensions: ${includes.extensions.join(', ')}`);\n }\n if (includes.folders && includes.folders.length > 0) {\n console.log(` Folders: ${includes.folders.join(', ')}`);\n }\n logger.dim('');\n logger.dim(\n 'These are synced in addition to the default scope (developer files (.ts, .js, .py, .yml, .yaml, .md, .json) non-hidden, non-blocklisted).',\n );\n return;\n }\n\n // Handle --clear\n if (options.clear) {\n setSyncIncludes(tenant, {});\n logger.success(`Cleared all sync includes for ${tenant}.`);\n return;\n }\n\n // Load current includes\n const current = getSyncIncludes(tenant) || {};\n const extensions = new Set(current.extensions || []);\n const folders = new Set(current.folders || []);\n\n // Add extensions (normalize: ensure leading dot, lowercase)\n for (const ext of options.ext as string[]) {\n const normalized = ext.startsWith('.') ? ext.toLowerCase() : `.${ext.toLowerCase()}`;\n extensions.add(normalized);\n }\n\n // Add folders\n for (const folder of options.folder as string[]) {\n folders.add(folder);\n }\n\n // Remove extensions\n for (const ext of options.removeExt as string[]) {\n const normalized = ext.startsWith('.') ? ext.toLowerCase() : `.${ext.toLowerCase()}`;\n extensions.delete(normalized);\n }\n\n // Remove folders\n for (const folder of options.removeFolder as string[]) {\n folders.delete(folder);\n }\n\n const updated: SyncIncludes = {\n extensions: extensions.size > 0 ? [...extensions] : undefined,\n folders: folders.size > 0 ? [...folders] : undefined,\n };\n\n setSyncIncludes(tenant, updated);\n\n // Show result\n const includes = getSyncIncludes(tenant);\n if (!includes) {\n logger.success(`Sync includes cleared for ${tenant}.`);\n } else {\n logger.success(`Updated sync includes for ${tenant}:`);\n if (includes.extensions && includes.extensions.length > 0) {\n console.log(` Extensions: ${includes.extensions.join(', ')}`);\n }\n if (includes.folders && includes.folders.length > 0) {\n console.log(` Folders: ${includes.folders.join(', ')}`);\n }\n }\n });\n}\n\nfunction collect(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,2BAUO;AACP,yBAA4B;AAC5B,qBAA6E;AAC7E,4BAAkC;AAE3B,SAAS,sBAAsB,SAAwB;AAC1D,QAAM,YAAY,QACb,QAAQ,QAAQ,EAChB,YAAY,kCAAkC,EAC9C;AAAA,IACG;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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CAAC;AAClF,iBAAW,IAAI,UAAU;AAAA,IAC7B;AAGA,eAAW,UAAU,QAAQ,QAAoB;AAC7C,cAAQ,IAAI,MAAM;AAAA,IACtB;AAGA,eAAW,OAAO,QAAQ,WAAuB;AAC7C,YAAM,aAAa,IAAI,WAAW,GAAG,IAAI,IAAI,YAAY,IAAI,IAAI,IAAI,YAAY,CAAC;AAClF,iBAAW,OAAO,UAAU;AAAA,IAChC;AAGA,eAAW,UAAU,QAAQ,cAA0B;AACnD,cAAQ,OAAO,MAAM;AAAA,IACzB;AAEA,UAAM,UAAwB;AAAA,MAC1B,YAAY,WAAW,OAAO,IAAI,CAAC,GAAG,UAAU,IAAI;AAAA,MACpD,SAAS,QAAQ,OAAO,IAAI,CAAC,GAAG,OAAO,IAAI;AAAA,IAC/C;AAEA,8CAAgB,QAAQ,OAAO;AAG/B,UAAM,eAAW,sCAAgB,MAAM;AACvC,QAAI,CAAC,UAAU;AACX,2BAAO,QAAQ,6BAA6B,MAAM,GAAG;AAAA,IACzD,OAAO;AACH,2BAAO,QAAQ,6BAA6B,MAAM,GAAG;AACrD,UAAI,SAAS,cAAc,SAAS,WAAW,SAAS,GAAG;AACvD,gBAAQ,IAAI,iBAAiB,SAAS,WAAW,KAAK,IAAI,CAAC,EAAE;AAAA,MACjE;AACA,UAAI,SAAS,WAAW,SAAS,QAAQ,SAAS,GAAG;AACjD,gBAAQ,IAAI,iBAAiB,SAAS,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,MAC9D;AAAA,IACJ;AAAA,EACJ,CAAC;AACT;AAEA,SAAS,QAAQ,OAAe,UAA8B;AAC1D,SAAO,SAAS,OAAO,CAAC,KAAK,CAAC;AAClC;",
|
|
6
6
|
"names": ["includes"]
|
|
7
7
|
}
|
package/dist/commands/install.js
CHANGED
|
@@ -36,8 +36,13 @@ var import_helpers = require("../utils/helpers");
|
|
|
36
36
|
var import_packageManager = require("../utils/packageManager");
|
|
37
37
|
var fs = __toESM(require("fs"));
|
|
38
38
|
var import_child_process = require("child_process");
|
|
39
|
+
var import_agentSandbox = require("../utils/agentSandbox");
|
|
39
40
|
function registerInstallCommand(program) {
|
|
40
41
|
program.command("install [tenant]").description("Install npm dependencies for a tenant (creates package.json if needed)").action(async (tenantArg) => {
|
|
42
|
+
if ((0, import_agentSandbox.inAgentSandbox)()) {
|
|
43
|
+
import_logger.logger.error(import_agentSandbox.LOCAL_APP_RUNS_UNAVAILABLE);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
41
46
|
const tenant = (0, import_helpers.resolveTenantOrExit)(tenantArg);
|
|
42
47
|
const tenantDir = (0, import_helpers.getTenantDir)(tenant);
|
|
43
48
|
if (!fs.existsSync(tenantDir)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { ensurePackageJson } from '../utils/packageManager';\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 (creates package.json if needed)')\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 // Auto-create package.json if missing, or add farseer-client if missing\n const added = ensurePackageJson(tenantDir, tenant);\n if (added.length > 0) {\n logger.info(`Updated package.json: ${added.join(', ')}`);\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,4BAAkC;AAClC,SAAoB;AACpB,2BAAsB;
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { logger } from '../utils/logger';\nimport { getTenantDir, resolveTenantOrExit } from '../utils/helpers';\nimport { ensurePackageJson } from '../utils/packageManager';\nimport * as fs from 'fs';\nimport { spawn } from 'child_process';\nimport { inAgentSandbox, LOCAL_APP_RUNS_UNAVAILABLE } from '../utils/agentSandbox';\n\nexport function registerInstallCommand(program: Command): void {\n program\n .command('install [tenant]')\n .description('Install npm dependencies for a tenant (creates package.json if needed)')\n .action(async (tenantArg) => {\n if (inAgentSandbox()) {\n logger.error(LOCAL_APP_RUNS_UNAVAILABLE);\n process.exit(1);\n }\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 // Auto-create package.json if missing, or add farseer-client if missing\n const added = ensurePackageJson(tenantDir, tenant);\n if (added.length > 0) {\n logger.info(`Updated package.json: ${added.join(', ')}`);\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,4BAAkC;AAClC,SAAoB;AACpB,2BAAsB;AACtB,0BAA2D;AAEpD,SAAS,uBAAuB,SAAwB;AAC3D,UACK,QAAQ,kBAAkB,EAC1B,YAAY,wEAAwE,EACpF,OAAO,OAAO,cAAc;AACzB,YAAI,oCAAe,GAAG;AAClB,2BAAO,MAAM,8CAA0B;AACvC,cAAQ,KAAK,CAAC;AAAA,IAClB;AACA,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;AAGA,UAAM,YAAQ,yCAAkB,WAAW,MAAM;AACjD,QAAI,MAAM,SAAS,GAAG;AAClB,2BAAO,KAAK,yBAAyB,MAAM,KAAK,IAAI,CAAC,EAAE;AAAA,IAC3D;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
6
|
"names": []
|
|
7
7
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -162,9 +162,9 @@ async function loginWithApiKey() {
|
|
|
162
162
|
type: "apiKey",
|
|
163
163
|
tenantId: tenant,
|
|
164
164
|
apiKey,
|
|
165
|
-
basePath
|
|
165
|
+
basePath: (0, import_configService.storedBasePath)(organisation)
|
|
166
166
|
};
|
|
167
|
-
const service = new import_farseerService.FarseerService({ kind: "apiKey", credential });
|
|
167
|
+
const service = new import_farseerService.FarseerService({ kind: "apiKey", credential: { ...credential, basePath } });
|
|
168
168
|
const connection = await service.checkConnection();
|
|
169
169
|
if (!connection.ok) {
|
|
170
170
|
import_logger.logger.error((0, import_helpers.connectionFailureMessage)(connection.reason, basePath, tenant));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/login.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport {\n setCredential,\n setUserAuth,\n generateBasePath,\n saveOrganisationRealm,\n ApiKeyCredential,\n DEFAULT_REALM,\n} from '../services/configService';\nimport { fetchOrganisationKeycloakConfig, type OrganisationKeycloakConfig } from '../services/realms';\nimport { loginWithBrowser, resolveRealm, FarseerService } from '../services/farseerService';\nimport { connectionFailureMessage } from '../utils/helpers';\n\n/** Keycloak identity provider that brokers a master-realm account into a customer realm. */\nconst MASTER_IDP_HINT = 'farseer-master';\n\nexport function registerLoginCommand(program: Command): void {\n program\n .command('login')\n .description('Login to Farseer (opens browser or use --api-key)')\n .option('--api-key', 'Login using API key instead of browser')\n .option('--org <organisation>', \"Log in to the Keycloak realm of this organisation's tenants (e.g. jgl)\")\n .option('--realm <realm>', 'Keycloak realm to use (default: master)')\n .option(\n '--idp-hint <hint>',\n `Identity provider to log in through (default: the organisation's own; Farseer staff: \"${MASTER_IDP_HINT}\")`,\n )\n .option('--no-idp-hint', \"Use the realm's own login form, ignoring the organisation's identity provider\")\n .action(async (options) => {\n if (options.apiKey) {\n await loginWithApiKey();\n } else {\n await loginViaBrowser(options);\n }\n });\n}\n\ninterface BrowserLoginOptions {\n org?: string;\n realm?: string;\n idpHint?: string | boolean;\n}\n\nasync function loginViaBrowser({ org, realm, idpHint }: BrowserLoginOptions): Promise<void> {\n logger.header('Farseer Login');\n\n if (org && realm) {\n logger.error('Pass either --org or --realm, not both.');\n process.exit(1);\n }\n\n const target = org\n ? await realmOfOrganisationOrExit(org)\n : { realm: realm ? await resolveRealmOrExit(realm) : DEFAULT_REALM };\n const realmToUse = target.realm;\n\n // Same default as the web app: the organisation's own provider. An @farseer.io\n // account has no password in a customer realm, so staff go through the\n // farseer-master broker instead, which federates their master-realm session.\n const hintToUse = resolveIdpHint(idpHint, target.idpHint);\n\n logger.info('Opening browser for login...');\n logger.dim('Waiting for authentication (timeout: 5 minutes)...');\n if (hintToUse) {\n logger.dim(`Identity provider: ${hintToUse}`);\n } else if (realmToUse !== DEFAULT_REALM) {\n logger.dim(`Farseer staff: add --idp-hint ${MASTER_IDP_HINT} to log in with your Farseer account.`);\n }\n\n const result = await loginWithBrowser(realmToUse, {\n idpHint: hintToUse,\n viaMasterSession: hintToUse === MASTER_IDP_HINT,\n });\n\n if (!result.ok) {\n logger.error(`Login failed or timed out${result.error ? ` (${result.error})` : ''}.`);\n logger.dim('Try using --api-key for manual API key login.');\n process.exit(1);\n }\n\n const expiresAt = new Date(Date.now() + result.expiresIn * 1000);\n\n setUserAuth({\n accessToken: result.accessToken,\n refreshToken: result.refreshToken,\n expiresAt: expiresAt.toISOString(),\n realm: realmToUse,\n });\n\n logger.success('Login successful!');\n logger.dim(`Realm: ${realmToUse}`);\n logger.dim(`Token expires at: ${expiresAt.toLocaleString()}`);\n logger.dim(`You can now access any tenant in realm \"${realmToUse}\" you have permissions for.`);\n process.exit(0);\n}\n\nasync function realmOfOrganisationOrExit(organisation: string): Promise<OrganisationKeycloakConfig> {\n logger.info(`Looking up the realm of organisation: ${organisation}...`);\n const config = await fetchOrganisationKeycloakConfig(organisation);\n if (!config) {\n logger.error(`Could not read the login configuration of \"${organisation}\".`);\n logger.dim(`Check that https://${organisation}.farseer.io is reachable, or pass --realm <realm> instead.`);\n process.exit(1);\n }\n saveOrganisationRealm(organisation, config.realm);\n logger.info(`Using realm: ${config.realm}`);\n return config;\n}\n\n/** Realm names are case-sensitive, and people type them from the org name. */\nasync function resolveRealmOrExit(realm: string): Promise<string> {\n logger.info(`Resolving realm: ${realm}...`);\n const resolved = await resolveRealm(realm);\n if (!resolved) {\n logger.error(`Realm \"${realm}\" not found on Keycloak server.`);\n logger.dim('Check the realm name and try again (realm names are case-sensitive).');\n logger.dim('Or let the organisation pick it: farseer login --org jgl');\n process.exit(1);\n }\n logger.info(resolved !== realm ? `Realm resolved to: ${resolved}` : `Using realm: ${resolved}`);\n return resolved;\n}\n\n/**\n * `--idp-hint <hint>` picks the provider, `--no-idp-hint` forces the realm's own form\n * (commander gives us `false` for it), and anything else falls back to the\n * organisation's own provider \u2014 none with `--realm`, which names no organisation.\n */\nfunction resolveIdpHint(idpHint: string | boolean | undefined, organisationHint?: string): string | undefined {\n if (typeof idpHint === 'string') {\n return idpHint;\n }\n if (idpHint === false) {\n return undefined;\n }\n return organisationHint;\n}\n\nasync function loginWithApiKey(): Promise<void> {\n logger.header('Farseer Login (API Key)');\n\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'tenant',\n message: 'Tenant ID (e.g., tthotels):',\n validate: (input) => {\n if (!input || input.trim() === '') {\n return 'Tenant ID is required';\n }\n return true;\n },\n },\n {\n type: 'input',\n name: 'organisation',\n message: 'Organisation (leave empty if same as tenant):',\n },\n {\n type: 'password',\n name: 'apiKey',\n message: 'API Key:',\n mask: '*',\n validate: (input) => {\n if (!input || input.trim() === '') {\n return 'API Key is required';\n }\n return true;\n },\n },\n ]);\n\n const tenant = answers.tenant.trim();\n const organisation = answers.organisation.trim() || tenant;\n const apiKey = answers.apiKey.trim();\n const basePath = generateBasePath(organisation);\n\n logger.info('Testing connection...');\n\n const credential: ApiKeyCredential = {\n type: 'apiKey',\n tenantId: tenant,\n apiKey: apiKey,\n basePath:
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAqB;AACrB,oBAAuB;AACvB,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport {\n setCredential,\n setUserAuth,\n generateBasePath,\n storedBasePath,\n saveOrganisationRealm,\n ApiKeyCredential,\n DEFAULT_REALM,\n} from '../services/configService';\nimport { fetchOrganisationKeycloakConfig, type OrganisationKeycloakConfig } from '../services/realms';\nimport { loginWithBrowser, resolveRealm, FarseerService } from '../services/farseerService';\nimport { connectionFailureMessage } from '../utils/helpers';\n\n/** Keycloak identity provider that brokers a master-realm account into a customer realm. */\nconst MASTER_IDP_HINT = 'farseer-master';\n\nexport function registerLoginCommand(program: Command): void {\n program\n .command('login')\n .description('Login to Farseer (opens browser or use --api-key)')\n .option('--api-key', 'Login using API key instead of browser')\n .option('--org <organisation>', \"Log in to the Keycloak realm of this organisation's tenants (e.g. jgl)\")\n .option('--realm <realm>', 'Keycloak realm to use (default: master)')\n .option(\n '--idp-hint <hint>',\n `Identity provider to log in through (default: the organisation's own; Farseer staff: \"${MASTER_IDP_HINT}\")`,\n )\n .option('--no-idp-hint', \"Use the realm's own login form, ignoring the organisation's identity provider\")\n .action(async (options) => {\n if (options.apiKey) {\n await loginWithApiKey();\n } else {\n await loginViaBrowser(options);\n }\n });\n}\n\ninterface BrowserLoginOptions {\n org?: string;\n realm?: string;\n idpHint?: string | boolean;\n}\n\nasync function loginViaBrowser({ org, realm, idpHint }: BrowserLoginOptions): Promise<void> {\n logger.header('Farseer Login');\n\n if (org && realm) {\n logger.error('Pass either --org or --realm, not both.');\n process.exit(1);\n }\n\n const target = org\n ? await realmOfOrganisationOrExit(org)\n : { realm: realm ? await resolveRealmOrExit(realm) : DEFAULT_REALM };\n const realmToUse = target.realm;\n\n // Same default as the web app: the organisation's own provider. An @farseer.io\n // account has no password in a customer realm, so staff go through the\n // farseer-master broker instead, which federates their master-realm session.\n const hintToUse = resolveIdpHint(idpHint, target.idpHint);\n\n logger.info('Opening browser for login...');\n logger.dim('Waiting for authentication (timeout: 5 minutes)...');\n if (hintToUse) {\n logger.dim(`Identity provider: ${hintToUse}`);\n } else if (realmToUse !== DEFAULT_REALM) {\n logger.dim(`Farseer staff: add --idp-hint ${MASTER_IDP_HINT} to log in with your Farseer account.`);\n }\n\n const result = await loginWithBrowser(realmToUse, {\n idpHint: hintToUse,\n viaMasterSession: hintToUse === MASTER_IDP_HINT,\n });\n\n if (!result.ok) {\n logger.error(`Login failed or timed out${result.error ? ` (${result.error})` : ''}.`);\n logger.dim('Try using --api-key for manual API key login.');\n process.exit(1);\n }\n\n const expiresAt = new Date(Date.now() + result.expiresIn * 1000);\n\n setUserAuth({\n accessToken: result.accessToken,\n refreshToken: result.refreshToken,\n expiresAt: expiresAt.toISOString(),\n realm: realmToUse,\n });\n\n logger.success('Login successful!');\n logger.dim(`Realm: ${realmToUse}`);\n logger.dim(`Token expires at: ${expiresAt.toLocaleString()}`);\n logger.dim(`You can now access any tenant in realm \"${realmToUse}\" you have permissions for.`);\n process.exit(0);\n}\n\nasync function realmOfOrganisationOrExit(organisation: string): Promise<OrganisationKeycloakConfig> {\n logger.info(`Looking up the realm of organisation: ${organisation}...`);\n const config = await fetchOrganisationKeycloakConfig(organisation);\n if (!config) {\n logger.error(`Could not read the login configuration of \"${organisation}\".`);\n logger.dim(`Check that https://${organisation}.farseer.io is reachable, or pass --realm <realm> instead.`);\n process.exit(1);\n }\n saveOrganisationRealm(organisation, config.realm);\n logger.info(`Using realm: ${config.realm}`);\n return config;\n}\n\n/** Realm names are case-sensitive, and people type them from the org name. */\nasync function resolveRealmOrExit(realm: string): Promise<string> {\n logger.info(`Resolving realm: ${realm}...`);\n const resolved = await resolveRealm(realm);\n if (!resolved) {\n logger.error(`Realm \"${realm}\" not found on Keycloak server.`);\n logger.dim('Check the realm name and try again (realm names are case-sensitive).');\n logger.dim('Or let the organisation pick it: farseer login --org jgl');\n process.exit(1);\n }\n logger.info(resolved !== realm ? `Realm resolved to: ${resolved}` : `Using realm: ${resolved}`);\n return resolved;\n}\n\n/**\n * `--idp-hint <hint>` picks the provider, `--no-idp-hint` forces the realm's own form\n * (commander gives us `false` for it), and anything else falls back to the\n * organisation's own provider \u2014 none with `--realm`, which names no organisation.\n */\nfunction resolveIdpHint(idpHint: string | boolean | undefined, organisationHint?: string): string | undefined {\n if (typeof idpHint === 'string') {\n return idpHint;\n }\n if (idpHint === false) {\n return undefined;\n }\n return organisationHint;\n}\n\nasync function loginWithApiKey(): Promise<void> {\n logger.header('Farseer Login (API Key)');\n\n const answers = await inquirer.prompt([\n {\n type: 'input',\n name: 'tenant',\n message: 'Tenant ID (e.g., tthotels):',\n validate: (input) => {\n if (!input || input.trim() === '') {\n return 'Tenant ID is required';\n }\n return true;\n },\n },\n {\n type: 'input',\n name: 'organisation',\n message: 'Organisation (leave empty if same as tenant):',\n },\n {\n type: 'password',\n name: 'apiKey',\n message: 'API Key:',\n mask: '*',\n validate: (input) => {\n if (!input || input.trim() === '') {\n return 'API Key is required';\n }\n return true;\n },\n },\n ]);\n\n const tenant = answers.tenant.trim();\n const organisation = answers.organisation.trim() || tenant;\n const apiKey = answers.apiKey.trim();\n const basePath = generateBasePath(organisation);\n\n logger.info('Testing connection...');\n\n const credential: ApiKeyCredential = {\n type: 'apiKey',\n tenantId: tenant,\n apiKey: apiKey,\n basePath: storedBasePath(organisation),\n };\n\n const service = new FarseerService({ kind: 'apiKey', credential: { ...credential, basePath } });\n const connection = await service.checkConnection();\n\n if (!connection.ok) {\n logger.error(connectionFailureMessage(connection.reason, basePath, tenant));\n logger.dim(connection.message);\n process.exit(1);\n }\n\n setCredential(tenant, credential);\n\n logger.success(`Successfully connected to ${tenant}!`);\n logger.dim(`Credentials saved for tenant: ${tenant}`);\n logger.dim(`Base path: ${basePath}`);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAqB;AACrB,oBAAuB;AACvB,2BAQO;AACP,oBAAiF;AACjF,4BAA+D;AAC/D,qBAAyC;AAGzC,MAAM,kBAAkB;AAEjB,SAAS,qBAAqB,SAAwB;AACzD,UACK,QAAQ,OAAO,EACf,YAAY,mDAAmD,EAC/D,OAAO,aAAa,wCAAwC,EAC5D,OAAO,wBAAwB,wEAAwE,EACvG,OAAO,mBAAmB,yCAAyC,EACnE;AAAA,IACG;AAAA,IACA,yFAAyF,eAAe;AAAA,EAC5G,EACC,OAAO,iBAAiB,+EAA+E,EACvG,OAAO,OAAO,YAAY;AACvB,QAAI,QAAQ,QAAQ;AAChB,YAAM,gBAAgB;AAAA,IAC1B,OAAO;AACH,YAAM,gBAAgB,OAAO;AAAA,IACjC;AAAA,EACJ,CAAC;AACT;AAQA,eAAe,gBAAgB,EAAE,KAAK,OAAO,QAAQ,GAAuC;AACxF,uBAAO,OAAO,eAAe;AAE7B,MAAI,OAAO,OAAO;AACd,yBAAO,MAAM,yCAAyC;AACtD,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,QAAM,SAAS,MACT,MAAM,0BAA0B,GAAG,IACnC,EAAE,OAAO,QAAQ,MAAM,mBAAmB,KAAK,IAAI,mCAAc;AACvE,QAAM,aAAa,OAAO;AAK1B,QAAM,YAAY,eAAe,SAAS,OAAO,OAAO;AAExD,uB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AAK,uBAAuB;AAEnC,QAAM,aAA+B;AAAA,IACjC,MAAM;AAAA,IACN,UAAU;AAAA,IACV;AAAA,IACA,cAAU,qCAAe,YAAY;AAAA,EACzC;AAEA,QAAM,UAAU,IAAI,qCAAe,EAAE,MAAM,UAAU,YAAY,EAAE,GAAG,YAAY,SAAS,EAAE,CAAC;AAC9F,QAAM,aAAa,MAAM,QAAQ,gBAAgB;AAEjD,MAAI,CAAC,WAAW,IAAI;AAChB,yBAAO,UAAM,yCAAyB,WAAW,QAAQ,UAAU,MAAM,CAAC;AAC1E,yBAAO,IAAI,WAAW,OAAO;AAC7B,YAAQ,KAAK,CAAC;AAAA,EAClB;AAEA,0CAAc,QAAQ,UAAU;AAEhC,uBAAO,QAAQ,6BAA6B,MAAM,GAAG;AACrD,uBAAO,IAAI,iCAAiC,MAAM,EAAE;AACpD,uBAAO,IAAI,cAAc,QAAQ,EAAE;AACvC;",
|
|
6
6
|
"names": ["inquirer"]
|
|
7
7
|
}
|
package/dist/commands/pull.js
CHANGED
|
@@ -59,7 +59,8 @@ function registerPullCommand(program) {
|
|
|
59
59
|
"-y, --yes",
|
|
60
60
|
"Skip confirmation when local has uncommitted changes OR remote has deletions that would remove local files/apps (ignored under --force)"
|
|
61
61
|
).option("--include-ext <ext>", "Include extra file extension (repeatable)", import_cliOptions.collectValues, []).option("--include-folder <folder>", "Include all files in folder (repeatable)", import_cliOptions.collectValues, []).action(async (arg1, arg2, options) => {
|
|
62
|
-
const
|
|
62
|
+
const target = await (0, import_preflight.preflight)(arg1, arg2);
|
|
63
|
+
const { organisation, tenant, client } = target;
|
|
63
64
|
const syncService = new import_syncService.SyncService(tenant, client);
|
|
64
65
|
const tenantDir = (0, import_helpers.getTenantDir)(tenant);
|
|
65
66
|
(0, import_helpers.ensureDirectoryExists)(tenantDir);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { fileLogger } from '../utils/fileLogger';\nimport { preflight } from '../services/preflight';\nimport { SyncService, ConflictResolutions, SyncStatus } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport {\n getTenantDir,\n getTenantFilesDir,\n ensureDirectoryExists,\n appendToAuditLog,\n AuditLogEntry,\n safeResolveWithinBase,\n} from '../utils/helpers';\nimport { formatClientError } from '../utils/errorFormatter';\nimport { isLikelyTextFile } from '../utils/fileValidation';\nimport { collectValues, normalizeExtensions } from '../utils/cliOptions';\nimport { FARSEER_CLIENT_URL, FARSEER_CLIENT_AXIOS_URL } from '../utils/constants';\nimport { ensureGitignoreEntries } from '../utils/workspace';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\n/**\n * Pull semantics:\n *\n * farseer pull\n * 1. Show local-vs-remote diff. If you have unsynced local edits OR\n * remote has deletions that would remove local files/apps, the\n * command stops here and asks for confirmation before doing\n * anything (we don't merge or delete silently).\n * 2. Apply remote-side changes (downloads, deletions, modifications).\n * Per-file conflicts are resolved interactively.\n *\n * farseer pull --force\n * Hard reset to remote. After it runs, the working tree mirrors what's\n * on remote: any file that exists locally but not on remote is deleted,\n * remote versions overwrite local edits, deletions are accepted. Always\n * asks for confirmation because the operation is destructive.\n */\nexport function registerPullCommand(program: Command): void {\n program\n .command('pull [org] [tenant]')\n .description(\n 'Pull files from Farseer instance to local\\n\\nUsage: pull <org> <tenant> OR pull <tenant> (if org is known)',\n )\n .option(\n '--all',\n 'Pull every non-hidden, non-blocklisted file (default: developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist). Data files (.csv, .xlsx, .parquet, \u2026) are backend-accepted but excluded from default \u2014 opt in via --include-ext .csv or `farseer config include --ext .csv`.',\n )\n .option(\n '--force',\n 'Hard reset local to remote within the current sync scope: overwrite local edits, delete local-only files. Files outside scope (data files like .csv on a default run without --include-ext .csv) are NOT touched. Always asks for confirmation.',\n )\n .option(\n '-y, --yes',\n 'Skip confirmation when local has uncommitted changes OR remote has deletions that would remove local files/apps (ignored under --force)',\n )\n .option('--include-ext <ext>', 'Include extra file extension (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder (repeatable)', collectValues, [])\n .action(async (arg1, arg2, options) => {\n // preflight resolves the target, authenticates, and confirms the\n // org owns the tenant (the guard that used to live only in\n // `checkout`). pull is the setup path now, so scaffolding follows.\n const { organisation, tenant, client } = await preflight(arg1, arg2);\n\n const syncService = new SyncService(tenant, client);\n\n const tenantDir = getTenantDir(tenant);\n ensureDirectoryExists(tenantDir);\n\n // Ensure .gitignore covers `.farseer-sync.json` on the first pull\n // into a fresh workspace. Without it, a workspace initialized by\n // `farseer pull` would commit the per-machine baseline and\n // reproduce the cross-machine drift bug the gitignore prevents.\n ensureGitignoreEntries(path.join(tenantDir, '.gitignore'));\n\n await createDefaultPackageJson(tenantDir, tenant);\n\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n const filterOptions = {\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n };\n const syncOptions = {\n all: options.all,\n force: options.force,\n ...filterOptions,\n };\n\n // Step 1: Inspect current state. We do this BEFORE mutating\n // anything so the user can decide whether to bail.\n const filesDir = getTenantFilesDir(tenant);\n const folderInitialised = fs.existsSync(filesDir);\n\n // With `checkout` gone, a first pull IS the setup \u2014 so it has to\n // close by naming the one step the CLI can't do itself: a child\n // process can't export into the shell that launched it. Gated on a\n // fresh workspace; on every routine pull this would just be noise.\n const printShellHint = (): void => {\n if (folderInitialised) return;\n console.log();\n logger.success(`Workspace ready for ${chalk.bold(tenant)}.`);\n logger.dim('To target this tenant in this shell, set:');\n logger.info(\n organisation === tenant\n ? ` export FARSEER_TENANT=${tenant}`\n : ` export FARSEER_TENANT=${tenant} FARSEER_ORG=${organisation}`,\n );\n logger.dim(`Or pass it explicitly each time: farseer status ${tenant}`);\n };\n\n let preStatus: SyncStatus | null = null;\n let preStatusError: Error | null = null;\n if (folderInitialised) {\n try {\n preStatus = await syncService.getStatus({ ...filterOptions, all: options.all, deep: false });\n } catch (error) {\n preStatusError = error as Error;\n logger.dim(`Could not compute pre-pull status: ${preStatusError.message}`);\n }\n }\n\n // Preview app deletions too. Without this the destructive\n // prompt only covers files and the user discovers (post-pull)\n // that an app JSON was wiped because someone deleted the app\n // on remote. Uses listApps only \u2014 no per-app fetch \u2014 so this\n // doesn't double the network cost of the apps pull below.\n //\n // Best-effort: a failure here shouldn't block the pull. Worst\n // case the user gets the legacy behaviour (silent app\n // deletion) on this run.\n const appSyncService = new AppSyncService(tenant, client);\n let appDeletions: string[] = [];\n try {\n appDeletions = await appSyncService.getRemoteDeletions();\n } catch (error) {\n logger.dim(`Could not compute pre-pull app deletions: ${(error as Error).message}`);\n }\n\n const localChanges = preStatus\n ? preStatus.addedLocally.length +\n preStatus.modifiedLocally.length +\n preStatus.deletedLocally.length +\n preStatus.conflicts.length\n : 0;\n const remoteDeletions = (preStatus?.deletedRemotely.length ?? 0) + appDeletions.length;\n\n // Step 2: Decide whether to confirm. The matrix:\n // --force \u2192 always confirm (destructive reset).\n // local edits OR remote deletions \u2192 confirm unless -y.\n // clean tree, no deletes \u2192 just go.\n //\n // Remote deletions are gated because pull would silently\n // remove a previously-synced local file/app if someone deleted\n // it on remote \u2014 a real script could vanish without warning.\n // Local edits stay gated for the existing reason: we don't\n // want to merge into a dirty tree without an opt-in.\n if (options.force) {\n console.log();\n console.log(chalk.red.bold('--force will hard-reset local to match remote.'));\n if (preStatus) {\n summarisePreStatus(preStatus);\n } else if (preStatusError) {\n // Without a local diff we'd be confirming a destructive\n // mirror operation blind. Refuse rather than press on \u2014\n // the cost of failing here is one re-run; the cost of\n // pressing on is silent loss of in-progress files.\n console.log(\n chalk.red(\n 'Cannot show what will be lost \u2014 pre-pull status failed (see line above). Refusing to --force without visibility.',\n ),\n );\n logger.dim('Re-run after the underlying issue clears, or use a non-force pull to merge.');\n process.exit(1);\n } else {\n // Folder isn't initialised yet \u2014 first --force pull on a\n // brand-new tenant. Nothing local to lose; proceed.\n logger.dim('No local files yet \u2014 nothing to discard.');\n }\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: `Discard local changes and reset ${tenant} to remote?`,\n default: false,\n },\n ]);\n if (!confirm.proceed) {\n logger.info('Pull cancelled.');\n return;\n }\n } else if ((localChanges > 0 || remoteDeletions > 0) && !options.yes) {\n console.log();\n if (localChanges > 0) {\n logger.warning(`Local has ${localChanges} unsynced change(s).`);\n summarisePreStatus(preStatus!);\n logger.dim('Pull will keep your edits and merge remote-side changes around them.');\n }\n if (remoteDeletions > 0) {\n logger.warning(`Pull will remove ${remoteDeletions} local item(s) that were deleted on remote:`);\n summariseRemoteDeletions(preStatus?.deletedRemotely ?? [], appDeletions);\n logger.dim('Decline to abort and keep your local copies (you can push them back to restore).');\n }\n if (localChanges > 0 && remoteDeletions === 0) {\n logger.dim('To wipe local and reset to remote: re-run with --force.');\n }\n const promptMessage =\n remoteDeletions > 0 && localChanges > 0\n ? `Continue pull (merge into dirty tree AND delete ${remoteDeletions} local item(s))?`\n : remoteDeletions > 0\n ? `Continue pull and delete ${remoteDeletions} local item(s)?`\n : `Continue pulling into a dirty working tree?`;\n // Dirty-tree-only keeps the soft default (Enter = continue\n // merge). The moment remote deletions are on the table we\n // flip to default-false: a wrong \"yes\" wipes local items\n // for good, same calculus as `pull --force` below.\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: promptMessage,\n default: remoteDeletions === 0,\n },\n ]);\n if (!confirm.proceed) {\n logger.info('Pull cancelled.');\n return;\n }\n }\n\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(syncOptions);\n\n // Conflicts: prompt per file (only when not --force).\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 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 for (const conflict of result.conflicts) {\n let choices: { name: string; value: string }[];\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 // Only offer git-style merge for files we know\n // are text. Binary blobs would just get\n // corrupted by UTF-8 splicing. The service has\n // a defensive fallback for binary anyway, but\n // not showing the option avoids the confusing\n // \"I picked merge_markers but got keep_both\"\n // experience.\n if (isLikelyTextFile(conflict.filePath)) {\n choices.push({\n name: 'Merge with markers (git-style \u2014 edit file, then push to finish)',\n value: 'merge_markers',\n });\n }\n }\n const answer = await inquirer.prompt([\n {\n type: 'list',\n name: 'resolution',\n message: `${conflict.filePath} - ${conflict.description}`,\n choices,\n },\n ]);\n resolutions[conflict.filePath] = answer.resolution;\n }\n result = await syncService.pull({ ...syncOptions, conflictResolutions: resolutions });\n }\n\n if (result.downloaded.length > 0) {\n console.log(chalk.green('Downloaded:'));\n for (const file of result.downloaded) console.log(chalk.green(` + ${file}`));\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted (removed from remote):'));\n for (const file of result.deleted) console.log(chalk.red(` - ${file}`));\n }\n\n if (result.conflictFilesWritten.length > 0) {\n console.log(chalk.yellow('Conflict files created:'));\n for (const file of result.conflictFilesWritten) console.log(chalk.yellow(` ~ ${file}`));\n if (result.conflictFilesWritten.some((f) => f.includes('(merge markers)'))) {\n console.log();\n logger.dim('Files marked with \"(merge markers)\" contain git-style <<<<<<</=======/>>>>>>>');\n logger.dim('blocks. Open them, pick which version to keep, remove the marker lines,');\n logger.dim(`then run \\`farseer push ${tenant}\\` to upload the resolved version.`);\n }\n }\n\n logger.dim(\n `Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`,\n );\n\n // --force extra: also delete any local-only files. The\n // service-level pull keeps `local_new` files unchanged\n // (it's the right default for a non-destructive pull),\n // but --force at the command layer means \"mirror remote\",\n // so remove those locally.\n let extraLocalDeletes: string[] = [];\n if (options.force) {\n // Forward `--all` so `pull --force --all` wipes every\n // local-only file in scope, not just those that match\n // the default sync scope.\n extraLocalDeletes = await wipeLocalOnly(syncService, filesDir, {\n ...filterOptions,\n all: options.all,\n });\n if (extraLocalDeletes.length > 0) {\n console.log(chalk.red('Local-only files removed (mirror remote):'));\n for (const file of extraLocalDeletes) console.log(chalk.red(` - ${file}`));\n }\n }\n\n // Audit log\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 appendToAuditLog(tenant, auditEntries);\n }\n\n let hasChanges =\n result.downloaded.length > 0 || result.deleted.length > 0 || extraLocalDeletes.length > 0;\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 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) console.log(chalk.green(` + ${app}`));\n }\n if (appResult.updated.length > 0) {\n console.log(chalk.yellow('Updated apps:'));\n for (const app of appResult.updated) console.log(chalk.yellow(` ~ ${app}`));\n }\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps (removed from remote):'));\n for (const app of appResult.deleted) console.log(chalk.red(` - ${app}`));\n }\n\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n\n hasChanges =\n hasChanges ||\n appResult.created.length > 0 ||\n appResult.updated.length > 0 ||\n appResult.deleted.length > 0;\n\n if (!hasChanges) {\n logger.success('Already up to date.');\n printShellHint();\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(\n `Files: +${result.downloaded.length} -${result.deleted.length} ${\n extraLocalDeletes.length > 0 ? `(${extraLocalDeletes.length} local-only removed) ` : ''\n }(${result.unchanged.length} unchanged)`,\n );\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n printShellHint();\n } catch (error) {\n fileLogger.error('pull', error);\n logger.error('Pull failed.');\n logger.error(await formatClientError(error));\n const logPath = fileLogger.getLogPath();\n if (logPath) {\n logger.dim(`Debug log: ${logPath}`);\n }\n process.exit(1);\n }\n });\n}\n\n/**\n * Print actual paths (not just counts) so the user can see what local\n * changes a `pull --force` is about to overwrite. Counts alone hid the\n * destructive blast radius: under `--force --all` someone could lose\n * dozens of in-progress files without knowing which ones. Cap at\n * MAX_PATHS_PER_SECTION per section to avoid scrollback floods on huge\n * trees \u2014 anything beyond that collapses into \"+ N more\".\n */\nfunction summarisePreStatus(status: SyncStatus): void {\n const MAX_PATHS_PER_SECTION = 20;\n const renderSection = (label: string, paths: string[], color: (s: string) => string) => {\n if (paths.length === 0) return;\n console.log(color(` ${label} (${paths.length}):`));\n const visible = paths.slice(0, MAX_PATHS_PER_SECTION);\n for (const p of visible) console.log(color(` ${p}`));\n if (paths.length > MAX_PATHS_PER_SECTION) {\n console.log(chalk.dim(` ... and ${paths.length - MAX_PATHS_PER_SECTION} more`));\n }\n };\n renderSection('+ new local file(s)', status.addedLocally, chalk.green);\n renderSection('M locally modified file(s)', status.modifiedLocally, chalk.yellow);\n renderSection('- locally deleted file(s)', status.deletedLocally, chalk.red);\n if (status.conflicts.length > 0) {\n const conflictPaths = status.conflicts.map((c) => c.filePath);\n renderSection('! conflict(s)', conflictPaths, chalk.red.bold);\n }\n console.log();\n}\n\n/**\n * Print the file + app paths that pull is about to delete because remote\n * removed them. Same cap as `summarisePreStatus` so a huge purge doesn't\n * flood the scrollback \u2014 the user still gets the count above.\n */\nfunction summariseRemoteDeletions(deletedFiles: string[], deletedApps: string[]): void {\n const MAX_PATHS_PER_SECTION = 20;\n const renderSection = (label: string, paths: string[]) => {\n if (paths.length === 0) return;\n console.log(chalk.red(` ${label} (${paths.length}):`));\n const visible = paths.slice(0, MAX_PATHS_PER_SECTION);\n for (const p of visible) console.log(chalk.red(` - ${p}`));\n if (paths.length > MAX_PATHS_PER_SECTION) {\n console.log(chalk.dim(` ... and ${paths.length - MAX_PATHS_PER_SECTION} more`));\n }\n };\n renderSection('file(s) deleted on remote', deletedFiles);\n renderSection('app(s) deleted on remote', deletedApps);\n console.log();\n}\n\n/**\n * Hard-reset helper for `pull --force`. Removes local files that have no\n * remote counterpart (the regular pull keeps them \u2014 see service comment).\n * Cleans up the syncState entry too so the next status doesn't show ghosts.\n */\nasync function wipeLocalOnly(\n syncService: SyncService,\n filesDir: string,\n filterOptions: { all?: boolean; includeExtensions?: string[]; includeFolders?: string[] },\n): Promise<string[]> {\n // `all` matters: under `pull --force --all` the user expects every\n // local-only file to be wiped, not just files in the default sync\n // scope. Without it, getStatus filters down to the curated developer\n // files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden\n // directories and the folder blocklist, so the wipe loop never sees\n // anything those rules exclude.\n const status = await syncService.getStatus({ ...filterOptions, deep: false });\n const removed: string[] = [];\n const failed: { file: string; reason: string }[] = [];\n const syncState = syncService.loadSyncState();\n for (const file of status.addedLocally) {\n const fullPath = safeResolveWithinBase(filesDir, file);\n if (fs.existsSync(fullPath)) {\n // Wrap each unlink so a single permission error / file lock\n // doesn't strand the rest of the wipe. syncState is saved\n // incrementally as each unlink succeeds so a mid-run failure\n // leaves a consistent record for the next run, and the failed\n // list is surfaced at the end for manual cleanup.\n try {\n fs.unlinkSync(fullPath);\n removed.push(file);\n delete syncState.files[file];\n syncService.saveSyncState(syncState);\n } catch (err) {\n failed.push({ file, reason: err instanceof Error ? err.message : String(err) });\n }\n } else {\n // File was already gone \u2014 just drop the syncState entry.\n delete syncState.files[file];\n syncService.saveSyncState(syncState);\n }\n }\n if (failed.length > 0) {\n logger.warning(`${failed.length} local-only file(s) could not be removed:`);\n for (const f of failed) logger.dim(` ${f.file} \u2014 ${f.reason}`);\n }\n return removed;\n}\n\nasync function createDefaultPackageJson(tenantDir: string, tenant: string): Promise<void> {\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': FARSEER_CLIENT_URL,\n 'farseer-client-axios': FARSEER_CLIENT_AXIOS_URL,\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,wB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MAClB,SAAS;AAAA,MACT,OAAO;AAAA,MACP,eAAe;AAAA,MACf,aAAa;AAAA,MACb,iBAAiB;AAAA,MACjB,cAAc;AAAA,MACd,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,kBAAkB;AAAA,MAClB,wBAAwB;AAAA,MACxB,mBAAmB;AAAA,MACnB,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,cAAc;AAAA,MACd,OAAO;AAAA,MACP,iBAAiB;AAAA,MACjB,OAAO;AAAA,MACP,cAAc;AAAA,MACd,cAAc;AAAA,MACd,gBAAgB;AAAA,MAChB,SAAS;AAAA,MACT,UAAU;AAAA,MACV,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM;AAAA,MACN,oBAAoB;AAAA,MACpB,eAAe;AAAA,MACf,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM;AAAA,MACN,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,YAAY;AAAA,IAChB;AAAA,EACJ;AAEA,KAAG,cAAc,iBAAiB,KAAK,UAAU,aAAa,MAAM,CAAC,GAAG,OAAO;AAC/E,uBAAO,IAAI,4BAA4B,MAAM,EAAE;AACnD;",
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport inquirer from 'inquirer';\nimport { logger } from '../utils/logger';\nimport { fileLogger } from '../utils/fileLogger';\nimport { preflight } from '../services/preflight';\nimport { SyncService, ConflictResolutions, SyncStatus } from '../services/syncService';\nimport { AppSyncService } from '../services/appSyncService';\nimport {\n getTenantDir,\n getTenantFilesDir,\n ensureDirectoryExists,\n appendToAuditLog,\n AuditLogEntry,\n safeResolveWithinBase,\n} from '../utils/helpers';\nimport { formatClientError } from '../utils/errorFormatter';\nimport { isLikelyTextFile } from '../utils/fileValidation';\nimport { collectValues, normalizeExtensions } from '../utils/cliOptions';\nimport { FARSEER_CLIENT_URL, FARSEER_CLIENT_AXIOS_URL } from '../utils/constants';\nimport { ensureGitignoreEntries } from '../utils/workspace';\nimport * as fs from 'fs';\nimport * as path from 'path';\n\n/**\n * Pull semantics:\n *\n * farseer pull\n * 1. Show local-vs-remote diff. If you have unsynced local edits OR\n * remote has deletions that would remove local files/apps, the\n * command stops here and asks for confirmation before doing\n * anything (we don't merge or delete silently).\n * 2. Apply remote-side changes (downloads, deletions, modifications).\n * Per-file conflicts are resolved interactively.\n *\n * farseer pull --force\n * Hard reset to remote. After it runs, the working tree mirrors what's\n * on remote: any file that exists locally but not on remote is deleted,\n * remote versions overwrite local edits, deletions are accepted. Always\n * asks for confirmation because the operation is destructive.\n */\nexport function registerPullCommand(program: Command): void {\n program\n .command('pull [org] [tenant]')\n .description(\n 'Pull files from Farseer instance to local\\n\\nUsage: pull <org> <tenant> OR pull <tenant> (if org is known)',\n )\n .option(\n '--all',\n 'Pull every non-hidden, non-blocklisted file (default: developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist). Data files (.csv, .xlsx, .parquet, \u2026) are backend-accepted but excluded from default \u2014 opt in via --include-ext .csv or `farseer config include --ext .csv`.',\n )\n .option(\n '--force',\n 'Hard reset local to remote within the current sync scope: overwrite local edits, delete local-only files. Files outside scope (data files like .csv on a default run without --include-ext .csv) are NOT touched. Always asks for confirmation.',\n )\n .option(\n '-y, --yes',\n 'Skip confirmation when local has uncommitted changes OR remote has deletions that would remove local files/apps (ignored under --force)',\n )\n .option('--include-ext <ext>', 'Include extra file extension (repeatable)', collectValues, [])\n .option('--include-folder <folder>', 'Include all files in folder (repeatable)', collectValues, [])\n .action(async (arg1, arg2, options) => {\n // preflight resolves the target, authenticates, and confirms the\n // org owns the tenant (the guard that used to live only in\n // `checkout`). pull is the setup path now, so scaffolding follows.\n const target = await preflight(arg1, arg2);\n const { organisation, tenant, client } = target;\n\n const syncService = new SyncService(tenant, client);\n\n const tenantDir = getTenantDir(tenant);\n ensureDirectoryExists(tenantDir);\n\n // Ensure .gitignore covers `.farseer-sync.json` on the first pull\n // into a fresh workspace. Without it, a workspace initialized by\n // `farseer pull` would commit the per-machine baseline and\n // reproduce the cross-machine drift bug the gitignore prevents.\n ensureGitignoreEntries(path.join(tenantDir, '.gitignore'));\n\n await createDefaultPackageJson(tenantDir, tenant);\n\n const includeExtensions = normalizeExtensions(options.includeExt);\n const includeFolders = options.includeFolder as string[];\n const filterOptions = {\n includeExtensions: includeExtensions.length > 0 ? includeExtensions : undefined,\n includeFolders: includeFolders.length > 0 ? includeFolders : undefined,\n };\n const syncOptions = {\n all: options.all,\n force: options.force,\n ...filterOptions,\n };\n\n // Step 1: Inspect current state. We do this BEFORE mutating\n // anything so the user can decide whether to bail.\n const filesDir = getTenantFilesDir(tenant);\n const folderInitialised = fs.existsSync(filesDir);\n\n // With `checkout` gone, a first pull IS the setup \u2014 so it has to\n // close by naming the one step the CLI can't do itself: a child\n // process can't export into the shell that launched it. Gated on a\n // fresh workspace; on every routine pull this would just be noise.\n const printShellHint = (): void => {\n if (folderInitialised) return;\n console.log();\n logger.success(`Workspace ready for ${chalk.bold(tenant)}.`);\n logger.dim('To target this tenant in this shell, set:');\n logger.info(\n organisation === tenant\n ? ` export FARSEER_TENANT=${tenant}`\n : ` export FARSEER_TENANT=${tenant} FARSEER_ORG=${organisation}`,\n );\n logger.dim(`Or pass it explicitly each time: farseer status ${tenant}`);\n };\n\n let preStatus: SyncStatus | null = null;\n let preStatusError: Error | null = null;\n if (folderInitialised) {\n try {\n preStatus = await syncService.getStatus({ ...filterOptions, all: options.all, deep: false });\n } catch (error) {\n preStatusError = error as Error;\n logger.dim(`Could not compute pre-pull status: ${preStatusError.message}`);\n }\n }\n\n // Preview app deletions too. Without this the destructive\n // prompt only covers files and the user discovers (post-pull)\n // that an app JSON was wiped because someone deleted the app\n // on remote. Uses listApps only \u2014 no per-app fetch \u2014 so this\n // doesn't double the network cost of the apps pull below.\n //\n // Best-effort: a failure here shouldn't block the pull. Worst\n // case the user gets the legacy behaviour (silent app\n // deletion) on this run.\n const appSyncService = new AppSyncService(tenant, client);\n let appDeletions: string[] = [];\n try {\n appDeletions = await appSyncService.getRemoteDeletions();\n } catch (error) {\n logger.dim(`Could not compute pre-pull app deletions: ${(error as Error).message}`);\n }\n\n const localChanges = preStatus\n ? preStatus.addedLocally.length +\n preStatus.modifiedLocally.length +\n preStatus.deletedLocally.length +\n preStatus.conflicts.length\n : 0;\n const remoteDeletions = (preStatus?.deletedRemotely.length ?? 0) + appDeletions.length;\n\n // Step 2: Decide whether to confirm. The matrix:\n // --force \u2192 always confirm (destructive reset).\n // local edits OR remote deletions \u2192 confirm unless -y.\n // clean tree, no deletes \u2192 just go.\n //\n // Remote deletions are gated because pull would silently\n // remove a previously-synced local file/app if someone deleted\n // it on remote \u2014 a real script could vanish without warning.\n // Local edits stay gated for the existing reason: we don't\n // want to merge into a dirty tree without an opt-in.\n if (options.force) {\n console.log();\n console.log(chalk.red.bold('--force will hard-reset local to match remote.'));\n if (preStatus) {\n summarisePreStatus(preStatus);\n } else if (preStatusError) {\n // Without a local diff we'd be confirming a destructive\n // mirror operation blind. Refuse rather than press on \u2014\n // the cost of failing here is one re-run; the cost of\n // pressing on is silent loss of in-progress files.\n console.log(\n chalk.red(\n 'Cannot show what will be lost \u2014 pre-pull status failed (see line above). Refusing to --force without visibility.',\n ),\n );\n logger.dim('Re-run after the underlying issue clears, or use a non-force pull to merge.');\n process.exit(1);\n } else {\n // Folder isn't initialised yet \u2014 first --force pull on a\n // brand-new tenant. Nothing local to lose; proceed.\n logger.dim('No local files yet \u2014 nothing to discard.');\n }\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: `Discard local changes and reset ${tenant} to remote?`,\n default: false,\n },\n ]);\n if (!confirm.proceed) {\n logger.info('Pull cancelled.');\n return;\n }\n } else if ((localChanges > 0 || remoteDeletions > 0) && !options.yes) {\n console.log();\n if (localChanges > 0) {\n logger.warning(`Local has ${localChanges} unsynced change(s).`);\n summarisePreStatus(preStatus!);\n logger.dim('Pull will keep your edits and merge remote-side changes around them.');\n }\n if (remoteDeletions > 0) {\n logger.warning(`Pull will remove ${remoteDeletions} local item(s) that were deleted on remote:`);\n summariseRemoteDeletions(preStatus?.deletedRemotely ?? [], appDeletions);\n logger.dim('Decline to abort and keep your local copies (you can push them back to restore).');\n }\n if (localChanges > 0 && remoteDeletions === 0) {\n logger.dim('To wipe local and reset to remote: re-run with --force.');\n }\n const promptMessage =\n remoteDeletions > 0 && localChanges > 0\n ? `Continue pull (merge into dirty tree AND delete ${remoteDeletions} local item(s))?`\n : remoteDeletions > 0\n ? `Continue pull and delete ${remoteDeletions} local item(s)?`\n : `Continue pulling into a dirty working tree?`;\n // Dirty-tree-only keeps the soft default (Enter = continue\n // merge). The moment remote deletions are on the table we\n // flip to default-false: a wrong \"yes\" wipes local items\n // for good, same calculus as `pull --force` below.\n const confirm = await inquirer.prompt([\n {\n type: 'confirm',\n name: 'proceed',\n message: promptMessage,\n default: remoteDeletions === 0,\n },\n ]);\n if (!confirm.proceed) {\n logger.info('Pull cancelled.');\n return;\n }\n }\n\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(syncOptions);\n\n // Conflicts: prompt per file (only when not --force).\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 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 for (const conflict of result.conflicts) {\n let choices: { name: string; value: string }[];\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 // Only offer git-style merge for files we know\n // are text. Binary blobs would just get\n // corrupted by UTF-8 splicing. The service has\n // a defensive fallback for binary anyway, but\n // not showing the option avoids the confusing\n // \"I picked merge_markers but got keep_both\"\n // experience.\n if (isLikelyTextFile(conflict.filePath)) {\n choices.push({\n name: 'Merge with markers (git-style \u2014 edit file, then push to finish)',\n value: 'merge_markers',\n });\n }\n }\n const answer = await inquirer.prompt([\n {\n type: 'list',\n name: 'resolution',\n message: `${conflict.filePath} - ${conflict.description}`,\n choices,\n },\n ]);\n resolutions[conflict.filePath] = answer.resolution;\n }\n result = await syncService.pull({ ...syncOptions, conflictResolutions: resolutions });\n }\n\n if (result.downloaded.length > 0) {\n console.log(chalk.green('Downloaded:'));\n for (const file of result.downloaded) console.log(chalk.green(` + ${file}`));\n }\n\n if (result.deleted.length > 0) {\n console.log(chalk.red('Deleted (removed from remote):'));\n for (const file of result.deleted) console.log(chalk.red(` - ${file}`));\n }\n\n if (result.conflictFilesWritten.length > 0) {\n console.log(chalk.yellow('Conflict files created:'));\n for (const file of result.conflictFilesWritten) console.log(chalk.yellow(` ~ ${file}`));\n if (result.conflictFilesWritten.some((f) => f.includes('(merge markers)'))) {\n console.log();\n logger.dim('Files marked with \"(merge markers)\" contain git-style <<<<<<</=======/>>>>>>>');\n logger.dim('blocks. Open them, pick which version to keep, remove the marker lines,');\n logger.dim(`then run \\`farseer push ${tenant}\\` to upload the resolved version.`);\n }\n }\n\n logger.dim(\n `Files: +${result.downloaded.length} -${result.deleted.length} (${result.unchanged.length} unchanged)`,\n );\n\n // --force extra: also delete any local-only files. The\n // service-level pull keeps `local_new` files unchanged\n // (it's the right default for a non-destructive pull),\n // but --force at the command layer means \"mirror remote\",\n // so remove those locally.\n let extraLocalDeletes: string[] = [];\n if (options.force) {\n // Forward `--all` so `pull --force --all` wipes every\n // local-only file in scope, not just those that match\n // the default sync scope.\n extraLocalDeletes = await wipeLocalOnly(syncService, filesDir, {\n ...filterOptions,\n all: options.all,\n });\n if (extraLocalDeletes.length > 0) {\n console.log(chalk.red('Local-only files removed (mirror remote):'));\n for (const file of extraLocalDeletes) console.log(chalk.red(` - ${file}`));\n }\n }\n\n // Audit log\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 appendToAuditLog(tenant, auditEntries);\n }\n\n let hasChanges =\n result.downloaded.length > 0 || result.deleted.length > 0 || extraLocalDeletes.length > 0;\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 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) console.log(chalk.green(` + ${app}`));\n }\n if (appResult.updated.length > 0) {\n console.log(chalk.yellow('Updated apps:'));\n for (const app of appResult.updated) console.log(chalk.yellow(` ~ ${app}`));\n }\n if (appResult.deleted.length > 0) {\n console.log(chalk.red('Deleted apps (removed from remote):'));\n for (const app of appResult.deleted) console.log(chalk.red(` - ${app}`));\n }\n\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n\n hasChanges =\n hasChanges ||\n appResult.created.length > 0 ||\n appResult.updated.length > 0 ||\n appResult.deleted.length > 0;\n\n if (!hasChanges) {\n logger.success('Already up to date.');\n printShellHint();\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(\n `Files: +${result.downloaded.length} -${result.deleted.length} ${\n extraLocalDeletes.length > 0 ? `(${extraLocalDeletes.length} local-only removed) ` : ''\n }(${result.unchanged.length} unchanged)`,\n );\n logger.dim(\n `Apps: +${appResult.created.length} ~${appResult.updated.length} -${appResult.deleted.length} (${appResult.unchanged.length} unchanged)`,\n );\n printShellHint();\n } catch (error) {\n fileLogger.error('pull', error);\n logger.error('Pull failed.');\n logger.error(await formatClientError(error));\n const logPath = fileLogger.getLogPath();\n if (logPath) {\n logger.dim(`Debug log: ${logPath}`);\n }\n process.exit(1);\n }\n });\n}\n\n/**\n * Print actual paths (not just counts) so the user can see what local\n * changes a `pull --force` is about to overwrite. Counts alone hid the\n * destructive blast radius: under `--force --all` someone could lose\n * dozens of in-progress files without knowing which ones. Cap at\n * MAX_PATHS_PER_SECTION per section to avoid scrollback floods on huge\n * trees \u2014 anything beyond that collapses into \"+ N more\".\n */\nfunction summarisePreStatus(status: SyncStatus): void {\n const MAX_PATHS_PER_SECTION = 20;\n const renderSection = (label: string, paths: string[], color: (s: string) => string) => {\n if (paths.length === 0) return;\n console.log(color(` ${label} (${paths.length}):`));\n const visible = paths.slice(0, MAX_PATHS_PER_SECTION);\n for (const p of visible) console.log(color(` ${p}`));\n if (paths.length > MAX_PATHS_PER_SECTION) {\n console.log(chalk.dim(` ... and ${paths.length - MAX_PATHS_PER_SECTION} more`));\n }\n };\n renderSection('+ new local file(s)', status.addedLocally, chalk.green);\n renderSection('M locally modified file(s)', status.modifiedLocally, chalk.yellow);\n renderSection('- locally deleted file(s)', status.deletedLocally, chalk.red);\n if (status.conflicts.length > 0) {\n const conflictPaths = status.conflicts.map((c) => c.filePath);\n renderSection('! conflict(s)', conflictPaths, chalk.red.bold);\n }\n console.log();\n}\n\n/**\n * Print the file + app paths that pull is about to delete because remote\n * removed them. Same cap as `summarisePreStatus` so a huge purge doesn't\n * flood the scrollback \u2014 the user still gets the count above.\n */\nfunction summariseRemoteDeletions(deletedFiles: string[], deletedApps: string[]): void {\n const MAX_PATHS_PER_SECTION = 20;\n const renderSection = (label: string, paths: string[]) => {\n if (paths.length === 0) return;\n console.log(chalk.red(` ${label} (${paths.length}):`));\n const visible = paths.slice(0, MAX_PATHS_PER_SECTION);\n for (const p of visible) console.log(chalk.red(` - ${p}`));\n if (paths.length > MAX_PATHS_PER_SECTION) {\n console.log(chalk.dim(` ... and ${paths.length - MAX_PATHS_PER_SECTION} more`));\n }\n };\n renderSection('file(s) deleted on remote', deletedFiles);\n renderSection('app(s) deleted on remote', deletedApps);\n console.log();\n}\n\n/**\n * Hard-reset helper for `pull --force`. Removes local files that have no\n * remote counterpart (the regular pull keeps them \u2014 see service comment).\n * Cleans up the syncState entry too so the next status doesn't show ghosts.\n */\nasync function wipeLocalOnly(\n syncService: SyncService,\n filesDir: string,\n filterOptions: { all?: boolean; includeExtensions?: string[]; includeFolders?: string[] },\n): Promise<string[]> {\n // `all` matters: under `pull --force --all` the user expects every\n // local-only file to be wiped, not just files in the default sync\n // scope. Without it, getStatus filters down to the curated developer\n // files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden\n // directories and the folder blocklist, so the wipe loop never sees\n // anything those rules exclude.\n const status = await syncService.getStatus({ ...filterOptions, deep: false });\n const removed: string[] = [];\n const failed: { file: string; reason: string }[] = [];\n const syncState = syncService.loadSyncState();\n for (const file of status.addedLocally) {\n const fullPath = safeResolveWithinBase(filesDir, file);\n if (fs.existsSync(fullPath)) {\n // Wrap each unlink so a single permission error / file lock\n // doesn't strand the rest of the wipe. syncState is saved\n // incrementally as each unlink succeeds so a mid-run failure\n // leaves a consistent record for the next run, and the failed\n // list is surfaced at the end for manual cleanup.\n try {\n fs.unlinkSync(fullPath);\n removed.push(file);\n delete syncState.files[file];\n syncService.saveSyncState(syncState);\n } catch (err) {\n failed.push({ file, reason: err instanceof Error ? err.message : String(err) });\n }\n } else {\n // File was already gone \u2014 just drop the syncState entry.\n delete syncState.files[file];\n syncService.saveSyncState(syncState);\n }\n }\n if (failed.length > 0) {\n logger.warning(`${failed.length} local-only file(s) could not be removed:`);\n for (const f of failed) logger.dim(` ${f.file} \u2014 ${f.reason}`);\n }\n return removed;\n}\n\nasync function createDefaultPackageJson(tenantDir: string, tenant: string): Promise<void> {\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': FARSEER_CLIENT_URL,\n 'farseer-client-axios': FARSEER_CLIENT_AXIOS_URL,\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,wBAA2B;AAC3B,uBAA0B;AAC1B,yBAA6D;AAC7D,4BAA+B;AAC/B,qBAOO;AACP,4BAAkC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;AAAA,MACb,iBAAiB;AAAA,MACjB,cAAc;AAAA,MACd,QAAQ;AAAA,MACR,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,kBAAkB;AAAA,MAClB,wBAAwB;AAAA,MACxB,mBAAmB;AAAA,MACnB,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,UAAU;AAAA,MACV,cAAc;AAAA,MACd,OAAO;AAAA,MACP,iBAAiB;AAAA,MACjB,OAAO;AAAA,MACP,cAAc;AAAA,MACd,cAAc;AAAA,MACd,gBAAgB;AAAA,MAChB,SAAS;AAAA,MACT,UAAU;AAAA,MACV,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM;AAAA,MACN,oBAAoB;AAAA,MACpB,eAAe;AAAA,MACf,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM;AAAA,MACN,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,YAAY;AAAA,IAChB;AAAA,EACJ;AAEA,KAAG,cAAc,iBAAiB,KAAK,UAAU,aAAa,MAAM,CAAC,GAAG,OAAO;AAC/E,uBAAO,IAAI,4BAA4B,MAAM,EAAE;AACnD;",
|
|
6
6
|
"names": ["chalk", "inquirer"]
|
|
7
7
|
}
|
package/dist/commands/run.js
CHANGED
|
@@ -31,6 +31,7 @@ __export(run_exports, {
|
|
|
31
31
|
registerRunCommand: () => registerRunCommand
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(run_exports);
|
|
34
|
+
var import_agentSandbox = require("../utils/agentSandbox");
|
|
34
35
|
var import_logger = require("../utils/logger");
|
|
35
36
|
var import_configService = require("../services/configService");
|
|
36
37
|
var import_farseerService = require("../services/farseerService");
|
|
@@ -85,6 +86,10 @@ function collectArgs(value, previous) {
|
|
|
85
86
|
}
|
|
86
87
|
function registerRunCommand(program) {
|
|
87
88
|
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, []).option("--id <id>", "Select the app by its numeric id (use when names collide)").action(async (args, options) => {
|
|
89
|
+
if ((0, import_agentSandbox.inAgentSandbox)()) {
|
|
90
|
+
import_logger.logger.error(import_agentSandbox.LOCAL_APP_RUNS_UNAVAILABLE);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
88
93
|
const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args, {
|
|
89
94
|
allowEmptyName: !!options.id,
|
|
90
95
|
command: "run"
|
|
@@ -195,6 +200,10 @@ function registerRunCommand(program) {
|
|
|
195
200
|
});
|
|
196
201
|
});
|
|
197
202
|
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) => {
|
|
203
|
+
if ((0, import_agentSandbox.inAgentSandbox)()) {
|
|
204
|
+
import_logger.logger.error(import_agentSandbox.LOCAL_APP_RUNS_UNAVAILABLE);
|
|
205
|
+
process.exit(1);
|
|
206
|
+
}
|
|
198
207
|
const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args);
|
|
199
208
|
await (0, import_preflight.preflightForPair)(organisation, tenant);
|
|
200
209
|
let script = appName;
|