tsoft-cli 1.2.2 → 1.3.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 +7 -1
- package/package.json +1 -1
- package/src/commands/create.js +3 -2
- package/src/commands/start.js +18 -3
- package/src/commands/sync.js +4 -11
- package/src/file-manager.js +2 -2
- package/src/utils.js +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -44,4 +44,10 @@
|
|
|
44
44
|
|
|
45
45
|
### Fixed
|
|
46
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.
|
|
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ı.
|
package/package.json
CHANGED
package/src/commands/create.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const {Select, Input} = require('enquirer');
|
|
4
|
-
const {slugify} = require('../utils');
|
|
4
|
+
const {slugify, clearScreen} = require('../utils');
|
|
5
5
|
const {start} = require('./start');
|
|
6
6
|
const ThemeManager = require('../theme-manager');
|
|
7
7
|
|
|
@@ -116,9 +116,10 @@ async function createTheme() {
|
|
|
116
116
|
|
|
117
117
|
await saveThemeData(themePath, themeData);
|
|
118
118
|
|
|
119
|
+
clearScreen();
|
|
119
120
|
console.log(`Tema "${themeName}" başarıyla oluşturuldu.`);
|
|
120
121
|
|
|
121
|
-
await start(siteName, themeNameSlug);
|
|
122
|
+
await start(siteName, themeNameSlug, true);
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
module.exports = {
|
package/src/commands/start.js
CHANGED
|
@@ -7,7 +7,7 @@ const Tsoft = require('../tsoft');
|
|
|
7
7
|
const constants = require('../constants');
|
|
8
8
|
const cliProgress = require('cli-progress');
|
|
9
9
|
const { Input } = require('enquirer');
|
|
10
|
-
const { displayAsciiArt, clearScreen, info } = require('../utils');
|
|
10
|
+
const { displayAsciiArt, clearScreen, info, unzipFile } = require('../utils');
|
|
11
11
|
|
|
12
12
|
async function showProgress(tsoft, theme) {
|
|
13
13
|
const themePath = path.join(process.cwd(), tsoft.site, theme);
|
|
@@ -55,7 +55,7 @@ async function initializeAndAuthorize(tsoft, themeName) {
|
|
|
55
55
|
if (approval) {
|
|
56
56
|
await constants.APPROVAL.handler(tsoft.clientCredentials.setClientSecret(approval));
|
|
57
57
|
tsoft.buildEnvironment();
|
|
58
|
-
console.info('
|
|
58
|
+
console.info('Ortam dosyası başarıyla oluşturuldu.');
|
|
59
59
|
return true;
|
|
60
60
|
} else {
|
|
61
61
|
console.error('Onay kodu gerekli.');
|
|
@@ -210,7 +210,7 @@ async function handleUserInput(input, tsoft, theme, watcher, rl) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
async function start(siteName, themeName) {
|
|
213
|
+
async function start(siteName, themeName, recentlyCreated = false) {
|
|
214
214
|
await displayAsciiArt();
|
|
215
215
|
console.log('Geliştirme ortamı aşağıdaki ayrıntılarla başlatılıyor:');
|
|
216
216
|
console.log(`Site Adı: ${siteName}`);
|
|
@@ -227,6 +227,21 @@ async function start(siteName, themeName) {
|
|
|
227
227
|
|
|
228
228
|
const initializedAndAuthorized = await initializeAndAuthorize(tsoft, themeName);
|
|
229
229
|
if (initializedAndAuthorized) {
|
|
230
|
+
if(recentlyCreated) {
|
|
231
|
+
const defaultZipFile = path.join(process.cwd(), siteName, themeName, 'theme.zip');
|
|
232
|
+
console.log('Default tema dosyaları indirme işlemi başlatılıyor, lütfen bekleyin');
|
|
233
|
+
const themePath = path.join(process.cwd(), siteName, themeName)
|
|
234
|
+
await tsoft.fileManager.downloadAndSaveZip(
|
|
235
|
+
themePath, defaultZipFile,
|
|
236
|
+
tsoft.clientCredentials.bearer,
|
|
237
|
+
'default'
|
|
238
|
+
);
|
|
239
|
+
console.log('Default tema dosyaları indirildi. Çıkarma işlemi başlatılıyor');
|
|
240
|
+
await unzipFile(defaultZipFile, themePath);
|
|
241
|
+
console.log('Çıkarma işlemi tamamlandı.');
|
|
242
|
+
fs.unlinkSync(defaultZipFile);
|
|
243
|
+
}
|
|
244
|
+
|
|
230
245
|
await startWatching(path.join(process.cwd(), siteName, themeName), tsoft, themeName);
|
|
231
246
|
}
|
|
232
247
|
}
|
package/src/commands/sync.js
CHANGED
|
@@ -4,17 +4,10 @@ const {Input} = require('enquirer');
|
|
|
4
4
|
const {clearScreen} = require('../utils');
|
|
5
5
|
const {selectSite, createThemeDirectory} = require('./create');
|
|
6
6
|
const Tsoft = require("../tsoft");
|
|
7
|
-
const {slugify} = require('../utils');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return new Promise((resolve, reject) => {
|
|
12
|
-
fs.createReadStream(zipFilePath)
|
|
13
|
-
.pipe(unzipper.Extract({path: extractToDir}))
|
|
14
|
-
.on('close', resolve)
|
|
15
|
-
.on('error', reject);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
7
|
+
const {slugify, unzipFile} = require('../utils');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
18
11
|
|
|
19
12
|
async function syncTheme() {
|
|
20
13
|
const cwd = process.cwd();
|
package/src/file-manager.js
CHANGED
|
@@ -37,9 +37,9 @@ class FileManager {
|
|
|
37
37
|
return utils.allowedExtensions.includes(ext);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async downloadAndSaveZip(saveToDir, zipFilePath, bearerToken) {
|
|
40
|
+
async downloadAndSaveZip(saveToDir, zipFilePath, bearerToken, type = 'none') {
|
|
41
41
|
// Fetch the zip file and save it
|
|
42
|
-
const response = await buildDownloadZipRequest(this.site, `api/v3/admin/online-store-2/theme/download-theme`, {
|
|
42
|
+
const response = await buildDownloadZipRequest(this.site, `api/v3/admin/online-store-2/theme/download-theme?type=${type}`, {
|
|
43
43
|
headers: {
|
|
44
44
|
'Content-Type': 'application/zip',
|
|
45
45
|
'Accept': 'application/zip',
|
package/src/utils.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
const figlet = require("figlet");
|
|
2
|
+
const packageJson = require('../package.json');
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const unzipper = require("unzipper");
|
|
5
|
+
|
|
2
6
|
module.exports = {
|
|
3
7
|
slugify: function (text) {
|
|
4
8
|
return text.toString().toLowerCase()
|
|
@@ -26,6 +30,8 @@ module.exports = {
|
|
|
26
30
|
console.log(data);
|
|
27
31
|
resolve();
|
|
28
32
|
});
|
|
33
|
+
}).then(() => {
|
|
34
|
+
console.log('Versiyon: ' + packageJson.version);
|
|
29
35
|
});
|
|
30
36
|
},
|
|
31
37
|
info: function () {
|
|
@@ -40,6 +46,14 @@ module.exports = {
|
|
|
40
46
|
'* *\n' +
|
|
41
47
|
'********************************************************\n'
|
|
42
48
|
);
|
|
49
|
+
},
|
|
50
|
+
unzipFile: function (zipFilePath, extractToDir) {
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
fs.createReadStream(zipFilePath)
|
|
53
|
+
.pipe(unzipper.Extract({path: extractToDir}))
|
|
54
|
+
.on('close', resolve)
|
|
55
|
+
.on('error', reject);
|
|
56
|
+
});
|
|
43
57
|
}
|
|
44
58
|
|
|
45
59
|
}
|