mirror of
https://github.com/allankoechke/jwt-cpp.git
synced 2026-11-30 10:18:40 +00:00
* Implemented JsonCPP Traits * quick pass to add CI * correct find_packge to use config and not be required * typo in default version * jsoncpp forces out of source builds * disable tests and shared library * add missing build step * try a different target + build less "they" do not maintain the CMake scripts so this will be fun https://github.com/open-source-parsers/jsoncpp/issues/455#issuecomment-478251641 * fix name for traits (missed replaces) * Added missing array_type constructor so that basic_claims can be formed from sets of values * Linters and more tests + fetchcontent gtest * linter * support library names with many separators * linters * run clang format after rendering defaults --------- Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
58 lines
2.1 KiB
YAML
58 lines
2.1 KiB
YAML
name: "Render `defaults.h` Template"
|
|
description: "Generate the `defaults.h` header file for a JSON library"
|
|
inputs:
|
|
traits_name:
|
|
description: "Name of the traits structure to be used. Typically in the format `author_repository` or equivilant"
|
|
required: true
|
|
library_name:
|
|
description: "Name of the JSON library."
|
|
required: true
|
|
library_url:
|
|
description: "URL to the JSON library."
|
|
required: true
|
|
disable_default_traits:
|
|
description: "Set the macro to disable the default traits"
|
|
required: false
|
|
default: "true"
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 14
|
|
- run: npm install mustache
|
|
shell: bash
|
|
- uses: actions/github-script@v6
|
|
env:
|
|
TRAITS_NAME: ${{ inputs.traits_name }}
|
|
LIBRARY_NAME: ${{ inputs.library_name }}
|
|
LIBRARY_URL: ${{ inputs.library_url }}
|
|
DISABLE_DEFAULT_TRAITS: ${{ inputs.disable_default_traits }}
|
|
with:
|
|
script: |
|
|
const mustache = require('mustache')
|
|
const path = require('path')
|
|
const fs = require('fs')
|
|
|
|
const { TRAITS_NAME, LIBRARY_NAME, LIBRARY_URL, DISABLE_DEFAULT_TRAITS } = process.env
|
|
console.log(`Rendering ${TRAITS_NAME}!`)
|
|
|
|
const disableDefault = DISABLE_DEFAULT_TRAITS === 'true'
|
|
|
|
const template = fs.readFileSync(path.join('include', 'jwt-cpp', 'traits', 'defaults.h.mustache'), 'utf8')
|
|
const content = mustache.render(template, {
|
|
traits_name: TRAITS_NAME,
|
|
traits_name_upper: TRAITS_NAME.toUpperCase(),
|
|
library_name: LIBRARY_NAME,
|
|
library_url: LIBRARY_URL,
|
|
disable_default_traits: disableDefault,
|
|
})
|
|
// https://dmitripavlutin.com/replace-all-string-occurrences-javascript/
|
|
function replaceAll(string, search, replace) {
|
|
return string.split(search).join(replace);
|
|
}
|
|
|
|
const outputDir = path.join('include', 'jwt-cpp', 'traits', replaceAll(TRAITS_NAME, '_', '-'))
|
|
fs.mkdirSync(outputDir, { recursive: true })
|
|
fs.writeFileSync(path.join(outputDir, 'defaults.h'), content)
|