Skip to content

Commit

Permalink
chore: run npm format
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstork committed Jan 2, 2025
1 parent 7329416 commit 27f3cbd
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 50 deletions.
2 changes: 1 addition & 1 deletion packages/build-info/e2e/fixture/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/build-info/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
5 changes: 4 additions & 1 deletion packages/build-info/src/browser/file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { DirType, Environment, FileSystem } from '../file-system.js'

/** A sample implementation of a GitHub provider */
export class GithubProvider {
constructor(public repo: string, public branch?: string) {}
constructor(
public repo: string,
public branch?: string,
) {}

async dir(filePath = ''): Promise<{ path: string; type: 'file' | 'dir' }[]> {
let path = `/repos/${this.repo}/contents${filePath}`
Expand Down
6 changes: 5 additions & 1 deletion packages/build-info/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ export class Project {
return await this.fs.fileExists(this.fs.resolve(this.fs.cwd, 'redwood.toml'))
}

constructor(public fs: FileSystem, baseDirectory?: string, root?: string) {
constructor(
public fs: FileSystem,
baseDirectory?: string,
root?: string,
) {
this.baseDirectory = fs.resolve(root || '', baseDirectory !== undefined ? baseDirectory : fs.cwd)
this.root = root ? fs.resolve(fs.cwd, root) : undefined

Expand Down
4 changes: 2 additions & 2 deletions packages/build-info/src/workspaces/get-workspace-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export async function findPackages(
const startDir = project.jsWorkspaceRoot
? project.fs.resolve(project.jsWorkspaceRoot, dir)
: project.root
? project.fs.resolve(project.root, dir)
: project.fs.resolve(dir)
? project.fs.resolve(project.root, dir)
: project.fs.resolve(dir)
try {
content = await project.fs.readDir(startDir, true)
} catch (err) {
Expand Down
15 changes: 9 additions & 6 deletions packages/config/src/env/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,15 @@ const getGeneralEnv = async function ({
const getInternalEnv = function (
cachedEnv: Record<string, { sources: string[]; value: string }>,
): Record<string, string> {
return Object.entries(cachedEnv).reduce((prev, [key, { sources, value }]) => {
if (sources.includes('internal')) {
prev[key] = value
}
return prev
}, {} as Record<string, string>)
return Object.entries(cachedEnv).reduce(
(prev, [key, { sources, value }]) => {
if (sources.includes('internal')) {
prev[key] = value
}
return prev
},
{} as Record<string, string>,
)
}

const getDeployUrls = function ({
Expand Down
19 changes: 11 additions & 8 deletions packages/edge-bundler/node/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,17 @@ interface CreateFunctionConfigOptions {
}

const createFunctionConfig = ({ internalFunctionsWithConfig, declarations }: CreateFunctionConfigOptions) =>
Object.entries(internalFunctionsWithConfig).reduce((acc, [functionName, config]) => {
const mergedConfigFields = mergeWithDeclarationConfig({ functionName, config, declarations })

return {
...acc,
[functionName]: addGeneratorFallback(mergedConfigFields),
}
}, {} as Record<string, FunctionConfig>)
Object.entries(internalFunctionsWithConfig).reduce(
(acc, [functionName, config]) => {
const mergedConfigFields = mergeWithDeclarationConfig({ functionName, config, declarations })

return {
...acc,
[functionName]: addGeneratorFallback(mergedConfigFields),
}
},
{} as Record<string, FunctionConfig>,
)

interface VendorNPMOptions {
basePath: string
Expand Down
2 changes: 1 addition & 1 deletion packages/framework-info/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
Expand Down
2 changes: 1 addition & 1 deletion packages/zip-it-and-ship-it/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const getListedFunction = function ({
mainFile,
name,
runtime: runtime.name,
runtimeAPIVersion: staticAnalysisResult ? staticAnalysisResult?.runtimeAPIVersion ?? 1 : undefined,
runtimeAPIVersion: staticAnalysisResult ? (staticAnalysisResult?.runtimeAPIVersion ?? 1) : undefined,
schedule: staticAnalysisResult?.config?.schedule ?? config.schedule,
inputModuleFormat: staticAnalysisResult?.inputModuleFormat,
}
Expand Down
36 changes: 21 additions & 15 deletions packages/zip-it-and-ship-it/src/runtimes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,27 @@ export const getFunctionsFromPaths = async (
// through `findFunctionsInRuntime`. For each iteration, we collect all the
// functions found plus the list of paths that still need to be evaluated,
// using them as the input for the next iteration until the last runtime.
const { functions } = await RUNTIMES.reduce(async (aggregate, runtime) => {
const { functions: aggregateFunctions, remainingPaths: aggregatePaths } = await aggregate
const { functions: runtimeFunctions, remainingPaths: runtimePaths } = await findFunctionsInRuntime({
cache,
dedupe,
featureFlags,
paths: aggregatePaths,
runtime,
})

return {
functions: [...aggregateFunctions, ...runtimeFunctions],
remainingPaths: runtimePaths,
}
}, Promise.resolve({ functions: [], remainingPaths: paths } as { functions: FunctionTupleWithoutConfig[]; remainingPaths: string[] }))
const { functions } = await RUNTIMES.reduce(
async (aggregate, runtime) => {
const { functions: aggregateFunctions, remainingPaths: aggregatePaths } = await aggregate
const { functions: runtimeFunctions, remainingPaths: runtimePaths } = await findFunctionsInRuntime({
cache,
dedupe,
featureFlags,
paths: aggregatePaths,
runtime,
})

return {
functions: [...aggregateFunctions, ...runtimeFunctions],
remainingPaths: runtimePaths,
}
},
Promise.resolve({ functions: [], remainingPaths: paths } as {
functions: FunctionTupleWithoutConfig[]
remainingPaths: string[]
}),
)
const functionConfigs = await Promise.all(
functions.map(([, func]) => getConfigForFunction({ config, configFileDirectories, func })),
)
Expand Down
29 changes: 16 additions & 13 deletions packages/zip-it-and-ship-it/src/runtimes/node/parser/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,26 @@ const parseConfigESMExport = (node: Statement) => {
* and any others will be ignored and excluded from the resulting object.
*/
const parseObject = (node: ObjectExpression) =>
node.properties.reduce((acc, property): Record<string, unknown> => {
if (property.type === 'ObjectProperty' && property.key.type === 'Identifier') {
return {
...acc,
[property.key.name]: parsePrimitive(property.value),
node.properties.reduce(
(acc, property): Record<string, unknown> => {
if (property.type === 'ObjectProperty' && property.key.type === 'Identifier') {
return {
...acc,
[property.key.name]: parsePrimitive(property.value),
}
}
}

if (property.type === 'ObjectProperty' && property.key.type === 'StringLiteral') {
return {
...acc,
[property.key.value]: parsePrimitive(property.value),
if (property.type === 'ObjectProperty' && property.key.type === 'StringLiteral') {
return {
...acc,
[property.key.value]: parsePrimitive(property.value),
}
}
}

return acc
}, {} as Record<string, unknown>)
return acc
},
{} as Record<string, unknown>,
)

/**
* Takes an expression and, if it matches a JavaScript primitive type, returns
Expand Down

0 comments on commit 27f3cbd

Please sign in to comment.