semantic-release-openapi 1.5.1 → 2.1.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 +4 -2
- package/package.json +11 -8
- package/prepare.d.ts +3 -1
- package/prepare.js +18 -22
- package/prepare.js.map +1 -1
- package/verifyConditions.d.ts +2 -1
- package/verifyConditions.js +7 -7
- package/verifyConditions.js.map +1 -1
- package/getReplaceInFile.d.ts +0 -10
- package/getReplaceInFile.js +0 -13
- package/getReplaceInFile.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
[][npm]
|
|
4
4
|
[][npm]
|
|
5
5
|
[](https://github.com/aensley/semantic-release-openapi/blob/main/LICENSE)
|
|
6
|
-
[](https://standardjs.com)
|
|
7
|
+
[](https://prettier.io)
|
|
7
8
|
|
|
8
9
|
[](https://github.com/aensley/semantic-release-openapi/actions/workflows/ci.yml)
|
|
9
10
|
[][qltysh]
|
|
10
11
|
[][qltysh]
|
|
12
|
+
[][npm]
|
|
11
13
|
|
|
12
14
|
A Semantic Release plugin to update versions in OpenAPI / Swagger specification files.
|
|
13
15
|
|
|
@@ -15,7 +17,7 @@ A Semantic Release plugin to update versions in OpenAPI / Swagger specification
|
|
|
15
17
|
|
|
16
18
|
This module is distributed via npm and should be installed as one of your project's `devDependencies`:
|
|
17
19
|
|
|
18
|
-
```
|
|
20
|
+
```bash
|
|
19
21
|
npm install --save-dev semantic-release-openapi
|
|
20
22
|
```
|
|
21
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release-openapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "A Semantic Release plugin to update versions in OpenAPI / Swagger specification files",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"email": "aensley@users.noreply.github.com",
|
|
20
20
|
"url": "https://andrewensley.com"
|
|
21
21
|
},
|
|
22
|
+
"type": "module",
|
|
22
23
|
"license": "MIT",
|
|
23
24
|
"bugs": {
|
|
24
25
|
"url": "https://github.com/aensley/semantic-release-openapi/issues/new?template=bug-report.yml"
|
|
@@ -28,10 +29,10 @@
|
|
|
28
29
|
"https://paypal.me/AndrewEnsley"
|
|
29
30
|
],
|
|
30
31
|
"homepage": "https://github.com/aensley/semantic-release-openapi#readme",
|
|
31
|
-
"type": "module",
|
|
32
32
|
"main": "index.js",
|
|
33
33
|
"module": "index.js",
|
|
34
34
|
"types": "index.d.ts",
|
|
35
|
+
"source": "src/index.ts",
|
|
35
36
|
"files": [
|
|
36
37
|
"**/*"
|
|
37
38
|
],
|
|
@@ -41,12 +42,14 @@
|
|
|
41
42
|
"platform": "node",
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@semantic-release/error": "^4.0.0",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
45
|
+
"fs-extra": "^11.3.5",
|
|
46
|
+
"glob": "^13.0.6",
|
|
47
|
+
"replace-in-file": "^8.4.0",
|
|
48
|
+
"semantic-release": "^25.0.3"
|
|
48
49
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
50
|
+
"config": {
|
|
51
|
+
"commitizen": {
|
|
52
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
}
|
package/prepare.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { PrepareContext } from 'semantic-release';
|
|
1
2
|
import PluginConfig from './@types/pluginConfig.js';
|
|
2
3
|
/**
|
|
3
4
|
* prepare hook for semantic release
|
|
4
5
|
*
|
|
5
6
|
* @throws {SemanticReleaseError}
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
declare const _default: ({ apiSpecFiles }: PluginConfig, { nextRelease, logger }: PrepareContext) => any;
|
|
9
|
+
export default _default;
|
package/prepare.js
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import SemanticReleaseError from '@semantic-release/error';
|
|
2
|
+
import { readJsonSync, writeJsonSync } from 'fs-extra';
|
|
3
|
+
import { replaceInFileSync } from 'replace-in-file';
|
|
4
|
+
import { globSync } from 'glob';
|
|
5
5
|
/**
|
|
6
6
|
* Prepare the API Spec files
|
|
7
7
|
*
|
|
8
8
|
* @param {string[]} apiSpecFiles List of api spec file paths, globs supported
|
|
9
9
|
* @param {string} version The version string to write to the files
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {PrepareContext['logger']} logger The semantic release logger instance
|
|
11
11
|
*
|
|
12
12
|
* @throws {SemanticReleaseError}
|
|
13
13
|
*/
|
|
14
|
-
const prepareApiSpecFiles =
|
|
15
|
-
const SemanticReleaseError = (await import('@semantic-release/error')).default;
|
|
14
|
+
const prepareApiSpecFiles = (apiSpecFiles, version, logger) => {
|
|
16
15
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for (const fileName of fileNames) {
|
|
16
|
+
apiSpecFiles.forEach((fileNameGlob) => {
|
|
17
|
+
const fileNames = globSync(fileNameGlob);
|
|
18
|
+
fileNames.forEach((fileName) => {
|
|
21
19
|
let results;
|
|
22
20
|
if (fileName.split('.').pop() === 'json') {
|
|
23
21
|
results = prepareApiSpecFileJson(fileName, version);
|
|
24
22
|
}
|
|
25
23
|
else {
|
|
26
|
-
results =
|
|
24
|
+
results = prepareApiSpecFileYml(fileName, version);
|
|
27
25
|
}
|
|
28
26
|
results.forEach((resultFileName) => {
|
|
29
27
|
logger.log('Wrote version %s to %s', version, resultFileName);
|
|
30
28
|
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
33
31
|
}
|
|
34
32
|
catch (error) {
|
|
35
33
|
throw new SemanticReleaseError(error);
|
|
@@ -43,16 +41,15 @@ const prepareApiSpecFiles = async (apiSpecFiles, version, logger) => {
|
|
|
43
41
|
*
|
|
44
42
|
* @returns {string[]} A list of altered files
|
|
45
43
|
*/
|
|
46
|
-
const prepareApiSpecFileYml =
|
|
47
|
-
const
|
|
48
|
-
return replace
|
|
49
|
-
.sync({
|
|
44
|
+
const prepareApiSpecFileYml = (apiSpecFile, version) => {
|
|
45
|
+
const changedFiles = replaceInFileSync({
|
|
50
46
|
files: apiSpecFile,
|
|
51
47
|
from: /version: ?.+$/im,
|
|
52
48
|
to: 'version: ' + version
|
|
53
49
|
})
|
|
54
50
|
.filter((result) => result.hasChanged)
|
|
55
51
|
.map((result) => result.file);
|
|
52
|
+
return changedFiles;
|
|
56
53
|
};
|
|
57
54
|
/**
|
|
58
55
|
* Prepares a single API spec file in JSON format
|
|
@@ -73,12 +70,11 @@ const prepareApiSpecFileJson = (apiSpecFile, version) => {
|
|
|
73
70
|
*
|
|
74
71
|
* @throws {SemanticReleaseError}
|
|
75
72
|
*/
|
|
76
|
-
export default
|
|
73
|
+
export default ({ apiSpecFiles }, { nextRelease, logger }) => {
|
|
77
74
|
const version = nextRelease?.version ?? '';
|
|
78
75
|
if (version.length < 1) {
|
|
79
|
-
const SemanticReleaseError = (await import('@semantic-release/error')).default;
|
|
80
76
|
throw new SemanticReleaseError('Could not determine the version from semantic release.');
|
|
81
77
|
}
|
|
82
|
-
|
|
83
|
-
}
|
|
78
|
+
prepareApiSpecFiles(apiSpecFiles, version, logger);
|
|
79
|
+
};
|
|
84
80
|
//# sourceMappingURL=prepare.js.map
|
package/prepare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../src/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../src/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAA;AAC1D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,EAAE,EAAE,WAAW,GAAG,OAAO;KAC1B,CAAC;SACC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;SACrC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/B,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,sBAAsB,GAAG,CAAC,WAAmB,EAAE,OAAe,EAAY,EAAE;IAChF,MAAM,QAAQ,GAAG,YAAY,CAAC,WAAW,CAAC,CAAA;IAC1C,QAAQ,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC/B,aAAa,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;IACnD,OAAO,CAAC,WAAW,CAAC,CAAA;AACtB,CAAC,CAAA;AAED;;;;GAIG;AACH,eAAe,CAAC,EAAE,YAAY,EAAgB,EAAE,EAAE,WAAW,EAAE,MAAM,EAAkB,EAAO,EAAE;IAC9F,MAAM,OAAO,GAAG,WAAW,EAAE,OAAO,IAAI,EAAE,CAAA;IAC1C,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,oBAAoB,CAAC,wDAAwD,CAAC,CAAA;IAC1F,CAAC;IAED,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AACpD,CAAC,CAAA"}
|
package/verifyConditions.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ import PluginConfig from './@types/pluginConfig.js';
|
|
|
4
4
|
*
|
|
5
5
|
* @throws {SemanticReleaseError}
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare const _default: ({ apiSpecFiles }: PluginConfig) => Promise<any>;
|
|
8
|
+
export default _default;
|
package/verifyConditions.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import SemanticReleaseError from '@semantic-release/error';
|
|
2
|
+
import { globSync } from 'glob';
|
|
3
|
+
import { extname } from 'node:path';
|
|
2
4
|
/**
|
|
3
5
|
* verifyConditions hook for semantic release
|
|
4
6
|
*
|
|
5
7
|
* @throws {SemanticReleaseError}
|
|
6
8
|
*/
|
|
7
|
-
export default async
|
|
8
|
-
const SemanticReleaseError = (await import('@semantic-release/error')).default;
|
|
9
|
+
export default async ({ apiSpecFiles }) => {
|
|
9
10
|
if (apiSpecFiles.length < 1) {
|
|
10
11
|
throw new SemanticReleaseError('Option "apiSpecFiles" was not included in the plugin config. See the README for instructions.', 'ENOAPISPECFILES');
|
|
11
12
|
}
|
|
12
13
|
const expectedExts = ['json', 'yaml', 'yml'];
|
|
13
14
|
let specFilesFound = false;
|
|
14
15
|
apiSpecFiles.forEach((fileNameGlob) => {
|
|
15
|
-
|
|
16
|
-
const fileNames = new fdir().glob(fileNameGlob).withBasePath().crawl('.').sync();
|
|
16
|
+
const fileNames = globSync(fileNameGlob);
|
|
17
17
|
if (fileNames.length > 0) {
|
|
18
18
|
specFilesFound = true;
|
|
19
19
|
fileNames.forEach((fileName) => {
|
|
20
|
-
if (!expectedExts.includes(fileName
|
|
20
|
+
if (!expectedExts.includes(extname(fileName).slice(1))) {
|
|
21
21
|
throw new SemanticReleaseError('File "' + fileName + '" is not valid. Must be a file with .json, .yaml, or .yml extension', 'EINVALIDAPISPECFILETYPE');
|
|
22
22
|
}
|
|
23
23
|
});
|
|
@@ -26,5 +26,5 @@ export default async function ({ apiSpecFiles }) {
|
|
|
26
26
|
if (!specFilesFound) {
|
|
27
27
|
throw new SemanticReleaseError('No files match the paths in "apiSpecFiles". Check your plugin config and try again.', 'EINVALIDAPISPECFILES');
|
|
28
28
|
}
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
//# sourceMappingURL=verifyConditions.js.map
|
package/verifyConditions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyConditions.js","sourceRoot":"","sources":["../src/verifyConditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"verifyConditions.js","sourceRoot":"","sources":["../src/verifyConditions.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC;;;;GAIG;AACH,eAAe,KAAK,EAAE,EAAE,YAAY,EAAgB,EAAgB,EAAE;IACpE,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,oBAAoB,CAC5B,+FAA+F,EAC/F,iBAAiB,CAClB,CAAA;IACH,CAAC;IAED,MAAM,YAAY,GAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;IACtD,IAAI,cAAc,GAAY,KAAK,CAAA;IACnC,YAAY,CAAC,OAAO,CAAC,CAAC,YAAoB,EAAE,EAAE;QAC5C,MAAM,SAAS,GAAa,QAAQ,CAAC,YAAY,CAAC,CAAA;QAClD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,cAAc,GAAG,IAAI,CAAA;YACrB,SAAS,CAAC,OAAO,CAAC,CAAC,QAAgB,EAAE,EAAE;gBACrC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBACvD,MAAM,IAAI,oBAAoB,CAC5B,QAAQ,GAAG,QAAQ,GAAG,qEAAqE,EAC3F,yBAAyB,CAC1B,CAAA;gBACH,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,oBAAoB,CAC5B,qFAAqF,EACrF,sBAAsB,CACvB,CAAA;IACH,CAAC;AACH,CAAC,CAAA"}
|
package/getReplaceInFile.d.ts
DELETED
|
@@ -1,10 +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 function (): Promise<typeof import('replace-in-file').default>;
|
package/getReplaceInFile.js
DELETED
|
@@ -1,13 +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 () {
|
|
11
|
-
return (await import('replace-in-file')).default;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=getReplaceInFile.js.map
|
package/getReplaceInFile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getReplaceInFile.js","sourceRoot":"","sources":["../src/getReplaceInFile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK;IAClB,OAAO,CAAC,MAAM,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAA;AAClD,CAAC"}
|