Skip to content

Commit b7b7bba

Browse files
feat: add functionality to build and run npm package version of raplp
Signed-off-by: Nicklas Silversved <nicklas.silversved@digg.se>
1 parent 74e7245 commit b7b7bba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+301
-246
lines changed

jest.config.cjs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
22
//
33
// SPDX-License-Identifier: EUPL-1.2
44

5-
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
6-
module.exports = async () => {
7-
return {
8-
preset: 'ts-jest',
9-
testPathIgnorePatterns: ['util'],
10-
testEnvironment: 'node',
11-
"extensionsToTreatAsEsm": [".ts"],
12-
transform: {
13-
'.*': ['ts-jest', {useIsolatedModules: true }]
14-
}
15-
};
5+
/** @type {import('jest').Config} */
6+
module.exports = {
7+
preset: 'ts-jest/presets/default-esm',
8+
testEnvironment: 'node',
9+
extensionsToTreatAsEsm: ['.ts'],
10+
transform: {
11+
'^.+\\.ts$': ['ts-jest', {
12+
useESM: true,
13+
tsconfig: 'tsconfig.jest.json'
14+
}],
15+
},
16+
moduleNameMapper: {
17+
'^(\\.{1,2}/.*)\\.js$': '$1',
18+
},
19+
transformIgnorePatterns: ['/node_modules/'],
20+
testMatch: ['**/tests/unit/**/*.test.ts'],
21+
1622
};

jest.integration.config.cjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-FileCopyrightText: 2025 diggsweden/rest-api-profil-lint-processor
2+
//
3+
// SPDX-License-Identifier: EUPL-1.2
4+
const base = require('./jest.config.cjs');
5+
6+
/** @type {import('jest').Config} */
7+
module.exports = {
8+
...base,
9+
testMatch: ['**/tests/integration/**/*.test.ts']
10+
};

package-lock.json

Lines changed: 24 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
{
22
"name": "@diggsweden/rest-api-profil-lint-processor",
3-
"version": "v1.0.3-alpha.1",
4-
"main": ".src/app.ts",
3+
"version": "v1.0.0",
4+
"main": "./dist/app.js",
5+
"bin": {
6+
"raplp": "dist/cli.js"
7+
},
58
"type": "module",
69
"engines": {
710
"node": "<=22.15.1"
811
},
12+
"files": [
13+
"dist",
14+
"README.md",
15+
"GUIDELINES.md",
16+
"document/**"
17+
],
918
"repository": {
1019
"type": "git",
1120
"url": "git@github.com:diggsweden/rest-api-profil-lint-processor"
1221
},
1322
"description": "A command-line tool to lint OpenAPI v3 definitions using Spectral",
1423
"scripts": {
24+
"clean": "rm -rf dist",
1525
"build": "tsc -p tsconfig.json",
1626
"test": "jest",
27+
"test:integration": "node --experimental-vm-modules ./node_modules/.bin/jest --config jest.integration.config.cjs ",
28+
"prepare": "npm run clean && npm run build",
29+
"prepack": "npm run clean && npm run build",
1730
"start": "node --import=./register.js src/app.ts",
1831
"version": "standard-version --skip.commit"
1932
},
@@ -28,7 +41,8 @@
2841
"@types/node": "^22.18.6",
2942
"jest": "^30.0.4",
3043
"standard-version": "^9.5.0",
31-
"ts-jest": "^29.4.1",
44+
"ts-jest": "^29.4.2",
45+
"ts-node": "^10.9.2",
3246
"typescript": "^5.2.2"
3347
},
3448
"dependencies": {
@@ -43,7 +57,6 @@
4357
"fast-xml-parser": "^4.5.0",
4458
"js-yaml": "^4.1.0",
4559
"path": "^0.12.7",
46-
"ts-node": "^10.9.2",
4760
"yargs": "^17.7.2"
4861
},
4962
"//": [

src/app.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ import * as path from 'node:path';
1818
import { join } from 'path';
1919
import Parsers from '@stoplight/spectral-parsers';
2020
import spectralCore from '@stoplight/spectral-core';
21-
import { importAndCreateRuleInstances, getRuleModules } from './util/ruleUtil.ts'; // Import the helper function
21+
import { importAndCreateRuleInstances, getRuleModules } from './util/ruleUtil.js'; // Import the helper function
2222
import util from 'util';
23-
import { RapLPCustomSpectral } from './util/RapLPCustomSpectral.ts';
24-
import { DiagnosticReport, RapLPDiagnostic } from './util/RapLPDiagnostic.ts';
25-
import { AggregateError } from './util/RapLPCustomErrorInfo.ts';
23+
import { RapLPCustomSpectral } from './util/RapLPCustomSpectral.js';
24+
import { DiagnosticReport, RapLPDiagnostic } from './util/RapLPDiagnostic.js';
25+
import { AggregateError } from './util/RapLPCustomErrorInfo.js';
2626
import chalk from 'chalk';
27-
import { ExcelReportProcessor } from './util/excelReportProcessor.ts';
27+
import { ExcelReportProcessor } from './util/excelReportProcessor.js';
2828

2929
declare var AggregateError: {
3030
prototype: AggregateError;

src/cli.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
import "./app.js";
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
import { undefined as undefinedFunc, pattern } from '@stoplight/spectral-functions';
66
import { DiagnosticSeverity } from '@stoplight/types';
7-
import { parsePropertyNames } from './rulesetUtil.ts';
8-
import { CustomProperties } from '../ruleinterface/CustomProperties.ts';
9-
import { BaseRuleset } from './BaseRuleset.ts';
10-
import { isValidApplicationJson } from './util/AmeRulesUtil.ts';
7+
import { parsePropertyNames } from './rulesetUtil.js';
8+
import { CustomProperties } from '../ruleinterface/CustomProperties.js';
9+
import { BaseRuleset } from './BaseRuleset.js';
10+
import { isValidApplicationJson } from './util/AmeRulesUtil.js';
1111

12-
const moduleName: string = 'AmeRules.ts';
12+
const moduleName: string = 'AmeRules.js';
1313

1414
enum CasingType {
1515
snake = 'snake',
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
//
33
// SPDX-License-Identifier: EUPL-1.2
44

5-
import { Arq05Base } from './rulesetUtil.ts';
5+
import { Arq05Base } from './rulesetUtil.js';
66
import { schema } from '@stoplight/spectral-functions';
77
import { DiagnosticSeverity } from '@stoplight/types';
8-
import { CustomProperties } from '../ruleinterface/CustomProperties.ts';
9-
import { BaseRuleset } from './BaseRuleset.ts';
10-
import { isValidApplicationJson } from './rulesetUtil.ts';
8+
import { CustomProperties } from '../ruleinterface/CustomProperties.js';
9+
import { BaseRuleset } from './BaseRuleset.js';
10+
import { isValidApplicationJson } from './rulesetUtil.js';
1111

12-
const moduleName: string = 'ArqRules.ts';
12+
const moduleName: string = 'ArqRules.js';
1313

1414
export class Arq05NestedStructure extends Arq05Base {
1515
description = 'Om en header använder nästlade strukturer, är en requestbody mer lämplig.';

0 commit comments

Comments
 (0)