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

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.");
@@ -253285,29 +253284,22 @@ function resolveAppId(options) {
253285
253284
  hints: [
253286
253285
  { message: "Pass it explicitly with --app-id <id>" },
253287
253286
  {
253288
- message: "Or set BASE44_APP_ID (the Stripe Projects CLI writes it to .env via `stripe projects env --pull`)"
253287
+ message: "Or set the BASE44_APP_ID environment variable (e.g. via .env)"
253289
253288
  }
253290
253289
  ]
253291
253290
  });
253292
253291
  }
253293
253292
  return appId;
253294
253293
  }
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);
253294
+ async function initAction({ log, runTask: runTask2 }, name2, options) {
253295
+ const appId = resolveAppId(options);
253296
+ const resolvedPath = resolve6("./");
253297
+ const projectName = (name2 ?? basename4(resolvedPath)).trim();
253298
+ const template2 = await getTemplateById("backend-only");
253299
+ log.info(`Initializing project at ${resolvedPath}`);
253307
253300
  const { projectId, skippedFiles } = await runTask2("Setting up your project...", async () => {
253308
253301
  return await initProjectFiles({
253309
- name: name2,
253310
- description: description?.trim(),
253302
+ name: projectName,
253311
253303
  path: resolvedPath,
253312
253304
  template: template2,
253313
253305
  appId
@@ -253320,83 +253312,24 @@ async function executeInit({
253320
253312
  log.info(`Kept existing file${skippedFiles.length > 1 ? "s" : ""}: ${skippedFiles.join(", ")}`);
253321
253313
  }
253322
253314
  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,
253315
+ return await completeProjectSetup({
253316
+ projectId,
253317
+ name: projectName,
253318
+ resolvedPath,
253319
+ deploy: false,
253378
253320
  skills: options.skills,
253379
253321
  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);
253322
+ }, { log, runTask: runTask2 });
253390
253323
  }
253391
253324
  function getInitCommand() {
253392
253325
  return new Base44Command("init", {
253393
253326
  requireAppConfig: false,
253394
253327
  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", `
253328
+ }).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", `
253396
253329
  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);
253330
+ $ base44 init Scaffolds the current dir for $BASE44_APP_ID
253331
+ $ base44 init --app-id app_123 Scaffolds the current dir for the given app
253332
+ $ base44 init my-app --app-id app_123 Scaffolds the current dir, named "my-app"`).action(initAction);
253400
253333
  }
253401
253334
 
253402
253335
  // src/cli/commands/project/link.ts
@@ -261823,4 +261756,4 @@ export {
261823
261756
  CLIExitError
261824
261757
  };
261825
261758
 
261826
- //# debugId=B453E5669D23DDA064756E2164756E21
261759
+ //# debugId=C68C0B89C60CF11E64756E2164756E21