diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index 080c587..e458c4b 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -13,13 +13,15 @@ jobs:
env:
WORKING_DIRECTORY: ./
steps:
- - uses: actions/checkout@v4.2.2
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
- name: Setup Node.js
- uses: actions/setup-node@v4.1.0
+ uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
- node-version: 20.19.4
- cache: "yarn"
- cache-dependency-path: "${{ env.WORKING_DIRECTORY }}/yarn.lock"
+ node-version-file: '.nvmrc'
+ cache: 'yarn'
+ cache-dependency-path: '${{ env.WORKING_DIRECTORY }}/yarn.lock'
- name: Install dependencies
run: yarn install
@@ -32,13 +34,15 @@ jobs:
env:
WORKING_DIRECTORY: ./
steps:
- - uses: actions/checkout@v4.2.2
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
- name: Setup Node.js
- uses: actions/setup-node@v4.1.0
+ uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
- node-version: 20.19.4
- cache: "yarn"
- cache-dependency-path: "${{ env.WORKING_DIRECTORY }}/yarn.lock"
+ node-version-file: '.nvmrc'
+ cache: 'yarn'
+ cache-dependency-path: '${{ env.WORKING_DIRECTORY }}/yarn.lock'
- name: Install dependencies
run: yarn install
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 0000000..6bc1010
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,87 @@
+name: Publish
+
+on:
+ release:
+ types: [published]
+ workflow_dispatch:
+
+# Read-only by default; the publish job opts into `packages: write`.
+permissions:
+ contents: read
+
+concurrency:
+ group: publish-${{ github.event.release.tag_name || github.ref_name }}
+ cancel-in-progress: false
+
+jobs:
+ publish:
+ name: Publish to GitHub Packages
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read # checkout
+ packages: write # npm publish to npm.pkg.github.com
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ github.sha }}
+ fetch-depth: 0
+ persist-credentials: false
+
+ - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
+ with:
+ node-version-file: '.nvmrc'
+ registry-url: 'https://npm.pkg.github.com'
+ scope: '@copia-automation'
+
+ - name: Install dependencies
+ run: yarn install --frozen-lockfile
+
+ - name: Lint
+ run: yarn lint
+
+ - name: Build
+ run: yarn build
+
+ - name: Test
+ run: yarn test
+
+ - name: Publish
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ PUBLISH_NEXT: ${{ (github.event_name == 'workflow_dispatch' || github.event.release.prerelease) && 'true' || 'false' }}
+ run: |
+ NAME="$(node -p 'require("./package.json").name')"
+ VERSION="$(node -p 'require("./package.json").version')"
+
+ # Build metadata (`+sha.1234`) may contain a hyphen, so strip it before
+ # testing for a SemVer prerelease suffix, e.g. 4.1.0-rc.1.
+ if [[ "${VERSION%%+*}" == *-* ]]; then
+ IS_PRERELEASE=true
+ else
+ IS_PRERELEASE=false
+ fi
+
+ if [ "$PUBLISH_NEXT" != 'true' ]; then
+ # `latest` must only ever point at a stable version.
+ if [ "$IS_PRERELEASE" = 'true' ]; then
+ echo "::error::Refusing to publish prerelease version $VERSION to the latest tag; bump package.json to a stable version first."
+ exit 1
+ fi
+
+ npm publish --tag latest
+ exit 0
+ fi
+
+ # `next` must only ever point at a prerelease version.
+ if [ "$IS_PRERELEASE" != 'true' ]; then
+ echo "::error::Refusing to publish stable version $VERSION to the next tag; bump package.json to a prerelease version first."
+ exit 1
+ fi
+
+ # A manual run on an already-published prerelease only moves the tag.
+ if npm view "$NAME@$VERSION" version >/dev/null 2>&1; then
+ echo "$NAME@$VERSION is already published; retagging as next."
+ npm dist-tag add "$NAME@$VERSION" next
+ else
+ npm publish --tag next
+ fi
diff --git a/.nvmrc b/.nvmrc
new file mode 100644
index 0000000..60ade1a
--- /dev/null
+++ b/.nvmrc
@@ -0,0 +1 @@
+24.19.0
diff --git a/README.md b/README.md
index 419a4ac..7054568 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,6 @@
## Copia Notes
-This fork contains a small modification. The ReactDiffView component now has an added `renderNodeWrapper` property, which is a function to render the diff nodes (aka table rows) with a wrapper.
+
+This fork contains a small modification. The ReactDiffView component now has an added `renderNodeWrapper` property, which is a function to render the diff nodes (aka table rows) with a wrapper.
Keep in mind that since this package isn't published to npm, any modifications need to be built using `npm run build` and commited to this repo.
@@ -31,8 +32,8 @@ npm i react-diff-viewer
## Usage
```javascript
-import React, { PureComponent } from 'react';
-import ReactDiffViewer from 'react-diff-viewer';
+import React, { PureComponent } from 'react'
+import ReactDiffViewer from 'react-diff-viewer'
const oldCode = `
const a = 10
@@ -44,7 +45,7 @@ if(a > 10) {
}
console.log('done')
-`;
+`
const newCode = `
const a = 10
const boo = 10
@@ -52,14 +53,14 @@ const boo = 10
if(a === 10) {
console.log('bar')
}
-`;
+`
class Diff extends PureComponent {
render = () => {
return (