Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #36 from liferay/1.0
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
ealonso authored Jan 10, 2019
2 parents f222ffd + a3d9642 commit ffbd403
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 12 deletions.
161 changes: 154 additions & 7 deletions generators/app/__tests__/__snapshots__/app-generator.spec.js.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`app-generator allows a custom repository name 1`] = `
Object {
"content": "root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
",
"filePath": "/.editorconfig",
}
`;

exports[`app-generator allows a custom repository name 2`] = `
Object {
"content": "build/
node_modules/
",
"filePath": "/.gitignore",
}
`;

exports[`app-generator allows a custom repository name 3`] = `
Object {
"content": "{}
",
"filePath": "/.yo-rc.json",
}
`;

exports[`app-generator allows a custom repository name 4`] = `
Object {
"content": "{
\\"name\\": \\"my-nice-custom-project\\",
Expand Down Expand Up @@ -31,7 +66,7 @@ Object {
}
`;

exports[`app-generator allows a custom repository name 2`] = `
exports[`app-generator allows a custom repository name 5`] = `
Object {
"content": "# My Nice Custom Project
Expand All @@ -45,7 +80,56 @@ how to manage this project in the [generator documentation][2].
}
`;

exports[`app-generator allows a custom repository name 6`] = `
Object {
"content": "",
"filePath": "/src",
}
`;

exports[`app-generator allows a custom repository name 7`] = `
Object {
"content": "",
"filePath": "/src/.gitkeep",
}
`;

exports[`app-generator allows adding sample content 1`] = `
Object {
"content": "root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
",
"filePath": "/.editorconfig",
}
`;

exports[`app-generator allows adding sample content 2`] = `
Object {
"content": "build/
node_modules/
",
"filePath": "/.gitignore",
}
`;

exports[`app-generator allows adding sample content 3`] = `
Object {
"content": "{}
",
"filePath": "/.yo-rc.json",
}
`;

exports[`app-generator allows adding sample content 4`] = `
Object {
"content": "{
\\"name\\": \\"sample-liferay-fragments\\",
Expand Down Expand Up @@ -76,7 +160,7 @@ Object {
}
`;

exports[`app-generator allows adding sample content 2`] = `
exports[`app-generator allows adding sample content 5`] = `
Object {
"content": "# Sample Liferay Fragments
Expand All @@ -90,7 +174,21 @@ how to manage this project in the [generator documentation][2].
}
`;

exports[`app-generator allows adding sample content 3`] = `
exports[`app-generator allows adding sample content 6`] = `
Object {
"content": "",
"filePath": "/src",
}
`;

exports[`app-generator allows adding sample content 7`] = `
Object {
"content": "",
"filePath": "/src/.gitkeep",
}
`;

exports[`app-generator allows adding sample content 8`] = `
Object {
"content": "{
\\"cssPath\\": \\"styles.css\\",
Expand All @@ -104,7 +202,7 @@ Object {
}
`;

exports[`app-generator allows adding sample content 4`] = `
exports[`app-generator allows adding sample content 9`] = `
Object {
"content": "<div class=\\"sample-fragment\\">
Sample fragment
Expand All @@ -114,7 +212,7 @@ Object {
}
`;

exports[`app-generator allows adding sample content 5`] = `
exports[`app-generator allows adding sample content 10`] = `
Object {
"content": ".sample-fragment {
color: inherit;
Expand All @@ -124,7 +222,7 @@ Object {
}
`;

exports[`app-generator allows adding sample content 6`] = `
exports[`app-generator allows adding sample content 11`] = `
Object {
"content": "const content = fragmentElement.querySelector('.sample-fragment');
",
Expand All @@ -133,6 +231,41 @@ Object {
`;

exports[`app-generator generates a new project 1`] = `
Object {
"content": "root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
",
"filePath": "/.editorconfig",
}
`;

exports[`app-generator generates a new project 2`] = `
Object {
"content": "build/
node_modules/
",
"filePath": "/.gitignore",
}
`;

exports[`app-generator generates a new project 3`] = `
Object {
"content": "{}
",
"filePath": "/.yo-rc.json",
}
`;

exports[`app-generator generates a new project 4`] = `
Object {
"content": "{
\\"name\\": \\"sample-liferay-fragments\\",
Expand Down Expand Up @@ -163,7 +296,7 @@ Object {
}
`;

exports[`app-generator generates a new project 2`] = `
exports[`app-generator generates a new project 5`] = `
Object {
"content": "# Sample Liferay Fragments
Expand All @@ -176,3 +309,17 @@ how to manage this project in the [generator documentation][2].
"filePath": "/README.md",
}
`;

exports[`app-generator generates a new project 6`] = `
Object {
"content": "",
"filePath": "/src",
}
`;

exports[`app-generator generates a new project 7`] = `
Object {
"content": "",
"filePath": "/src/.gitkeep",
}
`;
9 changes: 7 additions & 2 deletions generators/app/__tests__/app-generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ const YeomanTest = require('yeoman-test');

function expectFile(base, _path) {
const filePath = path.join(base, _path);
const content = fs.readFileSync(filePath, 'utf-8');
const stat = fs.lstatSync(filePath);
let content = '';

if (stat.isFile()) {
content = fs.readFileSync(filePath, 'utf-8');
}

return expect({
filePath: _path.split(path.sep).join('/'),
Expand All @@ -22,7 +27,7 @@ function expectProjectFiles(base) {

return expectFiles(
base,
glob.sync(`${templatesPath}/**/*`).map(templatePath =>
glob.sync(`${templatesPath}/**/*`, { dot: true }).map(templatePath =>
path
.resolve(templatePath)
.replace(templatesPath, '')
Expand Down
2 changes: 2 additions & 0 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class AppGenerator extends CustomGenerator {
writing() {
logNewLine('Creating directory');

this.copyFiles(this.destinationRoot(), ['src/.gitkeep']);

this.copyTemplates(this.destinationRoot(), [
'.editorconfig',
'.gitignore',
Expand Down
Empty file.
3 changes: 2 additions & 1 deletion generators/fragment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ module.exports = class extends CustomGenerator {
name: FRAGMENT_TYPE_VAR,
message: FRAGMENT_TYPE_MESSAGE,
choices: FRAGMENT_TYPE_OPTIONS,
default: this.getValue(FRAGMENT_TYPE_VAR)
default: this.getValue(FRAGMENT_TYPE_DEFAULT),
when: !this.hasValue(FRAGMENT_TYPE_VAR)
}
]);

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "generator-liferay-fragments",
"version": "0.2.0",
"version": "1.0.0",
"description": "Yeoman generator for creating and maintaining Liferay Fragment projects",
"homepage": "https://www.npmjs.com/package/generator-liferay-fragments",
"author": {
Expand Down

0 comments on commit ffbd403

Please sign in to comment.