Skip to content

Commit 97005ee

Browse files
Rfc/issue 355 no bundle development (#417)
* basic unbundled rendering of home page * got livereload working for all files * JSON support * import CSS support * disable eslint complexity * header working * ading banner and stylinh and fixed binary image loading * integrated evergreen deps * fully restored the home page in develop mode * wip getting serialization working * wip getting serialization working * clean up and refactor, serialize WIP * upgrade puppeteer to latest * a bit hacky but home page is now being built for production * render header navigation from graph * page template working for site in development * all pages working in develop * all pages serializing for prod * sort header and shelf * shelf expansion and table of contents * label fallback handling * fix index page rendering * clean up logging * favicon support * refactor server lifecycle to use compilation and expose devServer * built in serve command * serve docs * add support for app templates * pretty URLs * shelf working WIP * quick styling tweak for side nav * copy assets and graph.json in copy lifecycle * basic support for css files * fix copy error for nested folders * call rollup from JS API * rollup configuration sourced from compilation * make sure to await Promise.all * Rfc/issue 355 organize serve lifecycle (#419) * task: organize serve * fix: remove ctx from resolve * fix: refactor further * task: scope filters by file * linting * renable default tests and limited smoke tests * disable all tests enable subset of tests * meta specs * enable custom title case * enable custom workspace spec * track missing dev dep * enabled workspace assets test case * fix link closing slash * content-outlet refactor * enabled getting started test case * enable nested directory test case * enable app template case * enable page template spec * enable user directory mapping case * update comments * got code markdown rendering and added support for custom plugins from config * markdown plugins working including prism * default markdown specs * enable all tests * rename markdown case * syntax highlighting markdown spec Co-authored-by: Grant Hutchinson <[email protected]>
1 parent d1b14b9 commit 97005ee

File tree

124 files changed

+3468
-8096
lines changed

Some content is hidden

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

124 files changed

+3468
-8096
lines changed

.eslintrc.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const path = require('path');
1+
// const path = require('path');
22

33
module.exports = {
4-
parser: 'babel-eslint',
54
parserOptions: {
65
ecmaVersion: 2018,
7-
sourceType: 'module',
8-
babelOptions: {
9-
configFile: path.join(__dirname, './packages/cli/src/config/babel.config.js')
10-
}
6+
sourceType: 'module'
7+
// TODO should we use this?
8+
// babelOptions: {
9+
// configFile: path.join(__dirname, './packages/cli/src/config/babel.config.js')
10+
// }
1111
},
1212
env: {
1313
browser: true,

.mocharc.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const path = require('path');
22

33
module.exports = {
4-
spec: path.join(__dirname, 'packages/**/test/**/**/**/*.spec.js'),
4+
// TODO spec: path.join(__dirname, 'packages/**/test/**/**/**/*.spec.js'),
5+
spec: path.join(__dirname, 'packages/**/test/cases/**/**/*.spec.js'),
56
timeout: 30000
67
};

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ Then in your _package.json_, you can run the CLI like so:
3131
"scripts": {
3232
"build": "greenwood build",
3333
"start": "greenwood develop",
34-
"eject": "greenwood eject",
34+
"serve": "greenwood serve",
35+
"eject": "greenwood eject"
3536
}
3637
```
3738

38-
- `npm run build`: generates a static build of your project
39-
- `npm start`: starts a local development server for your project
40-
- `npm run eject`: ejects configurations to your working directory for additional customizations
39+
- `greenwood build`: Generates a production build of your project
40+
- `greenwood develop`: Starts a local development server for your project
41+
- `greenwood serve`: Generates a production build of the project and serves it locally on a simple web server.
42+
- `greenwood eject`: Ejects configurations to your working directory for additional customizations.
4143

4244
## Documentation
4345
All of our documentation is on our [website](https://www.greenwoodjs.io/) (which itself is built by Greenwood!). See our website documentation to learn more about:

greenwood.config.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path');
2-
const pluginGoogleAnalytics = require('./packages/plugin-google-analytics/src/index');
3-
const pluginPolyfills = require('./packages/plugin-polyfills/src/index');
2+
// const pluginGoogleAnalytics = require('./packages/plugin-google-analytics/src/index');
3+
// const pluginPolyfills = require('./packages/plugin-polyfills/src/index');
44

55
const META_DESCRIPTION = 'A modern and performant static site generator supporting Web Component based development';
66
const FAVICON_HREF = '/assets/favicon.ico';
@@ -20,17 +20,19 @@ module.exports = {
2020
{ rel: 'icon', href: FAVICON_HREF },
2121
{ name: 'google-site-verification', content: '4rYd8k5aFD0jDnN0CCFgUXNe4eakLP4NnA18mNnK5P0' }
2222
],
23-
plugins: [
24-
...pluginGoogleAnalytics({
25-
analyticsId: 'UA-147204327-1'
26-
}),
27-
...pluginPolyfills()
28-
],
23+
// TODO
24+
// plugins: [
25+
// ...pluginGoogleAnalytics({
26+
// analyticsId: 'UA-147204327-1'
27+
// }),
28+
// ...pluginPolyfills()
29+
// ],
2930
markdown: {
3031
plugins: [
31-
require('rehype-slug'),
32-
require('rehype-autolink-headings'),
33-
require('remark-github')
32+
'@mapbox/rehype-prism',
33+
'rehype-autolink-headings',
34+
'rehype-slug',
35+
'remark-github'
3436
]
3537
}
3638
};

nyc.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ module.exports = {
33
all: true,
44

55
include: [
6+
'packages/cli/src/commands/*.js',
67
'packages/cli/src/data/*.js',
78
'packages/cli/src/lib/*.js',
89
'packages/cli/src/lifecycles/*.js',
9-
'packages/cli/src/tasks/*.js',
1010
'packages/plugin-*/src/*.js'
1111
],
1212

@@ -17,7 +17,7 @@ module.exports = {
1717
'text-summary'
1818
],
1919

20-
checkCoverage: true,
20+
checkCoverage: false, // TODO renable
2121

2222
statements: 85,
2323
branches: 75,

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"clean": "rimraf ./**/.greenwood/** && rimraf ./**/public/** && rimraf ./coverage",
1818
"clean:deps": "rimraf **/node_modules/**",
1919
"build": "node . build",
20-
"serve": "yarn build && cd ./public && ws",
20+
"serve": "node . serve",
2121
"develop": "node . develop",
2222
"test": "export BROWSERSLIST_IGNORE_OLD_DATA=true && nyc mocha",
2323
"test:tdd": "yarn test --watch",
@@ -27,9 +27,9 @@
2727
},
2828
"devDependencies": {
2929
"@ls-lint/ls-lint": "^1.9.2",
30-
"babel-eslint": "^10.0.3",
3130
"chai": "^4.2.0",
3231
"eslint": "^6.8.0",
32+
"glob-promise": "^3.4.0",
3333
"jsdom": "^14.0.0",
3434
"lerna": "^3.16.4",
3535
"mocha": "^6.1.4",

packages/cli/package.json

+23-44
Original file line numberDiff line numberDiff line change
@@ -25,54 +25,33 @@
2525
"access": "public"
2626
},
2727
"dependencies": {
28-
"@babel/core": "^7.8.3",
29-
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
30-
"@babel/plugin-transform-runtime": "^7.8.3",
31-
"@babel/preset-env": "^7.10.4",
32-
"@babel/runtime": "^7.8.3",
33-
"@webcomponents/webcomponentsjs": "^2.3.0",
34-
"apollo-cache-inmemory": "^1.6.3",
35-
"apollo-client": "^2.6.4",
36-
"apollo-link-http": "^1.5.16",
37-
"apollo-server": "^2.9.12",
38-
"babel-loader": "^8.0.5",
39-
"chalk": "^2.4.2",
40-
"colors": "^1.3.3",
28+
"@rollup/plugin-json": "^4.1.0",
29+
"@rollup/plugin-node-resolve": "^9.0.0",
30+
"@webcomponents/webcomponentsjs": "^2.4.4",
31+
"acorn": "^8.0.1",
32+
"acorn-walk": "^8.0.0",
4133
"commander": "^2.20.0",
42-
"copy-webpack-plugin": "^5.0.3",
43-
"core-js": "^3.4.1",
44-
"css-loader": "^2.1.1",
45-
"css-to-string-loader": "^0.1.3",
46-
"cssnano": "^4.1.10",
47-
"file-loader": "^3.0.1",
48-
"filewatcher-webpack-plugin": "^1.2.0",
49-
"front-matter": "^3.0.1",
50-
"fs-extra": "^8.1.0",
51-
"graphql": "^14.5.8",
52-
"graphql-tag": "^2.10.1",
53-
"html-webpack-plugin": "^3.2.0",
54-
"lit-element": "^2.0.1",
55-
"lit-redux-router": "^0.9.3",
56-
"local-web-server": "^2.6.1",
34+
"es-module-shims": "^0.5.2",
35+
"front-matter": "^4.0.2",
36+
"htmlparser2": "^4.1.0",
37+
"koa": "^2.13.0",
38+
"livereload": "^0.9.1",
5739
"markdown-toc": "^1.2.0",
58-
"node-fetch": "^2.6.0",
59-
"postcss-loader": "^3.0.0",
60-
"postcss-nested": "^4.1.2",
61-
"postcss-preset-env": "^6.7.0",
62-
"puppeteer": "^1.20.0",
63-
"pwa-helpers": "^0.9.1",
64-
"redux": "^4.0.1",
65-
"redux-thunk": "^2.3.0",
66-
"style-loader": "^0.23.1",
67-
"wc-markdown-loader": "~0.2.0",
68-
"webpack": "^4.29.6",
69-
"webpack-cli": "^3.3.0",
70-
"webpack-dev-server": "^3.2.1",
71-
"webpack-manifest-plugin": "^2.0.4",
72-
"webpack-merge": "^4.2.1"
40+
"node-html-parser": "^1.2.21",
41+
"puppeteer": "^5.3.0",
42+
"rehype-stringify": "^8.0.0",
43+
"remark-frontmatter": "^2.0.0",
44+
"remark-parse": "^8.0.3",
45+
"remark-rehype": "^7.0.0",
46+
"rollup": "^2.26.5",
47+
"rollup-plugin-ignore-import": "^1.3.2",
48+
"rollup-plugin-multi-input": "^1.1.1",
49+
"rollup-plugin-postcss": "^3.1.5",
50+
"rollup-plugin-terser": "^7.0.0",
51+
"unified": "^9.2.0"
7352
},
7453
"devDependencies": {
75-
"glob-promise": "^3.4.0",
54+
"@mapbox/rehype-prism": "^0.5.0",
7655
"rehype-autolink-headings": "^4.0.0",
7756
"rehype-slug": "^3.0.0"
7857
}

packages/cli/src/commands/build.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const bundleCompilation = require('../lifecycles/bundle');
2+
const copyAssets = require('../lifecycles/copy');
3+
const fs = require('fs');
4+
const generateCompilation = require('../lifecycles/compile');
5+
const serializeCompilation = require('../lifecycles/serialize');
6+
const { devServer } = require('../lifecycles/serve');
7+
8+
module.exports = runProductionBuild = async () => {
9+
10+
return new Promise(async (resolve, reject) => {
11+
12+
try {
13+
const compilation = await generateCompilation();
14+
const port = compilation.config.devServer.port;
15+
const outputDir = compilation.context.outputDir;
16+
17+
devServer(compilation).listen(port);
18+
19+
if (!fs.existsSync(outputDir)) {
20+
fs.mkdirSync(outputDir);
21+
}
22+
23+
await serializeCompilation(compilation);
24+
await bundleCompilation(compilation);
25+
await copyAssets(compilation);
26+
27+
resolve();
28+
} catch (err) {
29+
reject(err);
30+
}
31+
});
32+
33+
};

packages/cli/src/commands/develop.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const generateCompilation = require('../lifecycles/compile');
2+
const livereload = require('livereload');
3+
const { devServer } = require('../lifecycles/serve');
4+
5+
module.exports = runDevServer = async () => {
6+
7+
return new Promise(async (resolve, reject) => {
8+
9+
try {
10+
const compilation = await generateCompilation();
11+
const { port } = compilation.config.devServer;
12+
const { userWorkspace } = compilation.context;
13+
14+
devServer(compilation).listen(port, () => {
15+
console.info(`Started local development at localhost:${port}`);
16+
const liveReloadServer = livereload.createServer({
17+
exts: ['html', 'css', 'js', 'md'],
18+
applyCSSLive: false // https://github.com/napcs/node-livereload/issues/33#issuecomment-693707006
19+
});
20+
21+
liveReloadServer.watch(userWorkspace, () => {
22+
console.info(`Now watching directory "${userWorkspace}" for changes.`);
23+
});
24+
});
25+
} catch (err) {
26+
reject(err);
27+
}
28+
29+
});
30+
};
File renamed without changes.

packages/cli/src/commands/serve.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const generateCompilation = require('../lifecycles/compile');
2+
const { prodServer } = require('../lifecycles/serve');
3+
4+
module.exports = runProdServer = async () => {
5+
6+
return new Promise(async (resolve, reject) => {
7+
8+
try {
9+
const compilation = await generateCompilation();
10+
const port = 8080;
11+
12+
prodServer(compilation).listen(port, () => {
13+
console.info(`Started production test server at localhost:${port}`);
14+
});
15+
} catch (err) {
16+
reject(err);
17+
}
18+
19+
});
20+
};
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
plugins: {
3-
'postcss-preset-env': {}, // stage 2+
4-
'postcss-nested': {},
5-
'cssnano': {}
6-
}
2+
// plugins: {
3+
// 'postcss-preset-env': {}, // stage 2+
4+
// 'postcss-nested': {},
5+
// 'cssnano': {}
6+
// }
77
};

0 commit comments

Comments
 (0)