From: Haoqun Jiang Date: Tue, 7 Sep 2021 08:39:12 +0000 (+0800) Subject: chore: regenerate the playground projects X-Git-Tag: v3.0.0-beta.1~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8de8b0353dd2d8ad60c317045fb354693dbc2350;p=thirdparty%2Fvuejs%2Fcreate-vue.git chore: regenerate the playground projects --- diff --git a/index.js b/index.js index c99f0169..ab3eae75 100755 --- a/index.js +++ b/index.js @@ -9,17 +9,12 @@ import prompts from 'prompts' import { red, green, bold } from 'kolorist' import renderTemplate from './utils/renderTemplate.js' -import { - postOrderDirectoryTraverse, - preOrderDirectoryTraverse -} from './utils/directoryTraverse.js' +import { postOrderDirectoryTraverse, preOrderDirectoryTraverse } from './utils/directoryTraverse.js' import generateReadme from './utils/generateReadme.js' import getCommand from './utils/getCommand.js' function isValidPackageName(projectName) { - return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test( - projectName - ) + return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName) } function toValidPackageName(projectName) { @@ -66,14 +61,8 @@ async function init() { // if any of the feature flags is set, we would skip the feature prompts // use `??` instead of `||` once we drop Node.js 12 support const isFeatureFlagsUsed = - typeof ( - argv.default || - argv.ts || - argv.jsx || - argv.router || - argv.vuex || - argv.tests - ) === 'boolean' + typeof (argv.default || argv.ts || argv.jsx || argv.router || argv.vuex || argv.tests) === + 'boolean' let targetDir = argv._[0] const defaultProjectName = !targetDir ? 'vue-project' : targetDir @@ -99,18 +88,14 @@ async function init() { type: targetDir ? null : 'text', message: 'Project name:', initial: defaultProjectName, - onState: (state) => - (targetDir = String(state.value).trim() || defaultProjectName) + onState: (state) => (targetDir = String(state.value).trim() || defaultProjectName) }, { name: 'shouldOverwrite', - type: () => - canSafelyOverwrite(targetDir) || forceOverwrite ? null : 'confirm', + type: () => (canSafelyOverwrite(targetDir) || forceOverwrite ? null : 'confirm'), message: () => { const dirForPrompt = - targetDir === '.' - ? 'Current directory' - : `Target directory "${targetDir}"` + targetDir === '.' ? 'Current directory' : `Target directory "${targetDir}"` return `${dirForPrompt} is not empty. Remove existing files and continue?` } @@ -129,8 +114,7 @@ async function init() { type: () => (isValidPackageName(targetDir) ? null : 'text'), message: 'Package name:', initial: () => toValidPackageName(targetDir), - validate: (dir) => - isValidPackageName(dir) || 'Invalid package.json name' + validate: (dir) => isValidPackageName(dir) || 'Invalid package.json name' }, { name: 'needsTypeScript', @@ -206,10 +190,7 @@ async function init() { console.log(`\nScaffolding project in ${root}...`) const pkg = { name: packageName, version: '0.0.0' } - fs.writeFileSync( - path.resolve(root, 'package.json'), - JSON.stringify(pkg, null, 2) - ) + fs.writeFileSync(path.resolve(root, 'package.json'), JSON.stringify(pkg, null, 2)) const templateRoot = new URL('./template', import.meta.url).pathname const render = function render(templateName) { @@ -267,10 +248,7 @@ async function init() { if (filepath.endsWith('.js')) { fs.renameSync(filepath, filepath.replace(/\.js$/, '.ts')) } else if (path.basename(filepath) === 'jsconfig.json') { - fs.renameSync( - filepath, - filepath.replace(/jsconfig\.json$/, 'tsconfig.json') - ) + fs.renameSync(filepath, filepath.replace(/jsconfig\.json$/, 'tsconfig.json')) } } ) @@ -278,10 +256,7 @@ async function init() { // Rename entry in `index.html` const indexHtmlPath = path.resolve(root, 'index.html') const indexHtmlContent = fs.readFileSync(indexHtmlPath, 'utf8') - fs.writeFileSync( - indexHtmlPath, - indexHtmlContent.replace('src/main.js', 'src/main.ts') - ) + fs.writeFileSync(indexHtmlPath, indexHtmlContent.replace('src/main.js', 'src/main.ts')) } if (!needsTests) { diff --git a/playground/default/README.md b/playground/default/README.md index 134a494c..c1783556 100644 --- a/playground/default/README.md +++ b/playground/default/README.md @@ -13,17 +13,17 @@ See [Vite Configuration Reference](https://vitejs.dev/config/). ## Project Setup ```sh -npm install +pnpm install ``` ### Compile and Hot-Reload for Development ```sh -npm run dev +pnpm dev ``` ### Compile and Minify for Production ```sh -npm run build +pnpm build ``` diff --git a/playground/default/src/App.vue b/playground/default/src/App.vue index ab188d52..945ae423 100644 --- a/playground/default/src/App.vue +++ b/playground/default/src/App.vue @@ -1,13 +1,6 @@ diff --git a/playground/default/src/assets/base.css b/playground/default/src/assets/base.css index 6198c024..5427a030 100644 --- a/playground/default/src/assets/base.css +++ b/playground/default/src/assets/base.css @@ -12,7 +12,7 @@ --vt-c-divider-light-1: rgba(60, 60, 60, 0.29); --vt-c-divider-light-2: rgba(60, 60, 60, 0.12); - --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65); + --vt-c-divider-dadarkrk-1: rgba(84, 84, 84, 0.65); --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48); --vt-c-text-light-1: var(--vt-c-indigo); @@ -36,16 +36,18 @@ --section-gap: 160px; } -[data-color-scheme='dark'] { - --color-background: var(--vt-c-black); - --color-background-soft: var(--vt-c-black-soft); - --color-background-mute: var(--vt-c-black-mute); +@media (prefers-color-scheme: dark) { + :root { + --color-background: var(--vt-c-black); + --color-background-soft: var(--vt-c-black-soft); + --color-background-mute: var(--vt-c-black-mute); - --color-border: var(--vt-c-divider-dark-2); - --color-border-hover: var(--vt-c-divider-dark-1); + --color-border: var(--vt-c-divider-dark-2); + --color-border-hover: var(--vt-c-divider-dark-1); - --color-heading: var(--vt-c-text-dark-1); - --color-text: var(--vt-c-text-dark-2); + --color-heading: var(--vt-c-text-dark-1); + --color-text: var(--vt-c-text-dark-2); + } } *, diff --git a/playground/default/src/assets/logo.png b/playground/default/src/assets/logo.png deleted file mode 100644 index f3d2503f..00000000 Binary files a/playground/default/src/assets/logo.png and /dev/null differ diff --git a/playground/default/src/components/ColorSchemeSwitch.vue b/playground/default/src/components/ColorSchemeSwitch.vue deleted file mode 100644 index 8e5bb4e2..00000000 --- a/playground/default/src/components/ColorSchemeSwitch.vue +++ /dev/null @@ -1,137 +0,0 @@ - - - - - diff --git a/playground/default/src/components/Welcome.vue b/playground/default/src/components/Welcome.vue new file mode 100644 index 00000000..1d003f86 --- /dev/null +++ b/playground/default/src/components/Welcome.vue @@ -0,0 +1,84 @@ + + + diff --git a/playground/default/src/components/IntroductionItem.vue b/playground/default/src/components/WelcomeItem.vue similarity index 100% rename from playground/default/src/components/IntroductionItem.vue rename to playground/default/src/components/WelcomeItem.vue diff --git a/playground/default/src/components/icons/Community.vue b/playground/default/src/components/icons/IconCommunity.vue similarity index 100% rename from playground/default/src/components/icons/Community.vue rename to playground/default/src/components/icons/IconCommunity.vue diff --git a/playground/default/src/components/icons/Documentation.vue b/playground/default/src/components/icons/IconDocumentation.vue similarity index 100% rename from playground/default/src/components/icons/Documentation.vue rename to playground/default/src/components/icons/IconDocumentation.vue diff --git a/playground/default/src/components/icons/Ecosystem.vue b/playground/default/src/components/icons/IconEcosystem.vue similarity index 100% rename from playground/default/src/components/icons/Ecosystem.vue rename to playground/default/src/components/icons/IconEcosystem.vue diff --git a/playground/default/src/components/icons/Support.vue b/playground/default/src/components/icons/IconSupport.vue similarity index 100% rename from playground/default/src/components/icons/Support.vue rename to playground/default/src/components/icons/IconSupport.vue diff --git a/playground/default/src/components/icons/Tooling.vue b/playground/default/src/components/icons/IconTooling.vue similarity index 100% rename from playground/default/src/components/icons/Tooling.vue rename to playground/default/src/components/icons/IconTooling.vue diff --git a/playground/default/src/components/icons/Moon.vue b/playground/default/src/components/icons/Moon.vue deleted file mode 100644 index 8e02b917..00000000 --- a/playground/default/src/components/icons/Moon.vue +++ /dev/null @@ -1,18 +0,0 @@ - - - diff --git a/playground/default/src/components/icons/Sun.vue b/playground/default/src/components/icons/Sun.vue deleted file mode 100644 index 577f8031..00000000 --- a/playground/default/src/components/icons/Sun.vue +++ /dev/null @@ -1,34 +0,0 @@ - - - diff --git a/playground/default/src/composables/useColorScheme.js b/playground/default/src/composables/useColorScheme.js deleted file mode 100644 index be111aff..00000000 --- a/playground/default/src/composables/useColorScheme.js +++ /dev/null @@ -1,31 +0,0 @@ -import { ref, computed } from 'vue' -import useMediaQuery from './useMediaQuery' - -// Its value should be consistent when called multiple times. -// So we put it outside the composable function -const isUserToggledDark = ref() - -export default function useColorScheme() { - const isDefaultDark = useMediaQuery('(prefers-color-scheme: dark)') - - const isDark = computed(() => { - if (typeof isUserToggledDark.value !== 'undefined') { - return isUserToggledDark.value - } else { - return isDefaultDark.value - } - }) - - const toggle = () => { - if (typeof isUserToggledDark.value !== 'undefined') { - isUserToggledDark.value = !isUserToggledDark.value - } else { - isUserToggledDark.value = !isDefaultDark.value - } - } - - return { - toggle, - isDark - } -} diff --git a/playground/default/src/composables/useMediaQuery.js b/playground/default/src/composables/useMediaQuery.js deleted file mode 100644 index bf288056..00000000 --- a/playground/default/src/composables/useMediaQuery.js +++ /dev/null @@ -1,28 +0,0 @@ -import { ref, onUnmounted } from 'vue' - -export default function useMediaQuery(query) { - const mediaQueryList = window.matchMedia(query) - const matches = ref(mediaQueryList.matches) - - const handler = (event) => { - matches.value = event.matches - } - - // Safari < 14 does not support this - if (mediaQueryList.addEventListener) { - mediaQueryList.addEventListener('change', handler) - } else { - mediaQueryList.addListener(handler) - } - - onUnmounted(() => { - // Safari < 14 does not support this - if (mediaQueryList.removeEventListener) { - mediaQueryList.removeEventListener('change', handler) - } else { - mediaQueryList.removeListener(handler) - } - }) - - return matches -} diff --git a/playground/jsx-router-vuex-with-tests/README.md b/playground/jsx-router-vuex-with-tests/README.md index 3a1af2bc..d7b6cfcf 100644 --- a/playground/jsx-router-vuex-with-tests/README.md +++ b/playground/jsx-router-vuex-with-tests/README.md @@ -13,29 +13,29 @@ See [Vite Configuration Reference](https://vitejs.dev/config/). ## Project Setup ```sh -npm install +pnpm install ``` ### Compile and Hot-Reload for Development ```sh -npm run dev +pnpm dev ``` ### Compile and Minify for Production ```sh -npm run build +pnpm build ``` ### Run Unit Tests with [Cypress Component Testing](https://docs.cypress.io/guides/component-testing/introduction) ```sh -npm run test:unit # or `npm run test:unit:ci` for headless testing +pnpm test:unit # or `pnpm test:unit:ci` for headless testing ``` ### Run End-to-End Tests with [Cypress](https://www.cypress.io/) ```sh -npm run test:e2e # or `npm run test:e2e:ci` for headless testing +pnpm test:e2e # or `pnpm test:e2e:ci` for headless testing ``` diff --git a/playground/jsx-router-vuex-with-tests/src/App.vue b/playground/jsx-router-vuex-with-tests/src/App.vue index 523cdb78..fe3afbf6 100644 --- a/playground/jsx-router-vuex-with-tests/src/App.vue +++ b/playground/jsx-router-vuex-with-tests/src/App.vue @@ -1,6 +1,5 @@