From 0266f3dba5cabc784a8ff2e8adfb700c100003c9 Mon Sep 17 00:00:00 2001
From: Sam Avanesov
Date: Sun, 9 Jul 2023 10:23:56 -0400
Subject: [PATCH 1/8] Build config setup
---
demo/App.tsx | 11 -----------
package.json | 30 ++++++++++++++++++++++++++++--
tsconfig.build.json | 22 ++++++++++++++++++++++
3 files changed, 50 insertions(+), 13 deletions(-)
create mode 100644 tsconfig.build.json
diff --git a/demo/App.tsx b/demo/App.tsx
index 78a6a32..86e0189 100644
--- a/demo/App.tsx
+++ b/demo/App.tsx
@@ -14,17 +14,6 @@ function App() {
capabilities.
-
-
-
- Edit src/App.tsx
and save to test HMR
-
-
-
- Click on the Vite and React logos to learn more
-
>
);
}
diff --git a/package.json b/package.json
index da6604a..a1cb985 100644
--- a/package.json
+++ b/package.json
@@ -2,11 +2,37 @@
"name": "devtools-chopper",
"private": true,
"version": "0.0.0",
+ "license": "MIT",
+ "description": "Chopper is a Javascript log display devtool which allows you to monitor application logs in DOM",
+ "bugs": {
+ "url": "https://github.com/savanesoff/overdrag/issues"
+ },
+ "homepage": "https://savanesoff.github.io/overdrag-vanilla-demo",
+ "keywords": [
+ "logger",
+ "dom logger",
+ "control points",
+ "overdrag",
+ "log monitor"
+ ],
"type": "module",
+ "author": {
+ "name": "Samvel Avanesov",
+ "email": "sam.avanesoff@gmail.com"
+ },
+ "types": "./dist/types/index.d.ts",
+ "main": "./dist/index.js",
"scripts": {
"dev": "vite",
- "build": "tsc && vite build",
- "preview": "vite preview"
+ "build:demo": "tsc && vite build",
+ "preview": "vite preview",
+ "prepublish": "pnpm run build",
+ "predeploy": "pnpm run prepublish",
+ "clean": "rm -rf ./dist",
+ "build": "pnpm run clean && pnpm run build:esm",
+ "build:esm": "tsc -p ./tsconfig.build.json && mv ./dist/index.js ./dist/index.mjs",
+ "prepack": "pnpm run build",
+ "test": "vitest --run"
},
"devDependencies": {
"react": "^18.2.0",
diff --git a/tsconfig.build.json b/tsconfig.build.json
new file mode 100644
index 0000000..dcd4975
--- /dev/null
+++ b/tsconfig.build.json
@@ -0,0 +1,22 @@
+{
+ "compilerOptions": {
+ "lib": ["ES2022", "DOM"],
+ "target": "ES2022",
+ "module": "ESNext",
+ "moduleResolution": "bundler",
+ "outDir": "./dist",
+ "declarationDir": "./dist/types",
+ "forceConsistentCasingInFileNames": true,
+ "skipLibCheck": false,
+ "declaration": true,
+ "declarationMap": true,
+ "allowSyntheticDefaultImports": true,
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true,
+ "esModuleInterop": true
+ },
+ "files": ["./src/index.ts"]
+}
From f80905d2073e775ca9f8e04af38269acf95dbc35 Mon Sep 17 00:00:00 2001
From: Sam Avanesov
Date: Sun, 9 Jul 2023 11:35:24 -0400
Subject: [PATCH 2/8] set demo ts config
---
tsconfig.build.demo.json | 23 +++++++++++++++++++++++
tsconfig.json | 8 ++++----
2 files changed, 27 insertions(+), 4 deletions(-)
create mode 100644 tsconfig.build.demo.json
diff --git a/tsconfig.build.demo.json b/tsconfig.build.demo.json
new file mode 100644
index 0000000..96b543f
--- /dev/null
+++ b/tsconfig.build.demo.json
@@ -0,0 +1,23 @@
+{
+ "compilerOptions": {
+ "target": "ES2022",
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
+ "module": "ESNext",
+ "skipLibCheck": true,
+
+ /* Bundler mode */
+ "moduleResolution": "bundler",
+ "outDir": "dist-demo",
+ "resolveJsonModule": true,
+ "jsx": "react-jsx",
+
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true,
+ "baseUrl": "."
+ },
+ "files": ["demo/main.tsx"],
+ "references": [{ "path": "tsconfig.node.json" }]
+}
diff --git a/tsconfig.json b/tsconfig.json
index 2ddc47e..b2d55a1 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -8,13 +8,13 @@
/* Bundler mode */
"moduleResolution": "bundler",
- "outDir": "dist",
- "declarationDir": "dist/types",
+ "outDir": "dist-demo",
"resolveJsonModule": true,
"isolatedModules": false,
"jsx": "react-jsx",
- "declaration": true,
- "declarationMap": true,
+ // because this is a demo config
+ "declaration": false,
+ "declarationMap": false,
/* Linting */
"strict": true,
From ac46785dc7440d8fb4a559218f70f6e2d1664053 Mon Sep 17 00:00:00 2001
From: Sam Avanesov
Date: Sun, 9 Jul 2023 13:05:25 -0400
Subject: [PATCH 3/8] Demo build and deployment configuration
---
.gitignore | 1 +
demo-build.sh | 55 +++++++++++++++++
demo/App.tsx | 3 -
package.json | 13 ++--
pnpm-lock.yaml | 127 +++++++++++++++++++++++++++++++++++++++
tsconfig.build.demo.json | 4 +-
vite.config.ts | 3 +
7 files changed, 195 insertions(+), 11 deletions(-)
create mode 100644 demo-build.sh
diff --git a/.gitignore b/.gitignore
index 0583967..4370d00 100644
--- a/.gitignore
+++ b/.gitignore
@@ -81,6 +81,7 @@ typings/
# Nuxt.js build / generate output
.nuxt
dist
+dist-demo
# Gatsby files
.cache/
diff --git a/demo-build.sh b/demo-build.sh
new file mode 100644
index 0000000..b4130ee
--- /dev/null
+++ b/demo-build.sh
@@ -0,0 +1,55 @@
+# replaces tsconfig.json with custom tsconfig.json specified by the user
+# to build demo app with custom tsconfig.json using vite
+# Usage: demo-build.sh --path
+# Example: demo-build.sh --path ./tsconfig.demo.json
+# Note: tsconfig.json is renamed to tsconfig.json.bak
+# Note: tsconfig.json.bak is renamed to tsconfig.json after the build
+# Don't forget to ensure "build.outDir" is set to "dist-demo" in vite.config.ts
+# "build": {
+# "outDir": "dist-demo",
+# }
+# Also, ensure it matches custom ts config "outDir" value
+
+if [ $# -eq 0 ]
+ then
+ echo "No arguments supplied"
+ exit 1
+fi
+
+if [ $1 != "--path" ]
+ then
+ echo "--path argument is required"
+ echo "Usage: demo-build.sh --path "
+ echo $1
+ exit 1
+fi
+
+if [ -z $2 ]
+ then
+ echo "--path value is required"
+ echo "Usage: demo-build.sh --path "
+ exit 1
+fi
+# extract the path to the custom ts config
+CUSTOM_TS_CONFIG=$2
+echo "path to custom ts config: $CUSTOM_TS_CONFIG"
+
+# rename the tsconfig.json to tsconfig.json.bak
+mv ./tsconfig.json ./tsconfig.json.bak
+
+# copy the custom ts config to tsconfig.json
+cp $CUSTOM_TS_CONFIG ./tsconfig.json
+
+# searchString="/dist/"
+# replaceString="/dist-demo/"
+# filename="package.json"
+# sed -i s:$searchString:$replaceString:gi $filename
+# "types": "./dist/types/index.d.ts",
+# "main": "./dist/index.js",
+# build the library
+echo "building library"
+pnpm tsc && pnpm vite build --base=./
+
+
+# rename the tsconfig.json.bak to tsconfig.json
+mv ./tsconfig.json.bak ./tsconfig.json
\ No newline at end of file
diff --git a/demo/App.tsx b/demo/App.tsx
index 86e0189..8c98140 100644
--- a/demo/App.tsx
+++ b/demo/App.tsx
@@ -1,10 +1,7 @@
-import { useState } from "react";
import "./App.css";
import "./chopper";
function App() {
- const [count, setCount] = useState(0);
-
return (
<>
devtools-chopper
diff --git a/package.json b/package.json
index a1cb985..f6f97c0 100644
--- a/package.json
+++ b/package.json
@@ -5,9 +5,9 @@
"license": "MIT",
"description": "Chopper is a Javascript log display devtool which allows you to monitor application logs in DOM",
"bugs": {
- "url": "https://github.com/savanesoff/overdrag/issues"
+ "url": "https://github.com/savanesoff/devtools-chopper/issues"
},
- "homepage": "https://savanesoff.github.io/overdrag-vanilla-demo",
+ "homepage": "https://savanesoff.github.io/devtools-chopper",
"keywords": [
"logger",
"dom logger",
@@ -24,7 +24,9 @@
"main": "./dist/index.js",
"scripts": {
"dev": "vite",
- "build:demo": "tsc && vite build",
+ "clean:demo": "rm -rf ./dist-demo",
+ "build:demo": "bash ./demo-build.sh --path tsconfig.build.demo.json",
+ "deploy:demo": "pnpm run build:demo && gh-pages -d dist-demo",
"preview": "vite preview",
"prepublish": "pnpm run build",
"predeploy": "pnpm run prepublish",
@@ -35,8 +37,6 @@
"test": "vitest --run"
},
"devDependencies": {
- "react": "^18.2.0",
- "react-dom": "^18.2.0",
"@changesets/cli": "^2.26.2",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
@@ -48,7 +48,10 @@
"eslint": "^8.38.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.3.4",
+ "gh-pages": "^5.0.0",
"jsdom": "^22.1.0",
+ "react": "^18.2.0",
+ "react-dom": "^18.2.0",
"typescript": "^5.0.2",
"vite": "^4.3.9",
"vitest": "^0.32.4",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a46b231..aec180d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -43,6 +43,9 @@ devDependencies:
eslint-plugin-react-refresh:
specifier: ^0.3.4
version: 0.3.4(eslint@8.38.0)
+ gh-pages:
+ specifier: ^5.0.0
+ version: 5.0.0
jsdom:
specifier: ^22.1.0
version: 22.1.0
@@ -1165,11 +1168,23 @@ packages:
is-array-buffer: 3.0.2
dev: true
+ /array-union@1.0.2:
+ resolution: {integrity: sha512-Dxr6QJj/RdU/hCaBjOfxW+q6lyuVE6JFWIrAUpuOOhoJJoQ99cUn3igRaHVB5P9WrgFVN0FfArM3x0cueOU8ng==}
+ engines: {node: '>=0.10.0'}
+ dependencies:
+ array-uniq: 1.0.3
+ dev: true
+
/array-union@2.1.0:
resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==}
engines: {node: '>=8'}
dev: true
+ /array-uniq@1.0.3:
+ resolution: {integrity: sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==}
+ engines: {node: '>=0.10.0'}
+ dev: true
+
/array.prototype.flat@1.3.1:
resolution: {integrity: sha512-roTU0KWIOmJ4DRLmwKd19Otg0/mT3qPNt0Qb3GWW8iObuZXxrjB/pzn0R3hqpRSWg4HCwqx+0vwOnWnvlOyeIA==}
engines: {node: '>= 0.4'}
@@ -1189,6 +1204,10 @@ packages:
resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==}
dev: true
+ /async@3.2.4:
+ resolution: {integrity: sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==}
+ dev: true
+
/asynckit@0.4.0:
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
dev: true
@@ -1366,6 +1385,14 @@ packages:
delayed-stream: 1.0.0
dev: true
+ /commander@2.20.3:
+ resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
+ dev: true
+
+ /commondir@1.0.1:
+ resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==}
+ dev: true
+
/concat-map@0.0.1:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
dev: true
@@ -1559,6 +1586,10 @@ packages:
webidl-conversions: 7.0.0
dev: true
+ /email-addresses@5.0.0:
+ resolution: {integrity: sha512-4OIPYlA6JXqtVn8zpHpGiI7vE6EQOAg16aGnDMIAlZVinnoZ8208tW1hAbjWydgN/4PLTT9q+O1K6AH/vALJGw==}
+ dev: true
+
/emoji-regex@8.0.0:
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
dev: true
@@ -1905,6 +1936,20 @@ packages:
flat-cache: 3.0.4
dev: true
+ /filename-reserved-regex@2.0.0:
+ resolution: {integrity: sha512-lc1bnsSr4L4Bdif8Xb/qrtokGbq5zlsms/CYH8PP+WtCkGNF65DPiQY8vG3SakEdRn8Dlnm+gW/qWKKjS5sZzQ==}
+ engines: {node: '>=4'}
+ dev: true
+
+ /filenamify@4.3.0:
+ resolution: {integrity: sha512-hcFKyUG57yWGAzu1CMt/dPzYZuv+jAJUT85bL8mrXvNe6hWj6yEHEc4EdcgiA6Z3oi1/9wXJdZPXF2dZNgwgOg==}
+ engines: {node: '>=8'}
+ dependencies:
+ filename-reserved-regex: 2.0.0
+ strip-outer: 1.0.1
+ trim-repeated: 1.0.0
+ dev: true
+
/fill-range@7.0.1:
resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==}
engines: {node: '>=8'}
@@ -1912,6 +1957,15 @@ packages:
to-regex-range: 5.0.1
dev: true
+ /find-cache-dir@3.3.2:
+ resolution: {integrity: sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==}
+ engines: {node: '>=8'}
+ dependencies:
+ commondir: 1.0.1
+ make-dir: 3.1.0
+ pkg-dir: 4.2.0
+ dev: true
+
/find-up@4.1.0:
resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==}
engines: {node: '>=8'}
@@ -2036,6 +2090,20 @@ packages:
get-intrinsic: 1.2.1
dev: true
+ /gh-pages@5.0.0:
+ resolution: {integrity: sha512-Nqp1SjkPIB94Xw/3yYNTUL+G2dxlhjvv1zeN/4kMC1jfViTEqhtVz/Ba1zSXHuvXCN9ADNS1dN4r5/J/nZWEQQ==}
+ engines: {node: '>=10'}
+ hasBin: true
+ dependencies:
+ async: 3.2.4
+ commander: 2.20.3
+ email-addresses: 5.0.0
+ filenamify: 4.3.0
+ find-cache-dir: 3.3.2
+ fs-extra: 8.1.0
+ globby: 6.1.0
+ dev: true
+
/glob-parent@5.1.2:
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
engines: {node: '>= 6'}
@@ -2087,6 +2155,17 @@ packages:
slash: 3.0.0
dev: true
+ /globby@6.1.0:
+ resolution: {integrity: sha512-KVbFv2TQtbzCoxAnfD6JcHZTYCzyliEaaeM/gH8qQdkKr5s0OP9scEgvdcngyk7AVdY6YVW/TJHd+lQ/Df3Daw==}
+ engines: {node: '>=0.10.0'}
+ dependencies:
+ array-union: 1.0.2
+ glob: 7.2.3
+ object-assign: 4.1.1
+ pify: 2.3.0
+ pinkie-promise: 2.0.1
+ dev: true
+
/gopd@1.0.1:
resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==}
dependencies:
@@ -2680,6 +2759,13 @@ packages:
'@jridgewell/sourcemap-codec': 1.4.15
dev: true
+ /make-dir@3.1.0:
+ resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
+ engines: {node: '>=8'}
+ dependencies:
+ semver: 6.3.0
+ dev: true
+
/map-obj@1.0.1:
resolution: {integrity: sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==}
engines: {node: '>=0.10.0'}
@@ -2797,6 +2883,11 @@ packages:
resolution: {integrity: sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==}
dev: true
+ /object-assign@4.1.1:
+ resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
+ engines: {node: '>=0.10.0'}
+ dev: true
+
/object-inspect@1.12.3:
resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==}
dev: true
@@ -2973,11 +3064,28 @@ packages:
engines: {node: '>=8.6'}
dev: true
+ /pify@2.3.0:
+ resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==}
+ engines: {node: '>=0.10.0'}
+ dev: true
+
/pify@4.0.1:
resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==}
engines: {node: '>=6'}
dev: true
+ /pinkie-promise@2.0.1:
+ resolution: {integrity: sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==}
+ engines: {node: '>=0.10.0'}
+ dependencies:
+ pinkie: 2.0.4
+ dev: true
+
+ /pinkie@2.0.4:
+ resolution: {integrity: sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==}
+ engines: {node: '>=0.10.0'}
+ dev: true
+
/pkg-dir@4.2.0:
resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==}
engines: {node: '>=8'}
@@ -3251,6 +3359,11 @@ packages:
hasBin: true
dev: true
+ /semver@6.3.0:
+ resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==}
+ hasBin: true
+ dev: true
+
/semver@7.5.4:
resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==}
engines: {node: '>=10'}
@@ -3458,6 +3571,13 @@ packages:
acorn: 8.10.0
dev: true
+ /strip-outer@1.0.1:
+ resolution: {integrity: sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==}
+ engines: {node: '>=0.10.0'}
+ dependencies:
+ escape-string-regexp: 1.0.5
+ dev: true
+
/supports-color@5.5.0:
resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
engines: {node: '>=4'}
@@ -3540,6 +3660,13 @@ packages:
engines: {node: '>=8'}
dev: true
+ /trim-repeated@1.0.0:
+ resolution: {integrity: sha512-pkonvlKk8/ZuR0D5tLW8ljt5I8kmxp2XKymhepUeOdCEfKpZaktSArkLHZt76OB1ZvO9bssUsDty4SWhLvZpLg==}
+ engines: {node: '>=0.10.0'}
+ dependencies:
+ escape-string-regexp: 1.0.5
+ dev: true
+
/tslib@1.14.1:
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
dev: true
diff --git a/tsconfig.build.demo.json b/tsconfig.build.demo.json
index 96b543f..9626f4c 100644
--- a/tsconfig.build.demo.json
+++ b/tsconfig.build.demo.json
@@ -17,7 +17,5 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"baseUrl": "."
- },
- "files": ["demo/main.tsx"],
- "references": [{ "path": "tsconfig.node.json" }]
+ }
}
diff --git a/vite.config.ts b/vite.config.ts
index ec3d01f..f9a3768 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -5,6 +5,9 @@ import { defineConfig } from "vite";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
+ build: {
+ outDir: "./dist-demo",
+ },
test: {
globals: true,
environment: "jsdom",
From af2ecaa6ec3ba6dab756ca27a2685777725f1e67 Mon Sep 17 00:00:00 2001
From: Sam Avanesov
Date: Sun, 9 Jul 2023 13:22:43 -0400
Subject: [PATCH 4/8] Setup test env
---
tests/constructor.spec.ts | 64 +++++++++++++++++++++++++++++++++++++++
tests/setup.ts | 1 +
tsconfig.json | 2 +-
3 files changed, 66 insertions(+), 1 deletion(-)
create mode 100644 tests/constructor.spec.ts
create mode 100644 tests/setup.ts
diff --git a/tests/constructor.spec.ts b/tests/constructor.spec.ts
new file mode 100644
index 0000000..03daf16
--- /dev/null
+++ b/tests/constructor.spec.ts
@@ -0,0 +1,64 @@
+import "vitest-dom/extend-expect";
+import Chopper from "./../src";
+
+function isNullOrUndefined(value: any): boolean {
+ return value === null || value === undefined;
+}
+
+/**
+ * Mock HTMLElement.offsetParent as it is not supported in JEST DOM
+ */
+Object.defineProperty(HTMLElement.prototype, "offsetParent", {
+ get() {
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
+ let element = this;
+ while (
+ !isNullOrUndefined(element) &&
+ (isNullOrUndefined(element.style) ||
+ isNullOrUndefined(element.style.display) ||
+ element.style.display.toLowerCase() !== "none")
+ ) {
+ element = element.parentNode;
+ }
+
+ if (!isNullOrUndefined(element)) {
+ return null;
+ }
+
+ if (
+ !isNullOrUndefined(this.style) &&
+ !isNullOrUndefined(this.style.position) &&
+ this.style.position.toLowerCase() === "fixed"
+ ) {
+ return null;
+ }
+
+ if (
+ this.tagName.toLowerCase() === "html" ||
+ this.tagName.toLowerCase() === "body"
+ ) {
+ return null;
+ }
+
+ return this.parentNode;
+ },
+});
+
+export function getRandomValue(min = 0, max = 50) {
+ return min + Math.round(Math.random() * (max - min));
+}
+
+export function getRandomPixelValue(min = 0, max = 50) {
+ return `${getRandomValue(min, max)}px`;
+}
+
+describe("Constructor", () => {
+ afterEach(() => {
+ // Reset mock function calls
+ vi.clearAllMocks();
+ });
+
+ it(`Should be defined`, () => {
+ expect(Chopper).toBeDefined();
+ });
+});
diff --git a/tests/setup.ts b/tests/setup.ts
new file mode 100644
index 0000000..97cd9be
--- /dev/null
+++ b/tests/setup.ts
@@ -0,0 +1 @@
+import "vitest-dom/extend-expect";
diff --git a/tsconfig.json b/tsconfig.json
index b2d55a1..bd5ae62 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -25,6 +25,6 @@
"baseUrl": ".",
"types": ["vitest/globals"]
},
- "include": ["src", "demo"],
+ "include": ["src", "demo", "tests"],
"references": [{ "path": "tsconfig.node.json" }]
}
From f9e1cf5002e8f092c10c9b13007dc2afb1c95659 Mon Sep 17 00:00:00 2001
From: Sam Avanesov
Date: Sun, 9 Jul 2023 13:38:47 -0400
Subject: [PATCH 5/8] Use textContent instead of innerText
---
src/index.ts | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/index.ts b/src/index.ts
index 506f768..28ee3f4 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -161,7 +161,9 @@ export default class Chopper extends Overdrag {
this.on("click", () => {
this.render = !this.render;
- this.statusElement.innerText = this.render ? "click to pause" : "paused";
+ this.statusElement.textContent = this.render
+ ? "click to pause"
+ : "paused";
});
this.outputElement.addEventListener("scroll", () => {
@@ -171,7 +173,9 @@ export default class Chopper extends Overdrag {
this.outputElement.getBoundingClientRect().height <
5;
- this.statusElement.innerText = this.render ? "click to pause" : "paused";
+ this.statusElement.textContent = this.render
+ ? "click to pause"
+ : "paused";
});
}
@@ -181,7 +185,7 @@ export default class Chopper extends Overdrag {
const levels = Object.keys(this.gate) as Levels[];
const index = levels.indexOf(this.level);
this.level = levels[(index + 1) % levels.length];
- this.logLevelElement.innerText = this.level;
+ this.logLevelElement.textContent = this.level;
this.setLevelButtonColor();
});
@@ -216,7 +220,7 @@ export default class Chopper extends Overdrag {
}) {
const element = document.createElement(type);
element.classList.add(...classNames);
- if (text) element.innerText = text;
+ if (text) element.textContent = text;
parent.appendChild(element);
return element;
}
From a614e55b144f71ecbed85320b2e658e5379844f5 Mon Sep 17 00:00:00 2001
From: Sam Avanesov
Date: Sun, 9 Jul 2023 13:39:04 -0400
Subject: [PATCH 6/8] Tested rendering chopper
---
package.json | 2 +-
pnpm-lock.yaml | 188 +-------------------------------------
tests/constructor.spec.ts | 6 ++
3 files changed, 12 insertions(+), 184 deletions(-)
diff --git a/package.json b/package.json
index f6f97c0..10f896c 100644
--- a/package.json
+++ b/package.json
@@ -38,7 +38,7 @@
},
"devDependencies": {
"@changesets/cli": "^2.26.2",
- "@testing-library/jest-dom": "^5.16.5",
+ "@testing-library/dom": "^9.3.1",
"@testing-library/react": "^14.0.0",
"@types/react": "^18.0.37",
"@types/react-dom": "^18.0.11",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index aec180d..c82971f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -13,9 +13,9 @@ devDependencies:
'@changesets/cli':
specifier: ^2.26.2
version: 2.26.2
- '@testing-library/jest-dom':
- specifier: ^5.16.5
- version: 5.16.5
+ '@testing-library/dom':
+ specifier: ^9.3.1
+ version: 9.3.1
'@testing-library/react':
specifier: ^14.0.0
version: 14.0.0(react-dom@18.2.0)(react@18.2.0)
@@ -75,10 +75,6 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
- /@adobe/css-tools@4.2.0:
- resolution: {integrity: sha512-E09FiIft46CmH5Qnjb0wsW54/YQd69LsxeKUOWawmws1XWvyFGURnAChH0mlr7YPFR1ofwvUQfcL0J3lMxXqPA==}
- dev: true
-
/@babel/code-frame@7.22.5:
resolution: {integrity: sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ==}
engines: {node: '>=6.9.0'}
@@ -546,13 +542,6 @@ packages:
resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==}
dev: true
- /@jest/expect-utils@29.6.1:
- resolution: {integrity: sha512-o319vIf5pEMx0LmzSxxkYYxo4wrRLKHq9dP1yJU7FoPTB0LfAKSz8SWD6D/6U3v/O52t9cF5t+MeJiRsfk7zMw==}
- engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
- dependencies:
- jest-get-type: 29.4.3
- dev: true
-
/@jest/schemas@29.6.0:
resolution: {integrity: sha512-rxLjXyJBTL4LQeJW3aKo0M/+GkCOXsO+8i9Iu7eDb6KwtP65ayoDsitrdPBtujxQ88k4wI2FNYfa6TOGwSn6cQ==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
@@ -560,18 +549,6 @@ packages:
'@sinclair/typebox': 0.27.8
dev: true
- /@jest/types@29.6.1:
- resolution: {integrity: sha512-tPKQNMPuXgvdOn2/Lg9HNfUvjYVGolt04Hp03f5hAk878uwOLikN+JzeLY0HcVgKgFl9Hs3EIqpu3WX27XNhnw==}
- engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
- dependencies:
- '@jest/schemas': 29.6.0
- '@types/istanbul-lib-coverage': 2.0.4
- '@types/istanbul-reports': 3.0.1
- '@types/node': 20.3.3
- '@types/yargs': 17.0.24
- chalk: 4.1.2
- dev: true
-
/@jridgewell/sourcemap-codec@1.4.15:
resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==}
dev: true
@@ -747,21 +724,6 @@ packages:
pretty-format: 27.5.1
dev: true
- /@testing-library/jest-dom@5.16.5:
- resolution: {integrity: sha512-N5ixQ2qKpi5OLYfwQmUb/5mSV9LneAcaUfp32pn4yCnpb8r/Yz0pXFPck21dIicKmi+ta5WRAknkZCfA8refMA==}
- engines: {node: '>=8', npm: '>=6', yarn: '>=1'}
- dependencies:
- '@adobe/css-tools': 4.2.0
- '@babel/runtime': 7.22.6
- '@types/testing-library__jest-dom': 5.14.7
- aria-query: 5.3.0
- chalk: 3.0.0
- css.escape: 1.5.1
- dom-accessibility-api: 0.5.16
- lodash: 4.17.21
- redent: 3.0.0
- dev: true
-
/@testing-library/react@14.0.0(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-S04gSNJbYE30TlIMLTzv6QCTzt9AqIF5y6s6SzVFILNcNvbV/jU96GeiTPillGQo+Ny64M/5PV7klNYYgv5Dfg==}
engines: {node: '>=14'}
@@ -801,29 +763,6 @@ packages:
ci-info: 3.8.0
dev: true
- /@types/istanbul-lib-coverage@2.0.4:
- resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==}
- dev: true
-
- /@types/istanbul-lib-report@3.0.0:
- resolution: {integrity: sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==}
- dependencies:
- '@types/istanbul-lib-coverage': 2.0.4
- dev: true
-
- /@types/istanbul-reports@3.0.1:
- resolution: {integrity: sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==}
- dependencies:
- '@types/istanbul-lib-report': 3.0.0
- dev: true
-
- /@types/jest@29.5.2:
- resolution: {integrity: sha512-mSoZVJF5YzGVCk+FsDxzDuH7s+SCkzrgKZzf0Z0T2WudhBUPoF6ktoTPC4R0ZoCPCV5xUvuU6ias5NvxcBcMMg==}
- dependencies:
- expect: 29.6.1
- pretty-format: 29.6.0
- dev: true
-
/@types/json-schema@7.0.12:
resolution: {integrity: sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==}
dev: true
@@ -870,26 +809,6 @@ packages:
resolution: {integrity: sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==}
dev: true
- /@types/stack-utils@2.0.1:
- resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==}
- dev: true
-
- /@types/testing-library__jest-dom@5.14.7:
- resolution: {integrity: sha512-PFDoAbR9y8pD9+41oM1Yy0nVCkaRPlklmDZoPCXhNpR0ZO13HAYWqdNEjLtvIiveBmfB/+jdvmuOVeOXehKOaA==}
- dependencies:
- '@types/jest': 29.5.2
- dev: true
-
- /@types/yargs-parser@21.0.0:
- resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==}
- dev: true
-
- /@types/yargs@17.0.24:
- resolution: {integrity: sha512-6i0aC7jV6QzQB8ne1joVZ0eSFIstHsCrobmOtghM11yGlH0j43FKL2UhWdELkyps0zuf7qVTUVCCR+tgSlyLLw==}
- dependencies:
- '@types/yargs-parser': 21.0.0
- dev: true
-
/@typescript-eslint/eslint-plugin@5.59.0(@typescript-eslint/parser@5.59.0)(eslint@8.38.0)(typescript@5.1.6):
resolution: {integrity: sha512-p0QgrEyrxAWBecR56gyn3wkG15TJdI//eetInP3zYRewDh0XS+DhB3VUAd3QqvziFsfaQIoIuZMxZRB7vXYaYw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -1052,7 +971,7 @@ packages:
dependencies:
magic-string: 0.30.1
pathe: 1.1.1
- pretty-format: 29.6.0
+ pretty-format: 29.6.1
dev: true
/@vitest/spy@0.32.4:
@@ -1066,7 +985,7 @@ packages:
dependencies:
diff-sequences: 29.4.3
loupe: 2.3.6
- pretty-format: 29.6.0
+ pretty-format: 29.6.1
dev: true
/abab@2.0.6:
@@ -1301,14 +1220,6 @@ packages:
supports-color: 5.5.0
dev: true
- /chalk@3.0.0:
- resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==}
- engines: {node: '>=8'}
- dependencies:
- ansi-styles: 4.3.0
- supports-color: 7.2.0
- dev: true
-
/chalk@4.1.2:
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=10'}
@@ -1730,11 +1641,6 @@ packages:
engines: {node: '>=0.8.0'}
dev: true
- /escape-string-regexp@2.0.0:
- resolution: {integrity: sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==}
- engines: {node: '>=8'}
- dev: true
-
/escape-string-regexp@4.0.0:
resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
engines: {node: '>=10'}
@@ -1875,18 +1781,6 @@ packages:
resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==}
dev: false
- /expect@29.6.1:
- resolution: {integrity: sha512-XEdDLonERCU1n9uR56/Stx9OqojaLAQtZf9PrCHH9Hl8YXiEIka3H4NXJ3NOIBmQJTg7+j7buh34PMHfJujc8g==}
- engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
- dependencies:
- '@jest/expect-utils': 29.6.1
- '@types/node': 20.3.3
- jest-get-type: 29.4.3
- jest-matcher-utils: 29.6.1
- jest-message-util: 29.6.1
- jest-util: 29.6.1
- dev: true
-
/extendable-error@0.1.7:
resolution: {integrity: sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==}
dev: true
@@ -2518,58 +2412,6 @@ packages:
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
dev: true
- /jest-diff@29.6.1:
- resolution: {integrity: sha512-FsNCvinvl8oVxpNLttNQX7FAq7vR+gMDGj90tiP7siWw1UdakWUGqrylpsYrpvj908IYckm5Y0Q7azNAozU1Kg==}
- engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
- dependencies:
- chalk: 4.1.2
- diff-sequences: 29.4.3
- jest-get-type: 29.4.3
- pretty-format: 29.6.1
- dev: true
-
- /jest-get-type@29.4.3:
- resolution: {integrity: sha512-J5Xez4nRRMjk8emnTpWrlkyb9pfRQQanDrvWHhsR1+VUfbwxi30eVcZFlcdGInRibU4G5LwHXpI7IRHU0CY+gg==}
- engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
- dev: true
-
- /jest-matcher-utils@29.6.1:
- resolution: {integrity: sha512-SLaztw9d2mfQQKHmJXKM0HCbl2PPVld/t9Xa6P9sgiExijviSp7TnZZpw2Fpt+OI3nwUO/slJbOfzfUMKKC5QA==}
- engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
- dependencies:
- chalk: 4.1.2
- jest-diff: 29.6.1
- jest-get-type: 29.4.3
- pretty-format: 29.6.1
- dev: true
-
- /jest-message-util@29.6.1:
- resolution: {integrity: sha512-KoAW2zAmNSd3Gk88uJ56qXUWbFk787QKmjjJVOjtGFmmGSZgDBrlIL4AfQw1xyMYPNVD7dNInfIbur9B2rd/wQ==}
- engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
- dependencies:
- '@babel/code-frame': 7.22.5
- '@jest/types': 29.6.1
- '@types/stack-utils': 2.0.1
- chalk: 4.1.2
- graceful-fs: 4.2.11
- micromatch: 4.0.5
- pretty-format: 29.6.1
- slash: 3.0.0
- stack-utils: 2.0.6
- dev: true
-
- /jest-util@29.6.1:
- resolution: {integrity: sha512-NRFCcjc+/uO3ijUVyNOQJluf8PtGCe/W6cix36+M3cTFgiYqFOOW5MgN4JOOcvbUhcKTYVd1CvHz/LWi8d16Mg==}
- engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
- dependencies:
- '@jest/types': 29.6.1
- '@types/node': 20.3.3
- chalk: 4.1.2
- ci-info: 3.8.0
- graceful-fs: 4.2.11
- picomatch: 2.3.1
- dev: true
-
/js-sdsl@4.4.1:
resolution: {integrity: sha512-6Gsx8R0RucyePbWqPssR8DyfuXmLBooYN5cZFZKjHGnQuaf7pEzhtpceagJxVu4LqhYY5EYA7nko3FmeHZ1KbA==}
dev: true
@@ -2716,10 +2558,6 @@ packages:
resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==}
dev: true
- /lodash@4.17.21:
- resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
- dev: true
-
/loose-envify@1.4.0:
resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
hasBin: true
@@ -3140,15 +2978,6 @@ packages:
react-is: 17.0.2
dev: true
- /pretty-format@29.6.0:
- resolution: {integrity: sha512-XH+D4n7Ey0iSR6PdAnBs99cWMZdGsdKrR33iUHQNr79w1szKTCIZDVdXuccAsHVwDBp0XeWPfNEoaxP9EZgRmQ==}
- engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
- dependencies:
- '@jest/schemas': 29.6.0
- ansi-styles: 5.2.0
- react-is: 18.2.0
- dev: true
-
/pretty-format@29.6.1:
resolution: {integrity: sha512-7jRj+yXO0W7e4/tSJKoR7HRIHLPPjtNaUGG2xxKQnGvPNRkgWcQ0AZX6P4KBRJN4FcTBWb3sa7DVUJmocYuoog==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
@@ -3472,13 +3301,6 @@ packages:
resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==}
dev: true
- /stack-utils@2.0.6:
- resolution: {integrity: sha512-XlkWvfIm6RmsWtNJx+uqtKLS8eqFbxUg0ZzLXqY0caEy9l7hruX8IpiDnjsLavoBgqCCR71TqWO8MaXYheJ3RQ==}
- engines: {node: '>=10'}
- dependencies:
- escape-string-regexp: 2.0.0
- dev: true
-
/stackback@0.0.2:
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
dev: true
diff --git a/tests/constructor.spec.ts b/tests/constructor.spec.ts
index 03daf16..6f704ac 100644
--- a/tests/constructor.spec.ts
+++ b/tests/constructor.spec.ts
@@ -1,3 +1,4 @@
+import { screen } from "@testing-library/dom";
import "vitest-dom/extend-expect";
import Chopper from "./../src";
@@ -61,4 +62,9 @@ describe("Constructor", () => {
it(`Should be defined`, () => {
expect(Chopper).toBeDefined();
});
+
+ it("Should render chopper", () => {
+ new Chopper({ name: "Super name" });
+ expect(screen.getByText("Super name")).toBeInTheDocument();
+ });
});
From 49bcd4c7f6b2dbe244ed7f53dddb56af54243662 Mon Sep 17 00:00:00 2001
From: Sam Avanesov
Date: Sun, 9 Jul 2023 14:09:39 -0400
Subject: [PATCH 7/8] github workflows
---
.github/workflows/publish.yaml | 51 ++++++++++++++++++++++++++++++++++
.github/workflows/test.yaml | 44 +++++++++++++++++++++++++++++
package.json | 28 ++++++++++++++++---
3 files changed, 119 insertions(+), 4 deletions(-)
create mode 100644 .github/workflows/publish.yaml
create mode 100644 .github/workflows/test.yaml
diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml
new file mode 100644
index 0000000..46daefc
--- /dev/null
+++ b/.github/workflows/publish.yaml
@@ -0,0 +1,51 @@
+name: Publish NPM Package
+on:
+ push:
+ branches:
+ - "main"
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
+permissions:
+ contents: read
+ pages: write
+ id-token: write
+
+# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
+# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
+concurrency:
+ group: "publish"
+ cancel-in-progress: false
+
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: pnpm/action-setup@v2
+ with:
+ version: 8
+ - uses: actions/setup-node@v3
+ with:
+ node-version: 16.x
+ cache: "pnpm"
+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
+
+ - run: pnpm install --frozen-lockfile
+
+ - name: NPM Release
+ id: changesets
+ uses: changesets/action@v1
+ with:
+ publish: pnpm run release
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+
+ - name: Deploy Github Page
+ run: pnpm run deploy:demo
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ publish_dir: public
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
new file mode 100644
index 0000000..b7e2242
--- /dev/null
+++ b/.github/workflows/test.yaml
@@ -0,0 +1,44 @@
+name: Unit Tests
+run-name: ${{ github.actor }} is running unit tests... 🚀
+on:
+ pull_request:
+ types: [opened, synchronize, reopened, updated]
+
+jobs:
+ cache-and-install:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Install Node.js
+ uses: actions/setup-node@v3
+ with:
+ node-version: 16
+
+ - uses: pnpm/action-setup@v2
+ name: Install pnpm
+ id: pnpm-install
+ with:
+ version: 8
+ run_install: false
+
+ - name: Get pnpm store directory
+ id: pnpm-cache
+ shell: bash
+ run: |
+ echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
+
+ - uses: actions/cache@v3
+ name: Setup pnpm cache
+ with:
+ path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
+ restore-keys: |
+ ${{ runner.os }}-pnpm-store-
+
+ - name: Install dependencies
+ run: pnpm install --frozen-lockfile
+ - name: run tests
+ run: pnpm test
diff --git a/package.json b/package.json
index 10f896c..9f60b81 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,15 @@
"name": "Samvel Avanesov",
"email": "sam.avanesoff@gmail.com"
},
+ "packageManager": "^pnpm@8.6.6",
+ "release": {
+ "branches": [
+ "main"
+ ]
+ },
+ "publishConfig": {
+ "access": "public"
+ },
"types": "./dist/types/index.d.ts",
"main": "./dist/index.js",
"scripts": {
@@ -28,13 +37,12 @@
"build:demo": "bash ./demo-build.sh --path tsconfig.build.demo.json",
"deploy:demo": "pnpm run build:demo && gh-pages -d dist-demo",
"preview": "vite preview",
- "prepublish": "pnpm run build",
- "predeploy": "pnpm run prepublish",
"clean": "rm -rf ./dist",
"build": "pnpm run clean && pnpm run build:esm",
"build:esm": "tsc -p ./tsconfig.build.json && mv ./dist/index.js ./dist/index.mjs",
"prepack": "pnpm run build",
- "test": "vitest --run"
+ "test": "vitest --run",
+ "release": "pnpm build && pnpm test && pnpm changeset publish"
},
"devDependencies": {
"@changesets/cli": "^2.26.2",
@@ -59,5 +67,17 @@
},
"dependencies": {
"overdrag": "^1.0.1"
- }
+ },
+ "exports": {
+ ".": {
+ "import": {
+ "types": "./dist/types/index.d.ts",
+ "default": "./dist/index.mjs"
+ }
+ },
+ "./package.json": "./package.json"
+ },
+ "files": [
+ "dist/**/*"
+ ]
}
From 4f7b04c7a97eebc4e211f84dc288b2b0603c4a2e Mon Sep 17 00:00:00 2001
From: Sam Avanesov
Date: Sun, 9 Jul 2023 14:12:07 -0400
Subject: [PATCH 8/8] Changeset setup
---
.changeset/README.md | 8 ++++++++
.changeset/config.json | 11 +++++++++++
.changeset/stale-walls-laugh.md | 5 +++++
3 files changed, 24 insertions(+)
create mode 100644 .changeset/README.md
create mode 100644 .changeset/config.json
create mode 100644 .changeset/stale-walls-laugh.md
diff --git a/.changeset/README.md b/.changeset/README.md
new file mode 100644
index 0000000..e5b6d8d
--- /dev/null
+++ b/.changeset/README.md
@@ -0,0 +1,8 @@
+# Changesets
+
+Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
+with multi-package repos, or single-package repos to help you version and publish your code. You can
+find the full documentation for it [in our repository](https://github.com/changesets/changesets)
+
+We have a quick list of common questions to get you started engaging with this project in
+[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
diff --git a/.changeset/config.json b/.changeset/config.json
new file mode 100644
index 0000000..ab848d1
--- /dev/null
+++ b/.changeset/config.json
@@ -0,0 +1,11 @@
+{
+ "$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json",
+ "changelog": "@changesets/cli/changelog",
+ "commit": false,
+ "fixed": [],
+ "linked": [],
+ "access": "restricted",
+ "baseBranch": "main",
+ "updateInternalDependencies": "patch",
+ "ignore": []
+}
diff --git a/.changeset/stale-walls-laugh.md b/.changeset/stale-walls-laugh.md
new file mode 100644
index 0000000..40f0475
--- /dev/null
+++ b/.changeset/stale-walls-laugh.md
@@ -0,0 +1,5 @@
+---
+"devtools-chopper": minor
+---
+
+Initial NPM release