mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-09 20:08:32 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9eb6ea6e2 |
19
.github/workflows/cd.yml
vendored
19
.github/workflows/cd.yml
vendored
@@ -1,19 +0,0 @@
|
|||||||
name: CD
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ develop ]
|
|
||||||
# pull_request:
|
|
||||||
# branches: [ develop ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Trigger CD build
|
|
||||||
uses: peter-evans/repository-dispatch@v1
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.CI_DISPATCH_TOKEN }}
|
|
||||||
repository: forensic-architecture/configs
|
|
||||||
event-type: remote-build
|
|
||||||
client-payload: '{"runtime_args": "datasheet", "branch": "${GITHUB_REF##*/}"}'
|
|
||||||
|
|
||||||
25
.github/workflows/ci.yml
vendored
25
.github/workflows/ci.yml
vendored
@@ -1,25 +0,0 @@
|
|||||||
name: CI
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ develop ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ develop ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
ref: ${{ github.head_ref }}
|
|
||||||
- uses: actions/setup-node@v2-beta
|
|
||||||
with:
|
|
||||||
node-version: '12'
|
|
||||||
|
|
||||||
- run: npm install
|
|
||||||
- run: npm test
|
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
- run: npm run lint
|
|
||||||
env:
|
|
||||||
CI: true
|
|
||||||
14
.travis.yml
Normal file
14
.travis.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
language: node_js
|
||||||
|
node_js:
|
||||||
|
- stable
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- node_modules
|
||||||
|
before_script:
|
||||||
|
- npm install -g yarn
|
||||||
|
install:
|
||||||
|
- yarn
|
||||||
|
script:
|
||||||
|
- yarn build
|
||||||
|
- yarn lint
|
||||||
|
- yarn test
|
||||||
10
Dockerfile
10
Dockerfile
@@ -4,17 +4,17 @@ LABEL authors="Lachlan Kermode <lk@forensic-architecture.org>"
|
|||||||
|
|
||||||
# Install app dependencies
|
# Install app dependencies
|
||||||
COPY package.json /www/package.json
|
COPY package.json /www/package.json
|
||||||
RUN cd /www; npm install
|
RUN cd /www; yarn
|
||||||
|
|
||||||
# Copy app source
|
# Copy app source
|
||||||
COPY . /www
|
COPY . /www
|
||||||
WORKDIR /www
|
WORKDIR /www
|
||||||
RUN npm run build
|
RUN yarn build
|
||||||
RUN mkdir -p data
|
RUN mkdir -p data
|
||||||
|
|
||||||
# set your port
|
# set your port
|
||||||
ENV PORT 4040
|
ENV PORT 8080
|
||||||
EXPOSE 4040
|
EXPOSE 8080
|
||||||
|
|
||||||
# start command as per package.json
|
# start command as per package.json
|
||||||
CMD ["npm", "start"]
|
CMD ["yarn", "start"]
|
||||||
|
|||||||
Binary file not shown.
9478
package-lock.json
generated
9478
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
scripts/check-branch.sh
Executable file
11
scripts/check-branch.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ENCRYPT_MESSAGE="\nThe .env.enc file has not changed its contents from the version on origin/develop.\nTo ensure that tests pass in Travis, you need to encrypt the contents of .env before pushing to the remote, so that the Travis server can use your service account credentials.\nEnsure that the Travis CLI is installed on your local, run\n\n\tnpm run travis-encrypt\n\nand then push to the remote again.\nIf you don't care whether your build passes on Travis, you can run:\n\n\tgit push --no-verify\n\nand bypass this check.\n\n"
|
||||||
|
|
||||||
|
# check whether .env.enc has changed
|
||||||
|
if [ -z "`git diff origin/develop -- .env.enc`" ]; then
|
||||||
|
echo $ENCRYPT_MESSAGE
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
38
scripts/encrypt.sh
Executable file
38
scripts/encrypt.sh
Executable file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "Encrypting .env file for Travis..."
|
||||||
|
|
||||||
|
# confirm that the user has the core repo as origin, and is therefore a maintainer
|
||||||
|
# if [ -z `git config --get remote.origin.url | grep "forensic-architecture/datasheet-server"` ]; then
|
||||||
|
# echo "Travis encryption not required for satellite contributors, continuing.."
|
||||||
|
# exit 0
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# confirm travis is installed
|
||||||
|
if [ ! hash travis 2>/dev/null ]; then
|
||||||
|
echo "============================================================================================"
|
||||||
|
echo "ERROR: Travis CLI is not installed on your local. Please install from:"
|
||||||
|
echo "\thttps://github.com/travis-ci/travis.rb"
|
||||||
|
echo "After installing, make sure that you login with:"
|
||||||
|
echo "\ttravis login --pro"
|
||||||
|
echo "============================================================================================"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# confirm there is a .env file to encrypt
|
||||||
|
if [ ! -f .env ]; then
|
||||||
|
echo "============================================================================================"
|
||||||
|
echo "ERROR: You must create a .env file and add your credentials. See .env.example for an example"
|
||||||
|
echo "============================================================================================"
|
||||||
|
exit 3
|
||||||
|
fi
|
||||||
|
|
||||||
|
# regex to match and delete 'before_install' and everything after it
|
||||||
|
# necessary to delete these lines to get Travis to build for multiple accounts
|
||||||
|
echo "creating new .travis.yml configuration"
|
||||||
|
sed -i.old '/^before_install.*/,$ d' .travis.yml
|
||||||
|
echo "old config file saved as .travis.yml.old"
|
||||||
|
|
||||||
|
travis encrypt-file .env --add --force --org
|
||||||
|
git add .env.enc
|
||||||
|
git add .travis.yml
|
||||||
|
echo ".env.enc created and added to commit"
|
||||||
@@ -30,10 +30,10 @@ export default ({ config, controller }) => {
|
|||||||
success: msg
|
success: msg
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.catch(err => {
|
.catch(err =>
|
||||||
res.status(404)
|
res.status(404)
|
||||||
.send({ error: err.message, err })
|
.send({ error: err.message, err })
|
||||||
})
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
api.get('/:sheet/:tab/:resource/:frag', (req, res) => {
|
api.get('/:sheet/:tab/:resource/:frag', (req, res) => {
|
||||||
|
|||||||
@@ -63,7 +63,10 @@ export default (data) => {
|
|||||||
structure.__flat.forEach(label => {
|
structure.__flat.forEach(label => {
|
||||||
deepRow[label] = baseRow[label]
|
deepRow[label] = baseRow[label]
|
||||||
})
|
})
|
||||||
if (!Object.keys(deepRow).every(k => deepRow[k] === '')) {
|
if (!Object.keys(deepRow).every(k => (
|
||||||
|
(deepRow[k] === '') ||
|
||||||
|
(Array.isArray(deepRow[k]) && deepRow[k].length === 0)
|
||||||
|
))) {
|
||||||
output.push(deepRow)
|
output.push(deepRow)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ function prefixedTabs (prefix, cfg) {
|
|||||||
[`${prf('events')}export_events`]: BP.deeprows,
|
[`${prf('events')}export_events`]: BP.deeprows,
|
||||||
[`${prf('associations')}export_associations`]: BP.deeprows,
|
[`${prf('associations')}export_associations`]: BP.deeprows,
|
||||||
[`${prf('sources')}export_sources`]: BP.deepids,
|
[`${prf('sources')}export_sources`]: BP.deepids,
|
||||||
[`${prf('shapes')}export_shapes`]: BP.deeprows,
|
|
||||||
[`${prf('sites')}export_sites`]: BP.rows
|
[`${prf('sites')}export_sites`]: BP.rows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import copy from '../copy/en'
|
import copy from '../copy/en'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class
|
* Controller
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Controller {
|
class Controller {
|
||||||
|
|||||||
@@ -217,10 +217,7 @@ class GsheetFetcher extends Fetcher {
|
|||||||
})
|
})
|
||||||
.then(this._buildBlueprintsAsync())
|
.then(this._buildBlueprintsAsync())
|
||||||
.then(() => true)
|
.then(() => true)
|
||||||
.catch((err) => {
|
.catch(() => false)
|
||||||
console.log(`Error fetching gsheets: ${err.message} `)
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class StoreJson {
|
|||||||
|
|
||||||
save (url, data) {
|
save (url, data) {
|
||||||
const parts = url.split('/')
|
const parts = url.split('/')
|
||||||
|
|
||||||
return fs.writeFile(
|
return fs.writeFile(
|
||||||
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
|
`${STORAGE_DIRNAME}/${parts[0]}__${parts[1]}__${parts[2]}.json`,
|
||||||
JSON.stringify(data)
|
JSON.stringify(data)
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ const egInput1 = [
|
|||||||
[4, 5, 6]
|
[4, 5, 6]
|
||||||
]
|
]
|
||||||
|
|
||||||
// Test default blueprint exports
|
|
||||||
// Smoke tests
|
|
||||||
test('defaultBlueprint exports', t => {
|
test('defaultBlueprint exports', t => {
|
||||||
const expected = {
|
const expected = {
|
||||||
sheet: {
|
sheet: {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ test('should launch', t => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const passUrls = [
|
const passUrls = [
|
||||||
'/api/'
|
'/api/',
|
||||||
]
|
]
|
||||||
|
|
||||||
const failUrls = [
|
const failUrls = [
|
||||||
|
|||||||
Reference in New Issue
Block a user