Skip to content

Commit

Permalink
initial impl (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
syvlabs authored Oct 4, 2024
1 parent a0c8fb9 commit 6ebd0c3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/alpha-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
run: |
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "VERSION=$(npm view ./ version)" >> $GITHUB_ENV
echo "RELEASE_VERSION=$VERSION-alpha.$COMMIT_HASH" >> $GITHUB_ENV
- name: Build package
run: |
Expand All @@ -32,7 +33,7 @@ jobs:
- name: Publish package
run: |
npm version ${{ env.VERSION }}-alpha.${{ env.COMMIT_HASH }} --no-git-tag-version
npm version ${{ env.RELEASE_VERSION }} --no-git-tag-version
npm publish --tag alpha --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,18 @@ jobs:
- name: Publish package (alpha)
if: 'github.event.release.prerelease'
run: |
RELEASE_VERSION=${{ github.ref_name }}
npm run build:alpha
echo "Tag name from github.ref_name: ${{ github.ref_name }}"
npm version ${{ github.ref_name }} --no-git-tag-version
npm version $RELEASE_VERSION --no-git-tag-version
npm publish --tag alpha --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

- name: Publish package (stable)
if: '!github.event.release.prerelease'
run: |
RELEASE_VERSION=$(npm view ./ version)
npm run build
npm publish --access public
env:
Expand Down
7 changes: 7 additions & 0 deletions lib/components/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ const ElementsForm: FC<ElementsFormProps> = (props) => {
const formId = useMemo(() => `opjs-form-${uuidv4()}`, []);
const formRef = useRef<HTMLDivElement | null>(null);

useEffect(() => {
const ojs_version = { version: __APP_VERSION__, release_version: __RELEASE_VERSION__ };
// @ts-expect-error window typing
window['ojs_version'] = ojs_version;
console.log('OJS version:', ojs_version);
}, []);

const { cdeConn, connectToCdeIframe } = useCDEConnection();
const dynamicPreview = useDynamicPreview(
enableDynamicPreviews ?? false,
Expand Down
4 changes: 0 additions & 4 deletions lib/hooks/use-payment-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ export const usePaymentRequests = (
return;
}

// @ts-expect-error window typing
window['ojs_version'] = __APP_VERSION__;
console.log('OJS version', __APP_VERSION__);

const stripeCpm = availableCPMs.find(
(cpm) =>
cpm.processor_name === 'stripe' && PaymentRequestProvider.options.map((s) => String(s)).includes(cpm.provider)
Expand Down
1 change: 1 addition & 0 deletions lib/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// <reference types="vite/client" />

declare const __APP_VERSION__: string;
declare const __RELEASE_VERSION__: string;
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ export default defineConfig({
],
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
__RELEASE_VERSION__: JSON.stringify(process.env.RELEASE_VERSION ?? 'local_build'),
},
});

0 comments on commit 6ebd0c3

Please sign in to comment.