Skip to content

Commit

Permalink
Merge pull request #1 from hckrnews/feature/first-draft
Browse files Browse the repository at this point in the history
Add all files
  • Loading branch information
w3nl committed Oct 8, 2021
2 parents d26cebd + e721885 commit 871bd53
Show file tree
Hide file tree
Showing 16 changed files with 18,840 additions and 100 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
54 changes: 54 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Code scanning - action"

on:
push:
branches: [main, ]
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
schedule:
- cron: '0 4 * * 5'

jobs:
CodeQL-Build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
with:
languages: javascript

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
27 changes: 27 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Node CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

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

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, lint, and test
run: |
npm ci
npm run vulnerabilities
npm run lint
npm test
env:
CI: true
32 changes: 32 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16
- run: npm ci
- run: npm run vulnerabilities
- run: npm run lint
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci --production
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
118 changes: 19 additions & 99 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,104 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
.DS_Store
node_modules
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist
report

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/
# local env files
.env.local
.env.*.local

# DynamoDB Local files
.dynamodb/
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# TernJS port file
.tern-port
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.dccache
7 changes: 7 additions & 0 deletions .jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"threshold": 0,
"reporters": ["json", "console"],
"ignore": ["**/__snapshots__/**"],
"absolute": true,
"gitignore": true
}
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sudo: true
dist: trusty
addons:
language: node_js
node_js:
- "14"
- "16"
before_script:
- npm run lint
after_script:
- npm run coveralls
git:
depth: 10
cache:
yarn: true
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pieter Wigboldus <npm@w3news.org>
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
# local-fetch
# Local Fetch

[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Scrutinizer Code Quality][scrutinizer-image]][scrutinizer-url]

With this package you can get local file data like the fetch method.

## Example usage

```javascript
import localFetchfrom '@hckrnews/local-fetch'

const fetch = await localFetcher('./src/__fixtures__/example.json')
```

Returns the body as string.
```javascript
fetch.text()
```

Returns the body parsed as JSON.
```javascript
fetch.json()
```

Returns the body as [ReadableStream](https://streams.spec.whatwg.org/#readablestream).
```javascript
let result = ''
fetch.body.on('data', (chunk) => {
result += chunk
})

fetch.body.on('end', () => {
const data = JSON.parse(result)
})
```

[npm-url]: https://www.npmjs.com/package/@hckrnews/local-fetch
[npm-image]: https://img.shields.io/npm/v/@hckrnews/local-fetch.svg
[travis-url]: https://app.travis-ci.com/hckrnews/local-fetch
[travis-image]: https://app.travis-ci.com/hckrnews/local-fetch.svg?branch=main
[coveralls-url]: https://coveralls.io/r/hckrnews/local-fetch
[coveralls-image]: https://img.shields.io/coveralls/hckrnews/local-fetch/main.svg
[scrutinizer-url]: https://scrutinizer-ci.com/g/hckrnews/local-fetch/?branch=main
[scrutinizer-image]: https://scrutinizer-ci.com/g/hckrnews/local-fetch/badges/quality-score.png?b=main
13 changes: 13 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: true,
},
},
],
],
plugins: ['@babel/plugin-transform-modules-commonjs'],
};
20 changes: 20 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
moduleFileExtensions: ['js', 'jsx', 'json'],

transform: {
'^.+\\.js?$': 'babel-jest',
},

transformIgnorePatterns: ['node_modules/(?!(@hckrnews)/)'],

moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
},

testMatch: ['**/__tests__/*.js'],

testURL: 'http://localhost/',

collectCoverage: true,
collectCoverageFrom: ['src/**/*.js'],
};

0 comments on commit 871bd53

Please sign in to comment.