Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
**/__tests__
tsconfig.json
coverage
templates
cli
**/node_modules
*.spec.ts
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ module.exports = {
'@typescript-eslint/no-use-before-define': 'off',
'no-extend-native': [2, { exceptions: ['String'] }],
},
ignorePatterns: ['src/init/templates/*'],
};
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ typings/
Katalon Tests/Profiles/

.vscode
template
templates
dist
.DS_Store
lib
15 changes: 15 additions & 0 deletions src/init/templates/non-returner-typescript/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: Apache-2.0

root = true

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

[*.md]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions src/init/templates/non-returner-typescript/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-License-Identifier: Apache-2.0

**/__tests__
tsconfig.json
coverage
templates
build
**/node_modules
*.spec.ts
29 changes: 29 additions & 0 deletions src/init/templates/non-returner-typescript/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: Apache-2.0

module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
plugins: ['@typescript-eslint'],
env: {
jest: true,
},
extends: [
'eslint:recommended',
'standard',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'prettier',
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
},
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'no-extend-native': [2, { exceptions: ['String'] }],
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on:
push:
branches:
- 'main'

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js (.npmrc)
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://npm.pkg.github.com/
# Defaults to the user or organization that owns the workflow file
scope: '@frmscoe'

- name: Install dependencies
run: npm ci
env:
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

- name: Build library
run: npm run build

- name: Publish package
run: npm publish
env:
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
NODE_AUTH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
94 changes: 94 additions & 0 deletions src/init/templates/non-returner-typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# SPDX-License-Identifier: Apache-2.0

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*

# 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

# nyc test coverage

.nyc_output

# Grunt intermediate storage (http://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
build

# Dependency directories

node_modules/
jspm_packages/

# TypeScript v1 declaration files

typings/

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Eslint config file

.eslintrc.json

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

\*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variables file

.env

# next.js build output

.next
Katalon Tests/Profiles/

.vscode
template
templates
dist
.DS_Store
lib
4 changes: 4 additions & 0 deletions src/init/templates/non-returner-typescript/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
4 changes: 4 additions & 0 deletions src/init/templates/non-returner-typescript/.husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run test
17 changes: 17 additions & 0 deletions src/init/templates/non-returner-typescript/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
src
src/*.ts
**/index.ts
__tests__
.editorconfig
.eslintignore
.eslintrc.js
.github
.husky
.prettierrc.json
jest.config.ts
prettierrc.json
tsconfig.json
.vscode
coverage
.prettierignore
project.eslint.json
4 changes: 4 additions & 0 deletions src/init/templates/non-returner-typescript/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: Apache-2.0

@frmscoe:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GH_TOKEN}
5 changes: 5 additions & 0 deletions src/init/templates/non-returner-typescript/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0

# Ignore artifacts:
build
coverage
12 changes: 12 additions & 0 deletions src/init/templates/non-returner-typescript/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf"
}
2 changes: 2 additions & 0 deletions src/init/templates/non-returner-typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# {{rulename}}
Read me of {{rulename}} from {{orgname}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: Apache-2.0

const arangojs = require('arangojs');

class MockDatabase {
constructor(config) {
return {
exists() {
return true;
},
isArangoDatabase: true,
close() { },
};
}
}

module.exports = { ...arangojs, Database: MockDatabase };
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: Apache-2.0

// Dependency hoisting so third party library uses mock
module.exports = require('ioredis-mock');
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// SPDX-License-Identifier: Apache-2.0

/* eslint-disable @typescript-eslint/no-unused-vars */
import {
CreateDatabaseManager,
type DatabaseManagerInstance,
LoggerService,
} from '@frmscoe/frms-coe-lib';
import {
type RuleConfig,
type RuleRequest,
type RuleResult,
} from '@frmscoe/frms-coe-lib/lib//interfaces';
import { handleTransaction } from '../../src/{{rulename}}';

jest.mock('@frmscoe/frms-coe-lib', () => {
const original = jest.requireActual('@frmscoe/frms-coe-lib');
return {
...original,
aql: jest.fn(),
};
});

const determineOutcome = (
value: number,
ruleConfig: RuleConfig,
ruleResult: RuleResult,
): RuleResult => {
const bands = ruleConfig.config.bands;
if (bands && (value || value === 0)) {
for (const band of bands) {
if (
(!band.lowerLimit || value >= band.lowerLimit) &&
(!band.upperLimit || value < band.upperLimit)
) {
ruleResult.subRuleRef = band.subRuleRef;
ruleResult.result = band.outcome;
ruleResult.reason = band.reason;
break;
}
}
} else {
throw new Error(
'Value provided undefined, so cannot determine rule outcome',
);
}
return ruleResult;
};

const databaseManagerConfig = {
pseudonyms: {
certPath: '',
databaseName: '',
user: '',
password: '',
url: '',
},
transactionHistory: {
certPath: '',
databaseName: '',
user: '',
password: '',
url: '',
},
};

const loggerService: LoggerService = new LoggerService();


let databaseManager: DatabaseManagerInstance<typeof databaseManagerConfig>;

beforeAll(async () => {
databaseManager = await CreateDatabaseManager(databaseManagerConfig);
});

afterAll(() => {
databaseManager.quit();
});

describe('{{rulename}} Test', () => {
describe('handleTransaction', () => {
describe('{{rulename}} bands Testing', () => {
it('Should ?: When ? is happening', async () => {
expect(true).toBe(true);
});
});
});
});
Loading