-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepublish.js
90 lines (78 loc) · 2.23 KB
/
prepublish.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { copyFile, readFile, stat, writeFile } from 'node:fs/promises'
import { basename, join } from 'node:path'
import { globby } from 'globby'
const globbyOptions = { onlyFiles: false, markDirectories: true }
const copyJobs = [
[ 'LICENSE', 'packages/*' ],
[ 'README.md', 'packages/*' ]
]
const packageJsonJobs = {
'packages/bundled-stylelint-config': {
version: '0.1.9',
description: 'A preset for stylelint',
keywords: [
'stylelint preset',
'stylelint config',
'stylelint',
'lint',
'stylelint scss preset'
]
},
'packages/bundled-eslint-config': {
type: 'module',
version: '0.4.28',
description: 'A preset for ESLint',
keywords: [
'eslint',
'eslint preset',
'preset',
'typescript eslint preset',
'typescript-eslint',
'vue eslint preset',
'astro eslint preset',
'vitest eslint preset',
'react eslint preset'
]
},
'{packages/*}': {
author: 'DaniFoldi',
license: 'MIT',
bugs: {
url: 'https://github.com/DaniFoldi/lint-my-life/issues'
},
homepage: 'https://github.com/DaniFoldi/lint-my-life#readme',
repository: {
type: 'git',
url: 'git+https://github.com/DaniFoldi/lint-my-life.git'
}
}
}
for (const job of copyJobs) {
const destinations = await globby(job[1], globbyOptions)
for (const destination of destinations) {
await copyFile(job[0], destination.endsWith('/') ? destination + basename(job[0]) : destination)
}
if (destinations.length === 0) {
await copyFile(job[0], job[1])
}
}
for (const job of Object.entries(packageJsonJobs)) {
try {
if (await stat(job[0])) {
const destination = job[0]
const packageJson = {
...JSON.parse(await readFile(join(destination, 'package.json'))),
...job[1]
}
await writeFile(join(destination, 'package.json'), `${JSON.stringify(packageJson, null, 2)}\n`)
continue
}
} catch {}
for (const destination of await globby(job[0], globbyOptions)) {
const packageJson = {
...JSON.parse(await readFile(join(destination, 'package.json'))),
...job[1]
}
await writeFile(join(destination, 'package.json'), `${JSON.stringify(packageJson, null, 2)}\n`)
}
}