diff --git a/CHANGELOG.md b/CHANGELOG.md index 8814d776..d1139d62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ ## [Unreleased] +## [1.2.0] + +### Added +- Added new configuration prompts for `SERVICE_NAME` during initial setup. + +### Changed +- **BREAKING (for existing templates):** If you are re-running the generator to update an existing project, the new prompt variables will evaluate to blank. When Thor asks to overwrite your `config/tech-docs.yml`, press `n` to keep your existing configuration. ## 1.1.0 diff --git a/Gemfile.lock b/Gemfile.lock index 8876d3c9..032f5894 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (8.1.3) + activesupport (8.1.3.1) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) @@ -17,19 +17,20 @@ GEM addressable (2.9.0) public_suffix (>= 2.0.2, < 8.0) base64 (0.3.0) - bigdecimal (4.1.1) + bigdecimal (4.1.2) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.3.7) + concurrent-ruby (1.3.8) connection_pool (3.0.2) contracts (0.17.3) diff-lcs (1.6.2) dotenv (3.2.0) drb (2.2.3) erubi (1.13.1) - execjs (2.10.1) + execjs (2.10.2) + json (>= 2) fast_blank (1.0.1) fastimage (2.4.1) ffi (1.17.4) @@ -60,7 +61,7 @@ GEM rake webrick jasmine-core (3.99.0) - json (2.19.9) + json (2.21.2) kramdown (2.5.2) rexml (>= 3.4.4) listen (3.10.0) @@ -102,7 +103,7 @@ GEM toml uglifier (>= 3, < 5) webrick - minitest (6.0.4) + minitest (6.0.6) drb (~> 2.0) prism (~> 1.5) padrino-helpers (0.16.1) @@ -110,12 +111,12 @@ GEM padrino-support (= 0.16.1) tilt (>= 2.1, < 3) padrino-support (0.16.1) - parallel (2.0.1) + parallel (2.1.0) parslet (2.0.0) phantomjs (2.1.1.0) prism (1.9.0) public_suffix (7.0.5) - rack (3.2.6) + rack (3.2.7) rackup (2.3.1) rack (>= 3) rake (13.4.2) @@ -140,9 +141,9 @@ GEM ffi (~> 1.9) securerandom (0.4.1) servolux (0.13.0) - temple (0.10.4) + temple (0.10.7) thor (1.5.0) - tilt (2.7.0) + tilt (2.9.0) toml (0.3.0) parslet (>= 1.8.0, < 3.0.0) tzinfo (2.0.6) @@ -171,5 +172,78 @@ DEPENDENCIES rake rspec +CHECKSUMS + activesupport (8.1.3.1) sha256=85458765f25ea48b9019c46b6bb3fa5683197bf4280d9f06710a6e8d7a831376 + addressable (2.9.0) sha256=7fdf6ac3660f7f4e867a0838be3f6cf722ace541dd97767fa42bc6cfa980c7af + base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b + bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd + coffee-script (2.4.1) sha256=82fe281e11b93c8117b98c5ea8063e71741870f1c4fbb27177d7d6333dd38765 + coffee-script-source (1.12.2) sha256=e12b16fd8927fbbf8b87cb2e9a85a6cf457c6881cc7ff8b1af15b31f70da07a4 + concurrent-ruby (1.3.8) sha256=b2f1be836e968ccc78ccfce277ea79c72a88633f22306782c16ff23fb415d1e1 + connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a + contracts (0.17.3) sha256=e72e626413ea47099becb7b5683beb1c2ea902c69f5bad55c9258fe2b48314d7 + diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962 + dotenv (3.2.0) sha256=e375b83121ea7ca4ce20f214740076129ab8514cd81378161f11c03853fe619d + drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373 + erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9 + execjs (2.10.2) sha256=466cf2b49e50c0cfdff8fdb88a7a983dfab7ac0f6185c317ccb434a75c224c88 + fast_blank (1.0.1) sha256=269fc30414fed4e6403bc4a49081e1ea539f8b9226e59276ed1efaefabaa17ea + fastimage (2.4.1) sha256=c64bebd46b6fd8943ab70c1e6e85ff728f970f2e48f92ecd249b6bc3a540ad20 + ffi (1.17.4) sha256=bcd1642e06f0d16fc9e09ac6d49c3a7298b9789bcb58127302f934e437d60acf + ffi (1.17.4-aarch64-linux-gnu) sha256=b208f06f91ffd8f5e1193da3cae3d2ccfc27fc36fba577baf698d26d91c080df + ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39 + ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564 + ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95 + ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b + ffi (1.17.4-x86-linux-gnu) sha256=38e150df5f4ca555e25beca4090823ae09657bceded154e3c52f8631c1ed72cf + ffi (1.17.4-x86-linux-musl) sha256=fbeec0fc7c795bcf86f623bb18d31ea1820f7bd580e1703a3d3740d527437809 + ffi (1.17.4-x86_64-darwin) sha256=aa70390523cf3235096cf64962b709b4cfbd5c082a2cb2ae714eb0fe2ccda496 + ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d + ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e + haml (6.4.0) sha256=b2e20652be52ac9a3be328e8ff411ad007e82fc4e78e1a5cdefad537a697cf6a + hamster (3.0.0) sha256=5951e3a3ffd15ba854a976ac36ebae9469966f726034ffed0dccdb6d12d434d8 + hashie (5.1.0) sha256=c266471896f323c446ea8207f8ffac985d2718df0a0ba98651a3057096ca3870 + i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5 + jasmine (3.99.0) sha256=f76416a099adbad1055df013735f3e510d121a8ca530680f78fc8dd0463ef755 + jasmine-core (3.99.0) sha256=a8290894b4fce6de47fa53f0abc578e6592da65e3de9069de0744d4300451178 + json (2.21.2) sha256=1f1d3b7cf2b3ba1a69beca0bb6db13d5438b80bff3cd54cdaaa620b9b07c1c6a + kramdown (2.5.2) sha256=1ba542204c66b6f9111ff00dcc26075b95b220b07f2905d8261740c82f7f02fa + listen (3.10.0) sha256=c6e182db62143aeccc2e1960033bebe7445309c7272061979bb098d03760c9d2 + logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203 + memoist (0.16.2) sha256=a52c53a3f25b5875151670b2f3fd44388633486dc0f09f9a7150ead1e3bf3c45 + middleman (4.6.3) sha256=cf6293bf3d7917d495f466358c7d9707843c06347d5db2168e950b24c235704e + middleman-cli (4.6.3) sha256=03deb5b893f748a5adeaf22ccc1452dfede2de25a4583bb451a0162857eb9974 + middleman-core (4.6.3) sha256=5cab1e1f16b00d26f541a4ca787427e1e0203c34f2d81471c1fae3bf1e7509a8 + minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1 + padrino-helpers (0.16.1) sha256=dd897c7974c34b8642942e503474365b13336574f837b38d6309a8b67e94940b + padrino-support (0.16.1) sha256=fe7fa6e781f978a94299b2e99bebc58ab71f64e9453c81ed21cd74fa15d550a8 + parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356 + parslet (2.0.0) sha256=d45130695d39b43d7e6a91f4d2ec66b388a8d822bae38de9b4de9a5fbde1f606 + phantomjs (2.1.1.0) sha256=b392cfba33d374285d022c905c714948fc1a69d162cd17cfea39b684fd5a1779 + prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85 + public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623 + rack (3.2.7) sha256=93e13e1c24f93556671d85d2d79fa228c3485815c50d7e2f265b5330c6528fb7 + rackup (2.3.1) sha256=6c79c26753778e90983761d677a48937ee3192b3ffef6bc963c0950f94688868 + rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701 + rb-fsevent (0.11.2) sha256=43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe + rb-inotify (0.11.1) sha256=a0a700441239b0ff18eb65e3866236cd78613d6b9f78fea1f9ac47a85e47be6e + rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142 + rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587 + rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d + rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836 + rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47 + rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c + sassc (2.4.0) sha256=4c60a2b0a3b36685c83b80d5789401c2f678c1652e3288315a1551d811d9f83e + securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1 + servolux (0.13.0) sha256=1a33c45458f8061d8a989b19d3ad6e5cfad04881b3fe988508a90850a3961519 + temple (0.10.7) sha256=369fe560adb6534674ce232899c2232df614bcb29c5359b05efedff7a57ed9c0 + thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 + tilt (2.9.0) sha256=da5735d0280bba96e9a91041bb14aee435ccad5c17b0fa519249ae543d9aa3a5 + toml (0.3.0) sha256=0a91d0f76a9036e84e44f95693b12f58d358c1df3ac8e3b5271f2056ecc6e4b9 + tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b + uglifier (4.2.1) sha256=75d42b81b10bfd21e7a427fabb1d49ff5ea7bda3c4a5039ddb2a78d194c6f5aa + uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6 + webrick (1.9.2) sha256=beb4a15fc474defed24a3bda4ffd88a490d517c9e4e6118c3edce59e45864131 + BUNDLED WITH - 2.6.9 + 4.0.19 diff --git a/Thorfile b/Thorfile index bb42827a..cd6fc854 100644 --- a/Thorfile +++ b/Thorfile @@ -65,46 +65,52 @@ module Middleman directory 'template', '.', exclude_pattern: /\.DS_Store$/ end - def ask_about_paas + def ask_about_documentation_url return unless @first_time - - if option_set?('USE_PAAS') - @use_paas = parse_boolean('USE_PAAS') + if ENV['DOCUMENTATION_URL'] + @documentation_url = ENV['DOCUMENTATION_URL'] else - @use_paas = yes?('Will you be deploying this on GOV.UK PaaS?') + say "What will the URL of your documentation be, for example https://example-docs.gov.uk?", :blue + say "You can change this later in config/tech-docs.yml.", :blue + @documentation_url = ask("Documentation URL:") end + end - return unless @use_paas - - @application_name = ENV['APPLICATION_NAME'] || ask( - <<-MESSAGE -What is the name of your application on PaaS? -If your application URL is larry-the-cat.cloudapps.digital, this will be "larry-the-cat". - MESSAGE - ) + def ask_about_service_name + return unless @first_time + if ENV['SERVICE_NAME'] + @service_name = ENV['SERVICE_NAME'] + else + say "What is the name of the service or API your documentation is about, for example Data sharing service?", :yellow + say "You can change this later in config/tech-docs.yml.", :yellow + @service_name = ask("Service Name:") + end end - def ask_about_canonical_host + def ask_about_service_url return unless @first_time - @canonical_host = ENV['CANONICAL_HOST'] || ask( - <<-MESSAGE -What is the canonical hostname of your application? -e.g. docs.larry-the-cat.service.gov.uk - MESSAGE - ) + if ENV['SERVICE_URL'] + @service_url = ENV['SERVICE_URL'] + else + say "What is the URL for the service your documentation is about, for example https://new-service.gov.uk?", :green + say "You can change this later in config/tech-docs.yml.", :green + @service_url = ask("Service URL:") + end end - def configure_paas + # TODO:: once https://github.com/alphagov/tech-docs-gem/issues/516 is complete, + # also set gov.uk branding or generic header/font etc based on this + def ask_about_govuk_logo return unless @first_time - return unless @use_paas - - template 'optional/manifest.yml', 'manifest.yml' - copy_file 'optional/nginx.conf', 'source/nginx.conf' - gsub_file 'source/nginx.conf', '__CANONICAL_HOST__', @canonical_host - directory 'optional/script', 'script' + if option_set?('USE_GOVUK_LOGO') + @use_govuk_logo = parse_boolean('USE_GOVUK_LOGO') + else + @use_govuk_logo = yes?('Will you be using the GOV.UK logo?') + end end + def configure_tech_docs return unless @first_time diff --git a/create-test-site.sh b/create-test-site.sh index 3dce0c7e..a41525db 100755 --- a/create-test-site.sh +++ b/create-test-site.sh @@ -7,9 +7,10 @@ set -xe # The `middleman init` script can be configured with environment variables # instead of the interactive prompt. export FIRST_TIME=true -export USE_PAAS=true -export APPLICATION_NAME=larry-the-cat -export CANONICAL_HOST=larry-the-cat.cloudapps.digital +export USE_GOVUK_LOGO=true +export SERVICE_NAME=example service +export SERVICE_URL=example-service.cloudapps.digital +export DOCUMENTATION_URL=example.docs bundle exec middleman init tmp/test-run -T file://$(pwd) cd tmp/test-run diff --git a/optional/config/tech-docs.yml.tt b/optional/config/tech-docs.yml.tt index 296cbd28..77999e6e 100644 --- a/optional/config/tech-docs.yml.tt +++ b/optional/config/tech-docs.yml.tt @@ -1,18 +1,18 @@ # Host to use for canonical URL generation (without trailing slash) -host: <%= @canonical_host %> +host: <%= @documentation_url %> # Header-related options -show_govuk_logo: true -service_name: Name of API -service_link: https://www.larry-the-cat.service.gov.uk +show_govuk_logo: <%= @use_govuk_logo %> +service_name: <%= @service_name %> +service_link: <%= @service_url %> phase: Beta # Links to show on right-hand-side of header header_links: - About: https://www.larry-the-cat.service.gov.uk/about - Get Started: https://www.larry-the-cat.service.gov.uk/get-started - Documentation: / - Support: https://www.larry-the-cat.service.gov.uk/support + About: <%= @service_url %>/about + Get Started: <%= @service_url %>/get-started + Documentation: <%= @documentation_url %> + Support: <%= @service_url %>/support # Enables search functionality. This indexes pages only and is not recommended for single-page sites. enable_search: false diff --git a/optional/manifest.yml.tt b/optional/manifest.yml.tt deleted file mode 100644 index 6ed50520..00000000 --- a/optional/manifest.yml.tt +++ /dev/null @@ -1,7 +0,0 @@ ---- -applications: -- name: <%= @application_name %> - memory: 64M - instances: 2 - path: ./build - buildpack: staticfile_buildpack diff --git a/optional/nginx.conf b/optional/nginx.conf deleted file mode 100644 index 177ac42c..00000000 --- a/optional/nginx.conf +++ /dev/null @@ -1,75 +0,0 @@ -# This configuration is based from the CloudFoundry static buildpack's default, which you can view here: -# https://github.com/cloudfoundry/staticfile-buildpack/blob/bd7a288e11b27f1c5095d62bcd09780a14c5151e/conf/nginx.conf -worker_processes 1; -daemon off; - -error_log <%= ENV["APP_ROOT"] %>/nginx/logs/error.log; -events { worker_connections 1024; } - -http { - charset utf-8; - log_format cloudfoundry '$http_x_forwarded_for - $http_referer - [$time_local] "$request" $status $body_bytes_sent'; - access_log <%= ENV["APP_ROOT"] %>/nginx/logs/access.log cloudfoundry; - default_type application/octet-stream; - include mime.types; - sendfile on; - - gzip on; - gzip_disable "msie6"; - gzip_comp_level 6; - gzip_min_length 1100; - gzip_buffers 16 8k; - gzip_proxied any; - gunzip on; - gzip_static always; - gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss; - gzip_vary on; - - tcp_nopush on; - keepalive_timeout 30; - port_in_redirect off; # Ensure that redirects don't include the internal container PORT - <%= ENV["PORT"] %> - server_tokens off; - - server { - listen <%= ENV["PORT"] %>; - server_name localhost; - - location / { - root <%= ENV["APP_ROOT"] %>/public; - <% if File.exists?(File.join(ENV["APP_ROOT"], "nginx/conf/.enable_pushstate")) %> - if (!-e $request_filename) { - rewrite ^(.*)$ / break; - } - <% end %> - index index.html index.htm Default.htm; - <% if File.exists?(File.join(ENV["APP_ROOT"], "nginx/conf/.enable_directory_index")) %> - autoindex on; - <% end %> - <% if File.exists?(auth_file = File.join(ENV["APP_ROOT"], "nginx/conf/.htpasswd")) %> - auth_basic "Restricted"; #For Basic Auth - auth_basic_user_file <%= auth_file %>; #For Basic Auth - <% end %> - <% if ENV["FORCE_HTTPS"] %> - if ($http_x_forwarded_proto != "https") { - return 301 https://$host$request_uri; - } - <% end %> - <% if File.exists?(File.join(ENV["APP_ROOT"], "nginx/conf/.enable_ssi")) %> - ssi on; - <% end %> - <% if File.exists?(File.join(ENV["APP_ROOT"], "nginx/conf/.enable_hsts")) %> - add_header Strict-Transport-Security "max-age=31536000"; - <% end %> - if ($host != "__CANONICAL_HOST__") { - return 301 https://__CANONICAL_HOST__$request_uri; - } - } - - <% unless File.exists?(File.join(ENV["APP_ROOT"], "nginx/conf/.enable_dotfiles")) %> - location ~ /\. { - deny all; - return 404; - } - <% end %> - } -} diff --git a/optional/script/deploy b/optional/script/deploy deleted file mode 100755 index 09a81434..00000000 --- a/optional/script/deploy +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -set -e - -error() { - echo " ! $1" -} - -# Check that we have a Staticfile.auth we can use -echo "Checking Staticfile.auth..." -if [[ ! -f Staticfile.auth ]]; then - error "You are attempting to deploy to an environment that requires a Staticfile.auth, but do not have one locally." - error "Please add a Staticfile.auth file to this directory and try again." - error - error "For information on generating a Staticfile.auth, see" - error "http://docs.cloudfoundry.org/buildpacks/staticfile/index.html#basic-auth" - exit 1 -fi -echo "OK!" - -# Check that we're on main, or there's an environment variable set to override -BRANCH=$(git rev-parse --abbrev-ref HEAD) - -echo "Checking branch..." -if [[ $BRANCH != "main" ]] && [[ $I_REALISE_I_AM_NOT_ON_MAIN != "y" ]]; then - error "Current branch is not main, cowardly refusing to deploy" - error "To force override, run this again with I_REALISE_I_AM_NOT_ON_MAIN=y" - exit 1 -fi -echo "OK!" - -# Check that we've not got any uncommitted files in our working directory -echo "Checking dirty working tree..." -DIRTY_WORKING_TREE=$(git status --porcelain 2>/dev/null | egrep "^(M| M)" || exit 0) -if [[ $DIRTY_WORKING_TREE != "" ]]; then - error "There are uncommitted changes in the working directory." - error "Please commit or stash all changes and try again." - exit 1 -fi -echo "OK!" - -# Check if we're behind our Git remote -echo "Checking if we're behind origin..." -BEHIND_ORIGIN=$(git fetch origin >/dev/null 2>&1; git diff --stat HEAD...@{u}) -if [[ $BEHIND_ORIGIN != "" ]]; then - error "You are behind the origin branch - please pull and try again." - exit 1 -fi -echo "OK!" - -bundle exec middleman build -cp Staticfile.auth build -cf target -o govuk-service-manual -s integration -cf push diff --git a/template/Gemfile b/template/Gemfile index 31578d27..051fa324 100644 --- a/template/Gemfile +++ b/template/Gemfile @@ -9,4 +9,4 @@ gem 'wdm', '~> 0.1.0', platforms: [:mswin, :mingw, :x64_mingw] gem 'tzinfo-data', platforms: [:mswin, :mingw, :x64_mingw, :jruby] # Include the tech docs gem -gem 'govuk_tech_docs', '~> 6.0.0' +gem 'govuk_tech_docs', '~> 6.0'