-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkpkg.ps1
86 lines (74 loc) · 2.55 KB
/
mkpkg.ps1
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
#! /usr/bin/pwsh
$root = Get-Location
# we need to be where we hold all of the packages
Set-Location .\packages
# get package info
$packageName = Read-Host -Prompt "What do you want to call the new package?"
Write-Output $packageName
$description = Read-Host -Prompt "What should the description of the package be?"
# create and enter
New-Item -Path ".\$packageName" -ItemType Directory
Set-Location ('.\' + $packageName)
# set up source
New-Item -Path '.\src' -ItemType Directory
New-Item -Path '.\src\index.ts' -ItemType File -Value "// Entry point of the project`n"
New-Item -Path '.\src\typings' -ItemType Directory
# set up tests
New-Item -Path '.\tests' -ItemType Directory
New-Item -Path '.\tests\index.ts' -ItemType File -Value "// Main tests here`n"
# ignore files
New-Item -Path '.\.gitignore' -ItemType File -Value "node_modules/`n.DS_Store`ndist/`n"
New-Item -Path '.\.npmignore' -ItemType File -Value "tests/`nsrc/`ndocs/`n.gitignore`ntsconfig.json`n"
# npm files
New-Item -Path '.\package.json' -ItemType File -Value "{
`"name`": `"@infinite-fansub/$packageName`",
`"version`": `"1.0.0`",
`"description`": `"$description`",
`"author`": `"Infinite`",
`"license`": `"AGPL-3.0`",
`"main`": `"dist/index.js`",
`"types`": `"dist`",
`"scripts`": {
`"test`": `"ts-node tests/index.ts`",
`"lint`": `"eslint src/**/*.ts`",
`"lint:fix`": `"eslint src/**/*.ts --fix`",
`"docs`": `"rm -rf docs && typedoc && typedoc --plugin typedoc-plugin-coverage --plugin typedoc-plugin-markdown`",
`"build`": `"rm -rf dist && tsc`",
`"build:watch`": `"rm -rf dist && tsc --watch`",
`"build:test`": `"tsc --noEmit`",
`"node`": `"node .`",
`"tsn`": `"ts-node src/index.ts`"
},
`"repository`": {
`"type`": `"git`",
`"url`": `"https://github.com/Infinite-Fansub/infinite.git`"
},
`"homepage`": `"https://github.com/Infinite-Fansub/infinite/tree/main/packages/$packageName`"
}"
# typescript shenanigans
New-Item -Path '.\tsconfig.json' -ItemType File -Value '{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"baseUrl": "."
},
"typedocOptions": {
"entryPoints": [
"./src/index.ts"
],
"entryPointStrategy": "expand",
"plugin": [
"typedoc-theme-hierarchy",
"typedoc-plugin-coverage"
],
"theme": "hierarchy"
},
"include": [
"src/**/*"
]
}'
npm.cmd i tslib
# go back home
Set-Location $root
npm.cmd i