From e93776dd97993bd395012065929c651b3248d1a7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-0C9VR0P\\bradf" Date: Tue, 6 Nov 2018 17:16:17 -0500 Subject: [PATCH 1/6] added install-dependencies button --- lib/fast-forward-view.coffee | 12 ++++++++++++ lib/fast-forward.coffee | 6 ++++++ package.json | 6 ++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/fast-forward-view.coffee b/lib/fast-forward-view.coffee index 5507555..2ee4418 100644 --- a/lib/fast-forward-view.coffee +++ b/lib/fast-forward-view.coffee @@ -20,12 +20,24 @@ class FastForwardView ) @element.appendChild(@button) + # Create button element + @button2 = document.createElement('button') + @button2.textContent = "Install Dependencies" + @button2.classList.add('btn-primary') + @button2.classList.add('btn') + + # Event listening for button. Emits event to the FastForward module. + @button2.addEventListener('click', () => + @emitter.emit('install-button-event') + ) + @element.appendChild(@button2) # Returns an object that can be retrieved when package is activated serialize: -> # Tear down any state and detach destroy: -> @button.removeEventListener('click', 0) + @button2.removeEventListener('click', 0) @element.remove() getElement: -> diff --git a/lib/fast-forward.coffee b/lib/fast-forward.coffee index 557f287..eac590a 100644 --- a/lib/fast-forward.coffee +++ b/lib/fast-forward.coffee @@ -1,5 +1,6 @@ FastForwardView = require './fast-forward-view' {CompositeDisposable, Emitter} = require 'atom' +npm = require '../../npm-plus/lib/npm-plus.js' module.exports = FastForward = fastForwardView: null @@ -20,8 +21,10 @@ module.exports = FastForward = # Register command that toggles this view @subscriptions.add(atom.commands.add('atom-workspace', {'fast-forward:toggle': () => @toggle()})) + @subscriptions.add(atom.commands.add('atom-workspace', {'fast-forward:installdependencies': () => @installDependencies()})) @emitter.on 'toggle-button-event', => @toggle() + @emitter.on 'install-button-event', => @installDependencies() deactivate: -> @modalPanel.destroy() @@ -38,3 +41,6 @@ module.exports = FastForward = @modalPanel.hide() else @modalPanel.show() + + installDependencies: -> + npm("install") #this calls the npm function to install the depencies, this calls the function and that works but the fucntion fails rn diff --git a/package.json b/package.json index b8e9c24..2aee2cf 100644 --- a/package.json +++ b/package.json @@ -3,13 +3,11 @@ "main": "./lib/fast-forward", "version": "0.0.0", "description": "A short description of your package", - "keywords": [ - ], + "keywords": [], "repository": "https://github.com/atom/fast-forward", "license": "MIT", "engines": { "atom": ">=1.0.0 <2.0.0" }, - "dependencies": { - } + "dependencies": {} } From c1848f6fd0ec77927e3e2b3809eda641daf48961 Mon Sep 17 00:00:00 2001 From: "DESKTOP-0C9VR0P\\bradf" Date: Fri, 9 Nov 2018 17:19:38 -0500 Subject: [PATCH 2/6] clones a test repository into your c drive --- lib/fast-forward.coffee | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/fast-forward.coffee b/lib/fast-forward.coffee index eac590a..56fc8bf 100644 --- a/lib/fast-forward.coffee +++ b/lib/fast-forward.coffee @@ -1,6 +1,9 @@ FastForwardView = require './fast-forward-view' {CompositeDisposable, Emitter} = require 'atom' npm = require '../../npm-plus/lib/npm-plus.js' +git = require 'simple-git' +path = '/test' +REPO = 'https://github.com/rmccue/test-repository' module.exports = FastForward = fastForwardView: null @@ -43,4 +46,7 @@ module.exports = FastForward = @modalPanel.show() installDependencies: -> - npm("install") #this calls the npm function to install the depencies, this calls the function and that works but the fucntion fails rn + console.log path + log = (err, idk) -> console.log err + git().clone REPO, path, log + console.log path From b11d71e1bc9cf0ec3a2878ae665744ed7b47f63b Mon Sep 17 00:00:00 2001 From: "DESKTOP-0C9VR0P\\bradf" Date: Sun, 11 Nov 2018 15:36:24 -0500 Subject: [PATCH 3/6] added install to right path --- lib/fast-forward.coffee | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/fast-forward.coffee b/lib/fast-forward.coffee index 56fc8bf..73029b4 100644 --- a/lib/fast-forward.coffee +++ b/lib/fast-forward.coffee @@ -2,7 +2,9 @@ FastForwardView = require './fast-forward-view' {CompositeDisposable, Emitter} = require 'atom' npm = require '../../npm-plus/lib/npm-plus.js' git = require 'simple-git' -path = '/test' +del = require 'del' +path = atom.project.getPaths()[0] +project_path = "#{ path }\\student_repo" REPO = 'https://github.com/rmccue/test-repository' module.exports = FastForward = @@ -46,7 +48,24 @@ module.exports = FastForward = @modalPanel.show() installDependencies: -> - console.log path - log = (err, idk) -> console.log err - git().clone REPO, path, log - console.log path + + #del project_path + + #handler for just printing out errors for simplegit + errorlog = (err, idk) -> + if err != null + console.log err + else + console.log "successfull?" + + ###handler for simple git checkIsRepo + repoCheck = (err, idk) -> + if err != null + console.log err + if idk + console.log "#{ project_path } is already a repo" + + #git().cwd(project_path).checkIsRepo repoCheck + ### + + git().clone REPO, project_path, errorlog From afed0e00be97cff036ae652e17dff7ea8ae1acd4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-0C9VR0P\\bradf" Date: Tue, 4 Dec 2018 18:43:12 -0500 Subject: [PATCH 4/6] sync problems --- lib/fast-forward.coffee | 68 +++++++++++++++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/lib/fast-forward.coffee b/lib/fast-forward.coffee index 73029b4..6c565c5 100644 --- a/lib/fast-forward.coffee +++ b/lib/fast-forward.coffee @@ -1,11 +1,27 @@ FastForwardView = require './fast-forward-view' {CompositeDisposable, Emitter} = require 'atom' -npm = require '../../npm-plus/lib/npm-plus.js' git = require 'simple-git' -del = require 'del' -path = atom.project.getPaths()[0] -project_path = "#{ path }\\student_repo" +fs = require 'fs' +async = require 'async' + +project_directory = process.env['USERPROFILE'] + "\\Documents\\MyCodingAndCommunityProjects" + +plugin_path = atom.project.getPaths()[0] + +#have these entered in the plugin REPO = 'https://github.com/rmccue/test-repository' +name = 'first project' +base_project_path = project_directory + "\\My_first_project" +project_path = base_project_path + +count = 0 + + +handler = (err) -> + if err != null + console.log err + +fs.mkdir(project_directory, handler) module.exports = FastForward = fastForwardView: null @@ -49,23 +65,55 @@ module.exports = FastForward = installDependencies: -> - #del project_path - #handler for just printing out errors for simplegit errorlog = (err, idk) -> if err != null console.log err else - console.log "successfull?" + console.log "successful?" - ###handler for simple git checkIsRepo + #handler for simple git checkIsRepo repoCheck = (err, idk) -> if err != null console.log err if idk - console.log "#{ project_path } is already a repo" + console.log "is already a repo" + + projectStatHandler = (err, stat) -> + console.log err + console.log project_path + console.log count + + if err && err.code == "ENOENT" + fs.mkdirSync(project_path) + console.log "made the Directory at #{ project_path }" + + else + console.log('Directory already exists.') + count = count + 1 + project_path = base_project_path + "(" + count + ")" + + console.log count + console.log project_path + + projectCheck() + + + + projectCheck = () -> + fs.stat project_path, projectStatHandler + + + ###async.series([ + function(callback) { ... }, + function(callback) { ... } + ]);### + + projectCheck() + count = 0 + #git().cwd(project_path).checkIsRepo repoCheck - ### + git().clone REPO, project_path, errorlog From c1479d27c0c17e73c96a4cc5ce2f4d3b34f6e494 Mon Sep 17 00:00:00 2001 From: "DESKTOP-0C9VR0P\\bradf" Date: Tue, 4 Dec 2018 18:48:19 -0500 Subject: [PATCH 5/6] fixed sync problems using callback --- lib/fast-forward.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fast-forward.coffee b/lib/fast-forward.coffee index 6c565c5..ed27c56 100644 --- a/lib/fast-forward.coffee +++ b/lib/fast-forward.coffee @@ -65,6 +65,9 @@ module.exports = FastForward = installDependencies: -> + clone = () -> + git().clone REPO, project_path, errorlog + #handler for just printing out errors for simplegit errorlog = (err, idk) -> if err != null @@ -85,7 +88,7 @@ module.exports = FastForward = console.log count if err && err.code == "ENOENT" - fs.mkdirSync(project_path) + fs.mkdir(project_path, clone) console.log "made the Directory at #{ project_path }" else @@ -108,12 +111,9 @@ module.exports = FastForward = function(callback) { ... }, function(callback) { ... } ]);### - + projectCheck() count = 0 #git().cwd(project_path).checkIsRepo repoCheck - - - git().clone REPO, project_path, errorlog From 84a71cf612d793ecf6999d6879446d8bc2225f68 Mon Sep 17 00:00:00 2001 From: "DESKTOP-0C9VR0P\\bradf" Date: Wed, 5 Dec 2018 14:02:15 -0500 Subject: [PATCH 6/6] final changes --- lib/fast-forward-view.coffee | 2 +- lib/fast-forward.coffee | 47 +++++++++++++++--------------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/lib/fast-forward-view.coffee b/lib/fast-forward-view.coffee index 2ee4418..29d5388 100644 --- a/lib/fast-forward-view.coffee +++ b/lib/fast-forward-view.coffee @@ -22,7 +22,7 @@ class FastForwardView # Create button element @button2 = document.createElement('button') - @button2.textContent = "Install Dependencies" + @button2.textContent = "Clone Repo" @button2.classList.add('btn-primary') @button2.classList.add('btn') diff --git a/lib/fast-forward.coffee b/lib/fast-forward.coffee index ed27c56..1957f3e 100644 --- a/lib/fast-forward.coffee +++ b/lib/fast-forward.coffee @@ -2,7 +2,7 @@ FastForwardView = require './fast-forward-view' {CompositeDisposable, Emitter} = require 'atom' git = require 'simple-git' fs = require 'fs' -async = require 'async' +cmd = require 'node-cmd' project_directory = process.env['USERPROFILE'] + "\\Documents\\MyCodingAndCommunityProjects" @@ -63,57 +63,50 @@ module.exports = FastForward = else @modalPanel.show() + #brads button installDependencies: -> + #clones the repo inside of the project path clone = () -> git().clone REPO, project_path, errorlog - #handler for just printing out errors for simplegit + #handler for just printing out errors for simplegit which just prints out the error errorlog = (err, idk) -> if err != null console.log err - else - console.log "successful?" - - #handler for simple git checkIsRepo - repoCheck = (err, idk) -> - if err != null - console.log err - if idk - console.log "is already a repo" + #handler for chekcing the status for the directory projectStatHandler = (err, stat) -> - console.log err - console.log project_path - console.log count + #if the directory exists then create the directory and then the callback function clones the repo if err && err.code == "ENOENT" fs.mkdir(project_path, clone) console.log "made the Directory at #{ project_path }" + #otherwise add one to project path and then check the path again else console.log('Directory already exists.') count = count + 1 project_path = base_project_path + "(" + count + ")" - console.log count - console.log project_path - projectCheck() - - + #calls fs.stat which checks the status of a directory projectCheck = () -> fs.stat project_path, projectStatHandler - - ###async.series([ - function(callback) { ... }, - function(callback) { ... } - ]);### - + #the button code to find the correct project directory and clone it from github projectCheck() count = 0 - - #git().cwd(project_path).checkIsRepo repoCheck + #handler to print out stuff from cmd + cmdHandler = (err, data, stderr) -> + console.log err + console.log data + console.log stderr + + #install the dependencies from the newly cloned project + cmd.get( + ' + dir + ', cmdHandler)