Skip to content

Commit 919a849

Browse files
authored
Merge pull request #103 from patrickcate/scaffold-project
Initial project setup and components
2 parents 56fc3b0 + 21a599d commit 919a849

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+46642
-0
lines changed

.browserslistrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
> 1%
2+
last 2 versions
3+
Firefox ESR
4+
not dead
5+
not ie

.commitlintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] }

.cz-config.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
'use strict'
2+
3+
module.exports = {
4+
types: [
5+
{ value: 'feat', name: '✨ feat: A new feature' },
6+
{ value: 'fix', name: '🐛 fix: A bug fix' },
7+
{ value: 'docs', name: '📝 docs: Documentation only changes' },
8+
{
9+
value: 'style',
10+
name: '🎨 style: Changes that do not affect the meaning of the code\n(white-space, formatting, missing semi-colons, etc)',
11+
},
12+
{
13+
value: 'refactor',
14+
name: '♻️ refactor: A code change that neither fixes a bug nor adds a feature',
15+
},
16+
{
17+
value: 'perf',
18+
name: '⚡ perf: A code change that improves performance',
19+
},
20+
{
21+
value: 'test',
22+
name: '✅ test: Adding missing tests or stories (example scopes: Cypress, Storybook)',
23+
},
24+
{
25+
value: 'build',
26+
name: '🔨 build: Changes that affect the build system or external dependencies (example scopes: Vite, npm, hygen)',
27+
},
28+
{
29+
value: 'ci',
30+
name: '⚙️ ci: Changes to our CI configuration files and scripts (example scopes: GitHub Actions, Cypress, Storybook)',
31+
},
32+
{
33+
value: 'chore',
34+
name: '👷 chore: Changes to the build process or auxiliary tools\nand libraries such as documentation generation',
35+
},
36+
{ value: 'revert', name: '⏪ revert: Reverts a previous commit' },
37+
{ value: 'WIP', name: '🚧 WIP: Work in progress' },
38+
],
39+
40+
// override the messages, defaults are as follows
41+
messages: {
42+
type: "Select the type of change that you're committing:",
43+
scope: '\nDenote the SCOPE of this change (optional):',
44+
// used if allowCustomScopes is true
45+
// customScope: 'Denote the SCOPE of this change:',
46+
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
47+
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
48+
breaking: 'List any BREAKING CHANGES (optional):\n',
49+
footer:
50+
'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n',
51+
confirmCommit: 'Are you sure you want to proceed with the commit above?',
52+
},
53+
skipQuestions: ['scope'],
54+
allowCustomScopes: false,
55+
allowBreakingChanges: ['feat', 'fix'],
56+
57+
// limit subject length
58+
subjectLimit: 100,
59+
}

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
dist-ssr

.eslintrc.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
},
5+
extends: [
6+
'eslint:recommended',
7+
'plugin:cypress/recommended',
8+
'plugin:vue/vue3-recommended',
9+
'plugin:prettier/recommended',
10+
],
11+
globals: {
12+
defineProps: 'readonly',
13+
defineEmits: 'readonly',
14+
},
15+
rules: {
16+
// override/add rules settings here, such as:
17+
// 'vue/no-unused-vars': 'error'
18+
'vue/script-setup-uses-vars': 'error',
19+
},
20+
}

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules
2+
.DS_Store
3+
dist
4+
dist-ssr
5+
*.local
6+
7+
# Cypress testing artifacts.
8+
cypress/examples
9+
cypress/videos
10+
cypress/screenshots
11+
12+
# Storybook artifacts.
13+
.storybook/examples

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit $1

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14

.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
dist
3+
dist-ssr
4+
.nvmrc
5+
CHANGELOG.md
6+
package-lock.json

.prettierrc.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
bracketSpacing: true,
4+
endOfLine: 'lf',
5+
htmlWhitespaceSensitivity: 'strict',
6+
bracketSameLine: false,
7+
jsxSingleQuote: true,
8+
printWidth: 80,
9+
proseWrap: 'never',
10+
quoteProps: 'as-needed',
11+
semi: false,
12+
singleQuote: true,
13+
tabWidth: 2,
14+
trailingComma: 'es5',
15+
useTabs: false,
16+
vueIndentScriptAndStyle: false,
17+
}

.storybook/main.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const path = require('path')
2+
const { loadConfigFromFile, mergeConfig } = require('vite')
3+
4+
module.exports = {
5+
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
6+
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
7+
core: {
8+
builder: 'storybook-builder-vite',
9+
},
10+
async viteFinal(config, { configType }) {
11+
const { config: userConfig } = await loadConfigFromFile(
12+
path.resolve(__dirname, '../vite.config.ts')
13+
)
14+
15+
return mergeConfig(config, {
16+
...userConfig,
17+
// manually specify plugins to avoid conflict
18+
plugins: [],
19+
})
20+
},
21+
}

.storybook/preview.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import '../node_modules/uswds/dist/css/uswds.min.css'
2+
3+
export const parameters = {
4+
actions: { argTypesRegex: '^on[A-Z].*' },
5+
controls: {
6+
matchers: {
7+
color: /(background|color)$/i,
8+
date: /Date$/,
9+
},
10+
},
11+
}

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["johnsoncodehk.volar"]
3+
}

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Vue USWDS
2+
3+
A Vue 3 implementation of the [USWDS](https://designsystem.digital.gov).
4+
5+
## Recommended IDE Setup
6+
7+
- [VSCode](https://code.visualstudio.com)
8+
- [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
to: src/components/<%= h.changeCase.pascal(component_name) %>/<%= h.changeCase.pascal(component_name) %>.vue
3+
---
4+
<% if (api === 'options') { -%>
5+
<script>
6+
export default {
7+
name: '<%= h.changeCase.pascal(component_name) %>',
8+
props: {
9+
testProp: {
10+
type: String,
11+
default: '',
12+
validator: () => {
13+
return true
14+
},
15+
},
16+
},
17+
}
18+
</script>
19+
<% } else { -%>
20+
<script setup>
21+
import { computed } from 'vue'
22+
23+
const props = defineProps({
24+
testProp: {
25+
type: String,
26+
default: '',
27+
validator: () => {
28+
return true
29+
},
30+
},
31+
})
32+
</script>
33+
<% } %>
34+
<template>
35+
<div><slot></slot></div>
36+
</template>

_templates/new/component/index.ejs.t

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
to: src/components/<%= h.changeCase.pascal(component_name) %>/index.js
3+
---
4+
import <%= h.changeCase.pascal(component_name) %> from './<%= h.changeCase.pascal(component_name) %>.vue'
5+
6+
export { <%= h.changeCase.pascal(component_name) %> }
7+
export default <%= h.changeCase.pascal(component_name) %>

_templates/new/component/prompt.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = [
2+
{
3+
type: 'input',
4+
name: 'component_name',
5+
message: 'What is the name of the component?',
6+
validate(value) {
7+
if (!value) {
8+
return 'Components must have a name.'
9+
}
10+
11+
return true
12+
},
13+
},
14+
{
15+
type: 'select',
16+
name: 'api',
17+
message: 'Which API to start?',
18+
choices: [
19+
{
20+
name: 'options',
21+
message: 'Options API',
22+
},
23+
{
24+
name: 'composition',
25+
message: 'Composition API',
26+
},
27+
],
28+
},
29+
]

_templates/new/component/story.ejs.t

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
to: src/components/<%= h.changeCase.pascal(component_name) %>/<%= h.changeCase.pascal(component_name) %>.stories.js
3+
---
4+
import <%= h.changeCase.pascal(component_name) %> from './<%= h.changeCase.pascal(component_name) %>.vue'
5+
6+
const defaultProps = {}
7+
8+
export default {
9+
component: <%= h.changeCase.pascal(component_name) %>,
10+
title: 'Components/<%= h.changeCase.pascal(component_name) %>',
11+
argTypes: {
12+
defaultSlot: {
13+
control: { type: 'text' },
14+
},
15+
},
16+
args: {
17+
defaultSlot: 'Test',
18+
},
19+
}
20+
21+
const DefaultTemplate = (args, { argTypes }) => ({
22+
components: { <%= h.changeCase.pascal(component_name) %> },
23+
props: Object.keys(argTypes),
24+
setup() {
25+
return { ...args }
26+
},
27+
template: `<<%= h.changeCase.pascal(component_name) %>>${args.defaultSlot}</<%= h.changeCase.pascal(component_name) %>>`,
28+
})
29+
30+
export const Default<%= h.changeCase.pascal(component_name).replace('Usa', '') %> = DefaultTemplate.bind({})
31+
Default<%= h.changeCase.pascal(component_name).replace('Usa', '') %>.args = {
32+
...defaultProps,
33+
}
34+
Default<%= h.changeCase.pascal(component_name).replace('Usa', '') %>.storyName = 'Default'

_templates/new/component/unit.ejs.t

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
to: src/components/<%= h.changeCase.pascal(component_name) %>/<%= h.changeCase.pascal(component_name) %>.test.js
3+
---
4+
import '@module/uswds/dist/css/uswds.min.css'
5+
import { mount } from '@cypress/vue'
6+
import <%= h.changeCase.pascal(component_name) %> from './<%= h.changeCase.pascal(component_name) %>.vue'
7+
8+
describe('<%= h.changeCase.pascal(component_name) %>', () => {
9+
it('renders the component', () => {
10+
mount(<%= h.changeCase.pascal(component_name) %>, {})
11+
cy.get('.<%= h.changeCase.kebab(component_name) %>').should('exist')
12+
})
13+
})

cypress.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"component": {
3+
"componentFolder": "src/components",
4+
"testFiles": "**/*.test.js"
5+
}
6+
}

cypress/fixtures/example.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

cypress/plugins/index.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const path = require('path')
2+
const { startDevServer } = require('@cypress/vite-dev-server')
3+
4+
/// <reference types="cypress" />
5+
// ***********************************************************
6+
// This example plugins/index.js can be used to load plugins
7+
//
8+
// You can change the location of this file or turn off loading
9+
// the plugins file with the 'pluginsFile' configuration option.
10+
//
11+
// You can read more here:
12+
// https://on.cypress.io/plugins-guide
13+
// ***********************************************************
14+
15+
// This function is called when a project is opened or re-opened (e.g. due to
16+
// the project's config changing)
17+
18+
/**
19+
* @type {Cypress.PluginConfig}
20+
*/
21+
// eslint-disable-next-line no-unused-vars
22+
module.exports = (on, config) => {
23+
// `on` is used to hook into various events Cypress emits
24+
// `config` is the resolved Cypress config
25+
26+
on('dev-server:start', options => {
27+
const viteConfig = {
28+
configFile: path.resolve(__dirname, '..', '..', 'vite.config.js'),
29+
resolve: {
30+
alias: {
31+
vue: 'vue/dist/vue.esm-bundler.js',
32+
},
33+
},
34+
}
35+
36+
return startDevServer({ options, viteConfig })
37+
})
38+
39+
return config
40+
}

0 commit comments

Comments
 (0)