tsoft-cli 1.4.3 → 2.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.
package/README.md CHANGED
@@ -1,118 +1,53 @@
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
-
3
- T-Soft CLI Kullanım Kılavuzu
4
- ============================
1
+ # T-Soft CLI
5
2
 
6
3
  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
4
 
8
- Gereksinimler
9
- -------------
5
+ ## Gereksinimler
10
6
 
11
- * Node.js (v14.0.0 veya üstü)
12
- * NPM veya Yarn
7
+ - Node.js (v18.0.0 veya üstü)
8
+ - NPM veya Yarn
13
9
 
14
- Kurulum
15
- -------
10
+ ## Kurulum
16
11
 
17
12
  1. Proje dosyalarını bilgisayarınıza indirin.
18
13
  2. Proje dizinine gidin ve gerekli bağımlılıkları yükleyin:
19
14
 
20
- npm install tsoft-cli
15
+ ```sh
16
+ npm install tsoft-cli
17
+ ```
21
18
 
22
- veya
19
+ veya
23
20
 
24
- yarn add tsoft-cli
21
+ ```sh
22
+ yarn add tsoft-cli
23
+ ```
25
24
 
26
25
  3. Veya global olarak yükleyin:
27
26
 
28
- npm install -g tsoft-cli
27
+ ```sh
28
+ npm install -g tsoft-cli
29
+ ```
30
+
31
+ veya
29
32
 
30
- veya
33
+ ```sh
34
+ yarn global add tsoft-cli
35
+ ```
31
36
 
32
- yarn global add tsoft-cli
33
- Başlatma
34
- --------
37
+ ## Başlatma
35
38
 
36
39
  CLI uygulamasını başlatmak için aşağıdaki komutu kullanın:
37
40
 
38
- npx tsoft-cli
41
+ ```sh
42
+ npx tsoft-cli
43
+ ```
39
44
 
40
45
  veya global olarak yüklediyseniz:
41
-
42
- tsoft-cli
43
-
44
- Ana Menü
45
- --------
46
-
47
- CLI başlatıldığında ana menü karşınıza gelecektir. Ana menüde şu seçenekler bulunmaktadır:
48
-
49
- 1. Yeni bir tema oluştur
50
- 2. Geliştirme ortamını başlat
51
- 3. Uzak sunucudan dosyaları indir
52
- 4. Çıkış
53
-
54
- ### 1\. Yeni bir tema oluştur
55
-
56
- Yeni bir tema oluşturmak için bu seçeneği kullanabilirsiniz. Adımlar:
57
-
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.
62
-
63
- ### 2\. Geliştirme ortamını başlat
64
-
65
- Mevcut bir temayla çalışmak için geliştirme ortamını başlatabilirsiniz. Adımlar:
66
-
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.
71
-
72
- ### 3\. Uzak sunucudan dosyaları indir
73
-
74
- Uzak sunucudan tema dosyalarını indirmek için bu seçeneği kullanabilirsiniz. Adımlar:
75
-
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.
80
-
81
- ### 4\. Çıkış
82
-
83
- CLI uygulamasından çıkmak için bu seçeneği kullanabilirsiniz.
84
-
85
- Temel Komutlar ve Kullanımlar
86
- -----------------------------
87
-
88
- **Tema Yaratma:**
89
-
90
- Ana menüden "Yeni bir tema oluştur" seçeneğini takip edin.
91
-
92
- **Geliştirme Ortamı Başlatma:**
93
-
94
- Ana menüden "Geliştirme ortamını başlat" seçeneğini takip edin.
95
-
96
- **Uzak Sunucudan Dosya İndirme:**
97
-
98
- Ana menüden "Uzak sunucudan dosyaları indir" seçeneğini takip edin.
99
-
100
- Dosya Yapısı
101
- ------------
102
46
 
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.
47
+ ```sh
48
+ tsoft-cli
49
+ ```
114
50
 
115
- İletişim ve Destek
116
- ------------------
51
+ ## İletişim ve Destek
117
52
 
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!
53
+ 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/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execute } from '@oclif/core'
4
+
5
+ await execute({ dir: import.meta.url })
@@ -0,0 +1 @@
1
+ export declare const packageJson: any;
package/build/enums.js ADDED
@@ -0,0 +1,4 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ export const packageJson = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8'));
4
+ //# sourceMappingURL=enums.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../enums.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { CLIAllCommands, VersionCommand } from '@tsoft-cli/shared';
2
+ export declare const COMMANDS: {
3
+ commands: typeof CLIAllCommands;
4
+ version: typeof VersionCommand;
5
+ };
package/build/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import theme from '@tsoft-cli/theme';
2
+ import { CLIAllCommands, VersionCommand } from '@tsoft-cli/shared';
3
+ import { packageJson } from './enums.js';
4
+ VersionCommand.version = packageJson.version;
5
+ export const COMMANDS = {
6
+ ...theme,
7
+ [CLIAllCommands.cliTopic]: CLIAllCommands,
8
+ [VersionCommand.cliTopic]: VersionCommand,
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,cAAc,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,CAAA;AAE5C,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,GAAG,KAAK;IACR,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,cAAc;IACzC,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,cAAc;CAC1C,CAAA"}
package/package.json CHANGED
@@ -1,31 +1,59 @@
1
1
  {
2
2
  "name": "tsoft-cli",
3
- "version": "1.4.3",
4
- "description": "A theme development cli for developers who want to create themes for T-Soft.",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "jest"
8
- },
9
- "keywords": [],
10
- "author": "",
3
+ "version": "2.0.1",
4
+ "description": "T-Soft CLI Application",
5
+ "author": "T-Soft",
11
6
  "license": "ISC",
7
+ "type": "module",
8
+ "packageManager": "pnpm@9.9.0",
9
+ "main": "/build/index.js",
10
+ "types": "/build/index.d.ts",
12
11
  "bin": {
13
- "tsoft-cli": "./bin/index.js"
12
+ "tsoft-cli": "./bin/run.js"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc"
14
16
  },
15
17
  "dependencies": {
16
- "chokidar": "^3.6.0",
17
- "cli-progress": "^3.12.0",
18
- "commander": "^12.1.0",
19
- "enquirer": "^2.4.1",
20
- "figlet": "^1.7.0",
21
- "fs": "^0.0.1-security",
22
- "node-fetch": "^3.3.2",
23
- "open": "^10.1.0",
24
- "unzipper": "^0.12.1"
18
+ "@oclif/core": "4.0.21",
19
+ "@tsoft-cli/theme": "1.0.0",
20
+ "@tsoft-cli/shared": "1.0.0"
25
21
  },
26
- "type": "commonjs",
27
22
  "devDependencies": {
28
- "jest": "^29.7.0",
29
- "mock-fs": "^5.2.0"
23
+ "@types/node": "^22.5.2",
24
+ "ts-node": "^10.9.2",
25
+ "typescript": "^5.5.4"
26
+ },
27
+ "oclif": {
28
+ "bin": "tsoft-cli",
29
+ "dirname": "tsoft-cli",
30
+ "commands": {
31
+ "strategy": "explicit",
32
+ "target": "./build/index.js",
33
+ "identifier": "COMMANDS"
34
+ },
35
+ "topicSeparator": " ",
36
+ "topics": {
37
+ "theme": {
38
+ "description": "Tema işlemleri"
39
+ }
40
+ }
41
+ },
42
+ "files": [
43
+ "build"
44
+ ],
45
+ "exports": {
46
+ ".": {
47
+ "import": "./build/index.js",
48
+ "types": "./build/index.d.ts"
49
+ }
50
+ },
51
+ "engines": {
52
+ "node": ">= 18"
53
+ },
54
+ "homepage": "https://github.com/tekrom/tsoft-cli/tree/main/packages/cli",
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/tekrom/tsoft-cli.git"
30
58
  }
31
59
  }
package/CHANGELOG.md DELETED
@@ -1,88 +0,0 @@
1
- # Changelog
2
-
3
- ## [1.2.0] - 2024-06-12
4
- ### Added
5
- - Yeni site ismi girildiğinde geçerli olup olmadığını kontrol eden özellik eklendi.
6
- - Kullanıcı komut satırı etkileşimleri için `enquirer` kütüphanesi kullanımı güncellendi.
7
- - Dosya izleme ve tema güncelleme özellikleri geliştirildi.
8
-
9
- ### Changed
10
- - `ThemeManager` sınıfı geliştirildi ve yeni yöntemler eklendi.
11
- - `start.js` dosyasında önemli iyileştirmeler yapıldı.
12
- - `create.js` dosyasında kullanıcı girişleri doğrulandı ve daha kullanıcı dostu hale getirildi.
13
-
14
- ### Fixed
15
- - Birkaç hata düzeltildi ve genel kod kalitesi iyileştirildi.
16
-
17
- # Changelog
18
-
19
- ## [1.2.1] - 2024-06-13
20
- ### Added
21
- - T-Soft CLI'de yeni bir site oluşturma ve geçerliliğini kontrol etme özelliği eklendi.
22
-
23
- ### Changed
24
- - `start.js` ve `create.js` dosyalarında refaktörizasyon yapıldı.
25
- - T-Soft CLI ana menüsü, site ve tema seçimlerinin interaktif hale getirilmesi amacıyla güncellendi.
26
- - Tüm metinler Türkçeleştirildi ve kullanıcıya daha açıklayıcı mesajlar sağlandı.
27
-
28
- ### Fixed
29
- - Geliştirme ortamı başlatıldığında programın beklenmedik şekilde kapanmasına sebep olan hata giderildi.
30
- - T-Soft CLI'nın `start.js` dosyasında initialize fonksiyonunun doğru şekilde çalışmaması sorunu çözüldü.
31
-
32
- # Changelog
33
-
34
- ## [1.2.2] - 2024-06-14
35
- ### Added
36
- - Kurtarma anahtarı ile tema senkronizasyonu yapan `syncTheme` fonksiyonu eklendi.
37
- - `syncTheme` fonksiyonu zip dosyasını indirip açma işlemi gerçekleştiriyor.
38
- - Tema bilgilerini içeren `.theme` dosyası oluşturma ve `theme.env` dosyası yaratma işlemleri eklendi.
39
- - Kullanıcı komut satırı etkileşimleri için `enquirer` kütüphanesi kullanıldı.
40
-
41
- ### Changed
42
- - `unzipFile` fonksiyonu eklendi, zip dosyalarını açmak için kullanılıyor.
43
- - `sync.js` dosyasında kullanıcıdan kurtarma anahtarı alınarak gerekli işlemlerin yapılması sağlandı.
44
-
45
- ### Fixed
46
- - Zip dosyasının indirildikten sonra otomatik olarak silinmesi sağlandı.
47
- - `sync.js` dosyasında oluşan hatalar giderildi ve kod kalitesi iyileştirildi.
48
-
49
- ## [1.2.3] - 2024-06-14
50
-
51
- ### Fixed
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ı.
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.
73
-
74
- ## [1.4.1] - 2024-06-20
75
- ### Added
76
- - `p` tuşuna basıldığında tarayıcıda URL'yi açma özelliği eklendi. Temaların çalışma zamanında önizlemesini sağlanabilmektedir.
77
-
78
- ## [1.4.2] - 2024-06-21
79
- ### Changed
80
- - `Yeni Bir Tema Oluştur` seçeneği seçildiğinde, `.tsoft` dosyası olmayan dizinler listelenmeyecek şekilde güncellendi.
81
- - `createTheme` fonksiyonu, yeni bir site oluşturulduğunda `.tsoft` dosyasını da otomatik olarak oluşturacak şekilde güncellendi.
82
- - `Geliştirme ortamını başlat` seçeneği seçildiğinde, `.tsoft` dosyası olmayan dizinler listelenmeyecek şekilde güncellendi.
83
-
84
- ## [1.4.3] - 2024-06-21
85
- ### Changed
86
- - `.theme` dosyası artık tema dosyaları ile birlikte yüklenmektedir. Bu sayade, temaların meta bilgileri güncel tutulmaktadır.
87
- ### Fixed
88
- - `Yeni bir site oluştur` seçeneği seçildiğinde, `createNewSite` fonksiyonu çalıştırıldığında oluşan hata giderildi.
package/bin/index.js DELETED
@@ -1,77 +0,0 @@
1
- #!/usr/bin/env node
2
-
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, getSites } = require('../src/core/Utils');
8
- const fs = require('fs');
9
- const path = require('path');
10
-
11
- async function getDirectories(source) {
12
- return fs.readdirSync(source).filter(file => {
13
- return file.charAt(0) !== '.' && !['node_modules', 'build', 'dist'].includes(file);
14
- }).filter(file => fs.statSync(path.join(source, file)).isDirectory());
15
- }
16
-
17
- async function selectFromChoices(message, choices) {
18
- const prompt = new Select({
19
- name: 'selection',
20
- message: message,
21
- choices: choices
22
- });
23
-
24
- return await prompt.run();
25
- }
26
-
27
- async function selectSiteAndTheme() {
28
- const cwd = process.cwd();
29
- const sites = await getSites({
30
- cwd: cwd
31
- });
32
-
33
- if (sites.length === 0) {
34
- console.error('Mevcut dizinde site bulunamadı.');
35
- return null;
36
- }
37
-
38
- const selectedSite = await selectFromChoices('Bir site seçin:', sites);
39
- const themes = await getDirectories(path.join(cwd, selectedSite));
40
-
41
- if (themes.length === 0) {
42
- console.error('Seçilen site dizininde tema bulunamadı.');
43
- return null;
44
- }
45
-
46
- const selectedTheme = await selectFromChoices('Bir tema seçin:', themes);
47
-
48
- return { siteName: selectedSite, themeName: selectedTheme };
49
- }
50
-
51
- async function showMainMenu() {
52
- clearScreen();
53
- await displayAsciiArt();
54
-
55
- const commandChoices = ['Yeni bir tema oluştur', 'Geliştirme ortamını başlat', 'Uzak sunucudan dosyaları indir', 'Çıkış'];
56
- const selectedCommand = await selectFromChoices('Bir komut seçin:', commandChoices);
57
-
58
- switch (selectedCommand) {
59
- case 'Yeni bir tema oluştur':
60
- await CreateCommand.createTheme();
61
- break;
62
- case 'Geliştirme ortamını başlat':
63
- const selection = await selectSiteAndTheme();
64
- if (selection) {
65
- await StartCommand.start(selection.siteName, selection.themeName);
66
- }
67
- break;
68
- case 'Uzak sunucudan dosyaları indir':
69
- await SyncCommand.syncTheme();
70
- break;
71
- case 'Çıkış':
72
- console.log('Programdan çıkılıyor. Hoşça kalın!');
73
- process.exit(0);
74
- }
75
- }
76
-
77
- showMainMenu();
package/jest.config.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- testEnvironment: 'node',
3
- };
package/src/Tsoft.js DELETED
@@ -1,137 +0,0 @@
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
- const path = require("path");
6
- const { buildPostRequest } = require('./core/Request');
7
-
8
- class Tsoft {
9
- static TSOFT_CLI_UUID = '7583a318-8542-4ec8-980c-48ea67031be3';
10
- static ONLINESTORE_SAVE_URI = 'api/v3/admin/online-store-2/theme/file-manager?q=save';
11
- static ONLINESTORE_DELETE_URI = 'api/v3/admin/online-store-2/theme/file-manager?q=delete';
12
- static UPDATE_THEME_URI = 'api/v3/admin/online-store-2/theme/update-theme';
13
-
14
- constructor(site) {
15
- this.site = site;
16
- this.themeManager = new ThemeManager(site);
17
- this.fileManager = new FileManager(site);
18
- this.clientCredentials = new ClientCredentials(site);
19
- }
20
-
21
- async initialize(theme, reInit = false) {
22
- await this.themeManager.initializeTheme(theme, reInit);
23
- if (!this.themeManager.isRegistered()) {
24
- return await this.register(Tsoft.TSOFT_CLI_UUID, this.themeManager.getThemeInfo(theme));
25
- } else {
26
- console.warn('You are already registered');
27
- }
28
- }
29
-
30
- buildEnvironment() {
31
- this.themeManager.buildEnvironment(this.clientCredentials.getEnvironment());
32
- }
33
-
34
- async authorize() {
35
- await this.clientCredentials.authorize();
36
- }
37
-
38
- async register(CLIENT_UUID, clientConfiguration = {}) {
39
- const response = await this.clientCredentials.register(CLIENT_UUID, clientConfiguration);
40
- return response === true ? Constants.APPROVAL : null;
41
- }
42
-
43
- async saveOnlineStore(theme) {
44
- const fileList = this.fileManager.listFilesRecursive(
45
- path.join(process.cwd(), this.site, theme)
46
- );
47
- await Promise.all(fileList.filter(file => !file.includes('.env')).map(async file => {
48
- const fileName = this.fileManager.getRelativePath(theme, file);
49
- const content = this.fileManager.readFile(file);
50
- const env = this.themeManager.getEnvironment(theme);
51
- await buildPostRequest(this.site, Tsoft.ONLINESTORE_SAVE_URI, {
52
- headers: {
53
- Authorization: `Bearer ${env.bearer}`
54
- },
55
- body: JSON.stringify({
56
- theme: theme,
57
- path: fileName,
58
- content: content
59
- })
60
- });
61
- }));
62
- }
63
-
64
- async saveFile(theme, fileName, content, bearerToken) {
65
- return await buildPostRequest(this.site, Tsoft.ONLINESTORE_SAVE_URI, {
66
- headers: {
67
- Authorization: `Bearer ${bearerToken}`,
68
- Accept: 'application/json',
69
- 'Content-Type': 'application/json'
70
- },
71
- body: JSON.stringify({
72
- theme: theme,
73
- path: fileName,
74
- content: content
75
- })
76
- });
77
- }
78
-
79
- async deleteFile(theme, fileName, bearerToken) {
80
- return await buildPostRequest(this.site, Tsoft.ONLINESTORE_DELETE_URI, {
81
- headers: {
82
- Authorization: `Bearer ${bearerToken}`,
83
- 'Content-Type': 'application/json'
84
- },
85
- body: JSON.stringify({
86
- theme: theme,
87
- items: [
88
- { type: 'file', path: fileName }
89
- ]
90
- })
91
- });
92
- }
93
-
94
- async deleteDirectory(theme, folderName, bearerToken) {
95
- return await buildPostRequest(this.site, Tsoft.ONLINESTORE_DELETE_URI, {
96
- headers: {
97
- Authorization: `Bearer ${bearerToken}`,
98
- Accept: 'application/json',
99
- 'Content-Type': 'application/json'
100
- },
101
- body: JSON.stringify({
102
- theme: theme,
103
- items: [
104
- { type: 'dir', path: folderName }
105
- ]
106
- })
107
- });
108
- }
109
-
110
- async isTokenValid(theme) {
111
- const env = this.themeManager.getEnvironment(theme);
112
- return await this.clientCredentials.validateToken(env.bearer);
113
- }
114
-
115
- async updateTheme(directoryName) {
116
- const env = this.themeManager.getEnvironment(directoryName);
117
- const themeInfo = this.themeManager.getThemeInfo(directoryName); // .theme bilgisi alınıyor
118
-
119
- return await buildPostRequest(this.site, Tsoft.UPDATE_THEME_URI, {
120
- headers: {
121
- Authorization: `Bearer ${env.bearer}`,
122
- 'Accept': 'application/json',
123
- 'Content-Type': 'application/json'
124
- },
125
- body: JSON.stringify({
126
- theme: directoryName,
127
- themeInfo: themeInfo
128
- })
129
- });
130
- }
131
-
132
- async startRecovery(token) {
133
- return await this.clientCredentials.recovery(token);
134
- }
135
- }
136
-
137
- module.exports = Tsoft;
@@ -1,102 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const {Select, Input} = require('enquirer');
4
- const {slugify, clearScreen, getSites} = require('../core/Utils');
5
- const ThemeManager = require('../core/ThemeManager');
6
- const {start} = require('./StartCommand');
7
-
8
- class CreateCommand {
9
- static async selectSite(sites) {
10
- const siteChoices = [...sites, 'Yeni bir site oluştur'];
11
- const sitePrompt = new Select({
12
- name: 'site',
13
- message: 'Çalışmak istediğiniz sitenin adı:',
14
- choices: siteChoices
15
- });
16
- const selectedSite = await sitePrompt.run();
17
- return selectedSite === 'Yeni bir site oluştur' ? await CreateCommand.createNewSite() : selectedSite;
18
- }
19
-
20
- static async createNewSite() {
21
- const newSitePrompt = new Input({
22
- name: 'newSite',
23
- message: 'Yeni site adı:'
24
- });
25
- const siteName = await newSitePrompt.run();
26
- const themeManager = new ThemeManager(siteName);
27
- const isValid = await this.validateSiteName(themeManager, siteName);
28
- return isValid ? siteName : null;
29
- }
30
-
31
- static async validateSiteName(themeManager, siteName) {
32
- try {
33
- const isValid = await themeManager.checkSiteValidity(siteName);
34
- if (!isValid) {
35
- console.error('Geçersiz site adı. Lütfen geçerli bir site adı girin.');
36
- return false;
37
- }
38
- return true;
39
- } catch (error) {
40
- console.error('Site doğrulaması sırasında hata oluştu:', error.message);
41
- return false;
42
- }
43
- }
44
-
45
- static async getThemeDetails() {
46
- const themeNamePrompt = new Input({
47
- name: 'themeName',
48
- message: 'Tema adı:'
49
- });
50
- const authorPrompt = new Input({
51
- name: 'author',
52
- message: 'Author (isteğe bağlı):'
53
- });
54
- const versionPrompt = new Input({
55
- name: 'version',
56
- message: 'Version (isteğe bağlı, varsayılan 1.0.0):',
57
- initial: '1.0.0'
58
- });
59
- const themeName = await themeNamePrompt.run();
60
- const author = await authorPrompt.run();
61
- const version = await versionPrompt.run();
62
- return {themeName, author, version};
63
- }
64
-
65
- static async createThemeDirectory(siteName, themeNameSlug) {
66
- const cwd = process.cwd();
67
- const themePath = path.join(cwd, siteName, themeNameSlug);
68
- if (!fs.existsSync(themePath)) {
69
- fs.mkdirSync(themePath, {recursive: true});
70
- }
71
-
72
- const sitePath = path.join(process.cwd(), siteName);
73
- const tsoftFilePath = path.join(sitePath, '.tsoft');
74
- if (!fs.existsSync(tsoftFilePath)) {
75
- fs.writeFileSync(tsoftFilePath, '');
76
- }
77
-
78
-
79
- return themePath;
80
- }
81
-
82
- static async saveThemeData(themePath, themeData) {
83
- fs.writeFileSync(path.join(themePath, '.theme'), JSON.stringify(themeData, null, 2));
84
- }
85
-
86
- static async createTheme() {
87
- const sites = await getSites();
88
- const siteName = await this.selectSite(sites);
89
- if (!siteName) return;
90
-
91
- const {themeName, author, version} = await this.getThemeDetails();
92
- const themeNameSlug = slugify(themeName);
93
- const themePath = await this.createThemeDirectory(siteName, themeNameSlug);
94
- const themeData = {site: siteName, name: themeName, author: author, version: version};
95
- await this.saveThemeData(themePath, themeData);
96
- clearScreen();
97
- console.log(`Tema "${themeName}" başarıyla oluşturuldu.`);
98
- await start(siteName, themeNameSlug, true);
99
- }
100
- }
101
-
102
- module.exports = CreateCommand;