tsoft-cli 1.3.0 → 1.4.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/CHANGELOG.md +20 -1
- package/README.md +79 -67
- package/bin/index.js +10 -10
- package/package.json +2 -1
- package/src/{tsoft.js → Tsoft.js} +8 -13
- package/src/commands/CreateCommand.js +100 -0
- package/src/commands/StartCommand.js +280 -0
- package/src/commands/SyncCommand.js +97 -0
- package/src/{client-credentials.js → core/ClientCredentials.js} +41 -46
- package/src/{constants.js → core/Constants.js} +5 -2
- package/src/{file-manager.js → core/FileManager.js} +3 -20
- package/src/core/Request.js +41 -0
- package/src/{theme-manager.js → core/ThemeManager.js} +3 -2
- package/src/{utils.js → core/Utils.js} +23 -14
- package/src/commands/create.js +0 -127
- package/src/commands/start.js +0 -280
- package/src/commands/sync.js +0 -73
- package/src/request.js +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -50,4 +50,23 @@
|
|
|
50
50
|
|
|
51
51
|
### Fixed
|
|
52
52
|
- Yeni tema ekleme işlemi sırasında oluşan hatalar giderildi.
|
|
53
|
-
- `start.js` `utils.js` ve `sync.js` dosyalarında iyileştirmeler yapıldı.
|
|
53
|
+
- `start.js` `utils.js` ve `sync.js` dosyalarında iyileştirmeler yapıldı.
|
|
54
|
+
|
|
55
|
+
# Changelog
|
|
56
|
+
|
|
57
|
+
## [1.4.0] - 2024-06-16
|
|
58
|
+
### Added
|
|
59
|
+
- Zip dosyasının indirildiğinde ve çıkartıldığında oluşabilecek hatalar kontrol edilip anlamlı hata mesajları eklendi.
|
|
60
|
+
- Kurtarma kodu girildikten ve dosyalar başarıyla senkronize edildikten sonra otomatik olarak geliştirme ortamını başlatma özelliği eklendi.
|
|
61
|
+
|
|
62
|
+
### Changed
|
|
63
|
+
- Proje genelinde SoC (Separation of Concerns) prensiplerine uygun olarak sınıf tabanlı yapıya geçildi.
|
|
64
|
+
- `ClientCredentials`, `FileManager`, `Request`, `ThemeManager`, ve `Utils` dosyaları sınıf yapısına dönüştürüldü.
|
|
65
|
+
- `SyncCommand` dosyasındaki `syncTheme` fonksiyonu, kurtarma işlemi ve zip dosyası işlemlerini yönetmek için güncellendi.
|
|
66
|
+
- `StartCommand` ile senkronize şekilde çalışacak şekilde `syncTheme` fonksiyonu güncellendi.
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
- Zip dosyasının indirilmesi ve çıkartılması sırasında oluşabilecek hatalar için ek kontrol sağlandı.
|
|
70
|
+
- Kurtarma işlemi sırasında çok fazla deneme yapılırsa kullanıcıyı doğru şekilde bilgilendirme ve işlemi durdurma.
|
|
71
|
+
- Geliştirme ortamını başlatma işlemi sırasında oluşabilecek hatalar giderildi.
|
|
72
|
+
- Proje genelinde hata yönetimi ve kullanıcı bilgilendirme mesajları iyileştirildi.
|
package/README.md
CHANGED
|
@@ -1,106 +1,118 @@
|
|
|
1
|
+
T-Soft CLI Kullanım Kılavuzu body { font-family: Arial, sans-serif; line-height: 1.6; margin: 20px; } h1, h2, h3 { color: #2c3e50; } code { background: #f4f4f4; padding: 2px 4px; border-radius: 4px; } pre { background: #f4f4f4; padding: 10px; border-radius: 4px; }
|
|
2
|
+
|
|
1
3
|
T-Soft CLI Kullanım Kılavuzu
|
|
2
4
|
============================
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
T-Soft CLI, T-Soft temalarıyla çalışmak için geliştirilmiş bir komut satırı aracıdır. Bu kılavuz, T-Soft CLI'nin nasıl kullanılacağını adım adım açıklamaktadır.
|
|
7
|
+
|
|
8
|
+
Gereksinimler
|
|
9
|
+
-------------
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
* Node.js (v14.0.0 veya üstü)
|
|
12
|
+
* NPM veya Yarn
|
|
8
13
|
|
|
9
14
|
Kurulum
|
|
10
15
|
-------
|
|
11
16
|
|
|
12
|
-
|
|
17
|
+
1. Proje dosyalarını bilgisayarınıza indirin.
|
|
18
|
+
2. Proje dizinine gidin ve gerekli bağımlılıkları yükleyin:
|
|
19
|
+
|
|
20
|
+
npm install tsoft-cli
|
|
21
|
+
|
|
22
|
+
veya
|
|
13
23
|
|
|
14
|
-
|
|
24
|
+
yarn add tsoft-cli
|
|
15
25
|
|
|
16
|
-
|
|
26
|
+
3. Veya global olarak yükleyin:
|
|
17
27
|
|
|
18
|
-
|
|
28
|
+
npm install -g tsoft-cli
|
|
19
29
|
|
|
20
|
-
|
|
30
|
+
veya
|
|
31
|
+
|
|
32
|
+
yarn global add tsoft-cli
|
|
33
|
+
Başlatma
|
|
21
34
|
--------
|
|
22
35
|
|
|
23
|
-
CLI
|
|
36
|
+
CLI uygulamasını başlatmak için aşağıdaki komutu kullanın:
|
|
37
|
+
|
|
38
|
+
npx tsoft-cli
|
|
24
39
|
|
|
40
|
+
veya global olarak yüklediyseniz:
|
|
41
|
+
|
|
25
42
|
tsoft-cli
|
|
26
43
|
|
|
27
|
-
|
|
44
|
+
Ana Menü
|
|
45
|
+
--------
|
|
28
46
|
|
|
29
|
-
CLI başlatıldığında
|
|
47
|
+
CLI başlatıldığında ana menü karşınıza gelecektir. Ana menüde şu seçenekler bulunmaktadır:
|
|
30
48
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
1. Yeni bir tema oluştur
|
|
50
|
+
2. Geliştirme ortamını başlat
|
|
51
|
+
3. Uzak sunucudan dosyaları indir
|
|
52
|
+
4. Çıkış
|
|
34
53
|
|
|
35
|
-
### Yeni
|
|
54
|
+
### 1\. Yeni bir tema oluştur
|
|
36
55
|
|
|
37
|
-
Yeni bir tema oluşturmak için
|
|
56
|
+
Yeni bir tema oluşturmak için bu seçeneği kullanabilirsiniz. Adımlar:
|
|
38
57
|
|
|
39
|
-
1.
|
|
40
|
-
2.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
3. **Tema Detayları**:
|
|
44
|
-
* Tema adı, yazar adı (isteğe bağlı) ve versiyon numarasını girin.
|
|
45
|
-
4. **Tema Oluşturma**: Tema başarıyla oluşturulduktan sonra otomatik olarak geliştirme ortamına geçilir.
|
|
58
|
+
1. "Yeni bir tema oluştur" seçeneğini seçin.
|
|
59
|
+
2. Çalışmak istediğiniz siteyi seçin veya yeni bir site adı girin.
|
|
60
|
+
3. Tema adı, yazar adı ve tema versiyonunu girin.
|
|
61
|
+
4. Tema başarıyla oluşturulacaktır.
|
|
46
62
|
|
|
47
|
-
### Geliştirme
|
|
63
|
+
### 2\. Geliştirme ortamını başlat
|
|
48
64
|
|
|
49
|
-
Mevcut bir
|
|
65
|
+
Mevcut bir temayla çalışmak için geliştirme ortamını başlatabilirsiniz. Adımlar:
|
|
50
66
|
|
|
51
|
-
1.
|
|
52
|
-
2.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
3. **Geliştirme Ortamı**: Seçilen tema için geliştirme ortamı başlatılır ve dosya değişiklikleri izlenir.
|
|
67
|
+
1. "Geliştirme ortamını başlat" seçeneğini seçin.
|
|
68
|
+
2. Çalışmak istediğiniz siteyi ve temayı seçin.
|
|
69
|
+
3. Eğer ilk defa başlatıyorsanız, onay kodunu girmeniz istenecektir.
|
|
70
|
+
4. Geliştirme ortamı başlatılacak ve dosya değişiklikleri izlenmeye başlanacaktır.
|
|
56
71
|
|
|
57
|
-
###
|
|
72
|
+
### 3\. Uzak sunucudan dosyaları indir
|
|
58
73
|
|
|
59
|
-
|
|
74
|
+
Uzak sunucudan tema dosyalarını indirmek için bu seçeneği kullanabilirsiniz. Adımlar:
|
|
60
75
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* `o`: Tema dizinini açar.
|
|
76
|
+
1. "Uzak sunucudan dosyaları indir" seçeneğini seçin.
|
|
77
|
+
2. İndirmek istediğiniz siteyi ve temayı seçin.
|
|
78
|
+
3. Kurtarma anahtarını girin.
|
|
79
|
+
4. Dosyalar indirilecek ve çıkarılacaktır.
|
|
66
80
|
|
|
67
|
-
|
|
68
|
-
------------
|
|
81
|
+
### 4\. Çıkış
|
|
69
82
|
|
|
70
|
-
|
|
83
|
+
CLI uygulamasından çıkmak için bu seçeneği kullanabilirsiniz.
|
|
71
84
|
|
|
85
|
+
Temel Komutlar ve Kullanımlar
|
|
86
|
+
-----------------------------
|
|
72
87
|
|
|
73
|
-
|
|
74
|
-
├── bin/
|
|
75
|
-
│ └── index.js
|
|
76
|
-
├── src/
|
|
77
|
-
│ ├── commands/
|
|
78
|
-
│ │ ├── create.js
|
|
79
|
-
│ │ └── start.js
|
|
80
|
-
│ ├── tsoft/
|
|
81
|
-
│ │ └── themeManager.js
|
|
82
|
-
│ ├── utils.js
|
|
83
|
-
│ └── constants.js
|
|
84
|
-
├── CHANGELOG.md
|
|
85
|
-
├── package.json
|
|
86
|
-
└── README.md
|
|
88
|
+
**Tema Yaratma:**
|
|
87
89
|
|
|
90
|
+
Ana menüden "Yeni bir tema oluştur" seçeneğini takip edin.
|
|
88
91
|
|
|
89
|
-
|
|
92
|
+
**Geliştirme Ortamı Başlatma:**
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
* `src/commands/create.js`: Yeni bir tema oluşturmak için kullanılan komut dosyasıdır. Kullanıcıdan site ve tema adı alır ve temayı oluşturur.
|
|
93
|
-
* `src/commands/start.js`: Geliştirme ortamını başlatmak için kullanılan komut dosyasıdır. Dosya değişikliklerini izler ve temayı günceller.
|
|
94
|
-
* `src/tsoft/themeManager.js`: Tema yönetimi işlemlerini gerçekleştiren sınıftır. Temanın başlatılması, geçerliliğinin kontrol edilmesi ve ortamın oluşturulması işlemlerini yapar.
|
|
95
|
-
* `src/utils.js`: Yardımcı fonksiyonlar içerir.
|
|
96
|
-
* `src/constants.js`: Sabit değerleri içerir.
|
|
94
|
+
Ana menüden "Geliştirme ortamını başlat" seçeneğini takip edin.
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
---------------
|
|
96
|
+
**Uzak Sunucudan Dosya İndirme:**
|
|
100
97
|
|
|
101
|
-
|
|
98
|
+
Ana menüden "Uzak sunucudan dosyaları indir" seçeneğini takip edin.
|
|
102
99
|
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
Dosya Yapısı
|
|
101
|
+
------------
|
|
105
102
|
|
|
106
|
-
|
|
103
|
+
* **bin/index.js:** Ana giriş noktası.
|
|
104
|
+
* **src/commands/create.js:** Tema oluşturma işlemleri.
|
|
105
|
+
* **src/commands/start.js:** Geliştirme ortamını başlatma işlemleri.
|
|
106
|
+
* **src/commands/sync.js:** Dosya senkronizasyon işlemleri.
|
|
107
|
+
* **src/constants.js:** Sabit değerler ve mesajlar.
|
|
108
|
+
* **src/request.js:** HTTP istekleri için yardımcı fonksiyonlar.
|
|
109
|
+
* **src/utils.js:** Yardımcı fonksiyonlar (örn: ekran temizleme, dosya izleme).
|
|
110
|
+
* **src/tsoft.js:** T-Soft ile ilgili ana işlemler.
|
|
111
|
+
* **src/theme-manager.js:** Tema yönetim işlemleri.
|
|
112
|
+
* **src/file-manager.js:** Dosya yönetim işlemleri.
|
|
113
|
+
* **src/client-credentials.js:** Müşteri kimlik bilgileri yönetimi.
|
|
114
|
+
|
|
115
|
+
İletişim ve Destek
|
|
116
|
+
------------------
|
|
117
|
+
|
|
118
|
+
Bu kılavuz, T-Soft CLI'nin temel kullanımını ve işlevlerini kapsar. Daha fazla bilgi için proje dosyalarına göz atabilirsiniz. İyi çalışmalar!
|
package/bin/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const {Select} = require('enquirer');
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const {clearScreen, displayAsciiArt} = require('../src/
|
|
3
|
+
const { Select } = require('enquirer');
|
|
4
|
+
const StartCommand = require('../src/commands/StartCommand');
|
|
5
|
+
const SyncCommand = require('../src/commands/SyncCommand');
|
|
6
|
+
const CreateCommand = require('../src/commands/CreateCommand');
|
|
7
|
+
const { clearScreen, displayAsciiArt } = require('../src/core/Utils');
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
|
|
@@ -43,7 +43,7 @@ async function selectSiteAndTheme() {
|
|
|
43
43
|
|
|
44
44
|
const selectedTheme = await selectFromChoices('Bir tema seçin:', themes);
|
|
45
45
|
|
|
46
|
-
return {siteName: selectedSite, themeName: selectedTheme};
|
|
46
|
+
return { siteName: selectedSite, themeName: selectedTheme };
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
async function showMainMenu() {
|
|
@@ -51,20 +51,20 @@ async function showMainMenu() {
|
|
|
51
51
|
await displayAsciiArt();
|
|
52
52
|
|
|
53
53
|
const commandChoices = ['Yeni bir tema oluştur', 'Geliştirme ortamını başlat', 'Uzak sunucudan dosyaları indir', 'Çıkış'];
|
|
54
|
-
const selectedCommand = await selectFromChoices('Bir komut seçin', commandChoices);
|
|
54
|
+
const selectedCommand = await selectFromChoices('Bir komut seçin:', commandChoices);
|
|
55
55
|
|
|
56
56
|
switch (selectedCommand) {
|
|
57
57
|
case 'Yeni bir tema oluştur':
|
|
58
|
-
await createTheme();
|
|
58
|
+
await CreateCommand.createTheme();
|
|
59
59
|
break;
|
|
60
60
|
case 'Geliştirme ortamını başlat':
|
|
61
61
|
const selection = await selectSiteAndTheme();
|
|
62
62
|
if (selection) {
|
|
63
|
-
await start(selection.siteName, selection.themeName);
|
|
63
|
+
await StartCommand.start(selection.siteName, selection.themeName);
|
|
64
64
|
}
|
|
65
65
|
break;
|
|
66
66
|
case 'Uzak sunucudan dosyaları indir':
|
|
67
|
-
await syncTheme();
|
|
67
|
+
await SyncCommand.syncTheme();
|
|
68
68
|
break;
|
|
69
69
|
case 'Çıkış':
|
|
70
70
|
console.log('Programdan çıkılıyor. Hoşça kalın!');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsoft-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A theme development cli for developers who want to create themes for T-Soft.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"enquirer": "^2.4.1",
|
|
20
20
|
"figlet": "^1.7.0",
|
|
21
21
|
"fs": "^0.0.1-security",
|
|
22
|
+
"node-fetch": "^3.3.2",
|
|
22
23
|
"unzipper": "^0.12.1"
|
|
23
24
|
},
|
|
24
25
|
"type": "commonjs",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const ClientCredentials = require('./
|
|
2
|
-
const
|
|
3
|
-
const FileManager = require('./
|
|
4
|
-
const ThemeManager = require('./
|
|
1
|
+
const ClientCredentials = require('./core/ClientCredentials');
|
|
2
|
+
const Constants = require('./core/Constants');
|
|
3
|
+
const FileManager = require('./core/FileManager');
|
|
4
|
+
const ThemeManager = require('./core/ThemeManager');
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const {buildPostRequest} = require('./
|
|
6
|
+
const { buildPostRequest } = require('./core/Request');
|
|
7
7
|
|
|
8
8
|
class Tsoft {
|
|
9
9
|
static TSOFT_CLI_UUID = '7583a318-8542-4ec8-980c-48ea67031be3';
|
|
@@ -11,7 +11,6 @@ class Tsoft {
|
|
|
11
11
|
static ONLINESTORE_DELETE_URI = 'api/v3/admin/online-store-2/theme/file-manager?q=delete';
|
|
12
12
|
static UPDATE_THEME_URI = 'api/v3/admin/online-store-2/theme/update-theme';
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
constructor(site) {
|
|
16
15
|
this.site = site;
|
|
17
16
|
this.themeManager = new ThemeManager(site);
|
|
@@ -38,7 +37,7 @@ class Tsoft {
|
|
|
38
37
|
|
|
39
38
|
async register(CLIENT_UUID, clientConfiguration = {}) {
|
|
40
39
|
const response = await this.clientCredentials.register(CLIENT_UUID, clientConfiguration);
|
|
41
|
-
return response === true ?
|
|
40
|
+
return response === true ? Constants.APPROVAL : null;
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
async saveOnlineStore(theme) {
|
|
@@ -78,7 +77,6 @@ class Tsoft {
|
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
async deleteFile(theme, fileName, bearerToken) {
|
|
81
|
-
|
|
82
80
|
return await buildPostRequest(this.site, Tsoft.ONLINESTORE_DELETE_URI, {
|
|
83
81
|
headers: {
|
|
84
82
|
Authorization: `Bearer ${bearerToken}`,
|
|
@@ -87,11 +85,10 @@ class Tsoft {
|
|
|
87
85
|
body: JSON.stringify({
|
|
88
86
|
theme: theme,
|
|
89
87
|
items: [
|
|
90
|
-
{type: 'file', path: fileName}
|
|
88
|
+
{ type: 'file', path: fileName }
|
|
91
89
|
]
|
|
92
90
|
})
|
|
93
91
|
});
|
|
94
|
-
|
|
95
92
|
}
|
|
96
93
|
|
|
97
94
|
async deleteDirectory(theme, folderName, bearerToken) {
|
|
@@ -104,13 +101,12 @@ class Tsoft {
|
|
|
104
101
|
body: JSON.stringify({
|
|
105
102
|
theme: theme,
|
|
106
103
|
items: [
|
|
107
|
-
{type: 'dir', path: folderName}
|
|
104
|
+
{ type: 'dir', path: folderName }
|
|
108
105
|
]
|
|
109
106
|
})
|
|
110
107
|
});
|
|
111
108
|
}
|
|
112
109
|
|
|
113
|
-
|
|
114
110
|
async isTokenValid(theme) {
|
|
115
111
|
const env = this.themeManager.getEnvironment(theme);
|
|
116
112
|
return await this.clientCredentials.validateToken(env.bearer);
|
|
@@ -136,7 +132,6 @@ class Tsoft {
|
|
|
136
132
|
async startRecovery(token) {
|
|
137
133
|
return await this.clientCredentials.recovery(token);
|
|
138
134
|
}
|
|
139
|
-
|
|
140
135
|
}
|
|
141
136
|
|
|
142
137
|
module.exports = Tsoft;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { Select, Input } = require('enquirer');
|
|
4
|
+
const { slugify, clearScreen } = require('../core/Utils');
|
|
5
|
+
const ThemeManager = require('../core/ThemeManager');
|
|
6
|
+
const { start } = require('./StartCommand');
|
|
7
|
+
|
|
8
|
+
class CreateCommand {
|
|
9
|
+
static async getSites() {
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
return fs.readdirSync(cwd).filter(file => {
|
|
12
|
+
return file.charAt(0) !== '.' && !['node_modules', 'build', 'dist'].includes(file);
|
|
13
|
+
}).filter(file => fs.statSync(path.join(cwd, file)).isDirectory());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static async selectSite(sites) {
|
|
17
|
+
const siteChoices = [...sites, 'Yeni bir site oluştur'];
|
|
18
|
+
const sitePrompt = new Select({
|
|
19
|
+
name: 'site',
|
|
20
|
+
message: 'Çalışmak istediğiniz sitenin adı:',
|
|
21
|
+
choices: siteChoices
|
|
22
|
+
});
|
|
23
|
+
const selectedSite = await sitePrompt.run();
|
|
24
|
+
return selectedSite === 'Yeni bir site oluştur' ? await this.createNewSite() : selectedSite;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static async createNewSite() {
|
|
28
|
+
const newSitePrompt = new Input({
|
|
29
|
+
name: 'newSite',
|
|
30
|
+
message: 'Yeni site adı:'
|
|
31
|
+
});
|
|
32
|
+
const siteName = await newSitePrompt.run();
|
|
33
|
+
const themeManager = new ThemeManager(siteName);
|
|
34
|
+
const isValid = await this.validateSiteName(themeManager, siteName);
|
|
35
|
+
return isValid ? siteName : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static async validateSiteName(themeManager, siteName) {
|
|
39
|
+
try {
|
|
40
|
+
const isValid = await themeManager.checkSiteValidity(siteName);
|
|
41
|
+
if (!isValid) {
|
|
42
|
+
console.error('Geçersiz site adı. Lütfen geçerli bir site adı girin.');
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error('Site doğrulaması sırasında hata oluştu:', error.message);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static async getThemeDetails() {
|
|
53
|
+
const themeNamePrompt = new Input({
|
|
54
|
+
name: 'themeName',
|
|
55
|
+
message: 'Tema adı:'
|
|
56
|
+
});
|
|
57
|
+
const authorPrompt = new Input({
|
|
58
|
+
name: 'author',
|
|
59
|
+
message: 'Author (isteğe bağlı):'
|
|
60
|
+
});
|
|
61
|
+
const versionPrompt = new Input({
|
|
62
|
+
name: 'version',
|
|
63
|
+
message: 'Version (isteğe bağlı, varsayılan 1.0.0):',
|
|
64
|
+
initial: '1.0.0'
|
|
65
|
+
});
|
|
66
|
+
const themeName = await themeNamePrompt.run();
|
|
67
|
+
const author = await authorPrompt.run();
|
|
68
|
+
const version = await versionPrompt.run();
|
|
69
|
+
return { themeName, author, version };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static async createThemeDirectory(siteName, themeNameSlug) {
|
|
73
|
+
const cwd = process.cwd();
|
|
74
|
+
const themePath = path.join(cwd, siteName, themeNameSlug);
|
|
75
|
+
if (!fs.existsSync(themePath)) {
|
|
76
|
+
fs.mkdirSync(themePath, { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
return themePath;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static async saveThemeData(themePath, themeData) {
|
|
82
|
+
fs.writeFileSync(path.join(themePath, '.theme'), JSON.stringify(themeData, null, 2));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static async createTheme() {
|
|
86
|
+
const sites = await this.getSites();
|
|
87
|
+
const siteName = await this.selectSite(sites);
|
|
88
|
+
if (!siteName) return;
|
|
89
|
+
const { themeName, author, version } = await this.getThemeDetails();
|
|
90
|
+
const themeNameSlug = slugify(themeName);
|
|
91
|
+
const themePath = await this.createThemeDirectory(siteName, themeNameSlug);
|
|
92
|
+
const themeData = { site: siteName, name: themeName, author: author, version: version };
|
|
93
|
+
await this.saveThemeData(themePath, themeData);
|
|
94
|
+
clearScreen();
|
|
95
|
+
console.log(`Tema "${themeName}" başarıyla oluşturuldu.`);
|
|
96
|
+
await start(siteName, themeNameSlug, true);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = CreateCommand;
|