This repository was archived by the owner on Mar 18, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathcreate-pkg.js
More file actions
42 lines (35 loc) · 1.22 KB
/
create-pkg.js
File metadata and controls
42 lines (35 loc) · 1.22 KB
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
const fs = require('fs')
const path = require('path')
const packageFileContent = fs.readFileSync(path.resolve(__dirname, '../package.json'), { encoding: "utf8" });
const rootPackageContent = JSON.parse(packageFileContent);
let desiredKeys = [
"name",
"version",
"description",
"author",
"license",
"peerDependencies",
"keywords",
"homepage",
"repository"
]
let destinationPackageContent = {}
for (let key of desiredKeys) {
destinationPackageContent[key] = rootPackageContent[key]
}
Object.assign(destinationPackageContent, {
...destinationPackageContent,
"main": "index.js",
"types": "index.d.ts"
})
const finalFileContent = JSON.stringify(destinationPackageContent, null, 4)
fs.writeFileSync(path.resolve(__dirname, "../dist/package.json"), finalFileContent)
//Copy our readme and license file
const filesToCopy = ["README.md", "LICENSE", "CHANGELOG.md"]
for (let file of filesToCopy) {
fs.copyFileSync(path.resolve(__dirname, `../${file}`), path.resolve(__dirname, `../dist/${file}`))
}
const typeDefsToCopy = ["components/Template.svelte.d.ts"]
for (let file of typeDefsToCopy) {
fs.copyFileSync(path.resolve(__dirname, `../src/${file}`), path.resolve(__dirname, `../dist/${file}`))
}