@emeryld/manager 1.0.1 → 1.2.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.
Files changed (38) hide show
  1. package/README.md +86 -27
  2. package/dist/cli/interactive-settings.js +191 -0
  3. package/dist/create-package/shared.js +3 -1
  4. package/dist/create-package/variants/client/client_vite_r.js +85 -5
  5. package/dist/format-checker/cli/options.js +133 -0
  6. package/dist/format-checker/cli/prompts.js +108 -0
  7. package/dist/format-checker/cli/settings.js +140 -0
  8. package/dist/format-checker/config.js +63 -0
  9. package/dist/format-checker/index.js +48 -0
  10. package/dist/format-checker/report.js +118 -0
  11. package/dist/format-checker/scan/analysis.js +109 -0
  12. package/dist/format-checker/scan/collect.js +33 -0
  13. package/dist/format-checker/scan/constants.js +23 -0
  14. package/dist/format-checker/scan/duplicates.js +116 -0
  15. package/dist/format-checker/scan/functions.js +68 -0
  16. package/dist/format-checker/scan/indentation.js +58 -0
  17. package/dist/format-checker/scan/index.js +2 -0
  18. package/dist/format-checker/scan/types.js +1 -0
  19. package/dist/format-checker/scan/utils.js +68 -0
  20. package/dist/format-checker/scan/variables.js +246 -0
  21. package/dist/format-checker/scan.js +444 -0
  22. package/dist/menu.js +18 -0
  23. package/dist/publish.js +5 -0
  24. package/dist/robot/cli/prompts.js +102 -0
  25. package/dist/robot/cli/settings.js +120 -0
  26. package/dist/robot/config.js +83 -0
  27. package/dist/robot/coordinator.js +98 -0
  28. package/dist/robot/extractors/classes.js +41 -0
  29. package/dist/robot/extractors/components.js +57 -0
  30. package/dist/robot/extractors/constants.js +42 -0
  31. package/dist/robot/extractors/functions.js +40 -0
  32. package/dist/robot/extractors/shared.js +99 -0
  33. package/dist/robot/extractors/types.js +43 -0
  34. package/dist/robot/index.js +1 -0
  35. package/dist/robot/types.js +1 -0
  36. package/dist/utils/export.js +99 -0
  37. package/dist/utils/run.js +3 -0
  38. package/package.json +2 -1
@@ -0,0 +1,99 @@
1
+ import { tmpdir } from 'node:os';
2
+ import { unlink, writeFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { colors } from './log.js';
5
+ import { run } from './run.js';
6
+ import { promptSingleKey } from '../prompts.js';
7
+ const ANSI_ESCAPE = /\x1b\[[0-9;]*m/g;
8
+ const DEFAULT_EXPORT_MODE = 'console';
9
+ const EDITOR_CANDIDATES = [
10
+ process.env.MANAGER_EDITOR,
11
+ 'code',
12
+ 'code-insiders',
13
+ process.env.VISUAL,
14
+ process.env.EDITOR,
15
+ ];
16
+ export const EXPORT_MODES = ['console', 'editor'];
17
+ export async function promptExportMode(defaultMode = DEFAULT_EXPORT_MODE) {
18
+ const labels = EXPORT_MODES.map((mode) => {
19
+ const prefix = mode === 'console' ? 'c' : 'e';
20
+ const display = mode === defaultMode ? `${mode} (default)` : mode;
21
+ return `${prefix}=${display}`;
22
+ });
23
+ const question = colors.cyan(`View results in console or editor? (${labels.join(' / ')}): `);
24
+ return promptSingleKey(question, (key) => {
25
+ const normalized = key.trim().toLowerCase();
26
+ if (!normalized)
27
+ return defaultMode;
28
+ if (normalized === 'c')
29
+ return 'console';
30
+ if (normalized === 'e')
31
+ return 'editor';
32
+ return undefined;
33
+ });
34
+ }
35
+ export function captureConsoleOutput(callback) {
36
+ const lines = [];
37
+ const originalLog = console.log;
38
+ console.log = (...args) => {
39
+ lines.push(args.map((arg) => String(arg)).join(' '));
40
+ };
41
+ try {
42
+ const result = callback();
43
+ return { result, lines };
44
+ }
45
+ finally {
46
+ console.log = originalLog;
47
+ }
48
+ }
49
+ export async function exportReportLines(label, extension, lines) {
50
+ const sanitized = lines.map(stripAnsi);
51
+ const content = `${sanitized.join('\n')}\n`;
52
+ const filename = `${label}-${Date.now()}.${extension}`;
53
+ const filePath = path.join(tmpdir(), filename);
54
+ await writeFile(filePath, content, 'utf-8');
55
+ const opened = await tryOpenInEditor(filePath);
56
+ if (opened) {
57
+ await unlink(filePath).catch(() => { });
58
+ console.log(colors.green(`Opened the ${colors.bold(label)} report in your editor (temporary file removed).`));
59
+ return undefined;
60
+ }
61
+ console.log(colors.yellow(`Unable to launch an editor. The ${colors.bold(label)} report is at ${filePath}.`));
62
+ return filePath;
63
+ }
64
+ export function stripAnsi(value) {
65
+ return value.replace(ANSI_ESCAPE, '');
66
+ }
67
+ async function tryOpenInEditor(filePath) {
68
+ for (const candidate of EDITOR_CANDIDATES) {
69
+ if (!candidate)
70
+ continue;
71
+ const { command, args } = buildEditorCommand(candidate, filePath);
72
+ try {
73
+ await run(command, args, { stdio: 'ignore' });
74
+ return true;
75
+ }
76
+ catch {
77
+ // Try the next candidate if the command fails.
78
+ }
79
+ }
80
+ return false;
81
+ }
82
+ function buildEditorCommand(raw, filePath) {
83
+ const parts = raw.trim().split(/\s+/);
84
+ if (parts.length === 0) {
85
+ throw new Error('Editor command cannot be empty.');
86
+ }
87
+ const command = parts[0];
88
+ const extraArgs = parts.slice(1);
89
+ const terminalArgs = (() => {
90
+ if (command === 'code' || command === 'code-insiders') {
91
+ return [...extraArgs, '--goto', filePath, '--wait'];
92
+ }
93
+ if (command === 'open') {
94
+ return [...extraArgs, '-W', filePath];
95
+ }
96
+ return [...extraArgs, filePath];
97
+ })();
98
+ return { command, args: terminalArgs };
99
+ }
package/dist/utils/run.js CHANGED
@@ -17,5 +17,8 @@ export function run(command, args, options = {}) {
17
17
  else
18
18
  reject(new Error(`Command "${command} ${args.join(' ')}" exited with ${code}`));
19
19
  });
20
+ child.on('error', (error) => {
21
+ reject(new Error(`Command "${command} ${args.join(' ')}" failed: ${error.message}`));
22
+ });
20
23
  });
21
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emeryld/manager",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Interactive manager for pnpm monorepos (update/test/build/publish).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,6 +39,7 @@
39
39
  "swc": false
40
40
  },
41
41
  "scripts": {
42
+ "manager-cli": "node dist/manager-cli.js",
42
43
  "build": "tsc -p tsconfig.base.json && node scripts/copy-manager-cli.mjs",
43
44
  "typecheck": "tsc -p tsconfig.base.json --noEmit",
44
45
  "test": "cross-env TS_NODE_PROJECT=tsconfig.test.json node --loader ts-node/esm --test test/*.test.ts"