|
2 | 2 | title: Weaverse CLI |
3 | 3 | description: The Weaverse CLI facilitates tasks such as project setup, theme scaffolding, and other common developer operations. |
4 | 4 | publishedAt: November 20, 2023 |
5 | | -updatedAt: January 17, 2024 |
| 5 | +updatedAt: July 20, 2024 |
6 | 6 | order: 0 |
7 | 7 | published: true |
8 | 8 | --- |
9 | 9 |
|
10 | 10 | For developers crafting Weaverse Hydrogen themes, the Weaverse CLI is a simple yet powerful aid, streamlining project |
11 | 11 | setup and management tasks directly from the command line. |
12 | 12 |
|
13 | | -## Usage |
| 13 | +## Installation & Usage |
14 | 14 |
|
15 | | -You can run it directly using **`npx`** to ensure you're always using the latest version: |
| 15 | +You can run the CLI directly using **`npx`** to ensure you're always using the latest version: |
16 | 16 |
|
17 | 17 | ```txt data-line-numbers=false |
18 | 18 | npx @weaverse/cli@latest [command] |
19 | 19 | ``` |
20 | 20 |
|
21 | | -## Commands |
| 21 | +To view available commands and options: |
22 | 22 |
|
23 | | -#### `create` |
| 23 | +```txt data-line-numbers=false |
| 24 | +npx @weaverse/cli@latest --help |
| 25 | +``` |
| 26 | + |
| 27 | +## Available Commands |
| 28 | + |
| 29 | +### `create` |
| 30 | + |
| 31 | +The `create` command is essential for starting new Weaverse Hydrogen projects. It: |
| 32 | + |
| 33 | +- Creates a new project directory |
| 34 | +- Downloads and extracts the selected template |
| 35 | +- Sets up environment variables |
| 36 | +- Installs necessary dependencies (optional) |
| 37 | +- Starts the development server (optional) |
| 38 | + |
| 39 | +#### Available Templates |
24 | 40 |
|
25 | | -The \`create\` command in the Weaverse CLI is essential for starting new Weaverse Hydrogen projects. It creates a new |
26 | | -project directory, sets it up with a basic template, and installs necessary dependencies. After setting up, it |
27 | | -initializes the project and starts the development server, making sure your project is ready for development |
28 | | -immediately. |
| 41 | +Weaverse CLI currently supports the following templates: |
29 | 42 |
|
30 | | -**Options** |
| 43 | +| Template | Description | |
| 44 | +| --- | --- | |
| 45 | +| **pilot** | A modern and clean template for your Weaverse store | |
| 46 | +| **naturelle** | A beautiful and elegant template for your Weaverse store | |
31 | 47 |
|
32 | | -- **`--template`**: Specifies the template to be used when creating the project. Currently, the only supported template |
33 | | - is **`'pilot'`**. |
| 48 | +#### Options |
34 | 49 |
|
35 | | -- **`--project-id`**: This is the unique identifier for your project, which should correspond with the project ID in the |
36 | | - Weaverse app. |
| 50 | +| Option | Description | Required | Default | |
| 51 | +| --- | --- | --- | --- | |
| 52 | +| **`--template`** | Template name (`pilot` or `naturelle`) | Yes | - | |
| 53 | +| **`--project-id`** | Your Weaverse project ID | Yes | - | |
| 54 | +| **`--project-name`** | Name for your project directory | No | my-weaverse-hydrogen-project | |
| 55 | +| **`--commit`** | Specific Git commit hash to use | No | Latest from main branch | |
| 56 | +| **`--no-install`** | Skip dependency installation and dev server start | No | false | |
37 | 57 |
|
38 | | -- **`--project-name`**: Defines the name of your project, used as the directory name and within configuration files. |
| 58 | +#### Usage Examples |
39 | 59 |
|
40 | | -**Usage** |
| 60 | +**Basic usage with the Pilot template:** |
41 | 61 |
|
42 | | -To create a new project, you would use a command like this: |
| 62 | +```txt data-line-numbers=false |
| 63 | +npx @weaverse/cli@latest create --template=pilot --project-id=clocwvm3y08j2r79n3c44uhjh --project-name=my-store |
| 64 | +``` |
| 65 | + |
| 66 | +**Using the Naturelle template:** |
43 | 67 |
|
44 | 68 | ```txt data-line-numbers=false |
45 | | -npx @weaverse/cli@latest create --template=pilot --project-id=clocwvm3y08j2r79n3c44uhjh --project-name=my-hydrogen-storefront |
| 69 | +npx @weaverse/cli@latest create --template=naturelle --project-id=clocwvm3y08j2r79n3c44uhjh --project-name=naturelle-store |
46 | 70 | ``` |
47 | 71 |
|
48 | | -**Best Practices** |
| 72 | +**Using a specific commit version:** |
49 | 73 |
|
50 | | -It is recommended to create your project within the Weaverse app first. Doing so will allow you to copy the full |
51 | | -command, complete with the project ID and project name, ensuring accuracy. |
| 74 | +```txt data-line-numbers=false |
| 75 | +npx @weaverse/cli@latest create --template=pilot --project-id=clocwvm3y08j2r79n3c44uhjh --commit=a1b2c3d4 |
| 76 | +``` |
| 77 | + |
| 78 | +**Creating project without installing dependencies:** |
| 79 | + |
| 80 | +```txt data-line-numbers=false |
| 81 | +npx @weaverse/cli@latest create --template=pilot --project-id=clocwvm3y08j2r79n3c44uhjh --no-install |
| 82 | +``` |
| 83 | + |
| 84 | +## Workflow |
| 85 | + |
| 86 | +When you run the `create` command, the CLI will: |
| 87 | + |
| 88 | +1. Download the selected template from GitHub |
| 89 | +2. Extract the template to your specified project directory |
| 90 | +3. Configure environment variables (including your Weaverse project ID) |
| 91 | +4. Install dependencies using npm (unless `--no-install` is specified) |
| 92 | +5. Start the development server (unless `--no-install` is specified) |
| 93 | + |
| 94 | +After completion, you'll see instructions for the next steps to take. |
| 95 | + |
| 96 | +## Best Practices |
| 97 | + |
| 98 | +It is recommended to create your project within the Weaverse app first. Doing so will allow you to copy the |
| 99 | +full command, complete with the project ID and project name, ensuring accuracy. |
52 | 100 |
|
53 | 101 |  |
| 102 | + |
| 103 | +## Troubleshooting |
| 104 | + |
| 105 | +### Common Issues |
| 106 | + |
| 107 | +**Template Download Fails** |
| 108 | +- Check your internet connection |
| 109 | +- Verify that the specified commit hash is valid (if using `--commit`) |
| 110 | +- Try again with the default template without specifying a commit |
| 111 | + |
| 112 | +**Dependency Installation Fails** |
| 113 | +- Try running `npm install --legacy-peer-deps` manually in the project directory |
| 114 | +- Ensure you have the latest version of Node.js installed (v16+) |
| 115 | +- Check for errors in your project's package.json |
| 116 | + |
| 117 | +**Development Server Won't Start** |
| 118 | +- Make sure all required environment variables are set |
| 119 | +- Check that you've pulled Shopify environment variables with `npx shopify hydrogen env pull` |
| 120 | +- Verify port 3456 is available on your system |
0 commit comments