Skip to content

Commit

Permalink
consolidates version.ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
dmihalcik-virtru committed Jan 16, 2025
1 parent 309939b commit fb7c2ea
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 29 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/publish-to.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ v="${1%%+*}"
t="${2}"

cd lib
for f in {,tdf3/}src/version.ts; do
if ! sed "s/export const version = \'[^']\{1,\}\';\$/export const version = \'${v}\';/" "${f}" >"${f}.tmp"; then
echo "Failed to insert version [${v}] into file [$f]"
exit 1
fi
mv "${f}.tmp" "${f}"
done
f=src/version.ts
if ! sed "s/export const version = \'[^']\{1,\}\';\$/export const version = \'${v}\';/" "${f}" >"${f}.tmp"; then
echo "Failed to insert version [${v}] into file [$f]"
exit 1
fi
mv "${f}.tmp" "${f}"

npm version --no-git-tag-version --allow-same-version "$v"
npm publish --access public --tag "$t"

Expand Down
3 changes: 3 additions & 0 deletions lib/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export const version = '0.2.0';
*/
export const clientType = 'web-sdk';

/**
* Version of the opentdf/spec this library is targeting
*/
export const tdfSpecVersion = '4.3.0';
2 changes: 1 addition & 1 deletion lib/tdf3/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * as Client from './client/index.js';
export { Client as TDF3Client } from './client/index.js';
export * as Errors from '../../src/errors.js';
export { version, clientType } from './version.js';
export { clientType, tdfSpecVersion, version } from '../../src/version.js';
4 changes: 2 additions & 2 deletions lib/tdf3/src/tdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DecoratedReadableStream } from './client/DecoratedReadableStream.js';
import { fetchKasPubKey as fetchKasPubKeyV2, fetchWrappedKey } from '../../src/access.js';
import { DecryptParams } from './client/builders.js';
import { AssertionConfig, AssertionKey, AssertionVerificationKeys } from './assertions.js';
import { version } from './version.js';
import { tdfSpecVersion } from '../../src/version.js';
import { hex } from '../../src/encodings/index.js';
import * as assertions from './assertions.js';

Expand Down Expand Up @@ -271,7 +271,7 @@ async function _generateManifest(
// generate the manifest first, then insert integrity information into it
encryptionInformation: encryptionInformationStr,
assertions: assertions,
tdf_spec_version: version,
tdf_spec_version: tdfSpecVersion,
};
}

Expand Down
2 changes: 0 additions & 2 deletions lib/tdf3/src/version.ts

This file was deleted.

7 changes: 1 addition & 6 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ if ! sed_i "s/version=${old_version}/version=${new_version}/" "Makefile"; then
exit 1
fi

if ! sed_i "s/export const version = '[^']\{1,\}';\$/export const version = \'${new_version}\';/" lib{,/tdf3}/src/version.ts; then
echo "Unable to change version in version files"
exit 1
fi

if ! sed_i "s/export const version = '[^']\{1,\}';\$/export const version = \'${new_version}\';/" lib{,/tdf3}/src/version.ts; then
if ! sed_i "s/export const version = '[^']\{1,\}';\$/export const version = \'${new_version}\';/" lib/src/version.ts; then
echo "Unable to change version in version files"
exit 1
fi
Expand Down
19 changes: 9 additions & 10 deletions scripts/check-version-is.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ if ! grep --fixed-strings --line-regexp --quiet "version=${expected_version}" "M
exit 1
fi

for f in lib{,/tdf3}/src/version.ts; do
if ! grep --fixed-strings --line-regexp --quiet "export const version = '${expected_version}';" "$f"; then
if grep --quiet "^export const version" "$f"; then
echo "::error file=$f,line=$(sed -n '/export const version/=' $f)::Incorrect version line, should be setting it to [${expected_version}]"
else
echo "::error file=$f::Missing version line [version=${expected_version}]"
fi
exit 1
f=lib/src/version.ts
if ! grep --fixed-strings --line-regexp --quiet "export const version = '${expected_version}';" "$f"; then
if grep --quiet "^export const version" "$f"; then
echo "::error file=$f,line=$(sed -n '/export const version/=' $f)::Incorrect version line, should be setting it to [${expected_version}]"
else
echo "::error file=$f::Missing version line [version=${expected_version}]"
fi
done
exit 1
fi

for x in lib cli web-app; do
sub_version="$(cd $x && node -p "require('./package.json').version")"
Expand All @@ -36,7 +35,7 @@ for x in lib cli web-app; do
done

if [[ "${GITHUB_ACTION:-}" ]]; then
echo "TARGET_VERSION=$expected_version" >>$GITHUB_OUTPUT
echo "TARGET_VERSION=$expected_version" >>"$GITHUB_OUTPUT"
else
echo "SUCCESS: TARGET_VERSION=$expected_version"
fi
2 changes: 1 addition & 1 deletion scripts/platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ if [ $? -ne 0 ]; then
npm install @bufbuild/protoc-gen-es @bufbuild/buf @connectrpc/protoc-gen-connect-es
fi
npx buf generate platform/service
echo "Generated Typescript code from Protobuf files (src: platform/service, dst: lib/src/platform)"
echo "Generated Typescript code from Protobuf files (src: platform/service, dst: lib/src/platform)"

0 comments on commit fb7c2ea

Please sign in to comment.