Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor package directories #1265

Merged
merged 4 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**/*.min.css
**/_site/**/*.css
frontend/components/**/*.css
packages/vue-components/**/*.css
test/functional/**/expected/**/*.css
4 changes: 2 additions & 2 deletions docs/devGuide/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
8 changes: 4 additions & 4 deletions docs/devGuide/projectManagement.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

<box type="info" seamless>

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.
</box>
<box type="info" seamless>

Expand All @@ -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`).

Expand Down Expand Up @@ -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".
Expand Down
4 changes: 2 additions & 2 deletions docs/devGuide/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)!

Expand Down Expand Up @@ -130,7 +130,7 @@ feel free to look into `package.json` and use them as you see fit!

We use `npm install <package folder>` to <tooltip content="take a look under the command in the link!">[hoist](https://docs.npmjs.com/cli/install)</tooltip> 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 <tooltip content="i.e. is also listed under the root `package.json`">is also used</tooltip> in the root package, make sure to update its <tooltip content="as listed in the `package.json` file">version number</tooltip> as well!

Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
testPathIgnorePatterns: [
'/frontend/',
'/node_modules/',
'/packages/vue-components/',
'/test/functional/',
],
};
73 changes: 31 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions src/lib/markbind/package.json → packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "markbind",
"name": "@markbind/core",
"version": "2.14.1",
"description": "MarkBind core module",
"keywords": [
Expand All @@ -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",
Expand All @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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'],
};
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
File renamed without changes.
22 changes: 22 additions & 0 deletions packages/core/src/utils/logger.js
Original file line number Diff line number Diff line change
@@ -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,
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vue-components",
"name": "@markbind/vue-components",
"version": "2.14.1",
"description": "Bootstrap components built with Vue.js",
"keywords": [
Expand All @@ -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",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions src/Page.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
Loading