Skip to content

Commit 56264f6

Browse files
committed
#91 Nodeclipse CLI 0.10.0
1 parent c157aed commit 56264f6

File tree

9 files changed

+204
-37
lines changed

9 files changed

+204
-37
lines changed

org.nodeclipse.ui/templates/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Check <http://www.nodeclipse.org/> on how to get Nodeclipse or Enide Studio
3232
hello-coffee The same server written in CoffeeScript
3333
hello-typescript The same server written in TypeScript
3434
hello-html Template with HTML file
35-
35+
template-gradle-java Gradle Java project
36+
template-maven-java Maven Java project
37+
3638
Examples:
3739

3840
nodeclipse -p
@@ -106,6 +108,7 @@ options are:
106108

107109
0.8.2 fix #101 (bug on MacOS); -g option
108110
0.8.3 fix general project template
111+
0.10.0 add 2 java templates
109112

110113
## News
111114

org.nodeclipse.ui/templates/copier.js

Lines changed: 52 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,31 @@ var argv = require('optimist')
1414
.alias('v','version').describe('v', 'print nodeclipse CLI version')
1515
.alias('V','verbose').describe('V', 'be verbose')
1616
.argv;
17+
18+
var helpstr =
19+
" Usage: nodeclipse [arguments] \n\
20+
\n\
21+
Arguments: \n\
22+
-c, --create <name> create project folder and prepare it \n\
23+
-u, --use <template> use/copy specified template when creating project \n\
24+
-p, --prepare prepare Nodeclipse [Node.js] project for import, i.e. add needed `.project` file and other `.*`\n\
25+
files ('.gitignore', '.jshintrc', '.settings/') if there is no `.project` yet\n\
26+
-g, --eclipse_project_general prepare General Eclipse project for import, i.e. add only needed `.project` file\n\
27+
-n, --name [<name>] project name (default is folder name)\n\
28+
-h, --help this help screen\n\
29+
-v, --version print nodeclipse CLI's version\n\
30+
-V, --verbose be verbose\n\
31+
\n\
32+
Templates are just folders in this project sources:\n\
33+
hello-world The famous hello world HTTP server in 6 lines\n\
34+
hello-coffee The same server written in CoffeeScript\n\
35+
hello-typescript The same server written in TypeScript\n\
36+
hello-html Template with HTML file\n\
37+
template-gradle-java Gradle Java project\n\
38+
template-maven-java Maven Java project\n\
39+
";
40+
41+
1742
require('shelljs/global');
1843
var fs= require('fs');
1944
var path= require('path');
@@ -78,28 +103,6 @@ var executeActions = function () {
78103
// TypeError: path must be a string
79104
// at Object.fs.open (fs.js:404:11)
80105

81-
82-
var helpstr =
83-
" Usage: nodeclipse [arguments] \n\
84-
\n\
85-
Arguments: \n\
86-
-c, --create <name> create project folder and prepare it \n\
87-
-u, --use <template> use/copy specified template when creating project \n\
88-
-p, --prepare prepare Nodeclipse [Node.js] project for import, i.e. add needed `.project` file and other `.*`\n\
89-
files ('.gitignore', '.jshintrc', '.settings/') if there is no `.project` yet\n\
90-
-g, --eclipse_project_general prepare General Eclipse project for import, i.e. add only needed `.project` file\n\
91-
-n, --name [<name>] project name (default is folder name)\n\
92-
-h, --help this help screen\n\
93-
-v, --version print nodeclipse CLI's version\n\
94-
-V, --verbose be verbose\n\
95-
\n\
96-
Templates are just folders in this project sources:\n\
97-
hello-world The famous hello world HTTP server in 6 lines\n\
98-
hello-coffee The same server written in CoffeeScript\n\
99-
hello-typescript The same server written in TypeScript\n\
100-
hello-html Template with HTML file\n\
101-
";
102-
103106
console.log(helpstr);
104107
console.log("Check README.md and sources at "+__dirname);
105108
return;
@@ -108,7 +111,7 @@ var executeActions = function () {
108111
console.log("Nodeclipse CLI "+require('./package.json').version );
109112
return;
110113
}
111-
if (projectFileExists) {
114+
if (projectFileExists && !create) {
112115
console.log(".project file already exists!");
113116
return;
114117
}
@@ -125,14 +128,29 @@ var executeActions = function () {
125128
if (verbose) console.log("Created project/folder: " + create);
126129
}
127130

131+
var curfolder = pwd();
128132
var templatesfolder = __dirname;
129133
if (debug) console.log("Templates folder is: " + templatesfolder);
134+
if (!name){
135+
name = path.basename(curfolder);
136+
}
130137

131-
if (use){
138+
if (use){ //template
132139
//cp(__dirname+use+'/*','.');
133140
var fromfolder = path.join(templatesfolder, use, '/*')
134141
if (verbose) console.log("Copying from "+ fromfolder );
135142
cp( fromfolder, '.' )
143+
144+
if(use.indexOf('template') == 0 ){ //.startsWith() //http://stackoverflow.com/questions/646628/javascript-startswith
145+
// template-* do not use common-templates
146+
147+
// .files special treatment ( Node.js shelljs is likely not good tool for this)
148+
copyDotProjectFile(use, curfolder, '/.project', name);
149+
copyDotProjectFile(use, curfolder, '/.classpath', name);
150+
151+
inviteToSiteAsTheLastLine();
152+
return;
153+
}
136154
}
137155

138156
// common-templates
@@ -167,31 +185,30 @@ var executeActions = function () {
167185

168186
// .project
169187
if (debug) console.log('projectNodeclipse='+projectNodeclipse+', projectGeneral='+projectGeneral);
170-
var curfolder = pwd();
171188
if (verbose) console.log("Current folder is: " + curfolder);
172-
if (!name){
173-
name = path.basename(curfolder);
174-
}
175189
if (prepare){
176-
copyDotProjectFile('eclipse',curfolder, name);
190+
copyDotProjectFile('eclipse', curfolder, '/.project', name);
177191
} else if (projectGeneral){
178-
copyDotProjectFile('eclipse-project-general',curfolder, name);
192+
copyDotProjectFile('eclipse-project-general', curfolder, '/.project', name);
179193
}
180194

181195
inviteToSiteAsTheLastLine();
182196
}
183-
var copyDotProjectFile = function (eclipse, curfolder, name) {
197+
var copyDotProjectFile = function (eclipse, curfolder, what, name) {
184198
if (!eclipse) eclipse = 'eclipse';
185-
var str = cat(__dirname+'/'+eclipse+'/.project').replace('${projectname}', name);
186-
var destfile = curfolder + '/.project';
199+
if (!what) eclipse = '/.project';
200+
var str = cat(__dirname+'/'+eclipse + what).replace('${projectname}', name);
201+
var destfile = curfolder + what;
187202

188203
// http://www.nodejs.org/api/fs.html#fs_fs_appendfile_filename_data_options_callback
189204
fs.writeFile(destfile, str, function(err) {
190205
if (err)
191206
throw err;
192207
if (verbose) console.log('The file "'+destfile+'" was created !');
193-
console.log('In Eclipse/Enide select File -> Import... -> General / Existing Projects into Workspace');
194-
console.log('and enter project directory: '+curfolder);
208+
if (what == '/.project'){
209+
console.log('In Eclipse/Enide select File -> Import... -> General / Existing Projects into Workspace');
210+
console.log('and enter project directory: '+curfolder);
211+
}
195212
});
196213

197214
if (debug) console.log(str); // ''.toString()

org.nodeclipse.ui/templates/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nodeclipse",
3-
"version": "0.8.3",
3+
"version": "0.10.0",
44
"description": "nodeclipse CLI - prepare Node.js project to be imported into Eclipse (Nodeclipse)",
55
"main": "copier.js",
66
"scripts": {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src/main/java"/>
4+
<classpathentry kind="src" path="src/main/resources"/>
5+
<classpathentry kind="src" path="src/test/java"/>
6+
<classpathentry kind="src" path="src/test/resources"/>
7+
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
8+
<classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/>
9+
<classpathentry kind="output" path="bin"/>
10+
</classpath>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>${projectname}</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.springsource.ide.eclipse.gradle.core.nature</nature>
16+
<nature>org.eclipse.jdt.core.javanature</nature>
17+
</natures>
18+
</projectDescription>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apply plugin: 'java'
2+
apply plugin: 'eclipse'
3+
4+
sourceCompatibility = 1.5
5+
version = '1.0'
6+
jar {
7+
manifest {
8+
attributes 'Implementation-Title': '${projectname}', 'Implementation-Version': version
9+
}
10+
}
11+
12+
repositories {
13+
mavenCentral()
14+
}
15+
16+
dependencies {
17+
// compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
18+
// testCompile group: 'junit', name: 'junit', version: '4.+'
19+
}
20+
21+
test {
22+
systemProperties 'property': 'value'
23+
}
24+
25+
uploadArchives {
26+
repositories {
27+
flatDir {
28+
dirs 'repos'
29+
}
30+
}
31+
}
32+
33+
task "create-dirs" << {
34+
sourceSets*.java.srcDirs*.each { it.mkdirs() }
35+
sourceSets*.resources.srcDirs*.each { it.mkdirs() }
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
26+
<attributes>
27+
<attribute name="maven.pomderived" value="true"/>
28+
</attributes>
29+
</classpathentry>
30+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
31+
<attributes>
32+
<attribute name="maven.pomderived" value="true"/>
33+
</attributes>
34+
</classpathentry>
35+
<classpathentry kind="output" path="target/classes"/>
36+
</classpath>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>${projectname}</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>${projectname}</groupId>
5+
<artifactId>${projectname}</artifactId>
6+
<version>0.1.0-SNAPSHOT</version>
7+
8+
<properties>
9+
<!-- use UTF-8 for everything -->
10+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
12+
</properties>
13+
14+
<!--
15+
<dependencies>
16+
<dependency>
17+
<groupId>junit</groupId>
18+
<artifactId>junit</artifactId>
19+
<version>4.11</version>
20+
<scope>test</scope>
21+
</dependency>
22+
</dependencies>
23+
-->
24+
</project>

0 commit comments

Comments
 (0)