Skip to content

Commit

Permalink
Prepare release 1.4.0 (#1344)
Browse files Browse the repository at this point in the history
Prepare release 1.4.0
  • Loading branch information
jackycute committed Nov 11, 2019
2 parents 5256fe9 + 2358dd2 commit a0cc195
Show file tree
Hide file tree
Showing 108 changed files with 10,103 additions and 2,785 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
@@ -0,0 +1,14 @@
.idea
coverage
node_modules/

# ignore config files
config.json
.sequelizerc

# ignore webpack build
public/build
public/views/build

.nyc_output
coverage/
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

21 changes: 0 additions & 21 deletions .eslintrc.js

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -27,3 +27,5 @@ public/views/build

public/uploads/*
!public/uploads/.gitkeep
/.nyc_output
/coverage/
13 changes: 7 additions & 6 deletions .sequelizerc.example
@@ -1,8 +1,9 @@
var path = require('path');
const path = require('path')
const config = require('./lib/config')

module.exports = {
'config': path.resolve('config.json'),
'migrations-path': path.resolve('lib', 'migrations'),
'models-path': path.resolve('lib', 'models'),
'url': 'change this'
}
config: path.resolve('config.json'),
'migrations-path': path.resolve('lib', 'migrations'),
'models-path': path.resolve('lib', 'models'),
url: process.env['CMD_DB_URL'] || config.dbURL
}
57 changes: 25 additions & 32 deletions .travis.yml
@@ -1,41 +1,34 @@
language: node_js
dist: trusty

node_js:
- "lts/carbon"
- "lts/dubnium"
- "11"
- "12"

dist: xenial
cache: yarn
env:
global:
- CXX=g++-4.8
- YARN_VERSION=1.3.2

matrix:
fast_finish: true
include:
- node_js: lts/carbon
- node_js: lts/dubnium
allow_failures:
- node_js: "11"
- node_js: "12"

script:
- yarn test:ci
- yarn build

jobs:
include:
- env: task=npm-test
node_js:
- 8
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "$YARN_VERSION"
- export PATH="$HOME/.yarn/bin:$PATH"
- env: task=npm-test
node_js:
- 10
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "$YARN_VERSION"
- export PATH="$HOME/.yarn/bin:$PATH"
- env: task=ShellCheck
script:
- shellcheck bin/heroku bin/setup
language: generic
- env: task=doctoc
install: npm install doctoc
- stage: doctoc-check
install: npm install -g doctoc
if: type = pull_request OR branch = master
script:
- cp README.md README.md.orig
- npm run doctoc
- diff -q README.md README.md.orig
language: generic
- env: task=json-lint
addons:
apt:
packages:
- jq
script:
- npm run jsonlint
language: generic
node_js: lts/carbon
21 changes: 7 additions & 14 deletions README.md
Expand Up @@ -9,6 +9,8 @@ CodiMD
CodiMD lets you collaborate in real-time with markdown.
Built on [HackMD](https://hackmd.io) source code, CodiMD lets you host and control your team's content with speed and ease.

![screenshot](https://raw.githubusercontent.com/hackmdio/codimd/develop/public/screenshot.png)

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
# Table of Contents
Expand Down Expand Up @@ -71,20 +73,11 @@ All contributions are welcome! Even asking a question helps.
## Browser Support

CodiMD is a service that runs on Node.js, while users use the service through browsers. We support your users using the following browsers:
- ![Chrome](http://browserbadge.com/chrome/47/18px)
- Chrome >= 47
- Chrome for Android >= 47
- ![Safari](http://browserbadge.com/safari/9/18px)
- Safari >= 9
- iOS Safari >= 8.4
- ![Firefox](http://browserbadge.com/firefox/44/18px)
- Firefox >= 44
- ![IE](http://browserbadge.com/ie/9/18px)
- IE >= 9
- Edge >= 12
- ![Opera](http://browserbadge.com/opera/34/18px)
- Opera >= 34
- Opera Mini not supported
- <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
- <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
- <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" /> Firefox >= 44
- <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
- <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
- Android Browser >= 4.4

To stay up to date with your installation it's recommended to subscribe the [release feed][github-release-feed].
Expand Down
56 changes: 30 additions & 26 deletions app.js
Expand Up @@ -7,7 +7,6 @@ var ejs = require('ejs')
var passport = require('passport')
var methodOverride = require('method-override')
var cookieParser = require('cookie-parser')
var compression = require('compression')
var session = require('express-session')
var SequelizeStore = require('connect-session-sequelize')(session.Store)
var fs = require('fs')
Expand All @@ -26,34 +25,37 @@ var response = require('./lib/response')
var models = require('./lib/models')
var csp = require('./lib/csp')

// server setup
var app = express()
var server = null
if (config.useSSL) {
var ca = (function () {
var i, len, results
results = []
for (i = 0, len = config.sslCAPath.length; i < len; i++) {
results.push(fs.readFileSync(config.sslCAPath[i], 'utf8'))
function createHttpServer () {
if (config.useSSL) {
const ca = (function () {
let i, len
const results = []
for (i = 0, len = config.sslCAPath.length; i < len; i++) {
results.push(fs.readFileSync(config.sslCAPath[i], 'utf8'))
}
return results
})()
const options = {
key: fs.readFileSync(config.sslKeyPath, 'utf8'),
cert: fs.readFileSync(config.sslCertPath, 'utf8'),
ca: ca,
dhparam: fs.readFileSync(config.dhParamPath, 'utf8'),
requestCert: false,
rejectUnauthorized: false
}
return results
})()
var options = {
key: fs.readFileSync(config.sslKeyPath, 'utf8'),
cert: fs.readFileSync(config.sslCertPath, 'utf8'),
ca: ca,
dhparam: fs.readFileSync(config.dhParamPath, 'utf8'),
requestCert: false,
rejectUnauthorized: false
return require('https').createServer(options, app)
} else {
return require('http').createServer(app)
}
server = require('https').createServer(options, app)
} else {
server = require('http').createServer(app)
}

// server setup
var app = express()
var server = createHttpServer()

// logger
app.use(morgan('combined', {
'stream': logger.stream
stream: logger.stream
}))

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

// compression
app.use(compression())

// use hsts to tell https users stick to this
if (config.hsts.enable) {
app.use(helmet.hsts({
Expand Down Expand Up @@ -181,6 +180,7 @@ app.locals.serverURL = config.serverURL
app.locals.sourceURL = config.sourceURL
app.locals.allowAnonymous = config.allowAnonymous
app.locals.allowAnonymousEdits = config.allowAnonymousEdits
app.locals.permission = config.permission
app.locals.allowPDFExport = config.allowPDFExport
app.locals.authProviders = {
facebook: config.isFacebookEnable,
Expand Down Expand Up @@ -279,6 +279,7 @@ process.on('uncaughtException', function (err) {
function handleTermSignals () {
logger.info('CodiMD has been killed by signal, try to exit gracefully...')
realtime.maintenance = true
realtime.terminate()
// disconnect all socket.io clients
Object.keys(io.sockets.sockets).forEach(function (key) {
var socket = io.sockets.sockets[key]
Expand All @@ -299,6 +300,9 @@ function handleTermSignals () {
})
}
}, 100)
setTimeout(() => {
process.exit(1)
}, 5000)
}
process.on('SIGINT', handleTermSignals)
process.on('SIGTERM', handleTermSignals)
Expand Down
8 changes: 0 additions & 8 deletions app.json
Expand Up @@ -11,18 +11,10 @@
"logo": "https://github.com/hackmdio/codimd/raw/master/public/codimd-icon-1024.png",
"success_url": "/",
"env": {
"BUILD_ASSETS": {
"description": "Our build script variable",
"value": "true"
},
"NPM_CONFIG_PRODUCTION": {
"description": "Let npm also install development build tool",
"value": "false"
},
"DB_TYPE": {
"description": "Specify database type. See sequelize available databases. Default using postgres",
"value": "postgres"
},
"HMD_SESSION_SECRET": {
"description": "Secret used to secure session cookies.",
"required": false
Expand Down
7 changes: 2 additions & 5 deletions bin/heroku
Expand Up @@ -2,7 +2,7 @@

set -e

if [ "$BUILD_ASSETS" = true ]; then
if [ ! -z "$DYNO" ]; then
# setup config files
cat << EOF > .sequelizerc
var path = require('path');
Expand All @@ -11,8 +11,7 @@ module.exports = {
'config': path.resolve('config.json'),
'migrations-path': path.resolve('lib', 'migrations'),
'models-path': path.resolve('lib', 'models'),
'url': process.env.DATABASE_URL,
'dialect': process.env.DB_TYPE
'url': process.env.DATABASE_URL
}
EOF
Expand All @@ -26,6 +25,4 @@ EOF
EOF

# build app
npm run build
fi
13 changes: 10 additions & 3 deletions config.json.example
Expand Up @@ -3,7 +3,8 @@
"db": {
"dialect": "sqlite",
"storage": ":memory:"
}
},
"linkifyHeaderStyle": "gfm"
},
"development": {
"loglevel": "debug",
Expand All @@ -13,7 +14,8 @@
"db": {
"dialect": "sqlite",
"storage": "./db.codimd.sqlite"
}
},
"linkifyHeaderStyle": "gfm"
},
"production": {
"domain": "localhost",
Expand Down Expand Up @@ -123,6 +125,11 @@
{
"connectionString": "change this",
"container": "change this"
}
},
"plantuml":
{
"server": "https://www.plantuml.com/plantuml"
},
"linkifyHeaderStyle": "gfm"
}
}
23 changes: 23 additions & 0 deletions deployments/Dockerfile
@@ -0,0 +1,23 @@
FROM hackmdio/buildpack:1.0.4 as BUILD

COPY --chown=hackmd:hackmd . .

RUN set -xe && \
git reset --hard && \
git clean -fx && \
yarn install && \
yarn build && \
yarn install --production=true && \
cp ./deployments/docker-entrypoint.sh ./ && \
cp .sequelizerc.example .sequelizerc && \
rm -rf .git .gitignore .travis.yml .dockerignore .editorconfig .babelrc .mailmap .sequelizerc.example \
test docs contribute \
yarn.lock webpack.prod.js webpack.htmlexport.js webpack.dev.js webpack.common.js \
config.json.example README.md CONTRIBUTING.md AUTHORS

FROM hackmdio/runtime:1.0.4
USER hackmd
WORKDIR /home/hackmd/app
COPY --chown=1500:1500 --from=BUILD /home/hackmd/app .
EXPOSE 3000
ENTRYPOINT ["/home/hackmd/app/docker-entrypoint.sh"]
5 changes: 5 additions & 0 deletions deployments/build.sh
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

CURRENT_DIR=$(dirname "$BASH_SOURCE")

docker build -t hackmdio/codimd -f "$CURRENT_DIR/Dockerfile" "$CURRENT_DIR/.."

0 comments on commit a0cc195

Please sign in to comment.