From e8b448a1318b46c8e9671a4eb57a7e147e0c2eed Mon Sep 17 00:00:00 2001 From: Sven Sauleau Date: Tue, 5 May 2020 21:17:54 +0100 Subject: [PATCH] better show files --- cmd/checker/README.md | 2 ++ cmd/checker/main.go | 34 ++++++++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/cmd/checker/README.md b/cmd/checker/README.md index 5e1c087a..dc349650 100644 --- a/cmd/checker/README.md +++ b/cmd/checker/README.md @@ -1,5 +1,7 @@ # Checker +Tools for our CI. + ## `lint` Check that a package is correctly configured. diff --git a/cmd/checker/main.go b/cmd/checker/main.go index c87fc28a..89ceba10 100644 --- a/cmd/checker/main.go +++ b/cmd/checker/main.go @@ -57,25 +57,29 @@ 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) + // print info for the first version + fmt.Printf("Last version:\n") + fmt.Printf("```\n") + { + firstNpmVersion := npmVersions[0] + + util.Printf(ctx, "%s:\n", firstNpmVersion.Version) - tarballDir := npm.DownloadTar(ctx, npmVersion.Tarball) + tarballDir := npm.DownloadTar(ctx, firstNpmVersion.Tarball) filesToCopy := pckg.NpmFilesFrom(tarballDir) if len(filesToCopy) == 0 { @@ -87,6 +91,20 @@ func showFiles(path string) { util.Printf(ctx, "%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) + + util.Printf(ctx, "%s: %d file(s) matched\n", version.Version, len(filesToCopy)) + } + } + fmt.Printf("```\n") } func lintPackage(path string) {