8000 chore: make `text` the default `contentType` by benmccann · Pull Request #72 · sveltejs/cli · GitHub
[go: up one dir, main page]

Skip to content

chore: make text the default contentType #72

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

Merged
merged 5 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion community-adder-template/src/config/adder.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const adder = defineAdderConfig({
files: [
{
name: () => 'adder-template-demo.txt',
contentType: 'text',
content: ({ content, options }) => {
if (options.demo) {
return 'This is a text file made by the Community Adder Template demo!';
Expand Down
4 changes: 0 additions & 4 deletions packages/adders/drizzle/config/adder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@ export const adder = defineAdderConfig({
files: [
{
name: () => '.env',
contentType: 'text',
content: generateEnvFileContent
},
{
name: () => '.env.example',
contentType: 'text',
content: generateEnvFileContent
},
{
name: () => 'docker-compose.yml',
contentType: 'text',
condition: ({ options }) =>
options.docker && (options.mysql === 'mysql2' || options.postgresql === 'postgres.js'),
content: ({ content, options }) => {
Expand Down Expand Up @@ -142,7 +139,6 @@ export const adder = defineAdderConfig({
{
// Adds the db file to the gitignore if an ignore is present
name: () => '.gitignore',
contentType: 'text',
condition: ({ options }) => options.database === 'sqlite',
content: ({ content }) => {
if (content.length === 0) return content;
Expand Down
1 change: 0 additions & 1 deletion packages/adders/drizzle/config/tests.ts
8000
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const tests = defineAdderTests({
{
// override the config so we can remove strict mode
name: ({ typescript }) => `drizzle.config.${typescript ? 'ts' : 'js'}`,
contentType: 'text',
condition: ({ kit }) => Boolean(kit),
content: ({ content }) => {
return content.replace('strict: true,', '');
Expand Down
4 changes: 0 additions & 4 deletions packages/adders/lucia/config/adder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,6 @@ export const adder = defineAdderConfig({
name: ({ kit, typescript }) =>
`${kit!.routesDirectory}/demo/login/+page.server.${typescript ? 'ts' : 'js'}`,
condition: ({ options }) => options.demo,
contentType: 'text',
content({ content, typescript }) {
if (content) {
log.warn(
Expand Down Expand Up @@ -622,7 +621,6 @@ export const adder = defineAdderConfig({
{
name: ({ kit }) => `${kit!.routesDirectory}/demo/login/+page.svelte`,
condition: ({ options }) => options.demo,
contentType: 'text',
content({ content, typescript }) {
if (content) {
log.warn(`Existing ${colors.yellow('/demo/login/+page.svelte')} file. Could not update.`);
Expand Down Expand Up @@ -660,7 +658,6 @@ export const adder = defineAdderConfig({
name: ({ kit, typescript }) =>
`${kit!.routesDirectory}/demo/+page.server.${typescript ? 'ts' : 'js'}`,
condition: ({ options }) => options.demo,
contentType: 'text',
content({ content, typescript }) {
if (content) {
log.warn(
Expand Down Expand Up @@ -704,7 +701,6 @@ export const adder = defineAdderConfig({
{
name: ({ kit }) => `${kit!.routesDirectory}/demo/+page.svelte`,
condition: ({ options }) => options.demo,
contentType: 'text',
content({ content, typescript }) {
if (content) {
log.warn(`Existing ${colors.yellow('/demo/+page.svelte')} file. Could not update.`);
Expand Down
2 changes: 0 additions & 2 deletions packages/adders/mdsvex/config/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ export const tests = defineAdderTests({
},
{
name: ({ kit }) => `${kit?.routesDirectory}/Demo.svx`,
contentType: 'text',
content: addMarkdownFile,
condition: ({ kit }) => Boolean(kit)
},
{
name: () => 'src/Demo.svx',
contentType: 'text',
content: addMarkdownFile,
condition: ({ kit }) => !kit
}
Expand Down
2 changes: 0 additions & 2 deletions packages/adders/playwright/config/adder.ts
6D40
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const adder = defineAdderConfig({
},
{
name: () => '.gitignore',
contentType: 'text',
condition: ({ cwd }) => fs.existsSync(join(cwd, '.gitignore')),
content: ({ content }) => {
if (content.includes('test-results')) return content;
Expand All @@ -44,7 +43,6 @@ export const adder = defineAdderConfig({
},
{
name: ({ typescript }) => `e2e/demo.test.${typescript ? 'ts' : 'js'}`,
contentType: 'text',
content: ({ content }) => {
if (content) return content;

Expand Down
1 change: 0 additions & 1 deletion packages/adders/prettier/config/adder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const adder = defineAdderConfig({
files: [
{
name: () => '.prettierignore',
contentType: 'text',
content: ({ content }) => {
if (content) return content;
return dedent`
Expand Down
1 change: 0 additions & 1 deletion packages/adders/vitest/config/adder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const adder = defineAdderConfig({
},
{
name: ({ typescript }) => `src/demo.spec.${typescript ? 'ts' : 'js'}`,
contentType: 'text',
content: ({ content }) => {
if (content) return content;

Expand Down
4 changes: 2 additions & 2 deletions packages/core/files/processors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type SvelteFile<Args extends OptionDefinition> = {
content: (editor: SvelteFileEditor<Args>) => void;
};
type TextFile<Args extends OptionDefinition> = {
contentType: 'text';
contentType?: undefined;
content: (editor: TextFileEditor<Args>) => string;
};

Expand Down Expand Up @@ -107,7 +107,7 @@ export function createOrUpdateFiles<Args extends OptionDefinition>(
if (fileDetails.contentType === 'svelte') {
content = handleSvelteFile(content, fileDetails, workspace);
}
if (fileDetails.contentType === 'text') {
if (!fileDetails.contentType) {
content = handleTextFile(content, fileDetails, workspace);
}

Expand Down
0