semantic-release-openapi 1.4.3 → 1.5.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/README.md +5 -6
- package/package.json +50 -173
- package/src/@types/pluginConfig.ts +0 -3
- package/src/getReplaceInFile.ts +0 -12
- package/src/index.ts +0 -2
- package/src/prepare.ts +0 -87
- package/src/verifyConditions.ts +0 -40
- /package/{dist/@types → @types}/pluginConfig.d.ts +0 -0
- /package/{dist/@types → @types}/pluginConfig.js +0 -0
- /package/{dist/@types → @types}/pluginConfig.js.map +0 -0
- /package/{dist/getReplaceInFile.d.ts → getReplaceInFile.d.ts} +0 -0
- /package/{dist/getReplaceInFile.js → getReplaceInFile.js} +0 -0
- /package/{dist/getReplaceInFile.js.map → getReplaceInFile.js.map} +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/prepare.d.ts → prepare.d.ts} +0 -0
- /package/{dist/prepare.js → prepare.js} +0 -0
- /package/{dist/prepare.js.map → prepare.js.map} +0 -0
- /package/{dist/verifyConditions.d.ts → verifyConditions.d.ts} +0 -0
- /package/{dist/verifyConditions.js → verifyConditions.js} +0 -0
- /package/{dist/verifyConditions.js.map → verifyConditions.js.map} +0 -0
package/README.md
CHANGED
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
[][npm]
|
|
4
4
|
[][npm]
|
|
5
5
|
[](https://github.com/aensley/semantic-release-openapi/blob/main/LICENSE)
|
|
6
|
-
[](https://prettier.io)
|
|
6
|
+
[][npm]
|
|
8
7
|
|
|
9
8
|
[](https://github.com/aensley/semantic-release-openapi/actions/workflows/ci.yml)
|
|
10
|
-
[]
|
|
11
|
-
[]
|
|
12
|
-
[][npm]
|
|
9
|
+
[][qltysh]
|
|
10
|
+
[][qltysh]
|
|
13
11
|
|
|
14
12
|
A Semantic Release plugin to update versions in OpenAPI / Swagger specification files.
|
|
15
13
|
|
|
@@ -17,7 +15,7 @@ A Semantic Release plugin to update versions in OpenAPI / Swagger specification
|
|
|
17
15
|
|
|
18
16
|
This module is distributed via npm and should be installed as one of your project's `devDependencies`:
|
|
19
17
|
|
|
20
|
-
```
|
|
18
|
+
```
|
|
21
19
|
npm install --save-dev semantic-release-openapi
|
|
22
20
|
```
|
|
23
21
|
|
|
@@ -59,3 +57,4 @@ This plugin has one configuration option which must be supplied.
|
|
|
59
57
|
```
|
|
60
58
|
|
|
61
59
|
[npm]: https://www.npmjs.com/package/semantic-release-openapi
|
|
60
|
+
[qltysh]: https://qlty.sh/gh/aensley/projects/semantic-release-openapi
|
package/package.json
CHANGED
|
@@ -1,175 +1,52 @@
|
|
|
1
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
|
-
"replace-in-file": "^8.3.0"
|
|
53
|
-
},
|
|
54
|
-
"devDependencies": {
|
|
55
|
-
"@semantic-release/git": "^10.0.1",
|
|
56
|
-
"@types/fs-extra": "^11.0.4",
|
|
57
|
-
"@types/jest": "^29",
|
|
58
|
-
"@types/node": "^24.0.10",
|
|
59
|
-
"@types/picomatch": "^4.0.0",
|
|
60
|
-
"@types/semantic-release": "^20.0.6",
|
|
61
|
-
"@types/semantic-release__error": "^3.0.3",
|
|
62
|
-
"jest": "^29",
|
|
63
|
-
"pre-commit": "^1.2.2",
|
|
64
|
-
"prettier": "^3.6.2",
|
|
65
|
-
"ts-jest": "^29",
|
|
66
|
-
"ts-node": "^10.9.2",
|
|
67
|
-
"ts-standard": "^12.0.2",
|
|
68
|
-
"typescript": "^5.8.3"
|
|
69
|
-
},
|
|
70
|
-
"peerDependencies": {
|
|
71
|
-
"semantic-release": ">=20.0.0"
|
|
72
|
-
},
|
|
73
|
-
"scripts": {
|
|
74
|
-
"pre-commit-msg": "echo Running pre-commit checks...",
|
|
75
|
-
"build": "tsc --build",
|
|
76
|
-
"format": "prettier --write .",
|
|
77
|
-
"test": "ts-standard && prettier --check . && jest --coverage --verbose",
|
|
78
|
-
"lint": "ts-standard && prettier --check .",
|
|
79
|
-
"setup": "npm install && npm run prepare-hook",
|
|
80
|
-
"update": "npx npm-check-updates -u && npm update"
|
|
81
|
-
},
|
|
82
|
-
"pre-commit": {
|
|
83
|
-
"run": [
|
|
84
|
-
"pre-commit-msg",
|
|
85
|
-
"test"
|
|
86
|
-
],
|
|
87
|
-
"silent": true,
|
|
88
|
-
"colors": true
|
|
89
|
-
},
|
|
90
|
-
"release": {
|
|
91
|
-
"branches": [
|
|
92
|
-
"main"
|
|
93
|
-
],
|
|
94
|
-
"plugins": [
|
|
95
|
-
"@semantic-release/commit-analyzer",
|
|
96
|
-
"@semantic-release/release-notes-generator",
|
|
97
|
-
"@semantic-release/github",
|
|
98
|
-
"@semantic-release/npm",
|
|
99
|
-
[
|
|
100
|
-
"@semantic-release/git",
|
|
101
|
-
{
|
|
102
|
-
"assets": [
|
|
103
|
-
"package.json"
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
]
|
|
108
|
-
},
|
|
109
|
-
"eslintConfig": {
|
|
110
|
-
"extends": "standard-with-typescript",
|
|
111
|
-
"parserOptions": {
|
|
112
|
-
"project": "./tsconfig.json"
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
"ts-standard": {
|
|
116
|
-
"globals": [],
|
|
117
|
-
"ignore": [
|
|
118
|
-
"/test/**/*.ts"
|
|
119
|
-
]
|
|
120
|
-
},
|
|
121
|
-
"prettier": {
|
|
122
|
-
"tabWidth": 2,
|
|
123
|
-
"printWidth": 120,
|
|
124
|
-
"useTabs": false,
|
|
125
|
-
"endOfLine": "lf",
|
|
126
|
-
"trailingComma": "none",
|
|
127
|
-
"semi": false,
|
|
128
|
-
"singleQuote": true,
|
|
129
|
-
"arrowParens": "always",
|
|
130
|
-
"bracketSameLine": true,
|
|
131
|
-
"bracketSpacing": true,
|
|
132
|
-
"embeddedLanguageFormatting": "auto",
|
|
133
|
-
"htmlWhitespaceSensitivity": "css",
|
|
134
|
-
"insertPragma": false,
|
|
135
|
-
"jsxSingleQuote": false,
|
|
136
|
-
"proseWrap": "preserve",
|
|
137
|
-
"quoteProps": "as-needed",
|
|
138
|
-
"requirePragma": false,
|
|
139
|
-
"vueIndentScriptAndStyle": false
|
|
140
|
-
},
|
|
141
|
-
"jest": {
|
|
142
|
-
"preset": "ts-jest/presets/default-esm",
|
|
143
|
-
"testEnvironment": "node",
|
|
144
|
-
"extensionsToTreatAsEsm": [
|
|
145
|
-
".ts"
|
|
146
|
-
],
|
|
147
|
-
"transform": {
|
|
148
|
-
"^.+\\.tsx?$": [
|
|
149
|
-
"ts-jest",
|
|
150
|
-
{
|
|
151
|
-
"useESM": true
|
|
152
|
-
}
|
|
153
|
-
]
|
|
154
|
-
},
|
|
155
|
-
"moduleNameMapper": {
|
|
156
|
-
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
157
|
-
},
|
|
158
|
-
"testMatch": [
|
|
159
|
-
"**/test/**/*.test.ts"
|
|
160
|
-
],
|
|
161
|
-
"moduleFileExtensions": [
|
|
162
|
-
"ts",
|
|
163
|
-
"js",
|
|
164
|
-
"json",
|
|
165
|
-
"node"
|
|
166
|
-
],
|
|
167
|
-
"coverageDirectory": "./coverage",
|
|
168
|
-
"collectCoverageFrom": [
|
|
169
|
-
"src/**/*.{ts,js}"
|
|
170
|
-
],
|
|
171
|
-
"transformIgnorePatterns": [
|
|
172
|
-
"/node_modules/(?!@semantic-release/error)"
|
|
173
|
-
]
|
|
174
|
-
}
|
|
2
|
+
"name": "semantic-release-openapi",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "A Semantic Release plugin to update versions in OpenAPI / Swagger specification files",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/aensley/semantic-release-openapi.git"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"semantic-release",
|
|
11
|
+
"plugin",
|
|
12
|
+
"openapi",
|
|
13
|
+
"version",
|
|
14
|
+
"swagger",
|
|
15
|
+
"asyncapi"
|
|
16
|
+
],
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Andrew Ensley",
|
|
19
|
+
"email": "aensley@users.noreply.github.com",
|
|
20
|
+
"url": "https://andrewensley.com"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/aensley/semantic-release-openapi/issues/new?template=bug-report.yml"
|
|
25
|
+
},
|
|
26
|
+
"funding": [
|
|
27
|
+
"https://github.com/sponsors/aensley",
|
|
28
|
+
"https://paypal.me/AndrewEnsley"
|
|
29
|
+
],
|
|
30
|
+
"homepage": "https://github.com/aensley/semantic-release-openapi#readme",
|
|
31
|
+
"type": "module",
|
|
32
|
+
"main": "index.js",
|
|
33
|
+
"module": "index.js",
|
|
34
|
+
"types": "index.d.ts",
|
|
35
|
+
"files": [
|
|
36
|
+
"**/*"
|
|
37
|
+
],
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=16"
|
|
40
|
+
},
|
|
41
|
+
"platform": "node",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@semantic-release/error": "^4.0.0",
|
|
44
|
+
"fdir": "^6.4.6",
|
|
45
|
+
"fs-extra": "^11.3.0",
|
|
46
|
+
"picomatch": "^4.0.2",
|
|
47
|
+
"replace-in-file": "^8.3.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"semantic-release": ">=20.0.0"
|
|
51
|
+
}
|
|
175
52
|
}
|
package/src/getReplaceInFile.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dynamically imports and returns the default export from the 'replace-in-file' module.
|
|
3
|
-
*
|
|
4
|
-
* This function uses dynamic import to load the 'replace-in-file' package at runtime,
|
|
5
|
-
* which can help reduce initial load time and dependencies if the functionality is only
|
|
6
|
-
* needed conditionally.
|
|
7
|
-
*
|
|
8
|
-
* @returns A promise that resolves to the default export of the 'replace-in-file' module.
|
|
9
|
-
*/
|
|
10
|
-
export default async function (): Promise<typeof import('replace-in-file').default> {
|
|
11
|
-
return (await import('replace-in-file')).default
|
|
12
|
-
}
|
package/src/index.ts
DELETED
package/src/prepare.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import fsExtra from 'fs-extra'
|
|
2
|
-
import PluginConfig from './@types/pluginConfig.js'
|
|
3
|
-
import { fdir } from 'fdir'
|
|
4
|
-
import getReplaceInFile from './getReplaceInFile.js'
|
|
5
|
-
|
|
6
|
-
const { readJsonSync, writeJsonSync } = fsExtra
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Prepare the API Spec files
|
|
10
|
-
*
|
|
11
|
-
* @param {string[]} apiSpecFiles List of api spec file paths, globs supported
|
|
12
|
-
* @param {string} version The version string to write to the files
|
|
13
|
-
* @param {Context['logger']} logger The semantic release logger instance
|
|
14
|
-
*
|
|
15
|
-
* @throws {SemanticReleaseError}
|
|
16
|
-
*/
|
|
17
|
-
const prepareApiSpecFiles = async (apiSpecFiles: string[], version: string, logger: any): Promise<any> => {
|
|
18
|
-
const SemanticReleaseError = (await import('@semantic-release/error')).default
|
|
19
|
-
try {
|
|
20
|
-
for (const fileNameGlob of apiSpecFiles) {
|
|
21
|
-
// eslint-disable-next-line new-cap
|
|
22
|
-
const fileNames: string[] = new fdir().withRelativePaths().glob(fileNameGlob).crawl('.').sync()
|
|
23
|
-
for (const fileName of fileNames) {
|
|
24
|
-
let results: string[]
|
|
25
|
-
if (fileName.split('.').pop() === 'json') {
|
|
26
|
-
results = prepareApiSpecFileJson(fileName, version)
|
|
27
|
-
} else {
|
|
28
|
-
results = await prepareApiSpecFileYml(fileName, version)
|
|
29
|
-
}
|
|
30
|
-
results.forEach((resultFileName: string) => {
|
|
31
|
-
logger.log('Wrote version %s to %s', version, resultFileName)
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
} catch (error: any) {
|
|
36
|
-
throw new SemanticReleaseError(error)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Prepares a single API spec file in YAML format
|
|
42
|
-
*
|
|
43
|
-
* @param {string} apiSpecFile Single spec file to update, no globs
|
|
44
|
-
* @param {string} version The version string to write to the file
|
|
45
|
-
*
|
|
46
|
-
* @returns {string[]} A list of altered files
|
|
47
|
-
*/
|
|
48
|
-
const prepareApiSpecFileYml = async (apiSpecFile: string, version: string): Promise<string[]> => {
|
|
49
|
-
const replace = await getReplaceInFile()
|
|
50
|
-
return (replace as any)
|
|
51
|
-
.sync({
|
|
52
|
-
files: apiSpecFile,
|
|
53
|
-
from: /version: ?.+$/im,
|
|
54
|
-
to: 'version: ' + version
|
|
55
|
-
})
|
|
56
|
-
.filter((result: any) => result.hasChanged)
|
|
57
|
-
.map((result: any) => result.file)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Prepares a single API spec file in JSON format
|
|
62
|
-
*
|
|
63
|
-
* @param {string} apiSpecFile Single spec file to update, no globs
|
|
64
|
-
* @param {string} version The version string to write to the file
|
|
65
|
-
*
|
|
66
|
-
* @returns {string[]} A list of altered files
|
|
67
|
-
*/
|
|
68
|
-
const prepareApiSpecFileJson = (apiSpecFile: string, version: string): string[] => {
|
|
69
|
-
const specFile = readJsonSync(apiSpecFile)
|
|
70
|
-
specFile.info.version = version
|
|
71
|
-
writeJsonSync(apiSpecFile, specFile, { spaces: 2 })
|
|
72
|
-
return [apiSpecFile]
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* prepare hook for semantic release
|
|
77
|
-
*
|
|
78
|
-
* @throws {SemanticReleaseError}
|
|
79
|
-
*/
|
|
80
|
-
export default async function ({ apiSpecFiles }: PluginConfig, { nextRelease, logger }: any): Promise<any> {
|
|
81
|
-
const version = nextRelease?.version ?? ''
|
|
82
|
-
if (version.length < 1) {
|
|
83
|
-
const SemanticReleaseError = (await import('@semantic-release/error')).default
|
|
84
|
-
throw new SemanticReleaseError('Could not determine the version from semantic release.')
|
|
85
|
-
}
|
|
86
|
-
await prepareApiSpecFiles(apiSpecFiles, version, logger)
|
|
87
|
-
}
|
package/src/verifyConditions.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { fdir } from 'fdir'
|
|
2
|
-
import PluginConfig from './@types/pluginConfig.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* verifyConditions hook for semantic release
|
|
6
|
-
*
|
|
7
|
-
* @throws {SemanticReleaseError}
|
|
8
|
-
*/
|
|
9
|
-
export default async function ({ apiSpecFiles }: PluginConfig): Promise<any> {
|
|
10
|
-
const SemanticReleaseError = (await import('@semantic-release/error')).default
|
|
11
|
-
if (apiSpecFiles.length < 1) {
|
|
12
|
-
throw new SemanticReleaseError(
|
|
13
|
-
'Option "apiSpecFiles" was not included in the plugin config. See the README for instructions.',
|
|
14
|
-
'ENOAPISPECFILES'
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
const expectedExts: string[] = ['json', 'yaml', 'yml']
|
|
18
|
-
let specFilesFound: boolean = false
|
|
19
|
-
apiSpecFiles.forEach((fileNameGlob: string) => {
|
|
20
|
-
// eslint-disable-next-line new-cap
|
|
21
|
-
const fileNames: string[] = new fdir().glob(fileNameGlob).crawl('.').sync()
|
|
22
|
-
if (fileNames.length > 0) {
|
|
23
|
-
specFilesFound = true
|
|
24
|
-
fileNames.forEach((fileName: string) => {
|
|
25
|
-
if (!expectedExts.includes(fileName.split('.').pop() ?? '')) {
|
|
26
|
-
throw new SemanticReleaseError(
|
|
27
|
-
'File "' + fileName + '" is not valid. Must be a file with .json, .yaml, or .yml extension',
|
|
28
|
-
'EINVALIDAPISPECFILETYPE'
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
if (!specFilesFound) {
|
|
35
|
-
throw new SemanticReleaseError(
|
|
36
|
-
'No files match the paths in "apiSpecFiles". Check your plugin config and try again.',
|
|
37
|
-
'EINVALIDAPISPECFILES'
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|