tsoft-cli 1.4.1 → 1.4.3

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
@@ -73,4 +73,16 @@
73
73
 
74
74
  ## [1.4.1] - 2024-06-20
75
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.
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 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.1",
3
+ "version": "1.4.3",
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": {
@@ -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({
@@ -21,7 +14,7 @@ class CreateCommand {
21
14
  choices: siteChoices
22
15
  });
23
16
  const selectedSite = await sitePrompt.run();
24
- return selectedSite === 'Yeni bir site oluştur' ? await this.createNewSite() : selectedSite;
17
+ return selectedSite === 'Yeni bir site oluştur' ? await CreateCommand.createNewSite() : selectedSite;
25
18
  }
26
19
 
27
20
  static async createNewSite() {
@@ -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.`);
@@ -13,6 +13,7 @@ class StartCommand {
13
13
  static async showProgress(tsoft, theme) {
14
14
  const themePath = path.join(process.cwd(), tsoft.site, theme);
15
15
  const fileList = tsoft.fileManager.listFilesRecursive(themePath).filter(file => !file.includes('.env'));
16
+ fileList.push(path.join(themePath, '.theme'));
16
17
  const totalFiles = fileList.length;
17
18
 
18
19
  const progressBar = new cliProgress.SingleBar({
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) {
@@ -86,6 +87,18 @@ class Utils {
86
87
  .on('error', reject);
87
88
  });
88
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
+
89
102
  }
90
103
 
91
104
  module.exports = Utils;