Skip to content

Commit 8e03eb0

Browse files
feat: add functionality to build and run npm package version of raplp (#409)
* feat: add functionality to build and run npm package version of raplp * fix: add reuse to cli.ts * chore: update publiccode --------- Signed-off-by: Nicklas Silversved <nicklas.silversved@digg.se>
1 parent 807bf06 commit 8e03eb0

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

+235
-250
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: 25 additions & 14 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
},
1932
"directories": {
@@ -28,7 +41,8 @@
2841
"jest": "^30.0.4",
2942
"standard-version": "^9.5.0",
3043
"ts-jest": "^29.4.1",
31-
"typescript": "^5.9.2"
44+
"typescript": "^5.9.2",
45+
"ts-node": "^10.9.2"
3246
},
3347
"dependencies": {
3448
"@stoplight/spectral-core": "^1.19.5",
@@ -42,7 +56,6 @@
4256
"fast-xml-parser": "^4.5.0",
4357
"js-yaml": "^4.1.0",
4458
"path": "^0.12.7",
45-
"ts-node": "^10.9.2",
4659
"yargs": "^17.7.2"
4760
},
4861
"//": [

publiccode.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ description:
2020
- Missing attributes check
2121
- Detect missing or misconfigured attributes in specifications
2222
longDescription: |
23-
REST API-profil - Lint Processor is a command-line tool to lint OpenAPI v3 definitions of the swedish rest api-profile specification using Spectral.
23+
RAP-LP (REST API Profile Lint Processor) is a tool that reviews an OpenAPI specification against the national REST API Profile. The tool identifies syntax errors and deviations from the guidelines, making it easier to quickly find and correct issues.
24+
The tool analyzes the OpenAPI specification and checks that the API follows specific design rules associated with the REST API Profile. Each rule points to a specific part of the OpenAPI specification using a JSON Path Plus expression and verifies whether the values comply with the established rules. If deviations are found, one or more error messages are returned.
25+
In addition to the rules from the REST API Profile, RAP-LP also includes a rule area called Prerequisites. This area encompasses additional rules not included in the profile but based on established best practices for API design. The rules in Prerequisites can help further improve the quality of the API specification by identifying areas for improvement not covered by the national profile.
26+
The first version of RAP-LP is compatible with REST API Profile version 1.2.0, and each new version of the tool will specify which version of the profile it is intended to support.
2427
shortDescription: A linting tool for the swedish rest api-profile specification
2528
developmentStatus: beta
2629
legal:
@@ -31,8 +34,7 @@ localisation:
3134
localisationReady: false
3235
maintenance:
3336
contacts:
34-
- name: Digg OSPO
35-
- email: 'raplp-maintenance@digg.se'
37+
- name: raplp-maintenance@digg.se
3638
type: internal
3739
name: 'REST API-profil - Lint Processor (RAP-LP)'
3840
platforms:

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
// SPDX-FileCopyrightText: 2025 diggsweden/rest-api-profil-lint-processor
3+
//
4+
// SPDX-License-Identifier: EUPL-1.2
5+
import "./app.js";

0 commit comments

Comments
 (0)