Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/comment-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Comment when opened

on:
issues:
types:
- opened
jobs:
comment:
runs-on: ubuntu-latest
steps:
- run: gh issue comment $ISSUE --body "Thank you for opening this issue!"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE: ${{ github.event.issue.html_url }}
54 changes: 54 additions & 0 deletions .github/workflows/publish-beta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Beta

on:
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- src
- package.json
- tsconfig.json

jobs:
publish-beta:
name: Publish beta
runs-on: ubuntu-latest
environment: publish
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'

- name: Setup beta version
uses: kearisp/npm-version-action@v0.0.1
with:
tag: beta

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-npm-

- name: Install dependencies
shell: bash
run: npm install

- name: Publish beta to NPM
if: ${{ github.repository_owner == 'kearisp' }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
run: npm publish --provenance --tag beta
72 changes: 72 additions & 0 deletions .github/workflows/publish-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Publish

on:
release:
types:
- released

jobs:
publish:
name: Publish latest
runs-on: ubuntu-latest
environment: publish
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-npm-

- name: Install dependencies
shell: bash
run: npm install

- name: Publish to NPM
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
run: npm publish --provenance

unpublish-beta:
name: Unpublish beta
if: ${{ github.repository_owner == 'kearisp' }}
runs-on: ubuntu-latest
environment: publish
needs: publish
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'

- name: Unpublish previous beta versions
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
run: |
PACKAGE_NAME=$(npm pkg get name | sed -e 's/^"//' -e 's/"$//')
PACKAGE_VERSION=$(npm pkg get version | sed -e 's/^"//' -e 's/"$//')
BETA_VERSIONS=$(npm view $PACKAGE_NAME versions --json | jq -r '.[]' | grep -E "$PACKAGE_VERSION-beta\.[0-9]+$")

for VERSION in $BETA_VERSIONS; do
npm unpublish $PACKAGE_NAME@$VERSION --force 2>/dev/null || npm deprecate $PACKAGE_NAME@$VERSION "This is the beta version. Why can't it be deleted?"
done

31 changes: 0 additions & 31 deletions .github/workflows/publish.yml

This file was deleted.

30 changes: 22 additions & 8 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
# misc
/.idea
.idea
.vscode/
/.git
/.gitignore
.DS_Store

# dependencies
/.github
/node_modules
# Source code
/src
/.gitignore
/package-lock.json
/pnpm-lock.yaml
/tsconfig.json
/test
*.spec.js

# Build configs
.env
.env.*
.env.*.local
/package-lock.json
/tsconfig.json
/tsconfig.build.json

# Builds
/lib/tsconfig.tsbuildinfo
/coverage

# Dependency directories
/node_modules

# Development tools
/.github

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# React Canny

[![npm version](https://img.shields.io/npm/v/react-canny.svg)](https://www.npmjs.com/package/react-canny)
[![Publish](https://github.com/kearisp/react-canny/actions/workflows/publish-latest.yml/badge.svg?event=release)](https://github.com/kearisp/react-canny/actions/workflows/publish-latest.yml)
[![License](https://img.shields.io/npm/l/react-canny)](https://github.com/kearisp/react-canny/blob/main/LICENSE)

[![npm total downloads](https://img.shields.io/npm/dt/react-canny.svg)](https://www.npmjs.com/package/react-canny)
[![bundle size](https://img.shields.io/bundlephobia/minzip/react-canny)](https://bundlephobia.com/package/react-canny)


## Description

[Canny.io](https://canny.io/) integration for react
Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"name": "react-canny",
"version": "0.0.7",
"license": "MIT",
"version": "0.0.8",
"author": "Kris Papercut <krispcut@gmail.com>",
"description": "Canny.io integration for react",
"license": "MIT",
"keywords": [
"react",
"canny.io"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"repository": {
"type": "git",
"url": "git+https://github.com/kearisp/react-canny.git"
},
"homepage": "https://github.com/kearisp/react-canny/blob/master/README.md",
"bugs": {
"url": "https://github.com/kearisp/react-canny/issues"
},
"scripts": {
"prepublishOnly": "npm run build",
"start": "npm run watch",
"prepare": "npm run build",
"watch": "tsc --watch",
"build": "tsc --build",
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
20 changes: 6 additions & 14 deletions src/contexts/CannyContext.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
import {
createContext,
useContext
} from "react";

import {createContext, useContext} from "react";
import {Canny} from "../makes";


type CannyContextProps = {
appId?: string;
isLoaded: boolean;
isIdentified: boolean;
canny: Canny;
};

const CannyContext = createContext<CannyContextProps>({
export const CannyContext = createContext<CannyContextProps>({
isLoaded: false,
canny: new Canny(null)
isIdentified: false,
canny: new Canny()
});

const useCannyContext = (): CannyContextProps => {
export const useCannyContext = (): CannyContextProps => {
return useContext(CannyContext);
};


export {
useCannyContext,
CannyContext
};
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
export * from "./contexts";
export * from "./makes";
export * from "./views";

// Old version support
export {CannyFeedback as CannyWidget} from "./views";
55 changes: 28 additions & 27 deletions src/makes/Canny.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,53 @@ export type ChangeLogOptions = {
labelIDs?: string[];
};

export class Canny {
protected static pull: any[][] = [];

class Canny {
public constructor(
protected canny: any
) {}
protected get handle() {
return (window as any).Canny;
}

public identify(appID: string, user: any, callback?: () => void): void {
if(!this.canny) {
protected push(...args: any[]): void {
Canny.pull.push(args);
this.flush();
}

public flush(): void {
if(!this.handle) {
return;
}

this.canny("identify", {appID, user}, callback);
while(Canny.pull.length > 0) {
const row = Canny.pull.shift();

if(row) {
this.handle(...row);
}
}
}

public identify(appID: string, user: any, callback?: () => void): void {
this.push("identify", {appID, user}, callback);
}

public authenticateCannyLink(url: string): string {
if(!this.canny) {
if(!this.handle) {
return url;
}

return this.canny("authenticateCannyLink", url);
return this.handle("authenticateCannyLink", url);
}

public render(options: RenderOptions): void {
if(!this.canny) {
return;
}

this.canny("render", options);
this.push("render", options)
}

public initChangelog(options: ChangeLogOptions): void {
if(!this.canny) {
return;
}

this.canny("initChangelog", options);
this.push("initChangelog", options);
}

public closeChangelog(): void {
if(!this.canny) {
return;
}

this.canny("closeChangelog");
this.push("closeChangelog");
}
}


export {Canny};
Loading