tsoft-cli 1.4.1 → 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 +7 -1
- package/bin/index.js +4 -2
- package/package.json +1 -1
- package/src/commands/CreateCommand.js +17 -15
- package/src/core/Utils.js +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -73,4 +73,10 @@
|
|
|
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.
|
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
|
|
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,18 +1,11 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const {
|
|
4
|
-
const {
|
|
3
|
+
const {Select, Input} = require('enquirer');
|
|
4
|
+
const {slugify, clearScreen, getSites} = require('../core/Utils');
|
|
5
5
|
const ThemeManager = require('../core/ThemeManager');
|
|
6
|
-
const {
|
|
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 {
|
|
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, {
|
|
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
|
|
87
|
+
const sites = await getSites();
|
|
87
88
|
const siteName = await this.selectSite(sites);
|
|
88
89
|
if (!siteName) return;
|
|
89
|
-
|
|
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 = {
|
|
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.`);
|
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;
|