Skip to content
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: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.DS_Store
.idea
.bin
/bin
/.bin
/build
/bin
/linux
/darwin
/windows
192 changes: 138 additions & 54 deletions buildpack.toml

Large diffs are not rendered by default.

28 changes: 13 additions & 15 deletions dependency/retrieval/go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
module github.com/paketo-buildpacks/node-engine/retrieval

go 1.24.3

toolchain go1.24.4
go 1.24.6

require (
github.com/Masterminds/semver/v3 v3.4.0
github.com/paketo-buildpacks/libdependency v0.1.0
github.com/paketo-buildpacks/packit/v2 v2.20.0
github.com/paketo-buildpacks/libdependency v0.2.1
github.com/paketo-buildpacks/packit/v2 v2.25.0
)

require (
Expand All @@ -21,7 +19,7 @@ require (
github.com/dgryski/go-minhash v0.0.0-20190315135803-ad340ca03076 // indirect
github.com/ekzhu/minhash-lsh v0.0.0-20190924033628-faac2c6342f8 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gabriel-vasile/mimetype v1.4.10 // indirect
github.com/go-enry/go-license-detector/v4 v4.3.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
Expand All @@ -30,22 +28,22 @@ require (
github.com/hhatto/gorst v0.0.0-20181029133204-ca9f730cac5b // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jdkato/prose v1.2.1 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/moby/go-archive v0.1.0 // indirect
github.com/kevinburke/ssh_config v1.4.0 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/pjbgf/sha1cd v0.3.2 // indirect
github.com/pjbgf/sha1cd v0.5.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.4.0 // indirect
github.com/shogo82148/go-shuffle v1.1.1 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/ulikunitz/xz v0.5.14 // indirect
github.com/ulikunitz/xz v0.5.15 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.26.0 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/sys v0.36.0 // indirect
golang.org/x/text v0.29.0 // indirect
gonum.org/v1/gonum v0.16.0 // indirect
gopkg.in/neurosnap/sentences.v1 v1.0.7 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
156 changes: 94 additions & 62 deletions dependency/retrieval/go.sum

Large diffs are not rendered by default.

44 changes: 31 additions & 13 deletions dependency/retrieval/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func (nodeMetadata NodeMetadata) Version() *semver.Version {
}

func main() {
retrieve.NewMetadata("node", getAllVersions, generateMetadata)
retrieve.NewMetadataWithPlatforms("node", getAllVersions, generateMetadataWithPlatform)
}

func generateMetadata(versionFetcher versionology.VersionFetcher) ([]versionology.Dependency, error) {
func generateMetadataWithPlatform(versionFetcher versionology.VersionFetcher, platform retrieve.Platform) ([]versionology.Dependency, error) {
version := versionFetcher.Version().String()

body, err := httpGet("https://nodejs.org/dist/index.json")
Expand All @@ -58,7 +58,7 @@ func generateMetadata(versionFetcher versionology.VersionFetcher) ([]versionolog

for _, release := range nodeReleases {
if strings.TrimPrefix(release.Version, "v") == version {
return createDependencyMetadata(release, releaseSchedule)
return createDependencyMetadata(release, releaseSchedule, platform)
}
}

Expand Down Expand Up @@ -108,11 +108,19 @@ func getReleaseSchedule() (ReleaseSchedule, error) {
return releaseSchedule, nil
}

func createDependencyMetadata(release NodeRelease, releaseSchedule ReleaseSchedule) ([]versionology.Dependency, error) {
func createDependencyMetadata(release NodeRelease, releaseSchedule ReleaseSchedule, platform retrieve.Platform) ([]versionology.Dependency, error) {

var nodeArch string
if platform.Arch == "amd64" {
nodeArch = "x64"
} else {
nodeArch = platform.Arch
}

version := release.Version
url := fmt.Sprintf("https://nodejs.org/dist/%[1]s/node-%[1]s-linux-x64.tar.xz", version)
url := fmt.Sprintf("https://nodejs.org/dist/%[1]s/node-%[1]s-%[2]s-%[3]s.tar.xz", version, platform.OS, nodeArch)

checksum, err := getChecksum(version)
checksum, err := getChecksum(version, platform)
if err != nil {
return nil, err
}
Expand All @@ -132,15 +140,17 @@ func createDependencyMetadata(release NodeRelease, releaseSchedule ReleaseSchedu
Licenses: retrieve.LookupLicenses(url, upstream.DefaultDecompress),
DeprecationDate: deprecationDate,
StripComponents: 1,
Stacks: []string{"io.buildpacks.stacks.jammy", "*"},
Stacks: []string{"*"},
OS: platform.OS,
Arch: platform.Arch,
}

jammyDependency, err := versionology.NewDependency(dep, "jammy")
allStacksDependency, err := versionology.NewDependency(dep, "*")
if err != nil {
return nil, fmt.Errorf("could get create jammy dependency: %w", err)
return nil, fmt.Errorf("could not get create * dependency: %w", err)
}

return []versionology.Dependency{jammyDependency}, nil
return []versionology.Dependency{allStacksDependency}, nil
}

func getDeprecationDate(version string, releaseSchedule ReleaseSchedule) *time.Time {
Expand All @@ -161,20 +171,28 @@ func getDeprecationDate(version string, releaseSchedule ReleaseSchedule) *time.T
return &deprecationDate
}

func getChecksum(version string) (string, error) {
func getChecksum(version string, platform retrieve.Platform) (string, error) {

var nodeArch string
if platform.Arch == "amd64" {
nodeArch = "x64"
} else {
nodeArch = platform.Arch
}

body, err := httpGet(fmt.Sprintf("https://nodejs.org/dist/%s/SHASUMS256.txt", version))
if err != nil {
return "", fmt.Errorf("could not get SHA256 file: %w", err)
}

var dependencySHA string
for _, line := range strings.Split(string(body), "\n") {
if strings.HasSuffix(line, fmt.Sprintf("node-%s-linux-x64.tar.xz", version)) {
if strings.HasSuffix(line, fmt.Sprintf("node-%[1]s-%[2]s-%[3]s.tar.xz", version, platform.OS, nodeArch)) {
dependencySHA = strings.Fields(line)[0]
}
}
if dependencySHA == "" {
return "", fmt.Errorf("could not find SHA256 for node-%s-linux-x64.tar.xz", version)
return "", fmt.Errorf("could not find SHA256 for node-%s-%s-%s.tar.xz", version, platform.OS, nodeArch)
}
return dependencySHA, nil
}
Expand Down
38 changes: 19 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
cloud.google.com/go/storage v1.56.1 // indirect
dario.cat/mergo v1.0.2 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20250520111509-a70c2aa677fa // indirect
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/CycloneDX/cyclonedx-go v0.9.2 // indirect
github.com/DataDog/zstd v1.5.7 // indirect
Expand All @@ -41,16 +41,16 @@ require (
github.com/adrg/xdg v0.5.3 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/anchore/archiver/v3 v3.5.3-0.20241210171143-5b1d8d1c7c51 // indirect
github.com/anchore/clio v0.0.0-20250319180342-2cfe4b0cb716 // indirect
github.com/anchore/fangs v0.0.0-20250319222917-446a1e748ec2 // indirect
github.com/anchore/go-collections v0.0.0-20240216171411-9321230ce537 // indirect
github.com/anchore/clio v0.0.0-20250908162139-4390b5d3d46e // indirect
github.com/anchore/fangs v0.0.0-20250908220736-f686ade3235a // indirect
github.com/anchore/go-collections v0.0.0-20250717130425-e4a173a279ef // indirect
github.com/anchore/go-homedir v0.0.0-20250319154043-c29668562e4d // indirect
github.com/anchore/go-logger v0.0.0-20250318195838-07ae343dd722 // indirect
github.com/anchore/go-logger v0.0.0-20250813181427-74728f89a619 // indirect
github.com/anchore/go-lzo v0.1.0 // indirect
github.com/anchore/go-macholibre v0.0.0-20220308212642-53e6d0aaf6fb // indirect
github.com/anchore/go-macholibre v0.0.0-20250826193721-3cd206ca93aa // indirect
github.com/anchore/go-rpmdb v0.0.0-20250516171929-f77691e1faec // indirect
github.com/anchore/go-struct-converter v0.0.0-20221221214134-65614c61201e // indirect
github.com/anchore/go-sync v0.0.0-20250326131806-4eda43a485b6 // indirect
github.com/anchore/go-struct-converter v0.0.0-20250211213226-cce56d595160 // indirect
github.com/anchore/go-sync v0.0.0-20250826180238-74d8443d8ac6 // indirect
github.com/anchore/go-version v1.2.2-0.20200701162849-18adb9c92b9b // indirect
github.com/anchore/packageurl-go v0.1.1-0.20250220190351-d62adb6e1115 // indirect
github.com/anchore/stereoscope v0.1.9 // indirect
Expand Down Expand Up @@ -80,7 +80,7 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/becheran/wildmatch-go v1.0.0 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bitnami/go-version v0.0.0-20250131085805-b1f57a8634ef // indirect
github.com/bitnami/go-version v0.0.0-20250826054534-3a75c1206244 // indirect
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb // indirect
github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect
github.com/bodgit/plumbing v1.3.0 // indirect
Expand Down Expand Up @@ -110,15 +110,15 @@ require (
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da // indirect
github.com/deitch/magic v0.0.0-20240306090643-c67ab88f10cb // indirect
github.com/diskfs/go-diskfs v1.7.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/cli v28.4.0+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v28.4.0+incompatible // indirect
github.com/docker/docker-credential-helpers v0.9.3 // indirect
github.com/docker/go-connections v0.6.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-events v0.0.0-20250808211157-605354379745 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
Expand Down Expand Up @@ -151,7 +151,7 @@ require (
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-containerregistry v0.20.6 // indirect
github.com/google/licensecheck v0.3.1 // indirect
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 // indirect
github.com/google/pprof v0.0.0-20250903194437-c28834ac2320 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
Expand Down Expand Up @@ -208,7 +208,7 @@ require (
github.com/nwaples/rardecode/v2 v2.1.1 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/oklog/ulid/v2 v2.1.1 // indirect
github.com/olekukonko/cat v0.0.0-20250808191157-46fba99501f3 // indirect
github.com/olekukonko/cat v0.0.0-20250908003013-b0de306c343b // indirect
github.com/olekukonko/errors v1.1.0 // indirect
github.com/olekukonko/ll v0.1.1 // indirect
github.com/olekukonko/tablewriter v1.0.9 // indirect
Expand Down Expand Up @@ -242,7 +242,7 @@ require (
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/sorairolake/lzip-go v0.3.8 // indirect
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
github.com/spdx/gordf v0.0.0-20201111095634-7098f93598fb // indirect
github.com/spdx/gordf v0.0.0-20250128162952-000978ccd6fb // indirect
github.com/spdx/tools-golang v0.5.5 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
Expand Down Expand Up @@ -282,7 +282,7 @@ require (
go.yaml.in/yaml/v3 v3.0.4 // indirect
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
golang.org/x/exp v0.0.0-20250819193227-8b4c13bb791b // indirect
golang.org/x/mod v0.28.0 // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/oauth2 v0.31.0 // indirect
Expand All @@ -292,11 +292,11 @@ require (
golang.org/x/text v0.29.0 // indirect
golang.org/x/time v0.13.0 // indirect
golang.org/x/tools v0.36.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/api v0.249.0 // indirect
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250818200422-3122310a409c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
google.golang.org/genproto v0.0.0-20250908214217-97024824d090 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250908214217-97024824d090 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250908214217-97024824d090 // indirect
google.golang.org/grpc v1.75.1 // indirect
google.golang.org/protobuf v1.36.9 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
Loading
Loading