create-charcole 2.2.1 → 2.2.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/CHANGELOG.md +1 -1
- package/README.md +3 -0
- package/bin/index.js +53 -3
- package/package.json +3 -3
- package/packages/swagger/BACKWARD_COMPATIBILITY.md +1 -1
- package/packages/swagger/CHANGELOG.md +1 -1
- package/packages/swagger/README.md +3 -3
- package/packages/swagger/package.json +3 -3
- package/packages/swagger/src/setup.js +1 -1
- package/template/js/.env.example +1 -0
- package/template/js/README.md +7 -3
- package/template/js/basePackage.json +1 -1
- package/template/js/src/app.js +1 -1
- package/template/js/src/config/swagger.config.js +1 -1
- package/template/js/src/lib/swagger/SWAGGER_GUIDE.md +3 -3
- package/template/js/src/modules/swagger/package.json +1 -1
- package/template/ts/.env.example +1 -0
- package/template/ts/README.md +7 -3
- package/template/ts/basePackage.json +1 -1
- package/template/ts/src/config/swagger.config.ts +1 -1
- package/template/ts/src/lib/swagger/SWAGGER_GUIDE.md +2 -2
- package/template/ts/src/modules/swagger/package.json +1 -1
- package/packages/swagger/package-lock.json +0 -1715
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,7 @@ All notable changes to Charcole will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [2.2.
|
|
8
|
+
## [2.2.2] – 2026-02-06
|
|
9
9
|
|
|
10
10
|
### 🎉 Major Release: Auto-Generated Swagger Documentation
|
|
11
11
|
|
package/README.md
CHANGED
package/bin/index.js
CHANGED
|
@@ -233,14 +233,14 @@ function copyDirRecursive(src, dest, excludeFiles = [], excludeDirs = []) {
|
|
|
233
233
|
const swaggerPkgPath = path.join(swaggerModuleDir, "package.json");
|
|
234
234
|
const swaggerTgzPath = path.join(
|
|
235
235
|
swaggerModuleDir,
|
|
236
|
-
"charcole-swagger-1.0.
|
|
236
|
+
"charcole-swagger-1.0.1.tgz",
|
|
237
237
|
);
|
|
238
238
|
|
|
239
239
|
// Copy tarball temporarily for npm install (will be cleaned up after)
|
|
240
240
|
if (fs.existsSync(swaggerTgzPath)) {
|
|
241
241
|
fs.copyFileSync(
|
|
242
242
|
swaggerTgzPath,
|
|
243
|
-
path.join(targetDir, "charcole-swagger-1.0.
|
|
243
|
+
path.join(targetDir, "charcole-swagger-1.0.1.tgz"),
|
|
244
244
|
);
|
|
245
245
|
console.log("✓ Copied Swagger tarball temporarily for installation");
|
|
246
246
|
} else {
|
|
@@ -418,12 +418,62 @@ function copyDirRecursive(src, dest, excludeFiles = [], excludeDirs = []) {
|
|
|
418
418
|
Object.keys(mergedPkg.devDependencies || {}).join(", "),
|
|
419
419
|
);
|
|
420
420
|
|
|
421
|
+
// Create .env from .env.example and ensure APP_NAME default exists
|
|
422
|
+
try {
|
|
423
|
+
const exampleEnvPath = path.join(targetDir, ".env.example");
|
|
424
|
+
const envPath = path.join(targetDir, ".env");
|
|
425
|
+
|
|
426
|
+
if (fs.existsSync(exampleEnvPath) && !fs.existsSync(envPath)) {
|
|
427
|
+
let exampleContent = fs.readFileSync(exampleEnvPath, "utf-8");
|
|
428
|
+
|
|
429
|
+
if (!/APP_NAME\s*=/.test(exampleContent)) {
|
|
430
|
+
exampleContent = `APP_NAME=CHARCOLE API\n` + exampleContent;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
fs.writeFileSync(envPath, exampleContent, "utf-8");
|
|
434
|
+
console.log("✓ Created .env from .env.example with default APP_NAME");
|
|
435
|
+
}
|
|
436
|
+
} catch (err) {
|
|
437
|
+
console.warn("⚠️ Failed to create .env automatically:", err.message);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Initialize git repository to make project git-friendly
|
|
441
|
+
try {
|
|
442
|
+
const { execSync } = require("child_process");
|
|
443
|
+
|
|
444
|
+
execSync("git --version", { stdio: "ignore" });
|
|
445
|
+
execSync("git init", { cwd: targetDir, stdio: "ignore" });
|
|
446
|
+
|
|
447
|
+
// Ensure .gitignore exists (copy from template if missing)
|
|
448
|
+
const gitignoreSrc = path.join(templateDir, ".gitignore");
|
|
449
|
+
const gitignoreDest = path.join(targetDir, ".gitignore");
|
|
450
|
+
if (!fs.existsSync(gitignoreDest) && fs.existsSync(gitignoreSrc)) {
|
|
451
|
+
fs.copyFileSync(gitignoreSrc, gitignoreDest);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Stage files and attempt initial commit; ignore commit errors (e.g., missing git user config)
|
|
455
|
+
try {
|
|
456
|
+
execSync("git add .", { cwd: targetDir, stdio: "ignore" });
|
|
457
|
+
execSync('git commit -m "chore: initial commit from Charcole"', {
|
|
458
|
+
cwd: targetDir,
|
|
459
|
+
stdio: "ignore",
|
|
460
|
+
});
|
|
461
|
+
console.log("✓ Initialized git repository and created initial commit");
|
|
462
|
+
} catch (commitErr) {
|
|
463
|
+
console.log(
|
|
464
|
+
"✓ Initialized git repository (skipped commit — configure git user to enable commits)",
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
} catch (gitErr) {
|
|
468
|
+
console.log("ℹ️ Git not available; skipping repository initialization");
|
|
469
|
+
}
|
|
470
|
+
|
|
421
471
|
console.log(`\n📦 Installing dependencies using ${pkgManager}...`);
|
|
422
472
|
installDependencies(targetDir, pkgManager);
|
|
423
473
|
|
|
424
474
|
// Clean up the swagger tarball after installation
|
|
425
475
|
if (swagger) {
|
|
426
|
-
const tgzPath = path.join(targetDir, "charcole-swagger-1.0.
|
|
476
|
+
const tgzPath = path.join(targetDir, "charcole-swagger-1.0.1.tgz");
|
|
427
477
|
if (fs.existsSync(tgzPath)) {
|
|
428
478
|
fs.unlinkSync(tgzPath);
|
|
429
479
|
console.log("✓ Cleaned up temporary Swagger tarball");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-charcole",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "CLI to create production-ready Node.js Express APIs with TypeScript/JavaScript, JWT auth, auto-generated Swagger docs, and repository pattern",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/sheraz4196/
|
|
12
|
+
"url": "https://github.com/sheraz4196/charcole.git"
|
|
13
13
|
},
|
|
14
14
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/sheraz4196/
|
|
15
|
+
"url": "https://github.com/sheraz4196/charcole/issues"
|
|
16
16
|
},
|
|
17
17
|
"homepage": "https://www.charcole.site/",
|
|
18
18
|
"bin": {
|
|
@@ -30,7 +30,7 @@ const app = express();
|
|
|
30
30
|
|
|
31
31
|
setupSwagger(app, {
|
|
32
32
|
title: "My API",
|
|
33
|
-
version: "1.0.
|
|
33
|
+
version: "1.0.1",
|
|
34
34
|
schemas: {
|
|
35
35
|
createUserSchema, // Auto-converted from Zod!
|
|
36
36
|
loginSchema,
|
|
@@ -107,7 +107,7 @@ Sets up Swagger UI and documentation generation.
|
|
|
107
107
|
| Option | Type | Default | Description |
|
|
108
108
|
| ------------------------ | ------- | ---------------------------------- | ----------------------------------- |
|
|
109
109
|
| `title` | string | "Charcole API" | API title |
|
|
110
|
-
| `version` | string | "1.0.
|
|
110
|
+
| `version` | string | "1.0.1" | API version |
|
|
111
111
|
| `description` | string | "Auto-generated API documentation" | API description |
|
|
112
112
|
| `path` | string | "/api-docs" | Swagger UI path |
|
|
113
113
|
| `servers` | array | `[{url: "http://localhost:3000"}]` | Server URLs |
|
|
@@ -267,7 +267,7 @@ const app: Application = express();
|
|
|
267
267
|
|
|
268
268
|
const options: SwaggerOptions = {
|
|
269
269
|
title: "My API",
|
|
270
|
-
version: "1.0.
|
|
270
|
+
version: "1.0.1",
|
|
271
271
|
schemas: {
|
|
272
272
|
mySchema,
|
|
273
273
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcoles/swagger",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Auto-generated Swagger documentation for Charcole APIs",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/sheraz4196/
|
|
20
|
+
"url": "https://github.com/sheraz4196/charcole.git",
|
|
21
21
|
"directory": "packages/swagger"
|
|
22
22
|
},
|
|
23
23
|
"bugs": {
|
|
24
|
-
"url": "https://github.com/sheraz4196/
|
|
24
|
+
"url": "https://github.com/sheraz4196/charcole/issues"
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://www.charcole.site/guides/swagger/introduction",
|
|
27
27
|
"scripts": {
|
|
@@ -7,7 +7,7 @@ import { registerSchemas, getCommonResponses } from "./helpers.js";
|
|
|
7
7
|
export function setupSwagger(app, options = {}) {
|
|
8
8
|
const defaultOptions = {
|
|
9
9
|
title: "Charcole API",
|
|
10
|
-
version: "1.0.
|
|
10
|
+
version: "1.0.1",
|
|
11
11
|
description: "Auto-generated API documentation",
|
|
12
12
|
path: "/api-docs",
|
|
13
13
|
servers: [{ url: "http://localhost:3000", description: "Local server" }],
|
package/template/js/.env.example
CHANGED
package/template/js/README.md
CHANGED
|
@@ -34,9 +34,13 @@ Welcome! This guide will help you set up and start using the Charcole API framew
|
|
|
34
34
|
|
|
35
35
|
2. **Create environment file**
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
The `create-charcole` CLI will automatically create a `.env` from `.env.example` and initialize a Git repository for you. Edit the generated `.env` as needed.
|
|
38
|
+
|
|
39
|
+
If you prefer to create it manually:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cp .env.example .env
|
|
43
|
+
```
|
|
40
44
|
|
|
41
45
|
3. **Run the charcole**
|
|
42
46
|
```bash
|
package/template/js/src/app.js
CHANGED
|
@@ -18,8 +18,8 @@ import { createItemSchema } from "../modules/health/controller.ts";
|
|
|
18
18
|
|
|
19
19
|
const swaggerConfig = {
|
|
20
20
|
title: "My API",
|
|
21
|
-
version: "1.0.
|
|
22
|
-
// Auto-register schemas - they'll be
|
|
21
|
+
version: "1.0.1",
|
|
22
|
+
// Auto-register schemas - they'll be converted to OpenAPI automatically!
|
|
23
23
|
schemas: {
|
|
24
24
|
registerSchema,
|
|
25
25
|
loginSchema,
|
|
@@ -472,7 +472,7 @@ const app = express();
|
|
|
472
472
|
|
|
473
473
|
setupSwagger(app, {
|
|
474
474
|
title: "My API",
|
|
475
|
-
version: "1.0.
|
|
475
|
+
version: "1.0.1",
|
|
476
476
|
schemas: {
|
|
477
477
|
mySchema, // Your Zod schemas
|
|
478
478
|
},
|
package/template/ts/.env.example
CHANGED
package/template/ts/README.md
CHANGED
|
@@ -34,9 +34,13 @@ Welcome! This guide will help you set up and start using the Charcole API framew
|
|
|
34
34
|
|
|
35
35
|
2. **Create environment file**
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
The `create-charcole` CLI will automatically create a `.env` from `.env.example` and initialize a Git repository for you. Edit the generated `.env` as needed.
|
|
38
|
+
|
|
39
|
+
If you prefer to create it manually:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
cp .env.example .env
|
|
43
|
+
```
|
|
40
44
|
|
|
41
45
|
3. **Run the charcole**
|
|
42
46
|
```bash
|
|
@@ -3,7 +3,7 @@ import { createItemSchema } from "../modules/health/controller.ts";
|
|
|
3
3
|
|
|
4
4
|
const swaggerConfig = {
|
|
5
5
|
title: process.env.APP_NAME || "Charcole API",
|
|
6
|
-
version: process.env.APP_VERSION || "1.0.
|
|
6
|
+
version: process.env.APP_VERSION || "1.0.1",
|
|
7
7
|
description: "Production-ready Node.js Express API",
|
|
8
8
|
path: "/api-docs",
|
|
9
9
|
servers: [
|
|
@@ -18,7 +18,7 @@ import { createItemSchema } from "../modules/health/controller.ts";
|
|
|
18
18
|
|
|
19
19
|
const swaggerConfig = {
|
|
20
20
|
title: "My API",
|
|
21
|
-
version: "1.0.
|
|
21
|
+
version: "1.0.1",
|
|
22
22
|
// Auto-register schemas - they'll be converted to OpenAPI automatically!
|
|
23
23
|
schemas: {
|
|
24
24
|
registerSchema,
|
|
@@ -472,7 +472,7 @@ const app = express();
|
|
|
472
472
|
|
|
473
473
|
setupSwagger(app, {
|
|
474
474
|
title: "My API",
|
|
475
|
-
version: "1.0.
|
|
475
|
+
version: "1.0.1",
|
|
476
476
|
schemas: {
|
|
477
477
|
mySchema, // Your Zod schemas
|
|
478
478
|
},
|