@base44-preview/cli 0.0.33-pr.225.220b697 → 0.0.33-pr.225.3509af6
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 +117 -117
- package/dist/cli/index.js.map +9 -9
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -195109,122 +195109,6 @@ function getFunctionsDeployCommand(context) {
|
|
|
195109
195109
|
}));
|
|
195110
195110
|
}
|
|
195111
195111
|
|
|
195112
|
-
// src/cli/commands/project/logs.ts
|
|
195113
|
-
function parseFunctionFilters(options) {
|
|
195114
|
-
const filters = {};
|
|
195115
|
-
if (options.since) {
|
|
195116
|
-
filters.since = options.since;
|
|
195117
|
-
}
|
|
195118
|
-
if (options.until) {
|
|
195119
|
-
filters.until = options.until;
|
|
195120
|
-
}
|
|
195121
|
-
if (options.limit) {
|
|
195122
|
-
filters.limit = Number.parseInt(options.limit, 10);
|
|
195123
|
-
}
|
|
195124
|
-
if (options.order) {
|
|
195125
|
-
filters.order = options.order.toLowerCase();
|
|
195126
|
-
}
|
|
195127
|
-
return filters;
|
|
195128
|
-
}
|
|
195129
|
-
function parseFunctionNames(option) {
|
|
195130
|
-
if (!option)
|
|
195131
|
-
return [];
|
|
195132
|
-
return option.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
195133
|
-
}
|
|
195134
|
-
function normalizeDatetime(value) {
|
|
195135
|
-
if (/Z$|[+-]\d{2}:\d{2}$/.test(value))
|
|
195136
|
-
return value;
|
|
195137
|
-
return `${value}Z`;
|
|
195138
|
-
}
|
|
195139
|
-
function formatEntry(entry) {
|
|
195140
|
-
const time3 = entry.time.substring(0, 19).replace("T", " ");
|
|
195141
|
-
const level = entry.level.toUpperCase().padEnd(5);
|
|
195142
|
-
const message = entry.message.trim();
|
|
195143
|
-
return `${time3} ${level} ${message}`;
|
|
195144
|
-
}
|
|
195145
|
-
function formatLogs(entries) {
|
|
195146
|
-
if (entries.length === 0) {
|
|
195147
|
-
return `No logs found matching the filters.
|
|
195148
|
-
`;
|
|
195149
|
-
}
|
|
195150
|
-
const header2 = `Showing ${entries.length} function log entries
|
|
195151
|
-
`;
|
|
195152
|
-
return [header2, ...entries.map(formatEntry)].join(`
|
|
195153
|
-
`);
|
|
195154
|
-
}
|
|
195155
|
-
function normalizeLogEntry(entry, functionName) {
|
|
195156
|
-
return {
|
|
195157
|
-
time: entry.time,
|
|
195158
|
-
level: entry.level,
|
|
195159
|
-
message: `[${functionName}] ${entry.message}`,
|
|
195160
|
-
source: functionName
|
|
195161
|
-
};
|
|
195162
|
-
}
|
|
195163
|
-
async function fetchLogsForFunctions(functionNames, options, availableFunctionNames) {
|
|
195164
|
-
const filters = parseFunctionFilters(options);
|
|
195165
|
-
const allEntries = [];
|
|
195166
|
-
for (const functionName of functionNames) {
|
|
195167
|
-
let logs;
|
|
195168
|
-
try {
|
|
195169
|
-
logs = await fetchFunctionLogs(functionName, filters);
|
|
195170
|
-
} catch (error48) {
|
|
195171
|
-
if (error48 instanceof ApiError && error48.statusCode === 404 && availableFunctionNames.length > 0) {
|
|
195172
|
-
const available = availableFunctionNames.join(", ");
|
|
195173
|
-
throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
|
|
195174
|
-
hints: [
|
|
195175
|
-
{
|
|
195176
|
-
message: `Available functions in this project: ${available}`
|
|
195177
|
-
},
|
|
195178
|
-
{
|
|
195179
|
-
message: "Make sure the function has been deployed before fetching logs",
|
|
195180
|
-
command: "base44 functions deploy"
|
|
195181
|
-
}
|
|
195182
|
-
]
|
|
195183
|
-
});
|
|
195184
|
-
}
|
|
195185
|
-
throw error48;
|
|
195186
|
-
}
|
|
195187
|
-
const entries = logs.map((entry) => normalizeLogEntry(entry, functionName));
|
|
195188
|
-
allEntries.push(...entries);
|
|
195189
|
-
}
|
|
195190
|
-
if (functionNames.length > 1) {
|
|
195191
|
-
const order = options.order?.toUpperCase() === "ASC" ? 1 : -1;
|
|
195192
|
-
allEntries.sort((a2, b) => order * a2.time.localeCompare(b.time));
|
|
195193
|
-
}
|
|
195194
|
-
return allEntries;
|
|
195195
|
-
}
|
|
195196
|
-
async function getAllFunctionNames() {
|
|
195197
|
-
const { functions } = await readProjectConfig();
|
|
195198
|
-
return functions.map((fn) => fn.name);
|
|
195199
|
-
}
|
|
195200
|
-
async function logsAction(options) {
|
|
195201
|
-
const specifiedFunctions = parseFunctionNames(options.function);
|
|
195202
|
-
const allProjectFunctions = await getAllFunctionNames();
|
|
195203
|
-
const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : allProjectFunctions;
|
|
195204
|
-
if (functionNames.length === 0) {
|
|
195205
|
-
return { outroMessage: "No functions found in this project." };
|
|
195206
|
-
}
|
|
195207
|
-
let entries = await fetchLogsForFunctions(functionNames, options, allProjectFunctions);
|
|
195208
|
-
const limit = options.limit ? Number.parseInt(options.limit, 10) : undefined;
|
|
195209
|
-
if (limit !== undefined && entries.length > limit) {
|
|
195210
|
-
entries = entries.slice(0, limit);
|
|
195211
|
-
}
|
|
195212
|
-
const logsOutput = options.json ? `${JSON.stringify(entries, null, 2)}
|
|
195213
|
-
` : formatLogs(entries);
|
|
195214
|
-
return { outroMessage: "Fetched logs", stdout: logsOutput };
|
|
195215
|
-
}
|
|
195216
|
-
function getLogsCommand(context) {
|
|
195217
|
-
return new Command("logs").description("Fetch function logs for this app").option("--function <names>", "Filter by function name(s), comma-separated. If omitted, fetches logs for all project functions").option("--since <datetime>", "Show logs from this time (ISO format)", normalizeDatetime).option("--until <datetime>", "Show logs until this time (ISO format)", normalizeDatetime).option("-n, --limit <n>", "Results per page (1-1000, default: 50)", (v) => {
|
|
195218
|
-
const n2 = Number.parseInt(v, 10);
|
|
195219
|
-
if (Number.isNaN(n2) || n2 < 1 || n2 > 1000) {
|
|
195220
|
-
throw new InvalidInputError(`Invalid limit: "${v}". Must be a number between 1 and 1000.`);
|
|
195221
|
-
}
|
|
195222
|
-
return v;
|
|
195223
|
-
}).addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).option("--json", "Output raw JSON").action(async (options) => {
|
|
195224
|
-
await runCommand(() => logsAction(options), { requireAuth: true }, context);
|
|
195225
|
-
});
|
|
195226
|
-
}
|
|
195227
|
-
|
|
195228
195112
|
// src/cli/commands/project/create.ts
|
|
195229
195113
|
import { basename as basename3, join as join11, resolve as resolve2 } from "node:path";
|
|
195230
195114
|
var import_lodash = __toESM(require_lodash(), 1);
|
|
@@ -195619,6 +195503,122 @@ function getLinkCommand(context) {
|
|
|
195619
195503
|
});
|
|
195620
195504
|
}
|
|
195621
195505
|
|
|
195506
|
+
// src/cli/commands/project/logs.ts
|
|
195507
|
+
function parseFunctionFilters(options) {
|
|
195508
|
+
const filters = {};
|
|
195509
|
+
if (options.since) {
|
|
195510
|
+
filters.since = options.since;
|
|
195511
|
+
}
|
|
195512
|
+
if (options.until) {
|
|
195513
|
+
filters.until = options.until;
|
|
195514
|
+
}
|
|
195515
|
+
if (options.limit) {
|
|
195516
|
+
filters.limit = Number.parseInt(options.limit, 10);
|
|
195517
|
+
}
|
|
195518
|
+
if (options.order) {
|
|
195519
|
+
filters.order = options.order.toLowerCase();
|
|
195520
|
+
}
|
|
195521
|
+
return filters;
|
|
195522
|
+
}
|
|
195523
|
+
function parseFunctionNames(option) {
|
|
195524
|
+
if (!option)
|
|
195525
|
+
return [];
|
|
195526
|
+
return option.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
195527
|
+
}
|
|
195528
|
+
function normalizeDatetime(value) {
|
|
195529
|
+
if (/Z$|[+-]\d{2}:\d{2}$/.test(value))
|
|
195530
|
+
return value;
|
|
195531
|
+
return `${value}Z`;
|
|
195532
|
+
}
|
|
195533
|
+
function formatEntry(entry) {
|
|
195534
|
+
const time3 = entry.time.substring(0, 19).replace("T", " ");
|
|
195535
|
+
const level = entry.level.toUpperCase().padEnd(5);
|
|
195536
|
+
const message = entry.message.trim();
|
|
195537
|
+
return `${time3} ${level} ${message}`;
|
|
195538
|
+
}
|
|
195539
|
+
function formatLogs(entries) {
|
|
195540
|
+
if (entries.length === 0) {
|
|
195541
|
+
return `No logs found matching the filters.
|
|
195542
|
+
`;
|
|
195543
|
+
}
|
|
195544
|
+
const header2 = `Showing ${entries.length} function log entries
|
|
195545
|
+
`;
|
|
195546
|
+
return [header2, ...entries.map(formatEntry)].join(`
|
|
195547
|
+
`);
|
|
195548
|
+
}
|
|
195549
|
+
function normalizeLogEntry(entry, functionName) {
|
|
195550
|
+
return {
|
|
195551
|
+
time: entry.time,
|
|
195552
|
+
level: entry.level,
|
|
195553
|
+
message: `[${functionName}] ${entry.message}`,
|
|
195554
|
+
source: functionName
|
|
195555
|
+
};
|
|
195556
|
+
}
|
|
195557
|
+
async function fetchLogsForFunctions(functionNames, options, availableFunctionNames) {
|
|
195558
|
+
const filters = parseFunctionFilters(options);
|
|
195559
|
+
const allEntries = [];
|
|
195560
|
+
for (const functionName of functionNames) {
|
|
195561
|
+
let logs;
|
|
195562
|
+
try {
|
|
195563
|
+
logs = await fetchFunctionLogs(functionName, filters);
|
|
195564
|
+
} catch (error48) {
|
|
195565
|
+
if (error48 instanceof ApiError && error48.statusCode === 404 && availableFunctionNames.length > 0) {
|
|
195566
|
+
const available = availableFunctionNames.join(", ");
|
|
195567
|
+
throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
|
|
195568
|
+
hints: [
|
|
195569
|
+
{
|
|
195570
|
+
message: `Available functions in this project: ${available}`
|
|
195571
|
+
},
|
|
195572
|
+
{
|
|
195573
|
+
message: "Make sure the function has been deployed before fetching logs",
|
|
195574
|
+
command: "base44 functions deploy"
|
|
195575
|
+
}
|
|
195576
|
+
]
|
|
195577
|
+
});
|
|
195578
|
+
}
|
|
195579
|
+
throw error48;
|
|
195580
|
+
}
|
|
195581
|
+
const entries = logs.map((entry) => normalizeLogEntry(entry, functionName));
|
|
195582
|
+
allEntries.push(...entries);
|
|
195583
|
+
}
|
|
195584
|
+
if (functionNames.length > 1) {
|
|
195585
|
+
const order = options.order?.toUpperCase() === "ASC" ? 1 : -1;
|
|
195586
|
+
allEntries.sort((a2, b) => order * a2.time.localeCompare(b.time));
|
|
195587
|
+
}
|
|
195588
|
+
return allEntries;
|
|
195589
|
+
}
|
|
195590
|
+
async function getAllFunctionNames() {
|
|
195591
|
+
const { functions } = await readProjectConfig();
|
|
195592
|
+
return functions.map((fn) => fn.name);
|
|
195593
|
+
}
|
|
195594
|
+
async function logsAction(options) {
|
|
195595
|
+
const specifiedFunctions = parseFunctionNames(options.function);
|
|
195596
|
+
const allProjectFunctions = await getAllFunctionNames();
|
|
195597
|
+
const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : allProjectFunctions;
|
|
195598
|
+
if (functionNames.length === 0) {
|
|
195599
|
+
return { outroMessage: "No functions found in this project." };
|
|
195600
|
+
}
|
|
195601
|
+
let entries = await fetchLogsForFunctions(functionNames, options, allProjectFunctions);
|
|
195602
|
+
const limit = options.limit ? Number.parseInt(options.limit, 10) : undefined;
|
|
195603
|
+
if (limit !== undefined && entries.length > limit) {
|
|
195604
|
+
entries = entries.slice(0, limit);
|
|
195605
|
+
}
|
|
195606
|
+
const logsOutput = options.json ? `${JSON.stringify(entries, null, 2)}
|
|
195607
|
+
` : formatLogs(entries);
|
|
195608
|
+
return { outroMessage: "Fetched logs", stdout: logsOutput };
|
|
195609
|
+
}
|
|
195610
|
+
function getLogsCommand(context) {
|
|
195611
|
+
return new Command("logs").description("Fetch function logs for this app").option("--function <names>", "Filter by function name(s), comma-separated. If omitted, fetches logs for all project functions").option("--since <datetime>", "Show logs from this time (ISO format)", normalizeDatetime).option("--until <datetime>", "Show logs until this time (ISO format)", normalizeDatetime).option("-n, --limit <n>", "Results per page (1-1000, default: 50)", (v) => {
|
|
195612
|
+
const n2 = Number.parseInt(v, 10);
|
|
195613
|
+
if (Number.isNaN(n2) || n2 < 1 || n2 > 1000) {
|
|
195614
|
+
throw new InvalidInputError(`Invalid limit: "${v}". Must be a number between 1 and 1000.`);
|
|
195615
|
+
}
|
|
195616
|
+
return v;
|
|
195617
|
+
}).addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).option("--json", "Output raw JSON").action(async (options) => {
|
|
195618
|
+
await runCommand(() => logsAction(options), { requireAuth: true }, context);
|
|
195619
|
+
});
|
|
195620
|
+
}
|
|
195621
|
+
|
|
195622
195622
|
// src/cli/commands/site/deploy.ts
|
|
195623
195623
|
import { resolve as resolve3 } from "node:path";
|
|
195624
195624
|
async function deployAction2(options) {
|
|
@@ -200605,4 +200605,4 @@ export {
|
|
|
200605
200605
|
CLIExitError
|
|
200606
200606
|
};
|
|
200607
200607
|
|
|
200608
|
-
//# debugId=
|
|
200608
|
+
//# debugId=4A72726F99984B0D64756E2164756E21
|