1
0
mirror of https://github.com/webstudio-is/webstudio.git synced 2025-03-15 09:45:09 +00:00

chore: use console.info instead of console.log ()

## Description

We allow console.info (btw we should also allow warn/error/info), we
only disallow console.log in the linter because that's what we use for
debugging.

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @TrySound , I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
This commit is contained in:
Oleg Isonen
2024-03-24 12:52:46 +01:00
committed by GitHub
parent dc68851a5b
commit cd0174807d
40 changed files with 62 additions and 97 deletions
apps/builder
codemod
fixtures/webstudio-custom-template
app
custom-template-stage/app
packages
ai
bin
src/chains
command-detect
copywriter
template-generator
cli/src
css-data/bin
design-system/src/components/__DEPRECATED__
generate-arg-types/src
prisma-client
migrations-cli
prisma/migrations
20220905153337_noop
20220915144008_breakpoints-build_data
20230301134408_convert-background-to-layers
20231108172804_prop_expression
20240112011509_folders
20240131200102_page_meta_expressions
20240309212641_page_system_variable
src
project-build/src/db
react-sdk/src
scripts
trpc-interface/src/authorize

@ -164,7 +164,6 @@ export const fetchResult = async (
appliedOperations.add(JSON.stringify(operation));
}
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
}

@ -35,7 +35,6 @@ export const MediaRecorder = (options: { audioBitsPerSecond: number }) => {
const { start, stop, cancel, state } = useMediaRecorder(
{
onError: (error) => {
// eslint-disable-next-line no-console
console.error(error);
},
onComplete: (file) => {

@ -211,7 +211,6 @@ export const usePropsLogic = ({
const known = getAndDelete(unprocessedKnown, name);
if (known === undefined) {
// eslint-disable-next-line no-console
console.error(
`The prop "${name}" is defined in meta.initialProps but not in meta.props`
);

@ -15,8 +15,7 @@ export const PositionLayoutComponent = (
renderCell={() => <Cell />}
activeProperties={args.activeProperties}
onHover={(hoverProps) => {
// eslint-disable-next-line no-console
console.log(hoverProps);
console.info(hoverProps);
}}
/>
</Grid>

@ -815,7 +815,6 @@ export const useStyleInfoByInstanceId = (
instanceSelector !== undefined &&
isAncestorOrSelfOfSelectedInstance(instanceSelector) === false
) {
// eslint-disable-next-line no-console
console.error(
`The style works correctly only on ancestors of the selected element,
as our style data only includes information about these ancestors.

@ -226,14 +226,14 @@ const syncServer = async function () {
// It's usually ok to be here, probably restorable with retries
const text = await response.text();
// To investigate some strange errors we have seen
// eslint-disable-next-line no-console
console.info(`Non ok respone: ${text}`);
}
} catch (e) {
if (navigator.onLine) {
// ERR_CONNECTION_REFUSED or like, probably restorable with retries
// anyway lets's log it
// eslint-disable-next-line no-console
console.info(e instanceof Error ? e.message : JSON.stringify(e));
}
}

@ -85,8 +85,8 @@ const useElementsTree = (
if (typeof window === "undefined") {
// @todo remove after https://github.com/webstudio-is/webstudio/issues/1313 now its needed to be sure that no leaks exists
// eslint-disable-next-line no-console
console.log({
console.info({
$assets: $assets.get().size,
$pages: $pages.get()?.pages.length ?? 0,
$instances: $instances.get().size,

@ -122,7 +122,6 @@ export const Basic: StoryFn<typeof TextEditor> = ({ onChange }) => {
contentEditable={<ContentEditable />}
onChange={onChange}
onSelectInstance={(instanceId) =>
// eslint-disable-next-line no-console
console.info("select instance", instanceId)
}
/>

@ -75,8 +75,8 @@ export const loader = async ({
const diff = end - start;
// we need to log timings to figure out how to speed up loading
// eslint-disable-next-line no-console
console.log(`Project ${project.id} is loaded in ${diff}ms`);
console.info(`Project ${project.id} is loaded in ${diff}ms`);
const authToken = url.searchParams.get("authToken") ?? undefined;

@ -25,7 +25,6 @@ export const action = async ({ request }: ActionArgs) => {
if (response.ok === false) {
const message = await response.text();
// eslint-disable-next-line no-console
console.error("ERROR", response.status, message);
return {
@ -41,7 +40,6 @@ export const action = async ({ request }: ActionArgs) => {
const data = zTranscription.safeParse(await response.json());
if (data.success === false) {
// eslint-disable-next-line no-console
console.error("ERROR openai transcriptions", data.error);
}

@ -111,7 +111,6 @@ const getAction = (
};
return executeFn(getVariable, setVariable);
} catch (error) {
// eslint-disable-next-line no-console
console.error(error);
}
};

@ -37,8 +37,7 @@ export const sentryMessage = ({
}
if (skipLogging !== true) {
// eslint-disable-next-line no-console
console.log(message);
console.info(message);
}
};
@ -56,7 +55,6 @@ export const sentryException = ({
});
}
if (skipLogging !== true) {
// eslint-disable-next-line no-console
console.error(error);
}
};

@ -63,9 +63,8 @@ if (
}
if (errors.length) {
// eslint-disable-next-line no-console
console.error("❌ Invalid environment variables:");
// eslint-disable-next-line no-console
console.error(errors.join("\n"));
process.exit(1);
}

@ -215,7 +215,6 @@ const checkRateLimit = async (ctx, ratelimitName, key) => {
}
if (success === false) {
// eslint-disable-next-line no-console
console.warn(
`ratelimit triggered: [${ratelimitName}] limit=${limit}, reset=${reset}, remaining=${remaining} key=${key}`
);
@ -401,7 +400,6 @@ app.onError(async (err, ctx) => {
return err.getResponse();
}
// eslint-disable-next-line no-console
console.error(err.stack ?? err);
return ctx.json({ cause: err.cause, message: err.message });
@ -424,7 +422,6 @@ if (process.env.NODE_ENV !== "production") {
importedModule.then(({ serve }) => {
serve({ ...app, port: 3002 }, (info) => {
// eslint-disable-next-line no-console
console.info(`Listening on http://localhost:${info.port}`);
});
});

@ -31,7 +31,7 @@ const getRecursiveFileReads = async (dir: string) => {
const readDirectory = async (dir: string) => {
const results = await getRecursiveFileReads(dir);
console.log(results.length);
console.info(results.length);
return results;
};

@ -35,7 +35,6 @@ const logEvent = (
start: performance.now(),
});
// eslint-disable-next-line no-console
console.info(JSON.stringify({ name, params }));
};
@ -192,9 +191,8 @@ const sendToAnalitics: CLSReportCallbackWithAttribution &
params.debug_target_path = content;
}
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
// eslint-disable-next-line no-console
console.error(`selector: ${selector} seems like not working`);
}
}
@ -223,7 +221,6 @@ export const subscribe = () => {
try {
_isMobile = window.matchMedia("(hover: none)").matches;
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
}

@ -35,7 +35,6 @@ const logEvent = (
start: performance.now(),
});
// eslint-disable-next-line no-console
console.info(JSON.stringify({ name, params }));
};
@ -192,9 +191,8 @@ const sendToAnalitics: CLSReportCallbackWithAttribution &
params.debug_target_path = content;
}
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
// eslint-disable-next-line no-console
console.error(`selector: ${selector} seems like not working`);
}
}
@ -223,7 +221,6 @@ export const subscribe = () => {
try {
_isMobile = window.matchMedia("(hover: none)").matches;
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
}

@ -31,6 +31,6 @@ prompts.forEach((filePath) => {
.replace(/\$/g, "\\$"); // @todo technically we should escape only the $ that belong to template literals.;
fs.writeFileSync(generatedPath, `export const prompt = \`${content}\`;\n`);
// eslint-disable-next-line no-console
console.log(`Done generating argTypes for ${generatedPath}`);
console.info(`Done generating argTypes for ${generatedPath}`);
});

@ -39,7 +39,7 @@ export async function handler({ request }) {
if (result.succes === true) {
// An array of detected command names.
console.log(result.data);
console.info(result.data);
}
}
```

@ -90,7 +90,6 @@ export const createChain = <ModelMessageFormat>(): Chain<
};
}
// eslint-disable-next-line no-console
console.info(JSON.stringify({ prompt, detectedCommands }));
return {

@ -95,7 +95,7 @@ function UiComponent() {
signal: abort.current.signal,
onChunk: (id, { completion, done }) => {
// Log the completion.
console.log(completion)
console.info(completion)
if (done) {
doSomething(completion);
}
@ -161,7 +161,7 @@ useEffect(() => {
}
console.clear();
console.log(currenTextInstance);
console.info(currenTextInstance);
// patchTextInstance(currenTextInstance);
} catch (error) {
/**/

@ -77,7 +77,7 @@ function UiComponent() {
).then((response) => {
if (response.success) {
// Log the template
console.log(response.data);
console.info(response.data);
}
});
}}

@ -21,9 +21,9 @@ export const main = async () => {
if (err) {
throw err; // preserve stack
}
// eslint-disable-next-line no-console
console.error(msg);
// eslint-disable-next-line no-console
console.error(yargs.help());
process.exit(1);

@ -81,7 +81,7 @@ const backoff = (num: number) => {
for (let i = 0; i < newPropertiesNames.length; ) {
const properties = newPropertiesNames.slice(i, i + batchSize);
console.log(
console.info(
`[${Math.floor(i / batchSize) + 1}/${Math.ceil(
newPropertiesNames.length / batchSize
)}] Generating properties descriptions.`
@ -102,7 +102,7 @@ for (let i = 0; i < newPropertiesNames.length; ) {
if (Array.isArray(result)) {
// Retry
if (result[0] === 429) {
console.log(
console.info(
`❌ Error: 429 ${result[1]}. Retrying after sleep ${backoff(
retries
)}...`
@ -118,11 +118,11 @@ for (let i = 0; i < newPropertiesNames.length; ) {
const descriptions = grabDescriptions(result);
if (properties.length !== descriptions.length) {
console.log(
console.info(
"❌ Error: the number of generated descriptions does not match the amount of inputs. Retrying..."
);
console.log({ input: properties.join("\n"), output: result });
console.info({ input: properties.join("\n"), output: result });
continue;
}
@ -143,7 +143,7 @@ for (let i = 0; i < newPropertiesNames.length; ) {
i += batchSize;
}
console.log("\n✅ Properties description generated!\n");
console.info("\n✅ Properties description generated!\n");
/**
* Declarations descriptions
@ -216,7 +216,7 @@ for (let i = 0; i < newDeclarationsDescriptionsEntries.length; ) {
const list = batch.map(([descriptionKey, declaration]) => `- ${declaration}`);
console.log(
console.info(
`[${Math.floor(i / batchSize) + 1}/${Math.ceil(
newDeclarationsDescriptionsEntries.length / batchSize
)}] Generating declarations descriptions.`
@ -231,7 +231,7 @@ for (let i = 0; i < newDeclarationsDescriptionsEntries.length; ) {
if (Array.isArray(result)) {
// Retry
if (result[0] === 429) {
console.log(`❌ Error: 429 ${result[1]}. Retrying...`);
console.info(`❌ Error: 429 ${result[1]}. Retrying...`);
continue;
}
@ -241,11 +241,11 @@ for (let i = 0; i < newDeclarationsDescriptionsEntries.length; ) {
const descriptions = grabDescriptions(result);
if (list.length !== descriptions.length) {
console.log(
console.info(
"❌ Error: the number of generated descriptions does not match the amount of inputs. Retrying..."
);
console.log({ input: list.join("\n"), output: result });
console.info({ input: list.join("\n"), output: result });
continue;
}
@ -262,7 +262,7 @@ for (let i = 0; i < newDeclarationsDescriptionsEntries.length; ) {
description.replace("{color}", color);
});
} else {
console.log(
console.info(
`❌ Error: Expanding the colors for ${descriptionKey} failed because we couldn't find it in propertyColors. Skipping...`
);
}
@ -283,8 +283,8 @@ for (let i = 0; i < newDeclarationsDescriptionsEntries.length; ) {
i += batchSize;
}
console.log("\n✅ Declarations description generated!\n");
console.log("✨ Done.");
console.info("\n✅ Declarations description generated!\n");
console.info("✨ Done.");
function writeFile(descriptions: Record<string, unknown>) {
const autogeneratedHint = "// This file was auto-generated\n";

@ -166,7 +166,6 @@ export const Interactive: ComponentStory<typeof DeprecatedTextField> = () => {
/>
<Button
onClick={() => {
// eslint-disable-next-line no-console
setValue(JSON.stringify(wrapperRef.current?.getBoundingClientRect()));
}}
>

@ -115,8 +115,7 @@ export const getArgType = (propItem: PropItem): PropMeta | undefined => {
return;
}
} catch (error) {
// eslint-disable-next-line no-console
console.log("Error while parsing prop:", propItem);
console.info("Error while parsing prop:", propItem);
throw error;
}
};

@ -44,9 +44,9 @@ if (typeof componentsGlobString === "undefined") {
const globs = componentsGlobString.split(" ");
const componentFiles = fg.sync(globs);
console.log(`Resolved tscofig.json at ${tsConfigPath}\n`);
console.log(`Glob patterns used: \n${globs.join("\n")}\n`);
console.log(`Found files to process: \n${componentFiles.join("\n")}\n`);
console.info(`Resolved tscofig.json at ${tsConfigPath}\n`);
console.info(`Glob patterns used: \n${globs.join("\n")}\n`);
console.info(`Found files to process: \n${componentFiles.join("\n")}\n`);
if (componentFiles.length === 0) {
throw new Error("No component files found");
@ -146,6 +146,6 @@ type CustomDescriptionsType = {
mkdirSync(generatedDir, { recursive: true });
writeFileSync(generatedPath, fileContent);
console.log(`Done generating argTypes for ${generatedPath}`);
console.info(`Done generating argTypes for ${generatedPath}`);
}
})();

@ -1,6 +1,6 @@
/* eslint-disable no-console */
// When you're adding a log for debugging use console.log as normal.
// When you're adding a log for debugging use console.info as normal.
// Use logger only for CLI output.
export const info = (message: unknown) => {
@ -16,5 +16,5 @@ export const warn = (message: unknown) => {
};
export const debug = (message: unknown) => {
console.log(message);
console.info(message);
};

@ -5,7 +5,6 @@ export default () => {
return client.$transaction(async (prisma) => {
const usersCount = await prisma.user.count();
// eslint-disable-next-line no-console
console.log("Example noop migration test", { usersCount });
console.info("Example noop migration test", { usersCount });
});
};

@ -37,7 +37,7 @@ export default () => {
// );
// if (build === undefined) {
// // eslint-disable-next-line no-console
//
// console.warn(
// `Build not found for breakpoint ${breakpoint.treeId}. Deleting!`
// );
@ -62,7 +62,6 @@ export default () => {
);
if (build === undefined) {
// eslint-disable-next-line no-console
console.warn(
`Build not found for breakpoint ${breakpoint.treeId}. Deleting!`
);
@ -71,8 +70,7 @@ export default () => {
where: { treeId: breakpoint.treeId },
});
} else {
// eslint-disable-next-line no-console
console.log(`Updating breakpoint ${breakpoint.treeId}`);
console.info(`Updating breakpoint ${breakpoint.treeId}`);
await prisma.breakpoints.update({
where: { treeId: breakpoint.treeId },
data: {

@ -193,7 +193,6 @@ export default () => {
value: [style.value],
};
} else {
// eslint-disable-next-line no-console
console.warn("unsupported style value", style.value);
}
}

@ -70,7 +70,7 @@ export default async () => {
let hasNext = true;
while (hasNext) {
console.log("CHUNK", cursor);
console.info("CHUNK", cursor);
console.time("read");
const cursorOptions: {} = cursor
@ -179,7 +179,7 @@ export default async () => {
}
}
console.timeEnd("parse-change");
console.log("changedBuilds.length", changedBuilds.length);
console.info("changedBuilds.length", changedBuilds.length);
console.time("update");
const sql = `
@ -202,7 +202,7 @@ export default async () => {
);
console.timeEnd("update");
console.log("res", res);
console.info("res", res);
}
},
{ timeout: 3600000 }

@ -13,7 +13,7 @@ export default async () => {
let hasNext = true;
while (hasNext) {
console.log("CHUNK", cursor);
console.info("CHUNK", cursor);
console.time("read");
const cursorOptions: {} = cursor
@ -75,7 +75,7 @@ export default async () => {
}
console.timeEnd("parse-change");
console.log("changedBuilds.length", changedBuilds.length);
console.info("changedBuilds.length", changedBuilds.length);
console.time("update");
const sql = `
@ -93,7 +93,7 @@ export default async () => {
);
console.timeEnd("update");
console.log("res", res);
console.info("res", res);
}
},
{ timeout: 3600000 }

@ -85,7 +85,7 @@ export default async () => {
let hasNext = true;
while (hasNext) {
console.log("CHUNK", cursor);
console.info("CHUNK", cursor);
console.time("read");
const cursorOptions: {} = cursor
@ -138,7 +138,7 @@ export default async () => {
}
}
console.timeEnd("parse-change");
console.log("changedBuilds.length", changedBuilds.length);
console.info("changedBuilds.length", changedBuilds.length);
console.time("update");
const sql = `
@ -159,7 +159,7 @@ export default async () => {
);
console.timeEnd("update");
console.log("res", res);
console.info("res", res);
}
},
{ timeout: 3600000 }

@ -55,7 +55,7 @@ export default async () => {
let hasNext = true;
while (hasNext) {
console.log("CHUNK", cursor);
console.info("CHUNK", cursor);
console.time("read");
const cursorOptions: {} = cursor
@ -120,7 +120,7 @@ export default async () => {
}
console.timeEnd("parse-change");
console.log("changedBuilds.length", changedBuilds.length);
console.info("changedBuilds.length", changedBuilds.length);
console.time("update");
const sql = `
@ -140,7 +140,7 @@ export default async () => {
);
console.timeEnd("update");
console.log("res", res);
console.info("res", res);
}
},
{ timeout: 3600000 }

@ -46,8 +46,8 @@ export const prisma =
prisma.$on("query", (e) => {
// Try to minify the query as vercel/new relic log size is limited
// eslint-disable-next-line no-console
console.log(
console.info(
"Query: " +
e.query
.replace(/"public"\./g, "")
@ -57,10 +57,9 @@ prisma.$on("query", (e) => {
.replace(/"Asset"\./g, "")
);
// eslint-disable-next-line no-console
console.log("Params: " + e.params.slice(0, 200));
// eslint-disable-next-line no-console
console.log("Duration: " + e.duration + "ms");
console.info("Params: " + e.params.slice(0, 200));
console.info("Duration: " + e.duration + "ms");
});
if (process.env.NODE_ENV !== "production") {

@ -55,7 +55,6 @@ export const serializeConfig = <Type>(data: Type) => {
};
const parseBuild = async (build: DbBuild): Promise<Build> => {
// eslint-disable-next-line no-console
console.time("parseBuild");
try {
const pages = parsePages(build.pages);
@ -87,7 +86,6 @@ const parseBuild = async (build: DbBuild): Promise<Build> => {
} satisfies Data["build"] & { marketplaceProduct: MarketplaceProduct };
return result;
} finally {
// eslint-disable-next-line no-console
console.timeEnd("parseBuild");
}
};

@ -62,7 +62,7 @@ const generateAction = ({
const valueName = scope.getName(dep.id, dep.name);
return valueName;
}
// eslint-disable-next-line no-console
console.error(`Unknown dependency "${identifier}"`);
},
});

@ -82,9 +82,7 @@ if (noGeneratedAsEntries) {
}
if (watch) {
// eslint-disable-next-line no-console
console.info("watching...");
} else {
// eslint-disable-next-line no-console
console.info("build succeeded");
}

@ -110,8 +110,7 @@ export const hasProjectPermit = async (
} finally {
const diff = Date.now() - start;
// eslint-disable-next-line no-console
console.log(`hasProjectPermit execution ${diff}ms`);
console.info(`hasProjectPermit execution ${diff}ms`);
}
};
@ -150,7 +149,6 @@ export const getProjectPermit = async <T extends AuthPermit>(
} finally {
const diff = Date.now() - start;
// eslint-disable-next-line no-console
console.log(`getProjectPermit execution ${diff}ms`);
console.info(`getProjectPermit execution ${diff}ms`);
}
};