Skip to content

Commit

Permalink
Merge pull request #76 from stencila/rename-encoda
Browse files Browse the repository at this point in the history
Rename to Encoda
  • Loading branch information
nokome authored May 30, 2019
2 parents 6719817 + 09ef456 commit 8d3bc94
Show file tree
Hide file tree
Showing 44 changed files with 1,117 additions and 1,118 deletions.
2 changes: 1 addition & 1 deletion .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"projectName": "convert",
"projectName": "encoda",
"projectOwner": "stencila",
"repoType": "github",
"repoHost": "https://github.com",
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*token.json
/.sandbox
/bin
/convert-deps.tgz
/encoda-deps.tgz
/coverage
/dist
/docs/api
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Build from local source
# docker build --tag stencila/convert .
# docker build --tag stencila/encoda .
# Run tests
# docker run stencila/convert
# docker run stencila/encoda
# Or to test out interactively at the terminal
# docker run -it stencila/convert bash
# docker run -it stencila/encoda bash

FROM node

RUN mkdir -p /opt/stecila-convert
WORKDIR /opt/stecila-convert
RUN mkdir -p /opt/encoda
WORKDIR /opt/encoda

# Separate copy and Docker layer for `package.json` to prevent
# unecessary reinstall of `node_modules` when `src` changes
Expand All @@ -20,7 +20,7 @@ COPY . .

# Run as guest user
RUN useradd --create-home --home-dir /home/guest guest
RUN chown -R guest /opt/stecila-convert
RUN chown -R guest /opt/encoda
USER guest

CMD npm test
94 changes: 47 additions & 47 deletions README.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions bundle-win.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
osslsigncode sign \
-pkcs12 "win-cert.p12" \
-pass "$WIN_CERT_PASSWORD" \
-n "Convert" \
-n "Encoda" \
-i "https://stenci.la" \
-t "http://timestamp.comodoca.com/authenticode" \
-in "bin/stencila-convert.exe" \
-out "bin/stencila-convert.exe"
-in "bin/encoda.exe" \
-out "bin/encoda.exe"

zip -j bin/convert-win-x64.zip bin/stencila-convert.exe
zip -j bin/encoda-win-x64.zip bin/encoda.exe
28 changes: 14 additions & 14 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [[ "$OS" == "Linux" || "$OS" == "Darwin" ]]; then
'Linux')
PLATFORM="linux-x64"
if [ -z "$1" ]; then
VERSION=$(curl --silent "https://api.github.com/repos/stencila/convert/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
VERSION=$(curl --silent "https://api.github.com/repos/stencila/encoda/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
else
VERSION=$1
fi
Expand All @@ -17,27 +17,27 @@ if [[ "$OS" == "Linux" || "$OS" == "Darwin" ]]; then
'Darwin')
PLATFORM="macos-x64"
if [ -z "$1" ]; then
VERSION=$(curl --silent "https://api.github.com/repos/stencila/convert/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
VERSION=$(curl --silent "https://api.github.com/repos/stencila/encoda/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
else
VERSION=$1
fi
INSTALL_PATH="/usr/local/bin"
;;
esac

echo "Downloading stencila-convert $VERSION"
curl -Lo /tmp/convert.tar.gz https://github.com/stencila/convert/releases/download/$VERSION/convert-$PLATFORM.tar.gz
tar xvf /tmp/convert.tar.gz
rm -f /tmp/convert.tar.gz
echo "Downloading encoda $VERSION"
curl -Lo /tmp/encoda.tar.gz https://github.com/stencila/encoda/releases/download/$VERSION/encoda-$PLATFORM.tar.gz
tar xvf /tmp/encoda.tar.gz
rm -f /tmp/encoda.tar.gz

echo "Installing stencila-convert to $INSTALL_PATH/stencila-convert-$VERSION"
mkdir -p $INSTALL_PATH/stencila-convert-$VERSION
mv -f stencila-convert $INSTALL_PATH/stencila-convert-$VERSION
# Unpack `node_modules` etc into the $INSTALL_PATH/convert-$VERSION
$INSTALL_PATH/stencila-convert-$VERSION/stencila-convert --version
echo "Installing encoda to $INSTALL_PATH/encoda-$VERSION"
mkdir -p $INSTALL_PATH/encoda-$VERSION
mv -f encoda $INSTALL_PATH/encoda-$VERSION
# Unpack `node_modules` etc into the $INSTALL_PATH/encoda-$VERSION
$INSTALL_PATH/encoda-$VERSION/encoda --version

echo "Pointing stencila-convert to $INSTALL_PATH/stencila-convert-$VERSION/stencila-convert"
ln -sf stencila-convert-$VERSION/stencila-convert $INSTALL_PATH/stencila-convert
echo "Pointing encoda to $INSTALL_PATH/encoda-$VERSION/encoda"
ln -sf encoda-$VERSION/encoda $INSTALL_PATH/encoda
else
echo "Sorry, I don't know how to install on this OS, please see https://github.com/stencila/convert#install"
echo "Sorry, I don't know how to install on this OS, please see https://github.com/stencila/encoda#install"
fi
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "stencila-convert",
"name": "@stencila/encoda",
"version": "0.37.0",
"description": "Convert between Stencila document trees and other formats",
"description": "Codecs for executable document formats",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
"convert": "./dist/cli.js"
"encoda": "./dist/cli.js"
},
"scripts": {
"install": "node install.js",
Expand All @@ -17,10 +17,10 @@
"check:deps-unused": "dependency-check --unused --no-dev .",
"build": "npm run build:dist && npm run build:tgz && npm run build:bin",
"build:dist": "tsc && cp src/*.js dist/",
"build:tgz": "tar czf convert-deps.tgz src vendor node_modules/puppeteer/.local-chromium",
"build:bin": "pkg --target=host -o=bin/stencila-convert .",
"bundle:linux": "tar -czvf bin/convert-linux-x64.tar.gz -C bin stencila-convert",
"bundle:osx": "tar -czvf bin/convert-macos-x64.tar.gz -C bin stencila-convert",
"build:tgz": "tar czf encoda-deps.tgz src vendor node_modules/puppeteer/.local-chromium",
"build:bin": "pkg --target=node10 -o=bin/encoda .",
"bundle:linux": "tar -czvf bin/encoda-linux-x64.tar.gz -C bin encoda",
"bundle:osx": "tar -czvf bin/encoda-macos-x64.tar.gz -C bin encoda",
"bundle:windows": "./bundle-win.sh",
"docs": "markdown-toc -i --maxdepth=4 README.md && typedoc --options typedoc.js ./src",
"docs:dev": "ts-node --files src/cli devserve docs",
Expand All @@ -32,19 +32,19 @@
"pkg": {
"scripts": "./dist/**/*.js",
"assets": [
"./convert-deps.tgz",
"./encoda-deps.tgz",
"./dist/**/*.json",
"./node_modules/@stencila/schema/dist/**/*.json"
]
},
"license": "Apache-2.0",
"homepage": "https://github.com/stencila/convert#readme",
"homepage": "https://github.com/stencila/encoda#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/stencila/convert.git"
"url": "git+https://github.com/stencila/encoda.git"
},
"bugs": {
"url": "https://github.com/stencila/convert/issues"
"url": "https://github.com/stencila/encoda/issues"
},
"dependencies": {
"@stencila/schema": "^0.12.0",
Expand Down
8 changes: 4 additions & 4 deletions src/boot.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* Module for installing Convert native modules and executables
* Module for installing Encoda native modules and executables
*
* The [`pkg`](https://github.com/zeit/pkg) Node.js packager does not
* package native modules. i.e `*.node` files. There are various ways to handle this but
* we found the easiest/safest was to simply copy the directories for the
* packages with native modules, from the host system, into directory where the
* binary is installed. This script does that via `convert-deps.tar.gz` which is
* binary is installed. This script does that via `encoda-deps.tar.gz` which is
* packaged in the binary snapshot as an `asset`.
*
* See:
* - https://github.com/stencila/convert/pull/47#issuecomment-489912132
* - https://github.com/stencila/encoda/pull/47#issuecomment-489912132
* - https://github.com/zeit/pkg/issues/329
* - https://github.com/JoshuaWise/better-sqlite3/issues/173
* - `package.json`
Expand Down Expand Up @@ -41,7 +41,7 @@ export const home = packaged
if (packaged && !fs.existsSync(path.join(home, 'node_modules'))) {
tar.x({
sync: true,
file: path.join('/', 'snapshot', 'convert', 'convert-deps.tgz'),
file: path.join('/', 'snapshot', 'encoda', 'encoda-deps.tgz'),
C: home
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { convert } from './index'
const VERSION = require('../package').version

yargs
.scriptName('stencila-convert')
.scriptName('encoda')

// @ts-ignore
.command(
Expand Down
10 changes: 5 additions & 5 deletions src/csv.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Compiler for comma separated values (CSV)
* Codec for comma separated values (CSV)
*/

import stencila from '@stencila/schema'
Expand All @@ -8,10 +8,10 @@ import * as xlsx from './xlsx'

export const mediaTypes = ['text/csv']

export async function parse(file: VFile): Promise<stencila.Node> {
return xlsx.parse(file)
export async function decode(file: VFile): Promise<stencila.Node> {
return xlsx.decode(file)
}

export async function unparse(node: stencila.Node): Promise<VFile> {
return xlsx.unparse(node, undefined, 'csv')
export async function encode(node: stencila.Node): Promise<VFile> {
return xlsx.encode(node, undefined, 'csv')
}
10 changes: 5 additions & 5 deletions src/docx.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Compiler for Microsoft Word
* Codec for Microsoft Word
*/

import stencila from '@stencila/schema'
Expand All @@ -12,8 +12,8 @@ export const mediaTypes = [
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
]

export async function parse(file: VFile): Promise<stencila.Node> {
return pandoc.parse(
export async function decode(file: VFile): Promise<stencila.Node> {
return pandoc.decode(
file,
pandoc.InputFormat.docx,
[`--extract-media=${file.path}.media`],
Expand All @@ -29,12 +29,12 @@ const defaultDocxTemplatePath = path.join(
'stencila-template.docx'
)

export async function unparse(
export async function encode(
node: stencila.Node,
filePath?: string,
templatePath: string = defaultDocxTemplatePath
): Promise<VFile> {
return pandoc.unparse(
return pandoc.encode(
node,
filePath,
pandoc.OutputFormat.docx,
Expand Down
Loading

0 comments on commit 8d3bc94

Please sign in to comment.