@codeleap/cli 2.3.25 → 2.3.27-1

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.
Files changed (44) hide show
  1. package/dist/commands/codepushBootstrap.d.ts +28 -0
  2. package/dist/commands/codepushBootstrap.js +149 -0
  3. package/dist/commands/codepushDeploy.d.ts +28 -0
  4. package/dist/commands/codepushDeploy.js +101 -0
  5. package/dist/commands/configure.d.ts +26 -0
  6. package/dist/commands/convertorWebp.d.ts +29 -0
  7. package/dist/commands/convertorWebp.js +217 -0
  8. package/dist/commands/createApp.d.ts +40 -0
  9. package/dist/commands/createStyleSheets.d.ts +0 -0
  10. package/dist/commands/createStyleSheets.js +90 -0
  11. package/dist/commands/downloadKeystores.d.ts +24 -0
  12. package/dist/commands/downloadKeystores.js +68 -0
  13. package/dist/commands/keystoresAndroid.d.ts +25 -0
  14. package/dist/commands/rename.d.ts +64 -0
  15. package/dist/commands/syncIcons.d.ts +37 -0
  16. package/dist/commands/syncIcons.js +101 -0
  17. package/dist/constants.d.ts +10 -0
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.js +0 -0
  20. package/dist/lib/Command.d.ts +2 -0
  21. package/dist/lib/alterCliSettings.d.ts +2 -0
  22. package/dist/lib/alterCliSettings.js +19 -0
  23. package/dist/lib/android/index.d.ts +2 -0
  24. package/dist/lib/android/keystore.d.ts +14 -0
  25. package/dist/lib/android/rename.d.ts +7 -0
  26. package/dist/lib/android/utils.d.ts +3 -0
  27. package/dist/lib/appcenter.d.ts +21 -0
  28. package/dist/lib/appcenter.js +209 -0
  29. package/dist/lib/createApp/common.d.ts +1 -0
  30. package/dist/lib/createApp/mobile.d.ts +7 -0
  31. package/dist/lib/firebase.d.ts +2 -0
  32. package/dist/lib/getCliSettings.d.ts +4 -0
  33. package/dist/lib/getCliSettings.js +34 -0
  34. package/dist/lib/git.d.ts +2 -0
  35. package/dist/lib/git.js +73 -0
  36. package/dist/lib/index.d.ts +20 -0
  37. package/dist/lib/ios/index.d.ts +2 -0
  38. package/dist/lib/ios/rename.d.ts +7 -0
  39. package/dist/lib/ios/utils.d.ts +2 -0
  40. package/dist/lib/spinner.d.ts +6 -0
  41. package/dist/lib/utils.d.ts +18 -0
  42. package/dist/lib/walk.d.ts +37 -0
  43. package/dist/types.d.ts +28 -0
  44. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ export declare const codepushBootstrap: import("cleye").Command<{
2
+ name: "codepush-bootstrap";
3
+ parameters: "<apiToken>"[];
4
+ help: {
5
+ description: string;
6
+ examples: string[];
7
+ };
8
+ }, {
9
+ command: "codepush-bootstrap";
10
+ } & import("type-flag").TypeFlag<{
11
+ help: BooleanConstructor;
12
+ }> & {
13
+ _: {
14
+ apiToken: string;
15
+ };
16
+ showHelp: (options?: {
17
+ version?: string;
18
+ description?: string;
19
+ usage?: string | false | string[];
20
+ examples?: string | string[];
21
+ render?: (nodes: {
22
+ id?: string;
23
+ type: keyof import("cleye").Renderers;
24
+ data: any;
25
+ }[], renderers: import("cleye").Renderers) => string;
26
+ }) => void;
27
+ showVersion: () => void;
28
+ }>;
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
62
+ };
63
+ Object.defineProperty(exports, "__esModule", { value: true });
64
+ exports.codepushBootstrap = void 0;
65
+ var lib_1 = require("../lib");
66
+ var Command_1 = require("../lib/Command");
67
+ var commandName = 'codepush-bootstrap';
68
+ exports.codepushBootstrap = (0, Command_1.codeleapCommand)({
69
+ name: commandName,
70
+ parameters: [
71
+ '<apiToken>',
72
+ ],
73
+ help: {
74
+ description: 'Create a codepush app for iOS and Android, along with necessary tokens. To get the apiToken, go to https://appcenter.ms/settings/',
75
+ examples: [
76
+ "codeleap ".concat(commandName, " <apiToken>"),
77
+ ],
78
+ },
79
+ }, function (argv) { return __awaiter(void 0, void 0, void 0, function () {
80
+ var apiToken, settings, hasAppConfig, defaultBranchName, iosApp_1, e_1, androidApp_1, e_2;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0:
84
+ apiToken = argv._[0];
85
+ settings = (0, lib_1.getCliSettings)();
86
+ hasAppConfig = !!settings.codepush.android || !!settings.codepush.ios;
87
+ if (hasAppConfig) {
88
+ console.log([
89
+ 'You already have codepush apps configured',
90
+ 'If you want to create new ones, please apply the following changes to codeleapcli.config.json:',
91
+ '1. Remove codepush.ios and codepush.android keys',
92
+ '2. Change codepush.ApplicationName to a new value',
93
+ '3. Run this command again',
94
+ ].join('\n'));
95
+ return [2 /*return*/];
96
+ }
97
+ return [4 /*yield*/, (0, lib_1.getDefaultBranchName)()];
98
+ case 1:
99
+ defaultBranchName = _a.sent();
100
+ console.log('Creating applications...');
101
+ _a.label = 2;
102
+ case 2:
103
+ _a.trys.push([2, 5, , 6]);
104
+ return [4 /*yield*/, lib_1.Codepush.createApplication('ios', apiToken)];
105
+ case 3:
106
+ iosApp_1 = _a.sent();
107
+ console.log('iOS application created');
108
+ (0, lib_1.alterCliSettings)(function (currentSettings) {
109
+ currentSettings.codepush.ios = {
110
+ ApplicationName: iosApp_1.app.name,
111
+ ApiToken: iosApp_1.appToken,
112
+ };
113
+ return currentSettings;
114
+ });
115
+ return [4 /*yield*/, lib_1.Codepush.createDeployment(defaultBranchName, 'ios')];
116
+ case 4:
117
+ _a.sent();
118
+ return [3 /*break*/, 6];
119
+ case 5:
120
+ e_1 = _a.sent();
121
+ console.error.apply(console, __spreadArray(['Error creating iOS application'], __read((0, lib_1.formatError)(e_1)), false));
122
+ process.exit(1);
123
+ return [2 /*return*/];
124
+ case 6:
125
+ _a.trys.push([6, 9, , 10]);
126
+ return [4 /*yield*/, lib_1.Codepush.createApplication('android', apiToken)];
127
+ case 7:
128
+ androidApp_1 = _a.sent();
129
+ console.log('Android application created');
130
+ (0, lib_1.alterCliSettings)(function (currentSettings) {
131
+ currentSettings.codepush.android = {
132
+ ApplicationName: androidApp_1.app.name,
133
+ ApiToken: androidApp_1.appToken,
134
+ };
135
+ return currentSettings;
136
+ });
137
+ return [4 /*yield*/, lib_1.Codepush.createDeployment(defaultBranchName, 'android')];
138
+ case 8:
139
+ _a.sent();
140
+ return [3 /*break*/, 10];
141
+ case 9:
142
+ e_2 = _a.sent();
143
+ console.error.apply(console, __spreadArray(['Error creating Android application'], __read((0, lib_1.formatError)(e_2)), false));
144
+ process.exit(1);
145
+ return [2 /*return*/];
146
+ case 10: return [2 /*return*/];
147
+ }
148
+ });
149
+ }); });
@@ -0,0 +1,28 @@
1
+ export declare const codepushDeploy: import("cleye").Command<{
2
+ name: "codepush-deploy";
3
+ parameters: undefined[];
4
+ help: {
5
+ description: string;
6
+ examples: string[];
7
+ };
8
+ }, {
9
+ command: "codepush-deploy";
10
+ } & import("type-flag").TypeFlag<{
11
+ help: BooleanConstructor;
12
+ }> & {
13
+ _: {
14
+ [x: string]: string | string[];
15
+ };
16
+ showHelp: (options?: {
17
+ version?: string;
18
+ description?: string;
19
+ usage?: string | false | string[];
20
+ examples?: string | string[];
21
+ render?: (nodes: {
22
+ id?: string;
23
+ type: keyof import("cleye").Renderers;
24
+ data: any;
25
+ }[], renderers: import("cleye").Renderers) => string;
26
+ }) => void;
27
+ showVersion: () => void;
28
+ }>;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.codepushDeploy = void 0;
43
+ var lib_1 = require("../lib");
44
+ var Command_1 = require("../lib/Command");
45
+ var os_1 = __importDefault(require("os"));
46
+ var commandName = 'codepush-deploy';
47
+ exports.codepushDeploy = (0, Command_1.codeleapCommand)({
48
+ name: commandName,
49
+ parameters: [],
50
+ help: {
51
+ description: 'Update the codepush deployment from the current branch, creating it if it does not exist',
52
+ examples: [
53
+ "codeleap ".concat(commandName),
54
+ ],
55
+ },
56
+ }, function (argv) { return __awaiter(void 0, void 0, void 0, function () {
57
+ var androidApp, iosApp, branch, androidDeploymentExists, iosDeploymentExists;
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
60
+ case 0: return [4 /*yield*/, lib_1.Codepush.getApplication('android')];
61
+ case 1:
62
+ androidApp = _a.sent();
63
+ return [4 /*yield*/, lib_1.Codepush.getApplication('ios')];
64
+ case 2:
65
+ iosApp = _a.sent();
66
+ return [4 /*yield*/, (0, lib_1.getCurrentBranch)()];
67
+ case 3:
68
+ branch = _a.sent();
69
+ return [4 /*yield*/, lib_1.Codepush.deploymentExists(branch, 'android')];
70
+ case 4:
71
+ androidDeploymentExists = _a.sent();
72
+ if (!!androidDeploymentExists) return [3 /*break*/, 6];
73
+ return [4 /*yield*/, lib_1.Codepush.addDeployment(branch, androidApp)];
74
+ case 5:
75
+ _a.sent();
76
+ _a.label = 6;
77
+ case 6: return [4 /*yield*/, lib_1.Codepush.updateDeployment(branch, androidApp)];
78
+ case 7:
79
+ _a.sent();
80
+ if (!(os_1.default.platform() === 'darwin')) return [3 /*break*/, 12];
81
+ return [4 /*yield*/, lib_1.Codepush.deploymentExists(branch, 'ios')];
82
+ case 8:
83
+ iosDeploymentExists = _a.sent();
84
+ if (!!iosDeploymentExists) return [3 /*break*/, 10];
85
+ return [4 /*yield*/, lib_1.Codepush.addDeployment(branch, iosApp)];
86
+ case 9:
87
+ _a.sent();
88
+ _a.label = 10;
89
+ case 10: return [4 /*yield*/, lib_1.Codepush.updateDeployment(branch, iosApp)];
90
+ case 11:
91
+ _a.sent();
92
+ return [3 /*break*/, 13];
93
+ case 12:
94
+ console.log('Skipping iOS deployment as it is not supported on this platform');
95
+ _a.label = 13;
96
+ case 13:
97
+ console.log('Deployment updated');
98
+ return [2 /*return*/];
99
+ }
100
+ });
101
+ }); });
@@ -0,0 +1,26 @@
1
+ import '../lib/firebase';
2
+ export declare const configureCommand: import("cleye").Command<{
3
+ name: "configure";
4
+ help: {
5
+ description: string;
6
+ examples: string[];
7
+ };
8
+ }, {
9
+ command: "configure";
10
+ } & import("type-flag").TypeFlag<{
11
+ help: BooleanConstructor;
12
+ }> & {
13
+ _: {};
14
+ showHelp: (options?: {
15
+ version?: string;
16
+ description?: string;
17
+ usage?: string | false | string[];
18
+ examples?: string | string[];
19
+ render?: (nodes: {
20
+ id?: string;
21
+ type: keyof import("cleye").Renderers;
22
+ data: any;
23
+ }[], renderers: import("cleye").Renderers) => string;
24
+ }) => void;
25
+ showVersion: () => void;
26
+ }>;
@@ -0,0 +1,29 @@
1
+ import '../lib/firebase';
2
+ export declare const convertorWebpCommand: import("cleye").Command<{
3
+ name: "convertor-webp";
4
+ parameters: undefined[];
5
+ help: {
6
+ description: string;
7
+ examples: string[];
8
+ };
9
+ }, {
10
+ command: "convertor-webp";
11
+ } & import("type-flag").TypeFlag<{
12
+ help: BooleanConstructor;
13
+ }> & {
14
+ _: {
15
+ [x: string]: string | string[];
16
+ };
17
+ showHelp: (options?: {
18
+ version?: string;
19
+ description?: string;
20
+ usage?: string | false | string[];
21
+ examples?: string | string[];
22
+ render?: (nodes: {
23
+ id?: string;
24
+ type: keyof import("cleye").Renderers;
25
+ data: any;
26
+ }[], renderers: import("cleye").Renderers) => string;
27
+ }) => void;
28
+ showVersion: () => void;
29
+ }>;
@@ -0,0 +1,217 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __values = (this && this.__values) || function(o) {
39
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
+ if (m) return m.call(o);
41
+ if (o && typeof o.length === "number") return {
42
+ next: function () {
43
+ if (o && i >= o.length) o = void 0;
44
+ return { value: o && o[i++], done: !o };
45
+ }
46
+ };
47
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.convertorWebpCommand = void 0;
54
+ var Command_1 = require("../lib/Command");
55
+ var fs_1 = __importDefault(require("fs"));
56
+ var path_1 = __importDefault(require("path"));
57
+ var sharp_1 = __importDefault(require("sharp"));
58
+ var lib_1 = require("../lib");
59
+ require("../lib/firebase");
60
+ var commandName = 'convertor-webp';
61
+ exports.convertorWebpCommand = (0, Command_1.codeleapCommand)({
62
+ name: commandName,
63
+ parameters: [],
64
+ help: {
65
+ description: 'Command for easily convertor to webp, compression and resize images.',
66
+ examples: [
67
+ "codeleap ".concat(commandName),
68
+ ],
69
+ },
70
+ }, function (argv) { return __awaiter(void 0, void 0, void 0, function () {
71
+ var flags, _, settings, isMultipleConversion, isSingleConversion, filename, answers, files, inputFiles, _loop_1, inputFiles_1, inputFiles_1_1, inputFile, _loop_2, files_1, files_1_1, file, e_1_1;
72
+ var e_2, _a, e_1, _b;
73
+ var _c, _d, _e, _f, _g;
74
+ return __generator(this, function (_h) {
75
+ switch (_h.label) {
76
+ case 0:
77
+ flags = argv.flags, _ = argv._;
78
+ settings = (0, lib_1.getCliSettings)()['convertor-webp'];
79
+ isMultipleConversion = settings.mode === 'multi';
80
+ isSingleConversion = settings.mode === 'single';
81
+ filename = null;
82
+ if (!isSingleConversion) return [3 /*break*/, 2];
83
+ return [4 /*yield*/, lib_1.inquirer.prompt([
84
+ {
85
+ message: "Please insert the filename",
86
+ name: 'filename',
87
+ },
88
+ ])];
89
+ case 1:
90
+ answers = _h.sent();
91
+ filename = answers.filename;
92
+ _h.label = 2;
93
+ case 2:
94
+ console.log('Starting conversion', settings);
95
+ if (!fs_1.default.existsSync(settings.output)) {
96
+ try {
97
+ fs_1.default.mkdirSync(settings.output);
98
+ }
99
+ catch (e) {
100
+ console.error('Error on create output folder, check settings', {
101
+ settings: settings,
102
+ error: e,
103
+ });
104
+ process.exit(1);
105
+ return [2 /*return*/];
106
+ }
107
+ }
108
+ files = [];
109
+ if (fs_1.default.existsSync(settings.input)) {
110
+ inputFiles = fs_1.default.readdirSync(settings.input);
111
+ if (isMultipleConversion) {
112
+ _loop_1 = function (inputFile) {
113
+ var isCorrectFormat = (_d = (_c = settings === null || settings === void 0 ? void 0 : settings.convertor) === null || _c === void 0 ? void 0 : _c.inputFormats) === null || _d === void 0 ? void 0 : _d.some(function (_format) { return inputFile === null || inputFile === void 0 ? void 0 : inputFile.endsWith(_format); });
114
+ var isIgnoredFile = settings.convertor.ignoreFiles.includes(inputFile === null || inputFile === void 0 ? void 0 : inputFile.split('.')[0]);
115
+ if (isCorrectFormat && !isIgnoredFile) {
116
+ files.push(inputFile);
117
+ }
118
+ };
119
+ try {
120
+ for (inputFiles_1 = __values(inputFiles), inputFiles_1_1 = inputFiles_1.next(); !inputFiles_1_1.done; inputFiles_1_1 = inputFiles_1.next()) {
121
+ inputFile = inputFiles_1_1.value;
122
+ _loop_1(inputFile);
123
+ }
124
+ }
125
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
126
+ finally {
127
+ try {
128
+ if (inputFiles_1_1 && !inputFiles_1_1.done && (_a = inputFiles_1.return)) _a.call(inputFiles_1);
129
+ }
130
+ finally { if (e_2) throw e_2.error; }
131
+ }
132
+ }
133
+ else {
134
+ if (!!fs_1.default.existsSync(settings.input + '/' + filename)) {
135
+ files.push(filename);
136
+ }
137
+ else {
138
+ console.error('File not found, check filename', filename);
139
+ process.exit(1);
140
+ return [2 /*return*/];
141
+ }
142
+ }
143
+ }
144
+ else {
145
+ console.error('Input folder not found, check settings', settings);
146
+ process.exit(1);
147
+ return [2 /*return*/];
148
+ }
149
+ console.log('Files to convert', files);
150
+ _loop_2 = function (file) {
151
+ var inputPath, outputPath, img, img_metadata, imageProcessing, needResize, newWidth, newHeight, hasAlfaChannels;
152
+ return __generator(this, function (_j) {
153
+ switch (_j.label) {
154
+ case 0:
155
+ inputPath = path_1.default.join(settings.input, file);
156
+ outputPath = path_1.default.join(settings.output, path_1.default.parse(file).name + '.webp');
157
+ if (fs_1.default.existsSync(outputPath)) {
158
+ fs_1.default.unlinkSync(outputPath);
159
+ }
160
+ img = (0, sharp_1.default)(inputPath);
161
+ return [4 /*yield*/, img.metadata()];
162
+ case 1:
163
+ img_metadata = _j.sent();
164
+ imageProcessing = img.webp({ quality: Number((_e = settings === null || settings === void 0 ? void 0 : settings.convertor) === null || _e === void 0 ? void 0 : _e.compressionQuality) });
165
+ 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);
166
+ if (needResize) {
167
+ newWidth = parseInt(String((_g = settings === null || settings === void 0 ? void 0 : settings.convertor) === null || _g === void 0 ? void 0 : _g.resizeWidth));
168
+ newHeight = parseInt(String(img_metadata.height * (newWidth / img_metadata.width)));
169
+ imageProcessing = imageProcessing.resize({ width: newWidth, height: newHeight });
170
+ }
171
+ hasAlfaChannels = img_metadata.channels && img_metadata.channels >= 4;
172
+ if (hasAlfaChannels && !!settings.convertor.processColorChannels) {
173
+ imageProcessing = imageProcessing.toColorspace('srgb');
174
+ }
175
+ imageProcessing.toFile(outputPath, function (err, info) {
176
+ if (err) {
177
+ console.error("Error converting ".concat(file, " to webP"), err);
178
+ process.exit(1);
179
+ }
180
+ else {
181
+ console.log("Image ".concat(file, " converted to webP"), info);
182
+ }
183
+ });
184
+ return [2 /*return*/];
185
+ }
186
+ });
187
+ };
188
+ _h.label = 3;
189
+ case 3:
190
+ _h.trys.push([3, 8, 9, 10]);
191
+ files_1 = __values(files), files_1_1 = files_1.next();
192
+ _h.label = 4;
193
+ case 4:
194
+ if (!!files_1_1.done) return [3 /*break*/, 7];
195
+ file = files_1_1.value;
196
+ return [5 /*yield**/, _loop_2(file)];
197
+ case 5:
198
+ _h.sent();
199
+ _h.label = 6;
200
+ case 6:
201
+ files_1_1 = files_1.next();
202
+ return [3 /*break*/, 4];
203
+ case 7: return [3 /*break*/, 10];
204
+ case 8:
205
+ e_1_1 = _h.sent();
206
+ e_1 = { error: e_1_1 };
207
+ return [3 /*break*/, 10];
208
+ case 9:
209
+ try {
210
+ if (files_1_1 && !files_1_1.done && (_b = files_1.return)) _b.call(files_1);
211
+ }
212
+ finally { if (e_1) throw e_1.error; }
213
+ return [7 /*endfinally*/];
214
+ case 10: return [2 /*return*/];
215
+ }
216
+ });
217
+ }); });
@@ -0,0 +1,40 @@
1
+ import '../lib/firebase';
2
+ export declare const createAppCommand: import("cleye").Command<{
3
+ name: "create";
4
+ parameters: "[name]"[];
5
+ help: {
6
+ description: string;
7
+ examples: string[];
8
+ };
9
+ flags: {
10
+ initFirebase: {
11
+ type: BooleanConstructor;
12
+ default: boolean;
13
+ };
14
+ };
15
+ }, {
16
+ command: "create";
17
+ } & import("type-flag").TypeFlag<{
18
+ initFirebase: {
19
+ type: BooleanConstructor;
20
+ default: boolean;
21
+ };
22
+ } & {
23
+ help: BooleanConstructor;
24
+ }> & {
25
+ _: {
26
+ name: string;
27
+ };
28
+ showHelp: (options?: {
29
+ version?: string;
30
+ description?: string;
31
+ usage?: string | false | string[];
32
+ examples?: string | string[];
33
+ render?: (nodes: {
34
+ id?: string;
35
+ type: keyof import("cleye").Renderers;
36
+ data: any;
37
+ }[], renderers: import("cleye").Renderers) => string;
38
+ }) => void;
39
+ showVersion: () => void;
40
+ }>;
File without changes