Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modificaion in install.sh to take the sdk version #192

Draft
wants to merge 8 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions languages/cpp/templates/callback-initialization/tuple.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${if.namespace.notsame}${parent.Title}::${end.if.namespace.notsame}${title} ${property};
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}
}${end.if.optional}${if.non.optional}auto index((*proxyResponse)${Property.dependency}.${Property}.Elements());
while (index.Next() == true) {
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.value().push_back(index.Current().Value());${end.if.non.object}
${if.object}${items.with.indent}${end.if.object}${if.non.object} ${base.title}${property.dependency}${if.impl.optional}.value()${end.if.impl.optional}.${property}.push_back(index.Current().Value());${end.if.non.object}
}${end.if.non.optional}
11 changes: 7 additions & 4 deletions languages/cpp/templates/sdk/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ usage()
echo " -i install path"
echo " -s sdk path"
echo " -m module name. i.e, core/manage"
echo " -v sdk version"
echo
echo "usage: "
echo " ./install.sh -i path -s sdk path -m core"
echo " ./install.sh -i path -s sdk path -m core -v 1.2.0-next.2"
}

SdkPath=".."
InstallPath=".."
ModuleName="core"
while getopts i:s:m:h flag
Version=1.3.0-next.1
while getopts i:s:m:v:h flag
do
case "${flag}" in
i) InstallPath="${OPTARG}";;
s) SdkPath="${OPTARG}";;
m) ModuleName="${OPTARG}";;
v) Version="${OPTARG}";;
h) usage && exit 1;;
esac
done
Expand All @@ -40,8 +43,8 @@ GetVersion()
Version=${array[2]}
}

Version=0.0
GetVersion

# GetVersion
ReleaseName=firebolt-${ModuleName}-native-sdk-${Version}
ReleasePath=${InstallPath}/${ReleaseName}

Expand Down
4 changes: 2 additions & 2 deletions src/macrofier/types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ const insertEnumMacros = (content, schema, module, name, suffix, templateDir = "
if (!value) {
value = getTemplate(path.join(templateDir, 'unset' + suffix))
}
value ? values.push(template[i].replace(/\$\{key\}/g, getSafeEnumKeyName(value))
value ? values.push(template[i].replace(/\$\{key\}/g, getSafeEnumKeyName(value, schema.enumKeyPrefix))
.replace(/\$\{value\}/g, value)) : ''
})
template[i] = values.map((value, id) => {
Expand Down Expand Up @@ -360,7 +360,7 @@ const insertObjectMacros = (content, schema, module, title, property, options) =
.replace(/\$\{if\.base\.optional\}(.*?)\$\{end\.if\.base\.optional\}/gms, options.required ? '' : '$1')
.replace(/\$\{if\.non\.object\}(.*?)\$\{end\.if\.non\.object\}/gms, isObject(localizedProp) ? '' : '$1')
.replace(/\$\{if\.non\.array\}(.*?)\$\{end\.if\.non\.array\}/gms, (localizedProp.type === 'array') ? '' : '$1')
.replace(/\$\{if\.non\.anyOf\}(.*?)\$\{end\.if\.non\.anyOf\}/gms, (localizedProp.anyOf || localizedProp.anyOneOf) ? '' : '$1')
.replace(/\$\{if\.non\.anyOf\}(.*?)\$\{end\.if\.non\.anyOf\}/gms, (localizedProp.anyOf || localizedProp.oneOf) ? '' : '$1')
.replace(/\$\{if\.non\.const\}(.*?)\$\{end\.if\.non\.const\}/gms, (typeof localizedProp.const === 'string') ? '' : '$1')
let baseTitle = options.property

Expand Down
19 changes: 13 additions & 6 deletions src/shared/json-schema.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,19 @@ function mergeOneOf(schema) {
return union(schema.oneOf)
}

const getSafeEnumKeyName = (value) => value.split(':').pop() // use last portion of urn:style:values
.replace(/[\.\-]/g, '_') // replace dots and dashes
.replace(/\+/g, '_plus') // change + to _plus
.replace(/([a-z])([A-Z0-9])/g, '$1_$2') // camel -> snake case
.replace(/^([0-9]+(\.[0-9]+)?)/, 'v$1') // insert `v` in front of things that look like version numbers
.toUpperCase()
const getSafeEnumKeyName = function(value, keyPrefix = '') {
if (keyPrefix != '') {
value = keyPrefix + '_' + value
}

let key = value.split(':').pop() // use last portion of urn:style:values
.replace(/\+/g, '_plus') // change + to _plus
.replace(/[\.\-\/\;]/g, '_') // replace special characters
.replace(/([a-z])([A-Z0-9])/g, '$1_$2') // camel -> snake case
.replace(/^([0-9]+\_([0-9]+)?)/, 'v$1') // insert `v` in front of things that look like version numbers

return key.toUpperCase()
}

export {
getSchemaConstraints,
Expand Down
2 changes: 1 addition & 1 deletion src/validate/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const run = async ({

addFormats(ajv)
// explicitly add our custom extensions so we can keep strict mode on (TODO: put these in a JSON config?)
ajv.addVocabulary(['x-method', 'x-this-param', 'x-additional-params', 'x-schemas', 'components', 'x-property'])
ajv.addVocabulary(['x-method', 'x-this-param', 'x-additional-params', 'x-schemas', 'components', 'x-property', 'enumKeyPrefix'])

const firebolt = ajv.compile(fireboltOpenRpcSpec)
const jsonschema = ajv.compile(jsonSchemaSpec)
Expand Down
Loading