54
loading...
This website collects cookies to deliver better user experience
npm install -g @microsoft/rush
rush init
rm -rf .travis.yml
git add .
git commit -m "Initial commit"
git push origin master
git blame
or git bisect
.git subtree
.git subtree add
git subtree add --prefix apps/react-app \
https://github.com/abereghici/react-app master
apps/react-app
is used to specify the path inside of the monorepo where the project will be imported.https://github.com/abereghici/react-app
is the remote repository URL of the project we want to import.master
is the branch from where the project will be imported.git log
you'll see the history of react-app
project inside of our monorepo.apps/react-app/package.json
and change the name of the project with @monorepo/react-app
.@monorepo/react-app
project in rush configuration file. Open rush.json
file and add an entry like this under the projects inventory:"projects": [
{
"packageName": "@monorepo/react-app",
"projectFolder": "apps/react-app",
"reviewCategory": "production"
}
]
rush update
to install the dependencies of react-app
project. This command can be launched in any subfolder of the repo folder that contains rush.json
file.rush update
git add .
git commit -m "Imported react-app project"
git push origin master
git commit
..prettierrc.js
<repo root>/.prettierrc.js
module.exports = {
arrowParens: 'avoid',
bracketSpacing: true,
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
jsxBracketSameLine: false,
jsxSingleQuote: false,
printWidth: 80,
proseWrap: 'preserve',
quoteProps: 'as-needed',
requirePragma: false,
semi: true,
singleQuote: true,
tabWidth: 2,
trailingComma: 'es5',
useTabs: false,
};
.prettierignore
file to tell Prettier which files to skip. It is recommended for .prettierignore
to extend the same patterns used in .gitignore
.cp .gitignore .prettierignore
# See what files Prettier will format
# check the output and modify .prettierignore rules if needed
npx prettier . --list-different
# When you are ready, this will format all the source files
npx prettier . --write
git commit
hook, we'll use prettier-quick
to calculate the subset of files that are staged for commit and format them.# This creates the common/autoinstallers/rush-prettier/package.json file:
rush init-autoinstaller --name rush-prettier
cd common/autoinstallers/rush-prettier
# Install the dependencies.
# You can also manually edit the "dependencies" in the package.json file
pnpm install prettier
pnpm install pretty-quick
# update the auto-installer
rush update-autoinstaller --name rush-prettier
pretty-quick
tool. Add this to the "commands" section of config/rush/command-line.json
file:. . .
"commands": [
{
"name": "prettier",
"commandKind": "global",
"summary": "Used by the pre-commit Git hook. This command invokes Prettier to reformat staged changes.",
"safeForSimultaneousRushProcesses": true,
"autoinstallerName": "rush-prettier",
// This will invoke common/autoinstallers/rush-prettier/node_modules/.bin/pretty-quick
"shellCommand": "pretty-quick --staged"
}
. . .
rush prettier
.git commit
is performed.pre-commit
in the common/git-hooks
folder:common/git-hooks/pre-commit
#!/bin/sh
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
# Invoke the "rush prettier" custom command to reformat files whenever they
# are committed. The command is defined in common/config/rush/command-line.json
# and uses the "rush-prettier" autoinstaller.
node common/scripts/install-run-rush.js prettier || exit $?
rush install
.