Skip to content

Commit d58d3bc

Browse files
chore: rename adders to addons (#303)
Co-authored-by: AdrianGonz97 <[email protected]>
1 parent 61c62ec commit d58d3bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+334
-346
lines changed

.changeset/late-fireants-bow.md

+5

README.md

+1-1

community-adder-template/README.md

-58
This file was deleted.

community-adders/unocss.ts

-5
This file was deleted.

community-adders/unplugin-icons.ts

-5
This file was deleted.

community-addon-template/README.md

+58

community-adder-template/package.json renamed to community-addon-template/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "community-adder-template",
2+
"name": "community-addon-template",
33
"private": true,
44
"version": "0.0.0",
55
"type": "module",

community-adder-template/src/index.js renamed to community-addon-template/src/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
import { defineAdder, defineAdderOptions } from '@sveltejs/cli-core';
1+
import { defineAddon, defineAddonOptions } from '@sveltejs/cli-core';
22
import { imports } from '@sveltejs/cli-core/js';
33
import { parseSvelte } from '@sveltejs/cli-core/parsers';
44

5-
export const options = defineAdderOptions({
5+
export const options = defineAddonOptions({
66
demo: {
77
question: 'Do you want to use a demo?',
88
type: 'boolean',
99
default: false
1010
}
1111
});
1212

13-
export default defineAdder({
13+
export default defineAddon({
1414
id: 'community-addon',
1515
options,
1616
setup: ({ kit, unsupported }) => {
1717
if (!kit) unsupported('Requires SvelteKit');
1818
},
1919
run: ({ sv, options, typescript }) => {
20-
sv.file('adder-template-demo.txt', (content) => {
20+
sv.file('addon-template-demo.txt', (content) => {
2121
if (options.demo) {
22-
return 'This is a text file made by the Community Adder Template demo!';
22+
return 'This is a text file made by the Community Addon Template demo!';
2323
}
2424
return content;
2525
});
2626

2727
sv.file('src/DemoComponent.svelte', (content) => {
2828
if (!options.demo) return content;
2929
const { script, generateCode } = parseSvelte(content, { typescript });
30-
imports.addDefault(script.ast, '../adder-template-demo.txt?raw', 'demo');
30+
imports.addDefault(script.ast, '../addon-template-demo.txt?raw', 'demo');
3131
return generateCode({ script: script.generateCode(), template: '{demo}' });
3232
});
3333
}

community-adder-template/tests/custom-addon.test.ts renamed to community-addon-template/tests/custom-addon.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ test.concurrent.for(variants)('demo - %s', async (variant, { page, ...ctx }) =>
2424

2525
// expectations
2626
const textContent = await page.getByTestId('demo').textContent();
27-
expect(textContent).toContain('This is a text file made by the Community Adder Template demo!');
27+
expect(textContent).toContain('This is a text file made by the Community Addon Template demo!');
2828
});
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import demo from '../../adder-template-demo.txt?raw';
2+
import demo from '../../addon-template-demo.txt?raw';
33
</script>
44

55
<span data-testid="demo">{demo}</span>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
import demo from '../adder-template-demo.txt?raw';
2+
import demo from '../addon-template-demo.txt?raw';
33
</script>
44

55
<span data-testid="demo">{demo}</span>

community-adder-template/vitest.config.js renamed to community-addon-template/vitest.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export default defineConfig({
88
exclude: ['tests/setup/*'],
99
testTimeout: ONE_MINUTE * 3,
1010
hookTimeout: ONE_MINUTE * 3,
11-
maxConcurrency: 10,
1211
globalSetup: ['tests/setup/global.ts']
1312
}
1413
});

community-addons/unocss.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { CommunityAddon } from '../packages/addons/_config/community.ts';
2+
3+
export default {
4+
id: 'unocss-svelte-add-on'
5+
} satisfies CommunityAddon;

community-addons/unplugin-icons.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import type { CommunityAddon } from '../packages/addons/_config/community.ts';
2+
3+
export default {
4+
id: 'unplugin-icons-svelte-add-on'
5+
} satisfies CommunityAddon;

eslint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default [
3232
'**/dist/*',
3333
'packages/**/tests/**/{output,input}.ts',
3434
'rollup.config.js',
35-
'community-adder-template/tests/*'
35+
'community-addon-template/tests/*'
3636
]
3737
}
3838
];

packages/adders/_config/community.ts

-11
This file was deleted.

packages/adders/_config/index.ts

-2
This file was deleted.

packages/addons/_config/community.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export type CommunityAddon = {
2+
id: string; // the npm package name
3+
};
4+
5+
/** EVALUATED AT BUILD TIME */
6+
export const communityAddonIds: string[] = [];
7+
8+
export async function getCommunityAddon(name: string): Promise<CommunityAddon> {
9+
const { default: details } = await import(`../../../community-addons/${name}.ts`);
10+
return details;
11+
}

packages/addons/_config/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { officialAddons, getAddonDetails } from './official.ts';
2+
export { getCommunityAddon, communityAddonIds } from './community.ts';
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AdderWithoutExplicitArgs } from '@sveltejs/cli-core';
1+
import type { AddonWithoutExplicitArgs } from '@sveltejs/cli-core';
22

33
import drizzle from '../drizzle/index.ts';
44
import eslint from '../eslint/index.ts';
@@ -11,9 +11,9 @@ import storybook from '../storybook/index.ts';
1111
import tailwindcss from '../tailwindcss/index.ts';
1212
import vitest from '../vitest-addon/index.ts';
1313

14-
// The order of adders here determines the order they are displayed inside the CLI
14+
// The order of addons here determines the order they are displayed inside the CLI
1515
// We generally try to order them by perceived popularity
16-
export const officialAdders = [
16+
export const officialAddons = [
1717
prettier,
1818
eslint,
1919
vitest,
@@ -24,13 +24,13 @@ export const officialAdders = [
2424
mdsvex,
2525
paraglide,
2626
storybook
27-
] as AdderWithoutExplicitArgs[];
27+
] as AddonWithoutExplicitArgs[];
2828

29-
export function getAdderDetails(id: string): AdderWithoutExplicitArgs {
30-
const details = officialAdders.find((a) => a.id === id);
29+
export function getAddonDetails(id: string): AddonWithoutExplicitArgs {
30+
const details = officialAddons.find((a) => a.id === id);
3131
if (!details) {
32-
throw new Error(`Invalid adder: ${id}`);
32+
throw new Error(`Invalid add-on: ${id}`);
3333
}
3434

35-
return details as AdderWithoutExplicitArgs;
35+
return details as AddonWithoutExplicitArgs;
3636
}

packages/adders/_tests/_setup/global.ts renamed to packages/addons/_tests/_setup/global.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
22
import { setup, type ProjectVariant } from 'sv/testing';
33
import type { GlobalSetupContext } from 'vitest/node';
44

5-
const TEST_DIR = fileURLToPath(new URL('../../../../.test-output/adders/', import.meta.url));
5+
const TEST_DIR = fileURLToPath(new URL('../../../../.test-output/addons/', import.meta.url));
66
const variants: ProjectVariant[] = ['kit-js', 'kit-ts', 'vite-js', 'vite-ts'];
77

88
export default async function ({ provide }: GlobalSetupContext) {

packages/adders/_tests/_setup/suite.ts renamed to packages/addons/_tests/_setup/suite.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function setupTest<Addons extends AddonMap>(addons: Addons) {
5353
const metaPath = path.resolve(cwd, 'meta.json');
5454
fs.writeFileSync(metaPath, JSON.stringify({ variant, options }, null, '\t'), 'utf8');
5555

56-
// run adder
56+
// run addon
5757
await installAddon({ cwd, addons, options, packageManager: 'pnpm' });
5858

5959
return cwd;

packages/adders/_tests/all-addons/test.ts renamed to packages/addons/_tests/all-addons/test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import process from 'node:process';
22
import { expect } from '@playwright/test';
33
import { setupTest } from '../_setup/suite.ts';
4-
import { officialAdders } from '../../index.ts';
4+
import { officialAddons } from '../../index.ts';
55
import type { AddonMap, OptionMap } from 'sv';
66

77
const windowsCI = process.env.CI && process.platform === 'win32';
8-
const addons = officialAdders.reduce<AddonMap>((addonMap, addon) => {
8+
const addons = officialAddons.reduce<AddonMap>((addonMap, addon) => {
99
if (addon.id === 'storybook' && windowsCI) return addonMap;
1010
addonMap[addon.id] = addon;
1111
return addonMap;
1212
}, {});
1313

14-
const defaultOptions = officialAdders.reduce<OptionMap<typeof addons>>((options, addon) => {
14+
const defaultOptions = officialAddons.reduce<OptionMap<typeof addons>>((options, addon) => {
1515
options[addon.id] = {};
1616
return options;
1717
}, {});
File renamed without changes.

packages/adders/drizzle/index.ts renamed to packages/addons/drizzle/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { common, exports, functions, imports, object, variables } from '@sveltejs/cli-core/js';
2-
import { defineAdder, defineAdderOptions, dedent, type OptionValues } from '@sveltejs/cli-core';
2+
import { defineAddon, defineAddonOptions, dedent, type OptionValues } from '@sveltejs/cli-core';
33
import { parseJson, parseScript } from '@sveltejs/cli-core/parsers';
44

55
const PORTS = {
@@ -8,7 +8,7 @@ const PORTS = {
88
sqlite: ''
99
} as const;
1010

11-
const options = defineAdderOptions({
11+
const options = defineAddonOptions({
1212
database: {
1313
question: 'Which database would you like to use?',
1414
type: 'select',
@@ -63,7 +63,7 @@ const options = defineAdderOptions({
6363
}
6464
});
6565

66-
export default defineAdder({
66+
export default defineAddon({
6767
id: 'drizzle',
6868
homepage: 'https://orm.drizzle.team',
6969
options,
File renamed without changes.

packages/adders/eslint/index.ts renamed to packages/addons/eslint/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { addEslintConfigPrettier } from '../common.ts';
2-
import { defineAdder, log } from '@sveltejs/cli-core';
2+
import { defineAddon, log } from '@sveltejs/cli-core';
33
import {
44
array,
55
common,
@@ -12,7 +12,7 @@ import {
1212
} from '@sveltejs/cli-core/js';
1313
import { parseJson, parseScript } from '@sveltejs/cli-core/parsers';
1414

15-
export default defineAdder({
15+
export default defineAddon({
1616
id: 'eslint',
1717
homepage: 'https://eslint.org',
1818
options: {},
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)