Move plugins folder from electron to root folder (#366)

* Move plugins folder from electron to root folder

* Add CICD for plugins

* Fix error electron import plugin after change plugin name

* Add remove app cache on CI test pipeline

---------

Co-authored-by: Hien To <>
This commit is contained in:
hiento09 2023-10-16 19:18:00 +07:00 committed by GitHub
parent e5f636c0f1
commit e1e6fddcdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 5249 additions and 5554 deletions

View File

@ -32,6 +32,7 @@ jobs:
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
rm -rf ~/Library/Application\ Support/jan
- name: Getting the repo
uses: actions/checkout@v3
@ -58,6 +59,7 @@ jobs:
- name: Clean workspace
run: |
Remove-Item -Path .\* -Force -Recurse
Remove-Item -Path "$Env:APPDATA\jan" -Force -Recurse
- name: Getting the repo
uses: actions/checkout@v3
@ -85,6 +87,7 @@ jobs:
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
rm -rf ~/.config/jan
- name: Getting the repo
uses: actions/checkout@v3

91
.github/workflows/publish-plugins.yml vendored Normal file
View File

@ -0,0 +1,91 @@
name: Publish plugins/$dir Package to npmjs
on:
push:
branches:
- main
paths:
- "plugins/**"
- ".github/workflows/publish-plugins.yml"
- "!plugins/*/package.json"
jobs:
build:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
token: ${{ secrets.PAT_SERVICE_ACCOUNT }}
- name: Install jq
uses: dcarbone/install-jq-action@v2.0.1
- name: Check Path Change
run: |
git config --global user.email "service@jan.ai"
git config --global user.name "Service Account"
echo "Changes in these directories trigger the build:"
changed_dirs=$(git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}" diff --name-only HEAD HEAD~1 | grep 'plugins/' | awk -F/ '{print $2}' | uniq)
echo $changed_dirs > /tmp/change_dir.txt
- name: "Auto Increase package Version"
run: |
cd plugins
for dir in $(cat /tmp/change_dir.txt)
do
echo "$dir"
# Extract current version
current_version=$(jq -r '.version' $dir/package.json)
# Break the version into its components
major_version=$(echo $current_version | cut -d "." -f 1)
minor_version=$(echo $current_version | cut -d "." -f 2)
patch_version=$(echo $current_version | cut -d "." -f 3)
# Increment the patch version by one
new_patch_version=$((patch_version+1))
# Construct the new version
new_version="$major_version.$minor_version.$new_patch_version"
# Replace the old version with the new version in package.json
jq --arg version "$new_version" '.version = $version' $dir/package.json > /tmp/package.json && mv /tmp/package.json $dir/package.json
# Print the new version
echo "Updated $dir package.json version to: $new_version"
done
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- name: Publish npm packages
run: |
cd plugins
for dir in $(cat /tmp/change_dir.txt)
do
echo $dir
cd $dir
npm install && npm run build
npm publish --access public
cd ..
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "Commit new version to main and create tag"
run: |
for dir in $(cat /tmp/change_dir.txt)
do
echo "$dir"
version=$(jq -r '.version' plugins/$dir/package.json)
git config --global user.email "service@jan.ai"
git config --global user.name "Service Account"
git add plugins/$dir/package.json
git commit -m "${GITHUB_REPOSITORY}: Update tag build $version for $dir"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:main
git tag -a $dir-$version -m "${GITHUB_REPOSITORY}: Update tag build $version for $dir"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin $dir-$version
done

View File

@ -22,8 +22,8 @@
"build:core": "cd plugin-core && yarn install && yarn run build",
"build:web": "yarn workspace jan-web build && cpx \"web/out/**\" \"electron/renderer/\"",
"build:electron": "yarn workspace jan build",
"build:plugins": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./electron/core/plugins/data-plugin && npm install && npm run postinstall\" \"cd ./electron/core/plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./electron/core/plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./electron/core/plugins/monitoring-plugin && npm install && npm run postinstall\" && concurrently --kill-others-on-fail \"cd ./electron/core/plugins/data-plugin && npm run build:publish\" \"cd ./electron/core/plugins/inference-plugin && npm run build:publish\" \"cd ./electron/core/plugins/model-management-plugin && npm run build:publish\" \"cd ./electron/core/plugins/monitoring-plugin && npm run build:publish\"",
"build:plugins-darwin": "rimraf ./electron/core/pre-install/*.tgz && concurrently \"cd ./electron/core/plugins/data-plugin && npm install && npm run postinstall\" \"cd ./electron/core/plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./electron/core/plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./electron/core/plugins/monitoring-plugin && npm install && npm run postinstall\" && chmod +x ./electron/auto-sign.sh && ./electron/auto-sign.sh && concurrently \"cd ./electron/core/plugins/data-plugin && npm run build:publish\" \"cd ./electron/core/plugins/inference-plugin && npm run build:publish\" \"cd ./electron/core/plugins/model-management-plugin && npm run build:publish\" \"cd ./electron/core/plugins/monitoring-plugin && npm run build:publish\"",
"build:plugins": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm install && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"",
"build:plugins-darwin": "rimraf ./electron/core/pre-install/*.tgz && concurrently \"cd ./plugins/data-plugin && npm install && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && chmod +x ./electron/auto-sign.sh && ./electron/auto-sign.sh && concurrently \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"",
"build": "yarn build:web && yarn build:electron",
"build:darwin": "yarn build:web && yarn workspace jan build:darwin",
"build:win32": "yarn build:web && yarn workspace jan build:win32",

View File

@ -1,7 +1,7 @@
import { core, store, RegisterExtensionPoint, StoreService, DataService, PluginService } from "@janhq/plugin-core";
const PluginName = "data-plugin";
const MODULE_PATH = "data-plugin/dist/cjs/module.js";
const PluginName = "@janhq/data-plugin";
const MODULE_PATH = "@janhq/data-plugin/dist/cjs/module.js";
/**
* Create a collection on data store

View File

@ -1,12 +1,12 @@
{
"name": "data-plugin",
"version": "1.0.4",
"name": "@janhq/data-plugin",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "data-plugin",
"version": "1.0.4",
"name": "@janhq/data-plugin",
"version": "1.0.0",
"bundleDependencies": [
"pouchdb-node",
"pouchdb-find"
@ -14,7 +14,7 @@
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
"@janhq/plugin-core": "^0.1.5",
"@janhq/plugin-core": "^0.1.8",
"pouchdb-find": "^8.0.1",
"pouchdb-node": "^8.0.1"
},
@ -29,15 +29,6 @@
"webpack-cli": "^5.1.4"
}
},
"../../../../plugin-core": {
"name": "@janhq/plugin-core",
"version": "0.1.6",
"license": "MIT",
"devDependencies": {
"@types/node": "^12.0.2",
"typescript": "^5.2.2"
}
},
"node_modules/@cspotcode/source-map-support": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
@ -60,8 +51,9 @@
}
},
"node_modules/@janhq/plugin-core": {
"resolved": "../../../../plugin-core",
"link": true
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@janhq/plugin-core/-/plugin-core-0.1.8.tgz",
"integrity": "sha512-wJe+8ndMQLGLSV36Jt1V3s5lmH+nQw87ol2NMhHuVWXfwf+DAO1GTdTeHfemHWdcB/oUY1HVRvsNh8DvBgbh/w=="
},
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.3",

View File

@ -1,6 +1,6 @@
{
"name": "data-plugin",
"version": "1.0.4",
"name": "@janhq/data-plugin",
"version": "1.0.0",
"description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.",
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg",
"main": "dist/esm/index.js",
@ -12,7 +12,7 @@
"scripts": {
"build": "tsc --project ./config/tsconfig.esm.json && tsc --project ./config/tsconfig.cjs.json && webpack --config webpack.config.js",
"postinstall": "rimraf ./data-plugin*.tgz && npm run build",
"build:publish": "npm pack && cpx *.tgz ../../pre-install"
"build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install"
},
"exports": {
"import": "./dist/esm/index.js",
@ -39,7 +39,7 @@
"node_modules"
],
"dependencies": {
"@janhq/plugin-core": "^0.1.7",
"@janhq/plugin-core": "^0.1.8",
"pouchdb-find": "^8.0.1",
"pouchdb-node": "^8.0.1"
}

View File

@ -1,6 +1,6 @@
import { EventName, InferenceService, NewMessageRequest, PluginService, core, events, store } from "@janhq/plugin-core";
const PluginName = "inference-plugin";
const PluginName = "@janhq/inference-plugin";
const MODULE_PATH = `${PluginName}/dist/module.js`;
const inferenceUrl = "http://localhost:3928/llama/chat_completion";

View File

@ -1,11 +1,11 @@
{
"name": "inference-plugin",
"name": "@janhq/inference-plugin",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "inference-plugin",
"name": "@janhq/inference-plugin",
"version": "1.0.0",
"bundleDependencies": [
"tcp-port-used",
@ -14,7 +14,7 @@
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
"@janhq/plugin-core": "^0.1.5",
"@janhq/plugin-core": "^0.1.8",
"kill-port-process": "^3.2.0",
"tcp-port-used": "^1.0.2",
"ts-loader": "^9.5.0"
@ -29,15 +29,6 @@
"node": ">=18.0.0"
}
},
"../../../../plugin-core": {
"name": "@janhq/plugin-core",
"version": "0.1.6",
"license": "MIT",
"devDependencies": {
"@types/node": "^12.0.2",
"typescript": "^5.2.2"
}
},
"node_modules/@discoveryjs/json-ext": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz",
@ -48,8 +39,9 @@
}
},
"node_modules/@janhq/plugin-core": {
"resolved": "../../../../plugin-core",
"link": true
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@janhq/plugin-core/-/plugin-core-0.1.8.tgz",
"integrity": "sha512-wJe+8ndMQLGLSV36Jt1V3s5lmH+nQw87ol2NMhHuVWXfwf+DAO1GTdTeHfemHWdcB/oUY1HVRvsNh8DvBgbh/w=="
},
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.3",

View File

@ -1,5 +1,5 @@
{
"name": "inference-plugin",
"name": "@janhq/inference-plugin",
"version": "1.0.0",
"description": "Inference Plugin, powered by @janhq/nitro, bring a high-performance Llama model inference in pure C++.",
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/command-line.svg",
@ -12,7 +12,7 @@
"scripts": {
"build": "tsc -b . && webpack --config webpack.config.js",
"postinstall": "rimraf ./*.tgz && npm run build && rimraf dist/nitro/* && cpx \"nitro/**\" \"dist/nitro\"",
"build:publish": "npm pack && cpx *.tgz ../../pre-install"
"build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install"
},
"exports": {
".": "./dist/index.js",
@ -25,7 +25,7 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@janhq/plugin-core": "^0.1.7",
"@janhq/plugin-core": "^0.1.8",
"kill-port-process": "^3.2.0",
"tcp-port-used": "^1.0.2",
"ts-loader": "^9.5.0"

View File

@ -1,7 +1,7 @@
import { ModelManagementService, PluginService, RegisterExtensionPoint, core, store } from "@janhq/plugin-core";
const PluginName = "model-management-plugin";
const MODULE_PATH = "model-management-plugin/dist/module.js";
const PluginName = "@janhq/model-management-plugin";
const MODULE_PATH = "@janhq/model-management-plugin/dist/module.js";
const getDownloadedModels = () => core.invokePluginFunc(MODULE_PATH, "getDownloadedModels");

View File

@ -1,11 +1,11 @@
{
"name": "model-management-plugin",
"name": "@janhq/model-management-plugin",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "model-management-plugin",
"name": "@janhq/model-management-plugin",
"version": "1.0.0",
"bundleDependencies": [
"@huggingface/hub"
@ -14,7 +14,7 @@
"license": "MIT",
"dependencies": {
"@huggingface/hub": "^0.8.5",
"@janhq/plugin-core": "^0.1.5",
"@janhq/plugin-core": "^0.1.8",
"ts-loader": "^9.5.0"
},
"devDependencies": {
@ -24,15 +24,6 @@
"webpack-cli": "^5.1.4"
}
},
"../../../../plugin-core": {
"name": "@janhq/plugin-core",
"version": "0.1.6",
"license": "MIT",
"devDependencies": {
"@types/node": "^12.0.2",
"typescript": "^5.2.2"
}
},
"node_modules/@discoveryjs/json-ext": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz",
@ -55,8 +46,9 @@
}
},
"node_modules/@janhq/plugin-core": {
"resolved": "../../../../plugin-core",
"link": true
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@janhq/plugin-core/-/plugin-core-0.1.8.tgz",
"integrity": "sha512-wJe+8ndMQLGLSV36Jt1V3s5lmH+nQw87ol2NMhHuVWXfwf+DAO1GTdTeHfemHWdcB/oUY1HVRvsNh8DvBgbh/w=="
},
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.3",

View File

@ -1,5 +1,5 @@
{
"name": "model-management-plugin",
"name": "@janhq/model-management-plugin",
"version": "1.0.0",
"description": "Model Management Plugin provides model exploration and seamless downloads",
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/queue-list.svg",
@ -12,7 +12,7 @@
"scripts": {
"build": "tsc -b . && webpack --config webpack.config.js",
"postinstall": "rimraf ./*.tgz && npm run build",
"build:publish": "npm pack && cpx *.tgz ../../pre-install"
"build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install"
},
"devDependencies": {
"cpx": "^1.5.0",
@ -27,7 +27,7 @@
],
"dependencies": {
"@huggingface/hub": "^0.8.5",
"@janhq/plugin-core": "^0.1.7",
"@janhq/plugin-core": "^0.1.8",
"ts-loader": "^9.5.0"
},
"bundledDependencies": [

View File

@ -1,5 +1,5 @@
// Provide an async method to manipulate the price provided by the extension point
const PLUGIN_NAME = "monitoring-plugin/dist/module.js";
const PLUGIN_NAME = "@janhq/monitoring-plugin/dist/module.js";
const getResourcesInfo = () => {
return new Promise((resolve) => {

View File

@ -1,11 +1,11 @@
{
"name": "monitoring-plugin",
"name": "@janhq/monitoring-plugin",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "monitoring-plugin",
"name": "@janhq/monitoring-plugin",
"version": "1.0.0",
"bundleDependencies": [
"systeminformation"

View File

@ -1,5 +1,5 @@
{
"name": "monitoring-plugin",
"name": "@janhq/monitoring-plugin",
"version": "1.0.0",
"description": "Utilizing systeminformation, it provides essential System and OS information retrieval",
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/cpu-chip.svg",
@ -12,7 +12,7 @@
"scripts": {
"build": "webpack --config webpack.config.js",
"postinstall": "rimraf ./*.tgz && npm run build && cpx \"module.js\" \"dist\"",
"build:publish": "npm pack && cpx *.tgz ../../pre-install"
"build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install"
},
"devDependencies": {
"rimraf": "^3.0.2",

View File

@ -9,7 +9,7 @@ import {
} from "@janhq/plugin-core";
import { Configuration, OpenAIApi } from "azure-openai";
const PluginName = "openai-plugin";
const PluginName = "@janhq/openai-plugin";
const setRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
XMLHttpRequest.prototype.setRequestHeader = function newSetRequestHeader(key: string, val: string) {

View File

@ -1,5 +1,5 @@
{
"name": "azure-openai-plugin",
"name": "@janhq/azure-openai-plugin",
"version": "1.0.0",
"description": "Inference plugin for Azure OpenAI",
"icon": "https://static-assets.jan.ai/openai-icon.jpg",
@ -12,7 +12,7 @@
"scripts": {
"build": "tsc -b . && webpack --config webpack.config.js",
"postinstall": "rimraf ./*.tgz && npm run build && rimraf dist/nitro/* && cpx \"nitro/**\" \"dist/nitro\"",
"build:publish": "npm pack && cpx *.tgz ../../pre-install"
"build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install"
},
"exports": {
".": "./dist/index.js",
@ -25,7 +25,7 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@janhq/plugin-core": "^0.1.7",
"@janhq/plugin-core": "^0.1.8",
"azure-openai": "^0.9.4",
"kill-port-process": "^3.2.0",
"tcp-port-used": "^1.0.2",

View File

@ -13,7 +13,7 @@
"dependencies": {
"@headlessui/react": "^1.7.15",
"@heroicons/react": "^2.0.18",
"@janhq/plugin-core": "file:../plugin-core",
"@janhq/plugin-core": "^0.1.8",
"@tailwindcss/typography": "^0.5.9",
"@types/react": "18.2.15",
"@types/react-dom": "18.2.7",

10591
yarn.lock

File diff suppressed because it is too large Load Diff