create-nextly-app 0.0.2-alpha.2 → 0.0.2-alpha.20

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.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
- import { __commonJS, __require, __toESM, init, capture, createNextly, shutdown } from './chunk-AYJ2RKVJ.mjs';
4
- import path from 'path';
3
+ import { __commonJS, __require, __toESM, init, resolveProjectArg, validateProjectName, capture, createNextly, shutdown } from './chunk-6HFD2Q2U.mjs';
5
4
 
6
5
  createRequire(import.meta.url);
7
6
 
@@ -1168,7 +1167,7 @@ var require_command = __commonJS({
1168
1167
  "../../node_modules/.pnpm/commander@14.0.2/node_modules/commander/lib/command.js"(exports$1) {
1169
1168
  var EventEmitter = __require("events").EventEmitter;
1170
1169
  var childProcess = __require("child_process");
1171
- var path2 = __require("path");
1170
+ var path = __require("path");
1172
1171
  var fs = __require("fs");
1173
1172
  var process2 = __require("process");
1174
1173
  var { Argument: Argument2, humanReadableArgName } = require_argument();
@@ -2180,9 +2179,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2180
2179
  let launchWithNode = false;
2181
2180
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2182
2181
  function findFile(baseDir, baseName) {
2183
- const localBin = path2.resolve(baseDir, baseName);
2182
+ const localBin = path.resolve(baseDir, baseName);
2184
2183
  if (fs.existsSync(localBin)) return localBin;
2185
- if (sourceExt.includes(path2.extname(baseName))) return void 0;
2184
+ if (sourceExt.includes(path.extname(baseName))) return void 0;
2186
2185
  const foundExt = sourceExt.find(
2187
2186
  (ext) => fs.existsSync(`${localBin}${ext}`)
2188
2187
  );
@@ -2200,17 +2199,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
2200
2199
  } catch {
2201
2200
  resolvedScriptPath = this._scriptPath;
2202
2201
  }
2203
- executableDir = path2.resolve(
2204
- path2.dirname(resolvedScriptPath),
2202
+ executableDir = path.resolve(
2203
+ path.dirname(resolvedScriptPath),
2205
2204
  executableDir
2206
2205
  );
2207
2206
  }
2208
2207
  if (executableDir) {
2209
2208
  let localFile = findFile(executableDir, executableFile);
2210
2209
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2211
- const legacyName = path2.basename(
2210
+ const legacyName = path.basename(
2212
2211
  this._scriptPath,
2213
- path2.extname(this._scriptPath)
2212
+ path.extname(this._scriptPath)
2214
2213
  );
2215
2214
  if (legacyName !== this._name) {
2216
2215
  localFile = findFile(
@@ -2221,7 +2220,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2221
2220
  }
2222
2221
  executableFile = localFile || executableFile;
2223
2222
  }
2224
- launchWithNode = sourceExt.includes(path2.extname(executableFile));
2223
+ launchWithNode = sourceExt.includes(path.extname(executableFile));
2225
2224
  let proc;
2226
2225
  if (process2.platform !== "win32") {
2227
2226
  if (launchWithNode) {
@@ -3136,7 +3135,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3136
3135
  * @return {Command}
3137
3136
  */
3138
3137
  nameFromFilename(filename) {
3139
- this._name = path2.basename(filename, path2.extname(filename));
3138
+ this._name = path.basename(filename, path.extname(filename));
3140
3139
  return this;
3141
3140
  }
3142
3141
  /**
@@ -3150,9 +3149,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3150
3149
  * @param {string} [path]
3151
3150
  * @return {(string|null|Command)}
3152
3151
  */
3153
- executableDir(path3) {
3154
- if (path3 === void 0) return this._executableDir;
3155
- this._executableDir = path3;
3152
+ executableDir(path2) {
3153
+ if (path2 === void 0) return this._executableDir;
3154
+ this._executableDir = path2;
3156
3155
  return this;
3157
3156
  }
3158
3157
  /**
@@ -3435,7 +3434,7 @@ var require_package = __commonJS({
3435
3434
  "package.json"(exports$1, module) {
3436
3435
  module.exports = {
3437
3436
  name: "create-nextly-app",
3438
- version: "0.0.2-alpha.2",
3437
+ version: "0.0.2-alpha.20",
3439
3438
  description: "CLI to scaffold Nextly in your Next.js project",
3440
3439
  license: "MIT",
3441
3440
  type: "module",
@@ -3538,15 +3537,6 @@ var {
3538
3537
  Option,
3539
3538
  Help
3540
3539
  } = import_index.default;
3541
- function resolveProjectArg(directory) {
3542
- if (!directory || directory === "") {
3543
- return { projectName: void 0, installInCwd: false };
3544
- }
3545
- if (directory === ".") {
3546
- return { projectName: void 0, installInCwd: true };
3547
- }
3548
- return { projectName: path.basename(directory), installInCwd: false };
3549
- }
3550
3540
 
3551
3541
  // src/cli.ts
3552
3542
  var pkg = require_package();
@@ -3555,8 +3545,7 @@ program2.name("create-nextly-app").description(
3555
3545
  "Scaffold a new Nextly CMS project or add Nextly to an existing Next.js app"
3556
3546
  ).version("0.1.0").argument(
3557
3547
  "[directory]",
3558
- "Project name or '.' to install in the current directory",
3559
- "."
3548
+ "Project name or '.' to install in the current directory (omit to be prompted)"
3560
3549
  ).option(
3561
3550
  "-y, --yes",
3562
3551
  "Skip prompts and use defaults (blank template, SQLite, local storage)"
@@ -3573,11 +3562,12 @@ program2.name("create-nextly-app").description(
3573
3562
  "after",
3574
3563
  `
3575
3564
  Examples:
3565
+ $ npx create-nextly-app@alpha (prompts for folder name)
3576
3566
  $ npx create-nextly-app@alpha my-project
3577
3567
  $ npx create-nextly-app@alpha my-project -y
3578
3568
  $ npx create-nextly-app@alpha my-blog -t blog -a code-first
3579
3569
  $ npx create-nextly-app@alpha my-project --database postgresql
3580
- $ npx create-nextly-app@alpha .
3570
+ $ npx create-nextly-app@alpha . (install in the current directory)
3581
3571
  `
3582
3572
  ).action(
3583
3573
  async (directory, options) => {
@@ -3588,6 +3578,13 @@ Examples:
3588
3578
  try {
3589
3579
  const cwd = process.cwd();
3590
3580
  const { projectName, installInCwd } = resolveProjectArg(directory);
3581
+ if (projectName) {
3582
+ const nameError = validateProjectName(projectName);
3583
+ if (nameError) {
3584
+ console.error(`Error: Invalid project name '${projectName}'. ${nameError}.`);
3585
+ process.exit(1);
3586
+ }
3587
+ }
3591
3588
  const projectType = options.template;
3592
3589
  const validTypes = ["blank", "blog"];
3593
3590
  if (projectType && !validTypes.includes(projectType)) {