diff --git a/index.ts b/index.ts index b5fd6867..e6709dfc 100755 --- a/index.ts +++ b/index.ts @@ -107,7 +107,9 @@ async function init() { argv.cypress ?? argv.nightwatch ?? argv.playwright ?? - argv.eslint + argv.eslint ?? + argv.less ?? + argv.scss ) === 'boolean' let targetDir = argv._[0] @@ -127,6 +129,7 @@ async function init() { needsE2eTesting?: false | 'cypress' | 'nightwatch' | 'playwright' needsEslint?: boolean needsPrettier?: boolean + needsCssPreprocessor?: false | 'less' | 'scss' } = {} try { @@ -143,6 +146,8 @@ async function init() { // - Add Playwright for end-to-end testing? // - Add ESLint for code quality? // - Add Prettier for code formatting? + // - Add Scss for css style preprocessor? + // - Add Less for css style preprocessor? result = await prompts( [ { @@ -265,6 +270,23 @@ async function init() { initial: false, active: 'Yes', inactive: 'No' + }, + { + name: 'needsCssPreprocessor', + type: () => (isFeatureFlagsUsed ? null : 'select'), + message: 'Add a CSS preprocessor?', + initial: 0, + choices: (prev, answers) => [ + { title: 'No', value: false }, + { + title: 'Less', + value: 'less' + }, + { + title: 'Scss/Sass', + value: 'scss' + } + ] } ], { @@ -290,15 +312,17 @@ async function init() { needsPinia = argv.pinia, needsVitest = argv.vitest || argv.tests, needsEslint = argv.eslint || argv['eslint-with-prettier'], - needsPrettier = argv['eslint-with-prettier'] + needsPrettier = argv['eslint-with-prettier'], + needsCssPreprocessor = argv.scss || argv.less } = result - const { needsE2eTesting } = result const needsCypress = argv.cypress || argv.tests || needsE2eTesting === 'cypress' const needsCypressCT = needsCypress && !needsVitest const needsNightwatch = argv.nightwatch || needsE2eTesting === 'nightwatch' const needsNightwatchCT = needsNightwatch && !needsVitest const needsPlaywright = argv.playwright || needsE2eTesting === 'playwright' + const needsLess = argv.less || needsCssPreprocessor === 'less' + const needsScss = argv.scss || needsCssPreprocessor === 'scss' const root = path.join(cwd, targetDir) @@ -384,6 +408,16 @@ async function init() { renderEslint(root, { needsTypeScript, needsCypress, needsCypressCT, needsPrettier }) } + // Render CSS Preprocessor config + if (needsCssPreprocessor) { + if (needsScss) { + render('config/scss') + } + if (needsLess) { + render('config/less') + } + } + // Render code template. // prettier-ignore const codeTemplate = @@ -391,6 +425,14 @@ async function init() { (needsRouter ? 'router' : 'default') render(`code/${codeTemplate}`) + // Render app.vue in order to avoid too many unnecessary files + // prettier-ignore + const appTemplate = + (needsTypeScript ? 'typescript-' : '') + + (needsRouter ? 'router' : 'default') + + (needsLess ? '-less': '') + (needsScss ? '-scss': '') + render(`app/${appTemplate}`) + // Render entry file (main.js/ts). if (needsPinia && needsRouter) { render('entry/router-and-pinia') diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a7f4afc1..d5dea73d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -105,6 +105,12 @@ importers: specifier: ^4.4.6 version: 4.4.6(@types/node@18.17.0) + template/config/less: + devDependencies: + less: + specifier: ^4.1.3 + version: 4.1.3 + template/config/nightwatch: devDependencies: '@nightwatch/vue': @@ -162,6 +168,12 @@ importers: specifier: ^4.2.4 version: 4.2.4(vue@3.3.4) + template/config/scss: + devDependencies: + sass: + specifier: ^1.64.1 + version: 1.64.1 + template/config/typescript: devDependencies: '@types/node': @@ -2039,6 +2051,12 @@ packages: safe-buffer: 5.1.2 dev: true + /copy-anything@2.0.6: + resolution: {integrity: sha512-1j20GZTsvKNkc4BY3NpMOM8tt///wY3FpIzozTOFO2ffuZcV61nojHXVKIy3WM+7ADCy5FVhdZYHYDdgTU0yJw==} + dependencies: + is-what: 3.14.1 + dev: true + /core-util-is@1.0.2: resolution: {integrity: sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==} dev: true @@ -2444,6 +2462,15 @@ packages: hasBin: true dev: true + /errno@0.1.8: + resolution: {integrity: sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==} + hasBin: true + requiresBuild: true + dependencies: + prr: 1.0.1 + dev: true + optional: true + /error-ex@1.3.2: resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} dependencies: @@ -3380,10 +3407,22 @@ packages: engines: {node: '>= 4'} dev: true + /image-size@0.5.5: + resolution: {integrity: sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==} + engines: {node: '>=0.10.0'} + hasBin: true + requiresBuild: true + dev: true + optional: true + /immediate@3.0.6: resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==} dev: true + /immutable@4.3.1: + resolution: {integrity: sha512-lj9cnmB/kVS0QHsJnYKD1uo3o39nrbKxszjnqS9Fr6NB7bZzW45U6WSGBPKXDL/CvDKqDNPA4r3DoDQ8GTxo2A==} + dev: true + /indent-string@4.0.0: resolution: {integrity: sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==} engines: {node: '>=8'} @@ -3602,6 +3641,10 @@ packages: call-bind: 1.0.2 dev: true + /is-what@3.14.1: + resolution: {integrity: sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==} + dev: true + /is-wsl@2.2.0: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} @@ -3845,6 +3888,26 @@ packages: readable-stream: 2.3.8 dev: true + /less@4.1.3: + resolution: {integrity: sha512-w16Xk/Ta9Hhyei0Gpz9m7VS8F28nieJaL/VyShID7cYvP6IL5oHeL6p4TXSDJqZE/lNv0oJ2pGVjJsRkfwm5FA==} + engines: {node: '>=6'} + hasBin: true + dependencies: + copy-anything: 2.0.6 + parse-node-version: 1.0.1 + tslib: 2.4.0 + optionalDependencies: + errno: 0.1.8 + graceful-fs: 4.2.10 + image-size: 0.5.5 + make-dir: 2.1.0 + mime: 1.6.0 + needle: 3.2.0 + source-map: 0.6.1 + transitivePeerDependencies: + - supports-color + dev: true + /levn@0.3.0: resolution: {integrity: sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==} engines: {node: '>= 0.8.0'} @@ -4139,6 +4202,16 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 dev: true + /make-dir@2.1.0: + resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==} + engines: {node: '>=6'} + requiresBuild: true + dependencies: + pify: 4.0.1 + semver: 5.7.1 + dev: true + optional: true + /make-error@1.3.6: resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} dev: true @@ -4181,6 +4254,14 @@ packages: mime-db: 1.52.0 dev: true + /mime@1.6.0: + resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} + engines: {node: '>=4'} + hasBin: true + requiresBuild: true + dev: true + optional: true + /mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} @@ -4313,6 +4394,20 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + /needle@3.2.0: + resolution: {integrity: sha512-oUvzXnyLiVyVGoianLijF9O/RecZUf7TkBfimjGrLM4eQhXyeJwM6GeAWccwfQ9aa4gMCZKqhAOuLaMIcQxajQ==} + engines: {node: '>= 4.4.x'} + hasBin: true + requiresBuild: true + dependencies: + debug: 3.2.7(supports-color@8.1.1) + iconv-lite: 0.6.3 + sax: 1.2.4 + transitivePeerDependencies: + - supports-color + dev: true + optional: true + /nice-napi@1.0.2: resolution: {integrity: sha512-px/KnJAJZf5RuBGcfD+Sp2pAKq0ytz8j+1NehvgIGFkvtvFrDM3T8E4x/JJODXK9WZow8RRGrbA9QQ3hs+pDhA==} os: ['!win32'] @@ -4610,6 +4705,11 @@ packages: json-parse-better-errors: 1.0.2 dev: true + /parse-node-version@1.0.1: + resolution: {integrity: sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==} + engines: {node: '>= 0.10'} + dev: true + /parse5@6.0.1: resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==} dev: true @@ -4719,6 +4819,12 @@ packages: engines: {node: '>=4'} dev: true + /pify@4.0.1: + resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} + engines: {node: '>=6'} + dev: true + optional: true + /pinia@2.1.4(vue@3.3.4): resolution: {integrity: sha512-vYlnDu+Y/FXxv1ABo1vhjC+IbqvzUdiUC3sfDRrRyY2CQSrqqaa+iiHmqtARFxJVqWQMCJfXx1PBvFs9aJVLXQ==} peerDependencies: @@ -4826,6 +4932,11 @@ packages: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} dev: true + /prr@1.0.1: + resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} + dev: true + optional: true + /ps-tree@1.2.0: resolution: {integrity: sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA==} engines: {node: '>= 0.10'} @@ -5022,6 +5133,21 @@ packages: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} dev: true + /sass@1.64.1: + resolution: {integrity: sha512-16rRACSOFEE8VN7SCgBu1MpYCyN7urj9At898tyzdXFhC+a+yOX5dXwAR7L8/IdPJ1NB8OYoXmD55DM30B2kEQ==} + engines: {node: '>=14.0.0'} + hasBin: true + dependencies: + chokidar: 3.5.3 + immutable: 4.3.1 + source-map-js: 1.0.2 + dev: true + + /sax@1.2.4: + resolution: {integrity: sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==} + dev: true + optional: true + /saxes@5.0.1: resolution: {integrity: sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==} engines: {node: '>=10'} diff --git a/template/app/default-less/src/App.vue b/template/app/default-less/src/App.vue new file mode 100644 index 00000000..bd1faec9 --- /dev/null +++ b/template/app/default-less/src/App.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/template/app/default-scss/src/App.vue b/template/app/default-scss/src/App.vue new file mode 100644 index 00000000..1e1c63e1 --- /dev/null +++ b/template/app/default-scss/src/App.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/template/app/default/src/App.vue b/template/app/default/src/App.vue new file mode 100644 index 00000000..633a5dfe --- /dev/null +++ b/template/app/default/src/App.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/template/app/router-less/src/App.vue b/template/app/router-less/src/App.vue new file mode 100644 index 00000000..6a4d4940 --- /dev/null +++ b/template/app/router-less/src/App.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/template/app/router-scss/src/App.vue b/template/app/router-scss/src/App.vue new file mode 100644 index 00000000..94cf2a40 --- /dev/null +++ b/template/app/router-scss/src/App.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/template/app/router/src/App.vue b/template/app/router/src/App.vue new file mode 100644 index 00000000..e8641950 --- /dev/null +++ b/template/app/router/src/App.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/template/app/typescript-default-less/src/App.vue b/template/app/typescript-default-less/src/App.vue new file mode 100644 index 00000000..cff9bc92 --- /dev/null +++ b/template/app/typescript-default-less/src/App.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/template/app/typescript-default-scss/src/App.vue b/template/app/typescript-default-scss/src/App.vue new file mode 100644 index 00000000..13b1985b --- /dev/null +++ b/template/app/typescript-default-scss/src/App.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/template/app/typescript-default/src/App.vue b/template/app/typescript-default/src/App.vue new file mode 100644 index 00000000..d05208d6 --- /dev/null +++ b/template/app/typescript-default/src/App.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/template/app/typescript-router-less/src/App.vue b/template/app/typescript-router-less/src/App.vue new file mode 100644 index 00000000..0889f3d8 --- /dev/null +++ b/template/app/typescript-router-less/src/App.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/template/app/typescript-router-scss/src/App.vue b/template/app/typescript-router-scss/src/App.vue new file mode 100644 index 00000000..03e789c9 --- /dev/null +++ b/template/app/typescript-router-scss/src/App.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/template/app/typescript-router/src/App.vue b/template/app/typescript-router/src/App.vue new file mode 100644 index 00000000..7905b051 --- /dev/null +++ b/template/app/typescript-router/src/App.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/template/config/less/package.json b/template/config/less/package.json new file mode 100644 index 00000000..e7d90531 --- /dev/null +++ b/template/config/less/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "less": "^4.1.3" + } +} diff --git a/template/config/scss/package.json b/template/config/scss/package.json new file mode 100644 index 00000000..7991c56c --- /dev/null +++ b/template/config/scss/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "sass": "^1.64.1" + } +}