├── renovate.json ├── .gitignore ├── src ├── messages │ ├── index.js │ └── nuxt-core.json ├── index.js └── config.js ├── .eslintrc.js ├── .babelrc ├── scripts └── postrelease.sh ├── bili.config.js ├── test ├── __snapshots__ │ └── motd.test.js.snap ├── messages.test.js └── motd.test.js ├── CHANGELOG.md ├── LICENSE ├── package.json ├── .circleci └── config.yml └── README.md /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "@nuxtjs" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | lib 4 | dist 5 | .env* 6 | *.log 7 | *.err 8 | -------------------------------------------------------------------------------- /src/messages/index.js: -------------------------------------------------------------------------------- 1 | const coreMessages = require('./nuxt-core') 2 | 3 | module.exports = [ 4 | ...coreMessages 5 | ] 6 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | parser: 'babel-eslint', 5 | sourceType: 'module' 6 | }, 7 | extends: [ 8 | '@nuxtjs' 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "test": { 4 | "presets": [ 5 | [ "@babel/preset-env", { 6 | "targets": { "node": "current" } 7 | }] 8 | ] 9 | } 10 | }, 11 | } 12 | -------------------------------------------------------------------------------- /src/messages/nuxt-core.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "message": "The Nuxt.js core team wishes you a Happy New Year!", 4 | "periods": [{ 5 | "from": "0000-12-14", 6 | "till": "0000-12-31" 7 | }, { 8 | "from": "0000-01-01", 9 | "till": "0000-01-05" 10 | }] 11 | } 12 | ] 13 | -------------------------------------------------------------------------------- /scripts/postrelease.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | readme="README.md" 4 | msgCount=$(node -e "process.stdout.write(require('./src/messages/').length.toString())") 5 | 6 | sed -i -E 's/count-([^-]+)-blue/count-'"$msgCount"'-blue/g' "$readme" 7 | 8 | git commit -m "chore(readme): update messages count" "$readme" 9 | -------------------------------------------------------------------------------- /bili.config.js: -------------------------------------------------------------------------------- 1 | const messages = require('./src/messages') 2 | 3 | export default { 4 | plugins: { 5 | replace: { 6 | delimiters: ['', ''], 7 | values: { 8 | [`import data from './messages'`]: `const data = JSON.parse(\`${JSON.stringify(messages)}\`)` 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/__snapshots__/motd.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`motd returns any motd 1`] = ` 4 | Object { 5 | "tags": Object { 6 | "modules": Array [ 7 | "buildModule1", 8 | "buildModule2", 9 | "module1", 10 | "module2", 11 | ], 12 | "version": "wowsie", 13 | }, 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import { filter, motd } from 'motd-json' 2 | import { createConfig } from './config' 3 | import data from './messages' 4 | 5 | const createGenerator = (config) => { 6 | const messages = filter(data, createConfig(config)) 7 | 8 | const motdGenerator = () => motd(messages) 9 | return motdGenerator 10 | } 11 | 12 | export default createGenerator 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ## 0.1.0 (2019-12-08) 6 | 7 | 8 | ### Features 9 | 10 | * add HNY message ([6b3995a](https://github.com/nuxt-community/motd/commit/6b3995a16680d15029c0bb136bc7085cd6db9226)) 11 | 12 | 13 | ### Bug Fixes 14 | 15 | * fix validate command ([dfad8ec](https://github.com/nuxt-community/motd/commit/dfad8ecc4cd79745ca84d5b3da296ad92b6da777)) 16 | -------------------------------------------------------------------------------- /test/messages.test.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs' 2 | import path from 'path' 3 | import { matchersWithOptions } from 'jest-json-schema' 4 | import { schema } from 'motd-json' 5 | 6 | expect.extend(matchersWithOptions({ 7 | verbose: true 8 | })) 9 | 10 | describe('schema validation', () => { 11 | const msgDir = path.resolve(__dirname, '../src/messages') 12 | const files = fs.readdirSync(msgDir).filter(f => f.endsWith('.json')) 13 | 14 | for (const file of files) { 15 | test(`file '${file}' is valid`, async () => { 16 | const data = await import(path.join(msgDir, file)).then(m => m.default || m) 17 | 18 | expect(data).toMatchSchema(schema) 19 | }) 20 | } 21 | }) 22 | -------------------------------------------------------------------------------- /test/motd.test.js: -------------------------------------------------------------------------------- 1 | import motd from '../src' 2 | import * as config from '../src/config' 3 | 4 | jest.mock('nuxt', () => ({ 5 | Nuxt: { 6 | version: 'wowsie' 7 | } 8 | })) 9 | 10 | describe('motd', () => { 11 | test('returns any motd', () => { 12 | expect(typeof motd()()).toBe('string') 13 | }) 14 | 15 | test('returns any motd', () => { 16 | const nuxtConfig = { 17 | buildModules: [ 18 | 'buildModule1', 19 | ['buildModule2', {}], 20 | function () {} 21 | ], 22 | modules: [ 23 | 'module1', 24 | ['module2', {}], 25 | function () {} 26 | ] 27 | } 28 | 29 | expect(config.createConfig(nuxtConfig)).toMatchSnapshot() 30 | }) 31 | }) 32 | -------------------------------------------------------------------------------- /src/config.js: -------------------------------------------------------------------------------- 1 | import { Nuxt } from 'nuxt' 2 | 3 | export function getModuleNames (config = {}) { 4 | const moduleNames = [] 5 | 6 | for (const moduleType of ['buildModules', 'modules']) { 7 | if (!Array.isArray(config[moduleType])) { 8 | continue 9 | } 10 | 11 | for (const module of config[moduleType]) { 12 | if (typeof module === 'string') { 13 | moduleNames.push(module) 14 | continue 15 | } 16 | 17 | if (Array.isArray(module)) { 18 | moduleNames.push(module[0]) 19 | } 20 | } 21 | } 22 | 23 | return moduleNames 24 | } 25 | 26 | export function createConfig (config) { 27 | return { 28 | tags: { 29 | version: Nuxt.version, 30 | modules: getModuleNames(config) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (C) 2019+, pimlie 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@nuxtjs/motd", 3 | "description": "Messages of the day lib for Nuxt.js", 4 | "version": "0.1.0", 5 | "repository": "https://github.com/nuxt-community/motd", 6 | "main": "dist/index.js", 7 | "license": "MIT", 8 | "author": "pimlie", 9 | "module": "dist/index.esm.js", 10 | "files": [ 11 | "dist" 12 | ], 13 | "scripts": { 14 | "build": "bili --format cjs,es src/index.js", 15 | "coverage": "codecov", 16 | "lint": "eslint src test", 17 | "release": "yarn lint && yarn test && yarn build && yarn standard-version", 18 | "postrelease": "./scripts/postrelease.sh", 19 | "test": "jest", 20 | "validate": "ajv -s node_modules/motd-json/src/schema.json -d src/messages/*.json" 21 | }, 22 | "publishConfig": { 23 | "access": "public" 24 | }, 25 | "dependencies": { 26 | "motd-json": "^0.1.1" 27 | }, 28 | "devDependencies": { 29 | "@babel/core": "^7.7.5", 30 | "@babel/preset-env": "^7.7.6", 31 | "@nuxtjs/eslint-config": "^2.0.0", 32 | "ajv-cli": "^3.0.0", 33 | "babel-eslint": "^10.0.3", 34 | "babel-jest": "^24.9.0", 35 | "bili": "^4.8.1", 36 | "codecov": "^3.6.1", 37 | "eslint": "^6.7.2", 38 | "jest": "^24.9.0", 39 | "jest-json-schema": "^2.1.0", 40 | "nuxt": "^2.10.2", 41 | "standard-version": "^7.0.1" 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | executors: 4 | node: 5 | parameters: 6 | browsers: 7 | type: boolean 8 | default: false 9 | docker: 10 | - image: circleci/node:latest<<# parameters.browsers >>-browsers<> 11 | working_directory: ~/project 12 | environment: 13 | NODE_ENV: test 14 | 15 | commands: 16 | attach-project: 17 | steps: 18 | - checkout 19 | - attach_workspace: 20 | at: ~/project 21 | 22 | jobs: 23 | setup: 24 | executor: node 25 | steps: 26 | - checkout 27 | - restore_cache: 28 | key: yarn-{{ checksum "yarn.lock" }} 29 | - run: 30 | name: Install Dependencies 31 | command: NODE_ENV=dev yarn 32 | - save_cache: 33 | key: yarn-{{ checksum "yarn.lock" }} 34 | paths: 35 | - "node_modules" 36 | - persist_to_workspace: 37 | root: ~/project 38 | paths: 39 | - node_modules 40 | 41 | lint: 42 | executor: node 43 | steps: 44 | - attach-project 45 | - run: 46 | name: Lint 47 | command: yarn lint 48 | 49 | audit: 50 | executor: node 51 | steps: 52 | - attach-project 53 | - run: 54 | name: Security Audit 55 | command: yarn audit --groups dependencies || true 56 | 57 | test: 58 | executor: node 59 | steps: 60 | - attach-project 61 | - run: 62 | name: Unit Tests 63 | command: yarn test --coverage && yarn coverage 64 | 65 | workflows: 66 | version : 2 67 | 68 | commit: 69 | jobs: 70 | - setup 71 | - lint: { requires: [setup] } 72 | - audit: { requires: [setup] } 73 | - test: { requires: [lint] } 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nuxt.js MOTD 2 | 3 | [![npm version][npm-version-src]][npm-version-href] 4 | [![npm downloads][npm-downloads-src]][npm-downloads-href] 5 | [![Circle CI][circle-ci-src]][circle-ci-href] 6 | [![Codecov][codecov-src]][codecov-href] 7 | [![Number of Tips][tips-src]][tips-href] 8 | 9 | Your source for Nuxt 2 tips 10 | 11 | ## Guidelines for adding a new tip 12 | 13 | Thank you for wanting to contribute a Nuxt.js tip. Although we appreciate all contributions, we have to follow some guidelines to make sure that each Nuxt tip we add has an as large as possible impact 14 | 15 | A message of the day should be linked to a npm package, that can be one of the Nuxt.js core packages ~~or one from the eco-system~~. For the time being we will only accept tips with regards to functionalities that almost everybody uses. In general that means either one of the core packages or one of the officially supported Nuxt modules 16 | 17 | ## How to write a good tip 18 | 19 | A good tip is: 20 | - short and clear but descriptive 21 | - does not include an opinion (unless it's a widely shared one) 22 | - preferably has a call-to-action 23 | - uses proper English (emoticons are allowed but can be problematic on the console) 24 | 25 | Examples: 26 | 27 | **Bad** 28 | - You should use the http module and not axios _(opinon and not clear why)_ 29 | - Double quotes FTW!! _(uses slang)_ 30 | 31 | **Good** 32 | - Did you know you can use the husky package to run lint automatically when committing on git? 33 | - Most Nuxt.js projects expose a client-side api through window.$nuxt that can be used for e.g. programmatic navigation: `window.$nuxt.$router.push('/my-route')` 34 | 35 | 36 | ## Where are these Nuxt tips used? 37 | 38 | The Nuxt tips are shown both in the [@nuxt/loading-screen](https://github.com/nuxt/loading-screen) as in the banner that is displayed on the [@nuxt/cli](https://github.com/nuxt/nuxt.js/tree/dev/packages/cli) when running the dev server 39 | 40 | ## License 41 | 42 | MIT 43 | 44 | 45 | [npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/motd/latest.svg?style=flat-square 46 | [npm-version-href]: https://npmjs.com/package/@nuxtjs/motd 47 | 48 | [npm-downloads-src]: https://img.shields.io/npm/dt/@nuxtjs/motd.svg?style=flat-square 49 | [npm-downloads-href]: https://npmjs.com/package/@nuxtjs/motd 50 | 51 | [circle-ci-src]: https://img.shields.io/circleci/project/github/@nuxtjs/motd.svg?style=flat-square 52 | [circle-ci-href]: https://circleci.com/gh/@nuxtjs/motd 53 | 54 | [codecov-src]: https://img.shields.io/codecov/c/github/@nuxtjs/motd.svg?style=flat-square 55 | [codecov-href]: https://codecov.io/gh/@nuxtjs/motd 56 | 57 | [tips-src]: https://img.shields.io/badge/tips%20count-1-blue 58 | [tips-href]: https://github.com/@nuxtjs/motd 59 | --------------------------------------------------------------------------------