Skip to content

Commit 8bd97ae

Browse files
Merge pull request #14 from docusign/feat/update-getting-started
Updating getting started.
2 parents 7db07c1 + dd8685c commit 8bd97ae

File tree

5 files changed

+206
-55
lines changed

5 files changed

+206
-55
lines changed
17.7 KB
Loading
Lines changed: 150 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Customize your 1FE App
3-
description: Customize your 1FE App
2+
title: Take Ownership
3+
description: Take ownership of your 1FE app by customizing the default plugin and hosting it on a CDN.
44
sidebar:
55
order: 3
66
---
@@ -10,7 +10,7 @@ import { FcOk } from "react-icons/fc";
1010

1111
Let's customize your new 1FE app by making changes to the default plugin! Since 1FE is powered by CDN, we will update and build the plugin and host the assets.
1212

13-
## <SlPencil style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> Make changes to example plugin
13+
## <SlPencil style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> Setup your plugins
1414

1515
##### 1. Make any content change to `1fe-widget-starter-kit/src`
1616

@@ -54,72 +54,161 @@ yarn build:widget
5454

5555
![dist folder contents](./assets/example-plugin-dist.png)
5656

57+
##### 3. Setup the bathtub widget
58+
59+
We'll also need the bathtub widget for our 1FE application. The bathtub widget provides essential development tooling and runtime utilities.
60+
61+
1. Fork the [1fe-bathtub](https://github.com/docusign/1fe-bathtub) repository to your GitHub account.
62+
63+
```bash
64+
git clone https://github.com/<your-github-username>/1fe-bathtub.git
65+
cd 1fe-bathtub
66+
```
67+
68+
2. Install dependencies and build the widget:
69+
70+
```bash
71+
yarn install
72+
yarn build:widget
73+
```
74+
75+
:::tip
76+
The bathtub widget build will generate assets in the `dist` folder that we'll upload to our CDN later.
77+
:::
78+
5779

5880
## <SlCloudDownload style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> "Setup" your CDN
5981

60-
To get started quickly, we can use github's mirrored assets on the jsdelivr CDN.
82+
To get started quickly, we will use jsdelivr CDN to host the needed assets.
6183

6284
##### 1. Fork this [mock-cdn-assets](https://github.com/docusign/mock-cdn-assets/tree/main) repository
63-
This repository contains the Live Configurations and widget assets per environment that power demo.1fe.com. We will use this to host our plugin assets and rely on [jsdelivr](https://www.jsdelivr.com/) to act as a CDN to start powering our application.
85+
This repository contains the live configurations and widget assets per environment that power [demo.1fe.com](https://demo.1fe.com). We will use this as a jumping off point to get our own version of the assets and rely on [jsdelivr](https://www.jsdelivr.com/) to act as a CDN to start powering our application.
6486

65-
##### 2. Update the live configs
6687

67-
One of the key features of 1FE is the ability to dynamically load widgets and plugins via [Live Configurations](../../main-concepts/live-configurations). We will update the Live Configurations to point to our new plugin assets.
88+
## <SlCloudDownload style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> "Deploy" your plugins to CDN
89+
90+
We will host the plugin assets using our forked repo from the previous step to make them accessible to the 1FE app. This allows for dynamic loading of widgets and plugins.
6891

69-
## <SlCloudDownload style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> "Deploy" your plugin to CDN
92+
##### 1. Upload widget assets
7093

71-
Upload the new assets to your forked mocked-cdn-assets repository
72-
1. Create a new directory within `development/widgets/@1fe/starter-kit` of your forked repo. The directory name should be the next bumped version. (e.g `1.0.2`).
94+
<div className="prose">
95+
1. Create a new directory within `integration/widgets/@1fe/widget-starter-kit` of your forked cdn repo. The directory name should be the version from the package.json of the widget-starter-kit repository. (e.g `1.0.2`).
7396

7497
2. Upload the contents of the `1fe-widget-starter-kit/dist/` directory to the new directory.
7598

99+
3. Create a new directory within `integration/widgets/@1fe/bathtub` of your forked cdn repo. The directory name should be the version from the package.json of the bathtub repository (e.g `1.0.50`).
100+
101+
4. Upload the contents of the `1fe-bathtub/dist/` directory to the bathtub directory.
76102
![dist folder assets copied to CDN](./assets/example-plugin-cdn-assets.png)
77103

78-
3. Push these changes to your forked repository.
104+
5. Push these changes to your forked repository.
105+
106+
6. Create and push a tag. This is important for JSdelivr to cache the assets properly.
107+
```
108+
git tag v1.0.2
109+
git push origin v1.0.2
110+
```
111+
112+
6. Confirm that the assets are publicly accessible by visiting these jsdelivr cdn locations. Replace with your gh username and versions:
113+
```
114+
https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/integration/widgets/@1fe/widget-starter-kit/<version>/js/1fe-bundle.js
115+
https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/integration/widgets/@1fe/bathtub/<version>/js/1fe-bundle.js
116+
```
79117

80-
4. Confirm that the assets are publicly accessible by visiting this jsdelivr cdn location. Replace with your gh username and version:
118+
An example URL would look like this:
81119
```
82-
https://cdn.jsdelivr.net/gh/<your-github-username>/mock-cdn-assets/development/widgets/@1fe/starter-kit/<version>/js/1fe-bundle.js
120+
https://cdn.jsdelivr.net/gh/mohit-test-org/1fe-mock-cdn-assets@v1.0.2/integration/widgets/@1fe/bathtub/1.0.50/js/1fe-bundle.js
83121
```
84122

85-
##### 3. Update the Live Configurations to find your new plugin assets
123+
</div>
86124

87-
1. Locate `common-configs/development.json` within your forked mock-cdn-assets repository.
125+
##### 2. Update the live configs
88126

89-
2. Under `cdn.libraries.basePrefix` and `cdn.widgets.basePrefix`, update the base prefix to point to your jsdelivr cdn.
127+
One of the key features of 1FE is the ability to dynamically load widgets and plugins via [Live Configurations](../../main-concepts/live-configurations). We will now update the Live Configurations to point to our new plugin assets.
90128

91-
```json title="common-configs/development.json" {4,8}
92-
{
93-
"cdn": {
94-
"libraries": {
95-
"basePrefix": "https://cdn.jsdelivr.net/gh/<your-github-username>/mock-cdn-assets/development/libs/",
96-
{...}
97-
},
98-
"widgets": {
99-
"basePrefix": "https://cdn.jsdelivr.net/gh/<your-github-username>/mock-cdn-assets/development/widgets/",
100-
{...}
101-
}
129+
###### Update widget-versions.json
130+
131+
The `widget-versions.json` file defines the available versions for each widget that can be loaded by the 1FE platform.
132+
133+
1. Create `integration/configs/widget-versions.json` file within your forked mock-cdn-assets repository and update it like so:
134+
```json title="widget-versions.json"
135+
[
136+
{
137+
"widgetId": "@1fe/bathtub",
138+
"version": "<version uploaded to CDN>"
139+
},
140+
{
141+
"widgetId": "@1fe/widget-starter-kit",
142+
"version": "<version uploaded to CDN>"
102143
}
103-
}
144+
]
104145
```
105146

106-
3. Under `cdn.widgets.releaseConfig`, locate the widgetId `@1fe/starter-kit` and update with the new version.
147+
###### Update live.json
148+
149+
The [`live.json`](https://1fe-a.akamaihd.net/integration/configs/live.json) file contains the runtime configuration for the plugins that are being loaded
150+
151+
<div className="prose">
152+
1. Locate `integration/configs/live.json` within your forked mock-cdn-assets repository and make the following changes:
107153

108-
```json title="common-configs/development.json" {8}
109-
...
154+
2. Update the basePrefix to point to your jsdelivr cdn
155+
156+
3. Remove the `sample-widget` and `sample-widget-with-auth` widget configurations as they are not needed for this example.
157+
158+
Following is what the diff will look like. Also, here is a [PR](https://github.com/docusign/mock-cdn-assets/pull/28/files) showcasing these changes
159+
160+
```diff title="live.json"
110161
{
111-
"widgetId": "@1fe/starter-kit",
112-
"plugin": {
113-
"enabled": true,
114-
"route": "/app1"
115-
},
116-
"version": "1.0.2"
162+
+ "libraries": {
163+
+ "basePrefix": "https://cdn.jsdelivr.net/gh/<your-github-username>/mock-cdn-assets/development/libs/"
164+
+ },
165+
"widgets": {
166+
+ "basePrefix": "https://cdn.jsdelivr.net/gh/<your-github-username>/mock-cdn-assets/development/widgets/",
167+
"configs": [
168+
{
169+
"widgetId": "@1fe/bathtub",
170+
"plugin": {
171+
"enabled": true,
172+
"route": "/widget-starter-kit"
173+
}
174+
},
175+
- {
176+
- "widgetId": "@1fe/sample-widget",
177+
- "plugin": {
178+
- "enabled": true,
179+
- "route": "/sample-widget"
180+
- }
181+
- },
182+
- {
183+
- "widgetId": "@1fe/sample-widget-with-auth",
184+
- "plugin": {
185+
- "enabled": true,
186+
- "route": "/sample-widget-with-auth",
187+
- "auth": {
188+
- "authenticationType": "required"
189+
- }
190+
- }
191+
- }
192+
]
193+
}
117194
}
118195
```
119196

120-
4. Push these changes to your forked repository.
197+
4. Push these changes to your forked repository. Create and push a tag. This is important for JSdelivr to cache the assets properly.
198+
```
199+
git tag v1.0.3
200+
git push origin v1.0.3
201+
```
202+
5. Confirm that the updated Live Configurations is reflected on jsdelivr:
203+
```
204+
https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/integration/configs/live.json
205+
```
206+
</div>
121207

122-
5. Confirm that the update Live Configurations is reflected on jsdelivr: `https://cdn.jsdelivr.net/gh/<your-github-username>/mock-cdn-assets/common-configs/development.json`.
208+
An example URL would look like this:
209+
```
210+
https://cdn.jsdelivr.net/gh/mohit-test-org/1fe-mock-cdn-assets@v1.0.2/integration/widgets/@1fe/bathtub/1.0.50/js/1fe-bundle.js
211+
```
123212

124213
:::tip
125214
**Is jsdelivr not reflecting your changes?**
@@ -131,22 +220,29 @@ Read more about [Live Configurations](../../main-concepts/live-configurations).
131220

132221
##### 4. Point your local 1FE app to the new CDN assets
133222

134-
```tsx title="apps/starter-app/src/server.ts" {7}
223+
```tsx title="src/config/ecosystem-configs.ts" {4,7,10}
135224
// ...
136-
const options = {
137-
mode: envModeMap[ENVIRONMENT],
138-
environment: ENVIRONMENT,
139-
orgName: '1FE Starter App',
140-
configManagement: {
141-
url: `https://cdn.jsdelivr.net/gh/abe-hu/mock-cdn-assets/common-configs/development.json`,
142-
refreshMs: 30 * 1000,
225+
export const configManagement: OneFEConfigManagement = {
226+
widgetVersions: {
227+
url: `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/integration/configs/widget-versions.json`,
228+
},
229+
libraryVersions: {
230+
url: `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/integration/configs/lib-versions.json`,
143231
},
144-
shellBundleUrl,
145-
// ...
232+
dynamicConfigs: {
233+
url: `https://cdn.jsdelivr.net/gh/<your-github-username>/<repo-name>@<tag>/integration/configs/live.json`,
234+
},
235+
refreshMs: 30 * 1000,
146236
};
147-
148-
const app = oneFEServer(options);
149237
```
238+
:::note[🔒 CSP Gone Wrong!]
239+
**Whoops! Page reload causing CSP issues?**
240+
241+
If you refresh the page and see Content Security Policy errors blocking you from loading assets from jsdeliver, don't panic! 🚨
242+
243+
You need to update the CSP settings in the 1FE app(`src/csp-configs.ts`) to allow jsdeliver(`https://cdn.jsdelivr.net/`).
244+
:::
245+
Navigate to [starter kit locally](http://localhost:3001/widget-starter-kit/utils) and check the console for the message "Hello from app1!" to confirm that your changes are being reflected.
150246

151247
##### <FcOk style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> Tada!
152248

@@ -156,5 +252,7 @@ const app = oneFEServer(options);
156252
**In an ideal-state:**
157253
- There should be proper CDN hosting for Live Configurations and widget assets.
158254
- Each widget should live in their own repository.
159-
- Each widget should own CI/CD pipelines that upload assets to CDN and bump release versions on merge. (Templates Coming Soon! <SlRocket style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> )
255+
- Each widget should own CI/CD pipelines that upload assets to CDN and bump release versions on merge.
256+
257+
Follow the guide [here](../../platform-guides/productionize) to productionize your 1FE app.
160258
:::

src/content/docs/getting-started/local-development.mdx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,43 @@ yarn dev
1919

2020
1FE CLI will serve the widget bundle at `http://localhost:8080/js/1fe-bundle.js`
2121

22-
##### 2. Visit `http://localhost:3001/app1` and click the `{...}` button at the bottom right corner of the screen. ![Import map overrides button showing three dots in brackets](./assets/three-dots.png)
22+
##### 2. Visit `http://localhost:3001/widget-starter-kit` and click the `{...}` button at the bottom right corner of the screen. ![Import map overrides button showing three dots in brackets](./assets/three-dots.png)
2323

24-
##### 3. Search for `@1fe/starter-kit` within the shelf and select the matching module
24+
##### 3. Search for `@1fe/widget-starter-kit` within the shelf and select the matching module
2525

2626
![Import map shelf](./assets/import-map-shelf.png)
2727

2828
##### 4. In the `Override URL` field, enter `http://localhost:8080/js/1fe-bundle.js` and click `Apply override`.
2929

3030
![Import map override modal](./assets/override-modal.png)
3131

32-
##### 5. <FcOk style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> Make changes toy our widget and observe the changes in the browser.
32+
##### 5. <FcOk style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> Make changes to your widget and observe the changes in the browser.
33+
34+
:::note[🔒 CSP Fun Fact!]
35+
**Whoops! Page reload causing CSP issues?**
36+
37+
If you refresh the page and see Content Security Policy errors blocking your local widget, don't panic! 🚨
38+
39+
You need to update the CSP settings in the 1FE app(`src/csp-configs.ts`) to allow your local development server(`http://localhost:8080/`).
40+
:::
41+
42+
---
43+
44+
## 🎉 Congratulations! You made it!
45+
46+
You've successfully set up local development for your 1FE widgets! Now it's time to explore and build amazing things. Here are some important sections to check out next:
47+
48+
### 🧠 **Learn the Core Concepts**
49+
- **[Live Configurations](../../main-concepts/live-configurations)** - Understand how 1FE dynamically loads widgets
50+
- **[Widgets vs Plugins](../../main-concepts/widgets)** - Learn the difference and when to use each
51+
- **[Platform Architecture](../../main-concepts/architecture)** - Deep dive into how 1FE works under the hood
52+
53+
### 🔧 **Level Up Your Development**
54+
- **[API Reference](../../api-reference/1fe-server-reference)** - Complete API documentation for building widgets
55+
- **[Externalizing Libraries](../../platform-guides/externalizing-libraries)** - Optimize bundle sizes and share dependencies
56+
57+
### 🚀 **Ready for Production?**
58+
- **[Productionize your setup](../../platform-guides/productionize)** - Take your app to production
59+
60+
Happy coding! 🚀
61+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Architecture
3+
description: Learn about the architecture of 1FE and how to customize it.
4+
---
5+
6+
import { SlRocket } from "react-icons/sl";
7+
8+
## <SlRocket style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> Coming Soon!
9+
10+
We're working hard to bring you comprehensive guidance on the architecture of 1FE - stay tuned!
11+
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Productionize local setup
3+
description: 'Setup infra for production 1FE app'
4+
---
5+
6+
import { SlRocket } from "react-icons/sl";
7+
8+
## <SlRocket style={{ display: 'inline', marginRight: '0.5rem', verticalAlign: 'middle' }} /> Coming Soon!
9+
10+
We're working hard to bring you comprehensive guidance on productionizing your 1FE application - stay tuned!
11+
12+

0 commit comments

Comments
 (0)