-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from fossamagna/support-typescript
Add Support TypeScript
- Loading branch information
Showing
14 changed files
with
248 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const assert = require('yeoman-assert'); | ||
const helpers = require('yeoman-test'); | ||
|
||
describe('generator-gas:babel', () => { | ||
beforeAll(() => { | ||
return helpers | ||
.run(path.join(__dirname, '../generators/babel')) | ||
.withOptions({ | ||
appName: 'test-app', | ||
githubUsername: 'fossamagna', | ||
name: 'Full Name', | ||
email: 'fossamagna2@gmail.com' | ||
}); | ||
}); | ||
|
||
it('creates files', () => { | ||
assert.file([ | ||
'.babelrc', | ||
'.gitignore', | ||
'package.json', | ||
'.clasp.json', | ||
'.eslintrc.json', | ||
'README.md', | ||
'src/index.js', | ||
'src/hello.js' | ||
]); | ||
|
||
assert.jsonFileContent('package.json', { | ||
name: 'test-app', | ||
repository: 'fossamagna/test-app', | ||
author: { | ||
name: 'Full Name', | ||
email: 'fossamagna2@gmail.com' | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const assert = require('yeoman-assert'); | ||
const helpers = require('yeoman-test'); | ||
|
||
describe('generator-gas:typescript', () => { | ||
beforeAll(() => { | ||
return helpers | ||
.run(path.join(__dirname, '../generators/typescript')) | ||
.withOptions({ | ||
appName: 'test-app', | ||
githubUsername: 'fossamagna', | ||
name: 'Full Name', | ||
email: 'fossamagna2@gmail.com' | ||
}); | ||
}); | ||
|
||
it('creates files', () => { | ||
assert.file([ | ||
'.gitignore', | ||
'package.json', | ||
'.clasp.json', | ||
'README.md', | ||
'src/index.ts', | ||
'src/hello.ts', | ||
'src/shim.d.ts', | ||
'tsconfig.json', | ||
]); | ||
|
||
assert.jsonFileContent('package.json', { | ||
name: 'test-app', | ||
repository: 'fossamagna/test-app', | ||
author: { | ||
name: 'Full Name', | ||
email: 'fossamagna2@gmail.com' | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
const Generator = require('yeoman-generator'); | ||
|
||
module.exports = class extends Generator { | ||
|
||
constructor(args, opts) { | ||
super(args, opts); | ||
} | ||
|
||
writing() { | ||
this.fs.copyTpl( | ||
this.templatePath('**'), | ||
this.destinationPath(), | ||
{ | ||
appName: this.options.appName, | ||
githubUsername: this.options.githubUsername, | ||
name: this.options.name, | ||
email: this.options.email | ||
} | ||
); | ||
this.fs.move( | ||
this.destinationPath('_package.json'), | ||
this.destinationPath('package.json') | ||
); | ||
this.fs.move( | ||
this.destinationPath('_gitignore'), | ||
this.destinationPath('.gitignore') | ||
); | ||
this.fs.move( | ||
this.destinationPath('_clasp.json'), | ||
this.destinationPath('.clasp.json') | ||
); | ||
} | ||
|
||
install() { | ||
this.installDependencies({bower: false}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# <%= appName %> | ||
|
||
Google Apps Script Application with [Browserify](http://browserify.org) + [TypeScript](https://www.typescriptlang.org/). | ||
|
||
# For Local Development | ||
|
||
For Apps Script local development, You need to be enable Apps Script API: https://script.google.com/home/usersettings. This project will be use [clasp](https://github.com/google/clasp) to push Apps Script Project. | ||
|
||
.clasp.json: | ||
```json | ||
{ | ||
"scriptId": "<YOUR_SCRIPT_ID>", | ||
"rootDir": "dist" | ||
} | ||
``` | ||
|
||
Please see [clasp](https://github.com/google/clasp) and [Command Line Interface using clasp](https://developers.google.com/apps-script/guides/clasp) for details. | ||
|
||
# Deploy | ||
|
||
```sh | ||
$ npm run deploy | ||
``` | ||
|
||
* Server JavaScript files will be compiled by Browserify and [gasify](https://www.npmjs.com/package/gasify). | ||
* Sync compiled `Code.js` to Google Apps Script Project in Google Drive by clasp. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"scriptId": "<YOUR_SCRIPT_ID>", | ||
"rootDir": "dist" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "<%= appName %>", | ||
"version": "1.0.0", | ||
"description": "Google Apps Script Application with Browserify + TypeScript", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "eslint src", | ||
"clean": "rimraf dist", | ||
"initialize": "mkdirp dist", | ||
"watch": "npm-run-all initialize -p watch:gs", | ||
"prefetch:manifest": "npm-run-all initialize", | ||
"fetch:manifest": "clasp pull", | ||
"postfetch:manifest": "cpx ./dist/appsscript.json ./src/appsscript.json", | ||
"prebuild:gs": "cpx ./src/appsscript.json ./dist/appsscript.json", | ||
"build:gs": | ||
"browserify ./src/index.ts -p tsify -p gasify -o ./dist/Code.js", | ||
"watch:gs": "watchify ./src/index.ts -p tsify -p gasify -o ./dist/Code.js", | ||
"build": "npm-run-all clean initialize build:gs", | ||
"upload": "claps push", | ||
"deploy": "npm-run-all build upload" | ||
}, | ||
"keywords": ["google", "apps-script"], | ||
"author": { | ||
"name": "<%= name %>", | ||
"email": "<%= email %>" | ||
}, | ||
"repository": "<%= githubUsername %>/<%= appName %>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/google-apps-script": "0.0.27", | ||
"@google/clasp": "1.4.0", | ||
"browserify": "16.2.2", | ||
"browserify-shim": "3.8.13", | ||
"cpx": "1.5.0", | ||
"eslint": "5.2.0", | ||
"gasify": "0.1.2", | ||
"mkdirp": "0.5.1", | ||
"npm-run-all": "4.1.3", | ||
"onchange": "4.1.0", | ||
"rimraf": "2.4.4", | ||
"tsify": "4.0.0", | ||
"typescript": "3.0.1", | ||
"watch": "1.0.2", | ||
"watchify": "3.6.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default function helloWorldMessage() { | ||
Logger.log('hello world'); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import hello from './hello'; | ||
global.hello = hello; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare var global: any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "./dist", | ||
"target": "es3", | ||
"module": "commonjs", | ||
"declaration": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"compileOnSave": true, | ||
"rootDir": "src", | ||
"include": ["./src/**/*"] | ||
} |