diff --git a/.eslintignore b/.eslintignore index 3d12a0a740..25f656c5c7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,7 +1,7 @@ *.min.* -frontend node_modules -src/lib/markbind/src/lib/markdown-it/* -src/lib/markbind/src/lib/markdown-it-shared/* +packages/core/src/lib/markdown-it/* +packages/core/src/lib/markdown-it-shared/* +packages/vue-components !.eslintrc.js diff --git a/.stylelintignore b/.stylelintignore index 0c0d17d124..a3931ce906 100644 --- a/.stylelintignore +++ b/.stylelintignore @@ -1,4 +1,4 @@ **/*.min.css **/_site/**/*.css -frontend/components/**/*.css +packages/vue-components/**/*.css test/functional/**/expected/**/*.css diff --git a/docs/devGuide/design.md b/docs/devGuide/design.md index 79f9dd355f..dbb9d6e581 100644 --- a/docs/devGuide/design.md +++ b/docs/devGuide/design.md @@ -18,9 +18,9 @@ The MarkBind project is developed in a monorepo ([MarkBind/markbind](https://git * The command-line interface (CLI) application, which accepts commands from users and then uses the core library to parse and generate web pages, resides in the root. -* The core library, which resolves the content include path and renders Markdown content, resides in the `src/lib/markbind/` directory. +* The core library, which resolves the content include path and renders Markdown content, resides in the `packages/core/` directory. -* The UI components library, which MarkBind authors can use to create content with complex and interactive structure, resides in the `frontend/components/` directory. +* The UI components library, which MarkBind authors can use to create content with complex and interactive structure, resides in the `packages/vue-components/` directory. Stack used: *Node.js*, *Vue.js* diff --git a/docs/devGuide/projectManagement.md b/docs/devGuide/projectManagement.md index b2aa6cae86..5d74185621 100644 --- a/docs/devGuide/projectManagement.md +++ b/docs/devGuide/projectManagement.md @@ -76,11 +76,11 @@ For general best practices, refer to the guide [_Working with PRs_ @SE-EDU](http ### Building the UI components library 1. **Start with a "clean slate"** by running `npm run ci:all` or `npm run ciwin:all` in the root markbind directory, as this may affect the generated bundle. -1. **Build the bundle** by executing `npm run build:components` in the root directory, after which you should see changes in `frontend/components/dist/components.min.js`. +1. **Build the bundle** by executing `npm run build:components` in the root directory, after which you should see changes in `packages/vue-components/dist/components.min.js`. - Building the UI components bundle is optional if there are no changes to the files in `frontend/components/` since the last release of MarkBind. + Building the UI components bundle is optional if there are no changes to the files in `packages/vue-components/` since the last release of MarkBind. @@ -97,7 +97,7 @@ For general best practices, refer to the guide [_Working with PRs_ @SE-EDU](http * If there are significant changes (e.g. breaking changes, new release), a `minor` release is needed: 1. Run `npm version minor` as per normal. - 1. Update the version number inside the `frontend/components` and `src/lib/markbind` packages similarly using `npm version minor` (as `npm version` does not update the subpackage versions automatically). + 1. Update the version number of `packages/core/` and `packages/vue-components/` similarly using `npm version minor` (as `npm version` does not update the subpackage versions automatically). * We rarely do `major` releases, but if necessary, the steps are the same as the `minor` release (just change `minor` to `major`). @@ -300,7 +300,7 @@ For general best practices, refer to the guide [_Working with PRs_ @SE-EDU](http ### Dependencies - Bump acorn from 7.1.0 to 7.1.1 in /src/lib/markbind (#1120) + Bump acorn from 7.1.0 to 7.1.1 in /packages/core (#1120) ``` f. Click "Publish release". diff --git a/docs/devGuide/workflow.md b/docs/devGuide/workflow.md index bf8517d6f7..c38bb3b89c 100644 --- a/docs/devGuide/workflow.md +++ b/docs/devGuide/workflow.md @@ -97,7 +97,7 @@ To add a page to an existing test site, for this example, to `test_site`: ##### Adding snapshot tests for components -When making changes to the Vue components in `frontend/components`, you should add new snapshot tests or adapt existing ones as appropriate. +When making changes to the Vue components in `packages/vue-components`, you should add new snapshot tests or adapt existing ones as appropriate. Once you're done, be sure to run the `updatetest` script mentioned [above](#updating-and-writing-tests)! @@ -130,7 +130,7 @@ feel free to look into `package.json` and use them as you see fit! We use `npm install ` to [hoist](https://docs.npmjs.com/cli/install) the MarkBind core package's dependencies to the root `node_modules`, avoiding dependency duplication between the `markbind-cli` and `markbind` packages where possible. -Hence, when updating dependencies of the `markbind` core package, be sure to run the `npm install src/lib/markbind` command, or simply the `npm run install:markbind` script. If you upgraded the dependencies of multiple packages, simply run `npm run install:all` instead. +Hence, when updating dependencies of the `markbind` core package, be sure to run the `npm install packages/core` command, or simply the `npm run install:core` script. If you upgraded the dependencies of multiple packages, simply run `npm run install:all` instead. If the dependency is also used in the root package, make sure to update its version number as well! diff --git a/index.js b/index.js index 14cdc55ba3..e7d8e11e90 100755 --- a/index.js +++ b/index.js @@ -11,10 +11,11 @@ const Promise = require('bluebird'); const _ = {}; _.isBoolean = require('lodash/isBoolean'); +const utils = require('@markbind/core/src/utils'); + const cliUtil = require('./src/util/cliUtil'); const fsUtil = require('./src/util/fsUtil'); const logger = require('./src/util/logger'); -const utils = require('./src/lib/markbind/src/utils'); const Site = require('./src/Site'); diff --git a/jest.config.js b/jest.config.js index e89c4b85b2..f47739aef1 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,7 @@ module.exports = { testPathIgnorePatterns: [ - '/frontend/', '/node_modules/', + '/packages/vue-components/', '/test/functional/', ], }; diff --git a/package-lock.json b/package-lock.json index 753bdbf7d2..ae6f8dee1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -637,6 +637,37 @@ "chalk": "^3.0.0" } }, + "@markbind/core": { + "version": "file:packages/core", + "requires": { + "@sindresorhus/slugify": "^0.9.1", + "bluebird": "^3.7.2", + "cheerio": "^0.22.0", + "ensure-posix-path": "^1.1.1", + "fastmatter": "^2.1.1", + "highlight.js": "^9.14.2", + "htmlparser2": "^3.10.1", + "lodash": "^4.17.15", + "markdown-it": "^8.4.2", + "markdown-it-anchor": "^5.2.5", + "markdown-it-attrs": "^2.4.1", + "markdown-it-emoji": "^1.4.0", + "markdown-it-imsize": "^2.0.1", + "markdown-it-ins": "^2.0.0", + "markdown-it-linkify-images": "^1.1.1", + "markdown-it-mark": "^2.0.0", + "markdown-it-regexp": "^0.4.0", + "markdown-it-sub": "^1.0.0", + "markdown-it-sup": "^1.0.0", + "markdown-it-table-of-contents": "^0.4.4", + "markdown-it-task-lists": "^1.4.1", + "markdown-it-video": "^0.6.3", + "moment": "^2.24.0", + "nunjucks": "^3.2.0", + "path-is-inside": "^1.0.2", + "winston": "^2.4.4" + } + }, "@mrmlnc/readdir-enhanced": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", @@ -5883,48 +5914,6 @@ "object-visit": "^1.0.0" } }, - "markbind": { - "version": "file:src/lib/markbind", - "requires": { - "@sindresorhus/slugify": "^0.9.1", - "bluebird": "^3.7.2", - "cheerio": "^0.22.0", - "ensure-posix-path": "^1.1.1", - "fastmatter": "^2.1.1", - "highlight.js": "^9.14.2", - "htmlparser2": "^3.10.1", - "lodash": "^4.17.15", - "markdown-it": "^8.4.2", - "markdown-it-anchor": "^5.2.5", - "markdown-it-attrs": "^2.4.1", - "markdown-it-emoji": "^1.4.0", - "markdown-it-imsize": "^2.0.1", - "markdown-it-ins": "^2.0.0", - "markdown-it-linkify-images": "^1.1.1", - "markdown-it-mark": "^2.0.0", - "markdown-it-regexp": "^0.4.0", - "markdown-it-sub": "^1.0.0", - "markdown-it-sup": "^1.0.0", - "markdown-it-table-of-contents": "^0.4.4", - "markdown-it-task-lists": "^1.4.1", - "markdown-it-video": "^0.6.3", - "moment": "^2.24.0", - "nunjucks": "^3.2.0", - "path-is-inside": "^1.0.2" - }, - "dependencies": { - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" - }, - "moment": { - "version": "2.26.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz", - "integrity": "sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw==" - } - } - }, "markdown-escapes": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.3.tgz", diff --git a/package.json b/package.json index 8b05396428..e43e2b5e06 100644 --- a/package.json +++ b/package.json @@ -22,37 +22,38 @@ }, "scripts": { "autolint": "npm run lintfix && npm run csslintfix", - "build:components": "cd frontend/components && npm run build", - "ci:all": "npm ci && cd frontend/components && npm ci", + "build:components": "cd packages/vue-components && npm run build", + "ci:all": "npm ci && cd packages/vue-components && npm ci", "ciwin:all": "npm ci && npm run install:components", "csslint": "stylelint **/*.css", "csslintfix": "stylelint **/*.css --fix", - "install:all": "npm install && npm run install:markbind && npm run install:components", - "install:components": "cd frontend/components && npm install", - "install:markbind": "npm install src/lib/markbind", + "install:all": "npm install && npm run install:core && npm run install:components", + "install:components": "cd packages/vue-components && npm install", + "install:core": "npm install packages/core", "jest": "jest", "lint": "npm run lint:cli && npm run lint:components", "lint:cli": "eslint .", - "lint:components": "cd frontend/components && npm run lint", + "lint:components": "cd packages/vue-components && npm run lint", "lintfix": "npm run lintfix:cli && npm run lintfix:components", "lintfix:cli": "eslint . --fix", - "lintfix:components": "cd frontend/components && npm run lintfix", + "lintfix:components": "cd packages/vue-components && npm run lintfix", "pretest": "npm run lint && npm run csslint", "pretestwin": "npm run lint && npm run csslint", "test": "npm run test:cli && npm run test:components", "test:cli": "jest && cd test/functional && ./test.sh", - "test:components": "cd frontend/components && npm run test", + "test:components": "cd packages/vue-components && npm run test", "testwin": "npm run testwin:cli && npm run test:components", "testwin:cli": "jest && cd test/functional && test.bat", "updatetest": "npm run updatetest:cli && npm run updatetest:components", "updatetest:cli": "cd test/functional && ./update.sh", - "updatetest:components": "cd frontend/components && npm run updatesnapshot", + "updatetest:components": "cd packages/vue-components && npm run updatesnapshot", "updatetestwin": "npm run updatetestwin:cli && npm run updatetest:components", "updatetestwin:cli": "cd test/functional && update.bat", - "watch:components": "cd frontend/components && npm run watch" + "watch:components": "cd packages/vue-components && npm run watch" }, "dependencies": { "@fortawesome/fontawesome-free": "^5.7.2", + "@markbind/core": "file:packages/core", "@primer/octicons": "^9.3.1", "bluebird": "^3.7.2", "bootswatch": "^4.4.1", @@ -71,7 +72,6 @@ "js-beautify": "^1.10.3", "live-server": "^1.2.1", "lodash": "^4.17.15", - "markbind": "file:src/lib/markbind", "progress": "^2.0.3", "walk-sync": "^2.0.2", "winston": "^2.4.4", diff --git a/src/lib/markbind/index.js b/packages/core/index.js similarity index 100% rename from src/lib/markbind/index.js rename to packages/core/index.js diff --git a/src/lib/markbind/package.json b/packages/core/package.json similarity index 90% rename from src/lib/markbind/package.json rename to packages/core/package.json index 994248c0bb..2c80c267df 100644 --- a/src/lib/markbind/package.json +++ b/packages/core/package.json @@ -1,5 +1,5 @@ { - "name": "markbind", + "name": "@markbind/core", "version": "2.14.1", "description": "MarkBind core module", "keywords": [ @@ -15,7 +15,7 @@ "repository": { "type": "git", "url": "https://github.com/MarkBind/markbind.git", - "directory": "src/lib/markbind" + "directory": "packages/core" }, "dependencies": { "@sindresorhus/slugify": "^0.9.1", @@ -42,6 +42,7 @@ "markdown-it-video": "^0.6.3", "moment": "^2.24.0", "nunjucks": "^3.2.0", - "path-is-inside": "^1.0.2" + "path-is-inside": "^1.0.2", + "winston": "^2.4.4" } } diff --git a/src/lib/markbind/src/Parser.js b/packages/core/src/Parser.js similarity index 99% rename from src/lib/markbind/src/Parser.js rename to packages/core/src/Parser.js index c50574b697..225df050f9 100644 --- a/src/lib/markbind/src/Parser.js +++ b/packages/core/src/Parser.js @@ -5,7 +5,7 @@ const Promise = require('bluebird'); const slugify = require('@sindresorhus/slugify'); const componentParser = require('./parsers/componentParser'); const componentPreprocessor = require('./preprocessors/componentPreprocessor'); -const logger = require('../../../util/logger'); +const logger = require('./utils/logger'); const _ = {}; _.clone = require('lodash/clone'); diff --git a/src/lib/markbind/src/constants.js b/packages/core/src/constants.js similarity index 66% rename from src/lib/markbind/src/constants.js rename to packages/core/src/constants.js index 7db8440463..c95bdac2f8 100644 --- a/src/lib/markbind/src/constants.js +++ b/packages/core/src/constants.js @@ -1,9 +1,9 @@ module.exports = { - // src/lib/markbind/src/Parser.js + // packages/core/src/Parser.js ATTRIB_CWF: 'cwf', BOILERPLATE_FOLDER_NAME: '_markbind/boilerplates', - // src/lib/markbind/src/utils.js + // packages/core/src/utils.js markdownFileExts: ['md', 'mbd', 'mbdf'], }; diff --git a/src/lib/markbind/src/errors/CyclicReferenceError.js b/packages/core/src/errors/CyclicReferenceError.js similarity index 100% rename from src/lib/markbind/src/errors/CyclicReferenceError.js rename to packages/core/src/errors/CyclicReferenceError.js diff --git a/src/lib/markbind/src/errors/index.js b/packages/core/src/errors/index.js similarity index 100% rename from src/lib/markbind/src/errors/index.js rename to packages/core/src/errors/index.js diff --git a/src/lib/markbind/src/lib/markdown-it/index.js b/packages/core/src/lib/markdown-it/index.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/index.js rename to packages/core/src/lib/markdown-it/index.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/PluginEnvironment.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/PluginEnvironment.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/PluginEnvironment.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/PluginEnvironment.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/index.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/index.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/index.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/index.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/renderer.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/renderer.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/renderer.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/renderer.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/PowerPointOnlineService.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/services/PowerPointOnlineService.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/PowerPointOnlineService.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/services/PowerPointOnlineService.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/PreziService.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/services/PreziService.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/PreziService.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/services/PreziService.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/SlideShareService.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/services/SlideShareService.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/SlideShareService.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/services/SlideShareService.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/VideoServiceBase.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/services/VideoServiceBase.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/VideoServiceBase.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/services/VideoServiceBase.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/VimeoService.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/services/VimeoService.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/VimeoService.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/services/VimeoService.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/VineService.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/services/VineService.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/VineService.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/services/VineService.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/YouTubeService.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/services/YouTubeService.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/services/YouTubeService.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/services/YouTubeService.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/tokenizer.js b/packages/core/src/lib/markdown-it/markdown-it-block-embed/tokenizer.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-block-embed/tokenizer.js rename to packages/core/src/lib/markdown-it/markdown-it-block-embed/tokenizer.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-dimmed.js b/packages/core/src/lib/markdown-it/markdown-it-dimmed.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-dimmed.js rename to packages/core/src/lib/markdown-it/markdown-it-dimmed.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-emoji-fixed.js b/packages/core/src/lib/markdown-it/markdown-it-emoji-fixed.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-emoji-fixed.js rename to packages/core/src/lib/markdown-it/markdown-it-emoji-fixed.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-escape-special-tags.js b/packages/core/src/lib/markdown-it/markdown-it-escape-special-tags.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-escape-special-tags.js rename to packages/core/src/lib/markdown-it/markdown-it-escape-special-tags.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-footnotes.js b/packages/core/src/lib/markdown-it/markdown-it-footnotes.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-footnotes.js rename to packages/core/src/lib/markdown-it/markdown-it-footnotes.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-icons.js b/packages/core/src/lib/markdown-it/markdown-it-icons.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-icons.js rename to packages/core/src/lib/markdown-it/markdown-it-icons.js diff --git a/src/lib/markbind/src/lib/markdown-it/markdown-it-radio-button.js b/packages/core/src/lib/markdown-it/markdown-it-radio-button.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/markdown-it-radio-button.js rename to packages/core/src/lib/markdown-it/markdown-it-radio-button.js diff --git a/src/lib/markbind/src/lib/markdown-it/normalizeLink.js b/packages/core/src/lib/markdown-it/normalizeLink.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/normalizeLink.js rename to packages/core/src/lib/markdown-it/normalizeLink.js diff --git a/src/lib/markbind/src/lib/markdown-it/patches/markdown-it-attrs-nunjucks.js b/packages/core/src/lib/markdown-it/patches/markdown-it-attrs-nunjucks.js similarity index 100% rename from src/lib/markbind/src/lib/markdown-it/patches/markdown-it-attrs-nunjucks.js rename to packages/core/src/lib/markdown-it/patches/markdown-it-attrs-nunjucks.js diff --git a/src/lib/markbind/src/lib/nunjucks-extensions/nunjucks-date.js b/packages/core/src/lib/nunjucks-extensions/nunjucks-date.js similarity index 100% rename from src/lib/markbind/src/lib/nunjucks-extensions/nunjucks-date.js rename to packages/core/src/lib/nunjucks-extensions/nunjucks-date.js diff --git a/src/lib/markbind/src/parsers/componentParser.js b/packages/core/src/parsers/componentParser.js similarity index 99% rename from src/lib/markbind/src/parsers/componentParser.js rename to packages/core/src/parsers/componentParser.js index 3f464e68c4..ca36ece2ab 100644 --- a/src/lib/markbind/src/parsers/componentParser.js +++ b/packages/core/src/parsers/componentParser.js @@ -4,7 +4,7 @@ const _ = {}; _.has = require('lodash/has'); const md = require('../lib/markdown-it'); -const logger = require('../../../../util/logger'); +const logger = require('../utils/logger'); const { ATTRIB_CWF, diff --git a/src/lib/markbind/src/patches/htmlparser2.js b/packages/core/src/patches/htmlparser2.js similarity index 100% rename from src/lib/markbind/src/patches/htmlparser2.js rename to packages/core/src/patches/htmlparser2.js diff --git a/src/lib/markbind/src/preprocessors/VariablePreprocessor.js b/packages/core/src/preprocessors/VariablePreprocessor.js similarity index 99% rename from src/lib/markbind/src/preprocessors/VariablePreprocessor.js rename to packages/core/src/preprocessors/VariablePreprocessor.js index c54bd5caaa..3b5f61ff05 100644 --- a/src/lib/markbind/src/preprocessors/VariablePreprocessor.js +++ b/packages/core/src/preprocessors/VariablePreprocessor.js @@ -11,7 +11,7 @@ _.isEmpty = require('lodash/isEmpty'); const njUtil = require('../utils/nunjuckUtils'); const urlUtils = require('../utils/urls'); -const logger = require('../../../../util/logger'); +const logger = require('../utils/logger'); const { ATTRIB_CWF, diff --git a/src/lib/markbind/src/preprocessors/componentPreprocessor.js b/packages/core/src/preprocessors/componentPreprocessor.js similarity index 99% rename from src/lib/markbind/src/preprocessors/componentPreprocessor.js rename to packages/core/src/preprocessors/componentPreprocessor.js index d215fa0b62..afa4db4626 100644 --- a/src/lib/markbind/src/preprocessors/componentPreprocessor.js +++ b/packages/core/src/preprocessors/componentPreprocessor.js @@ -1,7 +1,7 @@ const cheerio = require('cheerio'); const path = require('path'); const url = require('url'); -const logger = require('../../../../util/logger'); +const logger = require('../utils/logger'); const { CyclicReferenceError } = require('../errors'); diff --git a/src/lib/markbind/src/utils/index.js b/packages/core/src/utils/index.js similarity index 100% rename from src/lib/markbind/src/utils/index.js rename to packages/core/src/utils/index.js diff --git a/packages/core/src/utils/logger.js b/packages/core/src/utils/logger.js new file mode 100644 index 0000000000..d3b469e1cc --- /dev/null +++ b/packages/core/src/utils/logger.js @@ -0,0 +1,22 @@ +const winston = require('winston'); + +const consoleTransport = new (winston.transports.Console)({ + colorize: true, + handleExceptions: true, + humanReadableUnhandledException: true, + level: 'debug', + showLevel: true, +}); + +winston.configure({ + exitOnError: false, + transports: [consoleTransport], +}); + +module.exports = { + error: winston.error, + warn: winston.warn, + info: winston.info, + verbose: winston.verbose, + debug: winston.debug, +}; diff --git a/src/lib/markbind/src/utils/nunjuckUtils.js b/packages/core/src/utils/nunjuckUtils.js similarity index 100% rename from src/lib/markbind/src/utils/nunjuckUtils.js rename to packages/core/src/utils/nunjuckUtils.js diff --git a/src/lib/markbind/src/utils/urls.js b/packages/core/src/utils/urls.js similarity index 100% rename from src/lib/markbind/src/utils/urls.js rename to packages/core/src/utils/urls.js diff --git a/frontend/components/.eslintignore b/packages/vue-components/.eslintignore similarity index 100% rename from frontend/components/.eslintignore rename to packages/vue-components/.eslintignore diff --git a/frontend/components/.eslintrc.js b/packages/vue-components/.eslintrc.js similarity index 100% rename from frontend/components/.eslintrc.js rename to packages/vue-components/.eslintrc.js diff --git a/frontend/components/LICENSE b/packages/vue-components/LICENSE similarity index 100% rename from frontend/components/LICENSE rename to packages/vue-components/LICENSE diff --git a/frontend/components/README.md b/packages/vue-components/README.md similarity index 100% rename from frontend/components/README.md rename to packages/vue-components/README.md diff --git a/frontend/components/babel.config.js b/packages/vue-components/babel.config.js similarity index 100% rename from frontend/components/babel.config.js rename to packages/vue-components/babel.config.js diff --git a/frontend/components/dist/components.min.js b/packages/vue-components/dist/components.min.js similarity index 100% rename from frontend/components/dist/components.min.js rename to packages/vue-components/dist/components.min.js diff --git a/frontend/components/dist/components.min.js.LICENSE.txt b/packages/vue-components/dist/components.min.js.LICENSE.txt similarity index 100% rename from frontend/components/dist/components.min.js.LICENSE.txt rename to packages/vue-components/dist/components.min.js.LICENSE.txt diff --git a/frontend/components/jest.config.js b/packages/vue-components/jest.config.js similarity index 100% rename from frontend/components/jest.config.js rename to packages/vue-components/jest.config.js diff --git a/frontend/components/package-lock.json b/packages/vue-components/package-lock.json similarity index 99% rename from frontend/components/package-lock.json rename to packages/vue-components/package-lock.json index 1b016c318b..534626c507 100644 --- a/frontend/components/package-lock.json +++ b/packages/vue-components/package-lock.json @@ -1,5 +1,5 @@ { - "name": "vue-components", + "name": "@markbind/vue-components", "version": "2.14.1", "lockfileVersion": 1, "requires": true, diff --git a/frontend/components/package.json b/packages/vue-components/package.json similarity index 93% rename from frontend/components/package.json rename to packages/vue-components/package.json index 6a6c080284..2b30fcda7e 100644 --- a/frontend/components/package.json +++ b/packages/vue-components/package.json @@ -1,5 +1,5 @@ { - "name": "vue-components", + "name": "@markbind/vue-components", "version": "2.14.1", "description": "Bootstrap components built with Vue.js", "keywords": [ @@ -19,7 +19,8 @@ "main": "dist/components.min.js", "repository": { "type": "git", - "url": "https://github.com/MarkBind/markbind.git" + "url": "https://github.com/MarkBind/markbind.git", + "directory": "packages/vue-components" }, "scripts": { "build": "webpack --progress --hide-modules --config webpack.build.js", diff --git a/frontend/components/src/Affix.vue b/packages/vue-components/src/Affix.vue similarity index 100% rename from frontend/components/src/Affix.vue rename to packages/vue-components/src/Affix.vue diff --git a/frontend/components/src/Dropdown.vue b/packages/vue-components/src/Dropdown.vue similarity index 100% rename from frontend/components/src/Dropdown.vue rename to packages/vue-components/src/Dropdown.vue diff --git a/frontend/components/src/Navbar.vue b/packages/vue-components/src/Navbar.vue similarity index 100% rename from frontend/components/src/Navbar.vue rename to packages/vue-components/src/Navbar.vue diff --git a/frontend/components/src/Panel.vue b/packages/vue-components/src/Panel.vue similarity index 100% rename from frontend/components/src/Panel.vue rename to packages/vue-components/src/Panel.vue diff --git a/frontend/components/src/Pic.vue b/packages/vue-components/src/Pic.vue similarity index 100% rename from frontend/components/src/Pic.vue rename to packages/vue-components/src/Pic.vue diff --git a/frontend/components/src/Question.vue b/packages/vue-components/src/Question.vue similarity index 100% rename from frontend/components/src/Question.vue rename to packages/vue-components/src/Question.vue diff --git a/frontend/components/src/Retriever.vue b/packages/vue-components/src/Retriever.vue similarity index 100% rename from frontend/components/src/Retriever.vue rename to packages/vue-components/src/Retriever.vue diff --git a/frontend/components/src/Searchbar.vue b/packages/vue-components/src/Searchbar.vue similarity index 100% rename from frontend/components/src/Searchbar.vue rename to packages/vue-components/src/Searchbar.vue diff --git a/frontend/components/src/SearchbarPageItem.vue b/packages/vue-components/src/SearchbarPageItem.vue similarity index 100% rename from frontend/components/src/SearchbarPageItem.vue rename to packages/vue-components/src/SearchbarPageItem.vue diff --git a/frontend/components/src/Tab.vue b/packages/vue-components/src/Tab.vue similarity index 100% rename from frontend/components/src/Tab.vue rename to packages/vue-components/src/Tab.vue diff --git a/frontend/components/src/TabGroup.vue b/packages/vue-components/src/TabGroup.vue similarity index 100% rename from frontend/components/src/TabGroup.vue rename to packages/vue-components/src/TabGroup.vue diff --git a/frontend/components/src/Tabset.vue b/packages/vue-components/src/Tabset.vue similarity index 100% rename from frontend/components/src/Tabset.vue rename to packages/vue-components/src/Tabset.vue diff --git a/frontend/components/src/Thumbnail.vue b/packages/vue-components/src/Thumbnail.vue similarity index 100% rename from frontend/components/src/Thumbnail.vue rename to packages/vue-components/src/Thumbnail.vue diff --git a/frontend/components/src/TipBox.vue b/packages/vue-components/src/TipBox.vue similarity index 100% rename from frontend/components/src/TipBox.vue rename to packages/vue-components/src/TipBox.vue diff --git a/frontend/components/src/Typeahead.vue b/packages/vue-components/src/Typeahead.vue similarity index 100% rename from frontend/components/src/Typeahead.vue rename to packages/vue-components/src/Typeahead.vue diff --git a/frontend/components/src/__tests__/TipBox.spec.js b/packages/vue-components/src/__tests__/TipBox.spec.js similarity index 100% rename from frontend/components/src/__tests__/TipBox.spec.js rename to packages/vue-components/src/__tests__/TipBox.spec.js diff --git a/frontend/components/src/__tests__/__snapshots__/TipBox.spec.js.snap b/packages/vue-components/src/__tests__/__snapshots__/TipBox.spec.js.snap similarity index 100% rename from frontend/components/src/__tests__/__snapshots__/TipBox.spec.js.snap rename to packages/vue-components/src/__tests__/__snapshots__/TipBox.spec.js.snap diff --git a/frontend/components/src/directives/Closeable.js b/packages/vue-components/src/directives/Closeable.js similarity index 100% rename from frontend/components/src/directives/Closeable.js rename to packages/vue-components/src/directives/Closeable.js diff --git a/frontend/components/src/directives/Float.js b/packages/vue-components/src/directives/Float.js similarity index 100% rename from frontend/components/src/directives/Float.js rename to packages/vue-components/src/directives/Float.js diff --git a/frontend/components/src/index.js b/packages/vue-components/src/index.js similarity index 100% rename from frontend/components/src/index.js rename to packages/vue-components/src/index.js diff --git a/frontend/components/src/main.js b/packages/vue-components/src/main.js similarity index 100% rename from frontend/components/src/main.js rename to packages/vue-components/src/main.js diff --git a/frontend/components/src/panels/MinimalPanel.vue b/packages/vue-components/src/panels/MinimalPanel.vue similarity index 100% rename from frontend/components/src/panels/MinimalPanel.vue rename to packages/vue-components/src/panels/MinimalPanel.vue diff --git a/frontend/components/src/panels/NestedPanel.vue b/packages/vue-components/src/panels/NestedPanel.vue similarity index 100% rename from frontend/components/src/panels/NestedPanel.vue rename to packages/vue-components/src/panels/NestedPanel.vue diff --git a/frontend/components/src/panels/PanelBase.js b/packages/vue-components/src/panels/PanelBase.js similarity index 100% rename from frontend/components/src/panels/PanelBase.js rename to packages/vue-components/src/panels/PanelBase.js diff --git a/frontend/components/src/panels/PanelSwitch.vue b/packages/vue-components/src/panels/PanelSwitch.vue similarity index 100% rename from frontend/components/src/panels/PanelSwitch.vue rename to packages/vue-components/src/panels/PanelSwitch.vue diff --git a/frontend/components/src/utils/NodeList.js b/packages/vue-components/src/utils/NodeList.js similarity index 100% rename from frontend/components/src/utils/NodeList.js rename to packages/vue-components/src/utils/NodeList.js diff --git a/frontend/components/src/utils/utils.js b/packages/vue-components/src/utils/utils.js similarity index 100% rename from frontend/components/src/utils/utils.js rename to packages/vue-components/src/utils/utils.js diff --git a/frontend/components/webpack.build.js b/packages/vue-components/webpack.build.js similarity index 100% rename from frontend/components/webpack.build.js rename to packages/vue-components/webpack.build.js diff --git a/frontend/components/webpack.common.js b/packages/vue-components/webpack.common.js similarity index 100% rename from frontend/components/webpack.common.js rename to packages/vue-components/webpack.common.js diff --git a/frontend/components/webpack.dev.js b/packages/vue-components/webpack.dev.js similarity index 100% rename from frontend/components/webpack.dev.js rename to packages/vue-components/webpack.dev.js diff --git a/src/Page.js b/src/Page.js index de5fbcaec1..aa592f1675 100644 --- a/src/Page.js +++ b/src/Page.js @@ -1,20 +1,20 @@ -const cheerio = require('cheerio'); require('markbind/src/patches/htmlparser2'); +const cheerio = require('cheerio'); require('@markbind/core/src/patches/htmlparser2'); const fm = require('fastmatter'); const fs = require('fs-extra-promise'); const htmlBeautify = require('js-beautify').html; const path = require('path'); const Promise = require('bluebird'); -const njUtil = require('markbind/src/utils/nunjuckUtils'); +const njUtil = require('@markbind/core/src/utils/nunjuckUtils'); const _ = {}; _.isString = require('lodash/isString'); _.isObject = require('lodash/isObject'); _.isArray = require('lodash/isArray'); -const { CyclicReferenceError } = require('markbind/src/errors'); -const MarkBind = require('markbind/src/Parser'); -const md = require('markbind/src/lib/markdown-it'); -const utils = require('markbind/src/utils'); +const { CyclicReferenceError } = require('@markbind/core/src/errors'); +const MarkBind = require('@markbind/core/src/Parser'); +const md = require('@markbind/core/src/lib/markdown-it'); +const utils = require('@markbind/core/src/utils'); const FsUtil = require('./util/fsUtil'); const logger = require('./util/logger'); diff --git a/src/Site.js b/src/Site.js index 4f8ed8f71b..68d216bf43 100644 --- a/src/Site.js +++ b/src/Site.js @@ -1,4 +1,4 @@ -const cheerio = require('cheerio'); require('markbind/src/patches/htmlparser2'); +const cheerio = require('cheerio'); require('@markbind/core/src/patches/htmlparser2'); const fs = require('fs-extra-promise'); const ghpages = require('gh-pages'); const ignore = require('ignore'); @@ -7,10 +7,10 @@ const Promise = require('bluebird'); const ProgressBar = require('progress'); const walkSync = require('walk-sync'); -const markbind = require('markbind'); -const njUtil = require('markbind/src/utils/nunjuckUtils'); -const utils = require('markbind/src/utils'); -const VariablePreprocessor = require('markbind/src/preprocessors/VariablePreprocessor'); +const markbind = require('@markbind/core'); +const njUtil = require('@markbind/core/src/utils/nunjuckUtils'); +const utils = require('@markbind/core/src/utils'); +const VariablePreprocessor = require('@markbind/core/src/preprocessors/VariablePreprocessor'); const _ = {}; _.difference = require('lodash/difference'); @@ -1137,7 +1137,7 @@ class Site { * Copies components.min.js bundle to the assets folder */ copyComponentsAsset() { - const componentsSrcPath = path.join(__dirname, '..', 'frontend', 'components', 'dist', + const componentsSrcPath = path.join(__dirname, '..', 'packages', 'vue-components', 'dist', 'components.min.js'); const componentsDestPath = path.join(this.siteAssetsDestPath, 'js', 'components.min.js'); diff --git a/src/plugins/default/markbind-plugin-footnotes-popovers.js b/src/plugins/default/markbind-plugin-footnotes-popovers.js index 4a4c964fd1..d82cf6eb78 100644 --- a/src/plugins/default/markbind-plugin-footnotes-popovers.js +++ b/src/plugins/default/markbind-plugin-footnotes-popovers.js @@ -1,5 +1,5 @@ const cheerio = module.parent.require('cheerio'); -const { parseComponents } = require('markbind/src/parsers/componentParser'); +const { parseComponents } = require('@markbind/core/src/parsers/componentParser'); module.exports = { postRender: (content) => { diff --git a/src/util/logger.js b/src/util/logger.js index dd8b151c79..b63c8c38d9 100644 --- a/src/util/logger.js +++ b/src/util/logger.js @@ -1,54 +1,46 @@ -/* eslint-disable no-console */ - const chalk = require('chalk'); const figlet = require('figlet'); -const winston = require('winston'); const DailyRotateFile = require('winston-daily-rotate-file'); +const winston = require('winston'); + +const coreLogger = require('@markbind/core/src/utils/logger'); + +// @markbind/core's consoleTransport but with level: info +const consoleTransport = new (winston.transports.Console)({ + colorize: true, + handleExceptions: true, + humanReadableUnhandledException: true, + level: 'info', + showLevel: true, +}); + +const dailyRotateFileTransport = new DailyRotateFile({ + datePattern: 'YYYY-MM-DD', + dirname: '_markbind/logs', + filename: 'markbind-%DATE%.log', + handleExceptions: true, + humanReadableUnhandledException: true, + level: 'debug', + maxFiles: 5, + showLevel: true, +}); +// Reconfigure the default instance logger winston provides with DailyRotateFile for markbind-cli winston.configure({ exitOnError: false, transports: [ - new (winston.transports.Console)({ - colorize: true, - handleExceptions: true, - humanReadableUnhandledException: true, - level: 'info', - showLevel: true, - }), - new DailyRotateFile({ - datePattern: 'YYYY-MM-DD', - dirname: '_markbind/logs', - filename: 'markbind-%DATE%.log', - handleExceptions: true, - humanReadableUnhandledException: true, - level: 'debug', - maxFiles: 5, - showLevel: true, - }), + consoleTransport, + dailyRotateFileTransport, ], }); module.exports = { - error: (text) => { - winston.error(text); - }, - warn: (text) => { - winston.warn(text); - }, - info: (text) => { - winston.info(text); - }, - verbose: (text) => { - winston.verbose(text); - }, - debug: (text) => { - winston.debug(text); - }, - log: (text) => { - console.log(text); - }, + error: coreLogger.error, + warn: coreLogger.warn, + info: coreLogger.info, + verbose: coreLogger.verbose, + debug: coreLogger.debug, + /* eslint-disable no-console */ + log: console.log, logo: () => console.log(chalk.cyan(figlet.textSync('MarkBind', { horizontalLayout: 'full' }))), - profile: (key) => { - winston.profile(key); - }, }; diff --git a/test/unit/Parser.test.js b/test/unit/Parser.test.js index 4ef24defa6..7591d79e2a 100644 --- a/test/unit/Parser.test.js +++ b/test/unit/Parser.test.js @@ -1,11 +1,10 @@ const path = require('path'); const fs = require('fs'); -const Parser = require('markbind/src/Parser'); -const VariablePreprocessor = require('markbind/src/preprocessors/VariablePreprocessor'); +const Parser = require('@markbind/core/src/Parser'); +const VariablePreprocessor = require('@markbind/core/src/preprocessors/VariablePreprocessor'); const { USER_VARIABLES_DEFAULT } = require('./utils/data'); jest.mock('fs'); -jest.mock('../../src/util/logger'); afterEach(() => fs.vol.reset()); diff --git a/test/unit/Site.test.js b/test/unit/Site.test.js index c92754285b..5ad7ef88dc 100644 --- a/test/unit/Site.test.js +++ b/test/unit/Site.test.js @@ -43,7 +43,7 @@ test('Site Generate builds the correct amount of assets', async () => { 'asset/js/setup.js': '', 'asset/js/vue.min.js': '', - 'frontend/components/dist/components.min.js': '', + 'packages/vue-components/dist/components.min.js': '', 'node_modules/@fortawesome/fontawesome-free/css/all.min.css': '', 'node_modules/@fortawesome/fontawesome-free/webfonts/font1.svg': '', diff --git a/test/unit/markdown-it-icons.test.js b/test/unit/markdown-it-icons.test.js index 0696432333..0287ff1739 100644 --- a/test/unit/markdown-it-icons.test.js +++ b/test/unit/markdown-it-icons.test.js @@ -1,6 +1,6 @@ const expectedOcticon = require('@primer/octicons')['git-pull-request'].toSVG(); -const markdownIt = require('markbind/src/lib/markdown-it'); +const markdownIt = require('@markbind/core/src/lib/markdown-it'); test('markdown-it-icons renders icon syntax correctly', () => { const source = ':fab-font-awesome: :glyphicon-home: :octicon-git-pull-request:'; diff --git a/test/unit/parsers/componentParser.test.js b/test/unit/parsers/componentParser.test.js index 6cc9103586..e733437ee0 100644 --- a/test/unit/parsers/componentParser.test.js +++ b/test/unit/parsers/componentParser.test.js @@ -1,6 +1,6 @@ const cheerio = require('cheerio'); const htmlparser = require('htmlparser2'); -const componentParser = require('markbind/src/parsers/componentParser'); +const componentParser = require('@markbind/core/src/parsers/componentParser'); const testData = require('../utils/componentParserData'); /**