@webflow/cloud-app 0.1.0-beta.10
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/LICENSE +21 -0
- package/README.md +161 -0
- package/dist/bindings.d.ts +190 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +126 -0
- package/dist/bindings.js.map +1 -0
- package/dist/compat-date.d.ts +68 -0
- package/dist/compat-date.d.ts.map +1 -0
- package/dist/compat-date.js +169 -0
- package/dist/compat-date.js.map +1 -0
- package/dist/config/package-json.d.ts +57 -0
- package/dist/config/package-json.d.ts.map +1 -0
- package/dist/config/package-json.js +94 -0
- package/dist/config/package-json.js.map +1 -0
- package/dist/config/webflow-json.d.ts +47 -0
- package/dist/config/webflow-json.d.ts.map +1 -0
- package/dist/config/webflow-json.js +72 -0
- package/dist/config/webflow-json.js.map +1 -0
- package/dist/create-webflow-json.d.ts +21 -0
- package/dist/create-webflow-json.d.ts.map +1 -0
- package/dist/create-webflow-json.js +168 -0
- package/dist/create-webflow-json.js.map +1 -0
- package/dist/diagnostics.d.ts +23 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +31 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +23 -0
- package/dist/errors.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts +28 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js +148 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.d.ts +34 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.js +89 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.d.ts +39 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.js +93 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.js.map +1 -0
- package/dist/frameworks/astro/astro5.d.ts +28 -0
- package/dist/frameworks/astro/astro5.d.ts.map +1 -0
- package/dist/frameworks/astro/astro5.js +276 -0
- package/dist/frameworks/astro/astro5.js.map +1 -0
- package/dist/frameworks/astro/astro6.d.ts +28 -0
- package/dist/frameworks/astro/astro6.d.ts.map +1 -0
- package/dist/frameworks/astro/astro6.js +305 -0
- package/dist/frameworks/astro/astro6.js.map +1 -0
- package/dist/frameworks/astro/astro7.d.ts +28 -0
- package/dist/frameworks/astro/astro7.d.ts.map +1 -0
- package/dist/frameworks/astro/astro7.js +303 -0
- package/dist/frameworks/astro/astro7.js.map +1 -0
- package/dist/frameworks/astro/index.d.ts +10 -0
- package/dist/frameworks/astro/index.d.ts.map +1 -0
- package/dist/frameworks/astro/index.js +16 -0
- package/dist/frameworks/astro/index.js.map +1 -0
- package/dist/frameworks/astro/session-check.d.ts +24 -0
- package/dist/frameworks/astro/session-check.d.ts.map +1 -0
- package/dist/frameworks/astro/session-check.js +166 -0
- package/dist/frameworks/astro/session-check.js.map +1 -0
- package/dist/frameworks/astro/templates/astro.config.webflow.ts +61 -0
- package/dist/frameworks/astro/templates/v5/astro.config.mjs.template +25 -0
- package/dist/frameworks/astro/templates/v5/webflow-loader.ts +126 -0
- package/dist/frameworks/astro/templates/v5/wrangler.json +6 -0
- package/dist/frameworks/astro/templates/v6/astro.config.mjs.template +35 -0
- package/dist/frameworks/astro/templates/v6/webflow-loader.ts +126 -0
- package/dist/frameworks/astro/templates/v6/wrangler.json +9 -0
- package/dist/frameworks/astro/templates/v7/astro.config.mjs.template +34 -0
- package/dist/frameworks/astro/templates/v7/webflow-loader.ts +125 -0
- package/dist/frameworks/astro/templates/v7/wrangler.json +9 -0
- package/dist/frameworks/astro/templates/webflow-image-url.ts +140 -0
- package/dist/frameworks/base.d.ts +134 -0
- package/dist/frameworks/base.d.ts.map +1 -0
- package/dist/frameworks/base.js +175 -0
- package/dist/frameworks/base.js.map +1 -0
- package/dist/frameworks/errors.d.ts +72 -0
- package/dist/frameworks/errors.d.ts.map +1 -0
- package/dist/frameworks/errors.js +120 -0
- package/dist/frameworks/errors.js.map +1 -0
- package/dist/frameworks/nextjs/adapter-resolver.d.ts +72 -0
- package/dist/frameworks/nextjs/adapter-resolver.d.ts.map +1 -0
- package/dist/frameworks/nextjs/adapter-resolver.js +246 -0
- package/dist/frameworks/nextjs/adapter-resolver.js.map +1 -0
- package/dist/frameworks/nextjs/index.d.ts +38 -0
- package/dist/frameworks/nextjs/index.d.ts.map +1 -0
- package/dist/frameworks/nextjs/index.js +268 -0
- package/dist/frameworks/nextjs/index.js.map +1 -0
- package/dist/frameworks/nextjs/templates/next.config.ts.template +13 -0
- package/dist/frameworks/nextjs/templates/next.config.webflow.ts +46 -0
- package/dist/frameworks/nextjs/templates/open-next.config.ts +3 -0
- package/dist/frameworks/nextjs/templates/webflow-loader.ts +44 -0
- package/dist/frameworks/nextjs/templates/wrangler.json +6 -0
- package/dist/frameworks/registry.d.ts +127 -0
- package/dist/frameworks/registry.d.ts.map +1 -0
- package/dist/frameworks/registry.js +257 -0
- package/dist/frameworks/registry.js.map +1 -0
- package/dist/frameworks/static/index.d.ts +116 -0
- package/dist/frameworks/static/index.d.ts.map +1 -0
- package/dist/frameworks/static/index.js +394 -0
- package/dist/frameworks/static/index.js.map +1 -0
- package/dist/frameworks/static/templates/wrangler.json +8 -0
- package/dist/frameworks/types.d.ts +138 -0
- package/dist/frameworks/types.d.ts.map +1 -0
- package/dist/frameworks/types.js +3 -0
- package/dist/frameworks/types.js.map +1 -0
- package/dist/frameworks/vite/index.d.ts +46 -0
- package/dist/frameworks/vite/index.d.ts.map +1 -0
- package/dist/frameworks/vite/index.js +303 -0
- package/dist/frameworks/vite/index.js.map +1 -0
- package/dist/frameworks/vite/templates/vite.config.ts.template +14 -0
- package/dist/frameworks/vite/templates/vite.config.webflow.ts +52 -0
- package/dist/frameworks/vite/templates/wrangler.json +10 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +136 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline.d.ts +12 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +293 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/ports/command-runner.d.ts +59 -0
- package/dist/ports/command-runner.d.ts.map +1 -0
- package/dist/ports/command-runner.js +126 -0
- package/dist/ports/command-runner.js.map +1 -0
- package/dist/ports/filesystem.d.ts +19 -0
- package/dist/ports/filesystem.d.ts.map +1 -0
- package/dist/ports/filesystem.js +68 -0
- package/dist/ports/filesystem.js.map +1 -0
- package/dist/ports/index.d.ts +17 -0
- package/dist/ports/index.d.ts.map +1 -0
- package/dist/ports/index.js +14 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/ports/logger.d.ts +22 -0
- package/dist/ports/logger.d.ts.map +1 -0
- package/dist/ports/logger.js +18 -0
- package/dist/ports/logger.js.map +1 -0
- package/dist/ports/telemetry.d.ts +23 -0
- package/dist/ports/telemetry.d.ts.map +1 -0
- package/dist/ports/telemetry.js +12 -0
- package/dist/ports/telemetry.js.map +1 -0
- package/dist/static-base-href.d.ts +31 -0
- package/dist/static-base-href.d.ts.map +1 -0
- package/dist/static-base-href.js +183 -0
- package/dist/static-base-href.js.map +1 -0
- package/dist/toolchain/errors.d.ts +32 -0
- package/dist/toolchain/errors.d.ts.map +1 -0
- package/dist/toolchain/errors.js +31 -0
- package/dist/toolchain/errors.js.map +1 -0
- package/dist/toolchain/resolver.d.ts +25 -0
- package/dist/toolchain/resolver.d.ts.map +1 -0
- package/dist/toolchain/resolver.js +200 -0
- package/dist/toolchain/resolver.js.map +1 -0
- package/dist/toolchain/types.d.ts +52 -0
- package/dist/toolchain/types.d.ts.map +1 -0
- package/dist/toolchain/types.js +10 -0
- package/dist/toolchain/types.js.map +1 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fs.d.ts +29 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +126 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +27 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/node-version.d.ts +20 -0
- package/dist/utils/node-version.d.ts.map +1 -0
- package/dist/utils/node-version.js +113 -0
- package/dist/utils/node-version.js.map +1 -0
- package/dist/utils/process.d.ts +25 -0
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +40 -0
- package/dist/utils/process.js.map +1 -0
- package/dist/utils/reserved-env.d.ts +26 -0
- package/dist/utils/reserved-env.d.ts.map +1 -0
- package/dist/utils/reserved-env.js +51 -0
- package/dist/utils/reserved-env.js.map +1 -0
- package/dist/utils/template.d.ts +15 -0
- package/dist/utils/template.d.ts.map +1 -0
- package/dist/utils/template.js +75 -0
- package/dist/utils/template.js.map +1 -0
- package/dist/utils/version.d.ts +9 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +52 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/wrangler.d.ts +195 -0
- package/dist/wrangler.d.ts.map +1 -0
- package/dist/wrangler.js +372 -0
- package/dist/wrangler.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { BuildContext, BuildOutput, FrameworkInfo, PackageJson, WebflowJson, DetectionResult, AdapterPackage, IntegrationPackage, WebflowLoaderConfig, NodeVersionRequirement } from './types';
|
|
2
|
+
export declare abstract class FrameworkBuilder {
|
|
3
|
+
/**
|
|
4
|
+
* Canonical framework name (e.g. 'nextjs', 'astro', 'vite').
|
|
5
|
+
* Subclasses override this static field; matches `info.name` on the instance.
|
|
6
|
+
*/
|
|
7
|
+
static frameworkName: string;
|
|
8
|
+
protected ctx: BuildContext;
|
|
9
|
+
constructor(ctx: BuildContext);
|
|
10
|
+
/**
|
|
11
|
+
* Framework identification. Returns info about this specific framework and version.
|
|
12
|
+
*/
|
|
13
|
+
abstract get info(): FrameworkInfo;
|
|
14
|
+
/**
|
|
15
|
+
* Detect if this builder handles the project.
|
|
16
|
+
*
|
|
17
|
+
* Returns true if this builder can handle the project. Detection order in the
|
|
18
|
+
* registry determines precedence (first match wins).
|
|
19
|
+
*/
|
|
20
|
+
static detect(_packageJson: PackageJson, _webflowJson?: WebflowJson): DetectionResult;
|
|
21
|
+
/**
|
|
22
|
+
* Detect this framework from a built output directory.
|
|
23
|
+
*
|
|
24
|
+
* Used at deploy time when webflow.json may be missing (e.g. CLI-built
|
|
25
|
+
* output). Each framework recognizes its own bundled artifact signature
|
|
26
|
+
* inside `cwd`. Default returns false; frameworks that can be detected from
|
|
27
|
+
* output override.
|
|
28
|
+
*/
|
|
29
|
+
static detectFromBuiltOutput(_cwd: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Static deploy metadata: framework name + entrypoint + deployment type.
|
|
32
|
+
*
|
|
33
|
+
* Same shape as `getOutputDeployMetadata()` but callable without constructing
|
|
34
|
+
* a builder, so the deploy phase (which has no BuildContext) can use it.
|
|
35
|
+
*/
|
|
36
|
+
static getOutputDeployMetadata(): BuildOutput;
|
|
37
|
+
/**
|
|
38
|
+
* Validate that the project meets requirements for this framework.
|
|
39
|
+
*
|
|
40
|
+
* @throws FrameworkValidationError if validation fails
|
|
41
|
+
*/
|
|
42
|
+
abstract validate(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Install required dependencies that are missing. Should be idempotent.
|
|
45
|
+
*/
|
|
46
|
+
abstract installDependencies(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Prepare configuration files (astro.config, wrangler.json, etc.). Handles
|
|
49
|
+
* renaming user configs and merging with templates.
|
|
50
|
+
*/
|
|
51
|
+
abstract prepareConfig(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the build command to execute, e.g. "astro build",
|
|
54
|
+
* "opennextjs-cloudflare build". Returns null for frameworks with no build
|
|
55
|
+
* step (the no-framework static builder), in which case the host skips the
|
|
56
|
+
* build phase.
|
|
57
|
+
*/
|
|
58
|
+
abstract getBuildCommand(): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Instance accessor for deploy metadata. Wraps the static method on the
|
|
61
|
+
* concrete class so existing instance-based call sites keep working.
|
|
62
|
+
*/
|
|
63
|
+
getOutputDeployMetadata(): BuildOutput;
|
|
64
|
+
/** Get the wrangler template path for this framework. */
|
|
65
|
+
abstract getWranglerTemplatePath(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Get the Cloudflare adapter package to install. Returns null if the
|
|
68
|
+
* framework doesn't need one (e.g., pure SPA).
|
|
69
|
+
*/
|
|
70
|
+
abstract getCloudflareAdapter(): AdapterPackage | null;
|
|
71
|
+
/**
|
|
72
|
+
* Get Webflow-specific integrations required for Webflow component support.
|
|
73
|
+
* Installed in addition to user dependencies.
|
|
74
|
+
*/
|
|
75
|
+
abstract getRequiredIntegrations(): IntegrationPackage[];
|
|
76
|
+
/**
|
|
77
|
+
* Get the Webflow loader configuration for image optimization. Returns null
|
|
78
|
+
* if the framework doesn't need a loader.
|
|
79
|
+
*/
|
|
80
|
+
abstract getWebflowLoader(): WebflowLoaderConfig | null;
|
|
81
|
+
/**
|
|
82
|
+
* Get Node.js version requirements for this framework. Returns null if no
|
|
83
|
+
* specific version is required.
|
|
84
|
+
*/
|
|
85
|
+
abstract getNodeVersionRequirement(): NodeVersionRequirement | null;
|
|
86
|
+
/**
|
|
87
|
+
* Post-build hook for any cleanup or modifications. Called after the build
|
|
88
|
+
* command succeeds.
|
|
89
|
+
*/
|
|
90
|
+
postBuild(): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Get additional config files to copy (beyond webflow-loader). Returns an
|
|
93
|
+
* array of full paths to files that should be copied to the project root.
|
|
94
|
+
*/
|
|
95
|
+
getAdditionalConfigFiles(): string[];
|
|
96
|
+
/**
|
|
97
|
+
* Get patterns for user config files that need to be renamed, e.g.
|
|
98
|
+
* ['astro.config.mjs', 'astro.config.ts', 'astro.config.js'].
|
|
99
|
+
*/
|
|
100
|
+
getUserConfigPatterns(): string[];
|
|
101
|
+
/**
|
|
102
|
+
* Resolve the user's installed framework version from package.json, coerced
|
|
103
|
+
* to a valid semver string (e.g. "14.2.3"). Returns undefined when the
|
|
104
|
+
* package isn't in the user's deps or the version spec can't be coerced.
|
|
105
|
+
*
|
|
106
|
+
* Subclasses override to point at the correct npm package (`next`, `astro`,
|
|
107
|
+
* `vite`). The default returns undefined — when that happens the producer
|
|
108
|
+
* omits `framework_version` from webflow.json (the field is optional under
|
|
109
|
+
* the deploy contract).
|
|
110
|
+
*/
|
|
111
|
+
getFrameworkVersion(): string | undefined;
|
|
112
|
+
/** Check if a dependency exists in package.json (deps or devDeps). */
|
|
113
|
+
protected hasDependency(name: string): boolean;
|
|
114
|
+
/** Get a dependency version from package.json (deps or devDeps). */
|
|
115
|
+
protected getDependencyVersion(name: string): string | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Read a dependency's version spec from the user's package.json and coerce it
|
|
118
|
+
* to a valid semver string. Returns undefined when the package isn't installed
|
|
119
|
+
* or the spec doesn't coerce (e.g. `workspace:*`, `latest`, a git URL). Used
|
|
120
|
+
* by `getFrameworkVersion` overrides.
|
|
121
|
+
*/
|
|
122
|
+
protected resolveFrameworkVersion(pkgName: string): string | undefined;
|
|
123
|
+
/** Logger port from context. */
|
|
124
|
+
protected get log(): import("..").Logger;
|
|
125
|
+
/** Command-runner port from context. */
|
|
126
|
+
protected get runCommand(): import("..").CommandRunner;
|
|
127
|
+
/** Telemetry port from context. */
|
|
128
|
+
protected get telemetry(): import("..").Telemetry;
|
|
129
|
+
/** Filesystem port from context. */
|
|
130
|
+
protected get fs(): import("..").FileSystemPort;
|
|
131
|
+
/** Working directory (the build workspace) from context. */
|
|
132
|
+
protected get cwd(): string;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/frameworks/base.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,EACX,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AAEjB,8BAAsB,gBAAgB;IACpC;;;OAGG;IACH,MAAM,CAAC,aAAa,SAAM;IAE1B,SAAS,CAAC,GAAG,EAAE,YAAY,CAAC;gBAEhB,GAAG,EAAE,YAAY;IAQ7B;;OAEG;IACH,QAAQ,KAAK,IAAI,IAAI,aAAa,CAAC;IAEnC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,WAAW,GAAG,eAAe;IAIrF;;;;;;;OAOG;IACH,MAAM,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAInD;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,IAAI,WAAW;IAI7C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAE7C;;;OAGG;IACH,QAAQ,CAAC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAEvC;;;;;OAKG;IACH,QAAQ,CAAC,e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
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FrameworkBuilder = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Abstract base class for framework builders.
|
|
39
|
+
*
|
|
40
|
+
* Each framework (Astro, Next.js, Vite) extends this class to implement
|
|
41
|
+
* framework-specific build logic. The base is framework-agnostic and reaches
|
|
42
|
+
* the outside world only through the ports carried on `BuildContext`.
|
|
43
|
+
*/
|
|
44
|
+
const semver = __importStar(require("semver"));
|
|
45
|
+
class FrameworkBuilder {
|
|
46
|
+
/**
|
|
47
|
+
* Canonical framework name (e.g. 'nextjs', 'astro', 'vite').
|
|
48
|
+
* Subclasses override this static field; matches `info.name` on the instance.
|
|
49
|
+
*/
|
|
50
|
+
static frameworkName = '';
|
|
51
|
+
ctx;
|
|
52
|
+
constructor(ctx) {
|
|
53
|
+
this.ctx = ctx;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Detect if this builder handles the project.
|
|
57
|
+
*
|
|
58
|
+
* Returns true if this builder can handle the project. Detection order in the
|
|
59
|
+
* registry determines precedence (first match wins).
|
|
60
|
+
*/
|
|
61
|
+
static detect(_packageJson, _webflowJson) {
|
|
62
|
+
return { detected: false };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Detect this framework from a built output directory.
|
|
66
|
+
*
|
|
67
|
+
* Used at deploy time when webflow.json may be missing (e.g. CLI-built
|
|
68
|
+
* output). Each framework recognizes its own bundled artifact signature
|
|
69
|
+
* inside `cwd`. Default returns false; frameworks that can be detected from
|
|
70
|
+
* output override.
|
|
71
|
+
*/
|
|
72
|
+
static detectFromBuiltOutput(_cwd) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Static deploy metadata: framework name + entrypoint + deployment type.
|
|
77
|
+
*
|
|
78
|
+
* Same shape as `getOutputDeployMetadata()` but callable without constructing
|
|
79
|
+
* a builder, so the deploy phase (which has no BuildContext) can use it.
|
|
80
|
+
*/
|
|
81
|
+
static getOutputDeployMetadata() {
|
|
82
|
+
throw new Error('getOutputDeployMetadata must be implemented by the framework subclass');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Instance accessor for deploy metadata. Wraps the static method on the
|
|
86
|
+
* concrete class so existing instance-based call sites keep working.
|
|
87
|
+
*/
|
|
88
|
+
getOutputDeployMetadata() {
|
|
89
|
+
return this.constructor.getOutputDeployMetadata();
|
|
90
|
+
}
|
|
91
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
92
|
+
// OPTIONAL METHODS WITH DEFAULT IMPLEMENTATIONS
|
|
93
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
94
|
+
/**
|
|
95
|
+
* Post-build hook for any cleanup or modifications. Called after the build
|
|
96
|
+
* command succeeds.
|
|
97
|
+
*/
|
|
98
|
+
async postBuild() {
|
|
99
|
+
// Default: no-op
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get additional config files to copy (beyond webflow-loader). Returns an
|
|
103
|
+
* array of full paths to files that should be copied to the project root.
|
|
104
|
+
*/
|
|
105
|
+
getAdditionalConfigFiles() {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get patterns for user config files that need to be renamed, e.g.
|
|
110
|
+
* ['astro.config.mjs', 'astro.config.ts', 'astro.config.js'].
|
|
111
|
+
*/
|
|
112
|
+
getUserConfigPatterns() {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Resolve the user's installed framework version from package.json, coerced
|
|
117
|
+
* to a valid semver string (e.g. "14.2.3"). Returns undefined when the
|
|
118
|
+
* package isn't in the user's deps or the version spec can't be coerced.
|
|
119
|
+
*
|
|
120
|
+
* Subclasses override to point at the correct npm package (`next`, `astro`,
|
|
121
|
+
* `vite`). The default returns undefined — when that happens the producer
|
|
122
|
+
* omits `framework_version` from webflow.json (the field is optional under
|
|
123
|
+
* the deploy contract).
|
|
124
|
+
*/
|
|
125
|
+
getFrameworkVersion() {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
129
|
+
// PROTECTED HELPER METHODS
|
|
130
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
131
|
+
/** Check if a dependency exists in package.json (deps or devDeps). */
|
|
132
|
+
hasDependency(name) {
|
|
133
|
+
const { packageJson } = this.ctx;
|
|
134
|
+
return name in (packageJson.dependencies || {}) || name in (packageJson.devDependencies || {});
|
|
135
|
+
}
|
|
136
|
+
/** Get a dependency version from package.json (deps or devDeps). */
|
|
137
|
+
getDependencyVersion(name) {
|
|
138
|
+
const { packageJson } = this.ctx;
|
|
139
|
+
return packageJson.dependencies?.[name] || packageJson.devDependencies?.[name];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Read a dependency's version spec from the user's package.json and coerce it
|
|
143
|
+
* to a valid semver string. Returns undefined when the package isn't installed
|
|
144
|
+
* or the spec doesn't coerce (e.g. `workspace:*`, `latest`, a git URL). Used
|
|
145
|
+
* by `getFrameworkVersion` overrides.
|
|
146
|
+
*/
|
|
147
|
+
resolveFrameworkVersion(pkgName) {
|
|
148
|
+
const spec = this.getDependencyVersion(pkgName);
|
|
149
|
+
if (!spec)
|
|
150
|
+
return undefined;
|
|
151
|
+
return semver.coerce(spec)?.version;
|
|
152
|
+
}
|
|
153
|
+
/** Logger port from context. */
|
|
154
|
+
get log() {
|
|
155
|
+
return this.ctx.log;
|
|
156
|
+
}
|
|
157
|
+
/** Command-runner port from context. */
|
|
158
|
+
get runCommand() {
|
|
159
|
+
return this.ctx.runCommand;
|
|
160
|
+
}
|
|
161
|
+
/** Telemetry port from context. */
|
|
162
|
+
get telemetry() {
|
|
163
|
+
return this.ctx.telemetry;
|
|
164
|
+
}
|
|
165
|
+
/** Filesystem port from context. */
|
|
166
|
+
get fs() {
|
|
167
|
+
return this.ctx.fs;
|
|
168
|
+
}
|
|
169
|
+
/** Working directory (the build workspace) from context. */
|
|
170
|
+
get cwd() {
|
|
171
|
+
return this.ctx.cwd;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.FrameworkBuilder = FrameworkBuilder;
|
|
175
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/frameworks/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AW,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,oEAAoE;IAC1D,oBAAoB,CAAC,IAAY;QACzC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;QACjC,OAAO,WAAW,CAAC,YAAY,EAAE,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC;IACjF,CAAC;IAED;;;;;OAKG;IACO,uBAAuB,CAAC,OAAe;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI;YAAE,OAAO,SAAS,CAAC;QAC5B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACtC,CAAC;IAED,gCAAgC;IAChC,IAAc,GAAG;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,wCAAwC;IACxC,IAAc,UAAU;QACtB,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;IAC7B,CAAC;IAED,mCAAmC;IACnC,IAAc,SAAS;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;IAC5B,CAAC;IAED,oCAAoC;IACpC,IAAc,EAAE;QACd,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACrB,CAAC;IAED,4DAA4D;IAC5D,IAAc,GAAG;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACtB,CAAC;;AApNH,4CAqNC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error types for framework builders.
|
|
3
|
+
*
|
|
4
|
+
* These errors carry remediation hints, documentation links, and
|
|
5
|
+
* framework-specific context so hosts can render actionable failures.
|
|
6
|
+
*/
|
|
7
|
+
export interface FrameworkErrorOptions {
|
|
8
|
+
cause?: Error;
|
|
9
|
+
remediation?: string;
|
|
10
|
+
documentationUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Base error for all framework-related errors.
|
|
14
|
+
* Includes optional remediation hints and documentation links.
|
|
15
|
+
*/
|
|
16
|
+
export declare class FrameworkError extends Error {
|
|
17
|
+
readonly remediation?: string;
|
|
18
|
+
readonly documentationUrl?: string;
|
|
19
|
+
readonly cause?: unknown;
|
|
20
|
+
constructor(message: string, options?: FrameworkErrorOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Format the error for display, including remediation if available.
|
|
23
|
+
*/
|
|
24
|
+
toDisplayString(): string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Thrown when project validation fails.
|
|
28
|
+
*
|
|
29
|
+
* Examples:
|
|
30
|
+
* - Wrong Node.js version
|
|
31
|
+
* - Missing required dependencies
|
|
32
|
+
* - Invalid configuration
|
|
33
|
+
* - Unsupported framework version
|
|
34
|
+
*/
|
|
35
|
+
export declare class FrameworkValidationError extends FrameworkError {
|
|
36
|
+
constructor(message: string, options?: FrameworkErrorOptions);
|
|
37
|
+
}
|
|
38
|
+
export interface FrameworkBuildErrorOptions extends FrameworkErrorOptions {
|
|
39
|
+
buildCommand?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Thrown when the build command fails.
|
|
43
|
+
* Includes framework-specific debugging hints.
|
|
44
|
+
*/
|
|
45
|
+
export declare class FrameworkBuildError extends FrameworkError {
|
|
46
|
+
readonly buildCommand?: string;
|
|
47
|
+
constructor(message: string, options?: FrameworkBuildErrorOptions);
|
|
48
|
+
toDisplayString(): string;
|
|
49
|
+
}
|
|
50
|
+
export interface FrameworkConfigErrorOptions extends FrameworkErrorOptions {
|
|
51
|
+
configFile?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Thrown when configuration is invalid or cannot be processed.
|
|
55
|
+
*
|
|
56
|
+
* Examples:
|
|
57
|
+
* - Malformed astro.config.mjs
|
|
58
|
+
* - Invalid wrangler.json
|
|
59
|
+
* - Missing required config fields
|
|
60
|
+
*/
|
|
61
|
+
export declare class FrameworkConfigError extends FrameworkError {
|
|
62
|
+
readonly configFile?: string;
|
|
63
|
+
constructor(message: string, options?: FrameworkConfigErrorOptions);
|
|
64
|
+
toDisplayString(): string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Thrown when framework cannot be detected.
|
|
68
|
+
*/
|
|
69
|
+
export declare class FrameworkDetectionError extends FrameworkError {
|
|
70
|
+
constructor(message: string, options?: FrameworkErrorOptions);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/frameworks/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrC,SAAgB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1C,SAAyB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAE7B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAa5D;;OAEG;IACH,eAAe,IAAI,MAAM;CAU1B;AAMD;;;;;;;;GAQG;AACH,qBAAa,wBAAyB,SAAQ,cAAc;gBAC9C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;CAI7D;AAMD,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,SAAgB,YAAY,CAAC,EAAE,MAAM,CAAC;gBAE1B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B;IAMxD,eAAe,IAAI,MAAM;CAOnC;AAMD,MAAM,WAAW,2BAA4B,SAAQ,qBAAqB;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,cAAc;IACtD,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,2BAA2B;IAMzD,eAAe,IAAI,MAAM;CAOnC;AAMD;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,cAAc;gBAC7C,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;CAI7D"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom error types for framework builders.
|
|
4
|
+
*
|
|
5
|
+
* These errors carry remediation hints, documentation links, and
|
|
6
|
+
* framework-specific context so hosts can render actionable failures.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FrameworkDetectionError = exports.FrameworkConfigError = exports.FrameworkBuildError = exports.FrameworkValidationError = exports.FrameworkError = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Base error for all framework-related errors.
|
|
12
|
+
* Includes optional remediation hints and documentation links.
|
|
13
|
+
*/
|
|
14
|
+
class FrameworkError extends Error {
|
|
15
|
+
remediation;
|
|
16
|
+
documentationUrl;
|
|
17
|
+
cause;
|
|
18
|
+
constructor(message, options) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'FrameworkError';
|
|
21
|
+
this.cause = options?.cause;
|
|
22
|
+
this.remediation = options?.remediation;
|
|
23
|
+
this.documentationUrl = options?.documentationUrl;
|
|
24
|
+
// Maintains proper stack trace for where error was thrown (V8 engines)
|
|
25
|
+
if (Error.captureStackTrace) {
|
|
26
|
+
Error.captureStackTrace(this, this.constructor);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Format the error for display, including remediation if available.
|
|
31
|
+
*/
|
|
32
|
+
toDisplayString() {
|
|
33
|
+
let result = this.message;
|
|
34
|
+
if (this.remediation) {
|
|
35
|
+
result += `\n\nHow to fix: ${this.remediation}`;
|
|
36
|
+
}
|
|
37
|
+
if (this.documentationUrl) {
|
|
38
|
+
result += `\n\nDocumentation: ${this.documentationUrl}`;
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.FrameworkError = FrameworkError;
|
|
44
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
45
|
+
// Validation Error
|
|
46
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
47
|
+
/**
|
|
48
|
+
* Thrown when project validation fails.
|
|
49
|
+
*
|
|
50
|
+
* Examples:
|
|
51
|
+
* - Wrong Node.js version
|
|
52
|
+
* - Missing required dependencies
|
|
53
|
+
* - Invalid configuration
|
|
54
|
+
* - Unsupported framework version
|
|
55
|
+
*/
|
|
56
|
+
class FrameworkValidationError extends FrameworkError {
|
|
57
|
+
constructor(message, options) {
|
|
58
|
+
super(message, options);
|
|
59
|
+
this.name = 'FrameworkValidationError';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.FrameworkValidationError = FrameworkValidationError;
|
|
63
|
+
/**
|
|
64
|
+
* Thrown when the build command fails.
|
|
65
|
+
* Includes framework-specific debugging hints.
|
|
66
|
+
*/
|
|
67
|
+
class FrameworkBuildError extends FrameworkError {
|
|
68
|
+
buildCommand;
|
|
69
|
+
constructor(message, options) {
|
|
70
|
+
super(message, options);
|
|
71
|
+
this.name = 'FrameworkBuildError';
|
|
72
|
+
this.buildCommand = options?.buildCommand;
|
|
73
|
+
}
|
|
74
|
+
toDisplayString() {
|
|
75
|
+
let result = super.toDisplayString();
|
|
76
|
+
if (this.buildCommand) {
|
|
77
|
+
result += `\n\nBuild command: ${this.buildCommand}`;
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.FrameworkBuildError = FrameworkBuildError;
|
|
83
|
+
/**
|
|
84
|
+
* Thrown when configuration is invalid or cannot be processed.
|
|
85
|
+
*
|
|
86
|
+
* Examples:
|
|
87
|
+
* - Malformed astro.config.mjs
|
|
88
|
+
* - Invalid wrangler.json
|
|
89
|
+
* - Missing required config fields
|
|
90
|
+
*/
|
|
91
|
+
class FrameworkConfigError extends FrameworkError {
|
|
92
|
+
configFile;
|
|
93
|
+
constructor(message, options) {
|
|
94
|
+
super(message, options);
|
|
95
|
+
this.name = 'FrameworkConfigError';
|
|
96
|
+
this.configFile = options?.configFile;
|
|
97
|
+
}
|
|
98
|
+
toDisplayString() {
|
|
99
|
+
let result = super.toDisplayString();
|
|
100
|
+
if (this.configFile) {
|
|
101
|
+
result += `\n\nConfig file: ${this.configFile}`;
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.FrameworkConfigError = FrameworkConfigError;
|
|
107
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
108
|
+
// Detection Error
|
|
109
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
110
|
+
/**
|
|
111
|
+
* Thrown when framework cannot be detected.
|
|
112
|
+
*/
|
|
113
|
+
class FrameworkDetectionError extends FrameworkError {
|
|
114
|
+
constructor(message, options) {
|
|
115
|
+
super(message, options);
|
|
116
|
+
this.name = 'FrameworkDetectionError';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.FrameworkDetectionError = FrameworkDetectionError;
|
|
120
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/frameworks/errors.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAYH;;;GA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|
4
|
+
* `@opennextjs/cloudflare` declares a `next` peer dependency whose range moves
|
|
5
|
+
* with each release and sometimes carves out "dead zones" — Next.js versions
|
|
6
|
+
* that are newer than an old floor but excluded by a tighter upper bound (e.g.
|
|
7
|
+
* peer `>=15.5.18 <16 || >=16.2.6` excludes next@16.0.0–16.2.5). Installing the
|
|
8
|
+
* adapter with no version constraint always pulls the latest, so an app pinned
|
|
9
|
+
* inside a dead zone fails with a cryptic npm `ERESOLVE` before the build even
|
|
10
|
+
* starts.
|
|
11
|
+
*
|
|
12
|
+
* This module resolves the concrete Next.js version the app will install and
|
|
13
|
+
* picks the highest published adapter release whose peer range accepts it,
|
|
14
|
+
* pinning that version explicitly. When the version cannot be determined it
|
|
15
|
+
* signals a fallback to the previous "install latest" behaviour; when no
|
|
16
|
+
* release is compatible it raises an actionable error instead of letting npm
|
|
17
|
+
* fail opaquely.
|
|
18
|
+
*
|
|
19
|
+
* All metadata is read through the app's own npm configuration (`npm view` run
|
|
20
|
+
* in the app directory), so adapter selection and the subsequent install
|
|
21
|
+
* resolve against the same registry, scoped registry, and auth.
|
|
22
|
+
*/
|
|
23
|
+
import type { Logger } from '../../ports';
|
|
24
|
+
/** A published adapter version and the Next.js range it declares as a peer. */
|
|
25
|
+
export interface AdapterCandidate {
|
|
26
|
+
/** Concrete published version, e.g. "1.20.1". */
|
|
27
|
+
version: string;
|
|
28
|
+
/** Value of `peerDependencies.next`, or undefined if the version declares none. */
|
|
29
|
+
nextPeerRange?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* I/O the resolver depends on, injectable so unit tests can run without
|
|
33
|
+
* touching the network or the `npm` CLI. Both lookups take the app's `cwd` so
|
|
34
|
+
* they honor its npm configuration (registry, scoped registry, auth) — the same
|
|
35
|
+
* surface the subsequent install resolves against.
|
|
36
|
+
*/
|
|
37
|
+
export interface AdapterResolverIO {
|
|
38
|
+
/** Fetch every published adapter version and its `next` peer range. */
|
|
39
|
+
fetchAdapterCandidates: (adapterName: string, cwd: string) => Promise<AdapterCandidate[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a package.json version spec to the concrete Next.js version npm
|
|
42
|
+
* would install, or null when it cannot be determined (local/workspace/git
|
|
43
|
+
* specs, an empty spec, or no matching published version).
|
|
44
|
+
*/
|
|
45
|
+
resolveInstalledNextVersion: (nextSpec: string, cwd: string) => Promise<string | null>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Pick the highest stable adapter version whose declared `next` peer range is
|
|
49
|
+
* satisfied by `installedNext`.
|
|
50
|
+
*
|
|
51
|
+
* Versions that declare no `next` peer dependency are ignored: they predate the
|
|
52
|
+
* adapter pinning Next.js and silently installing one would mask a real
|
|
53
|
+
* incompatibility. Prerelease adapter versions are ignored too. Returns null
|
|
54
|
+
* when nothing matches.
|
|
55
|
+
*/
|
|
56
|
+
export declare function selectAdapterVersion(installedNext: string, candidates: AdapterCandidate[]): string | null;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve the adapter version to install for a project pinned to `nextSpec`,
|
|
59
|
+
* reading all metadata through the app's npm config at `cwd`.
|
|
60
|
+
*
|
|
61
|
+
* - Returns a concrete version string to pin when a compatible release exists.
|
|
62
|
+
* - Returns null when the Next.js version can't be determined or the metadata
|
|
63
|
+
* lookup fails — the caller should fall back to installing the latest adapter
|
|
64
|
+
* (the previous behaviour), which is no worse than before.
|
|
65
|
+
* - Throws {@link FrameworkValidationError} when the Next.js version is known
|
|
66
|
+
* but no published adapter release accepts it, surfacing a clear remediation
|
|
67
|
+
* instead of a downstream npm `ERESOLVE`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function resolveCompatibleAdapterVersion(log: Logger, adapterName: string, nextSpec: string, cwd: string, io?: AdapterResolverIO): Promise<string | null>;
|
|
70
|
+
/** Production I/O: `npm view` run in the app's cwd. */
|
|
71
|
+
export declare const defaultAdapterResolverIO: AdapterResolverIO;
|
|
72
|
+
//# sourceMappingURL=adapter-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-resolver.d.ts","sourceRoot":"","sources":["../../../src/frameworks/nextjs/adapter-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAc1C,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAC/B,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,sBAAsB,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC1F;;;;OAIG;IACH,2BAA2B,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACxF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,gBAAgB,EAAE,GAC7B,MAAM,GAAG,IAAI,CAaf;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,EACX,EAAE,GAAE,iBAA4C,GAC/C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmDxB;AA2HD,uDAAuD;AACvD,eAAO,MAAM,wBAAwB,EAAE,iBAGtC,CAAC"}
|