@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/hooks.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
|
-
*/
|
|
4
|
-
import { exec } from 'node:child_process';
|
|
5
|
-
import { promisify } from 'node:util';
|
|
6
|
-
import { MirrorError } from './errors.js';
|
|
7
|
-
const execAsync = (command, options) => promisify(exec)(command, {
|
|
8
|
-
cwd: options.cwd,
|
|
9
|
-
env: { ...process.env, ...options.env },
|
|
10
|
-
maxBuffer: 10 * 1024 * 1024,
|
|
11
|
-
});
|
|
12
|
-
export const mirrorHookNames = [
|
|
13
|
-
'before:everything', 'after:everything',
|
|
14
|
-
'before:plan', 'after:plan',
|
|
15
|
-
'before:apply', 'after:apply',
|
|
16
|
-
'before:write', 'after:write',
|
|
17
|
-
'before:commit', 'after:commit',
|
|
18
|
-
'before:tag', 'after:tag',
|
|
19
|
-
'before:push', 'after:push',
|
|
20
|
-
];
|
|
21
|
-
const hookNameSet = new Set(mirrorHookNames);
|
|
22
|
-
export const normalizeHooksConfig = (raw) => {
|
|
23
|
-
if (!raw || typeof raw !== 'object')
|
|
24
|
-
return {};
|
|
25
|
-
const config = {};
|
|
26
|
-
for (const [key, value] of Object.entries(raw)) {
|
|
27
|
-
const name = key.replaceAll('_', ':');
|
|
28
|
-
if (!hookNameSet.has(name))
|
|
29
|
-
continue;
|
|
30
|
-
const commands = typeof value === 'string' ? [value] : value;
|
|
31
|
-
config[name] = commands;
|
|
32
|
-
}
|
|
33
|
-
return config;
|
|
34
|
-
};
|
|
35
|
-
export const runHooks = async (name, commands, env, cwd) => {
|
|
36
|
-
if (!commands || commands.length === 0)
|
|
37
|
-
return undefined;
|
|
38
|
-
const start = Date.now();
|
|
39
|
-
for (let i = 0; i < commands.length; i++) {
|
|
40
|
-
const command = commands[i];
|
|
41
|
-
if (!command)
|
|
42
|
-
continue;
|
|
43
|
-
try {
|
|
44
|
-
await execAsync(command, { cwd, env });
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
48
|
-
const exitCode = typeof error['code'] === 'number' ? error['code'] : 1;
|
|
49
|
-
throw new MirrorError(`Hook '${name}' failed (exit code ${exitCode}): ${command}\n${message}`, Number(exitCode));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
name,
|
|
54
|
-
commands,
|
|
55
|
-
status: 'success',
|
|
56
|
-
durationMs: Date.now() - start,
|
|
57
|
-
exitCode: 0,
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export const runHooksQuiet = async (name, commands, env, cwd, results) => {
|
|
61
|
-
if (!commands || commands.length === 0)
|
|
62
|
-
return;
|
|
63
|
-
try {
|
|
64
|
-
await runHooks(name, commands, env, cwd);
|
|
65
|
-
results.push({ name, commands, status: 'success', durationMs: 0, exitCode: 0 });
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
const exitCode = error instanceof MirrorError ? error.exitCode ?? 1 : 1;
|
|
69
|
-
results.push({ name, commands, status: 'failure', durationMs: 0, exitCode, stderr: error instanceof Error ? error.message : String(error) });
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
export const runActionHooks = async (name, commands, env, cwd, options) => {
|
|
73
|
-
if (options.dryRun || !commands || commands.length === 0)
|
|
74
|
-
return undefined;
|
|
75
|
-
return runHooks(name, commands, env, cwd);
|
|
76
|
-
};
|
|
77
|
-
export const hookEnvFromConfig = (config, target) => ({
|
|
78
|
-
MIRROR_CWD: config.cwd,
|
|
79
|
-
MIRROR_CONFIG_PATH: config.configPath ?? '',
|
|
80
|
-
MIRROR_SOURCE: config.version.source,
|
|
81
|
-
MIRROR_OUTPUT: config.version.output.join(','),
|
|
82
|
-
MIRROR_TARGET: target,
|
|
83
|
-
});
|
|
84
|
-
export const hookEnvForPlan = (plan, target) => ({
|
|
85
|
-
MIRROR_CWD: plan.cwd,
|
|
86
|
-
MIRROR_CONFIG_PATH: plan.configPath ?? '',
|
|
87
|
-
MIRROR_SOURCE: plan.source,
|
|
88
|
-
MIRROR_OUTPUT: plan.output.join(','),
|
|
89
|
-
MIRROR_TARGET: target,
|
|
90
|
-
MIRROR_CURRENT: plan.currentVersion,
|
|
91
|
-
MIRROR_NEXT: plan.nextVersion,
|
|
92
|
-
MIRROR_PROJECT_NAME: plan.project.name ?? '',
|
|
93
|
-
MIRROR_GIT_TAG: plan.gitTag ?? '',
|
|
94
|
-
MIRROR_FILE_PATHS: plan.fileOutputPaths.join(','),
|
|
95
|
-
MIRROR_COMMIT_ENABLED: String(plan.commitEnabled),
|
|
96
|
-
MIRROR_PUSH_ENABLED: String(plan.pushEnabled),
|
|
97
|
-
});
|
|
98
|
-
export const hookEnvForAction = (plan, target, action) => {
|
|
99
|
-
const env = hookEnvForPlan(plan, target);
|
|
100
|
-
if (action.type === 'write-file') {
|
|
101
|
-
env['MIRROR_FILE_PATH'] = action.path;
|
|
102
|
-
env['MIRROR_FILE_CURRENT'] = action.currentVersion;
|
|
103
|
-
env['MIRROR_FILE_NEXT'] = action.nextVersion;
|
|
104
|
-
}
|
|
105
|
-
if (action.type === 'git-commit') {
|
|
106
|
-
env['MIRROR_COMMIT_MSG'] = action.message;
|
|
107
|
-
env['MIRROR_COMMIT_PATHS'] = action.paths.join(' ');
|
|
108
|
-
}
|
|
109
|
-
if (action.type === 'git-tag') {
|
|
110
|
-
env['MIRROR_TAG'] = action.tag;
|
|
111
|
-
}
|
|
112
|
-
if (action.type === 'git-push') {
|
|
113
|
-
env['MIRROR_INCLUDE_COMMIT'] = String(action.includeCommit);
|
|
114
|
-
env['MIRROR_INCLUDE_TAGS'] = String(action.includeTags);
|
|
115
|
-
}
|
|
116
|
-
return env;
|
|
117
|
-
};
|
|
118
|
-
export const hookEnvForResult = (plan, target, applied, dryRun) => ({
|
|
119
|
-
...hookEnvForPlan(plan, target),
|
|
120
|
-
MIRROR_APPLIED: String(applied),
|
|
121
|
-
MIRROR_DRY_RUN: String(dryRun),
|
|
122
|
-
});
|
package/library/init.d.ts
DELETED
|
@@ -1,12 +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, MirrorInitAnswers, MirrorInitFlags, MirrorInitPrompter } from './types.js';
|
|
5
|
-
export declare const parseAdapterList: (value: string) => MirrorAdapterName[];
|
|
6
|
-
export declare const resolveInitAnswers: (flags: MirrorInitFlags, cwd: string, prompter?: MirrorInitPrompter) => Promise<MirrorInitAnswers>;
|
|
7
|
-
export declare const isInteractiveInit: (options: {
|
|
8
|
-
yes?: boolean;
|
|
9
|
-
nonInteractive?: boolean;
|
|
10
|
-
}) => boolean;
|
|
11
|
-
export declare const createReadlineInitPrompter: () => MirrorInitPrompter;
|
|
12
|
-
//# sourceMappingURL=init.d.ts.map
|
package/library/init.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../source/init.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAI3G,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,iBAAiB,EAQjE,CAAA;AAQD,eAAO,MAAM,kBAAkB,GAC7B,OAAO,eAAe,EACtB,KAAK,MAAM,EACX,WAAW,kBAAkB,KAC5B,OAAO,CAAC,iBAAiB,CAkD3B,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,SAAS;IAAE,GAAG,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,YACG,CAAA;AAEzF,eAAO,MAAM,0BAA0B,QAAO,kBAmB7C,CAAA"}
|
package/library/init.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
|
-
*/
|
|
4
|
-
import { createInterface } from 'node:readline/promises';
|
|
5
|
-
import { basename } from 'node:path';
|
|
6
|
-
const adapterValues = new Set(['package.json', 'jsr.json', 'git']);
|
|
7
|
-
export const parseAdapterList = (value) => {
|
|
8
|
-
const values = value
|
|
9
|
-
.split(',')
|
|
10
|
-
.map((item) => item.trim())
|
|
11
|
-
.filter(Boolean)
|
|
12
|
-
.filter((item) => adapterValues.has(item));
|
|
13
|
-
return [...new Set(values)];
|
|
14
|
-
};
|
|
15
|
-
const parsePathList = (value) => value
|
|
16
|
-
.split(',')
|
|
17
|
-
.map((item) => item.trim())
|
|
18
|
-
.filter(Boolean);
|
|
19
|
-
export const resolveInitAnswers = async (flags, cwd, prompter) => {
|
|
20
|
-
const source = flags.source ?? (await askAdapter(prompter, 'Version source (package.json, jsr.json, git)', 'package.json'));
|
|
21
|
-
const output = flags.output ?? (await askAdapterList(prompter, 'Version outputs (comma separated)', ['package.json', 'git']));
|
|
22
|
-
const usesPackage = source === 'package.json' || output.includes('package.json');
|
|
23
|
-
const usesJsr = source === 'jsr.json' || output.includes('jsr.json');
|
|
24
|
-
const usesGit = source === 'git' || output.includes('git');
|
|
25
|
-
const hasFileOutput = output.includes('package.json') || output.includes('jsr.json');
|
|
26
|
-
const packagePath = usesPackage
|
|
27
|
-
? flags.packagePath ?? (prompter ? await prompter.text('package.json path', 'package.json') : 'package.json')
|
|
28
|
-
: 'package.json';
|
|
29
|
-
const auxiliaryPaths = usesPackage
|
|
30
|
-
? flags.auxiliaryPaths ??
|
|
31
|
-
(prompter ? parsePathList(await prompter.text('Auxiliary package.json paths (comma separated, blank for none)', '')) : [])
|
|
32
|
-
: [];
|
|
33
|
-
const jsrPath = usesJsr
|
|
34
|
-
? flags.jsrPath ?? (prompter ? await prompter.text('jsr.json path', 'jsr.json') : 'jsr.json')
|
|
35
|
-
: 'jsr.json';
|
|
36
|
-
const name = flags.name ?? (source === 'git' ? basename(cwd) : undefined);
|
|
37
|
-
const nameAvailable = source === 'package.json' || source === 'jsr.json' || Boolean(name);
|
|
38
|
-
const defaultTagTemplate = nameAvailable ? '{name}@{version}' : 'v{version}';
|
|
39
|
-
const tagTemplate = usesGit
|
|
40
|
-
? flags.tagTemplate ?? (prompter ? await prompter.text('Git tag template', defaultTagTemplate) : defaultTagTemplate)
|
|
41
|
-
: defaultTagTemplate;
|
|
42
|
-
const defaultCommit = usesGit && hasFileOutput;
|
|
43
|
-
const commit = flags.commit ?? (usesGit && prompter ? await prompter.confirm('Create release commits?', defaultCommit) : defaultCommit);
|
|
44
|
-
const push = flags.push ?? (usesGit && prompter ? await prompter.confirm('Push release refs?', false) : false);
|
|
45
|
-
const prereleaseId = flags.prereleaseId ?? '';
|
|
46
|
-
return {
|
|
47
|
-
source,
|
|
48
|
-
output,
|
|
49
|
-
packagePath,
|
|
50
|
-
auxiliaryPaths,
|
|
51
|
-
jsrPath,
|
|
52
|
-
name,
|
|
53
|
-
prereleaseId,
|
|
54
|
-
tagTemplate,
|
|
55
|
-
commit,
|
|
56
|
-
push,
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
export const isInteractiveInit = (options) => Boolean(process.stdin.isTTY) && options.yes !== true && options.nonInteractive !== true;
|
|
60
|
-
export const createReadlineInitPrompter = () => {
|
|
61
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
62
|
-
return {
|
|
63
|
-
async text(question, defaultValue) {
|
|
64
|
-
const suffix = defaultValue.length > 0 ? ` [${defaultValue}]` : ' [none]';
|
|
65
|
-
const answer = (await rl.question(`${question}${suffix}: `)).trim();
|
|
66
|
-
return answer.length > 0 ? answer : defaultValue;
|
|
67
|
-
},
|
|
68
|
-
async confirm(question, defaultValue) {
|
|
69
|
-
const suffix = defaultValue ? ' [Y/n]' : ' [y/N]';
|
|
70
|
-
const answer = (await rl.question(`${question}${suffix}: `)).trim().toLowerCase();
|
|
71
|
-
if (answer.length === 0)
|
|
72
|
-
return defaultValue;
|
|
73
|
-
return answer === 'y' || answer === 'yes';
|
|
74
|
-
},
|
|
75
|
-
close() {
|
|
76
|
-
rl.close();
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
const askAdapter = async (prompter, question, defaultValue) => {
|
|
81
|
-
if (!prompter)
|
|
82
|
-
return defaultValue;
|
|
83
|
-
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
84
|
-
const answer = (await prompter.text(question, defaultValue)).trim();
|
|
85
|
-
if (adapterValues.has(answer))
|
|
86
|
-
return answer;
|
|
87
|
-
}
|
|
88
|
-
return defaultValue;
|
|
89
|
-
};
|
|
90
|
-
const askAdapterList = async (prompter, question, defaultValue) => {
|
|
91
|
-
if (!prompter)
|
|
92
|
-
return defaultValue;
|
|
93
|
-
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
94
|
-
const answer = await prompter.text(question, defaultValue.join(', '));
|
|
95
|
-
const parsed = parseAdapterList(answer);
|
|
96
|
-
if (parsed.length > 0)
|
|
97
|
-
return parsed;
|
|
98
|
-
}
|
|
99
|
-
return defaultValue;
|
|
100
|
-
};
|
package/library/plan.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
|
-
*/
|
|
4
|
-
import type { MirrorCliOptions, MirrorConfig, MirrorVersionPlan } from './types.js';
|
|
5
|
-
export declare const validateMirrorConfig: (options?: MirrorCliOptions) => Promise<MirrorConfig>;
|
|
6
|
-
export declare const buildVersionPlan: (target: string, options?: MirrorCliOptions) => Promise<MirrorVersionPlan>;
|
|
7
|
-
export declare const resolveFileOutputPaths: (config: MirrorConfig) => string[];
|
|
8
|
-
export declare const releaseLabel: (version: string, projectName?: string) => string;
|
|
9
|
-
export declare const planPathForDisplay: (plan: MirrorVersionPlan, path: string) => string;
|
|
10
|
-
//# sourceMappingURL=plan.d.ts.map
|
package/library/plan.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../source/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,iBAAiB,EAA2B,MAAM,YAAY,CAAA;AAM5G,eAAO,MAAM,oBAAoB,GAAU,UAAS,gBAAqB,KAAG,OAAO,CAAC,YAAY,CAW/F,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAU,QAAQ,MAAM,EAAE,UAAS,gBAAqB,KAAG,OAAO,CAAC,iBAAiB,CA8DhH,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,QAAQ,YAAY,aAU1D,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,EAAE,cAAc,MAAM,WAAgE,CAAA;AAElI,eAAO,MAAM,kBAAkB,GAAI,MAAM,iBAAiB,EAAE,MAAM,MAAM,WAAoC,CAAA"}
|
package/library/plan.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
|
-
*/
|
|
4
|
-
import { relative } from 'node:path';
|
|
5
|
-
import { MirrorError } from './errors.js';
|
|
6
|
-
import { loadMirrorConfig, relativeFromCwd, resolveMirrorPath } from './config.js';
|
|
7
|
-
import { ensureAdapterFiles, readCurrentVersion, readJsrVersionFile, readPackageVersionFile, renderGitTag, resolveProjectName } from './adapters.js';
|
|
8
|
-
import { resolveNextVersion } from './version.js';
|
|
9
|
-
export const validateMirrorConfig = async (options = {}) => {
|
|
10
|
-
const config = await loadMirrorConfig(options);
|
|
11
|
-
await ensureAdapterFiles(config);
|
|
12
|
-
const projectName = await resolveProjectName(config);
|
|
13
|
-
if (config.version.source === 'git' || config.version.output.includes('git')) {
|
|
14
|
-
renderGitTag(config.git.tagTemplate, '0.0.0', projectName);
|
|
15
|
-
}
|
|
16
|
-
return config;
|
|
17
|
-
};
|
|
18
|
-
export const buildVersionPlan = async (target, options = {}) => {
|
|
19
|
-
const config = await validateMirrorConfig(options);
|
|
20
|
-
const projectName = await resolveProjectName(config);
|
|
21
|
-
const currentVersion = await readCurrentVersion(config, projectName);
|
|
22
|
-
const nextVersion = resolveNextVersion(currentVersion, target, config.version.prereleaseId);
|
|
23
|
-
const fileOutputPaths = resolveFileOutputPaths(config);
|
|
24
|
-
const commitEnabled = config.git.commit;
|
|
25
|
-
const pushEnabled = config.git.push;
|
|
26
|
-
const actions = [];
|
|
27
|
-
for (const path of fileOutputPaths) {
|
|
28
|
-
const adapter = path === resolveMirrorPath(config.cwd, config.jsr.path) ? 'jsr.json' : 'package.json';
|
|
29
|
-
actions.push({
|
|
30
|
-
type: 'write-file',
|
|
31
|
-
adapter,
|
|
32
|
-
path,
|
|
33
|
-
currentVersion: adapter === 'package.json' ? await readPackageVersionFile(path) : await readJsrVersionFile(path),
|
|
34
|
-
nextVersion,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
const gitTag = config.version.output.includes('git') ? renderGitTag(config.git.tagTemplate, nextVersion, projectName) : undefined;
|
|
38
|
-
if (fileOutputPaths.length > 0 && gitTag && !commitEnabled && !pushEnabled) {
|
|
39
|
-
throw new MirrorError('Git tag output with file outputs requires --commit or --push so the tag points at the version commit.');
|
|
40
|
-
}
|
|
41
|
-
if (commitEnabled && fileOutputPaths.length > 0) {
|
|
42
|
-
actions.push({
|
|
43
|
-
type: 'git-commit',
|
|
44
|
-
message: releaseLabel(nextVersion, projectName),
|
|
45
|
-
paths: fileOutputPaths.map((path) => relative(config.cwd, path)),
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (gitTag)
|
|
49
|
-
actions.push({ type: 'git-tag', tag: gitTag });
|
|
50
|
-
if (pushEnabled) {
|
|
51
|
-
actions.push({
|
|
52
|
-
type: 'git-push',
|
|
53
|
-
includeCommit: fileOutputPaths.length > 0,
|
|
54
|
-
includeTags: Boolean(gitTag),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
cwd: config.cwd,
|
|
59
|
-
configPath: config.configPath,
|
|
60
|
-
source: config.version.source,
|
|
61
|
-
output: config.version.output,
|
|
62
|
-
currentVersion,
|
|
63
|
-
nextVersion,
|
|
64
|
-
project: { name: projectName },
|
|
65
|
-
commitEnabled,
|
|
66
|
-
pushEnabled,
|
|
67
|
-
allowDirty: config.git.allowDirty,
|
|
68
|
-
fileOutputPaths,
|
|
69
|
-
gitTag,
|
|
70
|
-
actions,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
export const resolveFileOutputPaths = (config) => {
|
|
74
|
-
const paths = [];
|
|
75
|
-
if (config.version.output.includes('package.json')) {
|
|
76
|
-
paths.push(resolveMirrorPath(config.cwd, config.package.path));
|
|
77
|
-
for (const path of config.package.auxiliaryPaths)
|
|
78
|
-
paths.push(resolveMirrorPath(config.cwd, path));
|
|
79
|
-
}
|
|
80
|
-
if (config.version.output.includes('jsr.json'))
|
|
81
|
-
paths.push(resolveMirrorPath(config.cwd, config.jsr.path));
|
|
82
|
-
return [...new Set(paths)];
|
|
83
|
-
};
|
|
84
|
-
export const releaseLabel = (version, projectName) => (projectName ? `${projectName}@${version}` : `v${version}`);
|
|
85
|
-
export const planPathForDisplay = (plan, path) => relativeFromCwd(plan.cwd, path);
|
package/library/reporter.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
|
-
*/
|
|
4
|
-
import type { MirrorAgentsInstructionsResult, MirrorConfig, MirrorExecutionResult, MirrorFormat, MirrorHookResult, MirrorSkillInstallResult, MirrorVersionPlan } from './types.js';
|
|
5
|
-
export declare const mirrorBanner: (configPath?: string) => string;
|
|
6
|
-
export declare const reportValue: (value: unknown, format?: MirrorFormat) => string;
|
|
7
|
-
export declare const reportConfig: (config: MirrorConfig, format?: MirrorFormat) => string;
|
|
8
|
-
export declare const reportConfigSchema: (format?: MirrorFormat) => string;
|
|
9
|
-
export declare const reportSkillInstall: (result: MirrorSkillInstallResult, format?: MirrorFormat) => string;
|
|
10
|
-
export declare const reportAgentsInstructions: (result: MirrorAgentsInstructionsResult, format?: MirrorFormat) => string;
|
|
11
|
-
export declare const reportPlan: (plan: MirrorVersionPlan, format?: MirrorFormat) => string;
|
|
12
|
-
export declare const reportExecution: (result: MirrorExecutionResult, format?: MirrorFormat) => string;
|
|
13
|
-
export declare const reportExecutionSummary: (result: MirrorExecutionResult, format?: MirrorFormat) => string;
|
|
14
|
-
export declare const reportHookResults: (results: MirrorHookResult[]) => string;
|
|
15
|
-
//# sourceMappingURL=reporter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../source/reporter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,8BAA8B,EAC9B,YAAY,EACZ,qBAAqB,EACrB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,YAAY,CAAA;AAInB,eAAO,MAAM,YAAY,GAAI,aAAa,MAAM,WAW/C,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,OAAO,OAAO,EAAE,SAAQ,YAAqB,WAGxE,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,QAAQ,YAAY,EAAE,SAAQ,YAAqB,WAoB/E,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,SAAQ,YAAqB,WAyD/D,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,QAAQ,wBAAwB,EAAE,SAAQ,YAAqB,WAWjG,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,QAAQ,8BAA8B,EAAE,SAAQ,YAAqB,WAS7G,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,MAAM,iBAAiB,EAAE,SAAQ,YAAqB,WAyBhF,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,QAAQ,qBAAqB,EAAE,SAAQ,YAAqB,WAK3F,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,QAAQ,qBAAqB,EAAE,SAAQ,YAAqB,WAkBlG,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAI,SAAS,gBAAgB,EAAE,WAG5D,CAAA"}
|
package/library/reporter.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Copyright (c) 2026 GUIHO Technologies as represented by Cristóvão GUIHO. All Rights Reserved.
|
|
3
|
-
*/
|
|
4
|
-
import { configPathForDisplay, relativeFromCwd } from './config.js';
|
|
5
|
-
import { renderMirrorConfigJsonSchema } from './schema.js';
|
|
6
|
-
export const mirrorBanner = (configPath) => {
|
|
7
|
-
const noColor = process.env['NO_COLOR'] === '1';
|
|
8
|
-
const title = noColor ? '🪞 GUIHO Mirror' : '\x1b[1;36m🪞 GUIHO Mirror\x1b[0m';
|
|
9
|
-
if (configPath === undefined)
|
|
10
|
-
return `\n${title}\n\n`;
|
|
11
|
-
const dim = noColor ? '' : '\x1b[2m';
|
|
12
|
-
const reset = noColor ? '' : '\x1b[0m';
|
|
13
|
-
const status = configPath ? configPath : '(none)';
|
|
14
|
-
return `\n${title}\n\n${dim}config: ${status}${reset}\n\n`;
|
|
15
|
-
};
|
|
16
|
-
export const reportValue = (value, format = 'text') => {
|
|
17
|
-
if (format === 'json')
|
|
18
|
-
return `${JSON.stringify(value, null, 2)}\n`;
|
|
19
|
-
return `${String(value)}\n`;
|
|
20
|
-
};
|
|
21
|
-
export const reportConfig = (config, format = 'text') => {
|
|
22
|
-
if (format === 'json')
|
|
23
|
-
return `${JSON.stringify(config, null, 2)}\n`;
|
|
24
|
-
return [
|
|
25
|
-
`config: ${configPathForDisplay(config)}`,
|
|
26
|
-
`source: ${config.version.source}`,
|
|
27
|
-
`output: ${config.version.output.join(', ')}`,
|
|
28
|
-
`package: ${config.package.path}`,
|
|
29
|
-
`package_auxiliary: ${config.package.auxiliaryPaths.join(', ') || '(none)'}`,
|
|
30
|
-
`jsr: ${config.jsr.path}`,
|
|
31
|
-
`tag_template: ${config.git.tagTemplate}`,
|
|
32
|
-
`commit: ${String(config.git.commit)}`,
|
|
33
|
-
`push: ${String(config.git.push)}`,
|
|
34
|
-
`allow_dirty: ${String(config.git.allowDirty)}`,
|
|
35
|
-
`write_changelog: ${String(config.agents.writeChangelog)}`,
|
|
36
|
-
`changelog_path: ${config.agents.changelogPath}`,
|
|
37
|
-
`auto_agents_md: ${String(config.agents.autoAgentsMd)}`,
|
|
38
|
-
`auto_skill_install: ${String(config.agents.autoSkillInstall)}`,
|
|
39
|
-
'',
|
|
40
|
-
].join('\n');
|
|
41
|
-
};
|
|
42
|
-
export const reportConfigSchema = (format = 'text') => {
|
|
43
|
-
if (format === 'json') {
|
|
44
|
-
return renderMirrorConfigJsonSchema();
|
|
45
|
-
}
|
|
46
|
-
return [
|
|
47
|
-
'MIRROR CONFIGURATION SCHEMA (mirror.config.toml)',
|
|
48
|
-
'',
|
|
49
|
-
' schema = 1 Required. Schema version. Must be 1.',
|
|
50
|
-
'',
|
|
51
|
-
' [project]',
|
|
52
|
-
' name = "<string>" Optional. Explicit project name.',
|
|
53
|
-
' name_source = "package.json" | "jsr.json" Optional. Read project name from this adapter.',
|
|
54
|
-
'',
|
|
55
|
-
' [version]',
|
|
56
|
-
' scheme = "semver" Required. Only "semver" is supported.',
|
|
57
|
-
' source = "package.json" | "jsr.json" | "git" Required. Adapter to read the current version from.',
|
|
58
|
-
' output = ["package.json", "jsr.json", "git"] Required. Adapters to write the next version to.',
|
|
59
|
-
' prerelease_id = "<string>" Optional. Default prerelease identifier (e.g. "alpha").',
|
|
60
|
-
'',
|
|
61
|
-
' [package]',
|
|
62
|
-
' path = "<path>" Optional. Path to package.json. Default: "package.json".',
|
|
63
|
-
' auxiliary_paths = ["<path>"] Optional. Extra package.json files that mirror the main package version.',
|
|
64
|
-
'',
|
|
65
|
-
' [jsr]',
|
|
66
|
-
' path = "<path>" Optional. Path to jsr.json. Default: "jsr.json".',
|
|
67
|
-
'',
|
|
68
|
-
' [git]',
|
|
69
|
-
' tag_template = "<template>" Optional. Git tag format. Default: "v{version}".',
|
|
70
|
-
' Supported: "v{version}", "{name}@{version}", "{name}/v{version}".',
|
|
71
|
-
' commit = true | false Optional. Create release commits. Default: false.',
|
|
72
|
-
' push = true | false Optional. Push release refs. Default: false.',
|
|
73
|
-
' allow_dirty = true | false Optional. Allow dirty Git worktree. Default: false.',
|
|
74
|
-
'',
|
|
75
|
-
' [agents]',
|
|
76
|
-
' write_changelog = true | false Optional. Tell agents to write changelog entries. Default: true.',
|
|
77
|
-
' changelog_path = "<path>" Optional. Changelog file path for agents. Default: "CHANGELOG.md".',
|
|
78
|
-
' auto_agents_md = true | false Optional. Insert Mirror guidance into AGENTS.md when present. Default: true.',
|
|
79
|
-
' auto_skill_install = true | false Optional. Install guiho-as-mirror globally when missing. Default: true.',
|
|
80
|
-
'',
|
|
81
|
-
' [hooks]',
|
|
82
|
-
' before_everything = "<command>" Optional. Shell command(s) before any release work.',
|
|
83
|
-
' after_everything = "<command>" Optional. Shell command(s) after all release work (always runs).',
|
|
84
|
-
' before_plan = "<command>" Optional. Shell command(s) before building the release plan.',
|
|
85
|
-
' after_plan = "<command>" Optional. Shell command(s) after the plan is built.',
|
|
86
|
-
' before_apply = "<command>" Optional. Shell command(s) before executing the plan.',
|
|
87
|
-
' after_apply = "<command>" Optional. Shell command(s) after plan execution (always runs).',
|
|
88
|
-
' before_write = "<command>" Optional. Shell command(s) before writing version files.',
|
|
89
|
-
' after_write = "<command>" Optional. Shell command(s) after writing version files.',
|
|
90
|
-
' before_commit = "<command>" Optional. Shell command(s) before creating a release commit.',
|
|
91
|
-
' after_commit = "<command>" Optional. Shell command(s) after creating a release commit.',
|
|
92
|
-
' before_tag = "<command>" Optional. Shell command(s) before creating a release tag.',
|
|
93
|
-
' after_tag = "<command>" Optional. Shell command(s) after creating a release tag.',
|
|
94
|
-
' before_push = "<command>" Optional. Shell command(s) before pushing release refs.',
|
|
95
|
-
' after_push = "<command>" Optional. Shell command(s) after pushing release refs.',
|
|
96
|
-
'',
|
|
97
|
-
].join('\n');
|
|
98
|
-
};
|
|
99
|
-
export const reportSkillInstall = (result, format = 'text') => {
|
|
100
|
-
if (format === 'json')
|
|
101
|
-
return `${JSON.stringify(result, null, 2)}\n`;
|
|
102
|
-
return [
|
|
103
|
-
'skill: guiho-as-mirror',
|
|
104
|
-
`scope: ${result.scope}`,
|
|
105
|
-
`path: ${result.path}`,
|
|
106
|
-
`installed: ${String(result.installed)}`,
|
|
107
|
-
`updated: ${String(result.updated)}`,
|
|
108
|
-
'',
|
|
109
|
-
].join('\n');
|
|
110
|
-
};
|
|
111
|
-
export const reportAgentsInstructions = (result, format = 'text') => {
|
|
112
|
-
if (format === 'json')
|
|
113
|
-
return `${JSON.stringify(result, null, 2)}\n`;
|
|
114
|
-
return [
|
|
115
|
-
`agents_md: ${result.path}`,
|
|
116
|
-
`exists: ${String(result.exists)}`,
|
|
117
|
-
`changed: ${String(result.changed)}`,
|
|
118
|
-
'',
|
|
119
|
-
].join('\n');
|
|
120
|
-
};
|
|
121
|
-
export const reportPlan = (plan, format = 'text') => {
|
|
122
|
-
if (format === 'json')
|
|
123
|
-
return `${JSON.stringify(plan, null, 2)}\n`;
|
|
124
|
-
const lines = [
|
|
125
|
-
`current: ${plan.currentVersion}`,
|
|
126
|
-
`next: ${plan.nextVersion}`,
|
|
127
|
-
`source: ${plan.source}`,
|
|
128
|
-
`output: ${plan.output.join(', ')}`,
|
|
129
|
-
];
|
|
130
|
-
if (plan.project.name)
|
|
131
|
-
lines.push(`project: ${plan.project.name}`);
|
|
132
|
-
if (plan.configPath)
|
|
133
|
-
lines.push(`config: ${relativeFromCwd(plan.cwd, plan.configPath)}`);
|
|
134
|
-
if (plan.fileOutputPaths.length > 0)
|
|
135
|
-
lines.push(`files: ${plan.fileOutputPaths.map((path) => relativeFromCwd(plan.cwd, path)).join(', ')}`);
|
|
136
|
-
if (plan.gitTag)
|
|
137
|
-
lines.push(`tag: ${plan.gitTag}`);
|
|
138
|
-
lines.push('actions:');
|
|
139
|
-
for (const action of plan.actions) {
|
|
140
|
-
if (action.type === 'write-file')
|
|
141
|
-
lines.push(`- write ${relativeFromCwd(plan.cwd, action.path)}: ${action.currentVersion} -> ${action.nextVersion}`);
|
|
142
|
-
if (action.type === 'git-commit')
|
|
143
|
-
lines.push(`- commit ${action.message}`);
|
|
144
|
-
if (action.type === 'git-tag')
|
|
145
|
-
lines.push(`- tag ${action.tag}`);
|
|
146
|
-
if (action.type === 'git-push')
|
|
147
|
-
lines.push(`- push commit=${String(action.includeCommit)} tags=${String(action.includeTags)}`);
|
|
148
|
-
}
|
|
149
|
-
return `${lines.join('\n')}\n`;
|
|
150
|
-
};
|
|
151
|
-
export const reportExecution = (result, format = 'text') => {
|
|
152
|
-
if (format === 'json')
|
|
153
|
-
return `${JSON.stringify(result, null, 2)}\n`;
|
|
154
|
-
let out = `${reportPlan(result.plan, 'text')}applied: ${String(result.applied)}\ndry_run: ${String(result.dryRun)}\n`;
|
|
155
|
-
if (result.hookResults && result.hookResults.length > 0)
|
|
156
|
-
out += reportHookResults(result.hookResults);
|
|
157
|
-
return out;
|
|
158
|
-
};
|
|
159
|
-
export const reportExecutionSummary = (result, format = 'text') => {
|
|
160
|
-
if (format === 'json')
|
|
161
|
-
return `${JSON.stringify(result, null, 2)}\n`;
|
|
162
|
-
const outputs = result.plan.output.join(', ');
|
|
163
|
-
const files = result.plan.fileOutputPaths.map((path) => relativeFromCwd(result.plan.cwd, path)).join(', ');
|
|
164
|
-
const lines = [
|
|
165
|
-
`applied: ${String(result.applied)}`,
|
|
166
|
-
`dry_run: ${String(result.dryRun)}`,
|
|
167
|
-
`version: ${result.plan.nextVersion}`,
|
|
168
|
-
`outputs: ${outputs}`,
|
|
169
|
-
];
|
|
170
|
-
if (files)
|
|
171
|
-
lines.push(`files: ${files}`);
|
|
172
|
-
if (result.plan.gitTag)
|
|
173
|
-
lines.push(`tag: ${result.plan.gitTag}`);
|
|
174
|
-
let out = `${lines.join('\n')}\n`;
|
|
175
|
-
if (result.hookResults && result.hookResults.length > 0)
|
|
176
|
-
out += reportHookResults(result.hookResults);
|
|
177
|
-
return out;
|
|
178
|
-
};
|
|
179
|
-
export const reportHookResults = (results) => {
|
|
180
|
-
const lines = results.map((r) => `hooks: ${r.name} ${r.status}${r.exitCode ? ` (exit ${r.exitCode})` : ''}`);
|
|
181
|
-
return `${lines.join('\n')}\n`;
|
|
182
|
-
};
|