create-nexora-next 0.1.0

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.
@@ -0,0 +1,83 @@
1
+ import { run, installCmd } from '../utils/runner.js'
2
+ import { safeStep } from '../utils/safe-step.js'
3
+
4
+ /**
5
+ * @param {string} targetDir
6
+ * @param {'npm'|'pnpm'|'bun'|'yarn'} pm
7
+ * @param {{
8
+ * i18n: boolean,
9
+ * query: boolean,
10
+ * auth: boolean,
11
+ * theming: boolean,
12
+ * animations: boolean,
13
+ * axios: boolean,
14
+ * }} opts
15
+ */
16
+ export async function stepInstallDeps(targetDir, pm, opts) {
17
+ // ── Core dependencies (always) ────────────────────────────────────────────
18
+ const coreDeps = [
19
+ 'zustand',
20
+ 'zod',
21
+ 'react-hook-form',
22
+ 'date-fns',
23
+ '@date-fns/tz',
24
+ 'clsx',
25
+ 'tailwind-merge',
26
+ 'nuqs',
27
+ 'nextjs-toploader',
28
+ 'sileo',
29
+ ]
30
+
31
+ // ── Core devDependencies (always) ─────────────────────────────────────────
32
+ const coreDevDeps = [
33
+ 'prettier',
34
+ 'prettier-plugin-tailwindcss',
35
+ 'babel-plugin-react-compiler',
36
+ ]
37
+
38
+ // ── Feature deps (excluding query persist — installed separately) ──────────
39
+ const featureDeps = []
40
+ const featureDevDeps = []
41
+
42
+ if (opts.theming) featureDeps.push('next-themes')
43
+ if (opts.animations) featureDeps.push('motion', 'gsap')
44
+ if (opts.auth) featureDeps.push('cookies-next')
45
+ if (opts.axios) featureDeps.push('axios')
46
+
47
+ // Install @tanstack/react-query first so persist packages find their peer dep
48
+ if (opts.query) featureDeps.push('@tanstack/react-query')
49
+ if (opts.query) featureDevDeps.push('@tanstack/eslint-plugin-query')
50
+
51
+ await safeStep('Installing core dependencies', () => {
52
+ run(installCmd(pm, coreDeps), targetDir)
53
+ })
54
+
55
+ await safeStep('Installing core devDependencies', () => {
56
+ run(installCmd(pm, coreDevDeps, true), targetDir)
57
+ })
58
+
59
+ if (featureDeps.length > 0) {
60
+ await safeStep('Installing feature dependencies', () => {
61
+ run(installCmd(pm, featureDeps), targetDir)
62
+ })
63
+ }
64
+
65
+ if (featureDevDeps.length > 0) {
66
+ await safeStep('Installing feature devDependencies', () => {
67
+ run(installCmd(pm, featureDevDeps, true), targetDir)
68
+ })
69
+ }
70
+
71
+ // ── TanStack persist packages — installed after react-query is resolved ───
72
+ if (opts.query) {
73
+ await safeStep('Installing TanStack Query persist plugins', () => {
74
+ run(
75
+ installCmd(pm, [
76
+ '@tanstack/react-query-persist-client',
77
+ '@tanstack/query-async-storage-persister',
78
+ ]),
79
+ targetDir,
80
+ )
81
+ })
82
+ }
83
+ }
@@ -0,0 +1,59 @@
1
+ import path from 'path'
2
+ import { run, installCmd, execCmd } from '../utils/runner.js'
3
+ import { writeFile } from '../utils/writer.js'
4
+ import { safeStep } from '../utils/safe-step.js'
5
+
6
+ const preCommitHook = `#!/usr/bin/env sh
7
+ echo -e "🚀 Running pre-commit checks...\\n"
8
+
9
+ echo "📝 Linting your code..."
10
+ bun lint
11
+
12
+ if [ $? -ne 0 ]; then
13
+ echo -e "❌ Lint failed. Fix the issues above.\\n"
14
+ exit 1
15
+ fi
16
+ echo -e "✅ Lint passed!\\n"
17
+
18
+ echo "🔍 Checking types..."
19
+ bun type-check
20
+
21
+ if [ $? -ne 0 ]; then
22
+ echo -e "❌ Type check failed. Fix the issues above.\\n"
23
+ exit 1
24
+ fi
25
+ echo -e "✅ Types are solid!\\n"
26
+
27
+ echo "🏗️ Building project..."
28
+ bun run build
29
+
30
+ if [ $? -ne 0 ]; then
31
+ echo -e "❌ Build failed. Fix the issues above.\\n"
32
+ exit 1
33
+ fi
34
+ echo -e "✅ Build successful!\\n"
35
+
36
+ TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
37
+ echo -e "🎉 All checks passed! Committing...\\n"
38
+ echo -e "⏰ Commit time: $TIMESTAMP\\n"
39
+ `
40
+
41
+ /**
42
+ * @param {string} targetDir
43
+ * @param {'npm'|'pnpm'|'bun'|'yarn'} pm
44
+ */
45
+ export async function stepSetupHusky(targetDir, pm) {
46
+ await safeStep('Installing Husky', () => {
47
+ run(installCmd(pm, ['husky'], true), targetDir)
48
+ })
49
+
50
+ await safeStep('Initialising Husky', () => {
51
+ const x = execCmd(pm)
52
+ run(`${x} husky init`, targetDir)
53
+ })
54
+
55
+ await safeStep('Writing pre-commit hook', () => {
56
+ const hookPath = path.join(targetDir, '.husky', 'pre-commit')
57
+ writeFile(hookPath, preCommitHook)
58
+ })
59
+ }
@@ -0,0 +1,15 @@
1
+ import path from 'path'
2
+ import { writeFile } from '../utils/writer.js'
3
+ import { safeStep } from '../utils/safe-step.js'
4
+ import { axiosClientTs, axiosServerTs } from '../templates/files.js'
5
+
6
+ /**
7
+ * @param {string} targetDir
8
+ */
9
+ export async function stepSetupAxios(targetDir) {
10
+ await safeStep('Writing axios client/server instances', () => {
11
+ const p = (...parts) => path.join(targetDir, ...parts)
12
+ writeFile(p('src', 'lib', 'axios', 'axios.client.ts'), axiosClientTs)
13
+ writeFile(p('src', 'lib', 'axios', 'axios.server.ts'), axiosServerTs)
14
+ })
15
+ }
@@ -0,0 +1,22 @@
1
+ import path from 'path'
2
+ import fs from 'fs'
3
+ import { safeStep } from '../utils/safe-step.js'
4
+
5
+ /**
6
+ * Patches the project's package.json scripts section after
7
+ * Next.js + deps are installed.
8
+ * @param {string} targetDir
9
+ */
10
+ export async function stepPatchPackageJson(targetDir) {
11
+ await safeStep('Patching package.json scripts', () => {
12
+ const pkgPath = path.join(targetDir, 'package.json')
13
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
14
+
15
+ pkg.scripts = {
16
+ ...pkg.scripts,
17
+ 'type-check': 'tsc --pretty --noEmit',
18
+ }
19
+
20
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8')
21
+ })
22
+ }