Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update things #123

Merged
merged 5 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ internal/backends/python/regression_tests/test
# nix build creates a "result" symlink to the nix store output
result
internal/backends/python/pypi_map.sqlite
play
play

/vendor

/.direnv
/.envrc
30 changes: 24 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
};
in
{
defaultPackage = upm;
packages = {
default = upm;
inherit upm;
};
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module github.com/replit/upm

go 1.17
go 1.20

require (
cloud.google.com/go/bigquery v1.44.0
github.com/BurntSushi/toml v0.3.1
github.com/hashicorp/go-version v1.2.0
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/mattn/go-sqlite3 v1.14.17
github.com/natefinch/atomic v0.0.0-20150920032501-a62ce929ffcc
github.com/rakyll/statik v0.1.6
github.com/smacker/go-tree-sitter v0.0.0-20230501083651-a7d92773b3aa
Expand All @@ -31,7 +32,6 @@ require (
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
go.opencensus.io v0.24.0 // indirect
Expand Down
988 changes: 0 additions & 988 deletions go.sum

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions internal/backends/backends_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package backends

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -18,7 +17,7 @@ func TestGetBackends(t *testing.T) {
"Cargo.toml": "rust",
}

dir, err := ioutil.TempDir("", "TestGetBackends")
dir, err := os.MkdirTemp("", "TestGetBackends")
if err != nil {
t.Errorf("failed to create a temp directory %v", err)
}
Expand All @@ -27,7 +26,7 @@ func TestGetBackends(t *testing.T) {
for file, backend := range fileToBackend {
tmpfile := filepath.Join(dir, file)

if err := ioutil.WriteFile(tmpfile, []byte{}, 0666); err != nil {
if err := os.WriteFile(tmpfile, []byte{}, 0666); err != nil {
t.Errorf("failed to create empty file: %s err: %v", tmpfile, err)
}

Expand Down
12 changes: 6 additions & 6 deletions internal/backends/dart/dart.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package dart
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -89,7 +89,7 @@ type dartPubspecLock struct {

// dartListPubspecLock lists all deps in a pubspec.lock file
func dartListPubspecLock() map[api.PkgName]api.PkgVersion {
contentsB, err := ioutil.ReadFile("pubspec.lock")
contentsB, err := os.ReadFile("pubspec.lock")
if err != nil {
util.Die("pubspec.lock: %s", err)
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func dartSearch(query string) []api.PkgInfo {
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
util.Die("Pub.dev: %s", err)
}
Expand Down Expand Up @@ -184,7 +184,7 @@ func dartInfo(name api.PkgName) api.PkgInfo {
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
util.Die("Pub.dev: %s", err)
}
Expand Down Expand Up @@ -228,14 +228,14 @@ func writeSpecFile(specs dartPubspecYaml) {
fmt.Println("Marshal Error")
}

err = ioutil.WriteFile("pubspec.yaml", data, 0666)
err = os.WriteFile("pubspec.yaml", data, 0666)
if err != nil {
panic(err)
}
}

func readSpecFile() dartPubspecYaml {
contentsB, err := ioutil.ReadFile("pubspec.yaml")
contentsB, err := os.ReadFile("pubspec.yaml")
if err != nil {
util.Die("pubspec.yaml: %s", err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/backends/dotnet/nuget.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"encoding/xml"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strings"
Expand Down Expand Up @@ -78,7 +78,7 @@ func search(query string) []api.PkgInfo {
return pkgs
}

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
util.Die("Could not read response: %s", err)
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func info(pkgName api.PkgName) api.PkgInfo {
util.Die("failed to get the versions: %s", err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
util.Die("could not read response: %s", err)
}
Expand All @@ -129,7 +129,7 @@ func info(pkgName api.PkgName) api.PkgInfo {
util.Die("failed to get the spec: %s", err)
}
defer res.Body.Close()
body, err = ioutil.ReadAll(res.Body)
body, err = io.ReadAll(res.Body)
if err != nil {
util.Die("could not read response: %s", err)
}
Expand Down
7 changes: 3 additions & 4 deletions internal/backends/dotnet/project_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"strings"

Expand All @@ -31,7 +30,7 @@ type project struct {

// looks for the .NET project files file in the current directory
func findSpecFile() string {
files, err := ioutil.ReadDir("./")
files, err := os.ReadDir("./")
if err != nil {
util.Die("can't read current directory: %s", err)
}
Expand Down Expand Up @@ -68,7 +67,7 @@ func listSpecfile() map[api.PkgName]api.PkgSpec {

// ReadSpec reads the spec and builds up packages.
func ReadSpec(specReader io.Reader) (map[api.PkgName]api.PkgSpec, error) {
xmlbytes, err := ioutil.ReadAll(specReader)
xmlbytes, err := io.ReadAll(specReader)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -123,7 +122,7 @@ type lockFile struct {

// ReadLock reads the lock file and buils up packages.
func ReadLock(lockFileReader io.Reader) (map[api.PkgName]api.PkgVersion, error) {
jsonBytes, err := ioutil.ReadAll(lockFileReader)
jsonBytes, err := io.ReadAll(lockFileReader)
if err != nil {
return nil, err
}
Expand Down
13 changes: 6 additions & 7 deletions internal/backends/elisp/elisp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package elisp
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
Expand All @@ -28,7 +27,7 @@ var ElispBackend = api.LanguageBackend{
return ".cask"
},
Search: func(query string) []api.PkgInfo {
tmpdir, err := ioutil.TempDir("", "elpa")
tmpdir, err := os.MkdirTemp("", "elpa")
if err != nil {
util.Die("%s", err)
}
Expand All @@ -52,7 +51,7 @@ var ElispBackend = api.LanguageBackend{
return results
},
Info: func(name api.PkgName) api.PkgInfo {
tmpdir, err := ioutil.TempDir("", "elpa")
tmpdir, err := os.MkdirTemp("", "elpa")
if err != nil {
util.Die("%s", err)
}
Expand All @@ -76,7 +75,7 @@ var ElispBackend = api.LanguageBackend{
return info
},
Add: func(pkgs map[api.PkgName]api.PkgSpec, projectName string) {
contentsB, err := ioutil.ReadFile("Cask")
contentsB, err := os.ReadFile("Cask")
var contents string
if os.IsNotExist(err) {
contents = `(source melpa)
Expand Down Expand Up @@ -108,7 +107,7 @@ var ElispBackend = api.LanguageBackend{
util.TryWriteAtomic("Cask", contentsB)
},
Remove: func(pkgs map[api.PkgName]bool) {
contentsB, err := ioutil.ReadFile("Cask")
contentsB, err := os.ReadFile("Cask")
if err != nil {
util.Die("Cask: %s", err)
}
Expand Down Expand Up @@ -159,7 +158,7 @@ var ElispBackend = api.LanguageBackend{
return pkgs
},
ListLockfile: func() map[api.PkgName]api.PkgVersion {
contentsB, err := ioutil.ReadFile("packages.txt")
contentsB, err := os.ReadFile("packages.txt")
if err != nil {
util.Die("packages.txt: %s", err)
}
Expand Down Expand Up @@ -197,7 +196,7 @@ var ElispBackend = api.LanguageBackend{
provided[match[1]] = true
}

tempdir, err := ioutil.TempDir("", "epkgs")
tempdir, err := os.MkdirTemp("", "epkgs")
if err != nil {
util.Die("%s", err)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/backends/java/java.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package java
import (
"encoding/xml"
"fmt"
"io/ioutil"
"os"
"regexp"

Expand Down Expand Up @@ -97,7 +96,7 @@ func readProjectOrMakeEmpty(path string) Project {
var xmlbytes []byte
if util.Exists("pom.xml") {
var err error
xmlbytes, err = ioutil.ReadFile("pom.xml")
xmlbytes, err = os.ReadFile("pom.xml")
if err != nil {
util.Die("error reading pom.xml: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/backends/java/msch.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ package java
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/url"
"strings"

Expand Down Expand Up @@ -58,7 +58,7 @@ func mavenSearch(searchURL string) ([]SearchDoc, error) {
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Printf("Could not read response\n")
return []SearchDoc{}, err
Expand Down
6 changes: 3 additions & 3 deletions internal/backends/nodejs/grab.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package nodejs

import (
"context"
"io/ioutil"
"log"
"os"
"path"
"path/filepath"
"strings"
Expand Down Expand Up @@ -142,7 +142,7 @@ func guessBareImports() map[api.PkgName]bool {
}
}

files, err := ioutil.ReadDir(dirName)
files, err := os.ReadDir(dirName)
if err != nil {
log.Fatalln(err)
}
Expand All @@ -164,7 +164,7 @@ func guessBareImports() map[api.PkgName]bool {
continue
}

contents, err := ioutil.ReadFile(absPath)
contents, err := os.ReadFile(absPath)
if err != nil {
log.Fatalln(err)
}
Expand Down
Loading