Skip to content

Commit

Permalink
automatically update version number on build (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
lochie authored Jul 19, 2023
1 parent 17a076b commit 451230e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
18 changes: 18 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* This script is used to copy over the version number in the package.json to
* the CONNECTKIT_VERSION constant in the index.ts file. This is done to
* ensure that the version number attribute on the ConnectKit wrapper is always
* up to date with the version number in the package.json file.
*/

const fs = require('fs');
const config = require('./packages/connectkit/package.json');

const file = fs.readFileSync('packages/connectkit/src/index.ts', 'utf8');
const lines = file.split('\n');
const versionLine = lines.findIndex((line) =>
line.includes('export const CONNECTKIT_VERSION = ')
);
lines[versionLine] = `export const CONNECTKIT_VERSION = '${config.version}';`;

fs.writeFileSync('packages/connectkit/src/index.ts', lines.join('\n'), 'utf8');
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dev:nextjs-siwe": "yarn workspace nextjs-siwe run dev",
"dev:vite": "yarn workspace vite run dev",
"dev:testbench": "yarn workspace testbench run dev",
"build": "yarn workspace connectkit run build && cp README.md packages/connectkit/README.md",
"build": "node build.js && yarn workspace connectkit run build && cp README.md packages/connectkit/README.md",
"build:connectkit-next-siwe": "yarn workspace connectkit-next-siwe run build",
"build:cra": "yarn build && yarn workspace cra build",
"build:nextjs": "yarn build && yarn workspace nextjs build",
Expand Down
2 changes: 1 addition & 1 deletion packages/connectkit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "connectkit",
"version": "1.4.0",
"version": "1.5.0",
"author": "Family",
"homepage": "https://docs.family.co/connectkit",
"license": "BSD-2-Clause license",
Expand Down
3 changes: 2 additions & 1 deletion packages/connectkit/src/components/Common/Portal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useState, useRef } from 'react';
import { createPortal } from 'react-dom';
import { CONNECTKIT_VERSION } from '../../..';

const Portal = (props: any) => {
props = {
Expand All @@ -19,7 +20,7 @@ const Portal = (props: any) => {
if (!ref.current) {
const div = document.createElement('div');
div.setAttribute('id', selector);
div.setAttribute('data-connectkit', '1.4.0');
div.setAttribute('data-connectkit', `${CONNECTKIT_VERSION}`);
document.body.appendChild(div);
ref.current = div;
}
Expand Down
7 changes: 3 additions & 4 deletions packages/connectkit/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
export const CONNECTKIT_VERSION = '1.5.0';

export * as Types from './types';
export { default as getDefaultConfig } from './defaultConfig';

export { useModal } from './hooks/useModal';
export { SIWEProvider, useSIWE } from './siwe';
export type { SIWESession, SIWEConfig } from './siwe';

export {
ConnectKitProvider,
Context,
} from './components/ConnectKit';
export { ConnectKitProvider, Context } from './components/ConnectKit';
export { ConnectKitButton } from './components/ConnectButton';
export { default as SIWEButton } from './components/Standard/SIWE';

Expand Down

4 comments on commit 451230e

@vercel
Copy link

@vercel vercel bot commented on 451230e Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

connectkit-cra – ./

connectkit-cra.vercel.app
connectkit-cra-git-main-lfe.vercel.app
connectkit-cra-lfe.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 451230e Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

connectkit-nextjs – ./

connectkit-nextjs-git-main-lfe.vercel.app
connectkit-nextjs.vercel.app
connectkit-nextjs-lfe.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 451230e Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

connectkit-vite – ./

connectkit-vite-git-main-lfe.vercel.app
connectkit-vite-lfe.vercel.app
connectkit-vite.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 451230e Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

connectkit-testbench – ./

connectkit-testbench-lfe.vercel.app
connectkit-testbench.vercel.app
connectkit-testbench-git-main-lfe.vercel.app

Please sign in to comment.