tsoft-cli 1.4.0 → 1.4.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 CHANGED
@@ -70,3 +70,13 @@
70
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
71
  - Geliştirme ortamını başlatma işlemi sırasında oluşabilecek hatalar giderildi.
72
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.
package/bin/index.js CHANGED
@@ -4,7 +4,7 @@ const { Select } = require('enquirer');
4
4
  const StartCommand = require('../src/commands/StartCommand');
5
5
  const SyncCommand = require('../src/commands/SyncCommand');
6
6
  const CreateCommand = require('../src/commands/CreateCommand');
7
- const { clearScreen, displayAsciiArt } = require('../src/core/Utils');
7
+ const { clearScreen, displayAsciiArt, getSites } = require('../src/core/Utils');
8
8
  const fs = require('fs');
9
9
  const path = require('path');
10
10
 
@@ -26,7 +26,9 @@ async function selectFromChoices(message, choices) {
26
26
 
27
27
  async function selectSiteAndTheme() {
28
28
  const cwd = process.cwd();
29
- const sites = await getDirectories(cwd);
29
+ const sites = await getSites({
30
+ cwd: cwd
31
+ });
30
32
 
31
33
  if (sites.length === 0) {
32
34
  console.error('Mevcut dizinde site bulunamadı.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsoft-cli",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
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": {
@@ -20,6 +20,7 @@
20
20
  "figlet": "^1.7.0",
21
21
  "fs": "^0.0.1-security",
22
22
  "node-fetch": "^3.3.2",
23
+ "open": "^10.1.0",
23
24
  "unzipper": "^0.12.1"
24
25
  },
25
26
  "type": "commonjs",
@@ -1,18 +1,11 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
- const { Select, Input } = require('enquirer');
4
- const { slugify, clearScreen } = require('../core/Utils');
3
+ const {Select, Input} = require('enquirer');
4
+ const {slugify, clearScreen, getSites} = require('../core/Utils');
5
5
  const ThemeManager = require('../core/ThemeManager');
6
- const { start } = require('./StartCommand');
6
+ const {start} = require('./StartCommand');
7
7
 
8
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
9
  static async selectSite(sites) {
17
10
  const siteChoices = [...sites, 'Yeni bir site oluştur'];
18
11
  const sitePrompt = new Select({
@@ -66,15 +59,23 @@ class CreateCommand {
66
59
  const themeName = await themeNamePrompt.run();
67
60
  const author = await authorPrompt.run();
68
61
  const version = await versionPrompt.run();
69
- return { themeName, author, version };
62
+ return {themeName, author, version};
70
63
  }
71
64
 
72
65
  static async createThemeDirectory(siteName, themeNameSlug) {
73
66
  const cwd = process.cwd();
74
67
  const themePath = path.join(cwd, siteName, themeNameSlug);
75
68
  if (!fs.existsSync(themePath)) {
76
- fs.mkdirSync(themePath, { recursive: true });
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, '');
77
76
  }
77
+
78
+
78
79
  return themePath;
79
80
  }
80
81
 
@@ -83,13 +84,14 @@ class CreateCommand {
83
84
  }
84
85
 
85
86
  static async createTheme() {
86
- const sites = await this.getSites();
87
+ const sites = await getSites();
87
88
  const siteName = await this.selectSite(sites);
88
89
  if (!siteName) return;
89
- const { themeName, author, version } = await this.getThemeDetails();
90
+
91
+ const {themeName, author, version} = await this.getThemeDetails();
90
92
  const themeNameSlug = slugify(themeName);
91
93
  const themePath = await this.createThemeDirectory(siteName, themeNameSlug);
92
- const themeData = { site: siteName, name: themeName, author: author, version: version };
94
+ const themeData = {site: siteName, name: themeName, author: author, version: version};
93
95
  await this.saveThemeData(themePath, themeData);
94
96
  clearScreen();
95
97
  console.log(`Tema "${themeName}" başarıyla oluşturuldu.`);
@@ -114,7 +114,7 @@ class StartCommand {
114
114
  output: process.stdout
115
115
  });
116
116
 
117
- info();
117
+ info(tsoft, theme);
118
118
 
119
119
  rl.on('line', async (input) => {
120
120
  await StartCommand.handleUserInput(input, tsoft, theme, watcher, rl);
@@ -159,7 +159,7 @@ class StartCommand {
159
159
  }
160
160
 
161
161
  static async handleUserInput(input, tsoft, theme, watcher, rl) {
162
- info();
162
+ info(tsoft, theme);
163
163
  switch (input.trim()) {
164
164
  case 'q':
165
165
  console.log('Dosya izleme işlemi sonlandırılıyor...');
package/src/core/Utils.js CHANGED
@@ -2,6 +2,7 @@ const figlet = require("figlet");
2
2
  const packageJson = require('../../package.json');
3
3
  const fs = require("fs");
4
4
  const unzipper = require("unzipper");
5
+ const path = require("path");
5
6
 
6
7
  class Utils {
7
8
  static slugify(text) {
@@ -40,8 +41,9 @@ class Utils {
40
41
  });
41
42
  }
42
43
 
43
- static info() {
44
+ static info(tsoft, theme) {
44
45
  Utils.clearScreen()
46
+
45
47
  console.log('\n' +
46
48
  '********************************************************\n' +
47
49
  '* *\n' +
@@ -50,9 +52,31 @@ class Utils {
50
52
  '* Temayı kaydetmek için "s" tuşuna basın, *\n' +
51
53
  '* .theme dosyasını düzenlemek için "e" tuşuna basın, *\n' +
52
54
  '* Tema dizinini açmak için "o" tuşuna basın. *\n' +
55
+ '* URL\'yi tarayıcıda açmak için "p" tuşuna basın. *\n' +
53
56
  '* *\n' +
54
57
  '********************************************************\n'
55
58
  );
59
+ const {clientId, clientSecret} = tsoft.themeManager.getEnvironment(theme);
60
+
61
+ const url = 'https://' + tsoft.site + '?tsoft-cli=' + clientId + '&tsoft-cli-secret=' + clientSecret;
62
+ console.log('İzlenen tema: ' + theme);
63
+ console.log('Önizleme: \n')
64
+ console.log(url+ '\n');
65
+
66
+ process.stdin.setRawMode(true);
67
+ process.stdin.resume();
68
+ process.stdin.on('data', async (key) => {
69
+ if (key.toString() === 'p') {
70
+ console.log('URL tarayıcıda açılıyor...');
71
+ const open = (await import('open')).default;
72
+ await open(url);
73
+ } else if (key.toString() === 'q') {
74
+ console.log('Programdan çıkılıyor. Hoşça kalın!');
75
+ process.exit(0);
76
+ }
77
+ // Other keypress handlers can go here
78
+ });
79
+
56
80
  }
57
81
 
58
82
  static unzipFile(zipFilePath, extractToDir) {
@@ -63,6 +87,18 @@ class Utils {
63
87
  .on('error', reject);
64
88
  });
65
89
  }
90
+
91
+ static async getSites(opt = {}) {
92
+ const cwd = opt.cwd ?? process.cwd();
93
+ return fs.readdirSync(cwd).filter(file => {
94
+ const filePath = path.join(cwd, file);
95
+ return file.charAt(0) !== '.'
96
+ && !['node_modules', 'build', 'dist'].includes(file)
97
+ && fs.statSync(filePath).isDirectory()
98
+ && fs.existsSync(path.join(filePath, '.tsoft'));
99
+ }).filter(file => fs.statSync(path.join(cwd, file)).isDirectory());
100
+ }
101
+
66
102
  }
67
103
 
68
104
  module.exports = Utils;