django-hero-gen 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/index.js +19 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,12 +1,28 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const fs = require("fs");
4
4
  const path = require("path");
5
5
 
6
- // Берем аргументы: 1-я команда, 2-е имя файла
7
6
  const [, , command, name] = process.argv;
8
7
 
9
- // Шаблоны
8
+ if (command === "admin") {
9
+ const filePath = path.join(process.cwd(), "admin.py");
10
+ const template = `from django.contrib import admin\n\n# Register your models here.`;
11
+ fs.writeFileSync(filePath, template);
12
+ console.log(`✅ Файл admin.py успешно создан!`);
13
+ process.exit(0);
14
+ }
15
+
16
+ if (!name) {
17
+ console.log(`
18
+ Использование:
19
+ dj-gen page <name> - Создать HTML шаблон
20
+ dj-gen view <name> - Создать Django View
21
+ dj-gen admin - Создать файл admin.py
22
+ `);
23
+ process.exit(1);
24
+ }
25
+
10
26
  const templates = {
11
27
  base: `<!DOCTYPE html>
12
28
  <html>
@@ -39,10 +55,4 @@ if (command === "page") {
39
55
 
40
56
  fs.writeFileSync(filePath, templates.view);
41
57
  console.log(`✅ Создана View: ${fileName}`);
42
- } else {
43
- console.log(`
44
- Использование:
45
- dj-gen page <name> - Создать HTML шаблон
46
- dj-gen view <name> - Создать Django View
47
- `);
48
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "django-hero-gen",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Генератор шаблонов для Django",
5
5
  "main": "index.js",
6
6
  "bin": {