@mediatool/frontend-tools 1.2.2 → 1.3.0
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/dist/mtft.cjs +35 -25
- package/lib/build/get-module-context.js +2 -2
- package/lib/test/index.js +31 -17
- package/package.json +2 -5
- package/lib/test/setup-mocha.cjs +0 -14
package/dist/mtft.cjs
CHANGED
|
@@ -3,20 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
var commander = require('commander');
|
|
5
5
|
var vite = require('vite');
|
|
6
|
-
var promises = require('
|
|
7
|
-
var
|
|
6
|
+
var promises = require('fs/promises');
|
|
7
|
+
var path = require('path');
|
|
8
8
|
var ramda = require('ramda');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
-
|
|
14
|
-
var Mocha__default = /*#__PURE__*/_interopDefaultLegacy(Mocha);
|
|
9
|
+
var module$1 = require('module');
|
|
10
|
+
var child_process = require('child_process');
|
|
15
11
|
|
|
16
12
|
async function getModuleContext () {
|
|
17
13
|
const location = process.cwd();
|
|
18
|
-
const pkgLocation =
|
|
19
|
-
const entryLocation =
|
|
14
|
+
const pkgLocation = path.resolve(location, './package.json');
|
|
15
|
+
const entryLocation = path.resolve(location, './index.js');
|
|
20
16
|
|
|
21
17
|
try {
|
|
22
18
|
await promises.stat(pkgLocation);
|
|
@@ -70,27 +66,41 @@ function build (type) {
|
|
|
70
66
|
return fn()
|
|
71
67
|
}
|
|
72
68
|
|
|
69
|
+
const require$1 = module$1.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('mtft.cjs', document.baseURI).href)));
|
|
70
|
+
const mochaCliPath = require$1.resolve('mocha/lib/cli/cli.js');
|
|
71
|
+
|
|
73
72
|
const extensions = '{js,jsx,ts,tsx}';
|
|
74
73
|
const types = {
|
|
75
|
-
all: `./{,!(node_modules)/**}
|
|
76
|
-
unit: `./{,!(node_modules)/**}/test/unit
|
|
77
|
-
it: `./{,!(node_modules)/**}/test/it
|
|
74
|
+
all: `./{,!(node_modules)/**}/**/*-test.${extensions}`,
|
|
75
|
+
unit: `./{,!(node_modules)/**}/test/unit/**/*-test.${extensions}`,
|
|
76
|
+
it: `./{,!(node_modules)/**}/test/it/**/*-test.${extensions}`,
|
|
78
77
|
};
|
|
79
78
|
|
|
80
|
-
async function test (typeOrSpec
|
|
81
|
-
const { require = [] } = options;
|
|
79
|
+
async function test (typeOrSpec) {
|
|
82
80
|
const spec = types[typeOrSpec] || typeOrSpec;
|
|
83
81
|
|
|
84
|
-
const
|
|
85
|
-
'
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
82
|
+
const args = [
|
|
83
|
+
'--loader=tsx',
|
|
84
|
+
mochaCliPath,
|
|
85
|
+
spec,
|
|
86
|
+
'--require',
|
|
87
|
+
'global-jsdom/register',
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
const mochaProcess = child_process.spawn(process.execPath, args, { stdio: 'inherit' });
|
|
91
|
+
|
|
92
|
+
mochaProcess.on('exit', (code, signal) => {
|
|
93
|
+
process.on('exit', () => {
|
|
94
|
+
if (signal) {
|
|
95
|
+
process.kill(process.pid, signal);
|
|
96
|
+
} else {
|
|
97
|
+
process.exit(code);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
process.on('SIGINT', () => {
|
|
102
|
+
mochaProcess.kill('SIGINT');
|
|
103
|
+
});
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
const program = new commander.Command();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { readFile, stat } from '
|
|
2
|
-
import { resolve } from '
|
|
1
|
+
import { readFile, stat } from 'fs/promises'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
3
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
4
|
import { keys, uniq } from 'ramda'
|
|
5
5
|
|
package/lib/test/index.js
CHANGED
|
@@ -1,25 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { createRequire } from 'module'
|
|
2
|
+
import { spawn } from 'child_process'
|
|
3
|
+
|
|
4
|
+
const require = createRequire(import.meta.url)
|
|
5
|
+
const mochaCliPath = require.resolve('mocha/lib/cli/cli.js')
|
|
3
6
|
|
|
4
7
|
const extensions = '{js,jsx,ts,tsx}'
|
|
5
8
|
const types = {
|
|
6
|
-
all: `./{,!(node_modules)/**}
|
|
7
|
-
unit: `./{,!(node_modules)/**}/test/unit
|
|
8
|
-
it: `./{,!(node_modules)/**}/test/it
|
|
9
|
+
all: `./{,!(node_modules)/**}/**/*-test.${extensions}`,
|
|
10
|
+
unit: `./{,!(node_modules)/**}/test/unit/**/*-test.${extensions}`,
|
|
11
|
+
it: `./{,!(node_modules)/**}/test/it/**/*-test.${extensions}`,
|
|
9
12
|
}
|
|
10
13
|
|
|
11
|
-
export default async function test (typeOrSpec
|
|
12
|
-
const { require = [] } = options
|
|
14
|
+
export default async function test (typeOrSpec) {
|
|
13
15
|
const spec = types[typeOrSpec] || typeOrSpec
|
|
14
16
|
|
|
15
|
-
const
|
|
16
|
-
'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
17
|
+
const args = [
|
|
18
|
+
'--loader=tsx',
|
|
19
|
+
mochaCliPath,
|
|
20
|
+
spec,
|
|
21
|
+
'--require',
|
|
22
|
+
'global-jsdom/register',
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
const mochaProcess = spawn(process.execPath, args, { stdio: 'inherit' })
|
|
26
|
+
|
|
27
|
+
mochaProcess.on('exit', (code, signal) => {
|
|
28
|
+
process.on('exit', () => {
|
|
29
|
+
if (signal) {
|
|
30
|
+
process.kill(process.pid, signal)
|
|
31
|
+
} else {
|
|
32
|
+
process.exit(code)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
})
|
|
36
|
+
process.on('SIGINT', () => {
|
|
37
|
+
mochaProcess.kill('SIGINT')
|
|
38
|
+
})
|
|
25
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mediatool/frontend-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Common configs and tooling for bundling, testing, linting frontend modules",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -20,11 +20,7 @@
|
|
|
20
20
|
"mtft": "./dist/mtft.cjs"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@babel/core": "^7.20.2",
|
|
24
|
-
"@babel/preset-env": "^7.20.2",
|
|
25
23
|
"@babel/preset-react": "^7.18.6",
|
|
26
|
-
"@babel/preset-typescript": "^7.18.6",
|
|
27
|
-
"@babel/register": "^7.18.9",
|
|
28
24
|
"@mediatool/eslint-config-mediatool": "^1.1.13",
|
|
29
25
|
"@testing-library/react": "^13.4.0",
|
|
30
26
|
"@testing-library/user-event": "^14.4.3",
|
|
@@ -36,6 +32,7 @@
|
|
|
36
32
|
"global-jsdom": "^8.6.0",
|
|
37
33
|
"jsdom": "^20.0.2",
|
|
38
34
|
"mocha": "^10.1.0",
|
|
35
|
+
"tsx": "^3.12.7",
|
|
39
36
|
"vite": "^3.2.4"
|
|
40
37
|
},
|
|
41
38
|
"peerDependencies": {
|
package/lib/test/setup-mocha.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* eslint-env es6 */
|
|
2
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
|
-
const babel = require('@babel/register').default
|
|
4
|
-
const jsdom = require('global-jsdom')
|
|
5
|
-
|
|
6
|
-
babel({
|
|
7
|
-
presets: [
|
|
8
|
-
'@babel/preset-env',
|
|
9
|
-
'@babel/preset-react',
|
|
10
|
-
'@babel/preset-typescript',
|
|
11
|
-
],
|
|
12
|
-
extensions: [ '.ts', '.tsx', '.js', '.jsx' ],
|
|
13
|
-
})
|
|
14
|
-
jsdom()
|