@webflow/webflow-cli 1.21.0 → 1.22.0-next.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.
- package/dist/cloud-scaffolds/__tests__/fetcher.test.ts +249 -0
- package/dist/cloud-scaffolds/__tests__/registry.test.ts +134 -0
- package/dist/cloud-scaffolds/fetcher.ts +205 -0
- package/dist/cloud-scaffolds/index.ts +19 -0
- package/dist/cloud-scaffolds/registry.ts +132 -0
- package/dist/cloud-scaffolds/types.ts +68 -0
- package/dist/index.js +98 -82
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cloud-scaffolds/astro/README.md +0 -76
- package/dist/cloud-scaffolds/astro/astro.config.mjs +0 -27
- package/dist/cloud-scaffolds/astro/gitignore +0 -31
- package/dist/cloud-scaffolds/astro/package.json +0 -26
- package/dist/cloud-scaffolds/astro/public/favicon.svg +0 -9
- package/dist/cloud-scaffolds/astro/src/assets/astro.svg +0 -1
- package/dist/cloud-scaffolds/astro/src/assets/background.svg +0 -1
- package/dist/cloud-scaffolds/astro/src/components/Welcome.astro +0 -210
- package/dist/cloud-scaffolds/astro/src/env.d.ts +0 -12
- package/dist/cloud-scaffolds/astro/src/layouts/Layout.astro +0 -32
- package/dist/cloud-scaffolds/astro/src/pages/index.astro +0 -73
- package/dist/cloud-scaffolds/astro/tsconfig.json +0 -17
- package/dist/cloud-scaffolds/astro/webflow.json +0 -13
- package/dist/cloud-scaffolds/astro/worker-configuration.d.ts +0 -4
- package/dist/cloud-scaffolds/astro/wrangler.json +0 -14
- package/dist/cloud-scaffolds/nextjs/README.md +0 -47
- package/dist/cloud-scaffolds/nextjs/cloudflare-env.d.ts +0 -5
- package/dist/cloud-scaffolds/nextjs/eslint.config.mjs +0 -22
- package/dist/cloud-scaffolds/nextjs/gitignore +0 -47
- package/dist/cloud-scaffolds/nextjs/next.config.ts +0 -10
- package/dist/cloud-scaffolds/nextjs/open-next.config.ts +0 -9
- package/dist/cloud-scaffolds/nextjs/package.json +0 -34
- package/dist/cloud-scaffolds/nextjs/postcss.config.mjs +0 -5
- package/dist/cloud-scaffolds/nextjs/public/file.svg +0 -1
- package/dist/cloud-scaffolds/nextjs/public/globe.svg +0 -1
- package/dist/cloud-scaffolds/nextjs/public/next.svg +0 -1
- package/dist/cloud-scaffolds/nextjs/public/window.svg +0 -1
- package/dist/cloud-scaffolds/nextjs/src/app/favicon.ico +0 -0
- package/dist/cloud-scaffolds/nextjs/src/app/globals.css +0 -31
- package/dist/cloud-scaffolds/nextjs/src/app/layout.tsx +0 -44
- package/dist/cloud-scaffolds/nextjs/src/app/page.css +0 -45
- package/dist/cloud-scaffolds/nextjs/src/app/page.tsx +0 -30
- package/dist/cloud-scaffolds/nextjs/src/webflow.d.ts +0 -14
- package/dist/cloud-scaffolds/nextjs/tsconfig.json +0 -30
- package/dist/cloud-scaffolds/nextjs/webflow.json +0 -13
- package/dist/cloud-scaffolds/nextjs/wrangler.json +0 -14
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { FrameworkDefinition } from "./types";
|
|
2
|
+
import { ScaffoldError } from "./types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Central registry of supported framework scaffolds.
|
|
6
|
+
* To add a new framework: add one entry here.
|
|
7
|
+
*
|
|
8
|
+
* Scaffold versioning convention
|
|
9
|
+
* ------------------------------
|
|
10
|
+
* Each scaffold repo (`Webflow-Examples/hello-world-*`) carries a `vN` branch
|
|
11
|
+
* per breaking change in the scaffold contract — i.e. the shape of
|
|
12
|
+
* `webflow.json`, required config files, or anything else the CLI relies on
|
|
13
|
+
* being there. Branches are NOT bumped with every CLI major; only when we
|
|
14
|
+
* actually break the contract. Most CLI releases keep using the same `vN`.
|
|
15
|
+
*
|
|
16
|
+
* The CLI always pulls from the `vN` branch its code expects, so older CLI
|
|
17
|
+
* installs keep working forever.
|
|
18
|
+
*
|
|
19
|
+
* Workflow when introducing a breaking change in the scaffold contract:
|
|
20
|
+
* 1. Branch `vN+1` from `main` in each scaffold repo.
|
|
21
|
+
* 2. Apply the breaking change on `vN+1` (and on `main`, which tracks the
|
|
22
|
+
* latest stable version for humans browsing the repo on GitHub).
|
|
23
|
+
* 3. Bump every `ref` below from `vN` to `vN+1` in the CLI release that
|
|
24
|
+
* ships the breaking change.
|
|
25
|
+
*
|
|
26
|
+
* Old `vN` branches stay frozen — we don't backport fixes.
|
|
27
|
+
*/
|
|
28
|
+
export const FRAMEWORK_REGISTRY: Record<string, FrameworkDefinition> = {
|
|
29
|
+
"astro-minimal": {
|
|
30
|
+
id: "astro-minimal",
|
|
31
|
+
name: "Astro",
|
|
32
|
+
source: {
|
|
33
|
+
type: "github",
|
|
34
|
+
repo: "Webflow-Examples/hello-world-astro",
|
|
35
|
+
ref: "v1",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
"nextjs-minimal": {
|
|
39
|
+
id: "nextjs-minimal",
|
|
40
|
+
name: "Next.js",
|
|
41
|
+
source: {
|
|
42
|
+
type: "github",
|
|
43
|
+
repo: "Webflow-Examples/hello-world-nextjs",
|
|
44
|
+
ref: "v1",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
astro: {
|
|
48
|
+
id: "astro",
|
|
49
|
+
name: "Astro (site-attached)",
|
|
50
|
+
source: {
|
|
51
|
+
type: "github",
|
|
52
|
+
repo: "Webflow-Examples/hello-world-astro-devlink",
|
|
53
|
+
ref: "v1",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
nextjs: {
|
|
57
|
+
id: "nextjs",
|
|
58
|
+
name: "Next.js (site-attached)",
|
|
59
|
+
source: {
|
|
60
|
+
type: "github",
|
|
61
|
+
repo: "Webflow-Examples/hello-world-nextjs-devlink",
|
|
62
|
+
ref: "v1",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get framework definition by ID.
|
|
69
|
+
* @throws ScaffoldError if framework is not supported
|
|
70
|
+
*/
|
|
71
|
+
export function getFrameworkDefinition(
|
|
72
|
+
scaffoldId: string
|
|
73
|
+
): FrameworkDefinition {
|
|
74
|
+
const def = FRAMEWORK_REGISTRY[scaffoldId];
|
|
75
|
+
if (!def) {
|
|
76
|
+
const supported = Object.keys(FRAMEWORK_REGISTRY);
|
|
77
|
+
throw new ScaffoldError(
|
|
78
|
+
`Unsupported framework: "${scaffoldId}". Supported: ${supported.join(
|
|
79
|
+
", "
|
|
80
|
+
)}`,
|
|
81
|
+
scaffoldId,
|
|
82
|
+
supported
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return def;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* List all supported scaffold IDs (for --new mode).
|
|
90
|
+
*/
|
|
91
|
+
export function listSupportedScaffoldIds(): string[] {
|
|
92
|
+
return Object.keys(FRAMEWORK_REGISTRY);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* List framework names (without -minimal) for prompts.
|
|
97
|
+
* e.g. ["astro", "nextjs"] — deduplicated
|
|
98
|
+
*/
|
|
99
|
+
export function getAvailableFrameworkNames(): string[] {
|
|
100
|
+
return [
|
|
101
|
+
...new Set(
|
|
102
|
+
listSupportedScaffoldIds().map((id) => id.replace(/-minimal$/, ""))
|
|
103
|
+
),
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* List scaffold IDs for --existing mode (site-attached, full scaffolds).
|
|
109
|
+
*/
|
|
110
|
+
export function listExistingScaffoldIds(): string[] {
|
|
111
|
+
return ["astro", "nextjs"];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Map framework name (e.g. "astro") to scaffold ID (e.g. "astro-minimal").
|
|
116
|
+
* Used when user selects "astro" and we need the minimal scaffold.
|
|
117
|
+
*/
|
|
118
|
+
export function toMinimalScaffoldId(frameworkName: string): string {
|
|
119
|
+
const normalized = frameworkName.replace(/-minimal$/, "");
|
|
120
|
+
const scaffoldId = `${normalized}-minimal`;
|
|
121
|
+
if (!FRAMEWORK_REGISTRY[scaffoldId]) {
|
|
122
|
+
const supported = listSupportedScaffoldIds();
|
|
123
|
+
throw new ScaffoldError(
|
|
124
|
+
`No minimal scaffold for "${frameworkName}". Supported: ${supported.join(
|
|
125
|
+
", "
|
|
126
|
+
)}`,
|
|
127
|
+
scaffoldId,
|
|
128
|
+
supported
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
return scaffoldId;
|
|
132
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub-based scaffold source.
|
|
3
|
+
* Used when fetching from a public GitHub repository.
|
|
4
|
+
*/
|
|
5
|
+
export interface GitHubScaffoldSource {
|
|
6
|
+
type: "github";
|
|
7
|
+
/** Repository in "owner/repo" format */
|
|
8
|
+
repo: string;
|
|
9
|
+
/** Branch or tag. Default: "main" */
|
|
10
|
+
ref?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Local scaffold source.
|
|
15
|
+
* Used when reading from bundled scaffold directories.
|
|
16
|
+
*/
|
|
17
|
+
export interface LocalScaffoldSource {
|
|
18
|
+
type: "local";
|
|
19
|
+
/** Path to scaffold directory (relative to dist root or absolute) */
|
|
20
|
+
path: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Union of supported scaffold sources.
|
|
25
|
+
* Each variant has only the properties it needs — no optional repo on local.
|
|
26
|
+
* The `type` discriminant enables TypeScript narrowing.
|
|
27
|
+
*/
|
|
28
|
+
export type ScaffoldSource = GitHubScaffoldSource | LocalScaffoldSource;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Definition of a supported framework scaffold.
|
|
32
|
+
* Single entry point for adding new frameworks.
|
|
33
|
+
*/
|
|
34
|
+
export interface FrameworkDefinition {
|
|
35
|
+
/** Unique ID used in CLI (e.g. "astro-minimal", "nextjs-minimal") */
|
|
36
|
+
id: string;
|
|
37
|
+
/** Display name for prompts */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Where to fetch the scaffold content */
|
|
40
|
+
source: ScaffoldSource;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Result of fetching scaffold content.
|
|
45
|
+
* Used by applyScaffold to write files.
|
|
46
|
+
*/
|
|
47
|
+
export interface ScaffoldContent {
|
|
48
|
+
/** Scaffold identifier */
|
|
49
|
+
scaffoldId: string;
|
|
50
|
+
/** Absolute paths to scaffold files */
|
|
51
|
+
files: string[];
|
|
52
|
+
/** Root directory of the scaffold (for path resolution) */
|
|
53
|
+
extractionRoot: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Error thrown when a scaffold is not found or unsupported.
|
|
58
|
+
*/
|
|
59
|
+
export class ScaffoldError extends Error {
|
|
60
|
+
constructor(
|
|
61
|
+
message: string,
|
|
62
|
+
public readonly scaffoldId?: string,
|
|
63
|
+
public readonly supportedIds?: string[]
|
|
64
|
+
) {
|
|
65
|
+
super(message);
|
|
66
|
+
this.name = "ScaffoldError";
|
|
67
|
+
}
|
|
68
|
+
}
|