Skip to content

Commit

Permalink
feat(swc-templates): update create process to require less manual int…
Browse files Browse the repository at this point in the history
…erference
  • Loading branch information
Westbrook committed May 19, 2021
1 parent 5f85c49 commit 1342649
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
4 changes: 0 additions & 4 deletions projects/templates/plop-templates/package.json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,8 @@
"lit-html"
],
"dependencies": {
"@spectrum-web-components/base": "^0.1.0",
"tslib": "^2.0.0"
},
"devDependencies": {
"@spectrum-css/{{spectrumCSS name}}": "^2.0.0"
},
"types": "./src/index.d.ts",
"sideEffects": [
"./sp-*.js",
Expand Down
4 changes: 2 additions & 2 deletions projects/templates/plop-templates/spectrum-config.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ governing permissions and limitations under the License.
*/

const config = {
spectrum: '{{spectrumCSS name}}',
spectrum: '{{spectrum}}',
components: [
{
name: '{{ name }}',
Expand All @@ -22,4 +22,4 @@ const config = {
],
};

export default config;
export default config;
25 changes: 22 additions & 3 deletions projects/templates/plopfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
export default function (plop) {

const { execSync } = require('child_process');

module.exports = function (plop) {
// name of custom element tag
plop.setPartial('tagnamePartial', 'sp-{{name}}');
// name of LitElement class
Expand All @@ -34,13 +37,26 @@ export default function (plop) {
const capitalized = camel.charAt(0).toUpperCase() + camel.substring(1);
return capitalized;
});
plop.setActionType('install deps', function (answers) {
execSync(
`cd ../../ && yarn lerna add @spectrum-web-components/base --scope=@spectrum-web-components/${answers.name} --no-bootstrap`
);
execSync(
`cd ../../ && yarn lerna add @spectrum-css/${answers.spectrum} --scope=@spectrum-web-components/${answers.name} --dev --no-bootstrap`
);
});
plop.setGenerator('component', {
description: 'application controller logic',
prompts: [
{
type: 'input',
name: 'name',
message: 'component name please',
message: 'SWC package name please',
},
{
type: 'input',
name: 'spectrum',
message: 'Spectrum CSS package name please',
},
],
actions: [
Expand Down Expand Up @@ -99,6 +115,9 @@ export default function (plop) {
path: '../../packages/{{name}}/package.json',
templateFile: 'plop-templates/package.json.hbs',
},
{
type: 'install deps',
},
],
});
}
};

0 comments on commit 1342649

Please sign in to comment.