create-next-pro-cli 0.1.14 → 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 +3 -2
- package/create-next-pro-completion.sh +9 -1
- package/dist/{bin.js → bin.bun.js} +124 -9
- package/dist/bin.node.js +681 -0
- package/dist/bin.node.js.map +1 -0
- package/dist/create-next-pro +9 -0
- package/package.json +24 -8
- package/templates/Projects/default/README.md +36 -0
- package/templates/Projects/default/src/app/[locale]/(public)/Login/page.tsx +6 -0
- package/templates/Projects/default/src/app/[locale]/(public)/Register/page.tsx +6 -0
- package/templates/Projects/default/src/app/[locale]/(public)/_home/loading.tsx +5 -0
- package/templates/Projects/default/src/app/[locale]/(public)/_home/page.tsx +6 -0
- package/templates/Projects/default/src/app/[locale]/(public)/layout.tsx +9 -0
- package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/error.tsx +38 -0
- package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/loading.tsx +10 -0
- package/templates/Projects/default/src/app/[locale]/(user)/Dashboard/page.tsx +5 -0
- package/templates/Projects/default/src/app/[locale]/(user)/Settings/loading.tsx +17 -0
- package/templates/Projects/default/src/app/[locale]/(user)/Settings/page.tsx +6 -0
- package/templates/Projects/default/src/app/[locale]/(user)/UserInfo/loading.tsx +17 -0
- package/templates/Projects/default/src/app/[locale]/(user)/UserInfo/page.tsx +6 -0
- package/templates/Projects/default/src/app/[locale]/(user)/layout.tsx +9 -0
- package/templates/Projects/default/src/app/[locale]/layout.tsx +31 -0
- package/templates/Projects/default/src/app/[locale]/loading.tsx +14 -0
- package/templates/Projects/default/src/app/[locale]/not-found.tsx +22 -0
- package/templates/Projects/default/src/app/[locale]/page.tsx +6 -0
- package/templates/Projects/default/src/app/api/auth/[...nextauth]/route.ts +62 -0
- package/templates/Projects/default/src/app/api/auth/post-login/route.ts +26 -0
- package/templates/Projects/default/src/app/favicon.ico +0 -0
- package/templates/Projects/default/src/app/layout.tsx +11 -0
- package/templates/Projects/default/src/app/not-found.tsx +17 -0
- package/templates/Projects/default/src/app/page.tsx +6 -0
- package/templates/Projects/default/src/app/sitemap.ts +27 -0
- package/templates/Projects/default/src/app/styles/globals.css +305 -0
- package/templates/Projects/default/src/auth.config.ts +0 -0
- package/templates/Projects/default/src/config.ts +4 -0
- package/templates/Projects/default/src/lib/auth/disconnect.ts +11 -0
- package/templates/Projects/default/src/lib/auth/isConnected.ts +18 -0
- package/templates/Projects/default/src/lib/i18n/navigation.ts +19 -0
- package/templates/Projects/default/src/lib/i18n/request.ts +31 -0
- package/templates/Projects/default/src/lib/i18n/routing.ts +20 -0
- package/templates/Projects/default/src/lib/utils.ts +6 -0
- package/templates/Projects/default/src/ui/Dashboard/LogoutButton.tsx +27 -0
- package/templates/Projects/default/src/ui/Dashboard/StatsCard.tsx +14 -0
- package/templates/Projects/default/src/ui/Dashboard/WelcomeCard.tsx +10 -0
- package/templates/Projects/default/src/ui/Dashboard/page-ui.tsx +23 -0
- package/templates/Projects/default/src/ui/Login/page-ui.tsx +22 -0
- package/templates/Projects/default/src/ui/Register/page-ui.tsx +26 -0
- package/templates/Projects/default/src/ui/Settings/page-ui.tsx +17 -0
- package/templates/Projects/default/src/ui/UserInfo/page-ui.tsx +17 -0
- package/templates/Projects/default/src/ui/_global/BackButton.tsx +17 -0
- package/templates/Projects/default/src/ui/_global/Button.tsx +75 -0
- package/templates/Projects/default/src/ui/_global/GlobalHeader.tsx +55 -0
- package/templates/Projects/default/src/ui/_global/GlobalMain.tsx +15 -0
- package/templates/Projects/default/src/ui/_global/Loading.tsx +13 -0
- package/templates/Projects/default/src/ui/_global/LocaleSwitcher.tsx +38 -0
- package/templates/Projects/default/src/ui/_global/PublicNav.tsx +91 -0
- package/templates/Projects/default/src/ui/_global/ThemeToggle.tsx +53 -0
- package/templates/Projects/default/src/ui/_global/UserNav.tsx +35 -0
- package/templates/Projects/default/src/ui/_home/page-ui.tsx +27 -0
- package/.github/workflows/ci.yml +0 -38
- package/bin.ts +0 -3
- package/commitlint.config.cjs +0 -12
- package/install.sh +0 -74
- 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
|
-
|
|
3
|
+
## Runtime Support
|
|
4
4
|
|
|
5
5
|
[](https://bun.sh)
|
|
6
6
|
[](https://nodejs.org)
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
<!-- [](https://deno.land) -->
|
|
8
9
|
|
|
9
10
|

|
|
10
11
|

|
|
@@ -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
|
-
#
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
5438
|
-
|
|
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
|
-
|
|
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();
|