-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gcp-build samples #710
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
50bbc20
Add uglifyjs sample
e07b3e4
Add GAE configs + tweak app description
cca79ce
Initial commit of Typescript sample
8ab351e
Address Steren's comments
76d2c2a
Add READMEs
a51b060
Remove handlers
24e8d4f
Merge branch 'master' into gcp-build
jkwlui 28652a9
Use (more) idiomatic typescript
bdd8076
Remove yarn
8caaccd
Add repo-tools tests
36262e8
Merge branch 'master' into gcp-build
JustinBeckwith 9792a12
Add Kokoro test configs
6eaefb9
Merge branch 'master' into gcp-build
2c52716
Merge branch 'gcp-build' of https://github.com/GoogleCloudPlatform/no…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Format: //devtools/kokoro/config/proto/build.proto | ||
|
||
# Set the folder in which the tests are run | ||
env_vars: { | ||
key: "PROJECT" | ||
value: "appengine/typescript" | ||
} | ||
|
||
# Tell the trampoline which build file to use. | ||
env_vars: { | ||
key: "TRAMPOLINE_BUILD_FILE" | ||
value: "github/nodejs-docs-samples/.kokoro/build.sh" | ||
} |
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,13 @@ | ||
# Format: //devtools/kokoro/config/proto/build.proto | ||
|
||
# Set the folder in which the tests are run | ||
env_vars: { | ||
key: "PROJECT" | ||
value: "appengine/uglifyjs" | ||
} | ||
|
||
# Tell the trampoline which build file to use. | ||
env_vars: { | ||
key: "TRAMPOLINE_BUILD_FILE" | ||
value: "github/nodejs-docs-samples/.kokoro/build.sh" | ||
} |
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,5 @@ | ||
# Exclude compiled .js files | ||
*.js | ||
|
||
# Exclude dependencies | ||
node_modules/ |
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,5 @@ | ||
# Exclude compiled .js files | ||
*.js | ||
|
||
# Exclude dependencies | ||
node_modules/ |
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 @@ | ||
# App Engine TypeScript sample | ||
|
||
This sample provides an example of how to compile TypeScript files while | ||
deploying to App Engine. | ||
|
||
The `gcp-build` NPM script is used to trigger the TypeScript compilation | ||
process. This step happens automatically when deploying to App Engine, but must | ||
be performed manually when developing locally. | ||
|
||
## Setup | ||
|
||
Install dependencies: | ||
|
||
npm install | ||
|
||
## Running locally | ||
|
||
1. Perform the build step: | ||
|
||
npm run gcp-build | ||
|
||
1. Run the completed program | ||
|
||
npm start | ||
|
||
## Deploying to App Engine | ||
|
||
Deploy your app: | ||
|
||
npm run deploy | ||
|
||
By default, this application deploys to [App Engine Standard][appengine]. _(Recommended)_ | ||
Deploy to App Engine Flexible by [modifying `app.yaml`][app_yaml]. | ||
|
||
[appengine]: https://cloud.google.com/appengine/docs/standard/nodejs | ||
[app_yaml]: https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml | ||
[tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/quickstart | ||
[contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md |
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 @@ | ||
runtime: nodejs8 |
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,34 @@ | ||
// Copyright 2018 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the 'License'); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an 'AS IS' BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/* tslint:disable:no-console */ | ||
|
||
declare var process: { | ||
env: { | ||
PORT: string, | ||
}, | ||
}; | ||
|
||
const PORT: number = Number(process.env.PORT) || 8080; | ||
import express = require("express"); | ||
|
||
const app: any = express(); | ||
|
||
app.get("/", (req: any, res: any) => { | ||
res.send("🎉 Hello TypeScript! 🎉"); | ||
}); | ||
|
||
const server: object = app.listen(PORT, () => { | ||
console.log(`App listening on port ${PORT}`); | ||
}); |
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,27 @@ | ||
{ | ||
"name": "appengine-typescript", | ||
"description": "An example TypeScript app running on Google App Engine.", | ||
"version": "0.0.1", | ||
"private": true, | ||
"license": "Apache Version 2.0", | ||
"author": "Google Inc.", | ||
"engines": { | ||
"node": "8.x" | ||
}, | ||
"scripts": { | ||
"test": "npm run gcp-build && npm run lint && repo-tools test app -- index.js", | ||
"lint": "tslint index.ts", | ||
"start": "node ./index.js", | ||
"gcp-build": "tsc index.ts", | ||
"deploy": "gcloud app deploy" | ||
}, | ||
"dependencies": { | ||
"express": "^4.16.3", | ||
"typescript": "^3.0.1" | ||
}, | ||
"devDependencies": { | ||
"@google-cloud/nodejs-repo-tools": "^2.3.3", | ||
"semistandard": "^12.0.1", | ||
"tslint": "^5.11.0" | ||
} | ||
} |
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,3 @@ | ||
{ | ||
"extends": "tslint:recommended" | ||
} |
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,5 @@ | ||
# Minify files on GCP | ||
**/*.min.* | ||
|
||
# Exclude dependencies | ||
node_modules/ |
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 @@ | ||
**/*.min.* |
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 @@ | ||
# App Engine minification sample | ||
|
||
This sample provides an example of how to minify static CSS and JS files while | ||
deploying to App Engine. | ||
|
||
The `gcp-build` NPM script is used to trigger the minification process. This | ||
step happens automatically when deploying to App Engine, but must be performed | ||
manually when developing locally. | ||
|
||
## Setup | ||
|
||
Install dependencies: | ||
|
||
npm install | ||
|
||
|
||
## Running locally | ||
|
||
1. Perform the build step locally: | ||
|
||
npm run gcp-build | ||
|
||
1. Run the completed program | ||
|
||
npm start | ||
|
||
## Deploying to App Engine | ||
|
||
Deploy your app: | ||
|
||
npm run deploy | ||
|
||
By default, this application deploys to [App Engine Standard][appengine]. _(Recommended)_ | ||
Deploy to App Engine Flexible by [modifying `app.yaml`][app_yaml]. | ||
|
||
[appengine]: https://cloud.google.com/appengine/docs/standard/nodejs | ||
[app_yaml]: https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml | ||
[tutorial]: https://cloud.google.com/appengine/docs/standard/nodejs/quickstart | ||
[contributing]: https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/CONTRIBUTING.md |
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,10 @@ | ||
runtime: nodejs8 | ||
|
||
handlers: | ||
- url: /static | ||
static_dir: static | ||
|
||
- url: /.* | ||
secure: always | ||
script: auto | ||
|
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,34 @@ | ||
// Copyright 2018 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the 'License'); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an 'AS IS' BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
'use strict'; | ||
|
||
const express = require('express'); | ||
const path = require('path'); | ||
|
||
const app = express(); | ||
const PORT = process.env.PORT || 8080; | ||
|
||
app.use(express.static('static')); | ||
|
||
app.get('/full', (req, res) => { | ||
res.sendFile(path.join(__dirname, '/static/index.html')); | ||
}); | ||
|
||
app.get('/min', (req, res) => { | ||
res.sendFile(path.join(__dirname, '/static/index_min.html')); | ||
}); | ||
|
||
app.listen(PORT); | ||
console.log(`App listening on port ${PORT}`); |
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": "appengine-uglifyjs", | ||
"description": "An example of minifying files with UglifyJS and Clean-CSS on Google App Engine.", | ||
"version": "0.0.1", | ||
"private": true, | ||
"license": "Apache Version 2.0", | ||
"author": "Google Inc.", | ||
"engines": { | ||
"node": "8.x" | ||
}, | ||
"scripts": { | ||
"start": "node ./index.js", | ||
"lint-css": "stylelint static/style.css", | ||
"lint-html": "htmlhint index.html", | ||
"lint-js": "semistandard index.js static/message.js", | ||
"lint": "npm run lint-css && npm run lint-html && npm run lint-js", | ||
"test": "npm run gcp-build && repo-tools test app -- index.js", | ||
"minify-css": "cleancss -o static/style.min.css static/style.css", | ||
"minify-js": "uglifyjs --compress --mangle -o static/message.min.js static/message.js", | ||
"gcp-build": "npm run minify-js && npm run minify-css", | ||
"deploy": "gcloud app deploy" | ||
}, | ||
"dependencies": { | ||
"clean-css-cli": "^4.2.1", | ||
"express": "^4.16.3", | ||
"uglify-js": "^3.4.7" | ||
}, | ||
"repo-tools": { | ||
"test": { | ||
"app": { | ||
"url": "/full", | ||
"msg": "message.min.js" | ||
} | ||
} | ||
}, | ||
"devDependencies": { | ||
"@google-cloud/nodejs-repo-tools": "^2.3.3", | ||
"htmlhint": "^0.9.13", | ||
"semistandard": "^12.0.1", | ||
"stylelint": "^9.4.0", | ||
"stylelint-config-recommended": "^2.1.0" | ||
}, | ||
"stylelint": { | ||
"extends": "stylelint-config-recommended" | ||
} | ||
} |
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,33 @@ | ||
<!DOCTYPE html> | ||
|
||
<!-- | ||
Copyright 2018 Google LLC | ||
|
||
Licensed under the Apache License, Version 2.0 (the 'License'); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an 'AS IS' BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<html> | ||
<head> | ||
<title>Simple web page</title> | ||
<script src="message.js" type="text/javascript"></script> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<button onclick="window.buttonClick()">Click me!</button> | ||
<br> | ||
<div id="message">You haven't clicked the button.</div> | ||
|
||
<!-- Error message --> | ||
<div id="cssError" style="font-size:40px; color:red">ERROR: CSS files not found!</div> | ||
</body> | ||
</html> |
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,33 @@ | ||
<!DOCTYPE html> | ||
|
||
<!-- | ||
Copyright 2018 Google LLC | ||
|
||
Licensed under the Apache License, Version 2.0 (the 'License'); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an 'AS IS' BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<html> | ||
<head> | ||
<title>Simple web page</title> | ||
<script src="message.min.js" type="text/javascript"></script> | ||
<link rel="stylesheet" href="style.min.css"> | ||
</head> | ||
<body> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add as a visible text to this page that this is loading minified resources. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto to below comment. |
||
<button onclick="window.buttonClick()">Click me!</button> | ||
<br> | ||
<div id="message">You haven't clicked the button.</div> | ||
|
||
<!-- Error message --> | ||
<div id="cssError" style="font-size:40px; color:red">ERROR: CSS files not found!</div> | ||
</body> | ||
</html> |
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,33 @@ | ||
// Copyright 2018 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the 'License'); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an 'AS IS' BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
window.onload = function () { | ||
window.messageDiv = document.getElementById('message'); | ||
window.buttonClicks = 0; | ||
}; | ||
|
||
window.buttonClick = function () { | ||
window.buttonClicks++; | ||
|
||
var buttonClickTimes; | ||
if (window.buttonClicks === 1) { | ||
buttonClickTimes = 'once'; | ||
} else if (window.buttonClicks === 2) { | ||
buttonClickTimes = 'twice'; | ||
} else { | ||
buttonClickTimes = window.buttonClicks + ' times'; | ||
} | ||
|
||
window.messageDiv.innerHTML = 'You clicked the button ' + buttonClickTimes; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add as a visible text to this page that this is loading unminified resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be obvious based on the different page URLs (
/index
vs/index_min
)