From 253d1bf5c015f563db3cc03227011e5ce9e0474c Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Sun, 25 Jun 2023 21:21:40 +0100 Subject: [PATCH 01/12] chore: add prettier GitHub action --- .github/workflows/prettier.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/prettier.yml diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 00000000..e12b8779 --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,22 @@ +name: Prettier + +on: [push, pull_request] + +jobs: + prettier: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Run npm ci + run: npm ci + + - name: Run Prettier + run: npx prettier --write . From c39e32e89eb772deeb0fd38996c350f9dd6547a9 Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Sun, 25 Jun 2023 21:45:58 +0100 Subject: [PATCH 02/12] chore(prettier.yml): ignore templates/ directory --- .github/workflows/prettier.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index e12b8779..f2c61a22 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -19,4 +19,4 @@ jobs: run: npm ci - name: Run Prettier - run: npx prettier --write . + run: npx prettier --write . --ignore "templates/**" From 94dae2a6c7979b9389d0eb7e449b741495283b7c Mon Sep 17 00:00:00 2001 From: Kelvin Oghenerhoro Omereshone Date: Sun, 25 Jun 2023 21:57:51 +0100 Subject: [PATCH 03/12] chore: lint files and fixed issue with prettier --- .github/workflows/prettier.yml | 2 +- CONTRIBUTING.md | 27 +- package.json | 6 +- templates/mellow-react/.babelrc | 2 +- templates/mellow-react/.eslintrc | 100 ++++--- templates/mellow-react/README.md | 7 +- .../api/controllers/example/index.js | 4 +- .../api/controllers/home/index.js | 4 +- .../mellow-react/api/hooks/webpack/index.js | 123 ++++---- templates/mellow-react/app.js | 54 ++-- .../assets/dependencies/sockets.js | 6 +- templates/mellow-react/assets/js/app.js | 2 +- templates/mellow-react/config/blueprints.js | 37 +-- templates/mellow-react/config/bootstrap.js | 6 +- templates/mellow-react/config/custom.js | 12 +- templates/mellow-react/config/datastores.js | 64 ++-- .../mellow-react/config/env/production.js | 280 ++++++++---------- templates/mellow-react/config/globals.js | 52 ++-- templates/mellow-react/config/http.js | 48 ++- templates/mellow-react/config/i18n.js | 38 ++- templates/mellow-react/config/inertia.js | 2 +- templates/mellow-react/config/log.js | 25 +- templates/mellow-react/config/models.js | 142 +++++---- templates/mellow-react/config/policies.js | 15 +- templates/mellow-react/config/routes.js | 4 +- templates/mellow-react/config/security.js | 54 ++-- templates/mellow-react/config/session.js | 39 ++- templates/mellow-react/config/sockets.js | 87 +++--- templates/mellow-react/config/views.js | 32 +- templates/mellow-react/config/webpack.js | 186 ++++++------ templates/mellow-react/postcss.config.js | 2 +- templates/mellow-react/prettier.config.js | 2 +- templates/mellow-react/tailwind.config.js | 9 +- templates/mellow-react/views/.eslintrc | 4 +- templates/mellow-svelte/.babelrc | 4 +- templates/mellow-svelte/.eslintrc | 100 ++++--- templates/mellow-svelte/README.md | 7 +- .../api/controllers/example/index.js | 4 +- .../api/controllers/home/index.js | 4 +- .../mellow-svelte/api/hooks/webpack/index.js | 123 ++++---- templates/mellow-svelte/app.js | 54 ++-- .../assets/dependencies/sockets.js | 6 +- templates/mellow-svelte/assets/js/app.js | 2 +- templates/mellow-svelte/config/blueprints.js | 37 +-- templates/mellow-svelte/config/bootstrap.js | 6 +- templates/mellow-svelte/config/custom.js | 12 +- templates/mellow-svelte/config/datastores.js | 64 ++-- .../mellow-svelte/config/env/production.js | 280 ++++++++---------- templates/mellow-svelte/config/globals.js | 52 ++-- templates/mellow-svelte/config/http.js | 48 ++- templates/mellow-svelte/config/i18n.js | 38 ++- templates/mellow-svelte/config/inertia.js | 2 +- templates/mellow-svelte/config/log.js | 25 +- templates/mellow-svelte/config/models.js | 142 +++++---- templates/mellow-svelte/config/policies.js | 15 +- templates/mellow-svelte/config/routes.js | 4 +- templates/mellow-svelte/config/security.js | 54 ++-- templates/mellow-svelte/config/session.js | 39 ++- templates/mellow-svelte/config/sockets.js | 87 +++--- templates/mellow-svelte/config/views.js | 32 +- templates/mellow-svelte/config/webpack.js | 198 ++++++------- templates/mellow-svelte/postcss.config.js | 2 +- templates/mellow-svelte/prettier.config.js | 2 +- templates/mellow-svelte/tailwind.config.js | 6 +- templates/mellow-svelte/views/.eslintrc | 4 +- templates/mellow-vue/.eslintrc | 100 ++++--- templates/mellow-vue/README.md | 7 +- .../api/controllers/example/index.js | 4 +- .../mellow-vue/api/controllers/home/index.js | 4 +- .../mellow-vue/api/hooks/webpack/index.js | 123 ++++---- templates/mellow-vue/app.js | 54 ++-- .../mellow-vue/assets/dependencies/sockets.js | 6 +- templates/mellow-vue/assets/js/app.js | 8 +- .../assets/js/components/Counter.vue | 4 +- .../mellow-vue/assets/js/pages/example.vue | 14 +- .../mellow-vue/assets/js/pages/index.vue | 10 +- templates/mellow-vue/config/blueprints.js | 37 +-- templates/mellow-vue/config/bootstrap.js | 6 +- templates/mellow-vue/config/custom.js | 12 +- templates/mellow-vue/config/datastores.js | 64 ++-- templates/mellow-vue/config/env/production.js | 280 ++++++++---------- templates/mellow-vue/config/globals.js | 52 ++-- templates/mellow-vue/config/http.js | 48 ++- templates/mellow-vue/config/i18n.js | 38 ++- templates/mellow-vue/config/inertia.js | 2 +- templates/mellow-vue/config/log.js | 25 +- templates/mellow-vue/config/models.js | 142 +++++---- templates/mellow-vue/config/policies.js | 15 +- templates/mellow-vue/config/routes.js | 4 +- templates/mellow-vue/config/security.js | 54 ++-- templates/mellow-vue/config/session.js | 39 ++- templates/mellow-vue/config/sockets.js | 87 +++--- templates/mellow-vue/config/views.js | 32 +- templates/mellow-vue/config/webpack.js | 158 +++++----- templates/mellow-vue/postcss.config.js | 2 +- templates/mellow-vue/prettier.config.js | 2 +- templates/mellow-vue/tailwind.config.js | 9 +- templates/mellow-vue/views/.eslintrc | 4 +- 98 files changed, 2072 insertions(+), 2304 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index f2c61a22..035ccae6 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -19,4 +19,4 @@ jobs: run: npm ci - name: Run Prettier - run: npx prettier --write . --ignore "templates/**" + run: npx prettier --config ./.prettierrc.js --write . --ignore "templates/**" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7d212094..12ab592d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,6 +7,7 @@ Thank you for taking the time to contribute to our project. We appreciate you! > **Pull Requests having no issue associated with them will not be accepted. Firstly get an issue assigned, whether it's already opened or raised by you, and then create a Pull Request.** ## Prerequisites + Before you contribute to The Boring JavaScript Stack, make sure you have the following prerequisites: - Open Source Etiquette: If you've never contributed to an open source project before, have a read of [Basic etiquette](https://developer.mozilla.org/en-US/docs/MDN/Community/Open_source_etiquette) for open source projects. @@ -18,6 +19,7 @@ Before you contribute to The Boring JavaScript Stack, make sure you have the fol --- ## How to Contribute 🤔 + To contribute to The Boring JavScript Stack, follow these steps: - Look at the existing [**Issues**](https://github.com/sailscastshq/boring-stack/issues) or create a new issue if you haven't found a suitable one. @@ -40,6 +42,7 @@ If you're new to our project, we recommend starting with the [_Good first issue_ ### Sending a Pull Request To ensure a smooth review process, please follow these guidelines: + - Fork (https://help.github.com/articles/fork-a-repo) the repository into your own account. - In your forked repository, create a new branch: `git checkout -b my-branch develop` - Make your changes/fixes. @@ -51,22 +54,22 @@ To ensure a smooth review process, please follow these guidelines: > > ** To ensure a better review experience, we kindly request that you use the following format for the PR title: `[chore]`, `[feat]`, or `[fix]`, followed by a descriptive title. For example, a chore-related change could have a title like `[chore] Update contributing guidelines`. This helps us categorize and understand the nature of the changes made in each PR..** - - Link the issue you have resolved in the Pull Request Template using the following syntax: - - If your Pull Request fixes issue #25, add `Fixes #25` or `Closes #25` to the description. - - If your Pull Request addresses multiple issues, list them using the same syntax (`Fixes #23, Fixes #15`). +- Link the issue you have resolved in the Pull Request Template using the following syntax: +- If your Pull Request fixes issue #25, add `Fixes #25` or `Closes #25` to the description. +- If your Pull Request addresses multiple issues, list them using the same syntax (`Fixes #23, Fixes #15`). - This helps us track and automatically close the relevant issue when your Pull Request is merged. +This helps us track and automatically close the relevant issue when your Pull Request is merged. ### Commits - We highly encourage the use of conventional commits. Here are some examples: +We highly encourage the use of conventional commits. Here are some examples: - - feat: Use this when adding a new feature. - - fix: Use this when resolving any issues in the codebase. - - chore: Use this when adding new links/resources or making minor changes. - (ex. chore: Add 'Privacy Policy' link in footer) - - Please keep your commit messages concise and clear. - - Write commit messages in the present tense, as they represent the current state of the codebase after the changes have been applied. +- feat: Use this when adding a new feature. +- fix: Use this when resolving any issues in the codebase. +- chore: Use this when adding new links/resources or making minor changes. + (ex. chore: Add 'Privacy Policy' link in footer) +- Please keep your commit messages concise and clear. +- Write commit messages in the present tense, as they represent the current state of the codebase after the changes have been applied. For additional reference, check out [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) @@ -74,4 +77,4 @@ For additional reference, check out [Conventional Commits](https://www.conventio - If you notice any missing information or feel that something is not adequately described, please don't hesitate to create a pull request (PR) or [raise an issue](https://github.com/sailscastshq/boring-stack/issues). Your input helps us improve our guidelines and make the Boring-Stack project even more awesome! -We're thrilled to have you on board. Let's make a difference together! 🚀 \ No newline at end of file +We're thrilled to have you on board. Let's make a difference together! 🚀 diff --git a/package.json b/package.json index 1173707a..9ad30ab0 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "prepare": "husky install", - "lint": "npx prettier --check .", - "lint:fix": "npx prettier --write ." + "lint": "npx prettier --config ./.prettierrc.js --check .", + "lint:fix": "npx prettier --config ./.prettierrc.js --write ." }, "keywords": [ "boring-stack", @@ -26,6 +26,6 @@ "prettier": "2.8.8" }, "lint-staged": { - "**/*": "prettier --write --ignore-unknown" + "**/*": "prettier --config ./.prettierrc.js --write --ignore-unknown" } } diff --git a/templates/mellow-react/.babelrc b/templates/mellow-react/.babelrc index b37d3533..08d007ea 100644 --- a/templates/mellow-react/.babelrc +++ b/templates/mellow-react/.babelrc @@ -1,6 +1,6 @@ { "presets": [ "@babel/preset-env", - ["@babel/preset-react", {"runtime": "automatic"}] + ["@babel/preset-react", { "runtime": "automatic" }] ] } diff --git a/templates/mellow-react/.eslintrc b/templates/mellow-react/.eslintrc index b284ab05..daf992b8 100644 --- a/templates/mellow-react/.eslintrc +++ b/templates/mellow-react/.eslintrc @@ -5,7 +5,7 @@ // A set of basic code conventions designed to encourage quality and consistency // across your Sails app's code base. These rules are checked against // automatically any time you run `npm test`. - // + // // > An additional eslintrc override file is included in the `assets/` folder // > right out of the box. This is specifically to allow for variations in acceptable // > global variables between front-end JavaScript code designed to run in the browser @@ -42,49 +42,67 @@ }, "rules": { - "block-scoped-var": ["error"], - "callback-return": ["error", ["done", "proceed", "next", "onwards", "callback", "cb"]], - "camelcase": ["warn", {"properties":"always"}], - "comma-style": ["warn", "last"], - "curly": ["warn"], - "eqeqeq": ["error", "always"], - "eol-last": ["warn"], - "handle-callback-err": ["error"], - "indent": ["warn", 2, { - "SwitchCase": 1, - "MemberExpression": "off", - "FunctionDeclaration": {"body":1, "parameters":"off"}, - "FunctionExpression": {"body":1, "parameters":"off"}, - "CallExpression": {"arguments":"off"}, - "ArrayExpression": 1, - "ObjectExpression": 1, - "ignoredNodes": ["ConditionalExpression"] - }], - "linebreak-style": ["error", "unix"], - "no-dupe-keys": ["error"], - "no-duplicate-case": ["error"], - "no-extra-semi": ["warn"], - "no-labels": ["error"], - "no-mixed-spaces-and-tabs": [2, "smart-tabs"], - "no-redeclare": ["warn"], - "no-return-assign": ["error", "always"], - "no-sequences": ["error"], - "no-trailing-spaces": ["warn"], - "no-undef": ["off"], + "block-scoped-var": ["error"], + "callback-return": [ + "error", + ["done", "proceed", "next", "onwards", "callback", "cb"] + ], + "camelcase": ["warn", { "properties": "always" }], + "comma-style": ["warn", "last"], + "curly": ["warn"], + "eqeqeq": ["error", "always"], + "eol-last": ["warn"], + "handle-callback-err": ["error"], + "indent": [ + "warn", + 2, + { + "SwitchCase": 1, + "MemberExpression": "off", + "FunctionDeclaration": { "body": 1, "parameters": "off" }, + "FunctionExpression": { "body": 1, "parameters": "off" }, + "CallExpression": { "arguments": "off" }, + "ArrayExpression": 1, + "ObjectExpression": 1, + "ignoredNodes": ["ConditionalExpression"] + } + ], + "linebreak-style": ["error", "unix"], + "no-dupe-keys": ["error"], + "no-duplicate-case": ["error"], + "no-extra-semi": ["warn"], + "no-labels": ["error"], + "no-mixed-spaces-and-tabs": [2, "smart-tabs"], + "no-redeclare": ["warn"], + "no-return-assign": ["error", "always"], + "no-sequences": ["error"], + "no-trailing-spaces": ["warn"], + "no-undef": ["off"], // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ^^Note: If this "no-undef" rule is enabled (set to `["error"]`), then all model globals // (e.g. `"Organization": true`) should be included above under "globals". // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "no-unexpected-multiline": ["warn"], - "no-unreachable": ["warn"], - "no-unused-vars": ["warn", {"caughtErrors":"all", "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", "argsIgnorePattern": "^unused($|[A-Z].*$)", "varsIgnorePattern": "^unused($|[A-Z].*$)" }], - "no-use-before-define": ["error", {"functions":false}], - "one-var": ["warn", "never"], - "prefer-arrow-callback": ["warn", {"allowNamedFunctions":true}], - "quotes": ["warn", "single", {"avoidEscape":false, "allowTemplateLiterals":true}], - "semi": ["warn", "always"], - "semi-spacing": ["warn", {"before":false, "after":true}], - "semi-style": ["warn", "last"] + "no-unexpected-multiline": ["warn"], + "no-unreachable": ["warn"], + "no-unused-vars": [ + "warn", + { + "caughtErrors": "all", + "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", + "argsIgnorePattern": "^unused($|[A-Z].*$)", + "varsIgnorePattern": "^unused($|[A-Z].*$)" + } + ], + "no-use-before-define": ["error", { "functions": false }], + "one-var": ["warn", "never"], + "prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }], + "quotes": [ + "warn", + "single", + { "avoidEscape": false, "allowTemplateLiterals": true } + ], + "semi": ["warn", "always"], + "semi-spacing": ["warn", { "before": false, "after": true }], + "semi-style": ["warn", "last"] } - } diff --git a/templates/mellow-react/README.md b/templates/mellow-react/README.md index dcb8fcf1..8867be8f 100644 --- a/templates/mellow-react/README.md +++ b/templates/mellow-react/README.md @@ -3,6 +3,7 @@ This template should help get you started developing with a modern Sails fullstack application with Inertia and Vue 3. This scaffold contains: -* webpack -* tailwind -* react + +- webpack +- tailwind +- react diff --git a/templates/mellow-react/api/controllers/example/index.js b/templates/mellow-react/api/controllers/example/index.js index dc252832..8fa66a22 100644 --- a/templates/mellow-react/api/controllers/example/index.js +++ b/templates/mellow-react/api/controllers/example/index.js @@ -9,7 +9,7 @@ module.exports = { fn: async function () { return sails.inertia.render('example', { - quote: "You can shine no matter what you're made of - Bigweld", + quote: "You can shine no matter what you're made of - Bigweld" }) - }, + } } diff --git a/templates/mellow-react/api/controllers/home/index.js b/templates/mellow-react/api/controllers/home/index.js index 14ba7bf7..be3c2b7b 100644 --- a/templates/mellow-react/api/controllers/home/index.js +++ b/templates/mellow-react/api/controllers/home/index.js @@ -9,7 +9,7 @@ module.exports = { fn: async function () { return sails.inertia.render('index', { - name: 'Inertia', + name: 'Inertia' }) - }, + } } diff --git a/templates/mellow-react/api/hooks/webpack/index.js b/templates/mellow-react/api/hooks/webpack/index.js index aaab5563..e031666b 100644 --- a/templates/mellow-react/api/hooks/webpack/index.js +++ b/templates/mellow-react/api/hooks/webpack/index.js @@ -1,71 +1,72 @@ /** * Module dependencies */ - const webpack = require('webpack'); +const webpack = require('webpack') +/** + * Webpack hook + * + * @description :: A hook to compile assets using Webhook. + */ - /** - * Webpack hook - * - * @description :: A hook to compile assets using Webhook. - */ - - module.exports = function defineWebpackHook(sails) { - - return { - - /** - * Runs when a Sails app loads/lifts. - * - * @param {Function} done - */ - initialize: function (done) { - - // In production mode, just compile the assets and continue lifting Sails. - if (process.env.NODE_ENV === 'production') { - return webpack(sails.config.webpack, done); - } - - // Otherwise, create a compiler so that we can watch files. - var compiler = webpack(sails.config.webpack); - - // Trigger the first compile, start watching files, and return - // an instance we can use to stop the watcher when Sails lowers. - var watcher = compiler.watch({ - // Wait a bit after a change is detected before recompiling, - // in case other changes come in. - aggregateTimeout: 300, - // Ignore changes to files in node_modules, even if they're - // imported by our scripts. - ignored: /node_modules/ - // poll: true - // ^^^^^ If native watching isn't working, uncomment the above. - }, function(err, stats) { - - // If the compilation generates errors and we're not already logging all the output from - // the watcher, log the errors to the console. - if (stats.hasErrors() && sails.config.log.level !== 'silly' && sails.config.log.level !== 'verbose') { - sails.log.verbose('Webpack encountered errors while compiling. Full output:'); - sails.log.error(stats.toString()); - } - - // Otherwise output the result of the compilation. - else { - sails.log.verbose('Webpack compiled files and outputted:'); - sails.log.verbose(stats.toString()); - } - }); +module.exports = function defineWebpackHook(sails) { + return { + /** + * Runs when a Sails app loads/lifts. + * + * @param {Function} done + */ + initialize: function (done) { + // In production mode, just compile the assets and continue lifting Sails. + if (process.env.NODE_ENV === 'production') { + return webpack(sails.config.webpack, done) + } - // When Sails lowers, stop watching files. - sails.on('lower', function() { - watcher && watcher.close(); - }); + // Otherwise, create a compiler so that we can watch files. + var compiler = webpack(sails.config.webpack) - // Continue lifting Sails. - return done(); + // Trigger the first compile, start watching files, and return + // an instance we can use to stop the watcher when Sails lowers. + var watcher = compiler.watch( + { + // Wait a bit after a change is detected before recompiling, + // in case other changes come in. + aggregateTimeout: 300, + // Ignore changes to files in node_modules, even if they're + // imported by our scripts. + ignored: /node_modules/ + // poll: true + // ^^^^^ If native watching isn't working, uncomment the above. + }, + function (err, stats) { + // If the compilation generates errors and we're not already logging all the output from + // the watcher, log the errors to the console. + if ( + stats.hasErrors() && + sails.config.log.level !== 'silly' && + sails.config.log.level !== 'verbose' + ) { + sails.log.verbose( + 'Webpack encountered errors while compiling. Full output:' + ) + sails.log.error(stats.toString()) + } - } + // Otherwise output the result of the compilation. + else { + sails.log.verbose('Webpack compiled files and outputted:') + sails.log.verbose(stats.toString()) + } + } + ) - }; + // When Sails lowers, stop watching files. + sails.on('lower', function () { + watcher && watcher.close() + }) - }; + // Continue lifting Sails. + return done() + } + } +} diff --git a/templates/mellow-react/app.js b/templates/mellow-react/app.js index f2c5f4eb..7799a854 100644 --- a/templates/mellow-react/app.js +++ b/templates/mellow-react/app.js @@ -20,35 +20,43 @@ * https://sailsjs.com/anatomy/app.js */ - // Ensure we're in the project directory, so cwd-relative paths work as expected // no matter where we actually lift from. // > Note: This is not required in order to lift, but it is a convenient default. -process.chdir(__dirname); - - +process.chdir(__dirname) // Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files). -var sails; -var rc; +var sails +var rc try { - sails = require('sails'); - rc = require('sails/accessible/rc'); + sails = require('sails') + rc = require('sails/accessible/rc') } catch (err) { - console.error('Encountered an error when attempting to require(\'sails\'):'); - console.error(err.stack); - console.error('--'); - console.error('To run an app using `node app.js`, you need to have Sails installed'); - console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re'); - console.error('in the same directory as your app and run `npm install`.'); - console.error(); - console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can'); - console.error('also run this app with `sails lift`. Running with `sails lift` will'); - console.error('not run this file (`app.js`), but it will do exactly the same thing.'); - console.error('(It even uses your app directory\'s local Sails install, if possible.)'); - return; -}//-• - + console.error("Encountered an error when attempting to require('sails'):") + console.error(err.stack) + console.error('--') + console.error( + 'To run an app using `node app.js`, you need to have Sails installed' + ) + console.error( + "locally (`./node_modules/sails`). To do that, just make sure you're" + ) + console.error('in the same directory as your app and run `npm install`.') + console.error() + console.error( + 'If Sails is installed globally (i.e. `npm install -g sails`) you can' + ) + console.error( + 'also run this app with `sails lift`. Running with `sails lift` will' + ) + console.error( + 'not run this file (`app.js`), but it will do exactly the same thing.' + ) + console.error( + "(It even uses your app directory's local Sails install, if possible.)" + ) + return +} //-• // Start server -sails.lift(rc('sails')); +sails.lift(rc('sails')) diff --git a/templates/mellow-react/assets/dependencies/sockets.js b/templates/mellow-react/assets/dependencies/sockets.js index a59721f1..5f9c93ab 100644 --- a/templates/mellow-react/assets/dependencies/sockets.js +++ b/templates/mellow-react/assets/dependencies/sockets.js @@ -1,4 +1,6 @@ // Wrap instantiation of sails.io.js in a module, so it can be safely shared // required from different modules even if they're nested within each other. -var io = require('sails.io.js/sails.io.js')(require('socket.io-client/dist/socket.io.js')); -module.exports = io; +var io = require('sails.io.js/sails.io.js')( + require('socket.io-client/dist/socket.io.js') +) +module.exports = io diff --git a/templates/mellow-react/assets/js/app.js b/templates/mellow-react/assets/js/app.js index f04df093..63faef43 100644 --- a/templates/mellow-react/assets/js/app.js +++ b/templates/mellow-react/assets/js/app.js @@ -10,5 +10,5 @@ createInertiaApp({ resolve: (name) => require(`./pages/${name}`), setup({ el, App, props }) { render(, el) - }, + } }) diff --git a/templates/mellow-react/config/blueprints.js b/templates/mellow-react/config/blueprints.js index e8552ef4..c4b692e5 100644 --- a/templates/mellow-react/config/blueprints.js +++ b/templates/mellow-react/config/blueprints.js @@ -10,32 +10,23 @@ */ module.exports.blueprints = { - /*************************************************************************** - * * - * Automatically expose implicit routes for every action in your app? * - * * - ***************************************************************************/ - + * * + * Automatically expose implicit routes for every action in your app? * + * * + ***************************************************************************/ // actions: false, - - /*************************************************************************** - * * - * Automatically expose RESTful routes for your models? * - * * - ***************************************************************************/ - + * * + * Automatically expose RESTful routes for your models? * + * * + ***************************************************************************/ // rest: true, - - /*************************************************************************** - * * - * Automatically expose CRUD "shortcut" routes to GET requests? * - * (These are enabled by default in development only.) * - * * - ***************************************************************************/ - + * * + * Automatically expose CRUD "shortcut" routes to GET requests? * + * (These are enabled by default in development only.) * + * * + ***************************************************************************/ // shortcuts: true, - -}; +} diff --git a/templates/mellow-react/config/bootstrap.js b/templates/mellow-react/config/bootstrap.js index fb1c17f1..21020476 100644 --- a/templates/mellow-react/config/bootstrap.js +++ b/templates/mellow-react/config/bootstrap.js @@ -9,8 +9,7 @@ * https://sailsjs.com/config/bootstrap */ -module.exports.bootstrap = async function() { - +module.exports.bootstrap = async function () { // By convention, this is a good place to set up fake data during development. // // For example: @@ -26,5 +25,4 @@ module.exports.bootstrap = async function() { // // etc. // ]); // ``` - -}; +} diff --git a/templates/mellow-react/config/custom.js b/templates/mellow-react/config/custom.js index 9ecf33ac..3bb077da 100644 --- a/templates/mellow-react/config/custom.js +++ b/templates/mellow-react/config/custom.js @@ -9,14 +9,12 @@ */ module.exports.custom = { - /*************************************************************************** - * * - * Any other custom config this Sails app should use during development. * - * * - ***************************************************************************/ + * * + * Any other custom config this Sails app should use during development. * + * * + ***************************************************************************/ // sendgridSecret: 'SG.fake.3e0Bn0qSQVnwb1E4qNPz9JZP5vLZYqjh7sn8S93oSHU', // stripeSecret: 'sk_test_Zzd814nldl91104qor5911gjald', // … - -}; +} diff --git a/templates/mellow-react/config/datastores.js b/templates/mellow-react/config/datastores.js index 38531843..1a913087 100644 --- a/templates/mellow-react/config/datastores.js +++ b/templates/mellow-react/config/datastores.js @@ -14,44 +14,38 @@ */ module.exports.datastores = { - - /*************************************************************************** - * * - * Your app's default datastore. * - * * - * Sails apps read and write to local disk by default, using a built-in * - * database adapter called `sails-disk`. This feature is purely for * - * convenience during development; since `sails-disk` is not designed for * - * use in a production environment. * - * * - * To use a different db _in development_, follow the directions below. * - * Otherwise, just leave the default datastore as-is, with no `adapter`. * - * * - * (For production configuration, see `config/env/production.js`.) * - * * - ***************************************************************************/ + * * + * Your app's default datastore. * + * * + * Sails apps read and write to local disk by default, using a built-in * + * database adapter called `sails-disk`. This feature is purely for * + * convenience during development; since `sails-disk` is not designed for * + * use in a production environment. * + * * + * To use a different db _in development_, follow the directions below. * + * Otherwise, just leave the default datastore as-is, with no `adapter`. * + * * + * (For production configuration, see `config/env/production.js`.) * + * * + ***************************************************************************/ default: { - /*************************************************************************** - * * - * Want to use a different database during development? * - * * - * 1. Choose an adapter: * - * https://sailsjs.com/plugins/databases * - * * - * 2. Install it as a dependency of your Sails app. * - * (For example: npm install sails-mysql --save) * - * * - * 3. Then pass it in, along with a connection URL. * - * (See https://sailsjs.com/config/datastores for help.) * - * * - ***************************************************************************/ + * * + * Want to use a different database during development? * + * * + * 1. Choose an adapter: * + * https://sailsjs.com/plugins/databases * + * * + * 2. Install it as a dependency of your Sails app. * + * (For example: npm install sails-mysql --save) * + * * + * 3. Then pass it in, along with a connection URL. * + * (See https://sailsjs.com/config/datastores for help.) * + * * + ***************************************************************************/ // adapter: 'sails-mysql', // url: 'mysql://user:password@host:port/database', - - }, - - -}; + } +} diff --git a/templates/mellow-react/config/env/production.js b/templates/mellow-react/config/env/production.js index 0d54db1d..9043768a 100644 --- a/templates/mellow-react/config/env/production.js +++ b/templates/mellow-react/config/env/production.js @@ -19,20 +19,19 @@ * http://sailsjs.com/docs/concepts/deployment */ - const TerserPlugin = require("terser-webpack-plugin"); +const TerserPlugin = require('terser-webpack-plugin') - module.exports = { - hookTimeout: 80000, - /************************************************************************** +module.exports = { + hookTimeout: 80000, + /************************************************************************** * * * Tell Sails what database(s) it should use in production. * * * * (http://sailsjs.com/config/datastores) * * * **************************************************************************/ - datastores: { - - /*************************************************************************** + datastores: { + /*************************************************************************** * * * Configure your default production database. * * * @@ -46,27 +45,23 @@ * (See http://sailsjs.com/config/datastores for help.) * * * ***************************************************************************/ - default: { - // adapter: require('sails-mysql'), - // url: 'mysql://user:password@host:port/database', - }, - //-------------------------------------------------------------------------- - // /\ To avoid checking it in to version control, you might opt to set - // || sensitive credentials like `url` using an environment variable. - // - // For example: - // ``` - // sails_datastores__default__url=mysql://admin:myc00lpAssw2D@db.example.com:3306/my_prod_db - // ``` - //-------------------------------------------------------------------------- - - }, - - - - models: { - - /************************************************************************** + default: { + // adapter: require('sails-mysql'), + // url: 'mysql://user:password@host:port/database', + } + //-------------------------------------------------------------------------- + // /\ To avoid checking it in to version control, you might opt to set + // || sensitive credentials like `url` using an environment variable. + // + // For example: + // ``` + // sails_datastores__default__url=mysql://admin:myc00lpAssw2D@db.example.com:3306/my_prod_db + // ``` + //-------------------------------------------------------------------------- + }, + + models: { + /************************************************************************** * * * To help avoid accidents, Sails automatically sets the automigration * * strategy to "safe" when your app lifts in production mode. * @@ -76,26 +71,23 @@ * http://sailsjs.com/docs/concepts/models-and-orm/model-settings#?migrate * * * ***************************************************************************/ - migrate: 'safe', - - }, - + migrate: 'safe' + }, - - /************************************************************************** + /************************************************************************** * * * Always disable "shortcut" blueprint routes. * * (you'll also want to disable any other blueprint routes that you are * * not actually using) * * * ***************************************************************************/ - blueprints: { - shortcuts: false, - // actions: false, - // rest: false, - }, + blueprints: { + shortcuts: false + // actions: false, + // rest: false, + }, - /*************************************************************************** + /*************************************************************************** * * * Configure your security settings for production. * * * @@ -106,9 +98,8 @@ * tested with CSRF protection turned on in development mode too. * * * ***************************************************************************/ - security: { - - /*************************************************************************** + security: { + /*************************************************************************** * * * If this app has CORS enabled (see `config/security.js`) with the * * `allowCredentials` setting enabled, then you should uncomment the * @@ -119,16 +110,14 @@ * > Be sure to use the right protocol! ("http://" vs. "https://") * * * ***************************************************************************/ - cors: { - // allowOrigins: [ - // 'https://example.com', - // ] - }, - - }, - - - /*************************************************************************** + cors: { + // allowOrigins: [ + // 'https://example.com', + // ] + } + }, + + /*************************************************************************** * * * Configure how your app handles sessions in production. * * * @@ -138,9 +127,8 @@ * > this section from your `config/env/production.js` file. * * * ***************************************************************************/ - session: { - - /*************************************************************************** + session: { + /*************************************************************************** * * * Production session store configuration. * * * @@ -154,22 +142,20 @@ * > (For a full list, see http://sailsjs.com/plugins/sessions) * * * ***************************************************************************/ - // adapter: 'connect-redis', - // url: 'redis://user:password@localhost:6379/dbname', - //-------------------------------------------------------------------------- - // /\ OR, to avoid checking it in to version control, you might opt to - // || set sensitive credentials like this using an environment variable. - // - // For example: - // ``` - // sails_session__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/sessions - // ``` - // - //-------------------------------------------------------------------------- - - - - /*************************************************************************** + // adapter: 'connect-redis', + // url: 'redis://user:password@localhost:6379/dbname', + //-------------------------------------------------------------------------- + // /\ OR, to avoid checking it in to version control, you might opt to + // || set sensitive credentials like this using an environment variable. + // + // For example: + // ``` + // sails_session__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/sessions + // ``` + // + //-------------------------------------------------------------------------- + + /*************************************************************************** * * * Production configuration for the session ID cookie. * * * @@ -190,16 +176,13 @@ * http://sailsjs.com/config/session#?the-session-id-cookie * * * ***************************************************************************/ - cookie: { - secure: true, - maxAge: 24 * 60 * 60 * 1000, // 24 hours - }, - - }, - - + cookie: { + secure: true, + maxAge: 24 * 60 * 60 * 1000 // 24 hours + } + }, - /************************************************************************** + /************************************************************************** * * * Set up Socket.io for your production environment. * * * @@ -209,9 +192,8 @@ * > this section from your `config/env/production.js` file. * * * ***************************************************************************/ - sockets: { - - /*************************************************************************** + sockets: { + /*************************************************************************** * * * Uncomment the `onlyAllowOrigins` whitelist below to configure which * * "origins" are allowed to open socket connections to your Sails app. * @@ -220,13 +202,12 @@ * > Be sure to use the right protocol! ("http://" vs. "https://") * * * ***************************************************************************/ - onlyAllowOrigins: [ - 'http://localhost:1337' - // 'https://example.com', - ], - + onlyAllowOrigins: [ + 'http://localhost:1337' + // 'https://example.com', + ] - /*************************************************************************** + /*************************************************************************** * * * If you are deploying a cluster of multiple servers and/or processes, * * then uncomment the following lines. This tells Socket.io about a Redis * @@ -235,46 +216,40 @@ * (http://sailsjs.com/docs/concepts/deployment/scaling) * * * ***************************************************************************/ - // adapter: 'socket.io-redis', - // url: 'redis://user:password@bigsquid.redistogo.com:9562/dbname', - //-------------------------------------------------------------------------- - // /\ OR, to avoid checking it in to version control, you might opt to - // || set sensitive credentials like this using an environment variable. - // - // For example: - // ``` - // sails_sockets__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/ - // ``` - //-------------------------------------------------------------------------- - - }, - - - - /************************************************************************** + // adapter: 'socket.io-redis', + // url: 'redis://user:password@bigsquid.redistogo.com:9562/dbname', + //-------------------------------------------------------------------------- + // /\ OR, to avoid checking it in to version control, you might opt to + // || set sensitive credentials like this using an environment variable. + // + // For example: + // ``` + // sails_sockets__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/ + // ``` + //-------------------------------------------------------------------------- + }, + + /************************************************************************** * * * Set the production log level. * * * * (http://sailsjs.com/config/log) * * * ***************************************************************************/ - log: { - level: 'debug' - }, - - + log: { + level: 'debug' + }, - http: { - - /*************************************************************************** + http: { + /*************************************************************************** * * * The number of milliseconds to cache static assets in production. * * (the "max-age" to include in the "Cache-Control" response header) * * * ***************************************************************************/ - cache: 365.25 * 24 * 60 * 60 * 1000, // One year + cache: 365.25 * 24 * 60 * 60 * 1000 // One year - /*************************************************************************** + /*************************************************************************** * * * Proxy settings * * * @@ -289,13 +264,10 @@ * (http://sailsjs.com/config/http) * * * ***************************************************************************/ - // trustProxy: true, - - }, + // trustProxy: true, + }, - - - /************************************************************************** + /************************************************************************** * * * Lift the server on port 80. * * (if deploying behind a proxy, or to a PaaS like Heroku or Deis, you * @@ -304,11 +276,9 @@ * this, just try deploying without setting it and see if it works.) * * * ***************************************************************************/ - // port: 80, - + // port: 80, - - /************************************************************************** + /************************************************************************** * * * Configure an SSL certificate * * * @@ -325,45 +295,41 @@ * > http://sailsjs.com/config/*#?ssl-configuration-example * * * **************************************************************************/ - // ssl: undefined, - + // ssl: undefined, - - /************************************************************************** + /************************************************************************** * * * Overrides for any custom configuration specifically for your app. * * (for example, production API keys) * * * ***************************************************************************/ - custom: { - - // mailgunApiKey: 'key-prod_fake_bd32301385130a0bafe030c', - // stripeSecret: 'sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm', - //-------------------------------------------------------------------------- - // /\ OR, to avoid checking them in to version control, you might opt to - // || set sensitive credentials like these using environment variables. - // - // For example: - // ``` - // sails_custom__mailgunApiKey=key-prod_fake_bd32301385130a0bafe030c - // sails_custom__stripeSecret=sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm - // ``` - //-------------------------------------------------------------------------- - - }, - - /*************************************************************************** + custom: { + // mailgunApiKey: 'key-prod_fake_bd32301385130a0bafe030c', + // stripeSecret: 'sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm', + //-------------------------------------------------------------------------- + // /\ OR, to avoid checking them in to version control, you might opt to + // || set sensitive credentials like these using environment variables. + // + // For example: + // ``` + // sails_custom__mailgunApiKey=key-prod_fake_bd32301385130a0bafe030c + // sails_custom__stripeSecret=sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm + // ``` + //-------------------------------------------------------------------------- + }, + + /*************************************************************************** * * * Override the default webpack plugin list to add the UglifyJsPlugin, * * which minifies the outputted JavaScript. * * * ***************************************************************************/ - webpack: { - mode: 'production', - optimization: { - minimize: true, - minimizer: [new TerserPlugin()], - } - } - } + webpack: { + mode: 'production', + optimization: { + minimize: true, + minimizer: [new TerserPlugin()] + } + } +} diff --git a/templates/mellow-react/config/globals.js b/templates/mellow-react/config/globals.js index f63701f9..5ddfcc0c 100644 --- a/templates/mellow-react/config/globals.js +++ b/templates/mellow-react/config/globals.js @@ -10,43 +10,41 @@ */ module.exports.globals = { - /**************************************************************************** - * * - * Whether to expose the locally-installed Lodash as a global variable * - * (`_`), making it accessible throughout your app. * - * * - ****************************************************************************/ + * * + * Whether to expose the locally-installed Lodash as a global variable * + * (`_`), making it accessible throughout your app. * + * * + ****************************************************************************/ _: require('@sailshq/lodash'), /**************************************************************************** - * * - * This app was generated without a dependency on the "async" NPM package. * - * * - * > Don't worry! This is totally unrelated to JavaScript's "async/await". * - * > Your code can (and probably should) use `await` as much as possible. * - * * - ****************************************************************************/ + * * + * This app was generated without a dependency on the "async" NPM package. * + * * + * > Don't worry! This is totally unrelated to JavaScript's "async/await". * + * > Your code can (and probably should) use `await` as much as possible. * + * * + ****************************************************************************/ async: false, /**************************************************************************** - * * - * Whether to expose each of your app's models as global variables. * - * (See the link at the top of this file for more information.) * - * * - ****************************************************************************/ + * * + * Whether to expose each of your app's models as global variables. * + * (See the link at the top of this file for more information.) * + * * + ****************************************************************************/ models: true, /**************************************************************************** - * * - * Whether to expose the Sails app instance as a global variable (`sails`), * - * making it accessible throughout your app. * - * * - ****************************************************************************/ - - sails: true, - -}; + * * + * Whether to expose the Sails app instance as a global variable (`sails`), * + * making it accessible throughout your app. * + * * + ****************************************************************************/ + + sails: true +} diff --git a/templates/mellow-react/config/http.js b/templates/mellow-react/config/http.js index 3cf438f1..56a61507 100644 --- a/templates/mellow-react/config/http.js +++ b/templates/mellow-react/config/http.js @@ -10,25 +10,22 @@ */ module.exports.http = { - /**************************************************************************** - * * - * Sails/Express middleware to run for every HTTP request. * - * (Only applies to HTTP requests -- not virtual WebSocket requests.) * - * * - * https://sailsjs.com/documentation/concepts/middleware * - * * - ****************************************************************************/ + * * + * Sails/Express middleware to run for every HTTP request. * + * (Only applies to HTTP requests -- not virtual WebSocket requests.) * + * * + * https://sailsjs.com/documentation/concepts/middleware * + * * + ****************************************************************************/ middleware: { - /*************************************************************************** - * * - * The order in which middleware should be run for HTTP requests. * - * (This Sails app's routes are handled by the "router" middleware below.) * - * * - ***************************************************************************/ - + * * + * The order in which middleware should be run for HTTP requests. * + * (This Sails app's routes are handled by the "router" middleware below.) * + * * + ***************************************************************************/ // order: [ // 'cookieParser', // 'session', @@ -39,22 +36,17 @@ module.exports.http = { // 'www', // 'favicon', // ], - - /*************************************************************************** - * * - * The body parser that will handle incoming multipart HTTP requests. * - * * - * https://sailsjs.com/config/http#?customizing-the-body-parser * - * * - ***************************************************************************/ - + * * + * The body parser that will handle incoming multipart HTTP requests. * + * * + * https://sailsjs.com/config/http#?customizing-the-body-parser * + * * + ***************************************************************************/ // bodyParser: (function _configureBodyParser(){ // var skipper = require('skipper'); // var middlewareFn = skipper({ strict: true }); // return middlewareFn; // })(), - - }, - -}; + } +} diff --git a/templates/mellow-react/config/i18n.js b/templates/mellow-react/config/i18n.js index 0b652d26..8b8a4d7e 100644 --- a/templates/mellow-react/config/i18n.js +++ b/templates/mellow-react/config/i18n.js @@ -13,33 +13,31 @@ */ module.exports.i18n = { - /*************************************************************************** - * * - * Which locales are supported? * - * * - ***************************************************************************/ + * * + * Which locales are supported? * + * * + ***************************************************************************/ - locales: ['en', 'es', 'fr', 'de'], + locales: ['en', 'es', 'fr', 'de'] /**************************************************************************** - * * - * What is the default locale for the site? Note that this setting will be * - * overridden for any request that sends an "Accept-Language" header (i.e. * - * most browsers), but it's still useful if you need to localize the * - * response for requests made by non-browser clients (e.g. cURL). * - * * - ****************************************************************************/ + * * + * What is the default locale for the site? Note that this setting will be * + * overridden for any request that sends an "Accept-Language" header (i.e. * + * most browsers), but it's still useful if you need to localize the * + * response for requests made by non-browser clients (e.g. cURL). * + * * + ****************************************************************************/ // defaultLocale: 'en', /**************************************************************************** - * * - * Path (relative to app root) of directory to store locale (translation) * - * files in. * - * * - ****************************************************************************/ + * * + * Path (relative to app root) of directory to store locale (translation) * + * files in. * + * * + ****************************************************************************/ // localesDirectory: 'config/locales' - -}; +} diff --git a/templates/mellow-react/config/inertia.js b/templates/mellow-react/config/inertia.js index 298e88a4..0d54d6b7 100644 --- a/templates/mellow-react/config/inertia.js +++ b/templates/mellow-react/config/inertia.js @@ -8,7 +8,7 @@ * https://inertia-sails.sailscasts.com */ - module.exports.inertia = { +module.exports.inertia = { /** * https://inertiajs.com/asset-versioning * You can pass a string, number that changes when your assets change diff --git a/templates/mellow-react/config/log.js b/templates/mellow-react/config/log.js index 1ef07f55..85c2eaf4 100644 --- a/templates/mellow-react/config/log.js +++ b/templates/mellow-react/config/log.js @@ -11,19 +11,16 @@ */ module.exports.log = { - /*************************************************************************** - * * - * Valid `level` configs: i.e. the minimum log level to capture with * - * sails.log.*() * - * * - * The order of precedence for log levels from lowest to highest is: * - * silly, verbose, info, debug, warn, error * - * * - * You may also set the level to "silent" to suppress all logs. * - * * - ***************************************************************************/ - + * * + * Valid `level` configs: i.e. the minimum log level to capture with * + * sails.log.*() * + * * + * The order of precedence for log levels from lowest to highest is: * + * silly, verbose, info, debug, warn, error * + * * + * You may also set the level to "silent" to suppress all logs. * + * * + ***************************************************************************/ // level: 'info' - -}; +} diff --git a/templates/mellow-react/config/models.js b/templates/mellow-react/config/models.js index 0c454000..96f6be96 100644 --- a/templates/mellow-react/config/models.js +++ b/templates/mellow-react/config/models.js @@ -14,64 +14,60 @@ */ module.exports.models = { - - /*************************************************************************** - * * - * Whether model methods like `.create()` and `.update()` should ignore * - * (and refuse to persist) unrecognized data-- i.e. properties other than * - * those explicitly defined by attributes in the model definition. * - * * - * To ease future maintenance of your code base, it is usually a good idea * - * to set this to `true`. * - * * - * > Note that `schema: false` is not supported by every database. * - * > For example, if you are using a SQL database, then relevant models * - * > are always effectively `schema: true`. And if no `schema` setting is * - * > provided whatsoever, the behavior is left up to the database adapter. * - * > * - * > For more info, see: * - * > https://sailsjs.com/docs/concepts/orm/model-settings#?schema * - * * - ***************************************************************************/ + * * + * Whether model methods like `.create()` and `.update()` should ignore * + * (and refuse to persist) unrecognized data-- i.e. properties other than * + * those explicitly defined by attributes in the model definition. * + * * + * To ease future maintenance of your code base, it is usually a good idea * + * to set this to `true`. * + * * + * > Note that `schema: false` is not supported by every database. * + * > For example, if you are using a SQL database, then relevant models * + * > are always effectively `schema: true`. And if no `schema` setting is * + * > provided whatsoever, the behavior is left up to the database adapter. * + * > * + * > For more info, see: * + * > https://sailsjs.com/docs/concepts/orm/model-settings#?schema * + * * + ***************************************************************************/ schema: true, - /*************************************************************************** - * * - * How and whether Sails will attempt to automatically rebuild the * - * tables/collections/etc. in your schema. * - * * - * > Note that, when running in a production environment, this will be * - * > automatically set to `migrate: 'safe'`, no matter what you configure * - * > here. This is a failsafe to prevent Sails from accidentally running * - * > auto-migrations on your production database. * - * > * - * > For more info, see: * - * > https://sailsjs.com/docs/concepts/orm/model-settings#?migrate * - * * - ***************************************************************************/ + * * + * How and whether Sails will attempt to automatically rebuild the * + * tables/collections/etc. in your schema. * + * * + * > Note that, when running in a production environment, this will be * + * > automatically set to `migrate: 'safe'`, no matter what you configure * + * > here. This is a failsafe to prevent Sails from accidentally running * + * > auto-migrations on your production database. * + * > * + * > For more info, see: * + * > https://sailsjs.com/docs/concepts/orm/model-settings#?migrate * + * * + ***************************************************************************/ migrate: 'alter', - /*************************************************************************** - * * - * Base attributes that are included in all of your models by default. * - * By convention, this is your primary key attribute (`id`), as well as two * - * other timestamp attributes for tracking when records were last created * - * or updated. * - * * - * > For more info, see: * - * > https://sailsjs.com/docs/concepts/orm/model-settings#?attributes * - * * - ***************************************************************************/ + * * + * Base attributes that are included in all of your models by default. * + * By convention, this is your primary key attribute (`id`), as well as two * + * other timestamp attributes for tracking when records were last created * + * or updated. * + * * + * > For more info, see: * + * > https://sailsjs.com/docs/concepts/orm/model-settings#?attributes * + * * + ***************************************************************************/ attributes: { - createdAt: { type: 'number', autoCreatedAt: true, }, - updatedAt: { type: 'number', autoUpdatedAt: true, }, - id: { type: 'number', autoIncrement: true, }, + createdAt: { type: 'number', autoCreatedAt: true }, + updatedAt: { type: 'number', autoUpdatedAt: true }, + id: { type: 'number', autoIncrement: true } //-------------------------------------------------------------------------- // /\ Using MongoDB? // || Replace `id` above with this instead: @@ -85,40 +81,36 @@ module.exports.models = { //-------------------------------------------------------------------------- }, - /****************************************************************************** - * * - * The set of DEKs (data encryption keys) for at-rest encryption. * - * i.e. when encrypting/decrypting data for attributes with `encrypt: true`. * - * * - * > The `default` DEK is used for all new encryptions, but multiple DEKs * - * > can be configured to allow for key rotation. In production, be sure to * - * > manage these keys like you would any other sensitive credential. * - * * - * > For more info, see: * - * > https://sailsjs.com/docs/concepts/orm/model-settings#?dataEncryptionKeys * - * * - ******************************************************************************/ + * * + * The set of DEKs (data encryption keys) for at-rest encryption. * + * i.e. when encrypting/decrypting data for attributes with `encrypt: true`. * + * * + * > The `default` DEK is used for all new encryptions, but multiple DEKs * + * > can be configured to allow for key rotation. In production, be sure to * + * > manage these keys like you would any other sensitive credential. * + * * + * > For more info, see: * + * > https://sailsjs.com/docs/concepts/orm/model-settings#?dataEncryptionKeys * + * * + ******************************************************************************/ dataEncryptionKeys: { default: '$defaultDEK' }, - /*************************************************************************** - * * - * Whether or not implicit records for associations should be cleaned up * - * automatically using the built-in polyfill. This is especially useful * - * during development with sails-disk. * - * * - * Depending on which databases you're using, you may want to disable this * - * polyfill in your production environment. * - * * - * (For production configuration, see `config/env/production.js`.) * - * * - ***************************************************************************/ + * * + * Whether or not implicit records for associations should be cleaned up * + * automatically using the built-in polyfill. This is especially useful * + * during development with sails-disk. * + * * + * Depending on which databases you're using, you may want to disable this * + * polyfill in your production environment. * + * * + * (For production configuration, see `config/env/production.js`.) * + * * + ***************************************************************************/ cascadeOnDestroy: true - - -}; +} diff --git a/templates/mellow-react/config/policies.js b/templates/mellow-react/config/policies.js index c4d1bb53..859e0fa6 100644 --- a/templates/mellow-react/config/policies.js +++ b/templates/mellow-react/config/policies.js @@ -9,14 +9,11 @@ */ module.exports.policies = { - /*************************************************************************** - * * - * Default policy for all controllers and actions, unless overridden. * - * (`true` allows public access) * - * * - ***************************************************************************/ - + * * + * Default policy for all controllers and actions, unless overridden. * + * (`true` allows public access) * + * * + ***************************************************************************/ // '*': true, - -}; +} diff --git a/templates/mellow-react/config/routes.js b/templates/mellow-react/config/routes.js index dd96ab7d..4961d3e5 100644 --- a/templates/mellow-react/config/routes.js +++ b/templates/mellow-react/config/routes.js @@ -8,7 +8,7 @@ * http://sailsjs.com/anatomy/config/routes-js */ - module.exports.routes = { +module.exports.routes = { /*************************************************************************** * * * Custom routes here... * @@ -19,5 +19,5 @@ * * ***************************************************************************/ 'GET /': 'home/index', - 'GET /example': 'example/index', + 'GET /example': 'example/index' } diff --git a/templates/mellow-react/config/security.js b/templates/mellow-react/config/security.js index bd576316..ba514b0d 100644 --- a/templates/mellow-react/config/security.js +++ b/templates/mellow-react/config/security.js @@ -14,41 +14,35 @@ */ module.exports.security = { - /*************************************************************************** - * * - * CORS is like a more modern version of JSONP-- it allows your application * - * to circumvent browsers' same-origin policy, so that the responses from * - * your Sails app hosted on one domain (e.g. example.com) can be received * - * in the client-side JavaScript code from a page you trust hosted on _some * - * other_ domain (e.g. trustedsite.net). * - * * - * For additional options and more information, see: * - * https://sailsjs.com/docs/concepts/security/cors * - * * - ***************************************************************************/ - + * * + * CORS is like a more modern version of JSONP-- it allows your application * + * to circumvent browsers' same-origin policy, so that the responses from * + * your Sails app hosted on one domain (e.g. example.com) can be received * + * in the client-side JavaScript code from a page you trust hosted on _some * + * other_ domain (e.g. trustedsite.net). * + * * + * For additional options and more information, see: * + * https://sailsjs.com/docs/concepts/security/cors * + * * + ***************************************************************************/ // cors: { // allRoutes: false, // allowOrigins: '*', // allowCredentials: false, // }, - - /**************************************************************************** - * * - * By default, Sails' built-in CSRF protection is disabled to facilitate * - * rapid development. But be warned! If your Sails app will be accessed by * - * web browsers, you should _always_ enable CSRF protection before deploying * - * to production. * - * * - * To enable CSRF protection, set this to `true`. * - * * - * For more information, see: * - * https://sailsjs.com/docs/concepts/security/csrf * - * * - ****************************************************************************/ - + * * + * By default, Sails' built-in CSRF protection is disabled to facilitate * + * rapid development. But be warned! If your Sails app will be accessed by * + * web browsers, you should _always_ enable CSRF protection before deploying * + * to production. * + * * + * To enable CSRF protection, set this to `true`. * + * * + * For more information, see: * + * https://sailsjs.com/docs/concepts/security/csrf * + * * + ****************************************************************************/ // csrf: false - -}; +} diff --git a/templates/mellow-react/config/session.js b/templates/mellow-react/config/session.js index 53d76a5f..970c8051 100644 --- a/templates/mellow-react/config/session.js +++ b/templates/mellow-react/config/session.js @@ -10,30 +10,27 @@ */ module.exports.session = { - /*************************************************************************** - * * - * Session secret is automatically generated when your new app is created * - * Replace at your own risk in production-- you will invalidate the cookies * - * of your users, forcing them to log in again. * - * * - ***************************************************************************/ - secret: '$secret', - + * * + * Session secret is automatically generated when your new app is created * + * Replace at your own risk in production-- you will invalidate the cookies * + * of your users, forcing them to log in again. * + * * + ***************************************************************************/ + secret: '$secret' /*************************************************************************** - * * - * Customize when built-in session support will be skipped. * - * * - * (Useful for performance tuning; particularly to avoid wasting cycles on * - * session management when responding to simple requests for static assets, * - * like images or stylesheets.) * - * * - * https://sailsjs.com/config/session * - * * - ***************************************************************************/ + * * + * Customize when built-in session support will be skipped. * + * * + * (Useful for performance tuning; particularly to avoid wasting cycles on * + * session management when responding to simple requests for static assets, * + * like images or stylesheets.) * + * * + * https://sailsjs.com/config/session * + * * + ***************************************************************************/ // isSessionDisabled: function (req){ // return !!req.path.match(req._sails.LOOKS_LIKE_ASSET_RX); // }, - -}; +} diff --git a/templates/mellow-react/config/sockets.js b/templates/mellow-react/config/sockets.js index 9f466a04..c3445b6c 100644 --- a/templates/mellow-react/config/sockets.js +++ b/templates/mellow-react/config/sockets.js @@ -10,38 +10,33 @@ */ module.exports.sockets = { - /*************************************************************************** - * * - * `transports` * - * * - * The protocols or "transports" that socket clients are permitted to * - * use when connecting and communicating with this Sails application. * - * * - * > Never change this here without also configuring `io.sails.transports` * - * > in your client-side code. If the client and the server are not using * - * > the same array of transports, sockets will not work properly. * - * > * - * > For more info, see: * - * > https://sailsjs.com/docs/reference/web-sockets/socket-client * - * * - ***************************************************************************/ - + * * + * `transports` * + * * + * The protocols or "transports" that socket clients are permitted to * + * use when connecting and communicating with this Sails application. * + * * + * > Never change this here without also configuring `io.sails.transports` * + * > in your client-side code. If the client and the server are not using * + * > the same array of transports, sockets will not work properly. * + * > * + * > For more info, see: * + * > https://sailsjs.com/docs/reference/web-sockets/socket-client * + * * + ***************************************************************************/ // transports: [ 'websocket' ], - - /*************************************************************************** - * * - * `beforeConnect` * - * * - * This custom beforeConnect function will be run each time BEFORE a new * - * socket is allowed to connect, when the initial socket.io handshake is * - * performed with the server. * - * * - * https://sailsjs.com/config/sockets#?beforeconnect * - * * - ***************************************************************************/ - + * * + * `beforeConnect` * + * * + * This custom beforeConnect function will be run each time BEFORE a new * + * socket is allowed to connect, when the initial socket.io handshake is * + * performed with the server. * + * * + * https://sailsjs.com/config/sockets#?beforeconnect * + * * + ***************************************************************************/ // beforeConnect: function(handshake, proceed) { // // // `true` allows the socket to connect. @@ -49,17 +44,14 @@ module.exports.sockets = { // return proceed(undefined, true); // // }, - - /*************************************************************************** - * * - * `afterDisconnect` * - * * - * This custom afterDisconnect function will be run each time a socket * - * disconnects * - * * - ***************************************************************************/ - + * * + * `afterDisconnect` * + * * + * This custom afterDisconnect function will be run each time a socket * + * disconnects * + * * + ***************************************************************************/ // afterDisconnect: function(session, socket, done) { // // // By default: do nothing. @@ -67,16 +59,11 @@ module.exports.sockets = { // return done(); // // }, - - /*************************************************************************** - * * - * Whether to expose a 'GET /__getcookie' route that sets an HTTP-only * - * session cookie. * - * * - ***************************************************************************/ - + * * + * Whether to expose a 'GET /__getcookie' route that sets an HTTP-only * + * session cookie. * + * * + ***************************************************************************/ // grant3rdPartyCookie: true, - - -}; +} diff --git a/templates/mellow-react/config/views.js b/templates/mellow-react/config/views.js index 601e667f..2f37a918 100644 --- a/templates/mellow-react/config/views.js +++ b/templates/mellow-react/config/views.js @@ -15,27 +15,25 @@ */ module.exports.views = { - /*************************************************************************** - * * - * Extension to use for your views. When calling `res.view()` in an action, * - * you can leave this extension off. For example, calling * - * `res.view('homepage')` will (using default settings) look for a * - * `views/homepage.ejs` file. * - * * - ***************************************************************************/ + * * + * Extension to use for your views. When calling `res.view()` in an action, * + * you can leave this extension off. For example, calling * + * `res.view('homepage')` will (using default settings) look for a * + * `views/homepage.ejs` file. * + * * + ***************************************************************************/ // extension: 'ejs', /*************************************************************************** - * * - * The path (relative to the views directory, and without extension) to * - * the default layout file to use, or `false` to disable layouts entirely. * - * * - * Note that layouts only work with the built-in EJS view engine! * - * * - ***************************************************************************/ + * * + * The path (relative to the views directory, and without extension) to * + * the default layout file to use, or `false` to disable layouts entirely. * + * * + * Note that layouts only work with the built-in EJS view engine! * + * * + ***************************************************************************/ layout: false - -}; +} diff --git a/templates/mellow-react/config/webpack.js b/templates/mellow-react/config/webpack.js index 58f386d7..0df5498e 100644 --- a/templates/mellow-react/config/webpack.js +++ b/templates/mellow-react/config/webpack.js @@ -2,105 +2,105 @@ * Module dependencies */ - const path = require('path') - const { CleanWebpackPlugin } = require('clean-webpack-plugin') - const CopyWebpackPlugin = require('copy-webpack-plugin') - const MiniCssExtractPlugin = require('mini-css-extract-plugin') +const path = require('path') +const { CleanWebpackPlugin } = require('clean-webpack-plugin') +const CopyWebpackPlugin = require('copy-webpack-plugin') +const MiniCssExtractPlugin = require('mini-css-extract-plugin') - /** - * A basic Webpack config to use with a Sails app. - * - * This config is used by the api/hooks/webpack hook which initializes a - * Webpack compiler in "watch" mode. - * - * See https://webpack.js.org/configuration for a full guide to Webpack config. - * - */ - module.exports.webpack = { - mode: 'development', - /*************************************************************************** - * * - * Create one item in the `entry` dictionary for each page in your app. * - * * - ***************************************************************************/ - entry: { - app: './assets/js/app.js', - }, +/** + * A basic Webpack config to use with a Sails app. + * + * This config is used by the api/hooks/webpack hook which initializes a + * Webpack compiler in "watch" mode. + * + * See https://webpack.js.org/configuration for a full guide to Webpack config. + * + */ +module.exports.webpack = { + mode: 'development', + /*************************************************************************** + * * + * Create one item in the `entry` dictionary for each page in your app. * + * * + ***************************************************************************/ + entry: { + app: './assets/js/app.js' + }, - resolve: { + resolve: { alias: { - '~': path.resolve(__dirname, '..', 'assets'), - '@': path.resolve(__dirname, '..', 'assets', 'js') - } + '~': path.resolve(__dirname, '..', 'assets'), + '@': path.resolve(__dirname, '..', 'assets', 'js') + } }, - /*************************************************************************** - * * - * Output bundled .js files with a `.bundle.js` extension into * - * the `.tmp/public/js` directory * - * * - ***************************************************************************/ - output: { - filename: 'js/[name].bundle.js', - path: path.resolve(__dirname, '..', '.tmp', 'public'), - }, + /*************************************************************************** + * * + * Output bundled .js files with a `.bundle.js` extension into * + * the `.tmp/public/js` directory * + * * + ***************************************************************************/ + output: { + filename: 'js/[name].bundle.js', + path: path.resolve(__dirname, '..', '.tmp', 'public') + }, - /*************************************************************************** - * * - * Set up a couple of rules for processing .css and .less files. These will * - * be extracted into their own bundles when they're imported in a * - * JavaScript file. * - * * - ***************************************************************************/ - module: { - rules: [ - { - test: /\.css$/i, - use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'], - }, - { - test: /\.(js|jsx)$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - }, - }, - ], - }, + /*************************************************************************** + * * + * Set up a couple of rules for processing .css and .less files. These will * + * be extracted into their own bundles when they're imported in a * + * JavaScript file. * + * * + ***************************************************************************/ + module: { + rules: [ + { + test: /\.css$/i, + use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'] + }, + { + test: /\.(js|jsx)$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader' + } + } + ] + }, - /*************************************************************************** - * * - * Set up some plugins to help with Sails development using Webpack. * - * * - ***************************************************************************/ - plugins: [ - // This plugin extracts CSS that was imported into .js files, and bundles - // it into separate .css files. The filename is based on the name of the - // .js file that the CSS was imported into. - new MiniCssExtractPlugin({ - filename: 'css/[name].bundle.css', - }), + /*************************************************************************** + * * + * Set up some plugins to help with Sails development using Webpack. * + * * + ***************************************************************************/ + plugins: [ + // This plugin extracts CSS that was imported into .js files, and bundles + // it into separate .css files. The filename is based on the name of the + // .js file that the CSS was imported into. + new MiniCssExtractPlugin({ + filename: 'css/[name].bundle.css' + }), - // This plugin cleans out your .tmp/public folder before lifting. - new CleanWebpackPlugin({ - verbose: true, - dry: false, - }), + // This plugin cleans out your .tmp/public folder before lifting. + new CleanWebpackPlugin({ + verbose: true, + dry: false + }), - // This plugin copies the `images` and `fonts` folders into - // the .tmp/public folder. You can add any other static asset - // folders to this list and they'll be copied as well. - new CopyWebpackPlugin({ - patterns: [ - { - from: './assets/images', - to: path.resolve(__dirname, '..', '.tmp', 'public', 'images'), - }, - { - from: './assets/fonts', - to: path.resolve(__dirname, '..', '.tmp', 'public', 'fonts'), - }, - ], - }), - ], - } + // This plugin copies the `images` and `fonts` folders into + // the .tmp/public folder. You can add any other static asset + // folders to this list and they'll be copied as well. + new CopyWebpackPlugin({ + patterns: [ + { + from: './assets/images', + to: path.resolve(__dirname, '..', '.tmp', 'public', 'images') + }, + { + from: './assets/fonts', + to: path.resolve(__dirname, '..', '.tmp', 'public', 'fonts') + } + ] + }) + ] +} diff --git a/templates/mellow-react/postcss.config.js b/templates/mellow-react/postcss.config.js index f1c8dac8..85f717cc 100644 --- a/templates/mellow-react/postcss.config.js +++ b/templates/mellow-react/postcss.config.js @@ -1,6 +1,6 @@ module.exports = { plugins: { tailwindcss: {}, - autoprefixer: {}, + autoprefixer: {} } } diff --git a/templates/mellow-react/prettier.config.js b/templates/mellow-react/prettier.config.js index cb950684..e94a48b6 100644 --- a/templates/mellow-react/prettier.config.js +++ b/templates/mellow-react/prettier.config.js @@ -1,5 +1,5 @@ module.exports = { plugins: [require('prettier-plugin-tailwindcss')], semi: false, - singleQuote: true, + singleQuote: true } diff --git a/templates/mellow-react/tailwind.config.js b/templates/mellow-react/tailwind.config.js index 71a3e395..cc0c401e 100644 --- a/templates/mellow-react/tailwind.config.js +++ b/templates/mellow-react/tailwind.config.js @@ -1,10 +1,7 @@ module.exports = { - content: [ - './views/**/*.ejs', - './assets/js/**/*.{js,jsx,ts,tsx}', - ], + content: ['./views/**/*.ejs', './assets/js/**/*.{js,jsx,ts,tsx}'], theme: { - extend: {}, + extend: {} }, - plugins: [], + plugins: [] } diff --git a/templates/mellow-react/views/.eslintrc b/templates/mellow-react/views/.eslintrc index ad4c06ef..6fd3589d 100644 --- a/templates/mellow-react/views/.eslintrc +++ b/templates/mellow-react/views/.eslintrc @@ -12,9 +12,7 @@ // For more information see: // https://sailsjs.com/anatomy/views/.eslintrc // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "extends": [ - "../assets/.eslintrc" - ], + "extends": ["../assets/.eslintrc"], "rules": { "eol-last": [0] } diff --git a/templates/mellow-svelte/.babelrc b/templates/mellow-svelte/.babelrc index a29ac998..1320b9a3 100644 --- a/templates/mellow-svelte/.babelrc +++ b/templates/mellow-svelte/.babelrc @@ -1,5 +1,3 @@ { - "presets": [ - "@babel/preset-env" - ] + "presets": ["@babel/preset-env"] } diff --git a/templates/mellow-svelte/.eslintrc b/templates/mellow-svelte/.eslintrc index b284ab05..daf992b8 100644 --- a/templates/mellow-svelte/.eslintrc +++ b/templates/mellow-svelte/.eslintrc @@ -5,7 +5,7 @@ // A set of basic code conventions designed to encourage quality and consistency // across your Sails app's code base. These rules are checked against // automatically any time you run `npm test`. - // + // // > An additional eslintrc override file is included in the `assets/` folder // > right out of the box. This is specifically to allow for variations in acceptable // > global variables between front-end JavaScript code designed to run in the browser @@ -42,49 +42,67 @@ }, "rules": { - "block-scoped-var": ["error"], - "callback-return": ["error", ["done", "proceed", "next", "onwards", "callback", "cb"]], - "camelcase": ["warn", {"properties":"always"}], - "comma-style": ["warn", "last"], - "curly": ["warn"], - "eqeqeq": ["error", "always"], - "eol-last": ["warn"], - "handle-callback-err": ["error"], - "indent": ["warn", 2, { - "SwitchCase": 1, - "MemberExpression": "off", - "FunctionDeclaration": {"body":1, "parameters":"off"}, - "FunctionExpression": {"body":1, "parameters":"off"}, - "CallExpression": {"arguments":"off"}, - "ArrayExpression": 1, - "ObjectExpression": 1, - "ignoredNodes": ["ConditionalExpression"] - }], - "linebreak-style": ["error", "unix"], - "no-dupe-keys": ["error"], - "no-duplicate-case": ["error"], - "no-extra-semi": ["warn"], - "no-labels": ["error"], - "no-mixed-spaces-and-tabs": [2, "smart-tabs"], - "no-redeclare": ["warn"], - "no-return-assign": ["error", "always"], - "no-sequences": ["error"], - "no-trailing-spaces": ["warn"], - "no-undef": ["off"], + "block-scoped-var": ["error"], + "callback-return": [ + "error", + ["done", "proceed", "next", "onwards", "callback", "cb"] + ], + "camelcase": ["warn", { "properties": "always" }], + "comma-style": ["warn", "last"], + "curly": ["warn"], + "eqeqeq": ["error", "always"], + "eol-last": ["warn"], + "handle-callback-err": ["error"], + "indent": [ + "warn", + 2, + { + "SwitchCase": 1, + "MemberExpression": "off", + "FunctionDeclaration": { "body": 1, "parameters": "off" }, + "FunctionExpression": { "body": 1, "parameters": "off" }, + "CallExpression": { "arguments": "off" }, + "ArrayExpression": 1, + "ObjectExpression": 1, + "ignoredNodes": ["ConditionalExpression"] + } + ], + "linebreak-style": ["error", "unix"], + "no-dupe-keys": ["error"], + "no-duplicate-case": ["error"], + "no-extra-semi": ["warn"], + "no-labels": ["error"], + "no-mixed-spaces-and-tabs": [2, "smart-tabs"], + "no-redeclare": ["warn"], + "no-return-assign": ["error", "always"], + "no-sequences": ["error"], + "no-trailing-spaces": ["warn"], + "no-undef": ["off"], // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ^^Note: If this "no-undef" rule is enabled (set to `["error"]`), then all model globals // (e.g. `"Organization": true`) should be included above under "globals". // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "no-unexpected-multiline": ["warn"], - "no-unreachable": ["warn"], - "no-unused-vars": ["warn", {"caughtErrors":"all", "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", "argsIgnorePattern": "^unused($|[A-Z].*$)", "varsIgnorePattern": "^unused($|[A-Z].*$)" }], - "no-use-before-define": ["error", {"functions":false}], - "one-var": ["warn", "never"], - "prefer-arrow-callback": ["warn", {"allowNamedFunctions":true}], - "quotes": ["warn", "single", {"avoidEscape":false, "allowTemplateLiterals":true}], - "semi": ["warn", "always"], - "semi-spacing": ["warn", {"before":false, "after":true}], - "semi-style": ["warn", "last"] + "no-unexpected-multiline": ["warn"], + "no-unreachable": ["warn"], + "no-unused-vars": [ + "warn", + { + "caughtErrors": "all", + "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", + "argsIgnorePattern": "^unused($|[A-Z].*$)", + "varsIgnorePattern": "^unused($|[A-Z].*$)" + } + ], + "no-use-before-define": ["error", { "functions": false }], + "one-var": ["warn", "never"], + "prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }], + "quotes": [ + "warn", + "single", + { "avoidEscape": false, "allowTemplateLiterals": true } + ], + "semi": ["warn", "always"], + "semi-spacing": ["warn", { "before": false, "after": true }], + "semi-style": ["warn", "last"] } - } diff --git a/templates/mellow-svelte/README.md b/templates/mellow-svelte/README.md index ef61a341..26e31447 100644 --- a/templates/mellow-svelte/README.md +++ b/templates/mellow-svelte/README.md @@ -3,6 +3,7 @@ This template should help get you started developing with a modern Sails fullstack application with Inertia and Vue 3. This scaffold contains: -* webpack -* tailwind -* svelte + +- webpack +- tailwind +- svelte diff --git a/templates/mellow-svelte/api/controllers/example/index.js b/templates/mellow-svelte/api/controllers/example/index.js index dc252832..8fa66a22 100644 --- a/templates/mellow-svelte/api/controllers/example/index.js +++ b/templates/mellow-svelte/api/controllers/example/index.js @@ -9,7 +9,7 @@ module.exports = { fn: async function () { return sails.inertia.render('example', { - quote: "You can shine no matter what you're made of - Bigweld", + quote: "You can shine no matter what you're made of - Bigweld" }) - }, + } } diff --git a/templates/mellow-svelte/api/controllers/home/index.js b/templates/mellow-svelte/api/controllers/home/index.js index 14ba7bf7..be3c2b7b 100644 --- a/templates/mellow-svelte/api/controllers/home/index.js +++ b/templates/mellow-svelte/api/controllers/home/index.js @@ -9,7 +9,7 @@ module.exports = { fn: async function () { return sails.inertia.render('index', { - name: 'Inertia', + name: 'Inertia' }) - }, + } } diff --git a/templates/mellow-svelte/api/hooks/webpack/index.js b/templates/mellow-svelte/api/hooks/webpack/index.js index aaab5563..e031666b 100644 --- a/templates/mellow-svelte/api/hooks/webpack/index.js +++ b/templates/mellow-svelte/api/hooks/webpack/index.js @@ -1,71 +1,72 @@ /** * Module dependencies */ - const webpack = require('webpack'); +const webpack = require('webpack') +/** + * Webpack hook + * + * @description :: A hook to compile assets using Webhook. + */ - /** - * Webpack hook - * - * @description :: A hook to compile assets using Webhook. - */ - - module.exports = function defineWebpackHook(sails) { - - return { - - /** - * Runs when a Sails app loads/lifts. - * - * @param {Function} done - */ - initialize: function (done) { - - // In production mode, just compile the assets and continue lifting Sails. - if (process.env.NODE_ENV === 'production') { - return webpack(sails.config.webpack, done); - } - - // Otherwise, create a compiler so that we can watch files. - var compiler = webpack(sails.config.webpack); - - // Trigger the first compile, start watching files, and return - // an instance we can use to stop the watcher when Sails lowers. - var watcher = compiler.watch({ - // Wait a bit after a change is detected before recompiling, - // in case other changes come in. - aggregateTimeout: 300, - // Ignore changes to files in node_modules, even if they're - // imported by our scripts. - ignored: /node_modules/ - // poll: true - // ^^^^^ If native watching isn't working, uncomment the above. - }, function(err, stats) { - - // If the compilation generates errors and we're not already logging all the output from - // the watcher, log the errors to the console. - if (stats.hasErrors() && sails.config.log.level !== 'silly' && sails.config.log.level !== 'verbose') { - sails.log.verbose('Webpack encountered errors while compiling. Full output:'); - sails.log.error(stats.toString()); - } - - // Otherwise output the result of the compilation. - else { - sails.log.verbose('Webpack compiled files and outputted:'); - sails.log.verbose(stats.toString()); - } - }); +module.exports = function defineWebpackHook(sails) { + return { + /** + * Runs when a Sails app loads/lifts. + * + * @param {Function} done + */ + initialize: function (done) { + // In production mode, just compile the assets and continue lifting Sails. + if (process.env.NODE_ENV === 'production') { + return webpack(sails.config.webpack, done) + } - // When Sails lowers, stop watching files. - sails.on('lower', function() { - watcher && watcher.close(); - }); + // Otherwise, create a compiler so that we can watch files. + var compiler = webpack(sails.config.webpack) - // Continue lifting Sails. - return done(); + // Trigger the first compile, start watching files, and return + // an instance we can use to stop the watcher when Sails lowers. + var watcher = compiler.watch( + { + // Wait a bit after a change is detected before recompiling, + // in case other changes come in. + aggregateTimeout: 300, + // Ignore changes to files in node_modules, even if they're + // imported by our scripts. + ignored: /node_modules/ + // poll: true + // ^^^^^ If native watching isn't working, uncomment the above. + }, + function (err, stats) { + // If the compilation generates errors and we're not already logging all the output from + // the watcher, log the errors to the console. + if ( + stats.hasErrors() && + sails.config.log.level !== 'silly' && + sails.config.log.level !== 'verbose' + ) { + sails.log.verbose( + 'Webpack encountered errors while compiling. Full output:' + ) + sails.log.error(stats.toString()) + } - } + // Otherwise output the result of the compilation. + else { + sails.log.verbose('Webpack compiled files and outputted:') + sails.log.verbose(stats.toString()) + } + } + ) - }; + // When Sails lowers, stop watching files. + sails.on('lower', function () { + watcher && watcher.close() + }) - }; + // Continue lifting Sails. + return done() + } + } +} diff --git a/templates/mellow-svelte/app.js b/templates/mellow-svelte/app.js index f2c5f4eb..7799a854 100644 --- a/templates/mellow-svelte/app.js +++ b/templates/mellow-svelte/app.js @@ -20,35 +20,43 @@ * https://sailsjs.com/anatomy/app.js */ - // Ensure we're in the project directory, so cwd-relative paths work as expected // no matter where we actually lift from. // > Note: This is not required in order to lift, but it is a convenient default. -process.chdir(__dirname); - - +process.chdir(__dirname) // Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files). -var sails; -var rc; +var sails +var rc try { - sails = require('sails'); - rc = require('sails/accessible/rc'); + sails = require('sails') + rc = require('sails/accessible/rc') } catch (err) { - console.error('Encountered an error when attempting to require(\'sails\'):'); - console.error(err.stack); - console.error('--'); - console.error('To run an app using `node app.js`, you need to have Sails installed'); - console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re'); - console.error('in the same directory as your app and run `npm install`.'); - console.error(); - console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can'); - console.error('also run this app with `sails lift`. Running with `sails lift` will'); - console.error('not run this file (`app.js`), but it will do exactly the same thing.'); - console.error('(It even uses your app directory\'s local Sails install, if possible.)'); - return; -}//-• - + console.error("Encountered an error when attempting to require('sails'):") + console.error(err.stack) + console.error('--') + console.error( + 'To run an app using `node app.js`, you need to have Sails installed' + ) + console.error( + "locally (`./node_modules/sails`). To do that, just make sure you're" + ) + console.error('in the same directory as your app and run `npm install`.') + console.error() + console.error( + 'If Sails is installed globally (i.e. `npm install -g sails`) you can' + ) + console.error( + 'also run this app with `sails lift`. Running with `sails lift` will' + ) + console.error( + 'not run this file (`app.js`), but it will do exactly the same thing.' + ) + console.error( + "(It even uses your app directory's local Sails install, if possible.)" + ) + return +} //-• // Start server -sails.lift(rc('sails')); +sails.lift(rc('sails')) diff --git a/templates/mellow-svelte/assets/dependencies/sockets.js b/templates/mellow-svelte/assets/dependencies/sockets.js index a59721f1..5f9c93ab 100644 --- a/templates/mellow-svelte/assets/dependencies/sockets.js +++ b/templates/mellow-svelte/assets/dependencies/sockets.js @@ -1,4 +1,6 @@ // Wrap instantiation of sails.io.js in a module, so it can be safely shared // required from different modules even if they're nested within each other. -var io = require('sails.io.js/sails.io.js')(require('socket.io-client/dist/socket.io.js')); -module.exports = io; +var io = require('sails.io.js/sails.io.js')( + require('socket.io-client/dist/socket.io.js') +) +module.exports = io diff --git a/templates/mellow-svelte/assets/js/app.js b/templates/mellow-svelte/assets/js/app.js index 2a218a57..20eff78f 100644 --- a/templates/mellow-svelte/assets/js/app.js +++ b/templates/mellow-svelte/assets/js/app.js @@ -8,5 +8,5 @@ createInertiaApp({ resolve: (name) => require(`./pages/${name}`), setup({ el, App, props }) { new App({ target: el, props }) - }, + } }) diff --git a/templates/mellow-svelte/config/blueprints.js b/templates/mellow-svelte/config/blueprints.js index e8552ef4..c4b692e5 100644 --- a/templates/mellow-svelte/config/blueprints.js +++ b/templates/mellow-svelte/config/blueprints.js @@ -10,32 +10,23 @@ */ module.exports.blueprints = { - /*************************************************************************** - * * - * Automatically expose implicit routes for every action in your app? * - * * - ***************************************************************************/ - + * * + * Automatically expose implicit routes for every action in your app? * + * * + ***************************************************************************/ // actions: false, - - /*************************************************************************** - * * - * Automatically expose RESTful routes for your models? * - * * - ***************************************************************************/ - + * * + * Automatically expose RESTful routes for your models? * + * * + ***************************************************************************/ // rest: true, - - /*************************************************************************** - * * - * Automatically expose CRUD "shortcut" routes to GET requests? * - * (These are enabled by default in development only.) * - * * - ***************************************************************************/ - + * * + * Automatically expose CRUD "shortcut" routes to GET requests? * + * (These are enabled by default in development only.) * + * * + ***************************************************************************/ // shortcuts: true, - -}; +} diff --git a/templates/mellow-svelte/config/bootstrap.js b/templates/mellow-svelte/config/bootstrap.js index fb1c17f1..21020476 100644 --- a/templates/mellow-svelte/config/bootstrap.js +++ b/templates/mellow-svelte/config/bootstrap.js @@ -9,8 +9,7 @@ * https://sailsjs.com/config/bootstrap */ -module.exports.bootstrap = async function() { - +module.exports.bootstrap = async function () { // By convention, this is a good place to set up fake data during development. // // For example: @@ -26,5 +25,4 @@ module.exports.bootstrap = async function() { // // etc. // ]); // ``` - -}; +} diff --git a/templates/mellow-svelte/config/custom.js b/templates/mellow-svelte/config/custom.js index 9ecf33ac..3bb077da 100644 --- a/templates/mellow-svelte/config/custom.js +++ b/templates/mellow-svelte/config/custom.js @@ -9,14 +9,12 @@ */ module.exports.custom = { - /*************************************************************************** - * * - * Any other custom config this Sails app should use during development. * - * * - ***************************************************************************/ + * * + * Any other custom config this Sails app should use during development. * + * * + ***************************************************************************/ // sendgridSecret: 'SG.fake.3e0Bn0qSQVnwb1E4qNPz9JZP5vLZYqjh7sn8S93oSHU', // stripeSecret: 'sk_test_Zzd814nldl91104qor5911gjald', // … - -}; +} diff --git a/templates/mellow-svelte/config/datastores.js b/templates/mellow-svelte/config/datastores.js index 38531843..1a913087 100644 --- a/templates/mellow-svelte/config/datastores.js +++ b/templates/mellow-svelte/config/datastores.js @@ -14,44 +14,38 @@ */ module.exports.datastores = { - - /*************************************************************************** - * * - * Your app's default datastore. * - * * - * Sails apps read and write to local disk by default, using a built-in * - * database adapter called `sails-disk`. This feature is purely for * - * convenience during development; since `sails-disk` is not designed for * - * use in a production environment. * - * * - * To use a different db _in development_, follow the directions below. * - * Otherwise, just leave the default datastore as-is, with no `adapter`. * - * * - * (For production configuration, see `config/env/production.js`.) * - * * - ***************************************************************************/ + * * + * Your app's default datastore. * + * * + * Sails apps read and write to local disk by default, using a built-in * + * database adapter called `sails-disk`. This feature is purely for * + * convenience during development; since `sails-disk` is not designed for * + * use in a production environment. * + * * + * To use a different db _in development_, follow the directions below. * + * Otherwise, just leave the default datastore as-is, with no `adapter`. * + * * + * (For production configuration, see `config/env/production.js`.) * + * * + ***************************************************************************/ default: { - /*************************************************************************** - * * - * Want to use a different database during development? * - * * - * 1. Choose an adapter: * - * https://sailsjs.com/plugins/databases * - * * - * 2. Install it as a dependency of your Sails app. * - * (For example: npm install sails-mysql --save) * - * * - * 3. Then pass it in, along with a connection URL. * - * (See https://sailsjs.com/config/datastores for help.) * - * * - ***************************************************************************/ + * * + * Want to use a different database during development? * + * * + * 1. Choose an adapter: * + * https://sailsjs.com/plugins/databases * + * * + * 2. Install it as a dependency of your Sails app. * + * (For example: npm install sails-mysql --save) * + * * + * 3. Then pass it in, along with a connection URL. * + * (See https://sailsjs.com/config/datastores for help.) * + * * + ***************************************************************************/ // adapter: 'sails-mysql', // url: 'mysql://user:password@host:port/database', - - }, - - -}; + } +} diff --git a/templates/mellow-svelte/config/env/production.js b/templates/mellow-svelte/config/env/production.js index 0d54db1d..9043768a 100644 --- a/templates/mellow-svelte/config/env/production.js +++ b/templates/mellow-svelte/config/env/production.js @@ -19,20 +19,19 @@ * http://sailsjs.com/docs/concepts/deployment */ - const TerserPlugin = require("terser-webpack-plugin"); +const TerserPlugin = require('terser-webpack-plugin') - module.exports = { - hookTimeout: 80000, - /************************************************************************** +module.exports = { + hookTimeout: 80000, + /************************************************************************** * * * Tell Sails what database(s) it should use in production. * * * * (http://sailsjs.com/config/datastores) * * * **************************************************************************/ - datastores: { - - /*************************************************************************** + datastores: { + /*************************************************************************** * * * Configure your default production database. * * * @@ -46,27 +45,23 @@ * (See http://sailsjs.com/config/datastores for help.) * * * ***************************************************************************/ - default: { - // adapter: require('sails-mysql'), - // url: 'mysql://user:password@host:port/database', - }, - //-------------------------------------------------------------------------- - // /\ To avoid checking it in to version control, you might opt to set - // || sensitive credentials like `url` using an environment variable. - // - // For example: - // ``` - // sails_datastores__default__url=mysql://admin:myc00lpAssw2D@db.example.com:3306/my_prod_db - // ``` - //-------------------------------------------------------------------------- - - }, - - - - models: { - - /************************************************************************** + default: { + // adapter: require('sails-mysql'), + // url: 'mysql://user:password@host:port/database', + } + //-------------------------------------------------------------------------- + // /\ To avoid checking it in to version control, you might opt to set + // || sensitive credentials like `url` using an environment variable. + // + // For example: + // ``` + // sails_datastores__default__url=mysql://admin:myc00lpAssw2D@db.example.com:3306/my_prod_db + // ``` + //-------------------------------------------------------------------------- + }, + + models: { + /************************************************************************** * * * To help avoid accidents, Sails automatically sets the automigration * * strategy to "safe" when your app lifts in production mode. * @@ -76,26 +71,23 @@ * http://sailsjs.com/docs/concepts/models-and-orm/model-settings#?migrate * * * ***************************************************************************/ - migrate: 'safe', - - }, - + migrate: 'safe' + }, - - /************************************************************************** + /************************************************************************** * * * Always disable "shortcut" blueprint routes. * * (you'll also want to disable any other blueprint routes that you are * * not actually using) * * * ***************************************************************************/ - blueprints: { - shortcuts: false, - // actions: false, - // rest: false, - }, + blueprints: { + shortcuts: false + // actions: false, + // rest: false, + }, - /*************************************************************************** + /*************************************************************************** * * * Configure your security settings for production. * * * @@ -106,9 +98,8 @@ * tested with CSRF protection turned on in development mode too. * * * ***************************************************************************/ - security: { - - /*************************************************************************** + security: { + /*************************************************************************** * * * If this app has CORS enabled (see `config/security.js`) with the * * `allowCredentials` setting enabled, then you should uncomment the * @@ -119,16 +110,14 @@ * > Be sure to use the right protocol! ("http://" vs. "https://") * * * ***************************************************************************/ - cors: { - // allowOrigins: [ - // 'https://example.com', - // ] - }, - - }, - - - /*************************************************************************** + cors: { + // allowOrigins: [ + // 'https://example.com', + // ] + } + }, + + /*************************************************************************** * * * Configure how your app handles sessions in production. * * * @@ -138,9 +127,8 @@ * > this section from your `config/env/production.js` file. * * * ***************************************************************************/ - session: { - - /*************************************************************************** + session: { + /*************************************************************************** * * * Production session store configuration. * * * @@ -154,22 +142,20 @@ * > (For a full list, see http://sailsjs.com/plugins/sessions) * * * ***************************************************************************/ - // adapter: 'connect-redis', - // url: 'redis://user:password@localhost:6379/dbname', - //-------------------------------------------------------------------------- - // /\ OR, to avoid checking it in to version control, you might opt to - // || set sensitive credentials like this using an environment variable. - // - // For example: - // ``` - // sails_session__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/sessions - // ``` - // - //-------------------------------------------------------------------------- - - - - /*************************************************************************** + // adapter: 'connect-redis', + // url: 'redis://user:password@localhost:6379/dbname', + //-------------------------------------------------------------------------- + // /\ OR, to avoid checking it in to version control, you might opt to + // || set sensitive credentials like this using an environment variable. + // + // For example: + // ``` + // sails_session__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/sessions + // ``` + // + //-------------------------------------------------------------------------- + + /*************************************************************************** * * * Production configuration for the session ID cookie. * * * @@ -190,16 +176,13 @@ * http://sailsjs.com/config/session#?the-session-id-cookie * * * ***************************************************************************/ - cookie: { - secure: true, - maxAge: 24 * 60 * 60 * 1000, // 24 hours - }, - - }, - - + cookie: { + secure: true, + maxAge: 24 * 60 * 60 * 1000 // 24 hours + } + }, - /************************************************************************** + /************************************************************************** * * * Set up Socket.io for your production environment. * * * @@ -209,9 +192,8 @@ * > this section from your `config/env/production.js` file. * * * ***************************************************************************/ - sockets: { - - /*************************************************************************** + sockets: { + /*************************************************************************** * * * Uncomment the `onlyAllowOrigins` whitelist below to configure which * * "origins" are allowed to open socket connections to your Sails app. * @@ -220,13 +202,12 @@ * > Be sure to use the right protocol! ("http://" vs. "https://") * * * ***************************************************************************/ - onlyAllowOrigins: [ - 'http://localhost:1337' - // 'https://example.com', - ], - + onlyAllowOrigins: [ + 'http://localhost:1337' + // 'https://example.com', + ] - /*************************************************************************** + /*************************************************************************** * * * If you are deploying a cluster of multiple servers and/or processes, * * then uncomment the following lines. This tells Socket.io about a Redis * @@ -235,46 +216,40 @@ * (http://sailsjs.com/docs/concepts/deployment/scaling) * * * ***************************************************************************/ - // adapter: 'socket.io-redis', - // url: 'redis://user:password@bigsquid.redistogo.com:9562/dbname', - //-------------------------------------------------------------------------- - // /\ OR, to avoid checking it in to version control, you might opt to - // || set sensitive credentials like this using an environment variable. - // - // For example: - // ``` - // sails_sockets__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/ - // ``` - //-------------------------------------------------------------------------- - - }, - - - - /************************************************************************** + // adapter: 'socket.io-redis', + // url: 'redis://user:password@bigsquid.redistogo.com:9562/dbname', + //-------------------------------------------------------------------------- + // /\ OR, to avoid checking it in to version control, you might opt to + // || set sensitive credentials like this using an environment variable. + // + // For example: + // ``` + // sails_sockets__url=redis://admin:myc00lpAssw2D@bigsquid.redistogo.com:9562/ + // ``` + //-------------------------------------------------------------------------- + }, + + /************************************************************************** * * * Set the production log level. * * * * (http://sailsjs.com/config/log) * * * ***************************************************************************/ - log: { - level: 'debug' - }, - - + log: { + level: 'debug' + }, - http: { - - /*************************************************************************** + http: { + /*************************************************************************** * * * The number of milliseconds to cache static assets in production. * * (the "max-age" to include in the "Cache-Control" response header) * * * ***************************************************************************/ - cache: 365.25 * 24 * 60 * 60 * 1000, // One year + cache: 365.25 * 24 * 60 * 60 * 1000 // One year - /*************************************************************************** + /*************************************************************************** * * * Proxy settings * * * @@ -289,13 +264,10 @@ * (http://sailsjs.com/config/http) * * * ***************************************************************************/ - // trustProxy: true, - - }, + // trustProxy: true, + }, - - - /************************************************************************** + /************************************************************************** * * * Lift the server on port 80. * * (if deploying behind a proxy, or to a PaaS like Heroku or Deis, you * @@ -304,11 +276,9 @@ * this, just try deploying without setting it and see if it works.) * * * ***************************************************************************/ - // port: 80, - + // port: 80, - - /************************************************************************** + /************************************************************************** * * * Configure an SSL certificate * * * @@ -325,45 +295,41 @@ * > http://sailsjs.com/config/*#?ssl-configuration-example * * * **************************************************************************/ - // ssl: undefined, - + // ssl: undefined, - - /************************************************************************** + /************************************************************************** * * * Overrides for any custom configuration specifically for your app. * * (for example, production API keys) * * * ***************************************************************************/ - custom: { - - // mailgunApiKey: 'key-prod_fake_bd32301385130a0bafe030c', - // stripeSecret: 'sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm', - //-------------------------------------------------------------------------- - // /\ OR, to avoid checking them in to version control, you might opt to - // || set sensitive credentials like these using environment variables. - // - // For example: - // ``` - // sails_custom__mailgunApiKey=key-prod_fake_bd32301385130a0bafe030c - // sails_custom__stripeSecret=sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm - // ``` - //-------------------------------------------------------------------------- - - }, - - /*************************************************************************** + custom: { + // mailgunApiKey: 'key-prod_fake_bd32301385130a0bafe030c', + // stripeSecret: 'sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm', + //-------------------------------------------------------------------------- + // /\ OR, to avoid checking them in to version control, you might opt to + // || set sensitive credentials like these using environment variables. + // + // For example: + // ``` + // sails_custom__mailgunApiKey=key-prod_fake_bd32301385130a0bafe030c + // sails_custom__stripeSecret=sk_prod__fake_Nfgh82401348jaDa3lkZ0d9Hm + // ``` + //-------------------------------------------------------------------------- + }, + + /*************************************************************************** * * * Override the default webpack plugin list to add the UglifyJsPlugin, * * which minifies the outputted JavaScript. * * * ***************************************************************************/ - webpack: { - mode: 'production', - optimization: { - minimize: true, - minimizer: [new TerserPlugin()], - } - } - } + webpack: { + mode: 'production', + optimization: { + minimize: true, + minimizer: [new TerserPlugin()] + } + } +} diff --git a/templates/mellow-svelte/config/globals.js b/templates/mellow-svelte/config/globals.js index f63701f9..5ddfcc0c 100644 --- a/templates/mellow-svelte/config/globals.js +++ b/templates/mellow-svelte/config/globals.js @@ -10,43 +10,41 @@ */ module.exports.globals = { - /**************************************************************************** - * * - * Whether to expose the locally-installed Lodash as a global variable * - * (`_`), making it accessible throughout your app. * - * * - ****************************************************************************/ + * * + * Whether to expose the locally-installed Lodash as a global variable * + * (`_`), making it accessible throughout your app. * + * * + ****************************************************************************/ _: require('@sailshq/lodash'), /**************************************************************************** - * * - * This app was generated without a dependency on the "async" NPM package. * - * * - * > Don't worry! This is totally unrelated to JavaScript's "async/await". * - * > Your code can (and probably should) use `await` as much as possible. * - * * - ****************************************************************************/ + * * + * This app was generated without a dependency on the "async" NPM package. * + * * + * > Don't worry! This is totally unrelated to JavaScript's "async/await". * + * > Your code can (and probably should) use `await` as much as possible. * + * * + ****************************************************************************/ async: false, /**************************************************************************** - * * - * Whether to expose each of your app's models as global variables. * - * (See the link at the top of this file for more information.) * - * * - ****************************************************************************/ + * * + * Whether to expose each of your app's models as global variables. * + * (See the link at the top of this file for more information.) * + * * + ****************************************************************************/ models: true, /**************************************************************************** - * * - * Whether to expose the Sails app instance as a global variable (`sails`), * - * making it accessible throughout your app. * - * * - ****************************************************************************/ - - sails: true, - -}; + * * + * Whether to expose the Sails app instance as a global variable (`sails`), * + * making it accessible throughout your app. * + * * + ****************************************************************************/ + + sails: true +} diff --git a/templates/mellow-svelte/config/http.js b/templates/mellow-svelte/config/http.js index 3cf438f1..56a61507 100644 --- a/templates/mellow-svelte/config/http.js +++ b/templates/mellow-svelte/config/http.js @@ -10,25 +10,22 @@ */ module.exports.http = { - /**************************************************************************** - * * - * Sails/Express middleware to run for every HTTP request. * - * (Only applies to HTTP requests -- not virtual WebSocket requests.) * - * * - * https://sailsjs.com/documentation/concepts/middleware * - * * - ****************************************************************************/ + * * + * Sails/Express middleware to run for every HTTP request. * + * (Only applies to HTTP requests -- not virtual WebSocket requests.) * + * * + * https://sailsjs.com/documentation/concepts/middleware * + * * + ****************************************************************************/ middleware: { - /*************************************************************************** - * * - * The order in which middleware should be run for HTTP requests. * - * (This Sails app's routes are handled by the "router" middleware below.) * - * * - ***************************************************************************/ - + * * + * The order in which middleware should be run for HTTP requests. * + * (This Sails app's routes are handled by the "router" middleware below.) * + * * + ***************************************************************************/ // order: [ // 'cookieParser', // 'session', @@ -39,22 +36,17 @@ module.exports.http = { // 'www', // 'favicon', // ], - - /*************************************************************************** - * * - * The body parser that will handle incoming multipart HTTP requests. * - * * - * https://sailsjs.com/config/http#?customizing-the-body-parser * - * * - ***************************************************************************/ - + * * + * The body parser that will handle incoming multipart HTTP requests. * + * * + * https://sailsjs.com/config/http#?customizing-the-body-parser * + * * + ***************************************************************************/ // bodyParser: (function _configureBodyParser(){ // var skipper = require('skipper'); // var middlewareFn = skipper({ strict: true }); // return middlewareFn; // })(), - - }, - -}; + } +} diff --git a/templates/mellow-svelte/config/i18n.js b/templates/mellow-svelte/config/i18n.js index 0b652d26..8b8a4d7e 100644 --- a/templates/mellow-svelte/config/i18n.js +++ b/templates/mellow-svelte/config/i18n.js @@ -13,33 +13,31 @@ */ module.exports.i18n = { - /*************************************************************************** - * * - * Which locales are supported? * - * * - ***************************************************************************/ + * * + * Which locales are supported? * + * * + ***************************************************************************/ - locales: ['en', 'es', 'fr', 'de'], + locales: ['en', 'es', 'fr', 'de'] /**************************************************************************** - * * - * What is the default locale for the site? Note that this setting will be * - * overridden for any request that sends an "Accept-Language" header (i.e. * - * most browsers), but it's still useful if you need to localize the * - * response for requests made by non-browser clients (e.g. cURL). * - * * - ****************************************************************************/ + * * + * What is the default locale for the site? Note that this setting will be * + * overridden for any request that sends an "Accept-Language" header (i.e. * + * most browsers), but it's still useful if you need to localize the * + * response for requests made by non-browser clients (e.g. cURL). * + * * + ****************************************************************************/ // defaultLocale: 'en', /**************************************************************************** - * * - * Path (relative to app root) of directory to store locale (translation) * - * files in. * - * * - ****************************************************************************/ + * * + * Path (relative to app root) of directory to store locale (translation) * + * files in. * + * * + ****************************************************************************/ // localesDirectory: 'config/locales' - -}; +} diff --git a/templates/mellow-svelte/config/inertia.js b/templates/mellow-svelte/config/inertia.js index 298e88a4..0d54d6b7 100644 --- a/templates/mellow-svelte/config/inertia.js +++ b/templates/mellow-svelte/config/inertia.js @@ -8,7 +8,7 @@ * https://inertia-sails.sailscasts.com */ - module.exports.inertia = { +module.exports.inertia = { /** * https://inertiajs.com/asset-versioning * You can pass a string, number that changes when your assets change diff --git a/templates/mellow-svelte/config/log.js b/templates/mellow-svelte/config/log.js index 1ef07f55..85c2eaf4 100644 --- a/templates/mellow-svelte/config/log.js +++ b/templates/mellow-svelte/config/log.js @@ -11,19 +11,16 @@ */ module.exports.log = { - /*************************************************************************** - * * - * Valid `level` configs: i.e. the minimum log level to capture with * - * sails.log.*() * - * * - * The order of precedence for log levels from lowest to highest is: * - * silly, verbose, info, debug, warn, error * - * * - * You may also set the level to "silent" to suppress all logs. * - * * - ***************************************************************************/ - + * * + * Valid `level` configs: i.e. the minimum log level to capture with * + * sails.log.*() * + * * + * The order of precedence for log levels from lowest to highest is: * + * silly, verbose, info, debug, warn, error * + * * + * You may also set the level to "silent" to suppress all logs. * + * * + ***************************************************************************/ // level: 'info' - -}; +} diff --git a/templates/mellow-svelte/config/models.js b/templates/mellow-svelte/config/models.js index 0c454000..96f6be96 100644 --- a/templates/mellow-svelte/config/models.js +++ b/templates/mellow-svelte/config/models.js @@ -14,64 +14,60 @@ */ module.exports.models = { - - /*************************************************************************** - * * - * Whether model methods like `.create()` and `.update()` should ignore * - * (and refuse to persist) unrecognized data-- i.e. properties other than * - * those explicitly defined by attributes in the model definition. * - * * - * To ease future maintenance of your code base, it is usually a good idea * - * to set this to `true`. * - * * - * > Note that `schema: false` is not supported by every database. * - * > For example, if you are using a SQL database, then relevant models * - * > are always effectively `schema: true`. And if no `schema` setting is * - * > provided whatsoever, the behavior is left up to the database adapter. * - * > * - * > For more info, see: * - * > https://sailsjs.com/docs/concepts/orm/model-settings#?schema * - * * - ***************************************************************************/ + * * + * Whether model methods like `.create()` and `.update()` should ignore * + * (and refuse to persist) unrecognized data-- i.e. properties other than * + * those explicitly defined by attributes in the model definition. * + * * + * To ease future maintenance of your code base, it is usually a good idea * + * to set this to `true`. * + * * + * > Note that `schema: false` is not supported by every database. * + * > For example, if you are using a SQL database, then relevant models * + * > are always effectively `schema: true`. And if no `schema` setting is * + * > provided whatsoever, the behavior is left up to the database adapter. * + * > * + * > For more info, see: * + * > https://sailsjs.com/docs/concepts/orm/model-settings#?schema * + * * + ***************************************************************************/ schema: true, - /*************************************************************************** - * * - * How and whether Sails will attempt to automatically rebuild the * - * tables/collections/etc. in your schema. * - * * - * > Note that, when running in a production environment, this will be * - * > automatically set to `migrate: 'safe'`, no matter what you configure * - * > here. This is a failsafe to prevent Sails from accidentally running * - * > auto-migrations on your production database. * - * > * - * > For more info, see: * - * > https://sailsjs.com/docs/concepts/orm/model-settings#?migrate * - * * - ***************************************************************************/ + * * + * How and whether Sails will attempt to automatically rebuild the * + * tables/collections/etc. in your schema. * + * * + * > Note that, when running in a production environment, this will be * + * > automatically set to `migrate: 'safe'`, no matter what you configure * + * > here. This is a failsafe to prevent Sails from accidentally running * + * > auto-migrations on your production database. * + * > * + * > For more info, see: * + * > https://sailsjs.com/docs/concepts/orm/model-settings#?migrate * + * * + ***************************************************************************/ migrate: 'alter', - /*************************************************************************** - * * - * Base attributes that are included in all of your models by default. * - * By convention, this is your primary key attribute (`id`), as well as two * - * other timestamp attributes for tracking when records were last created * - * or updated. * - * * - * > For more info, see: * - * > https://sailsjs.com/docs/concepts/orm/model-settings#?attributes * - * * - ***************************************************************************/ + * * + * Base attributes that are included in all of your models by default. * + * By convention, this is your primary key attribute (`id`), as well as two * + * other timestamp attributes for tracking when records were last created * + * or updated. * + * * + * > For more info, see: * + * > https://sailsjs.com/docs/concepts/orm/model-settings#?attributes * + * * + ***************************************************************************/ attributes: { - createdAt: { type: 'number', autoCreatedAt: true, }, - updatedAt: { type: 'number', autoUpdatedAt: true, }, - id: { type: 'number', autoIncrement: true, }, + createdAt: { type: 'number', autoCreatedAt: true }, + updatedAt: { type: 'number', autoUpdatedAt: true }, + id: { type: 'number', autoIncrement: true } //-------------------------------------------------------------------------- // /\ Using MongoDB? // || Replace `id` above with this instead: @@ -85,40 +81,36 @@ module.exports.models = { //-------------------------------------------------------------------------- }, - /****************************************************************************** - * * - * The set of DEKs (data encryption keys) for at-rest encryption. * - * i.e. when encrypting/decrypting data for attributes with `encrypt: true`. * - * * - * > The `default` DEK is used for all new encryptions, but multiple DEKs * - * > can be configured to allow for key rotation. In production, be sure to * - * > manage these keys like you would any other sensitive credential. * - * * - * > For more info, see: * - * > https://sailsjs.com/docs/concepts/orm/model-settings#?dataEncryptionKeys * - * * - ******************************************************************************/ + * * + * The set of DEKs (data encryption keys) for at-rest encryption. * + * i.e. when encrypting/decrypting data for attributes with `encrypt: true`. * + * * + * > The `default` DEK is used for all new encryptions, but multiple DEKs * + * > can be configured to allow for key rotation. In production, be sure to * + * > manage these keys like you would any other sensitive credential. * + * * + * > For more info, see: * + * > https://sailsjs.com/docs/concepts/orm/model-settings#?dataEncryptionKeys * + * * + ******************************************************************************/ dataEncryptionKeys: { default: '$defaultDEK' }, - /*************************************************************************** - * * - * Whether or not implicit records for associations should be cleaned up * - * automatically using the built-in polyfill. This is especially useful * - * during development with sails-disk. * - * * - * Depending on which databases you're using, you may want to disable this * - * polyfill in your production environment. * - * * - * (For production configuration, see `config/env/production.js`.) * - * * - ***************************************************************************/ + * * + * Whether or not implicit records for associations should be cleaned up * + * automatically using the built-in polyfill. This is especially useful * + * during development with sails-disk. * + * * + * Depending on which databases you're using, you may want to disable this * + * polyfill in your production environment. * + * * + * (For production configuration, see `config/env/production.js`.) * + * * + ***************************************************************************/ cascadeOnDestroy: true - - -}; +} diff --git a/templates/mellow-svelte/config/policies.js b/templates/mellow-svelte/config/policies.js index c4d1bb53..859e0fa6 100644 --- a/templates/mellow-svelte/config/policies.js +++ b/templates/mellow-svelte/config/policies.js @@ -9,14 +9,11 @@ */ module.exports.policies = { - /*************************************************************************** - * * - * Default policy for all controllers and actions, unless overridden. * - * (`true` allows public access) * - * * - ***************************************************************************/ - + * * + * Default policy for all controllers and actions, unless overridden. * + * (`true` allows public access) * + * * + ***************************************************************************/ // '*': true, - -}; +} diff --git a/templates/mellow-svelte/config/routes.js b/templates/mellow-svelte/config/routes.js index dd96ab7d..4961d3e5 100644 --- a/templates/mellow-svelte/config/routes.js +++ b/templates/mellow-svelte/config/routes.js @@ -8,7 +8,7 @@ * http://sailsjs.com/anatomy/config/routes-js */ - module.exports.routes = { +module.exports.routes = { /*************************************************************************** * * * Custom routes here... * @@ -19,5 +19,5 @@ * * ***************************************************************************/ 'GET /': 'home/index', - 'GET /example': 'example/index', + 'GET /example': 'example/index' } diff --git a/templates/mellow-svelte/config/security.js b/templates/mellow-svelte/config/security.js index bd576316..ba514b0d 100644 --- a/templates/mellow-svelte/config/security.js +++ b/templates/mellow-svelte/config/security.js @@ -14,41 +14,35 @@ */ module.exports.security = { - /*************************************************************************** - * * - * CORS is like a more modern version of JSONP-- it allows your application * - * to circumvent browsers' same-origin policy, so that the responses from * - * your Sails app hosted on one domain (e.g. example.com) can be received * - * in the client-side JavaScript code from a page you trust hosted on _some * - * other_ domain (e.g. trustedsite.net). * - * * - * For additional options and more information, see: * - * https://sailsjs.com/docs/concepts/security/cors * - * * - ***************************************************************************/ - + * * + * CORS is like a more modern version of JSONP-- it allows your application * + * to circumvent browsers' same-origin policy, so that the responses from * + * your Sails app hosted on one domain (e.g. example.com) can be received * + * in the client-side JavaScript code from a page you trust hosted on _some * + * other_ domain (e.g. trustedsite.net). * + * * + * For additional options and more information, see: * + * https://sailsjs.com/docs/concepts/security/cors * + * * + ***************************************************************************/ // cors: { // allRoutes: false, // allowOrigins: '*', // allowCredentials: false, // }, - - /**************************************************************************** - * * - * By default, Sails' built-in CSRF protection is disabled to facilitate * - * rapid development. But be warned! If your Sails app will be accessed by * - * web browsers, you should _always_ enable CSRF protection before deploying * - * to production. * - * * - * To enable CSRF protection, set this to `true`. * - * * - * For more information, see: * - * https://sailsjs.com/docs/concepts/security/csrf * - * * - ****************************************************************************/ - + * * + * By default, Sails' built-in CSRF protection is disabled to facilitate * + * rapid development. But be warned! If your Sails app will be accessed by * + * web browsers, you should _always_ enable CSRF protection before deploying * + * to production. * + * * + * To enable CSRF protection, set this to `true`. * + * * + * For more information, see: * + * https://sailsjs.com/docs/concepts/security/csrf * + * * + ****************************************************************************/ // csrf: false - -}; +} diff --git a/templates/mellow-svelte/config/session.js b/templates/mellow-svelte/config/session.js index 53d76a5f..970c8051 100644 --- a/templates/mellow-svelte/config/session.js +++ b/templates/mellow-svelte/config/session.js @@ -10,30 +10,27 @@ */ module.exports.session = { - /*************************************************************************** - * * - * Session secret is automatically generated when your new app is created * - * Replace at your own risk in production-- you will invalidate the cookies * - * of your users, forcing them to log in again. * - * * - ***************************************************************************/ - secret: '$secret', - + * * + * Session secret is automatically generated when your new app is created * + * Replace at your own risk in production-- you will invalidate the cookies * + * of your users, forcing them to log in again. * + * * + ***************************************************************************/ + secret: '$secret' /*************************************************************************** - * * - * Customize when built-in session support will be skipped. * - * * - * (Useful for performance tuning; particularly to avoid wasting cycles on * - * session management when responding to simple requests for static assets, * - * like images or stylesheets.) * - * * - * https://sailsjs.com/config/session * - * * - ***************************************************************************/ + * * + * Customize when built-in session support will be skipped. * + * * + * (Useful for performance tuning; particularly to avoid wasting cycles on * + * session management when responding to simple requests for static assets, * + * like images or stylesheets.) * + * * + * https://sailsjs.com/config/session * + * * + ***************************************************************************/ // isSessionDisabled: function (req){ // return !!req.path.match(req._sails.LOOKS_LIKE_ASSET_RX); // }, - -}; +} diff --git a/templates/mellow-svelte/config/sockets.js b/templates/mellow-svelte/config/sockets.js index 9f466a04..c3445b6c 100644 --- a/templates/mellow-svelte/config/sockets.js +++ b/templates/mellow-svelte/config/sockets.js @@ -10,38 +10,33 @@ */ module.exports.sockets = { - /*************************************************************************** - * * - * `transports` * - * * - * The protocols or "transports" that socket clients are permitted to * - * use when connecting and communicating with this Sails application. * - * * - * > Never change this here without also configuring `io.sails.transports` * - * > in your client-side code. If the client and the server are not using * - * > the same array of transports, sockets will not work properly. * - * > * - * > For more info, see: * - * > https://sailsjs.com/docs/reference/web-sockets/socket-client * - * * - ***************************************************************************/ - + * * + * `transports` * + * * + * The protocols or "transports" that socket clients are permitted to * + * use when connecting and communicating with this Sails application. * + * * + * > Never change this here without also configuring `io.sails.transports` * + * > in your client-side code. If the client and the server are not using * + * > the same array of transports, sockets will not work properly. * + * > * + * > For more info, see: * + * > https://sailsjs.com/docs/reference/web-sockets/socket-client * + * * + ***************************************************************************/ // transports: [ 'websocket' ], - - /*************************************************************************** - * * - * `beforeConnect` * - * * - * This custom beforeConnect function will be run each time BEFORE a new * - * socket is allowed to connect, when the initial socket.io handshake is * - * performed with the server. * - * * - * https://sailsjs.com/config/sockets#?beforeconnect * - * * - ***************************************************************************/ - + * * + * `beforeConnect` * + * * + * This custom beforeConnect function will be run each time BEFORE a new * + * socket is allowed to connect, when the initial socket.io handshake is * + * performed with the server. * + * * + * https://sailsjs.com/config/sockets#?beforeconnect * + * * + ***************************************************************************/ // beforeConnect: function(handshake, proceed) { // // // `true` allows the socket to connect. @@ -49,17 +44,14 @@ module.exports.sockets = { // return proceed(undefined, true); // // }, - - /*************************************************************************** - * * - * `afterDisconnect` * - * * - * This custom afterDisconnect function will be run each time a socket * - * disconnects * - * * - ***************************************************************************/ - + * * + * `afterDisconnect` * + * * + * This custom afterDisconnect function will be run each time a socket * + * disconnects * + * * + ***************************************************************************/ // afterDisconnect: function(session, socket, done) { // // // By default: do nothing. @@ -67,16 +59,11 @@ module.exports.sockets = { // return done(); // // }, - - /*************************************************************************** - * * - * Whether to expose a 'GET /__getcookie' route that sets an HTTP-only * - * session cookie. * - * * - ***************************************************************************/ - + * * + * Whether to expose a 'GET /__getcookie' route that sets an HTTP-only * + * session cookie. * + * * + ***************************************************************************/ // grant3rdPartyCookie: true, - - -}; +} diff --git a/templates/mellow-svelte/config/views.js b/templates/mellow-svelte/config/views.js index 601e667f..2f37a918 100644 --- a/templates/mellow-svelte/config/views.js +++ b/templates/mellow-svelte/config/views.js @@ -15,27 +15,25 @@ */ module.exports.views = { - /*************************************************************************** - * * - * Extension to use for your views. When calling `res.view()` in an action, * - * you can leave this extension off. For example, calling * - * `res.view('homepage')` will (using default settings) look for a * - * `views/homepage.ejs` file. * - * * - ***************************************************************************/ + * * + * Extension to use for your views. When calling `res.view()` in an action, * + * you can leave this extension off. For example, calling * + * `res.view('homepage')` will (using default settings) look for a * + * `views/homepage.ejs` file. * + * * + ***************************************************************************/ // extension: 'ejs', /*************************************************************************** - * * - * The path (relative to the views directory, and without extension) to * - * the default layout file to use, or `false` to disable layouts entirely. * - * * - * Note that layouts only work with the built-in EJS view engine! * - * * - ***************************************************************************/ + * * + * The path (relative to the views directory, and without extension) to * + * the default layout file to use, or `false` to disable layouts entirely. * + * * + * Note that layouts only work with the built-in EJS view engine! * + * * + ***************************************************************************/ layout: false - -}; +} diff --git a/templates/mellow-svelte/config/webpack.js b/templates/mellow-svelte/config/webpack.js index 1a28b153..1c4aa344 100644 --- a/templates/mellow-svelte/config/webpack.js +++ b/templates/mellow-svelte/config/webpack.js @@ -2,113 +2,113 @@ * Module dependencies */ - const path = require('path') - const { CleanWebpackPlugin } = require('clean-webpack-plugin') - const CopyWebpackPlugin = require('copy-webpack-plugin') - const MiniCssExtractPlugin = require('mini-css-extract-plugin') +const path = require('path') +const { CleanWebpackPlugin } = require('clean-webpack-plugin') +const CopyWebpackPlugin = require('copy-webpack-plugin') +const MiniCssExtractPlugin = require('mini-css-extract-plugin') - /** - * A basic Webpack config to use with a Sails app. - * - * This config is used by the api/hooks/webpack hook which initializes a - * Webpack compiler in "watch" mode. - * - * See https://webpack.js.org/configuration for a full guide to Webpack config. - * - */ - module.exports.webpack = { - mode: 'development', +/** + * A basic Webpack config to use with a Sails app. + * + * This config is used by the api/hooks/webpack hook which initializes a + * Webpack compiler in "watch" mode. + * + * See https://webpack.js.org/configuration for a full guide to Webpack config. + * + */ +module.exports.webpack = { + mode: 'development', - /*************************************************************************** - * * - * Create one item in the `entry` dictionary for each page in your app. * - * * - ***************************************************************************/ - entry: { - app: './assets/js/app.js', - }, + /*************************************************************************** + * * + * Create one item in the `entry` dictionary for each page in your app. * + * * + ***************************************************************************/ + entry: { + app: './assets/js/app.js' + }, - resolve: { - extensions: ['.svelte', '...'], - alias: { + resolve: { + extensions: ['.svelte', '...'], + alias: { '~': path.resolve(__dirname, '..', 'assets'), '@': path.resolve(__dirname, '..', 'assets', 'js') } - }, + }, - /*************************************************************************** - * * - * Output bundled .js files with a `.bundle.js` extension into * - * the `.tmp/public/js` directory * - * * - ***************************************************************************/ - output: { - filename: 'js/[name].bundle.js', - path: path.resolve(__dirname, '..', '.tmp', 'public'), - }, + /*************************************************************************** + * * + * Output bundled .js files with a `.bundle.js` extension into * + * the `.tmp/public/js` directory * + * * + ***************************************************************************/ + output: { + filename: 'js/[name].bundle.js', + path: path.resolve(__dirname, '..', '.tmp', 'public') + }, - /*************************************************************************** - * * - * Set up a couple of rules for processing .css and .less files. These will * - * be extracted into their own bundles when they're imported in a * - * JavaScript file. * - * * - ***************************************************************************/ - module: { - rules: [ - { - test: /\.css$/i, - use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'], - }, - { - test: /\.js?$/, - exclude: /node_modules/, - use: { - loader: 'babel-loader', - }, - }, - { - test: /\.svelte$/, - use: { - loader: 'svelte-loader', - }, - }, - ], - }, + /*************************************************************************** + * * + * Set up a couple of rules for processing .css and .less files. These will * + * be extracted into their own bundles when they're imported in a * + * JavaScript file. * + * * + ***************************************************************************/ + module: { + rules: [ + { + test: /\.css$/i, + use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader'] + }, + { + test: /\.js?$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader' + } + }, + { + test: /\.svelte$/, + use: { + loader: 'svelte-loader' + } + } + ] + }, - /*************************************************************************** - * * - * Set up some plugins to help with Sails development using Webpack. * - * * - ***************************************************************************/ - plugins: [ - // This plugin extracts CSS that was imported into .js files, and bundles - // it into separate .css files. The filename is based on the name of the - // .js file that the CSS was imported into. - new MiniCssExtractPlugin({ - filename: 'css/[name].bundle.css', - }), + /*************************************************************************** + * * + * Set up some plugins to help with Sails development using Webpack. * + * * + ***************************************************************************/ + plugins: [ + // This plugin extracts CSS that was imported into .js files, and bundles + // it into separate .css files. The filename is based on the name of the + // .js file that the CSS was imported into. + new MiniCssExtractPlugin({ + filename: 'css/[name].bundle.css' + }), - // This plugin cleans out your .tmp/public folder before lifting. - new CleanWebpackPlugin({ - verbose: true, - dry: false, - }), + // This plugin cleans out your .tmp/public folder before lifting. + new CleanWebpackPlugin({ + verbose: true, + dry: false + }), - // This plugin copies the `images` and `fonts` folders into - // the .tmp/public folder. You can add any other static asset - // folders to this list and they'll be copied as well. - new CopyWebpackPlugin({ - patterns: [ - { - from: './assets/images', - to: path.resolve(__dirname, '..', '.tmp', 'public', 'images'), - }, - { - from: './assets/fonts', - to: path.resolve(__dirname, '..', '.tmp', 'public', 'fonts'), - }, - ], - }), - ], - } + // This plugin copies the `images` and `fonts` folders into + // the .tmp/public folder. You can add any other static asset + // folders to this list and they'll be copied as well. + new CopyWebpackPlugin({ + patterns: [ + { + from: './assets/images', + to: path.resolve(__dirname, '..', '.tmp', 'public', 'images') + }, + { + from: './assets/fonts', + to: path.resolve(__dirname, '..', '.tmp', 'public', 'fonts') + } + ] + }) + ] +} diff --git a/templates/mellow-svelte/postcss.config.js b/templates/mellow-svelte/postcss.config.js index f1c8dac8..85f717cc 100644 --- a/templates/mellow-svelte/postcss.config.js +++ b/templates/mellow-svelte/postcss.config.js @@ -1,6 +1,6 @@ module.exports = { plugins: { tailwindcss: {}, - autoprefixer: {}, + autoprefixer: {} } } diff --git a/templates/mellow-svelte/prettier.config.js b/templates/mellow-svelte/prettier.config.js index cb950684..e94a48b6 100644 --- a/templates/mellow-svelte/prettier.config.js +++ b/templates/mellow-svelte/prettier.config.js @@ -1,5 +1,5 @@ module.exports = { plugins: [require('prettier-plugin-tailwindcss')], semi: false, - singleQuote: true, + singleQuote: true } diff --git a/templates/mellow-svelte/tailwind.config.js b/templates/mellow-svelte/tailwind.config.js index 01927258..78975a1b 100644 --- a/templates/mellow-svelte/tailwind.config.js +++ b/templates/mellow-svelte/tailwind.config.js @@ -1,7 +1,7 @@ module.exports = { - content: ['./assets/js/**/*.{html,js,svelte,ts}',], + content: ['./assets/js/**/*.{html,js,svelte,ts}'], theme: { - extend: {}, + extend: {} }, - plugins: [], + plugins: [] } diff --git a/templates/mellow-svelte/views/.eslintrc b/templates/mellow-svelte/views/.eslintrc index ad4c06ef..6fd3589d 100644 --- a/templates/mellow-svelte/views/.eslintrc +++ b/templates/mellow-svelte/views/.eslintrc @@ -12,9 +12,7 @@ // For more information see: // https://sailsjs.com/anatomy/views/.eslintrc // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "extends": [ - "../assets/.eslintrc" - ], + "extends": ["../assets/.eslintrc"], "rules": { "eol-last": [0] } diff --git a/templates/mellow-vue/.eslintrc b/templates/mellow-vue/.eslintrc index b284ab05..daf992b8 100644 --- a/templates/mellow-vue/.eslintrc +++ b/templates/mellow-vue/.eslintrc @@ -5,7 +5,7 @@ // A set of basic code conventions designed to encourage quality and consistency // across your Sails app's code base. These rules are checked against // automatically any time you run `npm test`. - // + // // > An additional eslintrc override file is included in the `assets/` folder // > right out of the box. This is specifically to allow for variations in acceptable // > global variables between front-end JavaScript code designed to run in the browser @@ -42,49 +42,67 @@ }, "rules": { - "block-scoped-var": ["error"], - "callback-return": ["error", ["done", "proceed", "next", "onwards", "callback", "cb"]], - "camelcase": ["warn", {"properties":"always"}], - "comma-style": ["warn", "last"], - "curly": ["warn"], - "eqeqeq": ["error", "always"], - "eol-last": ["warn"], - "handle-callback-err": ["error"], - "indent": ["warn", 2, { - "SwitchCase": 1, - "MemberExpression": "off", - "FunctionDeclaration": {"body":1, "parameters":"off"}, - "FunctionExpression": {"body":1, "parameters":"off"}, - "CallExpression": {"arguments":"off"}, - "ArrayExpression": 1, - "ObjectExpression": 1, - "ignoredNodes": ["ConditionalExpression"] - }], - "linebreak-style": ["error", "unix"], - "no-dupe-keys": ["error"], - "no-duplicate-case": ["error"], - "no-extra-semi": ["warn"], - "no-labels": ["error"], - "no-mixed-spaces-and-tabs": [2, "smart-tabs"], - "no-redeclare": ["warn"], - "no-return-assign": ["error", "always"], - "no-sequences": ["error"], - "no-trailing-spaces": ["warn"], - "no-undef": ["off"], + "block-scoped-var": ["error"], + "callback-return": [ + "error", + ["done", "proceed", "next", "onwards", "callback", "cb"] + ], + "camelcase": ["warn", { "properties": "always" }], + "comma-style": ["warn", "last"], + "curly": ["warn"], + "eqeqeq": ["error", "always"], + "eol-last": ["warn"], + "handle-callback-err": ["error"], + "indent": [ + "warn", + 2, + { + "SwitchCase": 1, + "MemberExpression": "off", + "FunctionDeclaration": { "body": 1, "parameters": "off" }, + "FunctionExpression": { "body": 1, "parameters": "off" }, + "CallExpression": { "arguments": "off" }, + "ArrayExpression": 1, + "ObjectExpression": 1, + "ignoredNodes": ["ConditionalExpression"] + } + ], + "linebreak-style": ["error", "unix"], + "no-dupe-keys": ["error"], + "no-duplicate-case": ["error"], + "no-extra-semi": ["warn"], + "no-labels": ["error"], + "no-mixed-spaces-and-tabs": [2, "smart-tabs"], + "no-redeclare": ["warn"], + "no-return-assign": ["error", "always"], + "no-sequences": ["error"], + "no-trailing-spaces": ["warn"], + "no-undef": ["off"], // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ^^Note: If this "no-undef" rule is enabled (set to `["error"]`), then all model globals // (e.g. `"Organization": true`) should be included above under "globals". // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "no-unexpected-multiline": ["warn"], - "no-unreachable": ["warn"], - "no-unused-vars": ["warn", {"caughtErrors":"all", "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", "argsIgnorePattern": "^unused($|[A-Z].*$)", "varsIgnorePattern": "^unused($|[A-Z].*$)" }], - "no-use-before-define": ["error", {"functions":false}], - "one-var": ["warn", "never"], - "prefer-arrow-callback": ["warn", {"allowNamedFunctions":true}], - "quotes": ["warn", "single", {"avoidEscape":false, "allowTemplateLiterals":true}], - "semi": ["warn", "always"], - "semi-spacing": ["warn", {"before":false, "after":true}], - "semi-style": ["warn", "last"] + "no-unexpected-multiline": ["warn"], + "no-unreachable": ["warn"], + "no-unused-vars": [ + "warn", + { + "caughtErrors": "all", + "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", + "argsIgnorePattern": "^unused($|[A-Z].*$)", + "varsIgnorePattern": "^unused($|[A-Z].*$)" + } + ], + "no-use-before-define": ["error", { "functions": false }], + "one-var": ["warn", "never"], + "prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }], + "quotes": [ + "warn", + "single", + { "avoidEscape": false, "allowTemplateLiterals": true } + ], + "semi": ["warn", "always"], + "semi-spacing": ["warn", { "before": false, "after": true }], + "semi-style": ["warn", "last"] } - } diff --git a/templates/mellow-vue/README.md b/templates/mellow-vue/README.md index e59aea4a..2c6a1c46 100644 --- a/templates/mellow-vue/README.md +++ b/templates/mellow-vue/README.md @@ -3,6 +3,7 @@ This template should help get you started developing with a modern Sails fullstack application with Inertia and Vue 3. This scaffold contains: -* webpack -* tailwind -* vue + +- webpack +- tailwind +- vue diff --git a/templates/mellow-vue/api/controllers/example/index.js b/templates/mellow-vue/api/controllers/example/index.js index dc252832..8fa66a22 100644 --- a/templates/mellow-vue/api/controllers/example/index.js +++ b/templates/mellow-vue/api/controllers/example/index.js @@ -9,7 +9,7 @@ module.exports = { fn: async function () { return sails.inertia.render('example', { - quote: "You can shine no matter what you're made of - Bigweld", + quote: "You can shine no matter what you're made of - Bigweld" }) - }, + } } diff --git a/templates/mellow-vue/api/controllers/home/index.js b/templates/mellow-vue/api/controllers/home/index.js index 14ba7bf7..be3c2b7b 100644 --- a/templates/mellow-vue/api/controllers/home/index.js +++ b/templates/mellow-vue/api/controllers/home/index.js @@ -9,7 +9,7 @@ module.exports = { fn: async function () { return sails.inertia.render('index', { - name: 'Inertia', + name: 'Inertia' }) - }, + } } diff --git a/templates/mellow-vue/api/hooks/webpack/index.js b/templates/mellow-vue/api/hooks/webpack/index.js index aaab5563..e031666b 100644 --- a/templates/mellow-vue/api/hooks/webpack/index.js +++ b/templates/mellow-vue/api/hooks/webpack/index.js @@ -1,71 +1,72 @@ /** * Module dependencies */ - const webpack = require('webpack'); +const webpack = require('webpack') +/** + * Webpack hook + * + * @description :: A hook to compile assets using Webhook. + */ - /** - * Webpack hook - * - * @description :: A hook to compile assets using Webhook. - */ - - module.exports = function defineWebpackHook(sails) { - - return { - - /** - * Runs when a Sails app loads/lifts. - * - * @param {Function} done - */ - initialize: function (done) { - - // In production mode, just compile the assets and continue lifting Sails. - if (process.env.NODE_ENV === 'production') { - return webpack(sails.config.webpack, done); - } - - // Otherwise, create a compiler so that we can watch files. - var compiler = webpack(sails.config.webpack); - - // Trigger the first compile, start watching files, and return - // an instance we can use to stop the watcher when Sails lowers. - var watcher = compiler.watch({ - // Wait a bit after a change is detected before recompiling, - // in case other changes come in. - aggregateTimeout: 300, - // Ignore changes to files in node_modules, even if they're - // imported by our scripts. - ignored: /node_modules/ - // poll: true - // ^^^^^ If native watching isn't working, uncomment the above. - }, function(err, stats) { - - // If the compilation generates errors and we're not already logging all the output from - // the watcher, log the errors to the console. - if (stats.hasErrors() && sails.config.log.level !== 'silly' && sails.config.log.level !== 'verbose') { - sails.log.verbose('Webpack encountered errors while compiling. Full output:'); - sails.log.error(stats.toString()); - } - - // Otherwise output the result of the compilation. - else { - sails.log.verbose('Webpack compiled files and outputted:'); - sails.log.verbose(stats.toString()); - } - }); +module.exports = function defineWebpackHook(sails) { + return { + /** + * Runs when a Sails app loads/lifts. + * + * @param {Function} done + */ + initialize: function (done) { + // In production mode, just compile the assets and continue lifting Sails. + if (process.env.NODE_ENV === 'production') { + return webpack(sails.config.webpack, done) + } - // When Sails lowers, stop watching files. - sails.on('lower', function() { - watcher && watcher.close(); - }); + // Otherwise, create a compiler so that we can watch files. + var compiler = webpack(sails.config.webpack) - // Continue lifting Sails. - return done(); + // Trigger the first compile, start watching files, and return + // an instance we can use to stop the watcher when Sails lowers. + var watcher = compiler.watch( + { + // Wait a bit after a change is detected before recompiling, + // in case other changes come in. + aggregateTimeout: 300, + // Ignore changes to files in node_modules, even if they're + // imported by our scripts. + ignored: /node_modules/ + // poll: true + // ^^^^^ If native watching isn't working, uncomment the above. + }, + function (err, stats) { + // If the compilation generates errors and we're not already logging all the output from + // the watcher, log the errors to the console. + if ( + stats.hasErrors() && + sails.config.log.level !== 'silly' && + sails.config.log.level !== 'verbose' + ) { + sails.log.verbose( + 'Webpack encountered errors while compiling. Full output:' + ) + sails.log.error(stats.toString()) + } - } + // Otherwise output the result of the compilation. + else { + sails.log.verbose('Webpack compiled files and outputted:') + sails.log.verbose(stats.toString()) + } + } + ) - }; + // When Sails lowers, stop watching files. + sails.on('lower', function () { + watcher && watcher.close() + }) - }; + // Continue lifting Sails. + return done() + } + } +} diff --git a/templates/mellow-vue/app.js b/templates/mellow-vue/app.js index f2c5f4eb..7799a854 100644 --- a/templates/mellow-vue/app.js +++ b/templates/mellow-vue/app.js @@ -20,35 +20,43 @@ * https://sailsjs.com/anatomy/app.js */ - // Ensure we're in the project directory, so cwd-relative paths work as expected // no matter where we actually lift from. // > Note: This is not required in order to lift, but it is a convenient default. -process.chdir(__dirname); - - +process.chdir(__dirname) // Attempt to import `sails` dependency, as well as `rc` (for loading `.sailsrc` files). -var sails; -var rc; +var sails +var rc try { - sails = require('sails'); - rc = require('sails/accessible/rc'); + sails = require('sails') + rc = require('sails/accessible/rc') } catch (err) { - console.error('Encountered an error when attempting to require(\'sails\'):'); - console.error(err.stack); - console.error('--'); - console.error('To run an app using `node app.js`, you need to have Sails installed'); - console.error('locally (`./node_modules/sails`). To do that, just make sure you\'re'); - console.error('in the same directory as your app and run `npm install`.'); - console.error(); - console.error('If Sails is installed globally (i.e. `npm install -g sails`) you can'); - console.error('also run this app with `sails lift`. Running with `sails lift` will'); - console.error('not run this file (`app.js`), but it will do exactly the same thing.'); - console.error('(It even uses your app directory\'s local Sails install, if possible.)'); - return; -}//-• - + console.error("Encountered an error when attempting to require('sails'):") + console.error(err.stack) + console.error('--') + console.error( + 'To run an app using `node app.js`, you need to have Sails installed' + ) + console.error( + "locally (`./node_modules/sails`). To do that, just make sure you're" + ) + console.error('in the same directory as your app and run `npm install`.') + console.error() + console.error( + 'If Sails is installed globally (i.e. `npm install -g sails`) you can' + ) + console.error( + 'also run this app with `sails lift`. Running with `sails lift` will' + ) + console.error( + 'not run this file (`app.js`), but it will do exactly the same thing.' + ) + console.error( + "(It even uses your app directory's local Sails install, if possible.)" + ) + return +} //-• // Start server -sails.lift(rc('sails')); +sails.lift(rc('sails')) diff --git a/templates/mellow-vue/assets/dependencies/sockets.js b/templates/mellow-vue/assets/dependencies/sockets.js index a59721f1..5f9c93ab 100644 --- a/templates/mellow-vue/assets/dependencies/sockets.js +++ b/templates/mellow-vue/assets/dependencies/sockets.js @@ -1,4 +1,6 @@ // Wrap instantiation of sails.io.js in a module, so it can be safely shared // required from different modules even if they're nested within each other. -var io = require('sails.io.js/sails.io.js')(require('socket.io-client/dist/socket.io.js')); -module.exports = io; +var io = require('sails.io.js/sails.io.js')( + require('socket.io-client/dist/socket.io.js') +) +module.exports = io diff --git a/templates/mellow-vue/assets/js/app.js b/templates/mellow-vue/assets/js/app.js index ada9015b..afbe101e 100644 --- a/templates/mellow-vue/assets/js/app.js +++ b/templates/mellow-vue/assets/js/app.js @@ -1,15 +1,15 @@ import { createApp, h } from 'vue' import { createInertiaApp } from '@inertiajs/inertia-vue3' import { InertiaProgress } from '@inertiajs/progress' -import '~/css/main.css'; +import '~/css/main.css' InertiaProgress.init() createInertiaApp({ - resolve: name => require(`./pages/${name}`), + resolve: (name) => require(`./pages/${name}`), setup({ el, App, props, plugin }) { - createApp({ render: () => h(App, props)}) + createApp({ render: () => h(App, props) }) .use(plugin) .mount(el) - }, + } }) diff --git a/templates/mellow-vue/assets/js/components/Counter.vue b/templates/mellow-vue/assets/js/components/Counter.vue index 603ab1ea..dc4af7cc 100644 --- a/templates/mellow-vue/assets/js/components/Counter.vue +++ b/templates/mellow-vue/assets/js/components/Counter.vue @@ -7,6 +7,6 @@ diff --git a/templates/mellow-vue/assets/js/pages/example.vue b/templates/mellow-vue/assets/js/pages/example.vue index e925c365..ba5a3de1 100644 --- a/templates/mellow-vue/assets/js/pages/example.vue +++ b/templates/mellow-vue/assets/js/pages/example.vue @@ -2,15 +2,15 @@ import { Link } from '@inertiajs/inertia-vue3' const { quote } = defineProps({ - quote: String, + quote: String }) diff --git a/templates/mellow-vue/assets/js/pages/index.vue b/templates/mellow-vue/assets/js/pages/index.vue index 1b20a41c..9b46fb7c 100644 --- a/templates/mellow-vue/assets/js/pages/index.vue +++ b/templates/mellow-vue/assets/js/pages/index.vue @@ -1,10 +1,10 @@