@iola_adm/iola-cli 0.2.18 → 0.2.19

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.
@@ -32,25 +32,27 @@ const steps = [
32
32
  ];
33
33
 
34
34
  const canAnimate = process.stdout.isTTY && process.env.CI !== "true";
35
+ const setupStarted = process.hrtime.bigint();
35
36
 
36
37
  console.log("");
37
- console.log("IOLA CLI: настройка после установки");
38
+ console.log("IOLA CLI: настройка после установки npm-пакета");
39
+ console.log("Время ниже считает только настройку CLI, без скачивания и распаковки npm-пакета.");
38
40
 
39
41
  for (let index = 0; index < steps.length; index += 1) {
40
42
  const step = steps[index];
41
43
  await runStep(step, index + 1, steps.length);
42
44
  }
43
45
 
44
- console.log("IOLA CLI готова. Запуск: iola");
46
+ console.log(`IOLA CLI готова за ${formatDuration(elapsedMs(setupStarted))}. Запуск: iola`);
45
47
 
46
48
  async function runStep(step, current, total) {
47
- const started = Date.now();
49
+ const started = process.hrtime.bigint();
48
50
  let frame = 0;
49
51
  let lastOutput = "";
50
52
  const prefix = `[${current}/${total}] ${step.title}`;
51
53
  const render = () => {
52
54
  if (!canAnimate) return;
53
- const seconds = Math.max(1, Math.round((Date.now() - started) / 1000));
55
+ const seconds = Math.max(1, Math.floor(elapsedMs(started) / 1000));
54
56
  process.stdout.write(`\r${frames[frame]} ${prefix}... ${seconds}s`);
55
57
  frame = (frame + 1) % frames.length;
56
58
  };
@@ -75,9 +77,9 @@ async function runStep(step, current, total) {
75
77
  }
76
78
 
77
79
  if (canAnimate) {
78
- process.stdout.write(`\r✓ ${prefix} готово за ${formatDuration(Date.now() - started)}\n`);
80
+ process.stdout.write(`\r✓ ${prefix} готово за ${formatDuration(elapsedMs(started))}\n`);
79
81
  } else {
80
- console.log(`✓ ${prefix} готово за ${formatDuration(Date.now() - started)}`);
82
+ console.log(`✓ ${prefix} готово за ${formatDuration(elapsedMs(started))}`);
81
83
  }
82
84
  }
83
85
 
@@ -114,9 +116,15 @@ function run(command, args, onOutput) {
114
116
  });
115
117
  }
116
118
 
119
+ function elapsedMs(started) {
120
+ return Number(process.hrtime.bigint() - started) / 1_000_000;
121
+ }
122
+
117
123
  function formatDuration(ms) {
118
- const seconds = Math.max(1, Math.round(ms / 1000));
119
- if (seconds < 60) return `${seconds}s`;
124
+ if (ms < 1000) return `${Math.max(1, Math.round(ms))}ms`;
125
+ const totalSeconds = ms / 1000;
126
+ if (totalSeconds < 60) return `${totalSeconds.toFixed(1)}s`;
127
+ const seconds = Math.floor(totalSeconds);
120
128
  const minutes = Math.floor(seconds / 60);
121
129
  const rest = seconds % 60;
122
130
  return `${minutes}m ${rest}s`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iola_adm/iola-cli",
3
- "version": "0.2.18",
3
+ "version": "0.2.19",
4
4
  "description": "CLI и AI-агент городского округа Йошкар-Ола.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/adm-iola/iola-cli#readme",
@@ -7,6 +7,7 @@ const rootDir = resolve(dirname(fileURLToPath(import.meta.url)), "..");
7
7
  const binPath = resolve(rootDir, "bin", "iola.js");
8
8
  const packageJson = JSON.parse(await readFile(resolve(rootDir, "package.json"), "utf8"));
9
9
  const cliSource = await readFile(resolve(rootDir, "src", "cli.js"), "utf8");
10
+ const postinstallSource = await readFile(resolve(rootDir, "bin", "postinstall.js"), "utf8");
10
11
 
11
12
  function runCli(args) {
12
13
  return new Promise((resolvePromise, reject) => {
@@ -76,6 +77,9 @@ assertNotIncludes(cliSource, "Сервисы через запятую [identity
76
77
  if (!packageJson.files.includes("docs/assets/iola-oauth-icon.png")) {
77
78
  throw new Error("package files should include the Yandex OAuth icon");
78
79
  }
80
+ assertIncludes(postinstallSource, "process.hrtime.bigint()", "postinstall should use a monotonic timer");
81
+ assertIncludes(postinstallSource, "без скачивания и распаковки npm-пакета", "postinstall timing should not imply full npm install time");
82
+ assertIncludes(postinstallSource, "IOLA CLI готова за", "postinstall should print total setup duration");
79
83
 
80
84
  const commands = await runCli(["commands"]);
81
85
  assertIncludes(commands, "iola browser status|install|open|text|html|screenshot|pdf|click|type|eval", "commands");