Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More work on project archetypes

  • Loading branch information...
commit 183996c8ea22db86a1297049fc53b295054eb2f3 1 parent 89edaa4
Magnar Sveen authored
12 project-archetypes/clj-ring-archetype.el
View
@@ -0,0 +1,12 @@
+(defun create-clj-ring (project-name)
+ (interactive "sProject name: ")
+ (pa-with-new-project project-name "clj-ring"
+ ((cons "__project-name__" project-name)
+ (cons "__project_name__" (s-snake-case project-name)))))
+
+(defun pa--testing-fn ()
+ (shell-command "rm -rf ~/projects/test-test" pa-out)
+ (create-clj-ring "test-test")
+ (find-file-other-window "~/projects/test-test"))
+
+(provide 'clj-ring-archetype)
12 project-archetypes/clj-ring/.gitignore
View
@@ -0,0 +1,12 @@
+/target
+/lib
+/classes
+/checkouts
+pom.xml
+pom.xml.asc
+*.jar
+*.class
+.lein-deps-sum
+.lein-failures
+.lein-plugins
+.lein-repl-history
2  project-archetypes/clj-ring/resources/public/css/reset.css
View
@@ -0,0 +1,2 @@
+/* Eric Meyer's Reset CSS v2.0 - http://cssreset.com */
+html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0}
17 project-archetypes/clj-ring/src/__project_name__/core.clj
View
@@ -0,0 +1,17 @@
+(ns __project-name__.core
+ (:use compojure.core)
+ (:use hiccup.core)
+ (:use hiccup.page)
+ (:require [compojure.route :as route]))
+
+(defn render-index []
+ (html5
+ [:head
+ [:meta {:charset "utf-8"}]
+ [:meta {:name "viewport"
+ :content "width=device-width, initial-scale=1.0, maximum-scale=1"}]]))
+
+(defroutes app
+ (GET "/" [] (render-index))
+ (route/resources "/")
+ (route/not-found "<h1>Page not found</h1>"))
14 project-archetypes/js-buster-browser-archetype.el
View
@@ -0,0 +1,14 @@
+(defun create-js-buster-browser (project-name description global)
+ (interactive "sProject name:
+sDescription:
+sGlobal namespace: ")
+ (pa-with-new-project project-name "js-buster-browser"
+ ((cons "__project-name__" project-name)
+ (cons "__description__" description)
+ (cons "__GLOBAL__" global))
+ (magit-ignore-file ".rvmrc" nil t)
+ (magit-ignore-file "todo.org" nil t)
+ (pa-sh "npm link buster")
+ (pa-sh "npm install")))
+
+(provide 'js-buster-browser-archetype)
3  project-archetypes/js-buster-browser/README.md
View
@@ -1,5 +1,6 @@
-#
+# __project-name__
+__description__
## License
9 project-archetypes/js-buster-browser/autolint.js
View
@@ -3,7 +3,9 @@ module.exports = {
"test/**/*.js",
"lib/**/*.js"
],
+
"linterOptions": {
+ "indent": 2,
"vars": true,
"nomen": true,
"sloppy": true,
@@ -14,8 +16,11 @@ module.exports = {
"buster",
"cull",
"dome",
- "document"
+ "__GLOBAL__"
]
},
- "excludes": []
+
+ "excludes": [
+ "external"
+ ]
};
12 project-archetypes/js-buster-browser/buster.js
View
@@ -1,8 +1,8 @@
exports["Browser tests"] = {
- environment: "browser",
- libs: ["external/cull.js", "external/dome.js"],
- sources: ["lib/*.js"],
- tests: ["test/*.js"],
- extensions: [require("buster-lint")],
- "buster-lint": require("./autolint")
+ environment: "browser",
+ libs: ["external/cull.js", "external/dome.js"],
+ sources: ["lib/*.js"],
+ tests: ["test/*.js"],
+ extensions: [require("buster-lint")],
+ "buster-lint": require("./autolint")
};
1  project-archetypes/js-buster-browser/lib/main.js
View
@@ -0,0 +1 @@
+var __GLOBAL__ = this.__GLOBAL__ || {};
16 project-archetypes/js-buster-browser/package.json
View
@@ -1,10 +1,10 @@
{
- "name": "testing",
- "version": "0.0.1",
- "description": "testing",
- "author": { "name": "Magnar Sveen" },
- "devDependencies": {
- "buster": "~0.6",
- "buster-lint": "~0"
- }
+ "name": "__project-name__",
+ "version": "0.1.0",
+ "description": "__description__",
+ "author": { "name": "Magnar Sveen" },
+ "devDependencies": {
+ "buster": "~0.6",
+ "buster-lint": "~0"
+ }
}
1  project-archetypes/js-buster-browser/run-tests.sh
View
@@ -0,0 +1 @@
+buster test -F warning
7 project-archetypes/js-buster-browser/test/main-test.js
View
@@ -0,0 +1,7 @@
+(function () {
+ buster.testCase("Main", {
+ "Your blank slate, Sir": function () {
+ assert(true);
+ }
+ });
+}());
2  project-archetypes/js-buster-browser/watch-tests.watchr
View
@@ -7,7 +7,7 @@ end
def run_all_tests
system('clear')
- result = run "buster test -F warning"
+ result = run "./run-tests.sh"
puts result
end
65 site-lisp/project-archetypes/project-archetypes.el
View
@@ -1,22 +1,57 @@
+(require 'dash)
+(require 's)
+
(defvar pa-folder (expand-file-name "project-archetypes" user-emacs-directory))
(defvar pa-project-folder (expand-file-name "projects" "~"))
(defvar pa-out "*project-archetypes-output*")
-(defun create-js-buster-browser ()
- (let* ((name (read-string "Project name: "))
- (desc (read-string "Short description: "))
- (p-id (read-string "Project shortcut: "))
- (folder (expand-file-name name pa-project-folder)))
- (copy-directory (expand-file-name "js-buster-browser" pa-folder)
- folder)
- (let ((default-directory (concat folder "/")))
- (shell-command "git init" pa-out)
- (magit-ignore-file ".rvmrc" nil t)
- (magit-ignore-file "todo.org" nil t)
- (shell-command "npm link buster" pa-out)
- (shell-command "npm install" pa-out)
- (shell-command "git add -A")
- (shell-command "git ci -m \"Initial commit\""))))
+(defun pa--join-patterns (patterns)
+ "Turn `ffip-paterns' into a string that `find' can use."
+ (mapconcat (lambda (pat) (format "-name \"%s\"" pat))
+ patterns " -or "))
+
+(defun pa--files-matching (patterns folder &optional type)
+ (split-string (shell-command-to-string
+ (format "find %s %s \\( %s \\) | head -n %s"
+ folder
+ (or type "")
+ (pa--join-patterns patterns)
+ 1000))))
+
+(defun pa--instantiate-template-file (file replacements)
+ (with-temp-file file
+ (insert-file-contents-literally file)
+ (--each replacements
+ (goto-char 0)
+ (while (search-forward (car it) nil t)
+ (replace-match (cdr it))))))
+
+(defun pa-sh (cmd)
+ (shell-command cmd pa-out))
+
+(defun pa-instantiate-template-directory (template folder &rest replacements)
+ (let ((tmp-folder (expand-file-name (concat "__pa_tmp_" template) pa-project-folder)))
+ (copy-directory (expand-file-name template pa-folder) tmp-folder nil nil t)
+ (--each (pa--files-matching (-map 'car replacements) tmp-folder)
+ (rename-file it (s-replace-all replacements it)))
+ (--each (pa--files-matching ["*"] tmp-folder "-type f")
+ (pa--instantiate-template-file it replacements))
+ (copy-directory tmp-folder folder)
+ (delete-directory tmp-folder t)))
+
+(put 'pa-instantiate-template-directory 'lisp-indent-function 2)
+
+(defmacro pa-with-new-project (project-name archetype replacements &rest body)
+ `(let ((folder (expand-file-name ,project-name pa-project-folder)))
+ (pa-instantiate-template-directory ,archetype folder ,@replacements)
+ (view-buffer-other-window pa-out)
+ (let ((default-directory (concat folder "/")))
+ (pa-sh "git init")
+ ,@body
+ (pa-sh "git add -A")
+ (pa-sh "git ci -m \"Initial commit\""))))
+
+(put 'pa-with-new-project 'lisp-indent-function 2)
(provide 'project-archetypes)
;;; project-archetypes.el ends here
Please sign in to comment.
Something went wrong with that request. Please try again.