# Gerrit Polymer Frontend
Follow the
[setup instructions for Gerrit backend developers](https://gerrit-review.googlesource.com/Documentation/dev-readme.html)
where applicable, the most important command is:
```sh
git clone --recurse-submodules https://gerrit.googlesource.com/gerrit
```
The --recurse-submodules option is needed on git clone to ensure that the core plugins, which are included as git submodules, are also cloned.
Then make sure to install the commit-hook that will set up the `ChangeId` for
each push to gerrit-reviews.
```sh
cd gerrit && (
cd .git/hooks
ln -s ../../resources/com/google/gerrit/server/tools/root/hooks/commit-msg
)
```
## Installing [Bazel](https://bazel.build/)
Follow the instructions
[here](https://gerrit-review.googlesource.com/Documentation/dev-bazel.html#_installation)
to get and install Bazel. The `npm install -g @bazel/bazelisk` method is
probably easiest since you will have npm as part of Nodejs.
## Installing [Node.js](https://nodejs.org/en/download/) and npm packages
The minimum nodejs version supported is 10.x+. We recommend at least the latest
LTS (v16 as of October 2022).
```sh
# Debian experimental
sudo apt-get install nodejs
sudo apt-get install npm
# OS X with Homebrew
brew install node@16
brew install npm
```
All other platforms:
[download from nodejs.org](https://nodejs.org/en/download/).
or use [nvm - Node Version Manager](https://github.com/nvm-sh/nvm).
### Additional packages
We have several bazel commands to install packages we may need for FE development.
For first time users to get the local server up, `bazel build gerrit` should be enough and will take care of all of them for you.
```sh
# Install yarn package manager
npm install -g yarn
# Install packages from root-level packages.json
bazel fetch @npm//:node_modules
# Install packages from polygerrit-ui/app/packages.json
bazel fetch @ui_npm//:node_modules
# Install packages from polygerrit-ui/packages.json
bazel fetch @ui_dev_npm//:node_modules
# Install packages from tools/node_tools/packages.json
bazel fetch @tools_npm//:node_modules
```
More information for installing and using nodejs rules can be found here https://bazelbuild.github.io/rules_nodejs/install.html
### Upgrade to @bazel-scoped packages
It might be necessary to run this command to upgrade to major `rules_nodejs` release:
```sh
yarn remove @bazel/...
```
## Setup typescript support in the IDE
Modern IDEs should automatically handle typescript settings from the
`polygerrit-ui/app/tsconfig.json` files. The `tsc` compiler places compiled
files in the `.ts-out/pg` directory at the root of gerrit workspace and you can
configure the IDE to exclude the whole .ts-out directory. To do it in the
IntelliJ IDEA click on this directory and select "Mark Directory As > Excluded"
in the context menu.
However, if you receive some errors from IDE, you can try to configure IDE
manually. For example, if IntelliJ IDEA shows
`Cannot find parent 'tsconfig.json'` error, you can try to setup typescript
options `--project polygerrit-ui/app/tsconfig.json` in the IDE settings.
## Developing locally
The preferred method for development is to serve the web files locally using the
Web Dev Server and then view a running gerrit instance (local or otherwise) to
replace its web client with the local one using the Gerrit FE Dev Helper
extension.
### Web Dev Server
The [Web Dev Server](https://modern-web.dev/docs/dev-server/overview/) serves
the compiled web files and dependencies unbundled over localhost. Start it using
this command:
```sh
yarn start
```
To inject plugins or other files, we use the [Gerrit FE Dev Helper](https://chrome.google.com/webstore/detail/gerrit-fe-dev-helper/jimgomcnodkialnpmienbomamgomglkd) Chrome extension.
If any issues occured, please refer to the Troubleshooting section at the bottom or contact the team!
### Chrome extension: Gerrit FE Dev Helper
To be able to bypass the auth and also help improve the productivity of Gerrit FE developers,
we created this chrome extension: [Gerrit FE Dev Helper](https://chrome.google.com/webstore/detail/gerrit-fe-dev-helper/jimgomcnodkialnpmienbomamgomglkd).
It basically works as a proxy that will block / redirect requests from current sites to any given url base on certain rules.
The source code is in [Gerrit - gerrit-fe-dev-helper](https://gerrit-review.googlesource.com/q/project:gerrit-fe-dev-helper), contributions are welcomed!
To use this extension, just follow its [readme here](https://gerrit.googlesource.com/gerrit-fe-dev-helper/+/master/README.md).
### Running locally against a Gerrit test site
Set up a local test site once:
1. [Build Gerrit](https://gerrit-review.googlesource.com/Documentation/dev-bazel.html#_gerrit_development_war_file)
2. [Set up a local test site](https://gerrit-review.googlesource.com/Documentation/dev-readme.html#init).
3. Optionally [populate](https://gerrit.googlesource.com/gerrit/+/master/contrib/populate-fixture-data.py) your test site with some test data.
For running a locally built Gerrit war against your test instance use
[this command](https://gerrit-review.googlesource.com/Documentation/dev-readme.html#run_daemon).
If you want to serve the Polymer frontend directly from the sources in `polygerrit_ui/app/` instead of from the war:
1. Start [Web Dev Server](#web-dev-server)
2. Add the `--dev-cdn` option:
```sh
$(bazel info output_base)/external/local_jdk/bin/java \
-DsourceRoot=$(bazel info workspace) \
-jar bazel-bin/gerrit.war daemon \
-d $GERRIT_SITE \
--console-log \
--dev-cdn http://localhost:8081
```
The Web Dev Server is currently not serving fonts or other static assets. Follow
[Issue 40015119](https://issues.gerritcodereview.com/issues/40015119) for
fixing this issue.
*NOTE* You can use any other cdn here, for example: https://cdn.googlesource.com/polygerrit_ui/678.0
## Running Tests
For daily development you typically only want to run and debug individual tests.
Our tests run using the
[Web Test Runner](https://modern-web.dev/docs/test-runner/overview/). There are
several ways to trigger tests:
* Run all tests once:
```sh
yarn test
```
* Run all tests and then watches for changes. Change a file will trigger all
tests affected by the changes.
```sh
yarn test:watch
```
* Run all tests once under bazel:
```sh
./polygerrit-ui/app/run_test.sh
```
* Run a single test file and rerun on any changes affecting it:
```
yarn test:single "**/gr-comment_test.ts"
```
Compiling code:
```sh
# Compile frontend once to check for type errors:
yarn compile
# Watch mode:
yarn compile:watch
```
## Style guide
We follow the [Google JavaScript Style Guide](https://google.github.io/styleguide/javascriptguide.xml)
with a few exceptions. When in doubt, remain consistent with the code around you.
In addition, we encourage the use of [ESLint](http://eslint.org/).
It is available as a command line utility, as well as a plugin for most editors
and IDEs.
`eslint-config-google` is a port of the Google JS Style Guide to an ESLint
config module, and `eslint-plugin-html` allows ESLint to lint scripts inside
HTML.
We have an .eslintrc.json config file in the polygerrit-ui/ directory configured
to enforce the preferred style of the PolyGerrit project.
After installing, you can use `eslint` on any new file you create.
In addition, you can supply the `--fix` flag to apply some suggested fixes for
simple style issues.
If you modify JS inside of `<script>` tags, like for test suites, you may have
to supply the `--ext .html` flag.
Some useful commands:
* To run ESLint on the whole app, less some dependency code:
```sh
yarn eslint
```
* To run ESLint on just the subdirectory you modified:
```sh
node_modules/eslint/bin/eslint.js --ext .html,.js polygerrit-ui/app/$YOUR_DIR_HERE
```
* To run the linter on all of your local changes:
```sh
git diff --name-only HEAD | xargs node_modules/eslint/bin/eslint.js --ext .html,.js
```
## Migrating tests to Typescript
You can
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Gerrit代码审查工具 v3.9.1.zip (2000个子文件)
flexmark-java.css 29KB
fonts.css 7KB
prettify.css 2KB
main.css 1KB
material-icons.css 579B
LoginForm.html 33KB
LoginForm.html 23KB
LoginForm.html 3KB
ConfigurationError.html 2KB
BecomeAnyAccount.html 2KB
LegacyGerrit.html 763B
LoginRedirect.html 741B
RedirectForm.html 426B
ReceiveCommits.java 144KB
ChangeField.java 79KB
TestKeys.java 76KB
RestApiServlet.java 75KB
TestTrustKeys.java 73KB
CommitValidators.java 42KB
MergeOp.java 42KB
ChangeJson.java 40KB
MergeUtil.java 38KB
ChangeApiImpl.java 28KB
GitwebServlet.java 28KB
ConsistencyChecker.java 28KB
ReviewerModifier.java 28KB
SshDaemon.java 27KB
ChangeInserter.java 27KB
PluginLoader.java 27KB
GerritLauncher.java 27KB
GitPositionTransformer.java 26KB
ProjectApiImpl.java 26KB
ChangeApi.java 26KB
HttpPluginServlet.java 26KB
RevisionApiImpl.java 25KB
H2CacheImpl.java 25KB
GitOverHttpServlet.java 25KB
ReplaceOp.java 25KB
PluginGuiceEnvironment.java 25KB
Daemon.java 25KB
RebaseUtil.java 25KB
WorkQueue.java 24KB
GroupsUpdate.java 24KB
FileDiffCacheImpl.java 23KB
VersionedMetaData.java 23KB
SubmitStrategyOp.java 23KB
ChangeIndexer.java 22KB
MultiProgressMonitor.java 21KB
LabelsJson.java 21KB
AccountApiImpl.java 21KB
OpenIdServiceImpl.java 21KB
Change.java 20KB
WebAppInitializer.java 20KB
JettyServer.java 20KB
AbstractLuceneIndex.java 20KB
LuceneChangeIndex.java 20KB
GroupConfig.java 20KB
CommitUtil.java 20KB
DiffOperationsImpl.java 20KB
BaseCommand.java 20KB
GitFileDiffCacheImpl.java 19KB
GroupNameNotes.java 19KB
RebaseChangeOp.java 19KB
AsyncReceiveCommits.java 19KB
PrologRuleEvaluator.java 18KB
RevisionJson.java 18KB
IndexedField.java 18KB
InMemoryModule.java 18KB
MergeValidators.java 18KB
PublicKeyStore.java 18KB
PublicKeyChecker.java 18KB
TagSet.java 17KB
RefNames.java 17KB
PatchScriptBuilder.java 17KB
QueryProcessor.java 17KB
DropWizardMetricMaker.java 17KB
AllChangesIndexer.java 16KB
FixCalculator.java 16KB
BaseInit.java 16KB
ChangeKindCacheImpl.java 16KB
PatchSetInserter.java 16KB
CommentsUtil.java 15KB
QueryBuilder.java 15KB
StaticModule.java 15KB
RebaseSubmitStrategy.java 15KB
IntraLineLoader.java 14KB
ReviewCommand.java 14KB
SubscriptionGraph.java 14KB
PostGpgKeys.java 14KB
SubmitWithStickyApprovalDiff.java 14KB
ChangesByProjectCacheImpl.java 14KB
SetAccountCommand.java 14KB
AbstractFakeIndex.java 13KB
RevisionApi.java 13KB
SubmoduleCommits.java 13KB
FileDiffOutput.java 13KB
ProjectApi.java 13KB
CommentContextCacheImpl.java 13KB
ConfigSuite.java 13KB
LoginForm.java 13KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
芝麻粒儿
- 粉丝: 5w+
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功