farseer-cli 1.0.10 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/commands/app.js +348 -344
- package/dist/commands/app.js.map +7 -0
- package/dist/commands/apps.js +110 -82
- package/dist/commands/apps.js.map +7 -0
- package/dist/commands/cells.js +161 -0
- package/dist/commands/cells.js.map +7 -0
- package/dist/commands/checkout.js +140 -155
- package/dist/commands/checkout.js.map +7 -0
- package/dist/commands/config.js +128 -126
- package/dist/commands/config.js.map +7 -0
- package/dist/commands/dashboards.js +130 -0
- package/dist/commands/dashboards.js.map +7 -0
- package/dist/commands/diff.js +171 -193
- package/dist/commands/diff.js.map +7 -0
- package/dist/commands/dimensions.js +222 -119
- package/dist/commands/dimensions.js.map +7 -0
- package/dist/commands/files.js +96 -77
- package/dist/commands/files.js.map +7 -0
- package/dist/commands/formula.js +116 -0
- package/dist/commands/formula.js.map +7 -0
- package/dist/commands/install.js +74 -76
- package/dist/commands/install.js.map +7 -0
- package/dist/commands/list.js +91 -73
- package/dist/commands/list.js.map +7 -0
- package/dist/commands/login.js +137 -98
- package/dist/commands/login.js.map +7 -0
- package/dist/commands/logout.js +59 -41
- package/dist/commands/logout.js.map +7 -0
- package/dist/commands/mcp-server.js +36 -23
- package/dist/commands/mcp-server.js.map +7 -0
- package/dist/commands/model.js +186 -175
- package/dist/commands/model.js.map +7 -0
- package/dist/commands/pull.js +264 -274
- package/dist/commands/pull.js.map +7 -0
- package/dist/commands/push.js +209 -221
- package/dist/commands/push.js.map +7 -0
- package/dist/commands/run.js +276 -321
- package/dist/commands/run.js.map +7 -0
- package/dist/commands/sheets.js +200 -0
- package/dist/commands/sheets.js.map +7 -0
- package/dist/commands/status.js +149 -169
- package/dist/commands/status.js.map +7 -0
- package/dist/commands/variables.js +247 -188
- package/dist/commands/variables.js.map +7 -0
- package/dist/commands/whoami.js +65 -44
- package/dist/commands/whoami.js.map +7 -0
- package/dist/index.js +179 -115
- package/dist/index.js.map +7 -0
- package/dist/mcp/index.js +33 -16
- package/dist/mcp/index.js.map +7 -0
- package/dist/mcp/prompts/workflows.js +191 -145
- package/dist/mcp/prompts/workflows.js.map +7 -0
- package/dist/mcp/resources/documentation.js +158 -148
- package/dist/mcp/resources/documentation.js.map +7 -0
- package/dist/mcp/server.js +56 -33
- package/dist/mcp/server.js.map +7 -0
- package/dist/mcp/tools/appTools.js +309 -277
- package/dist/mcp/tools/appTools.js.map +7 -0
- package/dist/mcp/tools/authTools.js +130 -121
- package/dist/mcp/tools/authTools.js.map +7 -0
- package/dist/mcp/tools/cellTools.js +148 -0
- package/dist/mcp/tools/cellTools.js.map +7 -0
- package/dist/mcp/tools/dashboardTools.js +133 -0
- package/dist/mcp/tools/dashboardTools.js.map +7 -0
- package/dist/mcp/tools/dataTools.js +270 -267
- package/dist/mcp/tools/dataTools.js.map +7 -0
- package/dist/mcp/tools/modelTools.js +575 -229
- package/dist/mcp/tools/modelTools.js.map +7 -0
- package/dist/mcp/tools/runTools.js +201 -203
- package/dist/mcp/tools/runTools.js.map +7 -0
- package/dist/mcp/tools/sheetTools.js +240 -0
- package/dist/mcp/tools/sheetTools.js.map +7 -0
- package/dist/mcp/tools/syncTools.js +335 -314
- package/dist/mcp/tools/syncTools.js.map +7 -0
- package/dist/mcp/utils/helpers.js +117 -123
- package/dist/mcp/utils/helpers.js.map +7 -0
- package/dist/services/appSyncService.js +381 -437
- package/dist/services/appSyncService.js.map +7 -0
- package/dist/services/configService.js +154 -143
- package/dist/services/configService.js.map +7 -0
- package/dist/services/farseerApi.js +422 -399
- package/dist/services/farseerApi.js.map +7 -0
- package/dist/services/farseerFactory.js +208 -273
- package/dist/services/farseerFactory.js.map +7 -0
- package/dist/services/farseerService.js +467 -486
- package/dist/services/farseerService.js.map +7 -0
- package/dist/services/syncService.js +661 -731
- package/dist/services/syncService.js.map +7 -0
- package/dist/utils/constants.js +52 -19
- package/dist/utils/constants.js.map +7 -0
- package/dist/utils/entityResolver.js +78 -0
- package/dist/utils/entityResolver.js.map +7 -0
- package/dist/utils/helpers.js +331 -365
- package/dist/utils/helpers.js.map +7 -0
- package/dist/utils/logger.js +74 -42
- package/dist/utils/logger.js.map +7 -0
- package/package.json +3 -2
package/dist/commands/app.js
CHANGED
|
@@ -1,18 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
11
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var app_exports = {};
|
|
30
|
+
__export(app_exports, {
|
|
31
|
+
registerAppCommand: () => registerAppCommand
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(app_exports);
|
|
34
|
+
var import_chalk = __toESM(require("chalk"));
|
|
35
|
+
var import_logger = require("../utils/logger");
|
|
36
|
+
var import_farseerFactory = require("../services/farseerFactory");
|
|
37
|
+
var import_helpers = require("../utils/helpers");
|
|
11
38
|
function registerAppCommand(program) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.addHelpText('after', `
|
|
39
|
+
const appCmd = program.command("app").description("Manage apps on a Farseer instance").addHelpText(
|
|
40
|
+
"after",
|
|
41
|
+
`
|
|
16
42
|
Commands:
|
|
17
43
|
list [tenant] List all apps
|
|
18
44
|
show [tenant] <name...> Show app details
|
|
@@ -27,351 +53,329 @@ Examples:
|
|
|
27
53
|
$ farseer app show mycompany "My App" # Explicit tenant
|
|
28
54
|
$ farseer app show My App # Uses checked-out tenant
|
|
29
55
|
$ farseer app configure "My App" --entrypoint index.ts
|
|
30
|
-
`
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const details = await api.getApp(app.reference);
|
|
59
|
-
if (details) {
|
|
60
|
-
console.log(` 📦 ${chalk_1.default.bold(details.name)}`);
|
|
61
|
-
if (details.description) {
|
|
62
|
-
console.log(` ${chalk_1.default.dim(details.description)}`);
|
|
63
|
-
}
|
|
64
|
-
console.log(` Status: ${details.status === 'AVAILABLE' ? chalk_1.default.green(details.status) : chalk_1.default.yellow(details.status)}`);
|
|
65
|
-
const detailScripts = details.scriptFiles ?? [];
|
|
66
|
-
if (detailScripts.length > 0) {
|
|
67
|
-
const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);
|
|
68
|
-
console.log(` Entrypoint: ${mainScript ? chalk_1.default.cyan(mainScript.name) : chalk_1.default.red('Not set')}`);
|
|
69
|
-
console.log(` Scripts:`);
|
|
70
|
-
for (const script of detailScripts) {
|
|
71
|
-
const isMain = script.id === details.mainScriptFileId;
|
|
72
|
-
console.log(` ${isMain ? chalk_1.default.green('▶') : ' '} ${script.name}${isMain ? chalk_1.default.dim(' (entrypoint)') : ''}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
console.log(` Scripts: ${chalk_1.default.dim('None')}`);
|
|
77
|
-
}
|
|
78
|
-
if (details.expectedArguments.length > 0) {
|
|
79
|
-
console.log(` Arguments:`);
|
|
80
|
-
for (const arg of details.expectedArguments) {
|
|
81
|
-
console.log(` - ${arg.name}: ${chalk_1.default.dim(arg.defaultValue)}`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
console.log();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
// Simple list
|
|
90
|
-
for (const app of apps) {
|
|
91
|
-
console.log(` 📦 ${app.name}`);
|
|
92
|
-
}
|
|
93
|
-
console.log();
|
|
94
|
-
logger_1.logger.dim(`Total: ${apps.length} app(s)`);
|
|
95
|
-
logger_1.logger.dim('Use --details to see more information.');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
logger_1.logger.error('Failed to list apps.');
|
|
100
|
-
if (error?.message) {
|
|
101
|
-
logger_1.logger.dim(error.message);
|
|
56
|
+
`
|
|
57
|
+
);
|
|
58
|
+
appCmd.command("list [tenant]").description("List all apps on a Farseer instance").option("--details", "Show detailed information for each app").action(async (tenantArg, options) => {
|
|
59
|
+
const { organisation, tenant } = (0, import_helpers.resolveTenantWithOrgMapping)(tenantArg);
|
|
60
|
+
const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
61
|
+
if (!result) {
|
|
62
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
const api = result.client;
|
|
66
|
+
const authLabel = result.authType === "apiKey" ? "API key" : "browser login";
|
|
67
|
+
import_logger.logger.info(`Fetching apps from ${tenant} (using ${authLabel})...`);
|
|
68
|
+
try {
|
|
69
|
+
const apps = await api.listApps();
|
|
70
|
+
if (apps.length === 0) {
|
|
71
|
+
import_logger.logger.warning("No apps found.");
|
|
72
|
+
import_logger.logger.dim("Create an app with: farseer app create <name>");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
import_logger.logger.header(`Apps on ${tenant}`);
|
|
76
|
+
console.log();
|
|
77
|
+
if (options.details) {
|
|
78
|
+
for (const app of apps) {
|
|
79
|
+
const details = await api.getApp(app.reference);
|
|
80
|
+
if (details) {
|
|
81
|
+
console.log(` \u{1F4E6} ${import_chalk.default.bold(details.name)}`);
|
|
82
|
+
if (details.description) {
|
|
83
|
+
console.log(` ${import_chalk.default.dim(details.description)}`);
|
|
102
84
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
logger_1.logger.header(`App: ${app.name}`);
|
|
124
|
-
console.log();
|
|
125
|
-
console.log(` ID: ${app.id}`);
|
|
126
|
-
console.log(` Status: ${app.status}`);
|
|
127
|
-
if (app.description) {
|
|
128
|
-
console.log(` Description: ${app.description}`);
|
|
129
|
-
}
|
|
130
|
-
console.log();
|
|
131
|
-
const appScripts = app.scriptFiles ?? [];
|
|
132
|
-
if (appScripts.length > 0) {
|
|
133
|
-
console.log(' Scripts:');
|
|
134
|
-
for (const script of appScripts) {
|
|
135
|
-
const isMain = script.id === app.mainScriptFileId;
|
|
136
|
-
console.log(` ${isMain ? chalk_1.default.green('▶') : ' '} ${script.name}${isMain ? chalk_1.default.dim(' (entrypoint)') : ''}`);
|
|
85
|
+
console.log(
|
|
86
|
+
` Status: ${details.status === "AVAILABLE" ? import_chalk.default.green(details.status) : import_chalk.default.yellow(details.status)}`
|
|
87
|
+
);
|
|
88
|
+
const detailScripts = details.scriptFiles ?? [];
|
|
89
|
+
if (detailScripts.length > 0) {
|
|
90
|
+
const mainScript = detailScripts.find((s) => s.id === details.mainScriptFileId);
|
|
91
|
+
console.log(
|
|
92
|
+
` Entrypoint: ${mainScript ? import_chalk.default.cyan(mainScript.name) : import_chalk.default.red("Not set")}`
|
|
93
|
+
);
|
|
94
|
+
console.log(` Scripts:`);
|
|
95
|
+
for (const script of detailScripts) {
|
|
96
|
+
const isMain = script.id === details.mainScriptFileId;
|
|
97
|
+
console.log(
|
|
98
|
+
` ${isMain ? import_chalk.default.green("\u25B6") : " "} ${script.name}${isMain ? import_chalk.default.dim(" (entrypoint)") : ""}`
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
console.log(` Scripts: ${import_chalk.default.dim("None")}`);
|
|
137
103
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (app.expectedArguments.length > 0) {
|
|
144
|
-
console.log(' Arguments:');
|
|
145
|
-
for (const arg of app.expectedArguments) {
|
|
146
|
-
console.log(` - ${arg.name}: ${chalk_1.default.dim(arg.defaultValue)}`);
|
|
104
|
+
if (details.expectedArguments.length > 0) {
|
|
105
|
+
console.log(` Arguments:`);
|
|
106
|
+
for (const arg of details.expectedArguments) {
|
|
107
|
+
console.log(` - ${arg.name}: ${import_chalk.default.dim(arg.defaultValue)}`);
|
|
108
|
+
}
|
|
147
109
|
}
|
|
110
|
+
console.log();
|
|
111
|
+
}
|
|
148
112
|
}
|
|
149
|
-
|
|
150
|
-
|
|
113
|
+
} else {
|
|
114
|
+
for (const app of apps) {
|
|
115
|
+
console.log(` \u{1F4E6} ${app.name}`);
|
|
151
116
|
}
|
|
152
117
|
console.log();
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
.
|
|
190
|
-
.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
118
|
+
import_logger.logger.dim(`Total: ${apps.length} app(s)`);
|
|
119
|
+
import_logger.logger.dim("Use --details to see more information.");
|
|
120
|
+
}
|
|
121
|
+
} catch (error) {
|
|
122
|
+
import_logger.logger.error("Failed to list apps.");
|
|
123
|
+
if (error?.message) {
|
|
124
|
+
import_logger.logger.dim(error.message);
|
|
125
|
+
}
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
appCmd.command("show <args...>").description("Show details of an app").action(async (args) => {
|
|
130
|
+
const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args);
|
|
131
|
+
const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
132
|
+
if (!result) {
|
|
133
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
const api = result.client;
|
|
137
|
+
const app = await api.getAppByName(appName);
|
|
138
|
+
if (!app) {
|
|
139
|
+
import_logger.logger.error(`App not found: ${appName}`);
|
|
140
|
+
process.exit(1);
|
|
141
|
+
}
|
|
142
|
+
import_logger.logger.header(`App: ${app.name}`);
|
|
143
|
+
console.log();
|
|
144
|
+
console.log(` ID: ${app.id}`);
|
|
145
|
+
console.log(` Status: ${app.status}`);
|
|
146
|
+
if (app.description) {
|
|
147
|
+
console.log(` Description: ${app.description}`);
|
|
148
|
+
}
|
|
149
|
+
console.log();
|
|
150
|
+
const appScripts = app.scriptFiles ?? [];
|
|
151
|
+
if (appScripts.length > 0) {
|
|
152
|
+
console.log(" Scripts:");
|
|
153
|
+
for (const script of appScripts) {
|
|
154
|
+
const isMain = script.id === app.mainScriptFileId;
|
|
155
|
+
console.log(
|
|
156
|
+
` ${isMain ? import_chalk.default.green("\u25B6") : " "} ${script.name}${isMain ? import_chalk.default.dim(" (entrypoint)") : ""}`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
console.log(" Scripts: None");
|
|
161
|
+
}
|
|
162
|
+
console.log();
|
|
163
|
+
if (app.expectedArguments.length > 0) {
|
|
164
|
+
console.log(" Arguments:");
|
|
165
|
+
for (const arg of app.expectedArguments) {
|
|
166
|
+
console.log(` - ${arg.name}: ${import_chalk.default.dim(arg.defaultValue)}`);
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
console.log(" Arguments: None");
|
|
170
|
+
}
|
|
171
|
+
console.log();
|
|
172
|
+
});
|
|
173
|
+
appCmd.command("create <args...>").description("Create a new app").action(async (args) => {
|
|
174
|
+
const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args);
|
|
175
|
+
const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
176
|
+
if (!result) {
|
|
177
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
const api = result.client;
|
|
181
|
+
const existing = await api.getAppByName(appName);
|
|
182
|
+
if (existing) {
|
|
183
|
+
import_logger.logger.error(`App already exists: ${appName}`);
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
import_logger.logger.info(`Creating app: ${appName}...`);
|
|
187
|
+
try {
|
|
188
|
+
const app = await api.createApp(appName);
|
|
189
|
+
import_logger.logger.success(`App created: ${app.name} (ID: ${app.id})`);
|
|
190
|
+
import_logger.logger.dim('Configure it with: farseer app configure "' + appName + '"');
|
|
191
|
+
} catch (error) {
|
|
192
|
+
import_logger.logger.error("Failed to create app.");
|
|
193
|
+
if (error instanceof Error) {
|
|
194
|
+
import_logger.logger.dim(error.message);
|
|
195
|
+
}
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
appCmd.command("delete <args...>").description("Delete an app").option("--force", "Skip confirmation").action(async (args, options) => {
|
|
200
|
+
const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args);
|
|
201
|
+
const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
202
|
+
if (!result) {
|
|
203
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
204
|
+
process.exit(1);
|
|
205
|
+
}
|
|
206
|
+
const api = result.client;
|
|
207
|
+
const apps = await api.listApps();
|
|
208
|
+
const app = apps.find((a) => a.name.toLowerCase() === appName.toLowerCase());
|
|
209
|
+
if (!app) {
|
|
210
|
+
import_logger.logger.error(`App not found: ${appName}`);
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
if (!options.force) {
|
|
214
|
+
import_logger.logger.warning(`This will permanently delete app: ${app.name}`);
|
|
215
|
+
import_logger.logger.dim("Use --force to skip this confirmation.");
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
import_logger.logger.info(`Deleting app: ${app.name}...`);
|
|
219
|
+
try {
|
|
220
|
+
await api.deleteApp(app.reference);
|
|
221
|
+
import_logger.logger.success(`App deleted: ${app.name}`);
|
|
222
|
+
} catch (error) {
|
|
223
|
+
import_logger.logger.error("Failed to delete app.");
|
|
224
|
+
if (error instanceof Error) {
|
|
225
|
+
import_logger.logger.dim(error.message);
|
|
226
|
+
}
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
appCmd.command("configure <args...>").description("Configure an app (set entrypoint, scripts, arguments)").option("--entrypoint <script>", 'Set the entrypoint script (e.g., "index.ts")').option("--scripts <scripts>", "Comma-separated list of scripts to include").option(
|
|
231
|
+
"--add-arg <arg>",
|
|
232
|
+
'Add argument in format "Name=DefaultValue" (can be used multiple times)',
|
|
233
|
+
collectArgs,
|
|
234
|
+
[]
|
|
235
|
+
).option("--description <desc>", "Set app description").option("--name <name>", "Rename the app").action(async (args, options) => {
|
|
236
|
+
const { organisation, tenant, appName } = (0, import_helpers.parseAppArgs)(args);
|
|
237
|
+
const result = await (0, import_farseerFactory.getFarseerClientWithFallback)(organisation, tenant);
|
|
238
|
+
if (!result) {
|
|
239
|
+
(0, import_farseerFactory.showLoginPrompt)(tenant);
|
|
240
|
+
process.exit(1);
|
|
241
|
+
}
|
|
242
|
+
const api = result.client;
|
|
243
|
+
const apps = await api.listApps();
|
|
244
|
+
const appListItem = apps.find((a) => a.name.toLowerCase() === appName.toLowerCase());
|
|
245
|
+
if (!appListItem) {
|
|
246
|
+
import_logger.logger.error(`App not found: ${appName}`);
|
|
247
|
+
process.exit(1);
|
|
248
|
+
}
|
|
249
|
+
const app = await api.getApp(appListItem.reference);
|
|
250
|
+
if (!app) {
|
|
251
|
+
import_logger.logger.error(`Failed to load app details: ${appName}`);
|
|
252
|
+
process.exit(1);
|
|
253
|
+
}
|
|
254
|
+
const update = {};
|
|
255
|
+
if (options.name) {
|
|
256
|
+
update.name = options.name;
|
|
257
|
+
}
|
|
258
|
+
if (options.description !== void 0) {
|
|
259
|
+
update.description = options.description;
|
|
260
|
+
}
|
|
261
|
+
if (options.scripts || options.entrypoint) {
|
|
262
|
+
const availableScripts = await api.getScriptFiles();
|
|
263
|
+
let autoSetEntrypoint = false;
|
|
264
|
+
let autoEntrypointName = "";
|
|
265
|
+
if (options.scripts) {
|
|
266
|
+
const scriptNames = options.scripts.split(",").map((s) => s.trim());
|
|
267
|
+
const scriptIds = [];
|
|
268
|
+
const resolvedScripts = [];
|
|
269
|
+
for (const name of scriptNames) {
|
|
270
|
+
const script = availableScripts.find(
|
|
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
|
+
);
|
|
251
278
|
process.exit(1);
|
|
279
|
+
}
|
|
280
|
+
scriptIds.push(script.id);
|
|
281
|
+
resolvedScripts.push({ id: script.id, name: script.name });
|
|
252
282
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (options.description !== undefined) {
|
|
259
|
-
update.description = options.description;
|
|
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;
|
|
260
288
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (!script) {
|
|
273
|
-
logger_1.logger.error(`Script not found: ${name}`);
|
|
274
|
-
logger_1.logger.dim('Available scripts: ' +
|
|
275
|
-
availableScripts.map((s) => s.name).join(', '));
|
|
276
|
-
process.exit(1);
|
|
277
|
-
}
|
|
278
|
-
scriptIds.push(script.id);
|
|
279
|
-
resolvedScripts.push({ id: script.id, name: script.name });
|
|
280
|
-
}
|
|
281
|
-
update.scriptFileIds = scriptIds;
|
|
282
|
-
// Auto-set first script as entrypoint if no entrypoint specified and app has none
|
|
283
|
-
if (!options.entrypoint && !app.mainScriptFileId && resolvedScripts.length > 0) {
|
|
284
|
-
update.mainScriptFileId = resolvedScripts[0].id;
|
|
285
|
-
autoSetEntrypoint = true;
|
|
286
|
-
autoEntrypointName = resolvedScripts[0].name;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
if (options.entrypoint) {
|
|
290
|
-
const entryScript = availableScripts.find((s) => s.name.toLowerCase() === options.entrypoint.toLowerCase());
|
|
291
|
-
if (!entryScript) {
|
|
292
|
-
logger_1.logger.error(`Entrypoint script not found: ${options.entrypoint}`);
|
|
293
|
-
logger_1.logger.dim('Available scripts: ' + availableScripts.map((s) => s.name).join(', '));
|
|
294
|
-
process.exit(1);
|
|
295
|
-
}
|
|
296
|
-
update.mainScriptFileId = entryScript.id;
|
|
297
|
-
// If setting entrypoint but no scripts specified, include the entrypoint in scripts
|
|
298
|
-
if (!update.scriptFileIds) {
|
|
299
|
-
update.scriptFileIds = [entryScript.id];
|
|
300
|
-
}
|
|
301
|
-
else if (!update.scriptFileIds.includes(entryScript.id)) {
|
|
302
|
-
update.scriptFileIds.push(entryScript.id);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
// Notify user about auto-set entrypoint
|
|
306
|
-
if (autoSetEntrypoint) {
|
|
307
|
-
logger_1.logger.info(`Auto-set "${autoEntrypointName}" as entrypoint (first script).`);
|
|
308
|
-
logger_1.logger.dim(`Change with: farseer app configure "${appName}" --entrypoint <script>`);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
// Handle arguments
|
|
312
|
-
if (options.addArg && options.addArg.length > 0) {
|
|
313
|
-
const newArgs = [...app.expectedArguments];
|
|
314
|
-
for (const arg of options.addArg) {
|
|
315
|
-
const [name, defaultValue] = arg.split('=');
|
|
316
|
-
if (!name || defaultValue === undefined) {
|
|
317
|
-
logger_1.logger.error(`Invalid argument format: ${arg}`);
|
|
318
|
-
logger_1.logger.dim('Use format: --add-arg "Name=DefaultValue"');
|
|
319
|
-
process.exit(1);
|
|
320
|
-
}
|
|
321
|
-
// Check if arg already exists
|
|
322
|
-
const existingIdx = newArgs.findIndex((a) => a.name.toLowerCase() === name.toLowerCase());
|
|
323
|
-
if (existingIdx >= 0) {
|
|
324
|
-
newArgs[existingIdx] = { name, type: 'variable', defaultValue };
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
newArgs.push({ name, type: 'variable', defaultValue });
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
update.expectedArguments = newArgs;
|
|
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);
|
|
331
300
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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);
|
|
336
306
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
if (update.description !== undefined)
|
|
352
|
-
console.log(` Description: ${updated.description || '(empty)'}`);
|
|
353
|
-
if (update.mainScriptFileId) {
|
|
354
|
-
const updatedScripts = updated.scriptFiles ?? [];
|
|
355
|
-
const mainScript = updatedScripts.find((s) => s.id === updated.mainScriptFileId);
|
|
356
|
-
console.log(` Entrypoint: ${mainScript?.name}`);
|
|
357
|
-
}
|
|
358
|
-
if (update.scriptFileIds) {
|
|
359
|
-
console.log(` Scripts: ${(updated.scriptFiles ?? []).map((s) => s.name).join(', ')}`);
|
|
360
|
-
}
|
|
361
|
-
if (update.expectedArguments) {
|
|
362
|
-
console.log(` Arguments: ${updated.expectedArguments.map((a) => `${a.name}=${a.defaultValue}`).join(', ')}`);
|
|
363
|
-
}
|
|
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
|
+
}
|
|
312
|
+
}
|
|
313
|
+
if (options.addArg && options.addArg.length > 0) {
|
|
314
|
+
const newArgs = [...app.expectedArguments];
|
|
315
|
+
for (const arg of options.addArg) {
|
|
316
|
+
const [name, defaultValue] = arg.split("=");
|
|
317
|
+
if (!name || defaultValue === void 0) {
|
|
318
|
+
import_logger.logger.error(`Invalid argument format: ${arg}`);
|
|
319
|
+
import_logger.logger.dim('Use format: --add-arg "Name=DefaultValue"');
|
|
320
|
+
process.exit(1);
|
|
364
321
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
process.exit(1);
|
|
322
|
+
const existingIdx = newArgs.findIndex((a) => a.name.toLowerCase() === name.toLowerCase());
|
|
323
|
+
if (existingIdx >= 0) {
|
|
324
|
+
newArgs[existingIdx] = { name, type: "variable", defaultValue };
|
|
325
|
+
} else {
|
|
326
|
+
newArgs.push({ name, type: "variable", defaultValue });
|
|
371
327
|
}
|
|
372
|
-
|
|
328
|
+
}
|
|
329
|
+
update.expectedArguments = newArgs;
|
|
330
|
+
}
|
|
331
|
+
if (Object.keys(update).length === 0) {
|
|
332
|
+
import_logger.logger.warning("No changes specified.");
|
|
333
|
+
import_logger.logger.dim("Use --entrypoint, --scripts, --add-arg, --description, or --name to configure the app.");
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
import_logger.logger.info(`Updating app: ${app.name}...`);
|
|
337
|
+
try {
|
|
338
|
+
if (!update.name) {
|
|
339
|
+
update.name = app.name;
|
|
340
|
+
}
|
|
341
|
+
if (update.description === void 0) {
|
|
342
|
+
update.description = app.description || "";
|
|
343
|
+
}
|
|
344
|
+
const updated = await api.updateApp(appListItem.reference, update);
|
|
345
|
+
import_logger.logger.success(`App updated: ${updated.name}`);
|
|
346
|
+
if (update.name) console.log(` Name: ${updated.name}`);
|
|
347
|
+
if (update.description !== void 0) console.log(` Description: ${updated.description || "(empty)"}`);
|
|
348
|
+
if (update.mainScriptFileId) {
|
|
349
|
+
const updatedScripts = updated.scriptFiles ?? [];
|
|
350
|
+
const mainScript = updatedScripts.find(
|
|
351
|
+
(s) => s.id === updated.mainScriptFileId
|
|
352
|
+
);
|
|
353
|
+
console.log(` Entrypoint: ${mainScript?.name}`);
|
|
354
|
+
}
|
|
355
|
+
if (update.scriptFileIds) {
|
|
356
|
+
console.log(
|
|
357
|
+
` Scripts: ${(updated.scriptFiles ?? []).map((s) => s.name).join(", ")}`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
if (update.expectedArguments) {
|
|
361
|
+
console.log(
|
|
362
|
+
` Arguments: ${updated.expectedArguments.map((a) => `${a.name}=${a.defaultValue}`).join(", ")}`
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
} catch (error) {
|
|
366
|
+
import_logger.logger.error("Failed to update app.");
|
|
367
|
+
if (error instanceof Error) {
|
|
368
|
+
import_logger.logger.dim(error.message);
|
|
369
|
+
}
|
|
370
|
+
process.exit(1);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
373
|
}
|
|
374
|
-
// Helper to collect multiple --add-arg options
|
|
375
374
|
function collectArgs(value, previous) {
|
|
376
|
-
|
|
375
|
+
return previous.concat([value]);
|
|
377
376
|
}
|
|
377
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
378
|
+
0 && (module.exports = {
|
|
379
|
+
registerAppCommand
|
|
380
|
+
});
|
|
381
|
+
//# sourceMappingURL=app.js.map
|