blockend-cli 2.1.0 → 2.1.1

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.
@@ -0,0 +1,2 @@
1
+ import type { AppliedBlock, ApplyBlockOptions, BlockPlan } from "./types.js";
2
+ export declare function applyBlock(plan: BlockPlan, options: ApplyBlockOptions): Promise<AppliedBlock>;
@@ -0,0 +1,3 @@
1
+ import type { InstalledBlockRecord } from "./types.js";
2
+ export declare function findUp(filename: string, startDir: string): Promise<string | null>;
3
+ export declare function recordInstalledBlock(configPath: string, record: InstalledBlockRecord): Promise<void>;
@@ -0,0 +1,7 @@
1
+ export declare function parseDepSpec(dep: string): {
2
+ name: string;
3
+ versionRange: string | null;
4
+ };
5
+ export declare function semverSatisfies(installed: string, range: string): boolean;
6
+ export declare function getVersionConflicts(deps: string[], installed: Record<string, string>): string[];
7
+ export declare const getMissingDependencies: (deps: string[], installed: Record<string, string>, forceLatest?: boolean) => string[];
@@ -0,0 +1 @@
1
+ export declare function rewriteFileImports(fileContent: string, writtenFilePath: string, blocksRoot: string, aliasBase: string | undefined, strategy: "rewrite" | "remove", downloadedFiles?: Set<string>, blockRoot?: string): string;
@@ -0,0 +1,9 @@
1
+ export type { AdapterConfig, AppliedBlock, ApplyBlockOptions, AssetMapping, AvailableBlock, BlockPlan, BlockPlanError, BlockPlanErrorCode, BlockPlanResult, BlockManifest, BlockendConfig, EnvironmentConfig, FrameworkName, InstalledBlockRecord, PlanBlockOptions, PreviewBlockOptions, PreviewFile, RegistryManifest, RegistrySource } from "./types.js";
2
+ export { createGitHubRegistrySource, createStaticRegistrySource, loadRegistry, type GitHubRegistrySourceOptions } from "./registry.js";
3
+ export { listAvailableBlocks, planBlock } from "./plan.js";
4
+ export { previewBlock } from "./preview.js";
5
+ export { applyBlock } from "./apply.js";
6
+ export { findUp } from "./config.js";
7
+ export { resolvePreferredVariant, selectVariant } from "./variants.js";
8
+ export { getMissingDependencies, getVersionConflicts, parseDepSpec, semverSatisfies } from "./deps.js";
9
+ export { rewriteFileImports } from "./imports.js";
@@ -0,0 +1,3 @@
1
+ import type { AvailableBlock, BlockPlanResult, PlanBlockOptions, RegistryManifest } from "./types.js";
2
+ export declare function planBlock(registry: RegistryManifest, blockName: string, environment: string, options?: PlanBlockOptions): Promise<BlockPlanResult>;
3
+ export declare function listAvailableBlocks(registry: RegistryManifest, environment: string): Promise<AvailableBlock[]>;
@@ -0,0 +1,2 @@
1
+ import type { BlockPlan, PreviewBlockOptions, PreviewFile } from "./types.js";
2
+ export declare function previewBlock(plan: BlockPlan, options: PreviewBlockOptions): Promise<PreviewFile[]>;
@@ -0,0 +1,11 @@
1
+ import type { BlockManifest, RegistryManifest, RegistrySource } from "./types.js";
2
+ export interface GitHubRegistrySourceOptions {
3
+ owner?: string;
4
+ repo?: string;
5
+ branch?: string;
6
+ baseUrl?: string;
7
+ }
8
+ export declare function createGitHubRegistrySource(options?: GitHubRegistrySourceOptions): RegistrySource;
9
+ export declare function createStaticRegistrySource(registry: RegistryManifest, files: Record<string, string>): RegistrySource;
10
+ export declare function loadRegistry(source: RegistrySource): Promise<RegistryManifest>;
11
+ export declare function getBlockMap(registry: RegistryManifest): Record<string, BlockManifest>;
@@ -0,0 +1,94 @@
1
+ import type { AdapterConfig as RegistryAdapterConfig, AssetMapping as RegistryAssetMapping, BlockManifest as RegistryBlockManifest, EnvironmentConfig as RegistryEnvironmentConfig, FrameworkName as RegistryFrameworkName, RegistryManifest as RegistryManifestType } from "@blockend/registry";
2
+ export type AssetMapping = RegistryAssetMapping;
3
+ export type AdapterConfig = RegistryAdapterConfig;
4
+ export type EnvironmentConfig = RegistryEnvironmentConfig;
5
+ export type FrameworkName = RegistryFrameworkName;
6
+ export type BlockManifest = RegistryBlockManifest;
7
+ export type RegistryManifest = RegistryManifestType;
8
+ export interface RegistrySource {
9
+ fetchRegistry(): Promise<RegistryManifest>;
10
+ fetchFile(sourcePath: string): Promise<string>;
11
+ }
12
+ export interface InstalledBlockRecord {
13
+ name: string;
14
+ version: string;
15
+ installedAt: string;
16
+ files: string[];
17
+ contentHash: string;
18
+ variant?: string;
19
+ }
20
+ export interface BlockendConfig {
21
+ $schema: string;
22
+ environment: FrameworkName | "none";
23
+ language: "typescript" | "javascript";
24
+ packageManager: string;
25
+ importRewriteStrategy: "rewrite" | "remove";
26
+ includeRedis: boolean;
27
+ aliases: {
28
+ blocks?: string;
29
+ };
30
+ paths: {
31
+ blocks: string;
32
+ };
33
+ installed?: InstalledBlockRecord[];
34
+ }
35
+ export interface PlanBlockOptions {
36
+ variant?: string;
37
+ recordedVariant?: string;
38
+ targetFolder?: string;
39
+ }
40
+ export interface BlockPlan {
41
+ blockName: string;
42
+ block: BlockManifest;
43
+ environment: string;
44
+ variant: string;
45
+ variantKeys: string[];
46
+ files: AssetMapping[];
47
+ dependencies: string[];
48
+ devDependencies: string[];
49
+ }
50
+ export type BlockPlanErrorCode = "not-found" | "unsupported-environment" | "no-adapter" | "no-variants";
51
+ export interface BlockPlanError {
52
+ code: BlockPlanErrorCode;
53
+ blockName: string;
54
+ environment: string;
55
+ message: string;
56
+ }
57
+ export type BlockPlanResult = {
58
+ ok: true;
59
+ plan: BlockPlan;
60
+ } | {
61
+ ok: false;
62
+ error: BlockPlanError;
63
+ };
64
+ export interface AvailableBlock {
65
+ name: string;
66
+ description: string;
67
+ variants: string[];
68
+ }
69
+ export interface PreviewFile {
70
+ name: string;
71
+ sourcePath: string;
72
+ targetPath: string;
73
+ existingContent: string | null;
74
+ newContent: string;
75
+ status: "new" | "modified" | "unchanged";
76
+ }
77
+ export interface PreviewBlockOptions {
78
+ source: RegistrySource;
79
+ targetFolder: string;
80
+ onDownloadError?: "throw" | "empty";
81
+ }
82
+ export interface ApplyBlockOptions {
83
+ source: RegistrySource;
84
+ blocksRoot: string;
85
+ aliasBase?: string;
86
+ rewriteStrategy: "rewrite" | "remove";
87
+ configPath: string;
88
+ }
89
+ export interface AppliedBlock {
90
+ block: string;
91
+ variant: string;
92
+ files: string[];
93
+ record: InstalledBlockRecord;
94
+ }
@@ -0,0 +1,2 @@
1
+ export declare function selectVariant(variantKeys: string[], preferredVariant?: string): string;
2
+ export declare function resolvePreferredVariant(variantKeys: string[], recordedVariant: string | undefined, targetFolder: string): Promise<string | undefined>;
@@ -1,44 +1,3 @@
1
- export interface AssetMapping {
2
- source: string;
3
- target: string;
4
- }
5
- export interface AdapterConfig {
6
- dependencies?: string[];
7
- devDependencies?: string[];
8
- files: string[] | AssetMapping[];
9
- }
10
- export interface EnvironmentConfig {
11
- core?: string;
12
- dependencies?: string[];
13
- devDependencies?: string[];
14
- variants: Record<string, AdapterConfig>;
15
- }
16
- export interface BlockManifest {
17
- name: string;
18
- description: string;
19
- version?: string;
20
- frameworks?: Array<"express" | "fastify" | "hono" | "next" | "*">;
21
- dependencies?: string[];
22
- devDependencies?: string[];
23
- baseFiles?: AssetMapping[];
24
- adapters?: Record<string, EnvironmentConfig>;
25
- environments?: Record<string, EnvironmentConfig>;
26
- }
27
- export interface RegistryManifest {
28
- version?: string;
29
- blocks?: Record<string, BlockManifest>;
30
- [blockKey: string]: unknown;
31
- }
32
- export declare function selectVariant(variantKeys: string[], preferredVariant?: string): string;
33
- export declare function resolvePreferredVariant(variantKeys: string[], recordedVariant: string | undefined, targetFolder: string): Promise<string | undefined>;
34
- export declare function parseDepSpec(dep: string): {
35
- name: string;
36
- versionRange: string | null;
37
- };
38
- export declare function semverSatisfies(installed: string, range: string): boolean;
39
- export declare function getVersionConflicts(deps: string[], installed: Record<string, string>): string[];
40
- export declare const getMissingDependencies: (deps: string[], installed: Record<string, string>, forceLatest?: boolean) => string[];
41
- export declare function rewriteFileImports(fileContent: string, writtenFilePath: string, blocksRoot: string, aliasBase: string | undefined, strategy: "rewrite" | "remove", downloadedFiles?: Set<string>): string;
42
1
  export declare function addCommand(blockName: string | undefined, options?: {
43
2
  yes?: boolean;
44
3
  json?: boolean;
@@ -2,26 +2,3 @@ export declare function initCommand(options?: {
2
2
  yes?: boolean;
3
3
  json?: boolean;
4
4
  }): Promise<void>;
5
- export interface InstalledBlockRecord {
6
- name: string;
7
- version: string;
8
- installedAt: string;
9
- files: string[];
10
- contentHash: string;
11
- variant?: string;
12
- }
13
- export type configPayloadType = {
14
- $schema: string;
15
- environment: "express" | "fastify" | "hono" | "next" | "none";
16
- language: "typescript" | "javascript";
17
- packageManager: string;
18
- importRewriteStrategy: "rewrite" | "remove";
19
- includeRedis: boolean;
20
- aliases: {
21
- blocks?: string;
22
- };
23
- paths: {
24
- blocks: string;
25
- };
26
- installed?: InstalledBlockRecord[];
27
- };
@@ -0,0 +1,2 @@
1
+ export declare function flattenTsPaths(paths: Record<string, string[]>): Record<string, string>;
2
+ export declare function deriveBlocksAlias(tsPaths: Record<string, string[]>, blocksPhysicalPath: string): string | undefined;
@@ -1,2 +1,5 @@
1
1
  import type { ProjectContext } from "../types/index.js";
2
- export declare function detectProject(cwd: string): Promise<ProjectContext>;
2
+ export interface DetectProjectOptions {
3
+ blocksDir?: string;
4
+ }
5
+ export declare function detectProject(cwd: string, options?: DetectProjectOptions): Promise<ProjectContext>;
@@ -7,4 +7,8 @@ export interface TsConfig {
7
7
  moduleResolution?: string;
8
8
  };
9
9
  }
10
- export declare function readTsConfig(cwd: string): Promise<TsConfig | null>;
10
+ export interface CompilerConfig {
11
+ kind: "tsconfig" | "jsconfig";
12
+ config: TsConfig;
13
+ }
14
+ export declare function readCompilerConfig(cwd: string): Promise<CompilerConfig | null>;