Skip to content
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

t/5: Introducing the CKEDITOR namespace, the AMD API and the Builder. #6

Merged
merged 34 commits into from Jan 19, 2015
Merged

Conversation

fredck
Copy link
Contributor

@fredck fredck commented Jan 15, 2015

The proposed code means to close #2, #4 and #5.

I've pushed t/2 and t/4 as well, but I'm putting t/5 only under review because all those features are extremely related. They're actually defining the basics for our AMD approach. So it is simpler to review t/5 only and close all those issues at once.

There is a cross-requirement for this PR in ckeditor5-core:
https://github.com/ckeditor/ckeditor5-core/issues/1

Therefore to review this one, ckeditor5-core must be at t/1.

The builder is simply merging the main scripts for now. Other features are to be added in the future so a complete and real distribution version will be created. For now, the focus is creating an interchangeable build version of the root ckeditor.js.

No tests are included because it was not possible to bring the infrastructure necessary for the test environment (#1) without any API to get tested. Therefore, tests will be added later once this PR is masterised and #1 gets closed. A ticket will be opened as a followup to this PR.

The builder can be executed by simply running grunt build.

@Reinmar
Copy link
Member

Reinmar commented Jan 15, 2015

Just a very quick check 😈

  • 130b2c7 - would be good to fix these issues directly in the commits which introduced them, so the code is correct at every point.
  • 255d2b5 - the comments should be either indented (and followed by a space) or outdented - not both at the same time.


function cleanup( callback ) {
var del = require( 'del' );
del.sync( target );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why synchronously when you have a callback to call when ready?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make the code simpler, as we have another call right after that. In any case we need to wait for you anyway, so it should not be a big del, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be a big del

Right ^_^

@fredck
Copy link
Contributor Author

fredck commented Jan 15, 2015

@Reinmar:

130b2c7 - would be good to fix these issues directly in the commits which introduced them, so the code is correct at every point.

I think that, to properly handle PRs, we should avoid force-pushes so we'll have to live this as it is. In any case, in both points the code work. Those are just small details.

255d2b5 - the comments should be either indented (and followed by a space) or outdented - not both at the same time.

Ok, I've removed those comments as we should not really have them at this stage.

@fredck
Copy link
Contributor Author

fredck commented Jan 15, 2015

@gregpabian, I've fixed all your remarks with the above commits.

preserveLicenseComments: false,
wrap: {
startFile: [ 'dev/tasks/build/start.frag', require.resolve( 'almond' ) ],
endFile: 'dev/tasks/build/end.frag'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should put start and end fragments somewhere near the sources, not in dev/tasks/build. Eg. jQuery uses src/intro.js, src/outro.js, angular uses eg. src/module.prefix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from me because those are closer to cource code then to tasks source code/configuration.

Be careful with extension. The .frag is good because it can be white listed on jshint/jscss and in IDE/text editor. Those files can be "invalid" like a function that is cut in half and put in two separate files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense. I've moved them with 76d64c6.

// * CKEditor source code
// * end.frag

( function ( root, factory ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no space after function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 10246ac.


// Before starting, run the initial checkups.
if ( !this.checkUp() ) {
console.log( 'Build operation aborted.' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use http://gruntjs.com/api/grunt.log - e.g. grunt.error.log.

BTW. I think I've read somewhere that using console.log in Node.JS for something more than debugging isn't good. @gregpabian: Do you confirm?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIR it was because of the process output. If you use proc.stdout/stderr you can pipe or redirect this, while with console.log you can't.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really - console.log is just a wrapper around stdout.write so the logs will be redirected if we want to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, the class is coded in a way that it is independent from grunt so it can use by pure node code as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I remembered something wrong. Just one thing then - console.error() is IMO more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 990f135.

* @property {Array}
*/
this.taskList = [
[ 'cleanUp', 'Cleaning the "' + target + '" directory...' ],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now (49b17a2) I've got:

Running "build" task
1. Cleaning the "undefined" directory...

BTW. I miss very much an information about where the build was created - where should I look for it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with 8880b20.


// Make the build an AMD module.
if ( typeof define == 'function' && define.amd ) {
define( [], function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://requirejs.org/docs/api.html#deffunc - the array seems to be unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with ef856f4.

var replace = require( 'replace' );

replace( {
regex: /^\s*CKEDITOR\.(define|require)/mg,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to do this? Can't the minified code be using define and require through the CKEDITOR namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary for r.js to find dependencies. Actually, to find modules and theirs deps.

@Reinmar
Copy link
Member

Reinmar commented Jan 19, 2015

Hurray! The end of the review marathon :D

PS. Before merging please check 1a37506.

@Reinmar
Copy link
Member

Reinmar commented Jan 19, 2015

I'll extract #6 (diff) to a new ticket.

return;
}

console.log( 'Building CKEditor into the "' + this.target + '" directory:')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSHint and JSCS throw errors here - missing semicolon and missing space before closing round bracket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with cccf119.

Damn WebStorm that doesn't work with our pre-commit hook. They fixed it some good time ago but still it didn't land into any of their releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce the AMD API
5 participants