]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
wip: basic structure
authorHaoqun Jiang <haoqunjiang@gmail.com>
Fri, 23 Jul 2021 06:03:21 +0000 (14:03 +0800)
committerHaoqun Jiang <haoqunjiang@gmail.com>
Fri, 23 Jul 2021 06:04:40 +0000 (14:04 +0800)
40 files changed:
index.js [new file with mode: 0644]
package.json [new file with mode: 0644]
playground/.gitkeep [new file with mode: 0644]
pnpm-lock.yaml [new file with mode: 0644]
renderTemplate.js [new file with mode: 0644]
template/config/base/.vscode/extensions.json [new file with mode: 0644]
template/config/base/README.md [new file with mode: 0644]
template/config/base/_gitignore [new file with mode: 0644]
template/config/base/index.html [new file with mode: 0644]
template/config/base/package.json [new file with mode: 0644]
template/config/base/public/favicon.ico [new file with mode: 0644]
template/config/base/vite.config.js [new file with mode: 0644]
template/config/cypress/cypress.json [new file with mode: 0644]
template/config/cypress/cypress/fixtures/example.json [new file with mode: 0644]
template/config/cypress/cypress/plugins/index.js [new file with mode: 0644]
template/config/cypress/cypress/support/commands.js [new file with mode: 0644]
template/config/cypress/cypress/support/index.js [new file with mode: 0644]
template/config/cypress/cypress/tsconfig.json [new file with mode: 0644]
template/config/cypress/package.json [new file with mode: 0644]
template/config/typescript/package.json [new file with mode: 0644]
template/config/typescript/src/shims-vue.d.ts [new file with mode: 0644]
template/config/typescript/src/vite-env.d.ts [new file with mode: 0644]
template/config/typescript/tsconfig.json [new file with mode: 0644]
template/config/typescript/vite.config.ts [new file with mode: 0644]
template/source/default/cypress/integration/example.spec.js [new file with mode: 0644]
template/source/spa/cypress/integration/example.spec.js [new file with mode: 0644]
template/source/spa/package.json [new file with mode: 0644]
template/source/typescript-default/cypress/integration/example.spec.ts [new file with mode: 0644]
template/source/typescript-spa/cypress/integration/example.spec.ts [new file with mode: 0644]
template/source/typescript-spa/src/App.vue [new file with mode: 0644]
template/source/typescript-spa/src/assets/logo.png [new file with mode: 0644]
template/source/typescript-spa/src/components/HelloWorld.vue [new file with mode: 0644]
template/source/typescript-spa/src/components/__tests__/HelloWorld.spec.ts [new file with mode: 0644]
template/source/typescript-spa/src/main.ts [new file with mode: 0644]
template/source/typescript-spa/src/router/index.ts [new file with mode: 0644]
template/source/typescript-spa/src/shims-vue.d.ts [new file with mode: 0644]
template/source/typescript-spa/src/store/index.ts [new file with mode: 0644]
template/source/typescript-spa/src/views/About.vue [new file with mode: 0644]
template/source/typescript-spa/src/views/Home.vue [new file with mode: 0644]
template/source/typescript-spa/src/vite-env.d.ts [new file with mode: 0644]

diff --git a/index.js b/index.js
new file mode 100644 (file)
index 0000000..0d33e06
--- /dev/null
+++ b/index.js
@@ -0,0 +1,40 @@
+import prompts from 'prompts'
+import kolorist from 'kolorist'
+
+import renderTemplate from './renderTemplate.js'
+
+// Prompts:
+// - Project name:
+// - Project language: JavaScript / TypeScript
+// - Install Vue Router & Vuex for Single Page Applications?
+// - Adding tests?
+
+// TODO:
+// add command-line for all possible option combinations
+// so that we can generate them in playgrounds
+
+// Add configs.
+// renderTemplate('config/base')
+// if (needs tests) {
+//   renderTemplate('config/cypress')
+// }
+// if (is typescript) {
+//   renderTemplate('config/typescript')
+// }
+
+// sourceTemplateName =
+//   (isTs ? 'typescript-' : '') +
+//   (isSPA ? 'spa' : 'default')
+// renderTemplate(`source/${sourceTemplateName}`)
+
+// Cleanup.
+
+// All templates assumes the need of tests.
+// If the user doesn't need it:
+// rm -rf cypress **/__tests__/
+
+// TS config template may add redundant tsconfig.json.
+// Should clean that too.
+
+// Instructions:
+// Supported package managers: pnpm > yarn > npm
diff --git a/package.json b/package.json
new file mode 100644 (file)
index 0000000..90b1484
--- /dev/null
@@ -0,0 +1,36 @@
+{
+  "name": "create-vue",
+  "version": "3.0.0",
+  "description": "An easy way to start a Vue project",
+  "type": "module",
+  "main": "index.js",
+  "bin": {
+    "create-vue": "index.js"
+  },
+  "files": [
+    "index.js",
+    "renderTemplate.js",
+    "templates"
+  ],
+  "engines": {
+    "node": "^12.13.0 || ^14.0.0 || >= 16.0.0"
+  },
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/vuejs/create-vue.git"
+  },
+  "keywords": [],
+  "author": "Haoqun Jiang <haoqunjiang+npm@gmail.com>",
+  "license": "ISC",
+  "bugs": {
+    "url": "https://github.com/vuejs/create-vue/issues"
+  },
+  "homepage": "https://github.com/vuejs/create-vue#readme",
+  "dependencies": {
+    "kolorist": "^1.5.0",
+    "prompts": "^2.4.1"
+  }
+}
diff --git a/playground/.gitkeep b/playground/.gitkeep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
new file mode 100644 (file)
index 0000000..6cb3518
--- /dev/null
@@ -0,0 +1,32 @@
+lockfileVersion: 5.3
+
+specifiers:
+  kolorist: ^1.5.0
+  prompts: ^2.4.1
+
+dependencies:
+  kolorist: 1.5.0
+  prompts: 2.4.1
+
+packages:
+
+  /kleur/3.0.3:
+    resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
+    engines: {node: '>=6'}
+    dev: false
+
+  /kolorist/1.5.0:
+    resolution: {integrity: sha512-pPobydIHK884YBtkS/tWSZXpSAEpcMbilyun3KL37ot935qL2HNKm/tI45i/Rd+MxdIWEhm7/LmUQzWZYK+Qhg==}
+    dev: false
+
+  /prompts/2.4.1:
+    resolution: {integrity: sha512-EQyfIuO2hPDsX1L/blblV+H7I0knhgAd82cVneCwcdND9B8AuCDuRcBH6yIcG4dFzlOUqbazQqwGjx5xmsNLuQ==}
+    engines: {node: '>= 6'}
+    dependencies:
+      kleur: 3.0.3
+      sisteransi: 1.0.5
+    dev: false
+
+  /sisteransi/1.0.5:
+    resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==}
+    dev: false
diff --git a/renderTemplate.js b/renderTemplate.js
new file mode 100644 (file)
index 0000000..cdf3fbc
--- /dev/null
@@ -0,0 +1,7 @@
+export default function renderTemplate(templateFolder) {
+  // TODO:
+  // Recursively copy all files under `template/${templateFolder}`,
+  // with the following exception:
+  // - `_filename` should be renamed to `.filename`
+  // - Fields in `package.json` should be recursively merged
+}
diff --git a/template/config/base/.vscode/extensions.json b/template/config/base/.vscode/extensions.json
new file mode 100644 (file)
index 0000000..3dc5b08
--- /dev/null
@@ -0,0 +1,3 @@
+{
+  "recommendations": ["johnsoncodehk.volar"]
+}
diff --git a/template/config/base/README.md b/template/config/base/README.md
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/template/config/base/_gitignore b/template/config/base/_gitignore
new file mode 100644 (file)
index 0000000..133da84
--- /dev/null
@@ -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/template/config/base/index.html b/template/config/base/index.html
new file mode 100644 (file)
index 0000000..11603f8
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <link rel="icon" href="/favicon.ico" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Vite App</title>
+  </head>
+  <body>
+    <div id="app"></div>
+    <script type="module" src="/src/main.ts"></script>
+  </body>
+</html>
diff --git a/template/config/base/package.json b/template/config/base/package.json
new file mode 100644 (file)
index 0000000..ede5f01
--- /dev/null
@@ -0,0 +1,17 @@
+{
+  "scripts": {
+    "dev": "vite",
+    "build": "vite build",
+    "prepreview": "vite build",
+    "preview": "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"
+  }
+}
diff --git a/template/config/base/public/favicon.ico b/template/config/base/public/favicon.ico
new file mode 100644 (file)
index 0000000..df36fcf
Binary files /dev/null and b/template/config/base/public/favicon.ico differ
diff --git a/template/config/base/vite.config.js b/template/config/base/vite.config.js
new file mode 100644 (file)
index 0000000..8ae6fd0
--- /dev/null
@@ -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/template/config/cypress/cypress.json b/template/config/cypress/cypress.json
new file mode 100644 (file)
index 0000000..3d37225
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "baseUrl": "http://localhost:5050",
+  "component": {
+    "componentFolder": "src",
+    "testFiles": "**/__tests__/*.spec.{js,ts,jsx,tsx}"
+  }
+}
diff --git a/template/config/cypress/cypress/fixtures/example.json b/template/config/cypress/cypress/fixtures/example.json
new file mode 100644 (file)
index 0000000..02e4254
--- /dev/null
@@ -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/template/config/cypress/cypress/plugins/index.js b/template/config/cypress/cypress/plugins/index.js
new file mode 100644 (file)
index 0000000..ad2e351
--- /dev/null
@@ -0,0 +1,28 @@
+/// <reference types="cypress" />
+// ***********************************************************
+// 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/template/config/cypress/cypress/support/commands.js b/template/config/cypress/cypress/support/commands.js
new file mode 100644 (file)
index 0000000..119ab03
--- /dev/null
@@ -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/template/config/cypress/cypress/support/index.js b/template/config/cypress/cypress/support/index.js
new file mode 100644 (file)
index 0000000..d68db96
--- /dev/null
@@ -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/template/config/cypress/cypress/tsconfig.json b/template/config/cypress/cypress/tsconfig.json
new file mode 100644 (file)
index 0000000..e5d5ea6
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "compilerOptions": {
+    "target": "es5",
+    "lib": ["es5", "dom"],
+    "types": ["cypress"]
+  },
+  "include": ["./**/*.ts"]
+}
diff --git a/template/config/cypress/package.json b/template/config/cypress/package.json
new file mode 100644 (file)
index 0000000..9edbc27
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "scripts": {
+    "test:unit": "cypress open-ct",
+    "test:unit:ci": "cypress run-ct --quiet --reporter spec",
+    "test:e2e": "start-server-and-test preview 5050 'cypress open'",
+    "test:e2e:ci": "start-server-and-test preview 5050 'cypress run'"
+  },
+  "devDependencies": {
+    "@cypress/vite-dev-server": "^2.0.2",
+    "@cypress/vue": "^3.0.1",
+    "cypress": "^8.0.0",
+    "start-server-and-test": "^1.12.6"
+  }
+}
diff --git a/template/config/typescript/package.json b/template/config/typescript/package.json
new file mode 100644 (file)
index 0000000..2f2f369
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "scripts": {
+    "build": "vue-tsc --noEmit && vite build"
+  },
+  "devDependencies": {
+    "typescript": "~4.3.5",
+    "vue-tsc": "^0.2.2"
+  }
+}
diff --git a/template/config/typescript/src/shims-vue.d.ts b/template/config/typescript/src/shims-vue.d.ts
new file mode 100644 (file)
index 0000000..ec4f1b2
--- /dev/null
@@ -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/template/config/typescript/src/vite-env.d.ts b/template/config/typescript/src/vite-env.d.ts
new file mode 100644 (file)
index 0000000..11f02fe
--- /dev/null
@@ -0,0 +1 @@
+/// <reference types="vite/client" />
diff --git a/template/config/typescript/tsconfig.json b/template/config/typescript/tsconfig.json
new file mode 100644 (file)
index 0000000..883a694
--- /dev/null
@@ -0,0 +1,28 @@
+{
+  "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"]
+  },
+  "include": [
+    "vite.config.ts",
+
+    "src/**/*.ts",
+    "src/**/*.d.ts",
+    "src/**/*.tsx",
+    "src/**/*.vue"
+  ]
+}
diff --git a/template/config/typescript/vite.config.ts b/template/config/typescript/vite.config.ts
new file mode 100644 (file)
index 0000000..8ae6fd0
--- /dev/null
@@ -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/template/source/default/cypress/integration/example.spec.js b/template/source/default/cypress/integration/example.spec.js
new file mode 100644 (file)
index 0000000..493bfcf
--- /dev/null
@@ -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/template/source/spa/cypress/integration/example.spec.js b/template/source/spa/cypress/integration/example.spec.js
new file mode 100644 (file)
index 0000000..ec952ec
--- /dev/null
@@ -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/template/source/spa/package.json b/template/source/spa/package.json
new file mode 100644 (file)
index 0000000..364bb2b
--- /dev/null
@@ -0,0 +1,6 @@
+{
+  "dependencies": {
+    "vue-router": "^4.0.10",
+    "vuex": "^4.0.2"
+  }
+}
diff --git a/template/source/typescript-default/cypress/integration/example.spec.ts b/template/source/typescript-default/cypress/integration/example.spec.ts
new file mode 100644 (file)
index 0000000..bbe8f52
--- /dev/null
@@ -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/template/source/typescript-spa/cypress/integration/example.spec.ts b/template/source/typescript-spa/cypress/integration/example.spec.ts
new file mode 100644 (file)
index 0000000..3898b0c
--- /dev/null
@@ -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/template/source/typescript-spa/src/App.vue b/template/source/typescript-spa/src/App.vue
new file mode 100644 (file)
index 0000000..b964355
--- /dev/null
@@ -0,0 +1,30 @@
+<template>
+  <div id="nav">
+    <router-link to="/">Home</router-link> |
+    <router-link to="/about">About</router-link>
+  </div>
+  <router-view/>
+</template>
+
+<style>
+#app {
+  font-family: Avenir, Helvetica, Arial, sans-serif;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+  text-align: center;
+  color: #2c3e50;
+}
+
+#nav {
+  padding: 30px;
+}
+
+#nav a {
+  font-weight: bold;
+  color: #2c3e50;
+}
+
+#nav a.router-link-exact-active {
+  color: #42b983;
+}
+</style>
diff --git a/template/source/typescript-spa/src/assets/logo.png b/template/source/typescript-spa/src/assets/logo.png
new file mode 100644 (file)
index 0000000..f3d2503
Binary files /dev/null and b/template/source/typescript-spa/src/assets/logo.png differ
diff --git a/template/source/typescript-spa/src/components/HelloWorld.vue b/template/source/typescript-spa/src/components/HelloWorld.vue
new file mode 100644 (file)
index 0000000..383c309
--- /dev/null
@@ -0,0 +1,57 @@
+<template>
+  <h1>{{ msg }}</h1>
+
+  <p>
+    Recommended IDE setup:
+    <a href="https://code.visualstudio.com/" target="_blank">VSCode</a>
+    +
+    <a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
+  </p>
+
+  <p>See <code>README.md</code> for more information.</p>
+
+  <p>
+    <a href="https://vitejs.dev/guide/features.html" target="_blank">
+      Vite Docs
+    </a>
+    |
+    <a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
+  </p>
+
+  <button type="button" @click="count++">count is: {{ count }}</button>
+  <p>
+    Edit
+    <code>components/HelloWorld.vue</code> to test hot module replacement.
+  </p>
+</template>
+
+<script setup lang="ts">
+import { ref, defineComponent } from 'vue'
+
+defineProps({
+  msg: {
+    type: String,
+    required: true
+  }
+})
+
+const count = ref(0)
+</script>
+
+<style scoped>
+a {
+  color: #42b983;
+}
+
+label {
+  margin: 0 0.5em;
+  font-weight: bold;
+}
+
+code {
+  background-color: #eee;
+  padding: 2px 4px;
+  border-radius: 4px;
+  color: #304455;
+}
+</style>
diff --git a/template/source/typescript-spa/src/components/__tests__/HelloWorld.spec.ts b/template/source/typescript-spa/src/components/__tests__/HelloWorld.spec.ts
new file mode 100644 (file)
index 0000000..087c956
--- /dev/null
@@ -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/template/source/typescript-spa/src/main.ts b/template/source/typescript-spa/src/main.ts
new file mode 100644 (file)
index 0000000..ab55e6d
--- /dev/null
@@ -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/template/source/typescript-spa/src/router/index.ts b/template/source/typescript-spa/src/router/index.ts
new file mode 100644 (file)
index 0000000..8e2f95e
--- /dev/null
@@ -0,0 +1,25 @@
+import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
+import Home from '../views/Home.vue'
+
+const routes: Array<RouteRecordRaw> = [
+  {
+    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/template/source/typescript-spa/src/shims-vue.d.ts b/template/source/typescript-spa/src/shims-vue.d.ts
new file mode 100644 (file)
index 0000000..ec4f1b2
--- /dev/null
@@ -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/template/source/typescript-spa/src/store/index.ts b/template/source/typescript-spa/src/store/index.ts
new file mode 100644 (file)
index 0000000..5f05f19
--- /dev/null
@@ -0,0 +1,12 @@
+import { createStore } from 'vuex'
+
+export default createStore({
+  state: {
+  },
+  mutations: {
+  },
+  actions: {
+  },
+  modules: {
+  }
+})
diff --git a/template/source/typescript-spa/src/views/About.vue b/template/source/typescript-spa/src/views/About.vue
new file mode 100644 (file)
index 0000000..3fa2807
--- /dev/null
@@ -0,0 +1,5 @@
+<template>
+  <div class="about">
+    <h1>This is an about page</h1>
+  </div>
+</template>
diff --git a/template/source/typescript-spa/src/views/Home.vue b/template/source/typescript-spa/src/views/Home.vue
new file mode 100644 (file)
index 0000000..4ade1db
--- /dev/null
@@ -0,0 +1,19 @@
+<template>
+  <img alt="Vue logo" src="@/assets/logo.png" />
+  <HelloWorld msg="Hello Vue 3 + TypeScript + Vite" />
+</template>
+
+<script setup lang="ts">
+import HelloWorld from '@/components/HelloWorld.vue'
+</script>
+
+<style>
+#app {
+  font-family: Avenir, Helvetica, Arial, sans-serif;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+  text-align: center;
+  color: #2c3e50;
+  margin-top: 60px;
+}
+</style>
diff --git a/template/source/typescript-spa/src/vite-env.d.ts b/template/source/typescript-spa/src/vite-env.d.ts
new file mode 100644 (file)
index 0000000..11f02fe
--- /dev/null
@@ -0,0 +1 @@
+/// <reference types="vite/client" />