@rebasepro/cli 0.6.0 → 0.6.1

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.
@@ -15,5 +15,18 @@ export interface InitOptions {
15
15
  /** Command helpers for the detected PM. */
16
16
  pmCommands: PMCommands;
17
17
  }
18
+ export interface BuildQuestionsParams {
19
+ nameArg?: string;
20
+ templateArg?: TemplatePreset;
21
+ hasGitFlag: boolean;
22
+ hasInstallFlag: boolean;
23
+ pm: PackageManager;
24
+ }
25
+ /**
26
+ * Builds the interactive prompt questions for `rebase init`.
27
+ * Exported for testability — all prompt `type` values must match
28
+ * types registered by the installed version of inquirer.
29
+ */
30
+ export declare function buildInitQuestions(params: BuildQuestionsParams): Record<string, unknown>[];
18
31
  export declare function createRebaseApp(rawArgs: string[]): Promise<void>;
19
32
  export declare function configureEnvFile(targetDirectory: string, databaseUrl?: string): Promise<void>;
package/dist/index.es.js CHANGED
@@ -158,6 +158,63 @@ var PRESET_CHOICES = [
158
158
  short: "Blank"
159
159
  }
160
160
  ];
161
+ /**
162
+ * Builds the interactive prompt questions for `rebase init`.
163
+ * Exported for testability — all prompt `type` values must match
164
+ * types registered by the installed version of inquirer.
165
+ */
166
+ function buildInitQuestions(params) {
167
+ const { nameArg, templateArg, hasGitFlag, hasInstallFlag, pm } = params;
168
+ const questions = [];
169
+ if (!nameArg) questions.push({
170
+ type: "input",
171
+ name: "projectName",
172
+ message: "Project name:",
173
+ default: "my-rebase-app",
174
+ validate: (input) => {
175
+ if (!input.trim()) return "Project name is required";
176
+ 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";
177
+ return true;
178
+ }
179
+ });
180
+ if (!templateArg) questions.push({
181
+ type: "select",
182
+ name: "preset",
183
+ message: "Choose a starter template:",
184
+ choices: PRESET_CHOICES,
185
+ default: "blog"
186
+ });
187
+ if (!hasGitFlag) questions.push({
188
+ type: "confirm",
189
+ name: "git",
190
+ message: "Initialize a git repository?",
191
+ default: true
192
+ });
193
+ if (!hasInstallFlag) questions.push({
194
+ type: "confirm",
195
+ name: "installDeps",
196
+ message: `Install dependencies with ${pm}?`,
197
+ default: true
198
+ });
199
+ questions.push({
200
+ type: "input",
201
+ name: "databaseUrl",
202
+ message: "Enter your PostgreSQL database connection string (leave blank to use a local default):",
203
+ default: "",
204
+ validate: (input) => {
205
+ if (input.trim() && /[\r\n]/.test(input)) return "Database URL cannot contain newline characters.";
206
+ return true;
207
+ }
208
+ });
209
+ questions.push({
210
+ type: "confirm",
211
+ name: "introspect",
212
+ message: "Would you like to introspect this database to automatically generate collections?",
213
+ default: true,
214
+ when: (answers) => !!answers.databaseUrl?.trim()
215
+ });
216
+ return questions;
217
+ }
161
218
  async function createRebaseApp(rawArgs) {
162
219
  console.log(`
163
220
  ${chalk.bold("Rebase")} — Create a new project 🚀
@@ -205,53 +262,12 @@ async function promptForOptions(rawArgs, pm) {
205
262
  pmCommands
206
263
  };
207
264
  }
208
- const questions = [];
209
- if (!nameArg) questions.push({
210
- type: "input",
211
- name: "projectName",
212
- message: "Project name:",
213
- default: "my-rebase-app",
214
- validate: (input) => {
215
- if (!input.trim()) return "Project name is required";
216
- 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";
217
- return true;
218
- }
219
- });
220
- if (!templateArg) questions.push({
221
- type: "list",
222
- name: "preset",
223
- message: "Choose a starter template:",
224
- choices: PRESET_CHOICES,
225
- default: "blog"
226
- });
227
- if (!args["--git"]) questions.push({
228
- type: "confirm",
229
- name: "git",
230
- message: "Initialize a git repository?",
231
- default: true
232
- });
233
- if (!args["--install"]) questions.push({
234
- type: "confirm",
235
- name: "installDeps",
236
- message: `Install dependencies with ${pm}?`,
237
- default: true
238
- });
239
- questions.push({
240
- type: "input",
241
- name: "databaseUrl",
242
- message: "Enter your PostgreSQL database connection string (leave blank to use a local default):",
243
- default: "",
244
- validate: (input) => {
245
- if (input.trim() && /[\r\n]/.test(input)) return "Database URL cannot contain newline characters.";
246
- return true;
247
- }
248
- });
249
- questions.push({
250
- type: "confirm",
251
- name: "introspect",
252
- message: "Would you like to introspect this database to automatically generate collections?",
253
- default: true,
254
- when: (answers) => !!answers.databaseUrl?.trim()
265
+ const questions = buildInitQuestions({
266
+ nameArg,
267
+ templateArg,
268
+ hasGitFlag: !!args["--git"],
269
+ hasInstallFlag: !!args["--install"],
270
+ pm
255
271
  });
256
272
  const answers = await inquirer.prompt(questions);
257
273
  const targetDirectory = path.resolve(process.cwd(), nameArg || answers.projectName);
@@ -1885,6 +1901,6 @@ ${chalk.gray("Documentation: https://rebase.pro/docs")}
1885
1901
  `);
1886
1902
  }
1887
1903
  //#endregion
1888
- export { authCommand, buildCommand, configureEnvFile, createRebaseApp, dbCommand, detectPackageManager, devCommand, doctorCommand, entry, findBackendDir, findEnvFile, findFrontendDir, findProjectRoot, generateSdkCommand, getActiveBackendPlugin, getPMCommands, requireBackendDir, requireProjectRoot, resolveLocalBin, resolvePluginCliScript, resolveTsx, schemaCommand, startCommand };
1904
+ export { authCommand, buildCommand, buildInitQuestions, configureEnvFile, createRebaseApp, dbCommand, detectPackageManager, devCommand, doctorCommand, entry, findBackendDir, findEnvFile, findFrontendDir, findProjectRoot, generateSdkCommand, getActiveBackendPlugin, getPMCommands, requireBackendDir, requireProjectRoot, resolveLocalBin, resolvePluginCliScript, resolveTsx, schemaCommand, startCommand };
1889
1905
 
1890
1906
  //# sourceMappingURL=index.es.js.map