3
3
// https://google.github.io/zx/typescript
4
4
5
5
import 'node:fs'
6
+ import ct from 'chalk-template'
6
7
import 'zx/globals' ;
7
8
8
9
// Change this to a directory of your choosing.
9
10
// Your repo name and path
10
11
const root = path . resolve ( '.' ) ;
11
12
const repo = path . resolve ( "../kitsune_repo/x86_64" )
12
13
console . log ( `Root: ${ root } ` )
13
- console . log ( `Destination : ${ repo } ` )
14
+ console . log ( `Dest : ${ repo } ` )
14
15
15
16
// Ideally there will be 2 options for compiling
16
17
// 1. chroot" (Default)
@@ -20,13 +21,17 @@ console.log(`Destination: ${repo}`)
20
21
// maybe in the future if needed.
21
22
const dirs = ScanDirs ( )
22
23
await BuildPackages ( dirs )
24
+ BuildDone ( )
23
25
24
- // List of directories except the ones we don't want
26
+ /**
27
+ * List of directories except the ones we don't want
28
+ * @returns list of directories
29
+ */
25
30
function ScanDirs ( ) : Array < string > {
26
31
let result = new Array < string > ( )
27
32
const skipFiles = [ '.git' , 'node_modules' ]
28
33
29
- fs . readdirSync ( '.' ) . forEach ( file => {
34
+ fs . readdirSync ( '.' ) . forEach ( ( file : string ) => {
30
35
// Skip invalid dirs,
31
36
if ( skipFiles . includes ( file ) ) { return }
32
37
@@ -41,12 +46,16 @@ function ScanDirs() : Array<string> {
41
46
return result ;
42
47
}
43
48
49
+ /**
50
+ * Builds each package given the array of directories
51
+ * @param dirs directories as string to parse
52
+ */
44
53
function BuildPackages ( dirs : Array < string > ) {
45
54
// This is a list of dirs to process
46
55
dirs . forEach ( dir => {
47
56
// We would do a check to see if we are needing a
48
57
// chroot build or just a makepkg build.
49
- // Assuming just a chroot build for now.
58
+ // Assuming just a makepkg build for now.
50
59
MakepkgBuild ( dir ) ;
51
60
} )
52
61
}
@@ -70,32 +79,50 @@ function BuildPackages(dirs: Array<string>) {
70
79
71
80
// cd /tmp/tempbuild/
72
81
82
+ /**
83
+ * Tries to build package in a chroot environment
84
+ * @param path Directory of package to build
85
+ */
73
86
async function ChrootBuild ( path : string ) {
74
- await $ `tput setaf 2`
75
- echo `#############################################################################################`
76
- echo `######### Let us build the package in CHROOT "${ path } `
77
- echo `#############################################################################################`
78
- await $ `tput sgr0`
87
+ echo ( ct `{green
88
+ #############################################################################################
89
+ ######### Let us build the package in CHROOT
90
+ ######### {blue ${ path } }
91
+ #############################################################################################
92
+ }` )
79
93
//CHROOT=$HOME/Documents/chroot-data
80
94
await $ `arch-nspawn ${ path } /root pacman -Syu`
81
95
await $ `makechrootpkg -c -r ${ path } `
82
96
}
83
97
98
+ /**
99
+ * Basic directory build via makepkg
100
+ * @param path Directory to build package
101
+ */
84
102
async function MakepkgBuild ( path : string ) {
85
- await $ `tput setaf 3`
86
- echo `#############################################################################################`
87
- echo `######### Let us build the package with MAKEPKG ${ path } `
88
- echo `#############################################################################################`
89
- await $ `tput sgr0`
103
+ echo ( ct `{yellow
104
+ #############################################################################################
105
+ ######### Let us build the package with MAKEPKG
106
+ ######### {blue ${ path } }
107
+ #############################################################################################
108
+ }` )
90
109
cd ( path )
91
110
await $ `makepkg -sc`
92
111
MovePackages ( path )
112
+ cd ( root )
93
113
}
94
114
115
+ /**
116
+ * Moves packages to destination folder
117
+ * @param path Path of directory where packages exist
118
+ */
95
119
async function MovePackages ( path : string ) {
96
- echo `#############################################################################################`
97
- echo `######### Moving created files to ${ repo } `
98
- echo `#############################################################################################`
120
+ echo ( ct `{green
121
+ #############################################################################################
122
+ ######### Moving created files to...
123
+ ######### {blue ${ repo } }
124
+ #############################################################################################
125
+ }` )
99
126
await $ `mv ${ path } /*pkg.tar.zst ${ repo } `
100
127
}
101
128
@@ -114,10 +141,13 @@ async function MovePackages(path: string) {
114
141
// rm $pwdpath/*.tar.gz
115
142
// fi
116
143
144
+ /**
145
+ * Done banner
146
+ */
117
147
async function BuildDone ( ) {
118
- await $ `tput setaf 10`
119
- echo ` #############################################################################################`
120
- echo ` ################### build done ######################`
121
- echo ` #############################################################################################`
122
- await $ `tput sgr0`
148
+ echo ( ct `{greenBright
149
+ #############################################################################################
150
+ ################### build done ######################
151
+ #############################################################################################
152
+ }` )
123
153
}
0 commit comments