Skip to content

Commit

Permalink
feat(create-quasar): simplify prompts; ask for author only if not inf…
Browse files Browse the repository at this point in the history
…erred; remove repositoryType/repositoryURL/homepage/bugs
  • Loading branch information
rstoenescu committed Dec 9, 2024
1 parent ebb2aa2 commit d26cc6b
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 134 deletions.
4 changes: 0 additions & 4 deletions create-quasar/templates/app-extension/ae-js/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ module.exports = {
'preset',
'orgName',
'license',
'repositoryType',
'repositoryURL',
'homepage',
'bugs',

'codeFormat'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
"scripts": {
"test": "echo \"No test specified\" && exit 0"
},
"repository": {
"type": "<%= repositoryType %>",
"url": "<%= repositoryURL %>"
},
"bugs": "<%= bugs %>",
"homepage": "<%= homepage %>",
"engines": {
"node": ">= 12.2.0",
"npm": ">= 5.6.0",
Expand Down
29 changes: 6 additions & 23 deletions create-quasar/templates/app-extension/ae-js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export async function script ({ scope, utils }) {
]
},

utils.commonPrompts.description,
utils.commonPrompts.author,
utils.commonPrompts.description
])

await utils.injectAuthor(scope)

await utils.prompts(scope, [
{
type: 'text',
name: 'license',
Expand All @@ -59,27 +63,6 @@ export async function script ({ scope, utils }) {
}
],
format: utils.convertArrayToObject
},
{
type: 'text',
name: 'repositoryType',
initial: 'git',
message: 'Repository type:'
},
{
type: 'text',
name: 'repositoryURL',
message: 'Repository URL (eg https://github.com/quasarframework/quasar):'
},
{
type: 'text',
name: 'homepage',
message: 'Homepage URL:'
},
{
type: 'text',
name: 'bugs',
message: 'Issue reporting URL (eg https://github.com/quasarframework/quasar/issues):'
}
])

Expand Down
4 changes: 0 additions & 4 deletions create-quasar/templates/app-extension/ae-ts/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ module.exports = {
'orgName',
'pkgName',
'license',
'repositoryType',
'repositoryURL',
'homepage',
'bugs',

'packageManagerField',
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
"author": "<%= author %>",
"license": "<%= license %>",
"type": "module",
"repository": {
"type": "<%= repositoryType %>",
"url": "<%= repositoryURL %>"
},
"bugs": "<%= bugs %>",
"homepage": "<%= homepage %>",
"main": "./dist/runtime/index.js",
"module": "./dist/runtime/index.js",
"types": "./dist/runtime/index.d.ts",
Expand Down
27 changes: 5 additions & 22 deletions create-quasar/templates/app-extension/ae-ts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export async function script ({ scope, utils }) {
},

utils.commonPrompts.description,
utils.commonPrompts.author,
])

await utils.injectAuthor(scope)

await utils.prompts(scope, [
{
type: 'text',
name: 'license',
Expand All @@ -48,27 +52,6 @@ export async function script ({ scope, utils }) {
}
],
format: utils.convertArrayToObject
},
{
type: 'text',
name: 'repositoryType',
initial: 'git',
message: 'Repository type:'
},
{
type: 'text',
name: 'repositoryURL',
message: 'Repository URL (eg https://github.com/quasarframework/quasar):'
},
{
type: 'text',
name: 'homepage',
message: 'Homepage URL:'
},
{
type: 'text',
name: 'bugs',
message: 'Issue reporting URL (eg https://github.com/quasarframework/quasar/issues):'
}
])

Expand Down
5 changes: 3 additions & 2 deletions create-quasar/templates/app/quasar-v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export async function script ({ scope, utils }) {
utils.isValidPackageName(val) || 'Invalid package.json name'
},
utils.commonPrompts.productName,
utils.commonPrompts.description,
utils.commonPrompts.author
utils.commonPrompts.description
])

await utils.injectAuthor(scope)

const { script } = await import(`./${ scope.scriptType }/index.js`)
await script({ scope, utils })
}
5 changes: 4 additions & 1 deletion create-quasar/templates/app/quasar-v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export async function script ({ scope, utils }) {

utils.commonPrompts.productName,
utils.commonPrompts.description,
utils.commonPrompts.author,
])

await utils.injectAuthor(scope)

await utils.prompts(scope, [
{
type: 'select',
name: 'sfcStyle',
Expand Down
6 changes: 1 addition & 5 deletions create-quasar/templates/ui-kit/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ module.exports = {
'componentName',
'directiveName',

'license',
'repositoryType',
'repositoryURL',
'homepage',
'bugs'
'license'
]
},

Expand Down
14 changes: 6 additions & 8 deletions create-quasar/templates/ui-kit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ export async function script ({ scope, utils }) {
message: 'Project name (npm name, kebab-case, without "quasar-ui" prefix)',
validate: (val) =>
utils.isValidPackageName(val) || 'Invalid package.json name'
},
}
])

await utils.injectAuthor(scope)

utils.commonPrompts.author,
await utils.prompts(scope, [
utils.commonPrompts.license,

{
Expand Down Expand Up @@ -104,12 +107,7 @@ export async function script ({ scope, utils }) {
{ title: 'ESM (q/app-vite >= 1.5, q/app-webpack >= 3.10)', value: 'esm', description: 'recommended' },
{ title: 'CommonJS', value: 'commonjs' }
]
},

utils.commonPrompts.repositoryType,
utils.commonPrompts.repositoryURL,
utils.commonPrompts.homepage,
utils.commonPrompts.bugs
}
])

const { script } = await import(`./quasar-${ scope.quasarVersion }/index.js`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
"build:js": "node build/script.javascript.js",
"build:css": "node build/script.css.js"
},
"repository": {
"type": "<%= repositoryType %>",
"url": "<%= repositoryURL %>"
},
"bugs": "<%= bugs %>",
"homepage": "<%= homepage %>",
"devDependencies": {
"autoprefixer": "^10.0.2",
"cssnano": "^4.1.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
"author": "<%= author %>",
"license": "<%= license %>",
"main": "src/index.js",
"repository": {
"type": "<%= repositoryType %>",
"url": "<%= repositoryURL %>"
},
"bugs": "<%= bugs %>",
"homepage": "<%= homepage %>",
"dependencies": {
"quasar-ui-<%= name %>": "latest"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
"build:js": "node build/script.javascript.js",
"build:css": "node build/script.css.js"
},
"repository": {
"type": "<%= repositoryType %>",
"url": "<%= repositoryURL %>"
},
"bugs": "<%= bugs %>",
"homepage": "<%= homepage %>",
"devDependencies": {
"autoprefixer": "^10.0.2",
"cssnano": "^4.1.10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
"author": "<%= author %>",
"license": "<%= license %>",
"type": "<%= aeCodeFormat === 'esm' ? 'module' : 'commonjs' %>",
"repository": {
"type": "<%= repositoryType %>",
"url": "<%= repositoryURL %>"
},
"bugs": "<%= bugs %>",
"homepage": "<%= homepage %>",
"dependencies": {
"quasar-ui-<%= name %>": "latest"
},
Expand Down
47 changes: 18 additions & 29 deletions create-quasar/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,41 +337,29 @@ const commonPrompts = {
val.length > 0 || 'Invalid project description'
},

author: {
type: 'text',
name: 'author',
initial: () => getGitUser(),
message: 'Author:'
},

license: {
type: 'text',
name: 'license',
message: 'License type',
initial: 'MIT'
},
}
}

repositoryType: {
type: 'text',
name: 'repositoryType',
message: 'Repository type:',
initial: 'git'
},
repositoryURL: {
type: 'text',
name: 'repositoryURL',
message: 'Repository URL: (eg https://github.com/quasarframework/quasar)'
},
homepage: {
type: 'text',
name: 'homepage',
message: 'Homepage URL:'
},
bugs: {
type: 'text',
name: 'bugs',
message: 'Issue reporting URL: (eg https://github.com/quasarframework/quasar/issues)'
export async function injectAuthor (scope) {
const author = getGitUser()

if (author) {
scope.author = author
return
}

await prompts(scope, [
{
type: 'text',
name: 'author',
message: 'Author:'
}
])
}

export default {
Expand All @@ -391,5 +379,6 @@ export default {
ensureOutsideProject,
initializeGit,

commonPrompts
commonPrompts,
injectAuthor
}

0 comments on commit d26cc6b

Please sign in to comment.