Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
- Always setup Data Connect SDK when FDC_CONNECTOR env var is set.
- `firebase init` now uses FIREBASE_PROJECT env var as the default project name.
- Add emulator support to firestore MCP tools. (#8700)
- Increased npm timeout for web frameworks to 60s. (#8702)
- Fallback to reading web framework dependencies version directly from node_modules package.json when the npm timeout is reached. (#8702)
2 changes: 1 addition & 1 deletion src/frameworks/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as clc from "colorette";
import * as experiments from "../experiments";

export const NPM_COMMAND_TIMEOUT_MILLIES = 10_000;
export const NPM_COMMAND_TIMEOUT_MILLIES = 60_000;

export const SupportLevelWarnings = {
[SupportLevel.Experimental]: (framework: string) => `Thank you for trying our ${clc.italic(
Expand Down Expand Up @@ -73,10 +73,10 @@

export const I18N_ROOT = "/";

export function GET_DEFAULT_BUILD_TARGETS() {

Check warning on line 76 in src/frameworks/constants.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment

Check warning on line 76 in src/frameworks/constants.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
return Promise.resolve(["production", "development"]);
}

export function DEFAULT_SHOULD_USE_DEV_MODE_HANDLE(target: string) {

Check warning on line 80 in src/frameworks/constants.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment

Check warning on line 80 in src/frameworks/constants.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
return Promise.resolve(target === "development");
}
12 changes: 9 additions & 3 deletions src/frameworks/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readJSON as originalReadJSON } from "fs-extra";
import { readJSON as originalReadJSON, readJsonSync } from "fs-extra";
import type { ReadOptions } from "fs-extra";
import { dirname, extname, join, relative } from "path";
import { readFile } from "fs/promises";
Expand All @@ -23,7 +23,7 @@

// Use "true &&"" to keep typescript from compiling this file and rewriting
// the import statement into a require
const { dynamicImport } = require(true && "../dynamicImport");

Check warning on line 26 in src/frameworks/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Require statement not part of import statement

Check warning on line 26 in src/frameworks/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

const NPM_ROOT_TIMEOUT_MILLIES = 5_000;
const NPM_ROOT_MEMO = new Map<string, string>();
Expand All @@ -40,7 +40,7 @@
*
* Note: `throws: false` won't work with the async function: https://github.com/jprichardson/node-fs-extra/issues/542
*/
export function readJSON<JsonType = any>(

Check warning on line 43 in src/frameworks/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
file: string,
options?: ReadOptions | BufferEncoding | string,
): Promise<JsonType> {
Expand All @@ -57,8 +57,8 @@
defaultBuildScripts: string[],
): Promise<void> {
const packageJsonBuffer = await readFile(join(dir, "package.json"));
const packageJson = JSON.parse(packageJsonBuffer.toString());

Check warning on line 60 in src/frameworks/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const buildScript = packageJson.scripts?.build;

Check warning on line 61 in src/frameworks/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .scripts on an `any` value

Check warning on line 61 in src/frameworks/utils.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

if (buildScript && !defaultBuildScripts.includes(buildScript)) {
console.warn(
Expand Down Expand Up @@ -290,8 +290,14 @@
{ cwd, env, timeout: NPM_COMMAND_TIMEOUT_MILLIES },
);
if (!result.stdout) return;
const json = JSON.parse(result.stdout.toString());
return scanDependencyTree(name, json.dependencies);
try {
const json = JSON.parse(result.stdout.toString());
return scanDependencyTree(name, json.dependencies);
} catch (e) {
// fallback to reading the version directly from package.json if npm list times out
const packageJson = readJsonSync(join(cwd, name, "package.json"), { throws: false });
return packageJson?.version ? { version: packageJson.version } : undefined;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we choose to use this, we might want to mimic npm list json structure here. Currently all places calling this function are only using the version, so I only implemented the version for now

}
}

export function relativeRequire(
Expand Down
Loading