@solana-mobile/dapp-store-cli 0.4.1 → 0.4.3

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 (112) hide show
  1. package/bin/dapp-store.js +1 -1
  2. package/lib/CliSetup.js +730 -0
  3. package/lib/CliUtils.js +309 -0
  4. package/lib/__tests__/CliSetupTest.js +140 -0
  5. package/lib/commands/ValidateCommand.js +201 -0
  6. package/lib/commands/create/CreateCliApp.js +240 -0
  7. package/lib/commands/create/CreateCliPublisher.js +238 -0
  8. package/lib/commands/create/CreateCliRelease.js +270 -0
  9. package/lib/commands/create/index.js +41 -0
  10. package/lib/{esm/commands → commands}/index.js +0 -1
  11. package/lib/commands/publish/PublishCliRemove.js +186 -0
  12. package/lib/commands/publish/PublishCliSubmit.js +192 -0
  13. package/lib/commands/publish/PublishCliSupport.js +186 -0
  14. package/lib/commands/publish/PublishCliUpdate.js +193 -0
  15. package/lib/commands/publish/index.js +22 -0
  16. package/lib/{esm/commands → commands}/scaffolding/ScaffoldInit.js +7 -6
  17. package/lib/{esm/commands → commands}/scaffolding/index.js +0 -1
  18. package/lib/config/EnvVariables.js +59 -0
  19. package/lib/config/PublishDetails.js +555 -0
  20. package/lib/config/S3StorageManager.js +93 -0
  21. package/lib/config/index.js +2 -0
  22. package/lib/generated/config_obj.json +1 -0
  23. package/lib/generated/config_schema.json +1 -0
  24. package/lib/index.js +148 -0
  25. package/lib/package.json +74 -0
  26. package/lib/prebuild_schema/publishing_source.yaml +46 -0
  27. package/lib/prebuild_schema/schemagen.js +20 -0
  28. package/lib/upload/CachedStorageDriver.js +307 -0
  29. package/lib/{esm/upload → upload}/index.js +0 -1
  30. package/package.json +21 -7
  31. package/src/CliSetup.ts +512 -0
  32. package/src/CliUtils.ts +68 -19
  33. package/src/__tests__/CliSetupTest.ts +212 -0
  34. package/src/commands/create/CreateCliApp.ts +6 -1
  35. package/src/commands/create/CreateCliPublisher.ts +6 -1
  36. package/src/commands/create/CreateCliRelease.ts +6 -1
  37. package/src/config/EnvVariables.ts +39 -0
  38. package/src/config/PublishDetails.ts +4 -6
  39. package/src/config/S3StorageManager.ts +47 -0
  40. package/src/config/index.ts +2 -0
  41. package/src/index.ts +3 -510
  42. package/lib/esm/CliUtils.js +0 -105
  43. package/lib/esm/CliUtils.js.map +0 -1
  44. package/lib/esm/commands/ValidateCommand.js +0 -42
  45. package/lib/esm/commands/ValidateCommand.js.map +0 -1
  46. package/lib/esm/commands/create/CreateCliApp.js +0 -41
  47. package/lib/esm/commands/create/CreateCliApp.js.map +0 -1
  48. package/lib/esm/commands/create/CreateCliPublisher.js +0 -36
  49. package/lib/esm/commands/create/CreateCliPublisher.js.map +0 -1
  50. package/lib/esm/commands/create/CreateCliRelease.js +0 -50
  51. package/lib/esm/commands/create/CreateCliRelease.js.map +0 -1
  52. package/lib/esm/commands/create/index.js +0 -44
  53. package/lib/esm/commands/create/index.js.map +0 -1
  54. package/lib/esm/commands/index.js.map +0 -1
  55. package/lib/esm/commands/publish/PublishCliRemove.js +0 -26
  56. package/lib/esm/commands/publish/PublishCliRemove.js.map +0 -1
  57. package/lib/esm/commands/publish/PublishCliSubmit.js +0 -31
  58. package/lib/esm/commands/publish/PublishCliSubmit.js.map +0 -1
  59. package/lib/esm/commands/publish/PublishCliSupport.js +0 -26
  60. package/lib/esm/commands/publish/PublishCliSupport.js.map +0 -1
  61. package/lib/esm/commands/publish/PublishCliUpdate.js +0 -32
  62. package/lib/esm/commands/publish/PublishCliUpdate.js.map +0 -1
  63. package/lib/esm/commands/publish/index.js +0 -25
  64. package/lib/esm/commands/publish/index.js.map +0 -1
  65. package/lib/esm/commands/scaffolding/ScaffoldInit.js.map +0 -1
  66. package/lib/esm/commands/scaffolding/index.js.map +0 -1
  67. package/lib/esm/config/PublishDetails.js +0 -178
  68. package/lib/esm/config/PublishDetails.js.map +0 -1
  69. package/lib/esm/generated/config_obj.json +0 -1
  70. package/lib/esm/generated/config_schema.json +0 -1
  71. package/lib/esm/index.js +0 -307
  72. package/lib/esm/index.js.map +0 -1
  73. package/lib/esm/package.json +0 -60
  74. package/lib/esm/upload/CachedStorageDriver.js +0 -66
  75. package/lib/esm/upload/CachedStorageDriver.js.map +0 -1
  76. package/lib/esm/upload/index.js.map +0 -1
  77. package/lib/types/CliUtils.d.ts +0 -20
  78. package/lib/types/CliUtils.d.ts.map +0 -1
  79. package/lib/types/commands/ValidateCommand.d.ts +0 -6
  80. package/lib/types/commands/ValidateCommand.d.ts.map +0 -1
  81. package/lib/types/commands/create/CreateCliApp.d.ts +0 -12
  82. package/lib/types/commands/create/CreateCliApp.d.ts.map +0 -1
  83. package/lib/types/commands/create/CreateCliPublisher.d.ts +0 -9
  84. package/lib/types/commands/create/CreateCliPublisher.d.ts.map +0 -1
  85. package/lib/types/commands/create/CreateCliRelease.d.ts +0 -13
  86. package/lib/types/commands/create/CreateCliRelease.d.ts.map +0 -1
  87. package/lib/types/commands/create/index.d.ts +0 -4
  88. package/lib/types/commands/create/index.d.ts.map +0 -1
  89. package/lib/types/commands/index.d.ts +0 -4
  90. package/lib/types/commands/index.d.ts.map +0 -1
  91. package/lib/types/commands/publish/PublishCliRemove.d.ts +0 -13
  92. package/lib/types/commands/publish/PublishCliRemove.d.ts.map +0 -1
  93. package/lib/types/commands/publish/PublishCliSubmit.d.ts +0 -13
  94. package/lib/types/commands/publish/PublishCliSubmit.d.ts.map +0 -1
  95. package/lib/types/commands/publish/PublishCliSupport.d.ts +0 -13
  96. package/lib/types/commands/publish/PublishCliSupport.d.ts.map +0 -1
  97. package/lib/types/commands/publish/PublishCliUpdate.d.ts +0 -14
  98. package/lib/types/commands/publish/PublishCliUpdate.d.ts.map +0 -1
  99. package/lib/types/commands/publish/index.d.ts +0 -5
  100. package/lib/types/commands/publish/index.d.ts.map +0 -1
  101. package/lib/types/commands/scaffolding/ScaffoldInit.d.ts +0 -2
  102. package/lib/types/commands/scaffolding/ScaffoldInit.d.ts.map +0 -1
  103. package/lib/types/commands/scaffolding/index.d.ts +0 -2
  104. package/lib/types/commands/scaffolding/index.d.ts.map +0 -1
  105. package/lib/types/config/PublishDetails.d.ts +0 -17
  106. package/lib/types/config/PublishDetails.d.ts.map +0 -1
  107. package/lib/types/index.d.ts +0 -2
  108. package/lib/types/index.d.ts.map +0 -1
  109. package/lib/types/upload/CachedStorageDriver.d.ts +0 -30
  110. package/lib/types/upload/CachedStorageDriver.d.ts.map +0 -1
  111. package/lib/types/upload/index.d.ts +0 -2
  112. package/lib/types/upload/index.d.ts.map +0 -1
@@ -0,0 +1,555 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
8
+ }
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
10
+ try {
11
+ var info = gen[key](arg);
12
+ var value = info.value;
13
+ } catch (error) {
14
+ reject(error);
15
+ return;
16
+ }
17
+ if (info.done) {
18
+ resolve(value);
19
+ } else {
20
+ Promise.resolve(value).then(_next, _throw);
21
+ }
22
+ }
23
+ function _async_to_generator(fn) {
24
+ return function() {
25
+ var self = this, args = arguments;
26
+ return new Promise(function(resolve, reject) {
27
+ var gen = fn.apply(self, args);
28
+ function _next(value) {
29
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
30
+ }
31
+ function _throw(err) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
33
+ }
34
+ _next(undefined);
35
+ });
36
+ };
37
+ }
38
+ function _define_property(obj, key, value) {
39
+ if (key in obj) {
40
+ Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ } else {
47
+ obj[key] = value;
48
+ }
49
+ return obj;
50
+ }
51
+ function _iterable_to_array(iter) {
52
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
53
+ }
54
+ function _non_iterable_spread() {
55
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
56
+ }
57
+ function _object_spread(target) {
58
+ for(var i = 1; i < arguments.length; i++){
59
+ var source = arguments[i] != null ? arguments[i] : {};
60
+ var ownKeys = Object.keys(source);
61
+ if (typeof Object.getOwnPropertySymbols === "function") {
62
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
63
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
64
+ }));
65
+ }
66
+ ownKeys.forEach(function(key) {
67
+ _define_property(target, key, source[key]);
68
+ });
69
+ }
70
+ return target;
71
+ }
72
+ function ownKeys(object, enumerableOnly) {
73
+ var keys = Object.keys(object);
74
+ if (Object.getOwnPropertySymbols) {
75
+ var symbols = Object.getOwnPropertySymbols(object);
76
+ if (enumerableOnly) {
77
+ symbols = symbols.filter(function(sym) {
78
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
79
+ });
80
+ }
81
+ keys.push.apply(keys, symbols);
82
+ }
83
+ return keys;
84
+ }
85
+ function _object_spread_props(target, source) {
86
+ source = source != null ? source : {};
87
+ if (Object.getOwnPropertyDescriptors) {
88
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
89
+ } else {
90
+ ownKeys(Object(source)).forEach(function(key) {
91
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
92
+ });
93
+ }
94
+ return target;
95
+ }
96
+ function _to_consumable_array(arr) {
97
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
98
+ }
99
+ function _unsupported_iterable_to_array(o, minLen) {
100
+ if (!o) return;
101
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
102
+ var n = Object.prototype.toString.call(o).slice(8, -1);
103
+ if (n === "Object" && o.constructor) n = o.constructor.name;
104
+ if (n === "Map" || n === "Set") return Array.from(n);
105
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
106
+ }
107
+ function _ts_generator(thisArg, body) {
108
+ var f, y, t, g, _ = {
109
+ label: 0,
110
+ sent: function() {
111
+ if (t[0] & 1) throw t[1];
112
+ return t[1];
113
+ },
114
+ trys: [],
115
+ ops: []
116
+ };
117
+ return(g = {
118
+ next: verb(0),
119
+ "throw": verb(1),
120
+ "return": verb(2)
121
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
122
+ return this;
123
+ }), g);
124
+ function verb(n) {
125
+ return function(v) {
126
+ return step([
127
+ n,
128
+ v
129
+ ]);
130
+ };
131
+ }
132
+ function step(op) {
133
+ if (f) throw new TypeError("Generator is already executing.");
134
+ while(_)try {
135
+ 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;
136
+ if (y = 0, t) op = [
137
+ op[0] & 2,
138
+ t.value
139
+ ];
140
+ switch(op[0]){
141
+ case 0:
142
+ case 1:
143
+ t = op;
144
+ break;
145
+ case 4:
146
+ _.label++;
147
+ return {
148
+ value: op[1],
149
+ done: false
150
+ };
151
+ case 5:
152
+ _.label++;
153
+ y = op[1];
154
+ op = [
155
+ 0
156
+ ];
157
+ continue;
158
+ case 7:
159
+ op = _.ops.pop();
160
+ _.trys.pop();
161
+ continue;
162
+ default:
163
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
164
+ _ = 0;
165
+ continue;
166
+ }
167
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
168
+ _.label = op[1];
169
+ break;
170
+ }
171
+ if (op[0] === 6 && _.label < t[1]) {
172
+ _.label = t[1];
173
+ t = op;
174
+ break;
175
+ }
176
+ if (t && _.label < t[2]) {
177
+ _.label = t[2];
178
+ _.ops.push(op);
179
+ break;
180
+ }
181
+ if (t[2]) _.ops.pop();
182
+ _.trys.pop();
183
+ continue;
184
+ }
185
+ op = body.call(thisArg, _);
186
+ } catch (e) {
187
+ op = [
188
+ 6,
189
+ e
190
+ ];
191
+ y = 0;
192
+ } finally{
193
+ f = t = 0;
194
+ }
195
+ if (op[0] & 5) throw op[1];
196
+ return {
197
+ value: op[0] ? op[1] : void 0,
198
+ done: true
199
+ };
200
+ }
201
+ }
202
+ import { dump, load } from "js-yaml";
203
+ import Ajv from "ajv";
204
+ // eslint-disable-next-line require-extensions/require-extensions
205
+ import schemaJson from "../generated/config_schema.json" assert {
206
+ type: "json"
207
+ };
208
+ import fs from "fs";
209
+ import path from "path";
210
+ import { toMetaplexFile } from "@metaplex-foundation/js";
211
+ import { Constants, showMessage } from "../CliUtils.js";
212
+ import util from "util";
213
+ import { imageSize } from "image-size";
214
+ import { exec } from "child_process";
215
+ var runImgSize = util.promisify(imageSize);
216
+ var runExec = util.promisify(exec);
217
+ var AaptPrefixes = {
218
+ quoteRegex: "'(.*?)'",
219
+ quoteNonLazyRegex: "'(.*)'",
220
+ packagePrefix: "package: name=",
221
+ verCodePrefix: "versionCode=",
222
+ verNamePrefix: "versionName=",
223
+ sdkPrefix: "sdkVersion:",
224
+ localePrefix: "locales: "
225
+ };
226
+ var ajv = new Ajv({
227
+ strictTuples: false
228
+ });
229
+ var validate = ajv.compile(schemaJson);
230
+ export var loadPublishDetails = function() {
231
+ var _ref = _async_to_generator(function(configPath) {
232
+ var configFile, valid;
233
+ return _ts_generator(this, function(_state) {
234
+ switch(_state.label){
235
+ case 0:
236
+ return [
237
+ 4,
238
+ fs.promises.readFile(configPath, "utf-8")
239
+ ];
240
+ case 1:
241
+ configFile = _state.sent();
242
+ valid = validate(load(configFile));
243
+ if (!valid) {
244
+ console.error(validate.errors);
245
+ process.exit(1);
246
+ }
247
+ return [
248
+ 2,
249
+ load(configFile)
250
+ ];
251
+ }
252
+ });
253
+ });
254
+ return function loadPublishDetails(configPath) {
255
+ return _ref.apply(this, arguments);
256
+ };
257
+ }();
258
+ export var loadPublishDetailsWithChecks = function() {
259
+ var _ref = _async_to_generator(function() {
260
+ var buildToolsDir, _config_publisher_media_find, _config_publisher_media, _config_app_media_find, _config_app_media, _config_release_media_find, _config_release_media, config, apkEntry, apkPath, _, publisherIcon, iconPath, iconBuffer, appIcon, iconPath1, iconBuffer1, releaseIcon, iconPath2, googlePkg, pkgCompare;
261
+ var _arguments = arguments;
262
+ return _ts_generator(this, function(_state) {
263
+ switch(_state.label){
264
+ case 0:
265
+ buildToolsDir = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : null;
266
+ return [
267
+ 4,
268
+ loadPublishDetails(Constants.getConfigFilePath())
269
+ ];
270
+ case 1:
271
+ config = _state.sent();
272
+ apkEntry = config.release.files.find(function(asset) {
273
+ return asset.purpose === "install";
274
+ });
275
+ apkPath = path.join(process.cwd(), apkEntry === null || apkEntry === void 0 ? void 0 : apkEntry.uri);
276
+ if (!fs.existsSync(apkPath)) {
277
+ throw new Error("Invalid path to APK file.");
278
+ }
279
+ if (!buildToolsDir) return [
280
+ 3,
281
+ 3
282
+ ];
283
+ _ = config.release;
284
+ return [
285
+ 4,
286
+ getAndroidDetails(buildToolsDir, apkPath)
287
+ ];
288
+ case 2:
289
+ _.android_details = _state.sent();
290
+ _state.label = 3;
291
+ case 3:
292
+ publisherIcon = (_config_publisher_media_find = (_config_publisher_media = config.publisher.media) === null || _config_publisher_media === void 0 ? void 0 : _config_publisher_media.find(function(asset) {
293
+ return asset.purpose === "icon";
294
+ })) === null || _config_publisher_media_find === void 0 ? void 0 : _config_publisher_media_find.uri;
295
+ if (!publisherIcon) return [
296
+ 3,
297
+ 6
298
+ ];
299
+ iconPath = path.join(process.cwd(), publisherIcon);
300
+ return [
301
+ 4,
302
+ checkIconCompatibility(iconPath, "Publisher")
303
+ ];
304
+ case 4:
305
+ _state.sent();
306
+ return [
307
+ 4,
308
+ fs.promises.readFile(iconPath)
309
+ ];
310
+ case 5:
311
+ iconBuffer = _state.sent();
312
+ config.publisher.icon = toMetaplexFile(iconBuffer, publisherIcon);
313
+ _state.label = 6;
314
+ case 6:
315
+ appIcon = (_config_app_media_find = (_config_app_media = config.app.media) === null || _config_app_media === void 0 ? void 0 : _config_app_media.find(function(asset) {
316
+ return asset.purpose === "icon";
317
+ })) === null || _config_app_media_find === void 0 ? void 0 : _config_app_media_find.uri;
318
+ if (!appIcon) return [
319
+ 3,
320
+ 9
321
+ ];
322
+ iconPath1 = path.join(process.cwd(), appIcon);
323
+ return [
324
+ 4,
325
+ checkIconCompatibility(iconPath1, "App")
326
+ ];
327
+ case 7:
328
+ _state.sent();
329
+ return [
330
+ 4,
331
+ fs.promises.readFile(iconPath1)
332
+ ];
333
+ case 8:
334
+ iconBuffer1 = _state.sent();
335
+ config.app.icon = toMetaplexFile(iconBuffer1, appIcon);
336
+ _state.label = 9;
337
+ case 9:
338
+ releaseIcon = (_config_release_media_find = (_config_release_media = config.release.media) === null || _config_release_media === void 0 ? void 0 : _config_release_media.find(function(asset) {
339
+ return asset.purpose === "icon";
340
+ })) === null || _config_release_media_find === void 0 ? void 0 : _config_release_media_find.uri;
341
+ if (!releaseIcon) return [
342
+ 3,
343
+ 11
344
+ ];
345
+ iconPath2 = path.join(process.cwd(), releaseIcon);
346
+ return [
347
+ 4,
348
+ checkIconCompatibility(iconPath2, "Release")
349
+ ];
350
+ case 10:
351
+ _state.sent();
352
+ _state.label = 11;
353
+ case 11:
354
+ if (!appIcon && !releaseIcon) {
355
+ throw new Error("Please specify at least one media entry of type icon in your configuration file");
356
+ }
357
+ config.release.media.forEach(function(item) {
358
+ var imagePath = path.join(process.cwd(), item.uri);
359
+ if (!fs.existsSync(imagePath) || !checkImageExtension(imagePath)) {
360
+ throw new Error("Invalid media path or file type: ".concat(item.uri, ". Please ensure the file is a jpeg, png, or webp file."));
361
+ }
362
+ });
363
+ validateLocalizableResources(config);
364
+ googlePkg = config.solana_mobile_dapp_publisher_portal.google_store_package;
365
+ if (googlePkg === null || googlePkg === void 0 ? void 0 : googlePkg.length) {
366
+ pkgCompare = new RegExp("[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)+").exec(googlePkg);
367
+ if (!(pkgCompare === null || pkgCompare === void 0 ? void 0 : pkgCompare.length)) {
368
+ throw new Error("Please provide a valid Google store package name in the Publisher Portal section of your configuration file.");
369
+ }
370
+ }
371
+ return [
372
+ 2,
373
+ config
374
+ ];
375
+ }
376
+ });
377
+ });
378
+ return function loadPublishDetailsWithChecks() {
379
+ return _ref.apply(this, arguments);
380
+ };
381
+ }();
382
+ var checkIconCompatibility = function() {
383
+ var _ref = _async_to_generator(function(path, typeString) {
384
+ return _ts_generator(this, function(_state) {
385
+ switch(_state.label){
386
+ case 0:
387
+ if (!fs.existsSync(path) || !checkImageExtension(path)) {
388
+ throw new Error("Please check the path to your ".concat(typeString, " icon and ensure the file is a jpeg, png, or webp file."));
389
+ }
390
+ return [
391
+ 4,
392
+ checkIconDimensions(path)
393
+ ];
394
+ case 1:
395
+ if (_state.sent()) {
396
+ throw new Error("Icons must have square dimensions and be no greater than 512px by 512px.");
397
+ }
398
+ return [
399
+ 2
400
+ ];
401
+ }
402
+ });
403
+ });
404
+ return function checkIconCompatibility(path, typeString) {
405
+ return _ref.apply(this, arguments);
406
+ };
407
+ }();
408
+ var checkImageExtension = function(uri) {
409
+ var fileExt = path.extname(uri).toLowerCase();
410
+ return fileExt == ".png" || fileExt == ".jpg" || fileExt == ".jpeg" || fileExt == ".webp";
411
+ };
412
+ /**
413
+ * We need to pre-check some things in the localized resources before we move forward
414
+ */ var validateLocalizableResources = function(config) {
415
+ if (!config.release.catalog["en-US"]) {
416
+ throw new Error("Please ensure you have the en-US locale strings in your configuration file.");
417
+ }
418
+ var baselineSize = Object.keys(config.release.catalog["en-US"]).length;
419
+ Object.keys(config.release.catalog).forEach(function(locale) {
420
+ var size = Object.keys(config.release.catalog[locale]).length;
421
+ if (size != baselineSize) {
422
+ throw new Error("Please ensure you have included all localized strings for all locales in your configuration file.");
423
+ }
424
+ });
425
+ var descsWrongLength = Object.values(config.release.catalog).map(function(x) {
426
+ return x.short_description;
427
+ }).filter(function(desc) {
428
+ return !(desc === null || desc === void 0 ? void 0 : desc.length) || desc.length > 30;
429
+ });
430
+ if (descsWrongLength.length > 0) {
431
+ throw new Error("Please ensure all translations of short_description are between 0 and 30 characters");
432
+ }
433
+ };
434
+ var checkIconDimensions = function() {
435
+ var _ref = _async_to_generator(function(iconPath) {
436
+ var size, _size_width;
437
+ return _ts_generator(this, function(_state) {
438
+ switch(_state.label){
439
+ case 0:
440
+ return [
441
+ 4,
442
+ runImgSize(iconPath)
443
+ ];
444
+ case 1:
445
+ size = _state.sent();
446
+ return [
447
+ 2,
448
+ (size === null || size === void 0 ? void 0 : size.width) != (size === null || size === void 0 ? void 0 : size.height) || ((_size_width = size === null || size === void 0 ? void 0 : size.width) !== null && _size_width !== void 0 ? _size_width : 0) > 512
449
+ ];
450
+ }
451
+ });
452
+ });
453
+ return function checkIconDimensions(iconPath) {
454
+ return _ref.apply(this, arguments);
455
+ };
456
+ }();
457
+ var getAndroidDetails = function() {
458
+ var _ref = _async_to_generator(function(aaptDir, apkPath) {
459
+ var stdout, appPackage, versionCode, versionName, minSdk, permissions, locales, _locales_values, localeArray, localesSrc, _appPackage_, _minSdk_, _versionCode_, _versionName_, e;
460
+ return _ts_generator(this, function(_state) {
461
+ switch(_state.label){
462
+ case 0:
463
+ _state.trys.push([
464
+ 0,
465
+ 2,
466
+ ,
467
+ 3
468
+ ]);
469
+ return [
470
+ 4,
471
+ runExec("".concat(aaptDir, '/aapt2 dump badging "').concat(apkPath, '"'))
472
+ ];
473
+ case 1:
474
+ stdout = _state.sent().stdout;
475
+ appPackage = new RegExp(AaptPrefixes.packagePrefix + AaptPrefixes.quoteRegex).exec(stdout);
476
+ versionCode = new RegExp(AaptPrefixes.verCodePrefix + AaptPrefixes.quoteRegex).exec(stdout);
477
+ versionName = new RegExp(AaptPrefixes.verNamePrefix + AaptPrefixes.quoteRegex).exec(stdout);
478
+ minSdk = new RegExp(AaptPrefixes.sdkPrefix + AaptPrefixes.quoteRegex).exec(stdout);
479
+ permissions = _to_consumable_array(stdout.matchAll(/uses-permission: name='(.*)'/g));
480
+ locales = new RegExp(AaptPrefixes.localePrefix + AaptPrefixes.quoteNonLazyRegex).exec(stdout);
481
+ localeArray = Array.from((_locales_values = locales === null || locales === void 0 ? void 0 : locales.values()) !== null && _locales_values !== void 0 ? _locales_values : []);
482
+ if (localeArray.length == 2) {
483
+ localesSrc = localeArray[1];
484
+ localeArray = [
485
+ "en-US"
486
+ ].concat(localesSrc.split("' '").slice(1));
487
+ }
488
+ if (localeArray.length >= 60) {
489
+ showMessage("The bundle apk claims supports for following locales", "Claim for supported locales::\n" + localeArray + "\nIf this release does not support all these locales the release may be rejected" + "\nSee details at https://developer.android.com/guide/topics/resources/multilingual-support#design for configuring the supported locales", "warning");
490
+ }
491
+ return [
492
+ 2,
493
+ {
494
+ android_package: (_appPackage_ = appPackage === null || appPackage === void 0 ? void 0 : appPackage[1]) !== null && _appPackage_ !== void 0 ? _appPackage_ : "",
495
+ min_sdk: parseInt((_minSdk_ = minSdk === null || minSdk === void 0 ? void 0 : minSdk[1]) !== null && _minSdk_ !== void 0 ? _minSdk_ : "0", 10),
496
+ version_code: parseInt((_versionCode_ = versionCode === null || versionCode === void 0 ? void 0 : versionCode[1]) !== null && _versionCode_ !== void 0 ? _versionCode_ : "0", 10),
497
+ version: (_versionName_ = versionName === null || versionName === void 0 ? void 0 : versionName[1]) !== null && _versionName_ !== void 0 ? _versionName_ : "0",
498
+ permissions: permissions.flatMap(function(permission) {
499
+ return permission[1];
500
+ }),
501
+ locales: localeArray
502
+ }
503
+ ];
504
+ case 2:
505
+ e = _state.sent();
506
+ throw new Error("There was an error parsing your APK. Please ensure you have provided a valid Android tools directory containing AAPT2.");
507
+ case 3:
508
+ return [
509
+ 2
510
+ ];
511
+ }
512
+ });
513
+ });
514
+ return function getAndroidDetails(aaptDir, apkPath) {
515
+ return _ref.apply(this, arguments);
516
+ };
517
+ }();
518
+ export var writeToPublishDetails = function() {
519
+ var _ref = _async_to_generator(function(param) {
520
+ var publisher, app, release, currentConfig, _publisher_address, _app_address, _release_address, newConfig;
521
+ return _ts_generator(this, function(_state) {
522
+ switch(_state.label){
523
+ case 0:
524
+ publisher = param.publisher, app = param.app, release = param.release;
525
+ return [
526
+ 4,
527
+ loadPublishDetailsWithChecks()
528
+ ];
529
+ case 1:
530
+ currentConfig = _state.sent();
531
+ delete currentConfig.publisher.icon;
532
+ delete currentConfig.app.icon;
533
+ newConfig = {
534
+ publisher: _object_spread_props(_object_spread({}, currentConfig.publisher), {
535
+ address: (_publisher_address = publisher === null || publisher === void 0 ? void 0 : publisher.address) !== null && _publisher_address !== void 0 ? _publisher_address : currentConfig.publisher.address
536
+ }),
537
+ app: _object_spread_props(_object_spread({}, currentConfig.app), {
538
+ address: (_app_address = app === null || app === void 0 ? void 0 : app.address) !== null && _app_address !== void 0 ? _app_address : currentConfig.app.address
539
+ }),
540
+ release: _object_spread_props(_object_spread({}, currentConfig.release), {
541
+ address: (_release_address = release === null || release === void 0 ? void 0 : release.address) !== null && _release_address !== void 0 ? _release_address : currentConfig.release.address
542
+ }),
543
+ solana_mobile_dapp_publisher_portal: currentConfig.solana_mobile_dapp_publisher_portal
544
+ };
545
+ fs.writeFileSync(Constants.getConfigFilePath(), dump(newConfig));
546
+ return [
547
+ 2
548
+ ];
549
+ }
550
+ });
551
+ });
552
+ return function writeToPublishDetails(_) {
553
+ return _ref.apply(this, arguments);
554
+ };
555
+ }();
@@ -0,0 +1,93 @@
1
+ function _class_call_check(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
+ }
6
+ function _defineProperties(target, props) {
7
+ for(var i = 0; i < props.length; i++){
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
13
+ }
14
+ }
15
+ function _create_class(Constructor, protoProps, staticProps) {
16
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) _defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ }
20
+ function _define_property(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
33
+ function _instanceof(left, right) {
34
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
35
+ return !!right[Symbol.hasInstance](left);
36
+ } else {
37
+ return left instanceof right;
38
+ }
39
+ }
40
+ export var S3StorageManager = /*#__PURE__*/ function() {
41
+ "use strict";
42
+ function S3StorageManager(envVars) {
43
+ _class_call_check(this, S3StorageManager);
44
+ _define_property(this, "envVars", void 0);
45
+ _define_property(this, "_config", void 0);
46
+ this.envVars = envVars;
47
+ this._config = undefined;
48
+ if (envVars.hasS3EnvArgs) {
49
+ this._config = {
50
+ accessKey: this.envVars.s3Config.accessKey,
51
+ secretKey: this.envVars.s3Config.secretKey,
52
+ bucketName: this.envVars.s3Config.bucketName,
53
+ regionName: this.envVars.s3Config.regionName
54
+ };
55
+ }
56
+ }
57
+ _create_class(S3StorageManager, [
58
+ {
59
+ key: "hasS3Config",
60
+ get: function get() {
61
+ return this._config != undefined;
62
+ }
63
+ },
64
+ {
65
+ key: "s3Config",
66
+ get: function get() {
67
+ return this._config;
68
+ }
69
+ },
70
+ {
71
+ key: "parseCmdArg",
72
+ value: function parseCmdArg(cmdArg) {
73
+ if (!cmdArg || cmdArg == "") return;
74
+ try {
75
+ //This will overwrite any existing parameters already obtained from the .env file
76
+ var parsedArray = JSON.parse("".concat(cmdArg));
77
+ if (_instanceof(parsedArray, Array) && parsedArray[0] == "s3") {
78
+ if (parsedArray.length != 5) throw new Error("Invalid parameters");
79
+ this._config = {
80
+ accessKey: parsedArray[1],
81
+ secretKey: parsedArray[2],
82
+ bucketName: parsedArray[3],
83
+ regionName: parsedArray[4]
84
+ };
85
+ }
86
+ } catch (e) {
87
+ throw new Error("There was an error parsing your s3 parameters from the CLI. Please ensure they are formatted correctly.");
88
+ }
89
+ }
90
+ }
91
+ ]);
92
+ return S3StorageManager;
93
+ }();
@@ -0,0 +1,2 @@
1
+ export * from "./EnvVariables.js";
2
+ export * from "./S3StorageManager.js";
@@ -0,0 +1 @@
1
+ {"publisher":{"name":"<<YOUR_PUBLISHER_NAME>>","address":"","website":"<<URL_OF_PUBLISHER_WEBSITE>>","email":"<<EMAIL_ADDRESS_TO_CONTACT_PUBLISHER>>","media":[{"purpose":"icon","uri":"<<RELATIVE_PATH_TO_PUBLISHER_ICON>>"}]},"app":{"name":"<<APP_NAME>>","address":"","android_package":"<<ANDROID_PACKAGE_NAME>>","urls":{"license_url":"<<URL_OF_APP_LICENSE_OR_TERMS_OF_SERVICE>>","copyright_url":"<<URL_OF_COPYRIGHT_DETAILS_FOR_APP>>","privacy_policy_url":"<<URL_OF_APP_PRIVACY_POLICY>>","website":"<<URL_OF_APP_WEBSITE>>"},"media":[{"purpose":"icon","uri":"<<RELATIVE_PATH_TO_APP_ICON>>"}]},"release":{"address":"","media":[{"purpose":"icon","uri":"<<RELATIVE_PATH_TO_RELEASE_ICON>>"},{"purpose":"screenshot","uri":"<<RELATIVE_PATH_TO_SCREENSHOT>>"}],"files":[{"purpose":"install","uri":"<<RELATIVE_PATH_TO_APK>>"}],"catalog":{"en-US":{"name":"<<APP_NAME>>","short_description":"<<SHORT_APP_DESCRIPTION>>","long_description":"<<LONG_APP_DESCRIPTION>>","new_in_version":"<<WHATS_NEW_IN_THIS_VERSION>>","saga_features":"<<ANY_FEATURES_ONLY_AVAILBLE_WHEN_RUNNING_ON_SAGA>>"}}},"solana_mobile_dapp_publisher_portal":{"google_store_package":"<<ANDROID_PACKAGE_NAME_OF_GOOGLE_PLAY_STORE_VERSION_IF_DIFFERENT>>","testing_instructions":"<<TESTING_INSTRUCTIONS>>"}}
@@ -0,0 +1 @@
1
+ {"type":"object","properties":{"publisher":{"type":"object","properties":{"name":{"type":"string"},"address":{"type":"string"},"website":{"type":"string"},"email":{"type":"string"},"media":{"type":"array","items":{"type":"object","properties":{"purpose":{"type":"string"},"uri":{"type":"string"}}}}}},"app":{"type":"object","properties":{"name":{"type":"string"},"address":{"type":"string"},"android_package":{"type":"string"},"urls":{"type":"object","properties":{"license_url":{"type":"string"},"copyright_url":{"type":"string"},"privacy_policy_url":{"type":"string"},"website":{"type":"string"}}},"media":{"type":"array","items":{"type":"object","properties":{"purpose":{"type":"string"},"uri":{"type":"string"}}}}}},"release":{"type":"object","properties":{"address":{"type":"string"},"media":{"type":"array","items":{"type":"object","properties":{"purpose":{"type":"string"},"uri":{"type":"string"}},"required":["purpose","uri"]}},"files":{"type":"array","items":{"type":"object","properties":{"purpose":{"type":"string"},"uri":{"type":"string"}}}},"catalog":{"type":"object","properties":{"en-US":{"type":"object","properties":{"name":{"type":"string"},"short_description":{"type":"string"},"long_description":{"type":"string"},"new_in_version":{"type":"string"},"saga_features":{"type":"string"}},"required":["short_description"]}}}}},"solana_mobile_dapp_publisher_portal":{"type":"object","properties":{"google_store_package":{"type":"string"},"testing_instructions":{"type":"string"}}}}}