@helsenorge/library-build 27.1.3

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @helsenorge/library-build
2
+
3
+ Bygg og test av komponentbibliotek
@@ -0,0 +1,27 @@
1
+ const browserslistFromPackageJson = require('./../package.json').browserslist;
2
+
3
+ const parentBabelConfig = {
4
+ presets: [
5
+ [
6
+ '@babel/preset-env',
7
+ {
8
+ targets: {
9
+ node: 'current',
10
+ browsers: browserslistFromPackageJson,
11
+ },
12
+ useBuiltIns: 'usage',
13
+ corejs: 3,
14
+ loose: true,
15
+ },
16
+ ],
17
+ ['@babel/preset-react', { typescript: true }],
18
+ ['@babel/preset-typescript', { allExtensions: true, isTSX: true }],
19
+ ],
20
+ plugins: [
21
+ '@babel/plugin-syntax-dynamic-import',
22
+ ['@babel/plugin-proposal-class-properties', { loose: true }],
23
+ '@babel/plugin-proposal-object-rest-spread',
24
+ ],
25
+ };
26
+
27
+ module.exports = parentBabelConfig;
@@ -0,0 +1,42 @@
1
+ /* Legger til babel-jest + esm og babel-jest igjen uner 'transform' for å kunne håndtere esm import/exports */
2
+ /* Viktig å ha @helsenorge pakker under transformIgnorePatterns fordi de eksporteres i rå esm */
3
+
4
+ const rootDir = process.cwd();
5
+
6
+ module.exports = {
7
+ rootDir,
8
+ verbose: true,
9
+ setupFilesAfterEnv: ['<rootDir>/node_modules/@helsenorge/library-build/setupTests.js'],
10
+ coverageProvider: 'v8',
11
+ testEnvironment: 'jest-environment-jsdom',
12
+ testURL: 'http://tjenester.helsenorge.utvikling',
13
+ transform: {
14
+ '^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
15
+ },
16
+ transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\](?!@helsenorge[/\\\\])', '^.+\\.module\\.(css|sass|scss|scss.d.ts)$'],
17
+ coverageReporters: ['cobertura', 'lcov', 'json'],
18
+ collectCoverage: true,
19
+ collectCoverageFrom: [
20
+ '**/*.ts',
21
+ '**/*.tsx',
22
+ '!**/node_modules/**',
23
+ '!**/lib/**',
24
+ '!**/dist/**',
25
+ '!**/__devonly__/**',
26
+ '!**/scripts/**',
27
+ '!**/types/**',
28
+ '!**/constants/*.ts',
29
+ '!**/*types.ts',
30
+ ],
31
+ moduleNameMapper: {
32
+ '\\.(css|scss)$': 'identity-obj-proxy',
33
+ },
34
+ moduleDirectories: ['node_modules', 'src'],
35
+ // Unngå warning om jest-haste-map: Haste module naming collision
36
+ modulePathIgnorePatterns: ['lib'],
37
+ moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],
38
+ coveragePathIgnorePatterns: ['^.+\\.module\\.(css|sass|scss|scss.d.ts)$'],
39
+ testResultsProcessor: 'jest-junit-reporter',
40
+ snapshotSerializers: ['enzyme-to-json/serializer'],
41
+ cacheDirectory: '<rootDir>/.jest-cache',
42
+ };
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2015",
4
+ "module": "ES2020",
5
+ "moduleResolution": "node",
6
+ "sourceMap": true,
7
+ "jsx": "react",
8
+ "noImplicitAny": true,
9
+ "suppressImplicitAnyIndexErrors": true,
10
+ "allowSyntheticDefaultImports": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "esModuleInterop": true,
13
+ "newLine": "LF",
14
+ "allowUnreachableCode": false,
15
+ "skipLibCheck": true,
16
+ "lib": ["es5", "es2015.core", "es2015.promise", "es6", "dom", "scripthost"],
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "strictNullChecks": true,
20
+ "noEmit": false,
21
+ "importHelpers": true,
22
+ "declaration": true,
23
+ "declarationMap": true,
24
+ "removeComments": false,
25
+ "resolveJsonModule": true
26
+ }
27
+ }
package/copy.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=copy.d.ts.map
package/copy.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../src/copy.ts"],"names":[],"mappings":""}
package/copy.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var path_1 = require("path");
5
+ var copyfiles_1 = tslib_1.__importDefault(require("copyfiles"));
6
+ var rimraf_1 = tslib_1.__importDefault(require("rimraf"));
7
+ var yargs_1 = tslib_1.__importDefault(require("yargs"));
8
+ var helpers_1 = require("yargs/helpers");
9
+ var files_1 = require("./files");
10
+ var _a = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
11
+ .options({
12
+ root: { describe: 'Files to copy to root directory', type: 'array', default: [] },
13
+ include: { describe: 'Files to copy from src to lib, replacing "src" with "lib"', type: 'array', default: [] },
14
+ utils: { describe: 'Files to copy to lib/utils', type: 'array', default: [] },
15
+ rm: { describe: 'Files to delete', type: 'string', default: '' },
16
+ })
17
+ .parseSync(), root = _a.root, include = _a.include, utils = _a.utils, rm = _a.rm;
18
+ var originalPackageJson = (0, path_1.resolve)(process.cwd(), 'package.json');
19
+ var _b = require(originalPackageJson), packageName = _b.name, outputDirectory = _b.publishConfig.directory;
20
+ var outputPath = (0, path_1.resolve)(process.cwd(), outputDirectory);
21
+ var newPackageJson = (0, path_1.resolve)(outputPath, 'package.json');
22
+ Promise.all([
23
+ (0, copyfiles_1.default)(tslib_1.__spreadArray(tslib_1.__spreadArray([], root, true), [outputPath], false), console.error),
24
+ (0, copyfiles_1.default)(tslib_1.__spreadArray(tslib_1.__spreadArray([], include, true), [outputPath], false), { up: 1 }, console.error),
25
+ (0, copyfiles_1.default)(tslib_1.__spreadArray(tslib_1.__spreadArray([], utils, true), [(0, path_1.resolve)(outputPath, 'utils')], false), { up: true }, console.error),
26
+ ])
27
+ .then(function () { return (rm ? (0, rimraf_1.default)(rm) : Promise.resolve(true)); })
28
+ .then(function () { return (0, files_1.createPackageJsonFile)(packageName, originalPackageJson, newPackageJson); });
package/files.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Function used to create the package.json file under /lib
3
+ * @param packageName - the name field in package.json (for example: @helsenorge/toolkit')
4
+ */
5
+ export declare function createPackageJsonFile(packageName: string, inputPath: string, outputPath: string): Promise<unknown>;
6
+ //# sourceMappingURL=files.d.ts.map
package/files.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAcA;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAiC/F"}
package/files.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPackageJsonFile = void 0;
4
+ var fs_1 = require("fs");
5
+ /**
6
+ * Function used to create the package.json file under /lib
7
+ * @param packageName - the name field in package.json (for example: @helsenorge/toolkit')
8
+ */
9
+ function createPackageJsonFile(packageName, inputPath, outputPath) {
10
+ return new Promise(function (resolve) {
11
+ (0, fs_1.readFile)(inputPath, 'utf8', function (err, data) {
12
+ if (err) {
13
+ throw err;
14
+ }
15
+ resolve(data);
16
+ });
17
+ })
18
+ .then(function (data) { return JSON.parse(data); })
19
+ .then(function (packageData) {
20
+ var author = packageData.author, version = packageData.version, bin = packageData.bin, peerDependencies = packageData.peerDependencies, license = packageData.license, dependencies = packageData.dependencies;
21
+ var minimalPackage = {
22
+ name: packageName,
23
+ author: author,
24
+ version: version,
25
+ main: './index.js',
26
+ bin: bin,
27
+ license: license,
28
+ peerDependencies: peerDependencies,
29
+ dependencies: dependencies,
30
+ };
31
+ return new Promise(function (resolve) {
32
+ var data = JSON.stringify(minimalPackage, null, 2);
33
+ (0, fs_1.writeFile)(outputPath, data, function (err) {
34
+ if (err)
35
+ throw err;
36
+ console.log("Created package.json in ".concat(outputPath));
37
+ resolve(outputPath);
38
+ });
39
+ });
40
+ });
41
+ }
42
+ exports.createPackageJsonFile = createPackageJsonFile;
package/index.html ADDED
@@ -0,0 +1,44 @@
1
+ <!DOCTYPE html>
2
+ <html lang="no">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <meta http-equiv="X-UA-Compatible" content="ie=edge" />
7
+ <title>Helsenorge</title>
8
+ <!-- IMPORT TEMPLATE FOR WEBCOMP-->
9
+
10
+ <template id="hn-webcomp-header-footer-template">
11
+ <link href="https://static-hn-mas-01.int-hn.nhn.no/core/static/css/helsenorge/helsenorge.css" rel="stylesheet" />
12
+ <link
13
+ type="text/css"
14
+ rel="stylesheet"
15
+ href="https://static-hn-mas-01.int-hn.nhn.no/header-footer/static/css/header-footer/header-footer.css"
16
+ />
17
+ <link type="text/css" rel="stylesheet" href="index.css" />
18
+ </template>
19
+
20
+ <!-- ADDING RESET CSS -->
21
+ <link href="https://static-hn-mas-01.int-hn.nhn.no/core/static/css/helsenorge/helsenorge.css" rel="stylesheet" />
22
+ </head>
23
+
24
+ <body id="helsenorge">
25
+ <hn-webcomp-header></hn-webcomp-header>
26
+ <div id="main-content-wrapper"></div>
27
+ <!-- IMPORT React and react-dom from CDN -->
28
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script>
29
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script>
30
+
31
+ <!-- IMPORT Moment from CDN -->
32
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>
33
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/locale/en-gb.min.js"></script>
34
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/locale/se.min.js"></script>
35
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/locale/nb.min.js"></script>
36
+
37
+ <!-- IMPORT header-footer script -->
38
+ <script
39
+ type="text/javascript"
40
+ src="https://static-hn-mas-01.int-hn.nhn.no/header-footer/static/js/header-footer/header-footer.js"
41
+ ></script>
42
+ <script src="index.js"></script>
43
+ </body>
44
+ </html>
@@ -0,0 +1,3 @@
1
+ #! /usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=library-scripts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"library-scripts.d.ts","sourceRoot":"","sources":["../src/library-scripts.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ #! /usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ var sync = require('cross-spawn').sync;
5
+ var args = process.argv.slice(2);
6
+ var scriptIndex = args.findIndex(function (x) { return x === 'start' || x === 'test' || x === 'copy'; });
7
+ var script = scriptIndex === -1 ? args[0] : args[scriptIndex];
8
+ var nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
9
+ switch (script) {
10
+ case 'start':
11
+ case 'test':
12
+ case 'copy': {
13
+ var result = sync('node', nodeArgs.concat(require.resolve('./' + script)).concat(args.slice(scriptIndex + 1)), {
14
+ stdio: 'inherit',
15
+ });
16
+ if (result.signal) {
17
+ if (result.signal === 'SIGKILL') {
18
+ console.log('The build failed because the process exited too early. ' +
19
+ 'This probably means the system ran out of memory or someone called ' +
20
+ '`kill -9` on the process.');
21
+ }
22
+ else if (result.signal === 'SIGTERM') {
23
+ console.log('The build failed because the process exited too early. ' +
24
+ 'Someone might have called `kill` or `killall`, or the system could ' +
25
+ 'be shutting down.');
26
+ }
27
+ process.exit(1);
28
+ }
29
+ if (result.status)
30
+ process.exit(result.status);
31
+ break;
32
+ }
33
+ default:
34
+ console.log('Unknown script "' + script + '".');
35
+ console.log('Perhaps you need to update @helsenorge/library-build?');
36
+ break;
37
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@helsenorge/library-build",
3
+ "author": "Norsk helsenett SF",
4
+ "version": "27.1.3",
5
+ "main": "./index.js",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "bin": {
10
+ "library-scripts": "./library-scripts.js"
11
+ },
12
+ "license": "UNLICENSED",
13
+ "peerDependencies": {
14
+ "core-js": ">=3.26.1"
15
+ },
16
+ "dependencies": {
17
+ "@babel/core": "^7.21.0",
18
+ "@helsenorge/eslint-config": "^27.1.2",
19
+ "@testing-library/jest-dom": "^5.16.5",
20
+ "@testing-library/react": "^12.1.5",
21
+ "@testing-library/user-event": "^14.4.3",
22
+ "@types/copyfiles": "^2.4.1",
23
+ "@types/enzyme": "^3.10.12",
24
+ "@types/enzyme-to-json": "^1.5.4",
25
+ "@types/react": "^17.0.53",
26
+ "@types/react-dom": "^17.0.19",
27
+ "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
28
+ "babel-jest": "^27.5.1",
29
+ "core-js": ">=3.29.1",
30
+ "cross-spawn": "7.0.3",
31
+ "enzyme": "^3.11.0",
32
+ "enzyme-to-json": "^3.6.2",
33
+ "esbuild": "^0.17.11",
34
+ "esbuild-sass-plugin": "^2.6.0",
35
+ "identity-obj-proxy": "^3.0.0",
36
+ "isomorphic-fetch": "^3.0.0",
37
+ "jest-environment-jsdom": "^27.5.1",
38
+ "jest-junit-reporter": "^1.1.0",
39
+ "postcss": "^8.4.21",
40
+ "postcss-modules": "^6.0.0",
41
+ "react": "17.0.2",
42
+ "react-dom": "17.0.2",
43
+ "rimraf": "^4.4.0",
44
+ "typescript": "~4.9.5"
45
+ }
46
+ }
@@ -0,0 +1,3 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import 'isomorphic-fetch';
3
+ //# sourceMappingURL=setupTests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../src/setupTests.ts"],"names":[],"mappings":"AAIA,OAAO,yCAAyC,CAAC;AACjD,OAAO,kBAAkB,CAAC"}
package/setupTests.js ADDED
@@ -0,0 +1,13 @@
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() });
package/start.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=start.d.ts.map
package/start.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":""}
package/start.js ADDED
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var tslib_1 = require("tslib");
4
+ var fs_1 = require("fs");
5
+ var esbuild_1 = tslib_1.__importDefault(require("esbuild"));
6
+ var esbuild_sass_plugin_1 = require("esbuild-sass-plugin");
7
+ var yargs_1 = tslib_1.__importDefault(require("yargs"));
8
+ var helpers_1 = require("yargs/helpers");
9
+ (function () { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
10
+ var _a, entry, outDir, context;
11
+ return tslib_1.__generator(this, function (_b) {
12
+ switch (_b.label) {
13
+ case 0:
14
+ _a = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
15
+ .options({
16
+ entry: { type: 'string', default: 'src/__devonly__/index.tsx' },
17
+ outDir: { type: 'string', default: 'dist' },
18
+ })
19
+ .parseSync(), entry = _a.entry, outDir = _a.outDir;
20
+ if (!(0, fs_1.existsSync)(outDir)) {
21
+ (0, fs_1.mkdirSync)(outDir);
22
+ }
23
+ (0, fs_1.copyFileSync)(__dirname + '/index.html', outDir + '/index.html');
24
+ return [4 /*yield*/, esbuild_1.default.context({
25
+ logLevel: 'debug',
26
+ entryPoints: [entry],
27
+ outdir: outDir,
28
+ bundle: true,
29
+ define: {
30
+ global: 'window',
31
+ },
32
+ loader: {
33
+ '.svg': 'dataurl',
34
+ },
35
+ plugins: [
36
+ (0, esbuild_sass_plugin_1.sassPlugin)({
37
+ filter: /.module.(s[ac]ss|css)$/,
38
+ type: 'css',
39
+ transform: (0, esbuild_sass_plugin_1.postcssModules)({
40
+ // ...put here the options for postcss-modules: https://github.com/madyankin/postcss-modules
41
+ }),
42
+ }),
43
+ (0, esbuild_sass_plugin_1.sassPlugin)({
44
+ filter: /.(s[ac]ss|css)$/,
45
+ type: 'style',
46
+ }),
47
+ ],
48
+ })];
49
+ case 1:
50
+ context = _b.sent();
51
+ return [4 /*yield*/, context.watch()];
52
+ case 2:
53
+ _b.sent();
54
+ return [4 /*yield*/, context.serve({
55
+ port: 3000,
56
+ host: 'localhost',
57
+ servedir: outDir,
58
+ })];
59
+ case 3:
60
+ _b.sent();
61
+ return [2 /*return*/];
62
+ }
63
+ });
64
+ }); })();
package/test.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ declare const jestInstance: any;
2
+ declare const argv: string[];
3
+ //# sourceMappingURL=test.d.ts.map
package/test.d.ts.map ADDED
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,22 @@
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/config/jest/jest.config.js');
21
+ console.log('Du kjører jest med følgende arguments: ', argv);
22
+ jestInstance.run(argv);