refactor(@embark/embarkjs): move module into own package (#1945)

**TODO:** The `embark eject-webpack` command needs to be updated. @michaelsbradleyjr - do you have suggestions as to how we could port this over? We could **assume** that the `basic-pipeline` plugin will be installed, and then read the embark config and overrides from the file system, however this feels like we are sort adding a dependency to a plugin, which is not right. Any suggestions?
This commit is contained in:
Eric Mastro 2019-10-14 16:05:17 +09:00 committed by Iuri Matias
parent 5dbc1c791a
commit 3f7842cf24
12 changed files with 166 additions and 10 deletions

View File

@ -43,22 +43,16 @@ module.exports = (api) => {
const base = {};
const node = cloneDeep(base);
Object.assign(node, {
ignore: [
'src/lib/modules/basic-pipeline/babel-loader-overrides.js',
'src/lib/modules/basic-pipeline/webpack.config.js'
]
});
if (env === 'node') {
copyFiles(node.ignore);
copyFiles(node.ignore || []);
return node;
}
const test = cloneDeep(node);
if (env === 'test') {
copyFiles(test.ignore);
copyFiles(test.ignore || []);
return test;
}

View File

@ -94,6 +94,7 @@
"embark-accounts-manager": "^4.1.1",
"embark-api": "^4.1.1",
"embark-authenticator": "^4.1.1",
"embark-basic-pipeline": "^4.1.1",
"embark-code-runner": "^4.1.1",
"embark-communication": "^4.1.1",
"embark-compiler": "^4.1.1",
@ -207,7 +208,6 @@
"web3-providers-ws": "1.2.1",
"web3-shh": "1.2.1",
"web3-utils": "1.2.1",
"webpack": "4.41.0",
"window-size": "1.1.1",
"ws": "7.1.2",
"yo-yoify": "4.3.0"

View File

@ -114,7 +114,7 @@ class Engine {
}
pipelineService(_options) {
this.registerModule('basic-pipeline', {
this.registerModulePackage('embark-basic-pipeline', {
plugins: this.plugins,
webpackConfigName: this.webpackConfigName,
useDashboard: this.useDashboard

View File

@ -0,0 +1,66 @@
/* global __dirname module require */
const cloneDeep = require('lodash.clonedeep');
const {copySync, ensureDirSync} = require('fs-extra');
const glob = require('glob');
const {dirname, join, relative} = require('path');
// @babel/cli v7's --copy-files option does not work well together with
// config-specified ignore paths, and that's a problem for embark-collective
// actions since the @babel/cli invocation must be the same across all packages
// in the collective; so any package in the collective that excludes src/ files
// from transpilation via its package-local .babelrc.js should copy those files
// into dist/, but only if they are expected to be in dist/; .babelrc.js should
// also copy any non .js,.ts files into /dist
// in this case we want the un-transpiled webpack config and babel-loader
// overrides script from the basic-pipeline to be copied into the respective
// subdir in dist/; we also want to copy .ejs and .json files
function copyFiles (ignored) {
const others = glob.sync(
join(__dirname, 'src/**/*.*'),
{ignore: [
join(__dirname, 'src/**/*.js'),
join(__dirname, 'src/**/*.ts'),
join(__dirname, 'src/**/*.disabled')
]}
).map(path => relative(__dirname, path));
ignored = ignored.concat(others);
ignored
.map(path => path.replace('src/', 'dist/'))
.forEach((dest, index) => {
ensureDirSync(dirname(join(__dirname, dest)));
const source = ignored[index];
copySync(join(__dirname, source), join(__dirname, dest));
});
}
module.exports = (api) => {
const env = api.env();
const base = {};
const node = cloneDeep(base);
Object.assign(node, {
ignore: [
'src/babel-loader-overrides.js',
'src/webpack.config.js'
]
});
if (env === 'node') {
copyFiles(node.ignore);
return node;
}
const test = cloneDeep(node);
if (env === 'test') {
copyFiles(test.ignore);
return test;
}
return base;
};

View File

@ -0,0 +1,4 @@
engine-strict = true
package-lock = false
save-exact = true
scripts-prepend-node-path = true

View File

@ -0,0 +1,8 @@
# `embark-basic-pipeline`
> Basic pipeline for Embark that builds a DApp's frontend assets using webpack
Visit [embark.status.im](https://embark.status.im/) to get started with
[Embark](https://github.com/embark-framework/embark).
Contracts in `test/fixture/contracts` are from [OpenZeppelin](https://github.com/OpenZeppelin/openzeppelin-solidity) and [Gnosis Prediction Markets](https://github.com/gnosis/pm-contracts)

View File

@ -0,0 +1,84 @@
{
"name": "embark-basic-pipeline",
"version": "4.1.1",
"author": "Iuri Matias <iuri.matias@gmail.com>",
"contributors": [],
"description": "Basic pipeline for Embark that builds a DApp's frontend assets using webpack",
"homepage": "https://github.com/embark-framework/embark/tree/master/packages/plugins/basic-pipeline#readme",
"bugs": "https://github.com/embark-framework/embark/issues",
"keywords": [
"blockchain",
"dapps",
"ethereum",
"ipfs",
"serverless",
"solc",
"solidity"
],
"files": [
"dist"
],
"license": "MIT",
"repository": {
"directory": "packages/plugins/basic-pipeline",
"type": "git",
"url": "https://github.com/embark-framework/embark.git"
},
"main": "./dist/index.js",
"embark-collective": {
"build:node": true
},
"scripts": {
"_build": "npm run solo -- build",
"ci": "npm run qa",
"clean": "npm run reset",
"lint": "eslint src/",
"qa": "npm-run-all lint _build",
"reset": "npx rimraf dist embark-*.tgz package",
"solo": "embark-solo",
"test": "jest"
},
"eslintConfig": {
"extends": "../../../.eslintrc.json"
},
"dependencies": {
"@babel/runtime-corejs2": "7.6.2",
"async": "2.6.1",
"clone-deep": "4.0.0",
"embark-core": "^4.1.1",
"embark-i18n": "^4.1.1",
"embark-utils": "^4.1.1",
"fs-extra": "8.1.0",
"webpack": "4.41.0"
},
"devDependencies": {
"@babel/core": "7.6.2",
"babel-jest": "24.9.0",
"embark-solo": "^4.1.1",
"embark-testing": "^4.1.1",
"eslint": "5.7.0",
"jest": "24.9.0",
"npm-run-all": "4.1.5",
"rimraf": "3.0.0"
},
"engines": {
"node": ">=8.12.0 <12.0.0",
"npm": ">=6.4.1",
"yarn": ">=1.12.3"
},
"jest": {
"collectCoverage": true,
"testEnvironment": "node",
"testMatch": [
"**/test/**/*.js"
],
"transform": {
"\\.js$": [
"babel-jest",
{
"rootMode": "upward"
}
]
}
}
}