Skip to content

Commit

Permalink
feat: modularize the source code into individual Node packages
Browse files Browse the repository at this point in the history
Massive refactoring of the repository into a "monorepo" (a repository containing multiple
Node packages):
- the packages are the sub-directories of the top-level `packages` directory ('monorepo' layout)
- the packages are managed using Yarn Worspaces (1) and LernaJS (2).
- to add a dependency, run `yarn add` in the relevant package directory, as usual
- all the packages are built at once from the root directory
- the build and watch tasks are implemented in JS, in the `scripts` directory

1. https://yarnpkg.com/lang/en/docs/workspaces/
2. https://github.com/lerna/lerna
  • Loading branch information
rdeltour committed Dec 13, 2017
1 parent d131450 commit 76d49ce
Show file tree
Hide file tree
Showing 76 changed files with 2,150 additions and 1,221 deletions.
14 changes: 14 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": [
[
"env",
{
"targets": {
"node": [
"6"
]
}
}
]
]
}
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
logs
*.log
npm-debug.log*
lerna-debug.log
yarn-debug.log*
yarn-error.log*

# Build directory
dist/
# Build
/node_modules
/packages/*/lib/
/packages/*/node_modules/

# Website build directory
website/site

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

Expand Down
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspaces-experimental true
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"lerna": "2.5.1",
"version": "0.0.1",
"npmClient": "yarn",
"useWorkspaces": true
}
122 changes: 21 additions & 101 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,124 +1,44 @@
{
"name": "ace-core",
"version": "0.6.0",
"description": "Ace by DAISY, an Accessibility Checker for EPUB",
"keywords": [
"a11y",
"accessibility",
"ace",
"checker",
"daisy",
"epub",
"validator",
"wcag"
],
"private": "true",
"license": "MIT",
"licenses": [
{
"type": "MIT",
"url": "https://opensource.org/licenses/MIT"
}
],
"author": {
"name": "DAISY developers",
"organization": "DAISY Consortium",
"url": "https://github.com/daisy/"
},
"homepage": "https://github.com/daisy/ace",
"repository": {
"type": "git",
"url": "git+https://github.com/daisy/ace.git"
},
"bugs": {
"url": "https://github.com/daisy/ace/issues"
},
"engines": {
"node": ">=6",
"npm": ">=5",
"yarn": ">= 1.0.0"
},
"main": "dist/index.js",
"bin": {
"ace": "dist/cli/cli.js",
"ace-http": "dist/http/http.js"
},
"files": [
"LICENCE.txt",
"README.md",
"dist"
"workspaces": [
"packages/*"
],
"dependencies": {
"axe-core": "^2.4.2",
"env-paths": "^1.0.0",
"express": "^4.15.5",
"express-easy-zip": "^1.1.4",
"extract-zip": "^1.6.5",
"filehound": "^1.16.2",
"fs-extra": "^4.0.2",
"h5o": "^0.11.3",
"handlebars": "^4.0.11",
"marko": "^4.4.26",
"meow": "^3.7.0",
"multer": "^1.3.0",
"p-map": "^1.2.0",
"path": "^0.12.7",
"puppeteer": "^0.12.0",
"shortid": "^2.2.8",
"snyk": "^1.42.7",
"tmp": "^0.0.33",
"unzip": "^0.1.11",
"uuidv4": "^0.5.0",
"winston": "^2.4.0",
"xmldom": "^0.1.27",
"xpath": "^0.0.24"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.0.0",
"babel-jest": "^21.2.0",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.26.0",
"chalk": "^2.3.0",
"cross-spawn": "^5.1.0",
"eslint": "^3.19.0",
"eslint-config-airbnb-base": "^11.2.0",
"eslint-plugin-import": "^2.3.0",
"jest": "21.3.0-beta.3",
"glob": "^7.1.2",
"jest": "21.3.0-beta.10",
"lerna": "^2.5.1",
"micromatch": "^3.1.4",
"mkdirp": "^0.5.1",
"rimraf": "^2.6.1",
"snyk": "^1.56.0",
"standard-version": "^4.2.0",
"uglify-js": "^3.0.8",
"watch": "^1.0.2"
},
"scripts": {
"start": "node src/cli/cli.js",
"clean": "rimraf dist && mkdir dist",
"prebuild": "npm run clean",
"build": "npm run build:js",
"build:js": "babel src -d dist --copy-files --ignore *.test.js",
"build:scripts": "babel src -d dist --presets browsers --only src/scripts",
"build:watch": "watch 'npm run build' src",
"lint": "eslint src",
"ace": "node ./packages/ace-cli/bin/ace.js",
"clean": "rimraf packages/*/lib",
"clean-all": "yarn clean && rimraf packages/*/node_modules && rimraf node_modules",
"prebuild": "yarn run clean",
"build": "node ./scripts/build.js",
"docs": "echo docs script not implemented",
"lint": "echo lint script not implemented",
"postinstall": "yarn build",
"test": "jest",
"docs": "echo add docs",
"prepare": "snyk protect",
"prepublishOnly": "npm run build",
"release": "standard-version -s"
},
"babel": {
"presets": [
[
"env",
{
"targets": {
"node": [
"6"
]
}
}
]
]
"watch": "yarn build && node ./scripts/watch.js"
},
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/tests/jest-setup.js",
"testEnvironment": "node"
},
"snyk": true
}
}
3 changes: 3 additions & 0 deletions packages/ace-cli/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/__mocks__/**
**/__tests__/**
src
3 changes: 3 additions & 0 deletions packages/ace-cli/bin/ace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../lib').run();
27 changes: 27 additions & 0 deletions packages/ace-cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@daisy/ace-cli",
"version": "0.0.1",
"description": "Ace by DAISY, an Accessibility Checker for EPUB",
"author": {
"name": "DAISY developers",
"organization": "DAISY Consortium",
"url": "http://www.daisy.org/"
},
"repository": {
"type": "git",
"url": "https://github.com/daisy/ace"
},
"bugs": {
"url": "https://github.com/daisy/ace/issues"
},
"license": "MIT",
"main": "lib/index.js",
"bin": "bin/ace.js",
"dependencies": {
"meow": "^3.7.0",
"winston": "^2.4.0"
},
"publishConfig": {
"access": "public"
}
}
12 changes: 6 additions & 6 deletions src/cli/cli.js → packages/ace-cli/src/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/usr/bin/env node

'use strict';

const fs = require('fs');
const meow = require('meow');
const path = require('path');
const winston = require('winston');

const ace = require('../core/ace.js');
const logger = require('../core/logger.js');
const logger = require('@daisy/ace-logger');
const ace = require('@daisy/ace-core');

const cli = meow(`
Usage: ace [options] <input>
Expand Down Expand Up @@ -46,7 +44,7 @@ function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

(async function processArgs() {
async function run() {
logger.initLogger({ verbose: cli.flags.verbose, silent: cli.flags.silent });

// Check that an EPUB path is specified
Expand Down Expand Up @@ -101,4 +99,6 @@ ${overrides.map(file => ` - ${file}`).join('\n')}
process.exit(1);
});
});
}());
}

module.exports = { run };
3 changes: 3 additions & 0 deletions packages/ace-core-legacy/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/__mocks__/**
**/__tests__/**
src
1 change: 1 addition & 0 deletions packages/ace-core-legacy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TBD
3 changes: 3 additions & 0 deletions packages/ace-core-legacy/bin/ace-http.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('@daisy/ace-http/bin/ace-http');
3 changes: 3 additions & 0 deletions packages/ace-core-legacy/bin/ace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('@daisy/ace-cli/bin/ace');
42 changes: 42 additions & 0 deletions packages/ace-core-legacy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "ace-core",
"version": "0.0.1",
"description": "Ace by DAISY, an Accessibility Checker for EPUB",
"keywords": [
"a11y",
"accessibility",
"ace",
"checker",
"daisy",
"epub",
"validator",
"wcag"
],
"author": {
"name": "DAISY developers",
"organization": "DAISY Consortium",
"url": "http://www.daisy.org/"
},
"homepage": "https://daisy.github.io/ace",
"repository": {
"type": "git",
"url": "https://github.com/daisy/ace"
},
"bugs": {
"url": "https://github.com/daisy/ace/issues"
},
"license": "MIT",
"bin": {
"ace": "./bin/ace.js",
"ace-http": "./bin/ace-http.js"
},
"main": "lib/index.js",
"dependencies": {
"@daisy/ace-core": "^0.0.1",
"@daisy/ace-cli": "^0.0.1",
"@daisy/ace-http": "^0.0.1"
},
"publishConfig": {
"access": "public"
}
}
5 changes: 5 additions & 0 deletions packages/ace-core-legacy/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const ace = require('@daisy/ace-core');

module.exports = ace;
3 changes: 3 additions & 0 deletions packages/ace-core/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/__mocks__/**
**/__tests__/**
src
34 changes: 34 additions & 0 deletions packages/ace-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@daisy/ace-core",
"version": "0.0.1",
"description": "Core library for Ace",
"author": {
"name": "DAISY developers",
"organization": "DAISY Consortium",
"url": "http://www.daisy.org/"
},
"repository": {
"type": "git",
"url": "https://github.com/daisy/ace"
},
"bugs": {
"url": "https://github.com/daisy/ace/issues"
},
"license": "MIT",
"main": "lib/index.js",
"dependencies": {
"@daisy/ace-report": "^0.0.1",
"@daisy/ace-report-axe": "^0.0.1",
"@daisy/epub-utils": "^0.0.1",
"@daisy/jest-puppeteer": "^0.0.1",
"axe-core": "^2.5.0",
"h5o": "^0.11.3",
"p-map": "^1.2.0",
"puppeteer": "^0.12.0",
"tmp": "^0.0.33",
"winston": "^2.4.0"
},
"publishConfig": {
"access": "public"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const pMap = require('p-map');
const puppeteer = require('puppeteer');
const winston = require('winston');

const axe2ace = require('../report/axe2ace.js');
const utils = require('./puppeteer-utils');
const axe2ace = require('@daisy/ace-report-axe');
const utils = require('@daisy/puppeteer-utils');

const scripts = [
path.resolve(require.resolve('axe-core'), '../axe.min.js'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const builders = require('../report/report-builders.js');
const builders = require('@daisy/ace-report').builders;
const winston = require('winston');

const ASSERTED_BY = 'Ace';
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/core/ace.js → packages/ace-core/src/core/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
const fs = require('fs-extra');
const path = require('path');
const tmp = require('tmp');
const winston = require('winston');

const EPUB = require('@daisy/epub-utils').EPUB;
const Report = require('@daisy/ace-report').Report;
const checker = require('../checker/checker.js');
const EPUB = require('../epub/epub.js');
const Report = require('../report/report.js');
const winston = require('winston');

tmp.setGracefulCleanup();

Expand Down
Loading

0 comments on commit 76d49ce

Please sign in to comment.