Skip to content

Commit a0cc195

Browse files
authored
Prepare release 1.4.0 (#1344)
Prepare release 1.4.0
2 parents 5256fe9 + 2358dd2 commit a0cc195

File tree

108 files changed

+10103
-2785
lines changed

Some content is hidden

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

108 files changed

+10103
-2785
lines changed

Diff for: .dockerignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.idea
2+
coverage
3+
node_modules/
4+
5+
# ignore config files
6+
config.json
7+
.sequelizerc
8+
9+
# ignore webpack build
10+
public/build
11+
public/views/build
12+
13+
.nyc_output
14+
coverage/

Diff for: .eslintignore

-3
This file was deleted.

Diff for: .eslintrc.js

-21
This file was deleted.

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ public/views/build
2727

2828
public/uploads/*
2929
!public/uploads/.gitkeep
30+
/.nyc_output
31+
/coverage/

Diff for: .sequelizerc.example

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
var path = require('path');
1+
const path = require('path')
2+
const config = require('./lib/config')
23

34
module.exports = {
4-
'config': path.resolve('config.json'),
5-
'migrations-path': path.resolve('lib', 'migrations'),
6-
'models-path': path.resolve('lib', 'models'),
7-
'url': 'change this'
8-
}
5+
config: path.resolve('config.json'),
6+
'migrations-path': path.resolve('lib', 'migrations'),
7+
'models-path': path.resolve('lib', 'models'),
8+
url: process.env['CMD_DB_URL'] || config.dbURL
9+
}

Diff for: .travis.yml

+25-32
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
11
language: node_js
2-
dist: trusty
2+
3+
node_js:
4+
- "lts/carbon"
5+
- "lts/dubnium"
6+
- "11"
7+
- "12"
8+
9+
dist: xenial
310
cache: yarn
4-
env:
5-
global:
6-
- CXX=g++-4.8
7-
- YARN_VERSION=1.3.2
11+
12+
matrix:
13+
fast_finish: true
14+
include:
15+
- node_js: lts/carbon
16+
- node_js: lts/dubnium
17+
allow_failures:
18+
- node_js: "11"
19+
- node_js: "12"
20+
21+
script:
22+
- yarn test:ci
23+
- yarn build
824

925
jobs:
1026
include:
11-
- env: task=npm-test
12-
node_js:
13-
- 8
14-
before_install:
15-
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "$YARN_VERSION"
16-
- export PATH="$HOME/.yarn/bin:$PATH"
17-
- env: task=npm-test
18-
node_js:
19-
- 10
20-
before_install:
21-
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "$YARN_VERSION"
22-
- export PATH="$HOME/.yarn/bin:$PATH"
23-
- env: task=ShellCheck
24-
script:
25-
- shellcheck bin/heroku bin/setup
26-
language: generic
27-
- env: task=doctoc
28-
install: npm install doctoc
27+
- stage: doctoc-check
28+
install: npm install -g doctoc
29+
if: type = pull_request OR branch = master
2930
script:
3031
- cp README.md README.md.orig
3132
- npm run doctoc
3233
- diff -q README.md README.md.orig
33-
language: generic
34-
- env: task=json-lint
35-
addons:
36-
apt:
37-
packages:
38-
- jq
39-
script:
40-
- npm run jsonlint
41-
language: generic
34+
node_js: lts/carbon

Diff for: README.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ CodiMD
99
CodiMD lets you collaborate in real-time with markdown.
1010
Built on [HackMD](https://hackmd.io) source code, CodiMD lets you host and control your team's content with speed and ease.
1111

12+
![screenshot](https://raw.githubusercontent.com/hackmdio/codimd/develop/public/screenshot.png)
13+
1214
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
1315
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
1416
# Table of Contents
@@ -71,20 +73,11 @@ All contributions are welcome! Even asking a question helps.
7173
## Browser Support
7274

7375
CodiMD is a service that runs on Node.js, while users use the service through browsers. We support your users using the following browsers:
74-
- ![Chrome](http://browserbadge.com/chrome/47/18px)
75-
- Chrome >= 47
76-
- Chrome for Android >= 47
77-
- ![Safari](http://browserbadge.com/safari/9/18px)
78-
- Safari >= 9
79-
- iOS Safari >= 8.4
80-
- ![Firefox](http://browserbadge.com/firefox/44/18px)
81-
- Firefox >= 44
82-
- ![IE](http://browserbadge.com/ie/9/18px)
83-
- IE >= 9
84-
- Edge >= 12
85-
- ![Opera](http://browserbadge.com/opera/34/18px)
86-
- Opera >= 34
87-
- Opera Mini not supported
76+
- <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" /> Chrome >= 47, Chrome for Android >= 47
77+
- <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" /> Safari >= 9, iOS Safari >= 8.4
78+
- <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" /> Firefox >= 44
79+
- <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" /> IE >= 9, Edge >= 12
80+
- <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" /> Opera >= 34, Opera Mini not supported
8881
- Android Browser >= 4.4
8982

9083
To stay up to date with your installation it's recommended to subscribe the [release feed][github-release-feed].

Diff for: app.js

+30-26
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ var ejs = require('ejs')
77
var passport = require('passport')
88
var methodOverride = require('method-override')
99
var cookieParser = require('cookie-parser')
10-
var compression = require('compression')
1110
var session = require('express-session')
1211
var SequelizeStore = require('connect-session-sequelize')(session.Store)
1312
var fs = require('fs')
@@ -26,34 +25,37 @@ var response = require('./lib/response')
2625
var models = require('./lib/models')
2726
var csp = require('./lib/csp')
2827

29-
// server setup
30-
var app = express()
31-
var server = null
32-
if (config.useSSL) {
33-
var ca = (function () {
34-
var i, len, results
35-
results = []
36-
for (i = 0, len = config.sslCAPath.length; i < len; i++) {
37-
results.push(fs.readFileSync(config.sslCAPath[i], 'utf8'))
28+
function createHttpServer () {
29+
if (config.useSSL) {
30+
const ca = (function () {
31+
let i, len
32+
const results = []
33+
for (i = 0, len = config.sslCAPath.length; i < len; i++) {
34+
results.push(fs.readFileSync(config.sslCAPath[i], 'utf8'))
35+
}
36+
return results
37+
})()
38+
const options = {
39+
key: fs.readFileSync(config.sslKeyPath, 'utf8'),
40+
cert: fs.readFileSync(config.sslCertPath, 'utf8'),
41+
ca: ca,
42+
dhparam: fs.readFileSync(config.dhParamPath, 'utf8'),
43+
requestCert: false,
44+
rejectUnauthorized: false
3845
}
39-
return results
40-
})()
41-
var options = {
42-
key: fs.readFileSync(config.sslKeyPath, 'utf8'),
43-
cert: fs.readFileSync(config.sslCertPath, 'utf8'),
44-
ca: ca,
45-
dhparam: fs.readFileSync(config.dhParamPath, 'utf8'),
46-
requestCert: false,
47-
rejectUnauthorized: false
46+
return require('https').createServer(options, app)
47+
} else {
48+
return require('http').createServer(app)
4849
}
49-
server = require('https').createServer(options, app)
50-
} else {
51-
server = require('http').createServer(app)
5250
}
5351

52+
// server setup
53+
var app = express()
54+
var server = createHttpServer()
55+
5456
// logger
5557
app.use(morgan('combined', {
56-
'stream': logger.stream
58+
stream: logger.stream
5759
}))
5860

5961
// socket io
@@ -77,9 +79,6 @@ var sessionStore = new SequelizeStore({
7779
db: models.sequelize
7880
})
7981

80-
// compression
81-
app.use(compression())
82-
8382
// use hsts to tell https users stick to this
8483
if (config.hsts.enable) {
8584
app.use(helmet.hsts({
@@ -181,6 +180,7 @@ app.locals.serverURL = config.serverURL
181180
app.locals.sourceURL = config.sourceURL
182181
app.locals.allowAnonymous = config.allowAnonymous
183182
app.locals.allowAnonymousEdits = config.allowAnonymousEdits
183+
app.locals.permission = config.permission
184184
app.locals.allowPDFExport = config.allowPDFExport
185185
app.locals.authProviders = {
186186
facebook: config.isFacebookEnable,
@@ -279,6 +279,7 @@ process.on('uncaughtException', function (err) {
279279
function handleTermSignals () {
280280
logger.info('CodiMD has been killed by signal, try to exit gracefully...')
281281
realtime.maintenance = true
282+
realtime.terminate()
282283
// disconnect all socket.io clients
283284
Object.keys(io.sockets.sockets).forEach(function (key) {
284285
var socket = io.sockets.sockets[key]
@@ -299,6 +300,9 @@ function handleTermSignals () {
299300
})
300301
}
301302
}, 100)
303+
setTimeout(() => {
304+
process.exit(1)
305+
}, 5000)
302306
}
303307
process.on('SIGINT', handleTermSignals)
304308
process.on('SIGTERM', handleTermSignals)

Diff for: app.json

-8
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,10 @@
1111
"logo": "https://github.com/hackmdio/codimd/raw/master/public/codimd-icon-1024.png",
1212
"success_url": "/",
1313
"env": {
14-
"BUILD_ASSETS": {
15-
"description": "Our build script variable",
16-
"value": "true"
17-
},
1814
"NPM_CONFIG_PRODUCTION": {
1915
"description": "Let npm also install development build tool",
2016
"value": "false"
2117
},
22-
"DB_TYPE": {
23-
"description": "Specify database type. See sequelize available databases. Default using postgres",
24-
"value": "postgres"
25-
},
2618
"HMD_SESSION_SECRET": {
2719
"description": "Secret used to secure session cookies.",
2820
"required": false

Diff for: bin/heroku

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -e
44

5-
if [ "$BUILD_ASSETS" = true ]; then
5+
if [ ! -z "$DYNO" ]; then
66
# setup config files
77
cat << EOF > .sequelizerc
88
var path = require('path');
@@ -11,8 +11,7 @@ module.exports = {
1111
'config': path.resolve('config.json'),
1212
'migrations-path': path.resolve('lib', 'migrations'),
1313
'models-path': path.resolve('lib', 'models'),
14-
'url': process.env.DATABASE_URL,
15-
'dialect': process.env.DB_TYPE
14+
'url': process.env.DATABASE_URL
1615
}
1716
1817
EOF
@@ -26,6 +25,4 @@ EOF
2625
2726
EOF
2827

29-
# build app
30-
npm run build
3128
fi

Diff for: config.json.example

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"db": {
44
"dialect": "sqlite",
55
"storage": ":memory:"
6-
}
6+
},
7+
"linkifyHeaderStyle": "gfm"
78
},
89
"development": {
910
"loglevel": "debug",
@@ -13,7 +14,8 @@
1314
"db": {
1415
"dialect": "sqlite",
1516
"storage": "./db.codimd.sqlite"
16-
}
17+
},
18+
"linkifyHeaderStyle": "gfm"
1719
},
1820
"production": {
1921
"domain": "localhost",
@@ -123,6 +125,11 @@
123125
{
124126
"connectionString": "change this",
125127
"container": "change this"
126-
}
128+
},
129+
"plantuml":
130+
{
131+
"server": "https://www.plantuml.com/plantuml"
132+
},
133+
"linkifyHeaderStyle": "gfm"
127134
}
128135
}

Diff for: deployments/Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM hackmdio/buildpack:1.0.4 as BUILD
2+
3+
COPY --chown=hackmd:hackmd . .
4+
5+
RUN set -xe && \
6+
git reset --hard && \
7+
git clean -fx && \
8+
yarn install && \
9+
yarn build && \
10+
yarn install --production=true && \
11+
cp ./deployments/docker-entrypoint.sh ./ && \
12+
cp .sequelizerc.example .sequelizerc && \
13+
rm -rf .git .gitignore .travis.yml .dockerignore .editorconfig .babelrc .mailmap .sequelizerc.example \
14+
test docs contribute \
15+
yarn.lock webpack.prod.js webpack.htmlexport.js webpack.dev.js webpack.common.js \
16+
config.json.example README.md CONTRIBUTING.md AUTHORS
17+
18+
FROM hackmdio/runtime:1.0.4
19+
USER hackmd
20+
WORKDIR /home/hackmd/app
21+
COPY --chown=1500:1500 --from=BUILD /home/hackmd/app .
22+
EXPOSE 3000
23+
ENTRYPOINT ["/home/hackmd/app/docker-entrypoint.sh"]

Diff for: deployments/build.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
CURRENT_DIR=$(dirname "$BASH_SOURCE")
4+
5+
docker build -t hackmdio/codimd -f "$CURRENT_DIR/Dockerfile" "$CURRENT_DIR/.."

0 commit comments

Comments
 (0)