@base44-preview/cli 0.0.54-pr.538.7e2f1d6 → 0.0.54-pr.538.c7b934b

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 CHANGED
@@ -235165,27 +235165,28 @@ function decodeJwtClaims(token) {
235165
235165
  return null;
235166
235166
  }
235167
235167
  }
235168
- function readEnvAuth() {
235168
+ async function seedAuthFromEnv() {
235169
235169
  const accessToken = process.env.BASE44_ACCESS_TOKEN;
235170
235170
  if (!accessToken) {
235171
- return null;
235171
+ return false;
235172
235172
  }
235173
+ const refreshToken = process.env.BASE44_REFRESH_TOKEN;
235173
235174
  const claims = decodeJwtClaims(accessToken);
235174
- const sub = typeof claims?.sub === "string" ? claims.sub : "";
235175
- const exp = typeof claims?.exp === "number" ? claims.exp : null;
235176
- return {
235175
+ const sub = typeof claims?.sub === "string" ? claims.sub : undefined;
235176
+ const exp = typeof claims?.exp === "number" ? claims.exp : undefined;
235177
+ if (!refreshToken || !sub || !exp) {
235178
+ return false;
235179
+ }
235180
+ await writeAuth({
235177
235181
  accessToken,
235178
- refreshToken: process.env.BASE44_REFRESH_TOKEN ?? "",
235179
- expiresAt: exp !== null ? exp * 1000 : Number.POSITIVE_INFINITY,
235182
+ refreshToken,
235183
+ expiresAt: exp * 1000,
235180
235184
  email: sub,
235181
- name: ""
235182
- };
235185
+ name: sub
235186
+ });
235187
+ return true;
235183
235188
  }
235184
235189
  async function readAuth() {
235185
- const envAuth = readEnvAuth();
235186
- if (envAuth) {
235187
- return envAuth;
235188
- }
235189
235190
  try {
235190
235191
  const authData = await readJsonFile(getAuthFilePath());
235191
235192
  const result = AuthDataSchema.safeParse(authData);
@@ -235222,9 +235223,6 @@ function isTokenExpired(auth) {
235222
235223
  return Date.now() >= auth.expiresAt - TOKEN_REFRESH_BUFFER_MS;
235223
235224
  }
235224
235225
  async function refreshAndSaveTokens() {
235225
- if (readEnvAuth()) {
235226
- return null;
235227
- }
235228
235226
  if (refreshPromise) {
235229
235227
  return refreshPromise;
235230
235228
  }
@@ -244424,6 +244422,7 @@ async function login({
244424
244422
 
244425
244423
  // src/cli/utils/command/middleware.ts
244426
244424
  async function ensureAuth(ctx) {
244425
+ await seedAuthFromEnv();
244427
244426
  const loggedIn = await isLoggedIn();
244428
244427
  if (!loggedIn) {
244429
244428
  ctx.log.info("You need to login first to continue.");
@@ -253276,129 +253275,6 @@ function printStripeResult(r, log) {
253276
253275
  log.info(` Connectors dashboard: ${theme.colors.links(getConnectorsUrl())}`);
253277
253276
  }
253278
253277
 
253279
- // src/cli/commands/project/init.ts
253280
- import { basename as basename4, resolve as resolve6 } from "node:path";
253281
- function resolveAppId(options) {
253282
- const appId = options.appId ?? process.env.BASE44_APP_ID;
253283
- if (!appId) {
253284
- throw new InvalidInputError("No app ID found. `base44 init` scaffolds a local project for an existing Base44 app.", {
253285
- hints: [
253286
- { message: "Pass it explicitly with --app-id <id>" },
253287
- {
253288
- message: "Or set BASE44_APP_ID (the Stripe Projects CLI writes it to .env via `stripe projects env --pull`)"
253289
- }
253290
- ]
253291
- });
253292
- }
253293
- return appId;
253294
- }
253295
- async function executeInit({
253296
- template: template2,
253297
- name: rawName,
253298
- description,
253299
- appId,
253300
- projectPath,
253301
- deploy: deploy5,
253302
- skills,
253303
- isInteractive
253304
- }, { log, runTask: runTask2 }) {
253305
- const name2 = rawName.trim();
253306
- const resolvedPath = resolve6(projectPath);
253307
- const { projectId, skippedFiles } = await runTask2("Setting up your project...", async () => {
253308
- return await initProjectFiles({
253309
- name: name2,
253310
- description: description?.trim(),
253311
- path: resolvedPath,
253312
- template: template2,
253313
- appId
253314
- });
253315
- }, {
253316
- successMessage: theme.colors.base44Orange("Project created successfully"),
253317
- errorMessage: "Failed to create project"
253318
- });
253319
- if (skippedFiles.length > 0) {
253320
- log.info(`Kept existing file${skippedFiles.length > 1 ? "s" : ""}: ${skippedFiles.join(", ")}`);
253321
- }
253322
- setAppConfig({ id: projectId, projectRoot: resolvedPath });
253323
- return await completeProjectSetup({ projectId, name: name2, resolvedPath, deploy: deploy5, skills, isInteractive }, { log, runTask: runTask2 });
253324
- }
253325
- async function initInteractive(appId, options, ctx) {
253326
- const templates = await listTemplates();
253327
- const templateOptions = templates.map((t) => ({
253328
- value: t,
253329
- label: t.name,
253330
- hint: t.description
253331
- }));
253332
- const result = await Oe({
253333
- template: () => Je({
253334
- message: "Pick an option",
253335
- options: templateOptions
253336
- }),
253337
- name: () => {
253338
- return options.name ? Promise.resolve(options.name) : Ze({
253339
- message: "What is the name of your project?",
253340
- placeholder: basename4(process.cwd()),
253341
- initialValue: basename4(process.cwd()),
253342
- validate: (value) => {
253343
- if (!value || value.trim().length === 0) {
253344
- return "Every project deserves a name";
253345
- }
253346
- }
253347
- });
253348
- },
253349
- projectPath: () => Ze({
253350
- message: "Where should we set up your project?",
253351
- placeholder: "./",
253352
- initialValue: options.path ?? "./"
253353
- })
253354
- }, {
253355
- onCancel: onPromptCancel
253356
- });
253357
- return await executeInit({
253358
- template: result.template,
253359
- name: result.name,
253360
- appId,
253361
- projectPath: result.projectPath,
253362
- deploy: options.deploy,
253363
- skills: options.skills,
253364
- isInteractive: true
253365
- }, ctx);
253366
- }
253367
- async function initNonInteractive(appId, options, ctx) {
253368
- const projectPath = options.path ?? "./";
253369
- const name2 = options.name ?? basename4(resolve6(projectPath));
253370
- ctx.log.info(`Initializing project at ${resolve6(projectPath)}`);
253371
- const template2 = await getTemplateById(options.template ?? DEFAULT_TEMPLATE_ID);
253372
- return await executeInit({
253373
- template: template2,
253374
- name: name2,
253375
- appId,
253376
- projectPath,
253377
- deploy: options.deploy,
253378
- skills: options.skills,
253379
- isInteractive: false
253380
- }, ctx);
253381
- }
253382
- async function initAction({ log, runTask: runTask2, isNonInteractive }, name2, options) {
253383
- const appId = resolveAppId(options);
253384
- const opts = { ...options, name: options.name ?? name2 };
253385
- const ctx = { log, runTask: runTask2 };
253386
- if (isNonInteractive) {
253387
- return await initNonInteractive(appId, opts, ctx);
253388
- }
253389
- return await initInteractive(appId, opts, ctx);
253390
- }
253391
- function getInitCommand() {
253392
- return new Base44Command("init", {
253393
- requireAppConfig: false,
253394
- fullBanner: true
253395
- }).description("Scaffold a local project for an existing Base44 app (e.g. one provisioned by the Stripe Projects CLI)").addArgument(new Argument("name", "Project name").argOptional()).option("--app-id <id>", "Existing Base44 app ID (defaults to the BASE44_APP_ID environment variable)").option("-p, --path <path>", "Path where to set up the project (defaults to the current directory)").option("-t, --template <id>", "Template ID (e.g., backend-only, backend-and-client)").option("--deploy", "Build and deploy the site").option("--no-skills", "Skip AI agent skills installation").addHelpText("after", `
253396
- Examples:
253397
- $ base44 init Scaffolds in the current dir using $BASE44_APP_ID
253398
- $ base44 init --app-id app_123 Scaffolds in the current dir for the given app
253399
- $ base44 init my-app --app-id app_123 Scaffolds in the current dir named "my-app"`).action(initAction);
253400
- }
253401
-
253402
253278
  // src/cli/commands/project/link.ts
253403
253279
  function validateNonInteractiveFlags2(command2) {
253404
253280
  const { create: create4, name: name2, projectId } = command2.opts();
@@ -253668,6 +253544,63 @@ function getLogsCommand() {
253668
253544
  return new Base44Command("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).addOption(new Option("--level <level>", "Filter by log level").choices([...LogLevelSchema.options]).hideHelp()).option("-n, --limit <n>", "Results per page (1-1000, default: 50)").addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).action(logsAction);
253669
253545
  }
253670
253546
 
253547
+ // src/cli/commands/project/scaffold.ts
253548
+ import { basename as basename4, resolve as resolve6 } from "node:path";
253549
+ function resolveAppId(options) {
253550
+ const appId = options.appId ?? process.env.BASE44_APP_ID;
253551
+ if (!appId) {
253552
+ throw new InvalidInputError("No app ID found. `base44 scaffold` sets up a local project for an existing Base44 app.", {
253553
+ hints: [
253554
+ { message: "Pass it explicitly with --app-id <id>" },
253555
+ {
253556
+ message: "Or set the BASE44_APP_ID environment variable (e.g. via .env)"
253557
+ }
253558
+ ]
253559
+ });
253560
+ }
253561
+ return appId;
253562
+ }
253563
+ async function scaffoldAction({ log, runTask: runTask2 }, name2, options) {
253564
+ const appId = resolveAppId(options);
253565
+ const resolvedPath = resolve6("./");
253566
+ const projectName = (name2 ?? basename4(resolvedPath)).trim();
253567
+ const template2 = await getTemplateById("backend-only");
253568
+ log.info(`Scaffolding project at ${resolvedPath}`);
253569
+ const { projectId, skippedFiles } = await runTask2("Setting up your project...", async () => {
253570
+ return await initProjectFiles({
253571
+ name: projectName,
253572
+ path: resolvedPath,
253573
+ template: template2,
253574
+ appId
253575
+ });
253576
+ }, {
253577
+ successMessage: theme.colors.base44Orange("Project created successfully"),
253578
+ errorMessage: "Failed to create project"
253579
+ });
253580
+ if (skippedFiles.length > 0) {
253581
+ log.info(`Kept existing file${skippedFiles.length > 1 ? "s" : ""}: ${skippedFiles.join(", ")}`);
253582
+ }
253583
+ setAppConfig({ id: projectId, projectRoot: resolvedPath });
253584
+ return await completeProjectSetup({
253585
+ projectId,
253586
+ name: projectName,
253587
+ resolvedPath,
253588
+ deploy: false,
253589
+ skills: options.skills,
253590
+ isInteractive: false
253591
+ }, { log, runTask: runTask2 });
253592
+ }
253593
+ function getScaffoldCommand() {
253594
+ return new Base44Command("scaffold", {
253595
+ requireAppConfig: false,
253596
+ fullBanner: true
253597
+ }).description("Scaffold a local project for an existing Base44 app").addArgument(new Argument("name", "Project name").argOptional()).option("--app-id <id>", "Existing Base44 app ID (defaults to the BASE44_APP_ID environment variable)").option("--no-skills", "Skip AI agent skills installation").addHelpText("after", `
253598
+ Examples:
253599
+ $ base44 scaffold Scaffolds the current dir for $BASE44_APP_ID
253600
+ $ base44 scaffold --app-id app_123 Scaffolds the current dir for the given app
253601
+ $ base44 scaffold my-app --app-id app_123 Scaffolds the current dir, named "my-app"`).action(scaffoldAction);
253602
+ }
253603
+
253671
253604
  // src/cli/commands/secrets/delete.ts
253672
253605
  async function deleteSecretAction({ runTask: runTask2 }, key) {
253673
253606
  await runTask2(`Deleting secret "${key}"`, async () => {
@@ -257562,7 +257495,7 @@ function createProgram(context) {
257562
257495
  program2.addCommand(getWhoamiCommand());
257563
257496
  program2.addCommand(getLogoutCommand());
257564
257497
  program2.addCommand(getCreateCommand());
257565
- program2.addCommand(getInitCommand());
257498
+ program2.addCommand(getScaffoldCommand());
257566
257499
  program2.addCommand(getDashboardCommand());
257567
257500
  program2.addCommand(getDeployCommand2());
257568
257501
  program2.addCommand(getLinkCommand());
@@ -261823,4 +261756,4 @@ export {
261823
261756
  CLIExitError
261824
261757
  };
261825
261758
 
261826
- //# debugId=B453E5669D23DDA064756E2164756E21
261759
+ //# debugId=CEC26126A86D017564756E2164756E21