-
Notifications
You must be signed in to change notification settings - Fork 303
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
Framework: updated makefile to work with single build.js #275
Conversation
c780b88
to
5cd8b53
Compare
@@ -11,10 +11,10 @@ const debug = require( 'debug' )( 'desktop:crash-reporting' ); | |||
/** | |||
* Internal dependencies | |||
*/ | |||
const Config = require( 'lib/config' ); | |||
const Config = require( '../../lib/config' ); |
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.
nice workaround :)
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 :)
I don't see any problem with a relative path for desktop's internals!
An alternative that I've been playing with is just aliasing desktop
so that this becomes:
const Config = require( 'desktop/lib/config' );
Though I don't think this actually adds much value over a relative path, beyond just allowing further nested files use the same reference and avoid the '../../../../xx
type paths.
@@ -9,7 +9,7 @@ const debug = require( 'debug' )( 'desktop:external-links' ); | |||
/** | |||
* Internal dependencies | |||
*/ | |||
const Config = require( 'lib/config' ); | |||
const Config = require( '../../lib/config' ); |
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.
There are some many places that need to use this strange construct. Maybe we should move this folder elsewhere or rename it to something else? :D
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.
there would definitely be less friction if we change lib/config
in wp-calypso to be /lib/create-config
. I'm hoping we can come up with a cleaner solution like somehow having wp-desktop higher up in the NODE_PATH
@@ -11,10 +11,10 @@ const debug = require( 'debug' )( 'desktop:crash-reporting' ); | |||
/** | |||
* Internal dependencies | |||
*/ | |||
const Config = require( 'lib/config' ); | |||
const Config = require( '../../lib/config' ); |
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 :)
I don't see any problem with a relative path for desktop's internals!
An alternative that I've been playing with is just aliasing desktop
so that this becomes:
const Config = require( 'desktop/lib/config' );
Though I don't think this actually adds much value over a relative path, beyond just allowing further nested files use the same reference and avoid the '../../../../xx
type paths.
|
||
module.exports = function() { | ||
if ( Config.crash_reporter.electron ) { | ||
if ( Config.crash_reporter && Config.crash_reporter.electron ) { |
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 recall seeing errors from this line in my recent attempts to merge desktop > calypso so this is nice to see.
One concern that I have though: is there a chance that this'll give us false positives?
My guess is that it won't and that this change is of benefit, but I just wanted to raise the question anyway :)
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.
Also, I'll keep these in mind as once the projects are merged we'll have access to lodash's util methods here.
I think get(Config, 'crash_reporter.electron')
might work nicely at that point.
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 recall seeing errors from this line in my recent attempts to merge desktop > calypso so this is nice to see.
We were probably getting the error for the same reason: the wrong config was being imported. I'm hoping in the end this change isn't necessary
@rm -f $(THIS_DIR)/calypso/public/devmodules.* | ||
|
||
build-if-not-exists: | ||
@if [ -f $(CALYPSO_JS_STD) ]; then true; else make build; fi | ||
@if [ -f $(CALYPSO_JS) ]; then true; else make build; fi |
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.
Makes sense!
const Config = require( 'desktop/lib/config' ); I don't think it is a good idea to reference only one file located inside We have and We execute
If we would modify |
@gziolo, if we can get the NODE_PATH working properly that would definitely be the cleanest option (although the alias is pretty explicit which is nice). I'll see if I can get it working via NODE_PATH |
getting an error i've never seen now where |
Makefile
Outdated
@@ -91,17 +96,15 @@ endif | |||
package: build-if-changed | |||
@echo "Bundling app and server" | |||
@rm -rf $(BUILD_DIR)/public_desktop $(BUILD_DIR)/calypso | |||
@NODE_PATH=calypso/client $(WEBPACK_BIN) --config $(THIS_DIR)/webpack.config.js | |||
@NODE_PATH=calypso/server$(SEPARATOR)calypso/client $(WEBPACK_BIN) --config $(THIS_DIR)/webpack.config.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.
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 think this is used here because the webpack config requires config
which is found via the NODE_PATH
.
75918a5
to
44cafa2
Compare
I added a few changes which resolve all issues we have. I don't think it is perfect solution, but it should allow us to move forward. I had to update @mtias @blowery: do you know why |
I think it's because it's require'd into the client. It holds all of the section paths and their associated Yeah, the fact that it gets "overwritten" is a bit odd... |
We have been wanting to rename |
Makefile
Outdated
SEPARATOR := : | ||
endif | ||
|
||
|
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.
Minor but the SEPARATOR variable might be confused with path separator /
or \
especially with how it's used below - may I suggest ENV_PATH_SEP or something similar.
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.
Potentially stupid question ahead:
What is the benefit of using $(SEPARATOR)
in the first place? Is this so that we can use a different separator per system? ( I think I read that windows uses ;
for instance)?
Or is there something beyond this?
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.
Is this so that we can use a different separator per system?
nailed it. see https://github.com/Automattic/wp-desktop/pull/275/files#diff-b67911656ef5d18c4ae36cb6741b7965R1
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 copied it over from Calypso. I remember that there were some issues with make
commands on Windows. In the long run we should resolve those kind of issues by using npm scripts
😄
@@ -91,17 +96,15 @@ endif | |||
package: build-if-changed | |||
@echo "Bundling app and server" | |||
@rm -rf $(BUILD_DIR)/public_desktop $(BUILD_DIR)/calypso | |||
@NODE_PATH=calypso/client $(WEBPACK_BIN) --config $(THIS_DIR)/webpack.config.js | |||
@NODE_PATH=calypso/server$(ENV_PATH_SEP)calypso/client $(WEBPACK_BIN) --config $(THIS_DIR)/webpack.config.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.
solved 99% of the problem with the line right here. good work @gziolo 👍
Seems to be working for me except for |
I have to disagree with myself here :) I spent couple of hours debugging this issue. It turned out that when you execute Webpack magic it loads code from |
@gziolo Any chance you had time to look back at this one? |
@astralbodies looking into it now. |
d8adc5b
to
e5b0a58
Compare
@echo "Copying Calypso client and public files" | ||
@sed -e 's/build\///' $(THIS_DIR)/package.json >$(BUILD_DIR)/package.json | ||
@mkdir $(BUILD_DIR)/calypso $(BUILD_DIR)/calypso/config $(BUILD_DIR)/calypso/server | ||
@cp -R $(THIS_DIR)/public_desktop $(BUILD_DIR) | ||
@cp -R $(CALYPSO_DIR)/public $(BUILD_DIR)/calypso/public | ||
@cp -R $(CALYPSO_DIR)/server/pages $(BUILD_DIR)/calypso/server/pages | ||
@if [ -f $(CALYPSO_DIR)/config/secrets.json ]; then cp $(CALYPSO_DIR)/config/secrets.json $(BUILD_DIR)/calypso/config/secrets.json; else cp $(CALYPSO_DIR)/config/empty-secrets.json $(BUILD_DIR)/calypso/config/secrets.json; fi; | ||
@cp $(CALYPSO_DIR)/config/_shared.json $(BUILD_DIR)/calypso/config/ |
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.
It looks like make test
needs all config files to build config file properly. Those config files aren't needed for make run
, but might be needed for packaging. Let's leave them as they were.
Without this config files located in build folder make test
isn't able to load properly configuration and were trying to load web version of Calypso. This is why it couldn't load properly in test mode :)
@astralbodies I fixed
You were completely right. The only good part is that I find out that we don't copy over |
I have just noticed that we set node |
It looks like it is required to make test work.
023679d
to
a85c2a5
Compare
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.
OSX build runs for me!
Should I merge it as it is or does it need more testing? |
@gziolo I vote for you merging it in now, and then I can do a full beta release process from master. |
I did just note one problem with
|
@gziolo I fixed the paths in the test target but the
|
I am taking @johngodley's suggestion and not letting the |
@astralbodies thanks for help with testing :) |
Along with the
wp-calypso
PR here (which has already landed), this PR seeks makewp-desktop
compatible with the latest changes to wp-calypso (single build for non-development envs).Testing
try/framework/ssr-config-desktop-compat
master
Calypso branch.make test
to verify it works properly.make run
and check if it builds and works properly.