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

Fix Windows compatibility #666

Merged

Conversation

GeorgeGorbanev
Copy link
Contributor

@GeorgeGorbanev GeorgeGorbanev commented Jan 3, 2017

'install_generator.rb' uses *nix instruction 'which' to find Node and npm path.

Now it use 'where' if detect running on Windows and 'which' in other case.


This change is Reviewable

@coveralls
Copy link

coveralls commented Jan 3, 2017

Coverage Status

Coverage remained the same at 99.294% when pulling da203cc on GeorgeGorbanev:install_generator_windows_fix into 13cff3f on shakacode:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage remained the same at 99.294% when pulling da203cc on GeorgeGorbanev:install_generator_windows_fix into 13cff3f on shakacode:master.

@justin808
Copy link
Member

Thanks for this! We need a CHANGELOG.md entry per the instructions in https://github.com/shakacode/react_on_rails/blob/master/CONTRIBUTING.md and need travis to be passing.


Reviewed 1 of 1 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


lib/generators/react_on_rails/install_generator.rb, line 68 at r1 (raw file):

      def missing_npm?
        return false unless
            /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM ? `where npm`.blank? : `which npm`.blank?

Let's dry up this check in for a windows ruby platform by creating a utility method in https://github.com/shakacode/react_on_rails/blob/master/lib/react_on_rails/utils.rb

Let's add a unit test for this utility method that will compare the result against a different way of figuring out the value, as suggested by the answers here.

http://stackoverflow.com/a/171011/1009332


Comments from Reviewable

@GeorgeGorbanev GeorgeGorbanev force-pushed the install_generator_windows_fix branch from da203cc to 13cff3f Compare January 6, 2017 09:31
@justin808
Copy link
Member

@GeorgeGorbanev Why did you close this PR?

@GeorgeGorbanev
Copy link
Contributor Author

GeorgeGorbanev commented Jan 6, 2017

@justin808 My bad, it was not expected. Will fix it soon.

@GeorgeGorbanev GeorgeGorbanev reopened this Jan 6, 2017
@GeorgeGorbanev
Copy link
Contributor Author

GeorgeGorbanev commented Jan 6, 2017

@justin808 Added few lines in changelog and separated checking method to utils module. But have some troubles with tests. Practically I never did it before and don't know how to do it. I tried to do it using this tips and on command:

bundle && npm i && rake examples:prepare_all && rake node_package && rake

get error

> [email protected] babel /home/george/RubymineProjects/react_on_rails
> babel --out-dir node_package/lib node_package/src

SyntaxError: node_package/src/Authenticity.js: Unexpected token (6:15)
  4 | 
  5 |   authenticityToken() {
> 6 |     const token: ?HTMLElement = document.querySelector('meta[name="csrf-token"]');
    |                ^
  7 |     if (token && (token instanceof window.HTMLMetaElement)) {
  8 |       return token.content;
  9 |     }

npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/home/george/.nvm/versions/node/v7.4.0/bin/node" "/home/george/.nvm/versions/node/v7.4.0/bin/npm" "run" "babel"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] babel: `babel --out-dir node_package/lib node_package/src`
npm ERR! Exit status 1

Log file is attached. npm-debug.txt

Can you help me?

@justin808
Copy link
Member

@GeorgeGorbanev You'll have to yak shave that one. Possibly there's issues with Windows? Maybe downgrade the version of node to the latest 6.x version?

@justin808
Copy link
Member

Please rebase on top of master and try again.

@justin808
Copy link
Member

Remove the last commit and please try the rebase again. You should ONLY see the changes that you've made. @GeorgeGorbanev

@GeorgeGorbanev GeorgeGorbanev force-pushed the install_generator_windows_fix branch from 20b015f to 779fa51 Compare January 9, 2017 09:16
@justin808
Copy link
Member

@GeorgeGorbanev Any progress?

@GeorgeGorbanev
Copy link
Contributor Author

GeorgeGorbanev commented Jan 10, 2017

@justin808 Yes, some kind of progress. I configured system to run tests and ready to write rspec. Also, did I rebased branch right way this time?

@justin808
Copy link
Member

almost there. Yes, tests and pass CI. did you lint?


Reviewed 2 of 3 files at r2, 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks broke.


Comments from Reviewable

@GeorgeGorbanev
Copy link
Contributor Author

@justin808 Guess no, don't know how to do it.

@justin808
Copy link
Member

@GeorgeGorbanev
Copy link
Contributor Author

@justin808 Thank you. It will be done.

@coveralls
Copy link

coveralls commented Jan 10, 2017

Coverage Status

Coverage increased (+0.001%) to 99.299% when pulling b368777 on GeorgeGorbanev:install_generator_windows_fix into 6bb07f5 on shakacode:master.

@GeorgeGorbanev GeorgeGorbanev force-pushed the install_generator_windows_fix branch from 27b4894 to b368777 Compare January 10, 2017 18:00
@coveralls
Copy link

coveralls commented Jan 10, 2017

Coverage Status

Coverage increased (+0.001%) to 99.299% when pulling b1b247f on GeorgeGorbanev:install_generator_windows_fix into a607ad7 on shakacode:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 99.299% when pulling b1b247f on GeorgeGorbanev:install_generator_windows_fix into a607ad7 on shakacode:master.

@GeorgeGorbanev GeorgeGorbanev force-pushed the install_generator_windows_fix branch 2 times, most recently from c19a744 to 2085aa2 Compare January 10, 2017 21:12
@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 99.299% when pulling 2085aa2 on GeorgeGorbanev:install_generator_windows_fix into a607ad7 on shakacode:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 99.299% when pulling 2085aa2 on GeorgeGorbanev:install_generator_windows_fix into a607ad7 on shakacode:master.

@coveralls
Copy link

coveralls commented Jan 10, 2017

Coverage Status

Coverage increased (+0.001%) to 99.299% when pulling 2085aa2 on GeorgeGorbanev:install_generator_windows_fix into a607ad7 on shakacode:master.

@coveralls
Copy link

coveralls commented Jan 10, 2017

Coverage Status

Coverage increased (+0.001%) to 99.299% when pulling 2085aa2 on GeorgeGorbanev:install_generator_windows_fix into a607ad7 on shakacode:master.

@GeorgeGorbanev
Copy link
Contributor Author

@justin808 How it looks now?

@justin808
Copy link
Member

some more comments


Reviewed 5 of 5 files at r5.
Review status: 3 of 4 files reviewed at latest revision, 6 unresolved discussions.


CHANGELOG.md, line 19 at r5 (raw file):

### Fixed
- Removed foreman as a dependency. [#678](https://github.com/shakacode/react_on_rails/pull/678) by [x2es](https://github.com/x2es).
- Added checking of OS and fixed generator for Windows.

Please double check that your formatting matches all other entries.

get rid of the ====== and add the PR number and your github info!


lib/react_on_rails/utils.rb, line 43 at r5 (raw file):

      def self.linux?
        OS.unix? && !OS.mac?

Why do we care if mac or unix?


spec/react_on_rails/generators/install_generator_spec.rb, line 168 at r5 (raw file):

def `(*)
what is this syntax?


Comments from Reviewable

@GeorgeGorbanev
Copy link
Contributor Author

@justin808 Thanks for review and sorry for really dirty code. I will follow all your comments.
It would be right to use this method to detect OS?
And can I keep "def `(where)..." to mock windows system calls? Lint will not correctly take it.

@justin808
Copy link
Member

I've never seen the def `(where) syntax

I don't see why you will call the wrong command on the wrong OS. That's the point of your fix.

And yes, no need to detect Mac.

@GeorgeGorbanev
Copy link
Contributor Author

GeorgeGorbanev commented Jan 13, 2017

@justin808 This syntax described by Hal Fulton for example. Hope it is not bad style.

I don't see why you will call the wrong command on the wrong OS. That's the point of your fix.

Actually it turns wrong command to correct, so we can test method behavior as it would be correct OS. Now it defined in wrong place and "node_missing?" can't use it, but I'll fix it, when find how. Better do another way?

@GeorgeGorbanev
Copy link
Contributor Author

GeorgeGorbanev commented Jan 13, 2017

@justin808 Besides a RUBY_PLATFORM constant method I found method using shell command "uname -s" and method using rbconfig. But all of them require the same regexp-matching. Did you mean one of them?
Also, is it necessary to make new spec for this utility-method when it now tests with "missing_node?"?(it still not right, but soon will be)

@coveralls
Copy link

coveralls commented Jan 13, 2017

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 182f65e on GeorgeGorbanev:install_generator_windows_fix into 9f0f63b on shakacode:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 267e753 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 267e753 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 267e753 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 67a7f02 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 67a7f02 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 67a7f02 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 67a7f02 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@GeorgeGorbanev GeorgeGorbanev force-pushed the install_generator_windows_fix branch from 67a7f02 to e7d068c Compare January 13, 2017 13:24
@GeorgeGorbanev GeorgeGorbanev force-pushed the install_generator_windows_fix branch from e7d068c to 13cff3f Compare January 13, 2017 13:25
@coveralls
Copy link

coveralls commented Jan 13, 2017

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 13cff3f on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@GeorgeGorbanev GeorgeGorbanev force-pushed the install_generator_windows_fix branch from e17671e to 463ddb6 Compare January 13, 2017 13:36
@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 463ddb6 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 463ddb6 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 463ddb6 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 463ddb6 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@GeorgeGorbanev
Copy link
Contributor Author

GeorgeGorbanev commented Jan 13, 2017

@justin808 Fixed all. It works and tests without weird syntax. Also changelog and commits history was cleared. Can I do something else to make it better?

@coveralls
Copy link

coveralls commented Jan 13, 2017

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 463ddb6 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@coveralls
Copy link

coveralls commented Jan 13, 2017

Coverage Status

Coverage increased (+0.008%) to 99.329% when pulling 463ddb6 on GeorgeGorbanev:install_generator_windows_fix into dcd2a92 on shakacode:master.

@justin808
Copy link
Member

:lgtm:

Big improvement!


Reviewed 4 of 4 files at r6.
Review status: all files reviewed at latest revision, 6 unresolved discussions.


Comments from Reviewable

@justin808 justin808 merged commit 0796bf4 into shakacode:master Jan 18, 2017
justin808 pushed a commit that referenced this pull request Feb 11, 2017
system call for Windows and unit-tests for it. (#666)
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.

3 participants