create-faitjesed-generator-app 1.0.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/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ import { createProject } from './scaffold.js';
3
+ const projectName = process.argv[2];
4
+ if (!projectName) {
5
+ console.log('Usage: create-faitjesed-generator-app <project-name>');
6
+ process.exit(1);
7
+ }
8
+ await createProject(projectName);
@@ -0,0 +1,24 @@
1
+ import path from 'path';
2
+ import prompts from 'prompts';
3
+ import { validateProjectName, getTemplatePath, logger, patchPackageJson, copyTemplate, runCommand } from './utils.js';
4
+ export async function createProject(projectName) {
5
+ validateProjectName(projectName);
6
+ const cwd = process.cwd();
7
+ const targetDir = path.join(cwd, projectName);
8
+ const response = await prompts({
9
+ type: 'select',
10
+ name: 'template',
11
+ message: 'Choose template',
12
+ choices: [
13
+ { title: 'Fastify API (TypeORM)', value: 'fastify' },
14
+ ]
15
+ });
16
+ const templateDir = getTemplatePath(response.template);
17
+ await copyTemplate(templateDir, targetDir);
18
+ logger.info(`\nCreating project in:, ${targetDir}`);
19
+ await patchPackageJson(targetDir, projectName);
20
+ logger.info('Initializing git...');
21
+ runCommand('git init', targetDir);
22
+ logger.success(`\n✔ Project created: ${projectName}`);
23
+ logger.info(`\nNext: cd ${projectName} && npm install`);
24
+ }
package/dist/utils.js ADDED
@@ -0,0 +1,37 @@
1
+ import path from 'path';
2
+ import fs from 'fs-extra';
3
+ import { execSync } from 'child_process';
4
+ import kleur from 'kleur';
5
+ export function validateProjectName(name) {
6
+ if (!name)
7
+ throw new Error('Project name required');
8
+ if (!/^[a-z0-9-]+$/.test(name)) {
9
+ throw new Error('Use lowercase letters, numbers, dashes only');
10
+ }
11
+ }
12
+ export function getTemplatePath(template) {
13
+ return path.join(process.cwd(), 'templates', template);
14
+ }
15
+ export async function copyTemplate(src, dest) {
16
+ await fs.copy(src, dest);
17
+ }
18
+ export async function patchPackageJson(projectDir, name) {
19
+ const pkgPath = path.join(projectDir, 'package.json');
20
+ if (!(await fs.pathExists(pkgPath)))
21
+ return;
22
+ const pkg = await fs.readJSON(pkgPath);
23
+ pkg.name = name;
24
+ pkg.version = '1.0.0';
25
+ await fs.writeJSON(pkgPath, pkg, { spaces: 2 });
26
+ }
27
+ export function runCommand(command, cwd) {
28
+ execSync(command, {
29
+ cwd,
30
+ stdio: 'inherit'
31
+ });
32
+ }
33
+ export const logger = {
34
+ info: (msg) => console.log(kleur.cyan(msg)),
35
+ success: (msg) => console.log(kleur.green(msg)),
36
+ error: (msg) => console.log(kleur.red(msg))
37
+ };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "create-faitjesed-generator-app",
3
+ "version": "1.0.0",
4
+ "description": "CLI for generating faitjesed Node.js services",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-faitjesed-generator-app": "dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "prepare": "npm run build"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "templates"
16
+ ],
17
+ "dependencies": {
18
+ "fs-extra": "^11.3.5",
19
+ "kleur": "^4.1.5",
20
+ "prompts": "^2.4.2"
21
+ },
22
+ "devDependencies": {
23
+ "@types/fs-extra": "^11.0.4",
24
+ "@types/node": "^20.0.0",
25
+ "@types/prompts": "^2.4.9",
26
+ "tsx": "^4.21.0",
27
+ "typescript": "^5.9.0"
28
+ }
29
+ }
@@ -0,0 +1,2 @@
1
+ dist/*
2
+ node_modules
@@ -0,0 +1,8 @@
1
+ {
2
+ "tabWidth": 2,
3
+ "semi": true,
4
+ "trailingComma": "es5",
5
+ "singleQuote": true,
6
+ "printWidth": 80,
7
+ "bracketSameLine": true
8
+ }
@@ -0,0 +1,20 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import tsParser from '@typescript-eslint/parser';
3
+ import tseslint from 'typescript-eslint';
4
+ import globals from 'globals';
5
+ import prettierPlugin from 'eslint-plugin-prettier';
6
+
7
+ export default defineConfig([
8
+ {
9
+ ignores: ['node_modules', 'dist'],
10
+ files: ['**/*.{ts}'],
11
+ plugins: {
12
+ prettier: prettierPlugin,
13
+ },
14
+ languageOptions: {
15
+ globals: { ...globals.node },
16
+ parser: tsParser,
17
+ },
18
+ },
19
+ tseslint.configs.recommended,
20
+ ]);
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "template",
3
+ "version": "1.0.0",
4
+ "description": "This fastify app is created with create-faitjesed-generator-app",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "tsx watch src/app/app",
8
+ "build": "tsc",
9
+ "start": "node dist/app/app",
10
+ "lint": "eslint . --fix",
11
+ "format": "prettier --write src/**/*.ts"
12
+ },
13
+ "keywords": [],
14
+ "author": "faitjesed",
15
+ "license": "ISC",
16
+ "dependencies": {
17
+ "axios": "1.15.2",
18
+ "date-fns": "^4.1.0",
19
+ "dotenv": "^17.2.3",
20
+ "fastify": "5.8.5",
21
+ "fastify-axios": "^1.3.0",
22
+ "fastify-type-provider-zod": "^6.1.0",
23
+ "pg": "^8.18.0",
24
+ "pino": "^10.3.0",
25
+ "reflect-metadata": "^0.2.2",
26
+ "typeorm": "^0.3.28",
27
+ "zod": "^4.3.6"
28
+ },
29
+ "devDependencies": {
30
+ "@eslint/js": "^9.39.2",
31
+ "@types/dotenv": "^6.1.1",
32
+ "@types/node": "^25.2.3",
33
+ "@typescript-eslint/parser": "^8.53.1",
34
+ "eslint": "^9.39.2",
35
+ "eslint-plugin-prettier": "^5.5.5",
36
+ "globals": "^17.1.0",
37
+ "jiti": "^2.6.1",
38
+ "prettier": "^3.8.1",
39
+ "tsx": "^4.21.0",
40
+ "typescript": "^5.9.3",
41
+ "typescript-eslint": "^8.53.1"
42
+ }
43
+ }
@@ -0,0 +1,20 @@
1
+ import 'reflect-metadata';
2
+ import fastify from 'fastify';
3
+ import {
4
+ serializerCompiler,
5
+ validatorCompiler,
6
+ ZodTypeProvider,
7
+ } from 'fastify-type-provider-zod';
8
+ import { Configuration } from '@/config';
9
+
10
+ const app = fastify().withTypeProvider<ZodTypeProvider>();
11
+
12
+ app.setValidatorCompiler(validatorCompiler);
13
+ app.setSerializerCompiler(serializerCompiler);
14
+
15
+ try {
16
+ await app.listen({ port: Configuration.PORT });
17
+ } catch (err) {
18
+ app.log.error(err);
19
+ process.exit(1);
20
+ }
@@ -0,0 +1,10 @@
1
+ import { configDotenv } from 'dotenv';
2
+ import { BaseConfiguration } from '@/types';
3
+
4
+ configDotenv();
5
+
6
+ export const Configuration: BaseConfiguration = {
7
+ PORT: Number(process.env.PORT) || 3000,
8
+ NODE_ENV: process.env.NODE_ENV || 'development',
9
+ LOG_LEVEL: process.env.LOG_LEVEL || 'info',
10
+ };
@@ -0,0 +1 @@
1
+ export * from './configuration'
@@ -0,0 +1 @@
1
+ export * from './types'
@@ -0,0 +1,5 @@
1
+ export interface BaseConfiguration {
2
+ PORT: number,
3
+ NODE_ENV: string,
4
+ LOG_LEVEL: string,
5
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": ".",
4
+ "paths": {
5
+ "@/*": ["src/*"]
6
+ },
7
+ "lib": ["es2021", "es5", "es6"],
8
+ "esModuleInterop": true,
9
+ "allowSyntheticDefaultImports": true,
10
+ "target": "esnext",
11
+ "module": "esnext",
12
+ "moduleResolution": "node",
13
+ "outDir": "dist",
14
+ "rootDir": "src",
15
+ "strict": true,
16
+ "skipLibCheck": true,
17
+ "forceConsistentCasingInFileNames": true,
18
+ "resolveJsonModule": true,
19
+ "isolatedModules": true,
20
+ "emitDecoratorMetadata": true,
21
+ "experimentalDecorators": true,
22
+ "strictPropertyInitialization": false,
23
+ "types": ["node"]
24
+ },
25
+ "include": ["src"]
26
+ }