@weapp-tailwindcss/merge 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/merge",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "description": "weapp-tailwindcss",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -38,16 +38,19 @@
38
38
  }
39
39
  },
40
40
  "files": [
41
- "dist"
41
+ "dist",
42
+ "scripts"
42
43
  ],
43
44
  "dependencies": {
44
45
  "class-variance-authority": "^0.7.1",
45
46
  "clsx": "^2.1.1",
47
+ "local-pkg": "^1.0.0",
48
+ "semver": "^7.7.1",
46
49
  "tailwind-merge": "^3.0.2",
47
50
  "tailwind-merge-v2": "npm:tailwind-merge@^2.6.0"
48
51
  },
49
52
  "devDependencies": {
50
- "weapp-tailwindcss": "4.0.5"
53
+ "weapp-tailwindcss": "4.0.7"
51
54
  },
52
55
  "scripts": {
53
56
  "dev": "tsup --watch --sourcemap",
@@ -56,7 +59,8 @@
56
59
  "test:dev": "vitest",
57
60
  "release": "pnpm publish",
58
61
  "lint": "eslint .",
59
- "lint:fix": "eslint . --fix"
62
+ "lint:fix": "eslint . --fix",
63
+ "postinstall": "node scripts/postinstall.js"
60
64
  },
61
65
  "main": "./dist/index.cjs",
62
66
  "module": "./dist/index.js",
@@ -0,0 +1,39 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { getPackageInfoSync } from 'local-pkg'
4
+ import satisfies from 'semver/functions/satisfies.js'
5
+
6
+ function main() {
7
+ const distDir = path.resolve(import.meta.dirname, '../dist')
8
+
9
+ if (!fs.existsSync(distDir)) {
10
+ return
11
+ }
12
+ const packageInfo = getPackageInfoSync('tailwindcss')
13
+
14
+ if (!packageInfo) {
15
+ console.warn('tailwindcss not found in the project. Skipping swicth version of tailwind-merge.')
16
+ return
17
+ }
18
+
19
+ const tailwindVersion = packageInfo.version
20
+
21
+ let targetVersion = 3
22
+
23
+ if (satisfies(tailwindVersion, '^4.0.0')) {
24
+ targetVersion = 4
25
+ }
26
+
27
+ console.log(`tailwindcss version: ${tailwindVersion}`)
28
+ console.log(`Switch version of tailwind-merge to v${targetVersion - 1}.`)
29
+ for (const ext of ['cjs', 'd.cts', 'd.ts', 'js']) {
30
+ const file = `v${targetVersion}.${ext}`
31
+ fs.copyFileSync(
32
+ path.resolve(distDir, file),
33
+ path.resolve(distDir, `index.${ext}`),
34
+ )
35
+ }
36
+ console.log('Switch version of tailwind-merge success.')
37
+ }
38
+
39
+ main()