Skip to content

Commit

Permalink
Rename plugin-core to core (janhq#370)
Browse files Browse the repository at this point in the history
Co-authored-by: Hien To <>
  • Loading branch information
hiento09 authored Oct 17, 2023
1 parent bb1186a commit 3e2d878
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 33 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/publish-plugin-core.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Publish Plugin-core Package to npmjs
name: Publish plugin core Package to npmjs
on:
push:
branches:
- main
paths:
- "plugin-core/**"
- ".github/workflows/publish-plugin-core.yml"
- "!plugin-core/package.json"
- "core/**"
- ".github/workflows/publish-core.yml"
- "!core/package.json"
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -23,7 +23,7 @@ jobs:
- name: "Auto Increase package Version"
run: |
# Extract current version
current_version=$(jq -r '.version' plugin-core/package.json)
current_version=$(jq -r '.version' core/package.json)
# Break the version into its components
major_version=$(echo $current_version | cut -d "." -f 1)
Expand All @@ -37,7 +37,7 @@ jobs:
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' plugin-core/package.json > /tmp/package.json && mv /tmp/package.json plugin-core/package.json
jq --arg version "$new_version" '.version = $version' core/package.json > /tmp/package.json && mv /tmp/package.json core/package.json
# Print the new version
echo "Updated package.json version to: $new_version"
Expand All @@ -48,19 +48,19 @@ jobs:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: npm install && npm run build
working-directory: ./plugin-core
working-directory: ./core
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: ./plugin-core
working-directory: ./core

- name: "Commit new version to main and create tag"
run: |
version=$(jq -r '.version' plugin-core/package.json)
version=$(jq -r '.version' core/package.json)
git config --global user.email "[email protected]"
git config --global user.name "Service Account"
git add plugin-core/package.json
git add core/package.json
git commit -m "${GITHUB_REPOSITORY}: Update tag build $version"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:main
git tag -a plugin-core-$version -m "${GITHUB_REPOSITORY}: Update tag build $version for plugin-core"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin plugin-core-$version
git tag -a core-$version -m "${GITHUB_REPOSITORY}: Update tag build $version for core"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin core-$version
30 changes: 15 additions & 15 deletions plugin-core/README.md → core/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## @janhq/plugin-core
## @janhq/core

> The module includes functions for communicating with core APIs, registering plugin extensions, and exporting type definitions.
Expand All @@ -8,10 +8,10 @@

```js
// javascript
const core = require("@janhq/plugin-core");
const core = require("@janhq/core");

// typescript
import { core } from "@janhq/plugin-core";
import { core } from "@janhq/core";
```

### Register Plugin Extensions
Expand All @@ -23,7 +23,7 @@ You can `register` any function as a plugin extension using `CoreServiceAPI` bel
Once the extension is registered, it can be used by other plugins or components in the Jan platform. For example, a UI component might use the DataService.GetConversations extension to retrieve a list of conversations to display to the user.

```js
import { RegisterExtensionPoint, DataService } from "@janhq/plugin-core";
import { RegisterExtensionPoint, DataService } from "@janhq/core";

function getConversations() {
// Your logic here
Expand All @@ -43,7 +43,7 @@ The Core API allows you to interact with local data storage. Here are a couple o
You can use the store.insertOne function to insert data into a specific collection in the local data store.

```js
import { store } from "@janhq/plugin-core";
import { store } from "@janhq/core";

function insertData() {
store.insertOne("conversations", { name: "meow" });
Expand All @@ -59,7 +59,7 @@ store.getOne(collectionName, key) retrieves a single document that matches the p
store.getMany(collectionName, selector, sort) retrieves multiple documents that match the provided selector in the specified collection.

```js
import { store } from "@janhq/plugin-core";
import { store } from "@janhq/core";

function getData() {
const selector = { name: "meow" };
Expand Down Expand Up @@ -104,7 +104,7 @@ function deleteData() {
You can subscribe to NewMessageRequest events by defining a function to handle the event and registering it with the events object:

```js
import { events } from "@janhq/plugin-core";
import { events } from "@janhq/core";

function handleMessageRequest(message: NewMessageRequest) {
// Your logic here. For example:
Expand All @@ -122,7 +122,7 @@ export function init({ register }) {
In this example, we're defining a function called handleMessageRequest that takes a NewMessageRequest object as its argument. We're also defining a function called registerListener that registers the handleMessageRequest function as a listener for NewMessageRequest events using the on method of the events object.

```js
import { events } from "@janhq/plugin-core";
import { events } from "@janhq/core";

function handleMessageRequest(data: NewMessageRequest) {
// Your logic here. For example:
Expand All @@ -138,10 +138,10 @@ function handleMessageRequest(data: NewMessageRequest) {

### Preferences

To register plugin preferences, you can use the preferences object from the @janhq/plugin-core package. Here's an example of how to register and retrieve plugin preferences:
To register plugin preferences, you can use the preferences object from the @janhq/core package. Here's an example of how to register and retrieve plugin preferences:

```js
import { PluginService, preferences } from "@janhq/plugin-core";
import { PluginService, preferences } from "@janhq/core";

const pluginName = "your-first-plugin";
const preferenceKey = "";
Expand All @@ -165,7 +165,7 @@ In this example, we're registering preference update handlers and plugin prefere
To retrieve the values of the registered preferences, we're using the get method of the preferences object and passing in the name of the plugin and the name of the preference.

```js
import { preferences } from "@janhq/plugin-core";
import { preferences } from "@janhq/core";

const pluginName = "your-first-plugin";
const preferenceKey = "apiKey";
Expand All @@ -182,11 +182,11 @@ To access the Core API in your plugin, you can follow the code examples and expl
##### Import Core API and Store Module
In your main entry code (e.g., `index.ts`), start by importing the necessary modules and functions from the `@janhq/plugin-core` library.
In your main entry code (e.g., `index.ts`), start by importing the necessary modules and functions from the `@janhq/core` library.
```js
// index.ts
import { core } from "@janhq/plugin-core";
import { core } from "@janhq/core";
```
#### Perform File Operations
Expand Down Expand Up @@ -219,11 +219,11 @@ To execute a plugin module in the main process of your application, you can foll
##### Import the `core` Object
In your main process code (e.g., `index.ts`), start by importing the `core` object from the `@janhq/plugin-core` library.
In your main process code (e.g., `index.ts`), start by importing the `core` object from the `@janhq/core` library.
```js
// index.ts
import { core } from "@janhq/plugin-core";
import { core } from "@janhq/core";
```
##### Define the Module Path
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions plugin-core/package-lock.json → core/package-lock.json

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

4 changes: 2 additions & 2 deletions plugin-core/package.json → core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janhq/plugin-core",
"version": "0.1.8",
"name": "@janhq/core",
"version": "0.1.0",
"description": "Plugin core lib",
"keywords": [
"jan",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3e2d878

Please sign in to comment.