Skip to content

Commit

Permalink
fix: foo
Browse files Browse the repository at this point in the history
  • Loading branch information
dword-design committed Feb 15, 2023
1 parent fcadd28 commit 1bb100f
Show file tree
Hide file tree
Showing 11 changed files with 1,791 additions and 1,398 deletions.
1 change: 1 addition & 0 deletions .baserc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "@dword-design/node",
"seeAlso": [
{ "repository": "with-local-tmp-dir", "description": "Creates a temporary folder inside cwd, cds inside the folder, runs a function, and removes the folder. Especially useful for testing." },
{ "repository": "expect-mocha-image-snapshot", "description": "A wrapper around jest-image-snapshot that makes it compatible to Mocha." },
Expand Down
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
},
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-16",
"updateContentCommand": "yarn --frozen-lockfile"
}
30 changes: 15 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
github.event.pull_request.head.ref || '' }}
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "GitHub Actions"
- run: yarn --frozen-lockfile
Expand Down Expand Up @@ -46,31 +46,31 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: yarn --frozen-lockfile
- run: yarn test
- env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn test
- if: failure()
uses: actions/upload-artifact@v3
with:
name: Image Snapshot Diffs
path: "**/__image_snapshots__/__diff_output__"
- if: matrix.os == 'ubuntu-latest' && matrix.node == 14
uses: codecov/codecov-action@v2
- if: matrix.os == 'ubuntu-latest' && matrix.node == 16
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
strategy:
matrix:
exclude:
- node: 12
include:
- node: 14
os: ubuntu-latest
- node: 16
os: ubuntu-latest
- node: 18
os: ubuntu-latest
- node: 16
os: macos-latest
- node: 12
- node: 16
os: windows-latest
node:
- 12
- 14
os:
- macos-latest
- windows-latest
- ubuntu-latest
name: build
on:
pull_request: {}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deprecated-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
with:
comment: Auto-closing the issue
issue-number: ${{ steps.create-deprecation-issue.outputs.number }}
- uses: gautamkrishnar/keepalive-workflow@v1
name: deprecated-dependencies
on:
schedule:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/sync-metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
approve: false
commitMessage: "fix: write GitHub metadata to package.json [{changes}]"
githubToken: ${{ secrets.GITHUB_TOKEN }}
- uses: gautamkrishnar/keepalive-workflow@v1
name: sync-metadata
on:
schedule:
Expand Down
7 changes: 7 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@ FROM gitpod/workspace-full:latest
RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
RUN sudo apt-get install git-lfs
RUN git lfs install

# https://www.gitpod.io/docs/languages/javascript
RUN bash -c 'VERSION="16" && source $HOME/.nvm/nvm.sh && nvm install $VERSION && nvm use $VERSION && nvm alias default $VERSION'

RUN echo "\nexport PATH=$(yarn global bin):\$PATH" >> /home/gitpod/.bashrc

RUN yarn global add gitpod-env-per-project @babel/node @babel/core

RUN sudo apt-get install -y graphviz

RUN brew install gh

# Puppeteer dependencies
Expand Down
4 changes: 2 additions & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit "$1"
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
".babelrc.json": true,
".commitlintrc.json": true,
".cz.json": true,
".devcontainer": true,
".editorconfig": true,
".eslintrc.json": true,
".gitattributes": true,
Expand All @@ -16,6 +17,7 @@
".nyc_output": true,
".releaserc.json": true,
".renovaterc.json": true,
".vscode": true,
"CHANGELOG.md": true,
"LICENSE.md": true,
"coverage": true,
Expand Down
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
"funding": "https://github.com/sponsors/dword-design",
"license": "MIT",
"author": "Sebastian Landwehr <[email protected]>",
"type": "module",
"exports": "./dist/index.js",
"main": "dist/index.js",
"files": [
"dist"
],
"scripts": {
"checkUnknownFiles": "base checkUnknownFiles",
"commit": "base commit",
"depcheck": "base depcheck",
"dev": "base dev",
"lint": "base lint",
"prepare": "base prepare",
Expand All @@ -37,15 +40,16 @@
},
"dependencies": {
"@dword-design/functions": "^4.0.0",
"fs-extra": "^10.0.0"
"fs-extra": "^11.1.0"
},
"devDependencies": {
"@dword-design/base": "^8.0.0",
"globby": "^11.0.1",
"with-local-tmp-dir": "^4.0.0"
"@dword-design/base": "^9.4.2",
"@dword-design/tester": "^2.0.12",
"@dword-design/tester-plugin-tmp-dir": "^2.1.9",
"globby": "^13.1.3"
},
"engines": {
"node": ">=12"
"node": ">=14"
},
"publishConfig": {
"access": "public"
Expand Down
174 changes: 90 additions & 84 deletions src/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,102 +1,108 @@
import { identity, keyBy, mapValues, stubTrue } from '@dword-design/functions'
import globby from 'globby'
import withLocalTmpDir from 'with-local-tmp-dir'
import tester from '@dword-design/tester'
import testerPluginTmpDir from '@dword-design/tester-plugin-tmp-dir'
import { globby } from 'globby'

import self from '.'
import self from './index.js'

const runTest = config => () =>
withLocalTmpDir(async () => {
await self(...[...(config.path ? [config.path] : []), config.files])
expect(
globby('**', { onlyFiles: false })
|> await
|> keyBy(identity)
|> mapValues(stubTrue)
).toEqual(config.result)
})

export default {
'empty folder': {
files: {
folder: {},
'foo.txt': 'foo',
},
result: { folder: true, 'foo.txt': true },
},
'file folder chain': {
files: {
'folder/folder2/foo.txt': 'foo bar',
'foo.txt': 'foo',
},
result: {
folder: true,
'folder/folder2': true,
'folder/folder2/foo.txt': true,
'foo.txt': true,
export default tester(
{
'empty folder': {
files: {
folder: {},
'foo.txt': 'foo',
},
result: { folder: true, 'foo.txt': true },
},
},
files: {
files: { 'foo.txt': 'foo' },
result: {
'foo.txt': true,
'file folder chain': {
files: {
'folder/folder2/foo.txt': 'foo bar',
'foo.txt': 'foo',
},
result: {
folder: true,
'folder/folder2': true,
'folder/folder2/foo.txt': true,
'foo.txt': true,
},
},
},
folder: {
files: {
folder: {
'bar.txt': 'bar',
'baz.txt': 'baz',
files: { 'foo.txt': 'foo' },
result: {
'foo.txt': true,
},
'foo.txt': 'foo',
},
result: {
folder: true,
'folder/bar.txt': true,
'folder/baz.txt': true,
'foo.txt': true,
folder: {
files: {
folder: {
'bar.txt': 'bar',
'baz.txt': 'baz',
},
'foo.txt': 'foo',
},
result: {
folder: true,
'folder/bar.txt': true,
'folder/baz.txt': true,
'foo.txt': true,
},
},
},
'folder chain': {
files: {
'folder/folder2': {
'foo.txt': 'foo bar',
'folder chain': {
files: {
'folder/folder2': {
'foo.txt': 'foo bar',
},
'foo.txt': 'foo',
},
result: {
folder: true,
'folder/folder2': true,
'folder/folder2/foo.txt': true,
'foo.txt': true,
},
'foo.txt': 'foo',
},
result: {
folder: true,
'folder/folder2': true,
'folder/folder2/foo.txt': true,
'foo.txt': true,
'missing files': {
result: {},
},
},
'missing files': {
result: {},
},
'nested folders': {
files: {
folder: {
'bar.txt': 'bar',
folder2: {
'baz.txt': 'baz',
'nested folders': {
files: {
folder: {
'bar.txt': 'bar',
folder2: {
'baz.txt': 'baz',
},
},
'foo.txt': 'foo',
},
result: {
folder: true,
'folder/bar.txt': true,
'folder/folder2': true,
'folder/folder2/baz.txt': true,
'foo.txt': true,
},
'foo.txt': 'foo',
},
result: {
folder: true,
'folder/bar.txt': true,
'folder/folder2': true,
'folder/folder2/baz.txt': true,
'foo.txt': true,
path: {
files: { 'bar.txt': 'baz' },
path: 'foo',
result: {
foo: true,
'foo/bar.txt': true,
},
},
},
path: {
files: { 'bar.txt': 'baz' },
path: 'foo',
result: {
foo: true,
'foo/bar.txt': true,
[
testerPluginTmpDir(),
{
transform: config => async () => {
await self(...[...(config.path ? [config.path] : []), config.files])
expect(
globby('**', { onlyFiles: false })
|> await
|> keyBy(identity)
|> mapValues(stubTrue)
).toEqual(config.result)
},
},
},
} |> mapValues(runTest)
]
)
Loading

0 comments on commit 1bb100f

Please sign in to comment.