Skip to content

Commit

Permalink
Merge branch 'main' into vite_ESM_upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
yurishkuro authored Nov 25, 2023
2 parents e28f297 + 72106e4 commit 75ad7d4
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 25 deletions.
6 changes: 3 additions & 3 deletions packages/jaeger-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@testing-library/react": "^14.0.0",
"@types/react": "^18.2.33",
"@types/react-window": "^1.8.0",
"@types/redux-form": "^8.3.5",
"@types/redux-form": "^8.3.10",
"@types/rollup-plugin-visualizer": "^4.2.1",
"@vitejs/plugin-legacy": "^5.0.0",
"@vitejs/plugin-react": "^4.0.0",
Expand Down Expand Up @@ -84,10 +84,10 @@
"react-json-view-lite": "1.2.0",
"react-redux": "^8.1.2",
"react-router-dom": "5.3.4",
"react-router-dom-v5-compat": "^6.18.0",
"react-router-dom-v5-compat": "^6.20.0",
"react-vis": "^1.7.2",
"react-vis-force": "^0.3.1",
"react-window": "^1.8.3",
"react-window": "^1.8.10",
"redux": "^4.2.1",
"redux-actions": "2.6.5",
"redux-first-history": "^5.1.1",
Expand Down
144 changes: 144 additions & 0 deletions scripts/get-tracking-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
#!/usr/bin/env node

// Copyright (c) 2023 The Jaeger Authors
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This script is run during the build and generates strings used to identify
// the application to Google Analytics tracking (or any tracking).
//
// See the comment on `getVersion(..)` function below for details.
// See also packages/jaeger-ui/src/utils/tracking/README.md

/* eslint-disable @typescript-eslint/no-var-requires */
const spawnSync = require('child_process').spawnSync;

const version = require('../package.json').version;

function cleanRemoteUrl(url) {
return url.replace(/^(.*?@|.*?\/\/)|\.git\s*$/gi, '').replace(/:/g, '/');
}

function cleanBranchNames(pointsAt) {
const branch = pointsAt.replace(/"/g, '').split('\n')[0];
const i = branch.indexOf(' ');
const objName = branch.slice(0, i);
let refName = branch.slice(i + 1);
if (refName.indexOf('detached') > -1) {
refName = '(detached)';
}
return { objName, refName };
}

function getChanged(shortstat, status) {
const rv = { hasChanged: false, files: 0, insertions: 0, deletions: 0, untracked: 0 };
const joiner = [];
const regex = /(\d+) (.)/g;
let match = regex.exec(shortstat);
while (match) {
const [, n, type] = match;
switch (type) {
case 'f':
rv.files = Number(n);
joiner.push(`${n}f`);
break;
case 'i':
rv.insertions = Number(n);
joiner.push(`+${n}`);
break;
case 'd':
rv.deletions = Number(n);
joiner.push(`-${n}`);
break;
default:
throw new Error(`Invalid diff type: ${type}`);
}
match = regex.exec(shortstat);
}
const untracked = status && status.split('\n').filter(line => line[0] === '?').length;
if (untracked) {
rv.untracked = untracked;
joiner.push(`${untracked}?`);
}
rv.pretty = joiner.join(' ');
rv.hasChanged = Boolean(joiner.length);
return rv;
}

// This util function, which can be used via the CLI or as a module, outputs
// a JSON blob indicating the git state of a repo. It defaults to checking the
// repo at ".", but accepts a working directory.
//
// The output is along the lines of the following:
//
// {
// "version": "0.0.1",
// "remote": "github.com/jaegertracing/jaeger-ui",
// "objName": "64fbc13",
// "changed": {
// "hasChanged": true,
// "files": 1,
// "insertions": 21,
// "deletions": 0,
// "untracked": 0,
// "pretty": "1f +21"
// },
// "refName": "issue-39-track-js-errors",
// "pretty": "0.0.1 | github.com/jaegertracing/jaeger-ui | 64fbc13 | 1f +21 | issue-39-track-js-errors"
// }
//
// * version: The package.json version
// * remote: The git remote URL (normalized)
// * objName: The short SHA
// * changed: Indicates any changes in the repo
// * changed.pretty: formatted as "2f +3 -4 5?", which indicates two modified
// files having three insertions, 4 deletions, and 5 untracked files
// * refName: The name of the current branch, "(detached)" when the head is detached
// * pretty: A human-readable representation of the above fields
function getVersion(cwd) {
const opts = { cwd, encoding: 'utf8' };
const url = spawnSync('git', ['remote', 'get-url', '--push', 'origin'], opts).stdout;
const branch = spawnSync(
'git',
['branch', '--points-at', 'HEAD', '--format="%(objectname:short) %(refname:short)"'],
opts
).stdout;
const shortstat = spawnSync('git', ['diff-index', '--shortstat', 'HEAD'], opts).stdout;
const status = spawnSync('git', ['status', '--porcelain', '-uall'], opts).stdout;

const { objName, refName } = cleanBranchNames(branch);
const remote = cleanRemoteUrl(url);
const joiner = [version, remote, objName];
const changed = getChanged(shortstat, status);
if (changed.hasChanged) {
joiner.push(changed.pretty);
}
joiner.push(refName);
const rv = {
version,
remote,
objName,
changed,
refName,
pretty: joiner.join(' | '),
};
return rv;
}

if (require.main === module) {
const vsn = getVersion(process.argv[2] || '.');
process.stdout.write(JSON.stringify(vsn));
} else {
module.exports = getVersion;
}
44 changes: 22 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1847,10 +1847,10 @@
rc-resize-observer "^1.3.1"
rc-util "^5.38.0"

"@remix-run/router@1.12.0":
version "1.12.0"
resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.12.0.tgz#e89b64b6fa97a8a5b740a4c38c2904b80f1f229a"
integrity sha512-2hXv036Bux90e1GXTWSMfNzfDDK8LA8JYEWfyHxzvwdp6GyoWEovKc9cotb3KCKmkdwsIBuFGX7ScTWyiHv7Eg==
"@remix-run/router@1.13.0":
version "1.13.0"
resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.13.0.tgz#7e29c4ee85176d9c08cb0f4456bff74d092c5065"
integrity sha512-5dMOnVnefRsl4uRnAdoWjtVTdh8e6aZqgM4puy9nmEADH72ck+uXwzpJLEKE9Q6F8ZljNewLgmTfkxUrBdv4WA==

"@rollup/[email protected]":
version "4.4.1"
Expand Down Expand Up @@ -2330,10 +2330,10 @@
version "2.2.1"
resolved "https://registry.yarnpkg.com/@types/redux-actions/-/redux-actions-2.2.1.tgz#c1f4a7283ecd3cd696291550361e441bf9389370"

"@types/redux-form@^8.3.5":
version "8.3.9"
resolved "https://registry.yarnpkg.com/@types/redux-form/-/redux-form-8.3.9.tgz#b3677de9f24dbbd1103ffcea0938d75d281ba7d8"
integrity sha512-ajjKokq4tyxoS7PYn8ZzUtMPnf3gYgypqy67T/hxFmNNcUFYhCypUn5wqblhPYcrUjOVbFWw+wZDbYh5jt5Jag==
"@types/redux-form@^8.3.10":
version "8.3.10"
resolved "https://registry.yarnpkg.com/@types/redux-form/-/redux-form-8.3.10.tgz#7d07fdcee7b9cb107852daa9de74c2594acc15b3"
integrity sha512-LExE1Ql/PY4zjjDd6otptJ/ymwCNdEJAvcXpD+cWzhHR1QZhimo8p1DIrJoAMzn3KmEC5fgaH6PNdWhCPqHJnw==
dependencies:
"@types/react" "*"
redux "^3.6.0 || ^4.0.0"
Expand Down Expand Up @@ -8552,13 +8552,13 @@ react-refresh@^0.14.0:
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.0.tgz#4e02825378a5f227079554d4284889354e5f553e"
integrity sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==

react-router-dom-v5-compat@^6.18.0:
version "6.19.0"
resolved "https://registry.yarnpkg.com/react-router-dom-v5-compat/-/react-router-dom-v5-compat-6.19.0.tgz#8406f8ff57c5b73a18fc9dd41a07b3cc88ad0e59"
integrity sha512-TYYtkIlbtWUFzWwbCd5v88CkasBu822kSyP2rNz0xjihA7aSHH/cUb9a5jkzHFBDR9o4ojl7Q1TXkHNj3HTR7A==
react-router-dom-v5-compat@^6.20.0:
version "6.20.0"
resolved "https://registry.yarnpkg.com/react-router-dom-v5-compat/-/react-router-dom-v5-compat-6.20.0.tgz#9241b7ea0856af16b88371619bea518f8fd2e359"
integrity sha512-13xJxgmDmmCZwxVxTNJkxrlDtuNiNPNWNYuJO6CMqHloqjSzi+Xaq2dy9ZknS71NNvOHwzOmcF4rPK6fv0B4+Q==
dependencies:
history "^5.3.0"
react-router "6.19.0"
react-router "6.20.0"

[email protected]:
version "5.3.4"
Expand Down Expand Up @@ -8588,12 +8588,12 @@ [email protected]:
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"

react-router@6.19.0:
version "6.19.0"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.19.0.tgz#6d5062fa33495859daca98d86292ab03b037a9ca"
integrity sha512-0W63PKCZ7+OuQd7Tm+RbkI8kCLmn4GPjDbX61tWljPxWgqTKlEpeQUwPkT1DRjYhF8KSihK0hQpmhU4uxVMcdw==
react-router@6.20.0:
version "6.20.0"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.20.0.tgz#4275a3567ecc55f7703073158048db10096bb539"
integrity sha512-pVvzsSsgUxxtuNfTHC4IxjATs10UaAtvLGVSA1tbUE4GDaOSU1Esu2xF5nWLz7KPiMuW8BJWuPFdlGYJ7/rW0w==
dependencies:
"@remix-run/router" "1.12.0"
"@remix-run/router" "1.13.0"

react-shallow-renderer@^16.13.1, react-shallow-renderer@^16.15.0:
version "16.15.0"
Expand Down Expand Up @@ -8660,10 +8660,10 @@ react-vis@^1.7.2:
prop-types "^15.5.8"
react-motion "^0.5.2"

react-window@^1.8.3:
version "1.8.9"
resolved "https://registry.yarnpkg.com/react-window/-/react-window-1.8.9.tgz#24bc346be73d0468cdf91998aac94e32bc7fa6a8"
integrity sha512-+Eqx/fj1Aa5WnhRfj9dJg4VYATGwIUP2ItwItiJ6zboKWA6EX3lYDAXfGF2hyNqplEprhbtjbipiADEcwQ823Q==
react-window@^1.8.10:
version "1.8.10"
resolved "https://registry.yarnpkg.com/react-window/-/react-window-1.8.10.tgz#9e6b08548316814b443f7002b1cf8fd3a1bdde03"
integrity sha512-Y0Cx+dnU6NLa5/EvoHukUD0BklJ8qITCtVEPY1C/nL8wwoZ0b5aEw8Ff1dOVHw7fCzMt55XfJDd8S8W8LCaUCg==
dependencies:
"@babel/runtime" "^7.0.0"
memoize-one ">=3.1.1 <6"
Expand Down

0 comments on commit 75ad7d4

Please sign in to comment.