Skip to content

Commit

Permalink
Merge pull request #14 from alexlee-dev/v0.4.0
Browse files Browse the repository at this point in the history
📦 v0.4.0
  • Loading branch information
Alex Lee authored Jun 5, 2020
2 parents 8629116 + bfbbc2a commit 142f49a
Show file tree
Hide file tree
Showing 42 changed files with 6,627 additions and 919 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@babel/preset-env"],
"plugins": ["@babel/plugin-transform-runtime"]
}
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.0] - 2020-06-04

### 🧪 Testing

### Added

- Tests [#6](https://github.com/alexlee-dev/create-mern-application/issues/6)
- Favicon to Template [#11](https://github.com/alexlee-dev/create-mern-application/issues/11)

### Changed

- Build commands are quieter - only displaying errors [#4](https://github.com/alexlee-dev/create-mern-application/issues/4)
- Yellow chalk logs to Blue chalk logs [#5](https://github.com/alexlee-dev/create-mern-application/issues/5)

### Removed

### Fixed

## [0.3.0] - 2020-06-04

### ✨ MongoDB Support
Expand Down
156 changes: 156 additions & 0 deletions __tests__/application.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import { describe, expect, it, test } from "@jest/globals";
import fs from "fs-extra";
import path from "path";
import { executeCommand } from "../build/util";
import { fileMatcher } from "./util";

describe("create-mern-application", () => {
test("Create a JavaScript MERN application", async () => {
const root = path.resolve("test-application");

let verificationArr;

try {
await executeCommand("create-mern-application", ["test-application"]);

const templateBase = path.join(__dirname, "../src/template");

const filesToVerify = [
{
src: path.join(root, ".babelrc"),
fileContentsSrc: path.join(templateBase, "/babelrc"),
},
{
src: path.join(root, ".env-cmdrc.json"),
fileContentsSrc: path.join(__dirname, "./fixtures/.env-cmdrc.json"),
},
{
src: path.join(root, ".gitignore"),
fileContentsSrc: path.join(templateBase, "gitignore"),
},
{
src: path.join(root, "package.json"),
fileContentsSrc: path.join(__dirname, "./fixtures/package-js.json"),
},
{
src: path.join(root, "/public/index.html"),
fileContentsSrc: path.join(__dirname, "./fixtures/index.html"),
},
{
src: path.join(root, "README.md"),
fileContentsSrc: path.join(__dirname, "./fixtures/README.md"),
},
{
src: path.join(root, "webpack.config.js"),
fileContentsSrc: path.join(templateBase, "webpack-js.js"),
},
{
src: path.join(root, "/src/server/assets/site.webmanifest"),
fileContentsSrc: path.join(__dirname, "./fixtures/site.webmanifest"),
},
];

verificationArr = await Promise.all(
filesToVerify.map(async ({ src, fileContentsSrc }) => {
const fileContents = await fs.readFile(fileContentsSrc);
const doesFileMatch = await fileMatcher(src, fileContents);
return { doesFileMatch, src };
})
);

await executeCommand("rimraf", [root], {
shell: process.platform === "win32",
});
} catch (error) {
await executeCommand("rimraf", [root], {
shell: process.platform === "win32",
});
throw new Error(error);
}

expect(verificationArr).toEqual(
verificationArr.map(({ src }) => ({
doesFileMatch: true,
src,
}))
);
}, 120000);

test("Create a TypeScript MERN application", async () => {
const root = path.resolve("test-application");

let verificationArr;

try {
await executeCommand("create-mern-application", [
"test-application",
"--typescript",
]);

const templateBase = path.join(__dirname, "../src/template");

const filesToVerify = [
{
src: path.join(root, ".env-cmdrc.json"),
fileContentsSrc: path.join(__dirname, "./fixtures/.env-cmdrc.json"),
},
{
src: path.join(root, ".gitignore"),
fileContentsSrc: path.join(templateBase, "gitignore"),
},
{
src: path.join(root, "index.d.ts"),
fileContentsSrc: path.join(templateBase, "/ts/index.d.ts"),
},
{
src: path.join(root, "package.json"),
fileContentsSrc: path.join(__dirname, "./fixtures/package-ts.json"),
},
{
src: path.join(root, "/public/index.html"),
fileContentsSrc: path.join(__dirname, "./fixtures/index.html"),
},
{
src: path.join(root, "README.md"),
fileContentsSrc: path.join(__dirname, "./fixtures/README.md"),
},
{
src: path.join(root, "tsconfig.json"),
fileContentsSrc: path.join(__dirname, "./fixtures/tsconfig.json"),
},
{
src: path.join(root, "webpack.config.js"),
fileContentsSrc: path.join(templateBase, "webpack-ts.js"),
},
{
src: path.join(root, "/src/server/assets/site.webmanifest"),
fileContentsSrc: path.join(__dirname, "./fixtures/site.webmanifest"),
},
];

verificationArr = await Promise.all(
filesToVerify.map(async ({ src, fileContentsSrc }) => {
const fileContents = await fs.readFile(fileContentsSrc);
const doesFileMatch = await fileMatcher(src, fileContents);
return { doesFileMatch, src };
})
);

await executeCommand("rimraf", [root], {
shell: process.platform === "win32",
});
} catch (error) {
await executeCommand("rimraf", [root], {
shell: process.platform === "win32",
});
throw new Error(error);
}

expect(verificationArr).toEqual(
verificationArr.map(({ src }) => ({
doesFileMatch: true,
src,
}))
);
}, 120000);
});
20 changes: 20 additions & 0 deletions __tests__/fixtures/.env-cmdrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"production": {
"APP_NAME": "test-application",
"MONGODB_URL": "mongodb://localhost:27017/test-application",
"NODE_ENV": "production",
"PORT": 3000
},
"development": {
"APP_NAME": "test-application",
"MONGODB_URL": "mongodb://localhost:27017/test-application",
"NODE_ENV": "development",
"PORT": 3000
},
"test": {
"APP_NAME": "test-application",
"MONGODB_URL": "mongodb://localhost:27017/test-application",
"NODE_ENV": "test",
"PORT": 3000
}
}
36 changes: 36 additions & 0 deletions __tests__/fixtures/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<p align="center">
<a href="" rel="noopener">
<img width=256px height=256px src="https://svgshare.com/i/LWJ.svg" alt="Project logo"></a>
</p>

<h3 align="center">test-application</h3>

---

<p align="center"> This application was bootstrapped with <b>create-mern-application</b>
<br>
</p>

## 📝 Table of Contents

- [Getting Started](#getting_started)
- [Built Using](#built_using)
- [Authors](#authors)

## 🏁 Getting Started <a name = "getting_started"></a>

### Creating a Build

`npm run build`

### Starting Program

Please be sure to start your MongoDB instance prior to starting your application.

`npm start`

## ⛏️ Built Using <a name = "built_using"></a>

## ✍️ Authors <a name = "authors"></a>

- [Alex Lee](https://github.com/alexlee-dev) - Application Developer
48 changes: 48 additions & 0 deletions __tests__/fixtures/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>test-application</title>
<meta name="title" content="test-application" />
<meta
name="description"
content="Bootstrapped application with create-mern-application."
/>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<!-- FAVICON -->
<link
rel="apple-touch-icon"
sizes="180x180"
href="/assets/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/assets/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/assets/favicon-16x16.png"
/>
<link rel="manifest" href="/assets/site.webmanifest" />
<link
rel="mask-icon"
href="/assets/safari-pinned-tab.svg"
color="#00d3ff"
/>
<meta name="apple-mobile-web-app-title" content="test-application" />
<meta name="application-name" content="test-application" />
<meta name="msapplication-TileColor" content="#0e0e0e" />
<meta name="theme-color" content="#0e0e0e" />

<script src="/scripts/react.js"></script>
<script src="/scripts/react-dom.js"></script>
</head>
<body>
<div id="root"></div>
</body>
</html>
51 changes: 51 additions & 0 deletions __tests__/fixtures/package-js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "test-application",
"version": "0.0.0",
"description": "A MERN application bootstrapped with create-mern-application.",
"main": "build/index.js",
"scripts": {
"build": "rimraf dist && webpack --display=errors-only && rimraf build && babel src/server --out-dir build",
"dev": "env-cmd -e development npm run spinup",
"spinup": "node build/index.js",
"start": "start-server-and-test dev http://localhost:3000 'webpack-dev-server --info=false'",
"test": "start-server-and-test test-server http://localhost:3000 cy:run",
"test-gui": "start-server-and-test test-server http://localhost:3000 cy:open",
"test-server": "env-cmd -e test npm start"
},
"keywords": [],
"author": "",
"license": "",
"dependencies": {
"chalk": "^4.0.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"mongoose": "^5.9.17",
"morgan": "^1.10.0",
"node-fetch": "^2.6.0",
"react": "^16.13.1",
"react-dom": "^16.13.1"
},
"devDependencies": {
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/plugin-transform-runtime": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"@babel/preset-react": "^7.10.1",
"@babel/runtime": "^7.10.2",
"@svgr/webpack": "^5.4.0",
"babel-loader": "^8.1.0",
"clean-webpack-plugin": "^3.0.0",
"copyfiles": "^2.3.0",
"css-loader": "^3.5.3",
"env-cmd": "^10.1.0",
"html-webpack-plugin": "^4.3.0",
"rimraf": "^3.0.2",
"source-map-loader": "^1.0.0",
"start-server-and-test": "^1.11.0",
"style-loader": "^1.2.1",
"url-loader": "^4.1.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.11.0"
}
}
Loading

0 comments on commit 142f49a

Please sign in to comment.