@@ -36,11 +36,17 @@ Download: https://stackblitz.zip/edit/nuxt-starter-k7spa3r4
3636## CLI
3737
3838``` bash
39- # download a project
39+ # download a project as a zip file
4040npx stackblitz-zip https://stackblitz.com/edit/nuxt-starter-k7spa3r4
4141
42- # specify output path
42+ # specify output path for zip
4343npx stackblitz-zip https://stackblitz.com/edit/nuxt-starter-k7spa3r4 my-project.zip
44+
45+ # clone project to a directory
46+ npx stackblitz-clone https://stackblitz.com/edit/nuxt-starter-k7spa3r4
47+
48+ # clone to a specific directory
49+ npx stackblitz-clone https://stackblitz.com/edit/nuxt-starter-k7spa3r4 ./my-project
4450```
4551
4652## Programmatic Usage
@@ -54,9 +60,9 @@ npm install stackblitz-zip
5460### Node.js
5561
5662``` typescript
57- import { downloadToFile , parseUrl } from ' stackblitz-zip'
63+ import { cloneProject , downloadToFile , parseUrl } from ' stackblitz-zip'
5864
59- // download from a URL
65+ // download from a URL as a zip file
6066const projectId = parseUrl (' https://stackblitz.com/edit/nuxt-starter-k7spa3r4' )
6167await downloadToFile ({ projectId , outputPath: ' ./output.zip' })
6268
@@ -65,6 +71,12 @@ await downloadToFile({
6571 projectId: ' nuxt-starter-k7spa3r4' ,
6672 outputPath: ' ./my-project.zip' ,
6773})
74+
75+ // clone project to a directory
76+ await cloneProject ({
77+ projectId: ' nuxt-starter-k7spa3r4' ,
78+ outputPath: ' ./my-project' ,
79+ })
6880```
6981
7082### Web APIs
@@ -140,6 +152,20 @@ Downloads a StackBlitz project and returns the path to the created zip file.
140152- ` maxTotalSize ` (number, optional): Maximum total project size in bytes. Defaults to ` 104857600 ` (100MB)
141153- ` verbose ` (boolean, optional): Enable console logging. Defaults to ` false `
142154
155+ ### ` cloneProject(options: CloneOptions): Promise<string> `
156+
157+ Clones a StackBlitz project by creating all files in a target directory.
158+
159+ ** Options:**
160+ - ` projectId ` (string, required): The StackBlitz project ID
161+ - ` outputPath ` (string, optional): Path where the project directory should be created. Defaults to ` <project-id>/ `
162+ - ` timeout ` (number, optional): Timeout in milliseconds for loading the project. Defaults to ` 30000 ` (30 seconds)
163+ - ` maxFileSize ` (number, optional): Maximum size per file in bytes. Defaults to ` 10485760 ` (10MB)
164+ - ` maxTotalSize ` (number, optional): Maximum total project size in bytes. Defaults to ` 104857600 ` (100MB)
165+ - ` verbose ` (boolean, optional): Enable console logging. Defaults to ` false `
166+
167+ ** Returns:** Path to the created directory
168+
143169### ` downloadToResponse(options): Promise<Response> `
144170
145171Downloads a StackBlitz project and returns it as a Web Response (universal).
0 commit comments