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

chore: simpler / more flexible api #181

Merged
merged 136 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
1a77b3c
mock api
manuel3108 Oct 20, 2024
bd660a7
mock paraglide adder
manuel3108 Oct 20, 2024
f7fedd0
improve? api
manuel3108 Oct 20, 2024
390f6af
small tweaks
AdrianGonz97 Oct 20, 2024
6940e34
more tweaks
AdrianGonz97 Oct 20, 2024
ef89da7
more
AdrianGonz97 Oct 20, 2024
750cc0c
start implementing new api (no clue if it works, requires cleanup)
manuel3108 Oct 21, 2024
ba6a78a
rename
manuel3108 Oct 21, 2024
d4dca57
rename some stuff
manuel3108 Oct 22, 2024
24da62e
migrate eslint
manuel3108 Oct 22, 2024
2d4cceb
migrate mdsvex
manuel3108 Oct 22, 2024
627a68d
migrate playwright
manuel3108 Oct 22, 2024
741b6e1
migrate prettier
manuel3108 Oct 22, 2024
aca314d
delete routify
manuel3108 Oct 22, 2024
fd4a0a2
update storybook
manuel3108 Oct 22, 2024
dddde96
update tailwindcss
manuel3108 Oct 22, 2024
3f66470
migrate vitest
manuel3108 Oct 23, 2024
1feee6f
migrate drizzle
manuel3108 Oct 23, 2024
791d96c
migrate lucia
manuel3108 Oct 23, 2024
6ce2cb3
Merge branch 'main' into chore/simpler-api-v2
manuel3108 Oct 25, 2024
046e62d
exract `dependsOn` into seperate function
manuel3108 Oct 25, 2024
82e723f
cleanup
manuel3108 Oct 25, 2024
19ffb9c
migrate community adder
manuel3108 Oct 25, 2024
6745e59
Merge branch 'main' into chore/simpler-api-v2
manuel3108 Oct 30, 2024
ec831d2
try out `setup` api, without actually implementing it
manuel3108 Oct 30, 2024
70ebbce
Merge branch 'main' into chore/simpler-api-v2
manuel3108 Nov 4, 2024
5e22384
skip writing empty files
AdrianGonz97 Nov 4, 2024
bd75644
make `setup` function work
manuel3108 Nov 5, 2024
95ff386
rename dir because vitest hates us
AdrianGonz97 Nov 6, 2024
71e47f2
dont expose `options`
AdrianGonz97 Nov 6, 2024
7e0f152
simplify
AdrianGonz97 Nov 6, 2024
974e5ad
pm
AdrianGonz97 Nov 6, 2024
8570940
remove old tests
AdrianGonz97 Nov 6, 2024
809a72f
initial install helper impl
AdrianGonz97 Nov 7, 2024
3e6f6bd
ignores
AdrianGonz97 Nov 7, 2024
0c86f37
add initial tests
AdrianGonz97 Nov 7, 2024
665ead0
..pin storybook
AdrianGonz97 Nov 7, 2024
6446e59
fix scripts
AdrianGonz97 Nov 7, 2024
53934db
add storybook test
AdrianGonz97 Nov 7, 2024
d3ef737
simplify
AdrianGonz97 Nov 7, 2024
e398dc2
deps
AdrianGonz97 Nov 7, 2024
8068dfc
add retries
AdrianGonz97 Nov 7, 2024
4b2f036
not needed
AdrianGonz97 Nov 7, 2024
0a0ba1a
tweak community template
AdrianGonz97 Nov 7, 2024
cd1a56d
add fixtures
AdrianGonz97 Nov 7, 2024
ed32699
community template tests
AdrianGonz97 Nov 7, 2024
d40929a
naming
AdrianGonz97 Nov 7, 2024
36939bb
tweaks
AdrianGonz97 Nov 7, 2024
c1b61be
unneeded
AdrianGonz97 Nov 7, 2024
7ae9ad9
clean
AdrianGonz97 Nov 7, 2024
1379621
Merge branch 'main' into feat/simple-testing-lib
AdrianGonz97 Nov 7, 2024
6adea4d
lockfile trickery
AdrianGonz97 Nov 7, 2024
266fea4
fix eslint test
AdrianGonz97 Nov 7, 2024
6a139e2
fix paraglide
AdrianGonz97 Nov 7, 2024
0fa007f
tweak workflow
AdrianGonz97 Nov 7, 2024
d417939
...
AdrianGonz97 Nov 7, 2024
19e80da
fix lint
AdrianGonz97 Nov 7, 2024
b2af1bb
fix check
AdrianGonz97 Nov 7, 2024
6d96a56
Merge branch 'main' into feat/simple-testing-lib
AdrianGonz97 Nov 7, 2024
fa0a992
simplify
AdrianGonz97 Nov 7, 2024
a9bbe4f
simplify
AdrianGonz97 Nov 8, 2024
a76f89b
upgrade vitest
AdrianGonz97 Nov 8, 2024
55afcbe
fix nit
AdrianGonz97 Nov 8, 2024
e6386a7
fix lint
AdrianGonz97 Nov 8, 2024
6a1d29f
simplify
AdrianGonz97 Nov 8, 2024
1e5be34
cleanup
AdrianGonz97 Nov 8, 2024
1e676fe
rename `vi` to `vitest`
AdrianGonz97 Nov 8, 2024
0a56d26
windows fixes
AdrianGonz97 Nov 8, 2024
f6523d4
more windows annoyances
AdrianGonz97 Nov 8, 2024
5870036
tweaks
AdrianGonz97 Nov 8, 2024
677fbb0
add `test:ui` script
manuel3108 Nov 8, 2024
6e9360c
`tinyexec` `throwOnError: true`
manuel3108 Nov 8, 2024
7181351
revert
AdrianGonz97 Nov 8, 2024
d98c630
properly terminate child processes
AdrianGonz97 Nov 9, 2024
9aa59cf
dont skip storybook
AdrianGonz97 Nov 9, 2024
dd141e7
cleanup on failure to load the page
AdrianGonz97 Nov 9, 2024
d4794f0
unused
AdrianGonz97 Nov 9, 2024
50fde5c
newline
AdrianGonz97 Nov 9, 2024
2b98217
use vitest workspaces
AdrianGonz97 Nov 9, 2024
8e00672
add `try-catch` while killing processes
manuel3108 Nov 9, 2024
9526fee
increase navigation timeout
manuel3108 Nov 9, 2024
928f19a
Merge branch 'feat/simple-testing-lib' into chore/simpler-api-v2
manuel3108 Nov 9, 2024
479da37
apply merge changes
manuel3108 Nov 9, 2024
ebe7812
fix timeout
AdrianGonz97 Nov 9, 2024
ed81a57
add retries
AdrianGonz97 Nov 9, 2024
a3baf83
remove storybook log
AdrianGonz97 Nov 9, 2024
987b1e8
cleanup cli package
AdrianGonz97 Nov 10, 2024
5684673
Merge branch 'feat/simple-testing-lib' into chore/simpler-api-v2
manuel3108 Nov 10, 2024
cc1e27d
simplify
manuel3108 Nov 10, 2024
ba117c2
fix lucia tests
manuel3108 Nov 10, 2024
2f11278
dont print external command output while testing
manuel3108 Nov 10, 2024
8a1a47a
fix storybook
manuel3108 Nov 10, 2024
650ede7
fixes
AdrianGonz97 Nov 10, 2024
047c549
format before evaluating test
AdrianGonz97 Nov 10, 2024
fe810a5
fix dir path
AdrianGonz97 Nov 10, 2024
25cadb6
setup matrix
AdrianGonz97 Nov 10, 2024
88f9473
skip running docker containers outside of linux runners
AdrianGonz97 Nov 11, 2024
9d5b6b2
print console output?
manuel3108 Nov 11, 2024
6e8d0c6
Merge branch 'feat/simple-testing-lib' into chore/simpler-api-v2
manuel3108 Nov 11, 2024
7c69d4e
fix lint?
manuel3108 Nov 11, 2024
ef2df6e
force `npm` for storybook?
manuel3108 Nov 11, 2024
c3aa2fc
Revert "force `npm` for storybook?"
manuel3108 Nov 11, 2024
1c095d6
try latest
manuel3108 Nov 11, 2024
57ab58e
Revert "try latest"
manuel3108 Nov 11, 2024
88bf2ec
Revert "print console output?"
manuel3108 Nov 11, 2024
fc72e9a
skip runnung storybook tests in ci on windows
manuel3108 Nov 11, 2024
c294302
Merge branch 'feat/simple-testing-lib' into chore/simpler-api-v2
manuel3108 Nov 11, 2024
26062f6
Merge branch 'main' into chore/simpler-api-v2
manuel3108 Nov 12, 2024
8fd7853
improve
manuel3108 Nov 12, 2024
3834a7a
missing filename
AdrianGonz97 Nov 12, 2024
8569b27
enhance tests
AdrianGonz97 Nov 12, 2024
1c964fe
pipe stdio during tests
AdrianGonz97 Nov 12, 2024
715eff0
skip storybook
AdrianGonz97 Nov 12, 2024
8a3ee4a
fixes
AdrianGonz97 Nov 12, 2024
a2e7b83
fix test
AdrianGonz97 Nov 12, 2024
2588ab2
fix: apply defaults to unspecified options
AdrianGonz97 Nov 12, 2024
184bbef
unpin storybook and remove skipping windows ci
AdrianGonz97 Nov 12, 2024
81810c7
use `defineProject` instead for better type safety in a workspace
AdrianGonz97 Nov 12, 2024
adb2663
remove silent flag
AdrianGonz97 Nov 12, 2024
0e92311
use latest
AdrianGonz97 Nov 12, 2024
64afeb5
temp log
AdrianGonz97 Nov 12, 2024
715d83e
unwrap
AdrianGonz97 Nov 12, 2024
0fdf8be
clear cache and log cause
AdrianGonz97 Nov 12, 2024
406a7c1
move it along
AdrianGonz97 Nov 12, 2024
af23c2f
run sequentially
AdrianGonz97 Nov 12, 2024
9383815
revert
AdrianGonz97 Nov 12, 2024
804caa2
test
AdrianGonz97 Nov 13, 2024
489c692
exclude windows from running concurrently
AdrianGonz97 Nov 13, 2024
31c73c8
tweaks
AdrianGonz97 Nov 13, 2024
23b1912
dont return string from `file` function
manuel3108 Nov 13, 2024
b9ed6a1
improve `unsupported`
manuel3108 Nov 13, 2024
53289dc
log `stderr` on failed dep installs
AdrianGonz97 Nov 13, 2024
20ceb66
tweak error
AdrianGonz97 Nov 13, 2024
830fbd4
simplify
AdrianGonz97 Nov 14, 2024
b78a6a3
fixes and tweaks
AdrianGonz97 Nov 14, 2024
a3b6954
fix
AdrianGonz97 Nov 14, 2024
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
38 changes: 17 additions & 21 deletions community-adder-template/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,23 @@ export const options = defineAdderOptions({

export default defineAdder({
id: 'community-addon',
environments: { kit: true, svelte: true },
options,
packages: [],
files: [
{
name: () => 'adder-template-demo.txt',
content: ({ content, options }) => {
if (options.demo) {
return 'This is a text file made by the Community Adder Template demo!';
}
return content;
setup: ({ kit, unsupported }) => {
if (!kit) unsupported('Requires SvelteKit');
},
run: ({ sv, options, typescript }) => {
sv.file('adder-template-demo.txt', (content) => {
if (options.demo) {
return 'This is a text file made by the Community Adder Template demo!';
}
},
{
name: () => 'src/DemoComponent.svelte',
content: ({ content, options, typescript }) => {
if (!options.demo) return content;
const { script, generateCode } = parseSvelte(content, { typescript });
imports.addDefault(script.ast, '../adder-template-demo.txt?raw', 'demo');
return generateCode({ script: script.generateCode(), template: '{demo}' });
}
}
]
return content;
});

sv.file('src/DemoComponent.svelte', (content) => {
if (!options.demo) return content;
const { script, generateCode } = parseSvelte(content, { typescript });
imports.addDefault(script.ast, '../adder-template-demo.txt?raw', 'demo');
return generateCode({ script: script.generateCode(), template: '{demo}' });
});
}
});
2 changes: 1 addition & 1 deletion packages/adders/_config/official.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const officialAdders = [
mdsvex,
paraglide,
storybook
];
] as AdderWithoutExplicitArgs[];

export function getAdderDetails(id: string): AdderWithoutExplicitArgs {
const details = officialAdders.find((a) => a.id === id);
Expand Down
30 changes: 30 additions & 0 deletions packages/adders/_tests/all-addons/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import process from 'node:process';
import { expect } from '@playwright/test';
import { setupTest } from '../_setup/suite.ts';
import { officialAdders } from '../../index.ts';
import type { AddonMap, OptionMap } from 'sv';

const windowsCI = process.env.CI && process.platform === 'win32';
const addons = officialAdders.reduce<AddonMap>((addonMap, addon) => {
if (addon.id === 'storybook' && windowsCI) return addonMap;
addonMap[addon.id] = addon;
return addonMap;
}, {});

const defaultOptions = officialAdders.reduce<OptionMap<typeof addons>>((options, addon) => {
options[addon.id] = {};
return options;
}, {});

const { test, variants, prepareServer } = setupTest(addons);

const kitOnly = variants.filter((v) => v.startsWith('kit'));
test.concurrent.for(kitOnly)('run all addons - %s', async (variant, { page, ...ctx }) => {
const cwd = await ctx.run(variant, defaultOptions);

const { close } = await prepareServer({ cwd, page });
// kill server process when we're done
ctx.onTestFinished(async () => await close());

expect(true).toBe(true);
});
12 changes: 11 additions & 1 deletion packages/adders/_tests/eslint/test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { execSync } from 'node:child_process';
import { expect } from '@playwright/test';
import { setupTest } from '../_setup/suite.ts';
import eslint from '../../eslint/index.ts';
Expand All @@ -11,5 +14,12 @@ test.concurrent.for(variants)('core - %s', async (variant, { page, ...ctx }) =>
// kill server process when we're done
ctx.onTestFinished(async () => await close());

expect(true).toBe(true);
const unlintedFile = 'let foo = "";\nif (Boolean(foo)) {\n//\n}';
fs.writeFileSync(path.resolve(cwd, 'foo.js'), unlintedFile, 'utf8');

expect(() => execSync('pnpm lint', { cwd, stdio: 'pipe' })).toThrowError();

expect(() => execSync('pnpm eslint --fix .', { cwd, stdio: 'pipe' })).not.toThrowError();

expect(() => execSync('pnpm lint', { cwd, stdio: 'pipe' })).not.toThrowError();
});
12 changes: 11 additions & 1 deletion packages/adders/_tests/prettier/test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { execSync } from 'node:child_process';
import { expect } from '@playwright/test';
import { setupTest } from '../_setup/suite.ts';
import prettier from '../../prettier/index.ts';
Expand All @@ -11,5 +14,12 @@ test.concurrent.for(variants)('core - %s', async (variant, { page, ...ctx }) =>
// kill server process when we're done
ctx.onTestFinished(async () => await close());

expect(true).toBe(true);
const unformattedFile = 'const foo = "bar"';
fs.writeFileSync(path.resolve(cwd, 'foo.js'), unformattedFile, 'utf8');

expect(() => execSync('pnpm lint', { cwd, stdio: 'pipe' })).toThrowError();

expect(() => execSync('pnpm format', { cwd, stdio: 'pipe' })).not.toThrowError();

expect(() => execSync('pnpm lint', { cwd, stdio: 'pipe' })).not.toThrowError();
});
5 changes: 3 additions & 2 deletions packages/adders/_tests/storybook/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ const { test, variants, prepareServer } = setupTest({ storybook });

let port = 6006;

const skip = process.env.CI && process.platform === 'win32';
test.skipIf(skip).concurrent.for(variants)(
const windowsCI = process.env.CI && process.platform === 'win32';
test.for(variants)(
'storybook loaded - %s',
{ concurrent: !windowsCI },
async (variant, { page, ...ctx }) => {
const cwd = await ctx.run(variant, { storybook: {} });

Expand Down
8 changes: 2 additions & 6 deletions packages/adders/common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { imports, exports, common } from '@sveltejs/cli-core/js';
import { type Question, type FileEditor } from '@sveltejs/cli-core';
import { parseScript, parseSvelte } from '@sveltejs/cli-core/parsers';

export function addEslintConfigPrettier({ content }: FileEditor<Record<string, Question>>): string {
export function addEslintConfigPrettier(content: string): string {
const { ast, generateCode } = parseScript(content);

// if a default import for `eslint-plugin-svelte` already exists, then we'll use their specifier's name instead
Expand Down Expand Up @@ -65,10 +64,7 @@ export function addEslintConfigPrettier({ content }: FileEditor<Record<string, Q
return generateCode();
}

export function addToDemoPage(
{ content }: FileEditor<Record<string, Question>>,
path: string
): string {
export function addToDemoPage(content: string, path: string): string {
const { template, generateCode } = parseSvelte(content);

for (const node of template.ast.childNodes) {
Expand Down
Loading
Loading