Skip to content

Commit

Permalink
Moving JsonSchemas into this repo (#613)
Browse files Browse the repository at this point in the history
Co-authored-by: Kylstad <acn-nkyls@ai-dev.no>
Co-authored-by: EKEBERG Steffen <steffen.ekeberg@soprasteria.com>
Co-authored-by: Steffen Lorang Ekeberg <steffen.ekeberg@gmail.com>
Co-authored-by: Terje Holene <terje.holene@gmail.com>
Co-authored-by: Ole Martin Handeland <git@olemartin.org>
Co-authored-by: Martin Joakim Ulstein <mjulstein@users.noreply.github.com>
Co-authored-by: tba76 <70642698+tba76@users.noreply.github.com>
Co-authored-by: Nina Kylstad <nkylstad@gmail.com>
Co-authored-by: Ivar Nesje <ivarne@users.noreply.github.com>
Co-authored-by: FTLems <90687291+FTLems@users.noreply.github.com>
Co-authored-by: DanRJ <daniel.rustadj@gmail.com>
Co-authored-by: Håkon <2082481+haakemon@users.noreply.github.com>
Co-authored-by: Truls Gunnerød <Truls.Gunnerod@no.experis.com>
Co-authored-by: Martin Joakim Ulstein <6736558+mjulstein@users.noreply.github.com>
Co-authored-by: Magnus Revheim Martinsen <mrmartinsen.96@gmail.com>
Co-authored-by: Rune Tømmerås Larsen <rune@hjemmekino.no>
Co-authored-by: = <bjosttveit@gmail.com>
  • Loading branch information
18 people authored Nov 3, 2022
1 parent 2b5a069 commit 6ebaa4f
Show file tree
Hide file tree
Showing 6 changed files with 1,119 additions and 54 deletions.
149 changes: 149 additions & 0 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#!/usr/bin/env bash

set -e
set -u

PRE_RELEASE=no
COMMIT=no

while [[ $# -gt 0 ]]; do
case $1 in
--cdn)
PATH_TO_CDN=$(realpath "$2")
shift # pop option
shift # pop value
;;
--frontend)
PATH_TO_FRONTEND=$(realpath "$2")
shift # pop option
shift # pop value
;;
--pre-release)
PRE_RELEASE=yes
shift # pop option
;;
--commit)
COMMIT=yes
shift # pop option
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
echo "Unknown argument $1"
exit 1
;;
esac
done

SOURCE=src/altinn-app-frontend/dist
TARGET=toolkits/altinn-app-frontend

if ! test -d "$PATH_TO_CDN" || ! test -d "$PATH_TO_CDN/$TARGET"; then
echo "Unable to find $PATH_TO_CDN/$TARGET"
echo "Make sure path to CDN has been passed with --cdn <path>"
exit 1
fi
if ! test -d "$PATH_TO_FRONTEND" || ! test -d "$PATH_TO_FRONTEND/$SOURCE"; then
echo "Unable to find $PATH_TO_FRONTEND/$SOURCE (did you run yarn build first?)"
echo "Make sure path to CDN has been passed with --frontend <path>"
exit 1
fi

SOURCE_SCHEMAS="$PATH_TO_FRONTEND/schemas"
TARGET_SCHEMAS="$PATH_TO_CDN/schemas"

SOURCE="$PATH_TO_FRONTEND/$SOURCE"
TARGET="$PATH_TO_CDN/$TARGET"

echo "-------------------------------------"
echo "Source: $SOURCE"
echo "Target: $TARGET"
echo "Pre-release: $PRE_RELEASE (toggle with --pre-release)"
echo "Commit: $COMMIT (toggle with --commit)"
echo "-------------------------------------"

CURRENT_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null)
CURRENT_VERSION_PARTS=(${CURRENT_VERSION//./ })
APP_FULL=${CURRENT_VERSION:1}
APP_MAJOR=${CURRENT_VERSION_PARTS[0]:1}
APP_MAJOR_MINOR=${CURRENT_VERSION_PARTS[0]:1}.${CURRENT_VERSION_PARTS[1]}
AUTHOR_FULL=$(git log -1 | grep Author)
AUTHOR_NAME=$(git log -1 | grep Author | cut -d' ' -f2)
AUTHOR_EMAIL=$(git log -1 | grep Author | cut -d' ' -f3 | cut -d'<' -f2 | cut -d'>' -f1)
COMMIT_ID=$(git rev-parse HEAD~0)

echo "Full version: $APP_FULL"
echo "Major version: $APP_MAJOR"
echo "Major + minor: $APP_MAJOR_MINOR"
echo "Latest author: $AUTHOR_FULL"
echo "Author name: $AUTHOR_NAME"
echo "Author email: $AUTHOR_EMAIL"
echo "Commit ID: $COMMIT_ID"
echo "-------------------------------------"

COMMIT_FILE=$(mktemp --suffix=-cdn-commit)
{
echo "$AUTHOR_FULL updated altinn-app-frontend to $APP_FULL"
echo "based on commit https://github.com/Altinn/app-frontend-react/commit/$COMMIT_ID"
git log -1 | grep -Ev "commit|Author|Date"
} >> "$COMMIT_FILE"

echo "CDN commit message:"
echo
cat "$COMMIT_FILE"
echo "-------------------------------------"
echo "Files to be copied:"
echo
ls -1 $SOURCE/*
echo "-------------------------------------"
echo "Log:"
echo

# Needed in order for git commands to work
cd "$TARGET"

if [[ "$PRE_RELEASE" == "no" ]]; then
echo " * Copying Major version"
test -e "$TARGET/$APP_MAJOR" && git rm -r "$TARGET/$APP_MAJOR"
mkdir -p "$TARGET/$APP_MAJOR"
cp -fr $SOURCE/* "$TARGET/$APP_MAJOR/"
echo " * Copying Minor version"
test -e "$TARGET/$APP_MAJOR_MINOR" && git rm -r "$TARGET/$APP_MAJOR_MINOR"
mkdir -p "$TARGET/$APP_MAJOR_MINOR"
cp -fr $SOURCE/* "$TARGET/$APP_MAJOR_MINOR/"

echo " * Copying schemas"
cp -prv $SOURCE_SCHEMAS/* "$TARGET_SCHEMAS/"
else
echo " * Copying Major version (skipped using --pre-release)"
echo " * Copying Minor version (skipped using --pre-release)"
echo " * Copying schemas (skipped using --pre-release)"
fi

echo " * Copying Patch version"
test -e "$TARGET/$APP_FULL" && git rm -r "$TARGET/$APP_FULL"
mkdir -p "$TARGET/$APP_FULL"
cp -fr $SOURCE/* "$TARGET/$APP_FULL/"

echo " * Updating index.json"
ls -1 | \
grep --perl-regexp '^[\d\.]+(-[a-z0-9.]+)?$' | \
sort --version-sort | \
jq --raw-input --slurp 'split("\n") | map(select(. != ""))' > index.json

cd ../..

echo " * Staged for commit:"
git add .
git status --short

if [[ "$COMMIT" == "yes" ]]; then
echo " * Committing changes"
git commit --author="$AUTHOR_NAME <$AUTHOR_EMAIL>" -F "$COMMIT_FILE"
else
echo " * Skipping commit (toggle with --commit)"
fi

echo "-------------------------------------"
61 changes: 7 additions & 54 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,63 +36,16 @@ jobs:
token: ${{secrets.ALTINN_CDN_TOKEN}}
path: cdn

- name: Prepare version number
id: prepare
- name: Run release script
working-directory: app-frontend
run: |
echo Clone, copy, commit and push to Altinn-CDN
CURRENT_VERSION=`git describe --abbrev=0 --tags 2>/dev/null`
CURRENT_VERSION_PARTS=(${CURRENT_VERSION//./ })
echo ::set-output name=APP_FULL::${CURRENT_VERSION:1}
echo ::set-output name=APP_MAJOR::${CURRENT_VERSION_PARTS[0]:1}
echo ::set-output name=APP_MAJOR_MINOR::${CURRENT_VERSION_PARTS[0]:1}.${CURRENT_VERSION_PARTS[1]}
echo ::set-output name=AUTHOR_FULL::$(git log -1 | grep Author)
echo ::set-output name=AUTHOR_NAME::$(git log -1 | grep Author | cut -d' ' -f2)
echo ::set-output name=AUTHOR_EMAIL::$(git log -1 | grep Author | cut -d' ' -f3 | cut -d'<' -f2 | cut -d'>' -f1)
echo ::set-output name=COMMIT_ID::$(git rev-parse HEAD~0)
git log -1 | grep -Ev "commit|Author|Date" > ./../commitmsg.txt
- name: Copy version
working-directory: cdn
if: "!github.event.release.prerelease"
run: |
echo altinn-app-frontend version: ${{ steps.prepare.outputs.APP_FULL }}
echo Copy Major Version
test -e toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }} && git rm -r toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}
mkdir -p toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}
cp -fr ../app-frontend/src/altinn-app-frontend/dist/* toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR }}/
echo Copy Minor Version
test -e toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR_MINOR }} && git rm -r toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR_MINOR }}
mkdir -p toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR_MINOR }}
cp -fr ../app-frontend/src/altinn-app-frontend/dist/* toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_MAJOR_MINOR }}/
echo Copy Patch
test -e toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_FULL }} && git rm -r toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_FULL }}
mkdir -p toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_FULL }}
cp -fr ../app-frontend/src/altinn-app-frontend/dist/* toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_FULL }}/
run: bash .github/scripts/release.sh --frontend . --cdn ../cdn --commit

- name: Copy version (pre-release)
working-directory: cdn
- name: Run release script (pre-release)
working-directory: app-frontend
if: "github.event.release.prerelease"
run: |
echo altinn-app-frontend version: ${{ steps.prepare.outputs.APP_FULL }}
echo Copy Patch
test -e toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_FULL }} && git rm -r toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_FULL }}
mkdir -p toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_FULL }}
cp -fr ../app-frontend/src/altinn-app-frontend/dist/* toolkits/altinn-app-frontend/${{ steps.prepare.outputs.APP_FULL }}/
run: bash .github/scripts/release.sh --frontend . --cdn ../cdn --commit --pre-release

- name: Copy patch version and commit to CDN
- name: Push to CDN
working-directory: cdn
run: |
echo altinn-app-frontend version: ${{ steps.prepare.outputs.APP_FULL }}
cd toolkits/altinn-app-frontend
ls -1 | grep --perl-regexp '^[\d\.]+(-[a-z0-9.]+)?$' | sort --version-sort | jq --raw-input --slurp 'split("\n") | map(select(. != ""))' > index.json
cd ../..
git config --global user.email "${{ steps.prepare.outputs.AUTHOR_EMAIL }}"
git config --global user.name "${{ steps.prepare.outputs.AUTHOR_NAME }}"
git add .
echo "${{ steps.prepare.outputs.AUTHOR_FULL }} updated altinn-app-frontend to ${{ steps.prepare.outputs.APP_FULL }}" > ./../commit1.txt
echo "based on commit https://github.com/Altinn/app-frontend-react/commit/${{ steps.prepare.outputs.COMMIT_ID }}" > ./../commit2.txt
cat ./../commit1.txt ./../commit2.txt ./../commitmsg.txt > ./../commit.txt
cat ./../commit.txt
git commit -F ./../commit.txt
git push
run: git push
99 changes: 99 additions & 0 deletions schemas/json/component/number-format.schema.v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"$id": "https://altinncdn.no/schemas/json/component/number-format.schema.v1.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Input number formatting",
"description": "Schema that describes the options that can be configured for number formatting on an `input` component, based on react-number-format package. For complete list of available options, see https://github.com/s-yadav/react-number-format#props",
"type": "object",
"additionalProperties": true,
"properties": {
"allowedDecimalSeparators": {
"title": "Allowed decimal separators",
"description": "Characters which when pressed result in a decimal separator. When missing, decimalSeparator and '.' are used",
"type": "array",
"items": {
"type": "string",
"maxLength": 1
},
"examples": [[",", ".", "/"]]
},
"allowEmptyFormatting": {
"title": "Allow empty formatting",
"description": "Apply formatting to empty inputs",
"type": "boolean",
"default": false
},
"allowLeadingZeros": {
"title": "Allow leading zeros",
"description": "Allow leading zeros at beginning of number",
"type": "boolean",
"default": false
},
"allowNegative": {
"title": "Allow negative",
"description": "Allow negative numbers (Only when format option is not provided)",
"type": "boolean",
"default": true
},
"decimalScale": {
"title": "Decimal scale",
"description": "If defined it limits to given decimal scale.",
"type": "number",
"examples": [1, 2, 3]
},
"decimalSeparator": {
"title": "Decimal separator",
"description": "Support decimal point on a number. Single character string.",
"type": "string",
"maxLength": 1,
"default": "."
},
"fixedDecimalScale": {
"title": "Fixed decimal scale",
"description": "Used together with decimalScale. If true it adds 0s to match given decimal scale.",
"type": "boolean",
"default": false
},
"format": {
"title": "Format",
"description": "Format given as hash string, to allow number input in place of hash.",
"type": "string",
"examples": ["### ### ###", "+47 ### ## ###", "##-##-##-##"]
},
"mask": {
"title": "Mask",
"description": "Mask to show in place of non-entered values",
"type": "string",
"examples": ["_"],
"default": " "
},
"prefix": {
"title": "Prefix",
"description": "Add a prefix before the number",
"type": "string",
"examples": ["$", "kr", "-", "(+47) "]
},
"suffix": {
"title": "Suffix",
"description": "Add a suffix after the number",
"type": "string",
"examples": ["%", "kr", "kg"]
},
"thousandSeparator": {
"title": "Thousand separator",
"description": "Add thousand separators on number. Single character string or boolean true (true is default to ,)",
"type": ["string", "boolean"],
"maxLength": 1,
"examples": [true, ",", "."]
}
},
"allOf": [{
"if": {
"properties": { "fixedDecimalScale": { "const": true } },
"required": ["fixedDecimalScale"]
},
"then": {
"required": ["decimalScale"]
}
}
]
}
47 changes: 47 additions & 0 deletions schemas/json/layout/layout-sets.schema.v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$id": "https://altinncdn.no/schemas/json/layout/layout-sets.schema.v1.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Altinn layout sets",
"description": "Schema that describes the different layout sets for an Altinn application and when to use them",
"type": "object",
"additionalProperties": true,
"properties": {
"sets": {
"type": "array",
"items": {
"$ref": "#/definitions/layoutset"
}
},
"definitions": {
"layoutset": {
"type": "object",
"additionalProperties": false,
"description": "Settings regarding a specific layoutset",
"properties": {
"id": {
"type": "string",
"title": "id",
"description": "The layoutset ID. Must be unique within a given application."
},
"type": {
"type": "string",
"title": "dataType",
"description": "The datatype to use this layoyut."
},
"tasks": {
"$ref": "#/definitions/tasks"
}
}
},
"tasks": {
"additionalProperties": false,
"description": "An array specifying which task to use a layoutset",
"type": "array",
"items": {
"description": "A layoutSet name, for instance 'Form1'",
"type": "string"
}
}
}
}
}
Loading

0 comments on commit 6ebaa4f

Please sign in to comment.