mirror of
https://github.com/modernweb-dev/rocket.git
synced 2026-03-21 08:51:18 +00:00
Compare commits
9 Commits
@rocket/dr
...
@rocket/bu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
579ecfde50 | ||
|
|
9aa3265ebb | ||
|
|
d955b436b6 | ||
|
|
3468ff9fc2 | ||
|
|
fd4bc27f16 | ||
|
|
641c7e551c | ||
|
|
f9ae2b8208 | ||
|
|
a8c7173758 | ||
|
|
dd5c772ba3 |
@@ -1,2 +1,4 @@
|
||||
node_modules/**
|
||||
/docs/_assets/head.html
|
||||
/docs/_assets
|
||||
/docs/_includes
|
||||
/docs/_data
|
||||
|
||||
@@ -15,7 +15,7 @@ git clone git@github.com:modernweb-dev/rocket.git
|
||||
Once cloning is complete, change directory to the repo.
|
||||
|
||||
```sh
|
||||
cd web
|
||||
cd rocket
|
||||
```
|
||||
|
||||
Now add your fork as a remote
|
||||
@@ -89,7 +89,7 @@ Exceptions:
|
||||
|
||||
## Committing Your Changes
|
||||
|
||||
Commit messages must follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0-beta.2/)
|
||||
Commit messages must follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/)
|
||||
Modern-web uses package name as scope. So for example if you fix a _terrible bug_ in the package `@web/test-runner`, the commit message should look like this:
|
||||
|
||||
```sh
|
||||
|
||||
@@ -9,11 +9,8 @@ import { rocketLaunch } from '@rocket/launch';
|
||||
|
||||
export default {
|
||||
presets: [rocketLaunch()],
|
||||
build: {
|
||||
emptyOutputDir: true,
|
||||
pathPrefix: 'subfolder-only-for-build',
|
||||
serviceWorkerFileName: 'service-worker.js',
|
||||
},
|
||||
emptyOutputDir: true,
|
||||
pathPrefix: 'subfolder-only-for-build',
|
||||
};
|
||||
```
|
||||
|
||||
@@ -23,11 +20,22 @@ New plugins can be added and all default plugins can be adjusted or even removed
|
||||
|
||||
```js
|
||||
export default {
|
||||
// add remark/unified plugin to the markdown processing (e.g. enable special code blocks)
|
||||
setupUnifiedPlugins: [],
|
||||
|
||||
// add a rollup plugins to the web dev server (will be wrapped with @web/dev-server-rollup) AND the rollup build (e.g. enable json importing)
|
||||
setupDevAndBuildPlugins: [],
|
||||
|
||||
// add a plugin to the web dev server (will not be wrapped) (e.g. esbuild for typescript)
|
||||
setupDevPlugins: [],
|
||||
|
||||
// add a plugin to the rollup build (e.g. optimization steps)
|
||||
setupBuildPlugins: [],
|
||||
|
||||
// add a plugin to eleventy (e.g. a filter packs)
|
||||
setupEleventyPlugins: [],
|
||||
|
||||
// add a plugin to the cli (e.g. a new command like "rocket my-command")
|
||||
setupCliPlugins: [],
|
||||
};
|
||||
```
|
||||
|
||||
@@ -216,7 +216,11 @@ const plugins = finalMetaPlugins.map(pluginObj => {
|
||||
|
||||
**Examples**
|
||||
|
||||
Rollup has a more specific helper
|
||||
Rollup has a more specific helper that handles
|
||||
|
||||
- `config.setupPlugins`
|
||||
|
||||
Note: if you provide `config.plugins` then it will return that directly ignoring `setupPlugins`
|
||||
|
||||
```js
|
||||
import { metaConfigToRollupConfig } from 'plugins-manager';
|
||||
@@ -224,14 +228,19 @@ import { metaConfigToRollupConfig } from 'plugins-manager';
|
||||
const finalConfig = metaConfigToRollupConfig(currentConfig, defaultMetaPlugins);
|
||||
```
|
||||
|
||||
Web Dev Server has a more specific helper
|
||||
Web Dev Server has a more specific helper that handles
|
||||
|
||||
- `config.setupPlugins`
|
||||
- `config.setupRollupPlugins`
|
||||
|
||||
Note: if you provide `config.plugins` then it will return that directly ignoring `setupPlugins` and `setupRollupPlugins`
|
||||
|
||||
```js
|
||||
import { metaConfigToWebDevServerConfig } from 'plugins-manager';
|
||||
import { fromRollup } from '@web/dev-server-rollup';
|
||||
|
||||
const finalConfig = metaConfigToWebDevServerConfig(currentConfig, defaultMetaPlugins, {
|
||||
wrapperFunction: fromRollup,
|
||||
rollupWrapperFunction: fromRollup,
|
||||
});
|
||||
```
|
||||
|
||||
@@ -12,7 +12,6 @@ import { absoluteBaseUrlNetlify } from '@rocket/core/helpers';
|
||||
|
||||
export default /** @type {Partial<import('@rocket/cli').RocketCliOptions>} */ ({
|
||||
presets: [rocketLaunch(), rocketBlog(), rocketSearch()],
|
||||
emptyOutputDir: false,
|
||||
absoluteBaseUrl: absoluteBaseUrlNetlify('http://localhost:8080'),
|
||||
});
|
||||
```
|
||||
|
||||
@@ -51,6 +51,15 @@ Rocket uses the .gitignore file to manage it's requirements. If you skip this st
|
||||
};
|
||||
```
|
||||
|
||||
5. (optionally) Create a file `.eleventyignore` (this file will be needed once you start customizing presets)
|
||||
|
||||
```
|
||||
node_modules/**
|
||||
/docs/_assets
|
||||
/docs/_includes
|
||||
/docs/_data
|
||||
```
|
||||
|
||||
<inline-notification type="warning" title="note">
|
||||
|
||||
All further pathes are relative to your project root (my-project in this case)
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
# @rocket/blog
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c7173]
|
||||
- plugins-manager@0.2.0
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 1971f5d: Initial Release
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rocket/blog",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@@ -38,6 +38,6 @@
|
||||
"testing"
|
||||
],
|
||||
"dependencies": {
|
||||
"plugins-manager": "^0.1.0"
|
||||
"plugins-manager": "^0.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
# @rocket/building-rollup
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3468ff9: Update rollup-plugin-html to support `absolutePathPrefix` option
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 1971f5d: Initial Release
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rocket/building-rollup",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@@ -54,7 +54,7 @@
|
||||
"@babel/preset-env": "^7.12.11",
|
||||
"@rollup/plugin-babel": "^5.2.2",
|
||||
"@rollup/plugin-node-resolve": "^11.0.1",
|
||||
"@web/rollup-plugin-html": "^1.3.3",
|
||||
"@web/rollup-plugin-html": "^1.4.0",
|
||||
"@web/rollup-plugin-import-meta-assets": "^1.0.4",
|
||||
"@web/rollup-plugin-polyfills-loader": "^1.0.3",
|
||||
"browserslist": "^4.16.0",
|
||||
|
||||
@@ -1,6 +1,31 @@
|
||||
# @rocket/cli
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3468ff9: Pass prefix to rollup-plugin-html so assets can still be extracted
|
||||
- Updated dependencies [3468ff9]
|
||||
- @rocket/building-rollup@0.1.1
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 641c7e5: Add a pathPrefix option to allow deployment to a subdirectory
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a8c7173: Changes to config:
|
||||
- Do not auto rollupWrap plugins added via `setupDevPlugins`.
|
||||
- If you provide `devServer.plugins` then it will return that directly ignoring `setupDevAndBuildPlugins` and `setupDevPlugins`
|
||||
- Updated dependencies [a8c7173]
|
||||
- plugins-manager@0.2.0
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 1971f5d: Initial Release
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rocket/cli",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.3",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@@ -50,7 +50,7 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@11ty/eleventy": "^0.11.1",
|
||||
"@rocket/building-rollup": "^0.1.0",
|
||||
"@rocket/building-rollup": "^0.1.1",
|
||||
"@rocket/core": "^0.1.0",
|
||||
"@rocket/eleventy-plugin-mdjs-unified": "^0.1.0",
|
||||
"@rocket/eleventy-rocket-nav": "^0.1.0",
|
||||
@@ -63,7 +63,7 @@
|
||||
"command-line-args": "^5.1.1",
|
||||
"command-line-usage": "^6.1.1",
|
||||
"fs-extra": "^9.0.1",
|
||||
"plugins-manager": "^0.1.0"
|
||||
"plugins-manager": "^0.2.0"
|
||||
},
|
||||
"types": "dist-types/index.d.ts"
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||
// @ts-nocheck
|
||||
|
||||
import commandLineArgs from 'command-line-args';
|
||||
import { rollup } from 'rollup';
|
||||
import fs from 'fs-extra';
|
||||
import { copy } from '@web/rollup-plugin-copy';
|
||||
|
||||
import { createMpaConfig } from '@rocket/building-rollup';
|
||||
import { addPlugin } from 'plugins-manager';
|
||||
import { addPlugin, adjustPluginOptions } from 'plugins-manager';
|
||||
|
||||
/**
|
||||
* @param {object} config
|
||||
@@ -24,10 +23,21 @@ async function buildAndWrite(config) {
|
||||
}
|
||||
|
||||
async function productionBuild(config) {
|
||||
// const serviceWorkerFileName =
|
||||
// config.build && config.build.serviceWorkerFileName
|
||||
// ? config.build.serviceWorkerFileName
|
||||
// : 'service-worker.js';
|
||||
const defaultSetupPlugins = [
|
||||
addPlugin({
|
||||
name: 'copy',
|
||||
plugin: copy,
|
||||
options: {
|
||||
patterns: ['!(*.md|*.html)*', '_merged_assets/_static/**/*.{png,gif,jpg,json,css,svg,ico}'],
|
||||
rootDir: config.outputDevDir,
|
||||
},
|
||||
}),
|
||||
];
|
||||
if (config.pathPrefix) {
|
||||
defaultSetupPlugins.push(
|
||||
adjustPluginOptions('html', { absolutePathPrefix: config.pathPrefix }),
|
||||
);
|
||||
}
|
||||
|
||||
const mpaConfig = createMpaConfig({
|
||||
input: '**/*.html',
|
||||
@@ -38,17 +48,7 @@ async function productionBuild(config) {
|
||||
rootDir: config.outputDevDir,
|
||||
absoluteBaseUrl: config.absoluteBaseUrl,
|
||||
setupPlugins: [
|
||||
addPlugin({
|
||||
name: 'copy',
|
||||
plugin: copy,
|
||||
options: {
|
||||
patterns: [
|
||||
'!(*.md|*.html)*',
|
||||
'_merged_assets/_static/**/*.{png,gif,jpg,json,css,svg,ico}',
|
||||
],
|
||||
rootDir: config.outputDevDir,
|
||||
},
|
||||
}),
|
||||
...defaultSetupPlugins,
|
||||
...config.setupDevAndBuildPlugins,
|
||||
...config.setupBuildPlugins,
|
||||
],
|
||||
@@ -65,26 +65,10 @@ export class RocketBuild {
|
||||
return config;
|
||||
}
|
||||
|
||||
async setup({ config, argv }) {
|
||||
const buildDefinitions = [
|
||||
{
|
||||
name: 'mode',
|
||||
alias: 'm',
|
||||
type: String,
|
||||
defaultValue: 'full',
|
||||
description: 'What build to run [full, site, optimize]',
|
||||
},
|
||||
{ name: 'help', type: Boolean, description: 'See all options' },
|
||||
];
|
||||
const buildOptions = commandLineArgs(buildDefinitions, { argv });
|
||||
|
||||
async setup({ config }) {
|
||||
this.config = {
|
||||
...config,
|
||||
emptyOutputDir: true,
|
||||
build: {
|
||||
...config.build,
|
||||
...buildOptions,
|
||||
},
|
||||
...config,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -79,28 +79,12 @@ export class RocketCli {
|
||||
const rel = path.relative(process.cwd(), path.join(__dirname));
|
||||
const relCwdPathToConfig = path.join(rel, 'shared', '.eleventy.cjs');
|
||||
elev.setConfigPathOverride(relCwdPathToConfig);
|
||||
// elev.setDryRun(true); // do not write to file system
|
||||
await elev.init();
|
||||
|
||||
if (this.config.watch) {
|
||||
elev.watch();
|
||||
}
|
||||
|
||||
// // 11ty will bind this hook to itself
|
||||
// const that = this;
|
||||
// elev.config.filters['hook-for-rocket'] = async function hook(html, outputPath) {
|
||||
// // that.requestUpdate();
|
||||
// // const data = await this.getData();
|
||||
// // const { layout, title, inputPath } = data;
|
||||
// // const url = data.page.url;
|
||||
// // for (const plugin of that.plugins) {
|
||||
// // if (typeof plugin.transformHtml === 'function') {
|
||||
// // await plugin.transformHtml({ html, inputPath, outputPath, layout, title, url });
|
||||
// // }
|
||||
// // }
|
||||
// return html;
|
||||
// };
|
||||
|
||||
this.eleventy = elev;
|
||||
}
|
||||
}
|
||||
@@ -135,13 +119,13 @@ export class RocketCli {
|
||||
if (this.config) {
|
||||
for (const plugin of this.config.plugins) {
|
||||
if (this.considerPlugin(plugin)) {
|
||||
if (typeof plugin.setup === 'function') {
|
||||
await plugin.setup({ config: this.config, argv: this.subArgv });
|
||||
}
|
||||
|
||||
if (typeof plugin.setupCommand === 'function') {
|
||||
this.config = plugin.setupCommand(this.config);
|
||||
}
|
||||
|
||||
if (typeof plugin.setup === 'function') {
|
||||
await plugin.setup({ config: this.config, argv: this.subArgv });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,14 @@ import { metaConfigToWebDevServerConfig } from 'plugins-manager';
|
||||
export class RocketStart {
|
||||
commands = ['start'];
|
||||
|
||||
/**
|
||||
* @param {RocketCliOptions} config
|
||||
*/
|
||||
setupCommand(config) {
|
||||
delete config.pathPrefix;
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} options
|
||||
* @param {RocketCliOptions} options.config
|
||||
@@ -39,10 +47,11 @@ export class RocketStart {
|
||||
clearTerminalOnReload: false,
|
||||
...this.config.devServer,
|
||||
|
||||
setupPlugins: [...this.config.setupDevAndBuildPlugins, ...this.config.setupDevPlugins],
|
||||
setupRollupPlugins: this.config.setupDevAndBuildPlugins,
|
||||
setupPlugins: this.config.setupDevPlugins,
|
||||
},
|
||||
[],
|
||||
{ wrapperFunction: fromRollup },
|
||||
{ rollupWrapperFunction: fromRollup },
|
||||
);
|
||||
|
||||
this.devServer = await startDevServer({
|
||||
|
||||
@@ -122,7 +122,7 @@ describe('RocketCli e2e', () => {
|
||||
});
|
||||
|
||||
describe('setupDevAndBuildPlugins in config', () => {
|
||||
it('can add a rollup plugin to build', async () => {
|
||||
it('can add a rollup plugin via setupDevAndBuildPlugins for build command', async () => {
|
||||
cli = new RocketCli({
|
||||
argv: [
|
||||
'build',
|
||||
@@ -135,7 +135,7 @@ describe('RocketCli e2e', () => {
|
||||
expect(inlineModule).to.equal('var a={test:"data"};console.log(a);');
|
||||
});
|
||||
|
||||
it('can add a rollup plugin to dev', async () => {
|
||||
it('can add a rollup plugin via setupDevAndBuildPlugins for start command', async () => {
|
||||
cli = new RocketCli({
|
||||
argv: [
|
||||
'start',
|
||||
@@ -203,35 +203,53 @@ describe('RocketCli e2e', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.skip('can add a pathprefix for the build output', async () => {
|
||||
it('can add a pathprefix that will not influence the start command', async () => {
|
||||
cli = new RocketCli({
|
||||
argv: [
|
||||
'build',
|
||||
'start',
|
||||
'--config-file',
|
||||
path.join(__dirname, 'e2e-fixtures', 'content', 'eleventy.rocket.config.js'),
|
||||
path.join(__dirname, 'e2e-fixtures', 'content', 'pathprefix.rocket.config.js'),
|
||||
],
|
||||
});
|
||||
await execute();
|
||||
|
||||
// const indexHtml = await readOutput('index.html', {
|
||||
// type: 'start',
|
||||
// });
|
||||
// expect(indexHtml).to.equal("<p>Markdown in 'docs/page/index.md'</p>");
|
||||
const linkHtml = await readOutput('link/index.html', {
|
||||
type: 'start',
|
||||
});
|
||||
expect(linkHtml).to.equal(
|
||||
['<p><a href="../../">home</a></p>', '<p><a href="/">absolute home</a></p>'].join('\n'),
|
||||
);
|
||||
const assetHtml = await readOutput('use-assets/index.html', {
|
||||
type: 'start',
|
||||
});
|
||||
expect(assetHtml).to.equal('<link rel="stylesheet" href="/_merged_assets/some.css">');
|
||||
});
|
||||
|
||||
it.skip('works with an empty object in rocket.config.js', async () => {
|
||||
it('can add a pathPrefix that will be used in the build command', async () => {
|
||||
cli = new RocketCli({
|
||||
argv: [
|
||||
'build',
|
||||
'--config-file',
|
||||
path.join(__dirname, 'e2e-fixtures', 'content', 'empty.rocket.config.js'),
|
||||
path.join(__dirname, 'e2e-fixtures', 'content', 'pathPrefix.rocket.config.js'),
|
||||
],
|
||||
});
|
||||
await execute();
|
||||
|
||||
// const indexHtml = await readOutput('index.html', {
|
||||
// type: 'start',
|
||||
// });
|
||||
// expect(indexHtml).to.equal("<p>Markdown in 'docs/page/index.md'</p>");
|
||||
const linkHtml = await readOutput('link/index.html', {
|
||||
stripServiceWorker: true,
|
||||
stripToBody: true,
|
||||
});
|
||||
expect(linkHtml).to.equal(
|
||||
[
|
||||
'<p><a href="../../">home</a></p>',
|
||||
'<p><a href="/my-sub-folder/">absolute home</a></p>',
|
||||
].join('\n'),
|
||||
);
|
||||
const assetHtml = await readOutput('use-assets/index.html', {
|
||||
stripServiceWorker: true,
|
||||
});
|
||||
expect(assetHtml).to.equal(
|
||||
'<html><head><link rel="stylesheet" href="../41297ffa.css">\n\n\n\n</head><body>\n\n</body></html>',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
body { background: green; }
|
||||
@@ -1 +1,7 @@
|
||||
---
|
||||
layout: layout.njk
|
||||
---
|
||||
|
||||
[home](../index.md)
|
||||
|
||||
<a href="{{ '/' | url }}">absolute home</a>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
layout: layout.njk
|
||||
---
|
||||
|
||||
<link rel="stylesheet" href="{{ '/_assets/some.css' | asset | url }}">
|
||||
@@ -1,6 +1,6 @@
|
||||
/** @type {Partial<import("../../../types/main").RocketCliOptions>} */
|
||||
const config = {
|
||||
pathPrefix: 'my-sub-folder',
|
||||
pathPrefix: '/my-sub-folder/',
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,6 +1,13 @@
|
||||
# @rocket/drawer
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d955b43: reset translation on teardown overlay controller
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 1971f5d: Initial Release
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rocket/drawer",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
|
||||
@@ -64,6 +64,11 @@ export class RocketDrawer extends OverlayMixin(LitElement) {
|
||||
}
|
||||
}
|
||||
|
||||
_teardownOverlayCtrl() {
|
||||
super._teardownOverlayCtrl();
|
||||
this._overlayCtrl.contentNode.style.transform = 'translateX(0)';
|
||||
}
|
||||
|
||||
/** @param {import('lit-element').PropertyValues } changedProperties */
|
||||
updated(changedProperties) {
|
||||
super.updated(changedProperties);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
"mdjs"
|
||||
],
|
||||
"dependencies": {
|
||||
"@mdjs/core": "^0.6.0",
|
||||
"@mdjs/core": "^0.6.1",
|
||||
"es-module-lexer": "^0.3.26",
|
||||
"unist-util-visit": "^2.0.3"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
# @rocket/launch
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3468ff9: Do not double url social media images
|
||||
- Updated dependencies [d955b43]
|
||||
- @rocket/drawer@0.1.1
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 1971f5d: Initial Release
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rocket/launch",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@@ -31,7 +31,7 @@
|
||||
"preset"
|
||||
],
|
||||
"dependencies": {
|
||||
"@rocket/drawer": "^0.1.0",
|
||||
"@rocket/drawer": "^0.1.1",
|
||||
"@rocket/navigation": "^0.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<meta property="og:title" content="{{ _pageTitle }}"/>
|
||||
<meta property="og:type" content="website"/>
|
||||
|
||||
{% set _socialMediaImage = '/_assets/social-media-image.jpg' | asset | url %}
|
||||
{% set _socialMediaImage = '/_assets/social-media-image.jpg' | asset %}
|
||||
{% if socialMediaImage %}
|
||||
{% set _socialMediaImage = socialMediaImage %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# Change Log
|
||||
|
||||
## 0.6.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c7173]
|
||||
- plugins-manager@0.2.0
|
||||
|
||||
## 0.6.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mdjs/core",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@@ -48,7 +48,7 @@
|
||||
"@types/unist": "^2.0.3",
|
||||
"es-module-lexer": "^0.3.26",
|
||||
"github-markdown-css": "^4.0.0",
|
||||
"plugins-manager": "^0.1.0",
|
||||
"plugins-manager": "^0.2.0",
|
||||
"rehype-autolink-headings": "^5.0.1",
|
||||
"rehype-prism-template": "^0.4.1",
|
||||
"rehype-raw": "^5.0.0",
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
# plugins-manager
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- a8c7173: Changes to `metaConfigToWebDevServerConfig`:
|
||||
|
||||
- Renamed `wrapperFunction` to `rollupWrapperFunction`
|
||||
- Adds `setupRollupPlugins` which means those plugins are treated as rollup plugins and they will be wrapped by `rollupWrapperFunction` (if provided)
|
||||
- Plugins added via `setupPlugins` will no longer be wrapped
|
||||
- If you provide `config.plugins` then it will return that directly ignoring `setupPlugins` and `setupRollupPlugins`
|
||||
|
||||
Changes to `metaConfigToRollupConfig`:
|
||||
|
||||
- If you provide `config.plugins` then it will return that directly ignoring `setupPlugins`
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- b9a6274: First initial release
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "plugins-manager",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
|
||||
@@ -7,6 +7,10 @@ import { executeSetupFunctions } from 'plugins-manager';
|
||||
* @param {MetaPlugin[]} [metaPlugins]
|
||||
*/
|
||||
export function metaConfigToRollupConfig(config, metaPlugins = []) {
|
||||
if (config.plugins) {
|
||||
delete config.setupPlugins;
|
||||
return config;
|
||||
}
|
||||
const _metaPlugins = executeSetupFunctions(config.setupPlugins, [...metaPlugins]);
|
||||
|
||||
const plugins = _metaPlugins.map(pluginObj => {
|
||||
|
||||
@@ -1,28 +1,53 @@
|
||||
/** @typedef {import('../types/main').MetaPlugin} MetaPlugin */
|
||||
/** @typedef {import('../types/main').MetaPluginWrapable} MetaPluginWrapable */
|
||||
|
||||
import { executeSetupFunctions } from 'plugins-manager';
|
||||
|
||||
/**
|
||||
* @param {any} config
|
||||
* @param {MetaPlugin[]} metaPlugins
|
||||
* @param {MetaPluginWrapable[]} metaPlugins
|
||||
* @param {object} [options]
|
||||
* @param {function | null} [options.wrapperFunction]
|
||||
* @param {function | null} [options.rollupWrapperFunction]
|
||||
*/
|
||||
export function metaConfigToWebDevServerConfig(config, metaPlugins, { wrapperFunction = null }) {
|
||||
const _metaPlugins = executeSetupFunctions(config.setupPlugins, [...metaPlugins]);
|
||||
export function metaConfigToWebDevServerConfig(
|
||||
config,
|
||||
metaPlugins,
|
||||
{ rollupWrapperFunction = null } = {},
|
||||
) {
|
||||
if (config.plugins) {
|
||||
delete config.setupPlugins;
|
||||
delete config.setupRollupPlugins;
|
||||
return config;
|
||||
}
|
||||
|
||||
const metaPluginsNoWrap = metaPlugins.map(pluginObj => {
|
||||
pluginObj.__noWrap = true;
|
||||
return pluginObj;
|
||||
});
|
||||
|
||||
const rollupPlugins = /** @type {MetaPluginWrapable[]} */ (executeSetupFunctions(
|
||||
config.setupRollupPlugins,
|
||||
[...metaPluginsNoWrap],
|
||||
));
|
||||
|
||||
const wrappedRollupPlugins = rollupPlugins.map(pluginObj => {
|
||||
if (typeof rollupWrapperFunction === 'function' && pluginObj.__noWrap !== true) {
|
||||
pluginObj.plugin = rollupWrapperFunction(pluginObj.plugin);
|
||||
}
|
||||
return pluginObj;
|
||||
});
|
||||
|
||||
const _metaPlugins = executeSetupFunctions(config.setupPlugins, [...wrappedRollupPlugins]);
|
||||
|
||||
const plugins = _metaPlugins.map(pluginObj => {
|
||||
const usePlugin =
|
||||
typeof wrapperFunction === 'function' ? wrapperFunction(pluginObj.plugin) : pluginObj.plugin;
|
||||
|
||||
if (pluginObj.options) {
|
||||
return usePlugin(pluginObj.options);
|
||||
return pluginObj.plugin(pluginObj.options);
|
||||
} else {
|
||||
return usePlugin();
|
||||
return pluginObj.plugin();
|
||||
}
|
||||
});
|
||||
config.plugins = plugins;
|
||||
|
||||
delete config.setupPlugins;
|
||||
delete config.setupRollupPlugins;
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -28,4 +28,16 @@ describe('metaConfigToRollupConfig', () => {
|
||||
expect(config.plugins).to.deep.equal(['firstPlugin', '-- insertPlugin --']);
|
||||
expect(config.setupPlugins).to.be.undefined;
|
||||
});
|
||||
|
||||
it('prefers a user set config.plugins', async () => {
|
||||
const config = metaConfigToRollupConfig(
|
||||
{
|
||||
setupPlugins: [addPlugin({ name: 'insert', plugin: insertPlugin })],
|
||||
plugins: ['user-set'],
|
||||
},
|
||||
threeExistingPlugin,
|
||||
);
|
||||
expect(config.plugins).to.deep.equal(['user-set']);
|
||||
expect(config.setupPlugins).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,26 +1,56 @@
|
||||
import chai from 'chai';
|
||||
|
||||
import { metaConfigToWebDevServerConfig } from 'plugins-manager';
|
||||
import { metaConfigToWebDevServerConfig, addPlugin } from 'plugins-manager';
|
||||
|
||||
const { expect } = chai;
|
||||
|
||||
describe('metaConfigToWebDevServerConfig', () => {
|
||||
const threeExistingPlugin = [
|
||||
const twoExistingPlugin = [
|
||||
{ name: 'first', plugin: () => 'firstPlugin' },
|
||||
{ name: 'second', plugin: () => 'secondPlugin' },
|
||||
{ name: 'third', plugin: () => 'thirdPlugin' },
|
||||
];
|
||||
|
||||
it('accepts a wrapper function for plugins', async () => {
|
||||
function wrapperFunction(srcFn) {
|
||||
it('accepts a rollupWrapperFunction for setupRollupPlugins', async () => {
|
||||
function rollupWrapperFunction(srcFn) {
|
||||
return () => `*wrapped* ${srcFn()}`;
|
||||
}
|
||||
|
||||
const config = metaConfigToWebDevServerConfig({}, threeExistingPlugin, { wrapperFunction });
|
||||
const config = metaConfigToWebDevServerConfig(
|
||||
{
|
||||
setupRollupPlugins: [
|
||||
addPlugin({ name: 'third', plugin: () => 'thirdPlugin' }),
|
||||
addPlugin({ name: 'fourth', plugin: () => 'fourthPlugin' }),
|
||||
],
|
||||
setupPlugins: [
|
||||
addPlugin({ name: 'fifth', plugin: () => 'fifthPlugin' }),
|
||||
addPlugin({ name: 'sixth', plugin: () => 'sixthPlugin' }),
|
||||
],
|
||||
},
|
||||
twoExistingPlugin,
|
||||
{ rollupWrapperFunction },
|
||||
);
|
||||
|
||||
expect(config.plugins).to.deep.equal([
|
||||
'*wrapped* firstPlugin',
|
||||
'*wrapped* secondPlugin',
|
||||
'firstPlugin',
|
||||
'secondPlugin',
|
||||
'*wrapped* thirdPlugin',
|
||||
'*wrapped* fourthPlugin',
|
||||
'fifthPlugin',
|
||||
'sixthPlugin',
|
||||
]);
|
||||
});
|
||||
|
||||
it('prefers a user set config.plugins', async () => {
|
||||
const config = metaConfigToWebDevServerConfig(
|
||||
{
|
||||
setupPlugins: [addPlugin({ name: 'first', plugin: () => 'firstPlugin' })],
|
||||
setupRollupPlugins: [addPlugin({ name: 'second', plugin: () => 'secondPlugin' })],
|
||||
plugins: ['user-set'],
|
||||
},
|
||||
twoExistingPlugin,
|
||||
);
|
||||
expect(config.plugins).to.deep.equal(['user-set']);
|
||||
expect(config.setupPlugins).to.be.undefined;
|
||||
expect(config.setupRollupPlugins).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
4
packages/plugins-manager/types/main.d.ts
vendored
4
packages/plugins-manager/types/main.d.ts
vendored
@@ -3,3 +3,7 @@ export interface MetaPlugin {
|
||||
plugin: any;
|
||||
options?: any;
|
||||
}
|
||||
|
||||
export interface MetaPluginWrapable extends MetaPlugin {
|
||||
__noWrap?: boolean;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
# @rocket/search
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [a8c7173]
|
||||
- plugins-manager@0.2.0
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 1971f5d: Initial Release
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@rocket/search",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.1",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@@ -43,7 +43,7 @@
|
||||
"@lion/combobox": "^0.1.16",
|
||||
"@open-wc/scoped-elements": "^1.3.2",
|
||||
"minisearch": "^3.0.2",
|
||||
"plugins-manager": "^0.1.0",
|
||||
"plugins-manager": "^0.2.0",
|
||||
"sax-wasm": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1860,10 +1860,10 @@
|
||||
dependencies:
|
||||
glob "^7.0.0"
|
||||
|
||||
"@web/rollup-plugin-html@^1.3.3":
|
||||
version "1.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@web/rollup-plugin-html/-/rollup-plugin-html-1.3.3.tgz#366f1a889a93ef6a26afd227611deb23c52cd232"
|
||||
integrity sha512-SSgL72jIV0+N68wafDW7M40yry2RfJfcZsVOhTlir+U6RdEz0hdQPXkf/o9sHxIxo3w0sgL6tN+q7VlHMOWQGw==
|
||||
"@web/rollup-plugin-html@^1.4.0":
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/@web/rollup-plugin-html/-/rollup-plugin-html-1.4.0.tgz#bf94d1ee525e5f41dc527bbff9f7e24973a82238"
|
||||
integrity sha512-AYOeRuNsPXQmNpxlJRFLlfVMm4EazXcJEz0bbVd6wKQVcEBM71kRboGfupxhoIkDcVyThefw9gETcMZ4ntUcTw==
|
||||
dependencies:
|
||||
"@web/parse5-utils" "^1.1.2"
|
||||
glob "^7.1.6"
|
||||
|
||||
Reference in New Issue
Block a user