@helsenorge/library-build 37.1.0 → 38.0.2
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/{copy.js → lib/copy.js} +4 -11
- package/lib/exports.d.ts +2 -0
- package/lib/exports.d.ts.map +1 -0
- package/lib/exports.js +108 -0
- package/lib/library-scripts.d.ts +3 -0
- package/{library-scripts.js → lib/library-scripts.js} +3 -3
- package/lib/setupTests.vite.d.ts.map +1 -0
- package/lib/setupTests.vite.js +34 -0
- package/lib/vitest.config.d.ts +5 -0
- package/{vitest.config.d.ts.map → lib/vitest.config.d.ts.map} +1 -1
- package/{vitest.config.js → lib/vitest.config.js} +2 -2
- package/package.json +70 -25
- package/build.d.ts +0 -2
- package/build.d.ts.map +0 -1
- package/build.js +0 -24
- package/files.d.ts +0 -6
- package/files.d.ts.map +0 -1
- package/files.js +0 -47
- package/library-scripts.d.ts +0 -3
- package/setupTests.vite.d.ts.map +0 -1
- package/setupTests.vite.js +0 -47
- package/vitest.config.d.ts +0 -5
- /package/{copy.d.ts → lib/copy.d.ts} +0 -0
- /package/{copy.d.ts.map → lib/copy.d.ts.map} +0 -0
- /package/{library-scripts.d.ts.map → lib/library-scripts.d.ts.map} +0 -0
- /package/{setupTests.vite.d.ts → lib/setupTests.vite.d.ts} +0 -0
- /package/{vite.config.d.ts → lib/vite.config.d.ts} +0 -0
- /package/{vite.config.d.ts.map → lib/vite.config.d.ts.map} +0 -0
- /package/{vite.config.js → lib/vite.config.js} +0 -0
package/{copy.js → lib/copy.js}
RENAMED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
1
|
import path from 'path';
|
|
3
2
|
import copyfiles from 'copyfiles';
|
|
4
3
|
import { rimraf } from 'rimraf';
|
|
5
4
|
import yargs from 'yargs';
|
|
6
5
|
import { hideBin } from 'yargs/helpers';
|
|
7
|
-
const
|
|
8
|
-
import { createPackageJsonFile } from './files.js';
|
|
9
|
-
const { root, include, utils, rm } = yargs(hideBin(process.argv))
|
|
6
|
+
const { outDir, root, include, utils, rm } = yargs(hideBin(process.argv))
|
|
10
7
|
.options({
|
|
8
|
+
outDir: { describe: 'Output directory', type: 'string', default: 'lib' },
|
|
11
9
|
root: { describe: 'Files to copy to root directory', type: 'array', default: [] },
|
|
12
10
|
include: { describe: 'Files to copy from src to lib, replacing "src" with "lib"', type: 'array', default: [] },
|
|
13
11
|
utils: { describe: 'Files to copy to lib/utils', type: 'array', default: [] },
|
|
14
12
|
rm: { describe: 'Files to delete', type: 'array', default: [] },
|
|
15
13
|
})
|
|
16
14
|
.parse();
|
|
17
|
-
const
|
|
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');
|
|
15
|
+
const outputPath = path.resolve(process.cwd(), outDir);
|
|
21
16
|
Promise.all([
|
|
22
17
|
new Promise((resolve, reject) => root.length > 0 ? copyfiles([...root, outputPath], { error: true }, e => (e ? reject(e) : resolve())) : resolve()),
|
|
23
18
|
new Promise((resolve, reject) => include.length > 0 ? copyfiles([...include, outputPath], { up: 1, error: true }, e => (e ? reject(e) : resolve())) : resolve()),
|
|
24
19
|
new Promise((resolve, reject) => utils.length > 0
|
|
25
20
|
? copyfiles([...utils, path.resolve(outputPath, 'utils')], { up: true, error: true }, e => (e ? reject(e) : resolve()))
|
|
26
21
|
: resolve()),
|
|
27
|
-
])
|
|
28
|
-
.then(() => (rm ? rimraf(rm, { glob: true }) : Promise.resolve(true)))
|
|
29
|
-
.then(() => createPackageJsonFile(packageName, originalPackageJson, newPackageJson));
|
|
22
|
+
]).then(() => (rm ? rimraf(rm, { glob: true }) : Promise.resolve(true)));
|
package/lib/exports.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":""}
|
package/lib/exports.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { globSync } from 'glob';
|
|
4
|
+
// 1. CONFIGURATION
|
|
5
|
+
const PACKAGE_JSON_PATH = 'package.json';
|
|
6
|
+
// Directories that should be "flattened" in exports.
|
|
7
|
+
// e.g. lib/foo.js -> ./foo (instead of ./lib/foo)
|
|
8
|
+
const FLATTEN_DIRS = new Set(['lib', 'dist']);
|
|
9
|
+
const IGNORE_PATTERNS = [
|
|
10
|
+
'**/*.map',
|
|
11
|
+
'**/*.test.js',
|
|
12
|
+
'**/*.spec.js',
|
|
13
|
+
'**/__tests__/**',
|
|
14
|
+
'**/*.scss.d.ts',
|
|
15
|
+
'**/package.json',
|
|
16
|
+
'**/*.tsbuildinfo',
|
|
17
|
+
];
|
|
18
|
+
function run() {
|
|
19
|
+
const cwd = process.cwd();
|
|
20
|
+
const pkgPath = path.resolve(cwd, PACKAGE_JSON_PATH);
|
|
21
|
+
if (!fs.existsSync(pkgPath)) {
|
|
22
|
+
console.error(`❌ package.json not found in ${cwd}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
26
|
+
// Default to 'lib' if "files" is missing, but usually it respects package.json
|
|
27
|
+
const dirsToScan = pkg.files || ['lib'];
|
|
28
|
+
// Start with standard package.json export
|
|
29
|
+
const exportMap = {
|
|
30
|
+
'./package.json': './package.json',
|
|
31
|
+
};
|
|
32
|
+
let totalFilesFound = 0;
|
|
33
|
+
dirsToScan.forEach(dirEntry => {
|
|
34
|
+
const dirPath = path.resolve(cwd, dirEntry);
|
|
35
|
+
// Only process directories (skip root files like README.md in the files array)
|
|
36
|
+
if (!fs.existsSync(dirPath) || !fs.statSync(dirPath).isDirectory()) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// Determine if we strip this directory from the export key
|
|
40
|
+
// lib/foo.js -> ./foo (Flattened)
|
|
41
|
+
// config/foo.json -> ./config/foo.json (Not flattened)
|
|
42
|
+
const shouldFlatten = FLATTEN_DIRS.has(dirEntry);
|
|
43
|
+
// Scan the directory
|
|
44
|
+
const files = globSync('**/*.{js,d.ts,json}', {
|
|
45
|
+
cwd: dirPath,
|
|
46
|
+
ignore: IGNORE_PATTERNS,
|
|
47
|
+
posix: true,
|
|
48
|
+
});
|
|
49
|
+
const jsFileSet = new Set(files.filter(f => f.endsWith('.js')));
|
|
50
|
+
files.forEach(file => {
|
|
51
|
+
// "file" is relative to "dirEntry" (e.g. "utils/date.js")
|
|
52
|
+
const fullPath = `./${dirEntry}/${file}`;
|
|
53
|
+
// Calculate the base path for the export key
|
|
54
|
+
// If flat: "utils/date.js"
|
|
55
|
+
// If not flat: "config/utils/date.js"
|
|
56
|
+
const pathForExport = shouldFlatten ? file : `${dirEntry}/${file}`;
|
|
57
|
+
let exportKey = '';
|
|
58
|
+
// --- CASE 1: JavaScript ---
|
|
59
|
+
if (file.endsWith('.js')) {
|
|
60
|
+
if (pathForExport.endsWith('index.js')) {
|
|
61
|
+
// lib/components/index.js -> ./components
|
|
62
|
+
// config/index.js -> ./config
|
|
63
|
+
const dirName = path.dirname(pathForExport);
|
|
64
|
+
exportKey = dirName === '.' ? '.' : `./${dirName}`;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// lib/utils.js -> ./utils
|
|
68
|
+
const baseName = pathForExport.substring(0, pathForExport.length - 3);
|
|
69
|
+
exportKey = `./${baseName}`;
|
|
70
|
+
}
|
|
71
|
+
exportMap[exportKey] = fullPath;
|
|
72
|
+
}
|
|
73
|
+
// --- CASE 2: JSON ---
|
|
74
|
+
else if (file.endsWith('.json')) {
|
|
75
|
+
// Always keep extension for JSON
|
|
76
|
+
exportKey = `./${pathForExport}`;
|
|
77
|
+
exportMap[exportKey] = fullPath;
|
|
78
|
+
}
|
|
79
|
+
// --- CASE 3: Type Definitions (Orphans) ---
|
|
80
|
+
else if (file.endsWith('.d.ts')) {
|
|
81
|
+
const jsSibling = file.replace(/\.d\.ts$/, '.js');
|
|
82
|
+
// Skip if JS sibling exists (TS finds it automatically)
|
|
83
|
+
if (jsFileSet.has(jsSibling)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// Export standalone type
|
|
87
|
+
const baseName = pathForExport.substring(0, pathForExport.length - 5);
|
|
88
|
+
exportKey = `./${baseName}`;
|
|
89
|
+
exportMap[exportKey] = fullPath;
|
|
90
|
+
}
|
|
91
|
+
totalFilesFound++;
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
// SORTING
|
|
95
|
+
const sortedExports = Object.keys(exportMap)
|
|
96
|
+
.sort()
|
|
97
|
+
.reduce((obj, key) => {
|
|
98
|
+
obj[key] = exportMap[key];
|
|
99
|
+
return obj;
|
|
100
|
+
}, {});
|
|
101
|
+
// WRITE
|
|
102
|
+
pkg.exports = sortedExports;
|
|
103
|
+
delete pkg.typesVersions; // Clean up legacy field
|
|
104
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
105
|
+
console.log(`✅ Scanned [${dirsToScan.join(', ')}]`);
|
|
106
|
+
console.log(`✅ Generated ${Object.keys(sortedExports).length} exports in package.json`);
|
|
107
|
+
}
|
|
108
|
+
run();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import yargs from 'yargs';
|
|
@@ -7,9 +7,9 @@ const require = createRequire(import.meta.url);
|
|
|
7
7
|
const args = hideBin(process.argv);
|
|
8
8
|
yargs(args)
|
|
9
9
|
.command({
|
|
10
|
-
command: '
|
|
10
|
+
command: 'exports',
|
|
11
11
|
handler: () => {
|
|
12
|
-
const result = spawnSync('node', [require.resolve('./
|
|
12
|
+
const result = spawnSync('node', [require.resolve('./exports'), ...args.slice(1)], {
|
|
13
13
|
stdio: 'inherit',
|
|
14
14
|
});
|
|
15
15
|
if (result.status) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupTests.vite.d.ts","sourceRoot":"","sources":["../src/setupTests.vite.ts"],"names":[],"mappings":"AACA,OAAO,kCAAkC,CAAC;AAE1C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC7B;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { vi } from 'vitest';
|
|
2
|
+
import '@testing-library/jest-dom/vitest';
|
|
3
|
+
window.HN = {
|
|
4
|
+
Page: {},
|
|
5
|
+
Rest: {},
|
|
6
|
+
User: {},
|
|
7
|
+
Commands: {},
|
|
8
|
+
PortalCommands: {},
|
|
9
|
+
};
|
|
10
|
+
const MatchMediaMock = vi.fn((query) => ({
|
|
11
|
+
matches: query !== '(prefers-reduced-motion)',
|
|
12
|
+
addListener: vi.fn(),
|
|
13
|
+
addEventListener: vi.fn(),
|
|
14
|
+
removeEventListener: vi.fn(),
|
|
15
|
+
}));
|
|
16
|
+
vi.stubGlobal('matchMedia', MatchMediaMock);
|
|
17
|
+
const IntersectionObserverMock = vi.fn(class {
|
|
18
|
+
observe = vi.fn();
|
|
19
|
+
unobserve = vi.fn();
|
|
20
|
+
disconnect = vi.fn();
|
|
21
|
+
});
|
|
22
|
+
vi.stubGlobal('IntersectionObserver', IntersectionObserverMock);
|
|
23
|
+
const ResizeObserverMock = vi.fn(class {
|
|
24
|
+
observe = vi.fn();
|
|
25
|
+
unobserve = vi.fn();
|
|
26
|
+
disconnect = vi.fn();
|
|
27
|
+
});
|
|
28
|
+
vi.stubGlobal('ResizeObserver', ResizeObserverMock);
|
|
29
|
+
const MutationObserverMock = vi.fn(class {
|
|
30
|
+
observe = vi.fn();
|
|
31
|
+
disconnect = vi.fn();
|
|
32
|
+
});
|
|
33
|
+
vi.stubGlobal('MutationObserver', MutationObserverMock);
|
|
34
|
+
window.HTMLElement.prototype.scrollIntoView = vi.fn();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../src/vitest.config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../src/vitest.config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAwC,MAAM,eAAe,CAAC;AAE5F,eAAO,MAAM,SAAS,EAAE,gBAmCvB,CAAC;;AAEF,wBAAmD"}
|
|
@@ -13,7 +13,7 @@ export const getConfig = () => {
|
|
|
13
13
|
url: 'http://tjenester.helsenorge.utvikling',
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
|
-
setupFiles: ['
|
|
16
|
+
setupFiles: ['@helsenorge/library-build/setupTests.vite'],
|
|
17
17
|
css: {
|
|
18
18
|
modules: {
|
|
19
19
|
classNameStrategy: 'non-scoped',
|
|
@@ -31,7 +31,7 @@ export const getConfig = () => {
|
|
|
31
31
|
},
|
|
32
32
|
server: {
|
|
33
33
|
deps: {
|
|
34
|
-
inline: [
|
|
34
|
+
inline: [/@helsenorge/, '@portabletext/react'],
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
37
|
},
|
package/package.json
CHANGED
|
@@ -1,46 +1,91 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helsenorge/library-build",
|
|
3
|
+
"version": "38.0.2",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
3
7
|
"author": "Norsk helsenett SF",
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
"maintainers": [
|
|
9
|
+
"ROX"
|
|
10
|
+
],
|
|
11
|
+
"description": "Bygg og test av komponentbibliotek",
|
|
12
|
+
"license": "MIT",
|
|
7
13
|
"repository": {
|
|
8
14
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/helsenorge/core-frontend-packages"
|
|
15
|
+
"url": "git+https://github.com/helsenorge/core-frontend-packages.git"
|
|
10
16
|
},
|
|
11
17
|
"bin": {
|
|
12
|
-
"library-scripts": "./library-scripts.js"
|
|
18
|
+
"library-scripts": "./lib/library-scripts.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"config",
|
|
22
|
+
"lib"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
"./config/tsconfig.global.json": "./config/tsconfig.global.json",
|
|
26
|
+
"./config/tsconfig.node.json": "./config/tsconfig.node.json",
|
|
27
|
+
"./config/tsconfig.vite.json": "./config/tsconfig.vite.json",
|
|
28
|
+
"./copy": "./lib/copy.js",
|
|
29
|
+
"./exports": "./lib/exports.js",
|
|
30
|
+
"./library-scripts": "./lib/library-scripts.js",
|
|
31
|
+
"./package.json": "./package.json",
|
|
32
|
+
"./setupTests.vite": "./lib/setupTests.vite.js",
|
|
33
|
+
"./vite.config": "./lib/vite.config.js",
|
|
34
|
+
"./vitest.config": "./lib/vitest.config.js"
|
|
35
|
+
},
|
|
36
|
+
"type": "module",
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"scripts": {
|
|
39
|
+
"clean": "rimraf lib",
|
|
40
|
+
"prebuild": "npm run clean",
|
|
41
|
+
"build": "tsc",
|
|
42
|
+
"postbuild": "npm-run-all chmod exports",
|
|
43
|
+
"chmod": "chmod +x lib/library-scripts.js",
|
|
44
|
+
"exports": "node ./lib/library-scripts.js exports",
|
|
45
|
+
"watch": "tsc --watch",
|
|
46
|
+
"eslint": "eslint src/**/*.{js,jsx,ts,tsx}",
|
|
47
|
+
"eslint:fix": "npm run eslint -- --fix",
|
|
48
|
+
"prettier": "prettier --check \"src/**/*.{ts,tsx,js,jsx,css,scss,md,json}\"",
|
|
49
|
+
"prettier:fix": "npm run prettier -- --write",
|
|
50
|
+
"pretypecheck": "tsc -v",
|
|
51
|
+
"typecheck": "tsc --noEmit"
|
|
13
52
|
},
|
|
14
|
-
"license": "MIT",
|
|
15
53
|
"peerDependencies": {
|
|
16
|
-
"react": "^
|
|
17
|
-
"react-dom": "^
|
|
54
|
+
"react": "^19.0.0",
|
|
55
|
+
"react-dom": "^19.0.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/node": "^24.12.0",
|
|
59
|
+
"@types/yargs": "^17.0.35",
|
|
60
|
+
"npm-run-all2": "^8.0.4",
|
|
61
|
+
"react": "^19.2.4",
|
|
62
|
+
"react-dom": "^19.2.4"
|
|
18
63
|
},
|
|
19
64
|
"dependencies": {
|
|
20
|
-
"@helsenorge/eslint-config": "^
|
|
21
|
-
"@helsenorge/typed-scss-modules": "^9.0.
|
|
65
|
+
"@helsenorge/eslint-config": "^38.0.2",
|
|
66
|
+
"@helsenorge/typed-scss-modules": "^9.0.9",
|
|
22
67
|
"@testing-library/jest-dom": "^6.9.1",
|
|
23
|
-
"@testing-library/react": "^16.3.
|
|
68
|
+
"@testing-library/react": "^16.3.2",
|
|
24
69
|
"@testing-library/user-event": "^14.6.1",
|
|
25
70
|
"@types/copyfiles": "^2.4.4",
|
|
26
|
-
"@types/react": "^19.2.
|
|
71
|
+
"@types/react": "^19.2.14",
|
|
27
72
|
"@types/react-dom": "^19.2.3",
|
|
28
|
-
"@vitejs/plugin-react": "^5.1.
|
|
29
|
-
"@vitest/coverage-v8": "^
|
|
73
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
74
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
30
75
|
"copyfiles": "^2.4.1",
|
|
31
|
-
"esbuild": "~0.27.0",
|
|
32
76
|
"jsdom": "^26.1.0",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"sass": "^1.
|
|
36
|
-
"sass-embedded": "^1.93.3",
|
|
77
|
+
"rimraf": "^6.1.3",
|
|
78
|
+
"sass": "^1.98.0",
|
|
79
|
+
"sass-embedded": "^1.98.0",
|
|
37
80
|
"typescript": "~5.9.3",
|
|
38
|
-
"vite": "^7.
|
|
39
|
-
"vite-tsconfig-paths": "^
|
|
40
|
-
"vitest": "^
|
|
81
|
+
"vite": "^7.3.1",
|
|
82
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
83
|
+
"vitest": "^4.0.18",
|
|
41
84
|
"yargs": "^18.0.0"
|
|
42
85
|
},
|
|
43
|
-
"
|
|
44
|
-
|
|
86
|
+
"engineStrict": true,
|
|
87
|
+
"engines": {
|
|
88
|
+
"node": "^22.0.0 || ^24.0.0",
|
|
89
|
+
"npm": ">=10.0.0"
|
|
45
90
|
}
|
|
46
|
-
}
|
|
91
|
+
}
|
package/build.d.ts
DELETED
package/build.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":""}
|
package/build.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
})();
|
package/files.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function used to create the package.json file under /lib
|
|
3
|
-
* @param packageName - the name field in package.json (for example: @helsenorge/step')
|
|
4
|
-
*/
|
|
5
|
-
export declare function createPackageJsonFile(packageName: string, inputPath: string, outputPath: string): Promise<string>;
|
|
6
|
-
//# sourceMappingURL=files.d.ts.map
|
package/files.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { readFile, writeFile } from 'fs';
|
|
2
|
-
/**
|
|
3
|
-
* Function used to create the package.json file under /lib
|
|
4
|
-
* @param packageName - the name field in package.json (for example: @helsenorge/step')
|
|
5
|
-
*/
|
|
6
|
-
export function createPackageJsonFile(packageName, inputPath, outputPath) {
|
|
7
|
-
return new Promise((resolve) => {
|
|
8
|
-
readFile(inputPath, 'utf8', (err, data) => {
|
|
9
|
-
if (err) {
|
|
10
|
-
throw err;
|
|
11
|
-
}
|
|
12
|
-
resolve(data);
|
|
13
|
-
});
|
|
14
|
-
})
|
|
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 = {
|
|
19
|
-
name: packageName,
|
|
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,
|
|
30
|
-
};
|
|
31
|
-
if (publishConfig?.access) {
|
|
32
|
-
minimalPackage.publishConfig = {
|
|
33
|
-
access: publishConfig.access,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return new Promise(resolve => {
|
|
37
|
-
const data = JSON.stringify(minimalPackage, null, 2);
|
|
38
|
-
writeFile(outputPath, data, err => {
|
|
39
|
-
if (err)
|
|
40
|
-
throw err;
|
|
41
|
-
// eslint-disable-next-line no-console
|
|
42
|
-
console.log(`Created package.json in ${outputPath}`);
|
|
43
|
-
resolve(outputPath);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
}
|
package/library-scripts.d.ts
DELETED
package/setupTests.vite.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupTests.vite.d.ts","sourceRoot":"","sources":["../src/setupTests.vite.ts"],"names":[],"mappings":"AAEA,OAAO,kCAAkC,CAAC;AAe1C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC7B;CACF"}
|
package/setupTests.vite.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import fetchPolyfill, { Request as RequestPolyfill } from 'node-fetch';
|
|
2
|
-
import { vi } from 'vitest';
|
|
3
|
-
import '@testing-library/jest-dom/vitest';
|
|
4
|
-
// @todo: Fjern etter oppdatering til vitest 4, fjern da også dependency til node-fetch
|
|
5
|
-
// https://github.com/reduxjs/redux-toolkit/issues/4966#issuecomment-3115230061
|
|
6
|
-
Object.defineProperty(global, 'fetch', {
|
|
7
|
-
// MSW will overwrite this to intercept requests
|
|
8
|
-
writable: true,
|
|
9
|
-
value: fetchPolyfill,
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(global, 'Request', {
|
|
12
|
-
writable: false,
|
|
13
|
-
value: RequestPolyfill,
|
|
14
|
-
});
|
|
15
|
-
window.HN = {
|
|
16
|
-
Page: {},
|
|
17
|
-
Rest: {},
|
|
18
|
-
User: {},
|
|
19
|
-
Commands: {},
|
|
20
|
-
PortalCommands: {},
|
|
21
|
-
};
|
|
22
|
-
const MatchMediaMock = vi.fn((query) => ({
|
|
23
|
-
// @todo Her burde vi finne ut i hvilke tilfeller den skal være true, og bare sette den til true i de tilfellene
|
|
24
|
-
matches: query !== '(prefers-reduced-motion)',
|
|
25
|
-
addListener: vi.fn(),
|
|
26
|
-
addEventListener: vi.fn(),
|
|
27
|
-
removeEventListener: vi.fn(),
|
|
28
|
-
}));
|
|
29
|
-
vi.stubGlobal('matchMedia', MatchMediaMock);
|
|
30
|
-
const IntersectionObserverMock = vi.fn(() => ({
|
|
31
|
-
observe: vi.fn(),
|
|
32
|
-
unobserve: vi.fn(),
|
|
33
|
-
disconnect: vi.fn(),
|
|
34
|
-
}));
|
|
35
|
-
vi.stubGlobal('IntersectionObserver', IntersectionObserverMock);
|
|
36
|
-
const ResizeObserverMock = vi.fn(() => ({
|
|
37
|
-
observe: vi.fn(),
|
|
38
|
-
unobserve: vi.fn(),
|
|
39
|
-
disconnect: vi.fn(),
|
|
40
|
-
}));
|
|
41
|
-
vi.stubGlobal('ResizeObserver', ResizeObserverMock);
|
|
42
|
-
const MutationObserverMock = vi.fn(() => ({
|
|
43
|
-
observe: vi.fn(),
|
|
44
|
-
disconnect: vi.fn(),
|
|
45
|
-
}));
|
|
46
|
-
vi.stubGlobal('MutationObserver', MutationObserverMock);
|
|
47
|
-
window.HTMLElement.prototype.scrollIntoView = vi.fn();
|
package/vitest.config.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|