@solana-mobile/dapp-store-cli 0.1.9 → 0.2.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.
- package/README.md +18 -53
- package/lib/esm/commands/publish/remove.js +5 -1
- package/lib/esm/commands/publish/remove.js.map +1 -1
- package/lib/esm/commands/publish/submit.js +7 -3
- package/lib/esm/commands/publish/submit.js.map +1 -1
- package/lib/esm/commands/publish/support.js +5 -1
- package/lib/esm/commands/publish/support.js.map +1 -1
- package/lib/esm/commands/publish/update.js +5 -1
- package/lib/esm/commands/publish/update.js.map +1 -1
- package/lib/esm/commands/scaffolding/index.js +2 -0
- package/lib/esm/commands/scaffolding/index.js.map +1 -0
- package/lib/esm/commands/scaffolding/init.js +15 -0
- package/lib/esm/commands/scaffolding/init.js.map +1 -0
- package/lib/esm/commands/validate.js +4 -13
- package/lib/esm/commands/validate.js.map +1 -1
- package/lib/esm/config/index.js +1 -2
- package/lib/esm/config/index.js.map +1 -1
- package/lib/esm/generated/config_obj.json +1 -0
- package/lib/esm/generated/config_schema.json +1 -0
- package/lib/esm/index.js +20 -10
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/package.json +6 -3
- package/lib/esm/utils.js +40 -16
- package/lib/esm/utils.js.map +1 -1
- package/lib/types/commands/create/app.d.ts +1 -1
- package/lib/types/commands/create/app.d.ts.map +1 -1
- package/lib/types/commands/create/release.d.ts +1 -1
- package/lib/types/commands/create/release.d.ts.map +1 -1
- package/lib/types/commands/publish/remove.d.ts +1 -1
- package/lib/types/commands/publish/remove.d.ts.map +1 -1
- package/lib/types/commands/publish/submit.d.ts +1 -1
- package/lib/types/commands/publish/submit.d.ts.map +1 -1
- package/lib/types/commands/publish/support.d.ts +1 -1
- package/lib/types/commands/publish/support.d.ts.map +1 -1
- package/lib/types/commands/publish/update.d.ts +1 -1
- package/lib/types/commands/publish/update.d.ts.map +1 -1
- package/lib/types/commands/scaffolding/index.d.ts +2 -0
- package/lib/types/commands/scaffolding/index.d.ts.map +1 -0
- package/lib/types/commands/scaffolding/init.d.ts +2 -0
- package/lib/types/commands/scaffolding/init.d.ts.map +1 -0
- package/lib/types/commands/validate.d.ts.map +1 -1
- package/lib/types/config/index.d.ts.map +1 -1
- package/lib/types/upload/CachedStorageDriver.d.ts +3 -3
- package/lib/types/upload/CachedStorageDriver.d.ts.map +1 -1
- package/lib/types/utils.d.ts +6 -1
- package/lib/types/utils.d.ts.map +1 -1
- package/package.json +6 -3
- package/src/commands/publish/remove.ts +8 -1
- package/src/commands/publish/submit.ts +12 -4
- package/src/commands/publish/support.ts +8 -1
- package/src/commands/publish/update.ts +8 -1
- package/src/commands/scaffolding/index.ts +1 -0
- package/src/commands/scaffolding/init.ts +19 -0
- package/src/commands/validate.ts +5 -12
- package/src/config/index.ts +1 -2
- package/src/generated/config_obj.json +1 -0
- package/src/generated/config_schema.json +1 -0
- package/src/index.ts +30 -10
- package/src/prebuild_schema/publishing_source.yaml +44 -0
- package/src/prebuild_schema/schemagen.js +20 -0
- package/src/utils.ts +52 -19
- package/lib/esm/config/schema.json +0 -195
package/src/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import type { AndroidDetails, App, Publisher, Release } from "@solana-mobile/dapp-store-publishing-tools";
|
|
3
3
|
import type { Connection } from "@solana/web3.js";
|
|
4
|
-
import { Keypair } from "@solana/web3.js";
|
|
4
|
+
import { Keypair, PublicKey } from "@solana/web3.js";
|
|
5
5
|
import type { CLIConfig } from "./config/index.js";
|
|
6
6
|
import { getConfig } from "./config/index.js";
|
|
7
7
|
import debugModule from "debug";
|
|
@@ -14,23 +14,45 @@ import { imageSize } from "image-size";
|
|
|
14
14
|
import updateNotifier from "update-notifier";
|
|
15
15
|
import cliPackage from "./package.json" assert { type: "json" };
|
|
16
16
|
import boxen from "boxen";
|
|
17
|
+
import ver from "semver";
|
|
17
18
|
|
|
18
19
|
import { CachedStorageDriver } from "./upload/CachedStorageDriver.js";
|
|
19
20
|
|
|
20
21
|
const runImgSize = util.promisify(imageSize);
|
|
21
22
|
const runExec = util.promisify(exec);
|
|
22
23
|
|
|
24
|
+
export class Constants {
|
|
25
|
+
static CLI_VERSION = "0.2.0";
|
|
26
|
+
static CONFIG_FILE_NAME = "config.yaml";
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
export const debug = debugModule("CLI");
|
|
24
30
|
|
|
25
31
|
export const checkForSelfUpdate = async () => {
|
|
26
32
|
const notifier = updateNotifier({ pkg: cliPackage });
|
|
27
33
|
const updateInfo = await notifier.fetchInfo();
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
const latestVer = new ver.SemVer(updateInfo.latest);
|
|
36
|
+
const currentVer = new ver.SemVer(updateInfo.current);
|
|
37
|
+
|
|
38
|
+
if (latestVer.major > currentVer.major || latestVer.minor > currentVer.minor) {
|
|
30
39
|
throw new Error("Please update to the latest version of the dApp Store CLI before proceeding.");
|
|
31
40
|
}
|
|
32
41
|
};
|
|
33
42
|
|
|
43
|
+
export const checkMintedStatus = async (conn: Connection, pubAddr: string, appAddr: string, releaseAddr: string) => {
|
|
44
|
+
const results = await conn.getMultipleAccountsInfo([
|
|
45
|
+
new PublicKey(pubAddr),
|
|
46
|
+
new PublicKey(appAddr),
|
|
47
|
+
new PublicKey(releaseAddr),
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
const rentAccounts = results.filter((item) => !(item == undefined) && item?.lamports > 0);
|
|
51
|
+
if (rentAccounts?.length != 3) {
|
|
52
|
+
throw new Error("Please ensure you have minted all of your NFTs before submitting to the Solana Mobile dApp publisher portal.");
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
34
56
|
export const parseKeypair = (pathToKeypairFile: string) => {
|
|
35
57
|
try {
|
|
36
58
|
const keypairFile = fs.readFileSync(pathToKeypairFile, "utf-8");
|
|
@@ -56,7 +78,7 @@ const AaptPrefixes = {
|
|
|
56
78
|
export const getConfigFile = async (
|
|
57
79
|
buildToolsDir: string | null = null
|
|
58
80
|
): Promise<CLIConfig> => {
|
|
59
|
-
const configFilePath = `${process.cwd()}
|
|
81
|
+
const configFilePath = `${process.cwd()}/${Constants.CONFIG_FILE_NAME}`;
|
|
60
82
|
|
|
61
83
|
const config = await getConfig(configFilePath);
|
|
62
84
|
|
|
@@ -79,37 +101,38 @@ export const getConfigFile = async (
|
|
|
79
101
|
const publisherIcon = config.publisher.media?.find(
|
|
80
102
|
(asset: any) => asset.purpose === "icon"
|
|
81
103
|
)?.uri;
|
|
104
|
+
|
|
82
105
|
if (publisherIcon) {
|
|
83
106
|
const iconPath = path.join(process.cwd(), publisherIcon);
|
|
84
|
-
|
|
85
|
-
throw new Error("Please check the path to your Publisher icon and ensure the file is a jpeg, png, or webp file.");
|
|
86
|
-
}
|
|
107
|
+
await checkIconCompatibility(iconPath, "Publisher");
|
|
87
108
|
|
|
88
109
|
const iconBuffer = await fs.promises.readFile(iconPath);
|
|
89
|
-
|
|
90
|
-
if (await checkIconDimensions(iconPath)) {
|
|
91
|
-
throw new Error("Icons must have square dimensions and be no greater than 512px by 512px.")
|
|
92
|
-
}
|
|
93
|
-
|
|
94
110
|
config.publisher.icon = toMetaplexFile(iconBuffer, publisherIcon);
|
|
95
111
|
}
|
|
96
112
|
|
|
97
113
|
const appIcon = config.app.media?.find(
|
|
98
114
|
(asset: any) => asset.purpose === "icon"
|
|
99
115
|
)?.uri;
|
|
116
|
+
|
|
100
117
|
if (appIcon) {
|
|
101
118
|
const iconPath = path.join(process.cwd(), appIcon);
|
|
102
|
-
|
|
103
|
-
throw new Error("Please check the path to your App icon and ensure the file is a jpeg, png, or webp file.")
|
|
104
|
-
}
|
|
119
|
+
await checkIconCompatibility(iconPath, "App");
|
|
105
120
|
|
|
106
121
|
const iconBuffer = await fs.promises.readFile(iconPath);
|
|
122
|
+
config.app.icon = toMetaplexFile(iconBuffer, appIcon);
|
|
123
|
+
}
|
|
107
124
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
const releaseIcon = config.release.media?.find(
|
|
126
|
+
(asset: any) => asset.purpose === "icon"
|
|
127
|
+
)?.uri;
|
|
111
128
|
|
|
112
|
-
|
|
129
|
+
if (releaseIcon) {
|
|
130
|
+
const iconPath = path.join(process.cwd(), releaseIcon);
|
|
131
|
+
await checkIconCompatibility(iconPath, "Release");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!appIcon && !releaseIcon) {
|
|
135
|
+
throw new Error("Please specify at least one media entry of type icon in your configuration file");
|
|
113
136
|
}
|
|
114
137
|
|
|
115
138
|
config.release.media.forEach((item: CLIConfig["release"]["media"][0]) => {
|
|
@@ -122,6 +145,16 @@ export const getConfigFile = async (
|
|
|
122
145
|
return config;
|
|
123
146
|
};
|
|
124
147
|
|
|
148
|
+
const checkIconCompatibility = async (path: string, typeString: string) => {
|
|
149
|
+
if (!fs.existsSync(path) || !checkImageExtension(path)) {
|
|
150
|
+
throw new Error(`Please check the path to your ${typeString} icon and ensure the file is a jpeg, png, or webp file.`)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (await checkIconDimensions(path)) {
|
|
154
|
+
throw new Error("Icons must have square dimensions and be no greater than 512px by 512px.")
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
125
158
|
const checkImageExtension = (uri: string): boolean => {
|
|
126
159
|
const fileExt = path.extname(uri).toLowerCase();
|
|
127
160
|
return (
|
|
@@ -262,7 +295,7 @@ export const saveToConfig = async ({
|
|
|
262
295
|
};
|
|
263
296
|
|
|
264
297
|
// TODO(jon): Verify the contents of the YAML file
|
|
265
|
-
fs.writeFileSync(`${process.cwd()}
|
|
298
|
+
fs.writeFileSync(`${process.cwd()}/${Constants.CONFIG_FILE_NAME}`, dump(newConfig));
|
|
266
299
|
};
|
|
267
300
|
|
|
268
301
|
export const getMetaplexInstance = (
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "object",
|
|
3
|
-
"properties": {
|
|
4
|
-
"publisher": {
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string"
|
|
9
|
-
},
|
|
10
|
-
"address": {
|
|
11
|
-
"type": "string"
|
|
12
|
-
},
|
|
13
|
-
"website": {
|
|
14
|
-
"type": "string"
|
|
15
|
-
},
|
|
16
|
-
"email": {
|
|
17
|
-
"type": "string"
|
|
18
|
-
},
|
|
19
|
-
"media": {
|
|
20
|
-
"type": "array",
|
|
21
|
-
"items": [
|
|
22
|
-
{
|
|
23
|
-
"type": "object",
|
|
24
|
-
"properties": {
|
|
25
|
-
"purpose": {
|
|
26
|
-
"type": "string"
|
|
27
|
-
},
|
|
28
|
-
"uri": {
|
|
29
|
-
"type": "string"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"required": ["purpose", "uri"]
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"required": ["name", "website", "email", "media"]
|
|
38
|
-
},
|
|
39
|
-
"app": {
|
|
40
|
-
"type": "object",
|
|
41
|
-
"properties": {
|
|
42
|
-
"name": {
|
|
43
|
-
"type": "string"
|
|
44
|
-
},
|
|
45
|
-
"address": {
|
|
46
|
-
"type": "string"
|
|
47
|
-
},
|
|
48
|
-
"android_package": {
|
|
49
|
-
"type": "string"
|
|
50
|
-
},
|
|
51
|
-
"urls": {
|
|
52
|
-
"type": "object",
|
|
53
|
-
"properties": {
|
|
54
|
-
"license_url": {
|
|
55
|
-
"type": "string"
|
|
56
|
-
},
|
|
57
|
-
"copyright_url": {
|
|
58
|
-
"type": "string"
|
|
59
|
-
},
|
|
60
|
-
"privacy_policy_url": {
|
|
61
|
-
"type": "string"
|
|
62
|
-
},
|
|
63
|
-
"website": {
|
|
64
|
-
"type": "string"
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"required": [
|
|
68
|
-
"license_url",
|
|
69
|
-
"copyright_url",
|
|
70
|
-
"privacy_policy_url",
|
|
71
|
-
"website"
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
"media": {
|
|
75
|
-
"type": "array",
|
|
76
|
-
"items": [
|
|
77
|
-
{
|
|
78
|
-
"type": "object",
|
|
79
|
-
"properties": {
|
|
80
|
-
"purpose": {
|
|
81
|
-
"type": "string"
|
|
82
|
-
},
|
|
83
|
-
"uri": {
|
|
84
|
-
"type": "string"
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
"required": ["purpose", "uri"]
|
|
88
|
-
}
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
"required": ["name", "android_package", "urls", "media"]
|
|
93
|
-
},
|
|
94
|
-
"release": {
|
|
95
|
-
"type": "object",
|
|
96
|
-
"properties": {
|
|
97
|
-
"address": {
|
|
98
|
-
"type": "string"
|
|
99
|
-
},
|
|
100
|
-
"media": {
|
|
101
|
-
"type": "array",
|
|
102
|
-
"items": [
|
|
103
|
-
{
|
|
104
|
-
"type": "object",
|
|
105
|
-
"properties": {
|
|
106
|
-
"purpose": {
|
|
107
|
-
"type": "string"
|
|
108
|
-
},
|
|
109
|
-
"uri": {
|
|
110
|
-
"type": "string"
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
"required": ["purpose", "uri"]
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
},
|
|
117
|
-
"files": {
|
|
118
|
-
"type": "array",
|
|
119
|
-
"minItems": 1,
|
|
120
|
-
"contains": {
|
|
121
|
-
"type": "object",
|
|
122
|
-
"properties": {
|
|
123
|
-
"purpose": {
|
|
124
|
-
"type": "string",
|
|
125
|
-
"const": "install"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
"items": [
|
|
130
|
-
{
|
|
131
|
-
"type": "object",
|
|
132
|
-
"properties": {
|
|
133
|
-
"purpose": {
|
|
134
|
-
"type": "string"
|
|
135
|
-
},
|
|
136
|
-
"uri": {
|
|
137
|
-
"type": "string"
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
"required": ["purpose", "uri"]
|
|
141
|
-
}
|
|
142
|
-
]
|
|
143
|
-
},
|
|
144
|
-
"catalog": {
|
|
145
|
-
"type": "object",
|
|
146
|
-
"patternProperties": {
|
|
147
|
-
"^[a-zA-Z]{2,8}(-[a-zA-Z0-9]{2,8})*$": {
|
|
148
|
-
"type": "object",
|
|
149
|
-
"properties": {
|
|
150
|
-
"name": {
|
|
151
|
-
"type": "string"
|
|
152
|
-
},
|
|
153
|
-
"long_description": {
|
|
154
|
-
"type": "string"
|
|
155
|
-
},
|
|
156
|
-
"new_in_version": {
|
|
157
|
-
"type": "string"
|
|
158
|
-
},
|
|
159
|
-
"saga_features": {
|
|
160
|
-
"type": "string"
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
"required": [
|
|
164
|
-
"name",
|
|
165
|
-
"long_description",
|
|
166
|
-
"new_in_version",
|
|
167
|
-
"saga_features"
|
|
168
|
-
]
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
"additionalProperties": false
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
"required": ["media", "files", "catalog"]
|
|
175
|
-
},
|
|
176
|
-
"solana_mobile_dapp_publisher_portal": {
|
|
177
|
-
"type": "object",
|
|
178
|
-
"properties": {
|
|
179
|
-
"google_store_package": {
|
|
180
|
-
"type": "string"
|
|
181
|
-
},
|
|
182
|
-
"testing_instructions": {
|
|
183
|
-
"type": "string"
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
"required": ["testing_instructions"]
|
|
187
|
-
}
|
|
188
|
-
},
|
|
189
|
-
"required": [
|
|
190
|
-
"publisher",
|
|
191
|
-
"app",
|
|
192
|
-
"release",
|
|
193
|
-
"solana_mobile_dapp_publisher_portal"
|
|
194
|
-
]
|
|
195
|
-
}
|