Skip to content

Commit e5f9187

Browse files
committed
Import/Export sample - minor fixes
- Remove deprecated gulp-clean module from npm dependencies - New simpler “clean” implementations in gulp file. - README fit and polish
1 parent ef28902 commit e5f9187

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

import_export_development/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ This sample uses the community project [node-google-apps-script](https://www.npm
77
1. run `npm install -g node-google-apps-script` to install it globally. This will allow you to run a few of the steps below from the command line.
88
2. Go through the [configuration and authorization steps](https://www.npmjs.com/package/node-google-apps-script).
99
2. Run `npm install -g gulp` if you do not already have the [gulp](http://gulpjs.com/) task runner installed globally.
10-
3. Clone this repository, `cd google-apps-script-samples\import_export_development`, and run `npm install`. This will set up all of the local dependencies for the project.
10+
3. Clone this repository, `cd google-apps-script-samples/import_export_development`, and run `npm install`. This will set up all of the local dependencies for the project.
1111

1212
### Demonstrating the developer flow
1313
To get the initial setup working for you, perform the following steps. In a real project, each developer would perform these steps, so that they can do development in isolation from other developers:
1414

1515
1. Create a [new Google Spreadsheet](https://docs.google.com/spreadsheets/create), and copy the ID of the file. The file ID is found in the URL to the spreadsheet:
1616
docs.google.com/spreadsheets/d/***DRIVE_FILE_ID***/edit#gid=123
17-
2. Open the file *src\environments\dev\debug.local.config.js*, and replace DRIVE_FILE_ID with the ID that you copied.
17+
2. Open the file *src/environments/dev/debug.local.config.js*, and replace DRIVE_FILE_ID with the ID that you copied.
1818
3. Create a new standalone [Google Apps Script](https://script.google.com) project, and copy the ID of the script. The file ID is found in the URL to the script project:
1919
script.google.com/a/macros/google.com/d/***DRIVE_FILE_ID***/edit
2020
4. Perform the following commands:
2121
```
22+
mkdir build
2223
cd build
2324
mkdir dev
2425
cd dev
@@ -35,7 +36,7 @@ You can run the code either by publishing it as a web app, or testing it as an a
3536
This second phase mimics the setup to isolate testing from development. This would typically be a single Apps Script file for the project, and would have some different code added to enable testing scenarios. In a real project, a testing coordinator or other similar role would perform these steps:
3637

3738
1. Create a [new Google Spreadsheet](https://docs.google.com/spreadsheets/create), and copy the ID of the file. Add 4 additional sheets to the file (the test looks for 5 sheets).
38-
2. Open the file *src\environments\tst\a.myproj.tst.config.js*, and replace DRIVE_FILE_ID with the ID that you copied.
39+
2. Open the file *src/environments/tst/a.myproj.tst.config.js*, and replace DRIVE_FILE_ID with the ID that you copied.
3940
3. Perform the same steps #3 and #4 from above, replacing `dev` with `tst`.
4041
4. Refresh the Apps Script project, open the file `a.myproj.tests.server.main.js`, and then run the function `runAllTests`. Once the run completes, open the log view to see the output.
4142

@@ -47,7 +48,7 @@ This final phase mimics the setup to prepare for a production deployment. This w
4748

4849

4950
1. Perform the same steps #3 and #4 from above, replacing `dev` with `prd`.
50-
2. Refresh the Apps Script project, open the script properties, and click on the "Scopes" tab. You will see that the spreadsheet scope now only allows the current attached doc, which is what we would want for production.
51+
2. Refresh the Apps Script project, open the project properties (File --> Project properties), and click on the "Scopes" tab. You will see that the spreadsheet scope now only allows the current attached doc (`spreadsheets.currentonly`), which is what we would want for production.
5152
3. You can also create a new spreadsheet, set up for add-on testing, and the code will run successfully.
5253

5354
For production, the configuration file does *not* have a specific spreadsheet, and has the annotation @onlycurrent doc. That will ensure that only Spreadsheets that the code has been linked via the Add-on can be accessed. This limiting of scope is a good practice to provide more confidence to your users that you are only working on sheets that they have linked to your add-on.

import_export_development/gulpfile.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ var jshint = require('gulp-jshint');
1919
var shell = require('gulp-shell');
2020
var minimist = require('minimist');
2121
var rename = require('gulp-rename');
22-
var clean = require('gulp-clean');
2322
var debug = require('gulp-debug');
23+
var del = require('del');
2424

2525
// minimist structure and defaults for this task configuration
2626
var knownOptions = {
@@ -104,15 +104,17 @@ function copyEnvironmentSpecific() {
104104

105105
// Utility tasks
106106
gulp.task('clean-deployment', function(cb) {
107-
return gulp.src(dstRoot + '/*.*', {read: false})
108-
.pipe(clean());
107+
return del([
108+
dstRoot + '/*.*'
109+
]);
109110
});
110111

111112
gulp.task('clean-deployments', function(cb) {
112-
return gulp.src(['build/dev/src/*.*',
113-
'build/tst/src/*.*' ,
114-
'build/prd/src/*.*'], {read: false})
115-
.pipe(clean());
113+
return del([
114+
'build/dev/src/*.*',
115+
'build/tst/src/*.*' ,
116+
'build/prd/src/*.*'
117+
]);
116118
});
117119

118120
gulp.task('lint', function() {

import_export_development/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"author": "[email protected]",
33
"dependencies": {
4+
"del": "^2.2.0",
45
"gulp": "^3.9.0",
5-
"gulp-clean": "^0.3.1",
66
"gulp-debug": "^2.1.2",
77
"gulp-jshint": "^1.12.0",
88
"gulp-rename": "^1.2.2",
99
"gulp-shell": "^0.5.1",
1010
"jshint-stylish": "^2.0.1",
1111
"minimist": "^1.2.0",
12-
"node-google-apps-script": "^1.1.3"
12+
"node-google-apps-script": "^1.1.3",
13+
"vinyl-paths": "^2.1.0"
1314
},
1415
"description": "A sample showing command line tool techniques that can be used when developing for Google Apps Script projects.",
1516
"keywords": [
@@ -23,7 +24,6 @@
2324
"type": "git",
2425
"url": "https://github.com/tbd"
2526
},
26-
"scripts": {
27-
},
27+
"scripts": {},
2828
"version": "1.0.0"
2929
}

0 commit comments

Comments
 (0)