create-nextop-app 0.0.1 → 0.0.3

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/dist/index.js CHANGED
@@ -1,19 +1,18 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const path_1 = __importDefault(require("path"));
10
- const chalk_1 = __importDefault(require("chalk"));
11
- const prompts_1 = __importDefault(require("prompts"));
12
- const child_process_1 = require("child_process");
13
- const program = new commander_1.Command();
2
+ import { Command } from 'commander';
3
+ import fs from 'fs-extra';
4
+ import path from 'path';
5
+ import chalk from 'chalk';
6
+ import prompts from 'prompts';
7
+ import { spawn } from 'child_process';
8
+ import { fileURLToPath } from 'url';
9
+ import { dirname } from 'path';
10
+ const program = new Command();
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = dirname(__filename);
14
13
  function runInstall(projectPath) {
15
14
  return new Promise((resolve, reject) => {
16
- const child = (0, child_process_1.spawn)('npm', ['install'], {
15
+ const child = spawn('npm', ['install'], {
17
16
  cwd: projectPath,
18
17
  stdio: 'inherit',
19
18
  shell: true
@@ -33,7 +32,7 @@ program
33
32
  .action(async (projectDir) => {
34
33
  let targetDir = projectDir;
35
34
  if (!targetDir) {
36
- const response = await (0, prompts_1.default)({
35
+ const response = await prompts({
37
36
  type: 'text',
38
37
  name: 'projectName',
39
38
  message: 'Please type a project name',
@@ -43,32 +42,32 @@ program
43
42
  targetDir = response.projectName;
44
43
  }
45
44
  if (!targetDir) {
46
- console.log(chalk_1.default.yellow('\nProcess canceled.'));
45
+ console.log(chalk.yellow('\nProcess canceled.'));
47
46
  process.exit(0);
48
47
  }
49
- const targetPath = path_1.default.join(process.cwd(), targetDir);
50
- const templatePath = path_1.default.join(__dirname, '../templates/default');
51
- console.log(chalk_1.default.blue(`\n${targetDir} creating...\n`));
48
+ const targetPath = path.join(process.cwd(), targetDir);
49
+ const templatePath = path.join(__dirname, '../templates/default');
50
+ console.log(chalk.blue(`\n${targetDir} creating...\n`));
52
51
  try {
53
- if (fs_extra_1.default.existsSync(targetPath)) {
54
- console.error(chalk_1.default.red(`Error: ${targetDir} already exist.`));
52
+ if (fs.existsSync(targetPath)) {
53
+ console.error(chalk.red(`Error: ${targetDir} already exist.`));
55
54
  process.exit(1);
56
55
  }
57
- console.log(chalk_1.default.gray(`Files creating...`));
58
- await fs_extra_1.default.copy(templatePath, targetPath);
59
- const packPath = path_1.default.join(targetPath, 'package.json');
60
- if (fs_extra_1.default.existsSync(packPath)) {
61
- const pack = await fs_extra_1.default.readJson(packPath);
56
+ console.log(chalk.gray(`Files creating...`));
57
+ await fs.copy(templatePath, targetPath);
58
+ const packPath = path.join(targetPath, 'package.json');
59
+ if (fs.existsSync(packPath)) {
60
+ const pack = await fs.readJson(packPath);
62
61
  pack.name = targetDir;
63
- await fs_extra_1.default.writeJson(packPath, pack, { spaces: 2 });
62
+ await fs.writeJson(packPath, pack, { spaces: 2 });
64
63
  }
65
- console.log(chalk_1.default.cyan('\n Installing...'));
64
+ console.log(chalk.cyan('\n Installing...'));
66
65
  await runInstall(targetPath);
67
- console.log(chalk_1.default.green(`\n Project created succesfully.`));
66
+ console.log(chalk.green(`\n Project created succesfully.`));
68
67
  console.log(`\nBaşlamak için:\n cd ${targetDir} \n npm run dev\n`);
69
68
  }
70
69
  catch (error) {
71
- console.error(chalk_1.default.red(`\n Error ${error}`));
70
+ console.error(chalk.red(`\n Error ${error}`));
72
71
  process.exit(1);
73
72
  }
74
73
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nextop-app",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "NextOP framework starter CLI",
5
5
  "main": "./dist/index.js",
6
6
  "bin": {
@@ -33,6 +33,7 @@
33
33
  "@types/prompts": "^2.4.9"
34
34
  },
35
35
  "files": [
36
- "dist"
36
+ "dist",
37
+ "templates"
37
38
  ]
38
39
  }
@@ -0,0 +1,5 @@
1
+ # NextOP
2
+
3
+ This is a nextop-app project bootstrapped
4
+
5
+ `npx create-next-app app-name`
@@ -0,0 +1,15 @@
1
+ @import "tailwindcss";
2
+
3
+
4
+
5
+ h1 {
6
+ @apply scroll-m-20 text-center text-4xl font-extrabold tracking-tight text-balance
7
+ }
8
+
9
+ h2 {
10
+ @apply scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0
11
+ }
12
+
13
+ p {
14
+ @apply text-xl
15
+ }
@@ -0,0 +1,32 @@
1
+ import { ReactNode } from "react"
2
+ import './global.css'
3
+ import { Metadata } from "next"
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ export const metadata: Metadata = {
12
+ title: 'NextOP',
13
+ description: 'Generated by create nextop app',
14
+ icons: 'favicon.ico'
15
+ }
16
+
17
+
18
+
19
+ export default function RootLayout({
20
+ children
21
+ }: {
22
+ children: ReactNode
23
+ }) {
24
+
25
+ return (
26
+ <html>
27
+ <body>
28
+ {children}
29
+ </body>
30
+ </html>
31
+ )
32
+ }
@@ -0,0 +1,11 @@
1
+ /** type {import('next').NextConfig} */
2
+
3
+
4
+
5
+
6
+
7
+ const nextConfig = {
8
+ output: "standalone"
9
+ }
10
+
11
+ module.exports = nextConfig
@@ -0,0 +1,34 @@
1
+ import Image from 'next/image'
2
+ import Link from 'next/link'
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ export default function Page() {
13
+
14
+ return (
15
+ <main
16
+ className='flex flex-col gap-4 items-center justify-center h-screen'
17
+ >
18
+ <h1
19
+ className='text-xl font-semibold'
20
+ >
21
+ Developed by create-nextop-app
22
+ </h1>
23
+ <Image
24
+ src={'/favicon.png'}
25
+ width={256}
26
+ height={256}
27
+ alt='logo'
28
+ />
29
+ <label>
30
+ For contrubition <Link href={'https://github.com/FlyingTurkman/nextop-app'} className='underline text-lg font-semibold'>NextOP</Link>
31
+ </label>
32
+ </main>
33
+ )
34
+ }
@@ -0,0 +1,54 @@
1
+ import { app, BrowserWindow } from "electron"
2
+ import path from "path"
3
+ import { startNextServer } from "./startNext"
4
+ import { registerWindowHandlers } from "./window"
5
+ import { NextServerHandleType } from "./types"
6
+ import { registerNextOP } from 'nextop-app/main'
7
+
8
+
9
+ let mainWindow: BrowserWindow | null = null
10
+
11
+
12
+
13
+ let nextServer: NextServerHandleType | null = null
14
+
15
+
16
+ app.whenReady().then(async () => {
17
+
18
+ nextServer = await startNextServer(
19
+ process.cwd(),
20
+ !app.isPackaged,
21
+ 3000
22
+ )
23
+
24
+ registerNextOP()
25
+
26
+ mainWindow = new BrowserWindow({
27
+ width: 1200,
28
+ height: 800,
29
+ icon: path.join(__dirname, "favicon.ico"),
30
+ webPreferences: {
31
+ preload: path.join(__dirname, "preload.js"),
32
+ contextIsolation: true,
33
+ nodeIntegration: false
34
+ }
35
+ })
36
+
37
+ mainWindow.setIcon(path.join(__dirname, 'assets', 'favicon.ico'))
38
+
39
+ registerWindowHandlers(mainWindow)
40
+
41
+ await mainWindow.loadURL(`http://localhost:${nextServer.port}`)
42
+
43
+
44
+ })
45
+
46
+
47
+
48
+ app.on("before-quit", async () => {
49
+
50
+ if (nextServer) {
51
+ await nextServer.close()
52
+ }
53
+ })
54
+
@@ -0,0 +1,17 @@
1
+ import { contextBridge, ipcRenderer, MenuItemConstructorOptions } from "electron"
2
+
3
+ contextBridge.exposeInMainWorld("desktop", {
4
+ window: {
5
+ minimize: () => ipcRenderer.invoke("window:minimize"),
6
+ maximize: () => ipcRenderer.invoke("window:maximize"),
7
+ close: () => ipcRenderer.invoke("window:close"),
8
+ isMiximized: () => ipcRenderer.invoke("window:isMaximized")
9
+ },
10
+ fs: {
11
+ readFile: (filePath: string) => ipcRenderer.invoke('fs:readFile', filePath),
12
+ writeFile: (filePath: string, content: string) => ipcRenderer.invoke('fs:writeFile', filePath, content)
13
+ },
14
+ menu: {
15
+ setMenu: (template: MenuItemConstructorOptions[]) => ipcRenderer.send('set-menu', template)
16
+ }
17
+ })
@@ -0,0 +1,41 @@
1
+ import next from 'next'
2
+ import http from 'http'
3
+ import { spawn } from 'child_process'
4
+ import { NextServerHandleType } from './types'
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+ export async function startNextServer(
16
+ dir: string,
17
+ dev: boolean,
18
+ port: number
19
+ ): Promise<NextServerHandleType> {
20
+
21
+ const app = next({ dir, dev })
22
+ const handler = app.getRequestHandler()
23
+
24
+ await app.prepare()
25
+
26
+ const server = http.createServer((req, res) => {
27
+ handler(req, res)
28
+ })
29
+
30
+ await new Promise<void>((resolve) => {
31
+
32
+ server.listen(port, () => resolve())
33
+ })
34
+
35
+ return {
36
+ port,
37
+ close: async () => {
38
+ await new Promise<void>((resolve) => server.close(() => resolve()))
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,4 @@
1
+ export type NextServerHandleType = {
2
+ port: number
3
+ close: () => Promise<void>
4
+ }
@@ -0,0 +1,11 @@
1
+ import { BrowserWindow, ipcMain } from "electron"
2
+
3
+ export function registerWindowHandlers(win: BrowserWindow) {
4
+ ipcMain.handle("window:minimize", () => win.minimize())
5
+
6
+ ipcMain.handle("window:maximize", () => {
7
+ win.isMaximized() ? win.unmaximize() : win.maximize()
8
+ })
9
+
10
+ ipcMain.handle("window:close", () => win.close())
11
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "description": "",
4
+ "main": "dist/electron/main.js",
5
+ "bin": {
6
+ "nextop": "bin/nextop.ts"
7
+ },
8
+ "scripts": {
9
+ "dev": "nextop dev",
10
+ "build": "nextop build"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "@tailwindcss/postcss": "^4.1.18",
17
+ "electron": "^39.2.7",
18
+ "get-port": "^7.1.0",
19
+ "next": "^16.1.0",
20
+ "postcss": "^8.5.6",
21
+ "react": "^19.2.3",
22
+ "react-dom": "^19.2.3",
23
+ "tailwindcss": "^4.1.18",
24
+ "nextop-app": "0.0.1"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^25.0.3",
28
+ "@types/react": "^19.2.7",
29
+ "@types/react-dom": "^19.2.3",
30
+ "tsx": "^4.21.0",
31
+ "typescript": "^5.9.3",
32
+ "cpx": "^1.5.0"
33
+ }
34
+ }
@@ -0,0 +1,6 @@
1
+ const config = {
2
+ plugins: {
3
+ "@tailwindcss/postcss": {},
4
+ },
5
+ };
6
+ export default config;
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "rootDir": "electron",
6
+ "outDir": "dist/electron",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "moduleResolution": "node",
10
+ "sourceMap": true,
11
+ "types": ["node", "electron"],
12
+ "skipLibCheck": true
13
+ },
14
+ "include": ["electron/**/*.ts"]
15
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "nodenext",
4
+ "target": "es2020",
5
+ "types": [],
6
+ "lib": [
7
+ "ES2020",
8
+ "DOM"
9
+ ],
10
+ "esModuleInterop": true,
11
+ "moduleResolution": "nodenext",
12
+ "skipDefaultLibCheck": true,
13
+ "outDir": "dist",
14
+ "rootDir": ".",
15
+ "sourceMap": true,
16
+ "declaration": true,
17
+ "declarationMap": true,
18
+ "noUncheckedIndexedAccess": true,
19
+ "exactOptionalPropertyTypes": true,
20
+ "strict": true,
21
+ "jsx": "react-jsx",
22
+ "verbatimModuleSyntax": false,
23
+ "isolatedModules": true,
24
+ "noUncheckedSideEffectImports": true,
25
+ "moduleDetection": "force",
26
+ "skipLibCheck": true,
27
+ "allowJs": true,
28
+ "noEmit": false,
29
+ "incremental": true,
30
+ "resolveJsonModule": true,
31
+ "plugins": [
32
+ {
33
+ "name": "next"
34
+ }
35
+ ]
36
+ },
37
+ "include": [
38
+ "main.ts",
39
+ "preload.ts",
40
+ "window.ts",
41
+ "types.ts",
42
+ "types.d.ts",
43
+ ".next/types/**/*.ts",
44
+ ".next/dev/types/**/*.ts",
45
+ "electron/**/*.ts",
46
+ "electron/startNext.ts",
47
+ "**/*.d.ts",
48
+ ".next/types/**/*.ts",
49
+ ".next/dev/types/**/*.ts"
50
+ ],
51
+ "exclude": [
52
+ "node_modules",
53
+ "dist",
54
+ ".next"
55
+ ]
56
+ }