Skip to content

Commit

Permalink
ci: refactor beta-release.json to use import instead of require
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbarion committed May 8, 2024
1 parent adf57df commit 31a26d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
20 changes: 12 additions & 8 deletions beta-release.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const util = require('util')
const exec = util.promisify(require('child_process').exec)
const packageJson = require('./package.json')
import util from 'util'
import { exec as execCallback } from 'child_process'
import minimist from 'minimist'
import pkg from './package.json' assert { type: 'json' }

const args = require('minimist')(process.argv.slice(2))
const exec = util.promisify(execCallback)

const args = minimist(process.argv.slice(2))

console.log({ args })

const issueNumber = args['issue']

console.log(issueNumber)
console.log({ issueNumber })

const runCommand = async (command) => {
return new Promise((resolve) => {
Expand All @@ -26,7 +30,7 @@ const AutoBetaRelease = async () => {

// check if there is a beta release with the same issue number on published versions
const arrayOfBetaReleases = JSON.parse(stdout).filter((version) =>
version.includes(`${packageJson.version}-beta.${issueNumber}`),
version.includes(`${pkg.version}-beta.${issueNumber}`),
)

let fullLastBetaRelease = null
Expand Down Expand Up @@ -56,7 +60,7 @@ const AutoBetaRelease = async () => {
}

// next beta release version. Output: 1.0.0-beta.1.rc.1
const nextBetaReleaseVesionFull = `${packageJson.version}-beta.${issueNumber}.rc.${nextBetaReleaseVersion}`
const nextBetaReleaseVesionFull = `${pkg.version}-beta.${issueNumber}.rc.${nextBetaReleaseVersion}`

// update the beta version on packageJson.json
const { error } = await runCommand(
Expand Down
17 changes: 10 additions & 7 deletions src/components/TooltipController/TooltipController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,16 @@ const TooltipController = React.forwardRef<TooltipRefProps, ITooltipController>(
const styleInjectionRef = useRef(disableStyleInjection)

const getDataAttributesFromAnchorElement = (elementReference: HTMLElement) => {
const dataAttributes = elementReference?.getAttributeNames().reduce((acc, name) => {
if (name.startsWith('data-tooltip-')) {
const parsedAttribute = name.replace(/^data-tooltip-/, '') as DataAttribute
acc[parsedAttribute] = elementReference?.getAttribute(name) ?? null
}
return acc
}, {} as Record<DataAttribute, string | null>)
const dataAttributes = elementReference?.getAttributeNames().reduce(
(acc, name) => {
if (name.startsWith('data-tooltip-')) {
const parsedAttribute = name.replace(/^data-tooltip-/, '') as DataAttribute
acc[parsedAttribute] = elementReference?.getAttribute(name) ?? null
}
return acc
},
{} as Record<DataAttribute, string | null>,
)

return dataAttributes
}
Expand Down

0 comments on commit 31a26d0

Please sign in to comment.