semantic-release-openapi 2.0.0 → 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/@types/pluginConfig.js +1 -2
- package/index.d.ts +2 -2
- package/index.js +2 -10
- package/index.js.map +1 -1
- package/package.json +7 -6
- package/prepare.d.ts +3 -3
- package/prepare.js +12 -18
- package/prepare.js.map +1 -1
- package/verifyConditions.d.ts +1 -1
- package/verifyConditions.js +9 -13
- package/verifyConditions.js.map +1 -1
package/@types/pluginConfig.js
CHANGED
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.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"
|
|
@@ -40,11 +41,11 @@
|
|
|
40
41
|
},
|
|
41
42
|
"platform": "node",
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@semantic-release/error": "^
|
|
44
|
-
"fs-extra": "^
|
|
45
|
-
"glob": "^
|
|
46
|
-
"replace-in-file": "^
|
|
47
|
-
"semantic-release": "^
|
|
44
|
+
"@semantic-release/error": "^4.0.0",
|
|
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
|
"config": {
|
|
50
51
|
"commitizen": {
|
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 _default: ({ apiSpecFiles }: PluginConfig, { nextRelease, logger }:
|
|
8
|
+
declare const _default: ({ apiSpecFiles }: PluginConfig, { nextRelease, logger }: PrepareContext) => any;
|
|
9
9
|
export default _default;
|
package/prepare.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
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 { globSync } from 'glob';
|
|
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
|
-
const fileNames =
|
|
17
|
+
const fileNames = globSync(fileNameGlob);
|
|
23
18
|
fileNames.forEach((fileName) => {
|
|
24
19
|
let results;
|
|
25
20
|
if (fileName.split('.').pop() === 'json') {
|
|
@@ -35,7 +30,7 @@ const prepareApiSpecFiles = (apiSpecFiles, version, logger) => {
|
|
|
35
30
|
});
|
|
36
31
|
}
|
|
37
32
|
catch (error) {
|
|
38
|
-
throw new
|
|
33
|
+
throw new SemanticReleaseError(error);
|
|
39
34
|
}
|
|
40
35
|
};
|
|
41
36
|
/**
|
|
@@ -47,8 +42,7 @@ const prepareApiSpecFiles = (apiSpecFiles, version, logger) => {
|
|
|
47
42
|
* @returns {string[]} A list of altered files
|
|
48
43
|
*/
|
|
49
44
|
const prepareApiSpecFileYml = (apiSpecFile, version) => {
|
|
50
|
-
const changedFiles =
|
|
51
|
-
.sync({
|
|
45
|
+
const changedFiles = replaceInFileSync({
|
|
52
46
|
files: apiSpecFile,
|
|
53
47
|
from: /version: ?.+$/im,
|
|
54
48
|
to: 'version: ' + version
|
|
@@ -66,9 +60,9 @@ const prepareApiSpecFileYml = (apiSpecFile, version) => {
|
|
|
66
60
|
* @returns {string[]} A list of altered files
|
|
67
61
|
*/
|
|
68
62
|
const prepareApiSpecFileJson = (apiSpecFile, version) => {
|
|
69
|
-
const specFile =
|
|
63
|
+
const specFile = readJsonSync(apiSpecFile);
|
|
70
64
|
specFile.info.version = version;
|
|
71
|
-
|
|
65
|
+
writeJsonSync(apiSpecFile, specFile, { spaces: 2 });
|
|
72
66
|
return [apiSpecFile];
|
|
73
67
|
};
|
|
74
68
|
/**
|
|
@@ -76,10 +70,10 @@ const prepareApiSpecFileJson = (apiSpecFile, version) => {
|
|
|
76
70
|
*
|
|
77
71
|
* @throws {SemanticReleaseError}
|
|
78
72
|
*/
|
|
79
|
-
|
|
73
|
+
export default ({ apiSpecFiles }, { nextRelease, logger }) => {
|
|
80
74
|
const version = nextRelease?.version ?? '';
|
|
81
75
|
if (version.length < 1) {
|
|
82
|
-
throw new
|
|
76
|
+
throw new SemanticReleaseError('Could not determine the version from semantic release.');
|
|
83
77
|
}
|
|
84
78
|
prepareApiSpecFiles(apiSpecFiles, version, logger);
|
|
85
79
|
};
|
package/prepare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../src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Module", { 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 { globSync } from 'glob';
|
|
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
|
+
export default 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
|
-
const fileNames =
|
|
16
|
+
const fileNames = globSync(fileNameGlob);
|
|
21
17
|
if (fileNames.length > 0) {
|
|
22
18
|
specFilesFound = true;
|
|
23
19
|
fileNames.forEach((fileName) => {
|
|
24
|
-
if (!expectedExts.includes(fileName
|
|
25
|
-
throw new
|
|
20
|
+
if (!expectedExts.includes(extname(fileName).slice(1))) {
|
|
21
|
+
throw new SemanticReleaseError('File "' + fileName + '" is not valid. Must be a file with .json, .yaml, or .yml extension', 'EINVALIDAPISPECFILETYPE');
|
|
26
22
|
}
|
|
27
23
|
});
|
|
28
24
|
}
|
|
29
25
|
});
|
|
30
26
|
if (!specFilesFound) {
|
|
31
|
-
throw new
|
|
27
|
+
throw new SemanticReleaseError('No files match the paths in "apiSpecFiles". Check your plugin config and try again.', 'EINVALIDAPISPECFILES');
|
|
32
28
|
}
|
|
33
29
|
};
|
|
34
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":"
|
|
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,sBAAs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