Skip to content

Commit 8b56c60

Browse files
committed
Merge remote-tracking branch 'upstream/master' into allow-multiple-keywords-in-search
2 parents e65635e + 7119b08 commit 8b56c60

File tree

105 files changed

+2389
-1682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2389
-1682
lines changed

.buildpacks

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
https://github.com/Starkast/heroku-buildpack-cmake#a243c67
21
https://github.com/emk/heroku-buildpack-rust#578d630
32
https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/emberjs.tgz
43
https://github.com/heroku/heroku-buildpack-nginx.git#fbc49cd

.travis.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: rust
22
sudo: required
3-
dist: trusty
3+
dist: xenial
44

55
# Ignore this branch per bors-ng documentation
66
branches:
@@ -24,8 +24,11 @@ env:
2424
# on community-submitted PRs
2525
- PERCY_TOKEN=0d8707a02b19aebbec79bb0bf302b8d2fa95edb33169cfe41b084289596670b1
2626
- PERCY_PROJECT=crates-io/crates.io
27+
- PGPORT=5433
2728

2829
install:
30+
- sudo cp /etc/postgresql/10/main/pg_hba.conf /etc/postgresql/11/main/pg_hba.conf
31+
- sudo systemctl restart postgresql@11-main
2932
- script/ci/cargo-clean-on-new-rustc-version.sh
3033
- cargo install --force diesel_cli --vers `cat .diesel_version` --no-default-features --features postgres && export PATH=$HOME/.cargo/bin:$PATH
3134

@@ -34,15 +37,11 @@ before_script:
3437

3538
addons:
3639
chrome: stable
37-
postgresql: "9.5"
40+
postgresql: "11"
3841
apt:
39-
sources:
40-
- kalakris-cmake
4142
packages:
42-
- cmake
43-
- libcurl4-openssl-dev
44-
- libelf-dev
45-
- libdw-dev
43+
- postgresql-11
44+
- postgresql-client-11
4645

4746
matrix:
4847
fast_finish: true

Cargo.lock

Lines changed: 825 additions & 669 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ rustdoc-args = [
2929

3030
[dependencies]
3131
cargo-registry-s3 = { path = "src/s3", version = "0.2.0" }
32-
old_semver = { path = "src/old_semver", version = "0.1.0" }
33-
rand = "0.3"
34-
git2 = "0.6.4"
32+
rand = "0.6"
33+
git2 = "0.8.0"
3534
flate2 = "1.0"
3635
semver = { version = "0.9", git = "https://github.com/steveklabnik/semver.git", features = ["diesel", "serde"] }
3736
url = "1.2.1"
38-
tar = "0.4.13"
37+
tar = "0.4.16"
3938
base64 = "0.9"
4039

4140
openssl = "0.10.13"
@@ -49,26 +48,24 @@ dotenv = "0.11.0"
4948
toml = "0.4"
5049
diesel = { version = "1.4.0", features = ["postgres", "serde_json", "chrono", "r2d2"] }
5150
diesel_full_text_search = "1.0.0"
52-
diesel_ltree = "0.1.3"
51+
swirl = { git = "https://github.com/sgrif/swirl.git", rev = "de5d8bb" }
5352
serde_json = "1.0.0"
54-
serde_derive = "1.0.0"
55-
serde = "1.0.0"
53+
serde = { version = "1.0.0", features = ["derive"] }
5654
chrono = { version = "0.4.0", features = ["serde"] }
57-
comrak = { version = "0.2.3", default-features = false }
58-
ammonia = "1.0.0"
55+
comrak = { version = "0.4.0", default-features = false }
56+
ammonia = "2.0.0"
5957
docopt = "0.8.1"
60-
itertools = "0.7.0"
6158
scheduled-thread-pool = "0.2.0"
6259
derive_deref = "1.0.0"
6360
reqwest = "0.9.1"
6461
tempdir = "0.3.7"
6562
collecting-hashmap = "0.2"
6663
parking_lot = "0.7.1"
67-
jemallocator = { version = "0.1.8", features = ['unprefixed_malloc_on_supported_platforms'] }
64+
jemallocator = { version = "0.1.8", features = ['unprefixed_malloc_on_supported_platforms', 'profiling'] }
6865
jemalloc-ctl = "0.2.0"
6966

70-
lettre = {git = "https://github.com/lettre/lettre", version = "0.9"}
71-
lettre_email = {git = "https://github.com/lettre/lettre", version = "0.9"}
67+
lettre = "0.9"
68+
lettre_email = "0.9"
7269

7370
conduit = "0.8"
7471
conduit-conditional-get = "0.8"
@@ -79,6 +76,7 @@ conduit-router = "0.8"
7976
conduit-static = "0.8"
8077
conduit-git-http-backend = "0.8"
8178
civet = "0.9"
79+
conduit-hyper = "0.1.3"
8280

8381
[dev-dependencies]
8482
conduit-test = "0.8"
@@ -87,7 +85,6 @@ hyper-tls = "0.3"
8785
futures = "0.1"
8886
lazy_static = "1.0"
8987
tokio-core = "0.1"
90-
tokio-service = "0.1"
9188

9289
[build-dependencies]
9390
dotenv = "0.11"

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
web: bin/diesel migration run && bin/start-nginx ./target/release/server
2-
worker: ./target/release/update-downloads daemon 300
2+
background_worker: ./target/release/background-worker

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# crates.io
22

33
[![Build Status](https://travis-ci.org/rust-lang/crates.io.svg?branch=master)](https://travis-ci.org/rust-lang/crates.io)
4+
[![What's Deployed](https://img.shields.io/badge/whatsdeployed-prod-green.svg)](https://whatsdeployed.io/s-9IG)
45

56
Source code for the default [Cargo](http://doc.crates.io) registry. Viewable
67
online at [crates.io](https://crates.io).
@@ -15,7 +16,7 @@ of the following ways:
1516

1617
- [File a new issue](https://github.com/rust-lang/crates.io/issues/new)
1718
18-
- Chat on irc.mozilla.org in the [#rust-infra](https://kiwiirc.com/client/irc.mozilla.org:+6667/#rust-infra) channel
19+
- Chat on ops > #crates-io channel on https://discord.gg/rust-lang
1920

2021
A volunteer will get back to you as soon as possible.
2122

RustConfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VERSION=1.32.0

app/components/download-graph.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,20 @@ export default Component.extend({
7878

7979
let myData = window.google.visualization.arrayToDataTable(data);
8080

81-
let fmt = new window.google.visualization.DateFormat({
81+
let dateFmt = new window.google.visualization.DateFormat({
8282
pattern: 'LLL d, yyyy',
8383
});
84-
fmt.format(myData, 0);
84+
dateFmt.format(myData, 0);
85+
86+
// Create a formatter to use for daily download numbers
87+
let numberFormatWhole = new window.google.visualization.NumberFormat({
88+
pattern: '#,##0',
89+
});
90+
91+
// Create a formatter to use for 7-day average numbers
92+
let numberFormatDecimal = new window.google.visualization.NumberFormat({
93+
pattern: '#,##0.0',
94+
});
8595

8696
// use a DataView to calculate an x-day moving average
8797
let days = 7;
@@ -101,7 +111,7 @@ export default Component.extend({
101111
let avg = total / days;
102112
return {
103113
v: avg,
104-
f: avg.toFixed(2),
114+
f: numberFormatDecimal.formatValue(avg),
105115
};
106116
};
107117
};
@@ -113,6 +123,8 @@ export default Component.extend({
113123
// is at the end, but in the UI we want it at the top of the chart legend.
114124

115125
range(headers.length - 1, 0, -1).forEach((dataCol, i) => {
126+
// Set the number format for the colum in the data table.
127+
numberFormatWhole.format(myData, dataCol);
116128
columns.push(dataCol); // add the column itself
117129
columns.push({
118130
// add a 'calculated' column, the moving average

app/routes/crate/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default Route.extend({
6262
.get('versions')
6363
.then(versions => {
6464
const latestStableVersion = versions.find(version => {
65-
if (!isUnstableVersion(version.get('num'))) {
65+
if (!isUnstableVersion(version.get('num')) && !version.get('yanked')) {
6666
return version;
6767
}
6868
});

app/routes/github-authorize.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Route from '@ember/routing/route';
2-
import ajax from 'ember-fetch/ajax';
2+
import fetch from 'fetch';
33
import { serializeQueryParams } from 'ember-fetch/mixins/adapter-fetch';
44

55
/**
@@ -19,8 +19,9 @@ export default Route.extend({
1919
async beforeModel(transition) {
2020
try {
2121
let queryParams = serializeQueryParams(transition.queryParams);
22-
let d = await ajax(`/authorize?${queryParams}`);
23-
let item = JSON.stringify({ ok: true, data: d });
22+
let resp = await fetch(`/authorize?${queryParams}`);
23+
let json = await resp.json();
24+
let item = JSON.stringify({ ok: resp.ok, data: json });
2425
if (window.opener) {
2526
window.opener.github_response = item;
2627
}

app/routes/login.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ export default Route.extend({
5353
if (!response) {
5454
return;
5555
}
56-
if (!response.ok) {
57-
this.flashMessages.show('Failed to log in');
58-
return;
59-
}
56+
6057
let { data } = response;
61-
if (data.errors) {
58+
if (data && data.errors) {
6259
let error = `Failed to log in: ${data.errors[0].detail}`;
6360
this.flashMessages.show(error);
6461
return;
62+
} else if (!response.ok) {
63+
this.flashMessages.show('Failed to log in');
64+
return;
6565
}
6666

6767
let user = this.store.push(this.store.normalize('user', data.user));

app/templates/application.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
placeholder="Click or press 'S' to search..."
2121
value={{searchQuery}}
2222
oninput={{action (mut searchQuery) value="target.value"}}
23+
autocorrect="off"
24+
autocapitalize="off"
2325
autofocus="autofocus"
26+
spellcheck="false"
2427
required
2528
data-test-search-input>
2629
<label for="cargo-desktop-search">Search</label>

app/templates/crate/version.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
<h3>Dev-Dependencies</h3>
234234
<ul>
235235
{{#each currentDevDependencies as |dep|}}
236-
{{link-to-dep dep=dep}}
236+
{{link-to-dep tagName="li" dep=dep}}
237237
{{/each}}
238238
</ul>
239239
</div>

backend.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM rust:latest
22

33
RUN apt-get update \
4-
&& apt-get install -y postgresql cmake \
4+
&& apt-get install -y postgresql \
55
&& rm -rf /var/lib/apt/lists/* \
66
&& cargo install diesel_cli --no-default-features --features postgres
77

config/nginx.conf.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ http {
6767
location ~ ^/api/v./crates/new$ {
6868
proxy_pass http://app_server;
6969

70-
limit_req zone=publish burst=10 nodelay;
70+
limit_req zone=publish burst=30 nodelay;
7171
limit_req_status 429;
7272
}
7373
}

diesel.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
[print_schema]
44
file = "src/schema.rs"
55
with_docs = true
6-
import_types = ["diesel::sql_types::*", "diesel_full_text_search::{TsVector as Tsvector}", "diesel_ltree::Ltree"]
6+
import_types = ["diesel::sql_types::*", "diesel_full_text_search::{TsVector as Tsvector}"]
77
patch_file = "src/schema.patch"

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ services:
3737
build:
3838
context: .
3939
dockerfile: frontend.Dockerfile
40-
entrypoint: npm run start --proxy http://backend:8888
40+
entrypoint: npm run start -- --proxy http://backend:8888
4141
links:
4242
- backend
4343
ports:

docker_entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
# If the backend is started before postgres is ready, the migrations will fail
4-
until diesel migration run; do
4+
until diesel migration run --locked-schema; do
55
echo "Migrations failed, retrying in 5 seconds..."
66
sleep 5
77
done

docs/BACKEND.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ The server does the following things:
1212
3. Reads values from environment variables to configure a new instance of `cargo_registry::App`
1313
4. Adds middleware to the app by calling `cargo_registry::middleware`
1414
5. Syncs the categories defined in *src/categories.toml* with the categories in the database
15-
6. Starts a [civet][] `Server` that uses the `cargo_registry::App` instance
15+
6. Starts either a [conduit] or a [hyper] server that uses the `cargo_registry::App` instance
1616
7. Tells Nginx on Heroku that the application is ready to receive requests, if running on Heroku
17-
8. Blocks forever (or until the process is killed) waiting to receive messages on a channel that no
18-
messages are ever sent to, in order to outive the civet `Server` threads
17+
8. Blocks forever (or until the process is killed)
1918

2019
[civet]: https://crates.io/crates/civet
20+
[hyper]: https://crates.io/crates/hyper
2121

2222
## Routes
2323

docs/CONTRIBUTING.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ In order to run the backend, you will need to have installed:
145145

146146
- [Rust](https://www.rust-lang.org/en-US/) stable >= 1.16.0 and cargo, which comes with Rust
147147
- [Postgres](https://www.postgresql.org/) >= 9.5
148-
- [CMake](https://cmake.org/download/) >= 3.6.1
149148
- [OpenSSL](https://www.openssl.org/) >= 1.0.2k
150149
- [diesel_cli](http://diesel.rs/guides/getting-started/) >= 1.2.0
151150

@@ -230,15 +229,6 @@ by typing `\q`) without any errors to connect to your running Postgres server.
230229
> we'll help fix the problem and and will add the solution to these
231230
> instructions!
232231
233-
##### CMake
234-
235-
- All platforms: CMake [has binary distributions
236-
available](https://cmake.org/download/)
237-
- macOS: you can also install with homebrew by using `brew install cmake`
238-
- Linux: you should be able to use the distribution repositories by doing `sudo
239-
apt-get install cmake` (Ubuntu) or `sudo dnf install cmake` (Fedora) or
240-
whatever is appropriate for your distribution.
241-
242232
##### OpenSSL
243233
244234
- Windows: [Win32 OpenSSL Installation

frontend.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
FROM node:8.6-alpine
22

33
WORKDIR /app
4-
COPY package.json /app
4+
COPY package.json package-lock.json /app/
5+
6+
RUN npm install
57

68
COPY . /app
79

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE background_jobs;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE background_jobs (
2+
id BIGSERIAL PRIMARY KEY,
3+
job_type TEXT NOT NULL,
4+
data JSONB NOT NULL,
5+
retries INTEGER NOT NULL DEFAULT 0,
6+
last_retry TIMESTAMP NOT NULL DEFAULT '1970-01-01',
7+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
8+
);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE versions DROP CONSTRAINT fk_versions_published_by;
2+
3+
ALTER TABLE versions DROP COLUMN published_by;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ALTER TABLE versions
2+
ADD COLUMN published_by integer;
3+
4+
ALTER TABLE versions
5+
ADD CONSTRAINT "fk_versions_published_by"
6+
FOREIGN KEY (published_by)
7+
REFERENCES users(id);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE versions_published_by;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE TABLE versions_published_by (
2+
version_id INTEGER NOT NULL PRIMARY KEY REFERENCES versions(id) ON DELETE CASCADE,
3+
email VARCHAR NOT NULL
4+
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DROP MATERIALIZED VIEW recent_crate_downloads;
2+
CREATE MATERIALIZED VIEW recent_crate_downloads (crate_id, downloads) AS
3+
SELECT crate_id, SUM(downloads) FROM crate_downloads
4+
WHERE date > date(CURRENT_TIMESTAMP - INTERVAL '90 days')
5+
GROUP BY crate_id;
6+
CREATE UNIQUE INDEX recent_crate_downloads_crate_id ON recent_crate_downloads (crate_id);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
DROP MATERIALIZED VIEW recent_crate_downloads;
2+
CREATE MATERIALIZED VIEW recent_crate_downloads (crate_id, downloads) AS
3+
SELECT crate_id, SUM(version_downloads.downloads) FROM version_downloads
4+
INNER JOIN versions
5+
ON version_downloads.version_id = versions.id
6+
WHERE version_downloads.date > date(CURRENT_TIMESTAMP - INTERVAL '90 days')
7+
GROUP BY crate_id;
8+
CREATE UNIQUE INDEX recent_crate_downloads_crate_id ON recent_crate_downloads (crate_id);

0 commit comments

Comments
 (0)