create-next-pro-cli 0.1.13 → 0.1.16

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/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)
@@ -13,6 +14,7 @@
13
14
  ![GitHub](https://img.shields.io/github/stars/Rising-Corporation/create-next-pro-cli?style=social&logo=github)
14
15
  ![GitHub forks](https://img.shields.io/github/forks/Rising-Corporation/create-next-pro-cli?style=social&logo=github)
15
16
  ![GitHub issues](https://img.shields.io/github/issues/Rising-Corporation/create-next-pro-cli?logo=github)
17
+ ![CI](https://github.com/Rising-Corporation/typed-sse/actions/workflows/ci.yml/badge.svg)
16
18
 
17
19
  ![status](https://img.shields.io/badge/status-beta-orange)
18
20
  ![license](https://img.shields.io/github/license/Rising-Corporation/create-next-pro-cli?logo=open-source-initiative&logoColor=white)
@@ -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,13 @@ 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
+
4939
4946
  // src/lib/addComponent.ts
4940
4947
  var import_prompts = __toESM(require_prompts3(), 1);
4941
4948
  import { join as join2 } from "path";
@@ -5301,9 +5308,11 @@ async function rmPage(args) {
5301
5308
  import { cp, mkdir as mkdir3, rm, writeFile as writeFile4, readFile as readFile4 } from "fs/promises";
5302
5309
  import { join as join5 } from "path";
5303
5310
  import { existsSync as existsSync5 } from "fs";
5311
+ import { fileURLToPath } from "url";
5304
5312
  async function scaffoldProject(options) {
5305
5313
  const targetPath = join5(process.cwd(), options.projectName);
5306
- const templatePath = join5(import.meta.dir, "..", "templates", "Projects", "default");
5314
+ const __dirname2 = new URL(".", import.meta.url);
5315
+ const templatePath = join5(fileURLToPath(__dirname2), "..", "templates", "Projects", "default");
5307
5316
  if (existsSync5(targetPath)) {
5308
5317
  if (options.force) {
5309
5318
  console.warn("\u26A0\uFE0F Target directory already exists, removing...");
@@ -5346,7 +5355,7 @@ async function createProject(nameArg, force) {
5346
5355
  useSrcDir: true,
5347
5356
  useTurbopack: true,
5348
5357
  useI18n: true,
5349
- customAlias: false,
5358
+ customAlias: true,
5350
5359
  importAlias: "@/*",
5351
5360
  force
5352
5361
  };
@@ -5392,7 +5401,7 @@ async function createProjectWithPrompt() {
5392
5401
  type: "toggle",
5393
5402
  name: "useSrcDir",
5394
5403
  message: "\u2714 Use `src/` directory?",
5395
- initial: false,
5404
+ initial: true,
5396
5405
  active: "Yes",
5397
5406
  inactive: "No"
5398
5407
  },
@@ -5416,7 +5425,7 @@ async function createProjectWithPrompt() {
5416
5425
  type: "toggle",
5417
5426
  name: "customAlias",
5418
5427
  message: "\u2714 Customize import alias (`@/*` by default)?",
5419
- initial: false,
5428
+ initial: true,
5420
5429
  active: "Yes",
5421
5430
  inactive: "No"
5422
5431
  },
@@ -5434,10 +5443,116 @@ async function createProjectWithPrompt() {
5434
5443
  }
5435
5444
 
5436
5445
  // src/index.ts
5437
- async function main() {
5438
- console.log(`\uD83D\uDE80 Welcome to create-next-pro
5446
+ var __dirname = "/home/runner/work/create-next-pro-cli/create-next-pro-cli/src";
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
+ async function onboarding() {
5481
+ const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf8"));
5482
+ console.log(`\uD83D\uDE80 Welcome to create-next-pro v${pkg.version}
5483
+ `);
5484
+ const res = await import_prompts5.default([
5485
+ {
5486
+ type: "select",
5487
+ name: "shell",
5488
+ message: "Which shell do you use?",
5489
+ choices: [
5490
+ { title: "zsh", value: "zsh" },
5491
+ { title: "bash", value: "bash" }
5492
+ ],
5493
+ initial: (os.userInfo().shell || "").includes("zsh") ? 0 : 1
5494
+ },
5495
+ {
5496
+ type: "toggle",
5497
+ name: "completion",
5498
+ message: "Install autocompletion?",
5499
+ initial: true,
5500
+ active: "Yes",
5501
+ inactive: "No"
5502
+ }
5503
+ ], { onCancel: () => process.exit(1) });
5504
+ const cfg = {
5505
+ version: 1,
5506
+ shell: res.shell,
5507
+ completionInstalled: !!res.completion,
5508
+ createdAt: new Date().toISOString(),
5509
+ updatedAt: new Date().toISOString()
5510
+ };
5511
+ if (cfg.completionInstalled)
5512
+ await installCompletion(cfg.shell);
5513
+ writeCfg(cfg);
5514
+ console.log(`
5515
+ \u2705 Configuration saved.`);
5516
+ console.log("you can now use the CLI ! ex : create-next-pro <project-name>");
5517
+ console.log("For more information, visit: https://github.com/Rising-Corporation/create-next-pro-cli");
5518
+ console.log("Happy coding! \uD83C\uDF89");
5519
+ return cfg;
5520
+ }
5521
+ function showHelp() {
5522
+ console.log(`create-next-pro
5523
+
5524
+ Usage:
5525
+ create-next-pro <project-name> [--force]
5526
+ create-next-pro addpage [options]
5527
+ create-next-pro addcomponent [options]
5528
+ create-next-pro rmpage [options]
5529
+
5530
+ Options:
5531
+ --help Show this help message
5532
+ --reconfigure Run the configuration assistant again
5533
+ `);
5534
+ }
5535
+ function showVersion() {
5536
+ const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf8"));
5537
+ console.log(`v${pkg.version}`);
5538
+ }
5539
+ async function main() {
5540
+ let args;
5541
+ if (typeof Bun !== "undefined") {
5542
+ args = Bun.argv.slice(2);
5543
+ } else if (typeof process !== "undefined" && process.argv) {
5544
+ args = process.argv.slice(2);
5545
+ } else {
5546
+ args = [];
5547
+ }
5548
+ if (args.includes("--help"))
5549
+ return showHelp();
5550
+ if (args.includes("--version") || args.includes("-v"))
5551
+ return showVersion();
5552
+ if (args.includes("--reconfigure") || !readCfg()) {
5553
+ await onboarding();
5554
+ return;
5555
+ }
5441
5556
  const force = args.includes("--force");
5442
5557
  if (args[0] === "addpage" && args.length === 1) {
5443
5558
  args.push("-LPl");
@@ -5462,5 +5577,5 @@ async function main() {
5462
5577
  await createProjectWithPrompt();
5463
5578
  }
5464
5579
 
5465
- // bin.ts
5580
+ // bin.bun.ts
5466
5581
  main();