Skip to content

Commit

Permalink
Pack Chakra theme into NPM package (#2115)
Browse files Browse the repository at this point in the history
* build package

* update version

* fix name collision

* add workflow
  • Loading branch information
tom2drum authored Aug 12, 2024
1 parent 45b93c5 commit 2fb9169
Show file tree
Hide file tree
Showing 14 changed files with 2,810 additions and 6 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/chakra-npm-publisher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish Chakra theme package to NPM

on:
workflow_dispatch:
inputs:
version:
description: Package version
type: string
required: true
workflow_call:
inputs:
version:
description: Package version
type: string
required: true

jobs:
publish:
runs-on: ubuntu-latest
name: Publish package to NPM registry
permissions:
id-token: write

steps:
- name: Checkout repo
uses: actions/checkout@v4

# Also it will setup .npmrc file to publish to npm
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Update package version
run: |
cd ./theme
npm version ${{ inputs.version }}
- name: Build the package
run: |
cd ./theme
yarn
yarn build
- name: Publish to NPM registry
run: |
cd ./theme
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 1 addition & 1 deletion configs/app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const replaceQuotes = (value: string | undefined) => value?.replaceAll('\

export const getEnvValue = (envName: string) => {
// eslint-disable-next-line no-restricted-properties
const envs = isBrowser() ? window.__envs : process.env;
const envs = (isBrowser() ? window.__envs : process.env) ?? {};

if (isBrowser() && envs.NEXT_PUBLIC_APP_INSTANCE === 'pw') {
const storageValue = localStorage.getItem(envName);
Expand Down
2 changes: 1 addition & 1 deletion jest/lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React from 'react';
import { AppContextProvider } from 'lib/contexts/app';
import { ScrollDirectionProvider } from 'lib/contexts/scrollDirection';
import { SocketProvider } from 'lib/socket/context';
import theme from 'theme';
import theme from 'theme/theme';

import 'lib/setLocale';

Expand Down
2 changes: 1 addition & 1 deletion lib/contexts/chakra.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import type { ChakraProviderProps } from '@chakra-ui/react';
import React from 'react';

import theme from 'theme';
import theme from 'theme/theme';

interface Props extends ChakraProviderProps {
cookies?: string;
Expand Down
2 changes: 1 addition & 1 deletion pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React from 'react';
import logRequestFromBot from 'nextjs/utils/logRequestFromBot';
import * as serverTiming from 'nextjs/utils/serverTiming';

import theme from 'theme';
import theme from 'theme/theme';
import * as svgSprite from 'ui/shared/IconSvg';

class MyDocument extends Document {
Expand Down
2 changes: 1 addition & 1 deletion playwright/TestApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import config from 'configs/app';
import { AppContextProvider } from 'lib/contexts/app';
import { SocketProvider } from 'lib/socket/context';
import currentChain from 'lib/web3/currentChain';
import theme from 'theme';
import theme from 'theme/theme';

import { port as socketPort } from './utils/socket';

Expand Down
2 changes: 2 additions & 0 deletions theme/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/dist
Loading

0 comments on commit 2fb9169

Please sign in to comment.