create-nxpage-app 0.1.18 → 0.1.19

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 ADDED
@@ -0,0 +1,60 @@
1
+ # create-nxpage-app
2
+
3
+ CLI to scaffold a Next.js TypeScript app and wire in NxPage.
4
+
5
+ ## Why use this CLI
6
+
7
+ This package gives you a fast way to start a Next.js app that can serve optimized JSON responses to AI agents (ChatGPT/OpenAI, Claude, Perplexity, and others) using `nxpage`.
8
+
9
+ It helps you quickly adopt a dual-delivery model:
10
+
11
+ - normal users -> regular Next.js HTML
12
+ - AI agents -> lightweight NxPage JSON (when route filters allow)
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+ npx create-nxpage-app my-app
18
+ ```
19
+
20
+ ## What the CLI does
21
+
22
+ 1. Creates a Next.js app with TypeScript and App Router.
23
+ 2. Installs `nxpage`.
24
+ 3. Adds `server.ts` from template.
25
+ 4. Updates scripts in generated `package.json`:
26
+ - `dev`: `next dev`
27
+ - `build`: `next build && nxpage build`
28
+ - `start`: `NODE_ENV=production node server.js`
29
+
30
+ ## After scaffold (recommended)
31
+
32
+ 1. Open generated `server.ts`.
33
+ 2. Configure:
34
+ - `includeRoutePatterns`
35
+ - `blockRoutePatterns`
36
+ 3. Build app and run production server.
37
+
38
+ This setup can reduce agent-response transfer volume dramatically (often large savings, up to ~99% in favorable cases).
39
+
40
+ ## Template Files
41
+
42
+ - `templates/server.ts`
43
+ - `templates/next.config.ts`
44
+
45
+ These are copied into generated app output (via build pipeline).
46
+
47
+ ## Local Development (Monorepo)
48
+
49
+ ```bash
50
+ cd newupdate/packages/create-nxpage-app
51
+ npm install
52
+ npm run build
53
+ ```
54
+
55
+ ## Publish Notes
56
+
57
+ This package ships:
58
+
59
+ - `dist/index.cjs`
60
+ - `dist/templates/*`
package/dist/index.cjs CHANGED
@@ -36,30 +36,16 @@ var root = import_path.default.resolve(process.cwd(), appName);
36
36
  var templateDir = import_path.default.join(__dirname, "../dist/templates");
37
37
  import_cross_spawn.default.sync(
38
38
  "npx",
39
- [
40
- "create-next-app@latest",
41
- appName,
42
- "--ts",
43
- "--use-npm",
44
- "--eslint",
45
- "--app"
46
- ],
39
+ ["create-next-app@latest", appName, "--ts", "--use-npm", "--eslint", "--app"],
47
40
  { stdio: "inherit" }
48
41
  );
49
- import_cross_spawn.default.sync(
50
- "npm",
51
- ["install", "nxpage"],
52
- { cwd: root, stdio: "inherit" }
53
- );
54
- import_fs.default.copyFileSync(
55
- import_path.default.join(templateDir, "server.ts"),
56
- import_path.default.join(root, "server.ts")
57
- );
58
- var pkgPath = import_path.default.join(root, "package.json");
59
- var pkg = JSON.parse(import_fs.default.readFileSync(pkgPath, "utf-8"));
60
- pkg.scripts.dev = "next dev";
61
- pkg.scripts.build = "next build && nxpage build";
62
- pkg.scripts.start = "NODE_ENV=production node server.js";
63
- import_fs.default.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
64
- import_fs.default.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
42
+ import_cross_spawn.default.sync("npm", ["install", "nxpage"], { cwd: root, stdio: "inherit" });
43
+ import_fs.default.copyFileSync(import_path.default.join(templateDir, "nxpage.config.js"), import_path.default.join(root, "nxpage.config.js"));
44
+ import_fs.default.copyFileSync(import_path.default.join(templateDir, "server.js"), import_path.default.join(root, "server.js"));
45
+ var packageJsonPath = import_path.default.join(root, "package.json");
46
+ var packageJson = JSON.parse(import_fs.default.readFileSync(packageJsonPath, "utf-8"));
47
+ packageJson.scripts.dev = "nxpage dev";
48
+ packageJson.scripts.build = "nxpage build";
49
+ packageJson.scripts.start = "nxpage start";
50
+ import_fs.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
65
51
  console.log("NxPage app created successfully.");
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,12 @@
1
+ module.exports = function getNxPageConfig() {
2
+ return {
3
+ server: {
4
+ port: 3000,
5
+ },
6
+ build: {
7
+ distDir: ".next",
8
+ includeRoutePatterns: [],
9
+ blockRoutePatterns: [],
10
+ }
11
+ }
12
+ };
@@ -0,0 +1,3 @@
1
+ const { createNxPageServer } = require("nxpage");
2
+
3
+ createNxPageServer();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-nxpage-app",
3
3
  "description": "A CLI to scaffold a production-ready Next.js app with NxPage bot-optimized server setup and Turbopack-safe build pipeline.",
4
- "version": "0.1.18",
4
+ "version": "0.1.19",
5
5
  "bin": {
6
6
  "create-nxpage-app": "./dist/index.cjs"
7
7
  },
@@ -37,18 +37,23 @@
37
37
  "chatgpt bot optimizer"
38
38
  ],
39
39
  "files": [
40
- "dist"
40
+ "dist",
41
+ "src",
42
+ "templates"
41
43
  ],
42
44
  "scripts": {
43
45
  "build": "tsup && cpx \"templates/**/*\" dist/templates",
44
- "dev": "tsup --watch"
46
+ "dev": "tsup --watch",
47
+ "clean": "rm -rf dist"
45
48
  },
46
49
  "dependencies": {
47
50
  "cpx": "^1.5.0",
48
- "cross-spawn": "^7.0.3",
49
- "nxpage": "0.0.21"
51
+ "cross-spawn": "^7.0.3"
50
52
  },
51
53
  "devDependencies": {
52
- "@types/cross-spawn": "^6.0.6"
54
+ "@types/cross-spawn": "^6.0.6",
55
+ "@types/node": "^20.19.33",
56
+ "tsup": "^8.x",
57
+ "typescript": "^5.x"
53
58
  }
54
59
  }
package/src/index.ts ADDED
@@ -0,0 +1,34 @@
1
+ import spawn from "cross-spawn";
2
+ import fs from "fs";
3
+ import path from "path";
4
+
5
+ const appName = process.argv[2];
6
+
7
+ if (!appName) {
8
+ console.error("Please provide a project name.");
9
+ process.exit(1);
10
+ }
11
+
12
+ const root = path.resolve(process.cwd(), appName);
13
+ const templateDir = path.join(__dirname, "../dist/templates");
14
+
15
+ spawn.sync(
16
+ "npx",
17
+ ["create-next-app@latest", appName, "--ts", "--use-npm", "--eslint", "--app"],
18
+ { stdio: "inherit" }
19
+ );
20
+
21
+ spawn.sync("npm", ["install", "nxpage"], { cwd: root, stdio: "inherit" });
22
+
23
+ fs.copyFileSync(path.join(templateDir, "nxpage.config.js"), path.join(root, "nxpage.config.js"));
24
+ fs.copyFileSync(path.join(templateDir, "server.js"), path.join(root, "server.js"));
25
+
26
+ const packageJsonPath = path.join(root, "package.json");
27
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
28
+ packageJson.scripts.dev = "nxpage dev";
29
+ packageJson.scripts.build = "nxpage build";
30
+ packageJson.scripts.start = "nxpage start";
31
+
32
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
33
+
34
+ console.log("NxPage app created successfully.");
@@ -0,0 +1,12 @@
1
+ module.exports = function getNxPageConfig() {
2
+ return {
3
+ server: {
4
+ port: 3000,
5
+ },
6
+ build: {
7
+ distDir: ".next",
8
+ includeRoutePatterns: [],
9
+ blockRoutePatterns: [],
10
+ }
11
+ }
12
+ };
@@ -0,0 +1,3 @@
1
+ const { createNxPageServer } = require("nxpage");
2
+
3
+ createNxPageServer();
@@ -1,6 +0,0 @@
1
- import type { NextConfig } from "next";
2
- import { withNxPage } from "nxpage";
3
-
4
- const nextConfig: NextConfig = {};
5
-
6
- export default withNxPage(nextConfig);
@@ -1,5 +0,0 @@
1
- const { createNxPageServer } = require("nxpage");
2
-
3
- createNxPageServer({
4
- port: process.env.PORT || 3000,
5
- });