@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,309 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _class_call_check(instance, Constructor) {
31
+ if (!(instance instanceof Constructor)) {
32
+ throw new TypeError("Cannot call a class as a function");
33
+ }
34
+ }
35
+ function _define_property(obj, key, value) {
36
+ if (key in obj) {
37
+ Object.defineProperty(obj, key, {
38
+ value: value,
39
+ enumerable: true,
40
+ configurable: true,
41
+ writable: true
42
+ });
43
+ } else {
44
+ obj[key] = value;
45
+ }
46
+ return obj;
47
+ }
48
+ function _ts_generator(thisArg, body) {
49
+ var f, y, t, g, _ = {
50
+ label: 0,
51
+ sent: function() {
52
+ if (t[0] & 1) throw t[1];
53
+ return t[1];
54
+ },
55
+ trys: [],
56
+ ops: []
57
+ };
58
+ return(g = {
59
+ next: verb(0),
60
+ "throw": verb(1),
61
+ "return": verb(2)
62
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
63
+ return this;
64
+ }), g);
65
+ function verb(n) {
66
+ return function(v) {
67
+ return step([
68
+ n,
69
+ v
70
+ ]);
71
+ };
72
+ }
73
+ function step(op) {
74
+ if (f) throw new TypeError("Generator is already executing.");
75
+ while(_)try {
76
+ 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;
77
+ if (y = 0, t) op = [
78
+ op[0] & 2,
79
+ t.value
80
+ ];
81
+ switch(op[0]){
82
+ case 0:
83
+ case 1:
84
+ t = op;
85
+ break;
86
+ case 4:
87
+ _.label++;
88
+ return {
89
+ value: op[1],
90
+ done: false
91
+ };
92
+ case 5:
93
+ _.label++;
94
+ y = op[1];
95
+ op = [
96
+ 0
97
+ ];
98
+ continue;
99
+ case 7:
100
+ op = _.ops.pop();
101
+ _.trys.pop();
102
+ continue;
103
+ default:
104
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
105
+ _ = 0;
106
+ continue;
107
+ }
108
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
109
+ _.label = op[1];
110
+ break;
111
+ }
112
+ if (op[0] === 6 && _.label < t[1]) {
113
+ _.label = t[1];
114
+ t = op;
115
+ break;
116
+ }
117
+ if (t && _.label < t[2]) {
118
+ _.label = t[2];
119
+ _.ops.push(op);
120
+ break;
121
+ }
122
+ if (t[2]) _.ops.pop();
123
+ _.trys.pop();
124
+ continue;
125
+ }
126
+ op = body.call(thisArg, _);
127
+ } catch (e) {
128
+ op = [
129
+ 6,
130
+ e
131
+ ];
132
+ y = 0;
133
+ } finally{
134
+ f = t = 0;
135
+ }
136
+ if (op[0] & 5) throw op[1];
137
+ return {
138
+ value: op[0] ? op[1] : void 0,
139
+ done: true
140
+ };
141
+ }
142
+ }
143
+ import fs from "fs";
144
+ import { Keypair, PublicKey } from "@solana/web3.js";
145
+ import debugModule from "debug";
146
+ import { BundlrStorageDriver, keypairIdentity, Metaplex } from "@metaplex-foundation/js";
147
+ import updateNotifier from "update-notifier";
148
+ import cliPackage from "./package.json" assert {
149
+ type: "json"
150
+ };
151
+ import boxen from "boxen";
152
+ import ver from "semver";
153
+ import { CachedStorageDriver } from "./upload/CachedStorageDriver.js";
154
+ import { EnvVariables } from "./config/index.js";
155
+ import { S3Client } from "@aws-sdk/client-s3";
156
+ import { awsStorage } from "@metaplex-foundation/js-plugin-aws";
157
+ import { S3StorageManager } from "./config/index.js";
158
+ export var Constants = function Constants() {
159
+ "use strict";
160
+ _class_call_check(this, Constants);
161
+ };
162
+ _define_property(Constants, "CLI_VERSION", "0.4.3");
163
+ _define_property(Constants, "CONFIG_FILE_NAME", "config.yaml");
164
+ _define_property(Constants, "DEFAULT_RPC_DEVNET", "https://api.devnet.solana.com");
165
+ _define_property(Constants, "getConfigFilePath", function() {
166
+ return "".concat(process.cwd(), "/").concat(Constants.CONFIG_FILE_NAME);
167
+ });
168
+ export var debug = debugModule("CLI");
169
+ export var checkForSelfUpdate = function() {
170
+ var _ref = _async_to_generator(function() {
171
+ var notifier, updateInfo, latestVer, currentVer;
172
+ return _ts_generator(this, function(_state) {
173
+ switch(_state.label){
174
+ case 0:
175
+ notifier = updateNotifier({
176
+ pkg: cliPackage
177
+ });
178
+ return [
179
+ 4,
180
+ notifier.fetchInfo()
181
+ ];
182
+ case 1:
183
+ updateInfo = _state.sent();
184
+ latestVer = new ver.SemVer(updateInfo.latest);
185
+ currentVer = new ver.SemVer(updateInfo.current);
186
+ if (latestVer.major > currentVer.major || latestVer.minor > currentVer.minor) {
187
+ throw new Error("Please update to the latest version of the dApp Store CLI before proceeding.");
188
+ }
189
+ return [
190
+ 2
191
+ ];
192
+ }
193
+ });
194
+ });
195
+ return function checkForSelfUpdate() {
196
+ return _ref.apply(this, arguments);
197
+ };
198
+ }();
199
+ export var checkMintedStatus = function() {
200
+ var _ref = _async_to_generator(function(conn, pubAddr, appAddr, releaseAddr) {
201
+ var results, rentAccounts;
202
+ return _ts_generator(this, function(_state) {
203
+ switch(_state.label){
204
+ case 0:
205
+ return [
206
+ 4,
207
+ conn.getMultipleAccountsInfo([
208
+ new PublicKey(pubAddr),
209
+ new PublicKey(appAddr),
210
+ new PublicKey(releaseAddr)
211
+ ])
212
+ ];
213
+ case 1:
214
+ results = _state.sent();
215
+ rentAccounts = results.filter(function(item) {
216
+ return !(item == undefined) && (item === null || item === void 0 ? void 0 : item.lamports) > 0;
217
+ });
218
+ if ((rentAccounts === null || rentAccounts === void 0 ? void 0 : rentAccounts.length) != 3) {
219
+ throw new Error("Please ensure you have minted all of your NFTs before submitting to the Solana Mobile dApp publisher portal.");
220
+ }
221
+ return [
222
+ 2
223
+ ];
224
+ }
225
+ });
226
+ });
227
+ return function checkMintedStatus(conn, pubAddr, appAddr, releaseAddr) {
228
+ return _ref.apply(this, arguments);
229
+ };
230
+ }();
231
+ export var parseKeypair = function(pathToKeypairFile) {
232
+ try {
233
+ var keypairFile = fs.readFileSync(pathToKeypairFile, "utf-8");
234
+ return Keypair.fromSecretKey(Buffer.from(JSON.parse(keypairFile)));
235
+ } catch (e) {
236
+ showMessage("KeyPair Error", "Something went wrong when attempting to retrieve the keypair at " + pathToKeypairFile, "error");
237
+ }
238
+ };
239
+ export var isDevnet = function(rpcUrl) {
240
+ return rpcUrl.indexOf("devnet") != -1;
241
+ };
242
+ export var isTestnet = function(rpcUrl) {
243
+ return rpcUrl.indexOf("testnet") != -1;
244
+ };
245
+ export var checkSubmissionNetwork = function(rpcUrl) {
246
+ if (isDevnet(rpcUrl) || isTestnet(rpcUrl)) {
247
+ throw new Error("It looks like you are attempting to submit a request with a devnet or testnet RPC endpoint. Please ensure that your NFTs are minted on mainnet beta, and re-run with a mainnet beta RPC endpoint.");
248
+ }
249
+ };
250
+ export var generateNetworkSuffix = function(rpcUrl) {
251
+ var suffix = "";
252
+ if (isDevnet(rpcUrl)) {
253
+ suffix = "?cluster=devnet";
254
+ } else if (isTestnet(rpcUrl)) {
255
+ suffix = "?cluster=testnet";
256
+ } else {
257
+ suffix = "?cluster=mainnet";
258
+ }
259
+ return suffix;
260
+ };
261
+ export var showMessage = function() {
262
+ var titleMessage = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", contentMessage = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "", type = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "standard";
263
+ var color = "cyan";
264
+ if (type == "error") {
265
+ color = "redBright";
266
+ } else if (type == "warning") {
267
+ color = "yellow";
268
+ }
269
+ var msg = boxen(contentMessage, {
270
+ title: titleMessage,
271
+ padding: 1,
272
+ margin: 1,
273
+ borderStyle: "single",
274
+ borderColor: color,
275
+ textAlignment: "left",
276
+ titleAlignment: "center"
277
+ });
278
+ console.log(msg);
279
+ return msg;
280
+ };
281
+ export var getMetaplexInstance = function(connection, keypair) {
282
+ var storageParams = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "";
283
+ var metaplex = Metaplex.make(connection).use(keypairIdentity(keypair));
284
+ var isDevnet = connection.rpcEndpoint.includes("devnet");
285
+ //TODO: Use DI for this
286
+ var s3Mgr = new S3StorageManager(new EnvVariables());
287
+ s3Mgr.parseCmdArg(storageParams);
288
+ if (s3Mgr.hasS3Config) {
289
+ var awsClient = new S3Client({
290
+ region: s3Mgr.s3Config.regionName,
291
+ credentials: {
292
+ accessKeyId: s3Mgr.s3Config.accessKey,
293
+ secretAccessKey: s3Mgr.s3Config.secretKey
294
+ }
295
+ });
296
+ var bucketPlugin = awsStorage(awsClient, s3Mgr.s3Config.bucketName);
297
+ metaplex.use(bucketPlugin);
298
+ } else {
299
+ var bundlrStorageDriver = isDevnet ? new BundlrStorageDriver(metaplex, {
300
+ address: "https://devnet.bundlr.network",
301
+ providerUrl: Constants.DEFAULT_RPC_DEVNET
302
+ }) : new BundlrStorageDriver(metaplex);
303
+ metaplex.storage().setDriver(bundlrStorageDriver);
304
+ }
305
+ metaplex.storage().setDriver(new CachedStorageDriver(metaplex.storage().driver(), {
306
+ assetManifestPath: isDevnet ? "./.asset-manifest-devnet.json" : "./.asset-manifest.json"
307
+ }));
308
+ return metaplex;
309
+ };
@@ -0,0 +1,140 @@
1
+ import { beforeEach, expect } from "@jest/globals";
2
+ import { createAppCliCmd, createCliCmd, createPublisherCliCmd, createReleaseCliCmd, initCliCmd, mainCli } from "../CliSetup";
3
+ import { Constants } from "../CliUtils";
4
+ describe("Cli Setup & Execution", function() {
5
+ var outputHelpReference = "(outputHelp)";
6
+ var errorOutput = "";
7
+ var otherOutput = "";
8
+ beforeEach(function() {
9
+ errorOutput = "";
10
+ otherOutput = "";
11
+ mainCli.exitOverride();
12
+ mainCli.configureOutput({
13
+ getOutHelpWidth: function getOutHelpWidth() {
14
+ return 250;
15
+ },
16
+ getErrHelpWidth: function getErrHelpWidth() {
17
+ return 250;
18
+ },
19
+ writeOut: function writeOut(str) {
20
+ otherOutput = str;
21
+ },
22
+ writeErr: function writeErr(str) {
23
+ errorOutput = str;
24
+ }
25
+ });
26
+ });
27
+ test("Cli version argument reports correct version", function() {
28
+ expect(function() {
29
+ mainCli.parse([
30
+ "npx",
31
+ "dapp-store",
32
+ "-V"
33
+ ]);
34
+ }).toThrow(Constants.CLI_VERSION);
35
+ });
36
+ test("Calling cli with no parameters displays general help", function() {
37
+ expect(function() {
38
+ mainCli.parse([
39
+ "npx",
40
+ "dapp-store"
41
+ ]);
42
+ }).toThrow(outputHelpReference);
43
+ expect(generalHelp).toEqual(errorOutput);
44
+ });
45
+ test("Calling init command with help parameter shows contextual help info", function() {
46
+ initCliCmd.exitOverride();
47
+ expect(function() {
48
+ initCliCmd.parse([
49
+ "dapp-store",
50
+ "init",
51
+ "-h"
52
+ ]);
53
+ }).toThrow(outputHelpReference);
54
+ expect(otherOutput).toEqual(initHelp);
55
+ });
56
+ test("Calling create command with no options lists all options", function() {
57
+ createCliCmd.exitOverride();
58
+ expect(function() {
59
+ createCliCmd.parse([
60
+ "dapp-store",
61
+ "create"
62
+ ]);
63
+ }).toThrow(outputHelpReference);
64
+ expect(errorOutput).toEqual(createHelp);
65
+ });
66
+ test("Calling create publisher command with no arguments warns about required argument", function() {
67
+ createPublisherCliCmd.exitOverride();
68
+ expect(function() {
69
+ createPublisherCliCmd.parse([
70
+ "dapp-store",
71
+ "create",
72
+ "publisher"
73
+ ]);
74
+ }).toThrow(keyPairArgHelp);
75
+ });
76
+ test("Calling create publisher command with help flag shows contextual help", function() {
77
+ createPublisherCliCmd.exitOverride();
78
+ expect(function() {
79
+ createPublisherCliCmd.parse([
80
+ "dapp-store",
81
+ "create",
82
+ "publisher",
83
+ "-h"
84
+ ]);
85
+ }).toThrow(outputHelpReference);
86
+ expect(otherOutput).toEqual(createPublisherHelp);
87
+ });
88
+ test("Calling create app command with no arguments warns about required argument", function() {
89
+ createAppCliCmd.exitOverride();
90
+ expect(function() {
91
+ createAppCliCmd.parse([
92
+ "dapp-store",
93
+ "create",
94
+ "app"
95
+ ]);
96
+ }).toThrow(keyPairArgHelp);
97
+ });
98
+ test("Calling create app command with help flag shows contextual help", function() {
99
+ createAppCliCmd.exitOverride();
100
+ expect(function() {
101
+ createAppCliCmd.parse([
102
+ "dapp-store",
103
+ "create",
104
+ "app",
105
+ "-h"
106
+ ]);
107
+ }).toThrow(outputHelpReference);
108
+ expect(otherOutput).toEqual(createAppHelp);
109
+ });
110
+ test("Calling create release command with no arguments warns about required argument", function() {
111
+ createReleaseCliCmd.exitOverride();
112
+ expect(function() {
113
+ createReleaseCliCmd.parse([
114
+ "dapp-store",
115
+ "create",
116
+ "release"
117
+ ]);
118
+ }).toThrow(keyPairArgHelp);
119
+ });
120
+ test("Calling create release command with help flag shows contextual help", function() {
121
+ createReleaseCliCmd.exitOverride();
122
+ expect(function() {
123
+ createReleaseCliCmd.parse([
124
+ "dapp-store",
125
+ "create",
126
+ "release",
127
+ "-h"
128
+ ]);
129
+ }).toThrow(outputHelpReference);
130
+ expect(otherOutput).toEqual(createReleaseHelp);
131
+ });
132
+ //--------------------------------------------------
133
+ var generalHelp = "Usage: dapp-store [options] [command]\n\nCLI to assist with publishing to the Saga Dapp Store\n\nOptions:\n -V, --version output the version number\n -h, --help display help for command\n\nCommands:\n init First-time initialization of tooling configuration\n create Create a `publisher`, `app`, or `release`\n validate [options] Validates details prior to publishing\n publish Submit a publishing request (`submit`, `update`, `remove`, or `support`) to the Solana Mobile dApp publisher portal\n help [command] display help for command\n";
134
+ var initHelp = "Usage: dapp-store init [options]\n\nFirst-time initialization of tooling configuration\n\nOptions:\n -h, --help display help for command\n";
135
+ var keyPairArgHelp = "error: required option '-k, --keypair <path-to-keypair-file>' not specified";
136
+ var createHelp = "Usage: dapp-store create [options] [command]\n\nCreate a `publisher`, `app`, or `release`\n\nOptions:\n -h, --help display help for command\n\nCommands:\n publisher [options] Create a publisher\n app [options] Create a app\n release [options] Create a release\n help [command] display help for command\n";
137
+ var createPublisherHelp = 'Usage: dapp-store create publisher [options]\n\nCreate a publisher\n\nOptions:\n -k, --keypair <path-to-keypair-file> Path to keypair file\n -u, --url <url> RPC URL (default: "https://api.devnet.solana.com")\n -d, --dry-run Flag for dry run. Doesn\'t mint an NFT\n -s, --storage-config <storage-config> Provide alternative storage configuration details\n -h, --help display help for command\n';
138
+ var createAppHelp = 'Usage: dapp-store create app [options]\n\nCreate a app\n\nOptions:\n -k, --keypair <path-to-keypair-file> Path to keypair file\n -p, --publisher-mint-address <publisher-mint-address> The mint address of the publisher NFT\n -u, --url <url> RPC URL (default: "https://api.devnet.solana.com")\n -d, --dry-run Flag for dry run. Doesn\'t mint an NFT\n -s, --storage-config <storage-config> Provide alternative storage configuration details\n -h, --help display help for command\n';
139
+ var createReleaseHelp = 'Usage: dapp-store create release [options]\n\nCreate a release\n\nOptions:\n -k, --keypair <path-to-keypair-file> Path to keypair file\n -a, --app-mint-address <app-mint-address> The mint address of the app NFT\n -u, --url <url> RPC URL (default: "https://api.devnet.solana.com")\n -d, --dry-run Flag for dry run. Doesn\'t mint an NFT\n -b, --build-tools-path <build-tools-path> Path to Android build tools which contains AAPT2\n -s, --storage-config <storage-config> Provide alternative storage configuration details\n -h, --help display help for command\n';
140
+ });
@@ -0,0 +1,201 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _ts_generator(thisArg, body) {
31
+ var f, y, t, g, _ = {
32
+ label: 0,
33
+ sent: function() {
34
+ if (t[0] & 1) throw t[1];
35
+ return t[1];
36
+ },
37
+ trys: [],
38
+ ops: []
39
+ };
40
+ return(g = {
41
+ next: verb(0),
42
+ "throw": verb(1),
43
+ "return": verb(2)
44
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
45
+ return this;
46
+ }), g);
47
+ function verb(n) {
48
+ return function(v) {
49
+ return step([
50
+ n,
51
+ v
52
+ ]);
53
+ };
54
+ }
55
+ function step(op) {
56
+ if (f) throw new TypeError("Generator is already executing.");
57
+ while(_)try {
58
+ 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;
59
+ if (y = 0, t) op = [
60
+ op[0] & 2,
61
+ t.value
62
+ ];
63
+ switch(op[0]){
64
+ case 0:
65
+ case 1:
66
+ t = op;
67
+ break;
68
+ case 4:
69
+ _.label++;
70
+ return {
71
+ value: op[1],
72
+ done: false
73
+ };
74
+ case 5:
75
+ _.label++;
76
+ y = op[1];
77
+ op = [
78
+ 0
79
+ ];
80
+ continue;
81
+ case 7:
82
+ op = _.ops.pop();
83
+ _.trys.pop();
84
+ continue;
85
+ default:
86
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
87
+ _ = 0;
88
+ continue;
89
+ }
90
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
91
+ _.label = op[1];
92
+ break;
93
+ }
94
+ if (op[0] === 6 && _.label < t[1]) {
95
+ _.label = t[1];
96
+ t = op;
97
+ break;
98
+ }
99
+ if (t && _.label < t[2]) {
100
+ _.label = t[2];
101
+ _.ops.push(op);
102
+ break;
103
+ }
104
+ if (t[2]) _.ops.pop();
105
+ _.trys.pop();
106
+ continue;
107
+ }
108
+ op = body.call(thisArg, _);
109
+ } catch (e) {
110
+ op = [
111
+ 6,
112
+ e
113
+ ];
114
+ y = 0;
115
+ } finally{
116
+ f = t = 0;
117
+ }
118
+ if (op[0] & 5) throw op[1];
119
+ return {
120
+ value: op[0] ? op[1] : void 0,
121
+ done: true
122
+ };
123
+ }
124
+ }
125
+ import { createAppJson, createPublisherJson, createReleaseJson, validateApp, validatePublisher, validateRelease, metaplexFileReplacer } from "@solana-mobile/dapp-store-publishing-tools";
126
+ import { debug } from "../CliUtils.js";
127
+ import { loadPublishDetailsWithChecks } from "../config/PublishDetails.js";
128
+ export var validateCommand = function() {
129
+ var _ref = _async_to_generator(function(param) {
130
+ var signer, buildToolsPath, _ref, publisherDetails, appDetails, releaseDetails, publisherJson, _publisherJson_image, appJson, _appJson_image, releaseJson, objStringified;
131
+ return _ts_generator(this, function(_state) {
132
+ switch(_state.label){
133
+ case 0:
134
+ signer = param.signer, buildToolsPath = param.buildToolsPath;
135
+ return [
136
+ 4,
137
+ loadPublishDetailsWithChecks(buildToolsPath)
138
+ ];
139
+ case 1:
140
+ _ref = _state.sent(), publisherDetails = _ref.publisher, appDetails = _ref.app, releaseDetails = _ref.release;
141
+ debug({
142
+ publisherDetails: publisherDetails,
143
+ appDetails: appDetails,
144
+ releaseDetails: releaseDetails
145
+ });
146
+ publisherJson = createPublisherJson(publisherDetails);
147
+ if (typeof publisherJson.image !== "string") {
148
+ ;
149
+ publisherJson.image = (_publisherJson_image = publisherJson.image) === null || _publisherJson_image === void 0 ? void 0 : _publisherJson_image.fileName;
150
+ }
151
+ debug("publisherJson=", JSON.stringify({
152
+ publisherJson: publisherJson
153
+ }, metaplexFileReplacer, 2));
154
+ try {
155
+ validatePublisher(publisherJson);
156
+ console.info("Publisher JSON valid!");
157
+ } catch (e) {
158
+ console.error(e);
159
+ }
160
+ appJson = createAppJson(appDetails, signer.publicKey);
161
+ if (typeof appJson.image !== "string") {
162
+ ;
163
+ appJson.image = (_appJson_image = appJson.image) === null || _appJson_image === void 0 ? void 0 : _appJson_image.fileName;
164
+ }
165
+ debug("appJson=", JSON.stringify({
166
+ appJson: appJson
167
+ }, metaplexFileReplacer, 2));
168
+ try {
169
+ validateApp(appJson);
170
+ console.info("App JSON valid!");
171
+ } catch (e) {
172
+ console.error(e);
173
+ }
174
+ return [
175
+ 4,
176
+ createReleaseJson({
177
+ releaseDetails: releaseDetails,
178
+ appDetails: appDetails,
179
+ publisherDetails: publisherDetails
180
+ }, signer.publicKey)
181
+ ];
182
+ case 2:
183
+ releaseJson = _state.sent();
184
+ objStringified = JSON.stringify(releaseJson, metaplexFileReplacer, 2);
185
+ debug("releaseJson=", objStringified);
186
+ try {
187
+ validateRelease(JSON.parse(objStringified));
188
+ console.info("Release JSON valid!");
189
+ } catch (e) {
190
+ console.error(e);
191
+ }
192
+ return [
193
+ 2
194
+ ];
195
+ }
196
+ });
197
+ });
198
+ return function validateCommand(_) {
199
+ return _ref.apply(this, arguments);
200
+ };
201
+ }();