Commit Graph

503 Commits

Author SHA1 Message Date
Jonathan Rainville 71da423e4e fix(cockpit/console): increase number of suggestions 2019-03-13 10:21:01 -04:00
Jonathan Rainville 54698ccf53 fix(embark/dashboard): show command in the dashboard 2019-03-13 10:20:41 -04:00
emizzle 6f5efb16a6 fix(@embark/storage): Storage processes race conditions
Previously, storage providers in embarkjs were not waiting for their respective storage process (ipfs and swarm) to start before running `registerProvider` and `setProvider` in the console.

This PR forces the `registerProvider` and `setProviders` from running in the console until the storage processes have loaded. As a side effect, the code generation of `EmbarkJS` must wait for the storage module ot be fully initiated (ie once the processes have launched and the `registerProvider` and `setProviders` have been run) before generating the code.

This fixes errors pertaining to `Could not connect to a storage provider using any of the dappConnections in the storage config` as these errors were typically caused by `setProviders` being called before the storage processes had fully launched.
2019-03-13 10:15:52 -04:00
Jonathan Rainville be3817821d fix(cockpit/dashboard): fix logs not in cockpit with dashboard 2019-03-13 09:46:12 -04:00
Pascal Precht 20d3acb8b1 uiux(@embark/authenticator): Change web backend to Cockpit 2019-03-12 09:17:43 -04:00
Michael Bradley, Jr 5418f16082 feat: normalize README and package.json bugs, homepage, description
Make changes by running these commands in the root of the monorepo:

**bugs**
```shell
npx lerna exec --concurrency 1 --stream -- \
    'DIRPATH=$(realpath $PWD --relative-to=$LERNA_ROOT_PATH); \
    npx json -I -f package.json -e "this.bugs=\
        \"https://github.com/embark-framework/embark/issues\""'
```

**homepage**
```shell
npx lerna exec --concurrency 1 --stream -- \
    'DIRPATH=$(realpath $PWD --relative-to=$LERNA_ROOT_PATH); \
    npx json -I -f package.json -e "this.homepage=\
        \"https://github.com/embark-framework/embark/tree/master/${DIRPATH}#readme\""'
```

Don't commit changes to private packages, with the exceptions of embark-typings
and embark-reset because those may switch from private to public, and also
because the latter will be included in `node_modules` of embark even if it is
private since embark-reset is presently a bundled dependency of embark.

Don't include the homepage and bugs fields in dapps generated from the template
packages, except for the demo. Set those dapps' description field to an empty
string.

Ensure every package (inc. private packages) has a description.

Ensure every package (inc. private packages) has a README that begins with:

```markdown
`[pkgJson.name]`
================

> [pkgJson.description]

Visit [embark.status.im](https://embark.status.im/) to get started with
[Embark](https://github.com/embark-framework/embark).
```

Don't include the README in dapps generated from the template packages, except
for the demo.
2019-03-12 09:17:33 -04:00
emizzle 3aafde3335 fix(@embark/pipeline): Prevent crash when assets not specified
Prevent embark from crashing when app assets are not specified in `embark.json`.

Previously, if the `app` property of `embark.json` was missing, embark would crash with the error `TypeError: Cannot convert undefined or null to object`.

With this PR, the missing property is null-checked.
2019-03-12 07:55:01 -04:00
emizzle 5ea4807c90 feat(@embark/pipeline): Add `enabled` property to pipeline config
Add an `enabled` property to the pipeline config. This lets developers disable the pipeline using the config file.

Updates to the enabled property will be reflected while embark is running. For example if embark is running with the pipeline, setting `enabled: false` in the pipeline config will build/deploy the contracts but not run the pipeline. Conversely, if embark is running with the pipeline disabled, enabling the pipeline in the config will build/deploy the contracts then build the dapp.
2019-03-12 07:53:04 -04:00
Michael Bradley, Jr df0064f1a9 build: use package.json "files" instead of .npmignore
`package.json` allows for a [`"files"` whitelist][files] to be specified as an
alternative to a top-level `.npmignore` within a package root. Maintaining
whitelists is generally easier and less error-prone than maintaining
blacklists, so implement a `"files"` list for all non-private packages in the
monorepo and remove unneeded `.npmignore` files.

Switch `embark-reset` from being a private package to one that will be
published, adjust the workspace's `"nohoist"` setting accordingly, and no
longer specify `embark-reset` as a bundled dependency of `packages/embark`. I
originally thought there might be a good reason not to publish it, but I no
longer think so.

Remove unnecessary LICENSE files in `packages/{embark,embark-ui}` since Lerna
will automatically copy the root LICENSE into any packages lacking that file,
i.e. before tarballs are packed and published to the NPM registry.

Change the `"author"` field of `packages/embarkjs-connector-web3` to match the
other packages, i.e. such that it matches the copyright assignment in the root
LICENSE. If that's not a desirable thing to do, then instead that package can
have a separate LICENSE file that has a copyright assignment for `"Jonathan
Rainville"`.

Supply some missing `.npmrc` files in `packages/*`.

[files]: https://docs.npmjs.com/files/package.json#files
2019-03-12 07:50:25 -04:00
Andre Medeiros 0b530f308b fix: node_modules should be part of hidden files 2019-03-12 07:48:20 -04:00
Jonathan Rainville 88a41e7c28 fix(embark/logger): fix logs in the dashboard
they were displaying the color as text instead of as a color
2019-03-11 18:32:48 -04:00
Jonathan Rainville cba7c85242 fix(cockpit/transactions): fix a typo in the transactions page 2019-03-11 18:28:19 -04:00
Jonathan Rainville 74847ee323 feat(cockpit/transaction): display a link for contracts and accounts 2019-03-11 18:28:19 -04:00
emizzle 236f6e63e2 fix(@embark/core): Re-enable regular txs commands/api
https://github.com/embark-framework/embark/pull/1367 introduced a change that prevented the `blockchain_listener` from listening to logs until the IPC server connected. However, the restriction went too far, and included restricting registration of console commands and API endpoints for the regular transactions feature.

This fix reverts the changes that affect registration of regular txs endpoints and console commands.
2019-03-11 18:26:30 -04:00
Michael Bradley, Jr d61dc6ec2f refactor(embark): do not wrap mocha in a child process
It's possible to pass a `--require` option to mocha to load a script that sets
up `process.env.DAPP_PATH` as needed for embark's tests; that approach is
preferable to running mocha in a child process because when running in a child
process there seemed to be problems with sources maps and with VS Code's
debugger.

After the changes in this PR, the following works as expected, i.e. when there
are runtime errors line/col numbers are reported per the files in `src/`:

```
$ yarn build:no-ui
$ cd packages/embark
$ npx mocha "dist/test/**/*.js" \
            --exit \
            --no-timeouts \
            --require ./scripts/test.js \
            --require source-map-support/register
```

And the following VS Code launch config works well for me:

```json
{
  "type": "node",
  "request": "launch",
  "name": "test - packages/embark",
  "cwd": "${workspaceFolder}/packages/embark",
  "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
  "args": [
    "'dist/test/**/*.js'",
    "--exit",
    "--no-timeouts",
    "--require",
    "./scripts/test.js",
    "--require",
    "source-map-support/register"
  ],
  "autoAttachChildProcesses": true,
  "sourceMaps": true
}
```

NOTE for VS Code users: I found it's important to specify
`"'dist/test/**/*.js'"` in the launch config instead of
`"\"dist/test/**/*.js\""`, and that it's important to specify `"program":
"${workspaceFolder}/node_modules/mocha/bin/_mocha"` vs. `"program":
"${workspaceFolder}/packages/embark/node_modules/.bin/mocha"`.

KNOWN ISSUES: when there are runtime errors during `yarn test` in
`packages/embark`, line/col numbers reflect the sources in
`package/embark/dist` because `nyc` isn't setup correctly to use the
source-maps generated by babel. A solution has not yet been found.
2019-03-11 18:25:47 -04:00
Jonathan Rainville 99dcd785bc fix(cockpit/contract): remove contract profiling and use functions 2019-03-11 18:21:54 -04:00
Michael Bradley, Jr a9c5e1ade5 feat: add repository.directory field to package.json
See: https://github.com/npm/rfcs/blob/latest/implemented/0010-monorepo-subdirectory-declaration.md

Make changes by running this command in the root of the monorepo:

```shell
npx lerna exec --concurrency 1 --stream -- \
    'DIRPATH=$(realpath $PWD --relative-to=$LERNA_ROOT_PATH); \
    npx json -I -f package.json -e \
    "this.repository=\
        {\"directory\": \"$DIRPATH\", \
         \"type\": \"git\", \
         \"url\": \"https://github.com/embark-framework/embark.git\"}"'
```

Don't commit changes to private packages, with the exceptions of embark-typings
and embark-reset because those may switch from private to public, and also
because the latter will be included in `node_modules` of embark even if it is
private since embark-reset is presently a bundled dependency of embark.

Don't include the repository field in dapps generated from the template
packages, except for the demo.
2019-03-11 18:21:24 -04:00
Andre Medeiros f12ca22edb fix: limit cockpit editor file size 2019-03-11 18:20:56 -04:00
Andre Medeiros 616af6d765 fix: validate whisper channel name in communication tab 2019-03-11 18:19:00 -04:00
Andre Medeiros 4340a9b482 fix: editor wasn't saving changes 2019-03-11 18:18:52 -04:00
emizzle a6b15ae98f fix(@embark/cockpit): Switching between tabs resets logs
Switching between the two tabs shown on the Dashboard for the cockpit was removing some of the logs that were previously displayed. This was due to an overlap in `id`’s being assigned to the logs from different processes.

To alleviate this, the reducers has been updated to not only check `id` but also `process.name`.

Additionally, the reducer was updated so that the number of logs for **each process** is set to `ELEMENTS_LIMIT`. For example, our `ELEMENT_LIMIT` is currently set to `200` and it would have meant that the total number of process logs across all processes would have been capped at 200. The current changes in this PR allow for 400 total logs, given that we have two processes being monitored for logs.
2019-03-11 17:39:05 -04:00
emizzle 128ecd4c51 fix(@embark/core): Prevent unnecessary re-renderings
The services websocket was initiated in the AppContainer and causing all child components to continuously re-render every time there was a service check (which is effectively every second). In addition, the socket was never stopped when not needed (ie when the services component was unmounted).

Create a ServicesContainer that initiates the websocket as part of the container, and stops the socket when the container is unmounted.

Move the ContractsList to be part of the ContractsContainer with a `mode` switch.

Add Deployment page title and description.
2019-03-11 17:38:33 -04:00
Jonathan Rainville cc495c5cab hotfix(cockpit/editor): remove test alert 2019-03-11 16:00:26 -04:00
Jonathan Rainville c30c420ae8 fix(cockpit/editor): remove delay on tooltips
This caused issues when moving from one tooltip to the other
2019-03-11 09:05:49 -04:00
Jonathan Rainville 7720eac74f codacy fix 2019-03-11 09:05:15 -04:00
Jonathan Rainville ecdfd473df feat(cockpit/editor): add status messages for file operations 2019-03-11 09:05:15 -04:00
Jonathan Rainville 3f488e1d88 fix(cockpit/editor): add delete modal to confirm deletion
Also fix cases where modals closed for no reason
2019-03-11 09:04:45 -04:00
emizzle 563ba154a3 fix(@embark/tests): Make `web3` available in test descriptions
Previous to this PR, `web3` was only made available to each test case, as it was put in to the global namespace after each test deploy. This was causing issues for tests that use `web3` in the test description (ie in `describe()` or `contract()` functions), as the deploy had not happened yet, and thus `web3` was not yet available. The error encountered in these cases was `web3 is not defined`.

This PR puts `web3` in the global namespace before setting up the tests, making it available to test descriptions.
2019-03-11 12:15:45 +11:00
Jonathan Rainville da76c8d804 fix(cockpit/deployment): filter out silent contracts 2019-03-08 12:55:58 -05:00
Jonathan Rainville 0648824646 fix(cockpit/header): fix nav not highlighted for children pages 2019-03-08 12:55:05 -05:00
Jonathan Rainville 35648eefa0 fix(cockpit): fix converter inputs and copy-button position 2019-03-08 12:55:05 -05:00
Jonathan Rainville 359c28f5b5 fix(cockpit:editor): fix arrow not turning 2019-03-08 09:26:13 -05:00
Jonathan Rainville fac29e1601 revert console to only show cockpit results in cockpit 2019-03-08 08:54:30 -05:00
Jonathan Rainville 6662731898 fix(logger): filter undefined and null out of logs 2019-03-08 08:54:30 -05:00
Jonathan Rainville 32e8bd2ee1 fix(console/logger): fix console and logger not outputting objects
Also makes the logger smarter by stringifying objects
And revert repl changes
2019-03-08 08:54:30 -05:00
Jonathan Rainville e20c08ac6f fix(console): fix ENS tests not working with embark side by side 2019-03-08 08:54:30 -05:00
emizzle 9ea0383046 fix(@embark/storage): Allow upload when storage disabled
Allow `embark upload` to upload to IPFS/Swarm even if the storage module is disabled in the storage config.

An easy way to test this is to set `config/storage.js` > `enabled` to `false` in the demo. Then run `embark upload`.
2019-03-08 12:43:00 +11:00
emizzle c233dbc7fb fix(@embark/core): Metamask + geth warning to enable regular txs
A console warning is meant to appear in the browser console when the dapp is connecting to web3 using metamask and the blockchain client is geth. The warning displays information telling the user they should enable regular transactions to prevent known issues regarding transactions getting stuck.

The issue fixed here pertained to `warnAboutMetamask` vs `warnIfMetamask` - maybe there was a change that introduced this issue upstream.

Additionally, enabling and disabling of regular transactions via an API endpoint did not

Add ability to stop regular txs via query string, and validate request parameters.
2019-03-08 12:41:13 +11:00
Jonathan Rainville 0e63d6bcf9 feat(cockpit/contracts): don't display contracts marked as silent 2019-03-05 16:21:39 -05:00
Jonathan Rainville d80641c4e1 fix(ens/logger): add ens contracts to contract manager before deploy 2019-03-05 16:21:39 -05:00
André Medeiros 58ab76d2ca
fix: format \n as <br> in cockpit console (#1385) 2019-03-05 14:29:57 -05:00
André Medeiros 913b4e1817
fix: upgrade packages with vulnerabilities (#1388) 2019-03-05 14:29:36 -05:00
Michael Bradley, Jr eb1b6933af fix: revise test urls to reflect test_dapps/ -> dapps/tests/ 2019-03-05 13:26:38 -06:00
André Medeiros 73a06725ac
fix: don't eval function calls for suggestions (#1382) 2019-03-05 14:26:08 -05:00
André Medeiros 78201ce9df
fix: prevent HTML injection in the cockpit (#1381) 2019-03-05 14:14:58 -05:00
André Medeiros 41256cfb00
fix: blockchain logs show in cockpit (#1367) 2019-03-05 14:14:41 -05:00
André Medeiros 891174eda3
fix: cockpit search with tx hash shows tx page (#1386)
This issue was caused by a string to integer conversion. In JavaScript,
when converting a string that starts with `0` (which is the case for tx
hashes) to an integer using `parseInt` it will always yield 0. That,
combined with a block with number 0 would always return a block result
instead of the transaction.

```
> parseInt("0xluri", 10)
0
```

This PR checks if the resulting number equals the string that was
provided on top of checking for the block number.
2019-03-05 14:14:05 -05:00
Michael Bradley, Jr de0f02d00a build: make DApp templates member packages of the monorepo
Previously, templates were in a subdirectory of `packages/embark`. Reorganize
them so that they are member packages of the monorepo. This allows them to
cleanly depend on other members of the monorepo,
e.g. `embarkjs-connector-web3`.

It is desirable for the templates, in the context of the monorepo, to specify
embark as a dependency, to take advantage of `npx embark test` (and it's a
"forward looking" setup re: how we plan to evolve embark). However, if embark
were to specify the template packages as dependencies a circular relationship
would be introduced, which is [unsupported by Lerna][circular]. Therefore,
revise the template generator so that all templates are resolved / fetched at
runtime, i.e. `boilerplate`, `demo`, and `simple` are no longer
"built-ins" *per se*. This change won't be apparent to embark's users, but it
does mean that the template generator won't work (in a production install of
embark) if it can't connect to the npm registry, i.e. when the user runs
`embark demo` or `embark new [--simple]`. When embark is inside the monorepo,
templates are resolved and copied from the yarn workspace rather than being
fetched from the registry, which is convenient for development. Also, any
template dependencies that are members of the monorepo are linked into the
copied template's `node_modules` rather than being installed from the registry,
again for convenience. During template generation, remove scripts and
dependencies that pertain only to membership in the monorepo; for now, that
involves removing embark as a dependency since we're not quite ready for that
arrangement to be the default, i.e. outside of the monorepo.

Refactor the root scripts so that more of them can consistently be used with
Lerna's filter options, e.g. `--scope` and `--ignore`. "Combo" scripts that
don't support filtering generally have a `:full` postfix.

Flip `clean` and `reset` scripts at the root and in the member packages for
consistency re: Lerna's notion of `clean` and embark's notion of `reset`. Have
each package run its `reset` script when its `clean` script is invoked (and
that's all for now), relying on `lerna clean` to delete packages'
`node_modules` in view of how Lerna's topological sorting works.

Lift the implementation of `embark reset` into a private package in
`packages/embark-reset` and make it a bundled dependency of embark. Packages in
`dapps/*` depend on `embark-reset` directly and make use of it with `npx
embark-reset` (but only in monorepo context). This removes a "wart" where
reboots could show errors when embark's sources aren't already built in
`packages/embark/dist`. Users will not notice any difference since `embark
reset` works as before, transparently making use of the `embark-reset`
package. The only downside to having it be a bundled dependency of embark is
that bundled deps have all of their `node_modules` included in the tarball
built with `npm pack` (that's why having the templates as bundled dependencies
of embark isn't a viable approach). However, `embark-reset` only has one
dependency, `rimraf`, which is a tiny module, so the cost seems acceptable.

As part of the reorganization, move `test_dapps` into `dapps/tests` and
`packages/embark/templates` into `dapps/templates`. Keep the directory names
short but revise the package names to facilitate simple filtering with
`embark-dapp-*`. Consolidate `.yarnrc` and `.gitignore` and clean up some
redundant ignore listings.

Scripts run with `--scope embark-dapp-*` use `--concurrency=1` to avoid
conflicts that could arise over network ports. The `ci:full` and `qa:full`
scripts use `--concurrency=1` in all scopes, for two reasons: resource
limitations on Travis and AppVeyor result in slower runs with concurrency >1,
and if something fails in those contexts it's easier to see what went wrong
when Lerna's output isn't interleaved from a bunch of scripts in `packages/*`.

Bump the Lerna version.

[circular]: https://github.com/lerna/lerna/issues/1198#issuecomment-442278902
2019-03-05 10:20:57 -06:00
emizzle f957ba55dd fix(@embark/cockpit): Fix decode transaction error
Reproduce:
1. Go to cockpit > transactions
2. Click a transaction
3. There will be a flicker of an error, then the decoded tx displays OK. Inspecting the network requests, there is a 500 error with a response of
```
AssertionError [ERR_ASSERTION]: invalid remainder
```
This error is also printed in the console.

The issue is that the transaction is not a raw transaction, so instead of trying to decode the non-raw transaction, the transaction can be decoded by web3.
2019-03-05 12:01:07 +11:00
emizzle 9bd33a9de5 feature(@embark/console): Suggestions improvements
**Cache suggestions**
Suggestions are cached for better performance on each request. When contracts are deployed, the suggestion cache is cleared, allowing for updated contract methods to be built in to the suggestions.

** Handle edge cases **
Handle cases when console command is parsed as an empty string, or possibly returns an empty object, which would cause `Object.getOwnPropertyNames` to throw an error (that is ultimately swallowed).
2019-03-05 08:56:15 +11:00
emizzle 14323f5430 fix(@embark/swarm): Fix swarm not being registered
Swarm was not being registered as a service due to a recent change that introduced a bug. The previous change was meant to register “swarm” as a console command to provide output for the `swarm` console command when swarm had not been registered in the VM. The bug, however, returned too early in the cases when swarm was meant to be enabled, thus effectively not registering the entire process.

The fix simply returns only when swarm is in fact, disabled, and also alters slightly the way swarm is determined to be enabled (the changes of which have been copied over to `ipfs`).
2019-03-05 08:19:48 +11:00
emizzle 9fad77715b fix(@embark/core): Allow errors in event actions
Add the ability to pass an error in the callback of an event action.

Currently, event actions could either pass back a an error OR a result, but not both, and with no way to distinguish between the two parameters. This PR adds the ability to pass an error as the first parameter of the action callback.

An example of a use case that this fixed: errors on `deployIf` were silently swallowed, which has now been fixed.

All instances of `events.request(“deploy:contracts”)` were given an `error` parameter in their callback, and errors printed if it is not undefined.

All instances of `registerActionForEvent` were combed to ensure any callbacks were passing the expected error and result.
2019-03-04 12:35:35 +11:00
Jonathan Rainville 0639717d0c fix(blockchain): check if node is synched after connection 2019-03-01 11:04:14 -05:00
Jonathan Rainville 217357640a feat(test/reporter): only show tx details on option 2019-03-01 10:58:57 -05:00
Jonathan Rainville 87d92b6091 feat(test/reporter): log tx functions during tests
Extract function log function to utils to use in the reporter
  to show txs in tests
2019-03-01 10:58:57 -05:00
emizzle 89753c11e3 feature(@embark/cockpit): Add contract state changes to cockpit
Add contract state changes to the cockpit by sending contract state updates via the websocket.
2019-02-28 16:37:19 +11:00
emizzle bb86b605de fix(@embark/core): `web3.eth.getAccounts` returning empty
`web3.eth.getAccounts` was returning an empty array in the console due to a change, that I’m unsure of what the original intention was for.

@andremederios, could you please take a look, and let me know if this breaks the intention of the original changes?
2019-02-28 16:36:11 +11:00
emizzle a67a4ad96e fix(@embark/cockpit): Fix whisper messages not being received
Cockpit whisper messages were not being subscribed to due to a inocuous bug that would swallow errors and ultimately not be subscribed to the `rxjs` observer.
2019-02-27 14:51:24 +11:00
Jonathan Rainville c708bad8bb chore(cockpit/estimator): always return an integer for getGasPrice 2019-02-26 13:01:50 -05:00
Jonathan Rainville 1759aac8aa fix(cockpit/estimator): make estimator clearer 2019-02-26 13:01:50 -05:00
Jonathan Rainville 57cd6d3da1 feat(console): print console results as log so cockpit gets it 2019-02-26 12:55:58 -05:00
Jonathan Rainville e3396417da feat(cockpit/console): display cmds from cockpit in embark console 2019-02-26 12:55:58 -05:00
Anthony Laibe 46221a3bc0 feat(coverage): load contracts from plugin 2019-02-26 14:37:58 +00:00
Anthony Laibe f5f610d520 fix(embark-ui): pagination 2019-02-26 14:37:58 +00:00
Anthony Laibe 24a6a4701f fix: handle the case where account is an object 2019-02-26 14:37:58 +00:00
Anthony Laibe 7d5935dc0b fix: fetch accounts 2019-02-26 14:37:58 +00:00
Anthony Laibe 90adaab523 fix(solidity): make original really original 2019-02-26 14:36:37 +00:00
Iuri Matias 476fc246dd bug fix (@embark/embark) display better error message when an account is defined but invalid 2019-02-25 15:15:34 -05:00
Jonathan Rainville 7fffc442d4 fix(build): start code-generator service even for contracts only 2019-02-25 15:08:44 -05:00
Jonathan Rainville ed77fc7287 fix(blockchain-process): display error message when bad port 2019-02-25 15:08:10 -05:00
emizzle 0eaad43e4d fix(@embark/cockpit): Fix cockpit not suggesting console commands
This PR fixes a number of issues relating to the cockpit console.

#### Console commands display in cockpit console
Fix cockpit console not displaying console usage commands that included “<usage option>”. For example “resolve <name>” would not display the “<name>” part, as it was attempting to write this in as HTML (ansi-to-html conversion).

This was fixed by replacing any instances of “<usage>” with “[usage]”. Please note that future usage strings should not contain text wrapped in “<>”.

#### Autosuggestions for “web.eth.” not appearing
Fix “web3.eth.” not suggesting members of `web3.eth`. This was due to a `Object.keys(web3.eth)` throwing `'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property 'defaultAccount' that is incompatible with the existing property in the proxy target` in the console. Changing `Object.keys` to `Object.getOwnPropertyDescriptor` solved the problem.

#### Fix autosuggestion of known console commands (ie from plugins)
Fix known console commands (ie from  plugins) not being autosuggested. For example, typing “web”, should autosuggest `webserver start/stop`,  `log webserver on`, and `log webserver off`.

This PR adds in support for registered console commands (from plugins).
2019-02-25 15:06:23 -05:00
Andre Medeiros a295a5bff5 fix: contract length check now checks the correct thing 2019-02-25 15:05:05 -05:00
Iuri Matias 10f6b6bcdb chore (@embark/templates) add missing flags to genesis.json files in the templates 2019-02-25 15:03:57 -05:00
Iuri Matias 017ec59b23 chore (@embark/embark-ui) clarify token login in cockpit 2019-02-25 15:03:46 -05:00
Iuri Matias 5bb0d7ceae chore (@embark/embark-ui) clarify placeholders in ens utils 2019-02-25 15:03:46 -05:00
Jonathan Rainville a84dd01eba change port for API 2019-02-25 15:00:35 -05:00
Jonathan Rainville a62d03dc7e rename to embarkjs-connector-web3 2019-02-25 15:00:35 -05:00
Jonathan Rainville 4eee4dfc65 chore(templates): replace blockchain.connect by onReady 2019-02-25 15:00:35 -05:00
Jonathan Rainville 7eceaf6c0a feat(web3-connector): convert web3connector to class and add connect 2019-02-25 15:00:35 -05:00
Jonathan Rainville a0d336e49e fix(embarkjs/blockchain): only call doFirst once on connect 2019-02-25 15:00:35 -05:00
Jonathan Rainville 5ab3e46947 feat(plugins): enable external plugin to be classes 2019-02-25 15:00:35 -05:00
Jonathan Rainville c9e6da9377 chore: rename web3connector to embarkjs-web3-connector 2019-02-25 15:00:35 -05:00
Iuri Matias c099be6172 chore (@embark/embark) rename service name from api to cockpit so it's clearer where cockpit is running 2019-02-25 15:00:02 -05:00
Andre Medeiros 576836df87 fix: use right accounts for contract deployment 2019-02-25 14:59:08 -05:00
Jonathan Rainville b5a3897795 fix(contracts): fix contracts being instanceOf a contract with libs 2019-02-22 11:33:37 -05:00
Jonathan Rainville dd14262108 fix(contractsConfig): fix using ints as gas and gasPrice 2019-02-22 11:33:37 -05:00
Jonathan Rainville a895e839fa fix(contract-artifacts): set address as deployedAddress on artifacts 2019-02-22 11:33:37 -05:00
Jonathan Rainville 0b77710003 chore(templates): fix typo in explicit 2019-02-22 11:33:30 -05:00
Jonathan Rainville fc113e8b2d fix(pipeline): fix contract magic imports 2019-02-22 11:33:30 -05:00
emizzle 0d72ebeda8 fix(@embark/storage): Fix storage not connecting error
In addition to `EmbarkJS.Storage` not being available in the console (ie `await EmbarkJS.Storage.isAvailable() alway returned false), the error `Could not connect to a storage provider using any of the dappConnections in the storage config` would always appear in the console. The storage operations in the dapps were working OK.

The fix to this was three-fold:
1) Wait for the ipfs process to be started before attempting to run the `EmbarkJS.Storage.registerProvider/setProvider` in the console.
2) Wait for `EmbarkJS.Storage.registerProvider` to be called before `EmbarkJS.Storage.setProvider`. This was actually handled in the previous PR.
3) Remove any async operations from the `setProviders` method in the storage module. This was causing `callback is not defined` errors which were being swallowed and masqueraded as an unsuccessful attempt to connect to a `dappConnection` or `upload` config.
2019-02-22 10:38:50 +11:00
emizzle d378ccf150 feat(@embark/core): Auto generate EmbarkJS events
For every provider registered and set with EmbarkJS, auto generate events to inform other modules of the state of the provider.

Any provider that belongs to EmbarkJS (currently Blockchain, Names, Messages, and Storage) will have both a `runcode:<provider name>:providerRegistered` and a `runcode:<provider name>:providerSet` event created automatically when the `CodeRunner` is instantiated.

Once the `registerProvider` code is run through the VM, ie `EmbarkJS.Blockchain.registerProvider(…)`, the corresponding event will be fired, ie `runcode:blockchain:providerRegistered`.

Likewise, once the `setProvider` code is run through the VM, ie `EmbarkJS.Blockchain.setProvider(…)`, the corresponding event will be fired, ie `runcode:blockchain:providerSet`.

Additional updates/fixes with this PR:
* Move `CodeRunner` to TypeScript
* Fix console errors with ENS and Storage due to a recent PR that waits for `code-generator:ready`. The solution here was to ensure that `code-generator:ready` is requested, so that premature events can be handled.
2019-02-22 10:38:50 +11:00
emizzle 58ea3d9c30 fix(@embark/demo): Fix demo
Fix demo not running, by fixing the following issues:

This was due to the removal of `Web3` from the VM initialisation in a recent PR. The reasoning behind the removal was so that the modules that need Web3 could require it as needed, however, it is needed in 3 modules (ENS, Whisper, and web3Connector), all of which would define `const Web = …` in the code generated EmbarkJS, thus causing issues in itself. This needs to be rethought prior to removing it from the VM sandbox.

Because Web3 is back to being required in the global sandbox of the VM, it does not need to be registered in the `web3Connector` module, hence the removal of the `runcode:register`.

Module not found: Error: Can't resolve 'embarkArtifacts/contracts/SimpleStorage.js' in '/Users/emizzle/temp/embark_demo/app/components’`
This was fixed by replacing
```
import SimpleStorage from 'Embark/contracts/SimpleStorage';
```
with
```
import SimpleStorage from '../../embarkArtifacts/contracts/SimpleStorage';
```

revert changes changing __Web3 to Web3
2019-02-22 10:38:50 +11:00
Jonathan Rainville 5e9955e828 fix(coverage): fix coverage regex on Windows 2019-02-21 13:38:42 -05:00
Jonathan Rainville 84d4f3a252 fix(ens): fix ens transactions getting stuck
Only happened during tests connected to a WS node somehow
2019-02-21 13:38:42 -05:00
Jonathan Rainville e64ed36092 fix(test): fix tests getting stuck when embark is run next to it 2019-02-21 13:38:42 -05:00
Jonathan Rainville d33425fb4c fixes for the test_dapp to work 2019-02-21 12:00:10 -05:00
Jonathan Rainville e049b459c8 chore(templates): add web3connector plugin to templates 2019-02-21 12:00:10 -05:00
Andre Medeiros 1334900eae fix: log command in console 2019-02-21 11:59:59 -05:00
Jonathan Rainville ebcc3c4a8d feat: enable embark to be run with an external pipeline 2019-02-20 15:06:12 -05:00
Andre Medeiros c1d08c667a fix: specify full path for password files (geth) 2019-02-20 14:16:35 +01:00
Anthony Laibe e6eea1df06 fix(vyper): file path 2019-02-20 14:15:41 +01:00
Andre Medeiros 271a219c8b fix: template dependency errors don't exit 2019-02-20 14:15:03 +01:00
emizzle fc823bb7eb
fix(@embark/console): Fix console not working with VM2/monorepo
The console was not working correctly with the latest VM2/monorepo updates. This PR addresses namely fixes this problem, but also adds a few more notable changes:

* SIGNIFICANT improvement in loading time for `embark console` with an already running `embark run`. This is due to removing unneeded services starting, and instead forwarding user input to the main `embark run` process.
* All user input commands are now forwarded to the `embark run` process via IPC insteaad of evaluating the command in the `embark console` process.
* Removed IPC console history as it's no longer needed due to the above. Side effects:
  ** The signature of the `runcode:eval` and `runcode:register` events was changed to remove the `toRecord` parameter.
  ** Old `runcode:eval` signature: `events.request("runcode:eval", "code to be evaluated", (err, result) => {}, isNotUserInput, tolerateError)`
  ** New `runcode:eval` signature: `events.request("runcode:eval", "code to be evaluated", (err, result) => {}, tolerateError)`
  ** Old `runcode:register` signature: `events.request("runcode:register", "varName", variableValue, toRecord, (err, result) => {})`
  ** New `runcode:register` signature: `events.request("runcode:register", "varName", variableValue, (err, result) => {})`

* Removed unneeded `forceRegister` flag.
* Removed the `VM.getWeb3Config` method as it's no longer being used (EmbarkJS contracts are pulled out from the VM instead).
* Updated `web3Connector` `blockchain:connector:ready` to allow for event requests or event emissions.
* In the tests, removed the initial `initWeb3Provider` in the `init` as it was being called twice.
* In the tests, removed the `web3Connector` check message as the tests are now using the Console, and the console does this check. This was causing duplicate messages to be displayed in the output.
* Fix `web3 is not defined` browser error
2019-02-20 14:12:30 +01:00
emizzle 84ca98f962 feat(@embark/core): Add events oracle
Add the ability to request an event before it’s command handler has been set. Also, add the ability to emit an event before a listener has been set.

The most useful use case for this is to allow modules/plugins to load asynchronously and without need to know their load order beforehand. This let’s us request events in advance of having the event command handler set by the module/plugin.

BEFORE:
```
this.events.request(“event:name”, () => {
  // never fired
});
this.events.setCommandHandler(“event:name”, cb);
```

AFTER:
```
this.events.request(“event:name”, () => {
  // YAY it fires!
});
this.events.setCommandHandler(“event:name”, cb);
```
2019-02-20 13:05:08 +01:00
emizzle e943d03ce0 fix(@embark/cockpit): Fix contract method autosuggest
Prior to this PR, typing `SimpleStorage.methods.` in to the cockpit console would not show autosuggestions for the contract methods.

Contract names are case sensitive in the VM (VM2). Update the `Suggestions.getSuggestions` method to be case-sensitive when evaluating `Object.keys(<contract class name>.methods)`.
2019-02-15 13:22:57 -05:00
emizzle 876eee5354 fix(@embark/embarkjs): Fix potential race condition
`EmbarkJS.Blockchain.connectConsole` has a potential race condition with both `cb` and `doneCb` firing at the end of the method.

This PR is an attempt to fix that by first awaiting the `cb`, then finally calling `doneCb`, as suggested by @michaelsbradleyjr in https://github.com/embark-framework/embark/pull/1319#discussion_r256850820
2019-02-15 12:43:36 -05:00
Jonathan Rainville 9ccc453379 fix: use our global Web3 and not Metamask's 2019-02-14 12:17:16 -05:00
emizzle 129a35484f @fix(embark/core): Fix VM2 + Remap Imports + Monorepo + Tests
This PR introduces a large number of changes (for that, I am very sorry). Breaking this up in to smaller PR's was causing tests to fail, and the likelihood of them getting merged diminished. There a couple of PRs this PR closes, and as such, I have kep the original commits to preserve the history. The first two (of three) commits are the close PRs, and the last is the glue bringin it all together.

The main goal of this PR is to fix the fragility of the tests with EmbarkJS, however in doing so, a number of recent features have been updated:
Remapping of imports still had a few edge cases that needed to be ironed out, as well as have unit tests created for them. More details of the changes an be seen in the closed PR (below).
The main issue with VM2 was running the code generated EmbarkJS code inside the VM, and getting EmbarkJS contracts out of the VM and available to the tests. This fixed issues where ENS may not have been available to the tests. Notable additions include adding `EmbarkJS.Blockchain.connectTests` to the tests lifecycle, and ensuring `EmbarkJS` is only every required in the console module and not used or passed around elsewhere.
As mentioned above, the main issue with the tests in the context of a monorepo and with embark running as module inside the dapp’s `node_modules`, there were issues getting the correct contract state available inside of the tests. For some reason, this particular case was causing the tests to fail, with ENS never being available (assuming this to be an issue with `EmbarkJS.Blockchain.connect()` never being called). The main fix for this came with passing `web3` as an option in to `EmbarkJS.Blockchain.setProvider()`.
---
1. https://github.com/embark-framework/embark/pull/1286
2. https://github.com/embark-framework/embark/pull/1275
Go to bottom for details
---
There are few known issues with this PR. Instead of trying to fix all of them with this PR, I was hoping to get these issues tackled in separate PRs.
1. `deployIf` directive on contracts defined in the config are not working, however the tests are passing. The issue is that if `ContractA` has a `deployIf` set to `!!ContractB.options.address`, it means that it will not deploy if `ContractB` is not deployed. However, it appears that `ContractA` is attempted to be deployed prior to `ContractB` being deployed, and therefore `ContractA` fails to deploy. Instead, because `ContractA` depends on `ContractB`, `ContractB` should be deployed before `ContractA`.
2. `embark test --node embark` does not seem to be functioning for reasons unknown.
3. Remix tests: Currently there is support for adding contract tests that get process by `remix-tests`, however, there is an error that I believe is not due to embark, but due to the Assert library. For example, if we add a `test/remix_test.sol` to the `test_app` with the following content:
```
pragma solidity ^0.4.24;

import "remix_tests.sol";
import "../app/contracts/simple_storage.sol";

contract SimpleStorageTest {
  SimpleStorage simpleStorage;

  function beforeAll() public {
    simpleStorage = new SimpleStorage(100);
  }

  function initialValueShouldBeCorrect() public {
    return Assert.equal(
      100,
      simpleStorage.storedData,
      "stored data is not what I expected"
    );
  }
}
```
After compilation, we would get the error:
```
remix_test.sol:14:12: TypeError: Member "equal" not found or not visible after argument-dependent lookup in type(library Assert)
    return Assert.equal(
           ^—————^
```
---
This branch is based off of ()`refactor/embarkjs-in-monorepo`)[https://github.com/embark-framework/embark/tree/refactor/embarkjs-in-monorepo], which does not have passing tests due to the `EmbarkJS` ENS issue mentioned above. However, you should (hopefully) see the tests passing in this branch, meaning if both branches are merged, the tests should be passing.
Related PRs: https://github.com/embark-framework/embark-solc/pull/24

---

Changes include:
1. Add unit tests for recursively remapping imports
2. Handle plugin contracts correctly
3. Allow `prepareForCompilation` to be called from `File`, allowing for external compilers, like `embark-solc` to call this function before compilation.
4. Add flattened remappings to `File` that gets prepared for compilation (ie has it's imports remapped)
5. Return remapped contract content when file type is http. Previously this was broken, as always freshly downloaded (original) content was returned.
6. Handle additional cases for `custom` and http file types.

This PR was tested with:
- `embark` unit tests
- `embark` test_app
- `embark` test_app with `embark-solc` plugin
- `embark` test_app with `embark-flattener` plugin
- `Giveth/lpp-campaign`

Related change to get `embark-solc` up-to-date` with these changes: https://github.com/embark-framework/embark-solc/pull/24

When embark was running as module inside the dapp’s `node_modules`, the tests were failing due to several issues:
1. `web3` was not being set in the global namespace of vm2. `EmbarkJS.Blockchain.setProvider` was therefore failing because it relies on `global.web3` to be set. I guess somehow this works when the test app was running in a child tree of the executing program. maybe this is a security feature of vm2, but i’m not sure.
2. `embarkjs` provider code being injected to the vm twice. This really was the initial point of failure, as this piece of code is requiring embarkjs, so i’m assuming, but again not sure, that maybe it was getting a second instance of `EmbarkJS` which did not have it’s providers set up correctly (hence the error with `ENS provider not set`).

Fixes for those issues in this PR:
1. To circumvent the web3 issue, we are now setting `global.web3` for tests only (the global web3 accessible in the tests), and `web3` is now explicitly passed in to `EmbarkJS.Blockchain.setProvider`
2. To fix the `embarkjs` code being called twice, we are not re-injecting this code to the VM during test initialisations
2019-02-14 12:16:55 -05:00
emizzle 2f354c9323 fix(@embark/solc): Import remapping update
Changes include:
- Add unit tests for recursively remapping imports
- Handle plugin contracts
- Allow `prepareForCompilation` to be called from `File`. Allows external compilers, like `embark-solc` to call this.
- Add flattened remappings to file getting prepared for compilation
- Return remapped contract content when file type is http
- Add check allowing files to be remapped/prepared multiple times
2019-02-14 12:16:55 -05:00
emizzle eb4da28a61 fix(@embark/core): Fix tests for shim/monorepo
When embark was running as module inside the dapp’s `node_modules`, the tests were failing due to several issues:
1. `web3` was not being set in the global namespace of vm2. `EmbarkJS.Blockchain.setProvider` was therefore failing because it relies on `global.web3` to be set. I guess somehow this works when the test app was running in a child tree of the executing program. maybe this is a security feature of vm2, but i’m not sure.
2. `embarkjs` provider code being injected to the vm twice. This really was the initial point of failure, as this piece of code is requiring embarkjs, so i’m assuming, but again not sure, that maybe it was getting a second instance of `EmbarkJS` which did not have it’s providers set up correctly (hence the error with `ENS provider not set`).

Fixes for those issues in this PR:
1. To circumvent the web3 issue, we are now setting `global.web3` for tests only (the global web3 accessible in the tests), and `web3` is now explicitly passed in to `EmbarkJS.Blockchain.setProvider`
2. To fix the `embarkjs` code being called twice, we are not re-injecting this code to the VM during test initialisations
2019-02-14 12:16:55 -05:00
Michael Bradley, Jr 57445d0819 build(embarkjs): clean script should invoke 'npx rimraf'
Packages' `"clean"` scripts should run regardless of whether `node_modules` is
in place at the root and/or package levels, but the `embarkjs` package was
missing a needed `npx` in front of `rimraf` in its script.

Also, bump its devDeps version of rimraf to be in line with the rest of
`packages/*` and `test_dapps/*`.
2019-02-14 01:26:10 -06:00
Michael Bradley, Jr 23ae78a6d6 refactor: be consistent with callbacks and promises
If a function receives a callback argument then it should not return a promise
if the caller's callback will be invoked. Both invoking a callback and
returning a promise can lead to at best confusion (in code review and at
runtime) and at worst non-deterministic behavior, such as race
conditions. Also, a caller supplying a callback may not handle a returned
promise, leading to unhandled rejection errors.

Refactor all readily identified functions where a callback argument can be
supplied but the function returns a promise regardless. Make use of
`callbackify` and `promisify` where it made sense to do so during the
refactoring. Some callsites of the revised functions may have been accidentally
overlooked and still need to be updated. Some functions that take callback
arguments may execute them synchronously, at odds with control flow of a
returned promise (if a callback wasn't supplied). Such cases should be
identified and fixed so that asynchronous behavior is fully consistent whether
the caller supplies a callback or receives a promise.

Make sure promises that pass control flow to a callback ignore rejections,
since those should be handled by the callback.

Don't return promise instances unnecessarily from async functions (since they
always return promises) and change some functions that return promises to async
functions (where it's simple to do so).

Whisper was using an ad hoc promise-like `messageEvents` object. However, that
object behaved more like an observable, since promises either resolve or
reject, and only do so one time. `messageEvents` was also intertwined with
callbacks. Replace `messageEvents` with RxJS Observable. `listenTo` now returns
Observable instances and callers can subscribe to them.

`Blockchain.connect` of embarkjs could suffer from a race condition where tasks
associated with `execWhenReady` might be ongoing when `connect`'s returned
promise resolves/rejects (or a caller supplied callback fires). Attempt to
ensure that returned-promise / supplied-callback control flow proceeds only
after `execWhenReady` tasks have finished. The control flow involved
is... rather involved, and it could use some further review and refactoring.

Bump webpack and the hard-source-plugin for webpack.

[util]: https://www.npmjs.com/package/util
2019-02-13 14:27:42 -05:00
Andre Medeiros 8fd6a6dc3d fix: estimate gas automatically when not specified 2019-02-13 13:44:03 -05:00
Pascal Precht fdd51cfebb fix(@embark/solidity): ensure SolidityProcess receives proper Logger instance
Prior to this commit Embark had a bug where, when running `$ embark run` inside
an Embark project that was freshly cloned or reset, it'd get stuck at loading
the Solidity compiler.

However, this only seemed to happen when Embark was used with its dashboard. When
running

```
$ embark run --nodashboard
```

instead, Embark loaded Solidity successfully and moved on with compilation.

This bug pretty much boiled down to `SolidityProcess` not receiving a valid `Logger`
dependency when instantiated via `SolcW`. The reason this was happening
is that we were sending the needed dependencies via `ProcessLauncher.send()`, which
serializes/deserializes its sent data.

```
solidityProcessLauncher.send({action: 'init', options: { logger: this.logger }});
```

And inside `SolidityProcess`

```
process.on('message', (msg) => {
  if (msg.action === "init") {
    solcProcess = new SolcProcess(msg.options);
  }
  ...
}
```

`SolcProcess` passes its `logger` instance down to `longRunningProcessTimer` which
uses methods on `Logger`.

However, since the data had been serialized, all prototype methods on the data is
gone, resulting in an error, which made Embark stop.

**Why was this only a problem when using the dashboard?**

Turns out we've only relied on `Logger.info()` in case the dashboard is used.
2019-02-13 12:18:26 -05:00
Anthony Laibe 193abd4780 feat(ui): color console item info as success 2019-02-13 12:12:28 -05:00
emizzle 07ede9017e fix(@embark/core): fix tests as paths have changed again
URLs for test_app files have changed on the remote again, this PR updates the tests to reflect that change.
2019-02-12 18:25:13 -05:00
Jonathan Rainville 8ee32c19dc feat(console): wait for connector onReady to have warning 2019-02-12 16:59:54 -05:00
Jonathan Rainville d7da38f6c4 remove path events and use function directly
also use await
2019-02-12 16:59:54 -05:00
Jonathan Rainville b49acee143 change dependency names 2019-02-12 16:59:54 -05:00
Jonathan Rainville b89e049f25 change package version to beta.0 2019-02-12 16:59:54 -05:00
Jonathan Rainville 69ac239ca0 fix ci tests 2019-02-12 16:59:54 -05:00
Jonathan Rainville f6beeff9c7 fix errors in code_generator 2019-02-12 16:59:54 -05:00
Jonathan Rainville 8ebba404e2 fix(test/blockchain): fix race condition of installing web3 and test 2019-02-12 16:59:54 -05:00
Jonathan Rainville 976f9944a8 feat(web3connector): add web3 connector plugin to connect to web3 2019-02-12 16:59:54 -05:00
Jonathan Rainville 3b0a2b9b3e feat(embark/generation): remove generation of web3instance.js 2019-02-12 16:59:54 -05:00
Jonathan Rainville bd9fc6683a feat(embarkjs/blockchain): remove dependency on web3instance.js 2019-02-12 16:59:54 -05:00
Jonathan Rainville fdd8ad5321 fix(embarkjs/blockchain): pass error only when there is an error 2019-02-12 16:59:54 -05:00
Anthony Laibe cd326303ae feat(ui): keep state in frame 2019-02-12 16:42:16 -05:00
Anthony Laibe bc24598175 feat: create async wrapper 2019-02-12 08:24:20 +00:00
Iuri Matias c1d84fe8d8 refactor(@embark) add fs to plugin api; change (most) modules to use it instead of coupling them with require
refactor(@embark) add fs to plugin api; change (most) modules to use it instead of coupling them with require

refactor(@embark) add fs to plugin api; change (most) modules to use it instead of coupling them with require

refactor(@embark) add fs to plugin api; change (most) modules to use it instead of coupling them with require

refactor(@embark) add fs to plugin api; change (most) modules to use it instead of coupling them with require

refactor(@embark) add fs to plugin api; change (most) modules to use it instead of coupling them with require

refactor(@embark) add fs to plugin api; change (most) modules to use it instead of coupling them with require
2019-02-08 19:12:57 -05:00
Jonathan Rainville f0605bed2b refactor(generation/contracts): generate contracts to artifact dir 2019-02-08 17:13:48 -05:00
Jonathan Rainville c91e145981 refactor(generation/embarkjs): generate embarkjs in artifacts dir 2019-02-08 17:13:48 -05:00
Pascal Precht 40b9ac3c70 fix(@embark/core): fix memory leak when contract files are loaded
Prior to this commits `this.contractsFiles` kept growing at run time
for every file change that was detected by Embark.

The reason for that was a bug in a condition that determines whether
a subset of contract files needed to be added to memory or not.

In addition to that we kept pushing externally loaded contract files into
memory, even if they already existed in memory.
2019-02-08 17:11:54 -05:00
Michael Bradley, Jr 2e763f3720 feature(embark): add coveralls integration 2019-02-08 17:07:05 -05:00
Michael Bradley, Jr 9f0a370c34 refactor: add embarkjs to the monorepo
Don't import git history of embark-framework/EmbarkJS, simply copy over the
sources. Modify `package.json`, etc. re: being situated in the monorepo.

Make use of the root babel config but extend with
`packages/embarkjs/.babelrc.js`.

Build `test/` scripts into `build-test/` and git-ignore `build-test/`.

Revise `Blockchain.connect()` so that if the caller supplies a callback then a
promise is not returned.

Revise tests to test `Blockchain.connect()` usage with and without a callback.
2019-02-08 11:58:02 -06:00
Iuri Matias 1c10b17e15 refactor(@embark/code_generator) simplify listenToCommands function; use this instead of self; use bind for functions 2019-02-07 10:35:35 -05:00
Iuri Matias 7d325ee28b feature(@embark/code_generator) generate communication config artifact 2019-02-07 10:35:35 -05:00
Iuri Matias c9febdec93 feature(@embark/code_generator) generate storage config artifact 2019-02-07 10:35:35 -05:00
Iuri Matias 2c2a09ca68 feature(@embark/deploytracker) support configuring deployment tracking file on a per environment basis; put default dev on temporary directory 2019-02-07 10:27:09 -05:00
Michael Bradley, Jr 37080c55ae fix(embark): require embark-compiler in packages/embark's tests 2019-02-06 17:21:56 -06:00
Michael Bradley, Jr 376b6cacd6 fix: supply missing tsconfig.json in packages/*
Relative `"include"` path/s in a `tsconfig.json` are relative to the directory
in which the config is located, so each monorepo package that uses typescript
needs its own `tsconfig.json` that `"extends"` the root config.

For now, disable the `"typecheck"` script in embark-graph and embark-vyper, but
leave the relevant pieces in place (devDeps, configs) so that when they're
converted to TypeScript the scripts can simply be re-enabled. The problem is
that if no `.ts` files are present in the path/s specified in `"include"` of
`tsconfig.json`, tsc will exit with error.
2019-02-06 17:20:13 -06:00
Michael Bradley, Jr 733d8040a4 fix(embark-graph): add packages/embark-graph/tslint.json 2019-02-06 15:59:13 -06:00
Iuri Matias bac51196db refactor(@embark/embark-graph) move graph to its own module 2019-02-06 14:48:06 -05:00
Iuri Matias 8f393f7298 refactor(@embark/embark-vyper) move vyper to its own module 2019-02-06 14:32:54 -05:00
Michael Bradley 260efa535f Update packages/embark-compiler/package.json
Co-Authored-By: iurimatias <iuri.matias@gmail.com>
2019-02-06 13:24:45 -05:00
Iuri Matias 8e7c8e940a refactor(@embark/embark-compiler) move compiler to its own module
refactor(@embark/embark-compiler) move compiler to its own module

 This is a combination of 2 commits.

refactor(@embark/embark-compiler) move compiler to its own module

refactor(@embark/embark-compiler) move compiler to its own module

Update packages/embark-compiler/package.json

Co-Authored-By: iurimatias <iuri.matias@gmail.com>

Update packages/embark-compiler/package.json

Co-Authored-By: iurimatias <iuri.matias@gmail.com>

Update packages/embark-compiler/package.json

Co-Authored-By: iurimatias <iuri.matias@gmail.com>

refactor(@embark/embark-compiler) move compiler to its own module

refactor(@embark/embark-compiler) move compiler to its own module

refactor(@embark/embark-compiler) move compiler to its own module

refactor(@embark/embark-compiler) move compiler to its own module
2019-02-06 13:24:45 -05:00
Michael Bradley, Jr 9e035879a7 build: cleanup eslint configuration
Move `packages/embark`'s eslint config into the monorepo root.

Remove `"plugin:react/recommended"` since it's not commonly needed.

Put a `"eslintConfig"` config key/object in `packages/embark`'s `package.json`
that directs eslint to extend the root config; other `packages/*` can do
likewise.
2019-02-06 11:26:41 -06:00
Michael Bradley, Jr 3f61e314d9 build: implement a common babel config
Setup a `babel.config.js` in the root of the monorepo to be used by
`packages/*`. It won't be used by some packages, e.g. `packages/embark-ui`, but
most of them should use it instead of rolling their own.

Allow for package-level modifications by specifying `babelrcRoots` in the root
`babel.config.js`

Use the babel `--root-mode upward` option in `packages/embark`'s `build`
script. Other packages intending to use the common config should do likewise.

Use a `.babelrc.js` in `packages/embark` to supply the package-specific
`ignore` settings.

Make packages used by the common config devDeps of the root.

Extract babel-related devDeps from `packages/embark`, but don't extract the
non-dev deps since those are used by embark's pipeline in a production
install. Normally, it should only be necessary to have `@babel/cli` and
`@babel/core` in devDeps, and possibly `@babel/runtime-corejs2` in deps, plus
any package-specific babel-related dev/deps. Once we deprecate the pipeline, we
can finish the extraction.

Use `ncu -f '/babel/' -u` to bump the versions of all babel-related deps in the
root and in `packages/embark`. We get better space/time savings from the yarn
workspace when versions match.
2019-02-06 11:34:47 -05:00
Iuri Matias fbc8ab0fea refactor(@embark/embark-typings) move typings to its own module
fix typings

WIP: refactor

WIP: just needed an annotation 🎉 thanks @emizzle!

WIP: don't pack a tarball since it's a private package

WIP: no need to list as a devDep
2019-02-06 11:07:44 -05:00
Michael Bradley, Jr 8091c4e6d0 build: cleanup .gitignore
Put common patterns we expect to use across most `packages/*` into the
top-level `.gitignore`. If there are package-specific patterns they can go in
that package's `.gitignore`. For example, `packages/embark-ui` ignores its
`build/` directory while commonly we ignore the packages' `dist/` directories.
2019-02-05 18:08:14 -06:00
Michael Bradley, Jr 2bf1b15ac3 build: cleanup .yarnrc
Yarn merges `.yarnrc` from the current working directory with `.yarnrc` files
higher in the directory tree, so that file isn't needed in each package.

Unfortunately, npm doesn't do the same for `.npmrc` files, so a similar cleanup
isn't possible.

Add version info to `test_app/extensions/embark-service/package.json` to that
`yarn install` can work correctly if manually invoked in `test_app`.
2019-02-05 14:15:39 -06:00
emizzle 0ba16278bd fix(@embark/test_app): Fix tests as paths have chagned
The latest lerna changes have changed the HTTP paths of some test files used in the repo. This PR updates the paths to their new location.
2019-02-04 22:52:08 -06:00
Michael Bradley, Jr 7a93e4b6a7 build: implement a monorepo with Lerna
TL;DR
=====

`yarn install` in a fresh clone of the repo.

`yarn reboot` when switching branches.

When pulling in these changes, there may be untracked files at the root in
all/some of:

```
.embark/
.nyc_output/
coverage/
dist/
embark-ui/
test_apps/
```

They can be safely deleted since those paths are no longer in use at the root.

Many of the scripts in the top-level `package.json` support Lerna's [filter
options]. For example:

`yarn build --scope embark` build only `packages/embark`.

`yarn build --ignore embark-ui` build everything except `packages/embark-ui`.

Scoping scripts will be more useful when there are more packages in the
monorepo and, for example, `yarn start` doesn't need to be invoked for all of
them while working on just a few of them simultaneously, e.g `embark` and
`embarkjs`.

It's also possible to `cd` into a particular package and run its scripts
directly:

```
cd packages/embark && yarn watch
```

Hot Topics & Questions
======================

What should be done about the [README][embark-readme] for `packages/embark`?
Should the top-level README be duplicated in that package?

Lerna is setup to use [Fixed/Locked mode][fixed-locked], and accordingly
`packages/embark-ui` is set to `4.0.0-beta.0`. The same will be true when
adding embarkjs, swarm-api, etc. to the monorepo. Is this acceptable or do we
want to use [Independent mode][independent]?

Scripts
=======

If a package doesn't have a matching script, `lerna run` skips it
automatically. For example, `packages/embark-ui` doesn't have a `typecheck`
script.

`yarn build`
------------

Runs babel, webpack, etc. according to a package's `build` script.

`yarn build:no-ui` is a shortcut for `yarn build --ignore embark-ui`.

`yarn ci`
---------

Runs a series of scripts relevant in a CI context according to a package's `ci`
script. For `packages/embark` that's `lint typecheck build test package`.

Also runs the `ci` script of the embedded `test_dapps` monorepo.

`yarn clean`
------------

Runs rimraf, etc. according to a package's `clean` script.

`yarn globalize`
----------------

Makes the development embark available on the global PATH, either via
symlink (Linux, macOS) or a shim script (Windows).

`yarn lint`
-----------

Runs eslint, etc. according to a package's `lint` script.

`yarn package`
--------------

Invokes `npm pack` according to a package's `package` script.

`yarn qa`
---------

Very similar to `ci`, runs a series of scripts according to a package's `qa`
script. The big difference between `ci` and `qa` is that at the top-level `qa`
first kicks off `reboot:full`.

There is a `preqa` script ([invoked automatically][npm-scripts]), which is a
bit of a wart. It makes sure that `embark reset` can be run successfully in
`packages/embark/templates/*` when the `reboot` script invokes the `reset`
script.

The `qa` script is invoked by `yarn release` before the latter proceeds to
invoke `lerna publish`.

`yarn reboot`
-------------

Invokes the `reset` script and then does `yarn install`.

The `reboot:full` variant invokes `reset:full` and then does `yarn install`.

`yarn release`
--------------

Works in concert with [lerna publish], which will prompt to verify the version
before proceeding. Use `n` to cancel instead of `ctrl-c` as `lerna publish` has
been seen to occasionally misbehave when not exited cleanly (e.g. creating a
tag when it shouldn't have).

```
yarn release [bump] [--options]
```

* `[bump]` see [`publish` positionals][pub-pos] and [`version`
  positionals][ver-pos]; an exact version can also be specified.
* `--preid` prerelease identifier, e.g. `beta`; when doing a prerelease bump
  will default to whatever identifier is currently in use.
* `--dist-tag` registry distribution tag, defaults to `latest`.
* `--message` commit message format, defaults to `chore(release): %v`.
* `--sign` indicates that the git commit and tag should be signed; not signed
  by default.
* `--release-branch` default is `master`; must match the current branch.
* `--git-remote` default is `origin`.
* `--registry` default is `https://registry.npmjs.org/` per the top-level
  [`lerna.json`][lerna-json].

To release `4.0.0-beta.1` as `embark@next` (assuming version is currently at
`4.0.0-beta.0`) could do:

```
yarn release prerelease --dist-tag next
```

For *test releases* (there is no longer a `--dry-run` option) [verdaccio] and a
filesystem git remote can be used.

Condensend instructions:

```
mkdir -p ~/temp/clones && cd ~/temp/clones
git clone git@github.com:embark-framework/embark.git
cd ~/repos/embark
git remote add FAKEembark ~/temp/clones/embark
```
in another terminal:
```
npm i -g verdaccio && verdaccio
```
in the first terminal:
```
yarn release --git-remote FAKEembark --registry http://localhost:4873/
```

`yarn reset`
------------

Invokes cleaning and resetting steps according to a package's `reset`
script. The big difference between `clean` and `reset` is that `reset` is
intended to delete a package's `node_modules`.

The `reset:full` variant deletes the monorepo's top-level `node_modules` at the
end. That shouldn't be necessary too often, e.g. in day-to-day work when
switching branches, which is why there is `reboot` / `reset` vs. `reboot:full`
/ `reset:full`.

Errors may be seen related to invocation of `embark reset` if embark is not
built, but `reset` will still complete successfully.

`yarn start`
------------

Runs babel, webpack, tsc, etc. (in parallel, in watch mode) according to a
package's `start` script.

`yarn test`
-----------

Run mocha, etc. according to a package's `test` script.

The `test:full` variant runs a series of scripts: `lint typecheck test
test_dapps`.

`yarn test_dapps`
-----------------

Runs the `test` script of the embedded `test_dapps` monorepo.

The `test_dapps:ci` and `test_dapps:qa` variants run the `ci` and `qa` scripts
of the embedded `test_dapps` monorepo, respectively.

`yarn typecheck`
----------------

Runs tsc, etc. according to a package's `typecheck` script.

Notes
=====

`npx` is used in some of the top-level and package scripts to ensure the
scripts can run even if `node_modules` is missing.

[`"nohoist"`][nohoist] specifies a couple of embark packages because
[`restrictPath`][restrictpath] is interfering with access to modules that are
located in a higher-up `node_modules`.

All dependencies in `packages/embark-ui` have been made `devDependencies` since
its production build is self-contained.

`packages/embark`'s existing CHANGELOG's formatting has been slightly adjusted
to match the formatting that Lerna will use going forward (entries in the log
haven't been modified).

Lerna will generate a CHANGELOG at the top-level and in each package. Since
we're transitioning to a monorepo, things may look a little wonky with respect
to old entries in `packages/embark/CHANGELOG.md` and going forward we need to
consider how scoping our commits corresponds to member-packages of the
monorepo.

In `packages/embark`, `test` invokes `scripts/test`, which starts a child
process wherein `process.env.DAPP_PATH` is a temporary path that has all of
`packages/embark/dist/test` copied into it, so that paths to test
helpers/fixtures don't need to be prefixed with `dist/test/` and so that a
`.embark` directory doesn't get written into `packages/embark`.

The `"engines"` specified in top-level and packages' `package.json` reflect a
node and npm pair that match (a source of confusion in the past). The pair was
chosen according to the first post v5 npm that's bundled with node. A
`"runtime"` key/object has been introduced in `packages/embark/package.json`
which is used as the basis for specifying the minimum version of node that can
be used to run embark, and that's what is checked by `bin/embark`.

Some changes have been introduced, e.g. in `lib/core/config` and
`lib/utils/solidity/remapImports` so that it's *not* implicitly assumed that
`process.env.DAPP_PATH` / `fs.dappPath()` are the same as
`process.cwd()`. There are probably several++ places where that assumption is
still in effect, and we should work to identify and correct them.

`embark reset` now deletes `embarkArtifacts/` within a dapp root, and
`embarkArtifacts/` is git-ignored.

`lib/core/env` adds all `node_modules` relative to `process.env.EMBARK_PATH` to
`NODE_PATH` so that embark's modules can be resolved as expected whether
embark's `node_modules` have been deduped or are installed in npm's flat
"global style".

`checkDependencies` has been inlined (see `lib/utils/checkDependencies`) and
slightly modified to support dependencies that have been hoisted into a
higher-up `node_modules`, e.g. as part of a yarn workspace. eslint has been
disabled for that script to avoid more involved changes to it.

`test_apps` is not in `packages/embark`; rather, there is `test_dapps` at the
top-level of the monorepo. `test_dapps` is an embedded monorepo, and its `ci` /
`qa` scripts `npm install` embark from freshly built tarballs of the packages
in the outer monorepo and then use that installation to run `embark test` in
the dapps. This should allow us to rapidly detect breakage related to
auto-bumps in transitive dependencies.

[filter options]: https://github.com/lerna/lerna/tree/master/core/filter-options
[embark-readme]: https://github.com/embark-framework/embark/blob/build/lerna/packages/embark/README.md
[fixed-locked]: https://github.com/lerna/lerna#fixedlocked-mode-default
[independent]: https://github.com/lerna/lerna#independent-mode
[npm-scripts]: https://docs.npmjs.com/misc/scripts
[lerna publish]: https://github.com/lerna/lerna/tree/master/commands/publish
[pub-pos]: https://github.com/lerna/lerna/tree/master/commands/publish#positionals
[ver-pos]: https://github.com/lerna/lerna/tree/master/commands/version#positionals
[lerna-json]: https://github.com/embark-framework/embark/blob/build/lerna/lerna.json#L11
[verdaccio]: https://www.npmjs.com/package/verdaccio
[nohoist]: https://github.com/embark-framework/embark/blob/build/lerna/package.json#L52-L55
[restrictpath]: https://github.com/embark-framework/embark/blob/build/lerna/packages/embark/src/lib/core/fs.js#L9
2019-02-04 14:28:49 -06:00