@base44-preview/cli 0.0.33-pr.338.9ac2209 → 0.0.33-pr.338.c6ab1f7
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 +62 -53
- package/dist/cli/index.js.map +8 -8
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -186126,21 +186126,25 @@ async function readAllFunctions(functionsDir) {
|
|
|
186126
186126
|
// src/core/resources/function/deploy.ts
|
|
186127
186127
|
import { basename as basename2 } from "node:path";
|
|
186128
186128
|
async function loadFunctionCode(fn) {
|
|
186129
|
-
const
|
|
186129
|
+
const resolvedFiles = await Promise.all(fn.filePaths.map(async (filePath) => {
|
|
186130
186130
|
const content = await readTextFile(filePath);
|
|
186131
186131
|
return { path: basename2(filePath), content };
|
|
186132
186132
|
}));
|
|
186133
|
-
return { ...fn, files:
|
|
186133
|
+
return { ...fn, files: resolvedFiles };
|
|
186134
186134
|
}
|
|
186135
186135
|
async function deployOne(fn) {
|
|
186136
186136
|
try {
|
|
186137
|
-
const
|
|
186138
|
-
const
|
|
186139
|
-
entry:
|
|
186140
|
-
files:
|
|
186141
|
-
automations:
|
|
186137
|
+
const functionWithCode = await loadFunctionCode(fn);
|
|
186138
|
+
const response = await deploySingleFunction(functionWithCode.name, {
|
|
186139
|
+
entry: functionWithCode.entry,
|
|
186140
|
+
files: functionWithCode.files,
|
|
186141
|
+
automations: functionWithCode.automations
|
|
186142
186142
|
});
|
|
186143
|
-
return {
|
|
186143
|
+
return {
|
|
186144
|
+
name: functionWithCode.name,
|
|
186145
|
+
status: response.status,
|
|
186146
|
+
durationMs: response.duration_ms
|
|
186147
|
+
};
|
|
186144
186148
|
} catch (error48) {
|
|
186145
186149
|
return {
|
|
186146
186150
|
name: fn.name,
|
|
@@ -186149,7 +186153,7 @@ async function deployOne(fn) {
|
|
|
186149
186153
|
};
|
|
186150
186154
|
}
|
|
186151
186155
|
}
|
|
186152
|
-
async function
|
|
186156
|
+
async function deployFunctionsSequentially(functions, options) {
|
|
186153
186157
|
if (functions.length === 0)
|
|
186154
186158
|
return [];
|
|
186155
186159
|
const results = [];
|
|
@@ -186183,7 +186187,7 @@ async function pruneRemovedFunctions(localFunctionNames) {
|
|
|
186183
186187
|
// src/core/resources/function/resource.ts
|
|
186184
186188
|
var functionResource = {
|
|
186185
186189
|
readAll: readAllFunctions,
|
|
186186
|
-
push: (functions) =>
|
|
186190
|
+
push: (functions) => deployFunctionsSequentially(functions)
|
|
186187
186191
|
};
|
|
186188
186192
|
// src/core/project/config.ts
|
|
186189
186193
|
async function findConfigInDir(dir) {
|
|
@@ -186498,7 +186502,7 @@ function hasResourcesToDeploy(projectData) {
|
|
|
186498
186502
|
async function deployAll(projectData, options) {
|
|
186499
186503
|
const { project, entities, functions, agents, connectors } = projectData;
|
|
186500
186504
|
await entityResource.push(entities);
|
|
186501
|
-
await
|
|
186505
|
+
await deployFunctionsSequentially(functions, {
|
|
186502
186506
|
onStart: options?.onFunctionStart,
|
|
186503
186507
|
onResult: options?.onFunctionResult
|
|
186504
186508
|
});
|
|
@@ -195157,34 +195161,57 @@ function getDeleteCommand(context) {
|
|
|
195157
195161
|
function formatDuration(ms) {
|
|
195158
195162
|
return `${(ms / 1000).toFixed(1)}s`;
|
|
195159
195163
|
}
|
|
195160
|
-
function formatDeployResult(
|
|
195161
|
-
const label =
|
|
195162
|
-
if (
|
|
195163
|
-
const timing =
|
|
195164
|
+
function formatDeployResult(result) {
|
|
195165
|
+
const label = result.name.padEnd(25);
|
|
195166
|
+
if (result.status === "deployed") {
|
|
195167
|
+
const timing = result.durationMs ? theme.styles.dim(` (${formatDuration(result.durationMs)})`) : "";
|
|
195164
195168
|
R2.success(`${label} deployed${timing}`);
|
|
195165
|
-
} else if (
|
|
195169
|
+
} else if (result.status === "unchanged") {
|
|
195166
195170
|
R2.success(`${label} unchanged`);
|
|
195167
195171
|
} else {
|
|
195168
|
-
R2.error(`${label} error: ${
|
|
195172
|
+
R2.error(`${label} error: ${result.error}`);
|
|
195169
195173
|
}
|
|
195170
195174
|
}
|
|
195171
195175
|
|
|
195172
195176
|
// src/cli/commands/functions/deploy.ts
|
|
195177
|
+
function resolveFunctionsToDeploy(names, allFunctions) {
|
|
195178
|
+
if (names.length === 0)
|
|
195179
|
+
return allFunctions;
|
|
195180
|
+
const notFound = names.filter((n2) => !allFunctions.some((f) => f.name === n2));
|
|
195181
|
+
if (notFound.length > 0) {
|
|
195182
|
+
throw new InvalidInputError(`Function${notFound.length > 1 ? "s" : ""} not found in project: ${notFound.join(", ")}`);
|
|
195183
|
+
}
|
|
195184
|
+
return allFunctions.filter((f) => names.includes(f.name));
|
|
195185
|
+
}
|
|
195186
|
+
function formatPruneResults(pruneResults) {
|
|
195187
|
+
for (const pruneResult of pruneResults) {
|
|
195188
|
+
if (pruneResult.deleted) {
|
|
195189
|
+
R2.success(`${pruneResult.name.padEnd(25)} deleted`);
|
|
195190
|
+
} else {
|
|
195191
|
+
R2.error(`${pruneResult.name.padEnd(25)} error: ${pruneResult.error}`);
|
|
195192
|
+
}
|
|
195193
|
+
}
|
|
195194
|
+
if (pruneResults.length > 0) {
|
|
195195
|
+
const pruned = pruneResults.filter((r) => r.deleted).length;
|
|
195196
|
+
R2.info(`${pruned} function${pruned !== 1 ? "s" : ""} removed`);
|
|
195197
|
+
}
|
|
195198
|
+
}
|
|
195199
|
+
function buildDeploySummary(results) {
|
|
195200
|
+
const succeeded = results.filter((r) => r.status !== "error").length;
|
|
195201
|
+
const failed = results.filter((r) => r.status === "error").length;
|
|
195202
|
+
const parts = [];
|
|
195203
|
+
if (succeeded > 0)
|
|
195204
|
+
parts.push(`${succeeded}/${results.length} succeeded`);
|
|
195205
|
+
if (failed > 0)
|
|
195206
|
+
parts.push(`${failed} error${failed !== 1 ? "s" : ""}`);
|
|
195207
|
+
return parts.join(", ") || "No functions deployed";
|
|
195208
|
+
}
|
|
195173
195209
|
async function deployFunctionsAction(names, options) {
|
|
195174
195210
|
if (options.force && names.length > 0) {
|
|
195175
195211
|
throw new InvalidInputError("--force cannot be used when specifying function names");
|
|
195176
195212
|
}
|
|
195177
195213
|
const { functions } = await readProjectConfig();
|
|
195178
|
-
|
|
195179
|
-
if (names.length > 0) {
|
|
195180
|
-
const notFound = names.filter((n2) => !functions.some((f) => f.name === n2));
|
|
195181
|
-
if (notFound.length > 0) {
|
|
195182
|
-
throw new InvalidInputError(`Function${notFound.length > 1 ? "s" : ""} not found in project: ${notFound.join(", ")}`);
|
|
195183
|
-
}
|
|
195184
|
-
toDeploy = functions.filter((f) => names.includes(f.name));
|
|
195185
|
-
} else {
|
|
195186
|
-
toDeploy = functions;
|
|
195187
|
-
}
|
|
195214
|
+
const toDeploy = resolveFunctionsToDeploy(names, functions);
|
|
195188
195215
|
if (toDeploy.length === 0) {
|
|
195189
195216
|
return {
|
|
195190
195217
|
outroMessage: "No functions found. Create functions in the 'functions' directory."
|
|
@@ -195193,41 +195220,23 @@ async function deployFunctionsAction(names, options) {
|
|
|
195193
195220
|
R2.info(`Found ${toDeploy.length} ${toDeploy.length === 1 ? "function" : "functions"} to deploy`);
|
|
195194
195221
|
let completed = 0;
|
|
195195
195222
|
const total = toDeploy.length;
|
|
195196
|
-
const results = await
|
|
195223
|
+
const results = await deployFunctionsSequentially(toDeploy, {
|
|
195197
195224
|
onStart: (startNames) => {
|
|
195198
195225
|
const label = startNames.length === 1 ? startNames[0] : `${startNames.length} functions`;
|
|
195199
|
-
R2.step(theme.styles.dim(`[${completed}/${total}] Deploying ${label}...`));
|
|
195226
|
+
R2.step(theme.styles.dim(`[${completed + 1}/${total}] Deploying ${label}...`));
|
|
195200
195227
|
},
|
|
195201
|
-
onResult: (
|
|
195228
|
+
onResult: (result) => {
|
|
195202
195229
|
completed++;
|
|
195203
|
-
formatDeployResult(
|
|
195230
|
+
formatDeployResult(result);
|
|
195204
195231
|
}
|
|
195205
195232
|
});
|
|
195206
|
-
const succeeded = results.filter((r) => r.status !== "error").length;
|
|
195207
|
-
const failed = results.filter((r) => r.status === "error").length;
|
|
195208
195233
|
if (options.force) {
|
|
195209
195234
|
R2.info("Removing remote functions not found locally...");
|
|
195210
195235
|
const allLocalNames = functions.map((f) => f.name);
|
|
195211
195236
|
const pruneResults = await pruneRemovedFunctions(allLocalNames);
|
|
195212
|
-
|
|
195213
|
-
if (pr.deleted) {
|
|
195214
|
-
R2.success(`${pr.name.padEnd(25)} deleted`);
|
|
195215
|
-
} else {
|
|
195216
|
-
R2.error(`${pr.name.padEnd(25)} error: ${pr.error}`);
|
|
195217
|
-
}
|
|
195218
|
-
}
|
|
195219
|
-
if (pruneResults.length > 0) {
|
|
195220
|
-
const pruned = pruneResults.filter((r) => r.deleted).length;
|
|
195221
|
-
R2.info(`${pruned} function${pruned !== 1 ? "s" : ""} removed`);
|
|
195222
|
-
}
|
|
195237
|
+
formatPruneResults(pruneResults);
|
|
195223
195238
|
}
|
|
195224
|
-
|
|
195225
|
-
if (succeeded > 0)
|
|
195226
|
-
parts.push(`${succeeded}/${results.length} succeeded`);
|
|
195227
|
-
if (failed > 0)
|
|
195228
|
-
parts.push(`${failed} error${failed !== 1 ? "s" : ""}`);
|
|
195229
|
-
const summary = parts.join(", ") || "No functions deployed";
|
|
195230
|
-
return { outroMessage: summary };
|
|
195239
|
+
return { outroMessage: buildDeploySummary(results) };
|
|
195231
195240
|
}
|
|
195232
195241
|
function getDeployCommand(context) {
|
|
195233
195242
|
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) => {
|
|
@@ -195486,7 +195495,7 @@ ${summaryLines.join(`
|
|
|
195486
195495
|
const result = await deployAll(projectData, {
|
|
195487
195496
|
onFunctionStart: (names) => {
|
|
195488
195497
|
const label = names.length === 1 ? names[0] : `${names.length} functions`;
|
|
195489
|
-
R2.step(theme.styles.dim(`[${functionCompleted}/${functionTotal}] Deploying ${label}...`));
|
|
195498
|
+
R2.step(theme.styles.dim(`[${functionCompleted + 1}/${functionTotal}] Deploying ${label}...`));
|
|
195490
195499
|
},
|
|
195491
195500
|
onFunctionResult: (r) => {
|
|
195492
195501
|
functionCompleted++;
|
|
@@ -200649,4 +200658,4 @@ export {
|
|
|
200649
200658
|
CLIExitError
|
|
200650
200659
|
};
|
|
200651
200660
|
|
|
200652
|
-
//# debugId=
|
|
200661
|
+
//# debugId=848A655CD4CA165764756E2164756E21
|