Skip to content

Commit

Permalink
Merge pull request #1 from webpod/mvp
Browse files Browse the repository at this point in the history
chore: mvp
  • Loading branch information
antonmedv authored Mar 24, 2024
2 parents 2960ff3 + 4082d0d commit 7f3fc02
Show file tree
Hide file tree
Showing 19 changed files with 5,087 additions and 2 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This is a Github Workflow that runs tests on any push or pull request.
# If the tests pass and this is a push to the master branch it also runs Semantic Release.
name: CI
on: [push, pull_request]
jobs:
push:
name: Push ${{ github.ref }}
if: github.event_name == 'push'
runs-on: ubuntu-22.04
permissions:
checks: read
statuses: write
contents: write
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: ${{ github.ref == 'refs/heads/main' && '0' || '1' }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
# cache: 'yarn'

- name: Fetch deps
run: yarn --mutex network --frozen-lockfile --network-concurrency 25 --silent --disable-self-update-check

- name: Build
run: yarn build

- name: Run tests
run: yarn test

# - name: Codeclimate
# if: github.ref == 'refs/heads/main'
# uses: paambaati/[email protected]
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageLocations: |
# ${{github.workspace}}/target/coverage/lcov.info:lcov

# - name: Semantic Release
# if: github.ref == 'refs/heads/main'
# env:
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# NPM_PROVENANCE: true
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GIT_BRANCH: 'main'
# GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
# GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
# GIT_COMMITTER_NAME: ${{ secrets.GIT_COMMITTER_NAME }}
# GIT_COMMITTER_EMAIL: ${{ secrets.GIT_COMMITTER_EMAIL }}
# run: npm_config_yes=true npx zx-semrel

pr:
if: github.event_name == 'pull_request'
name: PR (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
strategy:
matrix:
os: [ ubuntu-22.04 ]
node-version: [ 20 ]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Fetch deps
run: yarn --mutex network --frozen-lockfile --network-concurrency 25 --silent --disable-self-update-check

- name: Build
run: yarn build

- name: Run tests
run: yarn test
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# IDEs
.idea

# Credentials
**/*.asc
**/*.key
**/*.pem
**/*.cert
**/.npmrc
**/.yarnrc

# Bundles
bundle
build
buildstamp.json
dist
docs
flow-typed
lib
target
typings

# Temp assets
.temp
temp

# Codeclimate
codeclimate.*
cc-reporter
cc-reporter.*

# Logs
logs
*.log
Expand All @@ -21,6 +52,7 @@ lib-cov

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

# nyc test coverage
Expand All @@ -47,6 +79,9 @@ web_modules/

# TypeScript cache
*.tsbuildinfo
.tsbuildinfo
buildcache
.buildcache

# Optional npm cache directory
.npm
Expand Down
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
# ingrid
A shell-printed tables parser
# @webpod/ingrid
> A shell-printed tables parser
## Usage
There are so many tools for printing tables in the shell, but much less to parse them back.

```ts
import { parse } from '@webpod/ingrid'

const table = `
foo bar baz
1 2 3
`
const result = parse(table.trim())
// {foo: ['1'], bar: ['2'], baz: ['3']}
```

To parse [wmic](https://en.wikipedia.org/wiki/Windows_Management_Instrumentation) grids, set the `format` option:

```ts
const table = `
foo bar baz
1
2 3
a
b c
d e
`

const result = parse(table.trim(), {format: 'win'})
/**
[
{ foo: ['1'], bar: ['2'], baz: ['3'] },
{ foo: ['a'], bar: ['b'], baz: ['c'] },
{ foo: ['a'], bar: ['d'], baz: ['e'] }
]
*/
```

## License
[MIT](./LICENSE)
58 changes: 58 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "@webpod/ingrid",
"version": "0.0.0",
"description": "A shell-printed tables parser",
"type": "module",
"main": "target/cjs/index.cjs",
"exports": {
".": {
"types": "./target/dts/index.d.ts",
"require": "./target/cjs/index.cjs",
"import": "./target/esm/index.mjs",
"default": "./target/esm/index.mjs"
}
},
"module": "target/esm/index.mjs",
"types": "target/dts/index.d.ts",
"files": [
"target/cjs",
"target/esm",
"target/dts"
],
"scripts": {
"build": "concurrently 'npm:build:*'",
"build:js": "node ./src/scripts/build.mjs",
"build:dts": "tsc --emitDeclarationOnly --outDir target/dts",
"build:docs": "typedoc --options src/main/typedoc",
"build:stamp": "npx buildstamp",
"test": "concurrently 'npm:test:*'",
"test:lint": "eslint -c src/test/lint/.eslintrc.json src",
"test:unit": "c8 -r lcov -r text -o target/coverage -x src/scripts -x src/test -x target node --loader ts-node/esm --experimental-specifier-resolution=node src/scripts/test.mjs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/webpod/ingrid.git"
},
"author": "Anton Golub <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/webpod/ingrid/issues"
},
"homepage": "https://github.com/webpod/ingrid#readme",
"dependencies": {},
"devDependencies": {
"@types/node": "^20.11.30",
"c8": "^9.1.0",
"concurrently": "^8.2.2",
"esbuild": "^0.20.2",
"esbuild-node-externals": "^1.13.0",
"esbuild-plugin-entry-chunks": "^0.1.11",
"eslint": "^8.57.0",
"eslint-config-qiwi": "^2.1.3",
"fast-glob": "^3.3.2",
"minimist": "^1.2.8",
"ts-node": "^10.9.2",
"typedoc": "^0.25.12",
"typescript": "^5.4.3"
}
}
2 changes: 2 additions & 0 deletions src/main/ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type * from './ingrid.ts'
export { parse } from './ingrid.ts'
Loading

0 comments on commit 7f3fc02

Please sign in to comment.