Skip to content

Commit 16b9409

Browse files
authored
Merge pull request #1439 from hackmdio/release/2.0.0
Release 2.0.0
2 parents a5bb0d6 + fc66266 commit 16b9409

File tree

170 files changed

+19285
-16031
lines changed

Some content is hidden

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

170 files changed

+19285
-16031
lines changed

Diff for: .gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules
2-
package-lock.json
32
composer.phar
43
composer.lock
54
.env.*.php

Diff for: .travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ node_js:
77
- "12"
88

99
dist: xenial
10-
cache: yarn
10+
cache: npm
1111

1212
matrix:
1313
fast_finish: true
@@ -19,8 +19,8 @@ matrix:
1919
- node_js: "12"
2020

2121
script:
22-
- yarn test:ci
23-
- yarn build
22+
- npm run test:ci
23+
- npm run build
2424

2525
jobs:
2626
include:

Diff for: Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: ./bin/heroku_start.sh

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ HackMD team is committed to keep CodiMD open source. All contributions are welco
4444
You would find all documentation here: [CodiMD Documentation](https://hackmd.io/c/codimd-documentation)
4545

4646
### Deployment
47-
If you want to spin up an instance and start using immediately, see [Docker deployment](https://hackmd.io/c/codimd-documentation/%2Fs%2Fcodimd-documentation#Deployment).
47+
If you want to spin up an instance and start using immediately, see [Docker deployment](https://hackmd.io/c/codimd-documentation/%2Fs%2Fcodimd-docker-deployment).
4848
If you want to contribute to the project, start with [manual deployment](https://hackmd.io/c/codimd-documentation/%2Fs%2Fcodimd-manual-deployment).
4949

5050
### Configuration

Diff for: app.js

+20-13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ var logger = require('./lib/logger')
2424
var response = require('./lib/response')
2525
var models = require('./lib/models')
2626
var csp = require('./lib/csp')
27+
const { Environment } = require('./lib/config/enum')
28+
29+
const { versionCheckMiddleware, checkVersion } = require('./lib/web/middleware/checkVersion')
2730

2831
function createHttpServer () {
2932
if (config.useSSL) {
@@ -66,7 +69,7 @@ io.engine.ws = new (require('ws').Server)({
6669
})
6770

6871
// others
69-
var realtime = require('./lib/realtime.js')
72+
var realtime = require('./lib/realtime/realtime.js')
7073

7174
// assign socket io to realtime
7275
realtime.io = io
@@ -153,7 +156,7 @@ server.on('resumeSession', function (id, cb) {
153156
})
154157

155158
// middleware which blocks requests when we're too busy
156-
app.use(require('./lib/web/middleware/tooBusy'))
159+
app.use(require('./lib/middleware/tooBusy'))
157160

158161
app.use(flash())
159162

@@ -162,10 +165,15 @@ app.use(passport.initialize())
162165
app.use(passport.session())
163166

164167
// check uri is valid before going further
165-
app.use(require('./lib/web/middleware/checkURIValid'))
168+
app.use(require('./lib/middleware/checkURIValid'))
166169
// redirect url without trailing slashes
167-
app.use(require('./lib/web/middleware/redirectWithoutTrailingSlashes'))
168-
app.use(require('./lib/web/middleware/codiMDVersion'))
170+
app.use(require('./lib/middleware/redirectWithoutTrailingSlashes'))
171+
app.use(require('./lib/middleware/codiMDVersion'))
172+
173+
if (config.autoVersionCheck && process.env.NODE_ENV === Environment.production) {
174+
checkVersion(app)
175+
app.use(versionCheckMiddleware)
176+
}
169177

170178
// routes need sessions
171179
// template files
@@ -186,6 +194,7 @@ app.locals.authProviders = {
186194
facebook: config.isFacebookEnable,
187195
twitter: config.isTwitterEnable,
188196
github: config.isGitHubEnable,
197+
bitbucket: config.isBitbucketEnable,
189198
gitlab: config.isGitLabEnable,
190199
mattermost: config.isMattermostEnable,
191200
dropbox: config.isDropboxEnable,
@@ -199,23 +208,21 @@ app.locals.authProviders = {
199208
email: config.isEmailEnable,
200209
allowEmailRegister: config.allowEmailRegister
201210
}
211+
app.locals.versionInfo = {
212+
latest: true,
213+
versionItem: null
214+
}
202215

203216
// Export/Import menu items
204217
app.locals.enableDropBoxSave = config.isDropboxEnable
205218
app.locals.enableGitHubGist = config.isGitHubEnable
206219
app.locals.enableGitlabSnippets = config.isGitlabSnippetsEnable
207220

208-
app.use(require('./lib/web/baseRouter'))
209-
app.use(require('./lib/web/statusRouter'))
210-
app.use(require('./lib/web/auth'))
211-
app.use(require('./lib/web/historyRouter'))
212-
app.use(require('./lib/web/userRouter'))
213-
app.use(require('./lib/web/imageRouter'))
214-
app.use(require('./lib/web/noteRouter'))
221+
app.use(require('./lib/routes').router)
215222

216223
// response not found if no any route matxches
217224
app.get('*', function (req, res) {
218-
response.errorNotFound(res)
225+
response.errorNotFound(req, res)
219226
})
220227

221228
// socket.io secure

Diff for: app.json

+38-30
Original file line numberDiff line numberDiff line change
@@ -15,124 +15,132 @@
1515
"description": "Let npm also install development build tool",
1616
"value": "false"
1717
},
18-
"HMD_SESSION_SECRET": {
18+
"CMD_SESSION_SECRET": {
1919
"description": "Secret used to secure session cookies.",
2020
"required": false
2121
},
22-
"HMD_HSTS_ENABLE": {
22+
"CMD_HSTS_ENABLE": {
2323
"description": "whether to also use HSTS if HTTPS is enabled",
2424
"required": false
2525
},
26-
"HMD_HSTS_MAX_AGE": {
26+
"CMD_HSTS_MAX_AGE": {
2727
"description": "max duration, in seconds, to tell clients to keep HSTS status",
2828
"required": false
2929
},
30-
"HMD_HSTS_INCLUDE_SUBDOMAINS": {
30+
"CMD_HSTS_INCLUDE_SUBDOMAINS": {
3131
"description": "whether to tell clients to also regard subdomains as HSTS hosts",
3232
"required": false
3333
},
34-
"HMD_HSTS_PRELOAD": {
34+
"CMD_HSTS_PRELOAD": {
3535
"description": "whether to allow at all adding of the site to HSTS preloads (e.g. in browsers)",
3636
"required": false
3737
},
38-
"HMD_DOMAIN": {
38+
"CMD_DOMAIN": {
3939
"description": "domain name",
4040
"required": false
4141
},
42-
"HMD_URL_PATH": {
42+
"CMD_URL_PATH": {
4343
"description": "sub url path, like `www.example.com/<URL_PATH>`",
4444
"required": false
4545
},
46-
"HMD_ALLOW_ORIGIN": {
46+
"CMD_ALLOW_ORIGIN": {
4747
"description": "domain name whitelist (use comma to separate)",
4848
"required": false,
4949
"value": "localhost"
5050
},
51-
"HMD_PROTOCOL_USESSL": {
51+
"CMD_PROTOCOL_USESSL": {
5252
"description": "set to use ssl protocol for resources path (only applied when domain is set)",
5353
"required": false
5454
},
55-
"HMD_URL_ADDPORT": {
55+
"CMD_URL_ADDPORT": {
5656
"description": "set to add port on callback url (port 80 or 443 won't applied) (only applied when domain is set)",
5757
"required": false
5858
},
59-
"HMD_FACEBOOK_CLIENTID": {
59+
"CMD_FACEBOOK_CLIENTID": {
6060
"description": "Facebook API client id",
6161
"required": false
6262
},
63-
"HMD_FACEBOOK_CLIENTSECRET": {
63+
"CMD_FACEBOOK_CLIENTSECRET": {
6464
"description": "Facebook API client secret",
6565
"required": false
6666
},
67-
"HMD_TWITTER_CONSUMERKEY": {
67+
"CMD_TWITTER_CONSUMERKEY": {
6868
"description": "Twitter API consumer key",
6969
"required": false
7070
},
71-
"HMD_TWITTER_CONSUMERSECRET": {
71+
"CMD_TWITTER_CONSUMERSECRET": {
7272
"description": "Twitter API consumer secret",
7373
"required": false
7474
},
75-
"HMD_GITHUB_CLIENTID": {
75+
"CMD_GITHUB_CLIENTID": {
7676
"description": "GitHub API client id",
7777
"required": false
7878
},
79-
"HMD_GITHUB_CLIENTSECRET": {
79+
"CMD_GITHUB_CLIENTSECRET": {
8080
"description": "GitHub API client secret",
8181
"required": false
8282
},
83-
"HMD_GITLAB_BASEURL": {
83+
"CMD_BITBUCKET_CLIENTID": {
84+
"description": "Bitbucket API client id",
85+
"required": false
86+
},
87+
"CMD_BITBUCKET_CLIENTSECRET": {
88+
"description": "Bitbucket API client secret",
89+
"required": false
90+
},
91+
"CMD_GITLAB_BASEURL": {
8492
"description": "GitLab authentication endpoint, set to use other endpoint than GitLab.com (optional)",
8593
"required": false
8694
},
87-
"HMD_GITLAB_CLIENTID": {
95+
"CMD_GITLAB_CLIENTID": {
8896
"description": "GitLab API client id",
8997
"required": false
9098
},
91-
"HMD_GITLAB_CLIENTSECRET": {
99+
"CMD_GITLAB_CLIENTSECRET": {
92100
"description": "GitLab API client secret",
93101
"required": false
94102
},
95-
"HMD_GITLAB_SCOPE": {
103+
"CMD_GITLAB_SCOPE": {
96104
"description": "GitLab API client scope (optional)",
97105
"required": false
98106
},
99-
"HMD_MATTERMOST_BASEURL": {
107+
"CMD_MATTERMOST_BASEURL": {
100108
"description": "Mattermost authentication endpoint",
101109
"required": false
102110
},
103-
"HMD_MATTERMOST_CLIENTID": {
111+
"CMD_MATTERMOST_CLIENTID": {
104112
"description": "Mattermost API client id",
105113
"required": false
106114
},
107-
"HMD_MATTERMOST_CLIENTSECRET": {
115+
"CMD_MATTERMOST_CLIENTSECRET": {
108116
"description": "Mattermost API client secret",
109117
"required": false
110118
},
111-
"HMD_DROPBOX_CLIENTID": {
119+
"CMD_DROPBOX_CLIENTID": {
112120
"description": "Dropbox API client id",
113121
"required": false
114122
},
115-
"HMD_DROPBOX_CLIENTSECRET": {
123+
"CMD_DROPBOX_CLIENTSECRET": {
116124
"description": "Dropbox API client secret",
117125
"required": false
118126
},
119-
"HMD_DROPBOX_APP_KEY": {
127+
"CMD_DROPBOX_APP_KEY": {
120128
"description": "Dropbox app key (for import/export)",
121129
"required": false
122130
},
123-
"HMD_GOOGLE_CLIENTID": {
131+
"CMD_GOOGLE_CLIENTID": {
124132
"description": "Google API client id",
125133
"required": false
126134
},
127-
"HMD_GOOGLE_CLIENTSECRET": {
135+
"CMD_GOOGLE_CLIENTSECRET": {
128136
"description": "Google API client secret",
129137
"required": false
130138
},
131-
"HMD_IMGUR_CLIENTID": {
139+
"CMD_IMGUR_CLIENTID": {
132140
"description": "Imgur API client id",
133141
"required": false
134142
},
135-
"HMD_ALLOW_PDF_EXPORT": {
143+
"CMD_ALLOW_PDF_EXPORT": {
136144
"description": "Enable or disable PDF exports",
137145
"required": false
138146
}

Diff for: bin/heroku

+1-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,7 @@ set -e
44

55
if [ ! -z "$DYNO" ]; then
66
# setup config files
7-
cat << EOF > .sequelizerc
8-
var path = require('path');
9-
10-
module.exports = {
11-
'config': path.resolve('config.json'),
12-
'migrations-path': path.resolve('lib', 'migrations'),
13-
'models-path': path.resolve('lib', 'models'),
14-
'url': process.env.DATABASE_URL
15-
}
16-
17-
EOF
7+
cp .sequelizerc.example .sequelizerc
188

199
cat << EOF > config.json
2010

Diff for: bin/heroku_start.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
CMD_DB_URL="$DATABASE_URL" CMD_PORT="$PORT" npm run start

Diff for: bin/setup

+4-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ if [ -d .git ]; then
88
cd "$(git rev-parse --show-toplevel)"
99
fi
1010

11-
if ! type yarn > /dev/null
11+
if ! type npm > /dev/null
1212
then
1313
cat << EOF
14-
yarn is not installed, please install Node.js, npm and yarn.
14+
npm is not installed, please install Node.js and npm.
1515
Read more on Node.js official website: https://nodejs.org
16-
And for yarn package manager at: https://yarnpkg.com/en/
1716
Setup will not be run
1817
EOF
1918
exit 0
@@ -29,14 +28,13 @@ if [ ! -f .sequelizerc ]; then
2928
fi
3029

3130
echo "install packages"
32-
yarn install --pure-lockfile
33-
yarn install --production=false --pure-lockfile
31+
npm install
3432

3533
cat << EOF
3634
3735
3836
Edit the following config file to setup CodiMD server and client.
39-
Read more info at https://github.com/hackmdio/codimd#configuration-files
37+
Read more info at https://hackmd.io/c/codimd-documentation/%2Fs%2Fcodimd-configuration
4038
4139
* config.json -- CodiMD config
4240
* .sequelizerc -- db config

Diff for: deployments/Dockerfile

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ COPY --chown=hackmd:hackmd . .
55
RUN set -xe && \
66
git reset --hard && \
77
git clean -fx && \
8-
yarn install && \
9-
yarn build && \
10-
yarn install --production=true && \
8+
npm install && \
9+
npm run build && \
1110
cp ./deployments/docker-entrypoint.sh ./ && \
1211
cp .sequelizerc.example .sequelizerc && \
1312
rm -rf .git .gitignore .travis.yml .dockerignore .editorconfig .babelrc .mailmap .sequelizerc.example \
1413
test docs contribute \
15-
yarn.lock webpack.prod.js webpack.htmlexport.js webpack.dev.js webpack.common.js \
14+
package-lock.json webpack.prod.js webpack.htmlexport.js webpack.dev.js webpack.common.js \
1615
config.json.example README.md CONTRIBUTING.md AUTHORS
1716

1817
FROM hackmdio/runtime:1.0.6

Diff for: deployments/docker-compose.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: "3"
22
services:
33
database:
4-
image: postgres:11.5
4+
image: postgres:11.6-alpine
55
environment:
66
- POSTGRES_USER=codimd
77
- POSTGRES_PASSWORD=change_password
@@ -11,10 +11,10 @@ services:
1111
restart: always
1212
codimd:
1313
# you can use image or custom build below
14-
# image: nabo.codimd.dev/hackmdio/hackmd:1.4.0
15-
build:
16-
context: ..
17-
dockerfile: ./deployments/Dockerfile
14+
image: nabo.codimd.dev/hackmdio/hackmd:2.0.0
15+
# build:
16+
# context: ..
17+
# dockerfile: ./deployments/Dockerfile
1818
environment:
1919
- CMD_DB_URL=postgres://codimd:change_password@database/codimd
2020
- CMD_USECDN=false

0 commit comments

Comments
 (0)