@lumpcode/cli-utils 0.0.12 → 0.0.13

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @lumpcode/cli-utils
2
2
 
3
- Published npm package: **types**, **`define*` helpers**, and **runtime utilities** for authoring Lumpcode lump configs and recipes.
3
+ **Types**, **`define*` helpers**, and **runtime utilities** for authoring Lumpcode lump configs and recipes.
4
4
 
5
5
  Re-exports all of [`@lumpcode/cli-types`](https://www.npmjs.com/package/@lumpcode/cli-types) plus runtime helpers bundled from `@lumpcode/cli` sources at build time (`cli-types` stays an external dependency at publish).
6
6
 
@@ -15,7 +15,7 @@ npm install @lumpcode/cli-utils
15
15
  ## Usage
16
16
 
17
17
  ```ts
18
- import { defineConfig, normalizeSteps, type LumpJsConfig } from '@lumpcode/cli-utils';
18
+ import { defineConfig, normalizeSteps, type LumpJsConfig, type StepFn } from '@lumpcode/cli-utils';
19
19
  ```
20
20
 
21
21
  ## Build
package/dist/index.cjs CHANGED
@@ -80,7 +80,7 @@ async function readYamlList(filePath) {
80
80
  function normalizeSteps({ prompt: originalPrompt, jsSteps: originalJsSteps, }) {
81
81
  const { prompt, jsSteps } = normalizePromptAndSteps({
82
82
  prompt: originalPrompt,
83
- jsSteps: originalJsSteps
83
+ jsSteps: originalJsSteps,
84
84
  });
85
85
  if (jsSteps && Array.isArray(jsSteps)) {
86
86
  return jsSteps;
@@ -94,6 +94,10 @@ function normalizeSteps({ prompt: originalPrompt, jsSteps: originalJsSteps, }) {
94
94
  }
95
95
  function normalizePromptAndSteps({ prompt, jsSteps, }) {
96
96
  if (jsSteps !== undefined && !Array.isArray(jsSteps)) {
97
+ // Solo dynamic steps fn must stay in the steps walk, not become promptFn.
98
+ if (typeof jsSteps === 'function') {
99
+ return { prompt, jsSteps: [jsSteps] };
100
+ }
97
101
  return { prompt: jsSteps, jsSteps: undefined };
98
102
  }
99
103
  return { prompt, jsSteps };
package/dist/index.d.ts CHANGED
@@ -36,7 +36,9 @@ type LumpJsConfigStep = MergeObjs<Step, {
36
36
  command?: CommandTag | FilePath | Step['commandFn'];
37
37
  }>;
38
38
 
39
- type LumpJsConfigSteps = Array<LumpJsConfigStep | ((input: Exclude<PromptFnInput, 'stepVariables'>) => MaybePromise<LumpJsConfigSteps>) | LumpJsConfigStep['promptTemplate']>;
39
+ type LumpJsConfigStepsFn = (input: Omit<PromptFnInput, 'stepVariables'>) => MaybePromise<LumpJsConfigSteps | LumpJsConfigStepsItem>;
40
+ type LumpJsConfigStepsItem = LumpJsConfigStep | LumpJsConfigStepsFn | LumpJsConfigStep['promptTemplate'];
41
+ type LumpJsConfigSteps = Array<LumpJsConfigStepsItem>;
40
42
 
41
43
  type LumpJsConfigSoloStep = LumpJsConfigStep | LumpJsConfigStep['promptTemplate'] | LumpJsConfigStep['promptFn'];
42
44
  type LumpJsConfig<V extends LumpVariables = LumpVariables> = MergeObjs<Omit<{
@@ -52,7 +54,7 @@ type LumpJsConfig<V extends LumpVariables = LumpVariables> = MergeObjs<Omit<{
52
54
  disabled?: boolean | (() => MaybePromise<boolean>) | FilePath;
53
55
  maximumNumberOfConcurrentBranches?: number;
54
56
  prompt?: LumpJsConfigSoloStep;
55
- steps?: LumpJsConfigSteps | LumpJsConfigSoloStep;
57
+ steps?: LumpJsConfigSteps | LumpJsConfigStepsItem;
56
58
  registerCommands?: string[];
57
59
  keepHistory?: boolean;
58
60
  verbose?: boolean;
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ async function readYamlList(filePath) {
57
57
  function normalizeSteps({ prompt: originalPrompt, jsSteps: originalJsSteps, }) {
58
58
  const { prompt, jsSteps } = normalizePromptAndSteps({
59
59
  prompt: originalPrompt,
60
- jsSteps: originalJsSteps
60
+ jsSteps: originalJsSteps,
61
61
  });
62
62
  if (jsSteps && Array.isArray(jsSteps)) {
63
63
  return jsSteps;
@@ -71,6 +71,10 @@ function normalizeSteps({ prompt: originalPrompt, jsSteps: originalJsSteps, }) {
71
71
  }
72
72
  function normalizePromptAndSteps({ prompt, jsSteps, }) {
73
73
  if (jsSteps !== undefined && !Array.isArray(jsSteps)) {
74
+ // Solo dynamic steps fn must stay in the steps walk, not become promptFn.
75
+ if (typeof jsSteps === 'function') {
76
+ return { prompt, jsSteps: [jsSteps] };
77
+ }
74
78
  return { prompt: jsSteps, jsSteps: undefined };
75
79
  }
76
80
  return { prompt, jsSteps };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumpcode/cli-utils",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Types, defineX helpers, and runtime utilities for Lumpcode lump configs and recipes",
5
5
  "keywords": [
6
6
  "lumpcode",
@@ -42,8 +42,8 @@
42
42
  "build": "rollup -c"
43
43
  },
44
44
  "dependencies": {
45
- "@lumpcode/cli-types": "^0.0.12",
46
- "@lumpcode/core": "^0.0.12",
45
+ "@lumpcode/cli-types": "^0.0.13",
46
+ "@lumpcode/core": "^0.0.13",
47
47
  "js-yaml": "^5.0.0"
48
48
  },
49
49
  "devDependencies": {