Commit bec009ce authored by Valerii Sorokobatko's avatar Valerii Sorokobatko Committed by Joe Haddad
Browse files

Fix workflow if react-scripts package is linked via npm-link (#1356)

* add npm-link support

* - remove extra veriable
- simplify condition

* update code after review:
- remove utils/isReactScriptsLinked
- add appPath and ownPath to paths.js (but only for "before eject" export case)

* update code after review:
- remove utils/isReactScriptsLinked
- add appPath and ownPath to paths.js (but only for "before eject" export case)

* update code after review:
- remove utils/isReactScriptsLinked
- add appPath and ownPath to paths.js (but only for "before eject" export case)
- remove "if" block for fs.removeSync(ownPath) at ejec.tjs

* change ownPath value
parent 67d0d49a
4 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file,!1933Add note about installing watchman
Showing with 24 additions and 18 deletions
+24 -18
...@@ -91,11 +91,13 @@ module.exports = { ...@@ -91,11 +91,13 @@ module.exports = {
// @remove-on-eject-begin // @remove-on-eject-begin
function resolveOwn(relativePath) { function resolveOwn(relativePath) {
return path.resolve(__dirname, relativePath); return path.resolve(__dirname, '..', relativePath);
} }
// config before eject: we're in ./node_modules/react-scripts/config/ // config before eject: we're in ./node_modules/react-scripts/config/
module.exports = { module.exports = {
appPath: resolveApp('.'),
ownPath: resolveApp('node_modules/react-scripts'),
appBuild: resolveApp('build'), appBuild: resolveApp('build'),
appPublic: resolveApp('public'), appPublic: resolveApp('public'),
appHtml: resolveApp('public/index.html'), appHtml: resolveApp('public/index.html'),
...@@ -106,28 +108,33 @@ module.exports = { ...@@ -106,28 +108,33 @@ module.exports = {
testsSetup: resolveApp('src/setupTests.js'), testsSetup: resolveApp('src/setupTests.js'),
appNodeModules: resolveApp('node_modules'), appNodeModules: resolveApp('node_modules'),
// this is empty with npm3 but node resolution searches higher anyway: // this is empty with npm3 but node resolution searches higher anyway:
ownNodeModules: resolveOwn('../node_modules'), ownNodeModules: resolveOwn('node_modules'),
nodePaths: nodePaths, nodePaths: nodePaths,
publicUrl: getPublicUrl(resolveApp('package.json')), publicUrl: getPublicUrl(resolveApp('package.json')),
servedPath: getServedPath(resolveApp('package.json')) servedPath: getServedPath(resolveApp('package.json'))
}; };
var reactScriptsPath = path.resolve('node_modules/react-scripts');
var reactScriptsLinked = fs.existsSync(reactScriptsPath) && fs.lstatSync(reactScriptsPath).isSymbolicLink();
// config before publish: we're in ./packages/react-scripts/config/ // config before publish: we're in ./packages/react-scripts/config/
if (__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) { if (!reactScriptsLinked && __dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) {
module.exports = { module.exports = {
appBuild: resolveOwn('../../../build'), appPath: resolveApp('.'),
appPublic: resolveOwn('../template/public'), ownPath: resolveOwn('.'),
appHtml: resolveOwn('../template/public/index.html'), appBuild: resolveOwn('../../build'),
appIndexJs: resolveOwn('../template/src/index.js'), appPublic: resolveOwn('template/public'),
appPackageJson: resolveOwn('../package.json'), appHtml: resolveOwn('template/public/index.html'),
appSrc: resolveOwn('../template/src'), appIndexJs: resolveOwn('template/src/index.js'),
yarnLockFile: resolveOwn('../template/yarn.lock'), appPackageJson: resolveOwn('package.json'),
testsSetup: resolveOwn('../template/src/setupTests.js'), appSrc: resolveOwn('template/src'),
appNodeModules: resolveOwn('../node_modules'), yarnLockFile: resolveOwn('template/yarn.lock'),
ownNodeModules: resolveOwn('../node_modules'), testsSetup: resolveOwn('template/src/setupTests.js'),
appNodeModules: resolveOwn('node_modules'),
ownNodeModules: resolveOwn('node_modules'),
nodePaths: nodePaths, nodePaths: nodePaths,
publicUrl: getPublicUrl(resolveOwn('../package.json')), publicUrl: getPublicUrl(resolveOwn('package.json')),
servedPath: getServedPath(resolveOwn('../package.json')) servedPath: getServedPath(resolveOwn('package.json'))
}; };
} }
// @remove-on-eject-end // @remove-on-eject-end
...@@ -28,8 +28,8 @@ prompt( ...@@ -28,8 +28,8 @@ prompt(
console.log('Ejecting...'); console.log('Ejecting...');
var ownPath = path.join(__dirname, '..'); var ownPath = paths.ownPath;
var appPath = path.join(ownPath, '..', '..'); var appPath = paths.appPath;
function verifyAbsent(file) { function verifyAbsent(file) {
if (fs.existsSync(path.join(appPath, file))) { if (fs.existsSync(path.join(appPath, file))) {
...@@ -135,7 +135,6 @@ prompt( ...@@ -135,7 +135,6 @@ prompt(
); );
// Add Babel config // Add Babel config
console.log(' Adding ' + cyan('Babel') + ' preset'); console.log(' Adding ' + cyan('Babel') + ' preset');
appPackage.babel = babelConfig; appPackage.babel = babelConfig;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment