Skip to content

Commit

Permalink
feat: properties support
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvorak committed Mar 17, 2023
1 parent 4a50b30 commit 32358f3
Show file tree
Hide file tree
Showing 17 changed files with 9,530 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"env": {
"es2020": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"quotes": [
"error",
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
]
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
registries:
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "fix(deps)"
prefix-development: "build(deps-dev)"
3 changes: 3 additions & 0 deletions .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/googleapis/repo-automation-bots/tree/main/packages/release-please#configuration
handleGHRelease: true
releaseType: node
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build

on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "**" ]
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
strategy:
matrix:
node-version: [ 14, 16, 18 ]
steps:
# Checkout
- name: Checkout
uses: actions/checkout@v3

# Setup
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm

# Test
- name: Install dependencies
run: npm ci

- name: Test
run: |-
npm run test:ci
npm run build
# Publish
- name: Publish
if: ${{ github.ref_type == 'tag' }}
run: npm publish
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on:
pull_request:
branches: [ "**" ]
workflow_dispatch:

permissions:
contents: read
pull-requests: write

jobs:
eslint:
name: ESLint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
# Checkout
- name: Checkout
uses: actions/checkout@v3

# Fix until https://github.com/reviewdog/action-eslint/issues/152 is resolved
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.13

# Lint
- uses: reviewdog/action-eslint@v1
with:
fail_on_error: true
reporter: ${{ github.event_name == 'pull_request' && 'github-pr-review' || 'github-check' }}
36 changes: 36 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Pull Request

on:
pull_request:
branches: [ "main" ]

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
name: Auto-merge Dependabot PRs
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.3.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

# Auto-merge non-production minor updates to dependencies
- name: Enable auto-merge for Dependabot PRs
if: ${{ steps.metadata.outputs.dependency-type != 'direct:production' && steps.metadata.outputs.update-type != 'version-update:semver-major' }}
run: gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Auto-approve
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pids
lib-cov

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

# nyc test coverage
Expand Down Expand Up @@ -102,3 +102,6 @@ dist

# TernJS port file
.tern-port

# IDEA
.idea/
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
# js-properties
# js-java-properties

Java properties file parser and formatter for Javascript.

Intended mostly for the tools that need to modify existing property file, without reformatting the contents.
That is achieved by using string array as a backing storage. If you want only to read the properties,
you might convert it to `Map` using `toMap(...)` function.

_Warning: Currently this parser does not support UTF-8 character escaping. If you want that feature, please open an
issue._

## Usage

TODO

```sh
npm install js-java-properties
```

## Development

TODO

### Publishing

TODO
25 changes: 25 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type {Config} from 'jest'

const config: Config = {
moduleFileExtensions: ['js', 'ts'],
rootDir: 'src',
testRegex: '.*\\.spec\\.ts$',
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
collectCoverageFrom: ['**/*.ts'],
coveragePathIgnorePatterns: ['/node_modules/'],
coverageDirectory: '../coverage',
testEnvironment: 'node',
};

// noinspection JSUnusedGlobalSymbols
export default config;
Loading

0 comments on commit 32358f3

Please sign in to comment.