@solana-mobile/dapp-store-cli 0.15.0 → 0.16.1
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.
- package/bin/dapp-store.js +3 -1
- package/lib/CliSetup.js +304 -505
- package/lib/CliUtils.js +6 -376
- package/lib/__tests__/CliSetupTest.js +484 -74
- package/lib/cli/__tests__/parseErrors.test.js +25 -0
- package/lib/cli/__tests__/signer.test.js +436 -0
- package/lib/cli/constants.js +23 -0
- package/lib/cli/messages.js +21 -0
- package/lib/cli/parseErrors.js +41 -0
- package/lib/{commands/publish/PublishCliSupport.js → cli/selfUpdate.js} +72 -38
- package/lib/{commands/publish/PublishCliRemove.js → cli/signer.js} +35 -56
- package/lib/index.js +96 -5
- package/lib/package.json +5 -24
- package/lib/portal/__tests__/releaseMetadata.test.js +647 -0
- package/lib/portal/__tests__/translators.test.js +76 -0
- package/lib/portal/__tests__/workflowClient.test.js +457 -0
- package/lib/portal/attestationClient.js +143 -0
- package/lib/portal/files.js +64 -0
- package/lib/portal/http.js +364 -0
- package/lib/portal/records.js +64 -0
- package/lib/portal/releaseMetadata.js +748 -0
- package/lib/portal/translators.js +460 -0
- package/lib/portal/types.js +1 -0
- package/lib/portal/workflowClient.js +704 -0
- package/lib/publication/PublicationProgressReporter.js +1051 -0
- package/lib/publication/__tests__/PublicationProgressReporter.test.js +174 -0
- package/lib/{commands/ValidateCommand.js → publication/__tests__/fundingPreflight.test.js} +90 -66
- package/lib/publication/__tests__/publicationSummary.test.js +26 -0
- package/lib/publication/cliValidation.js +482 -0
- package/lib/publication/fundingPreflight.js +246 -0
- package/lib/publication/publicationSummary.js +99 -0
- package/lib/{commands/utils.js → publication/runPublicationWorkflow.js} +16 -46
- package/package.json +5 -24
- package/src/CliSetup.ts +370 -505
- package/src/CliUtils.ts +9 -233
- package/src/__tests__/CliSetupTest.ts +272 -120
- package/src/cli/__tests__/parseErrors.test.ts +34 -0
- package/src/cli/__tests__/signer.test.ts +359 -0
- package/src/cli/constants.ts +3 -0
- package/src/cli/messages.ts +27 -0
- package/src/cli/parseErrors.ts +62 -0
- package/src/cli/selfUpdate.ts +59 -0
- package/src/cli/signer.ts +38 -0
- package/src/index.ts +31 -4
- package/src/portal/__tests__/releaseMetadata.test.ts +508 -0
- package/src/portal/__tests__/translators.test.ts +82 -0
- package/src/portal/__tests__/workflowClient.test.ts +278 -0
- package/src/portal/attestationClient.ts +19 -0
- package/src/portal/files.ts +73 -0
- package/src/portal/http.ts +170 -0
- package/src/portal/records.ts +38 -0
- package/src/portal/releaseMetadata.ts +489 -0
- package/src/portal/translators.ts +750 -0
- package/src/portal/types.ts +27 -0
- package/src/portal/workflowClient.ts +575 -0
- package/src/publication/PublicationProgressReporter.ts +1026 -0
- package/src/publication/__tests__/PublicationProgressReporter.test.ts +210 -0
- package/src/publication/__tests__/fundingPreflight.test.ts +78 -0
- package/src/publication/__tests__/publicationSummary.test.ts +30 -0
- package/src/publication/cliValidation.ts +264 -0
- package/src/publication/fundingPreflight.ts +123 -0
- package/src/publication/publicationSummary.ts +26 -0
- package/src/publication/runPublicationWorkflow.ts +46 -0
- package/lib/commands/create/CreateCliApp.js +0 -223
- package/lib/commands/create/CreateCliRelease.js +0 -290
- package/lib/commands/create/index.js +0 -40
- package/lib/commands/index.js +0 -3
- package/lib/commands/publish/PublishCliSubmit.js +0 -208
- package/lib/commands/publish/PublishCliUpdate.js +0 -211
- package/lib/commands/publish/index.js +0 -22
- package/lib/commands/scaffolding/ScaffoldInit.js +0 -15
- package/lib/commands/scaffolding/index.js +0 -1
- package/lib/config/EnvVariables.js +0 -59
- package/lib/config/PublishDetails.js +0 -915
- package/lib/config/S3StorageManager.js +0 -93
- package/lib/config/index.js +0 -2
- package/lib/generated/config_obj.json +0 -1
- package/lib/generated/config_schema.json +0 -1
- package/lib/prebuild_schema/publishing_source.yaml +0 -64
- package/lib/prebuild_schema/schemagen.js +0 -25
- package/lib/upload/CachedStorageDriver.js +0 -293
- package/lib/upload/TurboStorageDriver.js +0 -718
- package/lib/upload/index.js +0 -2
- package/src/commands/ValidateCommand.ts +0 -82
- package/src/commands/create/CreateCliApp.ts +0 -93
- package/src/commands/create/CreateCliRelease.ts +0 -149
- package/src/commands/create/index.ts +0 -47
- package/src/commands/index.ts +0 -3
- package/src/commands/publish/PublishCliRemove.ts +0 -66
- package/src/commands/publish/PublishCliSubmit.ts +0 -93
- package/src/commands/publish/PublishCliSupport.ts +0 -66
- package/src/commands/publish/PublishCliUpdate.ts +0 -101
- package/src/commands/publish/index.ts +0 -29
- package/src/commands/scaffolding/ScaffoldInit.ts +0 -20
- package/src/commands/scaffolding/index.ts +0 -1
- package/src/commands/utils.ts +0 -33
- package/src/config/EnvVariables.ts +0 -39
- package/src/config/PublishDetails.ts +0 -456
- package/src/config/S3StorageManager.ts +0 -47
- package/src/config/index.ts +0 -2
- package/src/prebuild_schema/publishing_source.yaml +0 -64
- package/src/prebuild_schema/schemagen.js +0 -31
- package/src/upload/CachedStorageDriver.ts +0 -99
- package/src/upload/TurboStorageDriver.ts +0 -277
- package/src/upload/index.ts +0 -2
|
@@ -1,93 +0,0 @@
|
|
|
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
|
-
}();
|
package/lib/config/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"publisher":{"name":"<<[REQUIRED] YOUR_PUBLISHER_NAME>>","website":"<<[REQUIRED] URL_OF_PUBLISHER_WEBSITE>>","email":"<<[REQUIRED] EMAIL_ADDRESS_TO_CONTACT_PUBLISHER>>","support_email":"<<[Optional] SUPPORT_EMAIL_ADDRESS_FOR_END_USERS>>"},"app":{"name":"<<[REQUIRED] APP_NAME>>","address":"","android_package":"<<[REQUIRED] ANDROID_PACKAGE_NAME>>","urls":{"license_url":"<<[REQUIRED] URL For App's T&C. Don't put placeholder urls.>>","copyright_url":"<<[REQUIRED] URL For App's Copyright. Don't put placeholder urls.>>","privacy_policy_url":"<<[REQUIRED] URL For App's Privacy Policy. Don't put placeholder urls.>>","website":"<<[REQUIRED] URL_OF_APP_WEBSITE>>"},"media":[{"purpose":"icon","uri":"<<[REQUIRED] RELATIVE_PATH_TO_APP_ICON>>"}]},"release":{"address":"","media":[{"purpose":"icon","uri":"<<[REQUIRED] RELATIVE_PATH_TO_RELEASE_ICON>>"},{"purpose":"banner","uri":"<<[REQUIRED] RELATIVE_PATH_TO_BANNER>>"},{"purpose":"featureGraphic","uri":"<<[Optional] RELATIVE_PATH_TO_FEATURE_GRAPHIC>>"},{"purpose":"screenshot","uri":"<<[REQUIRED] RELATIVE_PATH_TO_SCREENSHOT1>>"},{"purpose":"screenshot","uri":"<<[REQUIRED] RELATIVE_PATH_TO_SCREENSHOT2>>"},{"purpose":"screenshot","uri":"<<[REQUIRED] RELATIVE_PATH_TO_SCREENSHOT3>>"},{"purpose":"screenshot","uri":"<<[REQUIRED] RELATIVE_PATH_TO_SCREENSHOT4>>"},{"purpose":"video","uri":"<<[Optional] RELATIVE_PATH_TO_VIDEO1>>"}],"files":[{"purpose":"install","uri":"<<[REQUIRED] RELATIVE_PATH_TO_APK>>"}],"catalog":{"en-US":{"name":"<<[REQUIRED] APP_NAME>>","short_description":"<<[REQUIRED] SHORT_APP_DESCRIPTION>>","long_description":"<<[REQUIRED] LONG_APP_DESCRIPTION>>","new_in_version":"<<[REQUIRED] WHATS_NEW_IN_THIS_VERSION>>","saga_features":"<<[Optional.] ANY_FEATURES_ONLY_AVAILBLE_WHEN_RUNNING_ON_SAGA>>"}},"android_details":{"locales":["en-US","<Add more supported locales>"]}},"solana_mobile_dapp_publisher_portal":{"google_store_package":"<<[Optional] ANDROID_PACKAGE_NAME_OF_GOOGLE_PLAY_STORE_VERSION>>","testing_instructions":"<<[REQUIRED] TESTING_INSTRUCTIONS. Please provide any test account details if applicable>>","alpha_testers":[{"address":"<<Optional. genesis token wallet address>>","comment":"<<Optional. For internal use only>>"},{"address":"<<Optional. genesis token wallet address>>","comment":"<<Optional. For internal use only>>"}]}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"object","properties":{"publisher":{"type":"object","properties":{"name":{"type":"string"},"website":{"type":"string"},"email":{"type":"string"},"support_email":{"type":"string"}},"required":["name","website","email"]},"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"]}}},"android_details":{"type":"object","properties":{"locales":{"type":"array","items":{"type":"string"}}}}}},"solana_mobile_dapp_publisher_portal":{"type":"object","properties":{"google_store_package":{"type":"string"},"testing_instructions":{"type":"string"},"alpha_testers":{"type":"array","items":{"type":"object","properties":{"address":{"type":"string"},"comment":{"type":"string"}},"required":["address","comment"]}}}}}}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
publisher:
|
|
2
|
-
name: <<[REQUIRED] YOUR_PUBLISHER_NAME>>
|
|
3
|
-
website: <<[REQUIRED] URL_OF_PUBLISHER_WEBSITE>>
|
|
4
|
-
email: <<[REQUIRED] EMAIL_ADDRESS_TO_CONTACT_PUBLISHER>>
|
|
5
|
-
support_email: <<[Optional] SUPPORT_EMAIL_ADDRESS_FOR_END_USERS>>
|
|
6
|
-
app:
|
|
7
|
-
name: <<[REQUIRED] APP_NAME>>
|
|
8
|
-
address: ""
|
|
9
|
-
android_package: <<[REQUIRED] ANDROID_PACKAGE_NAME>>
|
|
10
|
-
urls:
|
|
11
|
-
license_url: <<[REQUIRED] URL For App's T&C. Don't put placeholder urls.>>
|
|
12
|
-
copyright_url: <<[REQUIRED] URL For App's Copyright. Don't put placeholder urls.>>
|
|
13
|
-
privacy_policy_url: <<[REQUIRED] URL For App's Privacy Policy. Don't put placeholder urls.>>
|
|
14
|
-
website: <<[REQUIRED] URL_OF_APP_WEBSITE>>
|
|
15
|
-
media:
|
|
16
|
-
- purpose: icon
|
|
17
|
-
uri: <<[REQUIRED] RELATIVE_PATH_TO_APP_ICON>>
|
|
18
|
-
release:
|
|
19
|
-
address: ""
|
|
20
|
-
media:
|
|
21
|
-
- purpose: icon
|
|
22
|
-
uri: <<[REQUIRED] RELATIVE_PATH_TO_RELEASE_ICON>>
|
|
23
|
-
- purpose: banner
|
|
24
|
-
uri: <<[REQUIRED] RELATIVE_PATH_TO_BANNER>>
|
|
25
|
-
- purpose: featureGraphic
|
|
26
|
-
uri: <<[Optional] RELATIVE_PATH_TO_FEATURE_GRAPHIC>>
|
|
27
|
-
- purpose: screenshot
|
|
28
|
-
uri: <<[REQUIRED] RELATIVE_PATH_TO_SCREENSHOT1>>
|
|
29
|
-
- purpose: screenshot
|
|
30
|
-
uri: <<[REQUIRED] RELATIVE_PATH_TO_SCREENSHOT2>>
|
|
31
|
-
- purpose: screenshot
|
|
32
|
-
uri: <<[REQUIRED] RELATIVE_PATH_TO_SCREENSHOT3>>
|
|
33
|
-
- purpose: screenshot
|
|
34
|
-
uri: <<[REQUIRED] RELATIVE_PATH_TO_SCREENSHOT4>>
|
|
35
|
-
- purpose: video
|
|
36
|
-
uri: <<[Optional] RELATIVE_PATH_TO_VIDEO1>>
|
|
37
|
-
files:
|
|
38
|
-
- purpose: install
|
|
39
|
-
uri: <<[REQUIRED] RELATIVE_PATH_TO_APK>>
|
|
40
|
-
catalog:
|
|
41
|
-
en-US:
|
|
42
|
-
name: >-
|
|
43
|
-
<<[REQUIRED] APP_NAME>>
|
|
44
|
-
short_description: >-
|
|
45
|
-
<<[REQUIRED] SHORT_APP_DESCRIPTION>>
|
|
46
|
-
long_description: >-
|
|
47
|
-
<<[REQUIRED] LONG_APP_DESCRIPTION>>
|
|
48
|
-
new_in_version: >-
|
|
49
|
-
<<[REQUIRED] WHATS_NEW_IN_THIS_VERSION>>
|
|
50
|
-
saga_features: >-
|
|
51
|
-
<<[Optional.] ANY_FEATURES_ONLY_AVAILBLE_WHEN_RUNNING_ON_SAGA>>
|
|
52
|
-
android_details:
|
|
53
|
-
locales:
|
|
54
|
-
- en-US
|
|
55
|
-
- <Add more supported locales>
|
|
56
|
-
solana_mobile_dapp_publisher_portal:
|
|
57
|
-
google_store_package: <<[Optional] ANDROID_PACKAGE_NAME_OF_GOOGLE_PLAY_STORE_VERSION>>
|
|
58
|
-
testing_instructions: >-
|
|
59
|
-
<<[REQUIRED] TESTING_INSTRUCTIONS. Please provide any test account details if applicable>>
|
|
60
|
-
alpha_testers:
|
|
61
|
-
- address: <<Optional. genesis token wallet address>>
|
|
62
|
-
comment: <<Optional. For internal use only>>
|
|
63
|
-
- address: <<Optional. genesis token wallet address>>
|
|
64
|
-
comment: <<Optional. For internal use only>>
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
schema["properties"]["publisher"].required = [
|
|
14
|
-
"name",
|
|
15
|
-
"website",
|
|
16
|
-
"email"
|
|
17
|
-
];
|
|
18
|
-
// Generator adds some keys/values we don't need & mess up validation
|
|
19
|
-
delete schema.$schema;
|
|
20
|
-
delete schema.title;
|
|
21
|
-
var toWrite = Buffer.from(JSON.stringify(schema));
|
|
22
|
-
fs.writeFileSync('./src/generated/config_schema.json', toWrite, 'utf-8');
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.log(":: Schema generation step failed ::");
|
|
25
|
-
}
|
|
@@ -1,293 +0,0 @@
|
|
|
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, _ = {
|
|
79
|
-
label: 0,
|
|
80
|
-
sent: function() {
|
|
81
|
-
if (t[0] & 1) throw t[1];
|
|
82
|
-
return t[1];
|
|
83
|
-
},
|
|
84
|
-
trys: [],
|
|
85
|
-
ops: []
|
|
86
|
-
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
87
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
88
|
-
return this;
|
|
89
|
-
}), g;
|
|
90
|
-
function verb(n) {
|
|
91
|
-
return function(v) {
|
|
92
|
-
return step([
|
|
93
|
-
n,
|
|
94
|
-
v
|
|
95
|
-
]);
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function step(op) {
|
|
99
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
100
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
101
|
-
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;
|
|
102
|
-
if (y = 0, t) op = [
|
|
103
|
-
op[0] & 2,
|
|
104
|
-
t.value
|
|
105
|
-
];
|
|
106
|
-
switch(op[0]){
|
|
107
|
-
case 0:
|
|
108
|
-
case 1:
|
|
109
|
-
t = op;
|
|
110
|
-
break;
|
|
111
|
-
case 4:
|
|
112
|
-
_.label++;
|
|
113
|
-
return {
|
|
114
|
-
value: op[1],
|
|
115
|
-
done: false
|
|
116
|
-
};
|
|
117
|
-
case 5:
|
|
118
|
-
_.label++;
|
|
119
|
-
y = op[1];
|
|
120
|
-
op = [
|
|
121
|
-
0
|
|
122
|
-
];
|
|
123
|
-
continue;
|
|
124
|
-
case 7:
|
|
125
|
-
op = _.ops.pop();
|
|
126
|
-
_.trys.pop();
|
|
127
|
-
continue;
|
|
128
|
-
default:
|
|
129
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
130
|
-
_ = 0;
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
134
|
-
_.label = op[1];
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
138
|
-
_.label = t[1];
|
|
139
|
-
t = op;
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
if (t && _.label < t[2]) {
|
|
143
|
-
_.label = t[2];
|
|
144
|
-
_.ops.push(op);
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
if (t[2]) _.ops.pop();
|
|
148
|
-
_.trys.pop();
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
op = body.call(thisArg, _);
|
|
152
|
-
} catch (e) {
|
|
153
|
-
op = [
|
|
154
|
-
6,
|
|
155
|
-
e
|
|
156
|
-
];
|
|
157
|
-
y = 0;
|
|
158
|
-
} finally{
|
|
159
|
-
f = t = 0;
|
|
160
|
-
}
|
|
161
|
-
if (op[0] & 5) throw op[1];
|
|
162
|
-
return {
|
|
163
|
-
value: op[0] ? op[1] : void 0,
|
|
164
|
-
done: true
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
import fs from "fs";
|
|
169
|
-
import path from "path";
|
|
170
|
-
import { createHash } from "crypto";
|
|
171
|
-
// TODO(jon): We need to manage the removal / replacement of assets in the manifest
|
|
172
|
-
export var CachedStorageDriver = /*#__PURE__*/ function() {
|
|
173
|
-
"use strict";
|
|
174
|
-
function CachedStorageDriver(storageDriver, param) {
|
|
175
|
-
var assetManifestPath = param.assetManifestPath;
|
|
176
|
-
_class_call_check(this, CachedStorageDriver);
|
|
177
|
-
_define_property(this, "assetManifest", void 0);
|
|
178
|
-
_define_property(this, "assetManifestPath", void 0);
|
|
179
|
-
_define_property(this, "storageDriver", void 0);
|
|
180
|
-
this.assetManifestPath = assetManifestPath;
|
|
181
|
-
var _this_loadAssetManifest;
|
|
182
|
-
this.assetManifest = (_this_loadAssetManifest = this.loadAssetManifest(assetManifestPath)) !== null && _this_loadAssetManifest !== void 0 ? _this_loadAssetManifest : {
|
|
183
|
-
schema_version: CachedStorageDriver.SCHEMA_VERSION,
|
|
184
|
-
assets: {}
|
|
185
|
-
};
|
|
186
|
-
this.storageDriver = storageDriver;
|
|
187
|
-
}
|
|
188
|
-
_create_class(CachedStorageDriver, [
|
|
189
|
-
{
|
|
190
|
-
key: "getUploadPrice",
|
|
191
|
-
value: function getUploadPrice(bytes) {
|
|
192
|
-
return _async_to_generator(function() {
|
|
193
|
-
return _ts_generator(this, function(_state) {
|
|
194
|
-
return [
|
|
195
|
-
2,
|
|
196
|
-
this.storageDriver.getUploadPrice(bytes)
|
|
197
|
-
];
|
|
198
|
-
});
|
|
199
|
-
}).call(this);
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
key: "loadAssetManifest",
|
|
204
|
-
value: function loadAssetManifest(filename) {
|
|
205
|
-
try {
|
|
206
|
-
return JSON.parse(fs.readFileSync(filename, "utf-8"));
|
|
207
|
-
} catch (error) {
|
|
208
|
-
console.warn("Failed opening ".concat(filename, "; initializing with a blank asset manifest"));
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
key: "uploadedAsset",
|
|
215
|
-
value: function uploadedAsset(filename, param) {
|
|
216
|
-
var sha256 = param.sha256;
|
|
217
|
-
var _this_assetManifest_assets_filename;
|
|
218
|
-
if (((_this_assetManifest_assets_filename = this.assetManifest.assets[filename]) === null || _this_assetManifest_assets_filename === void 0 ? void 0 : _this_assetManifest_assets_filename.sha256) === sha256) {
|
|
219
|
-
return this.assetManifest.assets[filename];
|
|
220
|
-
}
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
key: "upload",
|
|
226
|
-
value: function upload(file) {
|
|
227
|
-
return _async_to_generator(function() {
|
|
228
|
-
var hash, uploadedAsset, uri;
|
|
229
|
-
return _ts_generator(this, function(_state) {
|
|
230
|
-
switch(_state.label){
|
|
231
|
-
case 0:
|
|
232
|
-
if (!(file.fileName === "inline.json")) return [
|
|
233
|
-
3,
|
|
234
|
-
2
|
|
235
|
-
];
|
|
236
|
-
return [
|
|
237
|
-
4,
|
|
238
|
-
this.storageDriver.upload(file)
|
|
239
|
-
];
|
|
240
|
-
case 1:
|
|
241
|
-
return [
|
|
242
|
-
2,
|
|
243
|
-
_state.sent()
|
|
244
|
-
];
|
|
245
|
-
case 2:
|
|
246
|
-
hash = createHash("sha256").update(file.buffer).digest("base64");
|
|
247
|
-
uploadedAsset = this.uploadedAsset(file.fileName, {
|
|
248
|
-
sha256: hash
|
|
249
|
-
});
|
|
250
|
-
if (uploadedAsset) {
|
|
251
|
-
console.log("Asset ".concat(file.fileName, " already uploaded at ").concat(uploadedAsset.uri));
|
|
252
|
-
return [
|
|
253
|
-
2,
|
|
254
|
-
uploadedAsset.uri
|
|
255
|
-
];
|
|
256
|
-
}
|
|
257
|
-
console.log("Uploading ".concat(file.fileName));
|
|
258
|
-
return [
|
|
259
|
-
4,
|
|
260
|
-
this.storageDriver.upload(file)
|
|
261
|
-
];
|
|
262
|
-
case 3:
|
|
263
|
-
uri = _state.sent();
|
|
264
|
-
this.assetManifest.assets[file.fileName] = {
|
|
265
|
-
path: file.fileName,
|
|
266
|
-
sha256: hash,
|
|
267
|
-
uri: uri
|
|
268
|
-
};
|
|
269
|
-
return [
|
|
270
|
-
4,
|
|
271
|
-
fs.promises.writeFile(path.join(process.cwd(), this.assetManifestPath), // Something is really weird, I can't seem to stringify `this.assetManifest` straight-up. Here be dragons
|
|
272
|
-
JSON.stringify({
|
|
273
|
-
assets: _object_spread({}, this.assetManifest.assets)
|
|
274
|
-
}, null, 2), "utf-8")
|
|
275
|
-
];
|
|
276
|
-
case 4:
|
|
277
|
-
_state.sent();
|
|
278
|
-
console.log("".concat(file.fileName, " uploaded at ").concat(uri));
|
|
279
|
-
return [
|
|
280
|
-
2,
|
|
281
|
-
uri
|
|
282
|
-
];
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
}).call(this);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
]);
|
|
289
|
-
return CachedStorageDriver;
|
|
290
|
-
}();
|
|
291
|
-
// NOTE: this schema version is independent of the publishing JSON schema. It should be updated
|
|
292
|
-
// when the AssetManifestSchema or Asset types are updated.
|
|
293
|
-
_define_property(CachedStorageDriver, "SCHEMA_VERSION", "0.1");
|