Skip to content

Commit

Permalink
fix: move types definition into src folder and include them in the bu…
Browse files Browse the repository at this point in the history
…ild. (#322)
  • Loading branch information
Pavel910 authored Dec 9, 2018
1 parent 6d25ebe commit 6658d75
Show file tree
Hide file tree
Showing 97 changed files with 252 additions and 911 deletions.
2 changes: 2 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ module.name_mapper='^webiny-form/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-fo
module.name_mapper='^webiny-i18n-react/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-i18n-react/src/\1'
module.name_mapper='^webiny-i18n/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-i18n/src/\1'
module.name_mapper='^webiny-jimp/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-jimp/src/\1'
module.name_mapper='^webiny-load-assets/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-load-assets/src/\1'
module.name_mapper='^webiny-model/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-model/src/\1'
module.name_mapper='^webiny-mysql-connection/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-mysql-connection/src/\1'
module.name_mapper='^webiny-plugins/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-plugins/src/\1'
module.name_mapper='^webiny-react-router/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-react-router/src/\1'
module.name_mapper='^webiny-service-manager/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-service-manager/src/\1'
module.name_mapper='^webiny-sql-table-mysql/?\(.*\)$' -> '<PROJECT_ROOT>/packages/webiny-sql-table-mysql/src/\1'
Expand Down
1 change: 0 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const packages = getPackages(path.join(process.cwd(), "packages"));

const aliases = packages.reduce((aliases, dir) => {
const name = path.basename(dir);
aliases[`^${name}/types`] = `${name}/types`;
aliases[`^${name}/(?!src)(.+)$`] = `${name}/src/\\1`;
return aliases;
}, {});
Expand Down
3 changes: 2 additions & 1 deletion idea.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ System.config({
"webiny-app-cms/*": "./packages/webiny-app-cms/src/*",
"webiny-api/*": "./packages/webiny-api/src/*",
"webiny-api-cms/*": "./packages/webiny-api-cms/src/*",
"webiny-ui/*": "./packages/webiny-ui/src/*"
"webiny-ui/*": "./packages/webiny-ui/src/*",
"webiny-plugins/*": "./packages/webiny-plugins/src/*"
}
});
9 changes: 9 additions & 0 deletions packages/babel-preset-webiny-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# babel-preset-webiny-app

This preset contains our recommended set of plugins to use with Webiny apps:

- react-hot-loader (will enable react hot reloading in development)
- babel-plugin-emotion
- babel-plugin-named-asset-import (to import svg files as React components)
- @svgr/webpack (a loader to convert svg files to React components)
- babel-plugin-lodash (for lodash and recompose tree shaking )
2 changes: 2 additions & 0 deletions packages/babel-preset-webiny-app/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @flowIgnore
module.exports = require("./src");
19 changes: 19 additions & 0 deletions packages/babel-preset-webiny-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"private": true,
"name": "babel-preset-webiny-app",
"version": "0.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@svgr/webpack": "^4.1.0",
"babel-plugin-emotion": "^10.0.4",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-named-asset-import": "^0.2.3",
"react-hot-loader": "^4.3.12"
},
"scripts": {
"build": "babel src -d ${DEST:-build} --source-maps --copy-files",
"flow-copy-source": "flow-copy-source src ${DEST:-build}",
"postbuild": "yarn flow-copy-source"
}
}
22 changes: 22 additions & 0 deletions packages/babel-preset-webiny-app/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// @flowIgnore
module.exports = function(api, opts, env) {
const isDevelopment = env === "development";

return {
plugins: [
isDevelopment && ["react-hot-loader/babel"],
["babel-plugin-emotion", { autoLabel: true }],
[
"babel-plugin-named-asset-import",
{
loaderMap: {
svg: {
ReactComponent: "@svgr/webpack![path]"
}
}
}
],
["babel-plugin-lodash", { id: ["lodash", "recompose"] }]
].filter(Boolean)
};
};
3 changes: 1 addition & 2 deletions packages/demo-admin/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
module.exports = {
presets: ["babel-preset-react-app"],
plugins: [["react-hot-loader/babel"], ["babel-plugin-lodash", { id: ["lodash", "recompose"] }]]
presets: ["babel-preset-react-app", "babel-preset-webiny-app"]
};
2 changes: 1 addition & 1 deletion packages/demo-admin/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// @flowIgnore
module.exports = require("webiny-react-rewired/config-overrides")();
module.exports = require("webiny-react-rewired")();
12 changes: 6 additions & 6 deletions packages/demo-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"private": true,
"dependencies": {
"apollo-link-batch-http": "^1.2.3",
"demo-theme": "0.0.0-semantically-released",
"demo-theme": "0.0.0",
"react-apollo": "^2.2.4",
"react-hot-loader": "^4.3.5",
"webiny-app": "0.0.0-semantically-released",
"webiny-app-admin": "0.0.0-semantically-released",
"webiny-app-cms": "0.0.0-semantically-released",
"webiny-plugins": "0.0.0-semantically-released",
"webiny-ui": "0.0.0-semantically-released"
"webiny-app": "0.0.0",
"webiny-app-admin": "0.0.0",
"webiny-app-cms": "0.0.0",
"webiny-ui": "0.0.0",
"webiny-plugins": "0.0.0"
},
"devDependencies": {
"node-sass": "^4.9.3",
Expand Down
3 changes: 2 additions & 1 deletion packages/demo-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.0.0",
"babel-loader": "^8.0.0",
"date-fns": "^1.29.0",
"fs-extra": "^7.0.0",
"graphql": "^0.13.2",
"graphql-iso-date": "^3.5.0",
Expand All @@ -25,7 +26,7 @@
"serverless-apigwy-binary": "^0.1.0",
"sharp": "^0.21.0",
"uniqid": "^5.0.3",
"webiny-plugins": "0.0.0-semantically-released"
"webiny-api": "0.0.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
Expand Down
30 changes: 21 additions & 9 deletions packages/demo-api/src/configs/production.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import mysql from "mysql";
import { User, ApiToken } from "webiny-api/entities";
import { createIdentity, credentialsStrategy } from "webiny-api/security";
// @flow
import mysql from "serverless-mysql";
import addDays from "date-fns/add_days";
import { MySQLDriver } from "webiny-entity-mysql";

const connection = mysql.createPool({
Expand All @@ -14,15 +14,27 @@ const connection = mysql.createPool({
});

export default {
database: {
connection
},
entity: {
// Instantiate driver with DB connection
// Instantiate entity driver with DB connection
driver: new MySQLDriver({ connection }),
crud: {
logs: true,
read: {
maxPerPage: 100
},
delete: {
soft: true
}
}
},
security: {
token: { secret: "MyS3cr3tK3Y" },
identities: [
createIdentity(User, { strategy: credentialsStrategy() }),
createIdentity(ApiToken)
]
enabled: false,
token: {
secret: process.env.JWT_SECRET || "MyS3cr3tK3Y",
expiresOn: (args: Object) => addDays(new Date(), args.remember ? 30 : 1)
}
}
};
11 changes: 9 additions & 2 deletions packages/demo-api/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
// @flowIgnore
const slsw = require("serverless-webpack");

const path = require("path");
const getPackages = require("get-yarn-workspaces");
const packages = getPackages(path.join(process.cwd(), "../../"));

const aliases = packages.reduce((aliases, dir) => {
const name = path.basename(dir);
aliases[`^${name}/(?!src)(.+)$`] = `${name}/src/\\1`;
return aliases;
}, {});

const config = {
entry: slsw.lib.entries,
target: "node",
Expand Down Expand Up @@ -31,7 +38,6 @@ const config = {
loader: "babel-loader",
include: packages,
options: {
configFile: path.join(process.cwd(), "/../../babel.config.js"),
presets: [
[
"@babel/preset-env",
Expand All @@ -49,7 +55,8 @@ const config = {
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
"babel-plugin-dynamic-import-node"
"babel-plugin-dynamic-import-node",
["babel-plugin-module-resolver", { alias: aliases }]
]
}
}
Expand Down
57 changes: 0 additions & 57 deletions packages/demo-api/webpack.for-users.js

This file was deleted.

17 changes: 1 addition & 16 deletions packages/demo-theme/.babelrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
module.exports = {
presets: ["babel-preset-react-app"],
plugins: [
["react-hot-loader/babel"],
["babel-plugin-emotion", { autoLabel: true }],
[
"babel-plugin-named-asset-import",
{
loaderMap: {
svg: {
ReactComponent: "@svgr/webpack![path]"
}
}
}
],
["babel-plugin-lodash", { id: ["lodash", "recompose"] }]
]
presets: ["babel-preset-react-app", "babel-preset-webiny-app"]
};
2 changes: 1 addition & 1 deletion packages/demo-theme/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo-theme",
"version": "0.0.0-semantically-released",
"version": "0.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions packages/webiny-api-cms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webiny-api-cms",
"version": "0.0.0-semantically-released",
"version": "0.0.0",
"main": "index.js",
"repository": {
"type": "git",
Expand All @@ -13,8 +13,8 @@
"graphql-iso-date": "^3.5.0",
"mdbid": "^1.0.0",
"node-fetch": "2.1.2",
"webiny-api": "0.0.0-semantically-released",
"webiny-plugins": "0.0.0-semantically-released"
"webiny-api": "0.0.0",
"webiny-plugins": "0.0.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
Expand Down
16 changes: 8 additions & 8 deletions packages/webiny-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webiny-api",
"version": "0.0.0-semantically-released",
"version": "0.0.0",
"main": "index.js",
"repository": {
"type": "git",
Expand Down Expand Up @@ -28,12 +28,12 @@
"jsonwebtoken": "^8.2.2",
"lodash": "^4.17.4",
"md5": "^2.2.1",
"webiny-compose": "0.0.0-semantically-released",
"webiny-entity": "0.0.0-semantically-released",
"webiny-service-manager": "0.0.0-semantically-released",
"webiny-plugins": "0.0.0-semantically-released",
"webiny-sql-table-mysql": "0.0.0-semantically-released",
"webiny-sql-table-sync": "0.0.0-semantically-released"
"webiny-compose": "0.0.0",
"webiny-entity": "0.0.0",
"webiny-service-manager": "0.0.0",
"webiny-plugins": "0.0.0",
"webiny-sql-table-mysql": "0.0.0",
"webiny-sql-table-sync": "0.0.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
Expand All @@ -49,7 +49,7 @@
"fsevents": "^1.2.4"
},
"scripts": {
"build": "babel src types.js -d ${DEST:-build} --source-maps --copy-files --ignore types.js",
"build": "babel src -d ${DEST:-build} --source-maps --copy-files",
"flow-copy-source": "flow-copy-source src ${DEST:-build}",
"postbuild": "yarn flow-copy-source"
}
Expand Down
File renamed without changes.
7 changes: 0 additions & 7 deletions packages/webiny-app-admin/idea.js

This file was deleted.

Loading

0 comments on commit 6658d75

Please sign in to comment.