Skip to content

Commit

Permalink
package.json, sea-site-build - facilitate link to playground for deve…
Browse files Browse the repository at this point in the history
…loper convenience

Developing sea-map needs a way to deploy a mini map website. Doing
this via a dependency from (say) the `playground` project to `sea-map`
is a bit cumbersome, because changes to sea-map need to be propagated
back via a push to github.  Changing playground's dependency on
sea-map to a relative path also doesn't work well, because a) this
change mustn't be checked in, but more seriously b) it doesn't then
pull in the requirejs dependency.

A simpler way is to symlink to playground within sea-map, using a link
called (say) `ext`, and adding an npm script task to build and serve
that directly.

See documentation added to README.md
  • Loading branch information
Nick Stokoe committed Mar 20, 2020
1 parent 1d1ed9b commit 3a3556c
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
# NPM installs libraries here (and in subdirs)
node_modules/

# Transient build files go here:
/build
# Optional link to an external map project for development purposes
# (e.g. playground)
/ext

# Configuration for local testing
/www/configuration
Expand Down
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,46 @@ This is not currently properly documented, but here is an example:
}
```

# DEVELOPMENT

Developing `sea-map` needs a way to deploy a website using it for
testing. Doing this via a dependency from (say) the [`playground`][1]
project to `sea-map` is a bit cumbersome if changes to `sea-map` need
to be propagated back to the consuming project via pushing the changes
under test to github.

It is also possible to change a `package.json` dependency on `sea-map`
to a relative path. But this also doesn't work well, because

1. This change mustn't be checked in, but more seriously
2. It doesn't then pull in the RequireJS dependency correctly.

The latter seems to be a known problem with npm.

So, a suggested simpler way is to embed a simple project using
`sea-map` within a subdirectory `ext`, either directly (from within
the same directory as this README):

git clone $PROJECT_URL ext

Or using a symlink:

ln -sf $PROJECT_PATH ext

A pair of npm script tasks to build and serve that directly have been
added to `package.json`, so given the above, you can the build and
serve the project like this:

npm install # installs sea-map deps
npm run build # builds the embedded project in ext/build/out
npm run serve # serves the embedded project in ext/build/out

The website, using the under-development version of `sea-map`, will
then be accessible locally via the URL http://localhost:8080

*Caveat:* the embedded project should not have any extra dependencies
beyond `sea-map`, because the `npm install` above will not find those.

# SCRIPT TARGETS

This package does little in its own right. The following are the
Expand All @@ -97,4 +137,17 @@ script targets it supports.

Runs a static analysis of the source, highlighting possible improvements

npm build

Assuming a project consuming sea-map (such as [playground][1])has been
symlinked (or installed) into `ext/`, this builds that dependent
project. Primarily for the sea-map developers' convenience, rather
than any users of sea-map.

[1]: https://github.com/SolidarityEconomyAssociation/playground

npm serve

As above, a sea-map developers' convenience. Launches a PHP
development web-server, publishing a project consuming sea-map in
`ext/`
2 changes: 1 addition & 1 deletion bin/sea-site-build
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ scriptpath=$(dirname "$script")
rm -rf "$dest"/* &&
mkdir -p "$dest/in/www" &&
ln -sfrn "$sea_map/www"/* "$dest/in/www" &&
generate-version "$npm_package_name" >config/version.json &&
generate-version "$npm_package_name" >"$config/version.json" &&
ln -sfrn "$config" "$dest/in/www/configuration" &&
cp -f "$sea_map/build.js" "$dest/in/build.js" &&
{ if [ -n "$*" ]; then ln -vsfrn "$@" "$dest/in/www/"; fi } &&
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
},
"scripts": {
"lint": "eslint www/map-app/**/*.js",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "PATH=$PATH:$PWD/bin; sea-site-build -c ext/config -m ./ -d ext/build ext/src/*",
"serve": "php -t ext/build/out -S localhost:8080"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 3a3556c

Please sign in to comment.