@base44-preview/cli 0.0.44-pr.411.fe4049c → 0.0.44-pr.412.1367f72
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/cli/index.js +457 -211
- package/dist/cli/index.js.map +18 -12
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -16459,7 +16459,7 @@ var require_lodash = __commonJS((exports, module) => {
|
|
|
16459
16459
|
}
|
|
16460
16460
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
|
|
16461
16461
|
});
|
|
16462
|
-
function
|
|
16462
|
+
function join11(array2, separator) {
|
|
16463
16463
|
return array2 == null ? "" : nativeJoin.call(array2, separator);
|
|
16464
16464
|
}
|
|
16465
16465
|
function last(array2) {
|
|
@@ -16481,7 +16481,7 @@ var require_lodash = __commonJS((exports, module) => {
|
|
|
16481
16481
|
function nth(array2, n2) {
|
|
16482
16482
|
return array2 && array2.length ? baseNth(array2, toInteger(n2)) : undefined2;
|
|
16483
16483
|
}
|
|
16484
|
-
var
|
|
16484
|
+
var pull3 = baseRest(pullAll);
|
|
16485
16485
|
function pullAll(array2, values2) {
|
|
16486
16486
|
return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2) : array2;
|
|
16487
16487
|
}
|
|
@@ -18246,7 +18246,7 @@ __p += '`;
|
|
|
18246
18246
|
lodash.pickBy = pickBy;
|
|
18247
18247
|
lodash.property = property;
|
|
18248
18248
|
lodash.propertyOf = propertyOf;
|
|
18249
|
-
lodash.pull =
|
|
18249
|
+
lodash.pull = pull3;
|
|
18250
18250
|
lodash.pullAll = pullAll;
|
|
18251
18251
|
lodash.pullAllBy = pullAllBy;
|
|
18252
18252
|
lodash.pullAllWith = pullAllWith;
|
|
@@ -18391,7 +18391,7 @@ __p += '`;
|
|
|
18391
18391
|
lodash.isUndefined = isUndefined;
|
|
18392
18392
|
lodash.isWeakMap = isWeakMap;
|
|
18393
18393
|
lodash.isWeakSet = isWeakSet;
|
|
18394
|
-
lodash.join =
|
|
18394
|
+
lodash.join = join11;
|
|
18395
18395
|
lodash.kebabCase = kebabCase;
|
|
18396
18396
|
lodash.last = last;
|
|
18397
18397
|
lodash.lastIndexOf = lastIndexOf;
|
|
@@ -27503,7 +27503,7 @@ function cleanDoc(doc2) {
|
|
|
27503
27503
|
return mapDoc(doc2, (currentDoc) => cleanDocFn(currentDoc));
|
|
27504
27504
|
}
|
|
27505
27505
|
function replaceEndOfLine(doc2, replacement = literalline) {
|
|
27506
|
-
return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ?
|
|
27506
|
+
return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ? join15(replacement, currentDoc.split(`
|
|
27507
27507
|
`)) : currentDoc);
|
|
27508
27508
|
}
|
|
27509
27509
|
function canBreakFn(doc2) {
|
|
@@ -27583,7 +27583,7 @@ function indentIfBreak(contents, options) {
|
|
|
27583
27583
|
negate: options.negate
|
|
27584
27584
|
};
|
|
27585
27585
|
}
|
|
27586
|
-
function
|
|
27586
|
+
function join15(separator, docs) {
|
|
27587
27587
|
assertDoc(separator);
|
|
27588
27588
|
assertDocArray(docs);
|
|
27589
27589
|
const parts = [];
|
|
@@ -28294,7 +28294,7 @@ var init_doc = __esm(() => {
|
|
|
28294
28294
|
MODE_FLAT = Symbol("MODE_FLAT");
|
|
28295
28295
|
DOC_FILL_PRINTED_LENGTH = Symbol("DOC_FILL_PRINTED_LENGTH");
|
|
28296
28296
|
builders = {
|
|
28297
|
-
join:
|
|
28297
|
+
join: join15,
|
|
28298
28298
|
line,
|
|
28299
28299
|
softline,
|
|
28300
28300
|
hardline,
|
|
@@ -133208,7 +133208,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
133208
133208
|
return mapDoc2(doc2, (currentDoc) => cleanDocFn2(currentDoc));
|
|
133209
133209
|
}
|
|
133210
133210
|
function replaceEndOfLine2(doc2, replacement = literalline2) {
|
|
133211
|
-
return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ?
|
|
133211
|
+
return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ? join17(replacement, currentDoc.split(`
|
|
133212
133212
|
`)) : currentDoc);
|
|
133213
133213
|
}
|
|
133214
133214
|
function canBreakFn2(doc2) {
|
|
@@ -133294,7 +133294,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
133294
133294
|
negate: options8.negate
|
|
133295
133295
|
};
|
|
133296
133296
|
}
|
|
133297
|
-
function
|
|
133297
|
+
function join17(separator, docs) {
|
|
133298
133298
|
assertDoc2(separator);
|
|
133299
133299
|
assertDocArray2(docs);
|
|
133300
133300
|
const parts = [];
|
|
@@ -133959,7 +133959,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
133959
133959
|
}
|
|
133960
133960
|
}
|
|
133961
133961
|
var builders2 = {
|
|
133962
|
-
join:
|
|
133962
|
+
join: join17,
|
|
133963
133963
|
line: line3,
|
|
133964
133964
|
softline: softline2,
|
|
133965
133965
|
hardline: hardline4,
|
|
@@ -160399,10 +160399,10 @@ var require_view = __commonJS((exports, module) => {
|
|
|
160399
160399
|
var debug = require_src4()("express:view");
|
|
160400
160400
|
var path18 = __require("node:path");
|
|
160401
160401
|
var fs28 = __require("node:fs");
|
|
160402
|
-
var
|
|
160402
|
+
var dirname12 = path18.dirname;
|
|
160403
160403
|
var basename4 = path18.basename;
|
|
160404
160404
|
var extname2 = path18.extname;
|
|
160405
|
-
var
|
|
160405
|
+
var join18 = path18.join;
|
|
160406
160406
|
var resolve6 = path18.resolve;
|
|
160407
160407
|
module.exports = View;
|
|
160408
160408
|
function View(name2, options8) {
|
|
@@ -160438,7 +160438,7 @@ var require_view = __commonJS((exports, module) => {
|
|
|
160438
160438
|
for (var i5 = 0;i5 < roots.length && !path19; i5++) {
|
|
160439
160439
|
var root2 = roots[i5];
|
|
160440
160440
|
var loc = resolve6(root2, name2);
|
|
160441
|
-
var dir =
|
|
160441
|
+
var dir = dirname12(loc);
|
|
160442
160442
|
var file2 = basename4(loc);
|
|
160443
160443
|
path19 = this.resolve(dir, file2);
|
|
160444
160444
|
}
|
|
@@ -160464,12 +160464,12 @@ var require_view = __commonJS((exports, module) => {
|
|
|
160464
160464
|
};
|
|
160465
160465
|
View.prototype.resolve = function resolve7(dir, file2) {
|
|
160466
160466
|
var ext = this.ext;
|
|
160467
|
-
var path19 =
|
|
160467
|
+
var path19 = join18(dir, file2);
|
|
160468
160468
|
var stat2 = tryStat(path19);
|
|
160469
160469
|
if (stat2 && stat2.isFile()) {
|
|
160470
160470
|
return path19;
|
|
160471
160471
|
}
|
|
160472
|
-
path19 =
|
|
160472
|
+
path19 = join18(dir, basename4(file2, ext), "index" + ext);
|
|
160473
160473
|
stat2 = tryStat(path19);
|
|
160474
160474
|
if (stat2 && stat2.isFile()) {
|
|
160475
160475
|
return path19;
|
|
@@ -164164,7 +164164,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
164164
164164
|
var Stream2 = __require("stream");
|
|
164165
164165
|
var util2 = __require("util");
|
|
164166
164166
|
var extname2 = path18.extname;
|
|
164167
|
-
var
|
|
164167
|
+
var join18 = path18.join;
|
|
164168
164168
|
var normalize = path18.normalize;
|
|
164169
164169
|
var resolve6 = path18.resolve;
|
|
164170
164170
|
var sep = path18.sep;
|
|
@@ -164336,7 +164336,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
164336
164336
|
return res;
|
|
164337
164337
|
}
|
|
164338
164338
|
parts = path19.split(sep);
|
|
164339
|
-
path19 = normalize(
|
|
164339
|
+
path19 = normalize(join18(root2, path19));
|
|
164340
164340
|
} else {
|
|
164341
164341
|
if (UP_PATH_REGEXP.test(path19)) {
|
|
164342
164342
|
debug('malicious path "%s"', path19);
|
|
@@ -164476,7 +164476,7 @@ var require_send = __commonJS((exports, module) => {
|
|
|
164476
164476
|
return self2.onStatError(err);
|
|
164477
164477
|
return self2.error(404);
|
|
164478
164478
|
}
|
|
164479
|
-
var p4 =
|
|
164479
|
+
var p4 = join18(path19, self2._index[i5]);
|
|
164480
164480
|
debug('stat "%s"', p4);
|
|
164481
164481
|
fs28.stat(p4, function(err2, stat2) {
|
|
164482
164482
|
if (err2)
|
|
@@ -211071,7 +211071,7 @@ var require_buffer_list = __commonJS((exports, module) => {
|
|
|
211071
211071
|
}
|
|
211072
211072
|
}, {
|
|
211073
211073
|
key: "join",
|
|
211074
|
-
value: function
|
|
211074
|
+
value: function join18(s5) {
|
|
211075
211075
|
if (this.length === 0)
|
|
211076
211076
|
return "";
|
|
211077
211077
|
var p4 = this.head;
|
|
@@ -214782,7 +214782,7 @@ var require_dist5 = __commonJS((exports, module) => {
|
|
|
214782
214782
|
});
|
|
214783
214783
|
|
|
214784
214784
|
// src/cli/index.ts
|
|
214785
|
-
import { dirname as dirname16, join as
|
|
214785
|
+
import { dirname as dirname16, join as join21 } from "node:path";
|
|
214786
214786
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
214787
214787
|
|
|
214788
214788
|
// ../../node_modules/commander/esm.mjs
|
|
@@ -214802,7 +214802,7 @@ var {
|
|
|
214802
214802
|
} = import__.default;
|
|
214803
214803
|
|
|
214804
214804
|
// src/cli/commands/agents/pull.ts
|
|
214805
|
-
import { dirname as dirname7, join as
|
|
214805
|
+
import { dirname as dirname7, join as join11 } from "node:path";
|
|
214806
214806
|
|
|
214807
214807
|
// ../../node_modules/@clack/core/dist/index.mjs
|
|
214808
214808
|
var import_picocolors = __toESM(require_picocolors(), 1);
|
|
@@ -237317,7 +237317,7 @@ var generateGlobTasks = normalizeArguments(generateTasks);
|
|
|
237317
237317
|
var generateGlobTasksSync = normalizeArgumentsSync(generateTasksSync);
|
|
237318
237318
|
|
|
237319
237319
|
// src/core/project/config.ts
|
|
237320
|
-
import { dirname as dirname5, join as
|
|
237320
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
237321
237321
|
|
|
237322
237322
|
// src/core/resources/agent/schema.ts
|
|
237323
237323
|
var EntityOperationSchema = exports_external.enum(["create", "update", "delete", "read"]);
|
|
@@ -238249,11 +238249,24 @@ var BackendFunctionSchema = FunctionConfigSchema.extend({
|
|
|
238249
238249
|
entryPath: exports_external.string().min(1, "Entry path cannot be empty"),
|
|
238250
238250
|
filePaths: exports_external.array(exports_external.string()).min(1, "Function must have at least one file")
|
|
238251
238251
|
});
|
|
238252
|
-
var
|
|
238253
|
-
|
|
238254
|
-
|
|
238255
|
-
|
|
238256
|
-
|
|
238252
|
+
var DeploySingleFunctionResponseSchema = exports_external.object({
|
|
238253
|
+
status: exports_external.enum(["deployed", "unchanged"])
|
|
238254
|
+
});
|
|
238255
|
+
var FunctionInfoSchema = exports_external.object({
|
|
238256
|
+
name: exports_external.string(),
|
|
238257
|
+
deployment_id: exports_external.string(),
|
|
238258
|
+
entry: exports_external.string(),
|
|
238259
|
+
files: exports_external.array(FunctionFileSchema),
|
|
238260
|
+
automations: exports_external.array(AutomationSchema)
|
|
238261
|
+
}).transform((data) => ({
|
|
238262
|
+
name: data.name,
|
|
238263
|
+
deploymentId: data.deployment_id,
|
|
238264
|
+
entry: data.entry,
|
|
238265
|
+
files: data.files,
|
|
238266
|
+
automations: data.automations
|
|
238267
|
+
}));
|
|
238268
|
+
var ListFunctionsResponseSchema = exports_external.object({
|
|
238269
|
+
functions: exports_external.array(FunctionInfoSchema)
|
|
238257
238270
|
});
|
|
238258
238271
|
var LogLevelSchema = exports_external.enum(["info", "warning", "error", "debug"]);
|
|
238259
238272
|
var FunctionLogEntrySchema = exports_external.object({
|
|
@@ -238264,29 +238277,39 @@ var FunctionLogEntrySchema = exports_external.object({
|
|
|
238264
238277
|
var FunctionLogsResponseSchema = exports_external.array(FunctionLogEntrySchema);
|
|
238265
238278
|
|
|
238266
238279
|
// src/core/resources/function/api.ts
|
|
238267
|
-
function
|
|
238268
|
-
return {
|
|
238269
|
-
name: fn.name,
|
|
238270
|
-
entry: fn.entry,
|
|
238271
|
-
files: fn.files,
|
|
238272
|
-
automations: fn.automations
|
|
238273
|
-
};
|
|
238274
|
-
}
|
|
238275
|
-
async function deployFunctions(functions) {
|
|
238280
|
+
async function deploySingleFunction(name2, payload) {
|
|
238276
238281
|
const appClient = getAppClient();
|
|
238277
|
-
const payload = {
|
|
238278
|
-
functions: functions.map(toDeployPayloadItem)
|
|
238279
|
-
};
|
|
238280
238282
|
let response;
|
|
238281
238283
|
try {
|
|
238282
|
-
response = await appClient.put(
|
|
238283
|
-
|
|
238284
|
-
|
|
238284
|
+
response = await appClient.put(`backend-functions/${encodeURIComponent(name2)}`, { json: payload, timeout: false });
|
|
238285
|
+
} catch (error48) {
|
|
238286
|
+
throw await ApiError.fromHttpError(error48, `deploying function "${name2}"`);
|
|
238287
|
+
}
|
|
238288
|
+
const result = DeploySingleFunctionResponseSchema.safeParse(await response.json());
|
|
238289
|
+
if (!result.success) {
|
|
238290
|
+
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
238291
|
+
}
|
|
238292
|
+
return result.data;
|
|
238293
|
+
}
|
|
238294
|
+
async function deleteSingleFunction(name2) {
|
|
238295
|
+
const appClient = getAppClient();
|
|
238296
|
+
try {
|
|
238297
|
+
await appClient.delete(`backend-functions/${encodeURIComponent(name2)}`, {
|
|
238298
|
+
timeout: 60000
|
|
238285
238299
|
});
|
|
238286
238300
|
} catch (error48) {
|
|
238287
|
-
throw await ApiError.fromHttpError(error48,
|
|
238301
|
+
throw await ApiError.fromHttpError(error48, `deleting function "${name2}"`);
|
|
238302
|
+
}
|
|
238303
|
+
}
|
|
238304
|
+
async function listDeployedFunctions() {
|
|
238305
|
+
const appClient = getAppClient();
|
|
238306
|
+
let response;
|
|
238307
|
+
try {
|
|
238308
|
+
response = await appClient.get("backend-functions", { timeout: 30000 });
|
|
238309
|
+
} catch (error48) {
|
|
238310
|
+
throw await ApiError.fromHttpError(error48, "listing deployed functions");
|
|
238288
238311
|
}
|
|
238289
|
-
const result =
|
|
238312
|
+
const result = ListFunctionsResponseSchema.safeParse(await response.json());
|
|
238290
238313
|
if (!result.success) {
|
|
238291
238314
|
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
238292
238315
|
}
|
|
@@ -238409,24 +238432,135 @@ async function readAllFunctions(functionsDir) {
|
|
|
238409
238432
|
import { dirname as dirname4, relative as relative2 } from "node:path";
|
|
238410
238433
|
async function loadFunctionCode(fn) {
|
|
238411
238434
|
const functionDir = dirname4(fn.entryPath);
|
|
238412
|
-
const
|
|
238435
|
+
const resolvedFiles = await Promise.all(fn.filePaths.map(async (filePath) => {
|
|
238413
238436
|
const content = await readTextFile(filePath);
|
|
238414
238437
|
const path11 = relative2(functionDir, filePath).split(/[/\\]/).join("/");
|
|
238415
238438
|
return { path: path11, content };
|
|
238416
238439
|
}));
|
|
238417
|
-
return { ...fn, files:
|
|
238440
|
+
return { ...fn, files: resolvedFiles };
|
|
238418
238441
|
}
|
|
238419
|
-
async function
|
|
238420
|
-
|
|
238421
|
-
|
|
238442
|
+
async function deployOne(fn) {
|
|
238443
|
+
const start = Date.now();
|
|
238444
|
+
try {
|
|
238445
|
+
const functionWithCode = await loadFunctionCode(fn);
|
|
238446
|
+
const response = await deploySingleFunction(functionWithCode.name, {
|
|
238447
|
+
entry: functionWithCode.entry,
|
|
238448
|
+
files: functionWithCode.files,
|
|
238449
|
+
automations: functionWithCode.automations
|
|
238450
|
+
});
|
|
238451
|
+
return {
|
|
238452
|
+
name: functionWithCode.name,
|
|
238453
|
+
status: response.status,
|
|
238454
|
+
durationMs: Date.now() - start
|
|
238455
|
+
};
|
|
238456
|
+
} catch (error48) {
|
|
238457
|
+
return {
|
|
238458
|
+
name: fn.name,
|
|
238459
|
+
status: "error",
|
|
238460
|
+
error: error48 instanceof Error ? error48.message : String(error48)
|
|
238461
|
+
};
|
|
238462
|
+
}
|
|
238463
|
+
}
|
|
238464
|
+
async function deployFunctionsSequentially(functions, options) {
|
|
238465
|
+
if (functions.length === 0)
|
|
238466
|
+
return [];
|
|
238467
|
+
const results = [];
|
|
238468
|
+
for (const fn of functions) {
|
|
238469
|
+
options?.onStart?.([fn.name]);
|
|
238470
|
+
const result = await deployOne(fn);
|
|
238471
|
+
results.push(result);
|
|
238472
|
+
options?.onResult?.(result);
|
|
238473
|
+
}
|
|
238474
|
+
return results;
|
|
238475
|
+
}
|
|
238476
|
+
async function pruneRemovedFunctions(localFunctionNames, options) {
|
|
238477
|
+
const remote = await listDeployedFunctions();
|
|
238478
|
+
const localSet = new Set(localFunctionNames);
|
|
238479
|
+
const toDelete = remote.functions.filter((f) => !localSet.has(f.name));
|
|
238480
|
+
options?.onStart?.(toDelete.length);
|
|
238481
|
+
const results = [];
|
|
238482
|
+
for (const fn of toDelete) {
|
|
238483
|
+
options?.onBeforeDelete?.(fn.name);
|
|
238484
|
+
let result;
|
|
238485
|
+
try {
|
|
238486
|
+
await deleteSingleFunction(fn.name);
|
|
238487
|
+
result = { name: fn.name, deleted: true };
|
|
238488
|
+
} catch (error48) {
|
|
238489
|
+
result = {
|
|
238490
|
+
name: fn.name,
|
|
238491
|
+
deleted: false,
|
|
238492
|
+
error: error48 instanceof Error ? error48.message : String(error48)
|
|
238493
|
+
};
|
|
238494
|
+
}
|
|
238495
|
+
results.push(result);
|
|
238496
|
+
options?.onResult?.(result);
|
|
238497
|
+
}
|
|
238498
|
+
return results;
|
|
238499
|
+
}
|
|
238500
|
+
// src/core/resources/function/pull.ts
|
|
238501
|
+
import { join as join6 } from "node:path";
|
|
238502
|
+
import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
|
|
238503
|
+
async function writeFunctions(functionsDir, functions) {
|
|
238504
|
+
const written = [];
|
|
238505
|
+
const skipped = [];
|
|
238506
|
+
for (const fn of functions) {
|
|
238507
|
+
const functionDir = join6(functionsDir, fn.name);
|
|
238508
|
+
const configPath = join6(functionDir, "function.jsonc");
|
|
238509
|
+
if (await isFunctionUnchanged(functionDir, fn)) {
|
|
238510
|
+
skipped.push(fn.name);
|
|
238511
|
+
continue;
|
|
238512
|
+
}
|
|
238513
|
+
const config5 = {
|
|
238514
|
+
name: fn.name,
|
|
238515
|
+
entry: fn.entry
|
|
238516
|
+
};
|
|
238517
|
+
if (fn.automations.length > 0) {
|
|
238518
|
+
config5.automations = fn.automations;
|
|
238519
|
+
}
|
|
238520
|
+
await writeJsonFile(configPath, config5);
|
|
238521
|
+
for (const file2 of fn.files) {
|
|
238522
|
+
await writeFile(join6(functionDir, file2.path), file2.content);
|
|
238523
|
+
}
|
|
238524
|
+
written.push(fn.name);
|
|
238525
|
+
}
|
|
238526
|
+
return { written, skipped };
|
|
238527
|
+
}
|
|
238528
|
+
async function isFunctionUnchanged(functionDir, fn) {
|
|
238529
|
+
if (!await pathExists(functionDir)) {
|
|
238530
|
+
return false;
|
|
238531
|
+
}
|
|
238532
|
+
const configPath = join6(functionDir, "function.jsonc");
|
|
238533
|
+
try {
|
|
238534
|
+
const localConfig = await readJsonFile(configPath);
|
|
238535
|
+
if (localConfig.entry !== fn.entry) {
|
|
238536
|
+
return false;
|
|
238537
|
+
}
|
|
238538
|
+
if (!isDeepStrictEqual3(localConfig.automations ?? [], fn.automations)) {
|
|
238539
|
+
return false;
|
|
238540
|
+
}
|
|
238541
|
+
} catch {
|
|
238542
|
+
return false;
|
|
238422
238543
|
}
|
|
238423
|
-
const
|
|
238424
|
-
|
|
238544
|
+
for (const file2 of fn.files) {
|
|
238545
|
+
const filePath = join6(functionDir, file2.path);
|
|
238546
|
+
if (!await pathExists(filePath)) {
|
|
238547
|
+
return false;
|
|
238548
|
+
}
|
|
238549
|
+
try {
|
|
238550
|
+
const localContent = await readTextFile(filePath);
|
|
238551
|
+
if (localContent !== file2.content) {
|
|
238552
|
+
return false;
|
|
238553
|
+
}
|
|
238554
|
+
} catch {
|
|
238555
|
+
return false;
|
|
238556
|
+
}
|
|
238557
|
+
}
|
|
238558
|
+
return true;
|
|
238425
238559
|
}
|
|
238426
238560
|
// src/core/resources/function/resource.ts
|
|
238427
238561
|
var functionResource = {
|
|
238428
238562
|
readAll: readAllFunctions,
|
|
238429
|
-
push:
|
|
238563
|
+
push: (functions) => deployFunctionsSequentially(functions)
|
|
238430
238564
|
};
|
|
238431
238565
|
// src/core/project/config.ts
|
|
238432
238566
|
async function findConfigInDir(dir) {
|
|
@@ -238467,10 +238601,10 @@ async function readProjectConfig(projectRoot) {
|
|
|
238467
238601
|
const project = result.data;
|
|
238468
238602
|
const configDir = dirname5(configPath);
|
|
238469
238603
|
const [entities, functions, agents, connectors] = await Promise.all([
|
|
238470
|
-
entityResource.readAll(
|
|
238471
|
-
functionResource.readAll(
|
|
238472
|
-
agentResource.readAll(
|
|
238473
|
-
connectorResource.readAll(
|
|
238604
|
+
entityResource.readAll(join7(configDir, project.entitiesDir)),
|
|
238605
|
+
functionResource.readAll(join7(configDir, project.functionsDir)),
|
|
238606
|
+
agentResource.readAll(join7(configDir, project.agentsDir)),
|
|
238607
|
+
connectorResource.readAll(join7(configDir, project.connectorsDir))
|
|
238474
238608
|
]);
|
|
238475
238609
|
return {
|
|
238476
238610
|
project: { ...project, root, configPath },
|
|
@@ -238567,12 +238701,12 @@ async function readAppConfig(projectRoot) {
|
|
|
238567
238701
|
// src/core/project/template.ts
|
|
238568
238702
|
var import_ejs = __toESM(require_ejs(), 1);
|
|
238569
238703
|
var import_front_matter = __toESM(require_front_matter(), 1);
|
|
238570
|
-
import { dirname as dirname6, join as
|
|
238704
|
+
import { dirname as dirname6, join as join9 } from "node:path";
|
|
238571
238705
|
|
|
238572
238706
|
// src/core/assets.ts
|
|
238573
238707
|
import { cpSync, existsSync } from "node:fs";
|
|
238574
238708
|
import { homedir as homedir2 } from "node:os";
|
|
238575
|
-
import { join as
|
|
238709
|
+
import { join as join8 } from "node:path";
|
|
238576
238710
|
// package.json
|
|
238577
238711
|
var package_default = {
|
|
238578
238712
|
name: "base44",
|
|
@@ -238665,15 +238799,15 @@ var package_default = {
|
|
|
238665
238799
|
};
|
|
238666
238800
|
|
|
238667
238801
|
// src/core/assets.ts
|
|
238668
|
-
var ASSETS_DIR =
|
|
238802
|
+
var ASSETS_DIR = join8(homedir2(), ".base44", "assets", package_default.version);
|
|
238669
238803
|
function getTemplatesDir() {
|
|
238670
|
-
return
|
|
238804
|
+
return join8(ASSETS_DIR, "templates");
|
|
238671
238805
|
}
|
|
238672
238806
|
function getTemplatesIndexPath() {
|
|
238673
|
-
return
|
|
238807
|
+
return join8(ASSETS_DIR, "templates", "templates.json");
|
|
238674
238808
|
}
|
|
238675
238809
|
function getDenoWrapperPath() {
|
|
238676
|
-
return
|
|
238810
|
+
return join8(ASSETS_DIR, "deno-runtime", "main.js");
|
|
238677
238811
|
}
|
|
238678
238812
|
function ensureNpmAssets(sourceDir) {
|
|
238679
238813
|
if (existsSync(ASSETS_DIR))
|
|
@@ -238694,23 +238828,23 @@ async function listTemplates() {
|
|
|
238694
238828
|
return result.data.templates;
|
|
238695
238829
|
}
|
|
238696
238830
|
async function renderTemplate(template, destPath, data) {
|
|
238697
|
-
const templateDir =
|
|
238831
|
+
const templateDir = join9(getTemplatesDir(), template.path);
|
|
238698
238832
|
const files = await globby("**/*", {
|
|
238699
238833
|
cwd: templateDir,
|
|
238700
238834
|
dot: true,
|
|
238701
238835
|
onlyFiles: true
|
|
238702
238836
|
});
|
|
238703
238837
|
for (const file2 of files) {
|
|
238704
|
-
const srcPath =
|
|
238838
|
+
const srcPath = join9(templateDir, file2);
|
|
238705
238839
|
try {
|
|
238706
238840
|
if (file2.endsWith(".ejs")) {
|
|
238707
238841
|
const rendered = await import_ejs.default.renderFile(srcPath, data);
|
|
238708
238842
|
const { attributes, body } = import_front_matter.default(rendered);
|
|
238709
|
-
const destFile = attributes.outputFileName ?
|
|
238710
|
-
const destFilePath =
|
|
238843
|
+
const destFile = attributes.outputFileName ? join9(dirname6(file2), attributes.outputFileName) : file2.replace(/\.ejs$/, "");
|
|
238844
|
+
const destFilePath = join9(destPath, destFile);
|
|
238711
238845
|
await writeFile(destFilePath, body);
|
|
238712
238846
|
} else {
|
|
238713
|
-
const destFilePath =
|
|
238847
|
+
const destFilePath = join9(destPath, file2);
|
|
238714
238848
|
await copyFile(srcPath, destFilePath);
|
|
238715
238849
|
}
|
|
238716
238850
|
} catch (error48) {
|
|
@@ -238809,7 +238943,7 @@ async function getSiteFilePaths(outputDir) {
|
|
|
238809
238943
|
// src/core/site/deploy.ts
|
|
238810
238944
|
import { randomUUID } from "node:crypto";
|
|
238811
238945
|
import { tmpdir } from "node:os";
|
|
238812
|
-
import { join as
|
|
238946
|
+
import { join as join10 } from "node:path";
|
|
238813
238947
|
async function deploySite(siteOutputDir) {
|
|
238814
238948
|
if (!await pathExists(siteOutputDir)) {
|
|
238815
238949
|
throw new InvalidInputError(`Output directory does not exist: ${siteOutputDir}. Make sure to build your project first.`, {
|
|
@@ -238826,7 +238960,7 @@ async function deploySite(siteOutputDir) {
|
|
|
238826
238960
|
]
|
|
238827
238961
|
});
|
|
238828
238962
|
}
|
|
238829
|
-
const archivePath =
|
|
238963
|
+
const archivePath = join10(tmpdir(), `base44-site-${randomUUID()}.tar.gz`);
|
|
238830
238964
|
try {
|
|
238831
238965
|
await createArchive(siteOutputDir, archivePath);
|
|
238832
238966
|
return await uploadSite(archivePath);
|
|
@@ -238851,10 +238985,13 @@ function hasResourcesToDeploy(projectData) {
|
|
|
238851
238985
|
const hasConnectors = connectors.length > 0;
|
|
238852
238986
|
return hasEntities || hasFunctions || hasAgents || hasConnectors || hasSite;
|
|
238853
238987
|
}
|
|
238854
|
-
async function deployAll(projectData) {
|
|
238988
|
+
async function deployAll(projectData, options) {
|
|
238855
238989
|
const { project, entities, functions, agents, connectors } = projectData;
|
|
238856
238990
|
await entityResource.push(entities);
|
|
238857
|
-
await
|
|
238991
|
+
await deployFunctionsSequentially(functions, {
|
|
238992
|
+
onStart: options?.onFunctionStart,
|
|
238993
|
+
onResult: options?.onFunctionResult
|
|
238994
|
+
});
|
|
238858
238995
|
await agentResource.push(agents);
|
|
238859
238996
|
const { results: connectorResults } = await pushConnectors(connectors);
|
|
238860
238997
|
if (project.site?.outputDirectory) {
|
|
@@ -246611,7 +246748,7 @@ function formatYaml(data, options = {}) {
|
|
|
246611
246748
|
async function pullAgentsAction() {
|
|
246612
246749
|
const { project: project2 } = await readProjectConfig();
|
|
246613
246750
|
const configDir = dirname7(project2.configPath);
|
|
246614
|
-
const agentsDir =
|
|
246751
|
+
const agentsDir = join11(configDir, project2.agentsDir);
|
|
246615
246752
|
const remoteAgents = await runTask("Fetching agents from Base44", async () => {
|
|
246616
246753
|
return await fetchAgents();
|
|
246617
246754
|
}, {
|
|
@@ -246733,11 +246870,11 @@ function getConnectorsListAvailableCommand(context) {
|
|
|
246733
246870
|
}
|
|
246734
246871
|
|
|
246735
246872
|
// src/cli/commands/connectors/pull.ts
|
|
246736
|
-
import { dirname as dirname8, join as
|
|
246873
|
+
import { dirname as dirname8, join as join12 } from "node:path";
|
|
246737
246874
|
async function pullConnectorsAction() {
|
|
246738
246875
|
const { project: project2 } = await readProjectConfig();
|
|
246739
246876
|
const configDir = dirname8(project2.configPath);
|
|
246740
|
-
const connectorsDir =
|
|
246877
|
+
const connectorsDir = join12(configDir, project2.connectorsDir);
|
|
246741
246878
|
const remoteConnectors = await runTask("Fetching connectors from Base44", async () => {
|
|
246742
246879
|
return await pullAllConnectors();
|
|
246743
246880
|
}, {
|
|
@@ -247606,46 +247743,242 @@ function getEntitiesPushCommand(context) {
|
|
|
247606
247743
|
}));
|
|
247607
247744
|
}
|
|
247608
247745
|
|
|
247746
|
+
// src/cli/commands/functions/delete.ts
|
|
247747
|
+
async function deleteFunctionsAction(names) {
|
|
247748
|
+
let deleted = 0;
|
|
247749
|
+
let notFound = 0;
|
|
247750
|
+
let errors5 = 0;
|
|
247751
|
+
for (const name2 of names) {
|
|
247752
|
+
try {
|
|
247753
|
+
await runTask(`Deleting ${name2}...`, () => deleteSingleFunction(name2), {
|
|
247754
|
+
successMessage: `${name2} deleted`,
|
|
247755
|
+
errorMessage: `Failed to delete ${name2}`
|
|
247756
|
+
});
|
|
247757
|
+
deleted++;
|
|
247758
|
+
} catch (error48) {
|
|
247759
|
+
if (error48 instanceof ApiError && error48.statusCode === 404) {
|
|
247760
|
+
notFound++;
|
|
247761
|
+
} else {
|
|
247762
|
+
errors5++;
|
|
247763
|
+
}
|
|
247764
|
+
}
|
|
247765
|
+
}
|
|
247766
|
+
if (names.length === 1) {
|
|
247767
|
+
if (deleted)
|
|
247768
|
+
return { outroMessage: `Function "${names[0]}" deleted` };
|
|
247769
|
+
if (notFound)
|
|
247770
|
+
return { outroMessage: `Function "${names[0]}" not found` };
|
|
247771
|
+
return { outroMessage: `Failed to delete "${names[0]}"` };
|
|
247772
|
+
}
|
|
247773
|
+
const total = names.length;
|
|
247774
|
+
const parts = [];
|
|
247775
|
+
if (deleted > 0)
|
|
247776
|
+
parts.push(`${deleted}/${total} deleted`);
|
|
247777
|
+
if (notFound > 0)
|
|
247778
|
+
parts.push(`${notFound} not found`);
|
|
247779
|
+
if (errors5 > 0)
|
|
247780
|
+
parts.push(`${errors5} error${errors5 !== 1 ? "s" : ""}`);
|
|
247781
|
+
return { outroMessage: parts.join(", ") };
|
|
247782
|
+
}
|
|
247783
|
+
function parseNames(args) {
|
|
247784
|
+
return args.flatMap((arg) => arg.split(",")).map((n2) => n2.trim()).filter(Boolean);
|
|
247785
|
+
}
|
|
247786
|
+
function validateNames(command) {
|
|
247787
|
+
const names = parseNames(command.args);
|
|
247788
|
+
if (names.length === 0) {
|
|
247789
|
+
command.error("At least one function name is required");
|
|
247790
|
+
}
|
|
247791
|
+
}
|
|
247792
|
+
function getDeleteCommand(context) {
|
|
247793
|
+
return new Command("delete").description("Delete deployed functions").argument("<names...>", "Function names to delete").hook("preAction", validateNames).action(async (rawNames) => {
|
|
247794
|
+
const names = parseNames(rawNames);
|
|
247795
|
+
await runCommand(() => deleteFunctionsAction(names), { requireAuth: true }, context);
|
|
247796
|
+
});
|
|
247797
|
+
}
|
|
247798
|
+
|
|
247799
|
+
// src/cli/commands/functions/formatDeployResult.ts
|
|
247800
|
+
function formatDuration(ms) {
|
|
247801
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
247802
|
+
}
|
|
247803
|
+
function formatDeployResult(result) {
|
|
247804
|
+
const label = result.name.padEnd(25);
|
|
247805
|
+
if (result.status === "deployed") {
|
|
247806
|
+
const timing = result.durationMs ? theme.styles.dim(` (${formatDuration(result.durationMs)})`) : "";
|
|
247807
|
+
R2.success(`${label} deployed${timing}`);
|
|
247808
|
+
} else if (result.status === "unchanged") {
|
|
247809
|
+
R2.success(`${label} unchanged`);
|
|
247810
|
+
} else {
|
|
247811
|
+
R2.error(`${label} error: ${result.error}`);
|
|
247812
|
+
}
|
|
247813
|
+
}
|
|
247814
|
+
|
|
247815
|
+
// src/cli/commands/functions/parseNames.ts
|
|
247816
|
+
function parseNames2(args) {
|
|
247817
|
+
return args.flatMap((arg) => arg.split(",")).map((n2) => n2.trim()).filter(Boolean);
|
|
247818
|
+
}
|
|
247819
|
+
|
|
247609
247820
|
// src/cli/commands/functions/deploy.ts
|
|
247610
|
-
|
|
247821
|
+
function resolveFunctionsToDeploy(names, allFunctions) {
|
|
247822
|
+
if (names.length === 0)
|
|
247823
|
+
return allFunctions;
|
|
247824
|
+
const notFound = names.filter((n2) => !allFunctions.some((f) => f.name === n2));
|
|
247825
|
+
if (notFound.length > 0) {
|
|
247826
|
+
throw new InvalidInputError(`Function${notFound.length > 1 ? "s" : ""} not found in project: ${notFound.join(", ")}`);
|
|
247827
|
+
}
|
|
247828
|
+
return allFunctions.filter((f) => names.includes(f.name));
|
|
247829
|
+
}
|
|
247830
|
+
function formatPruneResult(pruneResult) {
|
|
247831
|
+
if (pruneResult.deleted) {
|
|
247832
|
+
R2.success(`${pruneResult.name.padEnd(25)} deleted`);
|
|
247833
|
+
} else {
|
|
247834
|
+
R2.error(`${pruneResult.name.padEnd(25)} error: ${pruneResult.error}`);
|
|
247835
|
+
}
|
|
247836
|
+
}
|
|
247837
|
+
function formatPruneSummary(pruneResults) {
|
|
247838
|
+
if (pruneResults.length > 0) {
|
|
247839
|
+
const pruned = pruneResults.filter((r) => r.deleted).length;
|
|
247840
|
+
R2.info(`${pruned} deleted`);
|
|
247841
|
+
}
|
|
247842
|
+
}
|
|
247843
|
+
function buildDeploySummary(results) {
|
|
247844
|
+
const deployed = results.filter((r) => r.status === "deployed").length;
|
|
247845
|
+
const unchanged = results.filter((r) => r.status === "unchanged").length;
|
|
247846
|
+
const failed = results.filter((r) => r.status === "error").length;
|
|
247847
|
+
const parts = [];
|
|
247848
|
+
if (deployed > 0)
|
|
247849
|
+
parts.push(`${deployed} deployed`);
|
|
247850
|
+
if (unchanged > 0)
|
|
247851
|
+
parts.push(`${unchanged} unchanged`);
|
|
247852
|
+
if (failed > 0)
|
|
247853
|
+
parts.push(`${failed} error${failed !== 1 ? "s" : ""}`);
|
|
247854
|
+
return parts.join(", ") || "No functions deployed";
|
|
247855
|
+
}
|
|
247856
|
+
async function deployFunctionsAction(names, options) {
|
|
247857
|
+
if (options.force && names.length > 0) {
|
|
247858
|
+
throw new InvalidInputError("--force cannot be used when specifying function names");
|
|
247859
|
+
}
|
|
247611
247860
|
const { functions } = await readProjectConfig();
|
|
247612
|
-
|
|
247861
|
+
const toDeploy = resolveFunctionsToDeploy(names, functions);
|
|
247862
|
+
if (toDeploy.length === 0) {
|
|
247613
247863
|
return {
|
|
247614
247864
|
outroMessage: "No functions found. Create functions in the 'functions' directory."
|
|
247615
247865
|
};
|
|
247616
247866
|
}
|
|
247617
|
-
R2.info(`Found ${
|
|
247618
|
-
|
|
247619
|
-
|
|
247867
|
+
R2.info(`Found ${toDeploy.length} ${toDeploy.length === 1 ? "function" : "functions"} to deploy`);
|
|
247868
|
+
let completed = 0;
|
|
247869
|
+
const total = toDeploy.length;
|
|
247870
|
+
const results = await deployFunctionsSequentially(toDeploy, {
|
|
247871
|
+
onStart: (startNames) => {
|
|
247872
|
+
const label = startNames.length === 1 ? startNames[0] : `${startNames.length} functions`;
|
|
247873
|
+
R2.step(theme.styles.dim(`[${completed + 1}/${total}] Deploying ${label}...`));
|
|
247874
|
+
},
|
|
247875
|
+
onResult: (result) => {
|
|
247876
|
+
completed++;
|
|
247877
|
+
formatDeployResult(result);
|
|
247878
|
+
}
|
|
247879
|
+
});
|
|
247880
|
+
if (options.force) {
|
|
247881
|
+
const allLocalNames = functions.map((f) => f.name);
|
|
247882
|
+
let pruneCompleted = 0;
|
|
247883
|
+
let pruneTotal = 0;
|
|
247884
|
+
const pruneResults = await pruneRemovedFunctions(allLocalNames, {
|
|
247885
|
+
onStart: (total2) => {
|
|
247886
|
+
pruneTotal = total2;
|
|
247887
|
+
if (total2 > 0) {
|
|
247888
|
+
R2.info(`Found ${total2} remote ${total2 === 1 ? "function" : "functions"} to delete`);
|
|
247889
|
+
}
|
|
247890
|
+
},
|
|
247891
|
+
onBeforeDelete: (name2) => {
|
|
247892
|
+
pruneCompleted++;
|
|
247893
|
+
R2.step(theme.styles.dim(`[${pruneCompleted}/${pruneTotal}] Deleting ${name2}...`));
|
|
247894
|
+
},
|
|
247895
|
+
onResult: formatPruneResult
|
|
247896
|
+
});
|
|
247897
|
+
formatPruneSummary(pruneResults);
|
|
247898
|
+
}
|
|
247899
|
+
return { outroMessage: buildDeploySummary(results) };
|
|
247900
|
+
}
|
|
247901
|
+
function getDeployCommand(context) {
|
|
247902
|
+
return new Command("deploy").description("Deploy functions to Base44").argument("[names...]", "Function names to deploy (deploys all if omitted)").option("--force", "Delete remote functions not found locally").action(async (rawNames, options) => {
|
|
247903
|
+
await runCommand(() => {
|
|
247904
|
+
const names = parseNames2(rawNames);
|
|
247905
|
+
return deployFunctionsAction(names, options);
|
|
247906
|
+
}, { requireAuth: true }, context);
|
|
247907
|
+
});
|
|
247908
|
+
}
|
|
247909
|
+
|
|
247910
|
+
// src/cli/commands/functions/list.ts
|
|
247911
|
+
async function listFunctionsAction() {
|
|
247912
|
+
const { functions } = await runTask("Fetching functions...", async () => listDeployedFunctions(), { errorMessage: "Failed to fetch functions" });
|
|
247913
|
+
if (functions.length === 0) {
|
|
247914
|
+
return { outroMessage: "No functions on remote" };
|
|
247915
|
+
}
|
|
247916
|
+
for (const fn of functions) {
|
|
247917
|
+
const automationCount = fn.automations.length;
|
|
247918
|
+
const automationLabel = automationCount > 0 ? theme.styles.dim(` (${automationCount} automation${automationCount > 1 ? "s" : ""})`) : "";
|
|
247919
|
+
R2.message(` ${fn.name}${automationLabel}`);
|
|
247920
|
+
}
|
|
247921
|
+
return {
|
|
247922
|
+
outroMessage: `${functions.length} function${functions.length !== 1 ? "s" : ""} on remote`
|
|
247923
|
+
};
|
|
247924
|
+
}
|
|
247925
|
+
function getListCommand(context) {
|
|
247926
|
+
return new Command("list").description("List all deployed functions").action(async () => {
|
|
247927
|
+
await runCommand(listFunctionsAction, { requireAuth: true }, context);
|
|
247928
|
+
});
|
|
247929
|
+
}
|
|
247930
|
+
|
|
247931
|
+
// src/cli/commands/functions/pull.ts
|
|
247932
|
+
import { dirname as dirname9, join as join13 } from "node:path";
|
|
247933
|
+
async function pullFunctionsAction(name2) {
|
|
247934
|
+
const { project: project2 } = await readProjectConfig();
|
|
247935
|
+
const configDir = dirname9(project2.configPath);
|
|
247936
|
+
const functionsDir = join13(configDir, project2.functionsDir);
|
|
247937
|
+
const remoteFunctions = await runTask("Fetching functions from Base44", async () => {
|
|
247938
|
+
const { functions } = await listDeployedFunctions();
|
|
247939
|
+
return functions;
|
|
247620
247940
|
}, {
|
|
247621
|
-
successMessage: "Functions
|
|
247622
|
-
errorMessage: "Failed to
|
|
247941
|
+
successMessage: "Functions fetched successfully",
|
|
247942
|
+
errorMessage: "Failed to fetch functions"
|
|
247623
247943
|
});
|
|
247624
|
-
|
|
247625
|
-
|
|
247944
|
+
const toPull = name2 ? remoteFunctions.filter((f) => f.name === name2) : remoteFunctions;
|
|
247945
|
+
if (name2 && toPull.length === 0) {
|
|
247946
|
+
return {
|
|
247947
|
+
outroMessage: `Function "${name2}" not found on remote`
|
|
247948
|
+
};
|
|
247626
247949
|
}
|
|
247627
|
-
if (
|
|
247628
|
-
|
|
247950
|
+
if (toPull.length === 0) {
|
|
247951
|
+
return { outroMessage: "No functions found on remote" };
|
|
247629
247952
|
}
|
|
247630
|
-
|
|
247631
|
-
|
|
247632
|
-
|
|
247633
|
-
|
|
247634
|
-
|
|
247635
|
-
|
|
247636
|
-
|
|
247637
|
-
});
|
|
247953
|
+
const { written, skipped } = await runTask("Writing function files", async () => {
|
|
247954
|
+
return await writeFunctions(functionsDir, toPull);
|
|
247955
|
+
}, {
|
|
247956
|
+
successMessage: "Function files written successfully",
|
|
247957
|
+
errorMessage: "Failed to write function files"
|
|
247958
|
+
});
|
|
247959
|
+
for (const name3 of written) {
|
|
247960
|
+
R2.success(`${name3.padEnd(25)} written`);
|
|
247638
247961
|
}
|
|
247639
|
-
|
|
247962
|
+
for (const name3 of skipped) {
|
|
247963
|
+
R2.info(`${name3.padEnd(25)} unchanged`);
|
|
247964
|
+
}
|
|
247965
|
+
return {
|
|
247966
|
+
outroMessage: `Pulled ${toPull.length} function${toPull.length !== 1 ? "s" : ""} to ${functionsDir}`
|
|
247967
|
+
};
|
|
247640
247968
|
}
|
|
247641
|
-
function
|
|
247642
|
-
return new Command("
|
|
247643
|
-
await runCommand(
|
|
247644
|
-
})
|
|
247969
|
+
function getPullCommand(context) {
|
|
247970
|
+
return new Command("pull").description("Pull deployed functions from Base44").argument("[name]", "Function name to pull (pulls all if omitted)").action(async (name2) => {
|
|
247971
|
+
await runCommand(() => pullFunctionsAction(name2), { requireAuth: true }, context);
|
|
247972
|
+
});
|
|
247973
|
+
}
|
|
247974
|
+
|
|
247975
|
+
// src/cli/commands/functions/index.ts
|
|
247976
|
+
function getFunctionsCommand(context) {
|
|
247977
|
+
return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand(context)).addCommand(getDeleteCommand(context)).addCommand(getListCommand(context)).addCommand(getPullCommand(context));
|
|
247645
247978
|
}
|
|
247646
247979
|
|
|
247647
247980
|
// src/cli/commands/project/create.ts
|
|
247648
|
-
import { basename as basename3, join as
|
|
247981
|
+
import { basename as basename3, join as join14, resolve as resolve2 } from "node:path";
|
|
247649
247982
|
var import_kebabCase = __toESM(require_kebabCase(), 1);
|
|
247650
247983
|
var DEFAULT_TEMPLATE_ID = "backend-only";
|
|
247651
247984
|
async function getTemplateById(templateId) {
|
|
@@ -247782,7 +248115,7 @@ async function executeCreate({
|
|
|
247782
248115
|
updateMessage("Building project...");
|
|
247783
248116
|
await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;
|
|
247784
248117
|
updateMessage("Deploying site...");
|
|
247785
|
-
return await deploySite(
|
|
248118
|
+
return await deploySite(join14(resolvedPath, outputDirectory));
|
|
247786
248119
|
}, {
|
|
247787
248120
|
successMessage: theme.colors.base44Orange("Site deployed successfully"),
|
|
247788
248121
|
errorMessage: "Failed to deploy site"
|
|
@@ -247869,11 +248202,17 @@ ${summaryLines.join(`
|
|
|
247869
248202
|
${summaryLines.join(`
|
|
247870
248203
|
`)}`);
|
|
247871
248204
|
}
|
|
247872
|
-
|
|
247873
|
-
|
|
247874
|
-
|
|
247875
|
-
|
|
247876
|
-
|
|
248205
|
+
let functionCompleted = 0;
|
|
248206
|
+
const functionTotal = functions.length;
|
|
248207
|
+
const result = await deployAll(projectData, {
|
|
248208
|
+
onFunctionStart: (names) => {
|
|
248209
|
+
const label = names.length === 1 ? names[0] : `${names.length} functions`;
|
|
248210
|
+
R2.step(theme.styles.dim(`[${functionCompleted + 1}/${functionTotal}] Deploying ${label}...`));
|
|
248211
|
+
},
|
|
248212
|
+
onFunctionResult: (r) => {
|
|
248213
|
+
functionCompleted++;
|
|
248214
|
+
formatDeployResult(r);
|
|
248215
|
+
}
|
|
247877
248216
|
});
|
|
247878
248217
|
const connectorResults = result.connectorResults ?? [];
|
|
247879
248218
|
await handleOAuthConnectors(connectorResults, options);
|
|
@@ -247887,7 +248226,7 @@ ${summaryLines.join(`
|
|
|
247887
248226
|
}
|
|
247888
248227
|
return { outroMessage: "App deployed successfully" };
|
|
247889
248228
|
}
|
|
247890
|
-
function
|
|
248229
|
+
function getDeployCommand2(context) {
|
|
247891
248230
|
return new Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
|
|
247892
248231
|
await runCommand(() => deployAction({
|
|
247893
248232
|
...options,
|
|
@@ -248432,10 +248771,10 @@ function toPascalCase(name2) {
|
|
|
248432
248771
|
return name2.split(/[-_\s]+/).map((w8) => w8.charAt(0).toUpperCase() + w8.slice(1)).join("");
|
|
248433
248772
|
}
|
|
248434
248773
|
// src/core/types/update-project.ts
|
|
248435
|
-
import { join as
|
|
248774
|
+
import { join as join17 } from "node:path";
|
|
248436
248775
|
var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
|
|
248437
248776
|
async function updateProjectConfig(projectRoot) {
|
|
248438
|
-
const tsconfigPath =
|
|
248777
|
+
const tsconfigPath = join17(projectRoot, "tsconfig.json");
|
|
248439
248778
|
if (!await pathExists(tsconfigPath)) {
|
|
248440
248779
|
return false;
|
|
248441
248780
|
}
|
|
@@ -248478,7 +248817,7 @@ function getTypesCommand(context) {
|
|
|
248478
248817
|
}
|
|
248479
248818
|
|
|
248480
248819
|
// src/cli/dev/dev-server/main.ts
|
|
248481
|
-
import { dirname as
|
|
248820
|
+
import { dirname as dirname14, join as join20 } from "node:path";
|
|
248482
248821
|
var import_cors = __toESM(require_lib4(), 1);
|
|
248483
248822
|
var import_express4 = __toESM(require_express(), 1);
|
|
248484
248823
|
|
|
@@ -249958,9 +250297,9 @@ class NodeFsHandler {
|
|
|
249958
250297
|
if (this.fsw.closed) {
|
|
249959
250298
|
return;
|
|
249960
250299
|
}
|
|
249961
|
-
const
|
|
250300
|
+
const dirname13 = sp2.dirname(file2);
|
|
249962
250301
|
const basename5 = sp2.basename(file2);
|
|
249963
|
-
const parent = this.fsw._getWatchedDir(
|
|
250302
|
+
const parent = this.fsw._getWatchedDir(dirname13);
|
|
249964
250303
|
let prevStats = stats;
|
|
249965
250304
|
if (parent.has(basename5))
|
|
249966
250305
|
return;
|
|
@@ -249987,7 +250326,7 @@ class NodeFsHandler {
|
|
|
249987
250326
|
prevStats = newStats2;
|
|
249988
250327
|
}
|
|
249989
250328
|
} catch (error48) {
|
|
249990
|
-
this.fsw._remove(
|
|
250329
|
+
this.fsw._remove(dirname13, basename5);
|
|
249991
250330
|
}
|
|
249992
250331
|
} else if (parent.has(basename5)) {
|
|
249993
250332
|
const at13 = newStats.atimeMs;
|
|
@@ -251008,8 +251347,8 @@ async function createDevServer(options8) {
|
|
|
251008
251347
|
broadcastEntityEvent(io6, appId, entityName, event);
|
|
251009
251348
|
};
|
|
251010
251349
|
const base44ConfigWatcher = new WatchBase44({
|
|
251011
|
-
functions:
|
|
251012
|
-
entities:
|
|
251350
|
+
functions: join20(dirname14(project2.configPath), project2.functionsDir),
|
|
251351
|
+
entities: join20(dirname14(project2.configPath), project2.entitiesDir)
|
|
251013
251352
|
}, devLogger);
|
|
251014
251353
|
base44ConfigWatcher.on("change", async (name2) => {
|
|
251015
251354
|
try {
|
|
@@ -251167,98 +251506,6 @@ function getEjectCommand(context) {
|
|
|
251167
251506
|
});
|
|
251168
251507
|
}
|
|
251169
251508
|
|
|
251170
|
-
// src/cli/commands/project/validate.ts
|
|
251171
|
-
import { dirname as dirname14, join as join19, relative as relative7 } from "node:path";
|
|
251172
|
-
async function validateFiles(dir, glob, schema9, projectRoot) {
|
|
251173
|
-
if (!await pathExists(dir)) {
|
|
251174
|
-
return [];
|
|
251175
|
-
}
|
|
251176
|
-
const files = await globby(glob, { cwd: dir, absolute: true });
|
|
251177
|
-
const results = [];
|
|
251178
|
-
for (const filePath of files) {
|
|
251179
|
-
const relativePath = relative7(projectRoot, filePath);
|
|
251180
|
-
try {
|
|
251181
|
-
const parsed = await readJsonFile(filePath);
|
|
251182
|
-
const result = schema9.safeParse(parsed);
|
|
251183
|
-
if (result.success) {
|
|
251184
|
-
results.push({ relativePath, valid: true });
|
|
251185
|
-
} else {
|
|
251186
|
-
results.push({
|
|
251187
|
-
relativePath,
|
|
251188
|
-
valid: false,
|
|
251189
|
-
errorText: exports_external.prettifyError(result.error)
|
|
251190
|
-
});
|
|
251191
|
-
}
|
|
251192
|
-
} catch (error48) {
|
|
251193
|
-
results.push({
|
|
251194
|
-
relativePath,
|
|
251195
|
-
valid: false,
|
|
251196
|
-
errorText: error48 instanceof Error ? error48.message : String(error48)
|
|
251197
|
-
});
|
|
251198
|
-
}
|
|
251199
|
-
}
|
|
251200
|
-
return results;
|
|
251201
|
-
}
|
|
251202
|
-
function printResults(results) {
|
|
251203
|
-
for (const result of results) {
|
|
251204
|
-
if (result.valid) {
|
|
251205
|
-
R2.success(result.relativePath);
|
|
251206
|
-
} else {
|
|
251207
|
-
const indented = result.errorText?.split(`
|
|
251208
|
-
`).map((line3) => ` ${line3}`).join(`
|
|
251209
|
-
`);
|
|
251210
|
-
R2.error(`${result.relativePath}
|
|
251211
|
-
${indented ?? ""}`);
|
|
251212
|
-
}
|
|
251213
|
-
}
|
|
251214
|
-
}
|
|
251215
|
-
async function validateAction() {
|
|
251216
|
-
const found = await findProjectRoot();
|
|
251217
|
-
if (!found) {
|
|
251218
|
-
throw new ConfigNotFoundError;
|
|
251219
|
-
}
|
|
251220
|
-
const { root: root2, configPath } = found;
|
|
251221
|
-
const relConfigPath = relative7(root2, configPath);
|
|
251222
|
-
const allResults = [];
|
|
251223
|
-
const configParsed = await readJsonFile(configPath);
|
|
251224
|
-
const configResult = ProjectConfigSchema.safeParse(configParsed);
|
|
251225
|
-
if (!configResult.success) {
|
|
251226
|
-
allResults.push({
|
|
251227
|
-
relativePath: relConfigPath,
|
|
251228
|
-
valid: false,
|
|
251229
|
-
errorText: exports_external.prettifyError(configResult.error)
|
|
251230
|
-
});
|
|
251231
|
-
printResults(allResults);
|
|
251232
|
-
process.exitCode = 1;
|
|
251233
|
-
return { outroMessage: "1 file checked — 0 passed, 1 failed" };
|
|
251234
|
-
}
|
|
251235
|
-
allResults.push({ relativePath: relConfigPath, valid: true });
|
|
251236
|
-
const config10 = configResult.data;
|
|
251237
|
-
const configDir = dirname14(configPath);
|
|
251238
|
-
const [entityResults, agentResults, connectorResults, functionResults] = await Promise.all([
|
|
251239
|
-
validateFiles(join19(configDir, config10.entitiesDir), `*.${CONFIG_FILE_EXTENSION_GLOB}`, EntitySchema, root2),
|
|
251240
|
-
validateFiles(join19(configDir, config10.agentsDir), `*.${CONFIG_FILE_EXTENSION_GLOB}`, AgentConfigSchema, root2),
|
|
251241
|
-
validateFiles(join19(configDir, config10.connectorsDir), `*.${CONFIG_FILE_EXTENSION_GLOB}`, ConnectorResourceSchema, root2),
|
|
251242
|
-
validateFiles(join19(configDir, config10.functionsDir), FUNCTION_CONFIG_GLOB, FunctionConfigSchema, root2)
|
|
251243
|
-
]);
|
|
251244
|
-
allResults.push(...entityResults, ...agentResults, ...connectorResults, ...functionResults);
|
|
251245
|
-
printResults(allResults);
|
|
251246
|
-
const failCount = allResults.filter((r5) => !r5.valid).length;
|
|
251247
|
-
const passCount = allResults.length - failCount;
|
|
251248
|
-
const total = allResults.length;
|
|
251249
|
-
if (failCount > 0) {
|
|
251250
|
-
process.exitCode = 1;
|
|
251251
|
-
}
|
|
251252
|
-
return {
|
|
251253
|
-
outroMessage: failCount > 0 ? `${total} file${total !== 1 ? "s" : ""} checked — ${passCount} passed, ${failCount} failed` : `All ${passCount} file${passCount !== 1 ? "s" : ""} valid`
|
|
251254
|
-
};
|
|
251255
|
-
}
|
|
251256
|
-
function getValidateCommand(context) {
|
|
251257
|
-
return new Command("validate").description("Validate all resource config files in the project (entities, functions, agents, connectors)").action(async () => {
|
|
251258
|
-
await runCommand(validateAction, { requireAuth: false, requireAppConfig: false }, context);
|
|
251259
|
-
});
|
|
251260
|
-
}
|
|
251261
|
-
|
|
251262
251509
|
// src/cli/program.ts
|
|
251263
251510
|
function createProgram(context) {
|
|
251264
251511
|
const program2 = new Command;
|
|
@@ -251271,14 +251518,13 @@ function createProgram(context) {
|
|
|
251271
251518
|
program2.addCommand(getLogoutCommand(context));
|
|
251272
251519
|
program2.addCommand(getCreateCommand(context));
|
|
251273
251520
|
program2.addCommand(getDashboardCommand(context));
|
|
251274
|
-
program2.addCommand(
|
|
251521
|
+
program2.addCommand(getDeployCommand2(context));
|
|
251275
251522
|
program2.addCommand(getLinkCommand(context));
|
|
251276
251523
|
program2.addCommand(getEjectCommand(context));
|
|
251277
|
-
program2.addCommand(getValidateCommand(context));
|
|
251278
251524
|
program2.addCommand(getEntitiesPushCommand(context));
|
|
251279
251525
|
program2.addCommand(getAgentsCommand(context));
|
|
251280
251526
|
program2.addCommand(getConnectorsCommand(context));
|
|
251281
|
-
program2.addCommand(
|
|
251527
|
+
program2.addCommand(getFunctionsCommand(context));
|
|
251282
251528
|
program2.addCommand(getSecretsCommand(context));
|
|
251283
251529
|
program2.addCommand(getSiteCommand(context));
|
|
251284
251530
|
program2.addCommand(getTypesCommand(context));
|
|
@@ -255492,7 +255738,7 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
|
|
|
255492
255738
|
// src/cli/index.ts
|
|
255493
255739
|
var __dirname4 = dirname16(fileURLToPath6(import.meta.url));
|
|
255494
255740
|
async function runCLI(options8) {
|
|
255495
|
-
ensureNpmAssets(
|
|
255741
|
+
ensureNpmAssets(join21(__dirname4, "../assets"));
|
|
255496
255742
|
const errorReporter = new ErrorReporter;
|
|
255497
255743
|
errorReporter.registerProcessErrorHandlers();
|
|
255498
255744
|
const isNonInteractive = !process.stdin.isTTY || !process.stdout.isTTY;
|
|
@@ -255525,4 +255771,4 @@ export {
|
|
|
255525
255771
|
CLIExitError
|
|
255526
255772
|
};
|
|
255527
255773
|
|
|
255528
|
-
//# debugId=
|
|
255774
|
+
//# debugId=D45CBAA052F0000364756E2164756E21
|