cmd/tsconnect: add README to generated NPM package

Makes the landing page at https://www.npmjs.com/package/@tailscale/connect
look slightly nicer.

Fixes #5976

Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:
Mihai Parparita 2022-10-24 13:38:47 -07:00 committed by Mihai Parparita
parent 9beb07b4ff
commit 660abd7309
3 changed files with 17 additions and 2 deletions

View File

@ -31,7 +31,7 @@ By default the build output is placed in the `dist/` directory and embedded in t
# Library / NPM Package
The client is also available as an NPM package. To build it, run:
The client is also available as [an NPM package](https://www.npmjs.com/package/@tailscale/connect). To build it, run:
```
./tool/go run ./cmd/tsconnect build-pkg

View File

@ -0,0 +1,3 @@
# @tailscale/connect
NPM package that contains a WebAssembly-based Tailscale client, see [the `cmd/tsconnect` directory in the tailscale repo](https://github.com/tailscale/tailscale/tree/main/cmd/tsconnect#library--npm-package) for more details.

View File

@ -27,7 +27,7 @@ func runBuildPkg() {
log.Fatalf("Linting failed: %v", err)
}
if err := cleanDir(*pkgDir, "package.json"); err != nil {
if err := cleanDir(*pkgDir); err != nil {
log.Fatalf("Cannot clean %s: %v", *pkgDir, err)
}
@ -51,6 +51,10 @@ func runBuildPkg() {
log.Fatalf("Cannot update version: %v", err)
}
if err := copyReadme(); err != nil {
log.Fatalf("Cannot copy readme: %v", err)
}
log.Printf("Built package version %s", version.Long)
}
@ -84,3 +88,11 @@ func updateVersion() error {
return os.WriteFile(path.Join(*pkgDir, "package.json"), packageJSONBytes, 0644)
}
func copyReadme() error {
readmeBytes, err := os.ReadFile("README.pkg.md")
if err != nil {
return fmt.Errorf("Could not read README.pkg.md: %w", err)
}
return os.WriteFile(path.Join(*pkgDir, "README.md"), readmeBytes, 0644)
}