pakasso-export 1.0.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/bin/index.js +80 -0
- package/package.json +41 -0
package/bin/index.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import ora from 'ora';
|
|
3
|
+
import AdmZip from 'adm-zip';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { writeFileSync, mkdirSync, existsSync } from 'fs';
|
|
6
|
+
import { join, dirname } from 'path';
|
|
7
|
+
const API_BASE = process.env.PAKASSO_API_URL || 'https://api.pakasso-ai.com/api';
|
|
8
|
+
async function main() {
|
|
9
|
+
const exportId = process.argv[2];
|
|
10
|
+
if (!exportId || exportId === '--help' || exportId === '-h') {
|
|
11
|
+
console.log('');
|
|
12
|
+
console.log(chalk.bold('pakasso-export') + ' — Download your Pakasso design project');
|
|
13
|
+
console.log('');
|
|
14
|
+
console.log(chalk.dim('Usage:'));
|
|
15
|
+
console.log(' npx pakasso-export <export-id>');
|
|
16
|
+
console.log('');
|
|
17
|
+
console.log(chalk.dim('Example:'));
|
|
18
|
+
console.log(' npx pakasso-export abc123def456');
|
|
19
|
+
console.log('');
|
|
20
|
+
console.log(chalk.dim('This will create a ./Design-From-Pakasso/ folder with your project.'));
|
|
21
|
+
console.log('');
|
|
22
|
+
process.exit(exportId ? 0 : 1);
|
|
23
|
+
}
|
|
24
|
+
const outputDir = join(process.cwd(), 'Design-From-Pakasso');
|
|
25
|
+
if (existsSync(outputDir)) {
|
|
26
|
+
console.error(chalk.red('Error: ') +
|
|
27
|
+
chalk.yellow('Design-From-Pakasso/') +
|
|
28
|
+
' already exists in this directory.');
|
|
29
|
+
console.error(chalk.dim('Remove or rename it before running this command again.'));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
const spinner = ora('Downloading project from Pakasso...').start();
|
|
33
|
+
try {
|
|
34
|
+
// 1. Download ZIP
|
|
35
|
+
const url = `${API_BASE}/public-export/${exportId}`;
|
|
36
|
+
const response = await fetch(url);
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
if (response.status === 404) {
|
|
39
|
+
spinner.fail('Export not found. Check your export ID and try again.');
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
spinner.fail(`Download failed (HTTP ${response.status})`);
|
|
43
|
+
}
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
spinner.text = 'Extracting files...';
|
|
47
|
+
// 2. Read response as buffer
|
|
48
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
49
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
50
|
+
// 3. Extract ZIP
|
|
51
|
+
const zip = new AdmZip(buffer);
|
|
52
|
+
const entries = zip.getEntries();
|
|
53
|
+
mkdirSync(outputDir, { recursive: true });
|
|
54
|
+
let fileCount = 0;
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
if (entry.isDirectory) {
|
|
57
|
+
mkdirSync(join(outputDir, entry.entryName), { recursive: true });
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const filePath = join(outputDir, entry.entryName);
|
|
61
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
62
|
+
writeFileSync(filePath, entry.getData());
|
|
63
|
+
fileCount++;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
spinner.succeed(chalk.green(`${fileCount} files extracted to ./Design-From-Pakasso/`));
|
|
67
|
+
console.log('');
|
|
68
|
+
console.log(chalk.bold('Next steps:'));
|
|
69
|
+
console.log(chalk.cyan(' cd Design-From-Pakasso'));
|
|
70
|
+
console.log(chalk.cyan(' npm install'));
|
|
71
|
+
console.log(chalk.cyan(' npm run dev'));
|
|
72
|
+
console.log('');
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
spinner.fail('Failed to download or extract project');
|
|
76
|
+
console.error(chalk.red(error instanceof Error ? error.message : String(error)));
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pakasso-export",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Download your Pakasso design project to use locally",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"pakasso-export": "bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"ora": "^8.1.1",
|
|
18
|
+
"adm-zip": "^0.5.16",
|
|
19
|
+
"chalk": "^5.4.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/adm-zip": "^0.5.7",
|
|
23
|
+
"@types/node": "^22.0.0",
|
|
24
|
+
"typescript": "^5.7.0"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18.0.0"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"pakasso",
|
|
31
|
+
"design",
|
|
32
|
+
"export",
|
|
33
|
+
"react",
|
|
34
|
+
"components"
|
|
35
|
+
],
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/pakasso/pakasso-export.git"
|
|
40
|
+
}
|
|
41
|
+
}
|