From: Haoqun Jiang Date: Tue, 27 Jul 2021 05:06:24 +0000 (+0800) Subject: workflow: generate a snapshot of each template before each release X-Git-Tag: v3.0.0-alpha.2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4114cc444f9cf7752ac208d9cea330ee9bf2a001;p=thirdparty%2Fvuejs%2Fcreate-vue.git workflow: generate a snapshot of each template before each release --- diff --git a/index.js b/index.js index 7ec584bc..c762c60b 100755 --- a/index.js +++ b/index.js @@ -8,6 +8,7 @@ import minimist from 'minimist' import prompts from 'prompts' import { red, green, bold } from 'kolorist' +import templateList from './utils/templateList.js' import renderTemplate from './utils/renderTemplate.js' import { postOrderDirectoryTraverse, @@ -48,11 +49,8 @@ async function init() { let targetDir = argv._[0] const defaultProjectName = !targetDir ? 'vue-project' : targetDir - const TEMPLATE_LIST = ['default', 'spa'] - .flatMap(x => [x, x + '-ts']) - .flatMap(x => [x, x + '-with-tests']) let template = argv.template || argv.t - const isValidTemplate = TEMPLATE_LIST.includes(template) + const isValidTemplate = templateList.includes(template) let result = {} diff --git a/package.json b/package.json index c4c60000..17567eb9 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "node": "^12.13.0 || ^14.0.0 || >= 16.0.0" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "prepublishOnly": "node snapshot.js" }, "repository": { "type": "git", diff --git a/playground/default-ts-with-tests/.gitignore b/playground/default-ts-with-tests/.gitignore new file mode 100644 index 00000000..133da84e --- /dev/null +++ b/playground/default-ts-with-tests/.gitignore @@ -0,0 +1,27 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/playground/.gitkeep b/playground/default-ts-with-tests/README.md similarity index 100% rename from playground/.gitkeep rename to playground/default-ts-with-tests/README.md diff --git a/playground/default-ts-with-tests/cypress.json b/playground/default-ts-with-tests/cypress.json new file mode 100644 index 00000000..3d372252 --- /dev/null +++ b/playground/default-ts-with-tests/cypress.json @@ -0,0 +1,7 @@ +{ + "baseUrl": "http://localhost:5050", + "component": { + "componentFolder": "src", + "testFiles": "**/__tests__/*.spec.{js,ts,jsx,tsx}" + } +} diff --git a/playground/default-ts-with-tests/cypress/fixtures/example.json b/playground/default-ts-with-tests/cypress/fixtures/example.json new file mode 100644 index 00000000..02e42543 --- /dev/null +++ b/playground/default-ts-with-tests/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/playground/default-ts-with-tests/cypress/integration/example.spec.ts b/playground/default-ts-with-tests/cypress/integration/example.spec.ts new file mode 100644 index 00000000..bbe8f52d --- /dev/null +++ b/playground/default-ts-with-tests/cypress/integration/example.spec.ts @@ -0,0 +1,8 @@ +// https://docs.cypress.io/api/introduction/api.html + +describe('My First Test', () => { + it('visits the app root url', () => { + cy.visit('/') + cy.contains('h1', 'Hello Vue 3 + TypeScript + Vite') + }) +}) diff --git a/playground/default-ts-with-tests/cypress/plugins/index.ts b/playground/default-ts-with-tests/cypress/plugins/index.ts new file mode 100644 index 00000000..ad2e351d --- /dev/null +++ b/playground/default-ts-with-tests/cypress/plugins/index.ts @@ -0,0 +1,28 @@ +/// +// *********************************************************** +// This example plugins/index.js can be used to load plugins +// +// You can change the location of this file or turn off loading +// the plugins file with the 'pluginsFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/plugins-guide +// *********************************************************** + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) + +const { startDevServer } = require('@cypress/vite-dev-server') + +/** + * @type {Cypress.PluginConfig} + */ +// eslint-disable-next-line no-unused-vars +module.exports = (on, config) => { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + on('dev-server:start', (options) => { + return startDevServer({ options }) + }) + return config +} diff --git a/playground/default-ts-with-tests/cypress/support/commands.ts b/playground/default-ts-with-tests/cypress/support/commands.ts new file mode 100644 index 00000000..119ab03f --- /dev/null +++ b/playground/default-ts-with-tests/cypress/support/commands.ts @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js 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) => { ... }) diff --git a/playground/default-ts-with-tests/cypress/support/index.ts b/playground/default-ts-with-tests/cypress/support/index.ts new file mode 100644 index 00000000..d68db96d --- /dev/null +++ b/playground/default-ts-with-tests/cypress/support/index.ts @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js 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') diff --git a/playground/default-ts-with-tests/cypress/tsconfig.json b/playground/default-ts-with-tests/cypress/tsconfig.json new file mode 100644 index 00000000..b5b2f972 --- /dev/null +++ b/playground/default-ts-with-tests/cypress/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["es5", "dom"], + "types": ["cypress"] + }, + "include": ["./**/*"] +} diff --git a/playground/default-ts-with-tests/index.html b/playground/default-ts-with-tests/index.html new file mode 100644 index 00000000..11603f87 --- /dev/null +++ b/playground/default-ts-with-tests/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/playground/default-ts-with-tests/package.json b/playground/default-ts-with-tests/package.json new file mode 100644 index 00000000..b1e12f16 --- /dev/null +++ b/playground/default-ts-with-tests/package.json @@ -0,0 +1,30 @@ +{ + "name": "default-ts-with-tests", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vue-tsc --noEmit && vite build", + "preserve": "vite build", + "serve": "vite preview --port 5050", + "test:unit": "cypress open-ct", + "test:unit:ci": "cypress run-ct --quiet --reporter spec", + "test:e2e": "start-server-and-test serve 5050 'cypress open'", + "test:e2e:ci": "start-server-and-test serve 5050 'cypress run'", + "typecheck": "vue-tsc --noEmit" + }, + "dependencies": { + "vue": "^3.1.5" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^1.2.5", + "@vitejs/plugin-vue-jsx": "^1.1.6", + "@vue/compiler-sfc": "^3.1.5", + "vite": "^2.4.3", + "@cypress/vite-dev-server": "^2.0.2", + "@cypress/vue": "^3.0.1", + "cypress": "^8.0.0", + "start-server-and-test": "^1.12.6", + "typescript": "~4.3.5", + "vue-tsc": "^0.2.2" + } +} \ No newline at end of file diff --git a/playground/default-ts-with-tests/public/favicon.ico b/playground/default-ts-with-tests/public/favicon.ico new file mode 100644 index 00000000..df36fcfb Binary files /dev/null and b/playground/default-ts-with-tests/public/favicon.ico differ diff --git a/playground/default-ts-with-tests/src/App.vue b/playground/default-ts-with-tests/src/App.vue new file mode 100644 index 00000000..f1611b6f --- /dev/null +++ b/playground/default-ts-with-tests/src/App.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/playground/default-ts-with-tests/src/assets/logo.png b/playground/default-ts-with-tests/src/assets/logo.png new file mode 100644 index 00000000..f3d2503f Binary files /dev/null and b/playground/default-ts-with-tests/src/assets/logo.png differ diff --git a/playground/default-ts-with-tests/src/components/HelloWorld.vue b/playground/default-ts-with-tests/src/components/HelloWorld.vue new file mode 100644 index 00000000..2dac5234 --- /dev/null +++ b/playground/default-ts-with-tests/src/components/HelloWorld.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/playground/default-ts-with-tests/src/components/__tests__/HelloWorld.spec.ts b/playground/default-ts-with-tests/src/components/__tests__/HelloWorld.spec.ts new file mode 100644 index 00000000..087c9561 --- /dev/null +++ b/playground/default-ts-with-tests/src/components/__tests__/HelloWorld.spec.ts @@ -0,0 +1,22 @@ +import { mount } from '@cypress/vue' +import HelloWorld from '../HelloWorld.vue' + +describe('HelloWorld', () => { + it('playground', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + }) + + it('renders properly', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + cy.get('h1').should('contain', 'Hello Cypress') + }) + + it('adds 1 when clicking the plus button', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + + cy.get('button') + .should('contain', '0') + .click() + .should('contain', '1') + }) +}) diff --git a/playground/default-ts-with-tests/src/main.ts b/playground/default-ts-with-tests/src/main.ts new file mode 100644 index 00000000..01433bca --- /dev/null +++ b/playground/default-ts-with-tests/src/main.ts @@ -0,0 +1,4 @@ +import { createApp } from 'vue' +import App from './App.vue' + +createApp(App).mount('#app') diff --git a/playground/default-ts-with-tests/src/shims-vue.d.ts b/playground/default-ts-with-tests/src/shims-vue.d.ts new file mode 100644 index 00000000..ec4f1b2e --- /dev/null +++ b/playground/default-ts-with-tests/src/shims-vue.d.ts @@ -0,0 +1,6 @@ +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/playground/default-ts-with-tests/src/vite-env.d.ts b/playground/default-ts-with-tests/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/playground/default-ts-with-tests/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/playground/default-ts-with-tests/tsconfig.json b/playground/default-ts-with-tests/tsconfig.json new file mode 100644 index 00000000..d3adf1bf --- /dev/null +++ b/playground/default-ts-with-tests/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"], + "skipLibCheck": true + }, + "include": [ + "vite.config.*", + + "src/**/*", + "src/**/*.vue" + ], + "exclude": [ + "src/**/__tests__/**" + ] +} diff --git a/playground/default-ts-with-tests/vite.config.ts b/playground/default-ts-with-tests/vite.config.ts new file mode 100644 index 00000000..8ae6fd07 --- /dev/null +++ b/playground/default-ts-with-tests/vite.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx()], + resolve: { + alias: { + '@/': new URL('./src/', import.meta.url).pathname, + }, + } +}) diff --git a/playground/default-ts/.gitignore b/playground/default-ts/.gitignore new file mode 100644 index 00000000..133da84e --- /dev/null +++ b/playground/default-ts/.gitignore @@ -0,0 +1,27 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/playground/default-ts/README.md b/playground/default-ts/README.md new file mode 100644 index 00000000..e69de29b diff --git a/playground/default-ts/index.html b/playground/default-ts/index.html new file mode 100644 index 00000000..11603f87 --- /dev/null +++ b/playground/default-ts/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/playground/default-ts/package.json b/playground/default-ts/package.json new file mode 100644 index 00000000..c12f476c --- /dev/null +++ b/playground/default-ts/package.json @@ -0,0 +1,22 @@ +{ + "name": "default-ts", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vue-tsc --noEmit && vite build", + "preserve": "vite build", + "serve": "vite preview --port 5050", + "typecheck": "vue-tsc --noEmit" + }, + "dependencies": { + "vue": "^3.1.5" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^1.2.5", + "@vitejs/plugin-vue-jsx": "^1.1.6", + "@vue/compiler-sfc": "^3.1.5", + "vite": "^2.4.3", + "typescript": "~4.3.5", + "vue-tsc": "^0.2.2" + } +} \ No newline at end of file diff --git a/playground/default-ts/public/favicon.ico b/playground/default-ts/public/favicon.ico new file mode 100644 index 00000000..df36fcfb Binary files /dev/null and b/playground/default-ts/public/favicon.ico differ diff --git a/playground/default-ts/src/App.vue b/playground/default-ts/src/App.vue new file mode 100644 index 00000000..f1611b6f --- /dev/null +++ b/playground/default-ts/src/App.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/playground/default-ts/src/assets/logo.png b/playground/default-ts/src/assets/logo.png new file mode 100644 index 00000000..f3d2503f Binary files /dev/null and b/playground/default-ts/src/assets/logo.png differ diff --git a/playground/default-ts/src/components/HelloWorld.vue b/playground/default-ts/src/components/HelloWorld.vue new file mode 100644 index 00000000..2dac5234 --- /dev/null +++ b/playground/default-ts/src/components/HelloWorld.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/playground/default-ts/src/main.ts b/playground/default-ts/src/main.ts new file mode 100644 index 00000000..01433bca --- /dev/null +++ b/playground/default-ts/src/main.ts @@ -0,0 +1,4 @@ +import { createApp } from 'vue' +import App from './App.vue' + +createApp(App).mount('#app') diff --git a/playground/default-ts/src/shims-vue.d.ts b/playground/default-ts/src/shims-vue.d.ts new file mode 100644 index 00000000..ec4f1b2e --- /dev/null +++ b/playground/default-ts/src/shims-vue.d.ts @@ -0,0 +1,6 @@ +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/playground/default-ts/src/vite-env.d.ts b/playground/default-ts/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/playground/default-ts/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/playground/default-ts/tsconfig.json b/playground/default-ts/tsconfig.json new file mode 100644 index 00000000..d3adf1bf --- /dev/null +++ b/playground/default-ts/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"], + "skipLibCheck": true + }, + "include": [ + "vite.config.*", + + "src/**/*", + "src/**/*.vue" + ], + "exclude": [ + "src/**/__tests__/**" + ] +} diff --git a/playground/default-ts/vite.config.ts b/playground/default-ts/vite.config.ts new file mode 100644 index 00000000..8ae6fd07 --- /dev/null +++ b/playground/default-ts/vite.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx()], + resolve: { + alias: { + '@/': new URL('./src/', import.meta.url).pathname, + }, + } +}) diff --git a/playground/default-with-tests/.gitignore b/playground/default-with-tests/.gitignore new file mode 100644 index 00000000..133da84e --- /dev/null +++ b/playground/default-with-tests/.gitignore @@ -0,0 +1,27 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/playground/default-with-tests/README.md b/playground/default-with-tests/README.md new file mode 100644 index 00000000..e69de29b diff --git a/playground/default-with-tests/cypress.json b/playground/default-with-tests/cypress.json new file mode 100644 index 00000000..3d372252 --- /dev/null +++ b/playground/default-with-tests/cypress.json @@ -0,0 +1,7 @@ +{ + "baseUrl": "http://localhost:5050", + "component": { + "componentFolder": "src", + "testFiles": "**/__tests__/*.spec.{js,ts,jsx,tsx}" + } +} diff --git a/playground/default-with-tests/cypress/fixtures/example.json b/playground/default-with-tests/cypress/fixtures/example.json new file mode 100644 index 00000000..02e42543 --- /dev/null +++ b/playground/default-with-tests/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/playground/default-with-tests/cypress/integration/example.spec.js b/playground/default-with-tests/cypress/integration/example.spec.js new file mode 100644 index 00000000..493bfcf0 --- /dev/null +++ b/playground/default-with-tests/cypress/integration/example.spec.js @@ -0,0 +1,8 @@ +// https://docs.cypress.io/api/introduction/api.html + +describe('My First Test', () => { + it('visits the app root url', () => { + cy.visit('/') + cy.contains('h1', 'Hello Vue 3 + Vite') + }) +}) diff --git a/playground/default-with-tests/cypress/jsconfig.json b/playground/default-with-tests/cypress/jsconfig.json new file mode 100644 index 00000000..b5b2f972 --- /dev/null +++ b/playground/default-with-tests/cypress/jsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["es5", "dom"], + "types": ["cypress"] + }, + "include": ["./**/*"] +} diff --git a/playground/default-with-tests/cypress/plugins/index.js b/playground/default-with-tests/cypress/plugins/index.js new file mode 100644 index 00000000..ad2e351d --- /dev/null +++ b/playground/default-with-tests/cypress/plugins/index.js @@ -0,0 +1,28 @@ +/// +// *********************************************************** +// This example plugins/index.js can be used to load plugins +// +// You can change the location of this file or turn off loading +// the plugins file with the 'pluginsFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/plugins-guide +// *********************************************************** + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) + +const { startDevServer } = require('@cypress/vite-dev-server') + +/** + * @type {Cypress.PluginConfig} + */ +// eslint-disable-next-line no-unused-vars +module.exports = (on, config) => { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + on('dev-server:start', (options) => { + return startDevServer({ options }) + }) + return config +} diff --git a/playground/default-with-tests/cypress/support/commands.js b/playground/default-with-tests/cypress/support/commands.js new file mode 100644 index 00000000..119ab03f --- /dev/null +++ b/playground/default-with-tests/cypress/support/commands.js @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js 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) => { ... }) diff --git a/playground/default-with-tests/cypress/support/index.js b/playground/default-with-tests/cypress/support/index.js new file mode 100644 index 00000000..d68db96d --- /dev/null +++ b/playground/default-with-tests/cypress/support/index.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js 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') diff --git a/playground/default-with-tests/index.html b/playground/default-with-tests/index.html new file mode 100644 index 00000000..11603f87 --- /dev/null +++ b/playground/default-with-tests/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/playground/default-with-tests/jsconfig.json b/playground/default-with-tests/jsconfig.json new file mode 100644 index 00000000..d3adf1bf --- /dev/null +++ b/playground/default-with-tests/jsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"], + "skipLibCheck": true + }, + "include": [ + "vite.config.*", + + "src/**/*", + "src/**/*.vue" + ], + "exclude": [ + "src/**/__tests__/**" + ] +} diff --git a/playground/default-with-tests/package.json b/playground/default-with-tests/package.json new file mode 100644 index 00000000..44a3acf9 --- /dev/null +++ b/playground/default-with-tests/package.json @@ -0,0 +1,27 @@ +{ + "name": "default-with-tests", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preserve": "vite build", + "serve": "vite preview --port 5050", + "test:unit": "cypress open-ct", + "test:unit:ci": "cypress run-ct --quiet --reporter spec", + "test:e2e": "start-server-and-test serve 5050 'cypress open'", + "test:e2e:ci": "start-server-and-test serve 5050 'cypress run'" + }, + "dependencies": { + "vue": "^3.1.5" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^1.2.5", + "@vitejs/plugin-vue-jsx": "^1.1.6", + "@vue/compiler-sfc": "^3.1.5", + "vite": "^2.4.3", + "@cypress/vite-dev-server": "^2.0.2", + "@cypress/vue": "^3.0.1", + "cypress": "^8.0.0", + "start-server-and-test": "^1.12.6" + } +} \ No newline at end of file diff --git a/playground/default-with-tests/public/favicon.ico b/playground/default-with-tests/public/favicon.ico new file mode 100644 index 00000000..df36fcfb Binary files /dev/null and b/playground/default-with-tests/public/favicon.ico differ diff --git a/playground/default-with-tests/src/App.vue b/playground/default-with-tests/src/App.vue new file mode 100644 index 00000000..a058d171 --- /dev/null +++ b/playground/default-with-tests/src/App.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/playground/default-with-tests/src/assets/logo.png b/playground/default-with-tests/src/assets/logo.png new file mode 100644 index 00000000..f3d2503f Binary files /dev/null and b/playground/default-with-tests/src/assets/logo.png differ diff --git a/playground/default-with-tests/src/components/HelloWorld.vue b/playground/default-with-tests/src/components/HelloWorld.vue new file mode 100644 index 00000000..36a089f1 --- /dev/null +++ b/playground/default-with-tests/src/components/HelloWorld.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/playground/default-with-tests/src/components/__tests__/HelloWorld.spec.js b/playground/default-with-tests/src/components/__tests__/HelloWorld.spec.js new file mode 100644 index 00000000..087c9561 --- /dev/null +++ b/playground/default-with-tests/src/components/__tests__/HelloWorld.spec.js @@ -0,0 +1,22 @@ +import { mount } from '@cypress/vue' +import HelloWorld from '../HelloWorld.vue' + +describe('HelloWorld', () => { + it('playground', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + }) + + it('renders properly', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + cy.get('h1').should('contain', 'Hello Cypress') + }) + + it('adds 1 when clicking the plus button', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + + cy.get('button') + .should('contain', '0') + .click() + .should('contain', '1') + }) +}) diff --git a/playground/default-with-tests/src/main.js b/playground/default-with-tests/src/main.js new file mode 100644 index 00000000..01433bca --- /dev/null +++ b/playground/default-with-tests/src/main.js @@ -0,0 +1,4 @@ +import { createApp } from 'vue' +import App from './App.vue' + +createApp(App).mount('#app') diff --git a/playground/default-with-tests/src/shims-vue.d.ts b/playground/default-with-tests/src/shims-vue.d.ts new file mode 100644 index 00000000..ec4f1b2e --- /dev/null +++ b/playground/default-with-tests/src/shims-vue.d.ts @@ -0,0 +1,6 @@ +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/playground/default-with-tests/src/vite-env.d.ts b/playground/default-with-tests/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/playground/default-with-tests/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/playground/default-with-tests/vite.config.js b/playground/default-with-tests/vite.config.js new file mode 100644 index 00000000..8ae6fd07 --- /dev/null +++ b/playground/default-with-tests/vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx()], + resolve: { + alias: { + '@/': new URL('./src/', import.meta.url).pathname, + }, + } +}) diff --git a/playground/default/.gitignore b/playground/default/.gitignore new file mode 100644 index 00000000..133da84e --- /dev/null +++ b/playground/default/.gitignore @@ -0,0 +1,27 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/playground/default/README.md b/playground/default/README.md new file mode 100644 index 00000000..e69de29b diff --git a/playground/default/index.html b/playground/default/index.html new file mode 100644 index 00000000..11603f87 --- /dev/null +++ b/playground/default/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/playground/default/jsconfig.json b/playground/default/jsconfig.json new file mode 100644 index 00000000..d3adf1bf --- /dev/null +++ b/playground/default/jsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"], + "skipLibCheck": true + }, + "include": [ + "vite.config.*", + + "src/**/*", + "src/**/*.vue" + ], + "exclude": [ + "src/**/__tests__/**" + ] +} diff --git a/playground/default/package.json b/playground/default/package.json new file mode 100644 index 00000000..0ff042cd --- /dev/null +++ b/playground/default/package.json @@ -0,0 +1,19 @@ +{ + "name": "default", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preserve": "vite build", + "serve": "vite preview --port 5050" + }, + "dependencies": { + "vue": "^3.1.5" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^1.2.5", + "@vitejs/plugin-vue-jsx": "^1.1.6", + "@vue/compiler-sfc": "^3.1.5", + "vite": "^2.4.3" + } +} \ No newline at end of file diff --git a/playground/default/public/favicon.ico b/playground/default/public/favicon.ico new file mode 100644 index 00000000..df36fcfb Binary files /dev/null and b/playground/default/public/favicon.ico differ diff --git a/playground/default/src/App.vue b/playground/default/src/App.vue new file mode 100644 index 00000000..a058d171 --- /dev/null +++ b/playground/default/src/App.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/playground/default/src/assets/logo.png b/playground/default/src/assets/logo.png new file mode 100644 index 00000000..f3d2503f Binary files /dev/null and b/playground/default/src/assets/logo.png differ diff --git a/playground/default/src/components/HelloWorld.vue b/playground/default/src/components/HelloWorld.vue new file mode 100644 index 00000000..36a089f1 --- /dev/null +++ b/playground/default/src/components/HelloWorld.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/playground/default/src/main.js b/playground/default/src/main.js new file mode 100644 index 00000000..01433bca --- /dev/null +++ b/playground/default/src/main.js @@ -0,0 +1,4 @@ +import { createApp } from 'vue' +import App from './App.vue' + +createApp(App).mount('#app') diff --git a/playground/default/src/shims-vue.d.ts b/playground/default/src/shims-vue.d.ts new file mode 100644 index 00000000..ec4f1b2e --- /dev/null +++ b/playground/default/src/shims-vue.d.ts @@ -0,0 +1,6 @@ +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/playground/default/src/vite-env.d.ts b/playground/default/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/playground/default/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/playground/default/vite.config.js b/playground/default/vite.config.js new file mode 100644 index 00000000..8ae6fd07 --- /dev/null +++ b/playground/default/vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx()], + resolve: { + alias: { + '@/': new URL('./src/', import.meta.url).pathname, + }, + } +}) diff --git a/playground/spa-ts-with-tests/.gitignore b/playground/spa-ts-with-tests/.gitignore new file mode 100644 index 00000000..133da84e --- /dev/null +++ b/playground/spa-ts-with-tests/.gitignore @@ -0,0 +1,27 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/playground/spa-ts-with-tests/README.md b/playground/spa-ts-with-tests/README.md new file mode 100644 index 00000000..e69de29b diff --git a/playground/spa-ts-with-tests/cypress.json b/playground/spa-ts-with-tests/cypress.json new file mode 100644 index 00000000..3d372252 --- /dev/null +++ b/playground/spa-ts-with-tests/cypress.json @@ -0,0 +1,7 @@ +{ + "baseUrl": "http://localhost:5050", + "component": { + "componentFolder": "src", + "testFiles": "**/__tests__/*.spec.{js,ts,jsx,tsx}" + } +} diff --git a/playground/spa-ts-with-tests/cypress/fixtures/example.json b/playground/spa-ts-with-tests/cypress/fixtures/example.json new file mode 100644 index 00000000..02e42543 --- /dev/null +++ b/playground/spa-ts-with-tests/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/playground/spa-ts-with-tests/cypress/integration/example.spec.ts b/playground/spa-ts-with-tests/cypress/integration/example.spec.ts new file mode 100644 index 00000000..3898b0ca --- /dev/null +++ b/playground/spa-ts-with-tests/cypress/integration/example.spec.ts @@ -0,0 +1,13 @@ +// https://docs.cypress.io/api/introduction/api.html + +describe('My First Test', () => { + it('visits the app root url', () => { + cy.visit('/') + cy.contains('h1', 'Hello Vue 3 + TypeScript + Vite') + }) + + it('navigates to the about page', () => { + cy.visit('/about') + cy.contains('h1', 'This is an about page') + }) +}) diff --git a/playground/spa-ts-with-tests/cypress/plugins/index.ts b/playground/spa-ts-with-tests/cypress/plugins/index.ts new file mode 100644 index 00000000..ad2e351d --- /dev/null +++ b/playground/spa-ts-with-tests/cypress/plugins/index.ts @@ -0,0 +1,28 @@ +/// +// *********************************************************** +// This example plugins/index.js can be used to load plugins +// +// You can change the location of this file or turn off loading +// the plugins file with the 'pluginsFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/plugins-guide +// *********************************************************** + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) + +const { startDevServer } = require('@cypress/vite-dev-server') + +/** + * @type {Cypress.PluginConfig} + */ +// eslint-disable-next-line no-unused-vars +module.exports = (on, config) => { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + on('dev-server:start', (options) => { + return startDevServer({ options }) + }) + return config +} diff --git a/playground/spa-ts-with-tests/cypress/support/commands.ts b/playground/spa-ts-with-tests/cypress/support/commands.ts new file mode 100644 index 00000000..119ab03f --- /dev/null +++ b/playground/spa-ts-with-tests/cypress/support/commands.ts @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js 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) => { ... }) diff --git a/playground/spa-ts-with-tests/cypress/support/index.ts b/playground/spa-ts-with-tests/cypress/support/index.ts new file mode 100644 index 00000000..d68db96d --- /dev/null +++ b/playground/spa-ts-with-tests/cypress/support/index.ts @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js 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') diff --git a/playground/spa-ts-with-tests/cypress/tsconfig.json b/playground/spa-ts-with-tests/cypress/tsconfig.json new file mode 100644 index 00000000..b5b2f972 --- /dev/null +++ b/playground/spa-ts-with-tests/cypress/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["es5", "dom"], + "types": ["cypress"] + }, + "include": ["./**/*"] +} diff --git a/playground/spa-ts-with-tests/index.html b/playground/spa-ts-with-tests/index.html new file mode 100644 index 00000000..11603f87 --- /dev/null +++ b/playground/spa-ts-with-tests/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/playground/spa-ts-with-tests/package.json b/playground/spa-ts-with-tests/package.json new file mode 100644 index 00000000..45ac7225 --- /dev/null +++ b/playground/spa-ts-with-tests/package.json @@ -0,0 +1,32 @@ +{ + "name": "spa-ts-with-tests", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vue-tsc --noEmit && vite build", + "preserve": "vite build", + "serve": "vite preview --port 5050", + "test:unit": "cypress open-ct", + "test:unit:ci": "cypress run-ct --quiet --reporter spec", + "test:e2e": "start-server-and-test serve 5050 'cypress open'", + "test:e2e:ci": "start-server-and-test serve 5050 'cypress run'", + "typecheck": "vue-tsc --noEmit" + }, + "dependencies": { + "vue": "^3.1.5", + "vue-router": "^4.0.10", + "vuex": "^4.0.2" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^1.2.5", + "@vitejs/plugin-vue-jsx": "^1.1.6", + "@vue/compiler-sfc": "^3.1.5", + "vite": "^2.4.3", + "@cypress/vite-dev-server": "^2.0.2", + "@cypress/vue": "^3.0.1", + "cypress": "^8.0.0", + "start-server-and-test": "^1.12.6", + "typescript": "~4.3.5", + "vue-tsc": "^0.2.2" + } +} \ No newline at end of file diff --git a/playground/spa-ts-with-tests/public/favicon.ico b/playground/spa-ts-with-tests/public/favicon.ico new file mode 100644 index 00000000..df36fcfb Binary files /dev/null and b/playground/spa-ts-with-tests/public/favicon.ico differ diff --git a/playground/spa-ts-with-tests/src/App.vue b/playground/spa-ts-with-tests/src/App.vue new file mode 100644 index 00000000..b9643551 --- /dev/null +++ b/playground/spa-ts-with-tests/src/App.vue @@ -0,0 +1,30 @@ + + + diff --git a/playground/spa-ts-with-tests/src/assets/logo.png b/playground/spa-ts-with-tests/src/assets/logo.png new file mode 100644 index 00000000..f3d2503f Binary files /dev/null and b/playground/spa-ts-with-tests/src/assets/logo.png differ diff --git a/playground/spa-ts-with-tests/src/components/HelloWorld.vue b/playground/spa-ts-with-tests/src/components/HelloWorld.vue new file mode 100644 index 00000000..2dac5234 --- /dev/null +++ b/playground/spa-ts-with-tests/src/components/HelloWorld.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/playground/spa-ts-with-tests/src/components/__tests__/HelloWorld.spec.ts b/playground/spa-ts-with-tests/src/components/__tests__/HelloWorld.spec.ts new file mode 100644 index 00000000..087c9561 --- /dev/null +++ b/playground/spa-ts-with-tests/src/components/__tests__/HelloWorld.spec.ts @@ -0,0 +1,22 @@ +import { mount } from '@cypress/vue' +import HelloWorld from '../HelloWorld.vue' + +describe('HelloWorld', () => { + it('playground', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + }) + + it('renders properly', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + cy.get('h1').should('contain', 'Hello Cypress') + }) + + it('adds 1 when clicking the plus button', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + + cy.get('button') + .should('contain', '0') + .click() + .should('contain', '1') + }) +}) diff --git a/playground/spa-ts-with-tests/src/main.ts b/playground/spa-ts-with-tests/src/main.ts new file mode 100644 index 00000000..ab55e6d5 --- /dev/null +++ b/playground/spa-ts-with-tests/src/main.ts @@ -0,0 +1,12 @@ +import { createApp } from 'vue' +import App from './App.vue' + +import router from './router' +import store from './store' + +const app = createApp(App) + +app.use(router) +app.use(store) + +app.mount('#app') diff --git a/playground/spa-ts-with-tests/src/router/index.ts b/playground/spa-ts-with-tests/src/router/index.ts new file mode 100644 index 00000000..06036285 --- /dev/null +++ b/playground/spa-ts-with-tests/src/router/index.ts @@ -0,0 +1,27 @@ +import { createRouter, createWebHistory } from 'vue-router' +import type { RouteRecordRaw } from 'vue-router' + +import Home from '../views/Home.vue' + +const routes: Array = [ + { + path: '/', + name: 'Home', + component: Home + }, + { + path: '/about', + name: 'About', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/About.vue') + } +] + +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes +}) + +export default router diff --git a/playground/spa-ts-with-tests/src/shims-vue.d.ts b/playground/spa-ts-with-tests/src/shims-vue.d.ts new file mode 100644 index 00000000..ec4f1b2e --- /dev/null +++ b/playground/spa-ts-with-tests/src/shims-vue.d.ts @@ -0,0 +1,6 @@ +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/playground/spa-ts-with-tests/src/store/index.ts b/playground/spa-ts-with-tests/src/store/index.ts new file mode 100644 index 00000000..5f05f193 --- /dev/null +++ b/playground/spa-ts-with-tests/src/store/index.ts @@ -0,0 +1,12 @@ +import { createStore } from 'vuex' + +export default createStore({ + state: { + }, + mutations: { + }, + actions: { + }, + modules: { + } +}) diff --git a/playground/spa-ts-with-tests/src/views/About.vue b/playground/spa-ts-with-tests/src/views/About.vue new file mode 100644 index 00000000..3fa28070 --- /dev/null +++ b/playground/spa-ts-with-tests/src/views/About.vue @@ -0,0 +1,5 @@ + diff --git a/playground/spa-ts-with-tests/src/views/Home.vue b/playground/spa-ts-with-tests/src/views/Home.vue new file mode 100644 index 00000000..4ade1db6 --- /dev/null +++ b/playground/spa-ts-with-tests/src/views/Home.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/playground/spa-ts-with-tests/src/vite-env.d.ts b/playground/spa-ts-with-tests/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/playground/spa-ts-with-tests/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/playground/spa-ts-with-tests/tsconfig.json b/playground/spa-ts-with-tests/tsconfig.json new file mode 100644 index 00000000..d3adf1bf --- /dev/null +++ b/playground/spa-ts-with-tests/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"], + "skipLibCheck": true + }, + "include": [ + "vite.config.*", + + "src/**/*", + "src/**/*.vue" + ], + "exclude": [ + "src/**/__tests__/**" + ] +} diff --git a/playground/spa-ts-with-tests/vite.config.ts b/playground/spa-ts-with-tests/vite.config.ts new file mode 100644 index 00000000..8ae6fd07 --- /dev/null +++ b/playground/spa-ts-with-tests/vite.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx()], + resolve: { + alias: { + '@/': new URL('./src/', import.meta.url).pathname, + }, + } +}) diff --git a/playground/spa-ts/.gitignore b/playground/spa-ts/.gitignore new file mode 100644 index 00000000..133da84e --- /dev/null +++ b/playground/spa-ts/.gitignore @@ -0,0 +1,27 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/playground/spa-ts/README.md b/playground/spa-ts/README.md new file mode 100644 index 00000000..e69de29b diff --git a/playground/spa-ts/index.html b/playground/spa-ts/index.html new file mode 100644 index 00000000..11603f87 --- /dev/null +++ b/playground/spa-ts/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/playground/spa-ts/package.json b/playground/spa-ts/package.json new file mode 100644 index 00000000..c9ae486e --- /dev/null +++ b/playground/spa-ts/package.json @@ -0,0 +1,24 @@ +{ + "name": "spa-ts", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vue-tsc --noEmit && vite build", + "preserve": "vite build", + "serve": "vite preview --port 5050", + "typecheck": "vue-tsc --noEmit" + }, + "dependencies": { + "vue": "^3.1.5", + "vue-router": "^4.0.10", + "vuex": "^4.0.2" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^1.2.5", + "@vitejs/plugin-vue-jsx": "^1.1.6", + "@vue/compiler-sfc": "^3.1.5", + "vite": "^2.4.3", + "typescript": "~4.3.5", + "vue-tsc": "^0.2.2" + } +} \ No newline at end of file diff --git a/playground/spa-ts/public/favicon.ico b/playground/spa-ts/public/favicon.ico new file mode 100644 index 00000000..df36fcfb Binary files /dev/null and b/playground/spa-ts/public/favicon.ico differ diff --git a/playground/spa-ts/src/App.vue b/playground/spa-ts/src/App.vue new file mode 100644 index 00000000..b9643551 --- /dev/null +++ b/playground/spa-ts/src/App.vue @@ -0,0 +1,30 @@ + + + diff --git a/playground/spa-ts/src/assets/logo.png b/playground/spa-ts/src/assets/logo.png new file mode 100644 index 00000000..f3d2503f Binary files /dev/null and b/playground/spa-ts/src/assets/logo.png differ diff --git a/playground/spa-ts/src/components/HelloWorld.vue b/playground/spa-ts/src/components/HelloWorld.vue new file mode 100644 index 00000000..2dac5234 --- /dev/null +++ b/playground/spa-ts/src/components/HelloWorld.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/playground/spa-ts/src/main.ts b/playground/spa-ts/src/main.ts new file mode 100644 index 00000000..ab55e6d5 --- /dev/null +++ b/playground/spa-ts/src/main.ts @@ -0,0 +1,12 @@ +import { createApp } from 'vue' +import App from './App.vue' + +import router from './router' +import store from './store' + +const app = createApp(App) + +app.use(router) +app.use(store) + +app.mount('#app') diff --git a/playground/spa-ts/src/router/index.ts b/playground/spa-ts/src/router/index.ts new file mode 100644 index 00000000..06036285 --- /dev/null +++ b/playground/spa-ts/src/router/index.ts @@ -0,0 +1,27 @@ +import { createRouter, createWebHistory } from 'vue-router' +import type { RouteRecordRaw } from 'vue-router' + +import Home from '../views/Home.vue' + +const routes: Array = [ + { + path: '/', + name: 'Home', + component: Home + }, + { + path: '/about', + name: 'About', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/About.vue') + } +] + +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes +}) + +export default router diff --git a/playground/spa-ts/src/shims-vue.d.ts b/playground/spa-ts/src/shims-vue.d.ts new file mode 100644 index 00000000..ec4f1b2e --- /dev/null +++ b/playground/spa-ts/src/shims-vue.d.ts @@ -0,0 +1,6 @@ +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/playground/spa-ts/src/store/index.ts b/playground/spa-ts/src/store/index.ts new file mode 100644 index 00000000..5f05f193 --- /dev/null +++ b/playground/spa-ts/src/store/index.ts @@ -0,0 +1,12 @@ +import { createStore } from 'vuex' + +export default createStore({ + state: { + }, + mutations: { + }, + actions: { + }, + modules: { + } +}) diff --git a/playground/spa-ts/src/views/About.vue b/playground/spa-ts/src/views/About.vue new file mode 100644 index 00000000..3fa28070 --- /dev/null +++ b/playground/spa-ts/src/views/About.vue @@ -0,0 +1,5 @@ + diff --git a/playground/spa-ts/src/views/Home.vue b/playground/spa-ts/src/views/Home.vue new file mode 100644 index 00000000..4ade1db6 --- /dev/null +++ b/playground/spa-ts/src/views/Home.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/playground/spa-ts/src/vite-env.d.ts b/playground/spa-ts/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/playground/spa-ts/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/playground/spa-ts/tsconfig.json b/playground/spa-ts/tsconfig.json new file mode 100644 index 00000000..d3adf1bf --- /dev/null +++ b/playground/spa-ts/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"], + "skipLibCheck": true + }, + "include": [ + "vite.config.*", + + "src/**/*", + "src/**/*.vue" + ], + "exclude": [ + "src/**/__tests__/**" + ] +} diff --git a/playground/spa-ts/vite.config.ts b/playground/spa-ts/vite.config.ts new file mode 100644 index 00000000..8ae6fd07 --- /dev/null +++ b/playground/spa-ts/vite.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx()], + resolve: { + alias: { + '@/': new URL('./src/', import.meta.url).pathname, + }, + } +}) diff --git a/playground/spa-with-tests/.gitignore b/playground/spa-with-tests/.gitignore new file mode 100644 index 00000000..133da84e --- /dev/null +++ b/playground/spa-with-tests/.gitignore @@ -0,0 +1,27 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/playground/spa-with-tests/README.md b/playground/spa-with-tests/README.md new file mode 100644 index 00000000..e69de29b diff --git a/playground/spa-with-tests/cypress.json b/playground/spa-with-tests/cypress.json new file mode 100644 index 00000000..3d372252 --- /dev/null +++ b/playground/spa-with-tests/cypress.json @@ -0,0 +1,7 @@ +{ + "baseUrl": "http://localhost:5050", + "component": { + "componentFolder": "src", + "testFiles": "**/__tests__/*.spec.{js,ts,jsx,tsx}" + } +} diff --git a/playground/spa-with-tests/cypress/fixtures/example.json b/playground/spa-with-tests/cypress/fixtures/example.json new file mode 100644 index 00000000..02e42543 --- /dev/null +++ b/playground/spa-with-tests/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/playground/spa-with-tests/cypress/integration/example.spec.js b/playground/spa-with-tests/cypress/integration/example.spec.js new file mode 100644 index 00000000..ec952ec4 --- /dev/null +++ b/playground/spa-with-tests/cypress/integration/example.spec.js @@ -0,0 +1,13 @@ +// https://docs.cypress.io/api/introduction/api.html + +describe('My First Test', () => { + it('visits the app root url', () => { + cy.visit('/') + cy.contains('h1', 'Hello Vue 3 + Vite') + }) + + it('navigates to the about page', () => { + cy.visit('/about') + cy.contains('h1', 'This is an about page') + }) +}) diff --git a/playground/spa-with-tests/cypress/jsconfig.json b/playground/spa-with-tests/cypress/jsconfig.json new file mode 100644 index 00000000..b5b2f972 --- /dev/null +++ b/playground/spa-with-tests/cypress/jsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["es5", "dom"], + "types": ["cypress"] + }, + "include": ["./**/*"] +} diff --git a/playground/spa-with-tests/cypress/plugins/index.js b/playground/spa-with-tests/cypress/plugins/index.js new file mode 100644 index 00000000..ad2e351d --- /dev/null +++ b/playground/spa-with-tests/cypress/plugins/index.js @@ -0,0 +1,28 @@ +/// +// *********************************************************** +// This example plugins/index.js can be used to load plugins +// +// You can change the location of this file or turn off loading +// the plugins file with the 'pluginsFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/plugins-guide +// *********************************************************** + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) + +const { startDevServer } = require('@cypress/vite-dev-server') + +/** + * @type {Cypress.PluginConfig} + */ +// eslint-disable-next-line no-unused-vars +module.exports = (on, config) => { + // `on` is used to hook into various events Cypress emits + // `config` is the resolved Cypress config + on('dev-server:start', (options) => { + return startDevServer({ options }) + }) + return config +} diff --git a/playground/spa-with-tests/cypress/support/commands.js b/playground/spa-with-tests/cypress/support/commands.js new file mode 100644 index 00000000..119ab03f --- /dev/null +++ b/playground/spa-with-tests/cypress/support/commands.js @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js 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) => { ... }) diff --git a/playground/spa-with-tests/cypress/support/index.js b/playground/spa-with-tests/cypress/support/index.js new file mode 100644 index 00000000..d68db96d --- /dev/null +++ b/playground/spa-with-tests/cypress/support/index.js @@ -0,0 +1,20 @@ +// *********************************************************** +// This example support/index.js 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') diff --git a/playground/spa-with-tests/index.html b/playground/spa-with-tests/index.html new file mode 100644 index 00000000..11603f87 --- /dev/null +++ b/playground/spa-with-tests/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/playground/spa-with-tests/jsconfig.json b/playground/spa-with-tests/jsconfig.json new file mode 100644 index 00000000..d3adf1bf --- /dev/null +++ b/playground/spa-with-tests/jsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"], + "skipLibCheck": true + }, + "include": [ + "vite.config.*", + + "src/**/*", + "src/**/*.vue" + ], + "exclude": [ + "src/**/__tests__/**" + ] +} diff --git a/playground/spa-with-tests/package.json b/playground/spa-with-tests/package.json new file mode 100644 index 00000000..443e5f8b --- /dev/null +++ b/playground/spa-with-tests/package.json @@ -0,0 +1,29 @@ +{ + "name": "spa-with-tests", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preserve": "vite build", + "serve": "vite preview --port 5050", + "test:unit": "cypress open-ct", + "test:unit:ci": "cypress run-ct --quiet --reporter spec", + "test:e2e": "start-server-and-test serve 5050 'cypress open'", + "test:e2e:ci": "start-server-and-test serve 5050 'cypress run'" + }, + "dependencies": { + "vue": "^3.1.5", + "vue-router": "^4.0.10", + "vuex": "^4.0.2" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^1.2.5", + "@vitejs/plugin-vue-jsx": "^1.1.6", + "@vue/compiler-sfc": "^3.1.5", + "vite": "^2.4.3", + "@cypress/vite-dev-server": "^2.0.2", + "@cypress/vue": "^3.0.1", + "cypress": "^8.0.0", + "start-server-and-test": "^1.12.6" + } +} \ No newline at end of file diff --git a/playground/spa-with-tests/public/favicon.ico b/playground/spa-with-tests/public/favicon.ico new file mode 100644 index 00000000..df36fcfb Binary files /dev/null and b/playground/spa-with-tests/public/favicon.ico differ diff --git a/playground/spa-with-tests/src/App.vue b/playground/spa-with-tests/src/App.vue new file mode 100644 index 00000000..b9643551 --- /dev/null +++ b/playground/spa-with-tests/src/App.vue @@ -0,0 +1,30 @@ + + + diff --git a/playground/spa-with-tests/src/assets/logo.png b/playground/spa-with-tests/src/assets/logo.png new file mode 100644 index 00000000..f3d2503f Binary files /dev/null and b/playground/spa-with-tests/src/assets/logo.png differ diff --git a/playground/spa-with-tests/src/components/HelloWorld.vue b/playground/spa-with-tests/src/components/HelloWorld.vue new file mode 100644 index 00000000..51f81a8f --- /dev/null +++ b/playground/spa-with-tests/src/components/HelloWorld.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/playground/spa-with-tests/src/components/__tests__/HelloWorld.spec.js b/playground/spa-with-tests/src/components/__tests__/HelloWorld.spec.js new file mode 100644 index 00000000..087c9561 --- /dev/null +++ b/playground/spa-with-tests/src/components/__tests__/HelloWorld.spec.js @@ -0,0 +1,22 @@ +import { mount } from '@cypress/vue' +import HelloWorld from '../HelloWorld.vue' + +describe('HelloWorld', () => { + it('playground', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + }) + + it('renders properly', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + cy.get('h1').should('contain', 'Hello Cypress') + }) + + it('adds 1 when clicking the plus button', () => { + mount(HelloWorld, { props: { msg: 'Hello Cypress' } }) + + cy.get('button') + .should('contain', '0') + .click() + .should('contain', '1') + }) +}) diff --git a/playground/spa-with-tests/src/main.js b/playground/spa-with-tests/src/main.js new file mode 100644 index 00000000..ab55e6d5 --- /dev/null +++ b/playground/spa-with-tests/src/main.js @@ -0,0 +1,12 @@ +import { createApp } from 'vue' +import App from './App.vue' + +import router from './router' +import store from './store' + +const app = createApp(App) + +app.use(router) +app.use(store) + +app.mount('#app') diff --git a/playground/spa-with-tests/src/router/index.js b/playground/spa-with-tests/src/router/index.js new file mode 100644 index 00000000..26bf8e7e --- /dev/null +++ b/playground/spa-with-tests/src/router/index.js @@ -0,0 +1,25 @@ +import { createRouter, createWebHistory } from 'vue-router' +import Home from '../views/Home.vue' + +const routes = [ + { + path: '/', + name: 'Home', + component: Home + }, + { + path: '/about', + name: 'About', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/About.vue') + } +] + +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes +}) + +export default router diff --git a/playground/spa-with-tests/src/shims-vue.d.ts b/playground/spa-with-tests/src/shims-vue.d.ts new file mode 100644 index 00000000..ec4f1b2e --- /dev/null +++ b/playground/spa-with-tests/src/shims-vue.d.ts @@ -0,0 +1,6 @@ +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/playground/spa-with-tests/src/store/index.js b/playground/spa-with-tests/src/store/index.js new file mode 100644 index 00000000..5f05f193 --- /dev/null +++ b/playground/spa-with-tests/src/store/index.js @@ -0,0 +1,12 @@ +import { createStore } from 'vuex' + +export default createStore({ + state: { + }, + mutations: { + }, + actions: { + }, + modules: { + } +}) diff --git a/playground/spa-with-tests/src/views/About.vue b/playground/spa-with-tests/src/views/About.vue new file mode 100644 index 00000000..3fa28070 --- /dev/null +++ b/playground/spa-with-tests/src/views/About.vue @@ -0,0 +1,5 @@ + diff --git a/playground/spa-with-tests/src/views/Home.vue b/playground/spa-with-tests/src/views/Home.vue new file mode 100644 index 00000000..d74dda2c --- /dev/null +++ b/playground/spa-with-tests/src/views/Home.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/playground/spa-with-tests/src/vite-env.d.ts b/playground/spa-with-tests/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/playground/spa-with-tests/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/playground/spa-with-tests/vite.config.js b/playground/spa-with-tests/vite.config.js new file mode 100644 index 00000000..8ae6fd07 --- /dev/null +++ b/playground/spa-with-tests/vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx()], + resolve: { + alias: { + '@/': new URL('./src/', import.meta.url).pathname, + }, + } +}) diff --git a/playground/spa/.gitignore b/playground/spa/.gitignore new file mode 100644 index 00000000..133da84e --- /dev/null +++ b/playground/spa/.gitignore @@ -0,0 +1,27 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +.DS_Store +dist +dist-ssr +*.local + +/cypress/videos/ +/cypress/screenshots/ + +# Editor directories and files +.vscode +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/playground/spa/README.md b/playground/spa/README.md new file mode 100644 index 00000000..e69de29b diff --git a/playground/spa/index.html b/playground/spa/index.html new file mode 100644 index 00000000..11603f87 --- /dev/null +++ b/playground/spa/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite App + + +
+ + + diff --git a/playground/spa/jsconfig.json b/playground/spa/jsconfig.json new file mode 100644 index 00000000..d3adf1bf --- /dev/null +++ b/playground/spa/jsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "paths": { + "@/*": [ + "src/*" + ] + }, + "lib": ["esnext", "dom", "dom.iterable", "scripthost"], + "skipLibCheck": true + }, + "include": [ + "vite.config.*", + + "src/**/*", + "src/**/*.vue" + ], + "exclude": [ + "src/**/__tests__/**" + ] +} diff --git a/playground/spa/package.json b/playground/spa/package.json new file mode 100644 index 00000000..a98131e1 --- /dev/null +++ b/playground/spa/package.json @@ -0,0 +1,21 @@ +{ + "name": "spa", + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build", + "preserve": "vite build", + "serve": "vite preview --port 5050" + }, + "dependencies": { + "vue": "^3.1.5", + "vue-router": "^4.0.10", + "vuex": "^4.0.2" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^1.2.5", + "@vitejs/plugin-vue-jsx": "^1.1.6", + "@vue/compiler-sfc": "^3.1.5", + "vite": "^2.4.3" + } +} \ No newline at end of file diff --git a/playground/spa/public/favicon.ico b/playground/spa/public/favicon.ico new file mode 100644 index 00000000..df36fcfb Binary files /dev/null and b/playground/spa/public/favicon.ico differ diff --git a/playground/spa/src/App.vue b/playground/spa/src/App.vue new file mode 100644 index 00000000..b9643551 --- /dev/null +++ b/playground/spa/src/App.vue @@ -0,0 +1,30 @@ + + + diff --git a/playground/spa/src/assets/logo.png b/playground/spa/src/assets/logo.png new file mode 100644 index 00000000..f3d2503f Binary files /dev/null and b/playground/spa/src/assets/logo.png differ diff --git a/playground/spa/src/components/HelloWorld.vue b/playground/spa/src/components/HelloWorld.vue new file mode 100644 index 00000000..51f81a8f --- /dev/null +++ b/playground/spa/src/components/HelloWorld.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/playground/spa/src/main.js b/playground/spa/src/main.js new file mode 100644 index 00000000..ab55e6d5 --- /dev/null +++ b/playground/spa/src/main.js @@ -0,0 +1,12 @@ +import { createApp } from 'vue' +import App from './App.vue' + +import router from './router' +import store from './store' + +const app = createApp(App) + +app.use(router) +app.use(store) + +app.mount('#app') diff --git a/playground/spa/src/router/index.js b/playground/spa/src/router/index.js new file mode 100644 index 00000000..26bf8e7e --- /dev/null +++ b/playground/spa/src/router/index.js @@ -0,0 +1,25 @@ +import { createRouter, createWebHistory } from 'vue-router' +import Home from '../views/Home.vue' + +const routes = [ + { + path: '/', + name: 'Home', + component: Home + }, + { + path: '/about', + name: 'About', + // route level code-splitting + // this generates a separate chunk (About.[hash].js) for this route + // which is lazy-loaded when the route is visited. + component: () => import('../views/About.vue') + } +] + +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes +}) + +export default router diff --git a/playground/spa/src/shims-vue.d.ts b/playground/spa/src/shims-vue.d.ts new file mode 100644 index 00000000..ec4f1b2e --- /dev/null +++ b/playground/spa/src/shims-vue.d.ts @@ -0,0 +1,6 @@ +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/playground/spa/src/store/index.js b/playground/spa/src/store/index.js new file mode 100644 index 00000000..5f05f193 --- /dev/null +++ b/playground/spa/src/store/index.js @@ -0,0 +1,12 @@ +import { createStore } from 'vuex' + +export default createStore({ + state: { + }, + mutations: { + }, + actions: { + }, + modules: { + } +}) diff --git a/playground/spa/src/views/About.vue b/playground/spa/src/views/About.vue new file mode 100644 index 00000000..3fa28070 --- /dev/null +++ b/playground/spa/src/views/About.vue @@ -0,0 +1,5 @@ + diff --git a/playground/spa/src/views/Home.vue b/playground/spa/src/views/Home.vue new file mode 100644 index 00000000..d74dda2c --- /dev/null +++ b/playground/spa/src/views/Home.vue @@ -0,0 +1,19 @@ + + + + + diff --git a/playground/spa/src/vite-env.d.ts b/playground/spa/src/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/playground/spa/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/playground/spa/vite.config.js b/playground/spa/vite.config.js new file mode 100644 index 00000000..8ae6fd07 --- /dev/null +++ b/playground/spa/vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue(), vueJsx()], + resolve: { + alias: { + '@/': new URL('./src/', import.meta.url).pathname, + }, + } +}) diff --git a/snapshot.js b/snapshot.js new file mode 100644 index 00000000..53b0c5fc --- /dev/null +++ b/snapshot.js @@ -0,0 +1,13 @@ +import templateList from './utils/templateList.js' +import { spawnSync } from 'child_process' + +for (const template of templateList) { + spawnSync('node', [ + new URL('./index.js', import.meta.url).pathname, + template, + '--template', + template + ], { + cwd: new URL('./playground/', import.meta.url).pathname + }) +} diff --git a/utils/templateList.js b/utils/templateList.js new file mode 100644 index 00000000..cdcb4221 --- /dev/null +++ b/utils/templateList.js @@ -0,0 +1,5 @@ +const templateList = ['default', 'spa'] + .flatMap(x => [x, x + '-ts']) + .flatMap(x => [x, x + '-with-tests']) + +export default templateList