functionalscript 0.0.494 → 0.0.495
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/{node.js.yml → ci.yml} +22 -2
- package/.github/workflows/com.yml +1 -1
- package/dev/module.mjs +10 -0
- package/dev/test/module.f.cjs +51 -41
- package/dev/test.mjs +7 -7
- package/package.json +1 -1
- package/.github/workflows/bun.yml +0 -17
- package/.github/workflows/deno.yml +0 -19
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
|
2
2
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
3
|
|
|
4
|
-
name:
|
|
4
|
+
name: CI
|
|
5
5
|
|
|
6
6
|
on:
|
|
7
7
|
push:
|
|
@@ -10,7 +10,7 @@ on:
|
|
|
10
10
|
pull_request:
|
|
11
11
|
|
|
12
12
|
jobs:
|
|
13
|
-
|
|
13
|
+
node:
|
|
14
14
|
|
|
15
15
|
runs-on: ubuntu-latest
|
|
16
16
|
|
|
@@ -29,3 +29,23 @@ jobs:
|
|
|
29
29
|
- run: npm test
|
|
30
30
|
- run: npm run version
|
|
31
31
|
- run: npm pack
|
|
32
|
+
|
|
33
|
+
deno:
|
|
34
|
+
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v2
|
|
39
|
+
- uses: denoland/setup-deno@v1
|
|
40
|
+
with:
|
|
41
|
+
deno-version: v1.x
|
|
42
|
+
- run: deno run --quiet --allow-read --allow-env --allow-net --allow-hrtime ./dev/test.mjs
|
|
43
|
+
|
|
44
|
+
bun:
|
|
45
|
+
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@v2
|
|
50
|
+
- run: curl https://bun.sh/install | bash
|
|
51
|
+
- run: /home/runner/.bun/bin/bun ./dev/test.mjs
|
package/dev/module.mjs
CHANGED
|
@@ -84,6 +84,16 @@ export const fs = () => import(self.Deno ? 'https://deno.land/std/node/fs/promis
|
|
|
84
84
|
/** @type {(code: number) => never} */
|
|
85
85
|
export const exit = self.Deno ? self.Deno.exit : process.exit
|
|
86
86
|
|
|
87
|
+
/** @type {(v: string) => string|undefined} */
|
|
88
|
+
export const env =
|
|
89
|
+
self.Deno ? self.Deno.env.get :
|
|
90
|
+
a => {
|
|
91
|
+
const r = Object.getOwnPropertyDescriptor(process.env, a)
|
|
92
|
+
return r === void 0 ? void 0 :
|
|
93
|
+
typeof r.get === 'function' ? r.get() :
|
|
94
|
+
r.value
|
|
95
|
+
}
|
|
96
|
+
|
|
87
97
|
export const loadModuleMap = async () => {
|
|
88
98
|
const { readdir, readFile } = await fs();
|
|
89
99
|
|
package/dev/test/module.f.cjs
CHANGED
|
@@ -37,9 +37,11 @@ const result = require('../../types/result/module.f.cjs')
|
|
|
37
37
|
* @typedef {{
|
|
38
38
|
* readonly moduleMap: ModuleMap,
|
|
39
39
|
* readonly log: Log<T>,
|
|
40
|
+
* readonly error: Log<T>,
|
|
40
41
|
* readonly measure: Measure<T>,
|
|
41
42
|
* readonly state: T,
|
|
42
|
-
* readonly tryCatch: <R>(f: () => R) => result.Result<R, unknown
|
|
43
|
+
* readonly tryCatch: <R>(f: () => R) => result.Result<R, unknown>,
|
|
44
|
+
* readonly env: (n: string) => string|undefined
|
|
43
45
|
* }} Input
|
|
44
46
|
*/
|
|
45
47
|
|
|
@@ -67,54 +69,62 @@ const addFail = delta => ts => ({ ...ts, time: ts.time + delta, fail: ts.fail +
|
|
|
67
69
|
|
|
68
70
|
/** @type {<T>(input: Input<T>) => readonly[number, T]} */
|
|
69
71
|
const main = input => {
|
|
70
|
-
let { moduleMap, log, measure, tryCatch, state } = input
|
|
72
|
+
let { moduleMap, log, error, measure, tryCatch, env, state } = input
|
|
73
|
+
const isGitHub = env('GITHUB_ACTION') !== void 0
|
|
71
74
|
/** @typedef {input extends Input<infer T> ? T : never} T */
|
|
72
|
-
/** @type {(
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
/** @type {(k: readonly[string, Module]) => (fs: FullState<T>) => FullState<T>} */
|
|
76
|
+
const f = ([k, v]) => {
|
|
77
|
+
/** @type {(i: string) => (v: unknown) => (fs: FullState<T>) => FullState<T>} */
|
|
78
|
+
const test = i => v => ([ts, state]) => {
|
|
79
|
+
const next = test(`${i}| `)
|
|
80
|
+
switch (typeof v) {
|
|
81
|
+
case 'function': {
|
|
82
|
+
if (v.length === 0) {
|
|
83
|
+
const [[s, r], delta, state0] = measure(() => tryCatch(/** @type {() => unknown} */(v)))(state)
|
|
84
|
+
state = state0
|
|
85
|
+
if (s === 'error') {
|
|
86
|
+
ts = addFail(delta)(ts)
|
|
87
|
+
if (isGitHub) {
|
|
88
|
+
// https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions
|
|
89
|
+
// https://github.com/OndraM/ci-detector/blob/main/src/Ci/GitHubActions.php
|
|
90
|
+
state = error(`::error file=${k},line=1,title=[3]['a']()::${r}`)(state)
|
|
91
|
+
} else {
|
|
92
|
+
state = error(`${i}() ${fgRed}error${reset}, ${delta} ms`)(state)
|
|
93
|
+
state = error(`${fgRed}${r}${reset}`)(state)
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
ts = addPass(delta)(ts)
|
|
97
|
+
state = log(`${i}() ${fgGreen}ok${reset}, ${delta} ms`)(state)
|
|
98
|
+
}
|
|
99
|
+
[ts, state] = next(r)([ts, state])
|
|
87
100
|
}
|
|
88
|
-
|
|
101
|
+
break
|
|
89
102
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
case 'object': {
|
|
104
|
+
if (v !== null) {
|
|
105
|
+
/** @type {(k: readonly[string|number, unknown]) => (fs: FullState<T>) => FullState<T>} */
|
|
106
|
+
const f = ([k, v]) => ([time, state]) => {
|
|
107
|
+
state = log(`${i}${k}:`)(state);
|
|
108
|
+
[time, state] = next(v)([time, state])
|
|
109
|
+
return [time, state]
|
|
110
|
+
}
|
|
111
|
+
[ts, state] = fold
|
|
112
|
+
(f)
|
|
113
|
+
([ts, state])
|
|
114
|
+
(v instanceof Array ? list.entries(v) : Object.entries(v))
|
|
99
115
|
}
|
|
100
|
-
|
|
101
|
-
(f)
|
|
102
|
-
([ts, state])
|
|
103
|
-
(v instanceof Array ? list.entries(v) : Object.entries(v))
|
|
116
|
+
break
|
|
104
117
|
}
|
|
105
|
-
break
|
|
106
118
|
}
|
|
119
|
+
return [ts, state]
|
|
107
120
|
}
|
|
108
|
-
return [ts, state]
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
state = log(`testing ${k}`)(state);
|
|
115
|
-
[ts, state] = next(v.exports)([ts, state])
|
|
121
|
+
return ([ts, state]) => {
|
|
122
|
+
if (isTest(k)) {
|
|
123
|
+
state = log(`testing ${k}`)(state);
|
|
124
|
+
[ts, state] = test('| ')(v.exports)([ts, state])
|
|
125
|
+
}
|
|
126
|
+
return [ts, state]
|
|
116
127
|
}
|
|
117
|
-
return [ts, state]
|
|
118
128
|
}
|
|
119
129
|
/** @type {TestState} */
|
|
120
130
|
let ts = { time: 0, pass: 0, fail: 0 };
|
package/dev/test.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { loadModuleMap, exit } from './module.mjs'
|
|
1
|
+
import { loadModuleMap, exit, env } from './module.mjs'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const log = s => state => {
|
|
7
|
-
consoleLog(s)
|
|
3
|
+
/** @type {(f: (s: string) => void) => (s: string) => <T>(_: T) => T} */
|
|
4
|
+
const anyLog = f => s => state => {
|
|
5
|
+
f(s)
|
|
8
6
|
return state
|
|
9
7
|
}
|
|
10
8
|
|
|
@@ -50,9 +48,11 @@ const main = async() => {
|
|
|
50
48
|
const f = moduleMap['./dev/test/module.f.cjs'].exports
|
|
51
49
|
const r = f({
|
|
52
50
|
moduleMap,
|
|
53
|
-
log,
|
|
51
|
+
log: anyLog(console.log),
|
|
52
|
+
error: anyLog(console.error),
|
|
54
53
|
measure,
|
|
55
54
|
tryCatch,
|
|
55
|
+
env,
|
|
56
56
|
})
|
|
57
57
|
exit(r[0])
|
|
58
58
|
}
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
name: bun
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
pull_request:
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v2
|
|
16
|
-
- run: curl https://bun.sh/install | bash
|
|
17
|
-
- run: /home/runner/.bun/bin/bun ./dev/test.mjs
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
name: deno
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
pull_request:
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v2
|
|
16
|
-
- uses: denoland/setup-deno@v1
|
|
17
|
-
with:
|
|
18
|
-
deno-version: v1.x
|
|
19
|
-
- run: deno run --allow-read --allow-env --allow-net --allow-hrtime ./dev/test.mjs
|