Skip to content

Commit 845c89e

Browse files
committed
feat: refactor code
1 parent cbdc22b commit 845c89e

File tree

20 files changed

+70
-69
lines changed

20 files changed

+70
-69
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"tailwindcss2": "npm:@tailwindcss/postcss7-compat@^2.2.17",
7171
"ts-node": "^10.9.2",
7272
"tslib": "^2.6.3",
73-
"tsup": "^8.1.2",
73+
"tsup": "^8.2.0",
7474
"tsx": "^4.16.2",
7575
"turbo": "^2.0.7",
7676
"typescript": "^5.5.3",

packages/tailwindcss-patch/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tailwindcss-patch",
3-
"version": "3.1.0-alpha.1",
3+
"version": "4.0.0-alpha.0",
44
"description": "patch tailwindcss for exposing context and extract classes",
55
"author": "SonOfMagic <[email protected]>",
66
"license": "MIT",
@@ -62,8 +62,5 @@
6262
"postcss": "^8.4.39",
6363
"resolve": "^1.22.8",
6464
"semver": "^7.6.3"
65-
},
66-
"directories": {
67-
"test": "test"
6865
}
6966
}

packages/tailwindcss-patch/src/core/cache.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@ export class CacheManager {
3535
this.options = this.getOptions(options)
3636
}
3737

38-
mkdir(cacheDirectory: string) {
39-
const exists = fs.existsSync(cacheDirectory)
40-
if (!exists) {
41-
fs.mkdirSync(cacheDirectory, {
42-
recursive: true,
43-
})
44-
}
45-
return cacheDirectory
46-
}
47-
4838
getOptions(options: CacheOptions = {}): Required<CacheOptions> & { filename: string } {
4939
const cwd = options.cwd ?? process.cwd()
5040
const dir = options.dir ?? path.resolve(cwd, 'node_modules/.cache', pkgName)
@@ -62,8 +52,8 @@ export class CacheManager {
6252
write(data: Set<string>) {
6353
try {
6454
const { dir, filename } = this.options
65-
this.mkdir(dir)
66-
fs.writeFileSync(filename, JSON.stringify([...data], undefined, 2), 'utf8')
55+
fs.ensureDirSync(dir)
56+
fs.outputFileSync(filename, JSON.stringify([...data], undefined, 2), 'utf8')
6757
return filename
6858
}
6959
catch {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from './tw-patcher'
1+
export * from './patcher'
22
export * from './patches'
3-
export * from './runtime-patcher'
3+
export * from './runtime'
44
export * from './cache'

packages/tailwindcss-patch/src/core/tw-patcher.ts renamed to packages/tailwindcss-patch/src/core/patcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path'
22
import fs from 'fs-extra'
33
import { CacheManager, getCacheOptions } from './cache'
4-
import { internalPatch } from './runtime-patcher'
4+
import { internalPatch } from './runtime'
55
import { processTailwindcss } from './postcss'
66
import type { UserConfig } from '@/config'
77
import { getPatchOptions } from '@/defaults'

packages/tailwindcss-patch/src/core/patches/exportContext/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path'
22
import fs from 'fs-extra'
3-
import { inspectPostcssPlugin, inspectProcessTailwindFeaturesReturnContext } from './postcss'
4-
import { inspectPostcssPlugin as inspectPostcssPluginCompat, inspectProcessTailwindFeaturesReturnContext as inspectProcessTailwindFeaturesReturnContextCompat } from './postcss-compat'
3+
import { inspectPostcssPlugin, inspectProcessTailwindFeaturesReturnContext } from './postcss-v3'
4+
import { inspectPostcssPlugin as inspectPostcssPluginCompat, inspectProcessTailwindFeaturesReturnContext as inspectProcessTailwindFeaturesReturnContextCompat } from './postcss-v2'
55
import type { InternalPatchOptions } from '@/types'
66
import { ensureFileContent } from '@/utils'
77
import logger from '@/logger'

packages/tailwindcss-patch/src/core/patches/supportCustomUnits/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'node:path'
22
import fs from 'fs-extra'
33
import * as t from '@babel/types'
44
import type { ArrayExpression, StringLiteral } from '@babel/types'
5-
import { defu } from 'defu'
5+
import { defu } from '@/utils'
66
import type { ILengthUnitsPatchOptions } from '@/types'
77
import { generate, parse, traverse } from '@/babel'
88
import logger from '@/logger'

0 commit comments

Comments
 (0)