Skip to content
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

Adapter build outputs are linted, formatted, and synced to Git #1832

Closed
Nick-Mazuk opened this issue Jul 5, 2021 · 4 comments · Fixed by #1924
Closed

Adapter build outputs are linted, formatted, and synced to Git #1832

Nick-Mazuk opened this issue Jul 5, 2021 · 4 comments · Fixed by #1924

Comments

@Nick-Mazuk
Copy link
Contributor

Describe the bug

Build outputs to the adapters are not in the .eslintignore, .prettierignore, and .gitignore by default. This means they are linted, formatted, and checked into version control by default. I suspect this is not desired behavior for most people.

To Reproduce

  • Create any new Sveltekit project
  • Add an adapter (e.g., adapter-vercel)
  • pnpm build
  • Running pnpm lint, pnpm format, or git add . will now also include these new build outputs

To fix, you can just add the build output to the relevant ignore files. I think they should be there by default.

I can provide a reproduction repo, stack traces, etc. if needed, but I think the issue is fairly self-explanatory.

Expected behavior

By default, these files should not be linted, formatted, or checked into version control.

Severity

Honestly, not that severe. It's a ~30 second fix for anyone creating a Svekte/kit project. But the bug fix would also be a ~30 second fix as well.

@benmccann
Copy link
Member

Each adapter needs to ignore a different set of files. There was a standard set of files originally in the .gitignore but they ended up being removed to support the Firebase adapter. There's a ticket discussing it somewhere, but we were leaning towards having each adapter be responsible for adding the files it creates to .gitignore

@Mlocik97
Copy link
Contributor

Mlocik97 commented Jul 6, 2021

What if Adapter would internally generate/modify .gitignore ? It can be good feature?

@benmccann
Copy link
Member

benmccann commented Jul 6, 2021

Yes, what I just said in my previous comment was that the adapter could modify .gitignore

@JeanJPNM
Copy link
Contributor

JeanJPNM commented Jul 14, 2021

We could put something like this inside adapter-utils.js to let the adapters have a standart way to change .gitignore

/** Adds glob patterns to the
 * @param {object} options
 * @param {string[]} options.patterns An array of glob patterns to be inserted into the project's `.gitignore` file
 * @param {boolean} [options.generate] Whether the `.gitignore` file should be created if it doesn't exist
 * @param {string} options.name The name of the adapter
 */
export async function addToGitIgnore({ patterns, generate = false, name }) {
	const path = '.gitignore';
	const { existsSync } = await import('fs');
	const { readFile, writeFile, appendFile } = await import('fs/promises');
	if (!existsSync(path)) {
		if (!generate) return;
		await writeFile(path, '');
	}
	const file = await readFile(path, {
		encoding: 'utf-8'
	});
	if (file.includes(`# Generated by ${name}`)) return;
	const text = `\n# Generated by ${name}\n${patterns.join('\n')}`;
	await appendFile(path, text);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants