@omni-oss/set-version 0.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/CHANGELOG.md +15 -0
- package/dist/cli.cjs +3 -0
- package/dist/cli.mjs +36 -0
- package/dist/index-BCvo12D0.js +1 -0
- package/dist/index-DjY1h20_.mjs +323 -0
- package/dist/set-version.cjs +1 -0
- package/dist/set-version.mjs +6 -0
- package/dist/src/cli/index.d.ts +3 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/built-in-profiles.d.ts +3 -0
- package/dist/src/lib/built-in-profiles.d.ts.map +1 -0
- package/dist/src/lib/codec-utils.d.ts +8 -0
- package/dist/src/lib/codec-utils.d.ts.map +1 -0
- package/dist/src/lib/config.d.ts +17 -0
- package/dist/src/lib/config.d.ts.map +1 -0
- package/dist/src/lib/find-config.d.ts +13 -0
- package/dist/src/lib/find-config.d.ts.map +1 -0
- package/dist/src/lib/format.d.ts +10 -0
- package/dist/src/lib/format.d.ts.map +1 -0
- package/dist/src/lib/index.d.ts +9 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/profile.d.ts +48 -0
- package/dist/src/lib/profile.d.ts.map +1 -0
- package/dist/src/lib/set-value.d.ts +33 -0
- package/dist/src/lib/set-value.d.ts.map +1 -0
- package/dist/src/lib/set-version.d.ts +30 -0
- package/dist/src/lib/set-version.d.ts.map +1 -0
- package/dist/src/lib/string-utils.d.ts +6 -0
- package/dist/src/lib/string-utils.d.ts.map +1 -0
- package/dist/src/lib/type-utils.d.ts +7 -0
- package/dist/src/lib/type-utils.d.ts.map +1 -0
- package/package.json +44 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
|
3
|
+
|
|
4
|
+
- - -
|
|
5
|
+
## @omni-oss/set-version-v0.1.0 - 2026-01-31
|
|
6
|
+
#### Features
|
|
7
|
+
- (**@omni-oss/set-version**) improve error handling - (3f8a9fb) - Clarence Manuel
|
|
8
|
+
- implement set-version script - (13f0c84) - Clarence Manuel
|
|
9
|
+
#### Miscellaneous Chores
|
|
10
|
+
- update package.json version [skip ci] - (5f549ba) - Clarence Manuel
|
|
11
|
+
- create set-version script - (f53c54e) - Clarence Manuel
|
|
12
|
+
|
|
13
|
+
- - -
|
|
14
|
+
|
|
15
|
+
Changelog generated by [cocogitto](https://github.com/cocogitto/cocogitto).
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
"use strict";const d=require("@commander-js/extra-typings"),i=require("./index-BCvo12D0.js"),f="@omni-oss/set-version",g="Sets version of various package manifests",h="0.0.0",c=new d.Command;c.name(f).version(h).description(g).argument("<version>","What version to set").option("-d, --dir <dir>","Directory to set version in",process.cwd()).option("-B, --no-built-in-profiles","Do not use built-in profiles").option("--dry-run","Do not write changes to disk",!1).action(async(l,n)=>{try{n.dryRun&&console.log("Dry run enabled, no changes will be written to disk");const o=await i.findConfig(n.dir,!1),r=n.builtInProfiles?[...i.BUILT_IN_PROFILES,...o?.profiles??[]]:o?.profiles??[];if(!r.length){console.warn("No profiles are configured, nothing to do");return}const s=await i.setVersion(n.dir,l,r,{dryRun:n.dryRun});if(s.length){const t=s.filter(e=>e.changed),a=s.filter(e=>!e.changed);console.log(`Matched ${t.length} file(s), updated ${t.length} file(s), skipped ${a.length} file(s)`);for(const e of t)console.log(` * [UPDATED]: ${e.path}`);for(const e of a)e.notChangedReasonMessage?console.log(` * [SKIPPED]: ${e.path}
|
|
3
|
+
> ${e.notChangedReasonMessage}`):console.log(` * [SKIPPED]: ${e.path}`)}else console.warn("No files updated")}catch(o){console.error(o),process.exit(1)}});c.parseAsync();
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { Command as c } from "@commander-js/extra-typings";
|
|
3
|
+
import { f as d, B as f, s as g } from "./index-DjY1h20_.mjs";
|
|
4
|
+
const h = "@omni-oss/set-version", p = "Sets version of various package manifests", u = "0.0.0", a = new c();
|
|
5
|
+
a.name(h).version(u).description(p).argument("<version>", "What version to set").option("-d, --dir <dir>", "Directory to set version in", process.cwd()).option("-B, --no-built-in-profiles", "Do not use built-in profiles").option("--dry-run", "Do not write changes to disk", !1).action(async (l, o) => {
|
|
6
|
+
try {
|
|
7
|
+
o.dryRun && console.log(
|
|
8
|
+
"Dry run enabled, no changes will be written to disk"
|
|
9
|
+
);
|
|
10
|
+
const n = await d(o.dir, !1), i = o.builtInProfiles ? [...f, ...n?.profiles ?? []] : n?.profiles ?? [];
|
|
11
|
+
if (!i.length) {
|
|
12
|
+
console.warn("No profiles are configured, nothing to do");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const s = await g(o.dir, l, i, {
|
|
16
|
+
dryRun: o.dryRun
|
|
17
|
+
});
|
|
18
|
+
if (s.length) {
|
|
19
|
+
const t = s.filter((e) => e.changed), r = s.filter((e) => !e.changed);
|
|
20
|
+
console.log(
|
|
21
|
+
`Matched ${t.length} file(s), updated ${t.length} file(s), skipped ${r.length} file(s)`
|
|
22
|
+
);
|
|
23
|
+
for (const e of t)
|
|
24
|
+
console.log(` * [UPDATED]: ${e.path}`);
|
|
25
|
+
for (const e of r)
|
|
26
|
+
e.notChangedReasonMessage ? console.log(
|
|
27
|
+
` * [SKIPPED]: ${e.path}
|
|
28
|
+
> ${e.notChangedReasonMessage}`
|
|
29
|
+
) : console.log(` * [SKIPPED]: ${e.path}`);
|
|
30
|
+
} else
|
|
31
|
+
console.warn("No files updated");
|
|
32
|
+
} catch (n) {
|
|
33
|
+
console.error(n), process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
a.parseAsync();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const f=require("zod"),v=require("@omni-oss/system-interface"),h=require("node:path"),C=require("comment-json"),$=require("fast-xml-parser"),I=require("smol-toml"),_=require("yaml"),R=require("picomatch");var o=(e=>(e.AUTO="auto",e.YAML="yaml",e.JSON="json",e.TOML="toml",e.XML="xml",e))(o||{});const b=f.enum(o),z=[{type:"path",files:["package.json"],format:o.JSON,path:["version"]},{type:"regex",files:["Cargo.toml"],pattern:'^\\s*version\\s*=\\s*"(?<version>.*)"\\s*$',flags:"m"},{type:"path",files:["*.csproj"],path:["Project","PropertyGroup","Version"],format:o.XML}],U={preserveOrder:!0,commentPropName:"#comment",ignoreAttributes:!1},y={__$$parser:new $.XMLParser(U),__$$builder:new $.XMLBuilder(U),parse:e=>y.__$$parser.parse(e),stringify:e=>y.__$$builder.build(e)};function P(e,t,r=o.AUTO){switch(r===o.AUTO&&(r=S(e)),r){case o.JSON:return C.parse(t);case o.YAML:return _.parse(t);case o.XML:return y.parse(t);case o.TOML:return I.parse(t);default:throw new T(e)}}function V(e,t,r=o.AUTO){switch(r===o.AUTO&&(r=S(e)),r){case o.JSON:return C.stringify(t,null,4);case o.YAML:return _.stringify(t);case o.XML:return y.stringify(t);case o.TOML:return I.stringify(t);default:throw new T(e)}}function S(e){switch(h.extname(e)){case".json":case".jsonc":return o.JSON;case".yaml":case".yml":return o.YAML;case".xml":return o.XML;case".toml":return o.TOML;default:throw new T(e)}}class T extends Error{constructor(t){super(`Unsupported file type for file ${t}`),super.name=this.constructor.name}}const X=f.object({files:f.string().array()}),D=X.extend({path:f.array(f.union([f.string(),f.number()])),format:b.optional()}),q=D.extend({type:f.literal("path")}),Y=X.extend({pattern:f.string(),flags:f.string().optional(),capture_group:f.string().optional()}),k=Y.extend({type:f.literal("regex")}),G=f.discriminatedUnion("type",[q,k]),J=f.object({profiles:f.array(G).optional().default([])}),B=["set-version.yaml","set-version.yml","set-version.toml","set-version.json","set-version.jsonc"];async function H(e,t,r){let n=h.resolve(e);for(;await r.fs.isDirectory(n)&&!Q(n);){for(const a of B){const s=h.join(n,a);if(await r.fs.pathExists(s)&&await r.fs.isFile(s)){const i=await r.fs.readFileAsString(s),u=P(s,i),c=J.safeParse(u);if(c.success)return c.data;throw new K(s,c.error.message)}}n=h.dirname(n)}if(t)throw new W(e)}class W extends Error{constructor(t){var r=(...n)=>(super(...n),this.dir=t,this);r(t?`No config found in ${t}`:"No config found"),super.name=this.constructor.name}}class K extends Error{constructor(t,r){super(`Invalid config at ${t}: ${r}`),this.filePath=t,super.name=this.constructor.name}}function Q(e){return h.parse(h.resolve(e)).root===e}function F(e,t,r){return M(e,t,r,[])}function M(e,t,r,n,a){if(t.length===0)return r;const[s,...i]=t;if(Array.isArray(e)){const p=s,l=e;if(!l[p])throw new m(n);return l[p]=M(l[p],i,r,[...n,p]),l}const u=s,c=e;if(!c[u])throw new m(n);return c[u]=M(c[u],i,r,[...n,u]),c}class m extends Error{constructor(t){super(`No value at path ${t.join(".")}`),this.path=t,super.name=this.constructor.name}}function Z(e,t,r,n){if(!t.test(e))throw new j(t.source);return e.replace(t,(a,...s)=>{const i=s[s.length-1],u=a,c=i[r];return c===void 0?u:u.replace(c,n)})}class j extends Error{constructor(t){super(`Regex ${t} did not match`),this.pattern=t,super.name=this.constructor.name}}async function ee(e,t,r,n,a={}){const s=Array.from(r.flatMap(l=>l.files)),i=R(s),u=r.map(l=>({...l,glob:R(l.files)})),c=await n.fs.readDirectory(e),p=[];for(const l of c){if(!i(l)||!await n.fs.isFile(l))continue;const w=h.join(e,l),A=await n.fs.readFileAsString(w);let d=A;const N=u.filter(L=>L.glob(l));if(!N.length)throw new te(l);let x,E;for(const L of N)try{d=re({path:w,content:d},t,L)}catch(g){if(g instanceof m)x="NO_VALUE_AT_PATH",E=`No value at path ${g.path.join(".")}, make sure the path is correct and it exists`;else if(g instanceof j)x="REGEX_PATTERN_NOT_MATCHED",E=`Regex pattern ${g.pattern} did not match`;else throw g}const O=A!==d;p.push({path:w,changed:O,notChangedReason:O?void 0:x??"ALREADY_UP_TO_DATE",notChangedReasonMessage:O?void 0:E??"File already up to date"}),!a.dryRun&&A!==d&&await n.fs.writeStringToFile(w,d)}return p}class te extends Error{constructor(t){super(`No profile found for file ${t}`),super.name=this.constructor.name}}function re(e,t,r){switch(r.type){case"path":{const n=(r.format===o.AUTO?S(e.path):r.format)??o.AUTO;if(r.format===o.YAML){const a=_.parseDocument(e.content);return a.setIn(r.path,t),a.toString()}else return r.format===o.XML?se(e,t,r,n):ne(e,t,r,n)}case"regex":{const n=new RegExp(r.pattern,r.flags??"m");return Z(e.content,n,r.capture_group??"version",t)}default:throw new ae(r.type)}}function ne(e,t,r,n){const a=P(e.path,e.content,n),s=F(a,r.path,t);return V(e.path,s,n)}function se(e,t,r,n){const a=P(e.path,e.content,n),s=oe(r.path,a),i=F(a,s,t);return V(e.path,i,n)}function oe(e,t){const r=[];let n=t;for(const s of e){const i=Array.from(n.entries());for(const[u,c]of i){if(c[s]){r.push(u,s),n=c[s];break}if(i.length===u+1)throw new m(e)}}const a=Array.from(n.entries());for(const[s,i]of a){if(i["#text"]){r.push(s,"#text");break}if(a.length===s+1)throw new m(e)}return r}class ae extends Error{constructor(t){super(`Unsupported profile type ${t}`),super.name=this.constructor.name}}async function ie(e,t,r,n={}){return ee(e,t,r,await v.OptimizedSystem.create(),n)}async function ce(e,t){return H(e,t,await v.OptimizedSystem.create())}exports.BUILT_IN_PROFILES=z;exports.findConfig=ce;exports.setVersion=ie;
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import l from "zod";
|
|
2
|
+
import { OptimizedSystem as v } from "@omni-oss/system-interface";
|
|
3
|
+
import h from "node:path";
|
|
4
|
+
import U from "comment-json";
|
|
5
|
+
import { XMLBuilder as I, XMLParser as b } from "fast-xml-parser";
|
|
6
|
+
import C from "smol-toml";
|
|
7
|
+
import _ from "yaml";
|
|
8
|
+
import $ from "picomatch";
|
|
9
|
+
var s = /* @__PURE__ */ ((t) => (t.AUTO = "auto", t.YAML = "yaml", t.JSON = "json", t.TOML = "toml", t.XML = "xml", t))(s || {});
|
|
10
|
+
const D = l.enum(s), dt = [
|
|
11
|
+
{
|
|
12
|
+
type: "path",
|
|
13
|
+
files: ["package.json"],
|
|
14
|
+
format: s.JSON,
|
|
15
|
+
path: ["version"]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: "regex",
|
|
19
|
+
files: ["Cargo.toml"],
|
|
20
|
+
pattern: '^\\s*version\\s*=\\s*"(?<version>.*)"\\s*$',
|
|
21
|
+
flags: "m"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: "path",
|
|
25
|
+
files: ["*.csproj"],
|
|
26
|
+
path: ["Project", "PropertyGroup", "Version"],
|
|
27
|
+
format: s.XML
|
|
28
|
+
}
|
|
29
|
+
], R = {
|
|
30
|
+
preserveOrder: !0,
|
|
31
|
+
// Required to keep comments near their tags
|
|
32
|
+
commentPropName: "#comment",
|
|
33
|
+
// Captures comments into this key
|
|
34
|
+
ignoreAttributes: !1
|
|
35
|
+
}, y = {
|
|
36
|
+
__$$parser: new b(R),
|
|
37
|
+
__$$builder: new I(R),
|
|
38
|
+
parse: (t) => y.__$$parser.parse(t),
|
|
39
|
+
stringify: (t) => y.__$$builder.build(t)
|
|
40
|
+
};
|
|
41
|
+
function P(t, e, r = s.AUTO) {
|
|
42
|
+
switch (r === s.AUTO && (r = S(t)), r) {
|
|
43
|
+
case s.JSON:
|
|
44
|
+
return U.parse(e);
|
|
45
|
+
case s.YAML:
|
|
46
|
+
return _.parse(e);
|
|
47
|
+
case s.XML:
|
|
48
|
+
return y.parse(e);
|
|
49
|
+
case s.TOML:
|
|
50
|
+
return C.parse(e);
|
|
51
|
+
default:
|
|
52
|
+
throw new T(t);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function V(t, e, r = s.AUTO) {
|
|
56
|
+
switch (r === s.AUTO && (r = S(t)), r) {
|
|
57
|
+
case s.JSON:
|
|
58
|
+
return U.stringify(e, null, 4);
|
|
59
|
+
case s.YAML:
|
|
60
|
+
return _.stringify(e);
|
|
61
|
+
case s.XML:
|
|
62
|
+
return y.stringify(e);
|
|
63
|
+
case s.TOML:
|
|
64
|
+
return C.stringify(e);
|
|
65
|
+
default:
|
|
66
|
+
throw new T(t);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function S(t) {
|
|
70
|
+
switch (h.extname(t)) {
|
|
71
|
+
case ".json":
|
|
72
|
+
case ".jsonc":
|
|
73
|
+
return s.JSON;
|
|
74
|
+
case ".yaml":
|
|
75
|
+
case ".yml":
|
|
76
|
+
return s.YAML;
|
|
77
|
+
case ".xml":
|
|
78
|
+
return s.XML;
|
|
79
|
+
case ".toml":
|
|
80
|
+
return s.TOML;
|
|
81
|
+
default:
|
|
82
|
+
throw new T(t);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
class T extends Error {
|
|
86
|
+
constructor(e) {
|
|
87
|
+
super(`Unsupported file type for file ${e}`), super.name = this.constructor.name;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const X = l.object({
|
|
91
|
+
files: l.string().array()
|
|
92
|
+
}), z = X.extend({
|
|
93
|
+
path: l.array(l.union([l.string(), l.number()])),
|
|
94
|
+
format: D.optional()
|
|
95
|
+
}), Y = z.extend({
|
|
96
|
+
type: l.literal("path")
|
|
97
|
+
}), k = X.extend({
|
|
98
|
+
pattern: l.string(),
|
|
99
|
+
flags: l.string().optional(),
|
|
100
|
+
capture_group: l.string().optional()
|
|
101
|
+
}), G = k.extend({
|
|
102
|
+
type: l.literal("regex")
|
|
103
|
+
}), J = l.discriminatedUnion("type", [
|
|
104
|
+
Y,
|
|
105
|
+
G
|
|
106
|
+
]), B = l.object({
|
|
107
|
+
profiles: l.array(J).optional().default([])
|
|
108
|
+
}), H = [
|
|
109
|
+
"set-version.yaml",
|
|
110
|
+
"set-version.yml",
|
|
111
|
+
"set-version.toml",
|
|
112
|
+
"set-version.json",
|
|
113
|
+
"set-version.jsonc"
|
|
114
|
+
];
|
|
115
|
+
async function W(t, e, r) {
|
|
116
|
+
let n = h.resolve(t);
|
|
117
|
+
for (; await r.fs.isDirectory(n) && !Q(n); ) {
|
|
118
|
+
for (const a of H) {
|
|
119
|
+
const o = h.join(n, a);
|
|
120
|
+
if (await r.fs.pathExists(o) && await r.fs.isFile(o)) {
|
|
121
|
+
const i = await r.fs.readFileAsString(o), u = P(o, i), c = B.safeParse(u);
|
|
122
|
+
if (c.success)
|
|
123
|
+
return c.data;
|
|
124
|
+
throw new K(
|
|
125
|
+
o,
|
|
126
|
+
c.error.message
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
n = h.dirname(n);
|
|
131
|
+
}
|
|
132
|
+
if (e)
|
|
133
|
+
throw new q(t);
|
|
134
|
+
}
|
|
135
|
+
class q extends Error {
|
|
136
|
+
constructor(e) {
|
|
137
|
+
var r = (...n) => (super(...n), this.dir = e, this);
|
|
138
|
+
r(e ? `No config found in ${e}` : "No config found"), super.name = this.constructor.name;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
class K extends Error {
|
|
142
|
+
constructor(e, r) {
|
|
143
|
+
super(`Invalid config at ${e}: ${r}`), this.filePath = e, super.name = this.constructor.name;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function Q(t) {
|
|
147
|
+
return h.parse(h.resolve(t)).root === t;
|
|
148
|
+
}
|
|
149
|
+
function j(t, e, r) {
|
|
150
|
+
return L(t, e, r, []);
|
|
151
|
+
}
|
|
152
|
+
function L(t, e, r, n, a) {
|
|
153
|
+
if (e.length === 0)
|
|
154
|
+
return r;
|
|
155
|
+
const [o, ...i] = e;
|
|
156
|
+
if (Array.isArray(t)) {
|
|
157
|
+
const p = o, f = t;
|
|
158
|
+
if (!f[p])
|
|
159
|
+
throw new g(n);
|
|
160
|
+
return f[p] = L(
|
|
161
|
+
f[p],
|
|
162
|
+
// biome-ignore lint/suspicious/noExplicitAny: expected runtime code
|
|
163
|
+
i,
|
|
164
|
+
r,
|
|
165
|
+
[...n, p]
|
|
166
|
+
), f;
|
|
167
|
+
}
|
|
168
|
+
const u = o, c = t;
|
|
169
|
+
if (!c[u])
|
|
170
|
+
throw new g(n);
|
|
171
|
+
return c[u] = L(
|
|
172
|
+
c[u],
|
|
173
|
+
// biome-ignore lint/suspicious/noExplicitAny: expected runtime code
|
|
174
|
+
i,
|
|
175
|
+
r,
|
|
176
|
+
[...n, u]
|
|
177
|
+
), c;
|
|
178
|
+
}
|
|
179
|
+
class g extends Error {
|
|
180
|
+
constructor(e) {
|
|
181
|
+
super(`No value at path ${e.join(".")}`), this.path = e, super.name = this.constructor.name;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function Z(t, e, r, n) {
|
|
185
|
+
if (!e.test(t)) throw new F(e.source);
|
|
186
|
+
return t.replace(e, (a, ...o) => {
|
|
187
|
+
const i = o[o.length - 1], u = a, c = i[r];
|
|
188
|
+
return c === void 0 ? u : u.replace(c, n);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
class F extends Error {
|
|
192
|
+
constructor(e) {
|
|
193
|
+
super(`Regex ${e} did not match`), this.pattern = e, super.name = this.constructor.name;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function tt(t, e, r, n, a = {}) {
|
|
197
|
+
const o = Array.from(r.flatMap((f) => f.files)), i = $(o), u = r.map((f) => ({
|
|
198
|
+
...f,
|
|
199
|
+
glob: $(f.files)
|
|
200
|
+
})), c = await n.fs.readDirectory(t), p = [];
|
|
201
|
+
for (const f of c) {
|
|
202
|
+
if (!i(f) || !await n.fs.isFile(f))
|
|
203
|
+
continue;
|
|
204
|
+
const w = h.join(t, f), A = await n.fs.readFileAsString(w);
|
|
205
|
+
let m = A;
|
|
206
|
+
const N = u.filter((O) => O.glob(f));
|
|
207
|
+
if (!N.length)
|
|
208
|
+
throw new et(f);
|
|
209
|
+
let x, E;
|
|
210
|
+
for (const O of N)
|
|
211
|
+
try {
|
|
212
|
+
m = rt(
|
|
213
|
+
{ path: w, content: m },
|
|
214
|
+
e,
|
|
215
|
+
O
|
|
216
|
+
);
|
|
217
|
+
} catch (d) {
|
|
218
|
+
if (d instanceof g)
|
|
219
|
+
x = "NO_VALUE_AT_PATH", E = `No value at path ${d.path.join(
|
|
220
|
+
"."
|
|
221
|
+
)}, make sure the path is correct and it exists`;
|
|
222
|
+
else if (d instanceof F)
|
|
223
|
+
x = "REGEX_PATTERN_NOT_MATCHED", E = `Regex pattern ${d.pattern} did not match`;
|
|
224
|
+
else
|
|
225
|
+
throw d;
|
|
226
|
+
}
|
|
227
|
+
const M = A !== m;
|
|
228
|
+
p.push({
|
|
229
|
+
path: w,
|
|
230
|
+
changed: M,
|
|
231
|
+
notChangedReason: M ? void 0 : x ?? "ALREADY_UP_TO_DATE",
|
|
232
|
+
notChangedReasonMessage: M ? void 0 : E ?? "File already up to date"
|
|
233
|
+
}), !a.dryRun && A !== m && await n.fs.writeStringToFile(w, m);
|
|
234
|
+
}
|
|
235
|
+
return p;
|
|
236
|
+
}
|
|
237
|
+
class et extends Error {
|
|
238
|
+
constructor(e) {
|
|
239
|
+
super(`No profile found for file ${e}`), super.name = this.constructor.name;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function rt(t, e, r) {
|
|
243
|
+
switch (r.type) {
|
|
244
|
+
case "path": {
|
|
245
|
+
const n = (r.format === s.AUTO ? S(t.path) : r.format) ?? s.AUTO;
|
|
246
|
+
if (r.format === s.YAML) {
|
|
247
|
+
const a = _.parseDocument(t.content);
|
|
248
|
+
return a.setIn(r.path, e), a.toString();
|
|
249
|
+
} else return r.format === s.XML ? ot(t, e, r, n) : nt(
|
|
250
|
+
t,
|
|
251
|
+
e,
|
|
252
|
+
r,
|
|
253
|
+
n
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
case "regex": {
|
|
257
|
+
const n = new RegExp(r.pattern, r.flags ?? "m");
|
|
258
|
+
return Z(
|
|
259
|
+
t.content,
|
|
260
|
+
n,
|
|
261
|
+
r.capture_group ?? "version",
|
|
262
|
+
e
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
default:
|
|
266
|
+
throw new at(r.type);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function nt(t, e, r, n) {
|
|
270
|
+
const a = P(t.path, t.content, n), o = j(a, r.path, e);
|
|
271
|
+
return V(t.path, o, n);
|
|
272
|
+
}
|
|
273
|
+
function ot(t, e, r, n) {
|
|
274
|
+
const a = P(t.path, t.content, n), o = st(r.path, a), i = j(a, o, e);
|
|
275
|
+
return V(t.path, i, n);
|
|
276
|
+
}
|
|
277
|
+
function st(t, e) {
|
|
278
|
+
const r = [];
|
|
279
|
+
let n = e;
|
|
280
|
+
for (const o of t) {
|
|
281
|
+
const i = Array.from(n.entries());
|
|
282
|
+
for (const [u, c] of i) {
|
|
283
|
+
if (c[o]) {
|
|
284
|
+
r.push(u, o), n = c[o];
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
if (i.length === u + 1)
|
|
288
|
+
throw new g(t);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const a = Array.from(n.entries());
|
|
292
|
+
for (const [o, i] of a) {
|
|
293
|
+
if (i["#text"]) {
|
|
294
|
+
r.push(o, "#text");
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
if (a.length === o + 1)
|
|
298
|
+
throw new g(t);
|
|
299
|
+
}
|
|
300
|
+
return r;
|
|
301
|
+
}
|
|
302
|
+
class at extends Error {
|
|
303
|
+
constructor(e) {
|
|
304
|
+
super(`Unsupported profile type ${e}`), super.name = this.constructor.name;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
async function gt(t, e, r, n = {}) {
|
|
308
|
+
return tt(
|
|
309
|
+
t,
|
|
310
|
+
e,
|
|
311
|
+
r,
|
|
312
|
+
await v.create(),
|
|
313
|
+
n
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
async function wt(t, e) {
|
|
317
|
+
return W(t, e, await v.create());
|
|
318
|
+
}
|
|
319
|
+
export {
|
|
320
|
+
dt as B,
|
|
321
|
+
wt as f,
|
|
322
|
+
gt as s
|
|
323
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BCvo12D0.js");exports.BUILT_IN_PROFILES=e.BUILT_IN_PROFILES;exports.findConfig=e.findConfig;exports.setVersion=e.setVersion;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"built-in-profiles.d.ts","sourceRoot":"","sources":["../../../src/lib/built-in-profiles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,eAAO,MAAM,iBAAiB,EAAE,OAAO,EAmB7B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Format } from './format';
|
|
2
|
+
export declare function deserialize(filePath: string, content: string, format?: Format): any;
|
|
3
|
+
export declare function serialize(filePath: string, object: unknown, format?: Format): string;
|
|
4
|
+
export declare function autoDetectFormat(filePath: string): Format;
|
|
5
|
+
export declare class UnsupportedFileTypeError extends Error {
|
|
6
|
+
constructor(file: string);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=codec-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/codec-utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAelC,wBAAgB,WAAW,CACvB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,MAAoB,OAiB/B;AAED,wBAAgB,SAAS,CACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,EACf,MAAM,GAAE,MAAoB,GAC7B,MAAM,CAgBR;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgBzD;AAED,qBAAa,wBAAyB,SAAQ,KAAK;gBACnC,IAAI,EAAE,MAAM;CAI3B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { default as z } from 'zod';
|
|
2
|
+
export declare const SetVersionConfigSchema: z.ZodObject<{
|
|
3
|
+
profiles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
|
+
files: z.ZodArray<z.ZodString>;
|
|
5
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
6
|
+
format: z.ZodOptional<z.ZodEnum<typeof import('./format').Format>>;
|
|
7
|
+
type: z.ZodLiteral<"path">;
|
|
8
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
9
|
+
files: z.ZodArray<z.ZodString>;
|
|
10
|
+
pattern: z.ZodString;
|
|
11
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
12
|
+
capture_group: z.ZodOptional<z.ZodString>;
|
|
13
|
+
type: z.ZodLiteral<"regex">;
|
|
14
|
+
}, z.core.$strip>], "type">>>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type SetVersionConfig = z.infer<typeof SetVersionConfigSchema>;
|
|
17
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;iBAEjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { System } from '@omni-oss/system-interface';
|
|
2
|
+
import { SetVersionConfig } from './config';
|
|
3
|
+
export declare const CONFIG_FILE_NAMES: string[];
|
|
4
|
+
export declare function findConfigAtDir<TRequired extends boolean>(startDir: string, required: TRequired, system: System): Promise<TRequired extends true ? SetVersionConfig : SetVersionConfig | undefined>;
|
|
5
|
+
export declare class NoConfigFoundError extends Error {
|
|
6
|
+
readonly dir?: string | undefined;
|
|
7
|
+
constructor(dir?: string | undefined);
|
|
8
|
+
}
|
|
9
|
+
export declare class InvalidConfigError extends Error {
|
|
10
|
+
readonly filePath: string;
|
|
11
|
+
constructor(filePath: string, message: string);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=find-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-config.d.ts","sourceRoot":"","sources":["../../../src/lib/find-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,UAAU,CAAC;AAEzE,eAAO,MAAM,iBAAiB,UAM7B,CAAC;AAEF,wBAAsB,eAAe,CAAC,SAAS,SAAS,OAAO,EAC3D,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,SAAS,EACnB,MAAM,EAAE,MAAM,GACf,OAAO,CACN,SAAS,SAAS,IAAI,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,SAAS,CAC3E,CAmCA;AAED,qBAAa,kBAAmB,SAAQ,KAAK;aACb,GAAG,CAAC,EAAE,MAAM;gBAAZ,GAAG,CAAC,EAAE,MAAM,YAAA;CAQ3C;AAED,qBAAa,kBAAmB,SAAQ,KAAK;aAErB,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM,EAChC,OAAO,EAAE,MAAM;CAKtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/lib/format.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,oBAAY,MAAM;IACd,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,GAAG,QAAQ;CACd;AAED,eAAO,MAAM,YAAY,0BAAiB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SetVersionConfig } from './config';
|
|
2
|
+
import { Profile } from './profile';
|
|
3
|
+
import { SetVersionOptions } from './set-version';
|
|
4
|
+
export { BUILT_IN_PROFILES } from './built-in-profiles';
|
|
5
|
+
export type { SetVersionConfig } from './config';
|
|
6
|
+
export type { SetVersionOptions } from './set-version';
|
|
7
|
+
export declare function setVersion(dir: string, version: string, profiles: Profile[], options?: SetVersionOptions): Promise<import('./set-version').Matched[]>;
|
|
8
|
+
export declare function findConfig<TRequired extends boolean>(dir: string, required: TRequired): Promise<TRequired extends true ? SetVersionConfig : SetVersionConfig | undefined>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,KAAK,iBAAiB,EAAmB,MAAM,eAAe,CAAC;AAExE,wBAAsB,UAAU,CAC5B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,GAAE,iBAAsB,8CASlC;AAED,wBAAsB,UAAU,CAAC,SAAS,SAAS,OAAO,EACtD,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,SAAS,GACpB,OAAO,CACN,SAAS,SAAS,IAAI,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,SAAS,CAC3E,CAEA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { default as z } from 'zod';
|
|
2
|
+
declare const ProfileBaseSchema: z.ZodObject<{
|
|
3
|
+
files: z.ZodArray<z.ZodString>;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export type ProfileBase = z.infer<typeof ProfileBaseSchema>;
|
|
6
|
+
export declare const PathProfileSchema: z.ZodObject<{
|
|
7
|
+
files: z.ZodArray<z.ZodString>;
|
|
8
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
9
|
+
format: z.ZodOptional<z.ZodEnum<typeof import('./format').Format>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const TaggedPathProfileSchema: z.ZodObject<{
|
|
12
|
+
files: z.ZodArray<z.ZodString>;
|
|
13
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
14
|
+
format: z.ZodOptional<z.ZodEnum<typeof import('./format').Format>>;
|
|
15
|
+
type: z.ZodLiteral<"path">;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type PathProfile = z.infer<typeof PathProfileSchema>;
|
|
18
|
+
export type TaggedPathProfile = z.infer<typeof TaggedPathProfileSchema>;
|
|
19
|
+
export declare const RegexProfileSchema: z.ZodObject<{
|
|
20
|
+
files: z.ZodArray<z.ZodString>;
|
|
21
|
+
pattern: z.ZodString;
|
|
22
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
23
|
+
capture_group: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const TaggedRegexProfileSchema: z.ZodObject<{
|
|
26
|
+
files: z.ZodArray<z.ZodString>;
|
|
27
|
+
pattern: z.ZodString;
|
|
28
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
29
|
+
capture_group: z.ZodOptional<z.ZodString>;
|
|
30
|
+
type: z.ZodLiteral<"regex">;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type RegexProfile = z.infer<typeof RegexProfileSchema>;
|
|
33
|
+
export type TaggedRegexProfile = z.infer<typeof TaggedRegexProfileSchema>;
|
|
34
|
+
export declare const ProfileSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
35
|
+
files: z.ZodArray<z.ZodString>;
|
|
36
|
+
path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
37
|
+
format: z.ZodOptional<z.ZodEnum<typeof import('./format').Format>>;
|
|
38
|
+
type: z.ZodLiteral<"path">;
|
|
39
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
+
files: z.ZodArray<z.ZodString>;
|
|
41
|
+
pattern: z.ZodString;
|
|
42
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
43
|
+
capture_group: z.ZodOptional<z.ZodString>;
|
|
44
|
+
type: z.ZodLiteral<"regex">;
|
|
45
|
+
}, z.core.$strip>], "type">;
|
|
46
|
+
export type Profile = z.infer<typeof ProfileSchema>;
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../src/lib/profile.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,QAAA,MAAM,iBAAiB;;iBAErB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,iBAAiB;;;;iBAG5B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;iBAElC,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,kBAAkB;;;;;iBAI7B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;iBAEnC,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E,eAAO,MAAM,aAAa;;;;;;;;;;;2BAGxB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IsTuple, Primitive, TupleKeys } from './type-utils';
|
|
2
|
+
type Path<T> = (T extends Primitive ? [] : T extends readonly (infer U)[] ? [TupleKeys<T>, ...Path<U>] : {
|
|
3
|
+
[K in keyof T & (string | number)]: [K] | [K, ...Path<T[K]>];
|
|
4
|
+
}[keyof T & (string | number)]) | [];
|
|
5
|
+
type SetAtPath<T, P extends readonly unknown[], V> = P extends [] ? V : P extends [infer H, ...infer R] ? T extends readonly unknown[] ? IsTuple<T> extends true ? {
|
|
6
|
+
[K in keyof T]: K extends `${H & number}` ? SetAtPath<T[K], R, V> : T[K];
|
|
7
|
+
} : T extends readonly (infer U)[] ? readonly SetAtPath<U, R, V>[] : T : H extends keyof T ? Omit<T, H> & {
|
|
8
|
+
[K in H]: SetAtPath<T[K], R, V>;
|
|
9
|
+
} : T : T;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the value at the given path in the object graph. If the path is empty, the value is returned.
|
|
12
|
+
*
|
|
13
|
+
* @param objectGraph the object graph to set the value.
|
|
14
|
+
* @param path where to set the value.
|
|
15
|
+
* @param value the value to set.
|
|
16
|
+
* @returns Cloned object graph with the value set at the given path.
|
|
17
|
+
*/
|
|
18
|
+
export declare function setValue<const TObject, const P extends Path<TObject>, const TValue>(objectGraph: TObject, path: readonly [...P], value: TValue): SetAtPath<TObject, P, TValue>;
|
|
19
|
+
/**
|
|
20
|
+
* Same with `setValue`, but returns the original object graph. This is useful when you want to directly mutate the object graph.
|
|
21
|
+
*
|
|
22
|
+
* @param objectGraph the object graph to set the value.
|
|
23
|
+
* @param path where to set the value.
|
|
24
|
+
* @param value the value to set.
|
|
25
|
+
* @returns The original object graph with the value set at the given path without clone but strongly typed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function setValueIn<const TObject, const P extends Path<TObject>, const TValue>(objectGraph: TObject, path: readonly [...P], value: TValue): SetAtPath<TObject, P, TValue>;
|
|
28
|
+
export declare class NoValueAtPathError extends Error {
|
|
29
|
+
readonly path: (number | string)[];
|
|
30
|
+
constructor(path: (number | string)[]);
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=set-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-value.d.ts","sourceRoot":"","sources":["../../../src/lib/set-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAElE,KAAK,IAAI,CAAC,CAAC,IACL,CAAC,CAAC,SAAS,SAAS,GACd,EAAE,GACF,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC5B,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,GAC1B;KACK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GACvC,EAAE,CAAC;AAET,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,GAC3D,CAAC,GACD,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,GAC7B,CAAC,SAAS,SAAS,OAAO,EAAE,GACxB,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,GACnB;KACK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,GAAG,MAAM,EAAE,GACnC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACrB,CAAC,CAAC,CAAC,CAAC;CACb,GACD,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAC5B,SAAS,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAC7B,CAAC,GACP,CAAC,SAAS,MAAM,CAAC,GACf,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;CAAE,GAChD,CAAC,GACP,CAAC,CAAC;AAEV;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACpB,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,EAC7B,KAAK,CAAC,MAAM,EAEZ,WAAW,EAAE,OAAO,EACpB,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EACrB,KAAK,EAAE,MAAM,GACd,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,CAE/B;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACtB,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,EAC7B,KAAK,CAAC,MAAM,EAEZ,WAAW,EAAE,OAAO,EACpB,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,EACrB,KAAK,EAAE,MAAM,GACd,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,CAE/B;AA6DD,qBAAa,kBAAmB,SAAQ,KAAK;aACb,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE;gBAAzB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE;CAIxD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { System } from '@omni-oss/system-interface';
|
|
2
|
+
import { Profile } from './profile';
|
|
3
|
+
export type SetVersionOptions = {
|
|
4
|
+
dryRun?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type Matched = {
|
|
7
|
+
path: string;
|
|
8
|
+
changed: boolean;
|
|
9
|
+
notChangedReason?: NotChangedReason | undefined;
|
|
10
|
+
notChangedReasonMessage?: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare enum NotChangedReason {
|
|
13
|
+
NO_VALUE_AT_PATH = "NO_VALUE_AT_PATH",
|
|
14
|
+
REGEX_PATTERN_NOT_MATCHED = "REGEX_PATTERN_NOT_MATCHED",
|
|
15
|
+
ALREADY_UP_TO_DATE = "ALREADY_UP_TO_DATE"
|
|
16
|
+
}
|
|
17
|
+
export declare function setVersionAtDir(dir: string, version: string, profiles: Profile[], system: System, options?: SetVersionOptions): Promise<Matched[]>;
|
|
18
|
+
export declare class NoProfileFoundError extends Error {
|
|
19
|
+
constructor(file: string);
|
|
20
|
+
}
|
|
21
|
+
type File = {
|
|
22
|
+
path: string;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function applyVersion(file: File, version: string, profile: Profile): string;
|
|
26
|
+
export declare class UnsupportedProfileTypeError extends Error {
|
|
27
|
+
constructor(type: string);
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=set-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-version.d.ts","sourceRoot":"","sources":["../../../src/lib/set-version.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAKzD,OAAO,KAAK,EAAe,OAAO,EAAE,MAAM,WAAW,CAAC;AAItD,MAAM,MAAM,iBAAiB,GAAG;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAChD,uBAAuB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChD,CAAC;AAEF,oBAAY,gBAAgB;IACxB,gBAAgB,qBAAqB;IACrC,yBAAyB,8BAA8B;IACvD,kBAAkB,uBAAuB;CAC5C;AAED,wBAAsB,eAAe,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,OAAO,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAChC,OAAO,CAAC,OAAO,EAAE,CAAC,CAiEpB;AAED,qBAAa,mBAAoB,SAAQ,KAAK;gBAC9B,IAAI,EAAE,MAAM;CAI3B;AAED,KAAK,IAAI,GAAG;IACR,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,YAAY,CACxB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,GACjB,MAAM,CAoCR;AAkED,qBAAa,2BAA4B,SAAQ,KAAK;gBACtC,IAAI,EAAE,MAAM;CAI3B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function replaceGroup(str: string, regex: RegExp, groupName: string, newValue: string): string;
|
|
2
|
+
export declare class RegexNotMatchedError extends Error {
|
|
3
|
+
readonly pattern: string;
|
|
4
|
+
constructor(pattern: string);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=string-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/string-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CACxB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,UAgBnB;AAED,qBAAa,oBAAqB,SAAQ,KAAK;aACf,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;CAI9C"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type StringToNumber<S extends string> = S extends `${infer N extends number}` ? N : never;
|
|
2
|
+
export type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
3
|
+
export type IsTuple<T> = T extends readonly [...infer _] ? number extends T["length"] ? false : true : false;
|
|
4
|
+
export type TupleKeys<T extends readonly unknown[]> = {
|
|
5
|
+
[K in keyof T]: K extends string ? StringToNumber<K> : K;
|
|
6
|
+
}[number];
|
|
7
|
+
//# sourceMappingURL=type-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/type-utils.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IACvC,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAEtD,MAAM,MAAM,SAAS,GACf,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,IAAI,GACJ,SAAS,CAAC;AAEhB,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,GAAG,MAAM,CAAC,CAAC,GAClD,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GACtB,KAAK,GACL,IAAI,GACR,KAAK,CAAC;AAEZ,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,IAAI;KACjD,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC;CAC3D,CAAC,MAAM,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@omni-oss/set-version",
|
|
3
|
+
"description": "Sets version of various package manifests",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"bin": "./dist/cli.mjs",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": {
|
|
13
|
+
"development": "./src/index.ts",
|
|
14
|
+
"default": "./dist/set-version.mjs"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"development": "./src/index.ts",
|
|
18
|
+
"default": "./dist/set-version.cjs"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"zod": "^4.3.6",
|
|
24
|
+
"commander": "^14.0.3",
|
|
25
|
+
"@commander-js/extra-typings": "14.0.0",
|
|
26
|
+
"@omni-oss/system-interface": "0.0.0",
|
|
27
|
+
"fast-xml-parser": "^5.3.4",
|
|
28
|
+
"yaml": "^2.8.2",
|
|
29
|
+
"comment-json": "^4.5.1",
|
|
30
|
+
"smol-toml": "^1.6.0",
|
|
31
|
+
"picomatch": "^4.0.3"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@omni-oss/tsconfig": "0.0.0",
|
|
35
|
+
"@omni-oss/vite-config": "0.0.0",
|
|
36
|
+
"@omni-oss/vitest-config": "0.0.0",
|
|
37
|
+
"vite": "^7.3.1",
|
|
38
|
+
"vitest": "^4.0.18",
|
|
39
|
+
"@types/node": "25.2.0",
|
|
40
|
+
"@types/bun": "^1.3.8",
|
|
41
|
+
"@types/picomatch": "^4.0.2",
|
|
42
|
+
"typescript": "^5.9.3"
|
|
43
|
+
}
|
|
44
|
+
}
|