Skip to content

Commit 76d49ce

Browse files
committed
feat: modularize the source code into individual Node packages
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
1 parent d131450 commit 76d49ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2150
-1221
lines changed

.babelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"targets": {
7+
"node": [
8+
"6"
9+
]
10+
}
11+
}
12+
]
13+
]
14+
}

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
logs
33
*.log
44
npm-debug.log*
5+
lerna-debug.log
56
yarn-debug.log*
67
yarn-error.log*
78

8-
# Build directory
9-
dist/
9+
# Build
10+
/node_modules
11+
/packages/*/lib/
12+
/packages/*/node_modules/
1013

1114
# Website build directory
1215
website/site
1316

14-
# Dependency directories
15-
node_modules/
16-
1717
# Optional npm cache directory
1818
.npm
1919

.yarnrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
workspaces-experimental true

lerna.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"lerna": "2.5.1",
3+
"version": "0.0.1",
4+
"npmClient": "yarn",
5+
"useWorkspaces": true
6+
}

package.json

Lines changed: 21 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,44 @@
11
{
2-
"name": "ace-core",
3-
"version": "0.6.0",
4-
"description": "Ace by DAISY, an Accessibility Checker for EPUB",
5-
"keywords": [
6-
"a11y",
7-
"accessibility",
8-
"ace",
9-
"checker",
10-
"daisy",
11-
"epub",
12-
"validator",
13-
"wcag"
14-
],
2+
"private": "true",
153
"license": "MIT",
16-
"licenses": [
17-
{
18-
"type": "MIT",
19-
"url": "https://opensource.org/licenses/MIT"
20-
}
21-
],
22-
"author": {
23-
"name": "DAISY developers",
24-
"organization": "DAISY Consortium",
25-
"url": "https://github.com/daisy/"
26-
},
27-
"homepage": "https://github.com/daisy/ace",
28-
"repository": {
29-
"type": "git",
30-
"url": "git+https://github.com/daisy/ace.git"
31-
},
32-
"bugs": {
33-
"url": "https://github.com/daisy/ace/issues"
34-
},
35-
"engines": {
36-
"node": ">=6",
37-
"npm": ">=5",
38-
"yarn": ">= 1.0.0"
39-
},
40-
"main": "dist/index.js",
41-
"bin": {
42-
"ace": "dist/cli/cli.js",
43-
"ace-http": "dist/http/http.js"
44-
},
45-
"files": [
46-
"LICENCE.txt",
47-
"README.md",
48-
"dist"
4+
"workspaces": [
5+
"packages/*"
496
],
50-
"dependencies": {
51-
"axe-core": "^2.4.2",
52-
"env-paths": "^1.0.0",
53-
"express": "^4.15.5",
54-
"express-easy-zip": "^1.1.4",
55-
"extract-zip": "^1.6.5",
56-
"filehound": "^1.16.2",
57-
"fs-extra": "^4.0.2",
58-
"h5o": "^0.11.3",
59-
"handlebars": "^4.0.11",
60-
"marko": "^4.4.26",
61-
"meow": "^3.7.0",
62-
"multer": "^1.3.0",
63-
"p-map": "^1.2.0",
64-
"path": "^0.12.7",
65-
"puppeteer": "^0.12.0",
66-
"shortid": "^2.2.8",
67-
"snyk": "^1.42.7",
68-
"tmp": "^0.0.33",
69-
"unzip": "^0.1.11",
70-
"uuidv4": "^0.5.0",
71-
"winston": "^2.4.0",
72-
"xmldom": "^0.1.27",
73-
"xpath": "^0.0.24"
74-
},
757
"devDependencies": {
76-
"babel-cli": "^6.26.0",
8+
"babel-core": "^6.0.0",
779
"babel-jest": "^21.2.0",
7810
"babel-preset-env": "^1.6.0",
7911
"babel-register": "^6.26.0",
12+
"chalk": "^2.3.0",
8013
"cross-spawn": "^5.1.0",
8114
"eslint": "^3.19.0",
8215
"eslint-config-airbnb-base": "^11.2.0",
8316
"eslint-plugin-import": "^2.3.0",
84-
"jest": "21.3.0-beta.3",
17+
"glob": "^7.1.2",
18+
"jest": "21.3.0-beta.10",
19+
"lerna": "^2.5.1",
20+
"micromatch": "^3.1.4",
21+
"mkdirp": "^0.5.1",
8522
"rimraf": "^2.6.1",
23+
"snyk": "^1.56.0",
8624
"standard-version": "^4.2.0",
8725
"uglify-js": "^3.0.8",
8826
"watch": "^1.0.2"
8927
},
9028
"scripts": {
91-
"start": "node src/cli/cli.js",
92-
"clean": "rimraf dist && mkdir dist",
93-
"prebuild": "npm run clean",
94-
"build": "npm run build:js",
95-
"build:js": "babel src -d dist --copy-files --ignore *.test.js",
96-
"build:scripts": "babel src -d dist --presets browsers --only src/scripts",
97-
"build:watch": "watch 'npm run build' src",
98-
"lint": "eslint src",
29+
"ace": "node ./packages/ace-cli/bin/ace.js",
30+
"clean": "rimraf packages/*/lib",
31+
"clean-all": "yarn clean && rimraf packages/*/node_modules && rimraf node_modules",
32+
"prebuild": "yarn run clean",
33+
"build": "node ./scripts/build.js",
34+
"docs": "echo docs script not implemented",
35+
"lint": "echo lint script not implemented",
36+
"postinstall": "yarn build",
9937
"test": "jest",
100-
"docs": "echo add docs",
101-
"prepare": "snyk protect",
102-
"prepublishOnly": "npm run build",
103-
"release": "standard-version -s"
104-
},
105-
"babel": {
106-
"presets": [
107-
[
108-
"env",
109-
{
110-
"targets": {
111-
"node": [
112-
"6"
113-
]
114-
}
115-
}
116-
]
117-
]
38+
"watch": "yarn build && node ./scripts/watch.js"
11839
},
11940
"jest": {
12041
"setupTestFrameworkScriptFile": "<rootDir>/tests/jest-setup.js",
12142
"testEnvironment": "node"
122-
},
123-
"snyk": true
43+
}
12444
}

packages/ace-cli/.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/__mocks__/**
2+
**/__tests__/**
3+
src

packages/ace-cli/bin/ace.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../lib').run();

packages/ace-cli/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "@daisy/ace-cli",
3+
"version": "0.0.1",
4+
"description": "Ace by DAISY, an Accessibility Checker for EPUB",
5+
"author": {
6+
"name": "DAISY developers",
7+
"organization": "DAISY Consortium",
8+
"url": "http://www.daisy.org/"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/daisy/ace"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/daisy/ace/issues"
16+
},
17+
"license": "MIT",
18+
"main": "lib/index.js",
19+
"bin": "bin/ace.js",
20+
"dependencies": {
21+
"meow": "^3.7.0",
22+
"winston": "^2.4.0"
23+
},
24+
"publishConfig": {
25+
"access": "public"
26+
}
27+
}

src/cli/cli.js renamed to packages/ace-cli/src/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
#!/usr/bin/env node
2-
31
'use strict';
42

53
const fs = require('fs');
64
const meow = require('meow');
75
const path = require('path');
86
const winston = require('winston');
97

10-
const ace = require('../core/ace.js');
11-
const logger = require('../core/logger.js');
8+
const logger = require('@daisy/ace-logger');
9+
const ace = require('@daisy/ace-core');
1210

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

49-
(async function processArgs() {
47+
async function run() {
5048
logger.initLogger({ verbose: cli.flags.verbose, silent: cli.flags.silent });
5149

5250
// Check that an EPUB path is specified
@@ -101,4 +99,6 @@ ${overrides.map(file => ` - ${file}`).join('\n')}
10199
process.exit(1);
102100
});
103101
});
104-
}());
102+
}
103+
104+
module.exports = { run };

packages/ace-core-legacy/.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/__mocks__/**
2+
**/__tests__/**
3+
src

0 commit comments

Comments
 (0)