Skip to content
This repository was archived by the owner on Apr 15, 2021. It is now read-only.

Commit 5b48bbc

Browse files
committed
Replace @XDN package
1 parent eb943ba commit 5b48bbc

36 files changed

+229
-224
lines changed

components/utils/useSegment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function useSegment() {
2020

2121
useEffect(() => {
2222
const segmentLoadInterval = setInterval(() => {
23-
if (window.analytics) {
23+
if (window.analytics && window.analytics.user) {
2424
const id = query.sgId || window.analytics.user().anonymousId()
2525
if (query.sgId) {
2626
window.analytics.alias(id)

constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const PRODUCT_NAME = 'Layer0'
22
export const CLI_NAME = 'l0'
3+
export const PACKAGE_NAME = '@l0'
34

45
export const DOMAIN = 'layer0.co'
56
export const APP_DOMAIN = `app.${DOMAIN}`

guides/angular.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ To prepare your Angular application for deployment on {{ PRODUCT_NAME }}:
5454
#### 1. Install {{ PRODUCT_NAME }} CLI globally:
5555

5656
```bash
57-
npm install -g @xdn/cli
57+
npm install -g {{ PACKAGE_NAME }}/cli
5858
```
5959

6060
#### 2. Run the following in the root folder of your project. This will configure your project for {{ PRODUCT_NAME }}.
@@ -65,9 +65,9 @@ xdn init
6565

6666
This will automatically add all of the required dependencies and files to your project. These include:
6767

68-
- The `@xdn/core` package
69-
- The `@xdn/angular` package
70-
- The `@xdn/cli` package
68+
- The `{{ PACKAGE_NAME }}/core` package
69+
- The `{{ PACKAGE_NAME }}/angular` package
70+
- The `{{ PACKAGE_NAME }}/cli` package
7171
- `xdn.config.js`- Contains various configuration options for {{ PRODUCT_NAME }}.
7272
- `routes.js` - A default routes file that sends all requests to the Angular Universal server. Update this file to add caching or proxy some URLs to a different origin.
7373

@@ -83,8 +83,8 @@ The default `routes.js` file created by `xdn init` sends all requests to Angular
8383
// This file was automatically added by xdn deploy.
8484
// You should commit this file to source control.
8585

86-
const { Router } = require('@xdn/core/router')
87-
import { angularRoutes } from '@xdn/angular'
86+
const { Router } = require('{{ PACKAGE_NAME }}/core/router')
87+
import { angularRoutes } from '{{ PACKAGE_NAME }}/angular'
8888

8989
export default new Router().use(angularRoutes)
9090
```

guides/caching.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Each edge point-of-presence (POP) has its own L1 cache. If a request cannot be f
1515
To cache a response, use the [cache](/docs/api/core/classes/_router_responsewriter_.responsewriter.html#cache) function in your route's callback:
1616

1717
```js
18-
import { CustomCacheKey } from '@xdn/core/router'
18+
import { CustomCacheKey } from '{{ PACKAGE_NAME }}/core/router'
1919

2020
router.get('/some/path', ({ cache }) => {
2121
cache({
@@ -73,7 +73,7 @@ It is often useful to customize the cache key, either to improve the cache hit r
7373
- Increasing the cache hit ratio by excluding query parameters that are not used in the rendering of the content:
7474

7575
```js
76-
import { CustomCacheKey } from '@xdn/core/router'
76+
import { CustomCacheKey } from '{{ PACKAGE_NAME }}/core/router'
7777

7878
router.get('/some/path', ({ cache }) => {
7979
cache({
@@ -88,7 +88,7 @@ This will remove the given query parameters from the URL before it is used in ca
8888
- Including other request parameters like cookies:
8989

9090
```js
91-
import { CustomCacheKey } from '@xdn/core/router'
91+
import { CustomCacheKey } from '{{ PACKAGE_NAME }}/core/router'
9292

9393
router.get('/some/path', ({ cache }) => {
9494
cache({
@@ -103,7 +103,7 @@ This will take the values of `language` and `currency` cookies from `cookie` req
103103
- Splitting the cache based on device type:
104104

105105
```js
106-
import { CustomCacheKey } from '@xdn/core/router'
106+
import { CustomCacheKey } from '{{ PACKAGE_NAME }}/core/router'
107107

108108
router.get('/some/path', ({ cache }) => {
109109
cache({

guides/cli.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ This guide shows you everything you can do with the XDN command line interface.
77
To install the XDN CLI run
88

99
```bash
10-
npm i -g @xdn/cli
10+
npm i -g {{ PACKAGE_NAME }}/cli
1111
```
1212

1313
Or with yarn:
1414

1515
```bash
16-
yarn global add @xdn/cli
16+
yarn global add {{ PACKAGE_NAME }}/cli
1717
```
1818

1919
## Commands
@@ -197,7 +197,7 @@ Production mode is always used whe running downloaded bundles.
197197

198198
### use
199199

200-
Switches the version of all @xdn/\* packages in your project.
200+
Switches the version of all {{ PACKAGE_NAME }}/\* packages in your project.
201201

202202
#### Example
203203

guides/connectors.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Connectors
22

3-
Connector packages help build and run your app within the XDN. When you run `xdn init`, the XDN CLI detects the framework used by your app and installs the corresponding connector package. For example, if you use Next.js, `@xdn/next` will be installed. If no connector package exists for the framework that you use, you can still deploy to the XDN by implementing the connector interface directly in your app.
3+
Connector packages help build and run your app within the XDN. When you run `xdn init`, the XDN CLI detects the framework used by your app and installs the corresponding connector package. For example, if you use Next.js, `{{ PACKAGE_NAME }}/next` will be installed. If no connector package exists for the framework that you use, you can still deploy to the XDN by implementing the connector interface directly in your app.
44

55
## Writing a connector
66

@@ -24,7 +24,7 @@ Example:
2424
```js
2525
/* istanbul ignore file */
2626
const { join } = require('path')
27-
const { DeploymentBuilder } = require('@xdn/core/deploy')
27+
const { DeploymentBuilder } = require('{{ PACKAGE_NAME }}/core/deploy')
2828

2929
/**
3030
* Called when the user runs xdn init.
@@ -57,14 +57,14 @@ Additional files can be added beyond the ones listed above. They will be copied
5757

5858
## dev.js
5959

60-
Called when the user runs `xdn dev`. This entry point is responsible for starting the user's application in development mode. The `@xdn/core` library provides a `createDevServer` function to help with this.
60+
Called when the user runs `xdn dev`. This entry point is responsible for starting the user's application in development mode. The `{{ PACKAGE_NAME }}/core` library provides a `createDevServer` function to help with this.
6161

6262
_Optional, if not provided, xdn dev will simply start the XDN in local development mode, but will not start a framework application server._
6363

6464
Example:
6565

6666
```js
67-
const { createDevServer } = require('@xdn/core/dev')
67+
const { createDevServer } = require('{{ PACKAGE_NAME }}/core/dev')
6868

6969
module.exports = function() {
7070
return createDevServer({
@@ -87,15 +87,15 @@ module.exports = function() {
8787

8888
## build.js
8989

90-
Exports a function that is called when you run `xdn build`. It is responsible for constructing the bundle that is deployed to the XDN cloud. This function typically uses `@xdn/core/deploy/DeploymentBuilder` to stage the exploded bundle in the `.xdn` directory.
90+
Exports a function that is called when you run `xdn build`. It is responsible for constructing the bundle that is deployed to the XDN cloud. This function typically uses `{{ PACKAGE_NAME }}/core/deploy/DeploymentBuilder` to stage the exploded bundle in the `.xdn` directory.
9191

9292
_Optional, and not needed in most cases. The xdn build command automatically creates a bundle that includes all static assets referenced in your routes file as well as the `prod` entry point mentioned above._
9393

9494
Example:
9595

9696
```js
97-
const { DeploymentBuilder } = require('@xdn/core/deploy')
98-
const FrameworkBuildError = require('@xdn/core/errors/FrameworkBuildError')
97+
const { DeploymentBuilder } = require('{{ PACKAGE_NAME }}/core/deploy')
98+
const FrameworkBuildError = require('{{ PACKAGE_NAME }}/core/errors/FrameworkBuildError')
9999

100100
export default async function build({ skipFramework }) {
101101
const builder = new DeploymentBuilder(appDir)

guides/cookbook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ router.get('/products/:id', ({ serveStatic, cache, renderWithApp }) => {
247247
```
248248

249249
This hybrid of static and dynamic rendering was first introduced in Next.js as [Incremental Static Generation (ISG)](https://nextjs.org/docs/basic-features/data-fetching#the-fallback-key-required). In Next.js apps, developers enable this behavior by returning `fallback: true` from
250-
`getStaticPaths()`. The `@xdn/next` package automatically configures the routes for ISG pages to use `onNotFound` and `loadingPage`.
250+
`getStaticPaths()`. The `{{ PACKAGE_NAME }}/next` package automatically configures the routes for ISG pages to use `onNotFound` and `loadingPage`.
251251

252252
### Returning a custom 404 page
253253

guides/core_web_vitals.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Instead of relying solely on Google Search Console, we recommend tracking Core W
2727

2828
## Installation
2929

30-
In order to start tracking Core Web Vitals on {{ PRODUCT_NAME }}, you need add the `@xdn/rum` client library to your application. There are a number of ways to do this:
30+
In order to start tracking Core Web Vitals on {{ PRODUCT_NAME }}, you need add the `{{ PACKAGE_NAME }}/rum` client library to your application. There are a number of ways to do this:
3131

3232
### Script Tag
3333

@@ -67,19 +67,19 @@ To add Core Web Vitals tracking via a script tag, add the following to each page
6767
To install the Core Web Vitals library using npm, run:
6868

6969
```
70-
npm install --save @xdn/rum
70+
npm install --save {{ PACKAGE_NAME }}/rum
7171
```
7272

7373
Or, using yarn:
7474

7575
```
76-
yarn add @xdn/rum
76+
yarn add {{ PACKAGE_NAME }}/rum
7777
```
7878

7979
Then, add the following to your application's browser bundle:
8080

8181
```js
82-
import { Metrics } from '@xdn/rum'
82+
import { Metrics } from '{{ PACKAGE_NAME }}/rum'
8383

8484
new Metrics({
8585
token: 'your-token-here', // get this from https://moovweb.app
@@ -90,7 +90,7 @@ new Metrics({
9090

9191
You can tie URLs to pages templates by providing an optional `router` parameter to `Metrics`.
9292

93-
When installing @xdn/rum using a script tag, use:
93+
When installing {{ PACKAGE_NAME }}/rum using a script tag, use:
9494

9595
```js
9696
new XDN.Metrics({
@@ -105,11 +105,11 @@ new XDN.Metrics({
105105
}).collect()
106106
```
107107

108-
When installing @xdn/rum via NPM or Yarn use:
108+
When installing {{ PACKAGE_NAME }}/rum via NPM or Yarn use:
109109

110110
```js
111-
import { Router } from '@xdn/rum/Router'
112-
import { Metrics } from '@xdn/rum'
111+
import { Router } from '{{ PACKAGE_NAME }}/rum/Router'
112+
import { Metrics } from '{{ PACKAGE_NAME }}/rum'
113113

114114
new Metrics({
115115
// get this from https://moovweb.app

guides/debugging.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ Edit the resulting configuration to look like this:
1818
"request": "launch",
1919
"cwd": "${workspaceFolder}",
2020
"autoAttachChildProcesses": true,
21-
"program": "${workspaceFolder}/node_modules/@xdn/cli",
21+
"program": "${workspaceFolder}/node_modules/{{ PACKAGE_NAME }}/cli",
2222
"args": ["run"]
2323
}
2424
```
2525

26-
The above assumes that the workspace folder is your app's root directory. If that is not the case, adjust `program` and `cwd` accordingly. The `program` config should always point to `@xdn/cli`. The `cwd` config should point to the root directory of your app.
26+
The above assumes that the workspace folder is your app's root directory. If that is not the case, adjust `program` and `cwd` accordingly. The `program` config should always point to `{{ PACKAGE_NAME }}/cli`. The `cwd` config should point to the root directory of your app.
2727

2828
Note that this configuration will allow you to set breakpoints in both your XDN router as well as your application code (for example in Next.js, Nuxt.js, Angular, etc...).
2929

3030
## Cloud
3131

3232
Your main tool in debugging XDN appplications that have been deployed are two sources of logs:
3333

34-
* [Server logs](/guides/logs#section_server_logs)
35-
* [Access logs](/guides/logs#section_access_logs)
34+
- [Server logs](/guides/logs#section_server_logs)
35+
- [Access logs](/guides/logs#section_access_logs)
3636

3737
Server logs will capture the output of your serverless in real time while access logs have complete traffic that is being served by your site including all the traffic that never reaches your serverless (e.g. cache hits, static assets, requests routed to custom backends, edge redirects, and so on).
3838

guides/deploying.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ To deploy your site to {{ PRODUCT_NAME }}, you must first sign up for an account
1111
Next, globally install the XDN cli using npm:
1212

1313
```bash
14-
npm i -g @xdn/cli
14+
npm i -g {{ PACKAGE_NAME }}/cli
1515
```
1616

1717
Or using yarn:
1818

1919
```bash
20-
yarn global add @xdn/cli
20+
yarn global add {{ PACKAGE_NAME }}/cli
2121
```
2222

2323
## xdn login

0 commit comments

Comments
 (0)