diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b71a4239..075ccb5c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: - name: Install pnpm uses: pnpm/action-setup@v2.0.1 with: - version: 6.15.1 + version: 7.1.6 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 @@ -38,6 +38,8 @@ jobs: - name: Install dependencies run: pnpm install + - name: Build packages + run: pnpm build:packages - name: Run code lint check run: pnpm lint - name: Run unit test diff --git a/.gitignore b/.gitignore index 9744124e..f828697d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ node_modules .DS_Store dist dist-ssr -dist-typings histoire-dist coverage *.local diff --git a/env.d.ts b/env.d.ts index 11f02fe2..9f8f1e2c 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1 +1,8 @@ /// + +declare module "*.vue" { + import type { DefineComponent } from "vue"; + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any>; + export default component; +} diff --git a/histoire.config.ts b/histoire.config.ts deleted file mode 100644 index 27bbb71f..00000000 --- a/histoire.config.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { defineConfig } from "histoire"; - -export default defineConfig({ - setupFile: "/src/histoire.setup.ts", -}); diff --git a/package.json b/package.json index 487709a1..539ea4e1 100644 --- a/package.json +++ b/package.json @@ -5,71 +5,73 @@ "prepare": "husky install", "dev": "vite --host", "build": "vue-tsc --noEmit && vite build", + "build:packages": "pnpm --filter './packages/**' build", "preview": "vite preview --port 5050", - "test:unit": "vitest --environment jsdom --run", + "test:unit": "vitest --environment jsdom --run && pnpm run test:unit:packages", "test:unit:watch": "vitest --environment jsdom --watch", "test:unit:ui": "vitest --environment jsdom --watch --ui", "test:unit:coverage": "vitest run --environment jsdom --coverage", "test:e2e": "start-server-and-test preview http://127.0.0.1:5050/ 'cypress open'", "test:e2e:ci": "start-server-and-test preview http://127.0.0.1:5050/ 'cypress run'", - "typecheck": "vue-tsc --noEmit -p tsconfig.app.json --composite false", - "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore", - "story:dev": "histoire dev --port 4000", - "story:build": "histoire build", - "prettier": "prettier --write './src/**/*.{vue,js,jsx,ts,tsx,css,scss,json,yml,yaml,html}'" + "typecheck": "vue-tsc --noEmit -p tsconfig.app.json --composite false && pnpm run typecheck:packages", + "lint": "eslint ./src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore && pnpm run lint:packages", + "prettier": "prettier --write './src/**/*.{vue,js,jsx,ts,tsx,css,scss,json,yml,yaml,html}' && pnpm run prettier:packages", + "typecheck:packages": "pnpm --filter './packages/**' run typecheck", + "lint:packages": "pnpm --filter './packages/**' lint", + "prettier:packages": "pnpm --filter './packages/**' prettier", + "test:unit:packages": "pnpm --filter './packages/**' run test:unit" }, + "workspaces": [ + "packages/*" + ], "dependencies": { - "@halo-dev/admin-api": "^1.0.0", - "@vueuse/core": "^8.5.0", - "filepond": "^4.30.3", + "@halo-dev/admin-api": "^1.1.0", + "@vueuse/core": "^8.6.0", + "filepond": "^4.30.4", "filepond-plugin-image-preview": "^4.6.11", "floating-vue": "2.0.0-beta.16", "lodash.clonedeep": "^4.5.0", "pinia": "^2.0.14", - "tippy.js": "^6.3.7", - "vue": "^3.2.36", + "vue": "^3.2.37", "vue-filepond": "^7.0.3", "vue-grid-layout": "3.0.0-beta1", - "vue-router": "^4.0.15" + "vue-router": "^4.0.16", + "@halo-dev/components": "workspace:*" }, "devDependencies": { - "@iconify-json/ri": "^1.1.2", "@rushstack/eslint-patch": "^1.1.3", "@tailwindcss/aspect-ratio": "^0.4.0", "@types/jsdom": "^16.2.14", "@types/lodash.clonedeep": "4.5.0", - "@types/node": "^17.0.35", + "@types/node": "^17.0.42", "@vitejs/plugin-vue": "^2.3.3", "@vitejs/plugin-vue-jsx": "^1.3.10", - "@vitest/ui": "^0.12.9", + "@vitest/ui": "^0.12.10", "@vue/eslint-config-prettier": "^7.0.0", "@vue/eslint-config-typescript": "^10.0.0", "@vue/test-utils": "^2.0.0", "@vue/tsconfig": "^0.1.3", "autoprefixer": "^10.4.7", "c8": "^7.11.3", - "cypress": "^9.6.1", - "eslint": "^8.16.0", + "cypress": "^9.7.0", + "eslint": "^8.17.0", "eslint-plugin-cypress": "^2.12.1", "eslint-plugin-vue": "^8.7.1", - "histoire": "^0.4.6", "husky": "^8.0.1", "jsdom": "^19.0.0", "postcss": "^8.4.14", "prettier": "^2.6.2", "prettier-plugin-tailwindcss": "^0.1.11", - "sass": "^1.52.1", + "sass": "^1.52.3", "start-server-and-test": "^1.14.0", - "tailwindcss": "^3.0.24", + "tailwindcss": "^3.1.2", "tailwindcss-safe-area": "^0.2.2", "tailwindcss-themeable": "^1.3.0", "typescript": "~4.6.4", - "unplugin-icons": "^0.14.3", - "vite": "^2.9.9", + "vite": "^2.9.12", "vite-compression-plugin": "^0.0.3", - "vite-plugin-dts": "^1.1.1", "vite-plugin-pwa": "^0.12.0", - "vitest": "^0.12.9", - "vue-tsc": "^0.34.16" + "vitest": "^0.12.10", + "vue-tsc": "^0.34.17" } } diff --git a/packages/components/.eslintrc.cjs b/packages/components/.eslintrc.cjs new file mode 100644 index 00000000..feeabc42 --- /dev/null +++ b/packages/components/.eslintrc.cjs @@ -0,0 +1,3 @@ +module.exports = { + extends: ["../../.eslintrc.cjs"], +}; diff --git a/packages/components/env.d.ts b/packages/components/env.d.ts new file mode 100644 index 00000000..c7222cf4 --- /dev/null +++ b/packages/components/env.d.ts @@ -0,0 +1,9 @@ +/// +/// + +declare module "*.vue" { + import type { DefineComponent } from "vue"; + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any>; + export default component; +} diff --git a/packages/components/histoire.config.ts b/packages/components/histoire.config.ts new file mode 100644 index 00000000..35d0cec2 --- /dev/null +++ b/packages/components/histoire.config.ts @@ -0,0 +1,21 @@ +import { defineConfig } from "histoire"; +import type { UserConfig } from "vite"; + +export default defineConfig({ + setupFile: "./src/histoire.setup.ts", + + vite: { + plugins: [ + { + name: "disable-lib-plugin", + config(config: UserConfig) { + if (!config || !config.build || !config.build.rollupOptions) { + return; + } + config.build.lib = false; + config.build.rollupOptions.external = []; + }, + }, + ], + }, +}); diff --git a/packages/components/package.json b/packages/components/package.json new file mode 100644 index 00000000..74f61a3f --- /dev/null +++ b/packages/components/package.json @@ -0,0 +1,68 @@ +{ + "name": "@halo-dev/components", + "version": "0.0.0", + "description": "", + "files": [ + "dist" + ], + "main": "./dist/halo-components.umd.js", + "module": "./dist/halo-components.es.js", + "unpkg": "./dist/halo-components.iife.js", + "jsdelivr": "./dist/halo-components.iife.js", + "types": "./dist/typings/index.d.ts", + "scripts": { + "dev": "vite build --watch", + "build": "vite build", + "test:unit": "vitest --environment jsdom --run", + "test:unit:watch": "vitest --environment jsdom --watch", + "test:unit:ui": "vitest --environment jsdom --watch --ui", + "test:unit:coverage": "vitest run --environment jsdom --coverage", + "typecheck": "vue-tsc --noEmit -p tsconfig.app.json --composite false", + "story:dev": "histoire dev --port 4000", + "story:build": "histoire build", + "lint": "eslint ./src --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts", + "prettier": "prettier --write './src/**/*.{vue,js,jsx,ts,tsx,css,scss,json,yml,yaml,html}'", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "halo", + "halo-components", + "halo-dev", + "@halo-dev/components" + ], + "author": { + "name": "@halo-dev", + "url": "https://github.com/halo-dev" + }, + "repository": { + "type": "git", + "url": "https://github.com/halo-dev/halo-admin.git", + "directory": "packages/components" + }, + "bugs": { + "url": "https://github.com/halo-dev/halo/issues" + }, + "homepage": "https://github.com/halo-dev/halo-admin/tree/next/packages/components#readme", + "license": "MIT", + "dependencies": { + "tippy.js": "^6.3.7" + }, + "devDependencies": { + "@iconify-json/ri": "^1.1.2", + "@rollup/plugin-typescript": "^8.3.3", + "histoire": "^0.7.6", + "unplugin-icons": "^0.14.3", + "vite-plugin-dts": "^1.2.0" + }, + "peerDependencies": { + "vue": "^3.2.37", + "vue-router": "^4.0.16" + }, + "exports": { + ".": { + "import": "./dist/halo-components.es.js", + "require": "./dist/halo-components.umd.js" + }, + "./dist/style.css": "./dist/style.css" + } +} diff --git a/packages/components/postcss.config.js b/packages/components/postcss.config.js new file mode 100644 index 00000000..12a703d9 --- /dev/null +++ b/packages/components/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; diff --git a/packages/components/prettier.config.js b/packages/components/prettier.config.js new file mode 100644 index 00000000..38409a26 --- /dev/null +++ b/packages/components/prettier.config.js @@ -0,0 +1,3 @@ +module.exports = { + plugins: ["../../prettier.config.js"], +}; diff --git a/packages/components/src/components.ts b/packages/components/src/components.ts new file mode 100644 index 00000000..2ea4cc78 --- /dev/null +++ b/packages/components/src/components.ts @@ -0,0 +1,15 @@ +export * from "./components/alert"; +export * from "./components/button"; +export * from "./components/card"; +export * from "./components/checkbox"; +export * from "./components/header"; +export * from "./components/input"; +export * from "./components/menu"; +export * from "./components/modal"; +export * from "./components/radio"; +export * from "./components/select"; +export * from "./components/space"; +export * from "./components/tabs"; +export * from "./components/tag"; +export * from "./components/textarea"; +export * from "./components/tooltip"; diff --git a/src/components/base/alert/Alert.story.vue b/packages/components/src/components/alert/Alert.story.vue similarity index 96% rename from src/components/base/alert/Alert.story.vue rename to packages/components/src/components/alert/Alert.story.vue index f4441989..2158d471 100644 --- a/src/components/base/alert/Alert.story.vue +++ b/packages/components/src/components/alert/Alert.story.vue @@ -1,7 +1,7 @@ diff --git a/src/components/base/menu/Menu.vue b/packages/components/src/components/menu/Menu.vue similarity index 100% rename from src/components/base/menu/Menu.vue rename to packages/components/src/components/menu/Menu.vue diff --git a/src/components/base/menu/MenuItem.vue b/packages/components/src/components/menu/MenuItem.vue similarity index 97% rename from src/components/base/menu/MenuItem.vue rename to packages/components/src/components/menu/MenuItem.vue index 59d581fb..1e92fb0c 100644 --- a/src/components/base/menu/MenuItem.vue +++ b/packages/components/src/components/menu/MenuItem.vue @@ -1,5 +1,5 @@ diff --git a/src/components/base/tag/Tag.vue b/packages/components/src/components/tag/Tag.vue similarity index 96% rename from src/components/base/tag/Tag.vue rename to packages/components/src/components/tag/Tag.vue index 8d45e48d..92256cc0 100644 --- a/src/components/base/tag/Tag.vue +++ b/packages/components/src/components/tag/Tag.vue @@ -1,7 +1,7 @@