diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 97e0fceec..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,194 +0,0 @@ -version: 2.1 # use CircleCI 2.1 -references: - common_environment: &common_environment - environment: - REPO_DIR: git-repo - REPO_WEBSITE_DIR: git-repo/website - BUILD_DIR: build_artifacts - TERM: xterm - BUNDLER_VERSION: 2.0.2 - HUGO_VERSION: 0.58.3 - working_directory: ~/working - attach_build_workspace: &attach_build_workspace - attach_workspace: - at: build_artifacts - checkout: &checkout - checkout: - path: git-repo - checkout-submodules: &checkout-submodules - run: - name: Checkout Submodules - command: | - cd "$REPO_DIR" - git submodule sync --recursive - git submodule update --recursive --init - publish_artifacts: &publish_artifacts - store_artifacts: - path: build_artifacts - restore_gem_cache: &restore_gem_cache - restore_cache: - keys: - - gem-cache-v10-{{ arch }}-{{ checksum "git-repo/website/Gemfile.lock" }} - - gem-cache-v10-{{ arch }}- - save_gem_cache: &save_gem_cache - save_cache: - key: gem-cache-v10-{{ arch }}-{{ checksum "git-repo/website/Gemfile.lock" }} - paths: - - git-repo/website/vendor/bundle -commands: - install-hugo: - description: "Install Hugo" - steps: - - run: - name: Get Hugo - command: | - wget "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.deb" - - run: - name: Install Hugo - command: | - sudo apt-get install "./hugo_extended_${HUGO_VERSION}_Linux-64bit.deb" - install-markdown-link-check: - description: "Install markdown-link-check" - steps: - - run: - name: Get markdown-link-check - command: | - sudo npm install -g markdown-link-check - install-bundler: - description: "Install bundler and html-proofer" - steps: - - run: - name: Install with Bundler - command: | - cd "$REPO_WEBSITE_DIR" - gem update --system - gem install bundler - bundle install --path vendor/bundle --jobs=4 --retry=3 && bundle clean - check-skip-build: - steps: - - run: - name: Check if job should be skipped - command: | - if [[ -f "$BUILD_DIR/.skipbuild" ]]; then - echo "Skipping job." - circleci step halt - fi -executors: - java-executor: - docker: # run the java jobs - - image: circleci/openjdk:11-jdk-node-browsers - <<: *common_environment - ruby-node-executor: - docker: # run the ruby jobs - - image: circleci/ruby:2.6.5-node-browsers - <<: *common_environment -jobs: # a collection of - job-ci-skip-check: - executor: java-executor - steps: - - checkout - - run: - name: Check if skip build - command: | - mkdir -p "$BUILD_DIR/state" - COMMIT_MSG=$(git log --format=oneline -n 1 $CIRCLE_SHA1) - if [[ $COMMIT_MSG == *"[ci deploy skip]"* ]]; then - echo "[ci deploy skip] detected. Stopping." - echo "branch: $CIRCLE_BRANCH" > "$BUILD_DIR/.skipbuild" - else - echo "branch: $CIRCLE_BRANCH" > "$BUILD_DIR/.runbuild" - fi - - persist_to_workspace: - root: build_artifacts - paths: - - .runbuild - - .skipbuild - job-validate-markdown: - executor: java-executor - steps: - - *checkout - - *attach_build_workspace - - check-skip-build - - install-markdown-link-check - - run: - name: Validate repo Markdown content instances - command: | - # this command will filter out any docs Markdown files, which are checked in a different job - find "$REPO_DIR" -path "${REPO_WEBSITE_DIR}" -prune -o -name \*.md -print0 | xargs -0 -n1 markdown-link-check -q -c "$REPO_DIR/scripts/config/.markdown-link-check/config.json" - job-validate-site-content: - executor: ruby-node-executor - steps: - - *checkout - - *checkout-submodules - - *attach_build_workspace - - check-skip-build - - *restore_gem_cache - - install-bundler - - install-hugo - - run: - name: Build and Validate Hugo site - command: | - cd "${REPO_WEBSITE_DIR}" - hugo -v --debug --minify - bundle exec htmlproofer --allow-hash-href --disable-external public/ --url-swap "\/metaschema\/:/" --assume-extension --log-level :debug - - *save_gem_cache - - *publish_artifacts - job-build-and-deploy-website: - executor: ruby-node-executor - steps: - - *checkout - - *checkout-submodules - - *attach_build_workspace - - check-skip-build - - *restore_gem_cache - - install-bundler - - install-hugo - - run: - name: Build Site with Hugo - command: | - # cp -vr "$BUILD_DIR"/* "$REPO_DIR" - cd "$REPO_WEBSITE_DIR" - hugo -v --debug --minify - mkdir -p public/.circleci - # copy the circleci config - cp ../.circleci/config.yml public/.circleci/config.yml - touch public/.nojekyll - - *save_gem_cache - - run: - name: Run deploy script - command: | - cd "$REPO_WEBSITE_DIR" - git config user.name "Deployment Bot" - bash ./deploy.sh --push-only -v -m "Deploying website [ci deploy skip]" - - *publish_artifacts -workflows: - version: 2 - build: - jobs: - - job-ci-skip-check: - filters: - tags: - ignore: /.*/ - - job-validate-markdown: - requires: - - job-ci-skip-check - filters: - branches: - ignore: - - master - - nist-pages - - job-validate-site-content: - requires: - - job-ci-skip-check - filters: - branches: - # only from PRs - ignore: - - master - - nist-pages - - job-build-and-deploy-website: - requires: - - job-ci-skip-check - filters: - branches: - only: master diff --git a/.github/workflows/status-ci-cd.yml b/.github/workflows/status-ci-cd.yml new file mode 100644 index 000000000..537ccff69 --- /dev/null +++ b/.github/workflows/status-ci-cd.yml @@ -0,0 +1,32 @@ +name: Metachema CI/CD +on: + push: + branches: + - main + - develop + - "feature-*" + - "release-*" + - "*" + pull_request: + branches: + - "*" + workflow_dispatch: +jobs: + validate-repo-markdown: + uses: ./.github/workflows/workflow-validate-repo-markdown.yml + validate-website: + if: github.event_name == 'pull_request' + needs: validate-repo-markdown + uses: ./.github/workflows/workflow-generate-website.yml + with: + hugo_version: 0.83.1 + commit_resources: false + push-website: + if: github.event_name == 'push' + needs: validate-website + uses: ./.github/workflows/workflow-generate-website.yml + with: + hugo_version: 0.83.1 + commit_resources: true + secrets: + access_token: ${{ secrets.COMMIT_TOKEN }} diff --git a/.github/workflows/workflow-generate-website.yml b/.github/workflows/workflow-generate-website.yml new file mode 100644 index 000000000..a3649ab41 --- /dev/null +++ b/.github/workflows/workflow-generate-website.yml @@ -0,0 +1,106 @@ +name: Metaschema Generate Website +on: + workflow_call: + inputs: + hugo_version: + description: 'the version of Hugo to use' + required: false + default: '0.83.1' + type: string + commit_resources: + description: 'commit the resources after generating them. Requires the access_token to be passed' + required: false + default: false + type: boolean + secrets: + access_token: + description: 'the access token to use for commits' + required: false + workflow_dispatch: + inputs: + hugo_version: + description: 'the version of Hugo to use' + required: false + default: '0.83.1' + type: string + commit_resources: + description: 'commit the resources after generating them. Requires a PAT defined as secrets.COMMIT_TOKEN' + required: true + default: false + type: boolean +jobs: + build-and-push-website: + name: Build and Push Website + runs-on: ubuntu-latest + env: + HUGO_VERSION: ${{ github.event.inputs.hugo_version }}${{ inputs.hugo_version }} + steps: + # use this for builds triggered from the UI on protected branches + - name: Checkout Latest (using COMMIT_TOKEN) + if: github.event_name == 'workflow_dispatch' && github.event.inputs.commit_resources == true + uses: actions/checkout@v3 # current: dcd71f646680f2efd8db4afa5ad64fdcba30e748 + with: + token: ${{ secrets.COMMIT_TOKEN }} + submodules: recursive + # use this for builds triggered from other workflows on protected branches + - name: Checkout Latest (using access_token) + if: github.event_name == 'push' && inputs.commit_resources == true + uses: actions/checkout@v3 # current: dcd71f646680f2efd8db4afa5ad64fdcba30e748 + with: + token: ${{ secrets.access_token }} + submodules: recursive + # use this for overything else (i.e., pull requests) where publication is not needed + - name: Checkout Latest + if: ${{ inputs.commit_resources == false }} + uses: actions/checkout@v3 # current: dcd71f646680f2efd8db4afa5ad64fdcba30e748 + with: + submodules: recursive + # Install Hugo + - name: Install Hugo + run: | + wget https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_Linux-64bit.deb + sudo apt-get install ./hugo_extended_${HUGO_VERSION}_Linux-64bit.deb + - name: Run Hugo + run: | + hugo --config "config.yaml,development-config.yaml" -v --debug --minify + working-directory: ${{ github.workspace }}/website + - name: Zip Artifacts for Upload + run: | + zip ${{ runner.temp }}/metaschema-website.zip -r public/ + working-directory: ${{ github.workspace }}/website + - uses: actions/upload-artifact@v3 # current: 6673cd052c4cd6fcf4b4e6e60ea986c889389535 + with: + name: website + path: | + ${{ runner.temp }}/metaschema-website.zip + retention-days: 5 + - name: Link Checker + id: linkchecker + uses: lycheeverse/lychee-action@f1da3291e1d03cbe11a413ae9f16b62fec99e6b6 # v1.4.1 + with: + args: --exclude-file ./build/config/.lycheeignore --verbose --no-progress './website/public/**/*.html' + format: json + output: html_link_report.json + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/upload-artifact@v3 # current: 6673cd052c4cd6fcf4b4e6e60ea986c889389535 + with: + name: html_link_report + path: html_link_report.json + retention-days: 5 + - uses: actions/github-script@v3 # current: f05a81df23035049204b043b50c3322045ce7eb3 + if: steps.linkchecker.outputs.exit_code != 0 + with: + script: | + core.setFailed('Link checker detected broken or invalid links, read attached report.') + - name: Deploy Website + uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # current: v3 + if: | + github.ref_name == 'main' && + (github.event.inputs.commit_resources == true || inputs.commit_resources == true) + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + enable_jekyll: false + publish_dir: ./website/public + publish_branch: nist-pages + commit_message: Deploying website [ci deploy skip] diff --git a/.github/workflows/workflow-validate-repo-markdown.yml b/.github/workflows/workflow-validate-repo-markdown.yml new file mode 100644 index 000000000..8f810541c --- /dev/null +++ b/.github/workflows/workflow-validate-repo-markdown.yml @@ -0,0 +1,55 @@ +name: Metaschema Validate Repo Markdown +on: + workflow_call: + inputs: + ignorePattern: + description: 'a pattern provided to grep for files/directories to ignore' + required: false + default: '^website/' + type: string + markdownLinkCheckConfig: + description: 'the path to the markdown link check config file' + required: false + default: 'build/config/.markdown-link-check/config.json' + type: string + workflow_dispatch: + inputs: + ignorePattern: + description: 'a pattern provided to grep for files/directories to ignore' + required: false + default: '^website/' + type: string + markdownLinkCheckConfig: + description: 'the path to the markdown link check config file' + required: false + default: 'build/config/.markdown-link-check/config.json' + type: string +jobs: + validate-repo-markdown: + name: Validate Repo Markdown + runs-on: ubuntu-latest + steps: + # use this for pulls where checkout is anonymous + - uses: actions/checkout@v3 # current: dcd71f646680f2efd8db4afa5ad64fdcba30e748 + with: + submodules: recursive + # Setup runtime environment + # ------------------------- + - name: Set up NodeJS + uses: actions/setup-node@v3 # current: 56337c425554a6be30cdef71bf441f15be286854 + with: + node-version-file: 'build/.nvmrc' + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + - name: Setup Dependencies + run: | + # NodeJS + cd "${{ github.workspace }}/build" + npm install --loglevel verbose + echo "$PWD/node_modules/.bin/" >> $GITHUB_PATH + # Build Artifacts + # --------------- + - name: Validate repo Markdown content instances + run: | + # this command will filter out any docs Markdown files, which are checked in a different job + git ls-files "*/*.md" -z | grep --null-data -v "${{ inputs.ignorePattern }}" | xargs -0 -n1 markdown-link-check -q -c "${{ inputs.markdownLinkCheckConfig }}" diff --git a/.gitignore b/.gitignore index 26ea91e39..a87794e09 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ # other generated files nohup.out /toolchains/xslt-M4/validate/xspec/metaschema-composition-schematron-result.html + +# Ignore NodeJS modules +node_modules/ \ No newline at end of file diff --git a/build/.nvmrc b/build/.nvmrc new file mode 100644 index 000000000..6f7f377bf --- /dev/null +++ b/build/.nvmrc @@ -0,0 +1 @@ +v16 diff --git a/build/config/.lycheeignore b/build/config/.lycheeignore new file mode 100644 index 000000000..3766a9c09 --- /dev/null +++ b/build/config/.lycheeignore @@ -0,0 +1 @@ +https://search.usa.gov/search \ No newline at end of file diff --git a/scripts/config/.markdown-link-check/config.json b/build/config/.markdown-link-check/config.json similarity index 100% rename from scripts/config/.markdown-link-check/config.json rename to build/config/.markdown-link-check/config.json diff --git a/build/package-lock.json b/build/package-lock.json new file mode 100644 index 000000000..e57975529 --- /dev/null +++ b/build/package-lock.json @@ -0,0 +1,409 @@ +{ + "name": "build", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "dependencies": { + "markdown-link-check": "^3.10.0" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/async": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", + "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==" + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/commander": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", + "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==", + "engines": { + "node": ">= 6" + } + }, + "node_modules/debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dependencies": { + "ms": "^2.1.1" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-absolute-url": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-3.0.3.tgz", + "integrity": "sha512-opmNIX7uFnS96NtPmhWQgQx6/NYFgsUXYMllcfzwWKUMwfo8kku1TvE6hkNcH+Q1ts5cMVrsY7j0bxXQDciu9Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-relative-url": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-relative-url/-/is-relative-url-3.0.0.tgz", + "integrity": "sha512-U1iSYRlY2GIMGuZx7gezlB5dp1Kheaym7zKzO1PV06mOihiWTXejLwm4poEJysPyXF+HtK/BEd0DVlcCh30pEA==", + "dependencies": { + "is-absolute-url": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isemail": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/isemail/-/isemail-3.2.0.tgz", + "integrity": "sha512-zKqkK+O+dGqevc93KNsbZ/TqTUFd46MwWjYOoMrjIMZ51eU7DtQG3Wmd9SQQT7i7RVnuTPEiYEWHU3MSbxC1Tg==", + "dependencies": { + "punycode": "2.x.x" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/link-check": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/link-check/-/link-check-5.1.0.tgz", + "integrity": "sha512-FHq/9tVnIE/3EVEPb91GcbD+K/Pv5K5DYqb7vXi3TTKIViMYPOWxYFVVENZ0rq63zfaGXGvLgPT9U6jOFc5JBw==", + "dependencies": { + "is-relative-url": "^3.0.0", + "isemail": "^3.2.0", + "ms": "^2.1.3", + "needle": "^3.0.0" + } + }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "node_modules/markdown-link-check": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/markdown-link-check/-/markdown-link-check-3.10.0.tgz", + "integrity": "sha512-P2WeISLd669q4yxmX3rU6zoGcmAXdvvRK8paXxLvOlTjtxY6cObpMv0blVtampmJGMeE7QcF4Q/9YT/wfXUNaw==", + "dependencies": { + "async": "^3.2.3", + "chalk": "^4.1.2", + "commander": "^6.2.0", + "link-check": "^5.1.0", + "lodash": "^4.17.21", + "markdown-link-extractor": "^2.0.1", + "needle": "^3.0.0", + "progress": "^2.0.3" + }, + "bin": { + "markdown-link-check": "markdown-link-check" + } + }, + "node_modules/markdown-link-extractor": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/markdown-link-extractor/-/markdown-link-extractor-2.0.1.tgz", + "integrity": "sha512-Qy5AcoW7CDfIAB3I6cz2QFGHoLQYSH15lmfEqRgPvC/DEEMhb/EK0yeXmpIk+GSuJveYxLvkpXVFEZhgvubxTw==", + "dependencies": { + "marked": "^4.0.12" + } + }, + "node_modules/marked": { + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.14.tgz", + "integrity": "sha512-HL5sSPE/LP6U9qKgngIIPTthuxC0jrfxpYMZ3LdGDD3vTnLs59m2Z7r6+LNDR3ToqEQdkKd6YaaEfJhodJmijQ==", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/needle": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-3.1.0.tgz", + "integrity": "sha512-gCE9weDhjVGCRqS8dwDR/D3GTAeyXLXuqp7I8EzH6DllZGXSUyxuqqLh+YX9rMAWaaTFyVAg6rHGL25dqvczKw==", + "dependencies": { + "debug": "^3.2.6", + "iconv-lite": "^0.6.3", + "sax": "^1.2.4" + }, + "bin": { + "needle": "bin/needle" + }, + "engines": { + "node": ">= 4.4.x" + } + }, + "node_modules/progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "engines": { + "node": ">=6" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + } + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "async": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", + "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==" + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "commander": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz", + "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==" + }, + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + }, + "is-absolute-url": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-absolute-url/-/is-absolute-url-3.0.3.tgz", + "integrity": "sha512-opmNIX7uFnS96NtPmhWQgQx6/NYFgsUXYMllcfzwWKUMwfo8kku1TvE6hkNcH+Q1ts5cMVrsY7j0bxXQDciu9Q==" + }, + "is-relative-url": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-relative-url/-/is-relative-url-3.0.0.tgz", + "integrity": "sha512-U1iSYRlY2GIMGuZx7gezlB5dp1Kheaym7zKzO1PV06mOihiWTXejLwm4poEJysPyXF+HtK/BEd0DVlcCh30pEA==", + "requires": { + "is-absolute-url": "^3.0.0" + } + }, + "isemail": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/isemail/-/isemail-3.2.0.tgz", + "integrity": "sha512-zKqkK+O+dGqevc93KNsbZ/TqTUFd46MwWjYOoMrjIMZ51eU7DtQG3Wmd9SQQT7i7RVnuTPEiYEWHU3MSbxC1Tg==", + "requires": { + "punycode": "2.x.x" + } + }, + "link-check": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/link-check/-/link-check-5.1.0.tgz", + "integrity": "sha512-FHq/9tVnIE/3EVEPb91GcbD+K/Pv5K5DYqb7vXi3TTKIViMYPOWxYFVVENZ0rq63zfaGXGvLgPT9U6jOFc5JBw==", + "requires": { + "is-relative-url": "^3.0.0", + "isemail": "^3.2.0", + "ms": "^2.1.3", + "needle": "^3.0.0" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "markdown-link-check": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/markdown-link-check/-/markdown-link-check-3.10.0.tgz", + "integrity": "sha512-P2WeISLd669q4yxmX3rU6zoGcmAXdvvRK8paXxLvOlTjtxY6cObpMv0blVtampmJGMeE7QcF4Q/9YT/wfXUNaw==", + "requires": { + "async": "^3.2.3", + "chalk": "^4.1.2", + "commander": "^6.2.0", + "link-check": "^5.1.0", + "lodash": "^4.17.21", + "markdown-link-extractor": "^2.0.1", + "needle": "^3.0.0", + "progress": "^2.0.3" + } + }, + "markdown-link-extractor": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/markdown-link-extractor/-/markdown-link-extractor-2.0.1.tgz", + "integrity": "sha512-Qy5AcoW7CDfIAB3I6cz2QFGHoLQYSH15lmfEqRgPvC/DEEMhb/EK0yeXmpIk+GSuJveYxLvkpXVFEZhgvubxTw==", + "requires": { + "marked": "^4.0.12" + } + }, + "marked": { + "version": "4.0.14", + "resolved": "https://registry.npmjs.org/marked/-/marked-4.0.14.tgz", + "integrity": "sha512-HL5sSPE/LP6U9qKgngIIPTthuxC0jrfxpYMZ3LdGDD3vTnLs59m2Z7r6+LNDR3ToqEQdkKd6YaaEfJhodJmijQ==" + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "needle": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/needle/-/needle-3.1.0.tgz", + "integrity": "sha512-gCE9weDhjVGCRqS8dwDR/D3GTAeyXLXuqp7I8EzH6DllZGXSUyxuqqLh+YX9rMAWaaTFyVAg6rHGL25dqvczKw==", + "requires": { + "debug": "^3.2.6", + "iconv-lite": "^0.6.3", + "sax": "^1.2.4" + } + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==" + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "requires": { + "has-flag": "^4.0.0" + } + } + } +} diff --git a/build/package.json b/build/package.json new file mode 100644 index 000000000..982ecc666 --- /dev/null +++ b/build/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "markdown-link-check": "^3.10.0" + } +} diff --git a/website/Gemfile b/website/Gemfile deleted file mode 100644 index 32a71ce13..000000000 --- a/website/Gemfile +++ /dev/null @@ -1,6 +0,0 @@ -source "https://rubygems.org" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] - -gem 'html-proofer' diff --git a/website/Gemfile.lock b/website/Gemfile.lock deleted file mode 100644 index 7d8134c9f..000000000 --- a/website/Gemfile.lock +++ /dev/null @@ -1,38 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - ethon (0.12.0) - ffi (>= 1.3.0) - ffi (1.11.1) - html-proofer (3.13.0) - addressable (~> 2.3) - mercenary (~> 0.3) - nokogiri (~> 1.10) - parallel (~> 1.3) - rainbow (~> 3.0) - typhoeus (~> 1.3) - yell (~> 2.0) - mercenary (0.3.6) - mini_portile2 (2.8.0) - nokogiri (1.13.3) - mini_portile2 (~> 2.8.0) - racc (~> 1.4) - parallel (1.18.0) - public_suffix (4.0.6) - racc (1.6.0) - rainbow (3.0.0) - typhoeus (1.3.1) - ethon (>= 0.9.0) - yell (2.2.0) - -PLATFORMS - ruby - -DEPENDENCIES - html-proofer - tzinfo-data - -BUNDLED WITH - 2.0.2 diff --git a/website/config.yaml b/website/config.yaml index 33d198837..d5a1bb40e 100644 --- a/website/config.yaml +++ b/website/config.yaml @@ -1,6 +1,9 @@ title: "Metaschema" baseURL: https://pages.nist.gov/metaschema/ +relativeURLs: true +canonifyURLs: true defaultContentLanguage: en +disableAliases: false languages: en: lang: en @@ -9,12 +12,21 @@ languages: MetaDataFormat: "yaml" theme: "uswds" googleAnalytics: UA-42404149-54 -canonifyurls: true enableGitInfo: true enableRobotsTXT: true pygmentsCodeFences: true pygmentsCodefencesGuessSyntax: true pygmentsUseClasses: true +markup: + goldmark: + extensions: + typographer: false + parser: + autoHeadingID: true + renderer: + unsafe: true + highlight: + guessSyntax: true params: header: project_shortname: "Metaschema" @@ -30,3 +42,7 @@ menu: url: /contribute/contact/ - name: Github url: https://github.com/usnistgov/metaschema +module: + mounts: + - source: static + target: static diff --git a/website/content/use/_index.md b/website/content/use/_index.md index d17219527..75bc2bdaf 100644 --- a/website/content/use/_index.md +++ b/website/content/use/_index.md @@ -8,6 +8,6 @@ menu: weight: 10 --- -Currently, the Metaschema syntax uses an [XML-based format](https://github.com/usnistgov/metaschema/schema/). Alternate formats (e.g., JSON, YAML) are currently being considered. +Currently, the Metaschema syntax uses an [XML-based format](https://github.com/usnistgov/metaschema/blob/master/toolchains/xslt-M4/validate/metaschema.xsd). Alternate formats (e.g., JSON, YAML) are currently being considered. -An [ISO Schematron](http://schematron.com/) ruleset is also [provided](https://github.com/david-waltermire-nist/metaschema/blob/master/toolchains/oscal-m2/lib/metaschema-check.sch) to enforce some of the rules described below. +An [ISO Schematron](http://schematron.com/) ruleset is also [provided]https://github.com/usnistgov/metaschema/blob/master/toolchains/xslt-M4/validate/metaschema-composition-check.sch) to enforce some of the rules described below. diff --git a/website/deploy.sh b/website/deploy.sh deleted file mode 100644 index 6da81c5a9..000000000 --- a/website/deploy.sh +++ /dev/null @@ -1,228 +0,0 @@ -#!/usr/bin/env bash -set -o errexit #abort if any command fails -me=$(basename "$0") - -help_message="\ -Usage: $me [-c FILE] [] -Deploy generated files to a git branch. - -Options: - - -h, --help Show this help information. - -v, --verbose Increase verbosity. Useful for debugging. - -e, --allow-empty Allow deployment of an empty directory. - -m, --message MESSAGE Specify the message used when committing on the - deploy branch. - -n, --no-hash Don't append the source commit's hash to the deploy - commit's message. - --source-only Only build but not push - --push-only Only push but not build - -b, --deploy-branch BRANCH Delpoy to specified branch -" - - -run_build() { - echo "Running Hugo" - hugo -v --debug --minify -} - -parse_args() { - # Set args from a local environment file. - if [ -e ".env" ]; then - source .env - fi - - # Parse arg flags - # If something is exposed as an environment variable, set/overwrite it - # here. Otherwise, set/overwrite the internal variable instead. - while : ; do - if [[ $1 = "-h" || $1 = "--help" ]]; then - echo "$help_message" - return 0 - elif [[ $1 = "-v" || $1 = "--verbose" ]]; then - verbose=true - shift - elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then - allow_empty=true - shift - elif [[ ( $1 = "-m" || $1 = "--message" ) && -n $2 ]]; then - commit_message=$2 - shift 2 - elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then - GIT_DEPLOY_APPEND_HASH=false - shift - elif [[ ( $1 = "-b" || $1 = "--deploy-branch" ) && -n $2 ]]; then - deploy-branch=$2 - shift 2 - else - break - fi - done - - # Set internal option vars from the environment and arg flags. All internal - # vars should be declared here, with sane defaults if applicable. - - # Source directory & target branch. - deploy_directory=public - - if [[ -z $deploy_branch ]]; then - deploy_branch=nist-pages - fi - - #if no user identity is already set in the current git environment, use this: - default_username=${GIT_DEPLOY_USERNAME:-deploy.sh} - default_email=${GIT_DEPLOY_EMAIL:-} - - #repository to deploy to. must be readable and writable. - repo=origin - - #append commit hash to the end of message by default - append_hash=${GIT_DEPLOY_APPEND_HASH:-true} -} - -main() { - parse_args "$@" - - enable_expanded_output - - if ! git diff --exit-code --quiet --cached; then - echo Aborting due to uncommitted changes in the index >&2 - return 1 - fi - - commit_title=`git log -n 1 --format="%s" HEAD` - commit_hash=` git log -n 1 --format="%H" HEAD` - - #default commit message uses last title if a custom one is not supplied - if [[ -z $commit_message ]]; then - commit_message="publish: $commit_title" - fi - - #append hash to commit message unless no hash flag was found - if [ $append_hash = true ]; then - commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash" - fi - - previous_branch=`git rev-parse --abbrev-ref HEAD` - - if [ ! -d "$deploy_directory" ]; then - echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2 - return 1 - fi - - # must use short form of flag in ls for compatibility with OS X and BSD - if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then - echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2 - return 1 - fi - - if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then - # deploy_branch exists in $repo; make sure we have the latest version - - disable_expanded_output - git fetch --force $repo $deploy_branch:$deploy_branch - enable_expanded_output - fi - - # check if deploy_branch exists locally - if git show-ref --verify --quiet "refs/heads/$deploy_branch" - then incremental_deploy - else initial_deploy - fi - - restore_head -} - -initial_deploy() { - echo "Deploying initial artifacts to '$deploy_branch'" - git --work-tree "$deploy_directory" checkout --orphan $deploy_branch - git --work-tree "$deploy_directory" add --all - commit+push -} - -incremental_deploy() { - echo "Deploying incremental artifacts to '$deploy_branch'" - #make deploy_branch the current branch - git symbolic-ref HEAD refs/heads/$deploy_branch - #put the previously committed contents of deploy_branch into the index - git --work-tree "$deploy_directory" reset --mixed --quiet - echo " Adding all changes in '$deploy_directory'" - git --work-tree "$deploy_directory" add --all - - set +o errexit - diff=$(git --work-tree "$deploy_directory" diff --exit-code --quiet HEAD --)$? - set -o errexit - case $diff in - 0) echo No changes to files in $deploy_directory. Skipping commit.;; - 1) commit+push;; - *) - echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2 - return $diff - ;; - esac -} - -commit+push() { - set_user_id - echo "Committing '$deploy_directory'" - git --work-tree "$deploy_directory" commit -m "$commit_message" - - disable_expanded_output - #--quiet is important here to avoid outputting the repo URL, which may contain a secret token - echo "Pushing changes to '$deploy_branch'" - git push --quiet $repo $deploy_branch - enable_expanded_output -} - -#echo expanded commands as they are executed (for debugging) -enable_expanded_output() { - if [ $verbose ]; then - set -o xtrace - set +o verbose - fi -} - -#this is used to avoid outputting the repo URL, which may contain a secret token -disable_expanded_output() { - if [ $verbose ]; then - set +o xtrace - set -o verbose - fi -} - -set_user_id() { - if [[ -z `git config user.name` ]]; then - git config user.name "$default_username" - fi - if [[ -z `git config user.email` ]]; then - git config user.email "$default_email" - fi -} - -restore_head() { - if [[ $previous_branch = "HEAD" ]]; then - #we weren't on any branch before, so just set HEAD back to the commit it was on - git update-ref --no-deref HEAD $commit_hash $deploy_branch - else - git symbolic-ref HEAD refs/heads/$previous_branch - fi - - git reset --mixed -} - -filter() { - sed -e "s|$repo|\$repo|g" -} - -sanitize() { - "$@" 2> >(filter 1>&2) | filter -} - -if [[ $1 = --source-only ]]; then - run_build -elif [[ $1 = --push-only ]]; then - main "$@" -else - run_build - main "$@" -fi diff --git a/website/themes/uswds b/website/themes/uswds index 1e4176d11..631e1143c 160000 --- a/website/themes/uswds +++ b/website/themes/uswds @@ -1 +1 @@ -Subproject commit 1e4176d113972e8f721ea179c29fe0a5478457a9 +Subproject commit 631e1143c32fbcfb8a6d7d5ed7d9e093f51a1c2b