Skip to content
Closed
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
13 changes: 7 additions & 6 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.eclipse.jgit.api.Git
@CompileStatic
@Parameters(commandDescription = "Execute plugin-specific commands")
class CmdPlugin extends CmdBase {
private static String DEFAULT_TEMPLATE_TAG='v0.2.1'

@Override
String getName() {
Expand Down Expand Up @@ -64,7 +65,7 @@ class CmdPlugin extends CmdBase {
Plugins.pull(args[1].tokenize(','))
}
else if( args[0] == 'create' ) {
createPlugin(args)
createPlugin(args, params.get('tag', DEFAULT_TEMPLATE_TAG))
}
// plugin run command
else if( args[0].contains(CMD_SEP) ) {
Expand Down Expand Up @@ -98,7 +99,7 @@ class CmdPlugin extends CmdBase {
}
}

static createPlugin(List<String> args) {
static createPlugin(List<String> args, String tag) {
if( args != ['create'] && (args[0] != 'create' || !(args.size() in [3, 4])) )
throw new AbortOperationException("Invalid create parameters - usage: nextflow plugin create <Plugin name> <Organization name>")

Expand Down Expand Up @@ -132,7 +133,7 @@ class CmdPlugin extends CmdBase {
final File targetDir = refactor.getPluginDir()

// clone the template repo
clonePluginTemplate(targetDir)
clonePluginTemplate(targetDir, tag)
// now refactor the template code
refactor.apply()
// remove git plat
Expand All @@ -148,14 +149,14 @@ class CmdPlugin extends CmdBase {
: new BufferedReader(new InputStreamReader(System.in)).readLine()
}

static private void clonePluginTemplate(File targetDir) {
static private void clonePluginTemplate(File targetDir, String tag) {
final templateUri = "https://github.com/nextflow-io/nf-plugin-template.git"
try {
Git.cloneRepository()
.setURI(templateUri)
.setDirectory(targetDir)
.setBranchesToClone(["refs/tags/v0.2.0"])
.setBranch("refs/tags/v0.2.0")
.setBranchesToClone(["refs/tags/$tag".toString()])
.setBranch("refs/tags/$tag")
.call()
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,29 @@ class CmdPluginCreateTest extends Specification {
folder?.deleteDir()
}

def 'should clone and create a plugin project for v0.2.0 tag' () {
given:
def folder = Files.createTempDirectory('test')
and:
def args = [
'create',
'hello world plugin',
'foo',
folder.toAbsolutePath().toString() + '/hello']
def params = [tag: 'v0.2.0']

when:
def cmd = new CmdPlugin(args: args, params: params)
and:
cmd.run()

then:
//Checks that clone is done from v0.2.0 by checking that gradle plugin version and url is the same as in the tag
Path.of(folder.resolve('hello/build.gradle').toUri()).text.contains("id 'io.nextflow.nextflow-plugin' version '0.0.1-alpha4'")
Path.of(folder.resolve('hello/build.gradle').toUri()).text.contains("url = 'https://nf-plugins-registry.dev-tower.net/api'")

cleanup:
folder?.deleteDir()
}

}