Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit 9014d4a

Browse files
authored
Merge pull request #263 from Nargonath/master
Deploy 3.4.0
2 parents 7165a49 + 6ef6fbb commit 9014d4a

File tree

7 files changed

+1435
-1192
lines changed

7 files changed

+1435
-1192
lines changed

.dependabot/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ update_configs:
1111
default_labels:
1212
- 'dependency'
1313
target_branch: 'master'
14+
commit_message:
15+
prefix: 'fix'
16+
prefix_development: 'build'
17+
include_scope: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ typings/
5757
# dotenv environment variables file
5858
.env
5959

60+
# ignore NPM package-lock because we use yarn
61+
package-lock.json

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ By default the script will generate everything into `build/` at your project roo
8585

8686
If those defaults do not work for you, the script accepts some arguments:
8787

88+
- `--after-initial-build-hook`: accepts a string of shell code that will be run only once after the initial build in the same process as the `cra-build-watch`.
89+
- `--after-rebuild-hook`: accepts a string of shell code that will be run every time webpack rebuilds your project after a filesystem change. It runs in the same process as `cra-build-watch`.
8890
- `-b|--build-path`: expects either an absolute or relative path. If a relative path is given it will be prefixed by your project root path.
8991
- default: `yourProjectRoot/build`.
9092
- `--chunk-filename`: Set the naming you want to use for non-entry chunk files. Accepts webpack placeholders such as `[id]`, `[name]`, `[hash]`. Directories can be supplied.
@@ -99,4 +101,4 @@ If those defaults do not work for you, the script accepts some arguments:
99101

100102
# Contributions
101103

102-
All contributions are welcomed. Please base your PR on the `develop` branch rather than `master`.
104+
All contributions are welcomed.

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,22 @@
8181
"react-scripts": ">= 1.0.x"
8282
},
8383
"devDependencies": {
84-
"@commitlint/cli": "8.3.5",
84+
"@commitlint/cli": "11.0.0",
8585
"@commitlint/config-conventional": "8.3.4",
8686
"@dixeed/eslint-config": "2.0.0",
8787
"cz-conventional-changelog": "3.1.0",
8888
"eslint": "6.8.0",
89-
"husky": "4.2.1",
90-
"jest": "^25.1.0",
91-
"lint-staged": "10.0.7",
92-
"prettier": "1.19.1"
89+
"husky": "4.3.0",
90+
"jest": "^26.6.1",
91+
"lint-staged": "10.5.1",
92+
"prettier": "2.1.2"
9393
},
9494
"dependencies": {
95-
"cross-spawn": "7.0.1",
96-
"fs-extra": "^8.1.0",
95+
"cross-spawn": "7.0.3",
96+
"fs-extra": "^9.0.1",
9797
"html-webpack-plugin": "^4.5.0",
9898
"import-cwd": "3.0.0",
99-
"meow": "6.0.0",
99+
"meow": "8.0.0",
100100
"ora": "4.0.3",
101101
"semver": "^7.1.1"
102102
}

scripts/index.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const fs = require('fs-extra');
88
const path = require('path');
99
const ora = require('ora');
1010
const assert = require('assert');
11+
const exec = require('child_process').exec;
1112

1213
const {
1314
flags: {
@@ -18,6 +19,8 @@ const {
1819
disableChunks,
1920
outputFilename,
2021
chunkFilename,
22+
afterInitialBuildHook,
23+
afterRebuildHook,
2124
},
2225
} = require('../utils/cliHandler');
2326
const { getReactScriptsVersion, isEjected } = require('../utils');
@@ -91,12 +94,11 @@ if (disableChunks) {
9194

9295
// update media path destination
9396
if (major >= 4) {
94-
const oneOfIndex = 1
97+
const oneOfIndex = 1;
9598
config.module.rules[oneOfIndex].oneOf[0].options.name = `media/[name].[hash:8].[ext]`;
9699
config.module.rules[oneOfIndex].oneOf[1].options.name = `media/[name].[hash:8].[ext]`;
97100
config.module.rules[oneOfIndex].oneOf[8].options.name = `media/[name].[hash:8].[ext]`;
98-
}
99-
else if (major >= 2) {
101+
} else if (major >= 2) {
100102
// 2.0.0 => 2
101103
// 2.0.1 => 3
102104
// 2.0.2 => 3
@@ -150,6 +152,9 @@ fs.emptyDir(paths.appBuild)
150152
}
151153

152154
spinner.succeed();
155+
156+
runHook('after rebuild hook', spinner, afterRebuildHook);
157+
153158
inProgress = false;
154159

155160
if (verbose) {
@@ -167,7 +172,8 @@ fs.emptyDir(paths.appBuild)
167172
});
168173
});
169174
})
170-
.then(() => copyPublicFolder());
175+
.then(() => copyPublicFolder())
176+
.then(() => runHook('after initial build hook', spinner, afterInitialBuildHook));
171177

172178
function copyPublicFolder() {
173179
return fs.copy(paths.appPublic, resolvedBuildPath, {
@@ -176,6 +182,24 @@ function copyPublicFolder() {
176182
});
177183
}
178184

185+
function runHook(label, spinner, hook) {
186+
if (!hook || typeof hook !== 'string') {
187+
return;
188+
}
189+
190+
spinner.start(label);
191+
192+
exec(hook, (error, stdout, stderr) => {
193+
if (error) {
194+
spinner.fail(`${label}: exec error: ${error}`);
195+
} else if (stderr) {
196+
spinner.warn(`${label}: ${stderr}`);
197+
} else {
198+
spinner.succeed(`${label}: ${stdout}`);
199+
}
200+
});
201+
}
202+
179203
function handleBuildPath(userBuildPath) {
180204
if (path.isAbsolute(userBuildPath)) {
181205
return userBuildPath;

utils/cliHandler.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ module.exports = meow(
1818
1919
-p, --public-path Public URL.
2020
21+
--after-rebuild-hook Run a command after each build/rebuild (e.g. 'node ./afterbuild.js')
22+
23+
--after-initial-build-hook Run a command after each the initial build only (e.g. 'node ./afterbuild.js')
24+
2125
--react-scripts-version Version of the react-scripts package used in your project i.e 2.0.3. If not given it will be implied from your package.json and if it cannot be implied the major version 2 will be the default.
2226
2327
-v, --verbose
@@ -54,6 +58,12 @@ module.exports = meow(
5458
type: 'boolean',
5559
alias: 'v',
5660
},
61+
'after-initial-build-hook': {
62+
type: 'string',
63+
},
64+
'after-rebuild-hook': {
65+
type: 'string',
66+
}
5767
},
5868
}
5969
);

0 commit comments

Comments
 (0)