Skip to content

Commit a855c1d

Browse files
authored
Initial commit
0 parents  commit a855c1d

12 files changed

+1084
-0
lines changed

.github/workflows/test.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Runs All Unit tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [ 20 ]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
25+
- name: Use pnpm
26+
uses: pnpm/action-setup@v3
27+
with:
28+
version: 8
29+
run_install: false
30+
31+
- name: Get pnpm store directory
32+
shell: bash
33+
run: |
34+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
35+
36+
- uses: actions/cache@v4
37+
name: Setup pnpm cache
38+
with:
39+
path: ${{ env.STORE_PATH }}
40+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
41+
restore-keys: |
42+
${{ runner.os }}-pnpm-store-
43+
44+
- name: Install Dependencies
45+
run: pnpm install
46+
47+
- name: Execute Unit tests
48+
run: pnpm test

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
sandbox

README.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Javascript Library Skeleton
2+
3+
[![Runs All Unit tests](https://github.com/cesargb/javascript-library-skeleton/actions/workflows/test.yml/badge.svg)](https://github.com/cesargb/javascript-library-skeleton/actions/workflows/test.yml)
4+
5+
This is a skeleton for a Javascript library.
6+
7+
## Build
8+
9+
```bash
10+
npm install
11+
npm run build
12+
```
13+
14+
## Usage
15+
16+
### Module Usage
17+
18+
```javascript
19+
import { inspire } from "myLibrary";
20+
21+
console.log(inspire());
22+
```
23+
24+
### Browser Usage
25+
26+
```html
27+
<!DOCTYPE html>
28+
<html>
29+
<head>
30+
<script src="myLibrary.js"></script>
31+
</head>
32+
<body>
33+
<script>
34+
console.log(myLibrary.inspire());
35+
</script>
36+
</body>
37+
</html>
38+
```
39+
40+
## Installation
41+
42+
```bash
43+
npm install myLibrary
44+
```

dist/myLibrary.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const e = () => "Are you inspired?";
2+
export {
3+
e as inspire
4+
};

dist/myLibrary.umd.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(function(e,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(e=typeof globalThis<"u"?globalThis:e||self,i(e.myLibrary={}))})(this,function(e){"use strict";const i=()=>"Are you inspired?";e.inspire=i,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});

package.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "javascript-library-skeleton",
3+
"version": "0.0.1",
4+
"description": "",
5+
"author": "",
6+
"license": "ISC",
7+
"private": true,
8+
"type": "module",
9+
"main": "dist/index.umd.cjs",
10+
"module": "dist/index.js",
11+
"exports": {
12+
".": {
13+
"import": "./dist/index.js",
14+
"require": "./dist/index.umd.cjs"
15+
}
16+
},
17+
"scripts": {
18+
"build": "vite build",
19+
"test": "vitest"
20+
},
21+
"devDependencies": {
22+
"vite": "^5.2.11",
23+
"vitest": "^1.6.0"
24+
}
25+
}

0 commit comments

Comments
 (0)