@codeleap/cli 1.1.0 → 2.3.16

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.
@@ -1,160 +1,163 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- 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;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
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.renameIos = void 0;
54
- var utils_1 = require("../utils");
55
- var utils_2 = require("./utils");
56
- var path_1 = __importDefault(require("path"));
57
- var fs_1 = __importDefault(require("fs"));
58
- var walk_1 = require("../walk");
59
- var firebase_admin_1 = __importDefault(require("firebase-admin"));
60
- function renameIos(iosFolder, newName, options) {
61
- return __awaiter(this, void 0, void 0, function () {
62
- var newBundleName, pbxProjPath, pbxProj, bundleId, currentName, renameQueue, pm, iosAppReqs, iosApps, googleServiceFile, newApp, newPlistFile;
63
- var _this = this;
64
- return __generator(this, function (_a) {
65
- switch (_a.label) {
66
- case 0:
67
- newBundleName = (0, utils_1.getNewBundleName)(newName);
68
- pbxProjPath = path_1.default.join(iosFolder, fs_1.default.readdirSync(iosFolder).find(function (x) { return x.endsWith('.xcodeproj'); }), 'project.pbxproj');
69
- pbxProj = fs_1.default.readFileSync(pbxProjPath).toString();
70
- bundleId = (0, utils_2.getIosBundleId)(pbxProj);
71
- currentName = (0, utils_2.getIosAppName)(pbxProj);
72
- renameQueue = [];
73
- newName = newName.trim();
74
- return [4 /*yield*/, (0, walk_1.walkDir)({
75
- action: function (info) {
76
- // console.log({ a: info.name })
77
- if (info.name.includes(currentName)) {
78
- var renameRegex = new RegExp(currentName, 'g');
79
- var lastMatch_1 = info.path.lastIndexOf(currentName);
80
- var idx_1 = 0;
81
- renameQueue.push({
82
- from: info.path.replace(renameRegex, function (str, i) {
83
- if (i == lastMatch_1) {
84
- return str;
85
- }
86
- idx_1++;
87
- return newName;
88
- }),
89
- to: info.path.replace(renameRegex, newName),
90
- });
91
- }
92
- if (!info.isDir) {
93
- var content = info.file.content;
94
- if (options === null || options === void 0 ? void 0 : options.changeBundle) {
95
- content = content.replace(new RegExp("".concat(bundleId), 'g'), newBundleName);
96
- }
97
- var nameExp = new RegExp("(?<!\\.)".concat(currentName), 'g');
98
- return content.replace(nameExp, newName);
99
- }
100
- },
101
- path: iosFolder,
102
- options: {
103
- scanFileContent: true,
104
- ignore: [
105
- {
106
- name: 'GoogleService-Info',
107
- ext: ['plist'],
108
- file: true,
109
- },
110
- {
111
- ext: ['png', 'jpg', 'jpeg'],
112
- file: true,
113
- },
114
- ],
115
- },
116
- })];
117
- case 1:
118
- _a.sent();
119
- renameQueue.sort(function (a, b) { return a.to.length - b.to.length; });
120
- renameQueue.forEach(function (i) {
121
- fs_1.default.renameSync(i.from, i.to);
122
- });
123
- pm = firebase_admin_1.default.projectManagement();
124
- return [4 /*yield*/, pm.listIosApps()];
125
- case 2:
126
- iosAppReqs = (_a.sent()).map(function (a) { return __awaiter(_this, void 0, void 0, function () {
127
- var _a;
128
- var _b;
129
- return __generator(this, function (_c) {
130
- switch (_c.label) {
131
- case 0:
132
- _a = [__assign({}, a)];
133
- _b = {};
134
- return [4 /*yield*/, a.getMetadata()];
135
- case 1: return [2 /*return*/, __assign.apply(void 0, _a.concat([(_b.meta = (_c.sent()), _b)]))];
136
- }
137
- });
138
- }); });
139
- return [4 /*yield*/, Promise.all(iosAppReqs)];
140
- case 3:
141
- iosApps = _a.sent();
142
- googleServiceFile = path_1.default.join(iosFolder, newName, 'GoogleService-Info.plist');
143
- if (!!iosApps.some(function (a) { return a.meta.bundleId === newBundleName; })) return [3 /*break*/, 6];
144
- console.log("Creating new ios app on firebase and updating GoogleService-Info.plist...");
145
- return [4 /*yield*/, pm.createIosApp(newBundleName, newName.trim())];
146
- case 4:
147
- newApp = _a.sent();
148
- return [4 /*yield*/, newApp.getConfig()];
149
- case 5:
150
- newPlistFile = _a.sent();
151
- fs_1.default.writeFileSync(googleServiceFile, newPlistFile, {
152
- encoding: 'utf-8',
153
- });
154
- _a.label = 6;
155
- case 6: return [2 /*return*/];
156
- }
157
- });
158
- });
159
- }
160
- exports.renameIos = renameIos;
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
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.renameIos = void 0;
54
+ var utils_1 = require("../utils");
55
+ var utils_2 = require("./utils");
56
+ var path_1 = __importDefault(require("path"));
57
+ var fs_1 = __importDefault(require("fs"));
58
+ var walk_1 = require("../walk");
59
+ var firebase_admin_1 = __importDefault(require("firebase-admin"));
60
+ var firebase_1 = require("../firebase");
61
+ function renameIos(iosFolder, newName, options) {
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var newBundleName, pbxProjPath, pbxProj, bundleId, currentName, renameQueue, pm, iosAppReqs, iosApps, googleServiceFile, newApp, newPlistFile;
64
+ var _this = this;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0:
68
+ newBundleName = (0, utils_1.getNewBundleName)(newName);
69
+ pbxProjPath = path_1.default.join(iosFolder, fs_1.default.readdirSync(iosFolder).find(function (x) { return x.endsWith('.xcodeproj'); }), 'project.pbxproj');
70
+ pbxProj = fs_1.default.readFileSync(pbxProjPath).toString();
71
+ bundleId = (0, utils_2.getIosBundleId)(pbxProj);
72
+ currentName = (0, utils_2.getIosAppName)(pbxProj);
73
+ renameQueue = [];
74
+ newName = newName.trim();
75
+ return [4 /*yield*/, (0, walk_1.walkDir)({
76
+ action: function (info) {
77
+ // console.log({ a: info.name })
78
+ if (info.name.includes(currentName)) {
79
+ var renameRegex = new RegExp(currentName, 'g');
80
+ var lastMatch_1 = info.path.lastIndexOf(currentName);
81
+ var idx_1 = 0;
82
+ renameQueue.push({
83
+ from: info.path.replace(renameRegex, function (str, i) {
84
+ if (i == lastMatch_1) {
85
+ return str;
86
+ }
87
+ idx_1++;
88
+ return newName;
89
+ }),
90
+ to: info.path.replace(renameRegex, newName),
91
+ });
92
+ }
93
+ if (!info.isDir) {
94
+ var content = info.file.content;
95
+ if (options === null || options === void 0 ? void 0 : options.changeBundle) {
96
+ content = content.replace(new RegExp("".concat(bundleId), 'g'), newBundleName);
97
+ }
98
+ var nameExp = new RegExp("(?<!\\.)".concat(currentName), 'g');
99
+ return content.replace(nameExp, newName);
100
+ }
101
+ },
102
+ path: iosFolder,
103
+ options: {
104
+ scanFileContent: true,
105
+ ignore: [
106
+ {
107
+ name: 'GoogleService-Info',
108
+ ext: ['plist'],
109
+ file: true,
110
+ },
111
+ {
112
+ ext: ['png', 'jpg', 'jpeg'],
113
+ file: true,
114
+ },
115
+ ],
116
+ },
117
+ })];
118
+ case 1:
119
+ _a.sent();
120
+ renameQueue.sort(function (a, b) { return a.to.length - b.to.length; });
121
+ renameQueue.forEach(function (i) {
122
+ fs_1.default.renameSync(i.from, i.to);
123
+ });
124
+ if (!firebase_1.firebaseApp)
125
+ return [2 /*return*/];
126
+ pm = firebase_admin_1.default.projectManagement();
127
+ return [4 /*yield*/, pm.listIosApps()];
128
+ case 2:
129
+ iosAppReqs = (_a.sent()).map(function (a) { return __awaiter(_this, void 0, void 0, function () {
130
+ var _a;
131
+ var _b;
132
+ return __generator(this, function (_c) {
133
+ switch (_c.label) {
134
+ case 0:
135
+ _a = [__assign({}, a)];
136
+ _b = {};
137
+ return [4 /*yield*/, a.getMetadata()];
138
+ case 1: return [2 /*return*/, __assign.apply(void 0, _a.concat([(_b.meta = (_c.sent()), _b)]))];
139
+ }
140
+ });
141
+ }); });
142
+ return [4 /*yield*/, Promise.all(iosAppReqs)];
143
+ case 3:
144
+ iosApps = _a.sent();
145
+ googleServiceFile = path_1.default.join(iosFolder, newName, 'GoogleService-Info.plist');
146
+ if (!!iosApps.some(function (a) { return a.meta.bundleId === newBundleName; })) return [3 /*break*/, 6];
147
+ console.log("Creating new ios app on firebase and updating GoogleService-Info.plist...");
148
+ return [4 /*yield*/, pm.createIosApp(newBundleName, newName.trim())];
149
+ case 4:
150
+ newApp = _a.sent();
151
+ return [4 /*yield*/, newApp.getConfig()];
152
+ case 5:
153
+ newPlistFile = _a.sent();
154
+ fs_1.default.writeFileSync(googleServiceFile, newPlistFile, {
155
+ encoding: 'utf-8',
156
+ });
157
+ _a.label = 6;
158
+ case 6: return [2 /*return*/];
159
+ }
160
+ });
161
+ });
162
+ }
163
+ exports.renameIos = renameIos;
@@ -1,28 +1,26 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getIosAppName = exports.getIosBundleId = void 0;
7
- var fs_1 = __importDefault(require("fs"));
8
- var path_1 = __importDefault(require("path"));
9
- var __1 = require("..");
10
- var getIosBundleId = function (pbxProjectContent) {
11
- var pkgStr = 'PRODUCT_BUNDLE_IDENTIFIER =';
12
- var packageIdx = pbxProjectContent.indexOf(pkgStr) + pkgStr.length;
13
- var packageName = pbxProjectContent.substring(packageIdx);
14
- var packageEndIdx = packageName.indexOf(';');
15
- packageName = packageName.substring(0, packageEndIdx);
16
- return packageName.trim();
17
- };
18
- exports.getIosBundleId = getIosBundleId;
19
- var getIosAppName = function (pbxProjectContent) {
20
- // const pkgStr = 'PRODUCT_NAME ='
21
- // const packageIdx = pbxProjectContent.indexOf(pkgStr) + pkgStr.length
22
- // let packageName = pbxProjectContent.substring(packageIdx)
23
- // const packageEndIdx = packageName.indexOf(';')
24
- // packageName = packageName.substring(0, packageEndIdx)
25
- // return packageName.trim()
26
- return JSON.parse(fs_1.default.readFileSync(path_1.default.join(__1.cwd, 'app.json')).toString()).name;
27
- };
28
- exports.getIosAppName = getIosAppName;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIosAppName = exports.getIosBundleId = void 0;
4
+ var getIosBundleId = function (pbxProjectContent) {
5
+ var pkgStr = 'PRODUCT_BUNDLE_IDENTIFIER =';
6
+ var packageIdx = pbxProjectContent.indexOf(pkgStr) + pkgStr.length;
7
+ var packageName = pbxProjectContent.substring(packageIdx);
8
+ var packageEndIdx = packageName.indexOf(';');
9
+ packageName = packageName.substring(0, packageEndIdx);
10
+ return packageName.trim();
11
+ };
12
+ exports.getIosBundleId = getIosBundleId;
13
+ var getIosAppName = function (pbxProjectContent) {
14
+ var pkgStr = 'PRODUCT_NAME =';
15
+ var packageIdx = pbxProjectContent.indexOf(pkgStr) + pkgStr.length;
16
+ var packageName = pbxProjectContent.substring(packageIdx);
17
+ var packageEndIdx = packageName.indexOf(';');
18
+ packageName = packageName.substring(0, packageEndIdx);
19
+ return packageName.trim();
20
+ // return JSON.parse(
21
+ // fs.readFileSync(
22
+ // path.join(cwd, 'app.json'),
23
+ // ).toString(),
24
+ // ).name
25
+ };
26
+ exports.getIosAppName = getIosAppName;
@@ -1,79 +1,79 @@
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 (_) 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 __rest = (this && this.__rest) || function (s, e) {
39
- var t = {};
40
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
41
- t[p] = s[p];
42
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
43
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
44
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
45
- t[p[i]] = s[p[i]];
46
- }
47
- return t;
48
- };
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.spinWhileNotCompleted = void 0;
51
- var nanospinner_1 = require("nanospinner");
52
- function spinWhileNotCompleted(operation, opts) {
53
- return __awaiter(this, void 0, void 0, function () {
54
- var name, others, spinner, result, e_1;
55
- return __generator(this, function (_a) {
56
- switch (_a.label) {
57
- case 0:
58
- name = opts.name, others = __rest(opts, ["name"]);
59
- spinner = (0, nanospinner_1.createSpinner)("".concat(name, "\n"), others);
60
- spinner.start();
61
- _a.label = 1;
62
- case 1:
63
- _a.trys.push([1, 3, , 4]);
64
- return [4 /*yield*/, operation()];
65
- case 2:
66
- result = _a.sent();
67
- spinner.success();
68
- return [2 /*return*/, result];
69
- case 3:
70
- e_1 = _a.sent();
71
- spinner.error();
72
- console.error(e_1);
73
- return [3 /*break*/, 4];
74
- case 4: return [2 /*return*/];
75
- }
76
- });
77
- });
78
- }
79
- exports.spinWhileNotCompleted = spinWhileNotCompleted;
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 (_) 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 __rest = (this && this.__rest) || function (s, e) {
39
+ var t = {};
40
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
41
+ t[p] = s[p];
42
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
43
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
44
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
45
+ t[p[i]] = s[p[i]];
46
+ }
47
+ return t;
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.spinWhileNotCompleted = void 0;
51
+ var nanospinner_1 = require("nanospinner");
52
+ function spinWhileNotCompleted(operation, opts) {
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ var name, others, spinner, result, e_1;
55
+ return __generator(this, function (_a) {
56
+ switch (_a.label) {
57
+ case 0:
58
+ name = opts.name, others = __rest(opts, ["name"]);
59
+ spinner = (0, nanospinner_1.createSpinner)("".concat(name, "\n"), others);
60
+ spinner.start();
61
+ _a.label = 1;
62
+ case 1:
63
+ _a.trys.push([1, 3, , 4]);
64
+ return [4 /*yield*/, operation()];
65
+ case 2:
66
+ result = _a.sent();
67
+ spinner.success();
68
+ return [2 /*return*/, result];
69
+ case 3:
70
+ e_1 = _a.sent();
71
+ spinner.error();
72
+ console.error(e_1);
73
+ return [3 /*break*/, 4];
74
+ case 4: return [2 /*return*/];
75
+ }
76
+ });
77
+ });
78
+ }
79
+ exports.spinWhileNotCompleted = spinWhileNotCompleted;