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

New TS templates #5

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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,092 changes: 1,092 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/bin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node
import updateNotifier from 'update-notifier';
import { readFile } from 'fs/promises';
import { run } from '../src/index.js';
import minimist from 'minimist';
import updateNotifier from 'update-notifier';
import { run } from '../src/index.js';

const args = minimist(process.argv.slice(2));

Expand Down
7 changes: 3 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { onCancel } from './utils/prompts.js';
import { existsSync, readdirSync } from 'fs';
import { mkdir } from 'fs/promises';
import k from 'kleur';
import symbols from 'log-symbols';
import { relative } from 'path';
import { resolve } from 'path';
import { relative, resolve } from 'path';
import prompts from 'prompts';
import k from 'kleur';
import { onCancel } from './utils/prompts.js';

const versions = {
2: () => import('./versions/two.js'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from 'cypress';

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
describe('[Home] template spec', () => {
it('passes', () => {
cy.visit('http://localhost:1337/');

cy.get('h1').should('have.text', 'Routify 3');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
14 changes: 14 additions & 0 deletions src/versions/three/examples/typescript-tailwind-cypress/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Svelte app</title>

<link rel="icon" href="/favicon.ico" type="image/x-icon" />

<script type="module" src="/src/main.ts"></script>
</head>

<body class="debug-screens"></body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "starter",
"type": "module",
"scripts": {
"build": "vite build",
"preview": "vite preview",
"dev": "vite",
"svelte-check": "svelte-check",
"cypress:open": "cypress open",
"cypress:test": "cypress run"
},
"devDependencies": {
"cypress": "^12.5.1",
"@roxi/routify": "3.0.0-next.142",
"autoprefixer": "^10.4.13",
"tailwindcss": "^3.2.6",
"tailwindcss-debug-screens": "^2.2.1",
"postcss": "^8.4.21",
"@sveltejs/vite-plugin-svelte": "^2.0.0",
"@tsconfig/svelte": "^3.0.0",
"svelte": "^3.55.1",
"svelte-preprocess": "^5.0.1",
"typescript": "^4.9.5",
"vite": "^4.0.0",
"svelte-check": "^3.0.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script lang="ts">
import { Router } from '@roxi/routify';
import routes from '../.routify/routes.default.js';
import './app.css';
</script>

<Router {routes} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import App from './App.svelte'

const app = new App({ target: document.body })

export default app
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script lang="ts">
let name = 'Routify 3';
</script>

<div class="container mx-auto p-10">
<h1 class="text-center text-4xl">{name}</h1>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: 'class',
content: ['./src/**/*.svelte', './src/**/*.css', './index.html'],
theme: {
extend: {},
},
plugins: [require('tailwindcss-debug-screens')],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "@tsconfig/svelte/tsconfig.json",
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"resolveJsonModule": true,
"baseUrl": ".",
"allowJs": true,
"checkJs": true
},
"include": [
"src//.d.ts",
"src/**/.ts",
"src//*.js",
"src//.svelte",
"src/main.ts",
"src/main.ts"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import routify from '@roxi/routify/vite-plugin';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import preprocess from 'svelte-preprocess';
import { defineConfig } from 'vite';

const production = process.env.NODE_ENV === 'production';

export default defineConfig({
clearScreen: false,

plugins: [
routify({
ssr: { enable: false },
}),
svelte({
compilerOptions: {
dev: !production,
hydratable: !!process.env.ROUTIFY_SSR_ENABLE,
},
extensions: ['.svelte'],
preprocess: [preprocess()],
}),
],

server: { port: 1337 },
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Svelte app</title>

<link rel="icon" href="/favicon.ico" type="image/x-icon" />

<script type="module" src="/src/main.ts"></script>
</head>

<body class="debug-screens"></body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "starter",
"type": "module",
"scripts": {
"build": "vite build",
"preview": "vite preview",
"dev": "vite",
"svelte-check": "svelte-check",
"test": "playwright test"
},
"devDependencies": {
"@playwright/test": "^1.30.0",
"@roxi/routify": "3.0.0-next.142",
"autoprefixer": "^10.4.13",
"tailwindcss": "^3.2.6",
"tailwindcss-debug-screens": "^2.2.1",
"postcss": "^8.4.21",
"@sveltejs/vite-plugin-svelte": "^2.0.0",
"@tsconfig/svelte": "^3.0.0",
"svelte": "^3.55.1",
"svelte-preprocess": "^5.0.1",
"typescript": "^4.9.5",
"vite": "^4.0.0",
"svelte-check": "^3.0.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run build && npm run preview',
port: 4173,
},
reporter: 'list',
testDir: 'tests',
};

export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script lang="ts">
import { Router } from '@roxi/routify';
import routes from '../.routify/routes.default.js';
import './app.css';
</script>

<Router {routes} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import App from './App.svelte'

const app = new App({ target: document.body })

export default app
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script lang="ts">
let name = 'Routify 3';
</script>

<div class="container mx-auto p-10">
<h1 class="text-center text-4xl">{name}</h1>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: 'class',
content: ['./src/**/*.svelte', './src/**/*.css', './index.html'],
theme: {
extend: {},
},
plugins: [require('tailwindcss-debug-screens')],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { expect, test } from '@playwright/test';

test('index page has expected h1', async ({ page }) => {
await page.goto('/');

expect(await page.textContent('h1')).toBe('Routify 3');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "@tsconfig/svelte/tsconfig.json",
"compilerOptions": {
"target": "esnext",
"useDefineForClassFields": true,
"module": "esnext",
"resolveJsonModule": true,
"baseUrl": ".",
"allowJs": true,
"checkJs": true
},
"include": [
"src//.d.ts",
"src/**/.ts",
"src//*.js",
"src//.svelte",
"src/main.ts",
"src/main.ts"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import routify from '@roxi/routify/vite-plugin';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import preprocess from 'svelte-preprocess';
import { defineConfig } from 'vite';

const production = process.env.NODE_ENV === 'production';

export default defineConfig({
clearScreen: false,

plugins: [
routify({
ssr: { enable: false },
}),
svelte({
compilerOptions: {
dev: !production,
hydratable: !!process.env.ROUTIFY_SSR_ENABLE,
},
extensions: ['.svelte'],
preprocess: [preprocess()],
}),
],

server: { port: 1337 },
});
Loading