-
Notifications
You must be signed in to change notification settings - Fork 178
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
Angular route subgenerator and test added #162
Conversation
state('<%= slugifiedName %>', { | ||
url: '/<%= slugifiedRoutePath %>', | ||
templateUrl: 'modules/<%= slugifiedModuleName %>/views/<%= slugifiedViewName %>.client.view.html' | ||
}). |
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.
New Line
Left some line comments. |
@codydaig Regarding new line in the end of |
state('<%= slugifiedName %>', { | ||
url: '/<%= slugifiedRoutePath %>', | ||
templateUrl: 'modules/<%= slugifiedModuleName %>/client/views/<%= slugifiedViewName %>.client.view.html' | ||
}). |
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.
newline
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.
Again, why newline in a partial, that is used to replace a
$stateProvider.
string in original file?
Newline in the end would just ruin the idea.
2015-12-21 1:38 GMT+03:00 Ilan Biala [email protected]:
In angular-route/templates/_.client.route.js
#162 (comment)
:@@ -0,0 +1,5 @@
+$stateProvider.
- state('<%= slugifiedName %>', {
- url: '/<%= slugifiedRoutePath %>',
- templateUrl: 'modules/<%= slugifiedModuleName %>/client/views/<%= slugifiedViewName %>.client.view.html'
- }).
newline
—
Reply to this email directly or view it on GitHub
https://github.com/meanjs/generator-meanjs/pull/162/files#r48109358.
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.
Where do this get pulled into that makes it a partial? Also, why does it end with a .?
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.
@ilanbiala It ends with a . exactly because it's a partial. Look up _.client.routes.js
- that's a template for routes file, which should contain many of them. If the file already exists, this partial is taken instead, and inserted into an already existing routes file. See index.js
, line 89 and below.
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.
Where is this implemented? How does it work? What is the goal and the end result?
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.
Please, see angular-route/index.js
, renderRoute
function:
renderRoute: function () {
var routesFilePath = process.cwd() + '/modules/' + this.slugifiedModuleName + '/client/config/' + this.slugifiedModuleName + '.client.routes.js';
// If routes file exists we add a new state otherwise we render a new one
if (fs.existsSync(routesFilePath)) {
// Read the source routes file content
var routesFileContent = this.readFileAsString(routesFilePath);
// Append the new state
routesFileContent = routesFileContent.replace('$stateProvider.', this.engine(this.read('_.client.route.js'), this));
// Save route file
this.writeFileFromString(routesFileContent, routesFilePath);
} else {
this.template('_.client.routes.js', 'modules/' + this.slugifiedModuleName + '/client/config/' + this.slugifiedModuleName + '.client.routes.js')
}
}
The code is quite well commented, but I will repeat the idea here:
- For module name
foo
check, thatfoo.client.routes.js
already exists
2a. If it does, render the partial_.client.route.js
and insert the rendered contents with new route description into an existingfoo.client.routes.js
2b. If it does not exist, render template_.client.routes.js
and save rendered result asfoo.client.routes.js
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.
@UndeadBaneGitHub @codydaig shouldn't any code be based on our using ui-router and not ng-route? I don't think we are using ng-route at all...
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.
@ilanbiala Ehm... But it is based on ui-router, hence $stateProvider
. Old ngRoute
uses $routeProvider
.
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.
Oh sorry, I thought you were actually referring to angular-route code..my mistake. Can you briefly detail all the possible scenarios and what happens? I just want to make sure we didn't miss one and there is nothing better for each scenario.
@ilanbiala LGTY? |
Only thing I'm worried about is some sort of scenario not working? @UndeadBaneGitHub can you maybe add a test for each scenario? For example, for the one where a file already exists, maybe create a file in the test that has xyz code, and then expect abc code after? That will ensure it works properly even in those cases. |
Fixed! Although, need help with squashing: if I do it, then conflicts emerge, because pull requests have been merged, which is kinda strange. |
@@ -34,4 +34,4 @@ gulp.task('mocha', function () { | |||
gulp.task('test', gulp.series('mocha', 'lint')); | |||
|
|||
// The default task (called when you run `gulp` from cli) | |||
gulp.task('default'); | |||
gulp.task('default'); |
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.
newline
@UndeadBaneGitHub how are you doing the squash? |
Normally, like this: |
Oh right, you need to get rid of those couple files. I usually do |
@ilanbiala ok, I managed to squash the commits into one now. Waiting for the merge to fix timeout(0) and temp folder! |
@@ -1,68 +0,0 @@ | |||
'use strict'; |
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.
Why are these files being deleted?
LGTM other than all the deleted files? Those don't look relevant to this PR, are they a result of rebasing/squashing/merging? |
@ilanbiala actually, let me check about the deleted files. |
@ilanbiala Ok, I just forgot to merge master into this branch. Now it's fixed and the files are back |
@UndeadBaneGitHub The comment is still there and there are a bunch of wholly deleted files, did you forget to push or finish the merge or something? |
Created a new PR #183, closing this one. |
No description provided.