shoplazza-cli 0.0.8 → 0.0.10
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/lib/app/commands/deploy.js +8 -1
- package/lib/utils.js +21 -1
- package/package.json +1 -1
|
@@ -76,7 +76,7 @@ const getSign = async () => {
|
|
|
76
76
|
const partnerId = getValue(PARTNER_KEYS.PARTNER_ID);
|
|
77
77
|
const sessionId = getValue(PARTNER_KEYS.SESSION_ID);
|
|
78
78
|
|
|
79
|
-
const url = `${PARNTER_URL}/api/partner/apps/${app.uid}/theme_extensions/file/
|
|
79
|
+
const url = `${PARNTER_URL}/api/partner/apps/${app.uid}/theme_extensions/file/signv2`;
|
|
80
80
|
const res = await axios.get(url, {
|
|
81
81
|
headers: {
|
|
82
82
|
Cookie: `awesomev2=${sessionId}`,
|
|
@@ -107,6 +107,7 @@ const deployOss = async () => {
|
|
|
107
107
|
formData.append('OSSAccessKeyId', signData.access_id);
|
|
108
108
|
formData.append('success_action_status', 200);
|
|
109
109
|
formData.append('signature', signData.sign);
|
|
110
|
+
formData.append('x-oss-forbid-overwrite', 'true');
|
|
110
111
|
formData.append('key', md5);
|
|
111
112
|
formData.append('file', buffer);
|
|
112
113
|
|
|
@@ -123,6 +124,12 @@ const deployOss = async () => {
|
|
|
123
124
|
spinner.succeed();
|
|
124
125
|
return md5;
|
|
125
126
|
} catch (e) {
|
|
127
|
+
// 409 repeat filename
|
|
128
|
+
if (e?.response?.status === 409) {
|
|
129
|
+
spinner.succeed();
|
|
130
|
+
return md5;
|
|
131
|
+
}
|
|
132
|
+
|
|
126
133
|
spinner.fail();
|
|
127
134
|
console.log(chalk.red(e.message || e));
|
|
128
135
|
}
|
package/lib/utils.js
CHANGED
|
@@ -5,6 +5,8 @@ const chalk = require('chalk');
|
|
|
5
5
|
|
|
6
6
|
const { SSO_AUTH_URL, ACCOUNT_URL, CLIENT_ID, DEV_SSO_AUTH_URL, DEV_ACCOUNT_URL, DEV_CLIENT_ID } = require('./config');
|
|
7
7
|
|
|
8
|
+
const ZIP_IGNORE_FOLDER = ['.git', '.DS_Store'];
|
|
9
|
+
|
|
8
10
|
exports.unzipTheme = (zipPath, outputPath) => {
|
|
9
11
|
const zip = new AdmZip(zipPath);
|
|
10
12
|
const zipEntries = zip.getEntries();
|
|
@@ -22,7 +24,25 @@ exports.unzipTheme = (zipPath, outputPath) => {
|
|
|
22
24
|
|
|
23
25
|
exports.zipTheme = (filePath, themeName) => {
|
|
24
26
|
const zip = new AdmZip();
|
|
25
|
-
|
|
27
|
+
// Old code
|
|
28
|
+
// zip.addLocalFolder(filePath, themeName);
|
|
29
|
+
|
|
30
|
+
// zip, but ignore some folder
|
|
31
|
+
const lsDir = fs.readdirSync(filePath);
|
|
32
|
+
lsDir.forEach((lsItem) => {
|
|
33
|
+
const lsItemStat = fs.statSync(path.join(filePath, lsItem));
|
|
34
|
+
|
|
35
|
+
if (ZIP_IGNORE_FOLDER.includes(lsItem)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (lsItemStat.isDirectory()) {
|
|
40
|
+
zip.addLocalFolder(path.join(filePath, lsItem), path.join(themeName, lsItem));
|
|
41
|
+
} else if (lsItemStat.isFile()) {
|
|
42
|
+
zip.addLocalFile(path.join(filePath, lsItem), path.join(themeName, lsItem));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
26
46
|
zip.writeZip(`${process.cwd()}/${themeName}.zip`);
|
|
27
47
|
};
|
|
28
48
|
|