Skip to content
Permalink
Browse files

open source release

  • Loading branch information...
jaredp committed Jan 22, 2019
0 parents commit 47420645000d76fb15b851a681916dc41fc7d75c
Showing 958 changed files with 255,038 additions and 0 deletions.
@@ -0,0 +1,47 @@
version: 2

jobs:
test:
docker:
- image: pcstl/generic-node-8.9-ruby-2.3:0.1.3
environment:
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root
- image: circleci/postgres:10-alpine-ram
environment:
POSTGRES_USER: root
POSTGRES_DB: circle-test_test
parallelism: 1
steps:
- checkout
- restore_cache:
keys:
- pagedraw-yarn-{{ checksum "yarn.lock" }}
- run:
name: Installing npm dependencies
command: yarn install
- run:
name: Running devserver
command: yarn run devserver
background: true
- run: yarn js-tests
- run: yarn html-email-tests
- run: yarn layout-vs-preview-test
- run: yarn compile-vs-preview-test
- run: yarn compile-vs-preview-angular
- run: yarn docs-compile-test
- run: yarn sketch-test
- run: THROTTLE=1 yarn editor-loads-safely-test
- run: node react-scripts/build.js
- save_cache:
key: pagedraw-yarn-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn


workflows:
version: 2
run-tests:
jobs:
- test
@@ -0,0 +1,170 @@
FROM buildpack-deps:jessie


## CircleCI dependencies
RUN apt-get update; \
apt-get install -y --no-install-recommends \
git \
ssh \
tar \
gzip \
ca-certificates \
zip unzip

RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node


## NODE
# gpg keys listed at https://github.com/nodejs/node#release-team
RUN set -ex \
&& for key in \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
FD3A5288F042B6850C66B31F09FE44734EB7990E \
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
56730D5401028683275BD23C23EFEFE93C4CFFFE \
77984A986EBC2AA786BC0F66B01FBB92821C587A \
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
; do \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
done

ENV NODE_VERSION 8.9.0

RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
ppc64el) ARCH='ppc64le';; \
s390x) ARCH='s390x';; \
arm64) ARCH='arm64';; \
armhf) ARCH='armv7l';; \
i386) ARCH='x86';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs


## YARN
ENV YARN_VERSION 1.9.2

RUN set -ex \
&& for key in \
6A010C5166006599AA17F08146C2130DFD2497F5 \
; do \
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& mkdir -p /opt \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz


## PUPPETEER DEPENDENCIES
# See https://crbug.com/795759
RUN apt-get update && apt-get install -yq libgconf-2-4

# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update && apt-get install -y wget --no-install-recommends \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get purge --auto-remove -y curl \
&& rm -rf /src/*.deb


## RUBY
# skip installing gem documentation
RUN mkdir -p /usr/local/etc \
&& { \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc

ENV RUBY_MAJOR 2.3
ENV RUBY_VERSION 2.3.4
ENV RUBY_DOWNLOAD_SHA256 341cd9032e9fd17c452ed8562a8d43f7e45bfe05e411d0d7d627751dd82c578c
ENV RUBYGEMS_VERSION 2.6.3
ENV BUNDLER_VERSION 1.16.3

# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
RUN set -ex \
\
&& buildDeps=' \
bison \
dpkg-dev \
libgdbm-dev \
ruby \
' \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& rm -rf /var/lib/apt/lists/* \
\
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
\
&& mkdir -p /usr/src/ruby \
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
&& rm ruby.tar.xz \
\
&& cd /usr/src/ruby \
\
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
# warning: Insecure world writable dir
&& { \
echo '#define ENABLE_PATH_CHECK 0'; \
echo; \
cat file.c; \
} > file.c.new \
&& mv file.c.new file.c \
\
&& autoconf \
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
&& ./configure \
--build="$gnuArch" \
--disable-install-doc \
--enable-shared \
&& make -j "$(nproc)" \
&& make install \
\
&& apt-get purge -y --auto-remove $buildDeps \
&& cd / \
&& rm -r /usr/src/ruby \
\
&& gem update --system "$RUBYGEMS_VERSION" \
&& gem install bundler --version "$BUNDLER_VERSION" --force \
&& rm -r /root/.gem/

# install things globally, for great justice
# and don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_PATH="$GEM_HOME" \
BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
# path recommendation: https://github.com/bundler/bundler/pull/6469#issuecomment-383235438
ENV PATH $GEM_HOME/bin:$BUNDLE_PATH/gems/bin:$PATH
# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)
@@ -0,0 +1 @@
.git
@@ -0,0 +1,29 @@
build/
dist/
node_modules/
*.sublime-workspace
localdev/
*.log
*.pyc
*.swp
*.swo
*.swm
*.swn
depgraph.png
.idea/
cli/.env
.vscode/
artifacts/
sample-app/
uploads/
offline-docserver-data/
compiler-blobs/*

# static/ and firebase/ are copied directly into static hosting, so we don't want
# anything in there that we could forget is in there
!static/**
!firebase/**

# okay but .DS_Store should *always* be ignored
.DS_Store

@@ -0,0 +1,6 @@
desktop-app/
test/
test-data/
html-importer/
sketch-importer/
whitedboard-importer/
@@ -0,0 +1 @@
REACT_APP_ENV=browser
21 LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Pagedraw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1 @@
web: yarn compileserver
@@ -0,0 +1,62 @@
Pagedraw
========

## Developing

### Setting up the development environment

As a prerequisite, install
1. Node.js version 8.9.0. (`nvm` is useful here)
2. `yarn`

```bash
# clone the repo and install the project dependencies
git clone https://github.com/Pagedraw/pagedraw
cd pagedraw
yarn install
cd desktop-app/ && npm install && cd ..
```

### Running Pagedraw in development

In the background, run
```bash
yarn devserver
```

then start Electron with
```bash
cd desktop-app/
npm start
```


### Config for development

The first time you run in development, in the Electron developer tools console, run `__openConfigEditor()` and set your local config to:
```json
{
"handleRawDocJson": true,
"crashButton": true,
"asserts": true
}
```

To get some debugging tools. In particular, make sure to turn asserts on.

### Running tests

To run the standard tests, run all the servers needed for Pagedraw development, as described in the section above. While `yarn devserver` is running, run

```bash
yarn test
```

## TODOs

- Today all images brought into Pagedraw are stored as part of the Pagedraw doc as base64 encoded strings and they also get compiled to generated code
as `img` tags with base 64 data `src`s. That bloats the Pagedraw docs and forces an unnecessary constraint on generated code.
We should move to a world where that system is more flexible and generates code that `require`s images instead
- Same thing for fonts. Today they're being stored directly in the Pagedraw doc as base64 strings and also injected into the compiled code as such
- Make Sketch Importer into a Sketch to Pagedraw converter command instead of a server.
- Compile-Check can work with local `/compiler-blobs`, and not depend on S3 to host them. Look in `/compiler-blob-builder` and `/deploy-checks/fetch-other-compiler-build.js`.
@@ -0,0 +1,11 @@
Pagedraw scripts
========

All scripts assume that the current working directory is Pagedraw's root directory. For this reason, scripts cannot be
run directly from the shell via something like `./script.sh`. Use `yarn run` instead.

For example, if you'd like to run the `deploy.sh` script, execute
```
yarn deploy
```
from the root directory.
@@ -0,0 +1,17 @@
import base64
import sys
import subprocess

# useful for translating a doc downloaded from firebase into base64 so you can paste it into tests

def write_to_clipboard(output):
process = subprocess.Popen(
'pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
process.communicate(output.encode('utf-8'))

filename = sys.argv[-1]
file_str = open(filename, 'r').read()

write_to_clipboard(base64.b64encode(file_str))

print 'Base 64 encoding copied to your clipboard!'
@@ -0,0 +1,13 @@
#!/bin/bash -e
set -o pipefail

# clear out the /dist dir
rm -rf desktop-app/dist desktop-app/build

# build fresh bundle
node react-scripts/build.js

# move it into the electron app directory
cp -r dist/ desktop-app/build

cd desktop-app && npm run build

0 comments on commit 4742064

Please sign in to comment.
You can’t perform that action at this time.