@helsenorge/library-build 31.0.0 → 33.1.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/build.d.ts +2 -0
- package/build.d.ts.map +1 -0
- package/build.js +24 -0
- package/config/tsconfig.global.json +17 -19
- package/copy.js +21 -22
- package/files.d.ts +1 -1
- package/files.d.ts.map +1 -1
- package/files.js +24 -25
- package/index.html +4 -4
- package/library-scripts.js +10 -9
- package/package.json +24 -32
- package/setupTests.vite.d.ts +8 -0
- package/setupTests.vite.d.ts.map +1 -0
- package/setupTests.vite.js +35 -0
- package/start.js +69 -82
- package/vitest.config.d.ts +5 -0
- package/vitest.config.d.ts.map +1 -0
- package/vitest.config.js +35 -0
- package/config/babel.config.js +0 -14
- package/jest.config.d.ts +0 -4
- package/jest.config.d.ts.map +0 -1
- package/jest.config.js +0 -34
- package/setupTests.d.ts +0 -8
- package/setupTests.d.ts.map +0 -1
- package/setupTests.js +0 -80
- package/test.d.ts +0 -3
- package/test.d.ts.map +0 -1
- package/test.js +0 -22
package/build.d.ts
ADDED
package/build.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":""}
|
package/build.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
2
|
+
import esbuild from 'esbuild';
|
|
3
|
+
import yargs from 'yargs';
|
|
4
|
+
import { hideBin } from 'yargs/helpers';
|
|
5
|
+
(async () => {
|
|
6
|
+
const { entry, outDir, tsconfig } = await yargs(hideBin(process.argv))
|
|
7
|
+
.options({
|
|
8
|
+
entry: { type: 'string', default: 'src/__devonly__/index.tsx' },
|
|
9
|
+
outDir: { type: 'string', default: 'dist' },
|
|
10
|
+
tsconfig: { type: 'string', default: 'tsconfig.json' },
|
|
11
|
+
})
|
|
12
|
+
.parse();
|
|
13
|
+
if (!existsSync(outDir)) {
|
|
14
|
+
mkdirSync(outDir);
|
|
15
|
+
}
|
|
16
|
+
await esbuild.build({
|
|
17
|
+
format: 'esm',
|
|
18
|
+
entryPoints: [entry],
|
|
19
|
+
outdir: outDir,
|
|
20
|
+
tsconfig: tsconfig,
|
|
21
|
+
bundle: true,
|
|
22
|
+
external: ['*'],
|
|
23
|
+
});
|
|
24
|
+
})();
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"jsx": "react",
|
|
8
|
-
"suppressImplicitAnyIndexErrors": true,
|
|
9
|
-
"allowSyntheticDefaultImports": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"newLine": "LF",
|
|
13
|
-
"allowUnreachableCode": false,
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
14
7
|
"skipLibCheck": true,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"declarationMap": true,
|
|
20
|
-
"removeComments": false,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"allowImportingTsExtensions": false,
|
|
21
12
|
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noEmit": false,
|
|
15
|
+
"jsx": "react-jsx",
|
|
22
16
|
|
|
23
17
|
/* Linting */
|
|
24
18
|
"strict": true,
|
|
25
19
|
"noUnusedLocals": true,
|
|
26
20
|
"noUnusedParameters": true,
|
|
27
21
|
"noFallthroughCasesInSwitch": true,
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
|
|
23
|
+
/* library-build specific options */
|
|
24
|
+
"declaration": true,
|
|
25
|
+
"declarationMap": true,
|
|
26
|
+
"esModuleInterop": true,
|
|
27
|
+
"types": ["vitest/globals", "@testing-library/jest-dom"]
|
|
30
28
|
}
|
|
31
29
|
}
|
package/copy.js
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _a = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import copyfiles from 'copyfiles';
|
|
4
|
+
import { rimraf } from 'rimraf';
|
|
5
|
+
import yargs from 'yargs';
|
|
6
|
+
import { hideBin } from 'yargs/helpers';
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
import { createPackageJsonFile } from './files.js';
|
|
9
|
+
const { root, include, utils, rm } = yargs(hideBin(process.argv))
|
|
11
10
|
.options({
|
|
12
11
|
root: { describe: 'Files to copy to root directory', type: 'array', default: [] },
|
|
13
12
|
include: { describe: 'Files to copy from src to lib, replacing "src" with "lib"', type: 'array', default: [] },
|
|
14
13
|
utils: { describe: 'Files to copy to lib/utils', type: 'array', default: [] },
|
|
15
14
|
rm: { describe: 'Files to delete', type: 'array', default: [] },
|
|
16
15
|
})
|
|
17
|
-
.parse()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
.parse();
|
|
17
|
+
const originalPackageJson = path.resolve(process.cwd(), 'package.json');
|
|
18
|
+
const { name: packageName, publishConfig: { directory: outputDirectory }, } = require(originalPackageJson);
|
|
19
|
+
const outputPath = path.resolve(process.cwd(), outputDirectory);
|
|
20
|
+
const newPackageJson = path.resolve(outputPath, 'package.json');
|
|
22
21
|
Promise.all([
|
|
23
|
-
new Promise(
|
|
24
|
-
new Promise(
|
|
25
|
-
new Promise(
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
new Promise((resolve, reject) => root.length > 0 ? copyfiles([...root, outputPath], { error: true }, e => (e ? reject(e) : resolve())) : resolve()),
|
|
23
|
+
new Promise((resolve, reject) => include.length > 0 ? copyfiles([...include, outputPath], { up: 1, error: true }, e => (e ? reject(e) : resolve())) : resolve()),
|
|
24
|
+
new Promise((resolve, reject) => utils.length > 0
|
|
25
|
+
? copyfiles([...utils, path.resolve(outputPath, 'utils')], { up: true, error: true }, e => (e ? reject(e) : resolve()))
|
|
26
|
+
: resolve()),
|
|
28
27
|
])
|
|
29
|
-
.then(
|
|
30
|
-
.then(
|
|
28
|
+
.then(() => (rm ? rimraf(rm, { glob: true }) : Promise.resolve(true)))
|
|
29
|
+
.then(() => createPackageJsonFile(packageName, originalPackageJson, newPackageJson));
|
package/files.d.ts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Function used to create the package.json file under /lib
|
|
3
3
|
* @param packageName - the name field in package.json (for example: @helsenorge/step')
|
|
4
4
|
*/
|
|
5
|
-
export declare function createPackageJsonFile(packageName: string, inputPath: string, outputPath: string): Promise<
|
|
5
|
+
export declare function createPackageJsonFile(packageName: string, inputPath: string, outputPath: string): Promise<string>;
|
|
6
6
|
//# sourceMappingURL=files.d.ts.map
|
package/files.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA2CjH"}
|
package/files.js
CHANGED
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPackageJsonFile = void 0;
|
|
4
|
-
var fs_1 = require("fs");
|
|
1
|
+
import { readFile, writeFile } from 'fs';
|
|
5
2
|
/**
|
|
6
3
|
* Function used to create the package.json file under /lib
|
|
7
4
|
* @param packageName - the name field in package.json (for example: @helsenorge/step')
|
|
8
5
|
*/
|
|
9
|
-
function createPackageJsonFile(packageName, inputPath, outputPath) {
|
|
10
|
-
return new Promise(
|
|
11
|
-
|
|
6
|
+
export function createPackageJsonFile(packageName, inputPath, outputPath) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
readFile(inputPath, 'utf8', (err, data) => {
|
|
12
9
|
if (err) {
|
|
13
10
|
throw err;
|
|
14
11
|
}
|
|
15
12
|
resolve(data);
|
|
16
13
|
});
|
|
17
14
|
})
|
|
18
|
-
.then(
|
|
19
|
-
.then(
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
.then((data) => JSON.parse(data))
|
|
16
|
+
.then((packageData) => {
|
|
17
|
+
const { author, version, main, sideEffects, repository, bin, peerDependencies, license, dependencies, publishConfig } = packageData;
|
|
18
|
+
const minimalPackage = {
|
|
22
19
|
name: packageName,
|
|
23
|
-
author
|
|
24
|
-
version
|
|
25
|
-
main
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
author,
|
|
21
|
+
version,
|
|
22
|
+
main,
|
|
23
|
+
type: ['@helsenorge/core-build', '@helsenorge/library-build'].includes(packageName) ? 'module' : undefined,
|
|
24
|
+
sideEffects,
|
|
25
|
+
repository,
|
|
26
|
+
bin,
|
|
27
|
+
license,
|
|
28
|
+
peerDependencies,
|
|
29
|
+
dependencies,
|
|
31
30
|
};
|
|
32
|
-
if (publishConfig
|
|
31
|
+
if (publishConfig?.access) {
|
|
33
32
|
minimalPackage.publishConfig = {
|
|
34
33
|
access: publishConfig.access,
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
|
-
return new Promise(
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
return new Promise(resolve => {
|
|
37
|
+
const data = JSON.stringify(minimalPackage, null, 2);
|
|
38
|
+
writeFile(outputPath, data, err => {
|
|
40
39
|
if (err)
|
|
41
40
|
throw err;
|
|
42
|
-
|
|
41
|
+
// eslint-disable-next-line no-console
|
|
42
|
+
console.log(`Created package.json in ${outputPath}`);
|
|
43
43
|
resolve(outputPath);
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
exports.createPackageJsonFile = createPackageJsonFile;
|
package/index.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="no">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
<hn-webcomp-header></hn-webcomp-header>
|
|
27
27
|
<div id="main-content-wrapper"></div>
|
|
28
28
|
|
|
29
|
-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/
|
|
30
|
-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/
|
|
29
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/18.3.1/umd/react.development.js"></script>
|
|
30
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.3.1/umd/react-dom.development.js"></script>
|
|
31
31
|
|
|
32
32
|
<!-- IMPORT header-footer script -->
|
|
33
33
|
<script type="module" src="https://static-hn-mas-01.int-hn.nhn.no/header-footer/static/js/header-footer/header-footer.js"></script>
|
|
34
|
-
<script src="index.js"></script>
|
|
34
|
+
<script type="module" src="index.js"></script>
|
|
35
35
|
</body>
|
|
36
36
|
</html>
|
package/library-scripts.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const sync = require('cross-spawn').sync;
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
const scriptIndex = args.findIndex(x => x === 'start' || x === 'build' || x === 'copy');
|
|
8
|
+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
|
|
9
|
+
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
|
|
9
10
|
switch (script) {
|
|
10
11
|
case 'start':
|
|
11
|
-
case '
|
|
12
|
+
case 'build':
|
|
12
13
|
case 'copy': {
|
|
13
|
-
|
|
14
|
+
const result = sync('node', nodeArgs.concat(require.resolve('./' + script)).concat(args.slice(scriptIndex + 1)), {
|
|
14
15
|
stdio: 'inherit',
|
|
15
16
|
});
|
|
16
17
|
if (result.signal) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helsenorge/library-build",
|
|
3
3
|
"author": "Norsk helsenett SF",
|
|
4
|
-
"version": "
|
|
5
|
-
"
|
|
4
|
+
"version": "33.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "https://github.com/helsenorge/core-frontend-packages"
|
|
@@ -11,40 +12,31 @@
|
|
|
11
12
|
"library-scripts": "./library-scripts.js"
|
|
12
13
|
},
|
|
13
14
|
"license": "MIT",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"react": "^18.0.0",
|
|
17
|
+
"react-dom": "^18.0.0"
|
|
18
|
+
},
|
|
14
19
|
"dependencies": {
|
|
15
|
-
"@
|
|
16
|
-
"@
|
|
17
|
-
"@testing-library/
|
|
18
|
-
"@testing-library/react": "^12.1.5",
|
|
20
|
+
"@helsenorge/eslint-config": "^33.0.0",
|
|
21
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
22
|
+
"@testing-library/react": "^16.0.1",
|
|
19
23
|
"@testing-library/user-event": "^14.5.2",
|
|
20
24
|
"@types/copyfiles": "^2.4.4",
|
|
21
|
-
"@types/
|
|
22
|
-
"@types/
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"crlf": "1.1.1",
|
|
30
|
-
"cross-spawn": "7.0.3",
|
|
31
|
-
"enzyme": "^3.11.0",
|
|
32
|
-
"enzyme-to-json": "^3.6.2",
|
|
33
|
-
"esbuild": "^0.20.2",
|
|
34
|
-
"esbuild-sass-plugin": "^3.2.0",
|
|
35
|
-
"identity-obj-proxy": "^3.0.0",
|
|
36
|
-
"isomorphic-fetch": "^3.0.0",
|
|
37
|
-
"jest": "^29.7.0",
|
|
38
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
39
|
-
"jest-junit-reporter": "^1.1.0",
|
|
40
|
-
"jest-resolve": "^29.7.0",
|
|
41
|
-
"postcss": "^8.4.38",
|
|
25
|
+
"@types/react": "^18.3.12",
|
|
26
|
+
"@types/react-dom": "^18.3.1",
|
|
27
|
+
"@vitest/coverage-v8": "^2.1.4",
|
|
28
|
+
"copyfiles": "^2.4.1",
|
|
29
|
+
"cross-spawn": "^7.0.3",
|
|
30
|
+
"esbuild": "^0.21.5",
|
|
31
|
+
"esbuild-sass-plugin": "^3.3.1",
|
|
32
|
+
"postcss": "^8.4.47",
|
|
42
33
|
"postcss-modules": "^6.0.0",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
34
|
+
"rimraf": "^6.0.1",
|
|
35
|
+
"typed-scss-modules": "^8.0.1",
|
|
36
|
+
"typescript": "~5.5.4",
|
|
37
|
+
"vitest": "^2.1.4",
|
|
38
|
+
"whatwg-fetch": "^3.6.20",
|
|
39
|
+
"yargs": "^17.7.2"
|
|
48
40
|
},
|
|
49
41
|
"publishConfig": {
|
|
50
42
|
"access": "public"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTests.vite.d.ts","sourceRoot":"","sources":["../src/setupTests.vite.ts"],"names":[],"mappings":"AACA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,cAAc,CAAC;AAEtB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC7B;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { vi } from 'vitest';
|
|
2
|
+
import '@testing-library/jest-dom/vitest';
|
|
3
|
+
import 'whatwg-fetch';
|
|
4
|
+
window.HN = {
|
|
5
|
+
Page: {},
|
|
6
|
+
Rest: {},
|
|
7
|
+
User: {},
|
|
8
|
+
Commands: {},
|
|
9
|
+
PortalCommands: {},
|
|
10
|
+
};
|
|
11
|
+
const MatchMediaMock = vi.fn(() => ({
|
|
12
|
+
matches: true,
|
|
13
|
+
addListener: vi.fn(),
|
|
14
|
+
addEventListener: vi.fn(),
|
|
15
|
+
removeEventListener: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
vi.stubGlobal('matchMedia', MatchMediaMock);
|
|
18
|
+
const IntersectionObserverMock = vi.fn(() => ({
|
|
19
|
+
observe: vi.fn(),
|
|
20
|
+
unobserve: vi.fn(),
|
|
21
|
+
disconnect: vi.fn(),
|
|
22
|
+
}));
|
|
23
|
+
vi.stubGlobal('IntersectionObserver', IntersectionObserverMock);
|
|
24
|
+
const ResizeObserverMock = vi.fn(() => ({
|
|
25
|
+
observe: vi.fn(),
|
|
26
|
+
unobserve: vi.fn(),
|
|
27
|
+
disconnect: vi.fn(),
|
|
28
|
+
}));
|
|
29
|
+
vi.stubGlobal('ResizeObserver', ResizeObserverMock);
|
|
30
|
+
const MutationObserverMock = vi.fn(() => ({
|
|
31
|
+
observe: vi.fn(),
|
|
32
|
+
disconnect: vi.fn(),
|
|
33
|
+
}));
|
|
34
|
+
vi.stubGlobal('MutationObserver', MutationObserverMock);
|
|
35
|
+
window.HTMLElement.prototype.scrollIntoView = vi.fn();
|
package/start.js
CHANGED
|
@@ -1,83 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
})];
|
|
67
|
-
case 2:
|
|
68
|
-
context = _b.sent();
|
|
69
|
-
return [4 /*yield*/, context.watch()];
|
|
70
|
-
case 3:
|
|
71
|
-
_b.sent();
|
|
72
|
-
return [4 /*yield*/, context.serve({
|
|
73
|
-
port: 3000,
|
|
74
|
-
host: 'localhost',
|
|
75
|
-
servedir: outDir,
|
|
76
|
-
fallback: outDir + '/index.html',
|
|
77
|
-
})];
|
|
78
|
-
case 4:
|
|
79
|
-
_b.sent();
|
|
80
|
-
return [2 /*return*/];
|
|
81
|
-
}
|
|
1
|
+
import { existsSync, mkdirSync, copyFileSync } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import url from 'url';
|
|
4
|
+
import esbuild from 'esbuild';
|
|
5
|
+
import { sassPlugin, postcssModules } from 'esbuild-sass-plugin';
|
|
6
|
+
import yargs from 'yargs';
|
|
7
|
+
import { hideBin } from 'yargs/helpers';
|
|
8
|
+
const __filename = url.fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
(async () => {
|
|
11
|
+
const { entry, outDir } = await yargs(hideBin(process.argv))
|
|
12
|
+
.options({
|
|
13
|
+
entry: { type: 'string', default: 'src/__devonly__/index.tsx' },
|
|
14
|
+
outDir: { type: 'string', default: 'dist' },
|
|
15
|
+
})
|
|
16
|
+
.parse();
|
|
17
|
+
if (!existsSync(outDir)) {
|
|
18
|
+
mkdirSync(outDir);
|
|
19
|
+
}
|
|
20
|
+
copyFileSync(__dirname + '/index.html', outDir + '/index.html');
|
|
21
|
+
const context = await esbuild.context({
|
|
22
|
+
format: 'esm',
|
|
23
|
+
logLevel: 'debug',
|
|
24
|
+
entryPoints: [entry],
|
|
25
|
+
outdir: outDir,
|
|
26
|
+
bundle: true,
|
|
27
|
+
define: {
|
|
28
|
+
global: 'window',
|
|
29
|
+
'import.meta.env': '{}',
|
|
30
|
+
},
|
|
31
|
+
loader: {
|
|
32
|
+
'.svg': 'dataurl',
|
|
33
|
+
'.woff': 'dataurl',
|
|
34
|
+
'.woff2': 'dataurl',
|
|
35
|
+
},
|
|
36
|
+
plugins: [
|
|
37
|
+
sassPlugin({
|
|
38
|
+
filter: /.module.(s[ac]ss|css)$/,
|
|
39
|
+
type: 'css',
|
|
40
|
+
transform: postcssModules({
|
|
41
|
+
// ...put here the options for postcss-modules: https://github.com/madyankin/postcss-modules
|
|
42
|
+
}),
|
|
43
|
+
importMapper: path => (path.endsWith('styles.module') ? path + '.scss' : path),
|
|
44
|
+
precompile(source, pathname) {
|
|
45
|
+
const basedir = path.dirname(pathname);
|
|
46
|
+
return source.replace(/(url\(['"]?)(\.\.?\/)([^'")]+['"]?\))/g, '$1'.concat(basedir.replace(/\\/g, '\\\\'), '/$2$3'));
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
sassPlugin({
|
|
50
|
+
filter: /.(s[ac]ss|css)$/,
|
|
51
|
+
type: 'style',
|
|
52
|
+
}),
|
|
53
|
+
{
|
|
54
|
+
name: 'resolve-fonts',
|
|
55
|
+
setup(build) {
|
|
56
|
+
build.onResolve({ filter: /\.woff2?$/ }, ({ path }) => {
|
|
57
|
+
return { path };
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
],
|
|
82
62
|
});
|
|
83
|
-
|
|
63
|
+
await context.watch();
|
|
64
|
+
await context.serve({
|
|
65
|
+
port: 3000,
|
|
66
|
+
host: 'localhost',
|
|
67
|
+
servedir: outDir,
|
|
68
|
+
fallback: outDir + '/index.html',
|
|
69
|
+
});
|
|
70
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../src/vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,eAAe,CAAC;AAE3D,eAAO,MAAM,SAAS,EAAE,YAgCvB,CAAC;;AAEF,wBAAmD"}
|
package/vitest.config.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
export const getConfig = () => {
|
|
3
|
+
return {
|
|
4
|
+
test: {
|
|
5
|
+
include: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
6
|
+
globals: true,
|
|
7
|
+
environment: 'jsdom',
|
|
8
|
+
environmentOptions: {
|
|
9
|
+
jsdom: {
|
|
10
|
+
url: 'http://tjenester.helsenorge.utvikling',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
setupFiles: ['node_modules/@helsenorge/library-build/setupTests.vite'],
|
|
14
|
+
css: {
|
|
15
|
+
modules: {
|
|
16
|
+
classNameStrategy: 'non-scoped',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
coverage: {
|
|
20
|
+
enabled: true,
|
|
21
|
+
reporter: ['cobertura', 'lcov', 'json'],
|
|
22
|
+
},
|
|
23
|
+
reporters: ['default', 'junit'],
|
|
24
|
+
outputFile: {
|
|
25
|
+
junit: 'test-report.xml',
|
|
26
|
+
},
|
|
27
|
+
server: {
|
|
28
|
+
deps: {
|
|
29
|
+
inline: ['@helsenorge/designsystem-react', '@helsenorge/datepicker', '@helsenorge/lightbox', '@portabletext/react'],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export default defineConfig(env => getConfig(env));
|
package/config/babel.config.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const parentBabelConfig = {
|
|
2
|
-
presets: [
|
|
3
|
-
['@babel/preset-env', { targets: { node: 'current' } }],
|
|
4
|
-
['@babel/preset-react', { typescript: true }],
|
|
5
|
-
['@babel/preset-typescript', { allExtensions: true, isTSX: true }],
|
|
6
|
-
],
|
|
7
|
-
plugins: [
|
|
8
|
-
'@babel/plugin-syntax-dynamic-import',
|
|
9
|
-
['@babel/plugin-proposal-class-properties', { loose: true }],
|
|
10
|
-
'@babel/plugin-transform-object-rest-spread',
|
|
11
|
-
],
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
module.exports = parentBabelConfig;
|
package/jest.config.d.ts
DELETED
package/jest.config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jest.config.d.ts","sourceRoot":"","sources":["../src/jest.config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAanC,QAAA,MAAM,MAAM,EAAE,MAuCb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/jest.config.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
/* Legger til babel-jest + esm og babel-jest igjen uner 'transform' for å kunne håndtere esm import/exports */
|
|
5
|
-
/* Viktig å ha @helsenorge pakker under transformIgnorePatterns fordi de eksporteres i rå esm */
|
|
6
|
-
var individualConfig;
|
|
7
|
-
var rootDir = process.cwd();
|
|
8
|
-
try {
|
|
9
|
-
individualConfig = require(rootDir + '/jest.config.cjs');
|
|
10
|
-
}
|
|
11
|
-
catch (ex) {
|
|
12
|
-
console.log('Benytter delt jest.config.js-fil');
|
|
13
|
-
}
|
|
14
|
-
var config = tslib_1.__assign({ rootDir: rootDir, verbose: true, setupFilesAfterEnv: ['<rootDir>/node_modules/@helsenorge/library-build/setupTests.js'], coverageProvider: 'v8', testEnvironment: 'jest-environment-jsdom', testEnvironmentOptions: {
|
|
15
|
-
url: 'http://tjenester.helsenorge.utvikling',
|
|
16
|
-
}, transform: {
|
|
17
|
-
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
|
|
18
|
-
}, transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\](?!(@helsenorge)[/\\\\])', '^.+\\.module\\.(css|sass|scss|scss.d.ts)$'], coverageReporters: ['cobertura', 'lcov', 'json'], collectCoverage: true, collectCoverageFrom: [
|
|
19
|
-
'**/*.ts',
|
|
20
|
-
'**/*.tsx',
|
|
21
|
-
'!**/node_modules/**',
|
|
22
|
-
'!**/lib/**',
|
|
23
|
-
'!**/dist/**',
|
|
24
|
-
'!**/__devonly__/**',
|
|
25
|
-
'!**/scripts/**',
|
|
26
|
-
'!**/types/**',
|
|
27
|
-
'!**/constants/*.ts',
|
|
28
|
-
'!**/*types.ts',
|
|
29
|
-
], moduleNameMapper: {
|
|
30
|
-
'\\.(css|scss)$': 'identity-obj-proxy',
|
|
31
|
-
}, moduleDirectories: ['node_modules', 'src'],
|
|
32
|
-
// Unngå warning om jest-haste-map: Haste module naming collision
|
|
33
|
-
modulePathIgnorePatterns: ['lib'], moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'], coveragePathIgnorePatterns: ['^.+\\.module\\.(css|sass|scss|scss.d.ts)$'], testResultsProcessor: 'jest-junit-reporter', snapshotSerializers: ['enzyme-to-json/serializer'], cacheDirectory: '<rootDir>/.jest-cache' }, individualConfig);
|
|
34
|
-
exports.default = config;
|
package/setupTests.d.ts
DELETED
package/setupTests.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../src/setupTests.ts"],"names":[],"mappings":"AAIA,OAAO,yCAAyC,CAAC;AACjD,OAAO,kBAAkB,CAAC;AAO1B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC7B;CACF"}
|
package/setupTests.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
|
5
|
-
// allows you to do things like:
|
|
6
|
-
// expect(element).toHaveTextContent(/react/i)
|
|
7
|
-
// learn more: https://github.com/testing-library/jest-dom
|
|
8
|
-
require("@testing-library/jest-dom/extend-expect");
|
|
9
|
-
require("isomorphic-fetch");
|
|
10
|
-
var enzyme_adapter_react_17_1 = tslib_1.__importDefault(require("@wojtekmaj/enzyme-adapter-react-17"));
|
|
11
|
-
var enzyme_1 = require("enzyme");
|
|
12
|
-
// configuring enzyme adapter
|
|
13
|
-
(0, enzyme_1.configure)({ adapter: new enzyme_adapter_react_17_1.default() });
|
|
14
|
-
window.HN = {
|
|
15
|
-
Page: {},
|
|
16
|
-
Rest: {},
|
|
17
|
-
User: {},
|
|
18
|
-
Commands: {},
|
|
19
|
-
PortalCommands: {},
|
|
20
|
-
};
|
|
21
|
-
var mockWindowMatchMedia = jest.fn().mockImplementation(function () { return ({
|
|
22
|
-
matches: true,
|
|
23
|
-
addEventListener: jest.fn(),
|
|
24
|
-
removeEventListener: jest.fn(),
|
|
25
|
-
}); });
|
|
26
|
-
Object.defineProperty(window, 'matchMedia', {
|
|
27
|
-
writable: true,
|
|
28
|
-
value: mockWindowMatchMedia,
|
|
29
|
-
});
|
|
30
|
-
var IntersectionObserver = /** @class */ (function () {
|
|
31
|
-
function IntersectionObserver() {
|
|
32
|
-
}
|
|
33
|
-
IntersectionObserver.prototype.observe = function () {
|
|
34
|
-
// do nothing
|
|
35
|
-
};
|
|
36
|
-
IntersectionObserver.prototype.unobserve = function () {
|
|
37
|
-
// do nothing
|
|
38
|
-
};
|
|
39
|
-
IntersectionObserver.prototype.disconnect = function () {
|
|
40
|
-
// do nothing
|
|
41
|
-
};
|
|
42
|
-
return IntersectionObserver;
|
|
43
|
-
}());
|
|
44
|
-
Object.defineProperty(window, 'IntersectionObserver', {
|
|
45
|
-
writable: true,
|
|
46
|
-
value: IntersectionObserver,
|
|
47
|
-
});
|
|
48
|
-
var ResizeObserver = /** @class */ (function () {
|
|
49
|
-
function ResizeObserver() {
|
|
50
|
-
}
|
|
51
|
-
ResizeObserver.prototype.observe = function () {
|
|
52
|
-
// do nothing
|
|
53
|
-
};
|
|
54
|
-
ResizeObserver.prototype.unobserve = function () {
|
|
55
|
-
// do nothing
|
|
56
|
-
};
|
|
57
|
-
ResizeObserver.prototype.disconnect = function () {
|
|
58
|
-
// do nothing
|
|
59
|
-
};
|
|
60
|
-
return ResizeObserver;
|
|
61
|
-
}());
|
|
62
|
-
Object.defineProperty(window, 'ResizeObserver', {
|
|
63
|
-
writable: true,
|
|
64
|
-
value: ResizeObserver,
|
|
65
|
-
});
|
|
66
|
-
var MutationObserver = /** @class */ (function () {
|
|
67
|
-
function MutationObserver() {
|
|
68
|
-
}
|
|
69
|
-
MutationObserver.prototype.observe = function () {
|
|
70
|
-
// do nothing
|
|
71
|
-
};
|
|
72
|
-
MutationObserver.prototype.disconnect = function () {
|
|
73
|
-
// do nothing
|
|
74
|
-
};
|
|
75
|
-
return MutationObserver;
|
|
76
|
-
}());
|
|
77
|
-
Object.defineProperty(window, 'MutationObserver', {
|
|
78
|
-
writable: true,
|
|
79
|
-
value: MutationObserver,
|
|
80
|
-
});
|
package/test.d.ts
DELETED
package/test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,YAAY,KAAkB,CAAC;AACrC,QAAA,MAAM,IAAI,UAAwB,CAAC"}
|
package/test.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var _a;
|
|
3
|
-
// Do this as the first thing so that any code reading it knows the right env.
|
|
4
|
-
process.env.BABEL_ENV = 'test';
|
|
5
|
-
process.env.NODE_ENV = 'test';
|
|
6
|
-
process.env.PUBLIC_URL = '';
|
|
7
|
-
process.env.TZ = (_a = process.env.TZ) !== null && _a !== void 0 ? _a : 'Europe/Oslo';
|
|
8
|
-
// Makes the script crash on unhandled rejections instead of silently
|
|
9
|
-
// ignoring them. In the future, promise rejections that are not handled will
|
|
10
|
-
// terminate the Node.js process with a non-zero exit code.
|
|
11
|
-
process.on('unhandledRejection', function (err) {
|
|
12
|
-
throw err;
|
|
13
|
-
});
|
|
14
|
-
var jestInstance = require('jest');
|
|
15
|
-
var argv = process.argv.slice(2);
|
|
16
|
-
// Always set config
|
|
17
|
-
argv.push('--coverage');
|
|
18
|
-
argv.push('--verbose');
|
|
19
|
-
argv.push('--no-cache');
|
|
20
|
-
argv.push('--config=node_modules/@helsenorge/library-build/jest.config.js');
|
|
21
|
-
console.log('Du kjører jest med følgende arguments: ', argv);
|
|
22
|
-
jestInstance.run(argv);
|