@guiho/mirror 3.2.1 → 3.3.0-alpha.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/CHANGELOG.md +15 -0
- package/DOCS.md +35 -74
- package/README.md +15 -41
- package/jsr.json +4 -2
- package/package.json +11 -20
- package/scripts/install-package.ts +70 -0
- package/scripts/mirror-bin.ts +20 -0
- package/skills/guiho-as-mirror/SKILL.md +2 -29
- package/library/adapters.d.ts +0 -32
- package/library/adapters.d.ts.map +0 -1
- package/library/adapters.js +0 -210
- package/library/agents.d.ts +0 -29
- package/library/agents.d.ts.map +0 -1
- package/library/agents.js +0 -212
- package/library/cli.d.ts +0 -29
- package/library/cli.d.ts.map +0 -1
- package/library/cli.js +0 -416
- package/library/config.d.ts +0 -18
- package/library/config.d.ts.map +0 -1
- package/library/config.js +0 -280
- package/library/errors.d.ts +0 -9
- package/library/errors.d.ts.map +0 -1
- package/library/errors.js +0 -15
- package/library/executor.d.ts +0 -7
- package/library/executor.d.ts.map +0 -1
- package/library/executor.js +0 -48
- package/library/flags.d.ts +0 -6
- package/library/flags.d.ts.map +0 -1
- package/library/flags.js +0 -80
- package/library/guiho-mirror-bin.d.ts +0 -6
- package/library/guiho-mirror-bin.d.ts.map +0 -1
- package/library/guiho-mirror-bin.js +0 -6
- package/library/guiho-mirror.d.ts +0 -18
- package/library/guiho-mirror.d.ts.map +0 -1
- package/library/guiho-mirror.js +0 -16
- package/library/hooks.d.ts +0 -14
- package/library/hooks.d.ts.map +0 -1
- package/library/hooks.js +0 -122
- package/library/init.d.ts +0 -12
- package/library/init.d.ts.map +0 -1
- package/library/init.js +0 -100
- package/library/plan.d.ts +0 -10
- package/library/plan.d.ts.map +0 -1
- package/library/plan.js +0 -85
- package/library/reporter.d.ts +0 -15
- package/library/reporter.d.ts.map +0 -1
- package/library/reporter.js +0 -182
- package/library/schema.d.ts +0 -164
- package/library/schema.d.ts.map +0 -1
- package/library/schema.js +0 -152
- package/library/types.d.ts +0 -205
- package/library/types.d.ts.map +0 -1
- package/library/types.js +0 -4
- package/library/version.d.ts +0 -10
- package/library/version.d.ts.map +0 -1
- package/library/version.js +0 -31
package/library/cli.js
DELETED
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
|
-
*/
|
|
4
|
-
import { defineCommand, runMain } from 'citty';
|
|
5
|
-
import { readFileSync } from 'node:fs';
|
|
6
|
-
import { resolve } from 'node:path';
|
|
7
|
-
import { ensureMirrorAgentsInstructions, installMirrorSkill, runMirrorAgentAutomation } from './agents.js';
|
|
8
|
-
import { MirrorError } from './errors.js';
|
|
9
|
-
import { readCurrentVersion, resolveProjectName } from './adapters.js';
|
|
10
|
-
import { configPathForDisplay, discoverMirrorConfig, loadMirrorConfig, relativeFromCwd, writeInitConfigFromAnswers } from './config.js';
|
|
11
|
-
import { executeVersionPlan } from './executor.js';
|
|
12
|
-
import { parseMirrorCliOptions } from './flags.js';
|
|
13
|
-
import { createReadlineInitPrompter, isInteractiveInit, resolveInitAnswers } from './init.js';
|
|
14
|
-
import { buildVersionPlan, validateMirrorConfig } from './plan.js';
|
|
15
|
-
import { mirrorBanner, reportAgentsInstructions, reportConfig, reportConfigSchema, reportExecution, reportExecutionSummary, reportPlan, reportSkillInstall, reportValue, } from './reporter.js';
|
|
16
|
-
import { resolveNextVersion } from './version.js';
|
|
17
|
-
import { runHooks, runHooksQuiet, hookEnvFromConfig, hookEnvForPlan, hookEnvForResult } from './hooks.js';
|
|
18
|
-
const mirrorVersion = readInstalledVersion();
|
|
19
|
-
const globalArgs = {
|
|
20
|
-
config: { type: 'string', description: 'Path to mirror.config.toml' },
|
|
21
|
-
cwd: { type: 'string', description: 'Run as if Mirror started in this directory' },
|
|
22
|
-
format: { type: 'enum', options: ['text', 'json'], default: 'text', description: 'Output format' },
|
|
23
|
-
'no-color': { type: 'boolean', description: 'Disable color output' },
|
|
24
|
-
verbose: { type: 'boolean', description: 'Show full error details and stack traces' },
|
|
25
|
-
};
|
|
26
|
-
const overrideArgs = {
|
|
27
|
-
...globalArgs,
|
|
28
|
-
source: { type: 'enum', options: ['package.json', 'jsr.json', 'git'], description: 'Override version source' },
|
|
29
|
-
output: { type: 'string', description: 'Override version output. Repeat or comma-separate values.' },
|
|
30
|
-
'package-file': { type: 'string', description: 'Override package.json path' },
|
|
31
|
-
'jsr-file': { type: 'string', description: 'Override jsr.json path' },
|
|
32
|
-
preid: { type: 'string', description: 'Override prerelease identifier' },
|
|
33
|
-
};
|
|
34
|
-
const applyArgs = {
|
|
35
|
-
...overrideArgs,
|
|
36
|
-
'dry-run': { type: 'boolean', alias: 'dy', description: 'Build and print the plan without applying it' },
|
|
37
|
-
commit: { type: 'boolean', description: 'Create a release commit when file outputs changed' },
|
|
38
|
-
push: { type: 'boolean', description: 'Create the release commit when needed, then push release refs' },
|
|
39
|
-
'allow-dirty': { type: 'boolean', description: 'Allow release in a dirty Git worktree' },
|
|
40
|
-
yes: { type: 'boolean', alias: 'y', description: 'Apply without interactive confirmation' },
|
|
41
|
-
};
|
|
42
|
-
const targetArg = {
|
|
43
|
-
target: { type: 'positional', description: 'Release target or exact semantic version', required: true },
|
|
44
|
-
};
|
|
45
|
-
export const createMirrorCommand = () => defineCommand({
|
|
46
|
-
meta: {
|
|
47
|
-
name: 'mirror',
|
|
48
|
-
version: mirrorVersion,
|
|
49
|
-
description: 'Open source project versioning for Bun, npm, JSR, and Git.',
|
|
50
|
-
},
|
|
51
|
-
args: globalArgs,
|
|
52
|
-
subCommands: {
|
|
53
|
-
init: createInitCommand(),
|
|
54
|
-
config: createConfigCommand(),
|
|
55
|
-
agents: createAgentsCommand(),
|
|
56
|
-
version: createVersionCommand(),
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
export const runMirrorCli = async (rawArgs = process.argv.slice(2)) => {
|
|
60
|
-
const effectiveArgs = rawArgs.length === 0 ? ['--help'] : rawArgs;
|
|
61
|
-
const verbose = effectiveArgs.includes('--verbose');
|
|
62
|
-
const restoreColorOutput = effectiveArgs.includes('--no-color') ? stripColorFromProcessOutput() : () => { };
|
|
63
|
-
try {
|
|
64
|
-
if (effectiveArgs.includes('--no-color'))
|
|
65
|
-
process.env['NO_COLOR'] = '1';
|
|
66
|
-
if (rawArgs.length === 0) {
|
|
67
|
-
await prepareAgents({});
|
|
68
|
-
}
|
|
69
|
-
if (effectiveArgs.includes('--help')) {
|
|
70
|
-
const parsed = parseMirrorCliOptions(effectiveArgs);
|
|
71
|
-
const cwd = resolve(parsed.cwd ?? process.cwd());
|
|
72
|
-
const discovery = await discoverMirrorConfig(cwd, parsed.config);
|
|
73
|
-
const configDisplay = discovery.path ? relativeFromCwd(cwd, discovery.path) : '';
|
|
74
|
-
process.stdout.write(mirrorBanner(configDisplay));
|
|
75
|
-
}
|
|
76
|
-
if (rawArgs.length === 0) {
|
|
77
|
-
process.on('exit', () => {
|
|
78
|
-
process.stdout.write([
|
|
79
|
-
'EXAMPLES',
|
|
80
|
-
'',
|
|
81
|
-
' mirror version current # Print the current version',
|
|
82
|
-
' mirror version plan patch # Preview a patch release plan',
|
|
83
|
-
' mirror version apply minor --commit # Apply a minor release with commit',
|
|
84
|
-
' mirror version plan patch --output=package.json,jsr.json,git # Plan with package, jsr, and git',
|
|
85
|
-
' mirror agents install local # Install guiho-as-mirror in this project',
|
|
86
|
-
' mirror agents instructions # Insert Mirror guidance into AGENTS.md',
|
|
87
|
-
' mirror config schema # Print the configuration file reference',
|
|
88
|
-
'',
|
|
89
|
-
].join('\n') + '\n');
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
let capturedError = undefined;
|
|
93
|
-
const originalConsoleError = console.error;
|
|
94
|
-
console.error = (...args) => {
|
|
95
|
-
if (args.length > 0 && args[0] instanceof Error) {
|
|
96
|
-
capturedError = args[0];
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
originalConsoleError(...args);
|
|
100
|
-
};
|
|
101
|
-
const originalProcessExit = process.exit;
|
|
102
|
-
let exitCode;
|
|
103
|
-
process.exit = ((code) => {
|
|
104
|
-
if (code !== 0 && capturedError) {
|
|
105
|
-
exitCode = code;
|
|
106
|
-
return undefined;
|
|
107
|
-
}
|
|
108
|
-
originalProcessExit(code);
|
|
109
|
-
});
|
|
110
|
-
try {
|
|
111
|
-
await runMain(createMirrorCommand(), { rawArgs: effectiveArgs });
|
|
112
|
-
}
|
|
113
|
-
finally {
|
|
114
|
-
console.error = originalConsoleError;
|
|
115
|
-
process.exit = originalProcessExit;
|
|
116
|
-
}
|
|
117
|
-
if (capturedError) {
|
|
118
|
-
handleCliError(capturedError, verbose, exitCode);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
handleCliError(error, verbose);
|
|
123
|
-
}
|
|
124
|
-
finally {
|
|
125
|
-
restoreColorOutput();
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const handleCliError = (error, verbose, exitCode) => {
|
|
129
|
-
if (error instanceof MirrorError) {
|
|
130
|
-
console.error(`error: ${error.message}`);
|
|
131
|
-
if (verbose)
|
|
132
|
-
console.error(error.stack);
|
|
133
|
-
process.exit(error.exitCode);
|
|
134
|
-
}
|
|
135
|
-
if (error instanceof Error) {
|
|
136
|
-
console.error(`error: ${error.message}`);
|
|
137
|
-
if (verbose)
|
|
138
|
-
console.error(error.stack);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
console.error('error: An unexpected error occurred.');
|
|
142
|
-
if (verbose)
|
|
143
|
-
console.error(error);
|
|
144
|
-
}
|
|
145
|
-
process.exit(exitCode ?? 1);
|
|
146
|
-
};
|
|
147
|
-
const createInitCommand = () => defineCommand({
|
|
148
|
-
meta: { name: 'init', description: 'Create or update a Mirror configuration file.' },
|
|
149
|
-
args: {
|
|
150
|
-
...globalArgs,
|
|
151
|
-
source: { type: 'positional', required: false, description: 'Version source: package.json, jsr.json, or git' },
|
|
152
|
-
output: { type: 'string', description: 'Version outputs. Repeat or comma-separate package.json, jsr.json, git.' },
|
|
153
|
-
'package-file': { type: 'string', description: 'Path to package.json' },
|
|
154
|
-
'jsr-file': { type: 'string', description: 'Path to jsr.json' },
|
|
155
|
-
auxiliary: { type: 'string', description: 'Auxiliary package.json paths. Repeat or comma-separate values.' },
|
|
156
|
-
'tag-template': { type: 'string', description: 'Git tag template' },
|
|
157
|
-
name: { type: 'string', description: 'Explicit project name' },
|
|
158
|
-
preid: { type: 'string', description: 'Default prerelease identifier' },
|
|
159
|
-
commit: { type: 'boolean', description: 'Create release commits' },
|
|
160
|
-
push: { type: 'boolean', description: 'Push release refs' },
|
|
161
|
-
'non-interactive': { type: 'boolean', description: 'Skip interactive prompts and use flags + defaults' },
|
|
162
|
-
yes: { type: 'boolean', description: 'Overwrite an existing mirror.config.toml with generated defaults' },
|
|
163
|
-
},
|
|
164
|
-
async run(context) {
|
|
165
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
166
|
-
const cwd = resolve(options.cwd ?? process.cwd());
|
|
167
|
-
const positionalSource = adapterArg(context.args['source']);
|
|
168
|
-
const commitProvided = context.rawArgs.includes('--commit');
|
|
169
|
-
const pushProvided = context.rawArgs.includes('--push');
|
|
170
|
-
const flags = {
|
|
171
|
-
source: options.source ?? positionalSource,
|
|
172
|
-
output: options.output,
|
|
173
|
-
packagePath: options.packageFile,
|
|
174
|
-
auxiliaryPaths: options.auxiliary,
|
|
175
|
-
jsrPath: options.jsrFile,
|
|
176
|
-
tagTemplate: options.tagTemplate,
|
|
177
|
-
name: options.name,
|
|
178
|
-
prereleaseId: options.preid,
|
|
179
|
-
commit: commitProvided ? options.commit : undefined,
|
|
180
|
-
push: pushProvided ? options.push : undefined,
|
|
181
|
-
};
|
|
182
|
-
const interactive = isInteractiveInit(options);
|
|
183
|
-
const prompter = interactive ? createReadlineInitPrompter() : undefined;
|
|
184
|
-
try {
|
|
185
|
-
const answers = await resolveInitAnswers(flags, cwd, prompter);
|
|
186
|
-
const path = await writeInitConfigFromAnswers(answers, cwd, Boolean(options.yes));
|
|
187
|
-
process.stdout.write(reportValue(`created ${path}`, options.format));
|
|
188
|
-
}
|
|
189
|
-
finally {
|
|
190
|
-
await prompter?.close();
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
const createConfigCommand = () => defineCommand({
|
|
195
|
-
meta: { name: 'config', description: 'Inspect and validate Mirror configuration.' },
|
|
196
|
-
subCommands: {
|
|
197
|
-
show: defineCommand({
|
|
198
|
-
meta: { name: 'show', description: 'Print the resolved configuration.' },
|
|
199
|
-
args: overrideArgs,
|
|
200
|
-
async run(context) {
|
|
201
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
202
|
-
await prepareAgents(options);
|
|
203
|
-
const config = await loadMirrorConfig(options);
|
|
204
|
-
if (options.format !== 'json')
|
|
205
|
-
process.stdout.write(mirrorBanner(configPathForDisplay(config)));
|
|
206
|
-
process.stdout.write(reportConfig(config, options.format));
|
|
207
|
-
},
|
|
208
|
-
}),
|
|
209
|
-
check: defineCommand({
|
|
210
|
-
meta: { name: 'check', description: 'Validate the resolved configuration.' },
|
|
211
|
-
args: overrideArgs,
|
|
212
|
-
async run(context) {
|
|
213
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
214
|
-
await prepareAgents(options);
|
|
215
|
-
await validateMirrorConfig(options);
|
|
216
|
-
process.stdout.write(reportValue('ok', options.format));
|
|
217
|
-
},
|
|
218
|
-
}),
|
|
219
|
-
schema: defineCommand({
|
|
220
|
-
meta: { name: 'schema', description: 'Print the configuration file reference.' },
|
|
221
|
-
args: globalArgs,
|
|
222
|
-
run(context) {
|
|
223
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
224
|
-
if (options.format !== 'json')
|
|
225
|
-
process.stdout.write(mirrorBanner());
|
|
226
|
-
process.stdout.write(reportConfigSchema(options.format));
|
|
227
|
-
},
|
|
228
|
-
}),
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
|
-
const createAgentsCommand = () => defineCommand({
|
|
232
|
-
meta: { name: 'agents', description: 'Install Mirror agent skills and AGENTS.md instructions.' },
|
|
233
|
-
subCommands: {
|
|
234
|
-
install: defineCommand({
|
|
235
|
-
meta: { name: 'install', description: 'Install the guiho-as-mirror agent skill.' },
|
|
236
|
-
subCommands: {
|
|
237
|
-
local: createInstallSkillCommand('local'),
|
|
238
|
-
global: createInstallSkillCommand('global'),
|
|
239
|
-
},
|
|
240
|
-
}),
|
|
241
|
-
instructions: defineCommand({
|
|
242
|
-
meta: { name: 'instructions', description: 'Insert GUIHO Mirror semantic versioning guidance into AGENTS.md.' },
|
|
243
|
-
args: globalArgs,
|
|
244
|
-
async run(context) {
|
|
245
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
246
|
-
const result = await ensureMirrorAgentsInstructions(resolve(options.cwd ?? process.cwd()), true);
|
|
247
|
-
process.stdout.write(reportAgentsInstructions(result, options.format));
|
|
248
|
-
},
|
|
249
|
-
}),
|
|
250
|
-
},
|
|
251
|
-
});
|
|
252
|
-
const createInstallSkillCommand = (scope) => defineCommand({
|
|
253
|
-
meta: { name: scope, description: `Install the guiho-as-mirror skill ${scope}.` },
|
|
254
|
-
args: globalArgs,
|
|
255
|
-
async run(context) {
|
|
256
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
257
|
-
const result = await installMirrorSkill(scope, { cwd: resolve(options.cwd ?? process.cwd()) });
|
|
258
|
-
process.stdout.write(reportSkillInstall(result, options.format));
|
|
259
|
-
},
|
|
260
|
-
});
|
|
261
|
-
const createVersionCommand = () => defineCommand({
|
|
262
|
-
meta: { name: 'version', description: 'Read, plan, and apply version changes.' },
|
|
263
|
-
subCommands: {
|
|
264
|
-
current: defineCommand({
|
|
265
|
-
meta: { name: 'current', description: 'Print the current project version.' },
|
|
266
|
-
args: overrideArgs,
|
|
267
|
-
async run(context) {
|
|
268
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
269
|
-
await prepareAgents(options);
|
|
270
|
-
const config = await loadMirrorConfig(options);
|
|
271
|
-
const projectName = await resolveProjectName(config);
|
|
272
|
-
process.stdout.write(reportValue(await readCurrentVersion(config, projectName), options.format));
|
|
273
|
-
},
|
|
274
|
-
}),
|
|
275
|
-
next: defineCommand({
|
|
276
|
-
meta: { name: 'next', description: 'Print the next version without checking outputs.' },
|
|
277
|
-
args: { ...overrideArgs, ...targetArg },
|
|
278
|
-
async run(context) {
|
|
279
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
280
|
-
await prepareAgents(options);
|
|
281
|
-
const config = await loadMirrorConfig(options);
|
|
282
|
-
const projectName = await resolveProjectName(config);
|
|
283
|
-
const currentVersion = await readCurrentVersion(config, projectName);
|
|
284
|
-
process.stdout.write(reportValue(resolveNextVersion(currentVersion, String(context.args['target']), config.version.prereleaseId), options.format));
|
|
285
|
-
},
|
|
286
|
-
}),
|
|
287
|
-
plan: defineCommand({
|
|
288
|
-
meta: { name: 'plan', description: 'Print the release plan without writing anything.' },
|
|
289
|
-
args: { ...overrideArgs, ...targetArg },
|
|
290
|
-
async run(context) {
|
|
291
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
292
|
-
await prepareAgents(options);
|
|
293
|
-
const plan = await buildVersionPlan(String(context.args['target']), options);
|
|
294
|
-
if (options.format !== 'json')
|
|
295
|
-
process.stdout.write(mirrorBanner(plan.configPath ? plan.configPath : ''));
|
|
296
|
-
process.stdout.write(reportPlan(plan, options.format));
|
|
297
|
-
},
|
|
298
|
-
}),
|
|
299
|
-
apply: defineCommand({
|
|
300
|
-
meta: { name: 'apply', description: 'Apply the release plan.' },
|
|
301
|
-
args: { ...applyArgs, ...targetArg },
|
|
302
|
-
async run(context) {
|
|
303
|
-
const options = cliOptions(context.rawArgs, context.args);
|
|
304
|
-
await prepareAgents(options);
|
|
305
|
-
const target = String(context.args['target']);
|
|
306
|
-
const config = await loadMirrorConfig(options);
|
|
307
|
-
const hooks = config.hooks;
|
|
308
|
-
const hookResults = [];
|
|
309
|
-
const baseEnv = hookEnvFromConfig(config, target);
|
|
310
|
-
try {
|
|
311
|
-
await runHooks('before:everything', hooks['before:everything'], baseEnv, config.cwd);
|
|
312
|
-
}
|
|
313
|
-
catch (error) {
|
|
314
|
-
hookResults.push({ name: 'before:everything', commands: hooks['before:everything'] ?? [], status: 'failure', durationMs: 0, exitCode: error instanceof Error ? 1 : 1, stderr: error instanceof Error ? error.message : String(error) });
|
|
315
|
-
throw error;
|
|
316
|
-
}
|
|
317
|
-
try {
|
|
318
|
-
await runHooks('before:plan', hooks['before:plan'], baseEnv, config.cwd);
|
|
319
|
-
const plan = await buildVersionPlan(target, options);
|
|
320
|
-
const planEnv = hookEnvForPlan(plan, target);
|
|
321
|
-
await runHooks('after:plan', hooks['after:plan'], planEnv, config.cwd);
|
|
322
|
-
if (options.format !== 'json')
|
|
323
|
-
process.stdout.write(mirrorBanner(plan.configPath ? plan.configPath : ''));
|
|
324
|
-
if (options.format !== 'json')
|
|
325
|
-
process.stdout.write(reportPlan(plan, options.format));
|
|
326
|
-
await runHooks('before:apply', hooks['before:apply'], planEnv, config.cwd);
|
|
327
|
-
try {
|
|
328
|
-
const result = await executeVersionPlan(plan, options, hooks, target);
|
|
329
|
-
result.hookResults = hookResults;
|
|
330
|
-
process.stdout.write(options.format === 'json' ? reportExecution(result, options.format) : reportExecutionSummary(result, options.format));
|
|
331
|
-
}
|
|
332
|
-
finally {
|
|
333
|
-
const resultEnv = hookEnvForResult(plan, target, true, Boolean(options.dryRun));
|
|
334
|
-
await runHooksQuiet('after:apply', hooks['after:apply'], resultEnv, config.cwd, hookResults);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
finally {
|
|
338
|
-
await runHooksQuiet('after:everything', hooks['after:everything'], baseEnv, config.cwd, hookResults);
|
|
339
|
-
}
|
|
340
|
-
},
|
|
341
|
-
}),
|
|
342
|
-
},
|
|
343
|
-
});
|
|
344
|
-
const cliOptions = (rawArgs, args) => {
|
|
345
|
-
const parsed = parseMirrorCliOptions(rawArgs);
|
|
346
|
-
return {
|
|
347
|
-
...parsed,
|
|
348
|
-
config: parsed.config ?? stringArg(args['config']),
|
|
349
|
-
cwd: parsed.cwd ?? stringArg(args['cwd']),
|
|
350
|
-
format: parsed.format ?? (args['format'] === 'json' ? 'json' : 'text'),
|
|
351
|
-
source: parsed.source ?? adapterArg(args['source']),
|
|
352
|
-
output: parsed.output ?? outputArg(args['output']),
|
|
353
|
-
packageFile: parsed.packageFile ?? stringArg(args['packageFile']),
|
|
354
|
-
jsrFile: parsed.jsrFile ?? stringArg(args['jsrFile']),
|
|
355
|
-
auxiliary: parsed.auxiliary ?? outputListArg(args['auxiliary']),
|
|
356
|
-
tagTemplate: parsed.tagTemplate ?? stringArg(args['tagTemplate']),
|
|
357
|
-
name: parsed.name ?? stringArg(args['name']),
|
|
358
|
-
preid: parsed.preid ?? stringArg(args['preid']),
|
|
359
|
-
dryRun: parsed.dryRun || args['dryRun'] === true,
|
|
360
|
-
commit: parsed.commit || args['commit'] === true,
|
|
361
|
-
push: parsed.push || args['push'] === true,
|
|
362
|
-
allowDirty: parsed.allowDirty || args['allowDirty'] === true,
|
|
363
|
-
nonInteractive: parsed.nonInteractive || args['nonInteractive'] === true,
|
|
364
|
-
yes: parsed.yes || args['yes'] === true,
|
|
365
|
-
verbose: parsed.verbose || args['verbose'] === true,
|
|
366
|
-
};
|
|
367
|
-
};
|
|
368
|
-
const stringArg = (value) => (typeof value === 'string' ? value : undefined);
|
|
369
|
-
const outputListArg = (value) => {
|
|
370
|
-
if (typeof value !== 'string')
|
|
371
|
-
return undefined;
|
|
372
|
-
const values = value.split(',').map((item) => item.trim()).filter(Boolean);
|
|
373
|
-
return values.length > 0 ? values : undefined;
|
|
374
|
-
};
|
|
375
|
-
const adapterArg = (value) => {
|
|
376
|
-
if (value === 'package.json' || value === 'jsr.json' || value === 'git')
|
|
377
|
-
return value;
|
|
378
|
-
return undefined;
|
|
379
|
-
};
|
|
380
|
-
const outputArg = (value) => {
|
|
381
|
-
if (typeof value !== 'string')
|
|
382
|
-
return undefined;
|
|
383
|
-
const values = value.split(',').map((item) => item.trim()).filter(Boolean);
|
|
384
|
-
if (values.length === 0)
|
|
385
|
-
return undefined;
|
|
386
|
-
return values.map((item) => {
|
|
387
|
-
const adapter = adapterArg(item);
|
|
388
|
-
if (!adapter)
|
|
389
|
-
throw new MirrorError(`Invalid --output value: ${item}`);
|
|
390
|
-
return adapter;
|
|
391
|
-
});
|
|
392
|
-
};
|
|
393
|
-
const prepareAgents = async (options) => {
|
|
394
|
-
await runMirrorAgentAutomation(options, (message) => console.error(message));
|
|
395
|
-
};
|
|
396
|
-
function readInstalledVersion() {
|
|
397
|
-
try {
|
|
398
|
-
const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
399
|
-
return typeof packageJson['version'] === 'string' ? packageJson['version'] : '0.0.0';
|
|
400
|
-
}
|
|
401
|
-
catch {
|
|
402
|
-
return '0.0.0';
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
const stripAnsi = (value) => value.replace(/\u001B\[[0-?]*[ -/]*[@-~]/g, '');
|
|
406
|
-
const stripColorFromProcessOutput = () => {
|
|
407
|
-
const originalLog = console.log;
|
|
408
|
-
const originalError = console.error;
|
|
409
|
-
console.log = (...values) => originalLog(...values.map(stripAnsiValue));
|
|
410
|
-
console.error = (...values) => originalError(...values.map(stripAnsiValue));
|
|
411
|
-
return () => {
|
|
412
|
-
console.log = originalLog;
|
|
413
|
-
console.error = originalError;
|
|
414
|
-
};
|
|
415
|
-
};
|
|
416
|
-
const stripAnsiValue = (value) => (typeof value === 'string' ? stripAnsi(value) : value);
|
package/library/config.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
|
-
*/
|
|
4
|
-
import type { MirrorAdapterName, MirrorCliOptions, MirrorConfig, MirrorConfigDiscovery, MirrorInitAnswers, MirrorRawConfig } from './types.js';
|
|
5
|
-
export declare const resolveMirrorPath: (cwd: string, path: string) => string;
|
|
6
|
-
export declare const relativeFromCwd: (cwd: string, path: string) => string;
|
|
7
|
-
export declare const discoverMirrorConfig: (cwd: string, explicitPath?: string) => Promise<MirrorConfigDiscovery>;
|
|
8
|
-
export declare const readConfigFile: (path: string) => Promise<MirrorRawConfig>;
|
|
9
|
-
export declare const loadMirrorConfig: (options?: MirrorCliOptions) => Promise<MirrorConfig>;
|
|
10
|
-
export declare const normalizeMirrorConfig: (raw: MirrorRawConfig, cwd: string, configPath: string | undefined, options?: MirrorCliOptions) => MirrorConfig;
|
|
11
|
-
export declare const defaultInitAnswersForSource: (kind: MirrorAdapterName, cwd: string) => MirrorInitAnswers;
|
|
12
|
-
export declare const generateInitConfig: (answers: MirrorInitAnswers, cwd: string) => string;
|
|
13
|
-
export declare const createInitConfig: (kind: MirrorAdapterName, cwd: string) => string;
|
|
14
|
-
export declare const writeInitConfig: (kind: MirrorAdapterName, cwd: string, overwrite?: boolean) => Promise<string>;
|
|
15
|
-
export declare const writeInitConfigFromAnswers: (answers: MirrorInitAnswers, cwd: string, overwrite?: boolean) => Promise<string>;
|
|
16
|
-
export declare const reconcileInitConfig: (existingContent: string, defaultsContent: string) => string;
|
|
17
|
-
export declare const configPathForDisplay: (config: MirrorConfig) => string;
|
|
18
|
-
//# sourceMappingURL=config.d.ts.map
|
package/library/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../source/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EAEjB,eAAe,EAChB,MAAM,YAAY,CAAA;AAQnB,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,MAAM,MAAM,WAAmD,CAAA;AAE9G,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,EAAE,MAAM,MAAM,WAGxD,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAU,KAAK,MAAM,EAAE,eAAe,MAAM,KAAG,OAAO,CAAC,qBAAqB,CAa5G,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,eAAe,CAe1E,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAU,UAAS,gBAAqB,KAAG,OAAO,CAAC,YAAY,CAO3F,CAAA;AAED,eAAO,MAAM,qBAAqB,GAChC,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,YAAY,MAAM,GAAG,SAAS,EAC9B,UAAS,gBAAqB,KAC7B,YA2DF,CAAA;AAED,eAAO,MAAM,2BAA2B,GAAI,MAAM,iBAAiB,EAAE,KAAK,MAAM,KAAG,iBAWjF,CAAA;AAEF,eAAO,MAAM,kBAAkB,GAAI,SAAS,iBAAiB,EAAE,KAAK,MAAM,WAsCzE,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,MAAM,iBAAiB,EAAE,KAAK,MAAM,WAAoE,CAAA;AAEzI,eAAO,MAAM,eAAe,GAAU,MAAM,iBAAiB,EAAE,KAAK,MAAM,EAAE,mBAAiB,oBACT,CAAA;AAEpF,eAAO,MAAM,0BAA0B,GAAU,SAAS,iBAAiB,EAAE,KAAK,MAAM,EAAE,mBAAiB,oBAW1G,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,iBAAiB,MAAM,EAAE,iBAAiB,MAAM,WAyBnF,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,QAAQ,YAAY,WAAoF,CAAA"}
|