@dhayalesh/create-nextjs 0.0.1
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 +11 -0
- package/generators/create-nextjs/files/nextjs/next.config.js.template +11 -0
- package/generators/create-nextjs/files/nextjs/package.json.template +30 -0
- package/generators/create-nextjs/files/nextjs/postcss.config.js.template +6 -0
- package/generators/create-nextjs/files/nextjs/project.json.template +44 -0
- package/generators/create-nextjs/files/nextjs/src/app/layout.tsx.template +19 -0
- package/generators/create-nextjs/files/nextjs/tailwind.config.js.template +18 -0
- package/generators/create-nextjs/files/nextjs/tsconfig.json.template +28 -0
- package/generators/create-nextjs/generator.d.ts +12 -0
- package/generators/create-nextjs/generator.d.ts.map +1 -0
- package/generators/create-nextjs/generator.js +67 -0
- package/generators/create-nextjs/schema.json +41 -0
- package/generators.json +9 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -0
- package/index.js +2 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# create-nextjs
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Building
|
|
6
|
+
|
|
7
|
+
Run `nx build create-nextjs` to build the library.
|
|
8
|
+
|
|
9
|
+
## Running unit tests
|
|
10
|
+
|
|
11
|
+
Run `nx test create-nextjs` to execute the unit tests via [Jest](https://jestjs.io).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= name %>",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "next dev -p <%= port %>",
|
|
7
|
+
"build": "next build",
|
|
8
|
+
"start": "next start -p <%= port %>",
|
|
9
|
+
"lint": "next lint",
|
|
10
|
+
"type-check": "tsc --noEmit"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"next": "^14.0.0",
|
|
14
|
+
"react": "^18.0.0",
|
|
15
|
+
"react-dom": "^18.0.0"<% if (styling === 'tailwind') { %>,
|
|
16
|
+
"tailwindcss": "^3.3.0",
|
|
17
|
+
"autoprefixer": "^10.4.16",
|
|
18
|
+
"postcss": "^8.4.31"<% } %><% if (styling === 'styled-components') { %>,
|
|
19
|
+
"styled-components": "^6.0.0"<% } %>
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {<% if (language === 'ts') { %>
|
|
22
|
+
"typescript": "^5.0.0",
|
|
23
|
+
"@types/node": "^20.0.0",
|
|
24
|
+
"@types/react": "^18.0.0",
|
|
25
|
+
"@types/react-dom": "^18.0.0",<% } %>
|
|
26
|
+
"eslint": "^8.0.0",
|
|
27
|
+
"eslint-config-next": "^14.0.0"<% if (styling === 'styled-components' && language === 'ts') { %>,
|
|
28
|
+
"@types/styled-components": "^5.1.0"<% } %>
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= name %>",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"projectType": "application",
|
|
5
|
+
"sourceRoot": "<%= projectRoot %>/src",
|
|
6
|
+
"targets": {
|
|
7
|
+
"build": {
|
|
8
|
+
"executor": "nx:run-commands",
|
|
9
|
+
"options": {
|
|
10
|
+
"cwd": "<%= projectRoot %>",
|
|
11
|
+
"command": "next build"
|
|
12
|
+
},
|
|
13
|
+
"outputs": ["{workspaceRoot}/<%= projectRoot %>/.next"]
|
|
14
|
+
},
|
|
15
|
+
"dev": {
|
|
16
|
+
"executor": "nx:run-commands",
|
|
17
|
+
"options": {
|
|
18
|
+
"cwd": "<%= projectRoot %>",
|
|
19
|
+
"command": "next dev -p <%= port %>"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"start": {
|
|
23
|
+
"executor": "nx:run-commands",
|
|
24
|
+
"options": {
|
|
25
|
+
"cwd": "<%= projectRoot %>",
|
|
26
|
+
"command": "next start -p <%= port %>"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"lint": {
|
|
30
|
+
"executor": "nx:run-commands",
|
|
31
|
+
"options": {
|
|
32
|
+
"cwd": "<%= projectRoot %>",
|
|
33
|
+
"command": "next lint"
|
|
34
|
+
}
|
|
35
|
+
}<% if (language === 'ts') { %>,
|
|
36
|
+
"type-check": {
|
|
37
|
+
"executor": "nx:run-commands",
|
|
38
|
+
"options": {
|
|
39
|
+
"cwd": "<%= projectRoot %>",
|
|
40
|
+
"command": "tsc --noEmit"
|
|
41
|
+
}
|
|
42
|
+
}<% } %>
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Metadata } from 'next'<% if (styling === 'tailwind') { %>
|
|
2
|
+
import './globals.css'<% } %>
|
|
3
|
+
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
title: '<%= name %>',
|
|
6
|
+
description: 'Generated by KTern Next.js generator',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default function RootLayout({
|
|
10
|
+
children,
|
|
11
|
+
}: {
|
|
12
|
+
children: React.ReactNode
|
|
13
|
+
}) {
|
|
14
|
+
return (
|
|
15
|
+
<html lang="en">
|
|
16
|
+
<body>{children}</body>
|
|
17
|
+
</html>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
content: [
|
|
4
|
+
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
|
|
5
|
+
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
|
|
6
|
+
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
|
|
7
|
+
],
|
|
8
|
+
theme: {
|
|
9
|
+
extend: {
|
|
10
|
+
backgroundImage: {
|
|
11
|
+
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
|
|
12
|
+
'gradient-conic':
|
|
13
|
+
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
plugins: [],
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "es6"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "preserve",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [
|
|
17
|
+
{
|
|
18
|
+
"name": "next"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"baseUrl": ".",
|
|
22
|
+
"paths": {
|
|
23
|
+
"@/*": ["./src/*"]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
|
27
|
+
"exclude": ["node_modules"]
|
|
28
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
|
+
interface CreateNextjsOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
language: string;
|
|
5
|
+
styling: string;
|
|
6
|
+
location?: string;
|
|
7
|
+
port?: number;
|
|
8
|
+
}
|
|
9
|
+
export default function (tree: Tree, options: CreateNextjsOptions): Promise<GeneratorCallback>;
|
|
10
|
+
import type { GeneratorCallback } from '@nx/devkit';
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../packages/create-nextjs/src/generators/create-nextjs/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yBAA+B,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,mBAAmB,8BAyDtE;AAED,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = default_1;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const path = tslib_1.__importStar(require("path"));
|
|
7
|
+
async function default_1(tree, options) {
|
|
8
|
+
const normalized = (0, devkit_1.names)(options.name);
|
|
9
|
+
const appName = normalized.fileName;
|
|
10
|
+
const location = options.location || 'packages/apps/web';
|
|
11
|
+
const projectRoot = `${location}/${appName}`;
|
|
12
|
+
if (tree.exists(projectRoot)) {
|
|
13
|
+
throw new Error(`❌ Next.js app "${appName}" already exists at ${projectRoot}.
|
|
14
|
+
Choose a different name or delete the existing app.`);
|
|
15
|
+
}
|
|
16
|
+
(0, devkit_1.generateFiles)(tree, path.join(__dirname, 'files/nextjs'), projectRoot, {
|
|
17
|
+
...options,
|
|
18
|
+
name: appName,
|
|
19
|
+
projectRoot: projectRoot,
|
|
20
|
+
port: options.port || 3000,
|
|
21
|
+
tmpl: "",
|
|
22
|
+
});
|
|
23
|
+
// Handle JS/TS entry files
|
|
24
|
+
if (options.language === 'js') {
|
|
25
|
+
// Convert TypeScript files to JavaScript
|
|
26
|
+
const tsFiles = [
|
|
27
|
+
'src/app/layout.tsx',
|
|
28
|
+
'src/app/page.tsx',
|
|
29
|
+
'next.config.ts',
|
|
30
|
+
'tailwind.config.ts'
|
|
31
|
+
];
|
|
32
|
+
tsFiles.forEach(file => {
|
|
33
|
+
const tsPath = path.join(projectRoot, file);
|
|
34
|
+
const jsPath = path.join(projectRoot, file.replace('.tsx', '.jsx').replace('.ts', '.js'));
|
|
35
|
+
if (tree.exists(tsPath)) {
|
|
36
|
+
const content = tree.read(tsPath, 'utf-8');
|
|
37
|
+
if (content) {
|
|
38
|
+
// Basic TS to JS conversion
|
|
39
|
+
const jsContent = content
|
|
40
|
+
.replace(/: React\.FC/g, '')
|
|
41
|
+
.replace(/: string/g, '')
|
|
42
|
+
.replace(/: number/g, '')
|
|
43
|
+
.replace(/interface \w+ \{[^}]*\}/g, '')
|
|
44
|
+
.replace(/import.*from ['"]react['"];?/g, "import React from 'react';");
|
|
45
|
+
tree.write(jsPath, jsContent);
|
|
46
|
+
}
|
|
47
|
+
tree.delete(tsPath);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
52
|
+
return printNextSteps(appName, options.language, projectRoot);
|
|
53
|
+
}
|
|
54
|
+
function printNextSteps(appName, language, projectRoot) {
|
|
55
|
+
return () => {
|
|
56
|
+
console.log(`
|
|
57
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
58
|
+
✅ Next.js app "${appName}" created successfully
|
|
59
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
60
|
+
|
|
61
|
+
Next steps:
|
|
62
|
+
cd ${projectRoot}
|
|
63
|
+
pnpm install
|
|
64
|
+
pnpm nx dev ${appName}
|
|
65
|
+
`);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "CreateNextjs",
|
|
4
|
+
"title": "Create Next.js App Options",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the app",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "argv",
|
|
12
|
+
"index": 0
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"language": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Language (js/ts)",
|
|
18
|
+
"default": "ts",
|
|
19
|
+
"enum": [
|
|
20
|
+
"js",
|
|
21
|
+
"ts"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"styling": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Styling solution",
|
|
27
|
+
"default": "tailwind"
|
|
28
|
+
},
|
|
29
|
+
"location": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "Location to generate the app"
|
|
32
|
+
},
|
|
33
|
+
"port": {
|
|
34
|
+
"type": "number",
|
|
35
|
+
"description": "Port number"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"required": [
|
|
39
|
+
"name"
|
|
40
|
+
]
|
|
41
|
+
}
|
package/generators.json
ADDED
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../packages/create-nextjs/src/index.ts"],"names":[],"mappings":""}
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dhayalesh/create-nextjs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"module": "./index.js",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"@org/source": "./src/index.ts",
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"import": "./index.js",
|
|
14
|
+
"default": "./index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"nx": {
|
|
18
|
+
"targets": {
|
|
19
|
+
"build": {
|
|
20
|
+
"executor": "@nx/js:tsc",
|
|
21
|
+
"outputs": [
|
|
22
|
+
"{options.outputPath}"
|
|
23
|
+
],
|
|
24
|
+
"options": {
|
|
25
|
+
"outputPath": "dist/packages/create-nextjs",
|
|
26
|
+
"main": "packages/create-nextjs/src/index.ts",
|
|
27
|
+
"tsConfig": "packages/create-nextjs/tsconfig.lib.json",
|
|
28
|
+
"rootDir": "packages/create-nextjs/src",
|
|
29
|
+
"generatePackageJson": false,
|
|
30
|
+
"assets": [
|
|
31
|
+
{
|
|
32
|
+
"input": "./packages/create-nextjs/src",
|
|
33
|
+
"glob": "**/!(*.ts)",
|
|
34
|
+
"output": "."
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"input": "./packages/create-nextjs/src",
|
|
38
|
+
"glob": "**/*.d.ts",
|
|
39
|
+
"output": "."
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"input": "./packages/create-nextjs",
|
|
43
|
+
"glob": "generators.json",
|
|
44
|
+
"output": "."
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"input": "./packages/create-nextjs",
|
|
48
|
+
"glob": "package.json",
|
|
49
|
+
"output": "."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"input": "./packages/create-nextjs",
|
|
53
|
+
"glob": "README.md",
|
|
54
|
+
"output": "."
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"generators": "./generators.json",
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"tslib": "^2.3.0",
|
|
64
|
+
"@nx/devkit": "^22.3.3"
|
|
65
|
+
}
|
|
66
|
+
}
|