farseer-cli 1.8.2 → 1.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -4
- package/dist/commands/app.js +42 -80
- package/dist/commands/app.js.map +2 -2
- package/dist/commands/pull.js +44 -9
- package/dist/commands/pull.js.map +2 -2
- package/dist/mcp/prompts/workflows.js +1 -1
- package/dist/mcp/prompts/workflows.js.map +2 -2
- package/dist/mcp/tools/appTools.js +33 -61
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/services/appSyncService.js +35 -31
- package/dist/services/appSyncService.js.map +2 -2
- package/dist/services/farseerApi.js +95 -16
- package/dist/services/farseerApi.js.map +3 -3
- package/dist/services/farseerFactory.js.map +1 -1
- package/dist/services/farseerService.js +11 -14
- package/dist/services/farseerService.js.map +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -473,7 +473,6 @@ Output:
|
|
|
473
473
|
"name": "My Import App",
|
|
474
474
|
"description": "Imports sales data",
|
|
475
475
|
"entrypoint": "import-sales.ts",
|
|
476
|
-
"scripts": ["import-sales.ts", "helpers.ts"],
|
|
477
476
|
"arguments": [
|
|
478
477
|
{ "name": "Year", "defaultValue": "2025" },
|
|
479
478
|
{ "name": "Version", "defaultValue": "Plan" }
|
|
@@ -495,9 +494,15 @@ Creates JSON file in `apps/<tenant>/apps/`. Use `push` to upload to instance.
|
|
|
495
494
|
|
|
496
495
|
Configure app settings.
|
|
497
496
|
|
|
497
|
+
An app's scripts are derived from its source folder, and the entrypoint must be one of
|
|
498
|
+
those files. Set the source folder first, then pick an entrypoint inside it.
|
|
499
|
+
|
|
498
500
|
```bash
|
|
499
|
-
# Set
|
|
500
|
-
farseer app configure My App --
|
|
501
|
+
# Set the source folder (path under Files/) the app's scripts come from
|
|
502
|
+
farseer app configure My App --source-folder "Scripts/MyApp"
|
|
503
|
+
|
|
504
|
+
# Set the entrypoint (must be a file in the source folder)
|
|
505
|
+
farseer app configure My App --entrypoint index.ts
|
|
501
506
|
|
|
502
507
|
# Add argument
|
|
503
508
|
farseer app configure My App --add-arg "Year=2025"
|
|
@@ -506,6 +511,16 @@ farseer app configure My App --add-arg "Year=2025"
|
|
|
506
511
|
farseer app configure My App --description "Imports data"
|
|
507
512
|
```
|
|
508
513
|
|
|
514
|
+
Settings you don't pass are preserved — `configure` only changes what you specify.
|
|
515
|
+
|
|
516
|
+
If you move the source folder to one that doesn't contain the app's current
|
|
517
|
+
entrypoint, pass `--entrypoint` in the same command — `configure` errors rather
|
|
518
|
+
than silently clearing or relocating the entrypoint.
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
farseer app configure My App --source-folder "Scripts/NewFolder" --entrypoint index.ts
|
|
522
|
+
```
|
|
523
|
+
|
|
509
524
|
### `farseer app delete <name>`
|
|
510
525
|
|
|
511
526
|
Delete app (requires `--force`).
|
|
@@ -750,7 +765,6 @@ apps/
|
|
|
750
765
|
"name": "My Import App",
|
|
751
766
|
"description": "Imports sales data",
|
|
752
767
|
"entrypoint": "import-sales.ts",
|
|
753
|
-
"scripts": ["import-sales.ts", "helpers.ts"],
|
|
754
768
|
"arguments": [
|
|
755
769
|
{ "name": "Year", "defaultValue": "2025" },
|
|
756
770
|
{ "name": "Version", "defaultValue": "Plan" }
|
package/dist/commands/app.js
CHANGED
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(app_exports);
|
|
|
34
34
|
var import_chalk = __toESM(require("chalk"));
|
|
35
35
|
var import_logger = require("../utils/logger");
|
|
36
36
|
var import_farseerFactory = require("../services/farseerFactory");
|
|
37
|
+
var import_farseerApi = require("../services/farseerApi");
|
|
37
38
|
var import_helpers = require("../utils/helpers");
|
|
38
39
|
function registerAppCommand(program) {
|
|
39
40
|
const appCmd = program.command("app").description("Manage apps on a Farseer instance").addHelpText(
|
|
@@ -43,7 +44,7 @@ Commands:
|
|
|
43
44
|
list [tenant] List all apps
|
|
44
45
|
show [tenant] <name...> Show app details
|
|
45
46
|
create [tenant] <name...> Create a new app
|
|
46
|
-
configure [tenant] <name...> Configure app (
|
|
47
|
+
configure [tenant] <name...> Configure app (source folder, entrypoint, arguments)
|
|
47
48
|
delete [tenant] <name...> Delete an app (requires --force)
|
|
48
49
|
|
|
49
50
|
Note: App names with spaces don't need quotes if tenant is checked out.
|
|
@@ -217,7 +218,12 @@ Examples:
|
|
|
217
218
|
}
|
|
218
219
|
import_logger.logger.info(`Deleting app: ${app.name}...`);
|
|
219
220
|
try {
|
|
220
|
-
await api.deleteApp(app.
|
|
221
|
+
await api.deleteApp(app.id);
|
|
222
|
+
const remaining = await api.listApps();
|
|
223
|
+
if (remaining.some((a) => a.id === app.id)) {
|
|
224
|
+
import_logger.logger.error(`Delete reported success but "${app.name}" is still present.`);
|
|
225
|
+
process.exit(1);
|
|
226
|
+
}
|
|
221
227
|
import_logger.logger.success(`App deleted: ${app.name}`);
|
|
222
228
|
} catch (error) {
|
|
223
229
|
import_logger.logger.error("Failed to delete app.");
|
|
@@ -227,7 +233,13 @@ Examples:
|
|
|
227
233
|
process.exit(1);
|
|
228
234
|
}
|
|
229
235
|
});
|
|
230
|
-
appCmd.command("configure <args...>").description("Configure an app (set
|
|
236
|
+
appCmd.command("configure <args...>").description("Configure an app (set source folder, entrypoint, arguments)").option(
|
|
237
|
+
"--entrypoint <script>",
|
|
238
|
+
`Set the entrypoint script \u2014 must be a file in the app's source folder (e.g., "index.ts")`
|
|
239
|
+
).option(
|
|
240
|
+
"--source-folder <path>",
|
|
241
|
+
`Set the source folder the app's scripts come from (path under Files/, e.g. "Scripts/MyApp")`
|
|
242
|
+
).option(
|
|
231
243
|
"--add-arg <arg>",
|
|
232
244
|
'Add argument in format "Name=DefaultValue" (can be used multiple times)',
|
|
233
245
|
collectArgs,
|
|
@@ -251,64 +263,23 @@ Examples:
|
|
|
251
263
|
import_logger.logger.error(`Failed to load app details: ${appName}`);
|
|
252
264
|
process.exit(1);
|
|
253
265
|
}
|
|
254
|
-
const
|
|
266
|
+
const changes = {};
|
|
255
267
|
if (options.name) {
|
|
256
|
-
|
|
268
|
+
changes.name = options.name;
|
|
257
269
|
}
|
|
258
270
|
if (options.description !== void 0) {
|
|
259
|
-
|
|
271
|
+
changes.description = options.description;
|
|
260
272
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
(s) => s.name.toLowerCase() === name.toLowerCase()
|
|
272
|
-
);
|
|
273
|
-
if (!script) {
|
|
274
|
-
import_logger.logger.error(`Script not found: ${name}`);
|
|
275
|
-
import_logger.logger.dim(
|
|
276
|
-
"Available scripts: " + availableScripts.map((s) => s.name).join(", ")
|
|
277
|
-
);
|
|
278
|
-
process.exit(1);
|
|
279
|
-
}
|
|
280
|
-
scriptIds.push(script.id);
|
|
281
|
-
resolvedScripts.push({ id: script.id, name: script.name });
|
|
282
|
-
}
|
|
283
|
-
update.scriptFileIds = scriptIds;
|
|
284
|
-
if (!options.entrypoint && !app.mainScriptFileId && resolvedScripts.length > 0) {
|
|
285
|
-
update.mainScriptFileId = resolvedScripts[0].id;
|
|
286
|
-
autoSetEntrypoint = true;
|
|
287
|
-
autoEntrypointName = resolvedScripts[0].name;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
if (options.entrypoint) {
|
|
291
|
-
const entryScript = availableScripts.find(
|
|
292
|
-
(s) => s.name.toLowerCase() === options.entrypoint.toLowerCase()
|
|
293
|
-
);
|
|
294
|
-
if (!entryScript) {
|
|
295
|
-
import_logger.logger.error(`Entrypoint script not found: ${options.entrypoint}`);
|
|
296
|
-
import_logger.logger.dim(
|
|
297
|
-
"Available scripts: " + availableScripts.map((s) => s.name).join(", ")
|
|
298
|
-
);
|
|
299
|
-
process.exit(1);
|
|
300
|
-
}
|
|
301
|
-
update.mainScriptFileId = entryScript.id;
|
|
302
|
-
if (!update.scriptFileIds) {
|
|
303
|
-
update.scriptFileIds = [entryScript.id];
|
|
304
|
-
} else if (!update.scriptFileIds.includes(entryScript.id)) {
|
|
305
|
-
update.scriptFileIds.push(entryScript.id);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
if (autoSetEntrypoint) {
|
|
309
|
-
import_logger.logger.info(`Auto-set "${autoEntrypointName}" as entrypoint (first script).`);
|
|
310
|
-
import_logger.logger.dim(`Change with: farseer app configure "${appName}" --entrypoint <script>`);
|
|
311
|
-
}
|
|
273
|
+
const sourceFolderError = await (0, import_farseerApi.applySourceFolderChange)(
|
|
274
|
+
api,
|
|
275
|
+
app,
|
|
276
|
+
changes,
|
|
277
|
+
{ sourceFolder: options.sourceFolder, entrypoint: options.entrypoint },
|
|
278
|
+
"cli"
|
|
279
|
+
);
|
|
280
|
+
if (sourceFolderError) {
|
|
281
|
+
import_logger.logger.error(sourceFolderError);
|
|
282
|
+
process.exit(1);
|
|
312
283
|
}
|
|
313
284
|
if (options.addArg && options.addArg.length > 0) {
|
|
314
285
|
const newArgs = [...app.expectedArguments];
|
|
@@ -330,38 +301,29 @@ Examples:
|
|
|
330
301
|
newArgs.push({ name, dataType: "string", defaultValue });
|
|
331
302
|
}
|
|
332
303
|
}
|
|
333
|
-
|
|
304
|
+
changes.expectedArguments = newArgs;
|
|
334
305
|
}
|
|
335
|
-
if (Object.keys(
|
|
306
|
+
if (Object.keys(changes).length === 0) {
|
|
336
307
|
import_logger.logger.warning("No changes specified.");
|
|
337
|
-
import_logger.logger.dim(
|
|
308
|
+
import_logger.logger.dim(
|
|
309
|
+
"Use --entrypoint, --source-folder, --add-arg, --description, or --name to configure the app."
|
|
310
|
+
);
|
|
338
311
|
return;
|
|
339
312
|
}
|
|
340
313
|
import_logger.logger.info(`Updating app: ${app.name}...`);
|
|
341
314
|
try {
|
|
342
|
-
|
|
343
|
-
update.name = app.name;
|
|
344
|
-
}
|
|
345
|
-
if (update.description === void 0) {
|
|
346
|
-
update.description = app.description || "";
|
|
347
|
-
}
|
|
348
|
-
const updated = await api.updateApp(appListItem.reference, update);
|
|
315
|
+
const updated = await api.updateApp(appListItem.reference, changes, app);
|
|
349
316
|
import_logger.logger.success(`App updated: ${updated.name}`);
|
|
350
|
-
if (
|
|
351
|
-
if (
|
|
352
|
-
|
|
317
|
+
if (changes.name) console.log(` Name: ${updated.name}`);
|
|
318
|
+
if (changes.description !== void 0)
|
|
319
|
+
console.log(` Description: ${updated.description || "(empty)"}`);
|
|
320
|
+
if (changes.sourceFolderId !== void 0 || changes.mainScriptFileId !== void 0) {
|
|
353
321
|
const updatedScripts = updated.scriptFiles ?? [];
|
|
354
|
-
const mainScript = updatedScripts.find(
|
|
355
|
-
|
|
356
|
-
);
|
|
357
|
-
console.log(` Entrypoint: ${mainScript?.name}`);
|
|
358
|
-
}
|
|
359
|
-
if (update.scriptFileIds) {
|
|
360
|
-
console.log(
|
|
361
|
-
` Scripts: ${(updated.scriptFiles ?? []).map((s) => s.name).join(", ")}`
|
|
362
|
-
);
|
|
322
|
+
const mainScript = updatedScripts.find((s) => s.id === updated.mainScriptFileId);
|
|
323
|
+
console.log(` Entrypoint: ${mainScript?.name ?? "(none)"}`);
|
|
324
|
+
console.log(` Scripts: ${updatedScripts.map((s) => s.name).join(", ") || "(none)"}`);
|
|
363
325
|
}
|
|
364
|
-
if (
|
|
326
|
+
if (changes.expectedArguments) {
|
|
365
327
|
console.log(
|
|
366
328
|
` Arguments: ${updated.expectedArguments.map((a) => {
|
|
367
329
|
const tags = [];
|
package/dist/commands/app.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/app.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt, IFarseerClient } from '../services/farseerFactory';\nimport { AppArgument } from '../services/farseerApi';\nimport { parseAppArgs, resolveTenantWithOrgMapping } from '../utils/helpers';\n\nexport function registerAppCommand(program: Command): void {\n const appCmd = program\n .command('app')\n .description('Manage apps on a Farseer instance')\n .addHelpText(\n 'after',\n `\nCommands:\n list [tenant] List all apps\n show [tenant] <name...> Show app details\n create [tenant] <name...> Create a new app\n configure [tenant] <name...> Configure app (entrypoint, scripts, arguments)\n delete [tenant] <name...> Delete an app (requires --force)\n\nNote: App names with spaces don't need quotes if tenant is checked out.\n\nExamples:\n $ farseer app list mycompany # List all apps\n $ farseer app show mycompany \"My App\" # Explicit tenant\n $ farseer app show My App # Uses checked-out tenant\n $ farseer app configure \"My App\" --entrypoint index.ts\n`,\n );\n\n // List apps\n appCmd\n .command('list [tenant]')\n .description('List all apps on a Farseer instance')\n .option('--details', 'Show detailed information for each app')\n .action(async (tenantArg, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(tenantArg);\n\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api = result.client;\n const authLabel = result.authType === 'apiKey' ? 'API key' : 'browser login';\n logger.info(`Fetching apps from ${tenant} (using ${authLabel})...`);\n\n try {\n const apps = await api.listApps();\n\n if (apps.length === 0) {\n logger.warning('No apps found.');\n logger.dim('Create an app with: farseer app create <name>');\n return;\n }\n\n logger.header(`Apps on ${tenant}`);\n console.log();\n\n if (options.details) {\n // Fetch full details for each app\n for (const app of apps) {\n const details = await api.getApp(app.reference);\n if (details) {\n console.log(` \uD83D\uDCE6 ${chalk.bold(details.name)}`);\n if (details.description) {\n console.log(` ${chalk.dim(details.description)}`);\n }\n console.log(\n ` Status: ${details.status === 'AVAILABLE' ? chalk.green(details.status) : chalk.yellow(details.status)}`,\n );\n const detailScripts = details.scriptFiles ?? [];\n if (detailScripts.length > 0) {\n const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);\n console.log(\n ` Entrypoint: ${mainScript ? chalk.cyan(mainScript.name) : chalk.red('Not set')}`,\n );\n console.log(` Scripts:`);\n for (const script of detailScripts) {\n const isMain = script.id === details.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(` Scripts: ${chalk.dim('None')}`);\n }\n if (details.expectedArguments.length > 0) {\n console.log(` Arguments:`);\n for (const arg of details.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n }\n console.log();\n }\n }\n } else {\n // Simple list\n for (const app of apps) {\n console.log(` \uD83D\uDCE6 ${app.name}`);\n }\n console.log();\n logger.dim(`Total: ${apps.length} app(s)`);\n logger.dim('Use --details to see more information.');\n }\n } catch (error) {\n logger.error('Failed to list apps.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Show app details\n appCmd\n .command('show <args...>')\n .description('Show details of an app')\n .action(async (args: string[]) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api: IFarseerClient = result.client;\n const app = await api.getAppByName(appName);\n\n if (!app) {\n logger.error(`App not found: ${appName}`);\n process.exit(1);\n }\n\n logger.header(`App: ${app.name}`);\n console.log();\n console.log(` ID: ${app.id}`);\n console.log(` Status: ${app.status}`);\n if (app.description) {\n console.log(` Description: ${app.description}`);\n }\n console.log();\n\n const appScripts = app.scriptFiles ?? [];\n if (appScripts.length > 0) {\n console.log(' Scripts:');\n for (const script of appScripts) {\n const isMain = script.id === app.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(' Scripts: None');\n }\n console.log();\n\n if (app.expectedArguments.length > 0) {\n console.log(' Arguments:');\n for (const arg of app.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n } else {\n console.log(' Arguments: None');\n }\n console.log();\n });\n\n // Create app\n appCmd\n .command('create <args...>')\n .description('Create a new app')\n .action(async (args: string[]) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api: IFarseerClient = result.client;\n\n // Check if app already exists\n const existing = await api.getAppByName(appName);\n if (existing) {\n logger.error(`App already exists: ${appName}`);\n process.exit(1);\n }\n\n logger.info(`Creating app: ${appName}...`);\n\n try {\n const app = await api.createApp(appName);\n logger.success(`App created: ${app.name} (ID: ${app.id})`);\n logger.dim('Configure it with: farseer app configure \"' + appName + '\"');\n } catch (error) {\n logger.error('Failed to create app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Delete app\n appCmd\n .command('delete <args...>')\n .description('Delete an app')\n .option('--force', 'Skip confirmation')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api: IFarseerClient = result.client;\n\n // Find app\n const apps = await api.listApps();\n const app = apps.find((a: { name: string }) => a.name.toLowerCase() === appName.toLowerCase());\n if (!app) {\n logger.error(`App not found: ${appName}`);\n process.exit(1);\n }\n\n if (!options.force) {\n logger.warning(`This will permanently delete app: ${app.name}`);\n logger.dim('Use --force to skip this confirmation.');\n process.exit(1);\n }\n\n logger.info(`Deleting app: ${app.name}...`);\n\n try {\n await api.deleteApp(app.reference);\n logger.success(`App deleted: ${app.name}`);\n } catch (error) {\n logger.error('Failed to delete app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Configure app\n appCmd\n .command('configure <args...>')\n .description('Configure an app (set entrypoint, scripts, arguments)')\n .option('--entrypoint <script>', 'Set the entrypoint script (e.g., \"index.ts\")')\n .option('--scripts <scripts>', 'Comma-separated list of scripts to include')\n .option(\n '--add-arg <arg>',\n 'Add argument in format \"Name=DefaultValue\" (can be used multiple times)',\n collectArgs,\n [],\n )\n .option('--description <desc>', 'Set app description')\n .option('--name <name>', 'Rename the app')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api: IFarseerClient = result.client;\n\n // Find app\n const apps = await api.listApps();\n const appListItem = apps.find((a: { name: string }) => a.name.toLowerCase() === appName.toLowerCase());\n if (!appListItem) {\n logger.error(`App not found: ${appName}`);\n process.exit(1);\n }\n\n const app = await api.getApp(appListItem.reference);\n if (!app) {\n logger.error(`Failed to load app details: ${appName}`);\n process.exit(1);\n }\n\n // Build update object\n const update: {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n scriptFileIds?: string[];\n } = {};\n\n if (options.name) {\n update.name = options.name;\n }\n\n if (options.description !== undefined) {\n update.description = options.description;\n }\n\n // Handle scripts and entrypoint\n if (options.scripts || options.entrypoint) {\n const availableScripts = await api.getScriptFiles();\n let autoSetEntrypoint = false;\n let autoEntrypointName = '';\n\n if (options.scripts) {\n const scriptNames = options.scripts.split(',').map((s: string) => s.trim());\n const scriptIds: string[] = [];\n const resolvedScripts: { id: string; name: string }[] = [];\n\n for (const name of scriptNames) {\n const script = availableScripts.find(\n (s: { name: string }) => s.name.toLowerCase() === name.toLowerCase(),\n );\n if (!script) {\n logger.error(`Script not found: ${name}`);\n logger.dim(\n 'Available scripts: ' +\n availableScripts.map((s: { name: string }) => s.name).join(', '),\n );\n process.exit(1);\n }\n scriptIds.push(script.id);\n resolvedScripts.push({ id: script.id, name: script.name });\n }\n\n update.scriptFileIds = scriptIds;\n\n // Auto-set first script as entrypoint if no entrypoint specified and app has none\n if (!options.entrypoint && !app.mainScriptFileId && resolvedScripts.length > 0) {\n update.mainScriptFileId = resolvedScripts[0].id;\n autoSetEntrypoint = true;\n autoEntrypointName = resolvedScripts[0].name;\n }\n }\n\n if (options.entrypoint) {\n const entryScript = availableScripts.find(\n (s: { name: string }) => s.name.toLowerCase() === options.entrypoint.toLowerCase(),\n );\n if (!entryScript) {\n logger.error(`Entrypoint script not found: ${options.entrypoint}`);\n logger.dim(\n 'Available scripts: ' + availableScripts.map((s: { name: string }) => s.name).join(', '),\n );\n process.exit(1);\n }\n update.mainScriptFileId = entryScript.id;\n\n // If setting entrypoint but no scripts specified, include the entrypoint in scripts\n if (!update.scriptFileIds) {\n update.scriptFileIds = [entryScript.id];\n } else if (!update.scriptFileIds.includes(entryScript.id)) {\n update.scriptFileIds.push(entryScript.id);\n }\n }\n\n // Notify user about auto-set entrypoint\n if (autoSetEntrypoint) {\n logger.info(`Auto-set \"${autoEntrypointName}\" as entrypoint (first script).`);\n logger.dim(`Change with: farseer app configure \"${appName}\" --entrypoint <script>`);\n }\n }\n\n // Handle arguments\n if (options.addArg && options.addArg.length > 0) {\n const newArgs: AppArgument[] = [...app.expectedArguments];\n\n for (const arg of options.addArg) {\n const [name, defaultValue] = arg.split('=');\n if (!name || defaultValue === undefined) {\n logger.error(`Invalid argument format: ${arg}`);\n logger.dim('Use format: --add-arg \"Name=DefaultValue\"');\n process.exit(1);\n }\n\n // Check if arg already exists. Lookup is case-insensitive\n // (user-friendly: --add-arg JOBNAME=x updates an existing\n // jobName), but the written name uses the backend's stored\n // casing \u2014 validateExpectedArguments on the server is\n // case-sensitive, and writing the caller-supplied case\n // would silently rename the arg.\n //\n // --add-arg only sets the defaultValue on a string arg; any\n // existing axes (`dataType`, `fixed`, `options`, `secret`)\n // are preserved so updating a boolean/dropdown/locked arg\n // with --add-arg doesn't silently demote it.\n const existingIdx = newArgs.findIndex((a) => a.name.toLowerCase() === name.toLowerCase());\n if (existingIdx >= 0) {\n const existing = newArgs[existingIdx];\n newArgs[existingIdx] = {\n ...existing,\n defaultValue,\n };\n } else {\n newArgs.push({ name, dataType: 'string', defaultValue });\n }\n }\n\n update.expectedArguments = newArgs;\n }\n\n if (Object.keys(update).length === 0) {\n logger.warning('No changes specified.');\n logger.dim('Use --entrypoint, --scripts, --add-arg, --description, or --name to configure the app.');\n return;\n }\n\n logger.info(`Updating app: ${app.name}...`);\n\n try {\n // API requires name field to be present\n if (!update.name) {\n update.name = app.name;\n }\n if (update.description === undefined) {\n update.description = app.description || '';\n }\n const updated = await api.updateApp(appListItem.reference, update);\n logger.success(`App updated: ${updated.name}`);\n\n // Show summary of changes\n if (update.name) console.log(` Name: ${updated.name}`);\n if (update.description !== undefined) console.log(` Description: ${updated.description || '(empty)'}`);\n if (update.mainScriptFileId) {\n const updatedScripts = updated.scriptFiles ?? [];\n const mainScript = updatedScripts.find(\n (s: { id: string | number }) => s.id === updated.mainScriptFileId,\n );\n console.log(` Entrypoint: ${mainScript?.name}`);\n }\n if (update.scriptFileIds) {\n console.log(\n ` Scripts: ${(updated.scriptFiles ?? []).map((s: { name: string }) => s.name).join(', ')}`,\n );\n }\n if (update.expectedArguments) {\n console.log(\n ` Arguments: ${updated.expectedArguments\n .map((a) => {\n const tags: string[] = [];\n if (a.fixed) tags.push('locked');\n if (a.dataType === 'boolean') tags.push('boolean');\n else if (a.options && a.options.length > 0) tags.push('dropdown');\n if (a.secret) tags.push('secret');\n const suffix = tags.length > 0 ? ` (${tags.join(', ')})` : '';\n return `${a.name}=${a.defaultValue ?? ''}${suffix}`;\n })\n .join(', ')}`,\n );\n }\n } catch (error) {\n logger.error('Failed to update app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n\n// Helper to collect multiple --add-arg options\nfunction collectArgs(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,4BAA8E;
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { getFarseerClientWithFallback, showLoginPrompt, IFarseerClient } from '../services/farseerFactory';\nimport { AppArgument, AppUpdateChanges, applySourceFolderChange } from '../services/farseerApi';\nimport { parseAppArgs, resolveTenantWithOrgMapping } from '../utils/helpers';\n\nexport function registerAppCommand(program: Command): void {\n const appCmd = program\n .command('app')\n .description('Manage apps on a Farseer instance')\n .addHelpText(\n 'after',\n `\nCommands:\n list [tenant] List all apps\n show [tenant] <name...> Show app details\n create [tenant] <name...> Create a new app\n configure [tenant] <name...> Configure app (source folder, entrypoint, arguments)\n delete [tenant] <name...> Delete an app (requires --force)\n\nNote: App names with spaces don't need quotes if tenant is checked out.\n\nExamples:\n $ farseer app list mycompany # List all apps\n $ farseer app show mycompany \"My App\" # Explicit tenant\n $ farseer app show My App # Uses checked-out tenant\n $ farseer app configure \"My App\" --entrypoint index.ts\n`,\n );\n\n // List apps\n appCmd\n .command('list [tenant]')\n .description('List all apps on a Farseer instance')\n .option('--details', 'Show detailed information for each app')\n .action(async (tenantArg, options) => {\n const { organisation, tenant } = resolveTenantWithOrgMapping(tenantArg);\n\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api = result.client;\n const authLabel = result.authType === 'apiKey' ? 'API key' : 'browser login';\n logger.info(`Fetching apps from ${tenant} (using ${authLabel})...`);\n\n try {\n const apps = await api.listApps();\n\n if (apps.length === 0) {\n logger.warning('No apps found.');\n logger.dim('Create an app with: farseer app create <name>');\n return;\n }\n\n logger.header(`Apps on ${tenant}`);\n console.log();\n\n if (options.details) {\n // Fetch full details for each app\n for (const app of apps) {\n const details = await api.getApp(app.reference);\n if (details) {\n console.log(` \uD83D\uDCE6 ${chalk.bold(details.name)}`);\n if (details.description) {\n console.log(` ${chalk.dim(details.description)}`);\n }\n console.log(\n ` Status: ${details.status === 'AVAILABLE' ? chalk.green(details.status) : chalk.yellow(details.status)}`,\n );\n const detailScripts = details.scriptFiles ?? [];\n if (detailScripts.length > 0) {\n const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);\n console.log(\n ` Entrypoint: ${mainScript ? chalk.cyan(mainScript.name) : chalk.red('Not set')}`,\n );\n console.log(` Scripts:`);\n for (const script of detailScripts) {\n const isMain = script.id === details.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(` Scripts: ${chalk.dim('None')}`);\n }\n if (details.expectedArguments.length > 0) {\n console.log(` Arguments:`);\n for (const arg of details.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n }\n console.log();\n }\n }\n } else {\n // Simple list\n for (const app of apps) {\n console.log(` \uD83D\uDCE6 ${app.name}`);\n }\n console.log();\n logger.dim(`Total: ${apps.length} app(s)`);\n logger.dim('Use --details to see more information.');\n }\n } catch (error) {\n logger.error('Failed to list apps.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Show app details\n appCmd\n .command('show <args...>')\n .description('Show details of an app')\n .action(async (args: string[]) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api: IFarseerClient = result.client;\n const app = await api.getAppByName(appName);\n\n if (!app) {\n logger.error(`App not found: ${appName}`);\n process.exit(1);\n }\n\n logger.header(`App: ${app.name}`);\n console.log();\n console.log(` ID: ${app.id}`);\n console.log(` Status: ${app.status}`);\n if (app.description) {\n console.log(` Description: ${app.description}`);\n }\n console.log();\n\n const appScripts = app.scriptFiles ?? [];\n if (appScripts.length > 0) {\n console.log(' Scripts:');\n for (const script of appScripts) {\n const isMain = script.id === app.mainScriptFileId;\n console.log(\n ` ${isMain ? chalk.green('\u25B6') : ' '} ${script.name}${isMain ? chalk.dim(' (entrypoint)') : ''}`,\n );\n }\n } else {\n console.log(' Scripts: None');\n }\n console.log();\n\n if (app.expectedArguments.length > 0) {\n console.log(' Arguments:');\n for (const arg of app.expectedArguments) {\n console.log(` - ${arg.name}: ${chalk.dim(arg.defaultValue ?? '')}`);\n }\n } else {\n console.log(' Arguments: None');\n }\n console.log();\n });\n\n // Create app\n appCmd\n .command('create <args...>')\n .description('Create a new app')\n .action(async (args: string[]) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api: IFarseerClient = result.client;\n\n // Check if app already exists\n const existing = await api.getAppByName(appName);\n if (existing) {\n logger.error(`App already exists: ${appName}`);\n process.exit(1);\n }\n\n logger.info(`Creating app: ${appName}...`);\n\n try {\n const app = await api.createApp(appName);\n logger.success(`App created: ${app.name} (ID: ${app.id})`);\n logger.dim('Configure it with: farseer app configure \"' + appName + '\"');\n } catch (error) {\n logger.error('Failed to create app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Delete app\n appCmd\n .command('delete <args...>')\n .description('Delete an app')\n .option('--force', 'Skip confirmation')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api: IFarseerClient = result.client;\n\n // Find app\n const apps = await api.listApps();\n const app = apps.find((a: { name: string }) => a.name.toLowerCase() === appName.toLowerCase());\n if (!app) {\n logger.error(`App not found: ${appName}`);\n process.exit(1);\n }\n\n if (!options.force) {\n logger.warning(`This will permanently delete app: ${app.name}`);\n logger.dim('Use --force to skip this confirmation.');\n process.exit(1);\n }\n\n logger.info(`Deleting app: ${app.name}...`);\n\n try {\n await api.deleteApp(app.id);\n\n // The folder API 200s even when nothing was deleted; confirm.\n const remaining = await api.listApps();\n if (remaining.some((a) => a.id === app.id)) {\n logger.error(`Delete reported success but \"${app.name}\" is still present.`);\n process.exit(1);\n }\n\n logger.success(`App deleted: ${app.name}`);\n } catch (error) {\n logger.error('Failed to delete app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n\n // Configure app\n appCmd\n .command('configure <args...>')\n .description('Configure an app (set source folder, entrypoint, arguments)')\n .option(\n '--entrypoint <script>',\n 'Set the entrypoint script \u2014 must be a file in the app\\'s source folder (e.g., \"index.ts\")',\n )\n .option(\n '--source-folder <path>',\n 'Set the source folder the app\\'s scripts come from (path under Files/, e.g. \"Scripts/MyApp\")',\n )\n .option(\n '--add-arg <arg>',\n 'Add argument in format \"Name=DefaultValue\" (can be used multiple times)',\n collectArgs,\n [],\n )\n .option('--description <desc>', 'Set app description')\n .option('--name <name>', 'Rename the app')\n .action(async (args: string[], options) => {\n const { organisation, tenant, appName } = parseAppArgs(args);\n const result = await getFarseerClientWithFallback(organisation, tenant);\n if (!result) {\n showLoginPrompt(tenant);\n process.exit(1);\n }\n\n const api: IFarseerClient = result.client;\n\n // Find app\n const apps = await api.listApps();\n const appListItem = apps.find((a: { name: string }) => a.name.toLowerCase() === appName.toLowerCase());\n if (!appListItem) {\n logger.error(`App not found: ${appName}`);\n process.exit(1);\n }\n\n const app = await api.getApp(appListItem.reference);\n if (!app) {\n logger.error(`Failed to load app details: ${appName}`);\n process.exit(1);\n }\n\n // Build the set of changes. updateApp merges these onto the app's\n // current state, so anything left out here is preserved.\n const changes: AppUpdateChanges = {};\n\n if (options.name) {\n changes.name = options.name;\n }\n\n if (options.description !== undefined) {\n changes.description = options.description;\n }\n\n // Source folder + entrypoint. An app's scripts are derived from its\n // source folder, and the entrypoint must be one of those files. The\n // decision lives in applySourceFolderChange (shared with the MCP\n // configure_app tool); the 'cli' caller gets dimmed, flag-worded hints.\n const sourceFolderError = await applySourceFolderChange(\n api,\n app,\n changes,\n { sourceFolder: options.sourceFolder, entrypoint: options.entrypoint },\n 'cli',\n );\n if (sourceFolderError) {\n logger.error(sourceFolderError);\n process.exit(1);\n }\n\n // Handle arguments\n if (options.addArg && options.addArg.length > 0) {\n const newArgs: AppArgument[] = [...app.expectedArguments];\n\n for (const arg of options.addArg) {\n const [name, defaultValue] = arg.split('=');\n if (!name || defaultValue === undefined) {\n logger.error(`Invalid argument format: ${arg}`);\n logger.dim('Use format: --add-arg \"Name=DefaultValue\"');\n process.exit(1);\n }\n\n // Check if arg already exists. Lookup is case-insensitive\n // (user-friendly: --add-arg JOBNAME=x updates an existing\n // jobName), but the written name uses the backend's stored\n // casing \u2014 validateExpectedArguments on the server is\n // case-sensitive, and writing the caller-supplied case\n // would silently rename the arg.\n //\n // --add-arg only sets the defaultValue on a string arg; any\n // existing axes (`dataType`, `fixed`, `options`, `secret`)\n // are preserved so updating a boolean/dropdown/locked arg\n // with --add-arg doesn't silently demote it.\n const existingIdx = newArgs.findIndex((a) => a.name.toLowerCase() === name.toLowerCase());\n if (existingIdx >= 0) {\n const existing = newArgs[existingIdx];\n newArgs[existingIdx] = {\n ...existing,\n defaultValue,\n };\n } else {\n newArgs.push({ name, dataType: 'string', defaultValue });\n }\n }\n\n changes.expectedArguments = newArgs;\n }\n\n if (Object.keys(changes).length === 0) {\n logger.warning('No changes specified.');\n logger.dim(\n 'Use --entrypoint, --source-folder, --add-arg, --description, or --name to configure the app.',\n );\n return;\n }\n\n logger.info(`Updating app: ${app.name}...`);\n\n try {\n const updated = await api.updateApp(appListItem.reference, changes, app);\n logger.success(`App updated: ${updated.name}`);\n\n // Show summary of changes\n if (changes.name) console.log(` Name: ${updated.name}`);\n if (changes.description !== undefined)\n console.log(` Description: ${updated.description || '(empty)'}`);\n if (changes.sourceFolderId !== undefined || changes.mainScriptFileId !== undefined) {\n const updatedScripts = updated.scriptFiles ?? [];\n const mainScript = updatedScripts.find((s) => s.id === updated.mainScriptFileId);\n console.log(` Entrypoint: ${mainScript?.name ?? '(none)'}`);\n console.log(` Scripts: ${updatedScripts.map((s) => s.name).join(', ') || '(none)'}`);\n }\n if (changes.expectedArguments) {\n console.log(\n ` Arguments: ${updated.expectedArguments\n .map((a) => {\n const tags: string[] = [];\n if (a.fixed) tags.push('locked');\n if (a.dataType === 'boolean') tags.push('boolean');\n else if (a.options && a.options.length > 0) tags.push('dropdown');\n if (a.secret) tags.push('secret');\n const suffix = tags.length > 0 ? ` (${tags.join(', ')})` : '';\n return `${a.name}=${a.defaultValue ?? ''}${suffix}`;\n })\n .join(', ')}`,\n );\n }\n } catch (error) {\n logger.error('Failed to update app.');\n if (error instanceof Error) {\n logger.dim(error.message);\n }\n process.exit(1);\n }\n });\n}\n\n// Helper to collect multiple --add-arg options\nfunction collectArgs(value: string, previous: string[]): string[] {\n return previous.concat([value]);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAkB;AAClB,oBAAuB;AACvB,4BAA8E;AAC9E,wBAAuE;AACvE,qBAA0D;AAEnD,SAAS,mBAAmB,SAAwB;AACvD,QAAM,SAAS,QACV,QAAQ,KAAK,EACb,YAAY,mCAAmC,EAC/C;AAAA,IACG;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBJ;AAGJ,SACK,QAAQ,eAAe,EACvB,YAAY,qCAAqC,EACjD,OAAO,aAAa,wCAAwC,EAC5D,OAAO,OAAO,WAAW,YAAY;AAClC,UAAM,EAAE,cAAc,OAAO,QAAI,4CAA4B,SAAS;AAEtE,UAAM,SAAS,UAAM,oDAA6B,cAAc,MAAM;AACtE,QAAI,CAAC,QAAQ;AACT,iDAAgB,MAAM;AACtB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAEA,UAAM,MAAM,OAAO;AACnB,UAAM,YAAY,OAAO,aAAa,WAAW,YAAY;AAC7D,y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2BAAO,MAAM,uBAAuB;AACpC,UAAI,iBAAiB,OAAO;AACxB,6BAAO,IAAI,MAAM,OAAO;AAAA,MAC5B;AACA,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;AAGA,SAAS,YAAY,OAAe,UAA8B;AAC9D,SAAO,SAAS,OAAO,CAAC,KAAK,CAAC;AAClC;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/dist/commands/pull.js
CHANGED
|
@@ -55,7 +55,10 @@ function registerPullCommand(program) {
|
|
|
55
55
|
).option(
|
|
56
56
|
"--force",
|
|
57
57
|
"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."
|
|
58
|
-
).option(
|
|
58
|
+
).option(
|
|
59
|
+
"-y, --yes",
|
|
60
|
+
"Skip confirmation when local has uncommitted changes OR remote has deletions that would remove local files/apps (ignored under --force)"
|
|
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) => {
|
|
59
62
|
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(arg1, arg2);
|
|
60
63
|
const clientResult = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
61
64
|
if (!clientResult) {
|
|
@@ -90,7 +93,15 @@ function registerPullCommand(program) {
|
|
|
90
93
|
import_logger.logger.dim(`Could not compute pre-pull status: ${preStatusError.message}`);
|
|
91
94
|
}
|
|
92
95
|
}
|
|
96
|
+
const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
|
|
97
|
+
let appDeletions = [];
|
|
98
|
+
try {
|
|
99
|
+
appDeletions = await appSyncService.getRemoteDeletions();
|
|
100
|
+
} catch (error) {
|
|
101
|
+
import_logger.logger.dim(`Could not compute pre-pull app deletions: ${error.message}`);
|
|
102
|
+
}
|
|
93
103
|
const localChanges = preStatus ? preStatus.addedLocally.length + preStatus.modifiedLocally.length + preStatus.deletedLocally.length + preStatus.conflicts.length : 0;
|
|
104
|
+
const remoteDeletions = (preStatus?.deletedRemotely.length ?? 0) + appDeletions.length;
|
|
94
105
|
if (options.force) {
|
|
95
106
|
console.log();
|
|
96
107
|
console.log(import_chalk.default.red.bold("--force will hard-reset local to match remote."));
|
|
@@ -119,18 +130,28 @@ function registerPullCommand(program) {
|
|
|
119
130
|
import_logger.logger.info("Pull cancelled.");
|
|
120
131
|
return;
|
|
121
132
|
}
|
|
122
|
-
} else if (localChanges > 0 && !options.yes) {
|
|
133
|
+
} else if ((localChanges > 0 || remoteDeletions > 0) && !options.yes) {
|
|
123
134
|
console.log();
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
135
|
+
if (localChanges > 0) {
|
|
136
|
+
import_logger.logger.warning(`Local has ${localChanges} unsynced change(s).`);
|
|
137
|
+
summarisePreStatus(preStatus);
|
|
138
|
+
import_logger.logger.dim("Pull will keep your edits and merge remote-side changes around them.");
|
|
139
|
+
}
|
|
140
|
+
if (remoteDeletions > 0) {
|
|
141
|
+
import_logger.logger.warning(`Pull will remove ${remoteDeletions} local item(s) that were deleted on remote:`);
|
|
142
|
+
summariseRemoteDeletions(preStatus?.deletedRemotely ?? [], appDeletions);
|
|
143
|
+
import_logger.logger.dim("Decline to abort and keep your local copies (you can push them back to restore).");
|
|
144
|
+
}
|
|
145
|
+
if (localChanges > 0 && remoteDeletions === 0) {
|
|
146
|
+
import_logger.logger.dim("To wipe local and reset to remote: re-run with --force.");
|
|
147
|
+
}
|
|
148
|
+
const promptMessage = remoteDeletions > 0 && localChanges > 0 ? `Continue pull (merge into dirty tree AND delete ${remoteDeletions} local item(s))?` : remoteDeletions > 0 ? `Continue pull and delete ${remoteDeletions} local item(s)?` : `Continue pulling into a dirty working tree?`;
|
|
128
149
|
const confirm = await import_inquirer.default.prompt([
|
|
129
150
|
{
|
|
130
151
|
type: "confirm",
|
|
131
152
|
name: "proceed",
|
|
132
|
-
message:
|
|
133
|
-
default:
|
|
153
|
+
message: promptMessage,
|
|
154
|
+
default: remoteDeletions === 0
|
|
134
155
|
}
|
|
135
156
|
]);
|
|
136
157
|
if (!confirm.proceed) {
|
|
@@ -237,7 +258,6 @@ function registerPullCommand(program) {
|
|
|
237
258
|
console.log();
|
|
238
259
|
console.log(import_chalk.default.bold("\u2550\u2550\u2550 Apps \u2550\u2550\u2550"));
|
|
239
260
|
import_logger.logger.info(`Pulling apps from ${tenant}...`);
|
|
240
|
-
const appSyncService = new import_appSyncService.AppSyncService(tenant, clientResult.client);
|
|
241
261
|
const appResult = await appSyncService.pull();
|
|
242
262
|
if (appResult.created.length > 0) {
|
|
243
263
|
console.log(import_chalk.default.green("New apps:"));
|
|
@@ -300,6 +320,21 @@ function summarisePreStatus(status) {
|
|
|
300
320
|
}
|
|
301
321
|
console.log();
|
|
302
322
|
}
|
|
323
|
+
function summariseRemoteDeletions(deletedFiles, deletedApps) {
|
|
324
|
+
const MAX_PATHS_PER_SECTION = 20;
|
|
325
|
+
const renderSection = (label, paths) => {
|
|
326
|
+
if (paths.length === 0) return;
|
|
327
|
+
console.log(import_chalk.default.red(` ${label} (${paths.length}):`));
|
|
328
|
+
const visible = paths.slice(0, MAX_PATHS_PER_SECTION);
|
|
329
|
+
for (const p of visible) console.log(import_chalk.default.red(` - ${p}`));
|
|
330
|
+
if (paths.length > MAX_PATHS_PER_SECTION) {
|
|
331
|
+
console.log(import_chalk.default.dim(` ... and ${paths.length - MAX_PATHS_PER_SECTION} more`));
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
renderSection("file(s) deleted on remote", deletedFiles);
|
|
335
|
+
renderSection("app(s) deleted on remote", deletedApps);
|
|
336
|
+
console.log();
|
|
337
|
+
}
|
|
303
338
|
async function wipeLocalOnly(syncService, filesDir, filterOptions) {
|
|
304
339
|
const status = await syncService.getStatus({ ...filterOptions, deep: false });
|
|
305
340
|
const removed = [];
|