semantic-release-yaml 1.0.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/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/get-error.d.ts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/verify-commands.d.ts +2 -0
- package/dist/yaml.d.ts +3 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# semantic-release-yaml
|
|
2
|
+
|
|
3
|
+
[**semantic-release**](https://github.com/semantic-release/semantic-release) plugin to change yaml files.
|
|
4
|
+
|
|
5
|
+
| Step | Description |
|
|
6
|
+
| --------- | ----------------------------------- |
|
|
7
|
+
| `prepare` | edit yaml during prepare the phase. |
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
$ npm install semantic-release-yaml -D
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
The plugin can be configured in the [**semantic-release** configuration file](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration):
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"plugins": [
|
|
22
|
+
[
|
|
23
|
+
"semantic-release-yaml",
|
|
24
|
+
{
|
|
25
|
+
"commands": [
|
|
26
|
+
{
|
|
27
|
+
"cwd": "./",
|
|
28
|
+
"phase": "prepare",
|
|
29
|
+
"file": "./Chart.yaml",
|
|
30
|
+
"selector": "version",
|
|
31
|
+
"value": "${nextRelease.version}"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"@semantic-release/git"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
```
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=require("path"),t=require("lodash/template"),r=require("js-yaml"),n=require("fs"),i=require("lodash/set"),o=require("lodash"),a=require("aggregate-error"),l=require("@semantic-release/error"),s=require("lodash/isString"),d=require("util");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=/*#__PURE__*/u(e),f=/*#__PURE__*/u(t),p=/*#__PURE__*/u(r),m=/*#__PURE__*/u(n),g=/*#__PURE__*/u(i),h=/*#__PURE__*/u(a),w=/*#__PURE__*/u(l),q=/*#__PURE__*/u(s);const y=["cwd","env","stdout","stderr","logger"],v=require("../../package.json"),[b]=v.homepage.split("#"),$=e=>q.default(e)?e:d.inspect(e,{breakLength:Infinity,depth:2,maxArrayLength:5}),j=e=>`${b}/blob/master/${e}`,E={cmd:e=>({message:`Invalid \`cmd\` option for phase \`${e.phase}\`.`,details:`The [\`cmd\` option](${j("README.md#options")}) is required and must be a non empty \`String\`.\n\nYour configuration for the \`cmd\` option is \`${$(e.template)}\`.`}),cwd:e=>({message:"Invalid `cwd` option.",details:`The [\`cwd\` option](${j("README.md#options")}) if defined, must be a non empty \`String\`.\n\nYour configuration for the \`cwd\` option is \`${$(e.cwd)}\`.`})};function S(e,t){const{message:r,details:n}=E[e](t);return new w.default(r,e,n)}const k=e=>o.isString(e)&&e.trim().length>0,A={cmd:k,cwd:(M=k,e=>o.isNil(e)||M(e))};var M;exports.prepare=function(e,t){const r=e.commands.filter(e=>"prepare"===e.phase);if(r.length>0)return function(e){const t=e.flatMap(e=>Object.keys(A).reduce((t,r)=>(0,A[r])(e[r])?t:t.concat(S(r,e)),[]));if(t.length>0)throw new h.default(t)}(r),r.forEach(e=>{((e,t)=>{let{cwd:r=process.cwd(),logger:n}=t,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(i[r]=e[r]);return i}(t,y);const o=f.default(e.template)(i);n.log("Call script %s",o);const a=e.cwd?c.default.resolve(r,e.cwd):r,l=c.default.resolve(a,e.file),s=p.default.load(m.default.readFileSync(l,"utf8"));if("object"!=typeof s||null===s)throw new Error(`The file ${l} is not a valid YAML file.`);g.default(s,e.selector,o),m.default.writeFileSync(l,p.default.dump(s))})(e,t)}),"Prepared"};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/get-error.ts","../src/verify-commands.ts","../src/index.ts","../src/yaml.ts"],"sourcesContent":["import SemanticReleaseError from \"@semantic-release/error\";\nimport isString from \"lodash/isString\";\nimport { inspect } from \"util\";\nimport { Command } from \"./definitions/configuration.interface\";\n\nconst pkg = require(\"../../package.json\");\n\nconst [homepage] = pkg.homepage.split(\"#\");\nconst stringify = (object) =>\n isString(object)\n ? object\n : inspect(object, { breakLength: Infinity, depth: 2, maxArrayLength: 5 });\nconst linkify = (file) => `${homepage}/blob/master/${file}`;\n\nconst errors = {\n cmd: (command: Command) => ({\n message: `Invalid \\`cmd\\` option for phase \\`${command.phase}\\`.`,\n details: `The [\\`cmd\\` option](${linkify(\n `README.md#options`\n )}) is required and must be a non empty \\`String\\`.\n\nYour configuration for the \\`cmd\\` option is \\`${stringify(\n command.template\n )}\\`.`,\n }),\n cwd: (command: Command) => ({\n message: \"Invalid `cwd` option.\",\n details: `The [\\`cwd\\` option](${linkify(\n \"README.md#options\"\n )}) if defined, must be a non empty \\`String\\`.\n\nYour configuration for the \\`cwd\\` option is \\`${stringify(command.cwd)}\\`.`,\n }),\n};\n\nexport function getError(\n commandKey: string,\n command: Command\n): SemanticReleaseError {\n const { message, details } = errors[commandKey](command);\n return new SemanticReleaseError(message, commandKey, details);\n}\n","import { Command } from \"./definitions/configuration.interface\";\nimport { isNil } from \"lodash\";\nimport { isString } from \"lodash\";\nimport AggregateError from \"aggregate-error\";\nimport { getError } from \"./get-error\";\n\nconst isNonEmptyString = (value: unknown) =>\n isString(value) && value.trim().length > 0;\n\nconst isOptional =\n (validator: (value: unknown) => boolean) => (value: unknown) =>\n isNil(value) || validator(value);\n\nconst VALIDATORS = {\n cmd: isNonEmptyString,\n cwd: isOptional(isNonEmptyString),\n};\n\nexport function verifyCommands(commands: Array<Command>) {\n const errors = commands.flatMap((command) =>\n Object.keys(VALIDATORS).reduce((errors, key) => {\n const validator = VALIDATORS[key];\n const value = command[key];\n\n if (!validator(value)) {\n return errors.concat(getError(key, command));\n }\n return errors;\n }, [])\n );\n\n if (errors.length > 0) {\n throw new AggregateError(errors);\n }\n}\n","import { yaml } from \"./yaml\";\nimport { verifyCommands } from \"./verify-commands\";\nimport { Configuration } from \"./definitions/configuration.interface\";\nimport { SemanticContext } from \"./definitions/semantic-context.interface\";\n\nexport function prepare(pluginConfig: Configuration, context: SemanticContext) {\n const commands = pluginConfig.commands.filter(command => command.phase === \"prepare\");\n\n if (commands.length > 0) {\n verifyCommands(commands);\n\n commands.forEach(command => {\n yaml(command, context);\n });\n return \"Prepared\";\n }\n}\n","import path from \"path\";\nimport template from \"lodash/template\";\nimport jsYaml from \"js-yaml\";\nimport fs from \"fs\";\nimport { Command } from \"./definitions/configuration.interface\";\nimport { SemanticContext } from \"./definitions/semantic-context.interface\";\nimport set from \"lodash/set\";\n\nexport const yaml = (\n command: Command,\n {\n cwd = process.cwd(),\n env,\n stdout,\n stderr,\n logger,\n ...context\n }: SemanticContext\n) => {\n const newValue = template(command.template)(context);\n\n logger.log(\"Call script %s\", newValue);\n\n const workingDirectory = command.cwd ? path.resolve(cwd, command.cwd) : cwd;\n const pathToFile = path.resolve(workingDirectory, command.file);\n\n const yamlFile = jsYaml.load(fs.readFileSync(pathToFile, \"utf8\"));\n\n if (typeof yamlFile !== \"object\" || yamlFile === null) {\n throw new Error(`The file ${pathToFile} is not a valid YAML file.`);\n }\n set(yamlFile, command.selector, newValue);\n\n fs.writeFileSync(pathToFile, jsYaml.dump(yamlFile));\n};\n"],"names":["pkg","require","homepage","split","stringify","object","isString","inspect","breakLength","Infinity","depth","maxArrayLength","linkify","file","errors","cmd","command","message","phase","details","template","cwd","getError","commandKey","SemanticReleaseError","isNonEmptyString","value","trim","length","VALIDATORS","validator","isNil","pluginConfig","context","commands","filter","flatMap","Object","keys","reduce","key","concat","AggregateError","verifyCommands","forEach","process","logger","newValue","log","workingDirectory","path","resolve","pathToFile","yamlFile","jsYaml","load","fs","readFileSync","Error","set","selector","writeFileSync","dump","yaml"],"mappings":"khBAKMA,EAAMC,QAAQ,uBAEbC,GAAYF,EAAIE,SAASC,MAAM,KAChCC,EAAaC,GACjBC,UAASD,GACLA,EAC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,UAAOC,KAAKC,UAAGC,aAAaL,EAAY,SAEzD,GAAwB,iBAAbC,GAAsC,OAAbA,EAClC,UAAUK,kBAAkBN,+BAE9BO,UAAIN,EAAUrC,EAAQ4C,SAAUb,GAEhCS,UAAGK,cAAcT,EAAYE,UAAOQ,KAAKT,KDrBrCU,CAAK/C,EAASiB,KAET"}
|
package/dist/yaml.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "semantic-release-yaml",
|
|
3
|
+
"description": "semantic-release plugin to edit yaml files",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": "Mees van Dongen",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/meesvandongen/semantic-release-yaml/issues"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@semantic-release/error": "^3.0.0",
|
|
11
|
+
"aggregate-error": "^3.0.0",
|
|
12
|
+
"debug": "^4.0.0",
|
|
13
|
+
"js-yaml": "^4.1.0",
|
|
14
|
+
"lodash": "^4.17.4"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@semantic-release/git": "^10.0.1",
|
|
18
|
+
"@types/js-yaml": "^4.0.5",
|
|
19
|
+
"@types/lodash": "^4.14.178",
|
|
20
|
+
"@types/semantic-release": "^17.2.3",
|
|
21
|
+
"microbundle": "^0.14.2",
|
|
22
|
+
"semantic-release": "18.0.1"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/**/*"
|
|
26
|
+
],
|
|
27
|
+
"homepage": "https://github.com/meesvandongen/semantic-release-yaml#readme",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"cli",
|
|
30
|
+
"publish",
|
|
31
|
+
"release",
|
|
32
|
+
"script",
|
|
33
|
+
"semantic-release",
|
|
34
|
+
"yaml",
|
|
35
|
+
"version"
|
|
36
|
+
],
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"source": "src/index.ts",
|
|
39
|
+
"main": "dist/index.js",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"semantic-release": ">=18.0.0"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/meesvandongen/semantic-release-yaml.git"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"semantic-release": "semantic-release",
|
|
52
|
+
"build": "microbundle --target=node --format cjs --compress",
|
|
53
|
+
"build:watch": "microbundle watch --target=node --format cjs --compress"
|
|
54
|
+
}
|
|
55
|
+
}
|