@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,212 @@
1
+ import { beforeEach, expect } from "@jest/globals";
2
+ import {
3
+ createAppCliCmd,
4
+ createCliCmd,
5
+ createPublisherCliCmd,
6
+ createReleaseCliCmd,
7
+ initCliCmd,
8
+ mainCli
9
+ } from "../CliSetup";
10
+ import { Constants } from "../CliUtils";
11
+
12
+ describe("Cli Setup & Execution", () => {
13
+ const outputHelpReference = "(outputHelp)"
14
+
15
+ let errorOutput: string = ""
16
+ let otherOutput: string = ""
17
+
18
+ beforeEach(() => {
19
+ errorOutput = "";
20
+ otherOutput = "";
21
+ mainCli.exitOverride();
22
+
23
+ mainCli.configureOutput({
24
+ getOutHelpWidth(): number { return 250; },
25
+ getErrHelpWidth(): number { return 250;},
26
+
27
+ writeOut(str: string) {
28
+ otherOutput = str;
29
+ },
30
+
31
+ writeErr(str: string) {
32
+ errorOutput = str;
33
+ }
34
+ });
35
+ });
36
+
37
+ test("Cli version argument reports correct version", () => {
38
+
39
+ expect(() => {
40
+ mainCli.parse(["npx", "dapp-store", "-V"]);
41
+ }).toThrow(Constants.CLI_VERSION)
42
+ });
43
+
44
+ test("Calling cli with no parameters displays general help", () => {
45
+ expect(() => {
46
+ mainCli.parse(["npx", "dapp-store"]);
47
+ }
48
+ ).toThrow(outputHelpReference);
49
+
50
+ expect(generalHelp).toEqual(errorOutput)
51
+ });
52
+
53
+ test("Calling init command with help parameter shows contextual help info", () => {
54
+ initCliCmd.exitOverride()
55
+
56
+ expect(() => {
57
+ initCliCmd.parse(["dapp-store", "init", "-h"])
58
+ }).toThrow(outputHelpReference)
59
+
60
+ expect(otherOutput).toEqual(initHelp)
61
+ })
62
+
63
+ test("Calling create command with no options lists all options", () => {
64
+ createCliCmd.exitOverride()
65
+
66
+ expect(() => {
67
+ createCliCmd.parse(["dapp-store", "create"]);
68
+ }
69
+ ).toThrow(outputHelpReference);
70
+
71
+ expect(errorOutput).toEqual(createHelp)
72
+ });
73
+
74
+ test("Calling create publisher command with no arguments warns about required argument", () => {
75
+ createPublisherCliCmd.exitOverride()
76
+
77
+ expect(() => {
78
+ createPublisherCliCmd.parse(["dapp-store", "create", "publisher"]);
79
+ }
80
+ ).toThrow(keyPairArgHelp);
81
+ });
82
+
83
+ test("Calling create publisher command with help flag shows contextual help", () => {
84
+ createPublisherCliCmd.exitOverride()
85
+
86
+ expect(() => {
87
+ createPublisherCliCmd.parse(["dapp-store", "create", "publisher", "-h"]);
88
+ }).toThrow(outputHelpReference)
89
+
90
+ expect(otherOutput).toEqual(createPublisherHelp)
91
+ });
92
+
93
+ test("Calling create app command with no arguments warns about required argument", () => {
94
+ createAppCliCmd.exitOverride()
95
+
96
+ expect(() => {
97
+ createAppCliCmd.parse(["dapp-store", "create", "app"]);
98
+ }
99
+ ).toThrow(keyPairArgHelp);
100
+ });
101
+
102
+ test("Calling create app command with help flag shows contextual help", () => {
103
+ createAppCliCmd.exitOverride()
104
+
105
+ expect(() => {
106
+ createAppCliCmd.parse(["dapp-store", "create", "app", "-h"]);
107
+ }).toThrow(outputHelpReference)
108
+
109
+ expect(otherOutput).toEqual(createAppHelp)
110
+ });
111
+
112
+ test("Calling create release command with no arguments warns about required argument", () => {
113
+ createReleaseCliCmd.exitOverride()
114
+
115
+ expect(() => {
116
+ createReleaseCliCmd.parse(["dapp-store", "create", "release"]);
117
+ }
118
+ ).toThrow(keyPairArgHelp);
119
+ });
120
+
121
+ test("Calling create release command with help flag shows contextual help", () => {
122
+ createReleaseCliCmd.exitOverride()
123
+
124
+ expect(() => {
125
+ createReleaseCliCmd.parse(["dapp-store", "create", "release", "-h"]);
126
+ }).toThrow(outputHelpReference)
127
+
128
+ expect(otherOutput).toEqual(createReleaseHelp)
129
+ });
130
+
131
+ //--------------------------------------------------
132
+
133
+ const generalHelp = `Usage: dapp-store [options] [command]
134
+
135
+ CLI to assist with publishing to the Saga Dapp Store
136
+
137
+ Options:
138
+ -V, --version output the version number
139
+ -h, --help display help for command
140
+
141
+ Commands:
142
+ init First-time initialization of tooling configuration
143
+ create Create a \`publisher\`, \`app\`, or \`release\`
144
+ validate [options] Validates details prior to publishing
145
+ publish Submit a publishing request (\`submit\`, \`update\`, \`remove\`, or \`support\`) to the Solana Mobile dApp publisher portal
146
+ help [command] display help for command
147
+ `;
148
+
149
+ const initHelp = `Usage: dapp-store init [options]
150
+
151
+ First-time initialization of tooling configuration
152
+
153
+ Options:
154
+ -h, --help display help for command
155
+ `;
156
+
157
+ const keyPairArgHelp = "error: required option '-k, --keypair <path-to-keypair-file>' not specified"
158
+
159
+ const createHelp = `Usage: dapp-store create [options] [command]
160
+
161
+ Create a \`publisher\`, \`app\`, or \`release\`
162
+
163
+ Options:
164
+ -h, --help display help for command
165
+
166
+ Commands:
167
+ publisher [options] Create a publisher
168
+ app [options] Create a app
169
+ release [options] Create a release
170
+ help [command] display help for command
171
+ `;
172
+
173
+ const createPublisherHelp = `Usage: dapp-store create publisher [options]
174
+
175
+ Create a publisher
176
+
177
+ Options:
178
+ -k, --keypair <path-to-keypair-file> Path to keypair file
179
+ -u, --url <url> RPC URL (default: "https://api.devnet.solana.com")
180
+ -d, --dry-run Flag for dry run. Doesn't mint an NFT
181
+ -s, --storage-config <storage-config> Provide alternative storage configuration details
182
+ -h, --help display help for command
183
+ `;
184
+
185
+ const createAppHelp = `Usage: dapp-store create app [options]
186
+
187
+ Create a app
188
+
189
+ Options:
190
+ -k, --keypair <path-to-keypair-file> Path to keypair file
191
+ -p, --publisher-mint-address <publisher-mint-address> The mint address of the publisher NFT
192
+ -u, --url <url> RPC URL (default: "https://api.devnet.solana.com")
193
+ -d, --dry-run Flag for dry run. Doesn't mint an NFT
194
+ -s, --storage-config <storage-config> Provide alternative storage configuration details
195
+ -h, --help display help for command
196
+ `;
197
+
198
+ const createReleaseHelp = `Usage: dapp-store create release [options]
199
+
200
+ Create a release
201
+
202
+ Options:
203
+ -k, --keypair <path-to-keypair-file> Path to keypair file
204
+ -a, --app-mint-address <app-mint-address> The mint address of the app NFT
205
+ -u, --url <url> RPC URL (default: "https://api.devnet.solana.com")
206
+ -d, --dry-run Flag for dry run. Doesn't mint an NFT
207
+ -b, --build-tools-path <build-tools-path> Path to Android build tools which contains AAPT2
208
+ -s, --storage-config <storage-config> Provide alternative storage configuration details
209
+ -h, --help display help for command
210
+ `;
211
+
212
+ });
@@ -18,16 +18,18 @@ const createAppNft = async (
18
18
  connection,
19
19
  publisherMintAddress,
20
20
  publisher,
21
+ storageParams,
21
22
  }: {
22
23
  appDetails: App;
23
24
  connection: Connection;
24
25
  publisherMintAddress: string;
25
26
  publisher: Keypair;
27
+ storageParams: string;
26
28
  },
27
29
  { dryRun }: { dryRun?: boolean }
28
30
  ) => {
29
31
  const mintAddress = Keypair.generate();
30
- const metaplex = getMetaplexInstance(connection, publisher);
32
+ const metaplex = getMetaplexInstance(connection, publisher, storageParams);
31
33
  const txBuilder = await createApp(
32
34
  {
33
35
  publisherMintAddress: new PublicKey(publisherMintAddress),
@@ -59,6 +61,7 @@ type CreateAppCommandInput = {
59
61
  signer: Keypair;
60
62
  url: string;
61
63
  dryRun?: boolean;
64
+ storageParams: string;
62
65
  };
63
66
 
64
67
  export const createAppCommand = async ({
@@ -66,6 +69,7 @@ export const createAppCommand = async ({
66
69
  url,
67
70
  dryRun,
68
71
  publisherMintAddress,
72
+ storageParams,
69
73
  }: CreateAppCommandInput) => {
70
74
  const connection = new Connection(url);
71
75
 
@@ -78,6 +82,7 @@ export const createAppCommand = async ({
78
82
  publisher: signer,
79
83
  publisherMintAddress: publisherDetails.address ?? publisherMintAddress,
80
84
  appDetails,
85
+ storageParams,
81
86
  },
82
87
  { dryRun }
83
88
  );
@@ -16,15 +16,17 @@ const createPublisherNft = async (
16
16
  connection,
17
17
  publisher,
18
18
  publisherDetails,
19
+ storageParams,
19
20
  }: {
20
21
  connection: Connection;
21
22
  publisher: Keypair;
22
23
  publisherDetails: Publisher;
24
+ storageParams: string;
23
25
  },
24
26
  { dryRun }: { dryRun: boolean }
25
27
  ) => {
26
28
  const mintAddress = Keypair.generate();
27
- const metaplex = getMetaplexInstance(connection, publisher);
29
+ const metaplex = getMetaplexInstance(connection, publisher, storageParams);
28
30
  console.info(
29
31
  `Creating publisher at address: ${mintAddress.publicKey.toBase58()}`
30
32
  );
@@ -54,10 +56,12 @@ export const createPublisherCommand = async ({
54
56
  signer,
55
57
  url,
56
58
  dryRun,
59
+ storageParams,
57
60
  }: {
58
61
  signer: Keypair;
59
62
  url: string;
60
63
  dryRun: boolean;
64
+ storageParams: string;
61
65
  }) => {
62
66
  const connection = new Connection(url);
63
67
 
@@ -68,6 +72,7 @@ export const createPublisherCommand = async ({
68
72
  connection,
69
73
  publisher: signer,
70
74
  publisherDetails,
75
+ storageParams: storageParams,
71
76
  },
72
77
  { dryRun }
73
78
  );
@@ -21,6 +21,7 @@ type CreateReleaseCommandInput = {
21
21
  signer: Keypair;
22
22
  url: string;
23
23
  dryRun?: boolean;
24
+ storageParams: string;
24
25
  };
25
26
 
26
27
  const createReleaseNft = async ({
@@ -30,6 +31,7 @@ const createReleaseNft = async ({
30
31
  publisherDetails,
31
32
  connection,
32
33
  publisher,
34
+ storageParams,
33
35
  }: {
34
36
  appMintAddress: string;
35
37
  releaseDetails: Release;
@@ -37,10 +39,11 @@ const createReleaseNft = async ({
37
39
  publisherDetails: Publisher;
38
40
  connection: Connection;
39
41
  publisher: Keypair;
42
+ storageParams: string;
40
43
  }) => {
41
44
  const releaseMintAddress = Keypair.generate();
42
45
 
43
- const metaplex = getMetaplexInstance(connection, publisher);
46
+ const metaplex = getMetaplexInstance(connection, publisher, storageParams);
44
47
 
45
48
  const { txBuilder } = await createRelease(
46
49
  {
@@ -77,6 +80,7 @@ export const createReleaseCommand = async ({
77
80
  signer,
78
81
  url,
79
82
  dryRun = false,
83
+ storageParams,
80
84
  }: CreateReleaseCommandInput) => {
81
85
  const connection = new Connection(url);
82
86
 
@@ -92,6 +96,7 @@ export const createReleaseCommand = async ({
92
96
  },
93
97
  appDetails: app,
94
98
  publisherDetails: publisher,
99
+ storageParams: storageParams,
95
100
  });
96
101
 
97
102
  writeToPublishDetails({
@@ -0,0 +1,39 @@
1
+ import * as dotenv from "dotenv";
2
+
3
+ export type S3Config = {
4
+ accessKey: string;
5
+ secretKey: string;
6
+ bucketName: string;
7
+ regionName: string;
8
+ }
9
+ export class EnvVariables {
10
+
11
+ public get hasAndroidTools(): boolean {
12
+ return process.env.ANDROID_TOOLS_DIR !== undefined;
13
+ }
14
+
15
+ public get androidToolsDir(): string {
16
+ return process.env.ANDROID_TOOLS_DIR as string;
17
+ }
18
+
19
+ public get hasS3EnvArgs(): boolean {
20
+ return process.env.STORAGE_TYPE == "s3" &&
21
+ process.env.S3_ACCESS_KEY != undefined &&
22
+ process.env.S3_SECRET_KEY != undefined &&
23
+ process.env.S3_BUCKET != undefined &&
24
+ process.env.S3_REGION != undefined;
25
+ }
26
+
27
+ public get s3Config(): S3Config {
28
+ return {
29
+ accessKey: process.env.S3_ACCESS_KEY as string,
30
+ secretKey: process.env.S3_SECRET_KEY as string,
31
+ bucketName: process.env.S3_BUCKET as string,
32
+ regionName: process.env.S3_REGION as string
33
+ };
34
+ }
35
+
36
+ constructor() {
37
+ dotenv.config();
38
+ }
39
+ }
@@ -178,10 +178,10 @@ const validateLocalizableResources = (config: PublishDetails) => {
178
178
 
179
179
  const descsWrongLength = Object.values(config.release.catalog)
180
180
  .map((x) => x.short_description)
181
- .filter((desc) => !desc?.length || desc.length > 50);
181
+ .filter((desc) => !desc?.length || desc.length > 30);
182
182
 
183
183
  if (descsWrongLength.length > 0) {
184
- throw new Error("Please ensure all translations of short_description are between 0 and 50 characters");
184
+ throw new Error("Please ensure all translations of short_description are between 0 and 30 characters");
185
185
  }
186
186
  };
187
187
 
@@ -237,6 +237,7 @@ const getAndroidDetails = async (
237
237
  min_sdk: parseInt(minSdk?.[1] ?? "0", 10),
238
238
  version_code: parseInt(versionCode?.[1] ?? "0", 10),
239
239
  version: versionName?.[1] ?? "0",
240
+ cert_fingerprint: await extractCertFingerprint(aaptDir, apkPath),
240
241
  permissions: permissions.flatMap(permission => permission[1]),
241
242
  locales: localeArray
242
243
  };
@@ -245,6 +246,19 @@ const getAndroidDetails = async (
245
246
  }
246
247
  };
247
248
 
249
+ export const extractCertFingerprint = async (aaptDir: string, apkPath: string): Promise<string> => {
250
+ const { stdout } = await runExec(`${aaptDir}/apksigner verify --print-certs -v "${apkPath}"`);
251
+
252
+ const regex = /Signer #1 certificate SHA-256 digest:\s*([a-fA-F0-9]+)/;
253
+ const match = stdout.match(regex);
254
+
255
+ if (match && match[1]) {
256
+ return match[1];
257
+ } else {
258
+ throw new Error("Could not obtain cert fingerprint")
259
+ }
260
+ }
261
+
248
262
  export const writeToPublishDetails = async ({ publisher, app, release }: SaveToConfigArgs) => {
249
263
  const currentConfig = await loadPublishDetailsWithChecks();
250
264
 
@@ -0,0 +1,47 @@
1
+ import { EnvVariables, S3Config } from "./EnvVariables.js";
2
+
3
+ export class S3StorageManager {
4
+ private _config: S3Config | undefined = undefined
5
+
6
+ public get hasS3Config(): boolean {
7
+ return this._config != undefined;
8
+ }
9
+
10
+ public get s3Config(): S3Config {
11
+ return this._config as S3Config;
12
+ }
13
+
14
+ constructor(private envVars: EnvVariables) {
15
+ if (envVars.hasS3EnvArgs) {
16
+ this._config = {
17
+ accessKey: this.envVars.s3Config.accessKey,
18
+ secretKey: this.envVars.s3Config.secretKey,
19
+ bucketName: this.envVars.s3Config.bucketName,
20
+ regionName: this.envVars.s3Config.regionName
21
+ };
22
+ }
23
+ }
24
+
25
+ parseCmdArg(cmdArg: string) {
26
+ if (!cmdArg || cmdArg == "") return;
27
+
28
+ try {
29
+ //This will overwrite any existing parameters already obtained from the .env file
30
+ const parsedArray = JSON.parse(`${cmdArg}`);
31
+
32
+ if (parsedArray instanceof Array && parsedArray[0] == "s3") {
33
+ if (parsedArray.length != 5) throw new Error("Invalid parameters")
34
+
35
+ this._config = {
36
+ accessKey: parsedArray[1],
37
+ secretKey: parsedArray[2],
38
+ bucketName: parsedArray[3],
39
+ regionName: parsedArray[4]
40
+ };
41
+ }
42
+ } catch (e) {
43
+ throw new Error("There was an error parsing your s3 parameters from the CLI. Please ensure they are formatted correctly.");
44
+ }
45
+ }
46
+
47
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./EnvVariables.js";
2
+ export * from "./S3StorageManager.js";