-
Notifications
You must be signed in to change notification settings - Fork 955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add supported range warnings #6562
Changes from all commits
d3585da
cfd1f99
333be70
a489204
fea89fb
4acd742
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
- Fixed an issue preventing Angular apps using ng-deploy from being emulated or deployed. (#6584) | ||
- Warn if a Web Framework is outside a well known version range on deploy/emulate. (#6562) | ||
- Use Web Framework's well known version range in `firebase init hosting`. (#6562) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { readFile } from "fs/promises"; | |
import { IncomingMessage, request as httpRequest, ServerResponse, Agent } from "http"; | ||
import { sync as spawnSync } from "cross-spawn"; | ||
import * as clc from "colorette"; | ||
import { satisfies as semverSatisfied } from "semver"; | ||
|
||
import { logger } from "../logger"; | ||
import { FirebaseError } from "../error"; | ||
|
@@ -360,21 +361,36 @@ export function relativeRequire(dir: string, mod: string) { | |
} | ||
} | ||
|
||
export function conjoinOptions( | ||
opts: any[], | ||
conjunction: string = "and", | ||
separator: string = "," | ||
): string | undefined { | ||
if (!opts.length) return; | ||
if (opts.length === 1) return opts[0].toString(); | ||
if (opts.length === 2) return `${opts[0].toString()} ${conjunction} ${opts[1].toString()}`; | ||
const lastElement = opts.slice(-1)[0].toString(); | ||
const allButLast = opts.slice(0, -1).map((it) => it.toString()); | ||
export function conjoinOptions(_opts: any[], conjunction = "and", separator = ","): string { | ||
if (!_opts.length) return ""; | ||
const opts: string[] = _opts.map((it) => it.toString().trim()); | ||
if (opts.length === 1) return opts[0]; | ||
if (opts.length === 2) return `${opts[0]} ${conjunction} ${opts[1]}`; | ||
const lastElement = opts.slice(-1)[0]; | ||
const allButLast = opts.slice(0, -1); | ||
return `${allButLast.join(`${separator} `)}${separator} ${conjunction} ${lastElement}`; | ||
} | ||
|
||
export function frameworksCallToAction(message: string, docsUrl = DEFAULT_DOCS_URL, prefix = "") { | ||
return `${prefix}${message} | ||
export function frameworksCallToAction( | ||
message: string, | ||
docsUrl = DEFAULT_DOCS_URL, | ||
prefix = "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe prefix could be handled internally in the function based on the params? e.g.: const prefix = framework ? " " : ""; just thinking about reducing the parameters here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'll refactor this in a follow on |
||
framework?: string, | ||
version?: string, | ||
supportedRange?: string, | ||
vite = false | ||
): string { | ||
return `${prefix}${message}${ | ||
framework && supportedRange && (!version || !semverSatisfied(version, supportedRange)) | ||
? clc.yellow( | ||
`\n${prefix}The integration is known to work with ${ | ||
vite ? "Vite" : framework | ||
} version ${clc.italic( | ||
conjoinOptions(supportedRange.split("||")) | ||
)}. You may encounter errors.` | ||
) | ||
: `` | ||
} | ||
|
||
${prefix}${clc.bold("Documentation:")} ${docsUrl} | ||
${prefix}${clc.bold("File a bug:")} ${FILE_BUG_URL} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sveltekit should probably have it's own supported range
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed but maybe after 2.0 is released? It seems like it won't be released anytime soon: https://github.com/sveltejs/kit/milestone/5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough