Skip to content

Commit 1de4bde

Browse files
committed
Set DEFAULT_TEMPLATE_TAG to v0.2.1(latest) and update create plugin to support --tag param
Signed-off-by: jorgee <jorge.ejarque@seqera.io>
1 parent 24903f2 commit 1de4bde

2 files changed

Lines changed: 32 additions & 6 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/cli/CmdPlugin.groovy

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import org.eclipse.jgit.api.Git
3737
@CompileStatic
3838
@Parameters(commandDescription = "Execute plugin-specific commands")
3939
class CmdPlugin extends CmdBase {
40+
private static String DEFAULT_TEMPLATE_TAG='v0.2.1'
4041

4142
@Override
4243
String getName() {
@@ -64,7 +65,7 @@ class CmdPlugin extends CmdBase {
6465
Plugins.pull(args[1].tokenize(','))
6566
}
6667
else if( args[0] == 'create' ) {
67-
createPlugin(args)
68+
createPlugin(args, params.get('tag', DEFAULT_TEMPLATE_TAG))
6869
}
6970
// plugin run command
7071
else if( args[0].contains(CMD_SEP) ) {
@@ -98,7 +99,7 @@ class CmdPlugin extends CmdBase {
9899
}
99100
}
100101

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

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

134135
// clone the template repo
135-
clonePluginTemplate(targetDir)
136+
clonePluginTemplate(targetDir, tag)
136137
// now refactor the template code
137138
refactor.apply()
138139
// remove git plat
@@ -148,14 +149,14 @@ class CmdPlugin extends CmdBase {
148149
: new BufferedReader(new InputStreamReader(System.in)).readLine()
149150
}
150151

151-
static private void clonePluginTemplate(File targetDir) {
152+
static private void clonePluginTemplate(File targetDir, String tag) {
152153
final templateUri = "https://github.com/nextflow-io/nf-plugin-template.git"
153154
try {
154155
Git.cloneRepository()
155156
.setURI(templateUri)
156157
.setDirectory(targetDir)
157-
.setBranchesToClone(["refs/tags/v0.2.0"])
158-
.setBranch("refs/tags/v0.2.0")
158+
.setBranchesToClone(["refs/tags/$tag".toString()])
159+
.setBranch("refs/tags/$tag")
159160
.call()
160161
}
161162
catch (Exception e) {

modules/nextflow/src/test/groovy/nextflow/cli/CmdPluginCreateTest.groovy

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,29 @@ class CmdPluginCreateTest extends Specification {
6969
folder?.deleteDir()
7070
}
7171

72+
def 'should clone and create a plugin project for v0.2.0 tag' () {
73+
given:
74+
def folder = Files.createTempDirectory('test')
75+
and:
76+
def args = [
77+
'create',
78+
'hello world plugin',
79+
'foo',
80+
folder.toAbsolutePath().toString() + '/hello']
81+
def params = [tag: 'v0.2.0']
82+
83+
when:
84+
def cmd = new CmdPlugin(args: args, params: params)
85+
and:
86+
cmd.run()
87+
88+
then:
89+
//Checks that clone is done from v0.2.0 by checking that gradle plugin version and url is the same as in the tag
90+
Path.of(folder.resolve('hello/build.gradle').toUri()).text.contains("id 'io.nextflow.nextflow-plugin' version '0.0.1-alpha4'")
91+
Path.of(folder.resolve('hello/build.gradle').toUri()).text.contains("url = 'https://nf-plugins-registry.dev-tower.net/api'")
92+
93+
cleanup:
94+
folder?.deleteDir()
95+
}
96+
7297
}

0 commit comments

Comments
 (0)