Previous: List of todos [1/1], Up: Create New Project [Index]
(defun create-new-project (project title author &optional bucket) "Create a new project in a new directory. - Depends on env var SYNC_ORG_TEMPLATE existing and pointing to this file. - Require a title, author, and AWS S3 bucket name - Create new directory structure: resources, and subdirs tools, images, etc - Copy template file into a new directory. - Update its title, author, and S3 bucket entries. - Tangle the bootstrap makefile and Readme. - Create a new git repo and add an initial commit. - Upload the git repo into GitHub, add a description to the GitHub repo." (message "NEW PROJECT=%s TITLE=%s AUTHOR=%s BUCKET=%s" project title author bucket) (setq SOT (getenv "SYNC_ORG_TEMPLATE")) (access-file SOT "Cannot access SYNC_ORG_TEMPLATE") ;; Project directory structure (setq project-dir (file-name-as-directory project)) (setq project-file (concat project-dir project ".org")) (setq resources-dir "resources/") (setq projrsc-dir (concat project-dir resources-dir)) (setq resources-subdirs (list "tools/" "images/")) ;; make the directories (mkdir project-dir t) (mkdir projrsc-dir) (dolist (subdir resources-subdirs) (mkdir (concat projrsc-dir subdir))) ;; create the project file from the template (copy-file SOT project-file) (with-current-buffer (find-file-noselect project-file) (let* ((cur-buf (current-buffer)) (proj-tree (project-tree cur-buf)) (delete-hl-list (list "build-scripts" "todos" "README"))) ;; Remove some sections (message "Deleting %s..." delete-hl-list) (seq-do (lambda (cid) (message "...Deleting %s in %s..." cid cur-buf) (let* ((beg-end (find-hl-cid proj-tree cid)) (beg (car beg-end)) (end (cdr beg-end))) (message " ...%s: %s" cid beg-end) (delete-region beg end) (message " ...done"))) delete-hl-list)) (message "Done deleting.") ;; update title, author, version, bucket ;; with values provided by the user (goto-char (point-min)) (re-search-forward "^#[+]title:\s*\\(TITLE\\)$") (replace-match title t nil nil 1) (re-search-forward "^#[+]author:\s*\\(AUTHOR\\)$") (replace-match author t nil nil 1) (re-search-forward "^#[+]macro:\s*version Version \\(.*\\)$") (replace-match "0.0.0" t nil nil 1) (when bucket (re-search-forward "^#[+]bucket:\s*\\(.*\\)$") (replace-match bucket t nil nil 1)) (re-search-forward "^#[+]texinfo_printed_title:\\(PRINTED TITLE\\)$") (replace-match (concat project "---" title) t nil nil 1) (save-buffer) ;; tangle the project readme and boot makefile (goto-char (point-min)) (org-babel-goto-named-src-block "project-readme") (org-babel-tangle (quote (4))) (org-babel-goto-named-src-block "boot-template") (org-babel-tangle (quote (4))) (kill-buffer)))
Listing B.1: Create New Project Code
Previous: List of todos [1/1], Up: Create New Project [Index]