Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

[WIP] Server removal #5374

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 0 additions & 13 deletions Dockerfile

This file was deleted.

179 changes: 17 additions & 162 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
PATH := ./node_modules/.bin:./bin/:$(PATH)
SHELL := /bin/bash
BABEL := babel --retain-lines
RSYNC := rsync --archive
VENV := .venv
.DEFAULT_GOAL := help
# Sets $(SCREENSHOTS_BACKEND) to http://localhost:10080 only if it isn't set
SCREENSHOTS_BACKEND ?= http://localhost:10080

# Here we have source/dest variables for many files and their destinations;
# we use these each to enumerate categories of source files, and translate
# them into the destination locations. These destination locations are the
# requirements for the other rules

shared_source := $(wildcard shared/*.js)
shared_server_dest := $(shared_source:%.js=build/%.js)

# static/js only gets copied to the server
static_js_source := $(wildcard static/js/*.js)
static_js_dest := $(static_js_source:%.js=build/server/%.js)

server_source := $(shell find server/src -name '*.js')
server_dest := $(server_source:server/src/%.js=build/server/%.js)

# Also scss gets put into two locations:
sass_source := $(wildcard static/css/*.scss)
sass_server_dest := $(sass_source:%.scss=build/server/%.css) $(sass_source:%.scss=build/server/%.ltr.css) $(sass_source:%.scss=build/server/%.rtl.css)
partials_source := $(wildcard static/css/partials/*.scss)

# And static images get placed somewhat eclectically:
imgs_source := $(wildcard static/img/*)
imgs_server_dest := $(imgs_source:%=build/server/%)

raven_source := $(shell node -e 'console.log(require.resolve("raven-js/dist/raven.js"))')

l10n_source := $(wildcard locales/*)
Expand All @@ -39,62 +23,14 @@ l10n_dest := $(l10n_source:%/webextension.properties=webextension/_locales/%/mes
## General transforms:
# These cover standard ways of building files given a source

# Need to put these two rules before the later general rule, so that we don't
# run babel on vendor libraries or the homepage libraries:
build/server/static/homepage/%.js: static/homepage/%.js
@mkdir -p $(@D)
cp $< $@

build/server/static/js/%.js: build/static/js/%.js
@mkdir -p $(@D)
cp $< $@

build/%.js: %.js
@mkdir -p $(@D)
$(BABEL) $< > $@

build/server/%.js: server/src/%.js
@mkdir -p $(@D)
$(BABEL) $< > $@

build/%.css: %.scss $(partials_source)
@mkdir -p $(@D)
node-sass $< $@

%.ltr.css: %.css
postcss $< -o $@ --config .postcss/ltr

%.rtl.css: %.css
postcss $< -o $@ --config .postcss/rtl

## Static files to be copied:

build/%.png: %.png
@mkdir -p $(@D)
cp $< $@

build/%.css: %.css
@mkdir -p $(@D)
cp $< $@

build/%.svg: %.svg
@mkdir -p $(@D)
./node_modules/.bin/svgo -q -i $< -o $@

build/%.sql: %.sql
@mkdir -p $(@D)
cp $< $@

build/%.ttf: %.ttf
@mkdir -p $(@D)
cp $< $@

build/%.html: %.html
@mkdir -p $(@D)
cp $< $@

.PHONY: addon
addon: npm set_backend set_sentry webextension/manifest.json addon_locales webextension/build/selection.js webextension/build/shot.js webextension/build/thumbnailGenerator.js webextension/build/inlineSelectionCss.js webextension/build/raven.js webextension/build/onboardingCss.js webextension/build/onboardingHtml.js webextension/build/buildSettings.js
addon: npm set_sentry webextension/manifest.json addon_locales webextension/build/inlineSelectionCss.js webextension/build/raven.js webextension/build/onboardingCss.js webextension/build/onboardingHtml.js webextension/build/buildSettings.js

$(VENV): requirements.txt
virtualenv -p python2.7 $(VENV)
Expand Down Expand Up @@ -130,26 +66,18 @@ signed_xpi: addon
addon_locales:
./node_modules/.bin/pontoon-to-webext --dest webextension/_locales > /dev/null

webextension/manifest.json: webextension/manifest.json.template build/.backend.txt package.json
./bin/build-scripts/update_manifest.py $< $@

webextension/build/selection.js: shared/selection.js
@mkdir -p $(@D)
./bin/build-scripts/modularize selection $< > $@

webextension/build/shot.js: shared/shot.js
build/static/%.css: static/%.scss $(partials_source)
@mkdir -p $(@D)
./bin/build-scripts/modularize shot $< > $@
node-sass $< $@

webextension/build/thumbnailGenerator.js: shared/thumbnailGenerator.js
@mkdir -p $(@D)
./bin/build-scripts/modularize thumbnailGenerator $< > $@
webextension/manifest.json: webextension/manifest.json.template package.json
./bin/build-scripts/update_manifest.py $< $@

webextension/build/inlineSelectionCss.js: build/server/static/css/inline-selection.css
webextension/build/inlineSelectionCss.js: build/static/css/inline-selection.css
@mkdir -p $(@D)
./bin/build-scripts/css_to_js.py inlineSelectionCss $< > $@

webextension/build/onboardingCss.js: build/server/static/css/onboarding.css
webextension/build/onboardingCss.js: build/static/css/onboarding.css
@mkdir -p $(@D)
./bin/build-scripts/css_to_js.py onboardingCss $< > $@

Expand All @@ -161,106 +89,35 @@ webextension/build/raven.js: $(raven_source)
@mkdir -p $(@D)
cp $< $@

## Server related rules:

# Copy shared files in from static/:
build/server/static/css/%.css: build/static/css/%.css
@mkdir -p $(@D)
cp $< $@

build/server/static/img/%: build/static/img/%
@mkdir -p $(@D)
cp $< $@

build/server/package.json: package.json
@mkdir -p $(@D)
cp $< $@

shot_dependencies := $(shell ./bin/build-scripts/bundle_dependencies shot getdeps "$(server_dest)")
build/server/static/js/shot-bundle.js: $(shot_dependencies)
./bin/build-scripts/bundle_dependencies shot build ./build/server/pages/shot/controller.js

homepage_dependencies := $(shell ./bin/build-scripts/bundle_dependencies homepage getdeps "$(server_dest)")
build/server/static/js/homepage-bundle.js: $(homepage_dependencies)
./bin/build-scripts/bundle_dependencies homepage build ./build/server/pages/homepage/controller.js

shotindex_dependencies := $(shell ./bin/build-scripts/bundle_dependencies shotindex getdeps "$(server_dest)")
build/server/static/js/shotindex-bundle.js: $(shotindex_dependencies)
./bin/build-scripts/bundle_dependencies shotindex build ./build/server/pages/shotindex/controller.js

leave_dependencies := $(shell ./bin/build-scripts/bundle_dependencies leave getdeps "$(server_dest)")
build/server/static/js/leave-bundle.js: $(leave_dependencies)
./bin/build-scripts/bundle_dependencies leave build ./build/server/pages/leave-screenshots/controller.js

creating_dependencies := $(shell ./bin/build-scripts/bundle_dependencies creating getdeps "$(server_dest)")
build/server/static/js/creating-bundle.js: $(creating_dependencies)
./bin/build-scripts/bundle_dependencies creating build ./build/server/pages/creating/controller.js

settings_dependencies := $(shell ./bin/build-scripts/bundle_dependencies settings getdeps "$(server_dest)")
build/server/static/js/settings-bundle.js: $(settings_dependencies)
./bin/build-scripts/bundle_dependencies settings build ./build/server/pages/settings/controller.js


# The intention here is to only write build-time when something else needs
# to be regenerated, but for some reason this gets rewritten every time
# anyway:
build/server/build-time.js: homepage $(server_dest) $(shared_server_dest) $(sass_server_dest) $(imgs_server_dest) $(static_js_dest) $(patsubst server/db-patches/%,build/server/db-patches/%,$(wildcard server/db-patches/*))
@mkdir -p $(@D)
./bin/build-scripts/write_build_time.py > build/server/build-time.js

# Convert all the server.ftl files into build/server/static/locales/[locale].js
build/server/static/locales: $(wildcard locales/**/server.ftl)
@mkdir -p $@
./bin/build-scripts/ftl-to-js.js $@ $^

.PHONY: server
server: npm build/server/build-time.js build/server/package.json build/server/static/js/shot-bundle.js build/server/static/js/homepage-bundle.js build/server/static/js/shotindex-bundle.js build/server/static/js/leave-bundle.js build/server/static/js/creating-bundle.js build/server/static/js/settings-bundle.js build/server/static/locales

## Homepage related rules:

build/server/static/homepage/%: static/homepage/%
@mkdir -p $(@D)
cp $< $@

.PHONY: homepage
homepage: $(patsubst static/homepage/%,build/server/static/homepage/%,$(shell find static/homepage -type f ! -name index.html))

## npm rule

.PHONY: npm
npm: build/.npm-install.log

build/.backend.txt: set_backend

.PHONY: set_backend
set_backend:
@echo "Setting backend to ${SCREENSHOTS_BACKEND}"
./bin/build-scripts/set_file build/.backend.txt $(SCREENSHOTS_BACKEND)
npm: .npm-install.log

webextension/build/buildSettings.js: set_build_settings

.PHONY: set_build_settings
.PHONY: set_sentry
set_sentry:
@if [[ -z "$(SCREENSHOTS_SENTRY)" ]] ; then echo "No default Sentry" ; fi
@if [[ -n "$(SCREENSHOTS_SENTRY)" ]] ; then echo "Setting default Sentry ${SCREENSHOTS_SENTRY}" ; fi
./bin/build-scripts/substitute-env.js webextension/buildSettings.js.template | ./bin/build-scripts/set_file webextension/build/buildSettings.js -

build/.npm-install.log: package.json package-lock.json
.npm-install.log: package.json package-lock.json
# Essentially .npm-install.log is just a timestamp showing the last time we ran
# the command
@mkdir -p $(@D)
echo "Installing at $(shell date)" > build/.npm-install.log
npm install >> build/.npm-install.log
echo "Installing at $(shell date)" > .npm-install.log
npm install >> .npm-install.log

# This causes intermediate files to be kept (e.g., files in static/ which are copied to the addon and server but aren't used/required directly):
.SECONDARY:

.PHONY: all
all: addon server
all: addon

.PHONY: clean
clean:
rm -rf build/ webextension/build/ webextension/manifest.json webextension/_locales/
rm -rf webextension/build/ webextension/manifest.json webextension/_locales/

.PHONY: distclean
distclean: clean
Expand All @@ -269,16 +126,14 @@ distclean: clean

.PHONY: help
help:
@echo "Makes the addon and server"
@echo "Makes the addon"
@echo "Commands:"
@echo " make addon"
@echo " make/update the addon directly in webextension/ (built files in webextension/build/)"
@echo " make server"
@echo " make the server in build/server/"
@echo " make all"
@echo " equivalent to make server addon"
@echo " equivalent to make addon"
@echo " make clean"
@echo " rm -rf build/ webextension/build"
@echo " rm -rf webextension/build build"
@echo " make zip"
@echo " make an unsigned zip of the webextension in build/screenshots.zip"
@echo " make unsigned_xpi"
Expand Down
8 changes: 0 additions & 8 deletions bin/_run-docker

This file was deleted.

33 changes: 0 additions & 33 deletions bin/build-docker-image

This file was deleted.

71 changes: 0 additions & 71 deletions bin/build-scripts/bundle_dependencies

This file was deleted.

Loading