forked from sambauers/tailwindcss-3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy-release-files.ts
31 lines (27 loc) · 1.29 KB
/
copy-release-files.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { copyFileSync, readFileSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
import { fileURLToPath } from 'node:url'
const packagePath = join('..', '..', 'package.json')
const packageURL = fileURLToPath(new URL(packagePath, import.meta.url))
const packageJson = JSON.parse(readFileSync(packageURL).toString())
// Create truncated package.json for distribution
const distPackagePath = join('..', '..', 'dist', 'package.json')
const distPackageURL = fileURLToPath(new URL(distPackagePath, import.meta.url))
const distPackageJson = { ...packageJson }
delete distPackageJson.devDependencies
delete distPackageJson.files
delete distPackageJson.packageManager
delete distPackageJson.scripts
distPackageJson.main = 'index.js'
distPackageJson.types = 'types/index.d.ts'
const distPackageContents = JSON.stringify(distPackageJson, null, ' ')
writeFileSync(distPackageURL, distPackageContents.concat('\n'))
// Copy README and LICENSE
const docFiles = ['README.md', 'LICENSE.md']
docFiles.forEach((docFile) => {
const docPath = join('..', '..', docFile)
const docURL = fileURLToPath(new URL(docPath, import.meta.url))
const docPackagePath = join('..', '..', 'dist', docFile)
const docPackageURL = fileURLToPath(new URL(docPackagePath, import.meta.url))
copyFileSync(docURL, docPackageURL)
})