tsoft-cli 1.2.3 → 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/package.json +1 -1
- package/src/commands/create.js +1 -1
- 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 +11 -0
package/package.json
CHANGED
package/src/commands/create.js
CHANGED
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,5 +1,8 @@
|
|
|
1
1
|
const figlet = require("figlet");
|
|
2
2
|
const packageJson = require('../package.json');
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const unzipper = require("unzipper");
|
|
5
|
+
|
|
3
6
|
module.exports = {
|
|
4
7
|
slugify: function (text) {
|
|
5
8
|
return text.toString().toLowerCase()
|
|
@@ -43,6 +46,14 @@ module.exports = {
|
|
|
43
46
|
'* *\n' +
|
|
44
47
|
'********************************************************\n'
|
|
45
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
|
+
});
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
}
|