@codeleap/cli 5.8.13 → 5.8.20
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/dist/commands/convertorWebp.js +12 -77
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/package.json.bak +1 -1
|
@@ -53,8 +53,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
53
53
|
exports.convertorWebpCommand = void 0;
|
|
54
54
|
var Command_1 = require("../lib/Command");
|
|
55
55
|
var fs_1 = __importDefault(require("fs"));
|
|
56
|
-
|
|
57
|
-
var sharp_1 = __importDefault(require("sharp"));
|
|
56
|
+
// import sharp from 'sharp'
|
|
58
57
|
var lib_1 = require("../lib");
|
|
59
58
|
require("../lib/firebase");
|
|
60
59
|
var constants_1 = require("../constants");
|
|
@@ -69,11 +68,11 @@ exports.convertorWebpCommand = (0, Command_1.codeleapCommand)({
|
|
|
69
68
|
],
|
|
70
69
|
},
|
|
71
70
|
}, function (argv) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
-
var flags, _, settings, isMultipleConversion, isSingleConversion, filename, answers, files, inputFiles, _loop_1, inputFiles_1, inputFiles_1_1, inputFile
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
return __generator(this, function (
|
|
76
|
-
switch (
|
|
71
|
+
var flags, _, settings, isMultipleConversion, isSingleConversion, filename, answers, files, inputFiles, _loop_1, inputFiles_1, inputFiles_1_1, inputFile;
|
|
72
|
+
var e_1, _a;
|
|
73
|
+
var _b, _c;
|
|
74
|
+
return __generator(this, function (_d) {
|
|
75
|
+
switch (_d.label) {
|
|
77
76
|
case 0:
|
|
78
77
|
flags = argv.flags, _ = argv._;
|
|
79
78
|
settings = constants_1.USER_CONFIG['convertor-webp'];
|
|
@@ -88,9 +87,9 @@ exports.convertorWebpCommand = (0, Command_1.codeleapCommand)({
|
|
|
88
87
|
},
|
|
89
88
|
])];
|
|
90
89
|
case 1:
|
|
91
|
-
answers =
|
|
90
|
+
answers = _d.sent();
|
|
92
91
|
filename = answers.filename;
|
|
93
|
-
|
|
92
|
+
_d.label = 2;
|
|
94
93
|
case 2:
|
|
95
94
|
console.log('Starting conversion', settings);
|
|
96
95
|
if (!fs_1.default.existsSync(settings.output)) {
|
|
@@ -110,7 +109,7 @@ exports.convertorWebpCommand = (0, Command_1.codeleapCommand)({
|
|
|
110
109
|
inputFiles = fs_1.default.readdirSync(settings.input);
|
|
111
110
|
if (isMultipleConversion) {
|
|
112
111
|
_loop_1 = function (inputFile) {
|
|
113
|
-
var isCorrectFormat = (
|
|
112
|
+
var isCorrectFormat = (_c = (_b = settings === null || settings === void 0 ? void 0 : settings.convertor) === null || _b === void 0 ? void 0 : _b.inputFormats) === null || _c === void 0 ? void 0 : _c.some(function (_format) { return inputFile === null || inputFile === void 0 ? void 0 : inputFile.endsWith(_format); });
|
|
114
113
|
var isIgnoredFile = settings.convertor.ignoreFiles.includes(inputFile === null || inputFile === void 0 ? void 0 : inputFile.split('.')[0]);
|
|
115
114
|
if (isCorrectFormat && !isIgnoredFile) {
|
|
116
115
|
files.push(inputFile);
|
|
@@ -122,12 +121,12 @@ exports.convertorWebpCommand = (0, Command_1.codeleapCommand)({
|
|
|
122
121
|
_loop_1(inputFile);
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
|
-
catch (
|
|
124
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
126
125
|
finally {
|
|
127
126
|
try {
|
|
128
127
|
if (inputFiles_1_1 && !inputFiles_1_1.done && (_a = inputFiles_1.return)) _a.call(inputFiles_1);
|
|
129
128
|
}
|
|
130
|
-
finally { if (
|
|
129
|
+
finally { if (e_1) throw e_1.error; }
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
else {
|
|
@@ -145,71 +144,7 @@ exports.convertorWebpCommand = (0, Command_1.codeleapCommand)({
|
|
|
145
144
|
process.exit(1);
|
|
146
145
|
}
|
|
147
146
|
console.log('Files to convert', files);
|
|
148
|
-
|
|
149
|
-
var inputPath, outputPath, img, img_metadata, imageProcessing, needResize, newWidth, newHeight, hasAlfaChannels;
|
|
150
|
-
return __generator(this, function (_j) {
|
|
151
|
-
switch (_j.label) {
|
|
152
|
-
case 0:
|
|
153
|
-
inputPath = path_1.default.join(settings.input, file);
|
|
154
|
-
outputPath = path_1.default.join(settings.output, path_1.default.parse(file).name + '.webp');
|
|
155
|
-
if (fs_1.default.existsSync(outputPath)) {
|
|
156
|
-
fs_1.default.unlinkSync(outputPath);
|
|
157
|
-
}
|
|
158
|
-
img = (0, sharp_1.default)(inputPath);
|
|
159
|
-
return [4 /*yield*/, img.metadata()];
|
|
160
|
-
case 1:
|
|
161
|
-
img_metadata = _j.sent();
|
|
162
|
-
imageProcessing = img.webp({ quality: Number((_e = settings === null || settings === void 0 ? void 0 : settings.convertor) === null || _e === void 0 ? void 0 : _e.compressionQuality) });
|
|
163
|
-
needResize = (img_metadata === null || img_metadata === void 0 ? void 0 : img_metadata.width) && (img_metadata === null || img_metadata === void 0 ? void 0 : img_metadata.width) > ((_f = settings === null || settings === void 0 ? void 0 : settings.convertor) === null || _f === void 0 ? void 0 : _f.resizeWidth);
|
|
164
|
-
if (needResize) {
|
|
165
|
-
newWidth = parseInt(String((_g = settings === null || settings === void 0 ? void 0 : settings.convertor) === null || _g === void 0 ? void 0 : _g.resizeWidth));
|
|
166
|
-
newHeight = parseInt(String(img_metadata.height * (newWidth / img_metadata.width)));
|
|
167
|
-
imageProcessing = imageProcessing.resize({ width: newWidth, height: newHeight });
|
|
168
|
-
}
|
|
169
|
-
hasAlfaChannels = img_metadata.channels && img_metadata.channels >= 4;
|
|
170
|
-
if (hasAlfaChannels && !!settings.convertor.processColorChannels) {
|
|
171
|
-
imageProcessing = imageProcessing.toColorspace('srgb');
|
|
172
|
-
}
|
|
173
|
-
imageProcessing.toFile(outputPath, function (err, info) {
|
|
174
|
-
if (err) {
|
|
175
|
-
console.error("Error converting ".concat(file, " to webP"), err);
|
|
176
|
-
process.exit(1);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
console.log("Image ".concat(file, " converted to webP"), info);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
return [2 /*return*/];
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
_h.label = 3;
|
|
187
|
-
case 3:
|
|
188
|
-
_h.trys.push([3, 8, 9, 10]);
|
|
189
|
-
files_1 = __values(files), files_1_1 = files_1.next();
|
|
190
|
-
_h.label = 4;
|
|
191
|
-
case 4:
|
|
192
|
-
if (!!files_1_1.done) return [3 /*break*/, 7];
|
|
193
|
-
file = files_1_1.value;
|
|
194
|
-
return [5 /*yield**/, _loop_2(file)];
|
|
195
|
-
case 5:
|
|
196
|
-
_h.sent();
|
|
197
|
-
_h.label = 6;
|
|
198
|
-
case 6:
|
|
199
|
-
files_1_1 = files_1.next();
|
|
200
|
-
return [3 /*break*/, 4];
|
|
201
|
-
case 7: return [3 /*break*/, 10];
|
|
202
|
-
case 8:
|
|
203
|
-
e_1_1 = _h.sent();
|
|
204
|
-
e_1 = { error: e_1_1 };
|
|
205
|
-
return [3 /*break*/, 10];
|
|
206
|
-
case 9:
|
|
207
|
-
try {
|
|
208
|
-
if (files_1_1 && !files_1_1.done && (_b = files_1.return)) _b.call(files_1);
|
|
209
|
-
}
|
|
210
|
-
finally { if (e_1) throw e_1.error; }
|
|
211
|
-
return [7 /*endfinally*/];
|
|
212
|
-
case 10: return [2 /*return*/];
|
|
147
|
+
return [2 /*return*/];
|
|
213
148
|
}
|
|
214
149
|
});
|
|
215
150
|
}); });
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var downloadKeystores_1 = require("./commands/downloadKeystores");
|
|
|
8
8
|
var keystoresAndroid_1 = require("./commands/keystoresAndroid");
|
|
9
9
|
var rename_1 = require("./commands/rename");
|
|
10
10
|
var syncIcons_1 = require("./commands/syncIcons");
|
|
11
|
-
|
|
11
|
+
// import { convertorWebpCommand } from './commands/convertorWebp'
|
|
12
12
|
var configureTheme_1 = require("./commands/configureTheme");
|
|
13
13
|
var linguiTranslate_1 = require("./commands/linguiTranslate");
|
|
14
14
|
var configureSplash_1 = require("./commands/configureSplash");
|
|
@@ -25,7 +25,7 @@ var packageJson = require('../package.json');
|
|
|
25
25
|
configure_1.configureCommand,
|
|
26
26
|
downloadKeystores_1.downloadKeystores,
|
|
27
27
|
syncIcons_1.syncIconsCommand,
|
|
28
|
-
|
|
28
|
+
// convertorWebpCommand,
|
|
29
29
|
configureTheme_1.configureThemeCommand,
|
|
30
30
|
linguiTranslate_1.linguiTranslateCommand,
|
|
31
31
|
configureSplash_1.configureSplashCommand,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeleap/cli",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.20",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"repository": "git@github.com:codeleap-uk/codeleap-lib.git",
|
|
6
6
|
"author": "Paulo Henrique De Souza <paulosouza300272@gmail.com>",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"codeleap-cli": "./dist/index.js"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@codeleap/config": "5.8.
|
|
13
|
+
"@codeleap/config": "5.8.20",
|
|
14
14
|
"@types/inquirer": "^8.2.0",
|
|
15
15
|
"@types/libsodium-wrappers": "^0.7.10",
|
|
16
16
|
"cross-env": "^7.0.3"
|