Support for all template URL syntax as spec’d in https://our.status.im/embark-3-2-much-more-than-a-moonshot/ (Everyone Gets A Template section).
Unit tests were added for all missing cases.
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 1a. Normal React template, no URL | `embark new 1-normal-template-react --template react` | No | see below |
```
Installing template from https://github.com/embark-framework/embark-react-template/tree/4.0
Downloading template...
Download failed, response code 404
Retrying with the default branch...
It may not be compatible with your Embark version 4.0.0-alpha.2
Installing template from https://github.com/embark-framework/embark-react-template
Downloading template...
Download failed, response code 404
Does the template really exist?
Embark's supported templates: https://embark.status.im/templates/
```
**Failure reason**: https://github.com/embark-framework/embark-react-template repo doesn't exist
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 1b. Normal TypeScript template, no URL | `embark new 1-normal-template-typescript --template typescript` | Yes | see below |
```
Installing template from https://github.com/embark-framework/embark-typescript-template/tree/4.0
Downloading template...
Download failed, response code 404
Retrying with the default branch...
It may not be compatible with your Embark version 4.0.0-alpha.2
Installing template from https://github.com/embark-framework/embark-typescript-template
Downloading template...
Installing packages...
Init complete
App ready at 1-normal-template-typescript
```
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 1c. Normal Vyper template, no URL | `embark new 1-normal-template-vyper --template vyper` | Yes |see below |
```
Installing template from https://github.com/embark-framework/embark-vyper-template/tree/4.0
Downloading template...
Download failed, response code 404
Retrying with the default branch...
It may not be compatible with your Embark version 4.0.0-alpha.2
Installing template from https://github.com/embark-framework/embark-vyper-template
Downloading template...
Installing packages...
Init complete
App ready at 1-normal-template-vyper
```
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 1d. Normal Vue.js template, no URL | `embark new 1-normal-template-vue --template vue` | Yes |see below|
```
Installing template from https://github.com/embark-framework/embark-vue-template/tree/4.0
Downloading template...
Download failed, response code 404
Retrying with the default branch...
It may not be compatible with your Embark version 4.0.0-alpha.2
Installing template from https://github.com/embark-framework/embark-vue-template
Downloading template...
Installing packages...
Init complete
App ready at 1-normal-template-vue
```
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 1e. Normal Bamboo template, no URL | `embark new 1-normal-template-bamboo --template bamboo` | Yes |see below|
```
Installing template from https://github.com/embark-framework/embark-bamboo-template/tree/4.0
Downloading template...
Download failed, response code 404
Retrying with the default branch...
It may not be compatible with your Embark version 4.0.0-alpha.2
Installing template from https://github.com/embark-framework/embark-bamboo-template
Downloading template...
Installing packages...
Init complete
App ready at 1-normal-template-bamboo
```
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 2. Github repo download | `embark new 2-github-repo --template status-im/dreddit-devcon` | Yes |see below|
```
Installing template from https://github.com/status-im/dreddit-devcon
Downloading template...
Installing packages...
Init complete
App ready at 2-github-repo
```
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 3a. Github template with non-existant branch | `embark new 3-github-branch --template status-im/dreddit-devcon#start-here` | Yes |
```
Installing template from https://github.com/status-im/dreddit-devcon/tree/start-here
Downloading template...
Download failed, response code 404
Does the template really exist?
```
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 3b. Github template with other branch | `embark new 3-github-branch --template status-im/dreddit-devcon#start` | Yes |see below|
```
Installing template from https://github.com/status-im/dreddit-devcon/tree/start
Downloading template...
Installing packages...
Init complete
App ready at 3-github-branch
```
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 4. Github download with git url | `embark new 4-github-git-url --template git@github.com/status-im/dreddit-devcon` | No |see below|
```
Unsupported template name or git host URL
```
**Failure reason:** Incorrect syntax. Repo owner need to postfix the host, ie `git@github.com:status-im/dreddit-devcon`. Fixed in this PR.
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 5. Github download with https url | `embark new 5-github-https-url --template https://github.com/status-im/dappcon-workshop-dapp` | Yes |see below|
```
Installing template from https://github.com/status-im/dappcon-workshop-dapp
Downloading template...
Installing packages...
Init complete
App ready at 5-github-https-url
```
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 6. Github download with no protocol | `embark new 6-github-url-no-protocol --template github.com/status-im/dappcon-workshop-dapp` | No |see below|
```
Unsupported template name or git host URL
```
**Failure reason:** Incorrect syntax. Can remove the github host, ie `status-im/dappcon-workshop-dapp`. Fixed in this PR.
| Test case | Command | Successful? | Output |
| :----------------------------------------- | :--------------------------------------------------------- | :---: | :-------- |
| 7. Github repo with no branch, and a default branch that is not `master` | `embark new 7-github-default-branch-not-master --template status-im/dreddit-devcon` | Yes |see below|
```
Installing template from https://github.com/status-im/dreddit-devcon
Downloading template...
Installing packages...
Init complete
App ready at 7-github-default-branch-not-master
```
Update replacements for less variance
Update URL replacements for less result variance if the `hosted-git-info` library were to change it’s functionality.
Move replacements to a constant.
Add unit test for additional `bitbucket.org/gitlab.com` URL shortcuts.
The demo scripts in `src/test/cli_shim`, while very useful when developing the
shim, were never fully completed and are not part of embark's CI, so remove
them. A future cross-platform test suite of the shim should be written in the
usual way (with TS/JS) instead of using bash scripts running in a Docker
container.
`waitForWeb3Ready` was never making it to the point it sets
`this.web3Ready = true` and invokes its callback because once the provider's
connection's `readyState` is `3` ("closed or couldn't be opened") there is no
possibility it will change to `1` ("open and ready").
Call the `connectToProvider` method before setting up a retry with `setTimeout`
so that a new instance of `Web3.providers.WebsocketProvider` is used on each
retry.
This PR replaces #1166. The "stuck sockets" bug is addressed in #1195 so there
is no longer a need to use timeouts. However a few aspects of the original PR
are still useful, and lessons learned from #1166, #1181, and #1195 can be put
to good use.
Use a websocket client from the `ws` package when pinging websocket endpoints
instead of manually building a request header. The `'upgrade'` event being
listened for was never actually firing; and though a response was received for
those pings, the response messages indicated problems with those requests. It
seems cleaner to use a proper websocket client and callback success upon the
`ws` client's `'open'` event.
Abstract error and success handling across websocket and http pings.
Report network errors other than `ECONNREFUSED`. Only `ECONNREFUSED` is
expected, as that genuinely indicates an endpoint isn't accepting connections
at the specified host and port. If other kinds of network errors are occurring,
it will be helpful to have a visual indicator to prompt investigation.
After success or the first error, cleanup the ping's request/connection
immediately since we're not awaiting `'data'` events on an http request and we
don't want to leave a websocket connection open. Don't callback any `'error'`
events that might fire after the first `'error'` event or a success event, but
do report them.
The problems described in embark PR #1166 can be resolved by implementing the
blockchain proxy with `http-proxy` directly instead of using `express` together
with `http-proxy-middleware`. The ultimate cause of the buggy behavior (the
"stuck sockets" problems described in #1166) is unknown.
The need to swallow some errors as described in embark PR #1181 is also
eliminated by dropping `http-proxy-middleware` and `express`.
In 1461e95c39 we've introduced a guard that ensures whisper isn't crashing
when Embark is used with the Simulator. This unfortunately also introduced
code that tries to connect to an existing websocket provider that isn't actually
ready at the time it tries to connect.
This commit ensures `web3.shh.getInfo()` is only called once `web3` is ready
and therefore the WS connection as well.
For reasons unknown, `ECONNRESET` errors on websocket connections to embark's
blockchain proxy are not automatically handled on Windows as they are on macOS
and Linux (or those errors aren't happening on those platforms, it's difficult
to determine). Explicitly swallow such errors so the blockchain process doesn't
crash. Prior to this PR, the crash-behavior can be reproduced on Windows by
running `embark blockchain` and `embark run` in separate terminals and quitting
`embark run` while `embark blockchain` is still running.
Consistently use the `simples` package's `WsParser` to process websocket
traffic instead of using `WsParser` for requests and the `ws` package's
`Websocket.Receiver` for responses.
Consistently use `pump` to connect parser streams instead of using `pump` in
some places and `chain` in others. Drop use of `cloneable` (and the package
dependency) since it was used previously in hopes it would fix the errors, but
it's unnecessary and didn't fix them.