@codeleap/cli 6.3.0 → 7.0.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.
Files changed (73) hide show
  1. package/dist/commands/configure.js +26 -61
  2. package/dist/commands/configure.js.map +1 -0
  3. package/dist/commands/configureSplash/index.js +21 -61
  4. package/dist/commands/configureSplash/index.js.map +1 -0
  5. package/dist/commands/configureSplash/utils.js +68 -86
  6. package/dist/commands/configureSplash/utils.js.map +1 -0
  7. package/dist/commands/configureTheme/index.js +31 -80
  8. package/dist/commands/configureTheme/index.js.map +1 -0
  9. package/dist/commands/configureTheme/types.js +1 -0
  10. package/dist/commands/configureTheme/types.js.map +1 -0
  11. package/dist/commands/configureTheme/utils.js +110 -105
  12. package/dist/commands/configureTheme/utils.js.map +1 -0
  13. package/dist/commands/convertorWebp.js +93 -189
  14. package/dist/commands/convertorWebp.js.map +1 -0
  15. package/dist/commands/createApp.js +24 -62
  16. package/dist/commands/createApp.js.map +1 -0
  17. package/dist/commands/createComponent/index.js +54 -88
  18. package/dist/commands/createComponent/index.js.map +1 -0
  19. package/dist/commands/createComponent/utils.js +66 -34
  20. package/dist/commands/createComponent/utils.js.map +1 -0
  21. package/dist/commands/downloadKeystores.js +11 -47
  22. package/dist/commands/downloadKeystores.js.map +1 -0
  23. package/dist/commands/keystoresAndroid.js +6 -40
  24. package/dist/commands/keystoresAndroid.js.map +1 -0
  25. package/dist/commands/linguiTranslate.js +64 -195
  26. package/dist/commands/linguiTranslate.js.map +1 -0
  27. package/dist/commands/rename.js +49 -110
  28. package/dist/commands/rename.js.map +1 -0
  29. package/dist/commands/syncIcons.js +29 -74
  30. package/dist/commands/syncIcons.js.map +1 -0
  31. package/dist/constants.js +42 -20
  32. package/dist/constants.js.map +1 -0
  33. package/dist/index.js +14 -13
  34. package/dist/index.js.map +1 -0
  35. package/dist/lib/Command.js +23 -76
  36. package/dist/lib/Command.js.map +1 -0
  37. package/dist/lib/android/index.js +1 -0
  38. package/dist/lib/android/index.js.map +1 -0
  39. package/dist/lib/android/keystore.js +91 -117
  40. package/dist/lib/android/keystore.js.map +1 -0
  41. package/dist/lib/android/rename.js +131 -246
  42. package/dist/lib/android/rename.js.map +1 -0
  43. package/dist/lib/android/utils.js +41 -36
  44. package/dist/lib/android/utils.js.map +1 -0
  45. package/dist/lib/createApp/common.js +13 -41
  46. package/dist/lib/createApp/common.js.map +1 -0
  47. package/dist/lib/createApp/mobile.js +120 -176
  48. package/dist/lib/createApp/mobile.js.map +1 -0
  49. package/dist/lib/firebase.js +11 -33
  50. package/dist/lib/firebase.js.map +1 -0
  51. package/dist/lib/index.js +4 -3
  52. package/dist/lib/index.js.map +1 -0
  53. package/dist/lib/ios/index.js +1 -0
  54. package/dist/lib/ios/index.js.map +1 -0
  55. package/dist/lib/ios/rename.js +90 -140
  56. package/dist/lib/ios/rename.js.map +1 -0
  57. package/dist/lib/ios/utils.js +21 -10
  58. package/dist/lib/ios/utils.js.map +1 -0
  59. package/dist/lib/spinner.js +21 -52
  60. package/dist/lib/spinner.js.map +1 -0
  61. package/dist/lib/utils.js +56 -32
  62. package/dist/lib/utils.js.map +1 -0
  63. package/dist/lib/walk.js +65 -87
  64. package/dist/lib/walk.js.map +1 -0
  65. package/dist/types.js +1 -0
  66. package/dist/types.js.map +1 -0
  67. package/dist/utils/index.js +1 -0
  68. package/dist/utils/index.js.map +1 -0
  69. package/dist/utils/misc.js +45 -34
  70. package/dist/utils/misc.js.map +1 -0
  71. package/package.json +10 -5
  72. package/.gitattributes +0 -1
  73. package/package.json.bak +0 -45
@@ -1,15 +1,4 @@
1
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
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,143 +8,104 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
20
9
  });
21
10
  };
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 (g && (g = 0, op[0] && (_ = 0)), _) 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
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
13
  };
52
14
  Object.defineProperty(exports, "__esModule", { value: true });
53
15
  exports.renameIos = renameIos;
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");
16
+ const utils_1 = require("../utils");
17
+ const utils_2 = require("./utils");
18
+ const path_1 = __importDefault(require("path"));
19
+ const fs_1 = __importDefault(require("fs"));
20
+ const walk_1 = require("../walk");
21
+ /**
22
+ * Renames an iOS project in place. Rewrites all text files under `iosFolder`
23
+ * and queues filesystem renames for any path segment that contains the
24
+ * current app name. Renames are applied shortest-path-first to avoid
25
+ * parent-before-child ordering issues.
26
+ *
27
+ * When `changeBundle` is true, rewrites the bundle identifier throughout all
28
+ * text files (using the `uk.co.codeleap.<name>` scheme).
29
+ *
30
+ * Skips: `GoogleService-Info.plist`, image files (`png`, `jpg`, `jpeg`).
31
+ *
32
+ * When a Firebase app instance is provided and no iOS app with the new bundle
33
+ * ID exists, creates one in Firebase and overwrites
34
+ * `<iosFolder>/<newName>/GoogleService-Info.plist`.
35
+ */
59
36
  function renameIos(iosFolder, newName, options) {
60
- return __awaiter(this, void 0, void 0, function () {
61
- var firebase, newBundleName, pbxProjPath, pbxProj, bundleId, currentName, renameQueue, pm, iosAppReqs, iosApps, googleServiceFile, newApp, newPlistFile;
62
- var _this = this;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
65
- case 0:
66
- firebase = (options || {}).firebase;
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
- if (!firebase)
124
- return [2 /*return*/];
125
- pm = firebase.projectManagement();
126
- return [4 /*yield*/, pm.listIosApps()];
127
- case 2:
128
- iosAppReqs = (_a.sent()).map(function (a) { return __awaiter(_this, void 0, void 0, function () {
129
- var _a;
130
- var _b;
131
- return __generator(this, function (_c) {
132
- switch (_c.label) {
133
- case 0:
134
- _a = [__assign({}, a)];
135
- _b = {};
136
- return [4 /*yield*/, a.getMetadata()];
137
- case 1: return [2 /*return*/, __assign.apply(void 0, _a.concat([(_b.meta = (_c.sent()), _b)]))];
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const { firebase } = options || {};
39
+ const newBundleName = (0, utils_1.getNewBundleName)(newName);
40
+ const pbxProjPath = path_1.default.join(iosFolder, fs_1.default.readdirSync(iosFolder).find(x => x.endsWith('.xcodeproj')), 'project.pbxproj');
41
+ const pbxProj = fs_1.default.readFileSync(pbxProjPath).toString();
42
+ const bundleId = (0, utils_2.getIosBundleId)(pbxProj);
43
+ const currentName = (0, utils_2.getIosAppName)(pbxProj);
44
+ const renameQueue = [];
45
+ newName = newName.trim();
46
+ yield (0, walk_1.walkDir)({
47
+ action: (info) => {
48
+ // console.log({ a: info.name })
49
+ if (info.name.includes(currentName)) {
50
+ const renameRegex = new RegExp(currentName, 'g');
51
+ const lastMatch = info.path.lastIndexOf(currentName);
52
+ let idx = 0;
53
+ renameQueue.push({
54
+ from: info.path.replace(renameRegex, (str, i) => {
55
+ if (i == lastMatch) {
56
+ return str;
138
57
  }
139
- });
140
- }); });
141
- return [4 /*yield*/, Promise.all(iosAppReqs)];
142
- case 3:
143
- iosApps = _a.sent();
144
- googleServiceFile = path_1.default.join(iosFolder, newName, 'GoogleService-Info.plist');
145
- if (!!iosApps.some(function (a) { return a.meta.bundleId === newBundleName; })) return [3 /*break*/, 6];
146
- console.log("Creating new ios app on firebase and updating GoogleService-Info.plist...");
147
- return [4 /*yield*/, pm.createIosApp(newBundleName, newName.trim())];
148
- case 4:
149
- newApp = _a.sent();
150
- return [4 /*yield*/, newApp.getConfig()];
151
- case 5:
152
- newPlistFile = _a.sent();
153
- fs_1.default.writeFileSync(googleServiceFile, newPlistFile, {
154
- encoding: 'utf-8',
58
+ idx++;
59
+ return newName;
60
+ }),
61
+ to: info.path.replace(renameRegex, newName),
155
62
  });
156
- _a.label = 6;
157
- case 6: return [2 /*return*/];
158
- }
63
+ }
64
+ if (!info.isDir) {
65
+ let content = info.file.content;
66
+ if (options === null || options === void 0 ? void 0 : options.changeBundle) {
67
+ content = content.replace(new RegExp(`${bundleId}`, 'g'), newBundleName);
68
+ }
69
+ const nameExp = new RegExp(`(?<!\\.)${currentName}`, 'g');
70
+ return content.replace(nameExp, newName);
71
+ }
72
+ },
73
+ path: iosFolder,
74
+ options: {
75
+ scanFileContent: true,
76
+ ignore: [
77
+ {
78
+ name: 'GoogleService-Info',
79
+ ext: ['plist'],
80
+ file: true,
81
+ },
82
+ {
83
+ ext: ['png', 'jpg', 'jpeg'],
84
+ file: true,
85
+ },
86
+ ],
87
+ },
88
+ });
89
+ renameQueue.sort((a, b) => a.to.length - b.to.length);
90
+ renameQueue.forEach((i) => {
91
+ fs_1.default.renameSync(i.from, i.to);
159
92
  });
93
+ if (!firebase)
94
+ return;
95
+ const pm = firebase.projectManagement();
96
+ const iosAppReqs = (yield pm.listIosApps()).map((a) => __awaiter(this, void 0, void 0, function* () {
97
+ return Object.assign(Object.assign({}, a), { meta: (yield a.getMetadata()) });
98
+ }));
99
+ const iosApps = yield Promise.all(iosAppReqs);
100
+ const googleServiceFile = path_1.default.join(iosFolder, newName, 'GoogleService-Info.plist');
101
+ if (!iosApps.some(a => a.meta.bundleId === newBundleName)) {
102
+ console.log(`Creating new ios app on firebase and updating GoogleService-Info.plist...`);
103
+ const newApp = yield pm.createIosApp(newBundleName, newName.trim());
104
+ const newPlistFile = yield newApp.getConfig();
105
+ fs_1.default.writeFileSync(googleServiceFile, newPlistFile, {
106
+ encoding: 'utf-8',
107
+ });
108
+ }
160
109
  });
161
110
  }
111
+ //# sourceMappingURL=rename.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rename.js","sourceRoot":"","sources":["../../../src/lib/ios/rename.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA6BA,8BAyGC;AAtID,oCAA2C;AAC3C,mCAAuD;AACvD,gDAAuB;AACvB,4CAAmB;AACnB,kCAAiC;AAUjC;;;;;;;;;;;;;;GAcG;AACH,SAAsB,SAAS,CAC7B,SAAiB,EACjB,OAAe,EACf,OAA0B;;QAE1B,MAAM,EAAE,QAA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AAA;QACF,IAAI,CAAC,QAAQ;YAAE,OAAM;QACrB,MAAM,EAAE,GAAG,QAAQ,CAAC,iBAAiB,EAAE,CAAA;QAEvC,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,CAAM,CAAC,EAAC,EAAE;YACxD,uCACK,CAAC,KACJ,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,IAC9B;QACH,CAAC,CAAA,CAAC,CAAA;QACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC7C,MAAM,iBAAiB,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,0BAA0B,CAAC,CAAA;QACnF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,KAAK,aAAa,CAAC,EAAE,CAAC;YAC1D,OAAO,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAA;YACxF,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;YACnE,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAA;YAC7C,YAAE,CAAC,aAAa,CAAC,iBAAiB,EAAE,YAAY,EAAE;gBAChD,QAAQ,EAAE,OAAO;aAClB,CAAC,CAAA;QAEJ,CAAC;IAEH,CAAC;CAAA"}
@@ -1,20 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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(';');
4
+ /**
5
+ * Extracts the first `PRODUCT_BUNDLE_IDENTIFIER` value from a
6
+ * `project.pbxproj` file string by simple substring search.
7
+ * Returns the value between the `=` and the terminating `;`.
8
+ */
9
+ const getIosBundleId = (pbxProjectContent) => {
10
+ const pkgStr = 'PRODUCT_BUNDLE_IDENTIFIER =';
11
+ const packageIdx = pbxProjectContent.indexOf(pkgStr) + pkgStr.length;
12
+ let packageName = pbxProjectContent.substring(packageIdx);
13
+ const packageEndIdx = packageName.indexOf(';');
9
14
  packageName = packageName.substring(0, packageEndIdx);
10
15
  return packageName.trim();
11
16
  };
12
17
  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
+ /**
19
+ * Extracts the first `PRODUCT_NAME` value from a `project.pbxproj` file
20
+ * string by simple substring search.
21
+ * Returns the value between the `=` and the terminating `;`.
22
+ */
23
+ const getIosAppName = (pbxProjectContent) => {
24
+ const pkgStr = 'PRODUCT_NAME =';
25
+ const packageIdx = pbxProjectContent.indexOf(pkgStr) + pkgStr.length;
26
+ let packageName = pbxProjectContent.substring(packageIdx);
27
+ const packageEndIdx = packageName.indexOf(';');
18
28
  packageName = packageName.substring(0, packageEndIdx);
19
29
  return packageName.trim();
20
30
  // return JSON.parse(
@@ -24,3 +34,4 @@ var getIosAppName = function (pbxProjectContent) {
24
34
  // ).name
25
35
  };
26
36
  exports.getIosAppName = getIosAppName;
37
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/lib/ios/utils.ts"],"names":[],"mappings":";;;AAIA;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAC,iBAAyB,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,6BAA6B,CAAA;IAE5C,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAA;IACpE,IAAI,WAAW,GAAG,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IACzD,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC9C,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,aAAa,CAAC,CAAA;IACrD,OAAO,WAAW,CAAC,IAAI,EAAE,CAAA;AAC3B,CAAC,CAAA;AARY,QAAA,cAAc,kBAQ1B;AAED;;;;GAIG;AACI,MAAM,aAAa,GAAG,CAAC,iBAAyB,EAAE,EAAE;IACzD,MAAM,MAAM,GAAG,gBAAgB,CAAA;IAC/B,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAA;IACpE,IAAI,WAAW,GAAG,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;IACzD,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC9C,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,aAAa,CAAC,CAAA;IACrD,OAAO,WAAW,CAAC,IAAI,EAAE,CAAA;IACzB,qBAAqB;IACrB,qBAAqB;IACrB,kCAAkC;IAClC,kBAAkB;IAClB,SAAS;AACX,CAAC,CAAA;AAZY,QAAA,aAAa,iBAYzB"}
@@ -8,33 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
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
11
  var __rest = (this && this.__rest) || function (s, e) {
39
12
  var t = {};
40
13
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -48,31 +21,27 @@ var __rest = (this && this.__rest) || function (s, e) {
48
21
  };
49
22
  Object.defineProperty(exports, "__esModule", { value: true });
50
23
  exports.spinWhileNotCompleted = spinWhileNotCompleted;
51
- var nanospinner_1 = require("nanospinner");
24
+ const nanospinner_1 = require("nanospinner");
25
+ /**
26
+ * Runs `operation` while displaying a terminal spinner labelled `opts.name`.
27
+ * Marks the spinner as succeeded on resolution or as errored on rejection
28
+ * (logging the error to stderr). Returns the resolved value, or `undefined`
29
+ * if the operation threw.
30
+ */
52
31
  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
- });
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const { name } = opts, others = __rest(opts, ["name"]);
34
+ const spinner = (0, nanospinner_1.createSpinner)(`${name}\n`, others);
35
+ spinner.start();
36
+ try {
37
+ const result = yield operation();
38
+ spinner.success();
39
+ return result;
40
+ }
41
+ catch (e) {
42
+ spinner.error();
43
+ console.error(e);
44
+ }
77
45
  });
78
46
  }
47
+ //# sourceMappingURL=spinner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../src/lib/spinner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA,sDAoBC;AAhCD,6CAA2C;AAM3C;;;;;GAKG;AACH,SAAsB,qBAAqB,CACzC,SAA6B,EAC7B,IAA+B;;QAE/B,MAAM,EAAE,IAAI,KAAgB,IAAI,EAAf,MAAM,UAAK,IAAI,EAA1B,QAAmB,CAAO,CAAA;QAEhC,MAAM,OAAO,GAAG,IAAA,2BAAa,EAAC,GAAG,IAAI,IAAI,EAAE,MAAM,CAAC,CAAA;QAElD,OAAO,CAAC,KAAK,EAAE,CAAA;QACf,IAAI,CAAC;YAEH,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;YAChC,OAAO,CAAC,OAAO,EAAE,CAAA;YAEjB,OAAO,MAAM,CAAA;QACf,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,EAAE,CAAA;YACf,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAClB,CAAC;IAEH,CAAC;CAAA"}
package/dist/lib/utils.js CHANGED
@@ -8,65 +8,88 @@ exports.subprocess = subprocess;
8
8
  exports.listPrompt = listPrompt;
9
9
  exports.findExecutable = findExecutable;
10
10
  exports.parseFilePathData = parseFilePathData;
11
- var child_process_1 = __importDefault(require("child_process"));
12
- var getNewBundleName = function (newName) { return "uk.co.codeleap.".concat(newName.trim()); };
11
+ const child_process_1 = __importDefault(require("child_process"));
12
+ /** Derives the CodeLeap-namespaced bundle/package ID for a given app name. */
13
+ const getNewBundleName = (newName) => `uk.co.codeleap.${newName.trim()}`;
13
14
  exports.getNewBundleName = getNewBundleName;
14
- function subprocess(name) {
15
- var params = [];
16
- for (var _i = 1; _i < arguments.length; _i++) {
17
- params[_i - 1] = arguments[_i];
18
- }
19
- return new Promise(function (resolve, reject) {
15
+ /**
16
+ * Wraps `child_process.spawn` in a promise.
17
+ *
18
+ * Every argument in `params[1]` is JSON-stringified before being passed to the
19
+ * child process, so values that contain spaces or special shell characters are
20
+ * quoted automatically.
21
+ *
22
+ * Rejects when the child emits an `error` event or exits with a non-zero code.
23
+ * stdout and stderr are forwarded to the parent process in real time via
24
+ * `console.log` / `console.error`.
25
+ *
26
+ * @param name Human-readable label used in log messages and error strings.
27
+ */
28
+ function subprocess(name, ...params) {
29
+ return new Promise((resolve, reject) => {
20
30
  var _a, _b, _c, _d;
21
- console.log("Running ".concat(params[0], " ").concat(params[1].join(' ')));
22
- var child = child_process_1.default.spawn(params[0], params[1].map(function (x) { return JSON.stringify(x); }), params[2]);
23
- child.on('error', function (err) {
24
- console.log("".concat(name, " finished with error: "), err.toString());
31
+ console.log(`Running ${params[0]} ${params[1].join(' ')}`);
32
+ const child = child_process_1.default.spawn(params[0], params[1].map(x => JSON.stringify(x)), params[2]);
33
+ child.on('error', (err) => {
34
+ console.log(`${name} finished with error: `, err.toString());
25
35
  reject(err);
26
36
  });
27
- child.on('close', function (code) {
28
- console.log("".concat(name, " finished with code: "), code);
37
+ child.on('close', (code) => {
38
+ console.log(`${name} finished with code: `, code);
29
39
  if (code !== 0) {
30
- reject("".concat(name, " finieshed with non zero exit code"));
40
+ reject(`${name} finieshed with non zero exit code`);
31
41
  }
32
42
  else {
33
43
  resolve(code);
34
44
  }
35
45
  });
36
- (_b = (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, 'data', function (outdata) {
46
+ (_b = (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, 'data', (outdata) => {
37
47
  console.log(outdata.toString());
38
48
  });
39
- (_d = (_c = child.stderr) === null || _c === void 0 ? void 0 : _c.on) === null || _d === void 0 ? void 0 : _d.call(_c, 'data', function (errdata) {
49
+ (_d = (_c = child.stderr) === null || _c === void 0 ? void 0 : _c.on) === null || _d === void 0 ? void 0 : _d.call(_c, 'data', (errdata) => {
40
50
  console.error(errdata.toString());
41
51
  });
42
52
  });
43
53
  }
44
- function listPrompt(items, numbered) {
45
- if (numbered === void 0) { numbered = false; }
46
- var textArr = items.map(function (i, idx) {
47
- var prefix = numbered ? "".concat(idx + 1, ". ") : '- ';
48
- return "".concat(prefix).concat(i);
54
+ /**
55
+ * Formats an array of strings into a bulleted or numbered list suitable for
56
+ * embedding inside an `inquirer` prompt message string.
57
+ */
58
+ function listPrompt(items, numbered = false) {
59
+ const textArr = items.map((i, idx) => {
60
+ const prefix = numbered ? `${idx + 1}. ` : '- ';
61
+ return `${prefix}${i}`;
49
62
  });
50
- return "\n".concat(textArr.join('\n'), "\n");
63
+ return `\n${textArr.join('\n')}\n`;
51
64
  }
52
- var path_1 = __importDefault(require("path"));
65
+ const path_1 = __importDefault(require("path"));
53
66
  exports.path = path_1.default;
54
- var fs_1 = __importDefault(require("fs"));
67
+ const fs_1 = __importDefault(require("fs"));
55
68
  exports.fs = fs_1.default;
56
- var os_1 = __importDefault(require("os"));
69
+ const os_1 = __importDefault(require("os"));
70
+ /**
71
+ * Resolves the full path of a command using `which`.
72
+ * Returns `undefined` on Windows (not supported) and throws if the executable
73
+ * is not on `PATH`.
74
+ */
57
75
  function findExecutable(exec) {
58
76
  if (os_1.default.platform() === 'win32')
59
77
  return;
60
78
  return child_process_1.default.execSync('which ' + exec).toString().replace(/\n/g, '');
61
79
  }
62
- var separators = /[\\\/]+/;
80
+ const separators = /[\\\/]+/;
81
+ /**
82
+ * Splits a file path into its directory, base name, and extension components.
83
+ * Handles both Unix (`/`) and Windows (`\`) separators. When the base name
84
+ * has no dot the `extension` field is an empty string.
85
+ */
63
86
  function parseFilePathData(path) {
64
- var parts = path.split(separators);
65
- var lastPart = parts[parts.length - 1];
66
- var fileName = lastPart;
67
- var ext = '';
87
+ const parts = path.split(separators);
88
+ const lastPart = parts[parts.length - 1];
89
+ let fileName = lastPart;
90
+ let ext = '';
68
91
  if (lastPart.includes('.')) {
69
- var dotIdx = fileName.lastIndexOf('.');
92
+ const dotIdx = fileName.lastIndexOf('.');
70
93
  fileName = fileName.substring(0, dotIdx);
71
94
  ext = lastPart.substring(dotIdx + 1);
72
95
  }
@@ -76,3 +99,4 @@ function parseFilePathData(path) {
76
99
  name: fileName,
77
100
  };
78
101
  }
102
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":";;;;;;AAkBA,gCA+BC;AAMD,gCAQC;AAcD,wCAIC;AASD,8CAoBC;AA9GD,kEAA8B;AAE9B,8EAA8E;AACvE,MAAM,gBAAgB,GAAG,CAAC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