Skip to content

Commit f9a050c

Browse files
committed
Run svelte-kit sync #1063
1 parent ce5aff7 commit f9a050c

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

browser/cli/src/generateIndex.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ export const generateIndex = (
4444
const importLines = names.map(createImportLine).join('\n');
4545
const registerArgs = names.join(', ');
4646

47-
const content = TEMPLATE.replaceAll(
48-
Inserts.MODULE_ALIAS,
49-
atomicConfig.moduleAlias ?? '@tomic/lib',
50-
)
47+
const moduleAlias = atomicConfig.moduleAlias ?? '@tomic/lib';
48+
const content = TEMPLATE.replaceAll(Inserts.MODULE_ALIAS, moduleAlias)
5149
.replace(Inserts.IMPORTS, importLines)
5250
.replace(Inserts.REGISTER_ARGS, registerArgs);
5351

browser/cli/src/utils.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ export const dedupe = <T>(array: T[]): T[] => {
1111

1212
export const getExtension = () => {
1313
try {
14-
const tsconfig = getTsconfig();
15-
if (!tsconfig) return '.js';
16-
const moduleResolution = tsconfig.config.compilerOptions?.moduleResolution;
17-
if (!moduleResolution) return '.js';
18-
19-
return moduleResolution === 'Bundler' ? '' : '.js';
20-
} catch (error) {
21-
console.error('Error getting extension:', error);
14+
return getTsconfig()?.config.compilerOptions?.moduleResolution === 'Bundler'
15+
? ''
16+
: '.js';
17+
} catch (e) {
18+
console.warn('Something went wrong getting TS Config / file extension', e);
2219

2320
return '.js';
2421
}

browser/create-template/src/postprocess.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function postProcess(context: PostProcessContext) {
3535
switch (ontology.error.type) {
3636
case ErrorType.NotFound:
3737
console.error(
38-
`\nThe ${baseTemplate.name} template does not exist on your drive. To get the template go to the Create Resource page and select the ${baseTemplate.name} template`,
38+
`\nThe '${baseTemplate.name}' template does not exist on your drive on '${ontologySubject}'. To get the template go to the Create Resource page and select the ${baseTemplate.name} template.`,
3939
);
4040
break;
4141
case ErrorType.Unauthorized:

browser/e2e/tests/template.spec.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,19 @@ const TEMPLATE_DIR_NAME = 'template-tests';
4040
// test.describe.configure({ mode: 'serial' });
4141

4242
async function setupTemplateSite(
43-
templateDir: string,
4443
serverUrl: string,
45-
siteType: string,
44+
siteType: 'nextjs-site' | 'sveltekit-site',
4645
) {
47-
if (!fs.existsSync(templateDir)) {
48-
fs.mkdirSync(templateDir);
46+
if (!fs.existsSync(TEMPLATE_DIR_NAME)) {
47+
fs.mkdirSync(TEMPLATE_DIR_NAME);
4948
}
5049

5150
await execAsync('pnpm link ../create-template');
5251
await execAsync(
53-
`pnpm exec create-template ${templateDir}/${siteType} --template ${siteType} --server-url ${serverUrl}`,
52+
`pnpm exec create-template ${TEMPLATE_DIR_NAME}/${siteType} --template ${siteType} --server-url ${serverUrl}`,
5453
);
5554

56-
const sitePath = `${templateDir}/${siteType}`;
55+
const sitePath = `${TEMPLATE_DIR_NAME}/${siteType}`;
5756
await execAsync('pnpm install', { cwd: sitePath });
5857
await execAsync('pnpm link ../../../cli', { cwd: sitePath });
5958
await execAsync('pnpm link ../../../lib', { cwd: sitePath });
@@ -62,6 +61,7 @@ async function setupTemplateSite(
6261
await execAsync('pnpm link ../../../react', { cwd: sitePath });
6362
} else if (siteType === 'sveltekit-site') {
6463
await execAsync('pnpm link ../../../svelte', { cwd: sitePath });
64+
await execAsync('pnpm svelte-kit sync', { cwd: sitePath });
6565
}
6666

6767
await execAsync('pnpm update-ontologies', { cwd: sitePath });
@@ -142,7 +142,7 @@ test.describe('Create Next.js Template', () => {
142142
});
143143
await applyTemplateButton.click();
144144

145-
await setupTemplateSite(TEMPLATE_DIR_NAME, drive.driveURL, 'nextjs-site');
145+
await setupTemplateSite(drive.driveURL, 'nextjs-site');
146146

147147
try {
148148
//start server
@@ -221,11 +221,7 @@ test.describe('Create SvelteKit Template', () => {
221221
});
222222
await applyTemplateButton.click();
223223

224-
await setupTemplateSite(
225-
TEMPLATE_DIR_NAME,
226-
drive.driveURL,
227-
'sveltekit-site',
228-
);
224+
await setupTemplateSite(drive.driveURL, 'sveltekit-site');
229225

230226
try {
231227
const child = startServer(TEMPLATE_DIR_NAME, 'sveltekit-site');

0 commit comments

Comments
 (0)