Skip to content

Commit

Permalink
docs: update some examples for the files setting (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud authored Mar 14, 2024
1 parent 3f813c4 commit c626f05
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 147 deletions.
37 changes: 20 additions & 17 deletions docs/client.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
---
id: client
title: Client
sidebar_label: Client
title: Publishing to Eik
sidebar_label: Publishing to Eik
---

## Installation
## Install the Eik CLI

```sh
npm install -g @eik/cli
```
See [Installation](./client_installation.md) for how to set up the CLI you will need for publishing.

## Quickstart guide
## Configure Eik

### Step 1.

Generate an eik.json file in the current directory
Generate an `eik.json` file in the current directory:

```sh
eik init
```

Fill in the generated `eik.json` file with the necessary details.
Set the URL to your Eik server as the `server` property. See [the server docs](/docs/server) if you need to set up a server.

For the `server` property, you will need to have set up and know the address to, and Eik asset server.
See [the server docs](/docs/server)
### Configure which files to publish

Set the `files` property of `eik.json` with paths to client side
asset files in your project relative to the `eik.json` file.
Eg. if you have a `scripts.js` file in an assets directory, the `js.input` value will be `assets/scripts.js`
asset files or directories in your project relative to the `eik.json` file.

```json
{
"name": "my-app",
"version": "1.0.0",
"server": "https://assets.myserver.com",
"files": "./public"
}
```

### Step 2
## Publish

Run publish to publish your assets to the server

```sh
eik publish
```

## Additional tasks
## Next steps

### Publishing global dependencies

Expand Down
20 changes: 10 additions & 10 deletions docs/client_app_packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In your app's Eik config you use the `files` key to define a local path or paths

```json
{
"files": "./dist"
"files": "./public"
}
```

Expand All @@ -27,7 +27,7 @@ In your app's Eik config you use the `files` key to define a local path or paths
```json
{
"eik": {
"files": "./dist"
"files": "./public"
}
}
```
Expand All @@ -48,12 +48,12 @@ The following example shows how entrypoint definitions correspond to final file

Given the following local files:

* `./dist/index.js`
* `./dist/index.js.map`
* `./dist/ie11.js`
* `./dist/ie11.js.map`
* `./dist/index.css`
* `./dist/index.css.map`
* `./public/index.js`
* `./public/index.js.map`
* `./public/ie11.js`
* `./public/ie11.js.map`
* `./public/index.css`
* `./public/index.css.map`

And the following eik.json definition:

Expand All @@ -62,7 +62,7 @@ And the following eik.json definition:
"server": "http://assets.myserver.com",
"name": "my-pack",
"version": "1.0.0",
"files": "./dist"
"files": "./public"
}
```

Expand All @@ -74,7 +74,7 @@ Or the following package.json definition:
"name": "my-pack",
"version": "1.0.0",
"server": "http://assets.myserver.com",
"files": "./dist"
"files": "./public"
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/client_installation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: client_installation
title: Client Installation
sidebar_label: Installation
title: CLI installation
sidebar_label: CLI installation
---

In order to interact with an Eik server, you must install the client which can then be used to perform a variety of tasks such as mirroring NPM packages, publishing app packages, aliasing, publishing import maps and more. Interacting with the client is done via the command line in a terminal. To get started, you will need to have [Node.js](https://nodejs.org/en/) installed which comes with the [NPM](https://npmjs.com) package manager.
Expand Down
12 changes: 6 additions & 6 deletions docs/client_login.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
id: client_login
title: Client Login
sidebar_label: Client Login
title: CLI Login
sidebar_label: CLI Login
---

To make use of the Eik client, it is necessary to authenticate with an Eik server. To do this, the `eik login` command can be used.
To make use of the Eik CLI, it is necessary to authenticate with an Eik server. To do this, the `eik login` command can be used.

## The Eik login command

```
eik login
```

The login command will ask for a server URL and a server key. Server keys are configured on the server and, once entered, the client will authenticate with the server and receive back a JSON web token which it will save in an `.eikrc` file in the users home directory for use in subsequent commands.
The login command will ask for a server URL and a server key. Server keys are configured on the server and, once entered, the client will authenticate with the server and receive back a JSON web token which it will save in an `.eikrc` file in the users home directory for use in subsequent commands.

![Login screenshot](/img/login.png)

## Authenticating
## Authenticating

### Without the command prompt

Expand All @@ -28,7 +28,7 @@ eik login --server https://assets.myeikserver.com --key ######

### With multiple Eik servers

It is possible to be authenticated against several Eik servers at once by calling the `eik login` command multiple times and providing different server URLs and keys each time.
It is possible to be authenticated against several Eik servers at once by calling the `eik login` command multiple times and providing different server URLs and keys each time.

```sh
eik login --server https://assets.myeikserver1.com --key ######
Expand Down
4 changes: 2 additions & 2 deletions docs/client_npm_packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ While not strictly necessary, to avoid clashes with your own app packages, Eik p
```json
{
"name": "lit",
"server": "https://myeikserver.com",
"server": "https://assets.myserver.com",
"version": "1.0.0",
"type": "npm",
"files": "./dist"
"files": "./public"
}
```

Expand Down
18 changes: 9 additions & 9 deletions docs/client_putting_it_all_together.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ Set the `package.json` name and version to match `@podium/browser` and add some
"name": "@podium/browser",
"version": "1.2.1",
"eik": {
"server": "https://myeikserver.com",
"files": "./dist",
"server": "https://assets.myserver.com",
"files": "./public",
"type": "npm"
}
}
```

### Run a build to bundle up @podium/browser into a single file

We can use Rollup to bundle up the code from `@podium/browser` into a single file and place it into the `dist` directory ready for upload like so:
We can use Rollup to bundle up the code from `@podium/browser` into a single file and place it into the `public` directory ready for upload like so:

```
npx rollup -f es -o ./dist/index.js ./node_modules/@podium/browser/src/index.js
npx rollup -f es -o ./public/index.js ./node_modules/@podium/browser/src/index.js
```

N.B. We ensure that ESM is preserved with the `-f es` flag.
Expand Down Expand Up @@ -123,11 +123,11 @@ Create an `eik.json` file describing the apps asset setup and enter the import m

```json
{
"server": "https://myeikserver.com",
"server": "https://assets.myserver.com",
"name": "my-app",
"version": "1.0.0",
"files": "./dist",
"import-map": "https://myeikserver.com/map/my-map/v1"
"files": "./public",
"import-map": "https://assets.myserver.com/map/my-map/v1"
}
```

Expand All @@ -150,7 +150,7 @@ import eik from '@eik/rollup-plugin';
export default {
input: './src/index.js',
output: {
file: './dist/index.js',
file: './public/index.js',
format: 'es',
sourcemap: true,
},
Expand All @@ -163,7 +163,7 @@ export default {
};
```

*n.b.* The `files` field in `eik.json` is set to read `./dist/index.js` which is produced by the rollup build.
*n.b.* The `files` field in `eik.json` is set to read `./public/index.js` which is produced by the rollup build.
Also note that you are not required to use Rollup at all. You could use Esbuild or Webpack for example.

### Publish bundled code to the Eik server
Expand Down
30 changes: 15 additions & 15 deletions docs/overview_eik_json.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ __*Example*__
{
"name": "my-app",
"version": "1.0.0",
"server": "https://assets.myeikserver.com",
"files": "./dist",
"import-map": "https://assets.myeikserver.com/map/my-map/1.0.0"
"server": "https://assets.myserver.com",
"files": "./public",
"import-map": "https://assets.myserver.com/map/my-map/1.0.0"
}
```

Expand All @@ -33,9 +33,9 @@ __*Example*__
"eik": {
"name": "my-app",
"version": "1.0.0",
"server": "https://assets.myeikserver.com",
"files": "./dist",
"import-map": "https://assets.myeikserver.com/map/my-map/1.0.0"
"server": "https://assets.myserver.com",
"files": "./public",
"import-map": "https://assets.myserver.com/map/my-map/1.0.0"
}
}
```
Expand All @@ -49,9 +49,9 @@ __*Example*__
"name": "my-app",
"version": "1.0.0",
"eik": {
"server": "https://assets.myeikserver.com",
"files": "./dist",
"import-map": "https://assets.myeikserver.com/map/my-map/1.0.0"
"server": "https://assets.myserver.com",
"files": "./public",
"import-map": "https://assets.myserver.com/map/my-map/1.0.0"
}
}
```
Expand Down Expand Up @@ -79,7 +79,7 @@ Once generated, it's necessary to add information about the Eik server URL for t

## eik.json file fields

### name
### name

* required

Expand Down Expand Up @@ -119,27 +119,27 @@ Defines JavaScript and CSS file entrypoints to publish. This can be a string def

#### Defining "files"

The following specifies that all files in the `dist` folder should be uploaded to the Eik server. Note that relative paths and absolute paths can be used as well.
The following specifies that all files in the `public` folder should be uploaded to the Eik server. Note that relative paths and absolute paths can be used as well.

```json
{
"files": "./dist",
"files": "./public",
}
```

Nested folders are also supported:

```json
{
"files": "./dist/assets",
"files": "./public/assets",
}
```

You can use glob syntax to decide which files to include:

```json
{
"files": "./dist/**/*.js",
"files": "./public/**/*.js",
}
```

Expand All @@ -151,7 +151,7 @@ files: {
// file `./path/to/esm.js` is uploaded and renamed to `/script.js`
'script.js': './path/to/esm.js',

// file `/absolute/path/to/esm.js` is uploaded and renamed to `/script.js`
// file `/absolute/path/to/esm.js` is uploaded and renamed to `/script.js`
'script.js': '/absolute/path/to/esm.js',

// everything in `./path/to/folder` is uploaded to `/folder`
Expand Down
11 changes: 6 additions & 5 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ module.exports = {
'overview_workflow',
'overview_eik_json',
],
Mapping: [
'mapping_import_map',
'mapping_browser',
'mapping_plugins',
],
Client: [
'client',
'client_installation',
'client_login',
'client_app_packages',
Expand All @@ -20,6 +16,11 @@ module.exports = {
'client_aliases',
'client_putting_it_all_together',
],
Mapping: [
'mapping_import_map',
'mapping_browser',
'mapping_plugins',
],
Server: [
'server',
'server_api',
Expand Down
Loading

0 comments on commit c626f05

Please sign in to comment.