@rebasepro/cli 0.9.1-canary.a57c262 → 0.9.1-canary.ad25bc0

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.
@@ -1,6 +1,4 @@
1
1
  import type { PackageManager, PMCommands } from "../utils/package-manager";
2
- /** Returns an error message, or null when the name is a valid package name. */
3
- export declare function validateProjectName(name: string): string | null;
4
2
  export type TemplatePreset = "blog" | "ecommerce" | "blank";
5
3
  /**
6
4
  * How much of Rebase to scaffold.
package/dist/index.es.js CHANGED
@@ -144,13 +144,6 @@ function findParentDir(currentDir, targetName) {
144
144
  return null;
145
145
  }
146
146
  var cliRoot = findParentDir(__dirname$1, "cli");
147
- var PROJECT_NAME_RE = /^[a-z0-9][a-z0-9._-]*$/;
148
- /** Returns an error message, or null when the name is a valid package name. */
149
- function validateProjectName(name) {
150
- if (!name.trim()) return "Project name is required";
151
- if (!PROJECT_NAME_RE.test(name)) return "Project name must start with a lowercase letter or number and contain only lowercase letters, numbers, hyphens, dots, or underscores";
152
- return null;
153
- }
154
147
  var FLAVOR_CHOICES = [{
155
148
  name: "BaaS + admin — API plus an admin UI, driven by collections you define (like Payload/Directus)",
156
149
  value: "cms",
@@ -190,7 +183,11 @@ function buildInitQuestions(params) {
190
183
  name: "projectName",
191
184
  message: "Project name:",
192
185
  default: "my-rebase-app",
193
- validate: (input) => validateProjectName(input) ?? true
186
+ validate: (input) => {
187
+ if (!input.trim()) return "Project name is required";
188
+ if (!/^[a-z0-9][a-z0-9._-]*$/.test(input)) return "Project name must start with a lowercase letter or number and contain only lowercase letters, numbers, hyphens, dots, or underscores";
189
+ return true;
190
+ }
194
191
  });
195
192
  if (!flavorArg) questions.push({
196
193
  type: "select",
@@ -264,14 +261,6 @@ async function promptForOptions(rawArgs, pm) {
264
261
  });
265
262
  const nameArg = args._[0];
266
263
  const isNonInteractive = args["--yes"] || false;
267
- if (nameArg) {
268
- const resolvedName = path.basename(path.resolve(process.cwd(), nameArg));
269
- const nameError = validateProjectName(resolvedName);
270
- if (nameError) {
271
- console.error(chalk.red(`Invalid project name "${resolvedName}": ${nameError}`));
272
- process.exit(1);
273
- }
274
- }
275
264
  const templateArg = args["--template"];
276
265
  if (templateArg && !PRESET_CHOICES.some((p) => p.value === templateArg)) {
277
266
  console.error(chalk.red(`Unknown template "${templateArg}". Available: ${PRESET_CHOICES.map((p) => p.value).join(", ")}`));
@@ -354,14 +343,7 @@ async function createProject$1(options) {
354
343
  console.error(`${chalk.red.bold("ERROR")} Failed to copy template files: ${err instanceof Error ? err.message : String(err)}`);
355
344
  process.exit(1);
356
345
  }
357
- for (const [from, to] of [["gitignore", ".gitignore"], ["npmrc", ".npmrc"]]) {
358
- const shipped = path.join(options.targetDirectory, from);
359
- if (fs.existsSync(shipped)) fs.renameSync(shipped, path.join(options.targetDirectory, to));
360
- }
361
- if (options.flavor !== "baas") {
362
- if (options.introspect && options.preset !== "blank") console.log(chalk.gray(" Using the blank template: collections will come from your database."));
363
- await applyPreset(options.targetDirectory, options.introspect ? "blank" : options.preset);
364
- }
346
+ if (options.flavor !== "baas") await applyPreset(options.targetDirectory, options.preset);
365
347
  await applyFlavor(options.targetDirectory, options.flavor);
366
348
  await replacePlaceholders(options);
367
349
  await configureEnvFile(options.targetDirectory, options.databaseUrl);
@@ -380,12 +362,6 @@ async function createProject$1(options) {
380
362
  "introspect",
381
363
  "--force"
382
364
  ]);
383
- const generateCmd = pmCommands.exec("rebase", [
384
- "schema",
385
- "generate",
386
- "--collections",
387
- "../config/collections"
388
- ]);
389
365
  if (options.installDeps) {
390
366
  console.log("");
391
367
  console.log(chalk.gray(` Installing dependencies with ${pm}...`));
@@ -409,14 +385,10 @@ async function createProject$1(options) {
409
385
  cwd: options.targetDirectory,
410
386
  stdio: "inherit"
411
387
  });
412
- await execa(generateCmd[0], generateCmd.slice(1), {
413
- cwd: options.targetDirectory,
414
- stdio: "inherit"
415
- });
416
388
  console.log(chalk.green(" Database successfully introspected!"));
417
389
  } catch {
418
390
  console.warn(chalk.yellow(" Warning: Failed to introspect database automatically."));
419
- console.warn(chalk.yellow(` You can run \`${execCmd.join(" ")}\` then \`${generateCmd.join(" ")}\` manually after setup.`));
391
+ console.warn(chalk.yellow(` You can run \`${execCmd.join(" ")}\` manually after setup.`));
420
392
  }
421
393
  } else {
422
394
  console.warn(chalk.yellow(" Skipping introspection because dependencies were not installed."));
@@ -663,7 +635,7 @@ async function configureEnvFile(targetDirectory, databaseUrl) {
663
635
  envContent = envContent.replace(/^DATABASE_URL=.*$/m, `DATABASE_URL=${databaseUrl}`);
664
636
  } else {
665
637
  const dbPort = await findAvailablePort(5432);
666
- envContent = envContent.replace(/^DATABASE_URL=.*$/m, `DATABASE_URL=postgresql://rebase:${dbPassword}@localhost:${dbPort}/rebase?options=-c%20search_path=public&sslmode=disable\nDATABASE_PASSWORD=${dbPassword}`);
638
+ envContent = envContent.replace(/^DATABASE_URL=.*$/m, `DATABASE_URL=postgresql://rebase:${dbPassword}@localhost:${dbPort}/rebase?options=-c%20search_path=public\nDATABASE_PASSWORD=${dbPassword}`);
667
639
  const dockerComposePath = path.join(targetDirectory, "docker-compose.yml");
668
640
  if (fs.existsSync(dockerComposePath)) {
669
641
  let dockerComposeContent = fs.readFileSync(dockerComposePath, "utf-8");
@@ -866,14 +838,13 @@ function getActiveBackendPlugin(backendDir) {
866
838
  * Resolve the active plugin's CLI script.
867
839
  */
868
840
  function resolvePluginCliScript(backendDir, pluginName) {
869
- const candidates = [];
870
- let dir = path.resolve(backendDir);
871
- const fsRoot = path.parse(dir).root;
872
- while (dir !== fsRoot) {
873
- candidates.push(path.join(dir, "node_modules", pluginName, "src", "cli.ts"), path.join(dir, "node_modules", pluginName, "dist", "cli.js"));
874
- dir = path.dirname(dir);
875
- }
876
- candidates.push(path.resolve(backendDir, "..", "..", "..", "packages", pluginName.replace("@rebasepro/", ""), "src", "cli.ts"), path.resolve(backendDir, "..", "..", "packages", pluginName.replace("@rebasepro/", ""), "src", "cli.ts"), path.resolve(backendDir, "..", "packages", pluginName.replace("@rebasepro/", ""), "src", "cli.ts"));
841
+ const candidates = [
842
+ path.join(backendDir, "node_modules", pluginName, "src", "cli.ts"),
843
+ path.join(backendDir, "node_modules", pluginName, "dist", "cli.js"),
844
+ path.resolve(backendDir, "..", "..", "..", "packages", pluginName.replace("@rebasepro/", ""), "src", "cli.ts"),
845
+ path.resolve(backendDir, "..", "..", "packages", pluginName.replace("@rebasepro/", ""), "src", "cli.ts"),
846
+ path.resolve(backendDir, "..", "packages", pluginName.replace("@rebasepro/", ""), "src", "cli.ts")
847
+ ];
877
848
  for (const candidate of candidates) if (fs.existsSync(candidate)) return candidate;
878
849
  return null;
879
850
  }
@@ -4022,6 +3993,6 @@ ${chalk.gray("Documentation: https://rebase.pro/docs")}
4022
3993
  `);
4023
3994
  }
4024
3995
  //#endregion
4025
- export { authCommand, buildCommand, buildInitQuestions, cloudCommand, configureEnvFile, createRebaseApp, dbCommand, detectPackageManager, devCommand, doctorCommand, entry, findBackendDir, findEnvFile, findFrontendDir, findProjectRoot, generateSdkCommand, getActiveBackendPlugin, getPMCommands, requireBackendDir, requireProjectRoot, resolveLocalBin, resolvePluginCliScript, resolveTsx, schemaCommand, startCommand, validateProjectName, validateTsxInstallation };
3996
+ export { authCommand, buildCommand, buildInitQuestions, cloudCommand, configureEnvFile, createRebaseApp, dbCommand, detectPackageManager, devCommand, doctorCommand, entry, findBackendDir, findEnvFile, findFrontendDir, findProjectRoot, generateSdkCommand, getActiveBackendPlugin, getPMCommands, requireBackendDir, requireProjectRoot, resolveLocalBin, resolvePluginCliScript, resolveTsx, schemaCommand, startCommand, validateTsxInstallation };
4026
3997
 
4027
3998
  //# sourceMappingURL=index.es.js.map