mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-24 10:41:19 -08:00
cmd/tsconnect: copy type declarations into package directory
Once the pkg-types script has generated pkg.d.ts and checked them against the tsconfig.json and node_modules in cmd/tsconnect, copy them into the pkgDir so they get bundled into the package. Updates #19707 Signed-off-by: Gesa Stupperich <[email protected]>
This commit is contained in:
1 parent
31d8badb3b
commit
b82b06c8ab
1 file changed
+19
@@ -11,6 +11,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/tailscale/hujson"
|
||||
"tailscale.com/cmd/tsconnect/wasmbuild"
|
||||
@@ -52,6 +53,9 @@ func runBuildPkg() {
|
||||
if err := runYarn("pkg-types"); err != nil {
|
||||
log.Fatalf("Type generation failed: %v", err)
|
||||
}
|
||||
if err := copyTypeDeclarations(); err != nil {
|
||||
log.Fatalf("Cannot copy generated types: %v", err)
|
||||
}
|
||||
|
||||
if err := updateVersion(); err != nil {
|
||||
log.Fatalf("Cannot update version: %v", err)
|
||||
@@ -117,3 +121,18 @@ func copyReadme() error {
|
||||
}
|
||||
return os.WriteFile(path.Join(*pkgDir, "README.md"), readmeBytes, 0644)
|
||||
}
|
||||
|
||||
// copyTypeDeclarations copies pkg.d.ts into pkgDir
|
||||
// if pkgDir differs from the local default ./pkg.
|
||||
func copyTypeDeclarations() error {
|
||||
const src = "pkg/pkg.d.ts"
|
||||
dst := path.Join(*pkgDir, "pkg.d.ts")
|
||||
if filepath.Clean(src) == filepath.Clean(dst) {
|
||||
return nil
|
||||
}
|
||||
data, err := os.ReadFile(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(dst, data, 0644)
|
||||
}
|
||||
Reference in new issue
Block a user