HabitRPG / habitica-chat-extension

A habitica.com Chat Client for Chrome
18 stars 13 forks source link

Browserify #42

Closed crookedneighbor closed 4 years ago

crookedneighbor commented 5 years ago

Since changes in the chrome extension need to be duplicated in the firefox folder, it's easy for things to get out of sync. I propose we leverage a build tool to ensure that all changes remain consistent.

We can leverage env variables to adjust for differences in the Chrome and Firefox extension APIs.

This does add some additional complexity to the development setup, but IMO it is worth it.

Also uses unminified code for jQuery and Habitica Markdown. (presumably, will fix the problem with the Firefox extension, but hard to say without trying to actually upload it)

Closes #40

cTheDragons commented 5 years ago

I might be a while before I can review this as I don't have access to node.js to install the tool above. (I'm on a (small) windows computer) Thanks

Also I am completely lost on how to make this all happen. Will try to do some research but I feel my beginner skills are showing again.

crookedneighbor commented 5 years ago

TBH, if you can’t maintain it with this structure, it may not be wise to make this change.

crookedneighbor commented 5 years ago

I would recommend making some kind of change to keep the 2 versions of the extension in sync that doesn’t just require a human to make the same change in both places. That’s extremely error prone.

cTheDragons commented 5 years ago

Agreed. I would prefer to that code was synced.

It should be noted that I was not the main coder with the recent changes. That was @coder-extreme (@benjaminbhollon). I only hacked the code as required. Maybe it is ok for them? I may make it hard though for other testers to check the code though. Most users found it difficult downloading the latest code and connecting it to their browser.

Again, I think it just showing my lack of skills in this area which is compounded by a lack of a linux environment where this is all just native.

I have used repl.it in the past to muck around in this area, but I fear this will not cut it. Will have a go later in the weekend when I have some more time to see if I can work something out.

crookedneighbor commented 5 years ago

Not being able to run this on a windows machine is a legitimate concern. Should be able to adjust the scripts to work universally, just need some free time to do it.

cTheDragons commented 5 years ago

Thanks! I ran out of time this weekend to do much research. (My computer decided I will not play today so I need to change my plans). Also one of pieces of code I look after for Habitica is playing up so I need to divert my time to that.

I am happy to test once the scripts are adjusted. Thanks

cTheDragons commented 5 years ago

Ok I have tried to get some headway with this.

> habitica-chat-extension@2.2.1 build D:\Profile\Documents\GitHub\habitica-chat-extension
> npm-run-all --parallel build:chrome build:firefox

> habitica-chat-extension@2.2.1 build:chrome D:\Profile\Documents\GitHub\habitica-chat-extension
> export BROWSER=chrome; npm-run-all build:base build:js

> habitica-chat-extension@2.2.1 build:firefox D:\Profile\Documents\GitHub\habitica-chat-extension
> export BROWSER=firefox; npm-run-all build:base build:js

'export' is not recognized as an internal or external command,
operable program or batch file.
'export' is not recognized as an internal or external command,
operable program or batch file.
npm npmERR!  codeERR! ELIFECYCLE
 code ELIFECYCLE
npm ERR! npmerrno  1
ERR! errnonpm 1
 ERR! habitica-chat-extension@2.2.1 build:chrome: `export BROWSER=chrome; npm-run-all build:base build:js`
npm ERR! Exit status 1
npm ERR!npm habitica-chat-extension@2.2.1 build:firefox: `export BROWSER=firefox; npm-run-all build:base build:js`
 npmERR! ERR!
npm Exit status 1
 ERR!npm  Failed at the habitica-chat-extension@2.2.1 build:chrome script.
ERR!npm ERR!
 This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! Failed at the habitica-chat-extension@2.2.1 build:firefox script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npmnpm  ERR!ERR! A complete log of this run can be found in:
 A complete log of this run can be found in:
npmnpm  ERR!ERR!     C:\Users\cTheDragons\AppData\Roaming\npm-cache\_logs\2019-06-29T12_31_47_569Z-debug.log
     C:\Users\cTheDragons\AppData\Roaming\npm-cache\_logs\2019-06-29T12_31_47_564Z-debug.log
ERROR: "build:firefox" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! habitica-chat-extension@2.2.1 build: `npm-run-all --parallel build:chrome build:firefox`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the habitica-chat-extension@2.2.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\cTheDragons\AppData\Roaming\npm-cache\_logs\2019-06-29T12_31_47_704Z-debug.log

The debug log states:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@6.9.0
3 info using node@v10.16.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle habitica-chat-extension@2.2.1~prebuild: habitica-chat-extension@2.2.1
6 info lifecycle habitica-chat-extension@2.2.1~build: habitica-chat-extension@2.2.1
7 verbose lifecycle habitica-chat-extension@2.2.1~build: unsafe-perm in lifecycle true
8 verbose lifecycle habitica-chat-extension@2.2.1~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\Profile\Documents\GitHub\habitica-chat-extension\node_modules\.bin;C:\Users\cTheDragons\AppData\Roaming\npm;C:\Program Files\nodejs\;C:\Program Files (x86)\Intel\TXE Components\iCLS\;C:\Program Files\Intel\TXE Components\iCLS\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Intel\TXE Components\DAL\;C:\Program Files (x86)\Intel\TXE Components\DAL\;C:\Program Files\Intel\TXE Components\IPT\;C:\Program Files (x86)\Intel\TXE Components\IPT\;C:\Program Files\nodejs\;C:\Users\cTheDragons\AppData\Local\Microsoft\WindowsApps;C:\Users\cTheDragons\AppData\Local\GitHubDesktop\bin;C:\Users\cTheDragons\AppData\Roaming\npm
9 verbose lifecycle habitica-chat-extension@2.2.1~build: CWD: D:\Profile\Documents\GitHub\habitica-chat-extension
10 silly lifecycle habitica-chat-extension@2.2.1~build: Args: [ '/d /s /c',
10 silly lifecycle   'npm-run-all --parallel build:chrome build:firefox' ]
11 silly lifecycle habitica-chat-extension@2.2.1~build: Returned: code: 1  signal: null
12 info lifecycle habitica-chat-extension@2.2.1~build: Failed to exec build script
13 verbose stack Error: habitica-chat-extension@2.2.1 build: `npm-run-all --parallel build:chrome build:firefox`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid habitica-chat-extension@2.2.1
15 verbose cwd D:\Profile\Documents\GitHub\habitica-chat-extension
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v10.16.0
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error habitica-chat-extension@2.2.1 build: `npm-run-all --parallel build:chrome build:firefox`
22 error Exit status 1
23 error Failed at the habitica-chat-extension@2.2.1 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I'm not sure what all this means. Please could someone help with this? Thanks

benjaminbhollon commented 5 years ago

I tried the same thing.

habitica-chat-extension@2.2.1 build:firefox C:\Users\Benjamin\Downloads\habitica-chat-extension-browserify export BROWSER=firefox; npm-run-all build:base build:js

habitica-chat-extension@2.2.1 build:chrome C:\Users\Benjamin\Downloads\habitica-chat-extension-browserify export BROWSER=chrome; npm-run-all build:base build:js

'export' is not recognized as an internal or external command, operable program or batch file. 'export' is not recognized as an internal or external command, operable program or batch file. npmnpm ERR!ERR! codecode ELIFECYCLE ELIFECYCLE npmnpm ERR!ERR! errnoerrno 1 1 npmnpm ERR!ERR! habitica-chat-extension@2.2.1 build:chrome: export BROWSER=chrome; npm-run-all build:base build:js npm habitica-chat-extension@2.2.1 build:firefox: export BROWSER=firefox; npm-run-all build:base build:js npm ERR!ERR! Exit status 1 Exit status 1 npm npmERR! ERR! npm npm ERR!ERR! Failed at the habitica-chat-extension@2.2.1 build:chrome script. npm Failed at the habitica-chat-extension@2.2.1 build:firefox script. ERR!npm ERR! This is probably not a problem with npm. There is likely additional logging output above. This is probably not a problem with npm. There is likely additional logging output above.

npmnpm ERR!ERR! A complete log of this run can be found in: npm A complete log of this run can be found in: npmERR! C:\Users\Benjamin\AppData\Roaming\npm-cache_logs\2019-07-01T13_20_50_439Z-debug.log ERR! C:\Users\Benjamin\AppData\Roaming\npm-cache_logs\2019-07-01T13_20_50_443Z-debug.log ERROR: "build:chrome" exited with 1. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! habitica-chat-extension@2.2.1 build: npm-run-all --parallel build:chrome build:firefox npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the habitica-chat-extension@2.2.1 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Benjamin\AppData\Roaming\npm-cache_logs\2019-07-01T13_20_50_614Z-debug.log

- The mentioned error log is:

0 info it worked if it ends with ok 1 verbose cli [ 'C:\Program Files\nodejs\node.exe', 1 verbose cli 'C:\Users\Benjamin\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'build' ] 2 info using npm@6.9.2 3 info using node@v8.12.0 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ] 5 info lifecycle habitica-chat-extension@2.2.1~prebuild: habitica-chat-extension@2.2.1 6 info lifecycle habitica-chat-extension@2.2.1~build: habitica-chat-extension@2.2.1 7 verbose lifecycle habitica-chat-extension@2.2.1~build: unsafe-perm in lifecycle true 8 verbose lifecycle habitica-chat-extension@2.2.1~build: PATH: C:\Users\Benjamin\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Benjamin\Downloads\habitica-chat-extension-browserify\node_modules.bin;C:\Users\Benjamin\AppData\Roaming\npm;C:\Program Files\nodejs\;C:\Program Files (x86)\Python37-32\Scripts\;C:\Program Files (x86)\Python37-32\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\nodejs\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Calibre2\;C:\Program Files\php-7;C:\Users\Benjamin\AppData\Local\Microsoft\WindowsApps;C:\Users\Benjamin\AppData\Local\GitHubDesktop\bin;C:\Users\Benjamin\AppData\Roaming\npm;C:\Exercism;C:\Users\Benjamin\AppData\Local\atom\bin;C:\Users\Benjamin\AppData\Local\Microsoft\WindowsApps 9 verbose lifecycle habitica-chat-extension@2.2.1~build: CWD: C:\Users\Benjamin\Downloads\habitica-chat-extension-browserify 10 silly lifecycle habitica-chat-extension@2.2.1~build: Args: [ '/d /s /c', 10 silly lifecycle 'npm-run-all --parallel build:chrome build:firefox' ] 11 silly lifecycle habitica-chat-extension@2.2.1~build: Returned: code: 1 signal: null 12 info lifecycle habitica-chat-extension@2.2.1~build: Failed to exec build script 13 verbose stack Error: habitica-chat-extension@2.2.1 build: npm-run-all --parallel build:chrome build:firefox 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (C:\Users\Benjamin\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at EventEmitter.emit (events.js:214:7) 13 verbose stack at ChildProcess. (C:\Users\Benjamin\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at ChildProcess.emit (events.js:214:7) 13 verbose stack at maybeClose (internal/child_process.js:915:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 14 verbose pkgid habitica-chat-extension@2.2.1 15 verbose cwd C:\Users\Benjamin\Downloads\habitica-chat-extension-browserify 16 verbose Windows_NT 10.0.18362 17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\Benjamin\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "build" 18 verbose node v8.12.0 19 verbose npm v6.9.2 20 error code ELIFECYCLE 21 error errno 1 22 error habitica-chat-extension@2.2.1 build: npm-run-all --parallel build:chrome build:firefox 22 error Exit status 1 23 error Failed at the habitica-chat-extension@2.2.1 build script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]



I seem to be having the same issues as @cTheDragons is. Now, I'm neither a node.js expert, and I haven't used Browserify before, but it definitely seems to have a problem with trying to build the firefox extension. I'm not sure what this problem is, but there is definitely not an npm error (as stated on line 23 of the debug log) but either a Browserify error or an error with our code's compatibility with Browserify. I'm not sure which, but I'm inclined to lean towards the latter.

I hope this helps!
crookedneighbor commented 5 years ago

Mostly i haven’t had a chance to update this to make it compatible with a windows environment.

It’s going to be a while before I can devote any time to this, so either someone else needs to pick it up, or go with an alternate solution.

crookedneighbor commented 4 years ago

Closing this as I haven't had a chance to work on it and it's waaaay out of date now.