-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.ps1
100 lines (81 loc) · 2.71 KB
/
bootstrap.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/pwsh
$react = "`^16.8.6"
$reactdom = "`^16.8.6"
$reactcssmods = "`^4.7.9"
yarn init --yes
## add files and scripts to the new package.json
$jsonfile = '.\package.json'
$json = Get-Content $jsonfile | Out-String | ConvertFrom-Json
$arr = echo '{"arr": ["dist/**/*","lib/**/*" ]}' | ConvertFrom-Json
$json | Add-Member -Type NoteProperty -Name 'files' -Value $arr.arr
$arr2 = echo '{"scripts": {
"analyze": "source-map-explorer dist/js/main.*",
"build": "yarn install && node scripts/build.js",
"test": "node scripts/test.js --passWithNoTests",
"new-version-patch": " yarn version --new-version patch",
"new-version": " yarn version"
}}' | ConvertFrom-Json
$json | Add-Member -Type NoteProperty -Name 'scripts' -Value $arr2.scripts
$arr3 = echo '{"peerDependencies": {}}' | ConvertFrom-Json
$json | Add-Member -Type NoteProperty -Name 'peerDependencies' -Value $arr3.peerDependencies
$json.main = 'lib/index.js'
# side effects allows webpack to trim unused deps
$json | Add-Member -Type NoteProperty -Name 'sideEffects' -Value $false
$json | ConvertTo-Json | Set-Content $jsonfile
yarn add -D @babel/core@`^7.4.3 `
@babel/[email protected] `
@babel/[email protected] `
@babel/[email protected] `
@babel/[email protected] `
@babel/preset-react@`^7.0.0 `
@babel/preset-typescript@`^7.3.3 `
@types/jest@`^24.0.11 `
@types/node@`^11.13.4 `
@types/[email protected] `
chalk@`^2.4.2 `
css-loader@`^2.1.1 `
file-loader@`^3.0.1 `
fs@`^0.0.1-security `
fs-extra@`^7.0.1 `
jest@`^24.7.1 `
jest-pnp-resolver@`^1.2.1 `
jest-resolve@`^24.7.1 `
jsdom@`^14.0.0 `
mini-css-extract-plugin@`^0.6.0 `
node-sass@`^4.11.0 `
path@`^0.12.7 `
postcss-flexbugs-fixes@`^4.1.0 `
postcss-loader@`^3.0.0 `
postcss-preset-env@`^6.6.0 `
sass-loader@`^7.1.0 `
terser-webpack-plugin@`^1.2.3 `
ts-loader@`^5.3.3 `
typescript@`^3.4.3 `
$confirmation = Read-Host "Add react libs? [y/n]"
while($confirmation -ne "y" -and $confirmation -ne "n")
{
$confirmation = Read-Host "Add react libs? [y/n]"
}
if ($confirmation -eq 'y') {
# add react based libs
yarn add -D @types/react@`^16.8.8 `
@types/react-css-modules@`^4.6.2 `
@types/react-dom@`^16.8.4
# add to deps
yarn add "react@$react" "react-css-modules@$reactcssmods" "react-dom@$reactdom"
}
# add git remote
$matches = git remote -v | Select-String -Pattern '(https|git)(.+)/(.+?)\.git'
$upstream = $matches.Matches.groups[1] + $matches.Matches.groups[2] + '/npm-package-template.git'
git remote add upstream $upstream
echo "Added remote $upstream"
git fetch upstream
# switch to initial branch
git checkout -b v1