Skip to content

Commit

Permalink
dev:publish end to end
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremycolin committed Sep 1, 2024
1 parent 1f6fedf commit a9874c4
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 14 deletions.
42 changes: 37 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,40 @@
# Website Analyzer Web Component

## Installation
## Installation and Usage

TODO when published
### Installation as a npm package

## Usage
```bash
pnpm install website-analyzer-wc
```

### Usage as a npm package

In the file where you want to use it, import the package:

```javascript
import "website-analyzer-wc";
```

and anywhere in your html / jsx use the tag `<website-analyzer />`

### Installation as a direct script

Copy the content of [main-script.html](./packages/website-analyzer-wc/dist-script/script.html) inside your HTML code, for example inside your <head> tag

TODO: Write usage instructions
### Usage as a direct script

Use the tag `<website-analyzer />` anywhere you want in your HTML code

## Examples

### UI

The UI looks like this: ![screenshot of web component](./screenshot.png)

### Code

Usage of exampe is in [./packages/website-analyzer-demo](./packages/website-analyzer-demo)

## Develop

Expand All @@ -16,7 +44,11 @@ Project is using pnpm with [Corepack](https://pnpm.io/installation#using-corepac
pnpm install
```

## Contributing
The package `website-analyzer-wc` contains the web component source code and the package `website-analyzer-demo` contains a simple demo setup.

You can uncomment `link-workspace-packages=true` in the .nmprc to link them locally to develop

## Contribute

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
Expand Down
2 changes: 1 addition & 1 deletion packages/website-analyzer-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"website-analyzer-wc": "0.1.0"
"website-analyzer-wc": "^0.2.0"
},
"devDependencies": {
"typescript": "^5.5.3",
Expand Down
1 change: 1 addition & 0 deletions packages/website-analyzer-wc/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
README.md
screenshot.png
5 changes: 3 additions & 2 deletions packages/website-analyzer-wc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "website-analyzer-wc",
"author": "Jeremy Colin",
"version": "0.2.0",
"version": "0.3.0",
"description": "Web component to show website performance",
"main": "dist/main.js",
"module": "dist/main.js",
Expand Down Expand Up @@ -38,6 +38,7 @@
"url": "https://github.com/jeremycolin/website-analyzer-wc.git"
},
"files": [
"dist"
"dist",
"screenshot.png"
]
}
5 changes: 4 additions & 1 deletion packages/website-analyzer-wc/scripts/prepublish-copy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ const DIST_SCRIPT_DIR = resolve(__dirname, "..", "dist-script");
// copy root repository README file inside published package
copyFileSync(resolve(ROOT_DIR, "README.md"), resolve(SOURCE_DIR, "README.md"));

// copy screenshot
copyFileSync(resolve(ROOT_DIR, "screenshot.png"), resolve(SOURCE_DIR, "screenshot.png"));

// create ready to copy script tag and write it to disk
const sourceCodeIIFE = readFileSync(resolve(DIST_SCRIPT_DIR, "main-iife.js"), "utf8").toString();

writeFileSync(
resolve(DIST_SCRIPT_DIR, "main-script.html"),
resolve(DIST_SCRIPT_DIR, "script.html"),
`<script>
${sourceCodeIIFE}</script>`
);
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a9874c4

Please sign in to comment.