base44 0.0.5 → 0.0.7
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 +48 -43
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -26282,30 +26282,48 @@ async function printBanner() {
|
|
|
26282
26282
|
//#region src/cli/utils/runCommand.ts
|
|
26283
26283
|
const base44Color = source_default.bgHex("#E86B3C");
|
|
26284
26284
|
/**
|
|
26285
|
-
* Wraps a command function with the Base44 intro
|
|
26285
|
+
* Wraps a command function with the Base44 intro/outro and error handling.
|
|
26286
26286
|
* All CLI commands should use this utility to ensure consistent branding.
|
|
26287
|
-
* Also loads .env.local from the project root if available.
|
|
26288
26287
|
*
|
|
26289
|
-
*
|
|
26288
|
+
* **Responsibilities**:
|
|
26289
|
+
* - Displays the intro (simple tag or full ASCII banner)
|
|
26290
|
+
* - Loads `.env.local` from the project root if available
|
|
26291
|
+
* - Checks authentication if `requireAuth` is set
|
|
26292
|
+
* - Runs the command function
|
|
26293
|
+
* - Displays the outro message returned by the command
|
|
26294
|
+
* - Handles errors and exits with code 1 on failure
|
|
26295
|
+
*
|
|
26296
|
+
* **Important**: Commands should NOT call `intro()` or `outro()` directly.
|
|
26297
|
+
* This function handles both. Commands can return an optional `outroMessage`
|
|
26298
|
+
* which will be displayed at the end.
|
|
26299
|
+
*
|
|
26300
|
+
* @param commandFn - The async function to execute. Returns `RunCommandResult` with optional `outroMessage`.
|
|
26290
26301
|
* @param options - Optional configuration for the command wrapper
|
|
26291
26302
|
*
|
|
26292
26303
|
* @example
|
|
26293
|
-
* // Standard command with
|
|
26304
|
+
* // Standard command with outro message
|
|
26305
|
+
* async function myAction(): Promise<RunCommandResult> {
|
|
26306
|
+
* // ... do work ...
|
|
26307
|
+
* return { outroMessage: "Done!" };
|
|
26308
|
+
* }
|
|
26309
|
+
*
|
|
26294
26310
|
* export const myCommand = new Command("my-command")
|
|
26295
26311
|
* .action(async () => {
|
|
26296
26312
|
* await runCommand(myAction);
|
|
26297
26313
|
* });
|
|
26298
26314
|
*
|
|
26299
26315
|
* @example
|
|
26300
|
-
* // Command requiring authentication
|
|
26316
|
+
* // Command requiring authentication with full banner
|
|
26301
26317
|
* export const myCommand = new Command("my-command")
|
|
26302
26318
|
* .action(async () => {
|
|
26303
|
-
* await runCommand(myAction, { requireAuth: true });
|
|
26319
|
+
* await runCommand(myAction, { requireAuth: true, fullBanner: true });
|
|
26304
26320
|
* });
|
|
26305
26321
|
*/
|
|
26306
26322
|
async function runCommand(commandFn, options) {
|
|
26307
|
-
if (options?.fullBanner)
|
|
26308
|
-
|
|
26323
|
+
if (options?.fullBanner) {
|
|
26324
|
+
await printBanner();
|
|
26325
|
+
Ie("");
|
|
26326
|
+
} else Ie(base44Color(" Base 44 "));
|
|
26309
26327
|
await loadProjectEnv();
|
|
26310
26328
|
try {
|
|
26311
26329
|
if (options?.requireAuth) {
|
|
@@ -26314,7 +26332,8 @@ async function runCommand(commandFn, options) {
|
|
|
26314
26332
|
await login();
|
|
26315
26333
|
}
|
|
26316
26334
|
}
|
|
26317
|
-
await commandFn();
|
|
26335
|
+
const { outroMessage } = await commandFn();
|
|
26336
|
+
Se(outroMessage || "");
|
|
26318
26337
|
} catch (e$1) {
|
|
26319
26338
|
if (e$1 instanceof Error) M.error(e$1.stack ?? e$1.message);
|
|
26320
26339
|
else M.error(String(e$1));
|
|
@@ -26440,7 +26459,7 @@ async function login() {
|
|
|
26440
26459
|
const token = await waitForAuthentication(deviceCodeResponse.deviceCode, deviceCodeResponse.expiresIn, deviceCodeResponse.interval);
|
|
26441
26460
|
const userInfo = await getUserInfo(token.accessToken);
|
|
26442
26461
|
await saveAuthData(token, userInfo);
|
|
26443
|
-
|
|
26462
|
+
return { outroMessage: `Successfully logged in as ${source_default.bold(userInfo.email)}` };
|
|
26444
26463
|
}
|
|
26445
26464
|
const loginCommand = new Command("login").description("Authenticate with Base44").action(async () => {
|
|
26446
26465
|
await runCommand(login);
|
|
@@ -26450,7 +26469,7 @@ const loginCommand = new Command("login").description("Authenticate with Base44"
|
|
|
26450
26469
|
//#region src/cli/commands/auth/whoami.ts
|
|
26451
26470
|
async function whoami() {
|
|
26452
26471
|
const auth = await readAuth();
|
|
26453
|
-
|
|
26472
|
+
return { outroMessage: `Logged in as: ${source_default.bold(auth.email)}` };
|
|
26454
26473
|
}
|
|
26455
26474
|
const whoamiCommand = new Command("whoami").description("Display current authenticated user").action(async () => {
|
|
26456
26475
|
await runCommand(whoami, { requireAuth: true });
|
|
@@ -26460,10 +26479,10 @@ const whoamiCommand = new Command("whoami").description("Display current authent
|
|
|
26460
26479
|
//#region src/cli/commands/auth/logout.ts
|
|
26461
26480
|
async function logout() {
|
|
26462
26481
|
await deleteAuth();
|
|
26463
|
-
|
|
26482
|
+
return { outroMessage: "Logged out successfully" };
|
|
26464
26483
|
}
|
|
26465
26484
|
const logoutCommand = new Command("logout").description("Logout from current device").action(async () => {
|
|
26466
|
-
await runCommand(logout
|
|
26485
|
+
await runCommand(logout);
|
|
26467
26486
|
});
|
|
26468
26487
|
|
|
26469
26488
|
//#endregion
|
|
@@ -26471,14 +26490,7 @@ const logoutCommand = new Command("logout").description("Logout from current dev
|
|
|
26471
26490
|
/**
|
|
26472
26491
|
* Response from the deploy API endpoint.
|
|
26473
26492
|
*/
|
|
26474
|
-
const DeployResponseSchema = object({
|
|
26475
|
-
success: boolean(),
|
|
26476
|
-
app_id: string(),
|
|
26477
|
-
files_count: number(),
|
|
26478
|
-
total_size_bytes: number(),
|
|
26479
|
-
deployed_at: string(),
|
|
26480
|
-
app_url: string().url()
|
|
26481
|
-
});
|
|
26493
|
+
const DeployResponseSchema = object({ app_url: url() }).transform((data) => ({ appUrl: data.app_url }));
|
|
26482
26494
|
|
|
26483
26495
|
//#endregion
|
|
26484
26496
|
//#region src/core/site/config.ts
|
|
@@ -31454,10 +31466,7 @@ async function createArchive(pathToArchive, targetArchivePath) {
|
|
|
31454
31466
|
//#region src/cli/commands/entities/push.ts
|
|
31455
31467
|
async function pushEntitiesAction() {
|
|
31456
31468
|
const { entities } = await readProjectConfig();
|
|
31457
|
-
if (entities.length === 0) {
|
|
31458
|
-
M.warn("No entities found in project");
|
|
31459
|
-
return;
|
|
31460
|
-
}
|
|
31469
|
+
if (entities.length === 0) return { outroMessage: "No entities found in project" };
|
|
31461
31470
|
M.info(`Found ${entities.length} entities to push`);
|
|
31462
31471
|
const result = await runTask("Pushing entities to Base44", async () => {
|
|
31463
31472
|
return await pushEntities(entities);
|
|
@@ -31468,7 +31477,7 @@ async function pushEntitiesAction() {
|
|
|
31468
31477
|
if (result.created.length > 0) M.success(`Created: ${result.created.join(", ")}`);
|
|
31469
31478
|
if (result.updated.length > 0) M.success(`Updated: ${result.updated.join(", ")}`);
|
|
31470
31479
|
if (result.deleted.length > 0) M.warn(`Deleted: ${result.deleted.join(", ")}`);
|
|
31471
|
-
|
|
31480
|
+
return {};
|
|
31472
31481
|
}
|
|
31473
31482
|
const entitiesPushCommand = new Command("entities").description("Manage project entities").addCommand(new Command("push").description("Push local entities to Base44").action(async () => {
|
|
31474
31483
|
await runCommand(pushEntitiesAction, { requireAuth: true });
|
|
@@ -38145,7 +38154,6 @@ var import_lodash = /* @__PURE__ */ __toESM(require_lodash(), 1);
|
|
|
38145
38154
|
const orange = source_default.hex("#E86B3C");
|
|
38146
38155
|
const cyan = source_default.hex("#00D4FF");
|
|
38147
38156
|
async function create() {
|
|
38148
|
-
Ie("Let's create something amazing!");
|
|
38149
38157
|
const templateOptions = (await listTemplates()).map((t) => ({
|
|
38150
38158
|
value: t,
|
|
38151
38159
|
label: t.name,
|
|
@@ -38188,9 +38196,9 @@ async function create() {
|
|
|
38188
38196
|
successMessage: orange("Project created successfully"),
|
|
38189
38197
|
errorMessage: "Failed to create project"
|
|
38190
38198
|
});
|
|
38191
|
-
await loadProjectEnv();
|
|
38199
|
+
await loadProjectEnv(resolvedPath);
|
|
38192
38200
|
const { project, entities } = await readProjectConfig(resolvedPath);
|
|
38193
|
-
let
|
|
38201
|
+
let finalAppUrl;
|
|
38194
38202
|
if (entities.length > 0) {
|
|
38195
38203
|
const shouldPushEntities = await ye({ message: "Would you like to push entities now?" });
|
|
38196
38204
|
if (!pD(shouldPushEntities) && shouldPushEntities) await runTask(`Pushing ${entities.length} entities to Base44...`, async () => {
|
|
@@ -38203,9 +38211,10 @@ async function create() {
|
|
|
38203
38211
|
if (project.site) {
|
|
38204
38212
|
const installCommand = project.site.installCommand;
|
|
38205
38213
|
const buildCommand = project.site.buildCommand;
|
|
38214
|
+
const outputDirectory = project.site.outputDirectory;
|
|
38206
38215
|
const shouldDeploy = await ye({ message: "Would you like to deploy the site now?" });
|
|
38207
|
-
if (!pD(shouldDeploy) && shouldDeploy && installCommand && buildCommand) {
|
|
38208
|
-
const {
|
|
38216
|
+
if (!pD(shouldDeploy) && shouldDeploy && installCommand && buildCommand && outputDirectory) {
|
|
38217
|
+
const { appUrl } = await runTask("Installing dependencies...", async (updateMessage) => {
|
|
38209
38218
|
await execa({
|
|
38210
38219
|
cwd: resolvedPath,
|
|
38211
38220
|
shell: true
|
|
@@ -38216,19 +38225,19 @@ async function create() {
|
|
|
38216
38225
|
shell: true
|
|
38217
38226
|
})`${buildCommand}`;
|
|
38218
38227
|
updateMessage("Deploying site...");
|
|
38219
|
-
return await deploySite(join(resolvedPath,
|
|
38228
|
+
return await deploySite(join(resolvedPath, outputDirectory));
|
|
38220
38229
|
}, {
|
|
38221
38230
|
successMessage: orange("Site deployed successfully"),
|
|
38222
38231
|
errorMessage: "Failed to deploy site"
|
|
38223
38232
|
});
|
|
38224
|
-
|
|
38233
|
+
finalAppUrl = appUrl;
|
|
38225
38234
|
}
|
|
38226
38235
|
}
|
|
38227
38236
|
const dashboardUrl = `${getBase44ApiUrl()}/apps/${projectId}/editor/preview`;
|
|
38228
38237
|
M.message(`${source_default.dim("Project")}: ${orange(name$1.trim())}`);
|
|
38229
38238
|
M.message(`${source_default.dim("Dashboard")}: ${cyan(dashboardUrl)}`);
|
|
38230
|
-
if (
|
|
38231
|
-
|
|
38239
|
+
if (finalAppUrl) M.message(`${source_default.dim("Site")}: ${cyan(finalAppUrl)}`);
|
|
38240
|
+
return { outroMessage: "Your project is set and ready to use" };
|
|
38232
38241
|
}
|
|
38233
38242
|
const createCommand = new Command("create").description("Create a new Base44 project").action(async () => {
|
|
38234
38243
|
await runCommand(create, {
|
|
@@ -38244,17 +38253,13 @@ async function deployAction() {
|
|
|
38244
38253
|
if (!project.site?.outputDirectory) throw new Error("No site configuration found. Please add 'site.outputDirectory' to your config.jsonc");
|
|
38245
38254
|
const outputDir = resolve(project.root, project.site.outputDirectory);
|
|
38246
38255
|
const shouldDeploy = await ye({ message: `Deploy site from ${project.site.outputDirectory}?` });
|
|
38247
|
-
if (pD(shouldDeploy) || !shouldDeploy) {
|
|
38248
|
-
|
|
38249
|
-
return;
|
|
38250
|
-
}
|
|
38251
|
-
const result = await runTask("Creating archive and deploying site...", async () => {
|
|
38256
|
+
if (pD(shouldDeploy) || !shouldDeploy) return { outroMessage: "Deployment cancelled" };
|
|
38257
|
+
return { outroMessage: `Visit your site at: ${(await runTask("Creating archive and deploying site...", async () => {
|
|
38252
38258
|
return await deploySite(outputDir);
|
|
38253
38259
|
}, {
|
|
38254
38260
|
successMessage: "Site deployed successfully",
|
|
38255
38261
|
errorMessage: "Deployment failed"
|
|
38256
|
-
});
|
|
38257
|
-
M.success(`Site deployed to: ${result.app_url}`);
|
|
38262
|
+
})).appUrl}` };
|
|
38258
38263
|
}
|
|
38259
38264
|
const siteDeployCommand = new Command("site").description("Manage site deployments").addCommand(new Command("deploy").description("Deploy built site files to Base44 hosting").action(async () => {
|
|
38260
38265
|
await runCommand(deployAction, { requireAuth: true });
|
|
@@ -38262,7 +38267,7 @@ const siteDeployCommand = new Command("site").description("Manage site deploymen
|
|
|
38262
38267
|
|
|
38263
38268
|
//#endregion
|
|
38264
38269
|
//#region package.json
|
|
38265
|
-
var version = "0.0.
|
|
38270
|
+
var version = "0.0.7";
|
|
38266
38271
|
|
|
38267
38272
|
//#endregion
|
|
38268
38273
|
//#region src/cli/index.ts
|