-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cfc
115 lines (84 loc) · 3.14 KB
/
Main.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
component extends="railoRunner" {
variables.controllerBookmark = "/* AutoGen - Do Not Delete */";
variables.mypath = getDirectoryFromPath(getCurrentTemplatePath());
variables.help = {
'create' : "The 'create' command creates a FW/1 scaffold application. All you need to pass is an application name, such as 'fw1 create MyApplication'",
'help' : "That's this method, I can't give you help using help",
'default' : "The current commands you can send to FW1 are: create, help. You can view documentation for a specific command by doing fw1 help <commandname>"
};
function create(paramArray=[]){
if(!ArrayLen(arguments.paramArray)){
return "There needs to be at least a name for the project";
}
if(!Len(arguments.paramArray[1])){
return "The project needs a name";
}
var projectName = paramArray[1];
var projectPath = "#variables.targetpath#/#projectName#" ;
var zipFile = variables.mypath & "templates/newproject.zip";
if(DirectoryExists(projectPath)){
return "Path #projectPath# already exists";
}
DirectoryCreate(projectPath);
zip action="unzip" file="#zipFile#" destination="#projectPath#";
return "Project created at #projectPath#";
}
function hello(){
return "Howdy!";
}
/**
@hint: creates a view, using the dot notation such as section.action
**/
function view(paramArray=[]){
if(!paramArray.Len()){
return "There needs to be a section and action defined";
}
if(paramArray.Len() == 1){
//let's create a view
var viewpath = variables.targetpath & "/views";
//Make sure the views folder has been created
if(!DirectoryExists(viewpath)){
println("Creating #viewpath#");
DirectoryCreate(viewpath);
}
var sectionpath = viewPath & "/" & ListFirst(paramArray[1], ".");
if(!DirectoryExists(sectionpath)){
println("Creating #sectionpath#");
DirectoryCreate(sectionpath);
}
// We only have a section
if(ListLen(paramArray[1],".") EQ 1){
//create the default file
var defaultViewFile = sectionpath & "/default.cfm";
println("Creating view '#paramArray[1]#.default'");
FileWrite(defaultViewFile, "<h1>#paramArray[1]#.default</h1>");
}
if(ListLen(paramArray[1],".") EQ 2){
//create the specific file
var viewFile = sectionpath & "/" & ListGetAt(paramArray[1],2, ".") & ".cfm";
println("Creating view '#paramArray[1]#'");
FileWrite(viewFile, "<h1>#paramArray[1]#</h1>");
}
return ;
}
}
function controller(paramArray=[]){
var controllerFolder = variables.targetpath & "/controllers";
if(!DirectoryExists(controllerFolder)){
println("Creating the controllers folder");
DirectoryCreate(controllerFolder);
}
if(paramArray.len()){
//At least we have the name of the controller!
var controllerFile = controllerFolder & "/" & paramArray[1] & ".cfc";
if(!FileExists(controllerFile)){
println("Creating the #paramArray[1]#.cfc controller file");
FileCopy(variables.mypath & "templates/controller.cfc", controllerFile);
}
}
println(Serialize(paramArray));
}
function section(paramArray=[]){
println(Serialize(paramArray));
}
}