Skip to content

Commit

Permalink
Migrating from NPM to GitHub for hosting IIFE file
Browse files Browse the repository at this point in the history
  • Loading branch information
patelka2211 committed Jun 16, 2023
1 parent cedfa49 commit b03b797
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 47 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ node_modules
.vscode

# Dominar distribution files
Dominar.iife.js
index.js
index.d.ts
index.d.ts

# Build
build.main.sh
build.test.sh
12 changes: 12 additions & 0 deletions Dominar.js

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

16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![](https://cdn.jsdelivr.net/gh/patelka2211/dominar@master/website-stuff/media/poster.png)](https://patelka2211.github.io/dominar)
[![](https://cdn.jsdelivr.net/gh/patelka2211/dominar/website-stuff/media/poster.png)](https://patelka2211.github.io/dominar)

# Dominar

Expand All @@ -13,20 +13,22 @@ Visit [https://patelka2211.github.io/dominar/](https://patelka2211.github.io/dom
## Installation

[![npm (scoped)](https://img.shields.io/npm/v/@patelka2211/dominar)](https://www.npmjs.com/package/@patelka2211/dominar)
[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@patelka2211/dominar)](https://bundlephobia.com/package/@patelka2211/dominar@1.1.9)
[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@patelka2211/dominar)](https://bundlephobia.com/package/@patelka2211/dominar@1.2.0)
[![npm](https://img.shields.io/npm/dy/@patelka2211/dominar)](https://www.npmjs.com/package/@patelka2211/dominar)
[![jsDelivr hits (npm scoped)](https://img.shields.io/jsdelivr/npm/hy/@patelka2211/dominar)](https://cdn.jsdelivr.net/npm/@patelka2211/[email protected]/)
[![jsDelivr hits (npm scoped)](https://img.shields.io/jsdelivr/npm/hy/@patelka2211/dominar)](https://cdn.jsdelivr.net/gh/patelka2211/[email protected]/)

<!-- [![jsDelivr hits (npm scoped)](https://img.shields.io/jsdelivr/gh/hy/patelka2211/dominar)](https://cdn.jsdelivr.net/gh/patelka2211/[email protected]/) -->

To install Dominar using npm, run the following command:

```sh
npm i @patelka2211/dominar
```

Alternatively, you can include [Dominar's IIFE file](https://cdn.jsdelivr.net/npm/@patelka2211/dominar@1.1.9/Dominar.iife.js) in your website using a `<script>` tag:
Alternatively, you can include [Dominar's IIFE file](https://cdn.jsdelivr.net/gh/patelka2211/dominar@1.2.0/Dominar.js) in your website using a `<script>` tag:

```html
<script src="https://cdn.jsdelivr.net/npm/@patelka2211/dominar@1.1.9/Dominar.iife.js"></script>
<script src="https://cdn.jsdelivr.net/gh/patelka2211/dominar@1.2.0/Dominar.js"></script>
```

## Examples
Expand Down Expand Up @@ -88,10 +90,10 @@ addEventListeners(document.body, {

### When included as a `<script>` tag in a website.

If the script tag is not already included in the `<head>` tag, please add the following script tag to include [Dominar's IIFE JavaScript](https://cdn.jsdelivr.net/npm/@patelka2211/dominar@1.1.9/Dominar.iife.js) file.
If the script tag is not already included in the `<head>` tag, please add the following script tag to include [Dominar's IIFE JavaScript](https://cdn.jsdelivr.net/gh/patelka2211/dominar@1.2.0/Dominar.js) file.

```html
<script src="https://cdn.jsdelivr.net/npm/@patelka2211/dominar@1.1.9/Dominar.iife.js"></script>
<script src="https://cdn.jsdelivr.net/gh/patelka2211/dominar@1.2.0/Dominar.js"></script>
```

```html
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
content="https://patelka2211.github.io/dominar/website-stuff/media/poster.png"
/>

<script defer src="./website-stuff/js/index.iife.js"></script>
<script defer src="./website-stuff/js/index.bundle.js"></script>
</head>

<body>
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"name": "@patelka2211/dominar",
"version": "1.1.9",
"version": "1.2.0",
"description": "Dominar is a powerful library designed to make it easy for developers to manipulate the Document Object Model (DOM) and create dynamic HTML content. Dominar empowers you to take control of your web development projects like a pro. Unleash the power to dominate the DOM with Dominar.",
"main": "index.js",
"module": "index.js",
"types": "index.d.ts",
"scripts": {
"build": "rm -rf ./lib/ && tsc -p tsconfig.json && rollup -c && terser ./Dominar.iife.js -c -m -o ./Dominar.iife.js",
"test": "tsc test/index.ts -t es6 && rollup test/index.js -o test/out.js",
"build": "tsc -p ./tsconfig.json && rollup -c && terser ./index.js -c -m -o ./index.js && terser ./Dominar.js -c -m -o ./Dominar.js && rm -rf ./lib/",
"test": "tsc -p ./tsconfig.json && tsc ./test/index.ts -t es6 && rollup ./test/index.js -o ./test/out.js && rm -rf ./lib/",
"prepare": "npm run build"
},
"files": [
"index.js",
"index.d.ts",
"Dominar.iife.js"
"index.d.ts"
],
"repository": {
"type": "git",
Expand All @@ -22,7 +21,6 @@
"keywords": [
"Dominar",
"Dominar.js",
"Dominar.iife.js",
"front-end",
"Dominar by KP",
"Developed by KP",
Expand Down
16 changes: 8 additions & 8 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import dts from "rollup-plugin-dts";

const time = new Date(),
const currentDate = new Date(),
options = { year: "numeric", month: "long", day: "numeric" },
formattedDate = currentDate.toLocaleDateString("en-US", options),
banner = `/**
* [**Dominar by KP**](https://www.npmjs.com/package/@patelka2211/dominar/)
* **Dominar** from KPVERSE
*
* Dominar is a powerful library designed to make it easy for developers to manipulate the Document Object Model (DOM) and create dynamic HTML content. Dominar empowers you to take control of your web development projects like a pro. Unleash the power to dominate the DOM with Dominar.
* Updated on ${formattedDate}.
*
* Copyright © 2023-present, Kartavya Patel. All rights reserved.
*
* @author Kartavya Patel <[email protected]>
*
* @license {@link https://github.com/patelka2211/dominar/blob/main/LICENSE MIT}
*
* @copyright Kartavya Patel ${time.getFullYear()}
*
* Last updated at : ${time.toISOString()}
*/`;

export default [
{
input: "./lib/index.js",
output: {
file: "./Dominar.iife.js",
file: "./Dominar.js",
format: "iife",
name: "Dominar",
banner: banner,
Expand Down
21 changes: 0 additions & 21 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,3 @@ export { render } from "./render";
export { setAttributes } from "./attributes";
export { addEventListeners, removeEventListeners } from "./eventListeners";
export { SVGParser } from "./svgParser";
const VERSION = "1.1.9";

async function getLatestVersion(packageName: string) {
try {
let response = await fetch(
`https://cdn.jsdelivr.net/npm/${packageName}/package.json`
);
let latest_version = (await response.json()).version;

return latest_version as string;
} catch (error) {
return undefined;
}
}

getLatestVersion("@patelka2211/dominar").then((latest_version) => {
if (latest_version !== undefined && VERSION < latest_version)
console.warn(
`You are using Dominar "v${VERSION}".\n\nDominar "v${latest_version}" is available. Visit https://patelka2211.github.io/dominar/ and follow provided instructions to upgrade to the latest version.`
);
});
2 changes: 1 addition & 1 deletion website-stuff/config.terser.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

terser "./js/index.iife.js" -c -m -o "./js/index.iife.js"
terser "./js/index.bundle.js" -c -m -o "./js/index.bundle.js"
File renamed without changes.
2 changes: 1 addition & 1 deletion website-stuff/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
input: "./js/index.js",
output: {
file: "./js/index.iife.js",
file: "./js/index.bundle.js",
format: "iife",
},
};

0 comments on commit b03b797

Please sign in to comment.