@solana-mobile/dapp-store-cli 0.4.2 → 0.5.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 (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 +591 -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 +511 -0
  32. package/src/CliUtils.ts +64 -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 +16 -2
  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 -108
  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 -177
  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 -21
  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 @@
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"}}}}}
package/lib/index.js ADDED
@@ -0,0 +1,148 @@
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 { mainCli } from "./CliSetup.js";
126
+ function main() {
127
+ return _main.apply(this, arguments);
128
+ }
129
+ function _main() {
130
+ _main = _async_to_generator(function() {
131
+ return _ts_generator(this, function(_state) {
132
+ switch(_state.label){
133
+ case 0:
134
+ return [
135
+ 4,
136
+ mainCli.parseAsync(process.argv)
137
+ ];
138
+ case 1:
139
+ _state.sent();
140
+ return [
141
+ 2
142
+ ];
143
+ }
144
+ });
145
+ });
146
+ return _main.apply(this, arguments);
147
+ }
148
+ main();
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@solana-mobile/dapp-store-cli",
3
+ "version": "0.5.0",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./lib/esm/index.js",
8
+ "module": "./lib/esm/index.js",
9
+ "types": "./lib/types/index.d.ts",
10
+ "engines": {
11
+ "node": ">=18"
12
+ },
13
+ "exports": {
14
+ "import": "./lib/esm/index.js",
15
+ "require": "./lib/esm/index.js",
16
+ "types": "./lib/types/index.d.ts"
17
+ },
18
+ "bin": {
19
+ "dapp-store": "./bin/dapp-store.js"
20
+ },
21
+ "files": [
22
+ "lib",
23
+ "src",
24
+ "LICENSE"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "clean": "shx mkdir -p lib && shx rm -rf lib",
31
+ "prebuild": "pnpm run clean && node src/prebuild_schema/schemagen.js",
32
+ "build": "swc src -d lib --copy-files",
33
+ "watch": "swc src --out-dir lib -w",
34
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
35
+ },
36
+ "devDependencies": {
37
+ "@metaplex-foundation/js": "0.18.3",
38
+ "@jest/globals": "^29.5.0",
39
+ "@jest/types": "^29.5.0",
40
+ "@swc/jest": "^0.2.26",
41
+ "@types/commander": "^2.12.2",
42
+ "@types/debug": "^4.1.7",
43
+ "@types/jest": "^29.5.1",
44
+ "@types/js-yaml": "^4.0.5",
45
+ "@types/terminal-link": "^1.2.0",
46
+ "@types/update-notifier": "^6.0.1",
47
+ "jest": "^29.5.0",
48
+ "jest-transform-stub": "^2.0.0",
49
+ "shx": "^0.3.4",
50
+ "ts-jest": "^29.1.0",
51
+ "ts-node": "^10.9.1"
52
+ },
53
+ "dependencies": {
54
+ "@aws-sdk/client-s3": "^3.321.1",
55
+ "@metaplex-foundation/js-plugin-aws": "^0.18.3",
56
+ "@solana-mobile/dapp-store-publishing-tools": "workspace:0.5.0",
57
+ "@solana/web3.js": "1.68.0",
58
+ "@types/semver": "^7.3.13",
59
+ "ajv": "^8.11.0",
60
+ "boxen": "^7.0.1",
61
+ "chokidar": "^3.5.3",
62
+ "commander": "^9.4.1",
63
+ "debug": "^4.3.4",
64
+ "dotenv": "^16.0.3",
65
+ "esm": "^3.2.25",
66
+ "generate-schema": "^2.6.0",
67
+ "image-size": "^1.0.2",
68
+ "js-yaml": "^4.1.0",
69
+ "semver": "^7.3.8",
70
+ "terminal-link": "^3.0.0",
71
+ "tweetnacl": "1.0.3",
72
+ "update-notifier": "^6.0.2"
73
+ }
74
+ }
@@ -0,0 +1,46 @@
1
+ publisher:
2
+ name: <<YOUR_PUBLISHER_NAME>>
3
+ address: ""
4
+ website: <<URL_OF_PUBLISHER_WEBSITE>>
5
+ email: <<EMAIL_ADDRESS_TO_CONTACT_PUBLISHER>>
6
+ media:
7
+ - purpose: icon
8
+ uri: <<RELATIVE_PATH_TO_PUBLISHER_ICON>>
9
+ app:
10
+ name: <<APP_NAME>>
11
+ address: ""
12
+ android_package: <<ANDROID_PACKAGE_NAME>>
13
+ urls:
14
+ license_url: <<URL_OF_APP_LICENSE_OR_TERMS_OF_SERVICE>>
15
+ copyright_url: <<URL_OF_COPYRIGHT_DETAILS_FOR_APP>>
16
+ privacy_policy_url: <<URL_OF_APP_PRIVACY_POLICY>>
17
+ website: <<URL_OF_APP_WEBSITE>>
18
+ media:
19
+ - purpose: icon
20
+ uri: <<RELATIVE_PATH_TO_APP_ICON>>
21
+ release:
22
+ address: ""
23
+ media:
24
+ - purpose: icon
25
+ uri: <<RELATIVE_PATH_TO_RELEASE_ICON>>
26
+ - purpose: screenshot
27
+ uri: <<RELATIVE_PATH_TO_SCREENSHOT>>
28
+ files:
29
+ - purpose: install
30
+ uri: <<RELATIVE_PATH_TO_APK>>
31
+ catalog:
32
+ en-US:
33
+ name: >-
34
+ <<APP_NAME>>
35
+ short_description: >-
36
+ <<SHORT_APP_DESCRIPTION>>
37
+ long_description: >-
38
+ <<LONG_APP_DESCRIPTION>>
39
+ new_in_version: >-
40
+ <<WHATS_NEW_IN_THIS_VERSION>>
41
+ saga_features: >-
42
+ <<ANY_FEATURES_ONLY_AVAILBLE_WHEN_RUNNING_ON_SAGA>>
43
+ solana_mobile_dapp_publisher_portal:
44
+ google_store_package: <<ANDROID_PACKAGE_NAME_OF_GOOGLE_PLAY_STORE_VERSION_IF_DIFFERENT>>
45
+ testing_instructions: >-
46
+ <<TESTING_INSTRUCTIONS>>
@@ -0,0 +1,20 @@
1
+ import fs from "fs";
2
+ import yaml from "js-yaml";
3
+ import generateSchema from "generate-schema";
4
+ try {
5
+ var yamlSrc = fs.readFileSync("./src/prebuild_schema/publishing_source.yaml", "utf8");
6
+ var convertedYaml = yaml.load(yamlSrc);
7
+ fs.writeFileSync("./src/generated/config_obj.json", Buffer.from(JSON.stringify(convertedYaml)), "utf-8");
8
+ var schema = generateSchema.json("result", convertedYaml);
9
+ // CLI 0.3.0: Adding requirement for `short_description` so validation will catch
10
+ schema["properties"]["release"]["properties"]["catalog"]["properties"]["en-US"].required = [
11
+ "short_description"
12
+ ];
13
+ // Generator adds some keys/values we don't need & mess up validation
14
+ delete schema.$schema;
15
+ delete schema.title;
16
+ var toWrite = Buffer.from(JSON.stringify(schema));
17
+ fs.writeFileSync("./src/generated/config_schema.json", toWrite, "utf-8");
18
+ } catch (e) {
19
+ console.log(":: Schema generation step failed ::");
20
+ }
@@ -0,0 +1,307 @@
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 _defineProperties(target, props) {
36
+ for(var i = 0; i < props.length; i++){
37
+ var descriptor = props[i];
38
+ descriptor.enumerable = descriptor.enumerable || false;
39
+ descriptor.configurable = true;
40
+ if ("value" in descriptor) descriptor.writable = true;
41
+ Object.defineProperty(target, descriptor.key, descriptor);
42
+ }
43
+ }
44
+ function _create_class(Constructor, protoProps, staticProps) {
45
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
46
+ if (staticProps) _defineProperties(Constructor, staticProps);
47
+ return Constructor;
48
+ }
49
+ function _define_property(obj, key, value) {
50
+ if (key in obj) {
51
+ Object.defineProperty(obj, key, {
52
+ value: value,
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true
56
+ });
57
+ } else {
58
+ obj[key] = value;
59
+ }
60
+ return obj;
61
+ }
62
+ function _object_spread(target) {
63
+ for(var i = 1; i < arguments.length; i++){
64
+ var source = arguments[i] != null ? arguments[i] : {};
65
+ var ownKeys = Object.keys(source);
66
+ if (typeof Object.getOwnPropertySymbols === "function") {
67
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
68
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
69
+ }));
70
+ }
71
+ ownKeys.forEach(function(key) {
72
+ _define_property(target, key, source[key]);
73
+ });
74
+ }
75
+ return target;
76
+ }
77
+ function _ts_generator(thisArg, body) {
78
+ var f, y, t, g, _ = {
79
+ label: 0,
80
+ sent: function() {
81
+ if (t[0] & 1) throw t[1];
82
+ return t[1];
83
+ },
84
+ trys: [],
85
+ ops: []
86
+ };
87
+ return g = {
88
+ next: verb(0),
89
+ "throw": verb(1),
90
+ "return": verb(2)
91
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
92
+ return this;
93
+ }), g;
94
+ function verb(n) {
95
+ return function(v) {
96
+ return step([
97
+ n,
98
+ v
99
+ ]);
100
+ };
101
+ }
102
+ function step(op) {
103
+ if (f) throw new TypeError("Generator is already executing.");
104
+ while(_)try {
105
+ 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;
106
+ if (y = 0, t) op = [
107
+ op[0] & 2,
108
+ t.value
109
+ ];
110
+ switch(op[0]){
111
+ case 0:
112
+ case 1:
113
+ t = op;
114
+ break;
115
+ case 4:
116
+ _.label++;
117
+ return {
118
+ value: op[1],
119
+ done: false
120
+ };
121
+ case 5:
122
+ _.label++;
123
+ y = op[1];
124
+ op = [
125
+ 0
126
+ ];
127
+ continue;
128
+ case 7:
129
+ op = _.ops.pop();
130
+ _.trys.pop();
131
+ continue;
132
+ default:
133
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
134
+ _ = 0;
135
+ continue;
136
+ }
137
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
138
+ _.label = op[1];
139
+ break;
140
+ }
141
+ if (op[0] === 6 && _.label < t[1]) {
142
+ _.label = t[1];
143
+ t = op;
144
+ break;
145
+ }
146
+ if (t && _.label < t[2]) {
147
+ _.label = t[2];
148
+ _.ops.push(op);
149
+ break;
150
+ }
151
+ if (t[2]) _.ops.pop();
152
+ _.trys.pop();
153
+ continue;
154
+ }
155
+ op = body.call(thisArg, _);
156
+ } catch (e) {
157
+ op = [
158
+ 6,
159
+ e
160
+ ];
161
+ y = 0;
162
+ } finally{
163
+ f = t = 0;
164
+ }
165
+ if (op[0] & 5) throw op[1];
166
+ return {
167
+ value: op[0] ? op[1] : void 0,
168
+ done: true
169
+ };
170
+ }
171
+ }
172
+ import fs from "fs";
173
+ import { createHash } from "crypto";
174
+ // TODO(jon): We need to manage the removal / replacement of assets in the manifest
175
+ export var CachedStorageDriver = /*#__PURE__*/ function() {
176
+ "use strict";
177
+ function CachedStorageDriver(storageDriver, param) {
178
+ var assetManifestPath = param.assetManifestPath;
179
+ _class_call_check(this, CachedStorageDriver);
180
+ _define_property(this, "assetManifest", void 0);
181
+ _define_property(this, "assetManifestPath", void 0);
182
+ _define_property(this, "storageDriver", void 0);
183
+ this.assetManifestPath = assetManifestPath;
184
+ console.info({
185
+ loading: true
186
+ });
187
+ var _this_loadAssetManifest;
188
+ this.assetManifest = (_this_loadAssetManifest = this.loadAssetManifest(assetManifestPath)) !== null && _this_loadAssetManifest !== void 0 ? _this_loadAssetManifest : {
189
+ schema_version: CachedStorageDriver.SCHEMA_VERSION,
190
+ assets: {}
191
+ };
192
+ this.storageDriver = storageDriver;
193
+ }
194
+ _create_class(CachedStorageDriver, [
195
+ {
196
+ key: "getUploadPrice",
197
+ value: function getUploadPrice(bytes) {
198
+ var _this = this;
199
+ return _async_to_generator(function() {
200
+ return _ts_generator(this, function(_state) {
201
+ return [
202
+ 2,
203
+ _this.storageDriver.getUploadPrice(bytes)
204
+ ];
205
+ });
206
+ })();
207
+ }
208
+ },
209
+ {
210
+ key: "loadAssetManifest",
211
+ value: function loadAssetManifest(filename) {
212
+ try {
213
+ return JSON.parse(fs.readFileSync(filename, "utf-8"));
214
+ } catch (error) {
215
+ console.warn("Failed opening ".concat(filename, "; initializing with a blank asset manifest"));
216
+ return;
217
+ }
218
+ }
219
+ },
220
+ {
221
+ key: "uploadedAsset",
222
+ value: function uploadedAsset(filename, param) {
223
+ var sha256 = param.sha256;
224
+ var _this_assetManifest_assets_filename;
225
+ if (((_this_assetManifest_assets_filename = this.assetManifest.assets[filename]) === null || _this_assetManifest_assets_filename === void 0 ? void 0 : _this_assetManifest_assets_filename.sha256) === sha256) {
226
+ return this.assetManifest.assets[filename];
227
+ }
228
+ return null;
229
+ }
230
+ },
231
+ {
232
+ key: "upload",
233
+ value: function upload(file) {
234
+ var _this = this;
235
+ return _async_to_generator(function() {
236
+ var hash, uploadedAsset, uri;
237
+ return _ts_generator(this, function(_state) {
238
+ switch(_state.label){
239
+ case 0:
240
+ if (!(file.fileName === "inline.json")) return [
241
+ 3,
242
+ 2
243
+ ];
244
+ return [
245
+ 4,
246
+ _this.storageDriver.upload(file)
247
+ ];
248
+ case 1:
249
+ return [
250
+ 2,
251
+ _state.sent()
252
+ ];
253
+ case 2:
254
+ hash = createHash("sha256").update(file.buffer).digest("base64");
255
+ console.info(JSON.stringify({
256
+ file: {
257
+ name: file.fileName,
258
+ disn: file.displayName,
259
+ un: file.uniqueName
260
+ }
261
+ }));
262
+ uploadedAsset = _this.uploadedAsset(file.fileName, {
263
+ sha256: hash
264
+ });
265
+ if (uploadedAsset) {
266
+ console.log("Asset ".concat(file.fileName, " already uploaded at ").concat(uploadedAsset.uri));
267
+ return [
268
+ 2,
269
+ uploadedAsset.uri
270
+ ];
271
+ }
272
+ console.log("Uploading ".concat(file.fileName));
273
+ return [
274
+ 4,
275
+ _this.storageDriver.upload(file)
276
+ ];
277
+ case 3:
278
+ uri = _state.sent();
279
+ _this.assetManifest.assets[file.fileName] = {
280
+ path: file.fileName,
281
+ sha256: hash,
282
+ uri: uri
283
+ };
284
+ return [
285
+ 4,
286
+ fs.promises.writeFile("".concat(process.cwd(), "/").concat(_this.assetManifestPath), // Something is really weird, I can't seem to stringify `this.assetManifest` straight-up. Here be dragons
287
+ JSON.stringify({
288
+ assets: _object_spread({}, _this.assetManifest.assets)
289
+ }, null, 2), "utf-8")
290
+ ];
291
+ case 4:
292
+ _state.sent();
293
+ return [
294
+ 2,
295
+ uri
296
+ ];
297
+ }
298
+ });
299
+ })();
300
+ }
301
+ }
302
+ ]);
303
+ return CachedStorageDriver;
304
+ }();
305
+ // NOTE: this schema version is independent of the publishing JSON schema. It should be updated
306
+ // when the AssetManifestSchema or Asset types are updated.
307
+ _define_property(CachedStorageDriver, "SCHEMA_VERSION", "0.1");
@@ -1,2 +1 @@
1
1
  export * from "./CachedStorageDriver.js";
2
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@solana-mobile/dapp-store-cli",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
- "main": "./lib/cjs/index.js",
7
+ "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
9
9
  "types": "./lib/types/index.d.ts",
10
10
  "engines": {
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "exports": {
14
14
  "import": "./lib/esm/index.js",
15
- "require": "./lib/cjs/index.js",
15
+ "require": "./lib/esm/index.js",
16
16
  "types": "./lib/types/index.d.ts"
17
17
  },
18
18
  "bin": {
@@ -27,20 +27,31 @@
27
27
  "access": "public"
28
28
  },
29
29
  "devDependencies": {
30
- "@metaplex-foundation/js": "0.17.11",
30
+ "@metaplex-foundation/js": "0.18.3",
31
+ "@jest/globals": "^29.5.0",
32
+ "@jest/types": "^29.5.0",
33
+ "@swc/jest": "^0.2.26",
31
34
  "@types/commander": "^2.12.2",
32
35
  "@types/debug": "^4.1.7",
36
+ "@types/jest": "^29.5.1",
33
37
  "@types/js-yaml": "^4.0.5",
34
38
  "@types/terminal-link": "^1.2.0",
35
39
  "@types/update-notifier": "^6.0.1",
36
- "shx": "^0.3.4"
40
+ "jest": "^29.5.0",
41
+ "jest-transform-stub": "^2.0.0",
42
+ "shx": "^0.3.4",
43
+ "ts-jest": "^29.1.0",
44
+ "ts-node": "^10.9.1"
37
45
  },
38
46
  "dependencies": {
39
- "@solana-mobile/dapp-store-publishing-tools": "0.4.2",
47
+ "@aws-sdk/client-s3": "^3.321.1",
48
+ "@metaplex-foundation/js-plugin-aws": "^0.18.3",
49
+ "@solana-mobile/dapp-store-publishing-tools": "0.5.0",
40
50
  "@solana/web3.js": "1.68.0",
41
51
  "@types/semver": "^7.3.13",
42
52
  "ajv": "^8.11.0",
43
53
  "boxen": "^7.0.1",
54
+ "chokidar": "^3.5.3",
44
55
  "commander": "^9.4.1",
45
56
  "debug": "^4.3.4",
46
57
  "dotenv": "^16.0.3",
@@ -55,6 +66,9 @@
55
66
  },
56
67
  "scripts": {
57
68
  "clean": "shx mkdir -p lib && shx rm -rf lib",
58
- "prebuild": "pnpm run clean && node src/prebuild_schema/schemagen.js"
69
+ "prebuild": "pnpm run clean && node src/prebuild_schema/schemagen.js",
70
+ "build": "swc src -d lib --copy-files",
71
+ "watch": "swc src --out-dir lib -w",
72
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
59
73
  }
60
74
  }