-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' of github.com:wordpress-mobile/gutenberg-mobile …
…into release/1.79.0
- Loading branch information
Showing
11 changed files
with
2,508 additions
and
2,387 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
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,27 @@ | ||
#!/bin/bash | ||
set -Eeuo pipefail | ||
|
||
# Check if nvm is installed | ||
[ -z "$NVM_DIR" ] && NVM_DIR="$HOME/.nvm" | ||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | ||
|
||
command -v nvm >/dev/null 2>&1 || { | ||
echo "nvm is not installed or cannot be sourced from $NVM_DIR/nvm.sh. Please verify that "'$NVM_DIR'" points to the .nvm directory." | ||
exit 1 | ||
} | ||
|
||
pushd jetpack | ||
|
||
# Set up node requirement for Jetpack | ||
nvm install | ||
|
||
# Set up required pnpm version | ||
listed_pnpm_version=$(npx -c 'echo $npm_package_engines_pnpm') | ||
pnpm_version=$(npx semver -c "$listed_pnpm_version") | ||
|
||
cd projects/plugins/jetpack | ||
|
||
# npx might prompt to install pnpm at the requested version. Let's just agree and carry on. | ||
( yes || true ) | npx --cache /tmp/empty-cache pnpm@"$pnpm_version" install | ||
|
||
popd |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Submodule jetpack
updated
4410 files
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 |
---|---|---|
@@ -1,45 +1,77 @@ | ||
const path = require( 'path' ); | ||
const fs = require( 'fs' ); | ||
const metroResolver = require( 'metro-resolver' ); | ||
|
||
const gutenbergMetroConfig = require( './gutenberg/packages/react-native-editor/metro.config.js' ); | ||
const extraNodeModules = {}; | ||
const gutenbergMetroConfigCopy = { | ||
...gutenbergMetroConfig, | ||
resolver: { | ||
...gutenbergMetroConfig.resolver, | ||
sourceExts: [ 'js', 'jsx', 'json', 'scss', 'sass', 'ts', 'tsx' ], | ||
extraNodeModules, | ||
}, | ||
}; | ||
|
||
gutenbergMetroConfigCopy.resolver.extraNodeModules = new Proxy( | ||
{}, | ||
{ | ||
get: ( target, name ) => { | ||
// Try to find the module in the Gutenberg submodule. | ||
const gutenbergFolder = path.join( | ||
process.cwd(), | ||
`gutenberg/node_modules/${ name }` | ||
); | ||
if ( fs.existsSync( gutenbergFolder ) ) { | ||
return gutenbergFolder; | ||
} | ||
const nodeModulePaths = [ | ||
'gutenberg/node_modules', | ||
'jetpack/projects/plugins/jetpack/node_modules', | ||
]; | ||
|
||
const possibleModulePaths = ( name ) => | ||
nodeModulePaths.map( ( dir ) => path.join( process.cwd(), dir, name ) ); | ||
|
||
gutenbergMetroConfigCopy.resolver.resolveRequest = ( | ||
context, | ||
moduleName, | ||
platform | ||
) => { | ||
// Add the module to the extra node modules object if the module is not on a local path. | ||
if ( ! ( moduleName.startsWith( '.' ) || moduleName.startsWith( '/' ) ) ) { | ||
const [ namespace, module = '' ] = moduleName.split( '/' ); | ||
const name = path.join( namespace, module ); | ||
|
||
// Try to find the module in Jetpack's .pnpm folder. | ||
const moduleFolderPnpm = path.join( | ||
process.cwd(), | ||
`./jetpack/node_modules/.pnpm/node_modules/${ name }` | ||
if ( ! extraNodeModules[ name ] ) { | ||
let extraNodeModulePath; | ||
|
||
const modulePath = possibleModulePaths( name ).find( | ||
fs.existsSync | ||
); | ||
|
||
if ( fs.existsSync( moduleFolderPnpm ) ) { | ||
// pnpm uses symlinks so, let's find the target | ||
const symlinkTarget = fs.readlinkSync( moduleFolderPnpm ); | ||
extraNodeModulePath = modulePath && fs.realpathSync( modulePath ); | ||
|
||
// If we haven't resolved the module yet, check if the module is managed by pnpm. | ||
if ( | ||
! extraNodeModulePath && | ||
context.originModulePath.includes( '.pnpm' ) | ||
) { | ||
const filePath = require.resolve( name, { | ||
paths: [ path.dirname( context.originModulePath ) ], | ||
} ); | ||
|
||
const innerNodeModules = filePath.match( | ||
/.*node_modules/ | ||
)?.[ 0 ]; | ||
|
||
// the target is still using paths relative to the parent folder of the module, let's find the real path. | ||
return path.resolve( | ||
moduleFolderPnpm + '/../' + symlinkTarget | ||
); | ||
extraNodeModulePath = | ||
innerNodeModules && path.join( innerNodeModules, name ); | ||
} | ||
}, | ||
|
||
if ( extraNodeModulePath ) { | ||
extraNodeModules[ name ] = extraNodeModulePath; | ||
} | ||
} | ||
} | ||
); | ||
|
||
// Restore the original resolver | ||
return metroResolver.resolve( | ||
{ | ||
...context, | ||
resolveRequest: null, | ||
}, | ||
moduleName, | ||
platform | ||
); | ||
}; | ||
|
||
module.exports = gutenbergMetroConfigCopy; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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