@reelout/cli 0.1.1 → 0.4.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/dist/index.js +66 -1
- package/dist/index.js.map +1 -0
- package/package.json +17 -5
- package/src/createProcessAbortSignal.ts +40 -0
- package/src/createProgram.ts +105 -0
- package/src/index.ts +4 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fai
|
|
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/dist/index.js
CHANGED
|
@@ -1 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
import { resolveConfig } from "@reelout/config";
|
|
2
|
+
import { createContext } from "@reelout/context";
|
|
3
|
+
import { compact, createPlugin, executeReleaseWorkflow, isTruthyString } from "@reelout/core";
|
|
4
|
+
import { Command, Option } from "commander";
|
|
5
|
+
//#region src/createProcessAbortSignal.ts
|
|
6
|
+
/**
|
|
7
|
+
* Create a process abort signal tied to termination events.
|
|
8
|
+
*
|
|
9
|
+
* Registers event listeners for `SIGINT` and `SIGTERM` on the active process
|
|
10
|
+
* to automatically trigger an abort action upon receipt. Attaches a custom
|
|
11
|
+
* disposal method to clean up listeners and enforce abort state on cleanup.
|
|
12
|
+
*
|
|
13
|
+
* @returns A newly configured process abort signal ready for use
|
|
14
|
+
*/
|
|
15
|
+
function createProcessAbortSignal() {
|
|
16
|
+
const controller = new AbortController();
|
|
17
|
+
const handler = () => controller.abort();
|
|
18
|
+
process.on("SIGINT", handler);
|
|
19
|
+
process.on("SIGTERM", handler);
|
|
20
|
+
const dispose = () => {
|
|
21
|
+
process.off("SIGINT", handler);
|
|
22
|
+
process.off("SIGTERM", handler);
|
|
23
|
+
if (!controller.signal.aborted) controller.abort();
|
|
24
|
+
};
|
|
25
|
+
const signal = controller.signal;
|
|
26
|
+
Object.defineProperty(signal, "controller", { value: controller });
|
|
27
|
+
Object.defineProperty(signal, Symbol.dispose, { value: dispose });
|
|
28
|
+
return signal;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/createProgram.ts
|
|
32
|
+
/**
|
|
33
|
+
* Create and configure a command-line program instance.
|
|
34
|
+
*
|
|
35
|
+
* Resolves project configuration settings, registers command-line options,
|
|
36
|
+
* and sets up execution handlers alongside version and help flags.
|
|
37
|
+
*
|
|
38
|
+
* @param options Options for configuring the command-line execution context
|
|
39
|
+
* @returns A promise that resolves to the configured `Command` instance
|
|
40
|
+
*/
|
|
41
|
+
async function createProgram(options) {
|
|
42
|
+
const { name, version, description } = options;
|
|
43
|
+
const { cwd, env } = options;
|
|
44
|
+
const { plugins, ...config } = await resolveConfig(cwd, name);
|
|
45
|
+
const program = new Command(name);
|
|
46
|
+
if (description) program.description(description);
|
|
47
|
+
program.addOption(new Option("--type <string>", "Specify the release type, bypassing automatic commit analysis.").choices([
|
|
48
|
+
"auto",
|
|
49
|
+
"major",
|
|
50
|
+
"minor",
|
|
51
|
+
"patch"
|
|
52
|
+
])).option("--qualifier <boolean or string>", "Set or override the version qualifier (e.g., `alpha`, `beta`); pass `false` to disable.", (value) => value === "true" ? true : value === "false" ? false : value).option("--channel <boolean or string>", "Set or override the release channel (e.g., `stable`, `canary`); pass `false` to disable.", (value) => value === "true" ? true : value === "false" ? false : value).option("--allow-empty", "Proceed with the release workflow even if no qualifying changes are detected.").option("--dry-run", "Simulate the release workflow without modifying files or publishing artifacts.").option("--debug", "Enable verbose logging for detailed troubleshooting.", isTruthyString(env.RUNNER_DEBUG) || isTruthyString(env.ACTIONS_STEP_DEBUG)).action(async (flags) => {
|
|
53
|
+
await executeReleaseWorkflow(await createContext({
|
|
54
|
+
...options,
|
|
55
|
+
...config,
|
|
56
|
+
...flags
|
|
57
|
+
}), compact(await Promise.all(plugins.map(createPlugin))));
|
|
58
|
+
});
|
|
59
|
+
if (version) program.version(version, "-v, --version", "Display the version number.");
|
|
60
|
+
program.helpOption("-h, --help", "Display command usage and options.");
|
|
61
|
+
return program;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { createProcessAbortSignal, createProgram };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/createProcessAbortSignal.ts","../src/createProgram.ts"],"sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nexport interface ProcessAbortSignal extends AbortSignal, Disposable {\n readonly controller: AbortController\n}\n\n/**\n * Create a process abort signal tied to termination events.\n *\n * Registers event listeners for `SIGINT` and `SIGTERM` on the active process\n * to automatically trigger an abort action upon receipt. Attaches a custom\n * disposal method to clean up listeners and enforce abort state on cleanup.\n *\n * @returns A newly configured process abort signal ready for use\n */\nexport function createProcessAbortSignal(): ProcessAbortSignal {\n const controller = new AbortController()\n const handler = () => controller.abort()\n\n process.on('SIGINT', handler)\n process.on('SIGTERM', handler)\n\n const dispose = () => {\n process.off('SIGINT', handler)\n process.off('SIGTERM', handler)\n\n if (!controller.signal.aborted) {\n controller.abort()\n }\n }\n\n const signal = controller.signal as ProcessAbortSignal\n\n Object.defineProperty(signal, 'controller', { value: controller })\n\n Object.defineProperty(signal, Symbol.dispose, { value: dispose })\n\n return signal\n}\n","// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Fai\n\nimport { resolveConfig } from '@reelout/config'\nimport { createContext } from '@reelout/context'\nimport {\n compact,\n createPlugin,\n executeReleaseWorkflow,\n isTruthyString,\n type ReleaseTypeHint,\n} from '@reelout/core'\nimport { Command, Option } from 'commander'\nimport type { ConsolaInstance } from 'consola/core'\n\nexport interface CreateProgramOptions {\n name: string\n version?: string | undefined\n description?: string | undefined\n cwd: string\n env: Readonly<NodeJS.ProcessEnv>\n signal?: AbortSignal | undefined\n stdout: NodeJS.WritableStream\n stderr: NodeJS.WritableStream\n logger?: ConsolaInstance | undefined\n}\n\ninterface Flags {\n type?: ReleaseTypeHint | undefined\n qualifier?: boolean | string | undefined\n channel?: boolean | string | undefined\n allowEmpty?: boolean | undefined\n dryRun?: boolean | undefined\n debug?: boolean | undefined\n}\n\n/**\n * Create and configure a command-line program instance.\n *\n * Resolves project configuration settings, registers command-line options,\n * and sets up execution handlers alongside version and help flags.\n *\n * @param options Options for configuring the command-line execution context\n * @returns A promise that resolves to the configured `Command` instance\n */\nexport async function createProgram(\n options: CreateProgramOptions\n): Promise<Command> {\n const { name, version, description } = options\n\n const { cwd, env } = options\n\n const { plugins, ...config } = await resolveConfig(cwd, name)\n\n const program = new Command(name)\n\n if (description) {\n program.description(description)\n }\n\n program\n .addOption(\n new Option(\n '--type <string>',\n 'Specify the release type, bypassing automatic commit analysis.'\n ).choices(['auto', 'major', 'minor', 'patch'] satisfies ReleaseTypeHint[])\n )\n .option(\n '--qualifier <boolean or string>',\n 'Set or override the version qualifier (e.g., `alpha`, `beta`); pass `false` to disable.',\n (value) => (value === 'true' ? true : value === 'false' ? false : value)\n )\n .option(\n '--channel <boolean or string>',\n 'Set or override the release channel (e.g., `stable`, `canary`); pass `false` to disable.',\n (value) => (value === 'true' ? true : value === 'false' ? false : value)\n )\n .option(\n '--allow-empty',\n 'Proceed with the release workflow even if no qualifying changes are detected.'\n )\n .option(\n '--dry-run',\n 'Simulate the release workflow without modifying files or publishing artifacts.'\n )\n .option(\n '--debug',\n 'Enable verbose logging for detailed troubleshooting.',\n isTruthyString(env.RUNNER_DEBUG) || isTruthyString(env.ACTIONS_STEP_DEBUG)\n )\n .action(async (flags: Flags) => {\n await executeReleaseWorkflow(\n await createContext({ ...options, ...config, ...flags }),\n compact(await Promise.all(plugins.map(createPlugin)))\n )\n })\n\n if (version) {\n program.version(version, '-v, --version', 'Display the version number.')\n }\n\n program.helpOption('-h, --help', 'Display command usage and options.')\n\n return program\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,SAAgB,2BAA+C;CAC7D,MAAM,aAAa,IAAI,gBAAgB;CACvC,MAAM,gBAAgB,WAAW,MAAM;CAEvC,QAAQ,GAAG,UAAU,OAAO;CAC5B,QAAQ,GAAG,WAAW,OAAO;CAE7B,MAAM,gBAAgB;EACpB,QAAQ,IAAI,UAAU,OAAO;EAC7B,QAAQ,IAAI,WAAW,OAAO;EAE9B,IAAI,CAAC,WAAW,OAAO,SACrB,WAAW,MAAM;CAErB;CAEA,MAAM,SAAS,WAAW;CAE1B,OAAO,eAAe,QAAQ,cAAc,EAAE,OAAO,WAAW,CAAC;CAEjE,OAAO,eAAe,QAAQ,OAAO,SAAS,EAAE,OAAO,QAAQ,CAAC;CAEhE,OAAO;AACT;;;;;;;;;;;;ACMA,eAAsB,cACpB,SACkB;CAClB,MAAM,EAAE,MAAM,SAAS,gBAAgB;CAEvC,MAAM,EAAE,KAAK,QAAQ;CAErB,MAAM,EAAE,SAAS,GAAG,WAAW,MAAM,cAAc,KAAK,IAAI;CAE5D,MAAM,UAAU,IAAI,QAAQ,IAAI;CAEhC,IAAI,aACF,QAAQ,YAAY,WAAW;CAGjC,QACG,UACC,IAAI,OACF,mBACA,gEACF,CAAC,CAAC,QAAQ;EAAC;EAAQ;EAAS;EAAS;CAAO,CAA6B,CAC3E,CAAC,CACA,OACC,mCACA,4FACC,UAAW,UAAU,SAAS,OAAO,UAAU,UAAU,QAAQ,KACpE,CAAC,CACA,OACC,iCACA,6FACC,UAAW,UAAU,SAAS,OAAO,UAAU,UAAU,QAAQ,KACpE,CAAC,CACA,OACC,iBACA,+EACF,CAAC,CACA,OACC,aACA,gFACF,CAAC,CACA,OACC,WACA,wDACA,eAAe,IAAI,YAAY,KAAK,eAAe,IAAI,kBAAkB,CAC3E,CAAC,CACA,OAAO,OAAO,UAAiB;EAC9B,MAAM,uBACJ,MAAM,cAAc;GAAE,GAAG;GAAS,GAAG;GAAQ,GAAG;EAAM,CAAC,GACvD,QAAQ,MAAM,QAAQ,IAAI,QAAQ,IAAI,YAAY,CAAC,CAAC,CACtD;CACF,CAAC;CAEH,IAAI,SACF,QAAQ,QAAQ,SAAS,iBAAiB,6BAA6B;CAGzE,QAAQ,WAAW,cAAc,oCAAoC;CAErE,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reelout/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "CLI for running release workflows.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/aicest/reelout.git",
|
|
8
|
+
"directory": "packages/cli"
|
|
9
|
+
},
|
|
4
10
|
"license": "MIT",
|
|
5
11
|
"type": "module",
|
|
6
12
|
"imports": {},
|
|
@@ -25,11 +31,17 @@
|
|
|
25
31
|
"./dist",
|
|
26
32
|
"./src"
|
|
27
33
|
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@reelout/context": "^0.4.0",
|
|
36
|
+
"@reelout/core": "^0.4.0",
|
|
37
|
+
"commander": "^15.0.0",
|
|
38
|
+
"consola": "^3.4.2"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=24.15"
|
|
42
|
+
},
|
|
28
43
|
"scripts": {
|
|
29
44
|
"build": "vite build --ssr --sourcemap",
|
|
30
45
|
"dev": "vite build --ssr --watch"
|
|
31
|
-
},
|
|
32
|
-
"engines": {
|
|
33
|
-
"node": ">=24.11"
|
|
34
46
|
}
|
|
35
|
-
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2026 Fai
|
|
3
|
+
|
|
4
|
+
export interface ProcessAbortSignal extends AbortSignal, Disposable {
|
|
5
|
+
readonly controller: AbortController
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create a process abort signal tied to termination events.
|
|
10
|
+
*
|
|
11
|
+
* Registers event listeners for `SIGINT` and `SIGTERM` on the active process
|
|
12
|
+
* to automatically trigger an abort action upon receipt. Attaches a custom
|
|
13
|
+
* disposal method to clean up listeners and enforce abort state on cleanup.
|
|
14
|
+
*
|
|
15
|
+
* @returns A newly configured process abort signal ready for use
|
|
16
|
+
*/
|
|
17
|
+
export function createProcessAbortSignal(): ProcessAbortSignal {
|
|
18
|
+
const controller = new AbortController()
|
|
19
|
+
const handler = () => controller.abort()
|
|
20
|
+
|
|
21
|
+
process.on('SIGINT', handler)
|
|
22
|
+
process.on('SIGTERM', handler)
|
|
23
|
+
|
|
24
|
+
const dispose = () => {
|
|
25
|
+
process.off('SIGINT', handler)
|
|
26
|
+
process.off('SIGTERM', handler)
|
|
27
|
+
|
|
28
|
+
if (!controller.signal.aborted) {
|
|
29
|
+
controller.abort()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const signal = controller.signal as ProcessAbortSignal
|
|
34
|
+
|
|
35
|
+
Object.defineProperty(signal, 'controller', { value: controller })
|
|
36
|
+
|
|
37
|
+
Object.defineProperty(signal, Symbol.dispose, { value: dispose })
|
|
38
|
+
|
|
39
|
+
return signal
|
|
40
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Copyright (c) 2026 Fai
|
|
3
|
+
|
|
4
|
+
import { resolveConfig } from '@reelout/config'
|
|
5
|
+
import { createContext } from '@reelout/context'
|
|
6
|
+
import {
|
|
7
|
+
compact,
|
|
8
|
+
createPlugin,
|
|
9
|
+
executeReleaseWorkflow,
|
|
10
|
+
isTruthyString,
|
|
11
|
+
type ReleaseTypeHint,
|
|
12
|
+
} from '@reelout/core'
|
|
13
|
+
import { Command, Option } from 'commander'
|
|
14
|
+
import type { ConsolaInstance } from 'consola/core'
|
|
15
|
+
|
|
16
|
+
export interface CreateProgramOptions {
|
|
17
|
+
name: string
|
|
18
|
+
version?: string | undefined
|
|
19
|
+
description?: string | undefined
|
|
20
|
+
cwd: string
|
|
21
|
+
env: Readonly<NodeJS.ProcessEnv>
|
|
22
|
+
signal?: AbortSignal | undefined
|
|
23
|
+
stdout: NodeJS.WritableStream
|
|
24
|
+
stderr: NodeJS.WritableStream
|
|
25
|
+
logger?: ConsolaInstance | undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface Flags {
|
|
29
|
+
type?: ReleaseTypeHint | undefined
|
|
30
|
+
qualifier?: boolean | string | undefined
|
|
31
|
+
channel?: boolean | string | undefined
|
|
32
|
+
allowEmpty?: boolean | undefined
|
|
33
|
+
dryRun?: boolean | undefined
|
|
34
|
+
debug?: boolean | undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create and configure a command-line program instance.
|
|
39
|
+
*
|
|
40
|
+
* Resolves project configuration settings, registers command-line options,
|
|
41
|
+
* and sets up execution handlers alongside version and help flags.
|
|
42
|
+
*
|
|
43
|
+
* @param options Options for configuring the command-line execution context
|
|
44
|
+
* @returns A promise that resolves to the configured `Command` instance
|
|
45
|
+
*/
|
|
46
|
+
export async function createProgram(
|
|
47
|
+
options: CreateProgramOptions
|
|
48
|
+
): Promise<Command> {
|
|
49
|
+
const { name, version, description } = options
|
|
50
|
+
|
|
51
|
+
const { cwd, env } = options
|
|
52
|
+
|
|
53
|
+
const { plugins, ...config } = await resolveConfig(cwd, name)
|
|
54
|
+
|
|
55
|
+
const program = new Command(name)
|
|
56
|
+
|
|
57
|
+
if (description) {
|
|
58
|
+
program.description(description)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
program
|
|
62
|
+
.addOption(
|
|
63
|
+
new Option(
|
|
64
|
+
'--type <string>',
|
|
65
|
+
'Specify the release type, bypassing automatic commit analysis.'
|
|
66
|
+
).choices(['auto', 'major', 'minor', 'patch'] satisfies ReleaseTypeHint[])
|
|
67
|
+
)
|
|
68
|
+
.option(
|
|
69
|
+
'--qualifier <boolean or string>',
|
|
70
|
+
'Set or override the version qualifier (e.g., `alpha`, `beta`); pass `false` to disable.',
|
|
71
|
+
(value) => (value === 'true' ? true : value === 'false' ? false : value)
|
|
72
|
+
)
|
|
73
|
+
.option(
|
|
74
|
+
'--channel <boolean or string>',
|
|
75
|
+
'Set or override the release channel (e.g., `stable`, `canary`); pass `false` to disable.',
|
|
76
|
+
(value) => (value === 'true' ? true : value === 'false' ? false : value)
|
|
77
|
+
)
|
|
78
|
+
.option(
|
|
79
|
+
'--allow-empty',
|
|
80
|
+
'Proceed with the release workflow even if no qualifying changes are detected.'
|
|
81
|
+
)
|
|
82
|
+
.option(
|
|
83
|
+
'--dry-run',
|
|
84
|
+
'Simulate the release workflow without modifying files or publishing artifacts.'
|
|
85
|
+
)
|
|
86
|
+
.option(
|
|
87
|
+
'--debug',
|
|
88
|
+
'Enable verbose logging for detailed troubleshooting.',
|
|
89
|
+
isTruthyString(env.RUNNER_DEBUG) || isTruthyString(env.ACTIONS_STEP_DEBUG)
|
|
90
|
+
)
|
|
91
|
+
.action(async (flags: Flags) => {
|
|
92
|
+
await executeReleaseWorkflow(
|
|
93
|
+
await createContext({ ...options, ...config, ...flags }),
|
|
94
|
+
compact(await Promise.all(plugins.map(createPlugin)))
|
|
95
|
+
)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
if (version) {
|
|
99
|
+
program.version(version, '-v, --version', 'Display the version number.')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
program.helpOption('-h, --help', 'Display command usage and options.')
|
|
103
|
+
|
|
104
|
+
return program
|
|
105
|
+
}
|
package/src/index.ts
CHANGED