@ci-kit/release 0.0.0-stage → 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/dist/index.d.mts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.mjs +61 -0
- package/package.json +33 -3
- package/README.md +0 -3
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type ReleaseChannel = 'beta' | 'production';
|
|
2
|
+
interface ParsedTag {
|
|
3
|
+
raw: string;
|
|
4
|
+
channel: ReleaseChannel;
|
|
5
|
+
version: string;
|
|
6
|
+
beta?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function parseTag(tag: string): ParsedTag | null;
|
|
9
|
+
declare function formatBetaTag(version: string, beta: number): string;
|
|
10
|
+
declare function formatProductionTag(version: string): string;
|
|
11
|
+
declare function nextBetaTag(existingTags: string[], version: string): string;
|
|
12
|
+
type BumpKind = 'patch' | 'minor' | 'major';
|
|
13
|
+
declare function bumpVersion(version: string, kind: BumpKind): string;
|
|
14
|
+
/**
|
|
15
|
+
* Build numbers follow `yyyymmddNN`, matching the existing app convention.
|
|
16
|
+
*/
|
|
17
|
+
declare function buildNumber(date?: Date, sequence?: number): string;
|
|
18
|
+
declare function nextBuildNumber(current: string, date?: Date): string;
|
|
19
|
+
declare function parsePubspecVersion(versionLine: string): {
|
|
20
|
+
version: string;
|
|
21
|
+
build: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { buildNumber, bumpVersion, formatBetaTag, formatProductionTag, nextBetaTag, nextBuildNumber, parsePubspecVersion, parseTag };
|
|
25
|
+
export type { BumpKind, ParsedTag, ReleaseChannel };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type ReleaseChannel = 'beta' | 'production';
|
|
2
|
+
interface ParsedTag {
|
|
3
|
+
raw: string;
|
|
4
|
+
channel: ReleaseChannel;
|
|
5
|
+
version: string;
|
|
6
|
+
beta?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function parseTag(tag: string): ParsedTag | null;
|
|
9
|
+
declare function formatBetaTag(version: string, beta: number): string;
|
|
10
|
+
declare function formatProductionTag(version: string): string;
|
|
11
|
+
declare function nextBetaTag(existingTags: string[], version: string): string;
|
|
12
|
+
type BumpKind = 'patch' | 'minor' | 'major';
|
|
13
|
+
declare function bumpVersion(version: string, kind: BumpKind): string;
|
|
14
|
+
/**
|
|
15
|
+
* Build numbers follow `yyyymmddNN`, matching the existing app convention.
|
|
16
|
+
*/
|
|
17
|
+
declare function buildNumber(date?: Date, sequence?: number): string;
|
|
18
|
+
declare function nextBuildNumber(current: string, date?: Date): string;
|
|
19
|
+
declare function parsePubspecVersion(versionLine: string): {
|
|
20
|
+
version: string;
|
|
21
|
+
build: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { buildNumber, bumpVersion, formatBetaTag, formatProductionTag, nextBetaTag, nextBuildNumber, parsePubspecVersion, parseTag };
|
|
25
|
+
export type { BumpKind, ParsedTag, ReleaseChannel };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const TAG_RE = /^v(\d+\.\d+\.\d+)(?:-beta\.(\d+))?$/;
|
|
2
|
+
function parseTag(tag) {
|
|
3
|
+
const match = tag.match(TAG_RE);
|
|
4
|
+
if (!match) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const [, version, beta] = match;
|
|
8
|
+
return beta ? {
|
|
9
|
+
raw: tag,
|
|
10
|
+
channel: "beta",
|
|
11
|
+
version,
|
|
12
|
+
beta: Number(beta)
|
|
13
|
+
} : { raw: tag, channel: "production", version };
|
|
14
|
+
}
|
|
15
|
+
function formatBetaTag(version, beta) {
|
|
16
|
+
return `v${version}-beta.${beta}`;
|
|
17
|
+
}
|
|
18
|
+
function formatProductionTag(version) {
|
|
19
|
+
return `v${version}`;
|
|
20
|
+
}
|
|
21
|
+
function nextBetaTag(existingTags, version) {
|
|
22
|
+
const used = existingTags.map(parseTag).filter((tag) => tag !== null && tag.channel === "beta" && tag.version === version).map((tag) => tag.beta ?? 0);
|
|
23
|
+
const next = used.length === 0 ? 1 : Math.max(...used) + 1;
|
|
24
|
+
return formatBetaTag(version, next);
|
|
25
|
+
}
|
|
26
|
+
function bumpVersion(version, kind) {
|
|
27
|
+
const parts = version.split(".").map(Number);
|
|
28
|
+
if (parts.length !== 3 || parts.some(Number.isNaN)) {
|
|
29
|
+
throw new Error(`Invalid version: ${version}`);
|
|
30
|
+
}
|
|
31
|
+
const [major = 0, minor = 0, patch = 0] = parts;
|
|
32
|
+
switch (kind) {
|
|
33
|
+
case "major":
|
|
34
|
+
return `${major + 1}.0.0`;
|
|
35
|
+
case "minor":
|
|
36
|
+
return `${major}.${minor + 1}.0`;
|
|
37
|
+
default:
|
|
38
|
+
return `${major}.${minor}.${patch + 1}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function buildNumber(date = /* @__PURE__ */ new Date(), sequence = 1) {
|
|
42
|
+
const year = date.getFullYear();
|
|
43
|
+
const month = `${date.getMonth() + 1}`.padStart(2, "0");
|
|
44
|
+
const day = `${date.getDate()}`.padStart(2, "0");
|
|
45
|
+
return `${year}${month}${day}${`${sequence}`.padStart(2, "0")}`;
|
|
46
|
+
}
|
|
47
|
+
function nextBuildNumber(current, date = /* @__PURE__ */ new Date()) {
|
|
48
|
+
const today = buildNumber(date, 1).slice(0, 8);
|
|
49
|
+
if (current.startsWith(today)) {
|
|
50
|
+
const sequence = Number(current.slice(8)) + 1;
|
|
51
|
+
return `${today}${`${sequence}`.padStart(2, "0")}`;
|
|
52
|
+
}
|
|
53
|
+
return `${today}01`;
|
|
54
|
+
}
|
|
55
|
+
function parsePubspecVersion(versionLine) {
|
|
56
|
+
const raw = versionLine.replace(/^version:\s*/, "").trim();
|
|
57
|
+
const [version, build = ""] = raw.split("+");
|
|
58
|
+
return { version, build };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { buildNumber, bumpVersion, formatBetaTag, formatProductionTag, nextBetaTag, nextBuildNumber, parsePubspecVersion, parseTag };
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ci-kit/release",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"description": "Semver and release tag helpers",
|
|
6
|
+
"author": "imba97",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/cikit-js/ci-kit#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/cikit-js/ci-kit.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/cikit-js/ci-kit/issues"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.mts",
|
|
19
|
+
"import": "./dist/index.mjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.mjs",
|
|
23
|
+
"module": "./dist/index.mjs",
|
|
24
|
+
"types": "./dist/index.d.mts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "unbuild",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"stub": "unbuild --stub"
|
|
35
|
+
}
|
|
6
36
|
}
|
package/README.md
DELETED