Skip to content

Commit

Permalink
Directly use the npm package, update ngeo
Browse files Browse the repository at this point in the history
Fixes for ngeo upgrade
  • Loading branch information
sbrunner committed Jul 27, 2018
1 parent d217d24 commit 6c44252
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 87 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
**/__pycache__/
*/.pytest_cache/
/npm-packages
/ngeo
/node_modules/
/package-lock.json
/Dockerfile
/commons/tests.yaml
/commons/c2cgeoportal_commons.egg-info/
Expand Down
18 changes: 9 additions & 9 deletions Dockerfile.mako
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ ENV VERSION=$VERSION
COPY npm-packages /opt/npm-packages

RUN \
npm install --no-optional --global `cat /opt/npm-packages` && \
npm cache clear
npm install --no-optional --global --unsafe-perm `cat /opt/npm-packages` && \
npm cache clear --force

RUN \
svg2ttf /usr/lib/node_modules/ngeo/contribs/gmf/fonts/gmf-icons.svg \
/usr/lib/node_modules/ngeo/contribs/gmf/fonts/gmf-icons.ttf && \
ttf2eot /usr/lib/node_modules/ngeo/contribs/gmf/fonts/gmf-icons.ttf \
/usr/lib/node_modules/ngeo/contribs/gmf/fonts/gmf-icons.eot && \
ttf2woff /usr/lib/node_modules/ngeo/contribs/gmf/fonts/gmf-icons.ttf \
/usr/lib/node_modules/ngeo/contribs/gmf/fonts/gmf-icons.woff
svg2ttf /usr/lib/node_modules/ngeo/contribs/gmf/src/fonts/gmf-icons.svg \
/usr/lib/node_modules/ngeo/contribs/gmf/src/fonts/gmf-icons.ttf && \
ttf2eot /usr/lib/node_modules/ngeo/contribs/gmf/src/fonts/gmf-icons.ttf \
/usr/lib/node_modules/ngeo/contribs/gmf/src/fonts/gmf-icons.eot && \
ttf2woff /usr/lib/node_modules/ngeo/contribs/gmf/src/fonts/gmf-icons.ttf \
/usr/lib/node_modules/ngeo/contribs/gmf/src/fonts/gmf-icons.woff

RUN \
mkdir --parents /opt/angular-locale && \
Expand All @@ -31,7 +31,7 @@ COPY admin /opt/c2cgeoportal_admin

RUN \
(cd /opt/c2cgeoportal_admin/; npm install --no-optional `cat npm-packages`) && \
npm cache clear && \
npm cache clear --force && \
chmod go+r -R /opt/c2cgeoportal_commons /opt/c2cgeoportal_geoportal /opt/c2cgeoportal_admin && \
ln -s /opt/c2cgeoportal_commons/c2cgeoportal_commons/alembic /opt && \
pip install --disable-pip-version-check --no-cache-dir --no-deps \
Expand Down
29 changes: 19 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,22 @@ quote:
.PHONY: spell
spell:
codespell --quiet-level=2 --check-filenames --ignore-words=spell-ignore-words.txt \
$(shell find -name node_modules -prune -or -name .build -prune -or -name .git -prune -or -name ngeo -prune \
-or -name '__pycache__' -prune -or -name _build -prune \
-or \( -type f -and -not -name '*.png' -and -not -name '*.mo' -and -not -name '*.po*' \
$(shell find \
-name node_modules -prune -or \
-name .build -prune -or \
-name .git -prune -or \
-name ngeo -prune -or \
-name '__pycache__' -prune -or \
-name _build -prune -or \
\( -type f -and -not -name '*.png' -and -not -name '*.mo' -and -not -name '*.po*' \
-and -not -name 'CONST_Makefile_tmpl' -and -not -name 'package-lock.json' \) -print)


YAML_FILES ?= $(shell find -name ngeo -prune -or -name functional -prune -or \( -name "*.yml" -or -name "*.yaml" \) -print)
YAML_FILES ?= $(shell find \
-name node_modules -prune -or \
-name ngeo -prune -or \
-name functional -prune -or \
\( -name "*.yml" -or -name "*.yaml" \) -print)
.PHONY: yamllint
yamllint:
yamllint --strict --config-file=yamllint.yaml -s $(YAML_FILES)
Expand Down Expand Up @@ -336,9 +345,8 @@ import-ngeo-apps: $(APPS_FILES) $(APPS_FILES_ALT)
.PRECIOUS: ngeo
ngeo:
$(PRERULE_CMD)
if [ ! -e "ngeo" ] ; then git clone --depth=100 --branch=$(shell VERSION=$(MAIN_BRANCH) npm-packages --branch) https://github.com/camptocamp/ngeo.git ; fi
git fetch origin
git reset --hard $(shell VERSION=$(MAIN_BRANCH) npm-packages --hash)
npm install
ln -s node_modules/ngeo .
touch --no-create $@

.PRECIOUS: ngeo/contribs/gmf/apps/%/index.html.ejs
Expand Down Expand Up @@ -403,11 +411,12 @@ geoportal/c2cgeoportal_geoportal/scaffolds/create/docker-run: docker-run

npm-packages: ngeo package.json
$(PRERULE_CMD)
npm-packages --ngeo \
npm-packages \
coveralls gaze jasmine-core jsdoc jsdom karma karma-chrome-launcher karma-coverage \
karma-jasmine karma-sourcemap-loader karma-webpack \
--src=ngeo/package.json --dst=$@
echo googshift eslint-plugin-googshift >> $@
bootstrap-table jquery.scrollintoview jstree jstreegrid magicsuggest-alpine typeahead.js \
--src=package.json --src=ngeo/package.json --dst=$@
echo googshift eslint-plugin-googshift loader-utils co >> $@

admin/npm-packages: ngeo package.json
$(PRERULE_CMD)
Expand Down
4 changes: 2 additions & 2 deletions docker/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ RUN \
. /etc/os-release && \
apt-get update && \
apt-get install --assume-yes --no-install-recommends tree apt-transport-https gettext sudo libxml2-utils && \
echo "deb https://deb.nodesource.com/node_6.x ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/nodesource.list && \
echo "deb https://deb.nodesource.com/node_8.x ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/nodesource.list && \
curl --silent https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - && \
# Docker source list should be like it but actually it's empty...
# echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu ${VERSION_CODENAME} stable" > /etc/apt/sources.list.d/docker.list && \
echo "deb [arch=amd64] https://download.docker.com/linux/debian stretch stable" > /etc/apt/sources.list.d/docker.list && \
curl --silent https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
apt-get update && \
apt-get install --assume-yes --no-install-recommends 'nodejs=6.*' docker-ce openjdk-8-jre-headless && \
apt-get install --assume-yes --no-install-recommends 'nodejs=8.*' docker-ce openjdk-8-jre-headless && \
apt-get clean && \
rm --recursive --force /var/lib/apt/lists/*

Expand Down
39 changes: 0 additions & 39 deletions docker/build/bin/npm-packages
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
# either expressed or implied, of the FreeBSD Project.


import os
import re
import json
from argparse import ArgumentParser
Expand All @@ -39,63 +38,25 @@ RE_NPM_VERSION = re.compile("^([0-9]+)\.([0-9]+)\.([0-9]+)$")
RE_NPM_PRERELEASE_VERSION = re.compile("^([0-9]+)\.([0-9]+)\.([0-9]+)\.?([a-z]+)([0-9]+)$")


def _ngeo_version():
if "TRAVIS_TAG" in os.environ and os.environ["TRAVIS_TAG"] != "":
match = RE_NPM_VERSION.match(os.environ["TRAVIS_TAG"])
prerelease_match = RE_NPM_PRERELEASE_VERSION.match(os.environ["TRAVIS_TAG"])
if match is not None:
return "{}.{}.{}".format(match.group(1), match.group(2), match.group(3))
if prerelease_match is not None:
return "{}.{}.{}-{}.{}".format(
prerelease_match.group(1),
prerelease_match.group(2),
prerelease_match.group(3),
prerelease_match.group(4),
prerelease_match.group(5)
)
return None


def main():
"""
Extract npm packages
"""

parser = ArgumentParser(description='Extract npm packages')

parser.add_argument('--branch', action="store_true", help="Get the ngeo branch and exit")
parser.add_argument('--hash', action="store_true", help="Get the ngeo commit hash and exit")
parser.add_argument('--ngeo', action="store_true", help="Add ngeo package")
parser.add_argument('--src', action='append', default=[], metavar='SRC', help="The ngeo source file")
parser.add_argument('--dst', metavar='DST', help="The destination file")
parser.add_argument('excludes', nargs='*', metavar='EXCLUDE', help="The npm package to exclude")

args = parser.parse_args()

if args.branch:
version = _ngeo_version()
print(os.environ["VERSION"] if version is None else version)
exit(0)

if args.hash:
version = _ngeo_version()
if version is None:
with open("package.json") as package_file:
version = json.loads(package_file)["dependencies"]["ngeo"].split(".")[-2]
print(version)
exit(0)

packages = {}
for src_ in args.src:
with open(src_) as src:
input_data = json.loads(src.read())
packages.update(input_data.get('devDependencies', {}))
packages.update(input_data.get('dependencies', {}))
if args.ngeo:
# Freeze the ngeo version
version = _ngeo_version()
if version is not None:
packages["ngeo"] = version
for package in args.excludes:
if package in packages:
del packages[package]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import "{{package}}.less";
@import "/usr/lib/node_modules/ngeo/contribs/gmf/less/desktop.less";
@import "{{package}}.scss";
@import "~gmf/less/desktop.scss";
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import "{{package}}.less";
@import "/usr/lib/node_modules/ngeo/contribs/gmf/less/mobile.less";
@import "{{package}}.scss";
@import "~gmf/less/mobile.scss";
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,6 @@ files_to_move:
- from: mapserver/tinyows.xml.tmpl.mako
to: mapserver/tinyows.xml.mako
version: 2.3
- from: geoportal/{{package}}_geoportal/static-ngeo/less/{{package}}.less
to: geoportal/{{package}}_geoportal/static-ngeo/sass/{{package}}.scss
version: 2.4
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,6 @@ files_to_move:
- from: mapserver/tinyows.xml.mako
to: mapserver/tinyows.xml.tmpl.mako
version: 2.3
- from: geoportal/{{package}}_geoportal/static-ngeo/less/{{package}}.less
to: geoportal/{{package}}_geoportal/static-ngeo/sass/{{package}}.scss
version: 2.4
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ APP_JS_JINJA_FILES += $(shell find geoportal/$(PACKAGE)_geoportal/static-ngeo/js
APP_JS_FILES += $(APP_JS_MAKO_FILES:.mako=) $(APP_JS_JINJA_FILES:.jinja=)
APP_HTML_FILES += $(addprefix geoportal/$(PACKAGE)_geoportal/static-ngeo/js/apps/, $(addsuffix .html.ejs, $(NGEO_INTERFACES)))
APP_DIRECTIVES_PARTIALS_FILES = $(shell find geoportal/$(PACKAGE)_geoportal/static-ngeo/components geoportal/$(PACKAGE)_geoportal/static-ngeo/partials geoportal/$(PACKAGE)_geoportal/static-ngeo/js -type f -name '*.html' 2> /dev/null)
LESS_FILES += $(shell find geoportal/$(PACKAGE)_geoportal/static-ngeo/less geoportal/$(PACKAGE)_geoportal/static-ngeo/components -type f -name '*.less' 2> /dev/null)
NGEO_GMF_FONTS = $(addprefix geoportal/$(PACKAGE)_geoportal/static-ngeo/fonts/gmf-icons, .woff .ttf .eot)
NGEO_FONTAWESOME_FONTS = $(addprefix geoportal/$(PACKAGE)_geoportal/static-ngeo/fonts/fontawesome-webfont, .woff .woff2 .ttf .eot)
NGEO_FONTS = $(NGEO_GMF_FONTS) $(NGEO_FONTAWESOME_FONTS)
SASS_FILES += $(shell find geoportal/$(PACKAGE)_geoportal/static-ngeo/sass geoportal/$(PACKAGE)_geoportal/static-ngeo/components -type f -name '*.scss' 2> /dev/null)
JSON_CLIENT_LOCALISATION_FILES = $(addprefix $(APP_OUTPUT_DIR)/, $(addsuffix .json, $(LANGUAGES)))
L10N_CLIENT_POSTFIX ?= client
L10N_SERVER_POSTFIX ?= server
Expand Down Expand Up @@ -416,9 +413,15 @@ yamllint: $(YAML_FILES)
.PHONY: spell
spell:
codespell --quiet-level=2 --check-filenames --ignore-words=spell-ignore-words.txt \
$(shell find -name node_modules -prune -or -name .git -prune -or -name '__pycache__' -prune \
-or -name 'build' -prune -or -name '.build' -prune -or -name 'cgxp' -prune -or -name 'c2cgeoportal_*' -prune \
-or \( -type f -and -not -name '*.png' -and -not -name '*.mo' -and -not -name '*.po*' \
$(shell find \
-name node_modules -prune -or \
-name .git -prune -or \
-name '__pycache__' -prune .or \
-name 'build' -prune -or \
-name '.build' -prune -or \
-name 'cgxp' -prune -or \
-name 'c2cgeoportal_*' -prune -or \
\( -type f -and -not -name '*.png' -and -not -name '*.mo' -and -not -name '*.po*' \
-and -not -name 'CONST_Makefile' -and -not -name 'package-lock.json' \) -print)

.PHONY: clean
Expand Down Expand Up @@ -592,19 +595,6 @@ $(APP_OUTPUT_DIR)/angular-locale_%.js: /usr/lib/node_modules/ngeo/package.json l
rm --force $@
cp /opt/angular-locale/angular-locale_`(grep $* language_mapping || echo $*) | cut --delimiter = --fields 2 | tr --delete '\r\n'`.js $@

.PRECIOUS: geoportal/$(PACKAGE)_geoportal/static-ngeo/fonts/gmf-icons.%
geoportal/$(PACKAGE)_geoportal/static-ngeo/fonts/gmf-icons.%: /usr/lib/node_modules/ngeo/contribs/gmf/fonts/gmf-icons.%
$(PRERULE_CMD)
mkdir --parent $(dir $@)
cp $< $@

.PRECIOUS: geoportal/$(PACKAGE)_geoportal/static-ngeo/fonts/fontawesome-webfont.%
geoportal/$(PACKAGE)_geoportal/static-ngeo/fonts/fontawesome-webfont.%: /usr/lib/node_modules/font-awesome/fonts/fontawesome-webfont.%
$(PRERULE_CMD)
mkdir --parent $(dir $@)
cp $< $@


$(APP_OUTPUT_DIR)/images/: /usr/lib/node_modules/jquery-ui/themes/base/images
$(PRERULE_CMD)
mkdir --parent $@
Expand All @@ -618,8 +608,7 @@ $(APP_OUTPUT_DIR)/images/: /usr/lib/node_modules/jquery-ui/themes/base/images
.PRECIOUS: /build/apps.%.timestamp
/build/apps.%.timestamp: $(OL_JS_FILES) $(NGEO_JS_FILES) $(APP_JS_FILES) \
$(APP_HTML_FILES) geoportal/webpack.config.js \
$(LESS_FILES) \
$(NGEO_FONTS) \
$(SASS_FILES) \
$(APP_OUTPUT_DIR)/images/
$(PRERULE_CMD)
# Workaround to make Webpack working for ol/index.js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"jstree": "3.3.5",
"jstreegrid": "3.9.4",
"magicsuggest-alpine": "1.0.0",
"ngeo": "2.4.0-daily.20180716T092301Z.76f80c4.HEAD",
"ngeo": "2.4.0-latest.20180727T081517Z.f1a2745.HEAD",
"openlayers": "4.6.5",
"typeahead.js": "0.11.1"
}
Expand Down

0 comments on commit 6c44252

Please sign in to comment.