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

[feat] Ignore adapter build files #1924

Merged
merged 43 commits into from
Jul 29, 2021

Conversation

JeanJPNM
Copy link
Contributor

@JeanJPNM JeanJPNM commented Jul 16, 2021

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

Closes #1832 by adding a function to the utils parameter that lets adapters update a list of targeted files that use the same syntax as .gitignore
Closes #1581 as well

@changeset-bot
Copy link

changeset-bot bot commented Jul 16, 2021

🦋 Changeset detected

Latest commit: 445b992

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@JeanJPNM JeanJPNM marked this pull request as draft July 16, 2021 20:00
@JeanJPNM JeanJPNM marked this pull request as ready for review July 16, 2021 22:04
Copy link
Member

@antony antony left a comment

Choose a reason for hiding this comment

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

Looks good, but I think it could be simplified

packages/kit/src/core/adapt/utils.js Outdated Show resolved Hide resolved
packages/kit/src/core/adapt/utils.js Outdated Show resolved Hide resolved
packages/kit/src/core/adapt/utils.js Outdated Show resolved Hide resolved
packages/adapter-static/index.js Outdated Show resolved Hide resolved
@benmccann
Copy link
Member

The ideal in my mind would be to, on first run, present a prompt to the user that says something like "Going to add update your files. Continue? Yes / Later / Never" and then if "Yes" or "Never" then write to some file somewhere to let the adapter know it doesn't need to do the update anymore.

Biggest question in my mind is if we did that, where would it write to? We could create new Svelte projects with a file named .sveltesetup to indicate setup is not yet complete and then just delete it when the user says "Yes" or "Never"

@JeanJPNM
Copy link
Contributor Author

Maybe, but idk if its necessary since the function checks if there are patterns missing, and if they are they are added. It also takes in account commented lines to let the users comment out some patterns

@JeanJPNM
Copy link
Contributor Author

It can also be a problem if someone happens to change their adapter


/** @param {{patterns: string[], log?: boolean}} options */
update_ignores({ patterns, log = true }) {
const targets = ['.gitignore', '.prettierignore', '.eslintignore'];
Copy link
Member

Choose a reason for hiding this comment

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

Rather than update all three files, can we update just .gitignore and use it as input to prettier and eslint in the new project template? That's what this repo does if you want an example:

"lint": "eslint --ignore-path .gitignore --ignore-pattern \"src/core/make_package/test/**\" \"src/**/*.{ts,mjs,js,svelte}\" && npm run check-format",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure


/** @param {{patterns: string[], log?: boolean}} options */
update_ignores({ patterns, log = true }) {
const target = '.gitignore';
Copy link
Member

Choose a reason for hiding this comment

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

we should also update the templates to use .gitignore. It looks like eslint might already, but not prettier. https://github.com/sveltejs/kit/tree/master/packages/create-svelte/shared

@JeanJPNM
Copy link
Contributor Author

The current implementation makes the test apps have their .gitignore files updated, should I just commit them too or should I do something to prevent this behavior?

@benmccann
Copy link
Member

I'd say go ahead and update the test files. This is looking pretty good to me. Thanks for going through a few iterations on it!

@JeanJPNM
Copy link
Contributor Author

Since .gitignore is the only file that will be modified, should I rename the function from update_ignores to ignore_patterns or update_gitignore?

@benmccann
Copy link
Member

I think the name's fine

@benmccann benmccann merged commit 883d4b8 into sveltejs:master Jul 29, 2021
@JeanJPNM JeanJPNM deleted the adapter-file-ignore branch July 29, 2021 12:32
sidharthv96 added a commit to sidharthv96/kit that referenced this pull request Jul 31, 2021
…ePath

* 'master' of https://github.com/sveltejs/kit: (85 commits)
  [chore] minor simplification of `parse_body` (sveltejs#2043)
  Version Packages (next) (sveltejs#2026)
  [chore] deduplicate config types (sveltejs#2030)
  [chore] remove invalid css declaration (sveltejs#2038)
  [fix] correctly pass Vite options in preview mode (sveltejs#2036)
  [feat] Ignore adapter build files (sveltejs#1924)
  [chore] Upgrade Rollup
  Don't check external links on prerender (sveltejs#1679)
  Version Packages (next) (sveltejs#2017)
  [chore] convert remaining type aliases (sveltejs#2018)
  [feat] explicitly set compilerOptions.hydratable to config.kit.hydrate (sveltejs#2024)
  [feat] More powerful and configurable rendering options (sveltejs#2008)
  [chore] typecheck example (sveltejs#2019)
  Change config `prerender.force` to `prerender.onError` (sveltejs#2007)
  [chore] prefer interfaces to types (sveltejs#2010)
  [docs] minor wording improvement in migration guide (sveltejs#2006)
  [chore] test debugging improvements
  [docs] fix typo (sveltejs#2003)
  [chore] use @ts-expect-error instead of @ts-ignore (sveltejs#1999)
  Version Packages (next) (sveltejs#1996)
  ...
Rich-Harris added a commit that referenced this pull request Jul 31, 2021
benmccann added a commit that referenced this pull request Aug 1, 2021
@github-actions github-actions bot mentioned this pull request Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants