Skip to content

Commit

Permalink
better show files
Browse files Browse the repository at this point in the history
  • Loading branch information
xtuc committed May 5, 2020
1 parent a7015c7 commit 7ee4d84
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions cmd/checker/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Checker

Tools for our CI.

## `lint`

Check that a package is correctly configured.
35 changes: 25 additions & 10 deletions cmd/checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,26 @@ func showFiles(path string) {
return
}

fmt.Printf("Preview for `%s`\n", path)

npmVersions := npm.GetVersions(pckg.Autoupdate.Target)
if len(npmVersions) == 0 {
err(ctx, "no version found on npm")
return
}

// Import all the versions since we have none locally.
// Limit the number of version to an abrirary number to avoid publishing
// too many outdated versions.
sort.Sort(sort.Reverse(npm.ByNpmVersion(npmVersions)))
sort.Sort(npm.ByNpmVersion(npmVersions))

if len(npmVersions) > util.IMPORT_ALL_MAX_VERSIONS {
npmVersions = npmVersions[len(npmVersions)-util.IMPORT_ALL_MAX_VERSIONS:]
npmVersions = npmVersions[:util.IMPORT_ALL_MAX_VERSIONS]
}

for _, npmVersion := range npmVersions {
util.Printf(ctx, "%s:\n", npmVersion.Version)

tarballDir := npm.DownloadTar(ctx, npmVersion.Tarball)
// print info for the first version
firstNpmVersion := npmVersions[0]
fmt.Printf("Last version (%s):\n", firstNpmVersion.Version)
fmt.Printf("```\n")
{
tarballDir := npm.DownloadTar(ctx, firstNpmVersion.Tarball)
filesToCopy := pckg.NpmFilesFrom(tarballDir)

if len(filesToCopy) == 0 {
Expand All @@ -84,9 +85,23 @@ func showFiles(path string) {
}

for _, file := range filesToCopy {
util.Printf(ctx, "%s\n", file.To)
fmt.Printf("%s\n", file.To)
}
}
fmt.Printf("```\n")

// aggregate info for the few last version
fmt.Printf("%d Last version:\n", util.IMPORT_ALL_MAX_VERSIONS)
fmt.Printf("```\n")
{
for _, version := range npmVersions {
tarballDir := npm.DownloadTar(ctx, version.Tarball)
filesToCopy := pckg.NpmFilesFrom(tarballDir)

fmt.Printf("%s: %d file(s) matched\n", version.Version, len(filesToCopy))
}
}
fmt.Printf("```\n")
}

func lintPackage(path string) {
Expand Down

0 comments on commit 7ee4d84

Please sign in to comment.