2016-10-18 18:29:29 +03:00
|
|
|
// Copyright 2016 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-12-07 04:04:34 +03:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2016-10-18 18:29:29 +03:00
|
|
|
"github.com/Masterminds/semver"
|
|
|
|
"github.com/sdboyer/gps"
|
|
|
|
)
|
|
|
|
|
|
|
|
type analyzer struct{}
|
|
|
|
|
2016-12-07 04:04:34 +03:00
|
|
|
// TODO: If we decide to support other tools manifest, this is where we would need
|
|
|
|
// to add that support.
|
2016-10-18 18:29:29 +03:00
|
|
|
func (a analyzer) DeriveManifestAndLock(path string, n gps.ProjectRoot) (gps.Manifest, gps.Lock, error) {
|
2016-12-07 04:04:34 +03:00
|
|
|
mf := filepath.Join(path, manifestName)
|
|
|
|
if fileOK, err := isRegular(mf); err != nil || !fileOK {
|
|
|
|
// Do not return an error, when does not exist
|
|
|
|
return nil, nil, nil
|
|
|
|
}
|
|
|
|
f, err := os.Open(mf)
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, nil
|
|
|
|
}
|
|
|
|
m, err := readManifest(f)
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, err
|
|
|
|
}
|
|
|
|
// TODO: no need to return lock til we decide about preferred versions
|
|
|
|
// https://github.com/sdboyer/gps/wiki/gps-for-Implementors#preferred-versions
|
|
|
|
return m, nil, nil
|
2016-10-18 18:29:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a analyzer) Info() (name string, version *semver.Version) {
|
|
|
|
v, _ := semver.NewVersion("v0.0.1")
|
2017-01-16 03:46:39 +03:00
|
|
|
return "hoard", v
|
2016-10-18 18:29:29 +03:00
|
|
|
}
|