Skip to content

Commit fd1f8ca

Browse files
committed
include marketpack
1 parent 01287d6 commit fd1f8ca

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ lerna-debug.log*
1010
node_modules
1111
dist
1212
dist-ssr
13+
publish
1314
*.local
1415

1516
# Editor directories and files

bun.lockb

1.45 KB
Binary file not shown.

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "vue-tsc -b && vite build",
9-
"preview": "vite preview"
9+
"preview": "vite preview",
10+
"prepare-marketplace": "tsx ./scripts/market-pack.cts"
1011
},
1112
"dependencies": {
1213
"@paralleldrive/cuid2": "^2.2.2",
@@ -20,7 +21,9 @@
2021
"@types/lodash": "^4.17.6",
2122
"@types/node": "^20.14.9",
2223
"@vitejs/plugin-vue": "^5.0.5",
24+
"adm-zip": "^0.5.14",
2325
"sass": "^1.77.6",
26+
"tsx": "^4.16.5",
2427
"typescript": "^5.2.2",
2528
"unplugin-auto-import": "^0.17.6",
2629
"vite": "^5.3.1",

scripts/market-pack.cts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import AdmZip from 'adm-zip';
2+
import fs from 'fs';
3+
import path from 'path';
4+
import { execSync } from 'child_process';
5+
6+
(async () => {
7+
8+
const { identifier } = (await import('../src/plugin.config')).default;
9+
10+
// check that identifier has valid naming scheme, only lowercase letters, digits, dots and dashes
11+
if (!/^[a-z0-9.-]+$/.test(identifier)) {
12+
throw new Error(`Invalid identifier: ${identifier}`);
13+
}
14+
15+
// run npm run build
16+
execSync('npm run build');
17+
18+
// The file that will be sent to the marketplace
19+
const publishDir = path.resolve(__dirname, '../publish');
20+
// create a release dir if not exists and remove all files
21+
if (!fs.existsSync(publishDir)) {
22+
fs.mkdirSync(publishDir);
23+
} else {
24+
fs.rmSync(publishDir, { recursive: true });
25+
fs.mkdirSync(publishDir);
26+
}
27+
28+
const distDir = path.resolve(__dirname, '../dist');
29+
const buildContentDir = path.resolve(__dirname, '../dist');
30+
31+
// make a publish dir
32+
if (!fs.existsSync(buildContentDir)) {
33+
fs.mkdirSync(buildContentDir);
34+
}
35+
36+
// write content of in dist/ to the root of the zip
37+
const zip = new AdmZip();
38+
zip.addLocalFolder(distDir);
39+
zip.writeZip(path.resolve(publishDir, `${identifier}.zip`));
40+
41+
})()

0 commit comments

Comments
 (0)