semantic-release-yaml 1.1.3 → 1.1.4
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/dist/index.d.ts +29 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +18 -17
- package/dist/src/get-error.d.ts +0 -2
- package/dist/src/index.d.ts +0 -3
- package/dist/src/verify-commands.d.ts +0 -2
- package/dist/src/yaml.d.ts +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PrepareContext } from "semantic-release";
|
|
2
|
+
interface Command {
|
|
3
|
+
/**
|
|
4
|
+
* Current working directory.
|
|
5
|
+
*/
|
|
6
|
+
cwd: string;
|
|
7
|
+
/**
|
|
8
|
+
* The YAML file on which the command should be executed.
|
|
9
|
+
*/
|
|
10
|
+
file: string;
|
|
11
|
+
/**
|
|
12
|
+
* The subpath leading to the field which should get a new value (evaluated with https://lodash.com/docs/4.17.15#set).
|
|
13
|
+
*/
|
|
14
|
+
selector: string;
|
|
15
|
+
/**
|
|
16
|
+
* The next value to be inserted in the YAML file.
|
|
17
|
+
*/
|
|
18
|
+
value: string;
|
|
19
|
+
}
|
|
20
|
+
interface Configuration {
|
|
21
|
+
/**
|
|
22
|
+
* A list of commands to run
|
|
23
|
+
*/
|
|
24
|
+
commands: Array<Command>;
|
|
25
|
+
}
|
|
26
|
+
type SemanticContext = PrepareContext;
|
|
27
|
+
export declare function prepare({ commands }: Configuration, context: SemanticContext): "Prepared" | undefined;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
var e=
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("path");c=s(c);let l=require("lodash/template");l=s(l);let u=require("fs");u=s(u);let d=require("lodash/set");d=s(d);let f=require("yaml-diff-patch"),p=require("js-yaml");p=s(p);let m=require("lodash"),h=require("aggregate-error");h=s(h);let g=require("@semantic-release/error");g=s(g);let _=require("lodash/isString");_=s(_);let v=require("util");const y=(e,{cwd:t=process.cwd(),env:n,logger:r,...i})=>{let a=(0,l.default)(e.cwd)(i),o=(0,l.default)(e.file)(i),s=(0,l.default)(e.selector)(i),m=(0,l.default)(e.value)(i),h=a?c.default.resolve(t,a):t,g=c.default.resolve(h,o);r.log(`Updating -> path: ${g} | selector: ${s} | value: ${m}`);let _=u.default.readFileSync(g,`utf8`),v=p.default.load(_),y=p.default.load(_);if(typeof y!=`object`||!y)throw Error(`The file ${g} is not a valid YAML file.`);(0,d.default)(y,s,m);let b=(0,f.yamlDiffPatch)(_,v,y);u.default.writeFileSync(g,b)},[b]=`https://github.com/meesvandongen/semantic-release-yaml#readme`.split(`#`);function x(e){return(0,_.default)(e)?e:(0,v.inspect)(e,{breakLength:1/0,depth:2,maxArrayLength:5})}function S(e){return`${b}/blob/master/${e}`}function C(e,t){let n=[`for usage, see ${S(`README.md#options`)}`,``,`Your configuration for the \`${e}\` option is \`${x(t[e])}\`.`].join(`
|
|
2
|
+
`);return new g.default(`Invalid \`${e}\` option.`,e,n)}const w=e=>(0,m.isString)(e)&&e.trim().length>0,T=[{key:`cwd`,validator:(e=>t=>(0,m.isNil)(t)||e(t))(w)},{key:`file`,validator:w},{key:`selector`,validator:w},{key:`value`,validator:w}];function E(e){let t=e.flatMap(e=>T.reduce((t,{key:n,validator:r})=>{let i=e[n];return r(i)?t:t.concat(C(n,e))},[]));if(t.length>0)throw new h.default(t)}function D({commands:e},t){if(e.length>0)return E(e),e.forEach(e=>{y(e,t)}),`Prepared`}exports.prepare=D;
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.js","names":["template","jsYaml","yamlDiffPatch","isString","inspect","SemanticReleaseError","isString","isNil","AggregateError","__create","__defProp","__getOwnPropDesc","__getOwnPropNames","__getProtoOf","__hasOwnProp","__copyProps","from","keys","i","n","key","to","except","k","desc","__toESM","mod","isNodeMode","target","path","lodash_template","fs","lodash_set","yaml_diff_patch","js_yaml","lodash","aggregate_error","_semantic_release_error","lodash_isString","util","yaml","context","interpretedCwd","command","interpretedFile","interpretedSelector","interpretedValue","workingDirectory","cwd","pathToFile","logger","yamlFileRaw","originalYamlFile","changedYamlFile","yamlResult","homepage","stringify","object","linkify","file","getError","message","isNonEmptyString","value","validators","validator","verifyCommands","errors","commands","prepare"],"sources":["../src/yaml.ts","../package.json","../src/get-error.ts","../src/verify-commands.ts","../src/index.ts"],"sourcesContent":["import path from \"path\";\nimport template from \"lodash/template\";\nimport fs from \"fs\";\nimport { Command } from \"./definitions/configuration.interface\";\nimport { SemanticContext } from \"./definitions/semantic-context.interface\";\nimport set from \"lodash/set\";\nimport { yamlDiffPatch } from \"yaml-diff-patch\";\nimport jsYaml from \"js-yaml\";\n\nexport const yaml = (\n command: Command,\n { cwd = process.cwd(), env, logger, ...context }: SemanticContext\n) => {\n const interpretedCwd = template(command.cwd)(context);\n const interpretedFile = template(command.file)(context);\n const interpretedSelector = template(command.selector)(context);\n const interpretedValue = template(command.value)(context);\n\n const workingDirectory = interpretedCwd\n ? path.resolve(cwd, interpretedCwd)\n : cwd;\n const pathToFile = path.resolve(workingDirectory, interpretedFile);\n\n logger.log(\n `Updating -> path: ${pathToFile} | selector: ${interpretedSelector} | value: ${interpretedValue}`\n );\n\n const yamlFileRaw = fs.readFileSync(pathToFile, \"utf8\");\n const originalYamlFile = jsYaml.load(yamlFileRaw);\n const changedYamlFile = jsYaml.load(yamlFileRaw);\n\n if (typeof changedYamlFile !== \"object\" || changedYamlFile === null) {\n throw new Error(`The file ${pathToFile} is not a valid YAML file.`);\n }\n\n set(changedYamlFile, interpretedSelector, interpretedValue);\n const yamlResult = yamlDiffPatch(\n yamlFileRaw,\n originalYamlFile,\n changedYamlFile\n );\n\n fs.writeFileSync(pathToFile, yamlResult);\n};\n","","import SemanticReleaseError from \"@semantic-release/error\";\nimport isString from \"lodash/isString\";\nimport { inspect } from \"util\";\nimport { Command } from \"./definitions/configuration.interface\";\nimport pkg from \"../package.json\";\n\nconst [homepage] = pkg.homepage.split(\"#\");\n\nfunction stringify(object: unknown) {\n if (isString(object)) {\n return object;\n }\n return inspect(object, {\n breakLength: Infinity,\n depth: 2,\n maxArrayLength: 5,\n });\n}\n\nfunction linkify(file: string) {\n return `${homepage}/blob/master/${file}`;\n}\n\nexport function getError(key: keyof Command, command: Command): Error {\n const message = [\n `for usage, see ${linkify(\"README.md#options\")}`,\n \"\",\n `Your configuration for the \\`${key}\\` option is \\`${stringify(\n command[key]\n )}\\`.`,\n ].join(\"\\n\");\n return new SemanticReleaseError(`Invalid \\`${key}\\` option.`, key, message);\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\ninterface Validator {\n key: keyof Command;\n validator: (value: unknown) => boolean;\n}\nconst validators: Array<Validator> = [\n { key: \"cwd\", validator: isOptional(isNonEmptyString) },\n { key: \"file\", validator: isNonEmptyString },\n { key: \"selector\", validator: isNonEmptyString },\n { key: \"value\", validator: isNonEmptyString },\n];\n\nexport function verifyCommands(commands: Array<Command>) {\n const errors = commands.flatMap((command) =>\n validators.reduce((errors, { key, validator }) => {\n const value = command[key];\n\n if (!validator(value)) {\n return errors.concat(getError(key, command));\n }\n return errors;\n }, [] as Array<Error>)\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({ commands }: Configuration, context: SemanticContext) {\n if (commands.length > 0) {\n verifyCommands(commands);\n\n commands.forEach((command) => {\n yaml(command, context);\n });\n return \"Prepared\";\n }\n}\n"],"mappings":"A,i6BASA,MAAawC,GACX,EACA,CAAE,MAAM,QAAQ,IAAI,EAAG,MAAK,SAAQ,GAAGC,KACpC,CACH,IAAMC,GAAA,EAAiB1C,EAAAA,QAAAA,CAAS2C,EAAQ,GAAG,CAAC,CAACF,CAAO,EAC9CG,GAAA,EAAkB5C,EAAAA,QAAAA,CAAS2C,EAAQ,IAAI,CAAC,CAACF,CAAO,EAChDI,GAAA,EAAsB7C,EAAAA,QAAAA,CAAS2C,EAAQ,QAAQ,CAAC,CAACF,CAAO,EACxDK,GAAA,EAAmB9C,EAAAA,QAAAA,CAAS2C,EAAQ,KAAK,CAAC,CAACF,CAAO,EAElDM,EAAmBL,EACrBb,EAAA,QAAK,QAAQmB,EAAKN,CAAc,EAChCM,EACEC,EAAapB,EAAA,QAAK,QAAQkB,EAAkBH,CAAe,EAEjEM,EAAO,IACL,qBAAqBD,EAAW,eAAeJ,EAAoB,YAAYC,GACjF,EAEA,IAAMK,EAAcpB,EAAA,QAAG,aAAakB,EAAY,MAAM,EAChDG,EAAmBnD,EAAAA,QAAO,KAAKkD,CAAW,EAC1CE,EAAkBp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,EAAS,QAAS,GAC/BJ,EAAW,QAAQ,EAAQ,CAAE,MAAK,eAAgB,CAChD,IAAMD,EAAQpB,EAAQvB,GAKtB,OAHK6C,EAAUF,CAAK,EAGbI,EAFEA,EAAO,OAAOP,EAASxC,EAAKuB,CAAO,CAAC,CAG/C,EAAG,CAAC,CAAiB,CACvB,EAEA,GAAIwB,EAAO,OAAS,EAClB,MAAM,IAAI3D,EAAAA,QAAe2D,CAAM,CAEnC,CClCA,SAAgBE,EAAQ,CAAE,YAA2B,EAA0B,CAC7E,GAAID,EAAS,OAAS,EAMpB,OALAF,EAAeE,CAAQ,EAEvBA,EAAS,QAAS,GAAY,CAC5B5B,EAAKG,EAASF,CAAO,CACvB,CAAC,EACM,UAEX,C"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release-yaml",
|
|
3
3
|
"description": "semantic-release plugin to edit yaml files",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.4",
|
|
5
5
|
"author": "Mees van Dongen",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/meesvandongen/semantic-release-yaml/issues"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@semantic-release/error": "^
|
|
10
|
+
"@semantic-release/error": "^4.0.0",
|
|
11
11
|
"aggregate-error": "^3.0.0",
|
|
12
12
|
"debug": "^4.0.0",
|
|
13
13
|
"js-yaml": "^4.1.0",
|
|
14
14
|
"lodash": "^4.17.4",
|
|
15
|
-
"yaml-diff-patch": "^
|
|
15
|
+
"yaml-diff-patch": "^2.0.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@semantic-release/git": "^
|
|
19
|
-
"@swc/core": "^1.2.125",
|
|
20
|
-
"@swc/jest": "^0.2.15",
|
|
21
|
-
"@types/jest": "^27.4.0",
|
|
18
|
+
"@semantic-release/git": "^11.0.1",
|
|
22
19
|
"@types/js-yaml": "^4.0.5",
|
|
23
20
|
"@types/lodash": "^4.14.178",
|
|
24
|
-
"@types/
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
21
|
+
"@types/node": "^24.19.2",
|
|
22
|
+
"semantic-release": "^25.0.9",
|
|
23
|
+
"type-fest": "^2.8.0",
|
|
24
|
+
"typescript": "^7.0.2",
|
|
25
|
+
"vite-plus": "catalog:"
|
|
29
26
|
},
|
|
30
27
|
"files": [
|
|
31
28
|
"dist/**/*"
|
|
@@ -55,9 +52,13 @@
|
|
|
55
52
|
},
|
|
56
53
|
"scripts": {
|
|
57
54
|
"semantic-release": "semantic-release",
|
|
58
|
-
"build": "
|
|
59
|
-
"build:watch": "
|
|
60
|
-
"test": "
|
|
61
|
-
"test:watch": "
|
|
62
|
-
|
|
55
|
+
"build": "vp pack",
|
|
56
|
+
"build:watch": "vp pack --watch",
|
|
57
|
+
"test": "vp test run",
|
|
58
|
+
"test:watch": "vp test",
|
|
59
|
+
"lint": "vp lint",
|
|
60
|
+
"format": "vp fmt",
|
|
61
|
+
"format:check": "vp fmt --check"
|
|
62
|
+
},
|
|
63
|
+
"packageManager": "pnpm@12.15.0+sha512.b3951d6d6ff4a9f13dc7cf56cd28d2b8eb37dbcc9c68e52e1e1191873ea9f82a017287ab50baadc5ccc494f036c67c0e47eb13608c2fa36f47711b61ea128e61"
|
|
63
64
|
}
|
package/dist/src/get-error.d.ts
DELETED
package/dist/src/index.d.ts
DELETED
package/dist/src/yaml.d.ts
DELETED