-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a Polymer 3 application template to
init
. (#134)
* Copy `polymer-2.x` template to `polymer-3.x`. * Update `init` and associated polymer-3.x template. * Update `README.md`. * Format, excluding broken changes due to templating. * Move templates to a folder in the package root so that they aren't checked by depcheck. * copy templates/application/polymer-2.x -> templates/application/polymer-3.x; add a stub option * Update Polymer 3 application template. * Add pass-through functions for Yeoman bug. * Add an integration test for the Polymer 3 application template. * Remove unused `static get is()` from the default app element. * Remove `main` field from `package.json`. * Add `polymer lint` to Polymer 3 application template `polymer.json` and integration test. * Fix Polymer 3 application template `.gitignore`. * Use CLI for installation instead of `npm` directly. * Fix comment typos.
- Loading branch information
Showing
12 changed files
with
248 additions
and
5 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
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 @@ | ||
/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,33 @@ | ||
# \<<%= name %>\> | ||
|
||
<%= description %> | ||
|
||
## Install the Polymer-CLI | ||
|
||
First, make sure you have the [Polymer CLI](https://www.npmjs.com/package/polymer-cli) installed. Then run `polymer serve` to serve your application locally. | ||
|
||
## Viewing Your Application | ||
|
||
``` | ||
$ polymer serve | ||
``` | ||
|
||
## Building Your Application | ||
|
||
``` | ||
$ polymer build | ||
``` | ||
|
||
This will create builds of your application in the `build/` directory, optimized to be served in production. You can then serve the built versions by giving `polymer serve` a folder to serve from: | ||
|
||
``` | ||
$ polymer serve build/default | ||
``` | ||
|
||
## Running Tests | ||
|
||
``` | ||
$ polymer test | ||
``` | ||
|
||
Your application is already set up to be tested via [web-component-tester](https://github.com/Polymer/web-component-tester). Run `polymer test` to run your application's test suite locally. |
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,22 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"> | ||
|
||
<title><%= name %></title> | ||
<meta name="description" content="<% | ||
if (description) { -%><%= description %><% } else { -%><%= name %> description<% } | ||
-%>"> | ||
|
||
<!-- See https://goo.gl/OOhYW5 --> | ||
<link rel="manifest" href="/manifest.json"> | ||
|
||
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> | ||
|
||
<script type="module" src="/src/<%= elementName %>/<%= elementName %>.js"></script> | ||
</head> | ||
<body> | ||
<<%= elementName %>></<%= elementName %>> | ||
</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,8 @@ | ||
{ | ||
"name": "<%= name %>", | ||
"short_name": "<%= name %>", | ||
<% if (description) { -%> "description": "<%= description %>", | ||
<% } -%> | ||
"start_url": "/", | ||
"display": "standalone" | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/cli/templates/application/polymer-3.x/package.json
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,12 @@ | ||
{ | ||
"name": "<%= name %>", | ||
<% if (description) { -%> "description": "<%= description %>", | ||
<% } -%> | ||
"dependencies": { | ||
"@polymer/polymer": "^3.0.0-pre.12" | ||
}, | ||
"devDependencies": { | ||
"@webcomponents/webcomponentsjs": "^1.0.0", | ||
"wct-browser-legacy": "^0.0.1-pre.11" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"npm": true, | ||
"moduleResolution": "node", | ||
"lint": { | ||
"rules": [ | ||
"polymer-3" | ||
] | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/cli/templates/application/polymer-3.x/src/_element/_element.js
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,28 @@ | ||
import {PolymerElement} from '@polymer/polymer/polymer-element.js'; | ||
|
||
/** | ||
* @customElement | ||
* @polymer | ||
*/ | ||
class <%= elementClassName %> extends PolymerElement { | ||
static get template() { | ||
return ` | ||
<style> | ||
:host { | ||
display: block; | ||
} | ||
</style> | ||
<h2>Hello [[prop1]]!</h2> | ||
`; | ||
} | ||
static get properties() { | ||
return { | ||
prop1: { | ||
type: String, | ||
value: '<%= elementName %>' | ||
} | ||
}; | ||
} | ||
} | ||
|
||
window.customElements.define('<%= elementName %>', <%= elementClassName %>); |
53 changes: 53 additions & 0 deletions
53
packages/cli/templates/application/polymer-3.x/test/_element/_element_test.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,53 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"> | ||
|
||
<title><%= elementName %> test</title> | ||
|
||
<script src="../../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> | ||
<script src="../../node_modules/wct-browser-legacy/browser.js"></script> | ||
|
||
<script type="module" src="../../src/<%= elementName %>/<%= elementName %>.js"></script> | ||
</head> | ||
<body> | ||
|
||
<test-fixture id="BasicTestFixture"> | ||
<template> | ||
<<%= elementName %>></<%= elementName %>> | ||
</template> | ||
</test-fixture> | ||
|
||
<test-fixture id="ChangedPropertyTestFixture"> | ||
<template> | ||
<<%= elementName %> prop1="new-prop1"></<%= elementName %>> | ||
</template> | ||
</test-fixture> | ||
|
||
<script> | ||
suite('<%= elementName %>', function() { | ||
|
||
test('instantiating the element with default properties works', function() { | ||
var element = fixture('BasicTestFixture'); | ||
assert.equal(element.prop1, '<%= elementName %>'); | ||
var elementShadowRoot = element.shadowRoot; | ||
var elementHeader = elementShadowRoot.querySelector('h2'); | ||
assert.equal(elementHeader.innerHTML, 'Hello <%= elementName %>!'); | ||
}); | ||
|
||
test('setting a property on the element works', function() { | ||
// Create a test fixture | ||
var element = fixture('ChangedPropertyTestFixture'); | ||
assert.equal(element.prop1, 'new-prop1'); | ||
var elementShadowRoot = element.shadowRoot; | ||
var elementHeader = elementShadowRoot.querySelector('h2'); | ||
assert.equal(elementHeader.innerHTML, 'Hello new-prop1!'); | ||
}); | ||
|
||
}); | ||
</script> | ||
|
||
|
||
</body> | ||
</html> |