@stencil/cli 5.0.0-alpha.7 → 5.0.0-alpha.9

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/index.d.mts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as d from "@stencil/core/compiler";
2
- import { LogLevel } from "@stencil/core/compiler";
2
+ import { ConfigCompat, LogLevel, OutputTarget } from "@stencil/core/compiler";
3
3
 
4
4
  //#region src/types.d.ts
5
5
  /**
6
6
  * Supported CLI task commands
7
7
  */
8
- type TaskCommand = 'build' | 'docs' | 'generate' | 'g' | 'help' | 'info' | 'init' | 'migrate' | 'prerender' | 'serve' | 'telemetry' | 'test' | 'version';
8
+ type TaskCommand = 'add' | 'build' | 'docs' | 'generate' | 'g' | 'help' | 'info' | 'init' | 'migrate' | 'prerender' | 'serve' | 'telemetry' | 'test' | 'version';
9
9
  //#endregion
10
10
  //#region src/config-flags.d.ts
11
11
  /**
@@ -151,14 +151,52 @@ declare const run: (init: d.CliInitOptions) => Promise<any>;
151
151
  declare const runTask: (coreCompiler: CoreCompiler, config: d.Config, task: TaskCommand, sys: d.CompilerSystem, flags?: ConfigFlags) => Promise<void>;
152
152
  //#endregion
153
153
  //#region src/wizard/types.d.ts
154
+ /**
155
+ * Stable, plugin-relevant subset of the compiler's resolved project config.
156
+ * Fields are fully resolved - paths are absolute, defaults are applied.
157
+ * Prefer this over reading `stencil.config.ts` directly.
158
+ */
159
+ interface ProjectConfig {
160
+ /** Absolute path to the project root. */
161
+ rootDir: string;
162
+ /** Absolute path to the source directory (default: `<rootDir>/src`). */
163
+ srcDir: string;
164
+ /** Component namespace, e.g. `"MyLib"`. Used in generated code and registry names. */
165
+ namespace: string;
166
+ /** Filesystem-safe namespace: `namespace.toLowerCase()` unless overridden. Used in output file/directory names. */
167
+ fsNamespace: string;
168
+ /** Fully resolved output targets with all defaults applied. */
169
+ outputTargets: ReadonlyArray<OutputTarget>;
170
+ /** Absolute path to the global script, if configured. */
171
+ globalScript?: string;
172
+ /** Absolute path to the global stylesheet, if configured. */
173
+ globalStyle?: string;
174
+ /** Backwards-compatibility flags (`compat` in stencil.config.ts). */
175
+ compat?: ConfigCompat;
176
+ /** Enable signal-based reactivity backing (top-level in stencil.config.ts). */
177
+ signalBacking?: boolean;
178
+ }
154
179
  /**
155
180
  * Context passed to wizard steps at runtime.
156
181
  */
157
182
  interface WizardContext {
158
- /** Absolute path to the project root directory. */
159
- rootDir: string;
160
183
  /** True when `stencil.config.ts` did not previously exist (fresh scaffold). */
161
184
  isNewProject: boolean;
185
+ /** Clack prompts - use instead of importing `@clack/prompts` directly for consistent UX. */
186
+ prompts: typeof import('@clack/prompts');
187
+ /** nypm - use instead of importing `nypm` directly so the package manager is auto-detected. */
188
+ nypm: typeof import('nypm');
189
+ /** Resolved project config. See {@link ProjectConfig} for available fields. */
190
+ config: ProjectConfig;
191
+ /**
192
+ * Absolute path to the monorepo workspace root when the project is part of a
193
+ * workspace, `undefined` for single-package projects.
194
+ *
195
+ * When present, `config.rootDir` is the core Stencil package (e.g.
196
+ * `<workspaceRoot>/packages/core/`). The plugin is responsible for deciding
197
+ * where in the workspace it wants to live and for creating that directory.
198
+ */
199
+ workspaceRoot?: string;
162
200
  }
163
201
  /**
164
202
  * A single file a plugin can offer during `stencil generate`.
@@ -183,17 +221,31 @@ interface WizardFileTemplate {
183
221
  /** Pre-selected in the generate prompt. Defaults to `true`. */
184
222
  selectedByDefault?: boolean;
185
223
  }
224
+ /**
225
+ * Context passed to dynamic `fileTemplates` resolvers during `stencil generate`.
226
+ */
227
+ interface GenerateContext {
228
+ /** The dash-case component tag name entered by the user. */
229
+ tagName: string;
230
+ /** Resolved project config. See {@link ProjectConfig} for available fields. */
231
+ config: ProjectConfig;
232
+ /** Clack prompts - use instead of importing `@clack/prompts` directly for consistent UX. */
233
+ prompts: typeof import('@clack/prompts');
234
+ /** nypm - use instead of importing `nypm` directly so the package manager is auto-detected. */
235
+ nypm: typeof import('nypm');
236
+ }
186
237
  /**
187
238
  * Contribution a package can make to `stencil generate`.
188
239
  */
189
240
  interface WizardGenerateContribution {
190
241
  /**
191
242
  * Files this plugin can generate alongside the component.
192
- * Each entry appears as a checkbox in the generate prompt.
193
- * A single plugin may contribute multiple entries (e.g. a vitest setup
194
- * with several project configs, each producing a differently-scoped test file).
243
+ *
244
+ * May be a static array or an async function that receives project context
245
+ * (e.g. to read `vitest.config.ts` and offer one template per configured
246
+ * Vitest project). Called after the user enters the component tag name.
195
247
  */
196
- fileTemplates?: ReadonlyArray<WizardFileTemplate>;
248
+ fileTemplates?: ReadonlyArray<WizardFileTemplate> | ((ctx: GenerateContext) => ReadonlyArray<WizardFileTemplate> | Promise<ReadonlyArray<WizardFileTemplate>>);
197
249
  /**
198
250
  * Additional style extensions this package supports (e.g. `['sass', 'scss']`
199
251
  * from `@stencil/sass`). The first entry is used as the default.
@@ -241,4 +293,4 @@ interface StencilWizardPlugin {
241
293
  init?: WizardInitContribution;
242
294
  }
243
295
  //#endregion
244
- export { BOOLEAN_CLI_FLAGS, type ConfigFlags, type StencilWizardPlugin, type TaskCommand, type WizardContext, type WizardFileTemplate, type WizardGenerateContribution, type WizardInitContribution, createConfigFlags, parseFlags, run, runTask };
296
+ export { BOOLEAN_CLI_FLAGS, type ConfigFlags, type GenerateContext, type ProjectConfig, type StencilWizardPlugin, type TaskCommand, type WizardContext, type WizardFileTemplate, type WizardGenerateContribution, type WizardInitContribution, createConfigFlags, parseFlags, run, runTask };