@reactunity/scripts 0.19.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/react-unity-scripts.js +11 -31
- package/config/babel-preset-extended.js +3 -3
- package/config/env.js +10 -20
- package/config/getHttpsConfig.js +7 -23
- package/config/jest/babelTransform.js +1 -9
- package/config/jest/cssTransform.js +1 -9
- package/config/jest/fileTransform.js +2 -2
- package/config/modules.js +11 -17
- package/config/paths.js +10 -37
- package/config/unityMiddleware.js +2 -2
- package/config/webpack/persistentCache/createEnvironmentHash.js +3 -3
- package/config/webpack.config.js +132 -211
- package/config/webpackDevServer.config.js +7 -16
- package/lib/types/base.d.ts +1 -3
- package/package.json +32 -42
- package/scripts/build.js +19 -63
- package/scripts/clean.js +2 -3
- package/scripts/eject.js +40 -109
- package/scripts/init.js +33 -102
- package/scripts/start.js +18 -43
- package/scripts/test.js +9 -29
- package/scripts/utils/cleanBuildDirectory.js +14 -15
- package/scripts/utils/createJestConfig.js +16 -61
- package/scripts/utils/verifyTypeScriptSetup.js +49 -100
- package/tsconfig.json +1 -3
- package/config/eslint/base.js +0 -43
- package/config/eslint/config.js +0 -252
- package/config/eslint/jest.js +0 -59
- package/config/eslintConfig.js +0 -31
- package/scripts/lint.js +0 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactunity/scripts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Configuration and scripts for React Unity.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -45,66 +45,56 @@
|
|
|
45
45
|
},
|
|
46
46
|
"tsconfig": "./tsconfig.json",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@babel/core": "^7.
|
|
49
|
-
"@babel/eslint-parser": "^7.24.5",
|
|
48
|
+
"@babel/core": "^7.27.4",
|
|
50
49
|
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
|
51
|
-
"@babel/preset-react": "^7.
|
|
52
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.
|
|
50
|
+
"@babel/preset-react": "^7.27.1",
|
|
51
|
+
"@pmmmwh/react-refresh-webpack-plugin": "^0.6.0",
|
|
53
52
|
"@svgr/webpack": "^8.1.0",
|
|
54
|
-
"@types/react": "^
|
|
55
|
-
"@types/webpack-env": "^1.18.
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"babel-jest": "^29.7.0",
|
|
59
|
-
"babel-loader": "^9.1.3",
|
|
53
|
+
"@types/react": "^19.1.8",
|
|
54
|
+
"@types/webpack-env": "^1.18.8",
|
|
55
|
+
"babel-jest": "^30.0.2",
|
|
56
|
+
"babel-loader": "^10.0.0",
|
|
60
57
|
"babel-plugin-named-asset-import": "^0.3.8",
|
|
61
|
-
"babel-preset-react-app": "^10.0
|
|
62
|
-
"bfj": "^
|
|
58
|
+
"babel-preset-react-app": "^10.1.0",
|
|
59
|
+
"bfj": "^9.1.2",
|
|
63
60
|
"camelcase": "^8.0.0",
|
|
64
61
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
65
62
|
"confusing-browser-globals": "^1.0.11",
|
|
66
|
-
"css-loader": "^7.1.
|
|
67
|
-
"dotenv": "^16.
|
|
68
|
-
"dotenv-expand": "^
|
|
69
|
-
"eslint": "^8.57.0",
|
|
70
|
-
"eslint-plugin-import": "^2.29.1",
|
|
71
|
-
"eslint-plugin-jest": "^28.4.0",
|
|
72
|
-
"eslint-plugin-react": "^7.34.1",
|
|
73
|
-
"eslint-plugin-react-hooks": "^4.6.2",
|
|
74
|
-
"eslint-plugin-testing-library": "^6.2.2",
|
|
75
|
-
"eslint-webpack-plugin": "^4.1.0",
|
|
63
|
+
"css-loader": "^7.1.2",
|
|
64
|
+
"dotenv": "^16.5.0",
|
|
65
|
+
"dotenv-expand": "^12.0.2",
|
|
76
66
|
"file-loader": "^6.2.0",
|
|
77
|
-
"fork-ts-checker-webpack-plugin": "^9.0
|
|
78
|
-
"fs-extra": "^11.
|
|
67
|
+
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
68
|
+
"fs-extra": "^11.3.0",
|
|
79
69
|
"identity-obj-proxy": "^3.0.0",
|
|
80
|
-
"jest": "^
|
|
81
|
-
"jest-resolve": "^
|
|
82
|
-
"jest-watch-typeahead": "^
|
|
83
|
-
"mini-css-extract-plugin": "^2.9.
|
|
70
|
+
"jest": "^30.0.3",
|
|
71
|
+
"jest-resolve": "^30.0.2",
|
|
72
|
+
"jest-watch-typeahead": "^3.0.1",
|
|
73
|
+
"mini-css-extract-plugin": "^2.9.2",
|
|
84
74
|
"null-loader": "^4.0.1",
|
|
85
|
-
"postcss": "^8.
|
|
75
|
+
"postcss": "^8.5.6",
|
|
86
76
|
"postcss-loader": "^8.1.1",
|
|
87
77
|
"prompts": "^2.4.2",
|
|
88
78
|
"raw-loader": "^4.0.2",
|
|
89
79
|
"react-app-polyfill": "^3.0.0",
|
|
90
80
|
"react-dev-utils": "^12.0.1",
|
|
91
|
-
"react-refresh": "^0.
|
|
92
|
-
"resolve": "^1.22.
|
|
81
|
+
"react-refresh": "^0.17.0",
|
|
82
|
+
"resolve": "^1.22.10",
|
|
93
83
|
"resolve-url-loader": "^5.0.0",
|
|
94
|
-
"sass": "^1.
|
|
95
|
-
"sass-loader": "^
|
|
96
|
-
"semver": "^7.
|
|
84
|
+
"sass": "^1.89.2",
|
|
85
|
+
"sass-loader": "^16.0.5",
|
|
86
|
+
"semver": "^7.7.2",
|
|
97
87
|
"source-map-loader": "^5.0.0",
|
|
98
88
|
"style-loader": "^4.0.0",
|
|
99
|
-
"tailwindcss": "^
|
|
100
|
-
"terser-webpack-plugin": "^5.3.
|
|
89
|
+
"tailwindcss": "^4.1.10",
|
|
90
|
+
"terser-webpack-plugin": "^5.3.14",
|
|
101
91
|
"url-loader": "^4.1.1",
|
|
102
|
-
"webpack": "^5.
|
|
103
|
-
"webpack-dev-server": "^5.
|
|
104
|
-
"webpack-manifest-plugin": "^5.0.
|
|
92
|
+
"webpack": "^5.99.9",
|
|
93
|
+
"webpack-dev-server": "^5.2.2",
|
|
94
|
+
"webpack-manifest-plugin": "^5.0.1"
|
|
105
95
|
},
|
|
106
96
|
"devDependencies": {
|
|
107
|
-
"typescript": "^5.
|
|
97
|
+
"typescript": "^5.8.3"
|
|
108
98
|
},
|
|
109
99
|
"optionalDependencies": {
|
|
110
100
|
"fsevents": "^2.3.3"
|
|
@@ -112,7 +102,7 @@
|
|
|
112
102
|
"peerDependencies": {
|
|
113
103
|
"@reactunity/previewer": "*",
|
|
114
104
|
"@reactunity/renderer": "^0.19.0",
|
|
115
|
-
"react": "^
|
|
105
|
+
"react": "^19.0.0",
|
|
116
106
|
"typescript": ">=5"
|
|
117
107
|
},
|
|
118
108
|
"peerDependenciesMeta": {
|
package/scripts/build.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
// @remove-on-eject-begin
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
// @remove-on-eject-end
|
|
9
|
-
'use strict';
|
|
10
|
-
|
|
11
1
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
12
2
|
process.env.BABEL_ENV = 'production';
|
|
13
3
|
process.env.NODE_ENV = 'production';
|
|
@@ -15,14 +5,14 @@ process.env.NODE_ENV = 'production';
|
|
|
15
5
|
// Makes the script crash on unhandled rejections instead of silently
|
|
16
6
|
// ignoring them. In the future, promise rejections that are not handled will
|
|
17
7
|
// terminate the Node.js process with a non-zero exit code.
|
|
18
|
-
process.on('unhandledRejection', err => {
|
|
8
|
+
process.on('unhandledRejection', (err) => {
|
|
19
9
|
throw err;
|
|
20
10
|
});
|
|
21
11
|
|
|
22
12
|
// Ensure environment variables are read.
|
|
23
13
|
require('../config/env');
|
|
24
14
|
|
|
25
|
-
const path = require('path');
|
|
15
|
+
const path = require('node:path');
|
|
26
16
|
const chalk = require('react-dev-utils/chalk');
|
|
27
17
|
const fs = require('fs-extra');
|
|
28
18
|
const bfj = require('bfj');
|
|
@@ -35,8 +25,7 @@ const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
|
|
35
25
|
const printBuildError = require('react-dev-utils/printBuildError');
|
|
36
26
|
const { cleanBuildDirectory, cleanUnusedMetaFiles } = require('./utils/cleanBuildDirectory');
|
|
37
27
|
|
|
38
|
-
const measureFileSizesBeforeBuild =
|
|
39
|
-
FileSizeReporter.measureFileSizesBeforeBuild;
|
|
28
|
+
const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild;
|
|
40
29
|
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
|
41
30
|
|
|
42
31
|
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
|
@@ -65,7 +54,7 @@ checkBrowsers(paths.appPath, isInteractive)
|
|
|
65
54
|
// This lets us display how much they changed later.
|
|
66
55
|
return measureFileSizesBeforeBuild(paths.appBuild);
|
|
67
56
|
})
|
|
68
|
-
.then(previousFileSizes => {
|
|
57
|
+
.then((previousFileSizes) => {
|
|
69
58
|
const metaFiles = cleanBuildDirectory(false);
|
|
70
59
|
// Merge with the public folder
|
|
71
60
|
copyPublicFolder();
|
|
@@ -80,51 +69,32 @@ checkBrowsers(paths.appPath, isInteractive)
|
|
|
80
69
|
if (warnings.length) {
|
|
81
70
|
console.log(chalk.yellow('Compiled with warnings.\n'));
|
|
82
71
|
console.log(warnings.join('\n\n'));
|
|
83
|
-
console.log(
|
|
84
|
-
'\nSearch for the ' +
|
|
85
|
-
chalk.underline(chalk.yellow('keywords')) +
|
|
86
|
-
' to learn more about each warning.'
|
|
87
|
-
);
|
|
88
|
-
console.log(
|
|
89
|
-
'To ignore, add ' +
|
|
90
|
-
chalk.cyan('// eslint-disable-next-line') +
|
|
91
|
-
' to the line before.\n'
|
|
92
|
-
);
|
|
72
|
+
console.log(`\nSearch for the ${chalk.underline(chalk.yellow('keywords'))} to learn more about each warning.`);
|
|
93
73
|
} else {
|
|
94
74
|
console.log(chalk.green('Compiled successfully.\n'));
|
|
95
75
|
}
|
|
96
76
|
|
|
97
77
|
console.log('File sizes after gzip:\n');
|
|
98
|
-
printFileSizesAfterBuild(
|
|
99
|
-
stats,
|
|
100
|
-
previousFileSizes,
|
|
101
|
-
paths.appBuild,
|
|
102
|
-
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
|
103
|
-
WARN_AFTER_CHUNK_GZIP_SIZE
|
|
104
|
-
);
|
|
78
|
+
printFileSizesAfterBuild(stats, previousFileSizes, paths.appBuild, WARN_AFTER_BUNDLE_GZIP_SIZE, WARN_AFTER_CHUNK_GZIP_SIZE);
|
|
105
79
|
console.log();
|
|
106
80
|
|
|
107
81
|
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
|
108
82
|
console.log(`The ${chalk.blue(buildFolder)} folder is ready to be used in ReactUnity.`);
|
|
109
83
|
},
|
|
110
|
-
err => {
|
|
84
|
+
(err) => {
|
|
111
85
|
const tscCompileOnError = process.env.TSC_COMPILE_ON_ERROR === 'true';
|
|
112
86
|
if (tscCompileOnError) {
|
|
113
|
-
console.log(
|
|
114
|
-
chalk.yellow(
|
|
115
|
-
'Compiled with the following type errors (you may want to check these before deploying your app):\n'
|
|
116
|
-
)
|
|
117
|
-
);
|
|
87
|
+
console.log(chalk.yellow('Compiled with the following type errors (you may want to check these before deploying your app):\n'));
|
|
118
88
|
printBuildError(err);
|
|
119
89
|
} else {
|
|
120
90
|
console.log(chalk.red('Failed to compile.\n'));
|
|
121
91
|
printBuildError(err);
|
|
122
92
|
process.exit(1);
|
|
123
93
|
}
|
|
124
|
-
}
|
|
94
|
+
},
|
|
125
95
|
)
|
|
126
|
-
.catch(err => {
|
|
127
|
-
if (err
|
|
96
|
+
.catch((err) => {
|
|
97
|
+
if (err?.message) {
|
|
128
98
|
console.log(err.message);
|
|
129
99
|
}
|
|
130
100
|
process.exit(1);
|
|
@@ -147,9 +117,7 @@ function build(previousFileSizes) {
|
|
|
147
117
|
|
|
148
118
|
// Add additional information for postcss errors
|
|
149
119
|
if (Object.prototype.hasOwnProperty.call(err, 'postcssNode')) {
|
|
150
|
-
errMessage +=
|
|
151
|
-
'\nCompileError: Begins at CSS selector ' +
|
|
152
|
-
err['postcssNode'].selector;
|
|
120
|
+
errMessage += `\nCompileError: Begins at CSS selector ${err.postcssNode.selector}`;
|
|
153
121
|
}
|
|
154
122
|
|
|
155
123
|
messages = formatWebpackMessages({
|
|
@@ -157,9 +125,7 @@ function build(previousFileSizes) {
|
|
|
157
125
|
warnings: [],
|
|
158
126
|
});
|
|
159
127
|
} else {
|
|
160
|
-
messages = formatWebpackMessages(
|
|
161
|
-
stats.toJson({ all: false, warnings: true, errors: true })
|
|
162
|
-
);
|
|
128
|
+
messages = formatWebpackMessages(stats.toJson({ all: false, warnings: true, errors: true }));
|
|
163
129
|
}
|
|
164
130
|
if (messages.errors.length) {
|
|
165
131
|
// Only keep the first error. Others are often indicative
|
|
@@ -169,22 +135,12 @@ function build(previousFileSizes) {
|
|
|
169
135
|
}
|
|
170
136
|
return reject(new Error(messages.errors.join('\n\n')));
|
|
171
137
|
}
|
|
172
|
-
if (
|
|
173
|
-
process.env.CI &&
|
|
174
|
-
(typeof process.env.CI !== 'string' ||
|
|
175
|
-
process.env.CI.toLowerCase() !== 'false') &&
|
|
176
|
-
messages.warnings.length
|
|
177
|
-
) {
|
|
138
|
+
if (process.env.CI && (typeof process.env.CI !== 'string' || process.env.CI.toLowerCase() !== 'false') && messages.warnings.length) {
|
|
178
139
|
// Ignore sourcemap warnings in CI builds. See #8227 for more info.
|
|
179
|
-
const filteredWarnings = messages.warnings.filter(
|
|
180
|
-
w => !/Failed to parse source map/.test(w)
|
|
181
|
-
);
|
|
140
|
+
const filteredWarnings = messages.warnings.filter((w) => !/Failed to parse source map/.test(w));
|
|
182
141
|
if (filteredWarnings.length) {
|
|
183
142
|
console.log(
|
|
184
|
-
chalk.yellow(
|
|
185
|
-
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
|
186
|
-
'Most CI servers set it automatically.\n'
|
|
187
|
-
)
|
|
143
|
+
chalk.yellow('\nTreating warnings as errors because process.env.CI = true.\n' + 'Most CI servers set it automatically.\n'),
|
|
188
144
|
);
|
|
189
145
|
return reject(new Error(filteredWarnings.join('\n\n')));
|
|
190
146
|
}
|
|
@@ -198,9 +154,9 @@ function build(previousFileSizes) {
|
|
|
198
154
|
|
|
199
155
|
if (writeStatsJson) {
|
|
200
156
|
return bfj
|
|
201
|
-
.write(paths.appBuild
|
|
157
|
+
.write(`${paths.appBuild}/bundle-stats.json`, stats.toJson())
|
|
202
158
|
.then(() => resolve(resolveArgs))
|
|
203
|
-
.catch(error => reject(new Error(error)));
|
|
159
|
+
.catch((error) => reject(new Error(error)));
|
|
204
160
|
}
|
|
205
161
|
|
|
206
162
|
return resolve(resolveArgs);
|
|
@@ -212,6 +168,6 @@ function copyPublicFolder() {
|
|
|
212
168
|
if (!fs.existsSync(paths.appPublic)) return;
|
|
213
169
|
fs.copySync(paths.appPublic, paths.appBuild, {
|
|
214
170
|
dereference: true,
|
|
215
|
-
filter: file => file !== paths.appHtml,
|
|
171
|
+
filter: (file) => file !== paths.appHtml,
|
|
216
172
|
});
|
|
217
173
|
}
|
package/scripts/clean.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
// @remove-on-eject-end
|
|
9
|
-
'use strict';
|
|
10
9
|
|
|
11
10
|
// Do this as the first thing so that any code reading it knows the right env.
|
|
12
11
|
process.env.BABEL_ENV = 'production';
|
|
@@ -15,14 +14,14 @@ process.env.NODE_ENV = 'production';
|
|
|
15
14
|
// Makes the script crash on unhandled rejections instead of silently
|
|
16
15
|
// ignoring them. In the future, promise rejections that are not handled will
|
|
17
16
|
// terminate the Node.js process with a non-zero exit code.
|
|
18
|
-
process.on('unhandledRejection', err => {
|
|
17
|
+
process.on('unhandledRejection', (err) => {
|
|
19
18
|
throw err;
|
|
20
19
|
});
|
|
21
20
|
|
|
22
21
|
// Ensure environment variables are read.
|
|
23
22
|
require('../config/env');
|
|
24
23
|
|
|
25
|
-
const path = require('path');
|
|
24
|
+
const path = require('node:path');
|
|
26
25
|
const chalk = require('react-dev-utils/chalk');
|
|
27
26
|
const paths = require('../config/paths');
|
|
28
27
|
const { cleanBuildDirectory } = require('./utils/cleanBuildDirectory');
|
package/scripts/eject.js
CHANGED
|
@@ -1,35 +1,26 @@
|
|
|
1
|
-
// @remove-file-on-eject
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2015-present, Facebook, Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
'use strict';
|
|
9
|
-
|
|
10
1
|
// Makes the script crash on unhandled rejections instead of silently
|
|
11
2
|
// ignoring them. In the future, promise rejections that are not handled will
|
|
12
3
|
// terminate the Node.js process with a non-zero exit code.
|
|
13
|
-
process.on('unhandledRejection', err => {
|
|
4
|
+
process.on('unhandledRejection', (err) => {
|
|
14
5
|
throw err;
|
|
15
6
|
});
|
|
16
7
|
|
|
17
8
|
const fs = require('fs-extra');
|
|
18
|
-
const path = require('path');
|
|
9
|
+
const path = require('node:path');
|
|
19
10
|
const prompts = require('prompts');
|
|
20
|
-
const execSync = require('child_process').execSync;
|
|
11
|
+
const execSync = require('node:child_process').execSync;
|
|
21
12
|
const chalk = require('react-dev-utils/chalk');
|
|
22
13
|
const paths = require('../config/paths');
|
|
23
14
|
const createJestConfig = require('./utils/createJestConfig');
|
|
24
15
|
const spawnSync = require('react-dev-utils/crossSpawn').sync;
|
|
25
|
-
const os = require('os');
|
|
16
|
+
const os = require('node:os');
|
|
26
17
|
|
|
27
18
|
const green = chalk.green;
|
|
28
19
|
const cyan = chalk.cyan;
|
|
29
20
|
|
|
30
21
|
function getGitStatus() {
|
|
31
22
|
try {
|
|
32
|
-
|
|
23
|
+
const stdout = execSync('git status --porcelain', {
|
|
33
24
|
stdio: ['pipe', 'pipe', 'ignore'],
|
|
34
25
|
}).toString();
|
|
35
26
|
return stdout.trim();
|
|
@@ -40,13 +31,9 @@ function getGitStatus() {
|
|
|
40
31
|
|
|
41
32
|
function tryGitAdd(appPath) {
|
|
42
33
|
try {
|
|
43
|
-
spawnSync(
|
|
44
|
-
'
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
stdio: 'inherit',
|
|
48
|
-
}
|
|
49
|
-
);
|
|
34
|
+
spawnSync('git', ['add', path.join(appPath, 'config'), path.join(appPath, 'scripts')], {
|
|
35
|
+
stdio: 'inherit',
|
|
36
|
+
});
|
|
50
37
|
|
|
51
38
|
return true;
|
|
52
39
|
} catch (e) {
|
|
@@ -57,8 +44,8 @@ function tryGitAdd(appPath) {
|
|
|
57
44
|
console.log(
|
|
58
45
|
chalk.cyan.bold(
|
|
59
46
|
'NOTE: Create React App 2+ supports TypeScript, Sass, CSS Modules and more without ejecting: ' +
|
|
60
|
-
|
|
61
|
-
)
|
|
47
|
+
'https://reactjs.org/blog/2018/10/01/create-react-app-v2.html',
|
|
48
|
+
),
|
|
62
49
|
);
|
|
63
50
|
console.log();
|
|
64
51
|
|
|
@@ -67,7 +54,7 @@ prompts({
|
|
|
67
54
|
name: 'shouldEject',
|
|
68
55
|
message: 'Are you sure you want to eject? This action is permanent.',
|
|
69
56
|
initial: false,
|
|
70
|
-
}).then(answer => {
|
|
57
|
+
}).then((answer) => {
|
|
71
58
|
if (!answer.shouldEject) {
|
|
72
59
|
console.log(cyan('Close one! Eject aborted.'));
|
|
73
60
|
return;
|
|
@@ -76,18 +63,10 @@ prompts({
|
|
|
76
63
|
const gitStatus = getGitStatus();
|
|
77
64
|
if (gitStatus) {
|
|
78
65
|
console.error(
|
|
79
|
-
chalk.red(
|
|
80
|
-
'This git repository has untracked files or uncommitted changes:'
|
|
81
|
-
) +
|
|
82
|
-
'\n\n' +
|
|
83
|
-
gitStatus
|
|
66
|
+
`${chalk.red('This git repository has untracked files or uncommitted changes:')}\n\n${gitStatus
|
|
84
67
|
.split('\n')
|
|
85
|
-
.map(line => line.match(/ .*/g)[0].trim())
|
|
86
|
-
.join('\n')
|
|
87
|
-
'\n\n' +
|
|
88
|
-
chalk.red(
|
|
89
|
-
'Remove untracked files, stash or commit any changes, and try again.'
|
|
90
|
-
)
|
|
68
|
+
.map((line) => line.match(/ .*/g)[0].trim())
|
|
69
|
+
.join('\n')}\n\n${chalk.red('Remove untracked files, stash or commit any changes, and try again.')}`,
|
|
91
70
|
);
|
|
92
71
|
process.exit(1);
|
|
93
72
|
}
|
|
@@ -100,10 +79,7 @@ prompts({
|
|
|
100
79
|
function verifyAbsent(file) {
|
|
101
80
|
if (fs.existsSync(path.join(appPath, file))) {
|
|
102
81
|
console.error(
|
|
103
|
-
`\`${file}\` already exists in your app folder. We cannot
|
|
104
|
-
'continue as you would lose all the changes in that file or directory. ' +
|
|
105
|
-
'Please move or delete it (maybe make a copy for backup) and run this ' +
|
|
106
|
-
'command again.'
|
|
82
|
+
`\`${file}\` already exists in your app folder. We cannot continue as you would lose all the changes in that file or directory. Please move or delete it (maybe make a copy for backup) and run this command again.`,
|
|
107
83
|
);
|
|
108
84
|
process.exit(1);
|
|
109
85
|
}
|
|
@@ -117,9 +93,9 @@ prompts({
|
|
|
117
93
|
fs
|
|
118
94
|
.readdirSync(path.join(ownPath, folder))
|
|
119
95
|
// set full path
|
|
120
|
-
.map(file => path.join(ownPath, folder, file))
|
|
96
|
+
.map((file) => path.join(ownPath, folder, file))
|
|
121
97
|
// omit dirs from file list
|
|
122
|
-
.filter(file => fs.lstatSync(file).isFile())
|
|
98
|
+
.filter((file) => fs.lstatSync(file).isFile()),
|
|
123
99
|
);
|
|
124
100
|
}, []);
|
|
125
101
|
|
|
@@ -128,39 +104,28 @@ prompts({
|
|
|
128
104
|
files.forEach(verifyAbsent);
|
|
129
105
|
|
|
130
106
|
// Prepare Jest config early in case it throws
|
|
131
|
-
const jestConfig = createJestConfig(
|
|
132
|
-
filePath => path.posix.join('<rootDir>', filePath),
|
|
133
|
-
null,
|
|
134
|
-
true
|
|
135
|
-
);
|
|
107
|
+
const jestConfig = createJestConfig((filePath) => path.posix.join('<rootDir>', filePath), null, true);
|
|
136
108
|
|
|
137
109
|
console.log();
|
|
138
110
|
console.log(cyan(`Copying files into ${appPath}`));
|
|
139
111
|
|
|
140
|
-
folders.forEach(folder => {
|
|
112
|
+
folders.forEach((folder) => {
|
|
141
113
|
fs.mkdirSync(path.join(appPath, folder), { recursive: true });
|
|
142
114
|
});
|
|
143
115
|
|
|
144
|
-
files.forEach(file => {
|
|
116
|
+
files.forEach((file) => {
|
|
145
117
|
let content = fs.readFileSync(file, 'utf8');
|
|
146
118
|
|
|
147
119
|
// Skip flagged files
|
|
148
120
|
if (content.match(/\/\/ @remove-file-on-eject/)) {
|
|
149
121
|
return;
|
|
150
122
|
}
|
|
151
|
-
content =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
)
|
|
158
|
-
// Remove dead code from .applescript files on eject
|
|
159
|
-
.replace(
|
|
160
|
-
/-- @remove-on-eject-begin([\s\S]*?)-- @remove-on-eject-end/gm,
|
|
161
|
-
''
|
|
162
|
-
)
|
|
163
|
-
.trim() + '\n';
|
|
123
|
+
content = `${content
|
|
124
|
+
// Remove dead code from .js files on eject
|
|
125
|
+
.replace(/\/\/ @remove-on-eject-begin([\s\S]*?)\/\/ @remove-on-eject-end/gm, '')
|
|
126
|
+
// Remove dead code from .applescript files on eject
|
|
127
|
+
.replace(/-- @remove-on-eject-begin([\s\S]*?)-- @remove-on-eject-end/gm, '')
|
|
128
|
+
.trim()}\n`;
|
|
164
129
|
console.log(` Adding ${cyan(file.replace(ownPath, ''))} to the project`);
|
|
165
130
|
fs.writeFileSync(file.replace(ownPath, appPath), content);
|
|
166
131
|
});
|
|
@@ -183,12 +148,9 @@ prompts({
|
|
|
183
148
|
console.log(` Removing ${cyan(ownPackageName)} from dependencies`);
|
|
184
149
|
delete appPackage.dependencies[ownPackageName];
|
|
185
150
|
}
|
|
186
|
-
Object.keys(ownPackage.dependencies).forEach(key => {
|
|
151
|
+
Object.keys(ownPackage.dependencies).forEach((key) => {
|
|
187
152
|
// For some reason optionalDependencies end up in dependencies after install
|
|
188
|
-
if (
|
|
189
|
-
ownPackage.optionalDependencies &&
|
|
190
|
-
ownPackage.optionalDependencies[key]
|
|
191
|
-
) {
|
|
153
|
+
if (ownPackage.optionalDependencies?.[key]) {
|
|
192
154
|
return;
|
|
193
155
|
}
|
|
194
156
|
console.log(` Adding ${cyan(key)} to dependencies`);
|
|
@@ -199,28 +161,20 @@ prompts({
|
|
|
199
161
|
appPackage.dependencies = {};
|
|
200
162
|
Object.keys(unsortedDependencies)
|
|
201
163
|
.sort()
|
|
202
|
-
.forEach(key => {
|
|
164
|
+
.forEach((key) => {
|
|
203
165
|
appPackage.dependencies[key] = unsortedDependencies[key];
|
|
204
166
|
});
|
|
205
167
|
console.log();
|
|
206
168
|
|
|
207
169
|
console.log(cyan('Updating the scripts'));
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const regex = new RegExp(binKey + ' (\\w+)', 'g');
|
|
170
|
+
Object.keys(appPackage.scripts).forEach((key) => {
|
|
171
|
+
Object.keys(ownPackage.bin).forEach((binKey) => {
|
|
172
|
+
const regex = new RegExp(`${binKey} (\\w+)`, 'g');
|
|
212
173
|
if (!regex.test(appPackage.scripts[key])) {
|
|
213
174
|
return;
|
|
214
175
|
}
|
|
215
|
-
appPackage.scripts[key] = appPackage.scripts[key].replace(
|
|
216
|
-
|
|
217
|
-
'node scripts/$1.js'
|
|
218
|
-
);
|
|
219
|
-
console.log(
|
|
220
|
-
` Replacing ${cyan(`"${binKey} ${key}"`)} with ${cyan(
|
|
221
|
-
`"node scripts/${key}.js"`
|
|
222
|
-
)}`
|
|
223
|
-
);
|
|
176
|
+
appPackage.scripts[key] = appPackage.scripts[key].replace(regex, 'node scripts/$1.js');
|
|
177
|
+
console.log(` Replacing ${cyan(`"${binKey} ${key}"`)} with ${cyan(`"node scripts/${key}.js"`)}`);
|
|
224
178
|
});
|
|
225
179
|
});
|
|
226
180
|
|
|
@@ -236,41 +190,23 @@ prompts({
|
|
|
236
190
|
presets: ['react-app'],
|
|
237
191
|
};
|
|
238
192
|
|
|
239
|
-
|
|
240
|
-
if (!appPackage.eslintConfig) {
|
|
241
|
-
console.log(` Adding ${cyan('ESLint')} configuration`);
|
|
242
|
-
appPackage.eslintConfig = {
|
|
243
|
-
extends: 'react-app',
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
fs.writeFileSync(
|
|
248
|
-
path.join(appPath, 'package.json'),
|
|
249
|
-
JSON.stringify(appPackage, null, 2) + os.EOL
|
|
250
|
-
);
|
|
193
|
+
fs.writeFileSync(path.join(appPath, 'package.json'), JSON.stringify(appPackage, null, 2) + os.EOL);
|
|
251
194
|
console.log();
|
|
252
195
|
|
|
253
196
|
if (fs.existsSync(paths.appTypeDeclarations)) {
|
|
254
197
|
try {
|
|
255
198
|
// Read app declarations file
|
|
256
199
|
let content = fs.readFileSync(paths.appTypeDeclarations, 'utf8');
|
|
257
|
-
const ownContent =
|
|
258
|
-
fs.readFileSync(paths.ownTypeDeclarations, 'utf8').trim() + os.EOL;
|
|
200
|
+
const ownContent = fs.readFileSync(paths.ownTypeDeclarations, 'utf8').trim() + os.EOL;
|
|
259
201
|
|
|
260
202
|
// Remove react-unity-scripts reference since they're getting a copy of the types in their project
|
|
261
203
|
content =
|
|
262
204
|
content
|
|
263
205
|
// Remove react-unity-scripts types
|
|
264
|
-
.replace(
|
|
265
|
-
/^\s*\/\/\/\s*<reference\s+types.+?"react-unity-scripts".*\/>.*(?:\n|$)/gm,
|
|
266
|
-
''
|
|
267
|
-
)
|
|
206
|
+
.replace(/^\s*\/\/\/\s*<reference\s+types.+?"react-unity-scripts".*\/>.*(?:\n|$)/gm, '')
|
|
268
207
|
.trim() + os.EOL;
|
|
269
208
|
|
|
270
|
-
fs.writeFileSync(
|
|
271
|
-
paths.appTypeDeclarations,
|
|
272
|
-
(ownContent + os.EOL + content).trim() + os.EOL
|
|
273
|
-
);
|
|
209
|
+
fs.writeFileSync(paths.appTypeDeclarations, (ownContent + os.EOL + content).trim() + os.EOL);
|
|
274
210
|
} catch (e) {
|
|
275
211
|
// It's not essential that this succeeds, the TypeScript user should
|
|
276
212
|
// be able to re-create these types with ease.
|
|
@@ -281,7 +217,7 @@ prompts({
|
|
|
281
217
|
if (ownPath.indexOf(appPath) === 0) {
|
|
282
218
|
try {
|
|
283
219
|
// remove react-unity-scripts and react-unity-scripts binaries from app node_modules
|
|
284
|
-
Object.keys(ownPackage.bin).forEach(binKey => {
|
|
220
|
+
Object.keys(ownPackage.bin).forEach((binKey) => {
|
|
285
221
|
fs.removeSync(path.join(appPath, 'node_modules', '.bin', binKey));
|
|
286
222
|
});
|
|
287
223
|
fs.removeSync(ownPath);
|
|
@@ -291,12 +227,7 @@ prompts({
|
|
|
291
227
|
}
|
|
292
228
|
|
|
293
229
|
if (fs.existsSync(paths.yarnLockFile)) {
|
|
294
|
-
const windowsCmdFilePath = path.join(
|
|
295
|
-
appPath,
|
|
296
|
-
'node_modules',
|
|
297
|
-
'.bin',
|
|
298
|
-
'react-unity-scripts.cmd'
|
|
299
|
-
);
|
|
230
|
+
const windowsCmdFilePath = path.join(appPath, 'node_modules', '.bin', 'react-unity-scripts.cmd');
|
|
300
231
|
let windowsCmdFileContent;
|
|
301
232
|
if (process.platform === 'win32') {
|
|
302
233
|
// https://github.com/facebook/create-react-app/pull/3806#issuecomment-357781035
|