@base44-preview/cli 0.0.11-pr.82.893c777 → 0.0.11-pr.83.b92b050

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.
Files changed (2) hide show
  1. package/dist/cli/index.js +93 -8
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -25532,6 +25532,27 @@ async function createProjectFiles(options) {
25532
25532
  };
25533
25533
  }
25534
25534
 
25535
+ //#endregion
25536
+ //#region src/core/project/env.ts
25537
+ const ENV_LOCAL_TEMPLATE = `# Base44 Project Environment Variables
25538
+ # This file contains environment-specific configuration for your Base44 project.
25539
+ # Do not commit this file to version control if it contains sensitive data.
25540
+
25541
+ # Your Base44 Application ID
25542
+ BASE44_CLIENT_ID={{projectId}}
25543
+ `;
25544
+ function generateEnvLocalContent(projectId) {
25545
+ return ENV_LOCAL_TEMPLATE.replace("{{projectId}}", projectId);
25546
+ }
25547
+ async function writeEnvLocal(projectRoot, projectId) {
25548
+ const envPath = getProjectEnvPath(projectRoot);
25549
+ await writeFile$1(envPath, generateEnvLocalContent(projectId));
25550
+ return envPath;
25551
+ }
25552
+ async function envLocalExists(projectRoot) {
25553
+ return pathExists(getProjectEnvPath(projectRoot));
25554
+ }
25555
+
25535
25556
  //#endregion
25536
25557
  //#region src/core/config.ts
25537
25558
  const __dirname$1 = dirname(fileURLToPath(import.meta.url));
@@ -25547,6 +25568,9 @@ function getTemplatesDir() {
25547
25568
  function getTemplatesIndexPath() {
25548
25569
  return join(getTemplatesDir(), "templates.json");
25549
25570
  }
25571
+ function getProjectEnvPath(projectRoot) {
25572
+ return join(projectRoot, PROJECT_SUBDIR, ".env.local");
25573
+ }
25550
25574
  /**
25551
25575
  * Load .env.local from the project root if it exists.
25552
25576
  * Values won't override existing process.env variables.
@@ -25555,7 +25579,7 @@ async function loadProjectEnv(projectRoot) {
25555
25579
  const found = projectRoot ? { root: projectRoot } : await findProjectRoot();
25556
25580
  if (!found) return;
25557
25581
  (0, import_main.config)({
25558
- path: join(found.root, PROJECT_SUBDIR, ".env.local"),
25582
+ path: getProjectEnvPath(found.root),
25559
25583
  override: false,
25560
25584
  quiet: true
25561
25585
  });
@@ -31120,8 +31144,8 @@ var Unpack = class extends Parser {
31120
31144
  case "GNUDumpDir": return this[DIRECTORY](entry, done);
31121
31145
  }
31122
31146
  }
31123
- [LINK](entry, linkpath, link, done) {
31124
- fs[link](linkpath, String(entry.absolute), (er) => {
31147
+ [LINK](entry, linkpath, link$1, done) {
31148
+ fs[link$1](linkpath, String(entry.absolute), (er) => {
31125
31149
  if (er) this[ONERROR](er, entry);
31126
31150
  else {
31127
31151
  this[UNPEND]();
@@ -31268,8 +31292,8 @@ var UnpackSync = class extends Unpack {
31268
31292
  return er;
31269
31293
  }
31270
31294
  }
31271
- [LINK](entry, linkpath, link, done) {
31272
- const ls = `${link}Sync`;
31295
+ [LINK](entry, linkpath, link$1, done) {
31296
+ const ls = `${link$1}Sync`;
31273
31297
  try {
31274
31298
  fs[ls](linkpath, String(entry.absolute));
31275
31299
  done();
@@ -38213,7 +38237,7 @@ async function getDefaultTemplate() {
38213
38237
  if (!template) throw new Error(`Default template "${DEFAULT_TEMPLATE_ID}" not found`);
38214
38238
  return template;
38215
38239
  }
38216
- function validateNonInteractiveFlags(command) {
38240
+ function validateNonInteractiveFlags$1(command) {
38217
38241
  const { name: name$1, path: path$17 } = command.opts();
38218
38242
  const providedCount = [name$1, path$17].filter(Boolean).length;
38219
38243
  if (providedCount > 0 && providedCount < 2) command.error("Non-interactive mode requires all flags: --name, --path");
@@ -38338,7 +38362,7 @@ async function executeCreate({ template, name: rawName, description, projectPath
38338
38362
  if (finalAppUrl) M.message(`${theme.styles.header("Site")}: ${theme.colors.links(finalAppUrl)}`);
38339
38363
  return { outroMessage: "Your project is set up and ready to use" };
38340
38364
  }
38341
- const createCommand = new Command("create").description("Create a new Base44 project").option("-n, --name <name>", "Project name").option("-d, --description <description>", "Project description").option("-p, --path <path>", "Path where to create the project").option("--deploy", "Build and deploy the site").hook("preAction", validateNonInteractiveFlags).action(async (options) => {
38365
+ const createCommand = new Command("create").description("Create a new Base44 project").option("-n, --name <name>", "Project name").option("-d, --description <description>", "Project description").option("-p, --path <path>", "Path where to create the project").option("--deploy", "Build and deploy the site").hook("preAction", validateNonInteractiveFlags$1).action(async (options) => {
38342
38366
  await chooseCreate(options);
38343
38367
  });
38344
38368
 
@@ -38892,7 +38916,66 @@ async function openDashboard() {
38892
38916
  return { outroMessage: `Dashboard opened at ${dashboardUrl}` };
38893
38917
  }
38894
38918
  const dashboardCommand = new Command("dashboard").description("Open the app dashboard in your browser").action(async () => {
38895
- await runCommand(openDashboard);
38919
+ await runCommand(openDashboard, { requireAuth: true });
38920
+ });
38921
+
38922
+ //#endregion
38923
+ //#region src/cli/commands/project/link.ts
38924
+ function validateNonInteractiveFlags(command) {
38925
+ const { create: create$1, name: name$1 } = command.opts();
38926
+ if (create$1 && !name$1) command.error("--name is required when using --create");
38927
+ }
38928
+ async function promptForProjectDetails() {
38929
+ const actionOptions = [{
38930
+ value: "create",
38931
+ label: "Create a new project",
38932
+ hint: "Create a new Base44 project and link it"
38933
+ }];
38934
+ const result = await Ce({
38935
+ action: () => ve({
38936
+ message: "How would you like to link this project?",
38937
+ options: actionOptions
38938
+ }),
38939
+ name: () => {
38940
+ return he({
38941
+ message: "What is the name of your project?",
38942
+ placeholder: "my-app",
38943
+ validate: (value) => {
38944
+ if (!value || value.trim().length === 0) return "Project name is required";
38945
+ }
38946
+ });
38947
+ },
38948
+ description: () => he({
38949
+ message: "Description (optional)",
38950
+ placeholder: "A brief description of your project"
38951
+ })
38952
+ }, { onCancel: onPromptCancel });
38953
+ return {
38954
+ name: result.name.trim(),
38955
+ description: result.description ? result.description.trim() : void 0
38956
+ };
38957
+ }
38958
+ async function link(options) {
38959
+ const projectRoot = await findProjectRoot();
38960
+ if (!projectRoot) throw new Error("No Base44 project found. Run this command from a project directory with a config.jsonc file.");
38961
+ if (await envLocalExists(projectRoot.root)) throw new Error("Project is already linked. A .env.local file with BASE44_CLIENT_ID already exists.");
38962
+ const { name: name$1, description } = options.create ? {
38963
+ name: options.name.trim(),
38964
+ description: options.description?.trim()
38965
+ } : await promptForProjectDetails();
38966
+ const { projectId } = await runTask("Creating project on Base44...", async () => {
38967
+ return await createProject(name$1, description);
38968
+ }, {
38969
+ successMessage: "Project created successfully",
38970
+ errorMessage: "Failed to create project"
38971
+ });
38972
+ await writeEnvLocal(projectRoot.root, projectId);
38973
+ const dashboardUrl = `${getBase44ApiUrl()}/apps/${projectId}/editor/workspace/overview`;
38974
+ M.message(`${theme.styles.header("Dashboard")}: ${theme.colors.links(dashboardUrl)}`);
38975
+ return { outroMessage: "Project linked" };
38976
+ }
38977
+ const linkCommand = new Command("link").description("Link a local project to a Base44 project").option("-c, --create", "Create a new project (skip selection prompt)").option("-n, --name <name>", "Project name (required when --create is used)").option("-d, --description <description>", "Project description").hook("preAction", validateNonInteractiveFlags).action(async (options) => {
38978
+ await runCommand(() => link(options), { requireAuth: true });
38896
38979
  });
38897
38980
 
38898
38981
  //#endregion
@@ -38924,11 +39007,13 @@ var version = "0.0.11";
38924
39007
  //#region src/cli/index.ts
38925
39008
  const program = new Command();
38926
39009
  program.name("base44").description("Base44 CLI - Unified interface for managing Base44 applications").version(version);
39010
+ program.configureHelp({ sortSubcommands: true });
38927
39011
  program.addCommand(loginCommand);
38928
39012
  program.addCommand(whoamiCommand);
38929
39013
  program.addCommand(logoutCommand);
38930
39014
  program.addCommand(createCommand);
38931
39015
  program.addCommand(dashboardCommand);
39016
+ program.addCommand(linkCommand);
38932
39017
  program.addCommand(entitiesPushCommand);
38933
39018
  program.addCommand(functionsDeployCommand);
38934
39019
  program.addCommand(siteDeployCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/cli",
3
- "version": "0.0.11-pr.82.893c777",
3
+ "version": "0.0.11-pr.83.b92b050",
4
4
  "description": "Base44 CLI - Unified interface for managing Base44 applications",
5
5
  "type": "module",
6
6
  "main": "./dist/cli/index.js",