Skip to content

Commit

Permalink
Merge pull request #124 from jchip/master
Browse files Browse the repository at this point in the history
Sync internal archetypes for src/lib mode
  • Loading branch information
jchip authored Jan 26, 2017
2 parents 26f4af3 + 1fe794a commit cfcf71e
Show file tree
Hide file tree
Showing 98 changed files with 1,267 additions and 546 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const runAppTest = (dir, forceLocal) => {
const appPkgFile = `${dir}/package.json`;
let appPkgData;

if (forceLocal || process.env.BUILD_TEST) {
if (forceLocal || process.env.BUILD_TEST || process.env.CI) {
appPkgData = fs.readFileSync(appPkgFile).toString();
const appPkg = JSON.parse(appPkgData);
updateToLocalPkgs(appPkg["dependencies"], localPkgs);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("electrode-archetype-react-app/config/archetype");
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"presets": [
"es2015",
"es2015-loose",
"react"
],
"plugins": [
"babel-plugin-transform-object-rest-spread",
["babel-plugin-react-intl", {
"messagesDir": "./tmp/messages/",
"enforceDescriptions": true
}],
"lodash",
"transform-runtime"
],
"env": {
"production": {
"plugins": [
"babel-plugin-transform-react-constant-elements"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"es2015-node"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ window.mocha.setup({
// --------------------------------------------------------------------------
// Use webpack to include all app code _except_ the entry point so we can get
// code coverage in the bundle, whether tested or not.
// NOTE: No need to specify src even in src mode since webpack should handle that already
var srcReq = require.context("client", true, /^((?!app).)*\.jsx?$/);
srcReq.keys().map(srcReq);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function (config) {
{ type: "lcov" },
{ type: "text" }
],
dir: path.join(process.cwd(), "coverage/client")
dir: path.resolve("coverage", "client")
}
});
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";
var Path = require("path");
var path = require("path");

var webpackCfg = require("../webpack/webpack.config.test");

Expand Down Expand Up @@ -46,7 +46,7 @@ module.exports = function (config) {
{ type: "lcov" },
{ type: "text" }
],
dir: Path.join(process.cwd(), "coverage/client")
dir: path.resolve("coverage", "client")
},
captureTimeout: 100000,
singleRun: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function (config) {
// Watch these files but do not add them to the bundle.
].concat(
[
"client/**",
"src/client/**",
"test/**"
].map(function (pattern) {
return {
Expand All @@ -32,4 +32,3 @@ module.exports = function (config) {
});

};

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--require electrode-archetype-react-app-dev/config/mocha/setup.js
--reporter spec
--recursive
--ui bdd
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"use strict";

var archetype = require("../archetype");
var _ = require("lodash");
var fs = require("fs");
var path = require("path");
var glob = archetype.devRequire("glob");
var glob = require("glob");
var webpack = require("webpack");
var archetype = require("../archetype");
var Path = archetype.Path;

module.exports = function (config) {
try {
var exists = fs.accessSync(path.join(process.cwd(), "client/dll.config.js"));
var filenames = glob.sync(path.join(process.cwd(), "dll/js/*-manifest.*.json"));
var exists = fs.existsSync(Path.resolve(archetype.AppMode.src.client, "dll.config.js"));
var filenames = glob.sync(Path.resolve("dll", "js", "*-manifest.*.json"));

if (exists && filenames.length) {
config.plugins = _.concat(config.plugins || [], filenames.map(function (filename) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"use strict";

var archetype = require("../archetype");
var mergeWebpackConfig = archetype.devRequire("webpack-partial").default;
var Path = archetype.PlatformPath;
var mergeWebpackConfig = require("webpack-partial").default;
var Path = archetype.Path;

var baseConfig = require("./base.js");

Expand All @@ -19,7 +18,7 @@ var testConfig = {
/node_modules\/sinon\//
]
},
context: Path.join(process.cwd(), "test/client"),
context: Path.resolve("test", "client"),
debug: false,
devServer: {
stats: "errors-only" // only show errors
Expand All @@ -34,7 +33,7 @@ var testConfig = {
alias: {
// Allow root import of `src/FOO` from ROOT/src.
src: process.cwd(),
sinon: archetype.devRequire.resolve("sinon/pkg/sinon")
sinon: require.resolve("sinon/pkg/sinon")
}
},
// Enzyme depends jsdom and cheerio being global to render their DOM.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

var _ = require("lodash");
var fs = require("fs");
var archetype = require("../archetype");
var Path = archetype.PlatformPath;
var mergeWebpackConfig = archetype.devRequire("webpack-partial").default;
var mergeWebpackConfig = require("webpack-partial").default;

// config partials
var babelConfig = require("./partial/babel");
Expand All @@ -15,13 +13,15 @@ var statsConfig = require("./partial/stats");
var isomorphicConfig = require("./partial/isomorphic");
var jsonConfig = require("./partial/json");
var pwaConfig = require("./partial/pwa");
var archetype = require("../archetype");
var Path = archetype.Path;
var AppMode = archetype.AppMode;
var context = Path.resolve(AppMode.src.client);

var archetypeNodeModules = Path.join(__dirname, "../../node_modules");
var archetypeDevNodeModules = Path.join(archetype.devPath, "node_modules");
var archetypeNodeModules = Path.join(archetype.dir, "node_modules");
var archetypeDevNodeModules = Path.join(archetype.devDir, "node_modules");
var inspectpack = process.env.INSPECTPACK_DEBUG === "true";

var context = Path.resolve(archetype.clientSrcDir);

/* eslint-disable func-style */

/*
Expand Down Expand Up @@ -57,7 +57,7 @@ var baseConfig = {
debug: false,
entry: entry,
output: {
path: Path.resolve("dist/js"),
path: Path.resolve("dist", "js"),
pathinfo: inspectpack, // Enable path information for inspectpack
publicPath: "/js/",
chunkFilename: "[hash].[name].js",
Expand All @@ -66,12 +66,22 @@ var baseConfig = {
: "bundle.[hash].js"
},
resolve: {
root: [archetypeNodeModules, archetypeDevNodeModules, process.cwd()],
modulesDirectories: ["client", "node_modules"].concat(archetype.webpack.modulesDirectories),
root: [
archetypeNodeModules,
archetypeDevNodeModules,
AppMode.isSrc && Path.resolve(AppMode.src.dir) || null,
process.cwd()
].filter((x) => x),
modulesDirectories: ["node_modules"].concat(archetype.webpack.modulesDirectories),
extensions: ["", ".js", ".jsx"]
},
resolveLoader: {
root: [archetypeNodeModules, archetypeDevNodeModules, process.cwd()]
root: [
archetypeNodeModules,
archetypeDevNodeModules,
Path.resolve("lib"),
process.cwd()
].filter((x) => x)
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ module.exports = function (rootConfigFileName) {
var rootConfig;

try {
rootConfig = require( // eslint-disable-line global-require
path.join(process.cwd(), rootConfigFileName)
);
rootConfig = require(path.resolve(rootConfigFileName)); // eslint-disable-line global-require
} catch (err) {
rootConfig = {};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";

var mergeWebpackConfig = require("webpack-partial").default;
var archetype = require("../../archetype");
var AppMode = archetype.AppMode;
var Path = archetype.Path;

module.exports = function (babel) {
var babelExcludeRegex = new RegExp(`(node_modules|\b${Path.join(AppMode.src.client, "vendor")}\b)`);
return function (config) {
return mergeWebpackConfig(config, {
module: {
loaders: [{
name: "babel",
test: /\.jsx?$/,
exclude: babelExcludeRegex,
// NOTE: webpack.config.hot.js inserts "react-hot" into loaders array
loader: "babel-loader",
query: babel
},
{
name: "json",
test: /\.json$/,
loader: "json"
}]
}
});
};
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"use strict";

var archetype = require("../../archetype");
var mergeWebpackConfig = archetype.devRequire("webpack-partial").default;
var ispartaLoader = archetype.devRequire.resolve("isparta-loader");
var ispartaLoader = require.resolve("isparta-loader");
var mergeWebpackConfig = require("webpack-partial").default;

module.exports = function () {
return function (config) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"use strict";

var archetype = require("../../archetype");
var mergeWebpackConfig = archetype.devRequire("webpack-partial").default;
var DefinePlugin = archetype.devRequire("webpack").DefinePlugin;
var mergeWebpackConfig = require("webpack-partial").default;
var DefinePlugin = require("webpack").DefinePlugin;

module.exports = function () {
return function (config) {
Expand All @@ -18,4 +17,3 @@ module.exports = function () {
});
};
};

Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
"use strict";

var mergeWebpackConfig = require("webpack-partial").default;
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var WebpackReporter = require("electrode-webpack-reporter");
var webpack = require("webpack");
var Fs = require("fs");
var archetype = require("../../archetype");
var mergeWebpackConfig = archetype.devRequire("webpack-partial").default;
var ExtractTextPlugin = archetype.devRequire("extract-text-webpack-plugin");
var webpack = archetype.devRequire("webpack");
var WebpackReporter = archetype.devRequire("electrode-webpack-reporter");
var fs = require("fs");
var Path = archetype.Path;

function notifyBundleValid() {
setTimeout(function () {
fs.writeFileSync(".etmp/bundle.valid.log", `${Date.now()}`);
Fs.writeFileSync(Path.resolve(archetype.eTmpDir, "bundle.valid.log"), `${Date.now()}`);
}, 100);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
"use strict";

var archetype = require("../../archetype");
var Path = archetype.PlatformPath;
var mergeWebpackConfig = archetype.devRequire("webpack-partial").default;
var Path = archetype.Path;
var mergeWebpackConfig = require("webpack-partial").default;

var glob = archetype.devRequire("glob");
var ExtractTextPlugin = archetype.devRequire("extract-text-webpack-plugin");
var CSSSplitPlugin = archetype.devRequire("css-split-webpack-plugin").default;
var atImport = archetype.devRequire("postcss-import");
var cssnext = archetype.devRequire("postcss-cssnext");
var glob = require("glob");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var CSSSplitPlugin = require("css-split-webpack-plugin").default;
var atImport = require("postcss-import");
var cssnext = require("postcss-cssnext");

var autoprefixer = archetype.devRequire("autoprefixer-stylus");
var cssLoader = archetype.devRequire.resolve("css-loader");
var styleLoader = archetype.devRequire.resolve("style-loader");
var stylusLoader = archetype.devRequire.resolve("stylus-relative-loader");
var postcssLoader = archetype.devRequire.resolve("postcss-loader");
var autoprefixer = require("autoprefixer-stylus");
var cssLoader = require.resolve("css-loader");
var styleLoader = require.resolve("style-loader");
var stylusLoader = require.resolve("stylus-relative-loader");
var postcssLoader = require.resolve("postcss-loader");

var AppMode = archetype.AppMode;

/**
* [cssModuleSupport By default, this archetype assumes you are using CSS-Modules + CSS-Next]
Expand All @@ -28,8 +30,8 @@ var postcssLoader = archetype.devRequire.resolve("postcss-loader");
* case 4: *none* *.css & *.styl exists => CSS-Modules + CSS-Next takes priority
*/

var cssNextExists = (glob.sync(Path.join(process.cwd() + "/client/**/*.css")).length > 0);
var stylusExists = (glob.sync(Path.join(process.cwd() + "/client/**/*.styl")).length > 0);
var cssNextExists = (glob.sync(Path.resolve(AppMode.src.client, "**", "*.css")).length > 0);
var stylusExists = (glob.sync(Path.resolve(AppMode.src.client, "**", "*.styl")).length > 0);

// By default, this archetype assumes you are using CSS-Modules + CSS-Next
var cssModuleSupport = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";

var mergeWebpackConfig = require("webpack-partial").default;
var FailPlugin = require("webpack-fail-plugin");

module.exports = function () {
return function (config) {
return mergeWebpackConfig(config, {
plugins: [
FailPlugin
]
});
};
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"use strict";

var archetype = require("../../archetype");
var mergeWebpackConfig = archetype.devRequire("webpack-partial").default;
var mergeWebpackConfig = require("webpack-partial").default;

var urlLoader = archetype.devRequire.resolve("url-loader");
var fileLoader = archetype.devRequire.resolve("file-loader");
var urlLoader = require.resolve("url-loader");
var fileLoader = require.resolve("file-loader");

module.exports = function () {
return function (config) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

var archetype = require("../../archetype");
var mergeWebpackConfig = archetype.devRequire("webpack-partial").default;
var mergeWebpackConfig = require("webpack-partial").default;

var getDefaultEntry = function (entry) {
return [
Expand Down
Loading

0 comments on commit cfcf71e

Please sign in to comment.