Apps Script: Google CLASP (Command Line Apps Script Project) NEW TOOL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone its Jordan ray here with another Google Apps scripting video pretty excited about this video it's actually a very new release from the team over there at Google Apps Script the clasp tool which allows you to develop these kinds of scripts locally on your local machine instead of out there in the cloud I am NOT a huge fan of the text editor though it's not terrible though it is much better to develop locally it's something like yes code or sublime text where you have a lot of really cool text editor features Before we jump into that I want to quickly mention I am gonna start a patreon account to help me keep developing this channel and doing these kinds of projects that really help teachers to kind of maximize productivity my goal is to hopefully go to ISTE this summer in Chicago and patreon will help me accomplish that goal that being said let's dive right in okay the first thing you're gonna need to do is have no js' install a Windows machine but the installation process is very similar for Mac he needs install I would just install the recommended for most users version though current it's not gonna hurt you at all to install that and if you already have node installed and it's an older version that is fine too I think it pretty much anything back to version 6 should work with what we're doing and also if you're on Windows you need get installed we don't need an insult but you need some sort of command line tool and in this case I'm using git bash which comes with your get installation if you're on Mac you can use I term on Linux you've got it built right in and Mac has it built into it's only us windows folks that's have to kind of find our way and I actually think you can use the CMD also though I think you'd be much better off installing it and using git bash then we've got to install this clasp tool with your node installation comes a tool called NPM and we're gonna install I'm going to add the G flag for global and it's Google clasp and we can go ahead and start that installation okay now that that has finished installing I'm going to I'm gonna make a little test directory for just to kind of play around with get used to this tool and we CD into the test folder now the first thing we got to do is actually run clasp log in and this should pull up a little login prompt on your browser just like you see there it's gonna ask me to log in I'm allowing the clasp tool to modify scripts on my drive and it says you can close it no problem back to the console and we'll take a look at this command line here control L will actually clear this out if you want to fear a little you know particularly your command line control held clears that so now we need to actually class create and I'm gonna just call it tests the name of my project and this will create an Apps Script JSON file and I think all it has in it is a script ID because it's gonna be creating this test right out there in your drive to enable the Apps Script API so actually we have to follow a link here to your user settings to then enable the Apps Script API and it's just toggling a switch on that's simple and then we can close out of here by the way while I'm in actually on in the dashboard home here what does everybody think of the new layout to the dashboard I'd be interested to hear what you think on Twitter no please let me let me know what you think maybe I'll do a video just about using the new dashboard some of the things that you can do with it now we're back to the command line here and clear that out and actually if I just list the files in this directory this is love isn't it the bash tool is very very slow oh I thought it oh sorry I have to run it again clasp create test and now it should actually create the JSON file and I think that's it I think it's just gonna create the JSON file let's let's see here and yeah it really is the git bash is very very slow okay so we've got an app script JSON I use vs code you can use whatever text editor you want but PS code is I started using it a couple of maybe a month or two ago and really joining it's super fast though this is not evidence of that it's running very slowly right now though I think this is the bash terminal I can't I can't tell okay so now I've got I'm just open this up next to it oh and we've got a okay so claps out JSON that has the script ID in it and an app script that JSON okay very simple little JSON no we are going to create some new files one is gonna be dot class ignore and what this is gonna do is this is gonna I'm gonna make some very simple little stuff here so that when I push and pull from the repository it doesn't send anything crazy up there but I'm not going to push everything that is HTML Google script and Apps Script Jason so those should be ignored now I'm gonna run from the console clasp pull this you know how what every time you start a project you get that basic code IGS that should pull in right here just with this class pull clogged one file it didn't create it that's fine well let's just create it ourselves code GS and I'm gonna write the function test log test now I'm noticing there's no syntax highlighting here we can fix that pretty easily too if you just go into settings and then file associations I'm gonna add this to my into my settings and then I'm going to start start GS and I want those to be read as JavaScript and save that and yep perfect now I've got syntax highlighting and then over here it even has this little JavaScript icon here so I'm gonna save that and we should actually send this code bad G yes let's make sure that it's the cloud pushing files code IGS app script that JSON perfect so now if you look on your drive you would see those changes that are made now one other thing that's super basic implementation of this check the github repository for any other first of all the other commands that you can use with this command line tool command line apps scripts project I guess was it yeah must be a script project you've got if you could actually deploy right from here you can change the versioning you can clone existing projects tons of cool stuff that you can start to automate because really the power of this now is you can bring in tools like gulp to automatically to automatically make your deployments on changes now if you're interested stick around otherwise hit the command line and start playing around with this but I'm in actually set it up so that gulp will do a lot of the hard work for me so I'm going to say install global not global sorry say dev and I want to install gulp and go exec and while it's doing that I'm going to start when I create a new file I'm gonna call it gulp file dot j s and in here I'm going to run Const gulp equals require gulp gulp is a little really take all the hard work at it so it'll automate some of these processes it's basically just a really fancy commander so I'm going over then run exec equals require go exec and we can actually detect the end I'm going to create a task here and I'm gonna call the task called push and we're on a run a function in there and what we're gonna do is just run exact and that's gonna be clasp push I think that will do it now I'm going to also create a watch task and this is going to gulp watch and there's two parameters I have to put in here that both going to be arrays because basically it's gonna be whenever any file GS changes or any file dot HTML changes then I'm gonna run push again and I'm gonna set up default task defaults and all the default tests is gonna do is start watching my files so now I should every time I change this code IGS I should actually should push it up to the cloud let's test it here now in this I'm going to run gulp and that should start the watching process let's see let's find out here we go starting watch started watch finished watch mmm I think it should let's make sure function testing go if I save that Oh something crashed so definitely watching exec is not a function so in my gulp file and go exec well the only way to maybe you have to run it as a method maybe it should be a property let's see here go check the documentation oh it's child process interesting all right so let's just fix that easy save that and we should be able to kill are able to watch process here run gulp again possibly it's not the fastest thing in the world here I was using this on Linux and it was much much faster skinned third try anything in that function let's just say it started push finished push after nine I thought you would see a console log and when you load up in your text editor you can see there it is it pushed all that code up there and one final thing you may have noticed when I was creating the go file I had it also grab HTML files this so that we can actually use the power of es code - if I created an HTML file here and use the exclamation point it's all this code you know snippets stuff is built in I'm just gonna call this test and each one h1 tag save that and now back here in the consult it should have pushed and I can take a look at that refresh this and there it is that index dot HTML built-in right there for you so ya use the all the powers of kind of a local text editor to really streamline your development process let me know what you think in the comments below what what other kinds of ways would you like to see me demonstrate how to use some of this stuff there's tons of extensibility that you can do here and as I'm saying this out truck realizing I forgot one last little thing here this node modules folder is everything that you have installed with gulp when you when I ran those npm install' gulp and gulp exec everything pulled into this node modules file you want to make sure that you have this clasp ignore file created and either you know this little command right here is what ignores that file otherwise it's gonna try to push all those folders into your app script project and it's gonna give you some kind of error message it's gonna air out so make sure that you have had gulp ignore file and then clasp ignore file that being said hit the command line and start having fun with this cheers everybody talk to you soon
Info
Channel: Jordan Rhea
Views: 9,684
Rating: undefined out of 5
Keywords: google apps script, javascript, cli, command line, coding
Id: kcnxP-x-6s8
Channel Id: undefined
Length: 18min 24sec (1104 seconds)
Published: Fri Feb 02 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.