-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from alexlee-dev/v0.4.0
📦 v0.4.0
- Loading branch information
Showing
42 changed files
with
6,627 additions
and
919 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": ["@babel/preset-env"], | ||
"plugins": ["@babel/plugin-transform-runtime"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
Oops, something went wrong.