mirror of
https://github.com/drone-plugins/drone-npm.git
synced 2026-06-14 05:12:29 +08:00
Add boilr template stubs
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2019, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/drone-plugins/drone-npm/pkg/npm"
|
||||
)
|
||||
|
||||
const (
|
||||
// Add all the flag names here as const strings.
|
||||
)
|
||||
|
||||
// settingsFlags has the cli.Flags for the plugin.Settings.
|
||||
func settingsFlags() []cli.Flag {
|
||||
// Replace below with all the flags required for the plugin's specific
|
||||
// settings.
|
||||
return []cli.Flag{}
|
||||
}
|
||||
|
||||
// settingsFromContext creates a plugin.Settings from the cli.Context.
|
||||
func settingsFromContext(ctx *cli.Context) npm.Settings {
|
||||
// Replace below with the parsing of the
|
||||
return npm.Settings{}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2019, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// DO NOT MODIFY THIS FILE DIRECTLY
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/drone-plugins/drone-plugin-lib/pkg/urfave"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/drone-plugins/drone-npm/pkg/npm"
|
||||
)
|
||||
|
||||
var (
|
||||
version = "unknown"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "npm plugin"
|
||||
app.Usage = "pushes a package to a npm repository"
|
||||
app.Action = run
|
||||
app.Flags = append(settingsFlags(), urfave.Flags()...)
|
||||
|
||||
// Run the application
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func run(ctx *cli.Context) error {
|
||||
urfave.LoggingFromContext(ctx)
|
||||
|
||||
plugin := npm.New(
|
||||
settingsFromContext(ctx),
|
||||
urfave.PipelineFromContext(ctx),
|
||||
urfave.NetworkFromContext(ctx),
|
||||
)
|
||||
|
||||
// Validate the settings
|
||||
if err := plugin.Validate(); err != nil {
|
||||
return errors.Wrap(err, "validation failed")
|
||||
}
|
||||
|
||||
// Run the plugin
|
||||
if err := plugin.Exec(); err != nil {
|
||||
return errors.Wrap(err, "exec failed")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2019, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package npm
|
||||
|
||||
import (
|
||||
"github.com/drone-plugins/drone-plugin-lib/pkg/plugin"
|
||||
"github.com/drone-plugins/drone-plugin-lib/pkg/urfave"
|
||||
)
|
||||
|
||||
type pluginImpl struct {
|
||||
settings Settings
|
||||
pipeline plugin.Pipeline
|
||||
network urfave.Network
|
||||
}
|
||||
|
||||
// New Plugin from the given Settings, Pipeline, and Network.
|
||||
func New(settings Settings, pipeline plugin.Pipeline, network urfave.Network) plugin.Plugin {
|
||||
return &pluginImpl{
|
||||
settings: settings,
|
||||
pipeline: pipeline,
|
||||
network: network,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2019, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package npm
|
||||
|
||||
// Settings for the Plugin.
|
||||
type Settings struct {
|
||||
// Fill in the data structure with appropriate values
|
||||
}
|
||||
|
||||
func (p *pluginImpl) Validate() error {
|
||||
// Validate the Config and return an error if there are issues.
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *pluginImpl) Exec() error {
|
||||
// Implementation of the plugin.
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright (c) 2019, the Drone Plugins project authors.
|
||||
// Please see the AUTHORS file for details. All rights reserved.
|
||||
// Use of this source code is governed by an Apache 2.0 license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package npm
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPlugin(t *testing.T) {
|
||||
t.Skip()
|
||||
}
|
||||
Reference in New Issue
Block a user