forked from napi-rs/napi-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.ts
64 lines (57 loc) · 1.39 KB
/
package.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
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
import { version } from '../../package.json'
import { DefaultPlatforms } from '../parse-triple'
export const createPackageJson = (
name: string,
binaryName: string,
targets: string[],
) => {
const pkgContent = {
name,
version: '0.0.0',
main: 'index.js',
types: 'index.d.ts',
napi: {
name: binaryName,
},
license: 'MIT',
devDependencies: {
'@napi-rs/cli': `^${version}`,
ava: '^4.3.3',
},
ava: {
timeout: '3m',
},
engines: {
node: '>= 10',
},
scripts: {
artifacts: 'napi artifacts',
build: 'napi build --platform --release',
'build:debug': 'napi build --platform',
prepublishOnly: 'napi prepublish -t npm',
test: 'ava',
universal: 'napi universal',
version: 'napi version',
},
}
const triples: any = {}
const defaultTargetsSupported = DefaultPlatforms.every((p) =>
targets!.includes(p.raw),
)
const isOnlyDefaultTargets =
targets.length === 3 &&
DefaultPlatforms.every((p) => targets.includes(p.raw))
if (!isOnlyDefaultTargets) {
if (!defaultTargetsSupported) {
triples.defaults = false
triples.additional = targets
} else {
triples.additional = targets.filter(
(t) => !DefaultPlatforms.map((p) => p.raw).includes(t),
)
}
}
// @ts-expect-error
pkgContent.napi.triples = triples
return pkgContent
}