nero-init 1.0.0 → 1.0.2
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 +69 -0
- package/dist/renderer.js +9 -3
- package/dist/templates/cli/.github/workflows/ci.yaml +36 -0
- package/dist/templates/cli/README.md +24 -0
- package/dist/templates/cli/{eslint.config.js → eslint.config.ts} +1 -1
- package/dist/templates/cli/package.json +4 -2
- package/dist/templates/cli/src/cli/options.ts +27 -25
- package/dist/templates/library/.github/workflows/ci.yaml +36 -0
- package/dist/templates/library/README.md +13 -0
- package/dist/templates/library/package.json +7 -3
- package/package.json +3 -1
- /package/dist/templates/library/{eslint.config.js → eslint.config.ts} +0 -0
package/README.md
CHANGED
|
@@ -18,8 +18,77 @@ Creates opinionated starter templates for:
|
|
|
18
18
|
npx nero-init
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
No arguments, no flags — just answer the prompts.
|
|
22
|
+
|
|
23
|
+
<br >
|
|
24
|
+
|
|
25
|
+
## Folder Structure
|
|
26
|
+
|
|
27
|
+
### CLI
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
.
|
|
31
|
+
├── src/ # Source code
|
|
32
|
+
│ ├── cli/ # CLI-specific logic
|
|
33
|
+
│ │ ├── args.ts # Command-line arguments
|
|
34
|
+
│ │ └── options.ts # CLI options & flags
|
|
35
|
+
│ └── index.ts # Entry point
|
|
36
|
+
│
|
|
37
|
+
├── .github/
|
|
38
|
+
│ └── workflows/
|
|
39
|
+
│ └── ci.yaml # CI pipeline
|
|
40
|
+
│
|
|
41
|
+
├── .gitignore # Git ignore rules
|
|
42
|
+
├── .prettierrc # Prettier configuration
|
|
43
|
+
├── .prettierignore # Prettier ignore rules
|
|
44
|
+
│
|
|
45
|
+
├── eslint.config.ts # ESLint configuration
|
|
46
|
+
├── tsconfig.json # TypeScript configuration
|
|
47
|
+
├── vitest.config.ts # Test configuration
|
|
48
|
+
│
|
|
49
|
+
├── package.json # Package metadata & scripts
|
|
50
|
+
├── README.md # Project documentation
|
|
51
|
+
└── LICENSE # License
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
<br >
|
|
55
|
+
|
|
56
|
+
### Library
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
.
|
|
60
|
+
├── src/
|
|
61
|
+
│ └── index.ts # Library entry point (public API)
|
|
62
|
+
│
|
|
63
|
+
├── .github/
|
|
64
|
+
│ └── workflows/
|
|
65
|
+
│ └── ci.yaml # CI pipeline
|
|
66
|
+
│
|
|
67
|
+
├── .gitignore # Git ignore rules
|
|
68
|
+
├── .prettierrc # Prettier configuration
|
|
69
|
+
├── .prettierignore # Prettier ignore rules
|
|
70
|
+
│
|
|
71
|
+
├── eslint.config.ts # ESLint (flat, TypeScript config)
|
|
72
|
+
├── tsconfig.json # TypeScript configuration
|
|
73
|
+
├── vitest.config.ts # Test configuration
|
|
74
|
+
│
|
|
75
|
+
├── package.json # Package metadata & scripts
|
|
76
|
+
├── README.md # Documentation
|
|
77
|
+
└── LICENSE # License
|
|
78
|
+
```
|
|
79
|
+
|
|
21
80
|
<br >
|
|
22
81
|
|
|
82
|
+
<!-- ### Web
|
|
83
|
+
|
|
84
|
+
Next.js template bootstrapped via `create-next-app@latest` and preconfigured with:
|
|
85
|
+
|
|
86
|
+
- Zod — schema validation
|
|
87
|
+
- Prisma — database ORM
|
|
88
|
+
- Supabase — auth & backend services
|
|
89
|
+
|
|
90
|
+
<br > -->
|
|
91
|
+
|
|
23
92
|
## License
|
|
24
93
|
|
|
25
94
|
MIT
|
package/dist/renderer.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
const _filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const _dirname = path.dirname(_filename);
|
|
6
|
+
const TEMPLATE_ROOT = path.resolve(_dirname, 'templates');
|
|
4
7
|
export async function renderTemplate(template, answers) {
|
|
5
8
|
const targetDir = path.resolve(process.cwd(), answers.projectName);
|
|
6
|
-
const templateDir = path.resolve(TEMPLATE_ROOT
|
|
9
|
+
const templateDir = path.resolve(TEMPLATE_ROOT, template.id);
|
|
10
|
+
if (!fs.existsSync(templateDir)) {
|
|
11
|
+
throw new Error(`Template ${template.id} not found at ${templateDir}`);
|
|
12
|
+
}
|
|
7
13
|
if (fs.existsSync(targetDir)) {
|
|
8
|
-
throw new Error(`Directory ${answers.projectName} already exists`);
|
|
14
|
+
throw new Error(`Directory "${answers.projectName}" already exists`);
|
|
9
15
|
}
|
|
10
16
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
11
17
|
copyDir(templateDir, targetDir, answers, template.placeholders);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
check:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Enable corepack
|
|
16
|
+
run: corepack enable
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: 18
|
|
21
|
+
cache: pnpm
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: pnpm install --frozen-lockfile
|
|
25
|
+
|
|
26
|
+
- name: Type check
|
|
27
|
+
run: pnpm run typecheck
|
|
28
|
+
|
|
29
|
+
- name: Lint
|
|
30
|
+
run: pnpm run lint
|
|
31
|
+
|
|
32
|
+
- name: Format check
|
|
33
|
+
run: pnpm run format:check
|
|
34
|
+
|
|
35
|
+
- name: Test
|
|
36
|
+
run: pnpm run test
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
Opinionated CLI for <one-line purpose>.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -g {{projectName}}
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
{{projectName}}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Notes
|
|
18
|
+
|
|
19
|
+
- Defaults are intentional
|
|
20
|
+
- Optimized for my workflow
|
|
21
|
+
|
|
22
|
+
## License
|
|
23
|
+
|
|
24
|
+
MIT
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"dev": "tsx src/index.ts",
|
|
16
|
+
"clean": "rimraf dist",
|
|
16
17
|
"build": "tsc",
|
|
17
18
|
"typecheck": "tsc --noEmit",
|
|
18
19
|
"test": "vitest",
|
|
19
20
|
"format": "prettier --write .",
|
|
20
21
|
"format:check": "prettier --check .",
|
|
21
|
-
"lint": "eslint .",
|
|
22
|
-
"lint:fix": "eslint . --fix",
|
|
22
|
+
"lint": "eslint . --config eslint.config.ts",
|
|
23
|
+
"lint:fix": "eslint . --fix --config eslint.config.ts",
|
|
23
24
|
"prepublishOnly": "npm run build",
|
|
24
25
|
"postbuild": "chmod +x dist/index.js"
|
|
25
26
|
},
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"@typescript-eslint/parser": "^8.53.1",
|
|
43
44
|
"eslint": "^9.39.2",
|
|
44
45
|
"prettier": "^3.8.1",
|
|
46
|
+
"rimraf": "^6.1.2",
|
|
45
47
|
"tsx": "^4.21.0",
|
|
46
48
|
"typescript": "^5.9.3",
|
|
47
49
|
"vitest": "^4.0.18"
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { args } from './args.js'
|
|
2
|
-
import pkg from '../../package.json' with {type:
|
|
2
|
+
import pkg from '../../package.json' with { type: 'json' }
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
${pkg} - a cli
|
|
4
|
+
function printHelp(): void {
|
|
5
|
+
console.log(`
|
|
6
|
+
${pkg.name} - a cli tool
|
|
8
7
|
Usage:
|
|
9
8
|
${pkg.name} [options]
|
|
10
9
|
|
|
@@ -12,34 +11,37 @@ Options:
|
|
|
12
11
|
-h, --help, help Show help
|
|
13
12
|
-v, --version, version Show version
|
|
14
13
|
`)
|
|
15
|
-
|
|
14
|
+
}
|
|
16
15
|
|
|
17
16
|
function printVersion(): void {
|
|
18
|
-
|
|
17
|
+
console.log(`
|
|
19
18
|
${pkg.name} version ${pkg.version}
|
|
20
19
|
`)
|
|
21
|
-
|
|
20
|
+
}
|
|
22
21
|
function printInvalidOptions(option: string): void {
|
|
23
|
-
|
|
22
|
+
console.error(`
|
|
24
23
|
unknown option: ${option}
|
|
25
24
|
usage: ${pkg.name} [-v | --version] [-h | --help]
|
|
26
25
|
`)
|
|
27
|
-
|
|
26
|
+
}
|
|
28
27
|
|
|
29
28
|
export function handleCliOptions(): void {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
if (args.length === 0) return
|
|
30
|
+
|
|
31
|
+
if (args.includes('-h') || args.includes('--help') || args.includes('help')) {
|
|
32
|
+
printHelp()
|
|
33
|
+
process.exit(0)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (
|
|
37
|
+
args.includes('-v') ||
|
|
38
|
+
args.includes('--version') ||
|
|
39
|
+
args.includes('version')
|
|
40
|
+
) {
|
|
41
|
+
printVersion()
|
|
42
|
+
process.exit(0)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
printInvalidOptions(args[0])
|
|
46
|
+
process.exit(2)
|
|
45
47
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
check:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Enable corepack
|
|
16
|
+
run: corepack enable
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: 18
|
|
21
|
+
cache: pnpm
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: pnpm install --frozen-lockfile
|
|
25
|
+
|
|
26
|
+
- name: Type check
|
|
27
|
+
run: pnpm run typecheck
|
|
28
|
+
|
|
29
|
+
- name: Lint
|
|
30
|
+
run: pnpm run lint
|
|
31
|
+
|
|
32
|
+
- name: Format check
|
|
33
|
+
run: pnpm run format:check
|
|
34
|
+
|
|
35
|
+
- name: Test
|
|
36
|
+
run: pnpm run test
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"dev": "tsx src/index.ts",
|
|
16
|
+
"clean": "rimraf dist",
|
|
16
17
|
"build": "tsc",
|
|
17
18
|
"typecheck": "tsc --noEmit",
|
|
18
19
|
"test": "vitest",
|
|
19
20
|
"format": "prettier --write .",
|
|
20
21
|
"format:check": "prettier --check .",
|
|
21
|
-
"lint": "eslint .",
|
|
22
|
-
"lint:fix": "eslint . --fix",
|
|
22
|
+
"lint": "eslint . --config eslint.config.ts",
|
|
23
|
+
"lint:fix": "eslint . --fix --config eslint.config.ts",
|
|
23
24
|
"prepublishOnly": "npm run build"
|
|
24
25
|
},
|
|
25
26
|
"engines": {
|
|
@@ -29,7 +30,9 @@
|
|
|
29
30
|
"type": "git",
|
|
30
31
|
"url": "git+https://github.com/alcanivorax/{{projectName}}.git"
|
|
31
32
|
},
|
|
32
|
-
"keywords": [
|
|
33
|
+
"keywords": [
|
|
34
|
+
"library"
|
|
35
|
+
],
|
|
33
36
|
"author": "alcanivorax",
|
|
34
37
|
"license": "MIT",
|
|
35
38
|
"packageManager": "pnpm@10.28.0",
|
|
@@ -39,6 +42,7 @@
|
|
|
39
42
|
"@typescript-eslint/parser": "^8.53.1",
|
|
40
43
|
"eslint": "^9.39.2",
|
|
41
44
|
"prettier": "^3.8.1",
|
|
45
|
+
"rimraf": "^6.1.2",
|
|
42
46
|
"tsx": "^4.21.0",
|
|
43
47
|
"typescript": "^5.9.3",
|
|
44
48
|
"vitest": "^4.0.18"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nero-init",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Project scaffold for CLI, library and Web templates.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"scripts": {
|
|
18
18
|
"dev": "tsx src/index.ts",
|
|
19
|
+
"clean": "rimraf dist",
|
|
19
20
|
"build": "tsc && cp -r src/templates dist/",
|
|
20
21
|
"format": "prettier --write .",
|
|
21
22
|
"lint": "eslint .",
|
|
@@ -53,6 +54,7 @@
|
|
|
53
54
|
"@typescript-eslint/parser": "^8.53.1",
|
|
54
55
|
"eslint": "^9.39.2",
|
|
55
56
|
"prettier": "^3.8.1",
|
|
57
|
+
"rimraf": "^6.1.2",
|
|
56
58
|
"tsx": "^4.21.0",
|
|
57
59
|
"typescript": "^5.9.3"
|
|
58
60
|
},
|
|
File without changes
|