-
Notifications
You must be signed in to change notification settings - Fork 973
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
Windows Local Dev: Construct build scripts for cross-platform use #363
Conversation
Love it! Let's run the build scripts and tests on Windows in GitHub actions as well. Here is the docs |
@mohsen1 Interesting suggestion (and I ❤️GHActions), but for our publishing workflow, I'm not sure this is needed. Or more specifically, since the heart of the problem on Windows is actually Powershell support vs Git Bash vs Etc., I don't think this would actually provide a helpful test -- we'd end up with false positives, effectively. Talk me into it? |
I don't have a lot of experience with Windows in GitHub actions. I think it's worth looking into. I think the default is PowerShell now. Things like path separator for generated files and end of file/line chars can be checked in Windows. You can add windows to the build matrix and let it run. if we saw new issues reported by Windows users we can see how we can test against that in CI then. I don't have Windows to try things out. |
I think this is the best approach, but I would love to do that in the next release. |
packages/cli/package.json
Outdated
@@ -33,10 +33,8 @@ | |||
"@types/node-fetch": "^2.5.5" | |||
}, | |||
"scripts": { | |||
"build": "yarn clean && yarn babel src --out-dir dist && cp -r ./src/commands/generate/templates/. ./dist/commands/generate/templates", | |||
"build": "yarn cross-env NODE_ENV=production babel --delete-dir-on-start src --out-dir dist --copy-files --no-copy-ignored", |
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.
Not a train smash, but I have trouble mentally parsing --delete-dir-on-start src
since it looks like that is the directory to delete, but it's actually the files to compile (I know they're essentially the same.)
"build": "yarn cross-env NODE_ENV=production babel --delete-dir-on-start src --out-dir dist --copy-files --no-copy-ignored", | |
"build": "babel --out-dir dist --env-name PRODUCTION --delete-dir-on-start --copy-files --no-copy-ignored src", |
I also found the --env-name
flag in babel-cli!
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.
--env-name [name] The name of the 'env' to use when loading configs and plugins. Defaults to the value of
BABEL_ENV, or else NODE_ENV, or else 'development'.
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.
Agreed these are painful to read. Feel the same and probably spent too much on that myself before getting reactions. Anyway, for both of these you’re suggesting I try:
- re-ordering flags to make
--delete-dir-on-start
more understandable. I could try:
yarn cross-env NODE_ENV=production babel src --out-dir dist --delete-dir-on-start --copy-files --no-copy-ignored
- See if
--env-name
flag can replacecross-env
package implementation
Correct?
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.
Yup! I actually prefer your suggestion to add src
to the front!
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.
Babel Docs are just, grrrr.
--env-name
does not allow us to set the variable, apparently. It’s just for choosing an env preset, which doesn’t really work with our current setup. But in the future this could be handy — could have settings specific to BABLE_ENV separate from those for NODE_ENV. Anyway, I actually found in some earlier version of the Babel docs where they just say to "use cross-env
”. There you have it.
@peterp any chance you could run this as-in within your Windows env and see if it even works? I can do the same if no time now. Will just take me a bit longer. |
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.
I've made some suggestions, there's a --env-name
flag that I just saw, where we can maybe remove cross-env
?
I also mentioned something about a --watch
flag where we might be able to remove nodemon?
@peterp See my comments about, well, babel == grrr. I did improve readability per comments. Going to take a quick stab at GH Action matrix build including Windows. BRB |
Matrix Build: Ubuntu, Windows, Mac OS
I don’t think it’s worth keeping Mac and Windows going forward. But interesting to see it in action. Build Passing on Windows ESLint Issues on Windows
I actually believe the line ending errors might have to do with git when files are checked out to the Windows system. I don’t have my Windows virtual machine setup and it’s too time consuming to keep testing via GH Actions. Could you try the following locally:
This article was helpful for ideas: To Dos (maybe)
|
I think gitattributes will solve this. I wish Windows wasn't this slow. How about running Windows only on master? Mac doesn't seem necessary to me. |
@thedavidprice It seems that Windows is not working well with: I had a look at the packages code to see if anything stood out, but nothing did. At the moment I'm at a loss to figure out why this isn't working. |
@peterp @thedavidprice - just tested this on my local machine. In addition to the Edit: it just occurred to me that this could be a result of my Git configuration, below.
This git config option should convert LFs to CRLFs on clone locally. (I think this is either the default option or a very common option.) I wonder if it's possible to add an ESLint rule to ignore CRs on Windows only... That said, I at least was able to |
I think the issue is within the Made a PR to get this fixed over there. It might take a while to get it fixed. Maybe disable the rule for now? You can make eslint config disable it based on the environment. |
@mohsen1 I would have imagined that the The error seems to indicate that there is a blank line, which separates the imports, and there shouldn't be, so the problem is that the imports aren't detected properly... My inner nerd really wants to understand this! (I need to confirm that my assumption about the error is correct thought.) |
@weaversam8 I would have thought that a Happy to hear that you're able to build! Now we just need to fix linting on windows :P |
@peterp I suggest we separate this effort into two parts, build and lint. That way I can move us forward:
That way we can at least provide Windows users the capability to build. And merge the PRs dependent on this one. re: .gitattributes
I'm going to set up a Windows environment to do this myself. Just haven't had the time (yet). |
|
…ocal-dev Windows Local Dev: Construct build scripts for cross-platform use
Closes #352
Some
package.json
scripts failed on a Windows system and blocked the ability to contribute.NODE_ENV=production
before a command fails on Windowsmv
,cp
, andrm
are not cross-platformenv vars
This PR uses cross-env to set env vars across all packages:
https://www.npmjs.com/package/cross-env
I used
yarn cross-env ...
instead of justcross-env ...
, which seems to improve readability.removing
dist/
and moving non-js files with babelNow using babel
--delete-dir-on-start
instead ofrm -rf /dist
, which allowed me to removeyarn clean
.And babel
--copy-files
supports moving non-js files into thedist/
directory.API package specific changes
Because the
api/
package requires movingimportAll.macro.js
outside ofdist/
during a build (and then also deleting it prior to a build), I used two packages for cross-platform support of the commandsrm
andmv
.It feels a bit messy...
This works, but it seems like a workaround instead of a proper process.
@peterp I suggest we discuss:
dist/
, which means a breaking change in CRA import forapi/src/functions/graphql.js