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

versioning support for Fides #5435

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions clients/admin-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "admin-ui",
"private": true,
"version": "2.48.0",
"scripts": {
"analyze": "cross-env ANALYZE=true next build",
"analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build",
Expand All @@ -26,7 +27,8 @@
"start": "next start",
"test": "jest --watchAll",
"test:ci": "npm run typecheck && jest",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"version": "npm version --allow-same-version=true --no-git-tag-version"
},
"dependencies": {
"@ant-design/cssinjs": "^1.21.0",
Expand All @@ -44,7 +46,7 @@
"date-fns": "^4.1.0",
"date-fns-tz": "^3.2.0",
"eslint-plugin-tailwindcss": "^3.17.4",
"fides-js": "^0.0.1",
"fides-js": "^2",
"fidesui": "*",
"file-saver": "^2.0.5",
"formik": "^2.4.6",
Expand Down
9 changes: 9 additions & 0 deletions clients/fides-js/docs/interfaces/Fides.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,12 @@ preferences) or in the case when the previous consent is no longer valid.
#### Returns

`boolean`

***

### version?

> `optional` **version**: `string`

Returns the current version of FidesJS. This can be useful for debugging
purposes, or for checking the version of FidesJS that is currently running.
6 changes: 4 additions & 2 deletions clients/fides-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fides-js",
"version": "0.0.1",
"version": "2.48.0",
"description": "FidesJS: JavaScript SDK for Fides",
"license": "Apache-2.0",
"main": "./dist/fides.js",
Expand All @@ -23,7 +23,8 @@
"lint:fix": "eslint . --fix",
"test": "jest --watchAll",
"test:ci": "jest",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"version": "npm version --allow-same-version=true --no-git-tag-version"
},
"repository": {
"type": "git",
Expand All @@ -45,6 +46,7 @@
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^6.0.1",
"@rollup/plugin-strip": "^3.0.4",
"@types/base-64": "^1.0.2",
"@types/jest": "^29.5.12",
Expand Down
20 changes: 20 additions & 0 deletions clients/fides-js/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import postcss from "rollup-plugin-postcss";
import commonjs from "@rollup/plugin-commonjs";
import { visualizer } from "rollup-plugin-visualizer";
import strip from "@rollup/plugin-strip";
import replace from "@rollup/plugin-replace";
import pkg from "./package.json" assert { type: "json" };

const NAME = "fides";
const IS_DEV = process.env.NODE_ENV === "development";
Expand All @@ -19,6 +21,19 @@ const GZIP_SIZE_WARN_KB = 35; // log a warning if bundle size exceeds this
const GZIP_SIZE_TCF_ERROR_KB = 85.5;
const GZIP_SIZE_TCF_WARN_KB = 75;

let PACKAGE_VERSION = "0.0.0";
try {
PACKAGE_VERSION = pkg.version;
if (!PACKAGE_VERSION) {
throw new Error("No version found in package.json");
}
console.log(
`Starting FidesJS build and tagging with current version (Fides.version=${PACKAGE_VERSION})...`,
);
} catch (e) {
console.error("🚨 Failed to get package version, defaulting to 0.0.0");
}

const preactAliases = {
entries: [
{ find: "react", replacement: "preact/compat" },
Expand Down Expand Up @@ -93,6 +108,11 @@ const fidesScriptPlugins = ({ name, gzipWarnSizeKb, gzipErrorSizeKb }) => [
visualizer({
filename: `bundle-size-stats/${name}-stats.html`,
}),
replace({
__FIDES_JS_VERSION_NUMBER__: PACKAGE_VERSION,
preventAssignment: true,
include: ["src/fides.ts", "src/fides-tcf.ts"],
}),
];

const SCRIPTS = [
Expand Down
6 changes: 6 additions & 0 deletions clients/fides-js/src/docs/fides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ export interface Fides {
*/
shouldShowExperience: () => boolean;

/**
* Returns the current version of FidesJS. This can be useful for debugging
* purposes, or for checking the version of FidesJS that is currently running.
*/
version?: string;

/**
* NOTE: The properties below are all marked @internal, despite being exported
* on the global Fides object. This is because they are mostly implementation
Expand Down
1 change: 1 addition & 0 deletions clients/fides-js/src/fides-tcf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ declare global {
const updateWindowFides = (fidesGlobal: FidesGlobal) => {
if (typeof window !== "undefined") {
window.Fides = fidesGlobal;
window.Fides.version = "__FIDES_JS_VERSION_NUMBER__";
}
};

Expand Down
1 change: 1 addition & 0 deletions clients/fides-js/src/fides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ declare global {
const updateWindowFides = (fidesGlobal: FidesGlobal) => {
if (typeof window !== "undefined") {
window.Fides = fidesGlobal;
window.Fides.version = "__FIDES_JS_VERSION_NUMBER__";
}
};

Expand Down
32 changes: 28 additions & 4 deletions clients/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions clients/privacy-center/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "privacy-center",
"version": "2.13.0",
"version": "2.48.0",
"private": true,
"scripts": {
"dev": "next dev -p 3001",
Expand All @@ -22,7 +22,8 @@
"analyze": "cross-env ANALYZE=true next build",
"analyze:server": "cross-env BUNDLE_ANALYZE=server next build",
"analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build",
"openapi:generate": "openapi --input http://localhost:8080/openapi.json --output ./types/api --exportCore false --exportServices false --indent 2 && prettier --write ."
"openapi:generate": "openapi --input http://localhost:8080/openapi.json --output ./types/api --exportCore false --exportServices false --indent 2 && prettier --write .",
"version": "npm version --allow-same-version=true --no-git-tag-version"
},
"dependencies": {
"@emotion/react": "^11.10.6",
Expand All @@ -32,7 +33,7 @@
"@reduxjs/toolkit": "^1.9.3",
"@types/react-dom": "^18.3.0",
"cache-control-parser": "^2.0.4",
"fides-js": "*",
"fides-js": "^2",
"fidesui": "*",
"formik": "^2.2.9",
"framer-motion": "^11.2.12",
Expand Down
16 changes: 16 additions & 0 deletions clients/privacy-center/pages/api/health.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable jsdoc/no-missing-syntax */
import * as fidesJSPackage from "fides-js/package.json";
import { NextApiRequest, NextApiResponse } from "next";

import * as privacyCenterPackage from "../../package.json";

export default function handler(req: NextApiRequest, res: NextApiResponse) {
try {
res.status(200).json({
core_fides_version: fidesJSPackage.version,
privacy_center_version: privacyCenterPackage.version,
});
} catch (error) {
res.status(500).json({ error: "failed to get health check" });
}
}
3 changes: 3 additions & 0 deletions clients/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
},
"openapi:generate-dictionary": {
"dependsOn": []
},
"version": {
"dependsOn": []
}
}
}
Loading