Skip to content

Commit

Permalink
chore(plugin): core plugin in create
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Dec 18, 2021
1 parent 1d75828 commit 0cf2d67
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 35 deletions.
22 changes: 19 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
{
"name": "root",
"private": true,
"workspaces": ["packages/*"],
"workspaces": [
"packages/*"
],
"scripts": {
"bootstrap": "lerna bootstrap --use-workspaces",
"dev": "lerna exec yarn dev",
"build": "lerna exec yarn build",
"test": "lerna exec yarn test",
"lint": "lerna exec yarn lint",
"deploy": "yarn bootstrap && yarn build"
"deploy": "yarn bootstrap && yarn build",
"release:validate": "yarn test && yarn build",
"release:initial": "yarn release:validate && standard-version --first-release",
"release:minor": "yarn release:validate && standard-version --release-as minor",
"release:alpha:minor": "yarn release:validate && standard-version --release-as minor --prerelease alpha",
"release:beta:minor": "yarn release:validate && standard-version --release-as minor --prerelease beta",
"release:patch": "yarn release:validate && standard-version --release-as patch",
"release:alpha:patch": "yarn release:validate && standard-version --release-as patch --prerelease alpha",
"release:beta:patch": "yarn release:validate && standard-version --release-as patch --prerelease beta",
"release:major": "yarn release:validate && standard-version --release-as major",
"release:alpha:major": "yarn release:validate && standard-version --release-as major --prerelease alpha",
"release:beta:major": "yarn release:validate && standard-version --release-as major --prerelease beta",
"release:alpha": "yarn release:validate && standard-version --prerelease alpha",
"release:beta": "yarn release:validate && standard-version --prerelease beta"
},
"devDependencies": {
"lerna": "4.0.0"
"lerna": "4.0.0",
"standard-version": "^9.3.2"
}
}
18 changes: 3 additions & 15 deletions packages/better-write-app/src/plugin/logger/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
import { PluginTypes } from 'better-write-types'
import { PluginLoggerActions } from './actions'
import { PluginLoggerProject } from './project'
import { createPlugin } from 'better-write-plugin-core'

export const LoggerPlugin = (): PluginTypes.Plugin => {
const defines = {
name: 'logger',
} as PluginTypes.PluginDefines

const init = (
emitter: PluginTypes.PluginEmitter,
stores: PluginTypes.PluginStores
) => {
PluginLoggerActions(emitter, stores)
PluginLoggerProject(emitter, stores)
}

return { init, defines }
}
export const LoggerPlugin = () =>
createPlugin({ name: 'logger' }, [PluginLoggerActions, PluginLoggerProject])
18 changes: 3 additions & 15 deletions packages/better-write-app/src/plugin/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
import { PluginTypes } from 'better-write-types'
import { createPlugin } from 'better-write-plugin-core'
import { PluginThemeSet } from './set'

export const ThemePlugin = (): PluginTypes.Plugin => {
const defines = {
name: 'theme',
} as PluginTypes.PluginDefines

const init = (
emitter: PluginTypes.PluginEmitter,
stores: PluginTypes.PluginStores
) => {
PluginThemeSet(emitter, stores)
}

return { init, defines }
}
export const ThemePlugin = () =>
createPlugin({ name: 'theme' }, [PluginThemeSet])
2 changes: 1 addition & 1 deletion packages/better-write-app/test/raw/raw_v1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { useFormat } from '../../src/use/format'
import { bold, italic, link, useRaw } from '../../src/use/raw'
import { Entity } from '../../src/types/context'
import { Entity } from 'better-write-types'

describe('Editor Converter - v1', () => {
beforeEach(() => {})
Expand Down
1 change: 1 addition & 0 deletions packages/better-write-entity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"types": "dist/index.d.ts",
"scripts": {
"dev": "rimraf ./dist && unbuild",
"test": "echo \"Error: no test specified\"",
"build": "rimraf ./dist && unbuild",
"lint": "prettier --write src/"
},
Expand Down
1 change: 1 addition & 0 deletions packages/better-write-plugin-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"dev": "rimraf ./dist && unbuild",
"build": "rimraf ./dist && unbuild",
"test": "echo \"Error: no test specified\"",
"lint": "prettier --write src/"
},
"files": [
Expand Down
13 changes: 13 additions & 0 deletions packages/better-write-plugin-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,18 @@ export function createPluginCore(options?: PluginTypes.CoreOption): PluginTypes.
return plugin;
}

export const createPlugin = (
defines: PluginTypes.PluginDefines,
cb: Array<Function>
): PluginTypes.Plugin => {
const init = (emitter: PluginTypes.PluginEmitter, stores: PluginTypes.PluginStores) => {
cb.forEach((fn) => {
fn && fn(emitter, stores);
});
};

return { init, defines };
};

export * as Cycle from './cycle';
export * as On from './on';
1 change: 1 addition & 0 deletions packages/better-write-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"types": "dist/index.d.ts",
"scripts": {
"dev": "rimraf ./dist && unbuild",
"test": "echo \"Error: no test specified\"",
"build": "rimraf ./dist && unbuild",
"lint": "prettier --write src/"
},
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9492,7 +9492,7 @@ stack-utils@^2.0.3:
dependencies:
escape-string-regexp "^2.0.0"

standard-version@9.3.2:
standard-version@9.3.2, standard-version@^9.3.2:
version "9.3.2"
resolved "https://registry.yarnpkg.com/standard-version/-/standard-version-9.3.2.tgz#28db8c1be66fd2d736f28f7c5de7619e64cd6dab"
integrity sha512-u1rfKP4o4ew7Yjbfycv80aNMN2feTiqseAhUhrrx2XtdQGmu7gucpziXe68Z4YfHVqlxVEzo4aUA0Iu3VQOTgQ==
Expand Down

0 comments on commit 0cf2d67

Please sign in to comment.