Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fixes #52 and clarifies behaviour of ace editor. Updates github actions #64

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Deploy Next.js site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
branches: ['main']

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -21,7 +21,7 @@ permissions:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: false

jobs:
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
Expand All @@ -49,20 +49,20 @@ jobs:
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
node-version: '18'
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v4
with:
# Automatically inject basePath in your Next.js configuration file and disable
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next
- name: Restore cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
.next/cache
Expand All @@ -71,14 +71,28 @@ jobs:
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-

- name: Restore build cache
uses: actions/cache@v4
with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: |
~/.npm
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-

- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next build
#- name: Static HTML export with Next.js
# run: ${{ steps.detect-package-manager.outputs.runner }} next export
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: ./out

Expand All @@ -92,4 +106,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
6 changes: 3 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:

strategy:
matrix:
node-version: [16.x, v18.x,v20.x]
node-version: [16.x, v18.x, v20.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install -g npm@9
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v20
10 changes: 9 additions & 1 deletion src/components/RemoveEmptyProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,17 @@ const RemoveEmptyProps = () => {
</h2>
<p className="card-text">
Enter some <code>JSON</code> below and watch the{' '}
<code>null</code> and <code>undefined</code> properties{' '}
<code>null</code> and <code>undefined</code> properties
magically disappear... recursively!
</p>
<p className="card-text">
<em>
Note: due to a limitation of the editor library and the use of{' '}
<code>JSON</code>, you cannot put <code>undefined</code> in
the editor, however the library itself will handle those
values just fine.
</em>
</p>
<form>
<div className="row">
<div className="col-lg-8 offset-lg-2">
Expand Down
2 changes: 1 addition & 1 deletion src/packages/async-timeout/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bagofholding/async-timeout",
"version": "0.9.0",
"version": "0.10.0",
"main": "./async-timeout.js",
"types": "./async-timeout.d.ts",
"author": "Darryl Walker <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/packages/camel-to-kebab/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/packages/camel-to-kebab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bagofholding/camel-to-kebab",
"version": "0.9.0",
"version": "0.10.0",
"main": "camel-to-kebab.js",
"types": "./camel-to-kebab.d.ts",
"author": "Darryl Walker <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/packages/flatten-object-array/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bagofholding/flatten-object-array",
"version": "0.9.0",
"version": "0.10.0",
"main": "flatten-object-array.js",
"types": "./flatten-object-array.d.ts",
"author": "Darryl Walker <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/packages/guid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bagofholding/guid",
"version": "0.9.0",
"version": "0.10.0",
"main": "guid.js",
"types": "./guid.d.ts",
"author": "Darryl Walker <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/packages/is-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bagofholding/is-client",
"version": "0.9.0",
"version": "0.10.0",
"main": "is-client.js",
"types": "./is-client.d.ts",
"author": "Darryl Walker <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion src/packages/is-external/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bagofholding/is-external",
"version": "0.9.0",
"version": "0.10.0",
"main": "is-external.js",
"types": "./is-external.d.ts",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/remove-empty-props/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/packages/remove-empty-props/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bagofholding/remove-empty-props",
"version": "0.9.0",
"version": "0.10.0",
"main": "remove-empty-props.js",
"types": "./remove-empty-props.d.ts",
"author": "Darryl Walker <[email protected]>",
Expand Down
1 change: 1 addition & 0 deletions src/packages/remove-empty-props/remove-empty-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const exportModule = (module.exports = function removeEmptyProps(object) {
return Object.fromEntries(
Object.entries(object)
.filter(([_k, v]) => v !== null)
.filter(([_k, v]) => v !== undefined)
.map(([k, v]) => {
if (isArray(v)) {
return [k, v];
Expand Down
2 changes: 1 addition & 1 deletion src/packages/strip-chars-url-safe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bagofholding/strip-chars-url-safe",
"version": "0.9.0",
"version": "0.10.0",
"main": "strip-chars-url-safe.js",
"types": "./strip-chars-url-safe.d.ts",
"author": "Darryl Walker <[email protected]>",
Expand Down
13 changes: 0 additions & 13 deletions src/pages/api/hello.ts

This file was deleted.

4 changes: 2 additions & 2 deletions tests/__snapshots__/remove-empty-props.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`leaves \`arrays\` untouched 1`] = `6`;
exports[`leaves \`arrays\` untouched 1`] = `5`;

exports[`recursively removes \`null\` and \`undefined\` properties from payload object 1`] = `6`;
exports[`recursively removes \`null\` and \`undefined\` properties from payload object 1`] = `5`;
9 changes: 4 additions & 5 deletions tests/remove-empty-props.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import removeEmptyProps, {
isObject
} from '../src/packages/remove-empty-props';

import * as funcs from '../src/packages/remove-empty-props';

const object = {
foo: null,
bar: undefined,
Expand All @@ -18,13 +16,14 @@ const object = {
three: Number('3'),
four: null,
five: undefined,
six: {},
seven: []
six: false,
seven: [],
eight: {}
}
};

it('recursively removes `null` and `undefined` properties from payload object', () => {
expect(Object.keys(removeEmptyProps(object)).length).toBe(6);
expect(Object.keys(removeEmptyProps(object)).length).toBe(5);
expect(Object.keys(removeEmptyProps(object).object).length).toBe(6);
expect(Object.keys(removeEmptyProps(object)).length).toMatchSnapshot();
});
Expand Down