create-next-pro-cli 0.1.14 → 0.1.17

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 (64) hide show
  1. package/README.md +3 -2
  2. package/create-next-pro-completion.sh +9 -1
  3. package/dist/{bin.js → bin.bun.js} +128 -9
  4. package/dist/bin.node.js +682 -0
  5. package/dist/bin.node.js.map +1 -0
  6. package/dist/create-next-pro +10 -0
  7. package/package.json +24 -8
  8. package/templates/Projects/default/README.md +36 -0
  9. package/templates/Projects/default/src/app/[locale]/(public)/Login/page.tsx +6 -0
  10. package/templates/Projects/default/src/app/[locale]/(public)/Register/page.tsx +6 -0
  11. package/templates/Projects/default/src/app/[locale]/(public)/_home/loading.tsx +5 -0
  12. package/templates/Projects/default/src/app/[locale]/(public)/_home/page.tsx +6 -0
  13. package/templates/Projects/default/src/app/[locale]/(public)/layout.tsx +9 -0
  14. package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/error.tsx +38 -0
  15. package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/loading.tsx +10 -0
  16. package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/page.tsx +5 -0
  17. package/templates/Projects/default/src/app/[locale]/(user)/Settings/loading.tsx +17 -0
  18. package/templates/Projects/default/src/app/[locale]/(user)/Settings/page.tsx +6 -0
  19. package/templates/Projects/default/src/app/[locale]/(user)/UserInfo/loading.tsx +17 -0
  20. package/templates/Projects/default/src/app/[locale]/(user)/UserInfo/page.tsx +6 -0
  21. package/templates/Projects/default/src/app/[locale]/(user)/layout.tsx +9 -0
  22. package/templates/Projects/default/src/app/[locale]/layout.tsx +31 -0
  23. package/templates/Projects/default/src/app/[locale]/loading.tsx +14 -0
  24. package/templates/Projects/default/src/app/[locale]/not-found.tsx +22 -0
  25. package/templates/Projects/default/src/app/[locale]/page.tsx +6 -0
  26. package/templates/Projects/default/src/app/api/auth/[...nextauth]/route.ts +62 -0
  27. package/templates/Projects/default/src/app/api/auth/post-login/route.ts +26 -0
  28. package/templates/Projects/default/src/app/favicon.ico +0 -0
  29. package/templates/Projects/default/src/app/layout.tsx +11 -0
  30. package/templates/Projects/default/src/app/not-found.tsx +17 -0
  31. package/templates/Projects/default/src/app/page.tsx +6 -0
  32. package/templates/Projects/default/src/app/sitemap.ts +27 -0
  33. package/templates/Projects/default/src/app/styles/globals.css +305 -0
  34. package/templates/Projects/default/src/auth.config.ts +0 -0
  35. package/templates/Projects/default/src/config.ts +4 -0
  36. package/templates/Projects/default/src/lib/auth/disconnect.ts +11 -0
  37. package/templates/Projects/default/src/lib/auth/isConnected.ts +18 -0
  38. package/templates/Projects/default/src/lib/i18n/navigation.ts +19 -0
  39. package/templates/Projects/default/src/lib/i18n/request.ts +31 -0
  40. package/templates/Projects/default/src/lib/i18n/routing.ts +20 -0
  41. package/templates/Projects/default/src/lib/utils.ts +6 -0
  42. package/templates/Projects/default/src/ui/Dashboard/LogoutButton.tsx +27 -0
  43. package/templates/Projects/default/src/ui/Dashboard/StatsCard.tsx +14 -0
  44. package/templates/Projects/default/src/ui/Dashboard/WelcomeCard.tsx +10 -0
  45. package/templates/Projects/default/src/ui/Dashboard/page-ui.tsx +23 -0
  46. package/templates/Projects/default/src/ui/Login/page-ui.tsx +22 -0
  47. package/templates/Projects/default/src/ui/Register/page-ui.tsx +26 -0
  48. package/templates/Projects/default/src/ui/Settings/page-ui.tsx +17 -0
  49. package/templates/Projects/default/src/ui/UserInfo/page-ui.tsx +17 -0
  50. package/templates/Projects/default/src/ui/_global/BackButton.tsx +17 -0
  51. package/templates/Projects/default/src/ui/_global/Button.tsx +75 -0
  52. package/templates/Projects/default/src/ui/_global/GlobalHeader.tsx +55 -0
  53. package/templates/Projects/default/src/ui/_global/GlobalMain.tsx +15 -0
  54. package/templates/Projects/default/src/ui/_global/Loading.tsx +13 -0
  55. package/templates/Projects/default/src/ui/_global/LocaleSwitcher.tsx +38 -0
  56. package/templates/Projects/default/src/ui/_global/PublicNav.tsx +91 -0
  57. package/templates/Projects/default/src/ui/_global/ThemeToggle.tsx +53 -0
  58. package/templates/Projects/default/src/ui/_global/UserNav.tsx +35 -0
  59. package/templates/Projects/default/src/ui/_home/page-ui.tsx +27 -0
  60. package/.github/workflows/ci.yml +0 -38
  61. package/bin.ts +0 -3
  62. package/commitlint.config.cjs +0 -12
  63. package/install.sh +0 -74
  64. package/tsconfig.json +0 -27
package/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  <img src="./public/cnp-banner.svg" alt="create-next-pro logo" style="width:100%;" />
2
2
 
3
- # Runtime Support
3
+ ## Runtime Support
4
4
 
5
5
  [![Bun](https://img.shields.io/badge/Bun-%23000000?logo=bun&logoColor=white&style=for-the-badge)](https://bun.sh)
6
6
  [![Node.js](https://img.shields.io/badge/Node.js-%23339933?logo=node.js&logoColor=white&style=for-the-badge)](https://nodejs.org)
7
- [![Deno](https://img.shields.io/badge/Deno-%23000000?logo=deno&logoColor=white&style=for-the-badge)](https://deno.land)
7
+
8
+ <!-- [![Deno](https://img.shields.io/badge/Deno-%23000000?logo=deno&logoColor=white&style=for-the-badge)](https://deno.land) -->
8
9
 
9
10
  ![npm](https://img.shields.io/npm/v/create-next-pro-cli?logo=npm&color=orange)
10
11
  ![npm dependencies](https://img.shields.io/librariesio/release/npm/create-next-pro-cli?logo=npm)
@@ -17,7 +17,7 @@ _create_next_pro_complete() {
17
17
  # List all nested page/component paths under src/ui
18
18
  local IFS=$'\n'
19
19
  local items=( $(find src/ui -type d | sed 's|src/ui/||; /^$/d' | grep -v '^$' | grep -v '^\.$' | grep -v '^src/ui$') )
20
- # Retire explicitement src/ui
20
+ # Explicitly remove src/ui
21
21
  items=( "${items[@]}" )
22
22
  COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
23
23
  return 0
@@ -32,5 +32,13 @@ _create_next_pro_complete() {
32
32
  COMPREPLY=( $(compgen -W "${children[*]}" -- ${prefix}) )
33
33
  return 0
34
34
  fi
35
+
36
+ # Autocomplete page names for rmpage (based on src/ui)
37
+ if [[ ${COMP_CWORD} == 2 && ${prev} == "rmpage" ]]; then
38
+ local IFS=$'\n'
39
+ local pages=( $(find src/ui -type d | sed 's|src/ui/||; /^$/d' | grep -v '^$' | grep -v '^\.$' | grep -v '^src/ui$') )
40
+ COMPREPLY=( $(compgen -W "${pages[*]}" -- ${cur}) )
41
+ return 0
42
+ fi
35
43
  }
36
44
  complete -F _create_next_pro_complete create-next-pro
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => {
19
19
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
20
20
  var __require = import.meta.require;
21
21
 
22
- // node_modules/kleur/index.js
22
+ // node_modules/prompts/node_modules/kleur/index.js
23
23
  var require_kleur = __commonJS((exports, module) => {
24
24
  var { FORCE_COLOR, NODE_DISABLE_COLORS, TERM } = process.env;
25
25
  var $ = {
@@ -4936,6 +4936,14 @@ var require_prompts3 = __commonJS((exports, module) => {
4936
4936
  module.exports = isNodeLT("8.6.0") ? require_dist() : require_lib();
4937
4937
  });
4938
4938
 
4939
+ // src/index.ts
4940
+ var import_prompts5 = __toESM(require_prompts3(), 1);
4941
+ import fs from "fs";
4942
+ import os from "os";
4943
+ import path from "path";
4944
+ import { fileURLToPath as fileURLToPath2 } from "url";
4945
+ import { dirname, resolve } from "path";
4946
+
4939
4947
  // src/lib/addComponent.ts
4940
4948
  var import_prompts = __toESM(require_prompts3(), 1);
4941
4949
  import { join as join2 } from "path";
@@ -5301,9 +5309,11 @@ async function rmPage(args) {
5301
5309
  import { cp, mkdir as mkdir3, rm, writeFile as writeFile4, readFile as readFile4 } from "fs/promises";
5302
5310
  import { join as join5 } from "path";
5303
5311
  import { existsSync as existsSync5 } from "fs";
5312
+ import { fileURLToPath } from "url";
5304
5313
  async function scaffoldProject(options) {
5305
5314
  const targetPath = join5(process.cwd(), options.projectName);
5306
- const templatePath = join5(import.meta.dir, "..", "templates", "Projects", "default");
5315
+ const __dirname2 = new URL(".", import.meta.url);
5316
+ const templatePath = join5(fileURLToPath(__dirname2), "..", "templates", "Projects", "default");
5307
5317
  if (existsSync5(targetPath)) {
5308
5318
  if (options.force) {
5309
5319
  console.warn("\u26A0\uFE0F Target directory already exists, removing...");
@@ -5346,7 +5356,7 @@ async function createProject(nameArg, force) {
5346
5356
  useSrcDir: true,
5347
5357
  useTurbopack: true,
5348
5358
  useI18n: true,
5349
- customAlias: false,
5359
+ customAlias: true,
5350
5360
  importAlias: "@/*",
5351
5361
  force
5352
5362
  };
@@ -5392,7 +5402,7 @@ async function createProjectWithPrompt() {
5392
5402
  type: "toggle",
5393
5403
  name: "useSrcDir",
5394
5404
  message: "\u2714 Use `src/` directory?",
5395
- initial: false,
5405
+ initial: true,
5396
5406
  active: "Yes",
5397
5407
  inactive: "No"
5398
5408
  },
@@ -5416,7 +5426,7 @@ async function createProjectWithPrompt() {
5416
5426
  type: "toggle",
5417
5427
  name: "customAlias",
5418
5428
  message: "\u2714 Customize import alias (`@/*` by default)?",
5419
- initial: false,
5429
+ initial: true,
5420
5430
  active: "Yes",
5421
5431
  inactive: "No"
5422
5432
  },
@@ -5434,10 +5444,119 @@ async function createProjectWithPrompt() {
5434
5444
  }
5435
5445
 
5436
5446
  // src/index.ts
5437
- async function main() {
5438
- console.log(`\uD83D\uDE80 Welcome to create-next-pro
5447
+ var CONFIG_DIR = process.env.XDG_CONFIG_HOME ? path.join(process.env.XDG_CONFIG_HOME, "create-next-pro") : path.join(os.homedir(), ".config", "create-next-pro");
5448
+ var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
5449
+ function readCfg() {
5450
+ try {
5451
+ return JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"));
5452
+ } catch {
5453
+ return null;
5454
+ }
5455
+ }
5456
+ function writeCfg(cfg) {
5457
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
5458
+ fs.writeFileSync(CONFIG_FILE, JSON.stringify(cfg, null, 2));
5459
+ }
5460
+ function rcFile(shell) {
5461
+ return path.join(os.homedir(), shell === "zsh" ? ".zshrc" : ".bashrc");
5462
+ }
5463
+ function ensureLineInRc(file, line) {
5464
+ try {
5465
+ const cur = fs.existsSync(file) ? fs.readFileSync(file, "utf8") : "";
5466
+ if (!cur.includes(line))
5467
+ fs.appendFileSync(file, `
5468
+ ${line}
5439
5469
  `);
5440
- let args = Bun.argv.slice(2);
5470
+ } catch {}
5471
+ }
5472
+ async function installCompletion(shell) {
5473
+ const __dirname2 = path.dirname(fileURLToPath2(import.meta.url));
5474
+ const completionSrc = path.resolve(__dirname2, "../create-next-pro-completion.sh");
5475
+ const completionDst = path.join(CONFIG_DIR, "completion.sh");
5476
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
5477
+ fs.copyFileSync(completionSrc, completionDst);
5478
+ ensureLineInRc(rcFile(shell), `source "${completionDst}"`);
5479
+ }
5480
+ var __filename2 = fileURLToPath2(import.meta.url);
5481
+ var __dirname2 = dirname(__filename2);
5482
+ var packageJsonPath = resolve(__dirname2, "../package.json");
5483
+ var packageJson = fs.readFileSync(packageJsonPath, "utf8");
5484
+ async function onboarding() {
5485
+ const pkg = JSON.parse(packageJson);
5486
+ console.log(`\uD83D\uDE80 Welcome to create-next-pro v${pkg.version}
5487
+ `);
5488
+ const res = await import_prompts5.default([
5489
+ {
5490
+ type: "select",
5491
+ name: "shell",
5492
+ message: "Which shell do you use?",
5493
+ choices: [
5494
+ { title: "zsh", value: "zsh" },
5495
+ { title: "bash", value: "bash" }
5496
+ ],
5497
+ initial: (os.userInfo().shell || "").includes("zsh") ? 0 : 1
5498
+ },
5499
+ {
5500
+ type: "toggle",
5501
+ name: "completion",
5502
+ message: "Install autocompletion?",
5503
+ initial: true,
5504
+ active: "Yes",
5505
+ inactive: "No"
5506
+ }
5507
+ ], { onCancel: () => process.exit(1) });
5508
+ const cfg = {
5509
+ version: 1,
5510
+ shell: res.shell,
5511
+ completionInstalled: !!res.completion,
5512
+ createdAt: new Date().toISOString(),
5513
+ updatedAt: new Date().toISOString()
5514
+ };
5515
+ if (cfg.completionInstalled)
5516
+ await installCompletion(cfg.shell);
5517
+ writeCfg(cfg);
5518
+ console.log(`
5519
+ \u2705 Configuration saved.`);
5520
+ console.log("you can now use the CLI ! ex : create-next-pro <project-name>");
5521
+ console.log("For more information, visit: https://github.com/Rising-Corporation/create-next-pro-cli");
5522
+ console.log("Happy coding! \uD83C\uDF89");
5523
+ return cfg;
5524
+ }
5525
+ function showHelp() {
5526
+ console.log(`create-next-pro
5527
+
5528
+ Usage:
5529
+ create-next-pro <project-name> [--force]
5530
+ create-next-pro addpage [options]
5531
+ create-next-pro addcomponent [options]
5532
+ create-next-pro rmpage [options]
5533
+
5534
+ Options:
5535
+ --help Show this help message
5536
+ --reconfigure Run the configuration assistant again
5537
+ `);
5538
+ }
5539
+ function showVersion() {
5540
+ const pkg = JSON.parse(packageJson);
5541
+ console.log(`v${pkg.version}`);
5542
+ }
5543
+ async function main() {
5544
+ let args;
5545
+ if (typeof Bun !== "undefined") {
5546
+ args = Bun.argv.slice(2);
5547
+ } else if (typeof process !== "undefined" && process.argv) {
5548
+ args = process.argv.slice(2);
5549
+ } else {
5550
+ args = [];
5551
+ }
5552
+ if (args.includes("--help"))
5553
+ return showHelp();
5554
+ if (args.includes("--version") || args.includes("-v"))
5555
+ return showVersion();
5556
+ if (args.includes("--reconfigure") || !readCfg()) {
5557
+ await onboarding();
5558
+ return;
5559
+ }
5441
5560
  const force = args.includes("--force");
5442
5561
  if (args[0] === "addpage" && args.length === 1) {
5443
5562
  args.push("-LPl");
@@ -5462,5 +5581,5 @@ async function main() {
5462
5581
  await createProjectWithPrompt();
5463
5582
  }
5464
5583
 
5465
- // bin.ts
5584
+ // bin.bun.ts
5466
5585
  main();