diff --git a/bin/app/webpack.dev.js b/bin/app/webpack.dev.js index fed1425..c195a87 100644 --- a/bin/app/webpack.dev.js +++ b/bin/app/webpack.dev.js @@ -1,4 +1,4 @@ -const merge = require("webpack-merge"); +const { merge } = require("webpack-merge"); const common = require("./webpack.common.js"); const path = require("path"); @@ -9,8 +9,8 @@ const config = { contentBase: path.resolve(__dirname, "public"), historyApiFallback: true, compress: true, - open: true - } + open: true, + }, }; module.exports = merge(common, config); diff --git a/bin/app/webpack.prod.js b/bin/app/webpack.prod.js index 3e667e9..26659bf 100644 --- a/bin/app/webpack.prod.js +++ b/bin/app/webpack.prod.js @@ -1,4 +1,4 @@ -const merge = require("webpack-merge"); +const { merge } = require("webpack-merge"); const common = require("./webpack.common.js"); const BundleAnalyzerPlugin = require("webpack-bundle-analyzer") .BundleAnalyzerPlugin; @@ -11,10 +11,10 @@ const config = { new BundleAnalyzerPlugin({ analyzerMode: "static", openAnalyzer: true, - reportFilename: "../analysis/bundle-analyzer.html" + reportFilename: "../analysis/bundle-analyzer.html", }), - new WebpackBundleSizeAnalyzerPlugin("../analysis/bundle-size-analyzer.log") - ] + new WebpackBundleSizeAnalyzerPlugin("../analysis/bundle-size-analyzer.log"), + ], }; module.exports = merge(common, config); diff --git a/bin/generator.js b/bin/generator.js index 6e02700..7d3e3ee 100644 --- a/bin/generator.js +++ b/bin/generator.js @@ -8,8 +8,7 @@ module.exports.ContentFile = ({ prefix, ts }) => { const typeArg = ts ? `: ${prefix}Props` : ""; const typeDef = ts - ? -` + ? ` type ${typeName} = { title: string; subtitle: string; @@ -125,7 +124,7 @@ type ${prefix}State = { text: string; }; -type ${prefix}Props = {}; +type ${prefix}Props = Record; ` : ``; @@ -256,14 +255,13 @@ const get${prefix}Action002 = () => ({ data: "RESULT OF YOUT ACTION", }); ${ - ts - ? -` + ts + ? ` export type ${prefix}Actions = ReturnType< typeof get${prefix}Action001 | typeof get${prefix}Action002 >; ` - : "" + : "" } export const ${prefix}ActionCreators = { actionCreator001() { @@ -285,30 +283,42 @@ export const ${prefix}ActionCreators = { module.exports.AppConstantFile = ({ prefixes, ts }) => { const actionTypeCode = prefixes .map( - prefix => -` ${prefix.toUpperCase()}_TYPE_001${ts ? " = " : ": "}"${prefix.toUpperCase()}_TYPE_001", - ${prefix.toUpperCase()}_TYPE_002${ts ? " = " : ": "}"${prefix.toUpperCase()}_TYPE_002", -`).reduce((p, c) => p + c, "").slice(0,-1); - -const actionCode = prefixes -.map( - prefix => `import { ${prefix}Actions } from "../actions/${prefix}ActionCreators"; -`).reduce((p, c) => p + c, ""); - -const exportActionCode = prefixes.map(prefix => [`${prefix}Actions`, ` | `]) - .reduce((p, c) => p.concat(c), []) - .slice(0, -1) - .reduce((p, c) => p + c, "") - -const code = ts ? `${actionCode} + (prefix) => + ` ${prefix.toUpperCase()}_TYPE_001${ + ts ? " = " : ": " + }"${prefix.toUpperCase()}_TYPE_001", + ${prefix.toUpperCase()}_TYPE_002${ + ts ? " = " : ": " + }"${prefix.toUpperCase()}_TYPE_002", +` + ) + .reduce((p, c) => p + c, "") + .slice(0, -1); + + const actionCode = prefixes + .map( + ( + prefix + ) => `import { ${prefix}Actions } from "../actions/${prefix}ActionCreators"; +` + ) + .reduce((p, c) => p + c, ""); + + const exportActionCode = prefixes + .map((prefix) => [`${prefix}Actions`, ` | `]) + .reduce((p, c) => p.concat(c), []) + .slice(0, -1) + .reduce((p, c) => p + c, ""); + + const code = ts + ? `${actionCode} export type Actions = ${exportActionCode}; export enum ActionTypes { ${actionTypeCode} } ` - : -`export const ActionTypes = { + : `export const ActionTypes = { ${actionTypeCode} }; `; diff --git a/package.json b/package.json index dbeadbe..e7ee74c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "starter-react-flux", - "version": "5.3.0", + "version": "5.3.1", "private": false, "preferGlobal": true, "scripts": {