Skip to content

Commit 5409939

Browse files
committed
chore(loader): load external resources
1. From file 2. From object literals
1 parent 77ee7bc commit 5409939

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+995
-352
lines changed

.eslintrc.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"env": {
33
"browser": false,
44
"commonjs": true,
5-
"es6": true,
65
"jasmine": true,
76
"jest": true,
87
"node": true
@@ -34,7 +33,6 @@
3433
"impliedStrict": true,
3534
"jsx": false
3635
},
37-
"ecmaVersion": 2019,
3836
"loc": true,
3937
"range": true,
4038
"sourceType": "module",
@@ -337,6 +335,7 @@
337335
"node/no-unsupported-features/es-syntax": [
338336
"error",
339337
{
338+
"version": ">= 8.0.0",
340339
"ignores": ["defaultParameters", "destructuring"]
341340
}
342341
],

.fossa.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by FOSSA CLI (https://github.com/fossas/fossa-cli)
2+
# Visit https://fossa.com to learn more
3+
4+
version: 2
5+
cli:
6+
server: https://app.fossa.com
7+
fetcher: custom
8+
project: https://github.com/commonality/archetypes-rules.git
9+
analyze:
10+
modules:
11+
- name: .
12+
type: npm
13+
target: .
14+
path: .

.github/legal/fossa-init.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
3+
verify_fossa_cli() {
4+
if test -n "$(fossa -v)"
5+
then
6+
echo "[fossa-init]: OK: fossa-cli installed"
7+
return 0
8+
else
9+
echo "[fossa-init]: ERR: fossa-cli not found."
10+
return 1
11+
fi
12+
}
13+
14+
verify_fossa_api_key() {
15+
if test -n "$FOSSA_API_KEY"
16+
then
17+
echo "[fossa-init]: OK: Found FOSSA_API_KEY."
18+
return 0
19+
else
20+
echo "[fossa-init]: ERR: ENVVAR FOSSA_API_KEY not found."
21+
return 1
22+
fi
23+
}
24+
25+
install_fossa_cli() {
26+
echo "[fossa-init]: INSTALL: installing the fossa-cli"
27+
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install.sh | bash
28+
}
29+
30+
run_fossa_analysis() {
31+
echo "[fossa-init]: analyzing your dependencies' legal licenses"
32+
fossa analyze
33+
}
34+
35+
run_fossa_test() {
36+
echo "[fossa-init]: testing for legal use compliance risks"
37+
fossa test
38+
}
39+
40+
main() {
41+
if verify_fossa_cli && verify_fossa_api_key
42+
then
43+
fossa
44+
else
45+
install_fossa_cli
46+
init_fossa
47+
run_fossa_analysis
48+
run_fossa_test
49+
fi
50+
exit 0
51+
}
52+
53+
main

.github/qa/code-climate-init.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
get_cc_test_reporter_url() {
4+
if [[ "$TRAVIS_OS_NAME" == "osx" ]]
5+
then
6+
echo "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64"
7+
else
8+
echo "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64"
9+
fi
10+
}
11+
12+
dl_cc_test_reporter() {
13+
CC_URL=$(get_cc_test_reporter_url)
14+
curl -L "$CC_URL" > "$TRAVIS_BUILD_DIR/cc-test-reporter"
15+
echo "[code-climate-init]: OK: Dowloaded script to $TRAVIS_BUILD_DIR/cc-test-reporter"
16+
}
17+
18+
init_cc_test_reporter() {
19+
chmod +x "$TRAVIS_BUILD_DIR/cc-test-reporter"
20+
echo "[code-climate-init]: OK: Apply exec to $TRAVIS_BUILD_DIR/cc-test-reporter"
21+
}
22+
23+
main() {
24+
dl_cc_test_reporter
25+
init_cc_test_reporter
26+
echo "[code-climate-init]: OK: $TRAVIS_BUILD_DIR/cc-test-reporter is ready for use."
27+
exit 0
28+
}
29+
30+
main

.travis.yml

+102-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,105 @@
1+
# Travis-CI
2+
# The complete job lifecycle
3+
# @see https://docs.travis-ci.com/user/job-lifecycle/#the-job-lifecycle
4+
# 1. OPTIONAL Install apt addons
5+
# 2. OPTIONAL Install cache components
6+
# 3. before_install
7+
# 4. install
8+
# 5. before_script
9+
# 6. script
10+
# 7. OPTIONAL before_cache (for cleaning up cache)
11+
# 8. after_success or after_failure
12+
# 9. OPTIONAL before_deploy
13+
# 10. OPTIONAL deploy
14+
# 11. OPTIONAL after_deploy
15+
# 12. after_script
16+
17+
118
language: node_js
219
node_js:
3-
- '10'
4-
- '11'
520
- '12'
6-
- v11
7-
- v10
8-
after_script: cat ./coverage/lcov.info | coveralls
21+
- '11'
22+
- '10'
23+
- '8'
24+
- '6'
25+
26+
os:
27+
- linux
28+
- osx
29+
- windows
30+
31+
git:
32+
depth: 1
33+
34+
before_install:
35+
# 2. Before installation (before_install) steps:
36+
37+
# 2.1. Set up dependency manager (node package manager "npm")
38+
- '[[ $(node -v) =~ ^v9.*$ ]] || npm install -g npm@latest'
39+
# 2.2. FOSS license-compliance evaluator (fossa-cli for Provided Builds)
40+
# Grant execution permission
41+
# @see https://docs.fossa.com/docs/provided-builds
42+
- chmod +x ./.github/ci/legal/fossa-init.sh
43+
44+
# 2.3. CodeClimate source code quality assessor
45+
# Grant execution permission
46+
- chmod +x ./.github/ci/qa/code-climate-init.sh
47+
48+
install:
49+
# 3. Installation step (install):
50+
- npm i
51+
52+
before_script:
53+
# 4. Before running unit tests...
54+
# 4.1. Initialize FOSSA for OSS license compliance evaluation
55+
- ./.github/ci/legal/fossa-init.sh
56+
57+
# 4.2. Initialize CodeClimate for quality assurance code review
58+
# automatically sent as comments during a Merge Request
59+
# to master.
60+
- ./.github/ci/qa/code-climate-init.sh
61+
62+
# 4.3. Initialize CodeClimate Code Coverage reporter
63+
- $TRAVIS_BUILD_DIR/cc-test-reporter before-build || exit 0
64+
65+
script:
66+
# 5. Test!
67+
- npm test
68+
- npm run security:audit:dependencies
69+
70+
after_script:
71+
# 5.1. Share code coverage with
72+
# - Codacy,
73+
# - Coveralls,
74+
- cat ./coverage/lcov.info | codacy-coverage
75+
- cat ./coverage/lcov.info | coveralls
76+
77+
# - and CodeClimate
78+
- $TRAVIS_BUILD_DIR/cc-test-reporter after-build --exit-code
79+
$TRAVIS_TEST_RESULT || exit 0
80+
81+
jobs:
82+
include:
83+
- stage: release
84+
name: 'Publish to NPM (public registry)'
85+
# 7. Deploy from the lastest Node.js Long-Term Support
86+
# (LTS) build.
87+
node_js: lts/*
88+
deploy:
89+
provider: script
90+
skip_cleanup: true
91+
script:
92+
# 7.1. Bump semantic version by commit message headers' "type"
93+
# 7.2. Generate GitHub Release Notes
94+
# 7.3. Append change list to the CHANGELOG.md
95+
# 7.4. Bump package.json#version
96+
# 7.5. Stage and commit all of the above
97+
# 7.6. Push to Git remote origin master
98+
# 7.7. Trigger all CI quality gates on master
99+
# 7.8. All gates pass (steps 1-6)? Bump semver and
100+
# 7.8.1. Squash and merge into origin/master
101+
# 7.8.2. Publish a GitHub release with notes and CHANGELOG
102+
# 7.8.3. Publish on NPM (including README)
103+
# 7.9. Any gate fails? Roll back and abort all release steps.
104+
- npx semantic-release
105+

README.md

+87-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
# archetypes-rules
22

3-
![banner](docs/assets/img/logo.png)
3+
![banner](docs/img/logos/logo.png)
44

5-
[![build status](https://secure.travis-ci.org/gregswindle/archetypes-rules.png)](http://travis-ci.org/gregswindle/archetypes-rules)
6-
[![Coverage Status](https://coveralls.io/repos/github/gregswindle/archetypes-rules/badge.png?branch=master)](https://coveralls.io/github/gregswindle/archetypes-rules?branch=master)
7-
[![Code Climate](https://codeclimate.com/github/gregswindle/archetypes-rules/badges/gpa.svg)](https://codeclimate.com/github/gregswindle/archetypes-rules)
8-
[![Codacy Badge](https://api.codacy.com/project/badge/grade/b6e496204f604f0e9955ca169fc8a1d7)](https://www.codacy.com/app/commonality/archetypes-rules)
9-
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
5+
[![The MIT License][license-image]][license-url]
6+
[![NPM version][npm-image]][npm-url] [![FOSSA Status][fossa-image]][fossa-url]
7+
[![Known Vulnerabilities][vulnerabilities-image]][vulnerabilities-url]<br>
8+
[![Dependency Status][daviddm-image]][daviddm-url]<br>
9+
[![MacOS and Ubuntu build statuses][travis-image]][travis-url]
10+
[![Windows build status][appveyor-image]][appveyor-url]
11+
[![Coveralls test coverage][coveralls-image]][coveralls-url]
12+
[![Codacy code quality][codacy-image]][codacy-url]
1013

1114
> Move conditional logic out of source code and database triggers and into a
1215
> reusable package, where explicit rules can be independently defined and
1316
> managed.
1417
1518
`archetypes-rules` models Boolean logic. Instead of writing conditionals like
16-
<samp>if / else if / else</samp>, you can instead create Rules that describe
17-
Facts, and then evaluate RuleContexts against them.
19+
<samp>if / else if / else</samp>, you can instead create Rules that describe and
20+
evaluate Facts (aka, RuleContexts).
1821

1922
## Table of Contents
2023

@@ -68,12 +71,18 @@ facts conform to the defined `Rule`.
6871
[Reverse Polish Notation (RPN)](https://en.wikipedia.org/wiki/Reverse_Polish_notation).
6972
See the examples below for details.
7073

74+
<small>[![Back to Table of contents][octicon-triangle-up]
75+
[toc]][toc-anchor]</small>
76+
7177
## 2. Installation
7278

7379
```sh
7480
npm install archetypes-rules
7581
```
7682

83+
<small>[![Back to Table of contents][octicon-triangle-up]
84+
[toc]][toc-anchor]</small>
85+
7786
## 3. Usage
7887

7988
### 3.1. Example 1: Is this customer eligible for a discount?
@@ -200,37 +209,97 @@ fact
200209
// ), value = true
201210
```
202211

212+
<small>[![Back to Table of contents][octicon-triangle-up]
213+
[toc]][toc-anchor]</small>
214+
203215
## 4. Maintainers
204216

205217
[@gregswindle](https://github.com/gregswindle)
206218

207-
> ![Information for Maintainers][octicon-info] The
219+
> ![Information for Maintainers][octicon-book] The
208220
> [Maintainer Guide](./docs/maintainer-guide/README.md) describes how we develop
209221
> and release **archetype-rules** (and has useful information for Maintainers
210222
> and Trusted Committers).
211223
224+
<small>[![Back to Table of contents][octicon-triangle-up]
225+
[toc]][toc-anchor]</small>
226+
212227
## 5. Contributions
213228

214-
We gratefully accept Pull Requests! Here's what you need to know to get started.
229+
[![GitHub Contributors](https://img.shields.io/github/contributors/commonality/archetypes-rules.svg?style=social)](https://github.com/commonality/archetypes-rules/graphs/contributors)
230+
[![GitHub](https://img.shields.io/github/stars/commonality/archetypes-rules.svg?style=social)](https://github.com/commonality/archetypes-rules)
231+
[![GitHub](https://img.shields.io/github/forks/commonality/archetypes-rules.svg?style=social)](https://github.com/commonality/archetypes-rules/network)
232+
[![Greenkeeper badge](https://badges.greenkeeper.io/commonality/archetypes-rules.svg?style=flat-square)](https://greenkeeper.io/)
233+
234+
![Gratitude][octicon-heart] We gratefully accept Pull Requests. Here's what you
235+
need to know to get started.
215236

216-
> ![Before submitting a Pull Request, please read][octicon-heart] Before
217-
> submitting a Pull Request, please read our:
218-
>
219-
> - [Code of Conduct](CODE_OF_CONDUCT.md)
220-
> - [Contributing Aggreement](CONTRIBUTING.md)
221-
> - [Developer Guide](docs/developer-guide#README.md)
222-
> - [Maintainer/Trusted Committer Guide](docs/maintainer-guide#readme)
223-
> - [Architecture Decision Records](docs/adr#readme)
237+
Before submitting a Pull Request, please read our:
238+
239+
- [Code of Conduct](CODE_OF_CONDUCT.md)
240+
- [Contributing Aggreement](CONTRIBUTING.md)
241+
- [Developer Guide](docs/developer-guide#README.md)
242+
- [Maintainer/Trusted Committer Guide](docs/maintainer-guide#readme)
243+
- [Architecture Decision Records](docs/adr#readme)
244+
245+
<small>[![Back to Table of contents][octicon-triangle-up]
246+
[toc]][toc-anchor]</small>
224247

225248
## 6. License
226249

227250
[MIT](LICENSE) © 2019 Greg Swindle
228251

252+
> [![Open Source Licenses][octicon-law] View the latest **detailed legal
253+
> NOTICE** report
254+
> ![This link will take you to another Web site][octicon-link-external]][fossa-legal-notice-url].
255+
256+
[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B804%2Fgithub.com%2Fcommonality%2Farchetypes-rules.svg?type=large)](https://app.fossa.com/projects/custom%2B804%2Fgithub.com%2Fcommonality%2Farchetypes-rules?ref=badge_large)
257+
258+
<small>[![Back to Table of contents][octicon-triangle-up]
259+
[toc]][toc-anchor]</small>
260+
229261
<!-- ⛔️ Do not remove this line or anything under it. ⛔️ -->
230262

231263
<!-- Link and image refs -->
232264

265+
[appveyor-image]:
266+
https://img.shields.io/appveyor/ci/commonality/archetypes-rules.svg?style=flat-square&logo=appveyor&label=windows%20build
267+
[appveyor-url]: https://ci.appveyor.com/project/commonality/archetypes-rules
233268
[archetypes-rules-overview]: ./docs/assets/archetypes.rules-overview.png
269+
[codacy-coverage-image]: https://img.shields.
270+
[codacy-image]:
271+
https://api.codacy.com/project/badge/Grade/bc3fdfbea2d84079b5d785b6de0886ab
272+
[codacy-url]:
273+
https://www.codacy.com/app/commonality/archetypes-rules?utm_source=github.com&utm_medium=referral&utm_content=commonality/archetypes-rules&utm_campaign=Badge_Grade
274+
[coveralls-image]:
275+
https://coveralls.io/repos/github/commonality/archetypes-rules/badge.svg?style=flat-square
276+
[coveralls-url]: https://coveralls.io/github/commonality/archetypes-rules
277+
[daviddm-image]:
278+
https://david-dm.org/commonality/archetypes-rules.svg?theme=shields.io&style=flat-square
279+
[daviddm-url]: https://david-dm.org/commonality/archetypes-rules
280+
[fossa-image]:
281+
https://app.fossa.com/api/projects/custom%2B804%2Fgithub.com%2Fcommonality%2Farchetypes-rules.svg?type=shield
282+
[fossa-legal-notice-url]:
283+
https://app.fossa.com/attribution/5895d784-6a99-4c46-961c-6aecd9414623
284+
[fossa-url]:
285+
https://app.fossa.com/projects/custom%2B804%2Fgithub.com%2Fcommonality%2Farchetypes-rules?ref=badge_shield
286+
[license-image]:
287+
https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square
288+
[license-url]: http://opensource.org/licenses/MIT
289+
[npm-image]: https://img.shields.io/npm/v/archetypes-rules.svg?style=flat-square
290+
[npm-url]: https://npmjs.org/package/archetypes-rules
291+
[toc-anchor]: #table-of-contents
292+
[travis-image]:
293+
https://img.shields.io/travis/com/commonality/archetypes-rules.svg?branch=master&style=flat-square&label=macOS%20%7C%20ubuntu%20builds&logo=travis
294+
[travis-url]: https://travis-ci.com/commonality/archetypes-rules
295+
[vulnerabilities-image]:
296+
https://snyk.io/test/github/commonality/archetypes-rules/badge.svg?style=flat-square&targetFile=package.json
297+
[vulnerabilities-url]:
298+
https://snyk.io/test/github/commonality/archetypes-rules?targetFile=package.json
299+
300+
daviddm-dev-image]:
301+
https://david-dm.org/commonality/archetypes-rules/dev-status.svg?theme=shields.io&style=flat-square
302+
io/codacy/coverage/c6edb2d74fca44279c24b1c4a35b8ad9.svg?style=flat-square
234303

235304
<!-- Octicon img references -->
236305

0 commit comments

Comments
 (0)