Skip to content

Commit

Permalink
Object remap action - v1
Browse files Browse the repository at this point in the history
  • Loading branch information
nickofthyme committed Sep 6, 2021
0 parents commit e5f0d00
Show file tree
Hide file tree
Showing 32 changed files with 30,934 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

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

[*.md]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist/
lib/
node_modules/
coverage/
jest.config.js
144 changes: 144 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'airbnb-typescript',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:eslint-comments/recommended',
'plugin:jest/recommended',
'plugin:promise/recommended',
'plugin:unicorn/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
],
plugins: [
'@typescript-eslint',
'eslint-comments',
'jest',
'import',
'promise',
'unicorn',
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 2 : 1,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 1,
'react/jsx-filename-extension': 0,
'no-unused-vars': 0,
'unicorn/no-null': 0,
'unicorn/prefer-module': 0,
'unicorn/prefer-node-protocol': 0,
'unicorn/prevent-abbreviations': 0,
'unicorn/no-array-reduce': 0,
'unicorn/no-new-array': 0,
'unicorn/prefer-object-from-entries': 0,
'unicorn/consistent-function-scoping': 0,
'@typescript-eslint/naming-convention': 0,
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/no-unnecessary-type-assertion': 0,
'jest/no-test-prefixes': 0,
'jest/no-disabled-tests': 0,
'prefer-destructuring': [
'warn',
{
array: false,
object: true,
},
{
enforceForRenamedProperties: false,
},
],
'function-call-argument-newline': ['error', 'consistent'],
'array-bracket-newline': ['error', 'consistent'],
'object-curly-newline': [
'error',
{
ObjectExpression: { multiline: true, minProperties: 10, consistent: true },
ObjectPattern: { multiline: true, minProperties: 10, consistent: true },
ImportDeclaration: { consistent: true },
ExportDeclaration: { consistent: true },
},
],
semi: ['error', 'always'],
'@typescript-eslint/indent': [ // https://github.com/typescript-eslint/typescript-eslint/issues/1824
'error',
2,
{
SwitchCase: 1,
MemberExpression: 1,
offsetTernaryExpressions: true,
},
],
'max-len': [
'warn',
{
code: 120,
ignoreUrls: true,
ignoreStrings: true,
ignoreComments: true,
ignoreRegExpLiterals: true,
},
],
'no-irregular-whitespace': 'error',
'no-unused-expressions': 'error',
'@typescript-eslint/return-await': ['error', 'always'], // https://v8.dev/blog/fast-async
'@typescript-eslint/ban-ts-comment': 1,
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'all',
args: 'after-used',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-use-before-define': [
'warn',
{
functions: false,
classes: true,
variables: true,
typedefs: false,
},
],
'import/order': [
'error',
{
'newlines-between': 'always',
groups: ['builtin', 'external', ['parent', 'sibling', 'index', 'internal']],
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
'unicorn/filename-case': [
'error',
{
case: 'snakeCase',
},
],
},
env: {
es6: true,
node: true,
browser: true,
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 6,
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
},
project: './tsconfig.lint.json',
tsconfigRootDir: __dirname,
},
settings: {
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts', '.tsx'],
moduleDirectory: ['node_modules'],
},
},
},
};
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** -diff linguist-generated=true
102 changes: 102 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Continuous Integration Tests

concurrency:
group: ${{ github.head_ref || github.ref }}
cancel-in-progress: true

on:
pull_request:
push:
branches:
- master
- 'releases/*'

jobs:
build:
name: Test Action Build
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2
- name: Install node_modules
uses: bahmutov/npm-install@v1
- run: npm run all
test:
name: Test Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create mock test object
id: mock
# example object being tested
# {
# one: 1,
# two: {
# one: 1,
# },
# three: {
# two: {
# one: 1,
# },
# },
# numbers: [1, 2, 3],
# array: [
# {
# test: 'key1',
# deeper: {
# deep: 1,
# },
# },
# {
# test: 'key2',
# },
# ],
# }
run: echo "::set-output name=json::{\"one\":1,\"two\":{\"one\":1},\"three\":{\"two\":{\"one\":1}},\"numbers\":[1,2,3],\"array\":[{\"test\":\"key1\",\"deeper\":{\"deep\":1}},{\"test\":\"key2\"}]}"
- name: Works with simple values
id: test1
uses: ./
with:
number: 21
string: 'a string'
yes: true
no: false
arr: '["one", "two"]'
obj: '{ "one": 1 }'
- run: '[[ ${{ fromJSON(steps.test1.outputs.json).number }} == 21 ]]'
- run: '[[ "${{ fromJSON(steps.test1.outputs.json).string }}" == "a string" ]]'
- run: '[[ ${{ fromJSON(steps.test1.outputs.json).yes }} == true ]]'
- run: '[[ ${{ fromJSON(steps.test1.outputs.json).no }} == false ]]'
- run: '[[ "${{ fromJSON(steps.test1.outputs.json).arr[0] }}" == "one" ]]'
- run: '[[ "${{ fromJSON(steps.test1.outputs.json).arr[1] }}" == "two" ]]'
- run: '[[ ${{ fromJSON(steps.test1.outputs.json).obj.one }} == 1 ]]'
- name: Works with deep complex values
id: test2
uses: ./
with:
test.deep.deeper: ${{ steps.mock.outputs.json }}
- run: '[[ ${{ fromJSON(steps.test2.outputs.json).test.deep.deeper.one }} == 1 ]]'
- name: Overrides previous values
id: test3
uses: ./
with:
test: ${{ steps.mock.outputs.json }}
test.one: 2
- run: '[[ ${{ fromJSON(steps.test3.outputs.json).test.one }} == 2 ]]'
- name: Unfilters filtered values
id: test4
uses: ./
with:
test.*.prop: ${{ toJSON(fromJSON(steps.mock.outputs.json).array.*.test) }}
- run: '[[ "${{ fromJSON(steps.test4.outputs.json).test[0].prop }}" == "key1" ]]'
- run: '[[ "${{ fromJSON(steps.test4.outputs.json).test[1].prop }}" == "key2" ]]'
- name: Trims object by depth
id: test5
uses: ./
with:
__depth: 1
first: 1
deep.deeper: 1
- run: '[[ ${{ fromJSON(steps.test5.outputs.json).first }} == 1 ]]'
- run: '[[ "${{ fromJSON(steps.test5.outputs.json).deep.deeper }}" == "" ]]'
99 changes: 99 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Dependency directory
node_modules

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# 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
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
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# 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 output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
Loading

0 comments on commit e5f0d00

Please sign in to comment.