Skip to content

Commit 4742064

Browse files
committed
open source release
0 parents  commit 4742064

File tree

958 files changed

+255038
-0
lines changed

Some content is hidden

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

958 files changed

+255038
-0
lines changed

.circleci/config.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: 2
2+
3+
jobs:
4+
test:
5+
docker:
6+
- image: pcstl/generic-node-8.9-ruby-2.3:0.1.3
7+
environment:
8+
RAILS_ENV: test
9+
PGHOST: 127.0.0.1
10+
PGUSER: root
11+
- image: circleci/postgres:10-alpine-ram
12+
environment:
13+
POSTGRES_USER: root
14+
POSTGRES_DB: circle-test_test
15+
parallelism: 1
16+
steps:
17+
- checkout
18+
- restore_cache:
19+
keys:
20+
- pagedraw-yarn-{{ checksum "yarn.lock" }}
21+
- run:
22+
name: Installing npm dependencies
23+
command: yarn install
24+
- run:
25+
name: Running devserver
26+
command: yarn run devserver
27+
background: true
28+
- run: yarn js-tests
29+
- run: yarn html-email-tests
30+
- run: yarn layout-vs-preview-test
31+
- run: yarn compile-vs-preview-test
32+
- run: yarn compile-vs-preview-angular
33+
- run: yarn docs-compile-test
34+
- run: yarn sketch-test
35+
- run: THROTTLE=1 yarn editor-loads-safely-test
36+
- run: node react-scripts/build.js
37+
- save_cache:
38+
key: pagedraw-yarn-{{ checksum "yarn.lock" }}
39+
paths:
40+
- ~/.cache/yarn
41+
42+
43+
workflows:
44+
version: 2
45+
run-tests:
46+
jobs:
47+
- test

.circleci/images/Dockerfile

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
FROM buildpack-deps:jessie
2+
3+
4+
## CircleCI dependencies
5+
RUN apt-get update; \
6+
apt-get install -y --no-install-recommends \
7+
git \
8+
ssh \
9+
tar \
10+
gzip \
11+
ca-certificates \
12+
zip unzip
13+
14+
RUN groupadd --gid 1000 node \
15+
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
16+
17+
18+
## NODE
19+
# gpg keys listed at https://github.com/nodejs/node#release-team
20+
RUN set -ex \
21+
&& for key in \
22+
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
23+
FD3A5288F042B6850C66B31F09FE44734EB7990E \
24+
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 \
25+
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
26+
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
27+
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
28+
56730D5401028683275BD23C23EFEFE93C4CFFFE \
29+
77984A986EBC2AA786BC0F66B01FBB92821C587A \
30+
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
31+
; do \
32+
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
33+
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
34+
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
35+
done
36+
37+
ENV NODE_VERSION 8.9.0
38+
39+
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
40+
&& case "${dpkgArch##*-}" in \
41+
amd64) ARCH='x64';; \
42+
ppc64el) ARCH='ppc64le';; \
43+
s390x) ARCH='s390x';; \
44+
arm64) ARCH='arm64';; \
45+
armhf) ARCH='armv7l';; \
46+
i386) ARCH='x86';; \
47+
*) echo "unsupported architecture"; exit 1 ;; \
48+
esac \
49+
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
50+
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
51+
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
52+
&& grep " node-v$NODE_VERSION-linux-$ARCH.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
53+
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
54+
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt \
55+
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs
56+
57+
58+
## YARN
59+
ENV YARN_VERSION 1.9.2
60+
61+
RUN set -ex \
62+
&& for key in \
63+
6A010C5166006599AA17F08146C2130DFD2497F5 \
64+
; do \
65+
gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \
66+
gpg --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \
67+
gpg --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \
68+
done \
69+
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
70+
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
71+
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
72+
&& mkdir -p /opt \
73+
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
74+
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
75+
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
76+
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz
77+
78+
79+
## PUPPETEER DEPENDENCIES
80+
# See https://crbug.com/795759
81+
RUN apt-get update && apt-get install -yq libgconf-2-4
82+
83+
# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
84+
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
85+
# installs, work.
86+
RUN apt-get update && apt-get install -y wget --no-install-recommends \
87+
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
88+
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
89+
&& apt-get update \
90+
&& apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont \
91+
--no-install-recommends \
92+
&& rm -rf /var/lib/apt/lists/* \
93+
&& apt-get purge --auto-remove -y curl \
94+
&& rm -rf /src/*.deb
95+
96+
97+
## RUBY
98+
# skip installing gem documentation
99+
RUN mkdir -p /usr/local/etc \
100+
&& { \
101+
echo 'install: --no-document'; \
102+
echo 'update: --no-document'; \
103+
} >> /usr/local/etc/gemrc
104+
105+
ENV RUBY_MAJOR 2.3
106+
ENV RUBY_VERSION 2.3.4
107+
ENV RUBY_DOWNLOAD_SHA256 341cd9032e9fd17c452ed8562a8d43f7e45bfe05e411d0d7d627751dd82c578c
108+
ENV RUBYGEMS_VERSION 2.6.3
109+
ENV BUNDLER_VERSION 1.16.3
110+
111+
# some of ruby's build scripts are written in ruby
112+
# we purge system ruby later to make sure our final image uses what we just built
113+
RUN set -ex \
114+
\
115+
&& buildDeps=' \
116+
bison \
117+
dpkg-dev \
118+
libgdbm-dev \
119+
ruby \
120+
' \
121+
&& apt-get update \
122+
&& apt-get install -y --no-install-recommends $buildDeps \
123+
&& rm -rf /var/lib/apt/lists/* \
124+
\
125+
&& wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz" \
126+
&& echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum -c - \
127+
\
128+
&& mkdir -p /usr/src/ruby \
129+
&& tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1 \
130+
&& rm ruby.tar.xz \
131+
\
132+
&& cd /usr/src/ruby \
133+
\
134+
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
135+
# warning: Insecure world writable dir
136+
&& { \
137+
echo '#define ENABLE_PATH_CHECK 0'; \
138+
echo; \
139+
cat file.c; \
140+
} > file.c.new \
141+
&& mv file.c.new file.c \
142+
\
143+
&& autoconf \
144+
&& gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
145+
&& ./configure \
146+
--build="$gnuArch" \
147+
--disable-install-doc \
148+
--enable-shared \
149+
&& make -j "$(nproc)" \
150+
&& make install \
151+
\
152+
&& apt-get purge -y --auto-remove $buildDeps \
153+
&& cd / \
154+
&& rm -r /usr/src/ruby \
155+
\
156+
&& gem update --system "$RUBYGEMS_VERSION" \
157+
&& gem install bundler --version "$BUNDLER_VERSION" --force \
158+
&& rm -r /root/.gem/
159+
160+
# install things globally, for great justice
161+
# and don't create ".bundle" in all our apps
162+
ENV GEM_HOME /usr/local/bundle
163+
ENV BUNDLE_PATH="$GEM_HOME" \
164+
BUNDLE_SILENCE_ROOT_WARNING=1 \
165+
BUNDLE_APP_CONFIG="$GEM_HOME"
166+
# path recommendation: https://github.com/bundler/bundler/pull/6469#issuecomment-383235438
167+
ENV PATH $GEM_HOME/bin:$BUNDLE_PATH/gems/bin:$PATH
168+
# adjust permissions of a few directories for running "gem install" as an arbitrary user
169+
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"
170+
# (BUNDLE_PATH = GEM_HOME, no need to mkdir/chown both)

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git

.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
build/
2+
dist/
3+
node_modules/
4+
*.sublime-workspace
5+
localdev/
6+
*.log
7+
*.pyc
8+
*.swp
9+
*.swo
10+
*.swm
11+
*.swn
12+
depgraph.png
13+
.idea/
14+
cli/.env
15+
.vscode/
16+
artifacts/
17+
sample-app/
18+
uploads/
19+
offline-docserver-data/
20+
compiler-blobs/*
21+
22+
# static/ and firebase/ are copied directly into static hosting, so we don't want
23+
# anything in there that we could forget is in there
24+
!static/**
25+
!firebase/**
26+
27+
# okay but .DS_Store should *always* be ignored
28+
.DS_Store
29+

.slugignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
desktop-app/
2+
test/
3+
test-data/
4+
html-importer/
5+
sketch-importer/
6+
whitedboard-importer/

.webpack.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
REACT_APP_ENV=browser

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Pagedraw
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: yarn compileserver

README.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Pagedraw
2+
========
3+
4+
## Developing
5+
6+
### Setting up the development environment
7+
8+
As a prerequisite, install
9+
1. Node.js version 8.9.0. (`nvm` is useful here)
10+
2. `yarn`
11+
12+
```bash
13+
# clone the repo and install the project dependencies
14+
git clone https://github.com/Pagedraw/pagedraw
15+
cd pagedraw
16+
yarn install
17+
cd desktop-app/ && npm install && cd ..
18+
```
19+
20+
### Running Pagedraw in development
21+
22+
In the background, run
23+
```bash
24+
yarn devserver
25+
```
26+
27+
then start Electron with
28+
```bash
29+
cd desktop-app/
30+
npm start
31+
```
32+
33+
34+
### Config for development
35+
36+
The first time you run in development, in the Electron developer tools console, run `__openConfigEditor()` and set your local config to:
37+
```json
38+
{
39+
"handleRawDocJson": true,
40+
"crashButton": true,
41+
"asserts": true
42+
}
43+
```
44+
45+
To get some debugging tools. In particular, make sure to turn asserts on.
46+
47+
### Running tests
48+
49+
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
50+
51+
```bash
52+
yarn test
53+
```
54+
55+
## TODOs
56+
57+
- 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
58+
as `img` tags with base 64 data `src`s. That bloats the Pagedraw docs and forces an unnecessary constraint on generated code.
59+
We should move to a world where that system is more flexible and generates code that `require`s images instead
60+
- 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
61+
- Make Sketch Importer into a Sketch to Pagedraw converter command instead of a server.
62+
- 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`.

bin/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Pagedraw scripts
2+
========
3+
4+
All scripts assume that the current working directory is Pagedraw's root directory. For this reason, scripts cannot be
5+
run directly from the shell via something like `./script.sh`. Use `yarn run` instead.
6+
7+
For example, if you'd like to run the `deploy.sh` script, execute
8+
```
9+
yarn deploy
10+
```
11+
from the root directory.

bin/btoa.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import base64
2+
import sys
3+
import subprocess
4+
5+
# useful for translating a doc downloaded from firebase into base64 so you can paste it into tests
6+
7+
def write_to_clipboard(output):
8+
process = subprocess.Popen(
9+
'pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
10+
process.communicate(output.encode('utf-8'))
11+
12+
filename = sys.argv[-1]
13+
file_str = open(filename, 'r').read()
14+
15+
write_to_clipboard(base64.b64encode(file_str))
16+
17+
print 'Base 64 encoding copied to your clipboard!'

bin/build-electron-app.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash -e
2+
set -o pipefail
3+
4+
# clear out the /dist dir
5+
rm -rf desktop-app/dist desktop-app/build
6+
7+
# build fresh bundle
8+
node react-scripts/build.js
9+
10+
# move it into the electron app directory
11+
cp -r dist/ desktop-app/build
12+
13+
cd desktop-app && npm run build

0 commit comments

Comments
 (0)