semantic-release-openapi 2.0.0 → 2.2.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/@types/pluginConfig.js +1 -2
- package/README.md +3 -5
- package/index.d.ts +2 -2
- package/index.js +2 -10
- package/index.js.map +1 -1
- package/package.json +8 -10
- package/prepare.d.ts +4 -4
- package/prepare.js +14 -18
- package/prepare.js.map +1 -1
- package/verifyConditions.d.ts +3 -3
- package/verifyConditions.js +11 -13
- package/verifyConditions.js.map +1 -1
package/@types/pluginConfig.js
CHANGED
package/README.md
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
# semantic-release-openapi
|
|
2
2
|
|
|
3
3
|
[][npm]
|
|
4
|
-
[][npm]
|
|
5
4
|
[](https://github.com/aensley/semantic-release-openapi/blob/main/LICENSE)
|
|
6
|
-
[](https://packagephobia.com/result?p=semantic-release-openapi)
|
|
6
|
+
[][npm]<br>
|
|
7
|
+
[][npm]
|
|
9
8
|
[](https://github.com/aensley/semantic-release-openapi/actions/workflows/ci.yml)
|
|
10
9
|
[][qltysh]
|
|
11
10
|
[][qltysh]
|
|
12
|
-
[][npm]
|
|
13
11
|
|
|
14
12
|
A Semantic Release plugin to update versions in OpenAPI / Swagger specification files.
|
|
15
13
|
|
package/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as verifyConditions } from './verifyConditions';
|
|
2
|
-
export { default as prepare } from './prepare';
|
|
1
|
+
export { default as verifyConditions } from './verifyConditions.js';
|
|
2
|
+
export { default as prepare } from './prepare.js';
|
package/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.prepare = exports.verifyConditions = void 0;
|
|
7
|
-
var verifyConditions_1 = require("./verifyConditions");
|
|
8
|
-
Object.defineProperty(exports, "verifyConditions", { enumerable: true, get: function () { return __importDefault(verifyConditions_1).default; } });
|
|
9
|
-
var prepare_1 = require("./prepare");
|
|
10
|
-
Object.defineProperty(exports, "prepare", { enumerable: true, get: function () { return __importDefault(prepare_1).default; } });
|
|
1
|
+
export { default as verifyConditions } from './verifyConditions.js';
|
|
2
|
+
export { default as prepare } from './prepare.js';
|
|
11
3
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release-openapi",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.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"
|
|
@@ -40,15 +41,12 @@
|
|
|
40
41
|
},
|
|
41
42
|
"platform": "node",
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@semantic-release/error": "^
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"replace-in-file": "^
|
|
47
|
-
"semantic-release": "^19.0.5"
|
|
44
|
+
"@semantic-release/error": "^4.0.0",
|
|
45
|
+
"fdir": "^6.5.0",
|
|
46
|
+
"fs-extra": "^11.3.5",
|
|
47
|
+
"replace-in-file": "^8.4.0"
|
|
48
48
|
},
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"path": "./node_modules/cz-conventional-changelog"
|
|
52
|
-
}
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"semantic-release": ">=20.0.0"
|
|
53
51
|
}
|
|
54
52
|
}
|
package/prepare.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import PluginConfig from './@types/pluginConfig';
|
|
1
|
+
import { PrepareContext } from 'semantic-release';
|
|
2
|
+
import PluginConfig from './@types/pluginConfig.js';
|
|
3
3
|
/**
|
|
4
4
|
* prepare hook for semantic release
|
|
5
5
|
*
|
|
6
6
|
* @throws {SemanticReleaseError}
|
|
7
7
|
*/
|
|
8
|
-
declare const
|
|
9
|
-
export default
|
|
8
|
+
declare const prepare: ({ apiSpecFiles }: PluginConfig, { nextRelease, logger }: PrepareContext) => any;
|
|
9
|
+
export default prepare;
|
package/prepare.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const error_1 = __importDefault(require("@semantic-release/error"));
|
|
7
|
-
const fs_extra_1 = require("fs-extra");
|
|
8
|
-
const replace_in_file_1 = __importDefault(require("replace-in-file"));
|
|
9
|
-
const glob_1 = __importDefault(require("glob"));
|
|
1
|
+
import SemanticReleaseError from '@semantic-release/error';
|
|
2
|
+
import { readJsonSync, writeJsonSync } from 'fs-extra';
|
|
3
|
+
import { replaceInFileSync } from 'replace-in-file';
|
|
4
|
+
import { fdir } from 'fdir';
|
|
10
5
|
/**
|
|
11
6
|
* Prepare the API Spec files
|
|
12
7
|
*
|
|
13
8
|
* @param {string[]} apiSpecFiles List of api spec file paths, globs supported
|
|
14
9
|
* @param {string} version The version string to write to the files
|
|
15
|
-
* @param {
|
|
10
|
+
* @param {PrepareContext['logger']} logger The semantic release logger instance
|
|
16
11
|
*
|
|
17
12
|
* @throws {SemanticReleaseError}
|
|
18
13
|
*/
|
|
19
14
|
const prepareApiSpecFiles = (apiSpecFiles, version, logger) => {
|
|
20
15
|
try {
|
|
21
16
|
apiSpecFiles.forEach((fileNameGlob) => {
|
|
22
|
-
|
|
17
|
+
// eslint-disable-next-line new-cap
|
|
18
|
+
const fileNames = new fdir().glob(fileNameGlob).withBasePath().crawl('.').sync();
|
|
23
19
|
fileNames.forEach((fileName) => {
|
|
24
20
|
let results;
|
|
25
21
|
if (fileName.split('.').pop() === 'json') {
|
|
@@ -35,7 +31,7 @@ const prepareApiSpecFiles = (apiSpecFiles, version, logger) => {
|
|
|
35
31
|
});
|
|
36
32
|
}
|
|
37
33
|
catch (error) {
|
|
38
|
-
throw new
|
|
34
|
+
throw new SemanticReleaseError(error);
|
|
39
35
|
}
|
|
40
36
|
};
|
|
41
37
|
/**
|
|
@@ -47,8 +43,7 @@ const prepareApiSpecFiles = (apiSpecFiles, version, logger) => {
|
|
|
47
43
|
* @returns {string[]} A list of altered files
|
|
48
44
|
*/
|
|
49
45
|
const prepareApiSpecFileYml = (apiSpecFile, version) => {
|
|
50
|
-
const changedFiles =
|
|
51
|
-
.sync({
|
|
46
|
+
const changedFiles = replaceInFileSync({
|
|
52
47
|
files: apiSpecFile,
|
|
53
48
|
from: /version: ?.+$/im,
|
|
54
49
|
to: 'version: ' + version
|
|
@@ -66,9 +61,9 @@ const prepareApiSpecFileYml = (apiSpecFile, version) => {
|
|
|
66
61
|
* @returns {string[]} A list of altered files
|
|
67
62
|
*/
|
|
68
63
|
const prepareApiSpecFileJson = (apiSpecFile, version) => {
|
|
69
|
-
const specFile =
|
|
64
|
+
const specFile = readJsonSync(apiSpecFile);
|
|
70
65
|
specFile.info.version = version;
|
|
71
|
-
|
|
66
|
+
writeJsonSync(apiSpecFile, specFile, { spaces: 2 });
|
|
72
67
|
return [apiSpecFile];
|
|
73
68
|
};
|
|
74
69
|
/**
|
|
@@ -76,11 +71,12 @@ const prepareApiSpecFileJson = (apiSpecFile, version) => {
|
|
|
76
71
|
*
|
|
77
72
|
* @throws {SemanticReleaseError}
|
|
78
73
|
*/
|
|
79
|
-
|
|
74
|
+
const prepare = ({ apiSpecFiles }, { nextRelease, logger }) => {
|
|
80
75
|
const version = nextRelease?.version ?? '';
|
|
81
76
|
if (version.length < 1) {
|
|
82
|
-
throw new
|
|
77
|
+
throw new SemanticReleaseError('Could not determine the version from semantic release.');
|
|
83
78
|
}
|
|
84
79
|
prepareApiSpecFiles(apiSpecFiles, version, logger);
|
|
85
80
|
};
|
|
81
|
+
export default prepare;
|
|
86
82
|
//# sourceMappingURL=prepare.js.map
|
package/prepare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../src/prepare.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../src/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAGnD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAE3B;;;;;;;;GAQG;AACH,MAAM,mBAAmB,GAAG,CAAC,YAAsB,EAAE,OAAe,EAAE,MAAgC,EAAO,EAAE;IAC7G,IAAI,CAAC;QACH,YAAY,CAAC,OAAO,CAAC,CAAC,YAAoB,EAAE,EAAE;YAC5C,mCAAmC;YACnC,MAAM,SAAS,GAAa,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,YAAY,EAAE,CAAC,KAAK,CAAC,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AAC,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,MAAM,OAAO,GAAG,CAAC,EAAE,YAAY,EAAgB,EAAE,EAAE,WAAW,EAAE,MAAM,EAAkB,EAAO,EAAE;IAC/F,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;AAED,eAAe,OAAO,CAAA"}
|
package/verifyConditions.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import PluginConfig from './@types/pluginConfig';
|
|
1
|
+
import PluginConfig from './@types/pluginConfig.js';
|
|
2
2
|
/**
|
|
3
3
|
* verifyConditions hook for semantic release
|
|
4
4
|
*
|
|
5
5
|
* @throws {SemanticReleaseError}
|
|
6
6
|
*/
|
|
7
|
-
declare const
|
|
8
|
-
export default
|
|
7
|
+
declare const verifyConditions: ({ apiSpecFiles }: PluginConfig) => Promise<any>;
|
|
8
|
+
export default verifyConditions;
|
package/verifyConditions.js
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const error_1 = __importDefault(require("@semantic-release/error"));
|
|
7
|
-
const glob_1 = __importDefault(require("glob"));
|
|
1
|
+
import SemanticReleaseError from '@semantic-release/error';
|
|
2
|
+
import { fdir } from 'fdir';
|
|
3
|
+
import { extname } from 'node:path';
|
|
8
4
|
/**
|
|
9
5
|
* verifyConditions hook for semantic release
|
|
10
6
|
*
|
|
11
7
|
* @throws {SemanticReleaseError}
|
|
12
8
|
*/
|
|
13
|
-
|
|
9
|
+
const verifyConditions = async ({ apiSpecFiles }) => {
|
|
14
10
|
if (apiSpecFiles.length < 1) {
|
|
15
|
-
throw new
|
|
11
|
+
throw new SemanticReleaseError('Option "apiSpecFiles" was not included in the plugin config. See the README for instructions.', 'ENOAPISPECFILES');
|
|
16
12
|
}
|
|
17
13
|
const expectedExts = ['json', 'yaml', 'yml'];
|
|
18
14
|
let specFilesFound = false;
|
|
19
15
|
apiSpecFiles.forEach((fileNameGlob) => {
|
|
20
|
-
|
|
16
|
+
// eslint-disable-next-line new-cap
|
|
17
|
+
const fileNames = new fdir().glob(fileNameGlob).withBasePath().crawl('.').sync();
|
|
21
18
|
if (fileNames.length > 0) {
|
|
22
19
|
specFilesFound = true;
|
|
23
20
|
fileNames.forEach((fileName) => {
|
|
24
|
-
if (!expectedExts.includes(fileName
|
|
25
|
-
throw new
|
|
21
|
+
if (!expectedExts.includes(extname(fileName).slice(1))) {
|
|
22
|
+
throw new SemanticReleaseError('File "' + fileName + '" is not valid. Must be a file with .json, .yaml, or .yml extension', 'EINVALIDAPISPECFILETYPE');
|
|
26
23
|
}
|
|
27
24
|
});
|
|
28
25
|
}
|
|
29
26
|
});
|
|
30
27
|
if (!specFilesFound) {
|
|
31
|
-
throw new
|
|
28
|
+
throw new SemanticReleaseError('No files match the paths in "apiSpecFiles". Check your plugin config and try again.', 'EINVALIDAPISPECFILES');
|
|
32
29
|
}
|
|
33
30
|
};
|
|
31
|
+
export default verifyConditions;
|
|
34
32
|
//# sourceMappingURL=verifyConditions.js.map
|
package/verifyConditions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyConditions.js","sourceRoot":"","sources":["../src/verifyConditions.ts"],"names":[],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