feat: create admin-shared package (#581)

Signed-off-by: Ryan Wang <i@ryanc.cc>
pull/582/head
Ryan Wang 2022-06-16 18:42:13 +08:00 committed by GitHub
parent b9f5d4fb6b
commit 93d154b484
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 206 additions and 3 deletions

View File

@ -27,6 +27,7 @@
"dependencies": { "dependencies": {
"@halo-dev/admin-api": "^1.1.0", "@halo-dev/admin-api": "^1.1.0",
"@halo-dev/components": "workspace:*", "@halo-dev/components": "workspace:*",
"@halo-dev/admin-shared": "workspace:*",
"@vueuse/core": "^8.6.0", "@vueuse/core": "^8.6.0",
"filepond": "^4.30.4", "filepond": "^4.30.4",
"filepond-plugin-image-preview": "^4.6.11", "filepond-plugin-image-preview": "^4.6.11",

View File

@ -0,0 +1,3 @@
module.exports = {
extends: ["../../.eslintrc.cjs"],
};

1
packages/shared/env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="vite/client" />

View File

@ -0,0 +1,44 @@
{
"name": "@halo-dev/admin-shared",
"version": "0.0.0",
"description": "",
"files": [
"dist"
],
"scripts": {
"dev": "vite build --watch",
"build": "vite build"
},
"keywords": [],
"author": {
"name": "@halo-dev",
"url": "https://github.com/halo-dev"
},
"main": "./dist/halo-admin-shared.cjs.js",
"module": "./dist/halo-admin-shared.es.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/halo-admin-shared.cjs.js",
"import": "./dist/halo-admin-shared.es.js"
}
},
"repository": {
"type": "git",
"url": "https://github.com/halo-dev/halo-admin.git",
"directory": "packages/shared"
},
"bugs": {
"url": "https://github.com/halo-dev/halo/issues"
},
"homepage": "https://github.com/halo-dev/halo-admin/tree/next/shared/components#readme",
"license": "MIT",
"devDependencies": {
"vite-plugin-dts": "^1.2.0"
},
"peerDependencies": {
"vue": "^3.2.37",
"vue-router": "^4.0.16"
}
}

View File

@ -0,0 +1,3 @@
module.exports = {
plugins: ["../../prettier.config.js"],
};

View File

View File

@ -0,0 +1,2 @@
export * from "./types/plugin";
export * from "./types/menus";

View File

@ -0,0 +1,14 @@
import type { Component } from "vue";
export interface MenuGroupType {
name?: string;
items: MenuItemType[];
}
export interface MenuItemType {
name: string;
path: string;
icon?: Component;
meta?: Record<string, unknown>;
children?: MenuItemType[];
}

View File

@ -0,0 +1,40 @@
import type { Component } from "vue";
import type { RouteRecordRaw } from "vue-router";
import type { MenuGroupType } from "./menus";
export type ExtensionPointName =
| "POSTS"
| "POST_EDITOR"
| "DASHBOARD"
| "USER_SETTINGS";
// TODO define extension point state
export type ExtensionPointState = Record<string, unknown>;
export interface Plugin {
name: string;
/**
* This components will be registered when plugin is activated.
*/
components?: Component[];
/**
* Activate hook will be called when plugin is activated.
*/
activated?: () => void;
/**
* Deactivate hook will be called when plugin is deactivated.
*/
deactivated?: () => void;
routes?: RouteRecordRaw[];
menus?: MenuGroupType[];
extensionPoints?: Record<
ExtensionPointName,
(state: ExtensionPointState) => void
>;
}

View File

@ -0,0 +1,12 @@
{
"extends": "@vue/tsconfig/tsconfig.web.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}

View File

@ -0,0 +1,14 @@
{
"files": [],
"references": [
{
"path": "./tsconfig.vite-config.json"
},
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.vitest.json"
}
]
}

View File

@ -0,0 +1,8 @@
{
"extends": "@vue/tsconfig/tsconfig.node.json",
"include": ["vite.config.*"],
"compilerOptions": {
"composite": true,
"types": ["node", "vitest"]
}
}

View File

@ -0,0 +1,9 @@
{
"extends": "./tsconfig.app.json",
"exclude": [],
"compilerOptions": {
"composite": true,
"lib": [],
"types": ["node", "jsdom"]
}
}

View File

@ -0,0 +1,44 @@
import { fileURLToPath, URL } from "url";
import { defineConfig } from "vite";
import Vue from "@vitejs/plugin-vue";
import VueJsx from "@vitejs/plugin-vue-jsx";
import path from "path";
import Dts from "vite-plugin-dts";
export default defineConfig({
plugins: [
Vue(),
VueJsx(),
Dts({
entryRoot: "./src",
outputDir: "./dist",
insertTypesEntry: true,
}),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
build: {
outDir: path.resolve(__dirname, "dist"),
lib: {
entry: path.resolve(__dirname, "src/index.ts"),
name: "HaloAdminShared",
formats: ["es", "cjs", "umd", "iife"],
fileName: (format) => `halo-admin-shared.${format}.js`,
},
rollupOptions: {
external: ["vue", "vue-router"],
output: {
globals: {
vue: "Vue",
"vue-router": "VueRouter",
},
exports: "named",
},
},
sourcemap: true,
},
});

View File

@ -5,6 +5,7 @@ importers:
.: .:
specifiers: specifiers:
'@halo-dev/admin-api': ^1.1.0 '@halo-dev/admin-api': ^1.1.0
'@halo-dev/admin-shared': workspace:*
'@halo-dev/components': workspace:* '@halo-dev/components': workspace:*
'@rushstack/eslint-patch': ^1.1.3 '@rushstack/eslint-patch': ^1.1.3
'@tailwindcss/aspect-ratio': ^0.4.0 '@tailwindcss/aspect-ratio': ^0.4.0
@ -52,6 +53,7 @@ importers:
vue-tsc: ^0.34.17 vue-tsc: ^0.34.17
dependencies: dependencies:
'@halo-dev/admin-api': 1.1.0 '@halo-dev/admin-api': 1.1.0
'@halo-dev/admin-shared': link:packages/shared
'@halo-dev/components': link:packages/components '@halo-dev/components': link:packages/components
'@vueuse/core': 8.6.0_vue@3.2.37 '@vueuse/core': 8.6.0_vue@3.2.37
filepond: 4.30.4 filepond: 4.30.4
@ -116,6 +118,12 @@ importers:
unplugin-icons: 0.14.4 unplugin-icons: 0.14.4
vite-plugin-dts: 1.2.0 vite-plugin-dts: 1.2.0
packages/shared:
specifiers:
vite-plugin-dts: ^1.2.0
devDependencies:
vite-plugin-dts: 1.2.0
packages: packages:
/@ampproject/remapping/2.1.2: /@ampproject/remapping/2.1.2:
@ -1803,7 +1811,7 @@ packages:
colors: 1.2.5 colors: 1.2.5
lodash: 4.17.21 lodash: 4.17.21
resolve: 1.17.0 resolve: 1.17.0
semver: 7.3.5 semver: 7.3.7
source-map: 0.6.1 source-map: 0.6.1
typescript: 4.6.4 typescript: 4.6.4
dev: true dev: true
@ -1951,7 +1959,7 @@ packages:
import-lazy: 4.0.0 import-lazy: 4.0.0
jju: 1.4.0 jju: 1.4.0
resolve: 1.17.0 resolve: 1.17.0
semver: 7.3.5 semver: 7.3.7
timsort: 0.3.0 timsort: 0.3.0
z-schema: 5.0.3 z-schema: 5.0.3
dev: true dev: true
@ -4698,7 +4706,7 @@ packages:
dev: true dev: true
/is-extglob/2.1.1: /is-extglob/2.1.1:
resolution: {integrity: sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=} resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==}
engines: {node: '>=0.10.0'} engines: {node: '>=0.10.0'}
dev: true dev: true