Skip to content

Commit

Permalink
chore: release
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed May 16, 2024
1 parent 644baf7 commit 1f1da26
Show file tree
Hide file tree
Showing 32 changed files with 1,009 additions and 345 deletions.
7 changes: 2 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@ export default defineConfig(
{
ignores: ['**/packages/istanbul-widget/src/components/**/*'],
},
{
rules: {
'node/no-deprecated-api': 'off',
},
},
],
{
astro: true,
react: true,
vue: true,
},
)
6 changes: 6 additions & 0 deletions packages/istanbul-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# istanbul-widget

## 1.5.6

### Patch Changes

- use merge replace with deepmerge

## 1.5.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/istanbul-widget/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"config": "tailwind.config.cjs",
"css": "src/styles/global.css",
"baseColor": "slate",
"cssVariables": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/istanbul-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "istanbul-widget",
"version": "1.5.5",
"version": "1.5.6",
"description": "收集 istanbul 代码覆盖率的web小组件",
"type": "module",
"keywords": [
Expand Down
Binary file modified packages/istanbul-widget/screenshots/light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions packages/istanbul-widget/src/core/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepMerge, isArray, isFunction, isObject, set } from '@minko-fe/lodash-pro'
import { isArray, isFunction, isObject, merge, set } from '@minko-fe/lodash-pro'
import { type ConsolaInstance, LogLevels, createConsola } from 'consola/browser'
import { ButtonGroupPlugin } from '@/plugins/button-group/ButtonGroupPlugin'
import { ReportPlugin } from '@/plugins/report/ReportPlugin'
Expand Down Expand Up @@ -59,9 +59,8 @@ export class IstanbulWidget {
this.isInited = false

if (isObject(opts)) {
this.option = deepMerge(this.option, opts, {
arrayMerge: (_, source) => source,
})
this.option = merge(this.option, opts)
IstanbulWidget.logger.debug('final options:', this.option)
}

// add built-in plugins
Expand Down
1 change: 1 addition & 0 deletions packages/istanbul-widget/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const lib = (option: Options): Options => ({
},
noExternal: Object.keys(pkg.dependencies) || [],
splitting: false,
minify: false,
injectStyle: true,
})

Expand Down
8 changes: 8 additions & 0 deletions packages/vite-plugin-istanbul-widget/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# vite-plugin-istanbul-widget

## 1.5.9

### Patch Changes

- log error message when git not found
- Updated dependencies
- istanbul-widget@1.5.6

## 1.5.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-istanbul-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-istanbul-widget",
"version": "1.5.8",
"version": "1.5.9",
"description": "集成了 istanbul-widget 和 vite-plugin-istanbul 的vite插件",
"type": "module",
"keywords": [
Expand Down
24 changes: 11 additions & 13 deletions packages/vite-plugin-istanbul-widget/src/astro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function istanbulWidget(opts: VitePluginIstanbulWidgetOptions): any {
},
}),
{
name: 'vite:plugin-istanbul-widget:astro',
name: 'vite:plugin-istanbul-widget:astro:pre',
enforce: 'pre',
transform(code, id) {
if (opts.istanbulWidgetConfig !== false) {
Expand All @@ -50,19 +50,17 @@ export function istanbulWidget(opts: VitePluginIstanbulWidgetOptions): any {
for (const file in bundle) {
const chunk = bundle[file]
if (chunk.type === 'chunk') {
if (chunk.code.includes('/* empty css')) {
if (chunk.name === VENDOR) {
const { format } = opts
const emptyCss = `\\/\\*\\s*empty\\s*css\\s*\\*\\/`
const emptyChunkRE = new RegExp(
format === 'es'
? `${emptyCss}\\bimport\\s*["'][^"']*(?:.*)["'];`
: `${emptyCss}(\\b|,\\s*)require\\(\\s*["'][^"']*(?:.*)["']\\)(;|,)`,
'g',
)
if (chunk.name === VENDOR) {
const { format } = opts
const emptyCss = `\\/\\*\\s*empty\\s*css\\s*\\*\\/`
const emptyChunkRE = new RegExp(
format === 'es'
? `${emptyCss}\\bimport\\s*["'][^"']*(?:.*)["'];`
: `${emptyCss}(\\b|,\\s*)require\\(\\s*["'][^"']*(?:.*)["']\\)(;|,)`,
'g',
)

chunk.code = chunk.code.replace(emptyChunkRE, '')
}
chunk.code = chunk.code.replace(emptyChunkRE, '')
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/vite-plugin-istanbul-widget/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import serialize from './serialize'
export function getCommitId() {
try {
return execSync('git rev-parse HEAD').toString().trim()
} catch {
return ''
} catch (e) {
console.error(`Failed to resolve git HEAD:\n${e}`)
}
}

Expand Down
2 changes: 1 addition & 1 deletion playground/astro-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react-dom": "^18.2.0",
"typescript": "^5.4.5",
"vite-plugin-istanbul-widget": "workspace:*",
"vite-plugin-public-typescript": "^2.4.0"
"vite-plugin-public-typescript": "latest"
},
"devDependencies": {
"@astrojs/react": "^3.3.1",
Expand Down
2 changes: 1 addition & 1 deletion playground/astro3-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"@types/react": "^18.2.0",
"typescript": "^5.4.5",
"vite-plugin-istanbul-widget": "workspace:*",
"vite-plugin-public-typescript": "^2.4.0"
"vite-plugin-public-typescript": "latest"
}
}
11 changes: 11 additions & 0 deletions playground/nextjs14-app/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": ["next/babel"],
"plugins": [
[
"istanbul",
{
"exclude": ["**/middleware.*"]
}
]
]
}
39 changes: 39 additions & 0 deletions playground/nextjs14-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

public/assets/js/
public-typescript/manifest.json
8 changes: 8 additions & 0 deletions playground/nextjs14-app/@types/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare global {
interface Window {
__report: (coverage: any, ...args: any[]) => Promise<void>
__customClick: (...args: any[]) => void
}
}

export {}
17 changes: 17 additions & 0 deletions playground/nextjs14-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Entry for vite -->
<!-- DO NOT EDIT -->
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Document</title>
</head>

<body>

</body>

</html>
12 changes: 12 additions & 0 deletions playground/nextjs14-app/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: false,
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
}

export default nextConfig
32 changes: 32 additions & 0 deletions playground/nextjs14-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "nextjs-app",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "NODE_ENV=development next dev",
"build": "next build",
"start": "next start",
"prebuild": "pnpm vite:build",
"predev": "NODE_ENV=development pnpm vite:build",
"vite:build": "vite build",
"lint": "next lint"
},
"dependencies": {
"next": "^14.2.3",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"babel-plugin-istanbul": "^6.1.1",
"istanbul-widget": "workspace:*",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5",
"vite": "^5.2.11",
"vite-plugin-istanbul-widget": "workspace:*",
"vite-plugin-public-typescript": "latest"
}
}
8 changes: 8 additions & 0 deletions playground/nextjs14-app/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
}

export default config
44 changes: 44 additions & 0 deletions playground/nextjs14-app/public-typescript/istanbul.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { IstanbulWidget } from 'istanbul-widget/lib'

const toFormData = (obj) => {
const formData = new FormData()
Object.keys(obj).forEach((key) => {
formData.append(key, obj[key])
})
return formData
}

async function report(coverage, params, ..._args) {
console.log(coverage, 'coverage')
const reponame = 'nextjs-app'
const res = await fetch(`http://localhost:3000/${reponame}/coverage/client?v=${__GIT_COMMIT_ID__}`, {
body: toFormData({
coverage,
params,
}),
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
})
if (!res.ok) {
throw new Error('上报失败')
}
}

new IstanbulWidget({
defaultPosition: {
y: 100,
},
plugin: {
report: {
async onReport(...args) {
await report(...args)
},
},
setting: {
requireReporter: false,
autoReport: false,
},
},
})
1 change: 1 addition & 0 deletions playground/nextjs14-app/public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions playground/nextjs14-app/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added playground/nextjs14-app/src/app/favicon.ico
Binary file not shown.
33 changes: 33 additions & 0 deletions playground/nextjs14-app/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
}

body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
}
Loading

0 comments on commit 1f1da26

Please sign in to comment.