Skip to content

Commit 04fb4a1

Browse files
author
craig
committed
2.0.0 / 2022-03-11
================== * Migrate to ESM module standard - @craigparra * Browser native support for IIFE and EMS bundles - @craigparra * Replace lodash dependency with JavaScript native alternatives - @craigparra * GitHub workflow - @craigparra
1 parent 11e39d5 commit 04fb4a1

File tree

7 files changed

+509
-1941
lines changed

7 files changed

+509
-1941
lines changed

.github/workflows/node.js.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches: [ main ]
10+
pull_request:
11+
branches: [ main ]
12+
13+
jobs:
14+
build:
15+
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
node-version: [16.x]
21+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Use Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v2
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
cache: 'npm'
30+
- run: npm ci
31+
- run: npm run lint
32+
- run: npm run coverage
33+
- run: npm run build
34+

.github/workflows/npm-publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
workflow_dispatch:
8+
release:
9+
types: [created]
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-node@v2
17+
with:
18+
node-version: 16
19+
- run: npm run lint
20+
- run: npm run coverage
21+
22+
publish-npm:
23+
needs: build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- uses: actions/setup-node@v2
28+
with:
29+
node-version: 16
30+
registry-url: https://registry.npmjs.org/
31+
- run: npm ci
32+
- run: npm run build
33+
- run: npm publish
34+
env:
35+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.nycrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@
1111
"text-summary"
1212
],
1313
"all": true,
14-
"instrument": true
15-
}
14+
"instrument": true,
15+
"exclude": [
16+
"dist/**/*.js",
17+
"coverage/**/*"
18+
]
19+
}

History.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2.0.0 / 2022-03-11
2+
==================
3+
4+
* Migrate to ESM module standard - @craigparra
5+
* Browser native support for IIFE and EMS bundles - @craigparra
6+
* Replace lodash dependency with JavaScript native alternatives - @craigparra
7+
* GitHub workflow - @craigparra
8+
19
1.0.12 / 2021-10-08
210
==================
311

README.md

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To use the module, substitute the named {config} module export, in place of the
2323
exports other useful classes as well.
2424

2525
```javascript
26-
const {config} = require('@alt-javascript/config');
26+
import { config } from '@alt-javascript/config' ;
2727

2828
config.get('key');
2929
config.get('nested.key');
@@ -42,9 +42,9 @@ function, and HTTP options can be specified as in the example config file. To a
4242
provide it by using `@alt-javascript/boot` to boot it into the global root context, where the package will detect it.
4343

4444
```javascript
45-
const {boot} = require('@alt-javascript/boot');
46-
const {config} = require('@alt-javascript/config');
47-
const fetch = require('node-fetch');
45+
import { boot } from '@alt-javascript/boot';
46+
import { config } from '@alt-javascript/config';
47+
import fetch from 'node-fetch';
4848

4949
boot({config,fetch})
5050
const webdata = await config.fetch('pathToUrlPrefixedValue');
@@ -86,6 +86,54 @@ const webdata = await config.fetch('pathToUrlPrefixedValue');
8686
}
8787
}
8888
```
89+
### Browser
90+
91+
The module is also able to be used directly in the browser, in combination with the config module.
92+
You can either import the LoggerFactory globally as an IIFE (Immediately Invoked Function Expression),
93+
as follows:
94+
95+
```html
96+
<script src="https://cdn.jsdelivr.net/npm/@alt-javascript/config/dist/alt-javascript-configfactory-iife.js"></script>
97+
<script>
98+
var config = ConfigFactory.getConfig({
99+
logging : {
100+
format : 'json',
101+
level : {
102+
'/' : 'info',
103+
'/MyPage': 'info'
104+
}
105+
}
106+
"http://127+0+0+1:8080" : {
107+
logging : {
108+
format : 'json',
109+
level : {
110+
'/' : 'info',
111+
'/MyPage' : 'debug'
112+
}
113+
}
114+
}
115+
116+
})
117+
var logger = LoggerFactory.getLogger('/MyPage',config);
118+
logger.debug('Hello World');
119+
</script>
120+
```
121+
122+
Or import the ES6 module bundle from a module, as follows:
123+
124+
```javascript
125+
import { ConfigFactory } from 'https://cdn.jsdelivr.net/npm/@alt-javascript/logger/dist/alt-javascript-config-esm.js'
126+
127+
//...as above
128+
```
129+
130+
Encrypted config is not supported in the browser (by default), as it is
131+
inherently unsecure (there is no safe way to hide the salt).
132+
133+
Additionally, config sections can be prefixed with the window location to allow
134+
site or environment specific configuration in the browser (periods must be replaced with
135+
a plus sign - so mysite.com => mysite+com).
136+
89137

90138
<a name="testing">Testability</a>
91139
-------------------------
@@ -95,10 +143,10 @@ and the module exports an EphemeralConfig that can source config paths from a pl
95143
object as follows, allowing you to assert varying configurations easily
96144

97145
```javascript
98-
const {
146+
import {
99147
EphemeralConfig, ValueResolvingConfig, PlaceHolderResolver, PlaceHolderSelector
100148

101-
} = require('@alt-javascript/config');
149+
} from '@alt-javascript/config';
102150

103151
const ephemeralConfig = new EphemeralConfig({
104152
key: 'value',

0 commit comments

Comments
 (0)