create-nelsonlai-app 0.0.0-stage → 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.
- package/README.md +37 -2
- package/dist/actions/install-dependencies.js +29 -0
- package/dist/actions/merge-package-json.js +30 -0
- package/dist/cli.js +42 -0
- package/dist/core/feature-resolver.js +53 -0
- package/dist/core/project-directory.js +47 -0
- package/dist/features/agents/index.js +8 -0
- package/dist/features/cspell/index.js +15 -0
- package/dist/features/dependabot/index.js +8 -0
- package/dist/features/github-actions/index.js +8 -0
- package/dist/features/knip/index.js +10 -0
- package/dist/features/lefthook/index.js +25 -0
- package/dist/features/oxfmt/index.js +22 -0
- package/dist/features/oxlint/index.js +26 -0
- package/dist/features/react-compiler/index.js +14 -0
- package/dist/features/tailwindcss/index.js +20 -0
- package/dist/features/varlock/index.js +20 -0
- package/dist/features/vscode/index.js +8 -0
- package/dist/package.json.js +3 -0
- package/dist/plopfile.js +79 -0
- package/dist/prompts/project.js +49 -0
- package/package.json +51 -3
- package/src/features/agents/templates/AGENTS.md.hbs +11 -0
- package/src/features/cspell/templates/.cspell/names.txt.hbs +10 -0
- package/src/features/cspell/templates/.cspell/tech-terms.txt.hbs +9 -0
- package/src/features/cspell/templates/cspell.config.yaml.hbs +28 -0
- package/src/features/dependabot/templates/.github/dependabot.yml.hbs +38 -0
- package/src/features/github-actions/templates/.github/workflows/ci.yml.hbs +77 -0
- package/src/features/knip/templates/knip.config.ts.hbs +11 -0
- package/src/features/lefthook/templates/lefthook.yml.hbs +17 -0
- package/src/features/oxfmt/templates/oxfmt.config.ts.hbs +3 -0
- package/src/features/oxlint/templates/oxlint.config.ts.hbs +12 -0
- package/src/features/tailwindcss/nextjs/templates/postcss.config.mjs.hbs +5 -0
- package/src/features/tailwindcss/nextjs/templates/src/app/globals.css.hbs +1 -0
- package/src/features/varlock/templates/.env.schema.hbs +6 -0
- package/src/features/vscode/templates/.vscode/extensions.json.hbs +7 -0
- package/src/features/vscode/templates/.vscode/settings.json.hbs +36 -0
- package/src/frameworks/nextjs/templates/.gitignore.hbs +21 -0
- package/src/frameworks/nextjs/templates/README.md.hbs +26 -0
- package/src/frameworks/nextjs/templates/next.config.ts.hbs +21 -0
- package/src/frameworks/nextjs/templates/package.json.hbs +22 -0
- package/src/frameworks/nextjs/templates/pnpm-workspace.yaml.hbs +15 -0
- package/src/frameworks/nextjs/templates/src/app/layout.tsx.hbs +21 -0
- package/src/frameworks/nextjs/templates/src/app/page.tsx.hbs +9 -0
- package/src/frameworks/nextjs/templates/tsconfig.json.hbs +11 -0
- package/src/frameworks/tanstack-start/templates/.gitignore.hbs +23 -0
- package/src/frameworks/tanstack-start/templates/README.md.hbs +23 -0
- package/src/frameworks/tanstack-start/templates/package.json.hbs +25 -0
- package/src/frameworks/tanstack-start/templates/pnpm-workspace.yaml.hbs +10 -0
- package/src/frameworks/tanstack-start/templates/src/components/main-layout.tsx.hbs +9 -0
- package/src/frameworks/tanstack-start/templates/src/router.tsx.hbs +14 -0
- package/src/frameworks/tanstack-start/templates/src/routes/__root.tsx.hbs +35 -0
- package/src/frameworks/tanstack-start/templates/src/routes/_main/index.tsx.hbs +9 -0
- package/src/frameworks/tanstack-start/templates/src/routes/_main/route.tsx.hbs +15 -0
- package/src/frameworks/tanstack-start/templates/src/styles/index.css.hbs +3 -0
- package/src/frameworks/tanstack-start/templates/tsconfig.json.hbs +11 -0
- package/src/frameworks/tanstack-start/templates/vite.config.ts.hbs +27 -0
package/README.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-nelsonlai-app
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create a TypeScript app with the Next.js App Router or TanStack Start. Choose which tools to include, such as Tailwind CSS, Oxlint, and GitHub Actions.
|
|
4
|
+
|
|
5
|
+
You'll need Node.js 24.15.0 or later and pnpm to run the generated app.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm create nelsonlai-app my-app
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Choose your framework and tools when prompted. Once the CLI installs the dependencies, start the development server in your new project.
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
cd my-app
|
|
17
|
+
pnpm dev
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Use `.` in place of `my-app` to create the project in the current directory. The directory must be empty.
|
|
21
|
+
|
|
22
|
+
### Noninteractive usage
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
pnpm create nelsonlai-app my-app --framework tanstack-start --features tailwindcss,oxlint --git --no-install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
With `--no-install`, the CLI prints the remaining setup commands. Run `pnpm create nelsonlai-app --help` for all options and feature names.
|
|
29
|
+
|
|
30
|
+
## Local development
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
pnpm install
|
|
34
|
+
pnpm build
|
|
35
|
+
pnpm start --help
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Use `pnpm dev` to rebuild the CLI as you edit and `pnpm test` to run the generator tests.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
// src/actions/install-dependencies.ts
|
|
4
|
+
function formatSetupCommands(directory, commands) {
|
|
5
|
+
const steps = commands.map((args) => ` pnpm ${args.join(" ")}`);
|
|
6
|
+
const relative = path.relative(process.cwd(), directory);
|
|
7
|
+
if (relative) {
|
|
8
|
+
if (process.platform === "win32") steps.unshift(` Set-Location -LiteralPath '${relative.replaceAll("'", "''")}'`);
|
|
9
|
+
else {
|
|
10
|
+
const target = relative.startsWith("-") ? `./${relative}` : relative;
|
|
11
|
+
const quoted = /^[\w./-]+$/.test(target) ? target : `'${target.replaceAll("'", "'\\''")}'`;
|
|
12
|
+
steps.unshift(` cd ${quoted}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return steps.join("\n");
|
|
16
|
+
}
|
|
17
|
+
async function installDependencies(directory, commands) {
|
|
18
|
+
for (const [index, args] of commands.entries()) try {
|
|
19
|
+
await execa("pnpm", args, {
|
|
20
|
+
cwd: directory,
|
|
21
|
+
stdio: "inherit"
|
|
22
|
+
});
|
|
23
|
+
} catch (error) {
|
|
24
|
+
const remaining = formatSetupCommands(directory, commands.slice(index));
|
|
25
|
+
throw new Error(`${String(error)}\nTo resume setup:\n${remaining}`, { cause: error });
|
|
26
|
+
}
|
|
27
|
+
return "Dependency and tool setup complete";
|
|
28
|
+
}
|
|
29
|
+
export { formatSetupCommands, installDependencies };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { packageManager } from "../package.json.js";
|
|
4
|
+
// src/actions/merge-package-json.ts
|
|
5
|
+
async function mergePackageJson(directory, features) {
|
|
6
|
+
const file = path.join(directory, "package.json");
|
|
7
|
+
const manifest = JSON.parse(await readFile(file, "utf-8"));
|
|
8
|
+
manifest.engines ??= {};
|
|
9
|
+
manifest.engines.node ??= ">=24.15.0";
|
|
10
|
+
manifest.packageManager ??= packageManager;
|
|
11
|
+
manifest.scripts ??= {};
|
|
12
|
+
manifest.scripts.typecheck ??= "tsc --noEmit";
|
|
13
|
+
for (const feature of features) {
|
|
14
|
+
if (feature.packageType) {
|
|
15
|
+
if (manifest.type && manifest.type !== feature.packageType) throw new Error(`Cannot add ${feature.name}: its config requires package.json type "${feature.packageType}".`);
|
|
16
|
+
manifest.type = feature.packageType;
|
|
17
|
+
}
|
|
18
|
+
for (const field of [
|
|
19
|
+
"dependencies",
|
|
20
|
+
"devDependencies",
|
|
21
|
+
"scripts"
|
|
22
|
+
]) for (const [key, value] of Object.entries(feature[field] ?? {})) {
|
|
23
|
+
const entries = manifest[field] ??= {};
|
|
24
|
+
if (Object.hasOwn(entries, key) && entries[key] !== value) throw new Error(`Cannot add ${feature.name}: package.json already defines ${field}.${key}.`);
|
|
25
|
+
entries[key] = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
await writeFile(file, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
29
|
+
}
|
|
30
|
+
export { mergePackageJson };
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { mkdir, mkdtempDisposable } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { Command } from "commander";
|
|
7
|
+
import nodePlop from "node-plop";
|
|
8
|
+
import { defaultFeatureNames, features, frameworks } from "./core/feature-resolver.js";
|
|
9
|
+
// src/cli.ts
|
|
10
|
+
const featureChoices = features.map(({ name }) => name);
|
|
11
|
+
const program = new Command("create-nelsonlai-app").description("Scaffold a Next.js or TanStack Start project.").argument("[project-directory]", "Path to the project directory").option("--framework <name>", `Project framework: ${frameworks.join(" or ")}`).option("--features <list>", `Comma-separated features, or "" for none. Choices: ${featureChoices.join(", ")}`).option("--git", "Initialize a Git repository").option("--no-git", "Skip Git initialization").option("--install", "Install dependencies with pnpm and run tool setup").option("--no-install", "Skip installation and print the setup commands").parse();
|
|
12
|
+
const options = program.opts();
|
|
13
|
+
try {
|
|
14
|
+
const directory = process.cwd();
|
|
15
|
+
const generator = (await nodePlop(path.join(import.meta.dirname, "plopfile.js"), {
|
|
16
|
+
destBasePath: directory,
|
|
17
|
+
force: false
|
|
18
|
+
})).getGenerator("project");
|
|
19
|
+
const answers = await generator.runPrompts([
|
|
20
|
+
program.args[0] ?? "_",
|
|
21
|
+
options.framework ?? "_",
|
|
22
|
+
options.features ?? (process.stdin.isTTY ? "_" : defaultFeatureNames.join(",")),
|
|
23
|
+
options.git?.toString() ?? "_",
|
|
24
|
+
options.install?.toString() ?? "_"
|
|
25
|
+
]);
|
|
26
|
+
const destination = path.resolve(directory, answers.projectDirectory);
|
|
27
|
+
const stagingParent = existsSync(destination) ? tmpdir() : path.dirname(destination);
|
|
28
|
+
await mkdir(stagingParent, { recursive: true });
|
|
29
|
+
await using staging = await mkdtempDisposable(path.join(stagingParent, ".create-nelsonlai-app-"));
|
|
30
|
+
const { failures } = await generator.runActions({
|
|
31
|
+
...answers,
|
|
32
|
+
name: path.basename(destination),
|
|
33
|
+
destination,
|
|
34
|
+
staging: path.join(staging.path, "project")
|
|
35
|
+
}, { onComment: console.log });
|
|
36
|
+
const [failure] = failures;
|
|
37
|
+
if (failure) throw new Error(failure.error || failure.message);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
40
|
+
process.exitCode = 1;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { agents } from "../features/agents/index.js";
|
|
2
|
+
import { cspell } from "../features/cspell/index.js";
|
|
3
|
+
import { dependabot } from "../features/dependabot/index.js";
|
|
4
|
+
import { githubActions } from "../features/github-actions/index.js";
|
|
5
|
+
import { knip } from "../features/knip/index.js";
|
|
6
|
+
import { lefthook } from "../features/lefthook/index.js";
|
|
7
|
+
import { oxfmt } from "../features/oxfmt/index.js";
|
|
8
|
+
import { oxlint } from "../features/oxlint/index.js";
|
|
9
|
+
import { reactCompiler } from "../features/react-compiler/index.js";
|
|
10
|
+
import { tailwindcss } from "../features/tailwindcss/index.js";
|
|
11
|
+
import { varlock } from "../features/varlock/index.js";
|
|
12
|
+
import { vscode } from "../features/vscode/index.js";
|
|
13
|
+
// src/core/feature-resolver.ts
|
|
14
|
+
const frameworks = ["nextjs", "tanstack-start"];
|
|
15
|
+
const features = [
|
|
16
|
+
oxlint,
|
|
17
|
+
oxfmt,
|
|
18
|
+
cspell,
|
|
19
|
+
knip,
|
|
20
|
+
varlock,
|
|
21
|
+
lefthook,
|
|
22
|
+
agents,
|
|
23
|
+
tailwindcss,
|
|
24
|
+
reactCompiler,
|
|
25
|
+
githubActions,
|
|
26
|
+
dependabot,
|
|
27
|
+
vscode
|
|
28
|
+
];
|
|
29
|
+
const defaultFeatureNames = features.filter(({ checked }) => checked).map(({ name }) => name);
|
|
30
|
+
function resolveFeatures(framework, names) {
|
|
31
|
+
if (!frameworks.includes(framework)) throw new Error(`Unknown framework: ${framework}`);
|
|
32
|
+
return [...new Set(names)].map((name) => {
|
|
33
|
+
const feature = features.find((item) => item.name === name);
|
|
34
|
+
if (!feature) throw new Error(`Unknown feature: ${name}`);
|
|
35
|
+
if (!feature.frameworks.includes(framework)) throw new Error(`${name} does not support ${framework}.`);
|
|
36
|
+
const conflict = feature.conflicts?.find((other) => names.includes(other));
|
|
37
|
+
if (conflict) throw new Error(`${name} conflicts with ${conflict}.`);
|
|
38
|
+
const packages = feature.additionalPackages?.(framework, names);
|
|
39
|
+
if (!packages) return feature;
|
|
40
|
+
return {
|
|
41
|
+
...feature,
|
|
42
|
+
dependencies: {
|
|
43
|
+
...feature.dependencies,
|
|
44
|
+
...packages.dependencies
|
|
45
|
+
},
|
|
46
|
+
devDependencies: {
|
|
47
|
+
...feature.devDependencies,
|
|
48
|
+
...packages.devDependencies
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export { defaultFeatureNames, features, frameworks, resolveFeatures };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { constants, copyFileSync, existsSync, lstatSync, mkdirSync, readdirSync, renameSync, rmdirSync, unlinkSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
// src/core/project-directory.ts
|
|
4
|
+
function validateProjectDirectory(input, base = process.cwd()) {
|
|
5
|
+
if (!input.trim()) return "Enter a project directory.";
|
|
6
|
+
const destination = path.resolve(base, input);
|
|
7
|
+
const name = path.basename(destination);
|
|
8
|
+
if (name.length > 214 || !/^[a-z0-9][a-z0-9._-]*$/.test(name)) return "Use a lowercase project name starting with a letter or number for the final directory name.";
|
|
9
|
+
const entry = lstatSync(destination, { throwIfNoEntry: false });
|
|
10
|
+
if (entry && !entry.isDirectory()) return `The destination "${destination}" is not a directory.`;
|
|
11
|
+
if (entry && readdirSync(destination).length > 0) return `The directory "${destination}" is not empty.`;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
function writeProjectFiles(staging, destination) {
|
|
15
|
+
const validation = validateProjectDirectory(destination);
|
|
16
|
+
if (validation !== true) throw new Error(validation);
|
|
17
|
+
if (!existsSync(destination)) {
|
|
18
|
+
renameSync(staging, destination);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const rollback = [];
|
|
22
|
+
try {
|
|
23
|
+
const entries = readdirSync(staging, {
|
|
24
|
+
recursive: true,
|
|
25
|
+
withFileTypes: true
|
|
26
|
+
});
|
|
27
|
+
for (const entry of entries.toSorted((a, b) => a.parentPath.length - b.parentPath.length)) {
|
|
28
|
+
const source = path.join(entry.parentPath, entry.name);
|
|
29
|
+
const target = path.join(destination, path.relative(staging, source));
|
|
30
|
+
if (entry.isDirectory()) {
|
|
31
|
+
mkdirSync(target);
|
|
32
|
+
rollback.push(() => {
|
|
33
|
+
rmdirSync(target);
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
copyFileSync(source, target, constants.COPYFILE_EXCL);
|
|
37
|
+
rollback.push(() => {
|
|
38
|
+
unlinkSync(target);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
for (const undo of rollback.toReversed()) undo();
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export { validateProjectDirectory, writeProjectFiles };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/features/cspell/index.ts
|
|
2
|
+
const cspell = {
|
|
3
|
+
name: "cspell",
|
|
4
|
+
vscodeExtension: "streetsidesoftware.code-spell-checker",
|
|
5
|
+
description: "Check spelling in source and documentation",
|
|
6
|
+
frameworks: ["nextjs", "tanstack-start"],
|
|
7
|
+
checked: true,
|
|
8
|
+
devDependencies: { cspell: "10.6.0" },
|
|
9
|
+
scripts: { spellcheck: "cspell lint --no-progress" },
|
|
10
|
+
preCommit: {
|
|
11
|
+
glob: "**/*",
|
|
12
|
+
run: "pnpm cspell lint --no-progress --no-must-find-files --files {staged_files}"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export { cspell };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/features/knip/index.ts
|
|
2
|
+
const knip = {
|
|
3
|
+
name: "knip",
|
|
4
|
+
description: "Find unused files, exports, and dependencies",
|
|
5
|
+
frameworks: ["nextjs", "tanstack-start"],
|
|
6
|
+
checked: true,
|
|
7
|
+
devDependencies: { knip: "6.49.0" },
|
|
8
|
+
scripts: { knip: "knip" }
|
|
9
|
+
};
|
|
10
|
+
export { knip };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parseDocument } from "yaml";
|
|
4
|
+
// src/features/lefthook/index.ts
|
|
5
|
+
const lefthook = {
|
|
6
|
+
name: "lefthook",
|
|
7
|
+
description: "Run selected checks on staged files",
|
|
8
|
+
frameworks: ["nextjs", "tanstack-start"],
|
|
9
|
+
checked: true,
|
|
10
|
+
devDependencies: { lefthook: "2.2.4" },
|
|
11
|
+
scripts: { "hooks:install": "lefthook install" }
|
|
12
|
+
};
|
|
13
|
+
async function configureLefthook(directory) {
|
|
14
|
+
const file = path.join(directory, "pnpm-workspace.yaml");
|
|
15
|
+
const contents = await readFile(file, "utf-8").catch((error) => {
|
|
16
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return "";
|
|
17
|
+
throw error;
|
|
18
|
+
});
|
|
19
|
+
const workspace = parseDocument(contents);
|
|
20
|
+
const [error] = workspace.errors;
|
|
21
|
+
if (error) throw error;
|
|
22
|
+
workspace.setIn(["allowBuilds", "lefthook"], false);
|
|
23
|
+
await writeFile(file, workspace.toString());
|
|
24
|
+
}
|
|
25
|
+
export { configureLefthook, lefthook };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/features/oxfmt/index.ts
|
|
2
|
+
const oxfmt = {
|
|
3
|
+
name: "oxfmt",
|
|
4
|
+
vscodeExtension: "oxc.oxc-vscode",
|
|
5
|
+
description: "Format source files",
|
|
6
|
+
frameworks: ["nextjs", "tanstack-start"],
|
|
7
|
+
checked: true,
|
|
8
|
+
packageType: "module",
|
|
9
|
+
devDependencies: {
|
|
10
|
+
"@nelsonlaidev/oxfmt-config": "0.3.1",
|
|
11
|
+
oxfmt: "0.80.0"
|
|
12
|
+
},
|
|
13
|
+
scripts: {
|
|
14
|
+
format: "oxfmt",
|
|
15
|
+
"format:check": "oxfmt --check"
|
|
16
|
+
},
|
|
17
|
+
preCommit: {
|
|
18
|
+
glob: "**/*",
|
|
19
|
+
run: "pnpm oxfmt --check --no-error-on-unmatched-pattern {staged_files}"
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export { oxfmt };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/features/oxlint/index.ts
|
|
2
|
+
const oxlint = {
|
|
3
|
+
name: "oxlint",
|
|
4
|
+
vscodeExtension: "oxc.oxc-vscode",
|
|
5
|
+
description: "Lint JavaScript and TypeScript",
|
|
6
|
+
frameworks: ["nextjs", "tanstack-start"],
|
|
7
|
+
checked: true,
|
|
8
|
+
packageType: "module",
|
|
9
|
+
devDependencies: {
|
|
10
|
+
"@eslint-react/eslint-plugin": "5.30.7",
|
|
11
|
+
"@nelsonlaidev/oxlint-config": "1.3.1",
|
|
12
|
+
"eslint-plugin-react-hooks": "7.1.1",
|
|
13
|
+
oxlint: "1.95.0",
|
|
14
|
+
"oxlint-tsgolint": "7.0.2009"
|
|
15
|
+
},
|
|
16
|
+
additionalPackages: (_framework, selected) => selected.includes("tailwindcss") ? { devDependencies: { "eslint-plugin-better-tailwindcss": "4.11.0" } } : void 0,
|
|
17
|
+
scripts: {
|
|
18
|
+
lint: "oxlint",
|
|
19
|
+
"lint:fix": "oxlint --fix"
|
|
20
|
+
},
|
|
21
|
+
preCommit: {
|
|
22
|
+
glob: "**/*.{js,jsx,mjs,cjs,ts,tsx,mts,cts}",
|
|
23
|
+
run: "pnpm oxlint {staged_files}"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export { oxlint };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/features/react-compiler/index.ts
|
|
2
|
+
const reactCompiler = {
|
|
3
|
+
name: "react-compiler",
|
|
4
|
+
description: "Enable automatic memoization with React Compiler",
|
|
5
|
+
frameworks: ["nextjs", "tanstack-start"],
|
|
6
|
+
checked: true,
|
|
7
|
+
additionalPackages: (framework) => {
|
|
8
|
+
switch (framework) {
|
|
9
|
+
case "nextjs": return { devDependencies: { "babel-plugin-react-compiler": "1.0.0" } };
|
|
10
|
+
case "tanstack-start": return { devDependencies: { "oxc-transform-react": "0.156.0" } };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export { reactCompiler };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/features/tailwindcss/index.ts
|
|
2
|
+
const tailwindStylesheets = {
|
|
3
|
+
nextjs: "src/app/globals.css",
|
|
4
|
+
"tanstack-start": "src/styles/index.css"
|
|
5
|
+
};
|
|
6
|
+
const tailwindcss = {
|
|
7
|
+
name: "tailwindcss",
|
|
8
|
+
vscodeExtension: "bradlc.vscode-tailwindcss",
|
|
9
|
+
description: "Style the app with Tailwind CSS",
|
|
10
|
+
frameworks: ["nextjs", "tanstack-start"],
|
|
11
|
+
checked: true,
|
|
12
|
+
devDependencies: { tailwindcss: "4.3.5" },
|
|
13
|
+
additionalPackages: (framework) => {
|
|
14
|
+
switch (framework) {
|
|
15
|
+
case "nextjs": return { devDependencies: { "@tailwindcss/postcss": "4.3.5" } };
|
|
16
|
+
case "tanstack-start": return { devDependencies: { "@tailwindcss/vite": "4.3.5" } };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export { tailwindStylesheets, tailwindcss };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/features/varlock/index.ts
|
|
2
|
+
const varlock = {
|
|
3
|
+
name: "varlock",
|
|
4
|
+
vscodeExtension: "varlock.env-spec-language",
|
|
5
|
+
description: "Validate environment variables against a schema",
|
|
6
|
+
frameworks: ["nextjs", "tanstack-start"],
|
|
7
|
+
checked: true,
|
|
8
|
+
dependencies: { varlock: "1.25.0" },
|
|
9
|
+
additionalPackages: (framework) => {
|
|
10
|
+
switch (framework) {
|
|
11
|
+
case "nextjs": return { dependencies: { "@varlock/nextjs-integration": "2.0.1" } };
|
|
12
|
+
case "tanstack-start": return { devDependencies: { "@varlock/vite-integration": "1.5.6" } };
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
scripts: {
|
|
16
|
+
"env:check": "varlock load",
|
|
17
|
+
"env:generate": "varlock codegen"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export { varlock };
|
package/dist/plopfile.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
import { formatSetupCommands, installDependencies } from "./actions/install-dependencies.js";
|
|
3
|
+
import { mergePackageJson } from "./actions/merge-package-json.js";
|
|
4
|
+
import { resolveFeatures } from "./core/feature-resolver.js";
|
|
5
|
+
import { writeProjectFiles } from "./core/project-directory.js";
|
|
6
|
+
import { configureLefthook } from "./features/lefthook/index.js";
|
|
7
|
+
import { tailwindStylesheets } from "./features/tailwindcss/index.js";
|
|
8
|
+
import { projectPrompts } from "./prompts/project.js";
|
|
9
|
+
// src/plopfile.ts
|
|
10
|
+
function registerProject(plop) {
|
|
11
|
+
const base = plop.getDestBasePath();
|
|
12
|
+
plop.setGenerator("project", {
|
|
13
|
+
description: "Create a Next.js or TanStack Start project",
|
|
14
|
+
prompts: projectPrompts(base),
|
|
15
|
+
actions(answers) {
|
|
16
|
+
if (!answers) throw new Error("Missing project answers.");
|
|
17
|
+
const { name, destination, framework, features, git, install, staging } = answers;
|
|
18
|
+
const selected = resolveFeatures(framework, features);
|
|
19
|
+
const tools = new Set(selected.map((feature) => feature.name));
|
|
20
|
+
const vscodeExtensions = [...new Set(selected.flatMap((feature) => feature.vscodeExtension ?? []))].toSorted();
|
|
21
|
+
const tailwindcss = tools.has("tailwindcss");
|
|
22
|
+
const actions = [`Creating ${name} with ${framework}...`];
|
|
23
|
+
const templateFolders = [`frameworks/${framework}`, ...selected.map(({ name }) => `features/${name}`)];
|
|
24
|
+
if (framework === "nextjs" && tailwindcss) templateFolders.push("features/tailwindcss/nextjs");
|
|
25
|
+
for (const folder of templateFolders) {
|
|
26
|
+
const templateBase = `../src/${folder}/templates`;
|
|
27
|
+
actions.push({
|
|
28
|
+
type: "addMany",
|
|
29
|
+
base: templateBase,
|
|
30
|
+
templateFiles: `${templateBase}/**/*.hbs`,
|
|
31
|
+
destination: "{{{staging}}}",
|
|
32
|
+
globOptions: { dot: true },
|
|
33
|
+
data: {
|
|
34
|
+
checks: selected.filter((feature) => feature.preCommit),
|
|
35
|
+
nextjs: framework === "nextjs",
|
|
36
|
+
tanstackStart: framework === "tanstack-start",
|
|
37
|
+
oxlint: tools.has("oxlint"),
|
|
38
|
+
oxfmt: tools.has("oxfmt"),
|
|
39
|
+
cspell: tools.has("cspell"),
|
|
40
|
+
knip: tools.has("knip"),
|
|
41
|
+
varlock: tools.has("varlock"),
|
|
42
|
+
lefthook: tools.has("lefthook"),
|
|
43
|
+
reactCompiler: tools.has("react-compiler"),
|
|
44
|
+
githubActions: tools.has("github-actions"),
|
|
45
|
+
vscode: tools.has("vscode"),
|
|
46
|
+
vscodeExtensions,
|
|
47
|
+
tailwindcss,
|
|
48
|
+
tailwindStylesheet: tailwindStylesheets[framework]
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
actions.push(async () => {
|
|
53
|
+
await mergePackageJson(staging, selected);
|
|
54
|
+
if (tools.has("lefthook")) await configureLefthook(staging);
|
|
55
|
+
writeProjectFiles(staging, destination);
|
|
56
|
+
return "Project files created";
|
|
57
|
+
});
|
|
58
|
+
if (git) actions.push(async () => {
|
|
59
|
+
await execa("git", ["init", "--quiet"], { cwd: destination });
|
|
60
|
+
return "Git initialized";
|
|
61
|
+
});
|
|
62
|
+
const commands = [["install"]];
|
|
63
|
+
if (tools.has("varlock")) commands.push(["run", "env:generate"]);
|
|
64
|
+
if (framework === "tanstack-start") commands.push(["build"]);
|
|
65
|
+
if (framework === "nextjs") commands.push([
|
|
66
|
+
"exec",
|
|
67
|
+
"next",
|
|
68
|
+
"typegen"
|
|
69
|
+
]);
|
|
70
|
+
if (tools.has("oxfmt")) commands.push(["run", "format"]);
|
|
71
|
+
if (git && tools.has("lefthook")) commands.push(["run", "hooks:install"]);
|
|
72
|
+
if (install) actions.push("Installing dependencies with pnpm...", async () => installDependencies(destination, commands));
|
|
73
|
+
const steps = formatSetupCommands(destination, [...install ? [] : commands, ["dev"]]);
|
|
74
|
+
actions.push(`\nCreated ${name} in ${destination}.\n\n${steps}`);
|
|
75
|
+
return actions;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export { registerProject as default };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { features } from "../core/feature-resolver.js";
|
|
2
|
+
import { validateProjectDirectory } from "../core/project-directory.js";
|
|
3
|
+
// src/prompts/project.ts
|
|
4
|
+
function projectPrompts(base) {
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
type: "input",
|
|
8
|
+
name: "projectDirectory",
|
|
9
|
+
message: "Project directory",
|
|
10
|
+
default: "my-app",
|
|
11
|
+
validate: (input) => validateProjectDirectory(input, base)
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: "list",
|
|
15
|
+
name: "framework",
|
|
16
|
+
message: "Framework",
|
|
17
|
+
choices: [{
|
|
18
|
+
name: "Next.js",
|
|
19
|
+
value: "nextjs"
|
|
20
|
+
}, {
|
|
21
|
+
name: "TanStack Start",
|
|
22
|
+
value: "tanstack-start"
|
|
23
|
+
}]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "checkbox",
|
|
27
|
+
name: "features",
|
|
28
|
+
message: "Project features",
|
|
29
|
+
choices: features.map(({ name, description, checked }) => ({
|
|
30
|
+
name: `${name} — ${description}`,
|
|
31
|
+
value: name,
|
|
32
|
+
checked
|
|
33
|
+
}))
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "confirm",
|
|
37
|
+
name: "git",
|
|
38
|
+
message: "Initialize Git?",
|
|
39
|
+
default: true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: "confirm",
|
|
43
|
+
name: "install",
|
|
44
|
+
message: "Install dependencies with pnpm?",
|
|
45
|
+
default: true
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
export { projectPrompts };
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nelsonlai-app",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffold a Next.js or TanStack Start app with your choice of development tools.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/nelsonlaidev/create-nelsonlai-app.git"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"create-nelsonlai-app": "dist/cli.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"src/**/templates/**/*.hbs"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"commander": "15.1.0",
|
|
19
|
+
"execa": "9.6.1",
|
|
20
|
+
"node-plop": "0.32.3",
|
|
21
|
+
"yaml": "2.9.1"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@nelsonlaidev/oxfmt-config": "0.3.1",
|
|
25
|
+
"@nelsonlaidev/oxlint-config": "1.3.1",
|
|
26
|
+
"@nelsonlaidev/typescript-config": "3.0.0",
|
|
27
|
+
"@types/node": "24.19.4",
|
|
28
|
+
"knip": "6.49.0",
|
|
29
|
+
"oxfmt": "0.80.0",
|
|
30
|
+
"oxlint": "1.95.0",
|
|
31
|
+
"oxlint-tsgolint": "7.0.2009",
|
|
32
|
+
"plop": "4.0.5",
|
|
33
|
+
"tegami": "1.5.0",
|
|
34
|
+
"tsdown": "0.23.7",
|
|
35
|
+
"typescript": "6.0.3",
|
|
36
|
+
"vitest": "5.1.2"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=24.4.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsdown",
|
|
43
|
+
"dev": "tsdown --watch",
|
|
44
|
+
"format": "oxfmt",
|
|
45
|
+
"format:check": "oxfmt --check",
|
|
46
|
+
"knip": "knip",
|
|
47
|
+
"lint": "oxlint",
|
|
48
|
+
"lint:fix": "oxlint --fix",
|
|
49
|
+
"start": "node dist/cli.js",
|
|
50
|
+
"tegami": "node scripts/tegami.ts",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"typecheck": "tsc --noEmit"
|
|
53
|
+
}
|
|
6
54
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Code style
|
|
2
|
+
|
|
3
|
+
- Use PascalCase for component names and kebab-case for component filenames. Prefer named function declarations and named exports for shared components.
|
|
4
|
+
- Declare component-specific props in a `ComponentNameProps` type next to the component. Accept a named `props` parameter and destructure it inside the function body when needed.
|
|
5
|
+
- Use `React.ComponentProps` to reuse the props of an element or component you wrap. For a `render` prop, pass a self-closing element and put children on the receiving component, as in `<DialogTrigger render={<Button />}>Sign in</DialogTrigger>`.
|
|
6
|
+
- Use `import type` for type-only imports. Group external packages, `@/` imports from the app, and relative imports separately.
|
|
7
|
+
- Use single quotes for strings and JSX attributes. Omit semicolons.
|
|
8
|
+
- Explain lint exceptions in a comment immediately above the disable directive.
|
|
9
|
+
{{#if tanstackStart}}
|
|
10
|
+
- In file routes, export `Route` with `component: RouteComponent` and declare the local `function RouteComponent()` below it.
|
|
11
|
+
{{/if}}
|