@powerhousedao/academy 2.5.0-dev.2 → 2.5.0-dev.21
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/CHANGELOG.md +124 -0
- package/docs/academy/01-GetStarted/00-ExploreDemoPackage.md +18 -10
- package/docs/academy/01-GetStarted/01-CreateNewPowerhouseProject.md +36 -39
- package/docs/academy/01-GetStarted/02-DefineToDoListDocumentModel.md +21 -6
- package/docs/academy/01-GetStarted/03-ImplementOperationReducers.md +5 -0
- package/docs/academy/01-GetStarted/04-BuildToDoListEditor.md +148 -420
- package/docs/academy/01-GetStarted/_04-BuildToDoListEditor +495 -0
- package/docs/academy/01-GetStarted/home.mdx +15 -15
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/01-WhatIsADocumentModel.md +11 -2
- package/docs/academy/02-MasteryTrack/02-DocumentModelCreation/02-SpecifyTheStateSchema.md +5 -0
- package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/01-BuildingDocumentEditors.md +5 -37
- package/docs/academy/02-MasteryTrack/05-Launch/02-PublishYourProject.md +70 -5
- package/docs/academy/02-MasteryTrack/05-Launch/03-SetupEnvironment.md +159 -73
- package/docs/academy/02-MasteryTrack/05-Launch/{03-RunOnACloudServer.md → _03-RunOnACloudServer} +8 -5
- package/docs/academy/04-APIReferences/00-PowerhouseCLI.md +7 -40
- package/docs/academy/06-ComponentLibrary/00-DocumentEngineering.md +67 -21
- package/docs/academy/06-ComponentLibrary/02-CreateCustomScalars.md +403 -0
- package/docs/academy/06-ComponentLibrary/{02-BuildingWithScalars.md → 02-ScalarComponent.mdx} +10 -12
- package/docs/academy/06-ComponentLibrary/{04-Complex-Components/01-sidebar.mdx → 03-ComplexComponent.mdx} +3 -1
- package/docs/academy/06-ComponentLibrary/03-IntegrateIntoAReactComponent.md +1 -0
- package/docs/academy/06-ComponentLibrary/04-LayoutComponent.mdx +5 -0
- package/docs/academy/06-ComponentLibrary/05-FragmentsComponent.mdx +5 -0
- package/docs/academy/07-Cookbook.md +0 -4
- package/docs/academy/08-Glossary.md +4 -1
- package/docs/academy/09-AIResources +23 -0
- package/package.json +1 -1
- package/sidebars.ts +6 -45
- package/docs/academy/06-ComponentLibrary/03-Scalar-Components/01-phid-field.mdx +0 -72
- package/docs/academy/06-ComponentLibrary/03-Scalar-Components/02-input-field.mdx +0 -0
- package/docs/academy/06-ComponentLibrary/05-Layout-Components/01-test-toupdate.mdx +0 -61
- package/docs/academy/06-ComponentLibrary/06-Fragments/01-test-toupdate.mdx +0 -61
- /package/docs/academy/02-MasteryTrack/05-Launch/{02-IntroductionToPackages.md → 01-IntroductionToPackages.md} +0 -0
- /package/docs/academy/02-MasteryTrack/05-Launch/{00-IntegrateInAFront-End → _00-IntegrateInAFront-End} +0 -0
- /package/docs/academy/02-MasteryTrack/05-Launch/{01-IntroducingFusion → _01-IntroducingFusion} +0 -0
- /package/docs/academy/02-MasteryTrack/05-Launch/{04-GraphQLNamespacing → _04-GraphQLNamespacing} +0 -0
- /package/docs/academy/02-MasteryTrack/05-Launch/{05-LaunchYourBackend.md → _05-LaunchYourBackend} +0 -0
- /package/docs/academy/02-MasteryTrack/05-Launch/{06-LaunchYourFrontend.md → _06-LaunchYourFrontend} +0 -0
- /package/docs/academy/04-APIReferences/{01-ReactHooks.md → 01-ReactHooks} +0 -0
- /package/docs/academy/04-APIReferences/{02-ReactorAPI.md → 02-ReactorAPI} +0 -0
- /package/docs/academy/04-APIReferences/{03-Configuration.md → 03-Configuration} +0 -0
package/docs/academy/02-MasteryTrack/03-BuildingUserExperiences/01-BuildingDocumentEditors.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Build Document Editors
|
|
1
|
+
# Build Document Editors (WIP)
|
|
2
2
|
|
|
3
3
|
## Build with React on Powerhouse
|
|
4
4
|
|
|
@@ -6,7 +6,8 @@ At Powerhouse, frontend development for document editors follows a simple and fa
|
|
|
6
6
|
|
|
7
7
|
### Development Environment
|
|
8
8
|
|
|
9
|
-
Connect Studio is your primary tool for development.
|
|
9
|
+
Connect Studio is your primary tool for development.
|
|
10
|
+
When you run `ph connect`, it provides a dynamic, local environment where you can define and preview your document models and their editors live. This replaces the need for tools like Storybook for editor development, though Storybook remains invaluable for exploring the [Powerhouse Component Library](#powerhouse-component-library).
|
|
10
11
|
|
|
11
12
|
Key aspects of the Powerhouse development environment:
|
|
12
13
|
- **React Foundation**: Build your editor UIs using React components, just as you would in any standard React project.
|
|
@@ -20,7 +21,8 @@ Powerhouse aims to keep your developer experience clean, familiar, and focused:
|
|
|
20
21
|
|
|
21
22
|
### Generating Your Editor Template
|
|
22
23
|
|
|
23
|
-
To kickstart your editor development, Powerhouse provides a command to generate a basic editor template. This command reads your document model
|
|
24
|
+
To kickstart your editor development, Powerhouse provides a command to generate a basic editor template. This command reads your document model specifications and creates the initial `editor.tsx` file.
|
|
25
|
+
If you want a refresher on how to define your document model specification please read the chapter on [specifying the State Schema](/academy/MasteryTrack/DocumentModelCreation/SpecifyTheStateSchema)
|
|
24
26
|
|
|
25
27
|
For example, to generate an editor for a `ToDoList` document model with a document type `powerhouse/todolist`:
|
|
26
28
|
```bash
|
|
@@ -72,40 +74,6 @@ You have several options for styling your editor components:
|
|
|
72
74
|
|
|
73
75
|
Choose the method or combination of methods that best suits your project needs and team preferences. Connect Studio (`ph connect`) will allow you to see your styles applied in real-time.
|
|
74
76
|
|
|
75
|
-
<details>
|
|
76
|
-
<summary>Refresher on React Hooks</summary>
|
|
77
|
-
|
|
78
|
-
All of the Powerhouse React Hooks can be found here: [Powerhouse React Hooks API Reference](docs/academy/APIReferences/ReactHooks)
|
|
79
|
-
|
|
80
|
-
React Hooks allow you to use various React features directly within your functional components. You can use built-in Hooks or combine them to create your own custom Hooks.
|
|
81
|
-
|
|
82
|
-
**What are Custom Hooks?**
|
|
83
|
-
A custom hook is a JavaScript function whose name starts with "use" and that calls other Hooks. They are used to:
|
|
84
|
-
- Reuse stateful logic between components.
|
|
85
|
-
- Abstract complex logic into a simpler interface.
|
|
86
|
-
- Isolate side effects, particularly those managed by `useEffect`.
|
|
87
|
-
|
|
88
|
-
**Key Built-in Hooks Examples:**
|
|
89
|
-
- `useState`: Lets a component "remember" information (state).
|
|
90
|
-
- `useEffect`: Lets a component perform side effects (e.g., data fetching, subscriptions, manually changing the DOM).
|
|
91
|
-
- `useContext`: Lets a component receive information from distant parent components without explicitly passing props through every level of the component tree.
|
|
92
|
-
|
|
93
|
-
**Naming Convention:**
|
|
94
|
-
Hook names must always start with `use` followed by a capital letter (e.g., `useState`, `useOnlineStatus`).
|
|
95
|
-
|
|
96
|
-
**Rules of Hooks:**
|
|
97
|
-
1. **Only Call Hooks at the Top Level**: Don't call Hooks inside loops, conditions, or nested functions.
|
|
98
|
-
2. **Only Call Hooks from React Functions**: Call Hooks from React functional components or from custom Hooks.
|
|
99
|
-
|
|
100
|
-
It's important to note that a function should only be named and treated as a hook if it actually utilizes one or more built-in React hooks. If a function (even if named `useSomething`) doesn't call any built-in hooks, it behaves like a regular JavaScript function, and making it a "hook" offers no specific React advantages.
|
|
101
|
-
|
|
102
|
-
For more details, see the official documentation and our API reference:
|
|
103
|
-
- [Reusing Logic with Custom Hooks (react.dev)](https://react.dev/learn/reusing-logic-with-custom-hooks)
|
|
104
|
-
- [Rules of Hooks (react.dev)](https://react.dev/reference/rules/rules-of-hooks)
|
|
105
|
-
- [Powerhouse React Hooks API Reference](docs/academy/APIReferences/ReactHooks)
|
|
106
|
-
|
|
107
|
-
</details>
|
|
108
|
-
|
|
109
77
|
### State Management in Editors
|
|
110
78
|
|
|
111
79
|
When you build an editor in Powerhouse, your main editor component receives `EditorProps`. These props are crucial for interacting with the document:
|
|
@@ -145,9 +145,10 @@ This command will **build** the project and create a build directory with the ou
|
|
|
145
145
|
|
|
146
146
|
This command will **start a local server** and serve the build output.
|
|
147
147
|
Inspect the build output and verify that the document models are working correctly.
|
|
148
|
+
Instead of `pnpm serve`, we'll be using:
|
|
148
149
|
|
|
149
150
|
```bash
|
|
150
|
-
|
|
151
|
+
ph connect
|
|
151
152
|
```
|
|
152
153
|
|
|
153
154
|
### 1.4 Storing your project in a git repository
|
|
@@ -202,15 +203,79 @@ If you're publishing a package under a scope (like @your-org/my-package), you mi
|
|
|
202
203
|
}
|
|
203
204
|
```
|
|
204
205
|
|
|
205
|
-
|
|
206
|
+
### 2.1 Versioning, Tagging, and Publishing Your Package
|
|
207
|
+
|
|
208
|
+
Before publishing, it's crucial to version your package correctly and tag the release in your Git repository. This helps track changes and allows users to depend on specific versions.
|
|
209
|
+
|
|
210
|
+
**1. Versioning with PNPM**
|
|
211
|
+
|
|
212
|
+
Use the `pnpm version` command to update your package version according to semantic versioning rules (`patch` for bugfixes, `minor` for new features, `major` for breaking changes). This command will:
|
|
213
|
+
- Update the `version` in your `package.json`.
|
|
214
|
+
- Create a Git commit for the version change.
|
|
215
|
+
- Create a Git tag for the new version (e.g., `v1.0.1`).
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# For a patch release (e.g., from 1.0.0 to 1.0.1)
|
|
219
|
+
pnpm version patch
|
|
220
|
+
|
|
221
|
+
# For a minor release (e.g., from 1.0.1 to 1.1.0)
|
|
222
|
+
pnpm version minor
|
|
223
|
+
|
|
224
|
+
# For a major release (e.g., from 1.1.0 to 2.0.0)
|
|
225
|
+
pnpm version major
|
|
226
|
+
```
|
|
227
|
+
Take note of the new version tag created (e.g., `v1.0.1`), as you'll need it in the next step.
|
|
228
|
+
|
|
229
|
+
**2. Pushing Changes to Git**
|
|
230
|
+
|
|
231
|
+
Next, push your commits and the new version tag to your remote Git repository:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Push your current branch (e.g., main or master)
|
|
235
|
+
# Replace 'main' with your default branch name if different
|
|
236
|
+
git push origin main
|
|
237
|
+
|
|
238
|
+
# Push the specific tag created by pnpm version
|
|
239
|
+
# Replace vX.Y.Z with the actual tag name (e.g., v1.0.1)
|
|
240
|
+
git push origin vX.Y.Z
|
|
241
|
+
```
|
|
242
|
+
The specific tag name (e.g., `v1.0.1`) is usually output by the `pnpm version` command. Pushing the specific tag is recommended to avoid unintentionally pushing other local tags.
|
|
243
|
+
|
|
244
|
+
Alternatively, to push all new local tags (use with caution):
|
|
245
|
+
```bash
|
|
246
|
+
# git push --tags
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
**3. Understanding Git Tags vs. NPM Distributor Tags**
|
|
250
|
+
|
|
251
|
+
It's important to distinguish between Git tags and NPM distributor tags (dist-tags):
|
|
252
|
+
|
|
253
|
+
- **Git Tags**: These are markers in your Git repository's history. They are primarily for developers to pinpoint specific release versions in the codebase (e.g., `v1.0.0`, `v1.0.1`). The `pnpm version` command creates these.
|
|
254
|
+
- **NPM Distributor Tags (dist-tags)**: These are labels used by the NPM registry to point to specific published versions of your package. Common NPM tags include:
|
|
255
|
+
- `latest`: This is the default tag. When someone runs `pnpm install my-package`, NPM installs the version tagged as `latest`.
|
|
256
|
+
- `beta`, `next`, `alpha`: Often used for pre-release versions.
|
|
257
|
+
When you publish a package without specifying an NPM tag, it usually gets the `latest` tag by default.
|
|
258
|
+
|
|
259
|
+
**4. Publishing to NPM**
|
|
260
|
+
|
|
261
|
+
Now you are ready to publish your package to the NPM registry. Ensure you are logged into NPM (the `npm login` command shown in previous steps should be used, or `pnpm login` which is an alias).
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
pnpm publish
|
|
265
|
+
```
|
|
266
|
+
This command will publish the version of your package that is currently specified in your `package.json`. By default, this will also set the `latest` NPM dist-tag for this version.
|
|
267
|
+
|
|
268
|
+
If your package is scoped (e.g., `@your-org/my-package`) and intended to be public, ensure your `package.json` includes the `publishConfig` shown earlier. If this is not set in `package.json` (and your package is scoped), you might need to use:
|
|
206
269
|
```bash
|
|
207
|
-
|
|
270
|
+
pnpm publish --access public
|
|
208
271
|
```
|
|
209
272
|
|
|
210
|
-
|
|
273
|
+
You can also publish a version to a specific NPM dist-tag. For example, to publish a beta version:
|
|
211
274
|
```bash
|
|
212
|
-
|
|
275
|
+
# Ensure your package.json version reflects the beta (e.g., 1.1.0-beta.0)
|
|
276
|
+
pnpm publish --tag beta
|
|
213
277
|
```
|
|
278
|
+
This is useful for testing releases before making them `latest`.
|
|
214
279
|
|
|
215
280
|
Now let's verify that the package(s) get published in the package repository, next to pre-existing packages that you might have been publishing before.
|
|
216
281
|
|
|
@@ -1,62 +1,23 @@
|
|
|
1
|
-
# Powerhouse Setup Guide
|
|
1
|
+
# Powerhouse Setup Guide
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
|
-
Powerhouse is a powerful platform that helps you manage and deploy your applications efficiently.
|
|
4
|
+
Powerhouse is a powerful platform that helps you manage and deploy your applications efficiently.
|
|
5
|
+
This guide will walk you through the process of setting up both the Powerhouse CLI and configuring your server machine to run Powerhouse services. Whether you're setting up a development environment or preparing for production deployment, this guide provides all the necessary steps and considerations.
|
|
5
6
|
|
|
6
7
|
## Prerequisites
|
|
7
|
-
Before you begin, ensure you have a Linux-based system (Ubuntu or Debian recommended), sudo privileges, and a stable internet connection.
|
|
8
|
+
Before you begin, ensure you have a Linux-based system (Ubuntu or Debian recommended), sudo privileges, and a stable internet connection.
|
|
9
|
+
These are essential for the installation and configuration process.
|
|
10
|
+
The system should have at least 1GB of RAM and 10GB of free disk space for optimal performance.
|
|
11
|
+
While these are minimum requirements, more resources will provide better performance, especially when running multiple services.
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
The `install` script provides a streamlined way to install the Powerhouse CLI tool and all its necessary dependencies. This script handles the installation of node.js 22, pnpm, Powerhouse CLI itself and the services. It's designed to work across different Linux distributions, though it's optimized for Ubuntu and Debian-based systems. It also prepares your machine for running Powerhouse services. It handles everything from package installation to service configuration, making the setup process straightforward and automated. This script is particularly useful for setting up new servers or reconfiguring existing ones.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
### Installation Steps:
|
|
15
|
-
1. Run the setup script:
|
|
16
|
-
```bash
|
|
17
|
-
curl -fsSL https://apps.powerhouse.io/install | bash # for macOS, Linux, and WSL
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
2. After installation, source your shell configuration:
|
|
21
|
-
```bash
|
|
22
|
-
source ~/.bashrc # or source ~/.zshrc if using zsh
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
3. Verify the installation:
|
|
26
|
-
```bash
|
|
27
|
-
ph --version
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
4. You will see ph-cli is not yet installed. But it will get installed automatically in the next step.
|
|
31
|
-
If you are a builder that wants to make use of the dev releases use `ph use dev` before going to the next step.
|
|
32
|
-
- `ph use dev`: Development version - Use this for testing new features or development work
|
|
33
|
-
- `ph use staging`: Staging version - Use this for pre-production testing
|
|
34
|
-
|
|
35
|
-
5. Follow the interactive prompts:
|
|
36
|
-
|
|
37
|
-
### Step 1: Package Installation
|
|
38
|
-
During the package installation phase, you'll be prompted to enter package names that you want to install. For example, you might want to install `@powerhousedao/todo-demo-package` or other Powerhouse packages. This step is crucial for adding the specific functionality you need to your Powerhouse installation. You can press Enter to skip this step if you don't need to install any packages immediately, but you can always install packages later using the `ph install` command.
|
|
39
|
-
|
|
40
|
-
### Step 2: Database Configuration
|
|
41
|
-
The script offers two options for database configuration.
|
|
42
|
-
|
|
43
|
-
**Option 1:** Sets up a local PostgreSQL database, which is ideal for development or small deployments. It automatically creates a database user with a secure random password and configures the database to accept local connections. This option is perfect for getting started quickly or for development environments.
|
|
44
|
-
|
|
45
|
-
**Option 2:** Allows you to connect to a remote PostgreSQL database by providing a connection URL in the format `postgres://user:password@host:port/db`. This is recommended for production environments where you might want to use a managed database service or a dedicated database server.
|
|
46
|
-
|
|
47
|
-
### Step 3: SSL Configuration
|
|
48
|
-
For SSL configuration, you have two choices.
|
|
49
|
-
|
|
50
|
-
**Option 1:** The **Let's Encrypt** option is recommended for production environments. It requires you to provide a base domain (like `powerhouse.xyz`) and optional subdomains for your services. The script will automatically obtain and configure SSL certificates for your domains, ensuring secure communication between your services and clients.
|
|
51
|
-
|
|
52
|
-
**Option 2:** The self-signed certificate option is suitable for development or testing environments. It uses your machine's hostname and generates a self-signed certificate, configuring the services with appropriate base paths. While this option is convenient for development, browsers will show security warnings, which is why it's not recommended for production use.
|
|
13
|
+
Also make sure you have your preferred domain registered and created subdomains for your Connect & Switchboard instances.
|
|
53
14
|
|
|
54
15
|
<details>
|
|
55
|
-
<summary
|
|
16
|
+
<summary>**Setting up a Droplet (Digital Ocean) instance and connecting your domain**</summary>
|
|
56
17
|
|
|
57
18
|
This tutorial will guide you through the process of creating a new virtual private server (called a "Droplet") on DigitalOcean and then pointing your custom domain name to it. This will allow users to access your server using a memorable URL like `www.yourdomain.com`.
|
|
58
19
|
|
|
59
|
-
**Current Date:** May 15,
|
|
20
|
+
**Current Date:** May 15, 2024
|
|
60
21
|
|
|
61
22
|
## Part 1: Setting Up Your DigitalOcean Droplet
|
|
62
23
|
|
|
@@ -156,6 +117,18 @@ Now your Droplet is running! Now you can continue with the Powerhouse tutorial o
|
|
|
156
117
|
- **WILL DIRECT TO:** Your Droplet's IP
|
|
157
118
|
- **TTL:** 3600
|
|
158
119
|
|
|
120
|
+
- **Connect Subdomain (A Record):**
|
|
121
|
+
- **TYPE:** A
|
|
122
|
+
- **HOSTNAME:** connect
|
|
123
|
+
- **WILL DIRECT TO:** Your Droplet's IP
|
|
124
|
+
- **TTL:** 3600
|
|
125
|
+
|
|
126
|
+
- **Switchboard Subdomain (A Record):**
|
|
127
|
+
- **TYPE:** A
|
|
128
|
+
- **HOSTNAME:** switchboard
|
|
129
|
+
- **WILL DIRECT TO:** Your Droplet's IP
|
|
130
|
+
- **TTL:** 3600
|
|
131
|
+
|
|
159
132
|
#### Option B: Using Your Existing Nameservers (NS locked)
|
|
160
133
|
|
|
161
134
|
1. **Just Create DNS Records at Your Registrar:**
|
|
@@ -171,6 +144,18 @@ Now your Droplet is running! Now you can continue with the Powerhouse tutorial o
|
|
|
171
144
|
- **VALUE:** Your Droplet's IP
|
|
172
145
|
- **TTL:** 3600
|
|
173
146
|
|
|
147
|
+
- **Connect Subdomain (A Record):**
|
|
148
|
+
- **TYPE:** A
|
|
149
|
+
- **HOSTNAME:** connect
|
|
150
|
+
- **VALUE:** Your Droplet's IP
|
|
151
|
+
- **TTL:** 3600
|
|
152
|
+
|
|
153
|
+
- **Switchboard Subdomain (A Record):**
|
|
154
|
+
- **TYPE:** A
|
|
155
|
+
- **HOSTNAME:** switchboard
|
|
156
|
+
- **VALUE:** Your Droplet's IP
|
|
157
|
+
- **TTL:** 3600
|
|
158
|
+
|
|
174
159
|
**Note:** DNS changes may take up to 48 hours to propagate globally.
|
|
175
160
|
|
|
176
161
|
### Verify Configuration
|
|
@@ -179,20 +164,43 @@ Now your Droplet is running! Now you can continue with the Powerhouse tutorial o
|
|
|
179
164
|
```bash
|
|
180
165
|
dig +short yourdomain.com
|
|
181
166
|
dig +short www.yourdomain.com
|
|
167
|
+
dig +short connect.yourdomain.com
|
|
168
|
+
dig +short switchboard.yourdomain.com
|
|
182
169
|
```
|
|
183
170
|
|
|
184
|
-
2.
|
|
171
|
+
2. All should return your Droplet's IP address
|
|
185
172
|
|
|
186
173
|
**Congratulations!** You have successfully set up your DigitalOcean Droplet and configured your domain. Your server is now ready to host your Powerhouse services.
|
|
187
174
|
|
|
188
175
|
</details>
|
|
189
176
|
|
|
190
177
|
<details>
|
|
191
|
-
<summary>Setting up
|
|
178
|
+
<summary> **Setting up an EC2 instance and connecting your domain** </summary>
|
|
192
179
|
|
|
193
180
|
This tutorial will guide you through the process of assigning a static IP (Elastic IP) to your EC2 instance and configuring your domain to point to it.
|
|
194
181
|
|
|
195
|
-
**Current Date:** May 15,
|
|
182
|
+
**Current Date:** May 15, 2024
|
|
183
|
+
|
|
184
|
+
- Make sure your region is set to eu-west-1 (Ireland)
|
|
185
|
+
- Name your instance something like `cloud-server` or your project's name
|
|
186
|
+
- Select Ubuntu 24.04 LTS
|
|
187
|
+
- Architecture 64-bit (x86)
|
|
188
|
+
- Scroll down to Instance type and select t2.medium (recommended)
|
|
189
|
+
- 2 vCPUs and 4 GiB of memory are the recommended minimum specs
|
|
190
|
+
- For larger projects or higher load, consider t2.large or t2.xlarge
|
|
191
|
+
- Create a new key pair and save it in a secure location from which you can connect to your instance with the SSH client later.
|
|
192
|
+
- Configure the security group to allow inbound traffic:
|
|
193
|
+
- SSH (Port 22) from your IP address
|
|
194
|
+
- HTTP (Port 80) from anywhere
|
|
195
|
+
- HTTPS (Port 443) from anywhere
|
|
196
|
+
- Custom TCP (Port 8442) for Connect
|
|
197
|
+
- Custom TCP (Port 8441) for Switchboard
|
|
198
|
+
- **Launch the instance**
|
|
199
|
+
|
|
200
|
+
:::warning
|
|
201
|
+
Make sure to keep your key pair file (.pem) secure and never share it. Without it, you won't be able to access your instance. Also, consider setting up AWS IAM roles and policies for better security management.
|
|
202
|
+
:::
|
|
203
|
+
|
|
196
204
|
|
|
197
205
|
## Part 1: Assigning a Static IP to EC2 Instance
|
|
198
206
|
|
|
@@ -247,6 +255,18 @@ This tutorial will guide you through the process of assigning a static IP (Elast
|
|
|
247
255
|
- **VALUE:** Your Elastic IP
|
|
248
256
|
- **TTL:** 3600
|
|
249
257
|
|
|
258
|
+
- **Connect Subdomain (A Record):**
|
|
259
|
+
- **TYPE:** A
|
|
260
|
+
- **HOSTNAME:** connect
|
|
261
|
+
- **VALUE:** Your Elastic IP
|
|
262
|
+
- **TTL:** 3600
|
|
263
|
+
|
|
264
|
+
- **Switchboard Subdomain (A Record):**
|
|
265
|
+
- **TYPE:** A
|
|
266
|
+
- **HOSTNAME:** switchboard
|
|
267
|
+
- **VALUE:** Your Elastic IP
|
|
268
|
+
- **TTL:** 3600
|
|
269
|
+
|
|
250
270
|
### Option B: Using Your Existing Nameservers
|
|
251
271
|
|
|
252
272
|
1. **Create DNS Records at Your Registrar:**
|
|
@@ -262,6 +282,18 @@ This tutorial will guide you through the process of assigning a static IP (Elast
|
|
|
262
282
|
- **VALUE:** Your Elastic IP
|
|
263
283
|
- **TTL:** 3600
|
|
264
284
|
|
|
285
|
+
- **Connect Subdomain (A Record):**
|
|
286
|
+
- **TYPE:** A
|
|
287
|
+
- **HOSTNAME:** connect
|
|
288
|
+
- **VALUE:** Your Elastic IP
|
|
289
|
+
- **TTL:** 3600
|
|
290
|
+
|
|
291
|
+
- **Switchboard Subdomain (A Record):**
|
|
292
|
+
- **TYPE:** A
|
|
293
|
+
- **HOSTNAME:** switchboard
|
|
294
|
+
- **VALUE:** Your Elastic IP
|
|
295
|
+
- **TTL:** 3600
|
|
296
|
+
|
|
265
297
|
1. **Set Up DNS First:**
|
|
266
298
|
- Create A records for all subdomains before running the setup script
|
|
267
299
|
- Point them to your EC2 instance's public IP address
|
|
@@ -273,27 +305,80 @@ This tutorial will guide you through the process of assigning a static IP (Elast
|
|
|
273
305
|
```bash
|
|
274
306
|
dig +short yourdomain.com
|
|
275
307
|
dig +short www.yourdomain.com
|
|
308
|
+
dig +short connect.yourdomain.com
|
|
309
|
+
dig +short switchboard.yourdomain.com
|
|
276
310
|
```
|
|
277
311
|
|
|
278
|
-
2.
|
|
312
|
+
2. All should return your Elastic IP address
|
|
279
313
|
|
|
280
314
|
**Congratulations!** You have successfully set up your EC2 instance with a static IP and configured your domain. Your server is now ready to host your Powerhouse services.
|
|
281
315
|
|
|
282
316
|
</details>
|
|
283
317
|
|
|
284
|
-
|
|
318
|
+
## 1. Setting up a new cloud environment
|
|
319
|
+
|
|
320
|
+
The `install` script provides a streamlined way to install the Powerhouse CLI tool and all its necessary dependencies. This script handles the installation of Node.js 22, pnpm, and the Powerhouse CLI itself. It's designed to work across different Linux distributions, though it's optimized for Ubuntu and Debian-based systems. It also prepares your machine for running Powerhouse services. It handles everything from package installation to service configuration, making the setup process straightforward and automated. This script is particularly useful for setting up new servers or reconfiguring existing ones.
|
|
321
|
+
|
|
322
|
+
### Installation
|
|
323
|
+
|
|
324
|
+
1. Run the setup script:
|
|
325
|
+
```bash
|
|
326
|
+
curl -fsSL https://apps.powerhouse.io/install | bash # for macOS, Linux, and WSL
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
2. After installation, source your shell configuration:
|
|
330
|
+
```bash
|
|
331
|
+
source ~/.bashrc # or source ~/.zshrc if using zsh
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
3. Verify that the Powerhouse CLI is ready to be installed in the next step:
|
|
335
|
+
```bash
|
|
336
|
+
ph --version
|
|
337
|
+
```
|
|
338
|
+
You will see that `ph-cli` is not yet installed. This is expected, as it will be installed by the service setup command.
|
|
339
|
+
|
|
340
|
+
4. Create a project with `ph-init <projectname>`. After creation, move into the project with `cd <projectname>`.
|
|
341
|
+
Up next is the configurations of your services.
|
|
342
|
+
|
|
343
|
+
### Service Configuration
|
|
344
|
+
|
|
345
|
+
Next, run `ph service setup` and follow the interactive prompts. This command installs the Powerhouse services (Connect and Switchboard) and guides you through their configuration.
|
|
346
|
+
|
|
347
|
+
:::info
|
|
348
|
+
**What does `ph service setup` do?**
|
|
349
|
+
The script takes care of all the necessary service configuration automatically.
|
|
350
|
+
It installs and configures **Nginx** as a reverse proxy, sets up SSL certificates, and configures the proxy settings for optimal performance.
|
|
351
|
+
It also installs **PM2** for process management and starts your services with the appropriate configuration based on your SSL choice.
|
|
352
|
+
The Nginx configuration includes optimizations for **WebSocket connections**, static file serving, and security headers.
|
|
353
|
+
PM2 is configured to automatically restart services if they crash and to start them on system boot.
|
|
354
|
+
:::
|
|
355
|
+
|
|
356
|
+
The setup command will prompt you for the following information:
|
|
357
|
+
|
|
358
|
+
#### Package Installation
|
|
359
|
+
During this phase, you can enter package names that you want to install. For example, you might want to `ph install @powerhousedao/todo-demo-package` or other Powerhouse packages. This step is crucial for adding the specific functionality you need. You can also press Enter to skip this step and install packages later using the `ph install` command.
|
|
360
|
+
|
|
361
|
+
#### Database Configuration
|
|
362
|
+
The script offers two options for database configuration:
|
|
363
|
+
* **Option 1: Local Database** Sets up a local PostgreSQL database, which is ideal for development or small deployments. It automatically creates a database user with a secure random password and configures the database to accept local connections. This option is perfect for getting started quickly.
|
|
364
|
+
* **Option 2: Remote Database** Allows you to connect to a remote PostgreSQL database by providing a connection URL in the format `postgres://user:password@host:port/db`. This is recommended for production environments.
|
|
285
365
|
|
|
286
|
-
|
|
366
|
+
#### SSL Configuration
|
|
367
|
+
For SSL configuration, you have two choices:
|
|
368
|
+
* **Option 1: Let's Encrypt (Recommended for Production)** This option requires you to provide a base domain (e.g., `powerhouse.xyz`) and subdomains for your services. The script will automatically obtain and configure SSL certificates for your domains.
|
|
369
|
+
* **Option 2: Self-signed Certificate** This is suitable for development or testing. It uses your machine's hostname and generates a self-signed certificate. Browsers will show security warnings with this option.
|
|
287
370
|
|
|
288
|
-
|
|
289
|
-
|
|
371
|
+
#### Domain Setup
|
|
372
|
+
You will be asked to enter your `connect` and `switchboard` subdomains to complete the setup. If you need more information, revisit the cloud provider setup sections at the beginning of this guide.
|
|
290
373
|
|
|
374
|
+
#### Security Features
|
|
375
|
+
Security is a top priority. The script implements automatic SSL certificate management, generates secure database passwords, and configures security headers in Nginx, and sets up proper proxy settings to support WebSocket connections securely.
|
|
291
376
|
|
|
292
|
-
##
|
|
377
|
+
## 2. Verifying the Setup
|
|
293
378
|
|
|
294
379
|
After the installation is complete, it's important to verify that everything is working correctly. You can check the status of your services using PM2, verify the Nginx configuration, and ensure your SSL certificates are properly installed. This step is crucial for identifying any potential issues before they affect your users.
|
|
295
380
|
|
|
296
|
-
1. Check service status of switchboard
|
|
381
|
+
1. Check service status of switchboard and connect:
|
|
297
382
|
```bash
|
|
298
383
|
ph service status
|
|
299
384
|
```
|
|
@@ -302,7 +387,7 @@ You can also use
|
|
|
302
387
|
```bash
|
|
303
388
|
ph service start | stop | restart
|
|
304
389
|
```
|
|
305
|
-
|
|
390
|
+
to start | stop | restart switchboard and connect
|
|
306
391
|
|
|
307
392
|
2. View Nginx configuration:
|
|
308
393
|
```bash
|
|
@@ -314,9 +399,10 @@ sudo nginx -t
|
|
|
314
399
|
sudo certbot certificates # if using Let's Encrypt
|
|
315
400
|
```
|
|
316
401
|
|
|
317
|
-
##
|
|
402
|
+
## 3. Accessing the Services
|
|
318
403
|
|
|
319
|
-
Once everything is set up, you can access your services through the configured domains.
|
|
404
|
+
Once everything is set up, you can access your services through the configured domains.
|
|
405
|
+
If you chose Let's Encrypt, your services will be available at their respective subdomains. With a self-signed certificate, you'll access the services through your machine's hostname with the appropriate base paths. The services are configured to use HTTPS by default, ensuring secure communication.
|
|
320
406
|
|
|
321
407
|
### With Let's Encrypt:
|
|
322
408
|
- Connect: `https://connect.yourdomain.com`
|
|
@@ -326,18 +412,18 @@ Once everything is set up, you can access your services through the configured d
|
|
|
326
412
|
- Connect: `https://your-hostname/connect`
|
|
327
413
|
- Switchboard: `https://your-hostname/switchboard`
|
|
328
414
|
|
|
329
|
-
##
|
|
415
|
+
## 4. Troubleshooting
|
|
330
416
|
|
|
331
417
|
When issues arise, there are several common problems you might encounter.
|
|
332
|
-
- The "ph
|
|
418
|
+
- The "`ph`: command not found" error usually means you need to source your shell configuration file.
|
|
333
419
|
- Nginx configuration errors can be investigated through the error logs, and service issues can be diagnosed using PM2 logs.
|
|
334
420
|
- SSL certificate problems often relate to DNS settings or certificate paths. Understanding these common issues and their solutions will help you maintain a stable Powerhouse installation.
|
|
335
421
|
|
|
336
422
|
### Common Issues:
|
|
337
|
-
1. **"ph
|
|
423
|
+
1. **"`ph`: command not found"**
|
|
338
424
|
- Run `source ~/.bashrc` or restart your terminal
|
|
339
|
-
- Verify that the PNPM_HOME environment variable is set correctly
|
|
340
|
-
- Check if the ph binary exists in the PNPM_HOME directory
|
|
425
|
+
- Verify that the `PNPM_HOME` environment variable is set correctly
|
|
426
|
+
- Check if the `ph` binary exists in the `PNPM_HOME` directory
|
|
341
427
|
|
|
342
428
|
2. **Nginx configuration errors**
|
|
343
429
|
- Check logs: `sudo tail -f /var/log/nginx/error.log`
|
|
@@ -354,7 +440,7 @@ When issues arise, there are several common problems you might encounter.
|
|
|
354
440
|
- Check certificate paths in Nginx config
|
|
355
441
|
- Ensure that the certificate files are readable by Nginx
|
|
356
442
|
|
|
357
|
-
##
|
|
443
|
+
## 5. Maintenance
|
|
358
444
|
|
|
359
445
|
Regular maintenance is crucial for keeping your Powerhouse installation running smoothly. You can update services using the Powerhouse CLI, restart services through PM2, and monitor logs to ensure everything is functioning correctly. Regular maintenance helps prevent issues and ensures that your services are running with the latest security patches and features.
|
|
360
446
|
|
|
@@ -368,16 +454,16 @@ ph update <package-name>
|
|
|
368
454
|
ph service restart
|
|
369
455
|
```
|
|
370
456
|
|
|
371
|
-
###
|
|
457
|
+
### Checking Service Status and Logs:
|
|
372
458
|
```bash
|
|
373
459
|
ph service status
|
|
374
460
|
```
|
|
375
461
|
|
|
376
|
-
##
|
|
462
|
+
## 6. Security Notes
|
|
377
463
|
|
|
378
464
|
Maintaining security is an ongoing process. It's essential to keep your database credentials secure and regularly update your SSL certificates. Regular monitoring of system logs helps identify potential security issues, and keeping your system and packages updated ensures you have the latest security patches. Consider implementing additional security measures such as firewall rules, intrusion detection systems, and regular security audits.
|
|
379
465
|
|
|
380
|
-
##
|
|
466
|
+
## 7. Backup
|
|
381
467
|
|
|
382
468
|
Regular backups are crucial for data safety. The database can be backed up using pg_dump, and your configuration files can be archived using tar. These backups should be stored securely and tested regularly to ensure they can be restored if needed. Consider implementing an automated backup schedule and storing backups in multiple locations for redundancy.
|
|
383
469
|
|
|
@@ -391,7 +477,7 @@ pg_dump -U powerhouse -d powerhouse > backup.sql
|
|
|
391
477
|
sudo tar -czf powerhouse-config.tar.gz /etc/powerhouse/
|
|
392
478
|
```
|
|
393
479
|
|
|
394
|
-
##
|
|
480
|
+
## 8. Best Practices
|
|
395
481
|
|
|
396
482
|
To get the most out of your Powerhouse installation, follow these best practices:
|
|
397
483
|
|
|
@@ -401,7 +487,7 @@ To get the most out of your Powerhouse installation, follow these best practices
|
|
|
401
487
|
4. **Testing**: Test your backup and restore procedures regularly.
|
|
402
488
|
5. **Security**: Regularly review and update your security measures.
|
|
403
489
|
|
|
404
|
-
##
|
|
490
|
+
## 9. Getting Help
|
|
405
491
|
|
|
406
492
|
If you encounter issues or need assistance, there are several resources available:
|
|
407
493
|
|
package/docs/academy/02-MasteryTrack/05-Launch/{03-RunOnACloudServer.md → _03-RunOnACloudServer}
RENAMED
|
@@ -17,7 +17,8 @@ Let's have a look at how to set up Connect & Switchboard apps on a cloud server.
|
|
|
17
17
|
Ask your IT provider to get access to the AWS environment to set up a server.
|
|
18
18
|
Launch a new server instance for Connect and Switchboard with the specific specs that fit your project.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
<details>
|
|
21
|
+
<summary> **The steps to create an EC2 instance** </summary>
|
|
21
22
|
- Make sure your region is set to eu-west-1 (Ireland)
|
|
22
23
|
- Name your instance something like `cloud-server` or your project's name
|
|
23
24
|
- Select Ubuntu 24.04 LTS
|
|
@@ -34,13 +35,15 @@ The steps to create an EC2 instance:
|
|
|
34
35
|
- Custom TCP (Port 8441) for Switchboard
|
|
35
36
|
- **Launch the instance**
|
|
36
37
|
|
|
38
|
+
:::warning
|
|
39
|
+
Make sure to keep your key pair file (.pem) secure and never share it. Without it, you won't be able to access your instance. Also, consider setting up AWS IAM roles and policies for better security management.
|
|
40
|
+
:::
|
|
41
|
+
|
|
42
|
+
</details>
|
|
43
|
+
|
|
37
44
|
Now click on your instance ID, which will open a new window with the instance details. Hit the 'Connect' button to get the connection details.
|
|
38
45
|
Within the instance details, you'll find the public IP address of your server instance. We'll use this to connect to our server instance later.
|
|
39
46
|
|
|
40
|
-
:::warning
|
|
41
|
-
Make sure to keep your key pair file (.pem) secure and never share it. Without it, you won't be able to access your instance. Also, consider setting up AWS IAM roles and policies for better security management.
|
|
42
|
-
:::
|
|
43
|
-
|
|
44
47
|
### 1.2. Setting up your SSH connection
|
|
45
48
|
|
|
46
49
|
Once you've generated your key pairs and added them to the designated folder, you can set up the SSH connections to start the process.
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
### Installing the Powerhouse CLI
|
|
4
4
|
:::tip
|
|
5
|
-
The **Powerhouse CLI tool** is the only essential tool to install on this page. Install it with the command below.
|
|
5
|
+
The **Powerhouse CLI tool** is the only essential tool to install on this page. Install it with the command below.
|
|
6
|
+
|
|
6
7
|
You can find all of the commands on this page, similar to what would displayed when using ph --help or ph *command* --help.
|
|
7
|
-
Use the table of content or the search function to find what you are looking for.
|
|
8
|
-
|
|
8
|
+
Use the table of content or the search function to find what you are looking for.
|
|
9
|
+
|
|
10
|
+
The Powerhouse CLI (`ph-cmd`) is a command-line interface tool that provides essential commands for managing Powerhouse projects. You can get access to the Powerhouse ecosystem tools by installing them globally.
|
|
9
11
|
|
|
10
12
|
```bash
|
|
11
13
|
pnpm install -g ph-cmd
|
|
@@ -208,7 +210,7 @@ Examples:
|
|
|
208
210
|
|
|
209
211
|
---
|
|
210
212
|
|
|
211
|
-
|
|
213
|
+
- [Connect Build](#connect-build)
|
|
212
214
|
- [Connect Preview](#connect-preview)
|
|
213
215
|
- [Connect Studio](#connect-studio)
|
|
214
216
|
- [Dev](#dev)
|
|
@@ -702,39 +704,4 @@ Notes:
|
|
|
702
704
|
|
|
703
705
|
---
|
|
704
706
|
|
|
705
|
-
*This document was automatically generated from the help text in the codebase
|
|
706
|
-
|
|
707
|
-
<details>
|
|
708
|
-
<summary> How to make use of different branches? </summary>
|
|
709
|
-
|
|
710
|
-
When installing or using the Powerhouse CLI commands you are able to make use of the dev & staging branches. These branches contain more experimental features then the latest stable release the PH CLI uses by default. They can be used to get access to a bugfix or features under development.
|
|
711
|
-
|
|
712
|
-
| Command | Description |
|
|
713
|
-
|---------|-------------|
|
|
714
|
-
| **pnpm install -g ph-cmd** | Install latest stable version |
|
|
715
|
-
| **pnpm install -g ph-cmd@dev** | Install development version |
|
|
716
|
-
| **pnpm install -g ph-cmd@staging** | Install staging version |
|
|
717
|
-
| **ph init** | Use latest stable version of the boilerplate |
|
|
718
|
-
| **ph init --dev** | Use development version of the boilerplate |
|
|
719
|
-
| **ph init --staging** | Use staging version of the boilerplate |
|
|
720
|
-
| **ph use** | Switch all dependencies to latest production versions |
|
|
721
|
-
| **ph use dev** | Switch all dependencies to development versions |
|
|
722
|
-
| **ph use prod** | Switch all dependencies to production versions |
|
|
723
|
-
|
|
724
|
-
Please be aware that these versions can contain bugs and experimental features that aren't fully tested.
|
|
725
|
-
</details>
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
the ph connect command now uses three subcommands:
|
|
729
|
-
|
|
730
|
-
studio (default) — runs connect studio. since this is the default argument, running ph connect still has the same behavior as before,
|
|
731
|
-
|
|
732
|
-
build — bundles the project's local and external model/editor code and injects the js/css into the already-built connect bundle for deployment,
|
|
733
|
-
|
|
734
|
-
preview — runs the vite preview server with the output of build for testing purposes,
|
|
735
|
-
|
|
736
|
-
running ph connect --help now lists the sub-commands. Running ph connect studio --help now shows the help for the studio command, likewise for the other new commands.
|
|
737
|
-
|
|
738
|
-
This approach avoids redundant build/compilation which is great for minimizing server resource use. The only compilation that runs is the esbuild of the project code (does not need tsc as that is handled separately) and then tailwind for the local project styles. The whole thing takes less than a second, albeit on my macbook.
|
|
739
|
-
|
|
740
|
-
This should just work with the current boilerplate since these are just new arguments to the existing ph-cli connect command.
|
|
707
|
+
*This document was automatically generated from the help text in the codebase.* <!-- AUTO-GENERATED-CLI-COMMANDS-END -->
|