8000 Merge pull request #15 from AlokTakshak/development · AlokTakshak/create-react-webpack@af56c02 · GitHub
[go: up one dir, main page]

Skip to content

Commit af56c02

Browse files
authored
Merge pull request #15 from AlokTakshak/development
Chnaged Prettier command to format all code
2 parents f54fe1a + 2868a64 commit af56c02

File tree

9 files changed

+208
-181
lines changed

9 files changed

+208
-181
lines changed

.prettierignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ignore node_modules
2+
node_modules
3+
4+
#ignore build folder
5+
dist
6+
7+
#ignore package-lock.json
8+
package-lock.json

.prettierrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tabWidth": 2,
3+
"semi": true,
4+
"singleQuote": false,
5+
"useTabs": true,
6+
"trailingComma": "all",
7+
"jsxBracketSameLine": true,
8+
"jsxSingleQuote": true
9+
}
10+

package.json

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
11
{
2-
"name": "create-react-webpack",
3-
"version": "0.1.2",
4-
"description": "create-react-webpack ",
5-
"main": "scripts/create.js",
6-
"bin": {
7-
"create-react-webpack": "./start.js"
8-
},
9-
"preferGlobal": true,
10-
"scripts": {
11-
"create-react-webpack": "node scripts/create.js"
12-
},
13-
"repository": {
14-
"type": "git",
15-
"url": "git+https://github.com/AlokTakshak/create-react-webpack.git"
16-
},
17-
"keywords": [
18-
"React",
19-
"Webpack"
20-
],
21-
"author": "Alok Takshak",
22-
"license": "ISC",
23-
"bugs": {
24-
"url": "https://github.com/AlokTakshak/create-react-webpack/issues"
25-
},
26-
"homepage": "https://github.com/AlokTakshak/create-react-webpack#readme",
27-
"dependencies": {
28-
"chalk": "^2.4.2",
29-
"update-notifier": "^3.0.1"
30-
}
2+
"name": "create-react-webpack",
3+
"version": "0.1.3",
4+
"description": "create-react-webpack ",
5+
"main": "scripts/create.js",
6+
"bin": {
7+
"create-react-webpack": "./start.js"
8+
},
9+
"preferGlobal": true,
10+
"scripts": {
11+
"create-react-webpack": "node scripts/create.js",
12+
"format": "prettier --write \"./**/*.{js,jsx,json}\""
13+
},
14+
"husky": {
15+
"hooks": {
16+
"pre-commit": "pretty-quick --staged"
17+
}
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "git+https://github.com/AlokTakshak/create-react-webpack.git"
22+
},
23+
"keywords": [
24+
"React",
25+
"Webpack"
26+
],
27+
"author": "Alok Takshak",
28+
"license": "ISC",
29+
"bugs": {
30+
"url": "https://github.com/AlokTakshak/create-react-webpack/issues"
31+
},
32+
"homepage": "https://github.com/AlokTakshak/create-react-webpack#readme",
33+
"dependencies": {
34+
"chalk": "^2.4.2",
35+
"husky": "^3.1.0",
36+
"prettier": "^1.19.1",
37+
"pretty-quick": "^2.0.1",
38+
"update-notifier": "^3.0.1"
39+
}
3140
}

scripts/constants.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
const CLEAN_NPM_CACHE = "npm cache clean --force";
22
const SPECIALCHAR = RegExp("/[!@#$%^&*()-=_,.?~:;\\{}|<>]/g");
33
const UNNECESSORY_FOLDERS_FOR_DEV = RegExp(
4-
"^node_modules|build|dist|server$",
5-
"i"
4+
"^node_modules|build|dist|server$",
5+
"i",
66
);
77
const UNNECESSORY_FOLDERS_FOR_PROD = RegExp("^node_modules|build|dist$", "i");
88

99
module.exports = {
10-
CLEAN_NPM_CACHE,
11-
SPECIALCHAR,
12-
UNNECESSORY_FOLDERS_FOR_DEV,
13-
UNNECESSORY_FOLDERS_FOR_PROD
10+
CLEAN_NPM_CACHE,
11+
SPECIALCHAR,
12+
UNNECESSORY_FOLDERS_FOR_DEV,
13+
UNNECESSORY_FOLDERS_FOR_PROD,
1414
};

scripts/create.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,46 @@ const path = require("path");
22
const { copyDirectory, ErrorMessage, SuccessMessage } = require("./helper");
33
const { CLEAN_NPM_CACHE, SPECIALCHAR } = require("./constants");
44
const {
5-
installDependencies,
6-
getDependencies,
7-
getDevDependencies,
8-
getProdDependencies
5+
installDependencies,
6+
getDependencies,
7+
getDevDependencies,
8+
getProdDependencies,
99
} = require("./dependencies");
1010

1111
var args = process.argv.slice(2);
1212
var dirName = args[0];
1313
var end_to_end = args[1];
1414

1515
if (dirName === "undefined") {
16-
throw new Error(ErrorMessage("directory name can't be empty"));
16+
throw new Error(ErrorMessage("directory name can't be empty"));
1717
} else if (dirName[0].match("^[A-Z0-9]")) {
18-
throw new Error(
19-
ErrorMessage("directory name can't start from capital letters ")
20-
);
18+
throw new Error(
19+
ErrorMessage("directory name can't start from capital letters "),
20+
);
2121
} else if (dirName.match(SPECIALCHAR)) {
22-
throw new Error(
23-
ErrorMessage(
24-
"directory name can't start from capital letters or contain special characters in it"
25-
)
26-
);
22+
throw new Error(
23+
ErrorMessage(
24+
"directory name can't start from capital letters or contain special characters in it",
25+
),
26+
);
2727
} else {
28-
//using process.cwd for getting current path
29-
const TEMPLATE_PATH = path.join(__dirname, "../template");
30-
let destination = path.join(process.cwd() + "/" + args[0]);
31-
const prod = end_to_end == "-e";
28+
//using process.cwd for getting current path
29+
const TEMPLATE_PATH = path.join(__dirname, "../template");
30+
let destination = path.join(process.cwd() + "/" + args[0]);
31+
const prod = end_to_end == "-e";
3232

33-
copyDirectory(TEMPLATE_PATH, destination, prod);
33+
copyDirectory(TEMPLATE_PATH, destination, prod);
3434

35-
let commands = [],
36-
options;
35+
let commands = [],
36+
options;
3737

38-
commands.push(CLEAN_NPM_CACHE);
39-
commands.push(getDependencies());
40-
prod && commands.push(getProdDependencies());
41-
commands.push(getDevDependencies());
38+
commands.push(CLEAN_NPM_CACHE);
39+
commands.push(getDependencies());
40+
prod && commands.push(getProdDependencies());
41+
commands.push(getDevDependencies());
4242

43-
options = { cwd: destination, stdio: "inherit" };
43+
options = { cwd: destination, stdio: "inherit" };
4444

45-
installDependencies(commands, options);
46-
console.log(SuccessMessage("Successfully created the directory"));
45+
installDependencies(commands, options);
46+
console.log(SuccessMessage("Successfully created the directory"));
4747
}

scripts/dependencies.js

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,63 @@ const child_process = require("child_process");
22

33
const DEPENDENCIES = ["prop-types", "react", "react-dom", "react-hot-loader"];
44
const DEV_DEPENDENCIES = [
5-
"@babel/cli",
6-
"@babel/core",
7-
"@babel/plugin-proposal-class-properties",
8-
"@babel/preset-env",
9-
"@babel/preset-react",
10-
"babel-loader",
11-
"brotli-webpack-plugin",
12-
"compression-webpack-plugin",
13-
"css-loader",
14-
"eslint",
15-
"eslint-plugin-react",
16-
"file-loader",
17-
"html-webpack-plugin",
18-
"husky",
19-
"jest",
20-
"prettier",
21-
"pretty-quick",
22-
"style-loader",
23-
"webpack",
24-
"webpack-cli",
25-
"webpack-dev-server",
26-
"webpack-manifest-plugin",
27-
"webpack-merge"
5+
"@babel/cli",
6+
"@babel/core",
7+
"@babel/plugin-proposal-class-properties",
8+
"@babel/preset-env",
9+
"@babel/preset-react",
10+
"babel-loader",
11+
"brotli-webpack-plugin",
12+
"compression-webpack-plugin",
13+
"css-loader",
14+
"eslint",
15+
"eslint-plugin-react",
16+
"file-loader",
17+
"html-webpack-plugin",
18+
"husky",
19+
"jest",
20+
"prettier",
21+
"pretty-quick",
22+
"style-loader",
23+
"webpack",
24+
"webpack-cli",
25+
"webpack-dev-server",
26+
"webpack-manifest-plugin",
27+
"webpack-merge",
2828
];
2929
const PROD_DEPENDENCIES = ["express", "express-static-gzip"];
3030

3131
/**
3232
* Returns npm command for installing dependencies
3333
*/
3434
function getDependencies() {
35-
var installCommand = "npm install --save";
36-
DEPENDENCIES.forEach(dependency => {
37-
installCommand += ` ${dependency} `;
38-
});
39-
return installCommand;
35+
var installCommand = "npm install --save";
36+
DEPENDENCIES.forEach(dependency => {
37+
installCommand += ` ${dependency} `;
38+
});
39+
return installCommand;
4040
}
4141

4242
/**
4343
* Returns npm command for installing dev-dependencies
4444
*/
4545
function getDevDependencies() {
46-
var installCommand = "npm install --save-dev";
47-
DEV_DEPENDENCIES.forEach(dependency => {
48-
installCommand += ` ${dependency} `;
49-
});
50-
return installCommand;
46+
var installCommand = "npm install --save-dev";
47+
DEV_DEPENDENCIES.forEach(dependency => {
48+
installCommand += ` ${dependency} `;
49+
});
50+
return installCommand;
5151
}
5252

5353
/**
5454
* Returns npm command for installing prod dependencies
5555
*/
5656
function getProdDependencies() {
57-
var installCommand = "npm install --save";
58-
PROD_DEPENDENCIES.forEach(dependency => {
59-
installCommand += ` ${dependency} `;
60-
});
61-
return installCommand;
57+
var installCommand = "npm install --save";
58+
PROD_DEPENDENCIES.forEach(dependency => {
10000
59+
installCommand += ` ${dependency} `;
60+
});
61+
return installCommand;
6262
}
6363

6464
/**
@@ -69,22 +69,22 @@ function getProdDependencies() {
6969
* @param {String} options.stdio process's stdio config
7070
*/
7171
function installDependencies(commands, options) {
72-
options.stdio = options.stdio || "inherit";
72+
options.stdio = options.stdio || "inherit";
7373

74-
if (commands) {
75-
try {
76-
commands.forEach(command => {
77-
child_process.execSync(command, options);
78-
});
79-
} catch (error) {
80-
throw error;
81-
}
82-
}
74+
if (commands) {
75+
try {
76+
commands.forEach(command => {
77+
child_process.execSync(command, options);
78+
});
79+
} catch (error) {
80+
throw error;
81+
}
82+
}
8383
}
8484

8585
module.exports = {
86-
installDependencies,
87-
getDependencies,
88-
getDevDependencies,
89-
getProdDependencies
86+
installDependencies,
87+
getDependencies,
88+
getDevDependencies,
89+
getProdDependencies,
9090
};

0 commit comments

Comments
 (0)
0