@peiyanlu/release 0.0.1
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 +111 -0
- package/dist/cli.mjs +1354 -0
- package/dist/index.cjs +27 -0
- package/dist/index.d.cts +51 -0
- package/dist/index.d.mts +51 -0
- package/dist/index.mjs +25 -0
- package/index.js +3 -0
- package/package.json +79 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/config.ts
|
|
3
|
+
function defineConfig(config) {
|
|
4
|
+
return config;
|
|
5
|
+
}
|
|
6
|
+
const toString = (self) => Object.prototype.toString.call(self);
|
|
7
|
+
const isPlainObject = (v) => toString(v) === "[object Object]";
|
|
8
|
+
const isFunction = (v) => toString(v) === "[object Function]";
|
|
9
|
+
const mergeConfig = (defaults, overrides) => {
|
|
10
|
+
if (!overrides) return structuredClone(defaults);
|
|
11
|
+
if (Object.keys(defaults).length === 0) return structuredClone(overrides);
|
|
12
|
+
const result = {};
|
|
13
|
+
for (const key in defaults) {
|
|
14
|
+
const defaultValue = defaults[key];
|
|
15
|
+
const overrideValue = overrides[key];
|
|
16
|
+
if (overrideValue === void 0) if (isFunction(defaultValue)) result[key] = defaultValue;
|
|
17
|
+
else result[key] = structuredClone(defaultValue);
|
|
18
|
+
else if (isPlainObject(defaultValue) && isPlainObject(overrideValue)) result[key] = mergeConfig(defaultValue, overrideValue);
|
|
19
|
+
else if (isFunction(overrideValue)) result[key] = overrideValue;
|
|
20
|
+
else result[key] = structuredClone(overrideValue);
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.defineConfig = defineConfig;
|
|
27
|
+
exports.mergeConfig = mergeConfig;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
|
|
3
|
+
type HookTiming = 'before' | 'after';
|
|
4
|
+
type HookAction = 'bump' | 'publish' | 'push' | 'release';
|
|
5
|
+
type ReleaseHookKey = `${HookTiming}:${HookAction}`;
|
|
6
|
+
type ReleaseHookValue = string | string[] | (() => Promise<void> | void);
|
|
7
|
+
type HookConfig = { [key in ReleaseHookKey]: ReleaseHookValue };
|
|
8
|
+
interface ReleaseConfig {
|
|
9
|
+
hooks: HookConfig;
|
|
10
|
+
git: {
|
|
11
|
+
commit: boolean | undefined;
|
|
12
|
+
tag: boolean | undefined;
|
|
13
|
+
push: boolean | undefined;
|
|
14
|
+
commitMessage: string;
|
|
15
|
+
tagMessage: string;
|
|
16
|
+
tagName: string;
|
|
17
|
+
};
|
|
18
|
+
npm: {
|
|
19
|
+
publish: boolean | undefined;
|
|
20
|
+
tag: string;
|
|
21
|
+
allowSameVersion: boolean;
|
|
22
|
+
};
|
|
23
|
+
github: {
|
|
24
|
+
release: boolean | undefined;
|
|
25
|
+
prerelease: boolean;
|
|
26
|
+
draft: boolean;
|
|
27
|
+
releaseName: string;
|
|
28
|
+
tokenRef: string;
|
|
29
|
+
assets: string[];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
33
|
+
type Builtin = Primitive | Date | RegExp | Error | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any>;
|
|
34
|
+
type DeepRequired<T> = T extends Builtin ? T : T extends ((...args: any[]) => any) ? T : T extends readonly (infer U)[] ? DeepRequired<U>[] : T extends Array<infer U> ? Array<DeepRequired<U>> : { [K in keyof T]-?: DeepRequired<T[K]> };
|
|
35
|
+
type DeepPartial<T> = T extends Builtin ? T : T extends ((...args: any[]) => any) ? T : T extends readonly (infer U)[] ? DeepPartial<U>[] : T extends Array<infer U> ? Array<DeepPartial<U>> : { [K in keyof T]?: DeepPartial<T[K]> };
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/config.d.ts
|
|
38
|
+
type UserConfig = DeepPartial<ReleaseConfig>;
|
|
39
|
+
type UserConfigFnObject = () => UserConfig;
|
|
40
|
+
type UserConfigFnPromise = () => Promise<UserConfig>;
|
|
41
|
+
type UserConfigFn = () => UserConfig | Promise<UserConfig>;
|
|
42
|
+
type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
|
|
43
|
+
declare function defineConfig(config: UserConfig): UserConfig;
|
|
44
|
+
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
|
45
|
+
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
46
|
+
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
|
47
|
+
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
|
48
|
+
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
49
|
+
declare const mergeConfig: <T extends object>(defaults: DeepRequired<T>, overrides?: DeepPartial<T>) => DeepRequired<T>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { type UserConfig, defineConfig, mergeConfig };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
|
|
3
|
+
type HookTiming = 'before' | 'after';
|
|
4
|
+
type HookAction = 'bump' | 'publish' | 'push' | 'release';
|
|
5
|
+
type ReleaseHookKey = `${HookTiming}:${HookAction}`;
|
|
6
|
+
type ReleaseHookValue = string | string[] | (() => Promise<void> | void);
|
|
7
|
+
type HookConfig = { [key in ReleaseHookKey]: ReleaseHookValue };
|
|
8
|
+
interface ReleaseConfig {
|
|
9
|
+
hooks: HookConfig;
|
|
10
|
+
git: {
|
|
11
|
+
commit: boolean | undefined;
|
|
12
|
+
tag: boolean | undefined;
|
|
13
|
+
push: boolean | undefined;
|
|
14
|
+
commitMessage: string;
|
|
15
|
+
tagMessage: string;
|
|
16
|
+
tagName: string;
|
|
17
|
+
};
|
|
18
|
+
npm: {
|
|
19
|
+
publish: boolean | undefined;
|
|
20
|
+
tag: string;
|
|
21
|
+
allowSameVersion: boolean;
|
|
22
|
+
};
|
|
23
|
+
github: {
|
|
24
|
+
release: boolean | undefined;
|
|
25
|
+
prerelease: boolean;
|
|
26
|
+
draft: boolean;
|
|
27
|
+
releaseName: string;
|
|
28
|
+
tokenRef: string;
|
|
29
|
+
assets: string[];
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
type Primitive = string | number | boolean | bigint | symbol | null | undefined;
|
|
33
|
+
type Builtin = Primitive | Date | RegExp | Error | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any>;
|
|
34
|
+
type DeepRequired<T> = T extends Builtin ? T : T extends ((...args: any[]) => any) ? T : T extends readonly (infer U)[] ? DeepRequired<U>[] : T extends Array<infer U> ? Array<DeepRequired<U>> : { [K in keyof T]-?: DeepRequired<T[K]> };
|
|
35
|
+
type DeepPartial<T> = T extends Builtin ? T : T extends ((...args: any[]) => any) ? T : T extends readonly (infer U)[] ? DeepPartial<U>[] : T extends Array<infer U> ? Array<DeepPartial<U>> : { [K in keyof T]?: DeepPartial<T[K]> };
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/config.d.ts
|
|
38
|
+
type UserConfig = DeepPartial<ReleaseConfig>;
|
|
39
|
+
type UserConfigFnObject = () => UserConfig;
|
|
40
|
+
type UserConfigFnPromise = () => Promise<UserConfig>;
|
|
41
|
+
type UserConfigFn = () => UserConfig | Promise<UserConfig>;
|
|
42
|
+
type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
|
|
43
|
+
declare function defineConfig(config: UserConfig): UserConfig;
|
|
44
|
+
declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
|
|
45
|
+
declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
|
|
46
|
+
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
|
47
|
+
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
|
48
|
+
declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
|
49
|
+
declare const mergeConfig: <T extends object>(defaults: DeepRequired<T>, overrides?: DeepPartial<T>) => DeepRequired<T>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { type UserConfig, defineConfig, mergeConfig };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/config.ts
|
|
2
|
+
function defineConfig(config) {
|
|
3
|
+
return config;
|
|
4
|
+
}
|
|
5
|
+
const toString = (self) => Object.prototype.toString.call(self);
|
|
6
|
+
const isPlainObject = (v) => toString(v) === "[object Object]";
|
|
7
|
+
const isFunction = (v) => toString(v) === "[object Function]";
|
|
8
|
+
const mergeConfig = (defaults, overrides) => {
|
|
9
|
+
if (!overrides) return structuredClone(defaults);
|
|
10
|
+
if (Object.keys(defaults).length === 0) return structuredClone(overrides);
|
|
11
|
+
const result = {};
|
|
12
|
+
for (const key in defaults) {
|
|
13
|
+
const defaultValue = defaults[key];
|
|
14
|
+
const overrideValue = overrides[key];
|
|
15
|
+
if (overrideValue === void 0) if (isFunction(defaultValue)) result[key] = defaultValue;
|
|
16
|
+
else result[key] = structuredClone(defaultValue);
|
|
17
|
+
else if (isPlainObject(defaultValue) && isPlainObject(overrideValue)) result[key] = mergeConfig(defaultValue, overrideValue);
|
|
18
|
+
else if (isFunction(overrideValue)) result[key] = overrideValue;
|
|
19
|
+
else result[key] = structuredClone(overrideValue);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { defineConfig, mergeConfig };
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@peiyanlu/release",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Release project tool.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"private": false,
|
|
8
|
+
"bin": {
|
|
9
|
+
"release": "index.js"
|
|
10
|
+
},
|
|
11
|
+
"main": "dist/index.cjs",
|
|
12
|
+
"types": "dist/index.d.cts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.mts",
|
|
17
|
+
"default": "./dist/index.mjs"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/index.d.cts",
|
|
21
|
+
"default": "./dist/index.cjs"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"dev": "tsdown -w",
|
|
27
|
+
"build": "tsdown",
|
|
28
|
+
"prepublish": "tsdown",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:cov": "vitest run --coverage"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@clack/prompts": "^0.11.0",
|
|
34
|
+
"@octokit/rest": "^22.0.1",
|
|
35
|
+
"@peiyanlu/cli-utils": "^0.0.1",
|
|
36
|
+
"@peiyanlu/ts-utils": "^0.0.1",
|
|
37
|
+
"ansis": "^4.2.0",
|
|
38
|
+
"commander": "^14.0.2",
|
|
39
|
+
"mime-types": "^3.0.2",
|
|
40
|
+
"open": "^11.0.0",
|
|
41
|
+
"semver": "^7.7.3",
|
|
42
|
+
"tinyglobby": "^0.2.15"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/semver": "^7.7.1",
|
|
46
|
+
"@types/mime-types": "^3.0.1",
|
|
47
|
+
"@types/node": "^24.10.3",
|
|
48
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
49
|
+
"tsdown": "^0.18.1",
|
|
50
|
+
"typescript": "^5.9.3",
|
|
51
|
+
"vitest": "^4.0.15"
|
|
52
|
+
},
|
|
53
|
+
"author": {
|
|
54
|
+
"name": "YanluPei",
|
|
55
|
+
"email": "peiyanlu@vip.qq.com"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=20"
|
|
59
|
+
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"typescript",
|
|
62
|
+
"cli"
|
|
63
|
+
],
|
|
64
|
+
"files": [
|
|
65
|
+
"dist"
|
|
66
|
+
],
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"access": "public",
|
|
69
|
+
"registry": "https://registry.npmjs.org"
|
|
70
|
+
},
|
|
71
|
+
"repository": {
|
|
72
|
+
"type": "git",
|
|
73
|
+
"url": "https://github.com/peiyanlu/release.git"
|
|
74
|
+
},
|
|
75
|
+
"bugs": {
|
|
76
|
+
"url": "https://github.com/peiyanlu/release/issues"
|
|
77
|
+
},
|
|
78
|
+
"homepage": "https://github.com/peiyanlu/release#readme"
|
|
79
|
+
}
|