@kici-dev/compiler 0.1.17 → 0.1.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.
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import { resolve } from "node:path";
6
6
  import { Argument, Command, Option } from "commander";
7
7
  import pc from "picocolors";
8
8
  //#region src/cli.ts
9
- const version = "0.1.17";
9
+ const version = "0.1.19";
10
10
  /**
11
11
  * Build the kici Commander program with every command registered. Exported so
12
12
  * the surface registry can walk the real command tree without parsing argv (no
@@ -12,6 +12,7 @@ import pc from "picocolors";
12
12
  import { existsSync } from "node:fs";
13
13
  import fs from "node:fs/promises";
14
14
  import { logger, toErrorMessage } from "@kici-dev/core";
15
+ import { PackageManager, detectPackageManagerSync } from "@kici-dev/core/package-manager";
15
16
  import { execSync } from "node:child_process";
16
17
  //#region src/commands/compile.ts
17
18
  /**
@@ -26,22 +27,21 @@ async function readExistingLockfileHash(lockPath) {
26
27
  }
27
28
  }
28
29
  /**
29
- * Reinstall dependencies in .kici/ using npm.
30
+ * Reinstall dependencies in .kici/ using the project's package manager.
31
+ *
32
+ * Detects the manager from `.kici/` (pnpm-lock.yaml / yarn.lock /
33
+ * package-lock.json) so a standalone-pnpm or -yarn `.kici` is reinstalled with
34
+ * the right tool — running `npm ci` against a pnpm lock fails, and against a
35
+ * stale npm lock left beside a pnpm lock it fails even harder.
30
36
  */
31
37
  async function reinstallDeps(kiciDir) {
32
- if (existsSync(path.join(kiciDir, "package-lock.json"))) {
33
- logger.info("Running " + pc.cyan("npm ci") + ` in ${kiciDir}`);
34
- execSync("npm ci", {
35
- cwd: kiciDir,
36
- stdio: "inherit"
37
- });
38
- } else {
39
- logger.info("Running " + pc.cyan("npm install") + ` in ${kiciDir}`);
40
- execSync("npm install", {
41
- cwd: kiciDir,
42
- stdio: "inherit"
43
- });
44
- }
38
+ const pm = detectPackageManagerSync(kiciDir);
39
+ const command = pm === PackageManager.Pnpm ? "pnpm install" : pm === PackageManager.Yarn ? "yarn install" : existsSync(path.join(kiciDir, "package-lock.json")) ? "npm ci" : "npm install";
40
+ logger.info("Running " + pc.cyan(command) + ` in ${kiciDir}`);
41
+ execSync(command, {
42
+ cwd: kiciDir,
43
+ stdio: "inherit"
44
+ });
45
45
  }
46
46
  /**
47
47
  * Execute the compile command.
@@ -10,7 +10,8 @@ import path from "node:path";
10
10
  import pc from "picocolors";
11
11
  import { readFile } from "node:fs/promises";
12
12
  import { logger, toErrorMessage } from "@kici-dev/core";
13
- import { matchAllWorkflows, normalizeRunsOn } from "@kici-dev/engine";
13
+ import { matchAllWorkflows } from "@kici-dev/engine";
14
+ import { normalizeRunsOnToMatchers } from "@kici-dev/engine/labels/compile";
14
15
  //#region src/commands/test.ts
15
16
  /**
16
17
  * Main test command entry point.
@@ -136,10 +137,7 @@ function workflowsToLockFormat(workflows) {
136
137
  return {
137
138
  _type: "static",
138
139
  name: j.name,
139
- runsOn: typeof j.runsOn === "string" || Array.isArray(j.runsOn) ? j.runsOn : (() => {
140
- const n = normalizeRunsOn(j.runsOn);
141
- return n.labels.length === 1 ? n.labels[0] : n.labels;
142
- })(),
140
+ runsOn: j.runsOn === void 0 ? [] : normalizeRunsOnToMatchers(j.runsOn, `job '${j.name}' runsOn`).include,
143
141
  needs: j.needs?.map((n) => {
144
142
  if (typeof n === "string") return n;
145
143
  if ("name" in n) return n.name;