Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move plugins folder from electron to root folder #366

Merged
merged 4 commits into from
Oct 16, 2023
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
3 changes: 3 additions & 0 deletions .github/workflows/linter-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/publish-plugins.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- name: Check Path Change
run: |
git config --global user.email "[email protected]"
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 "[email protected]"
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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

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

Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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";

Expand Down

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

Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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");

Expand Down

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

Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
Loading
Loading