mirror of
https://github.com/modernweb-dev/rocket.git
synced 2026-03-21 15:54:57 +00:00
Compare commits
2 Commits
@mdjs/mdjs
...
@rocket/en
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2555a8698d | ||
|
|
367529c211 |
@@ -1,5 +1,11 @@
|
|||||||
# @rocket/engine
|
# @rocket/engine
|
||||||
|
|
||||||
|
## 0.2.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 367529c: Make sure user provided content in the folder `site/public/*` wins over public folders content provided by plugins.
|
||||||
|
|
||||||
## 0.2.0
|
## 0.2.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rocket/engine",
|
"name": "@rocket/engine",
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -152,12 +152,7 @@ export class Engine {
|
|||||||
* @param {string} targetDir
|
* @param {string} targetDir
|
||||||
*/
|
*/
|
||||||
async copyPublicFilesTo(targetDir) {
|
async copyPublicFilesTo(targetDir) {
|
||||||
// copy public files
|
// 1. copy public files of plugins
|
||||||
const publicDir = path.join(this.docsDir, '..', 'public');
|
|
||||||
if (existsSync(publicDir)) {
|
|
||||||
await fse.copy(publicDir, targetDir);
|
|
||||||
}
|
|
||||||
// copy public files of plugins
|
|
||||||
if (this.options.plugins) {
|
if (this.options.plugins) {
|
||||||
for (const plugin of this.options.plugins) {
|
for (const plugin of this.options.plugins) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -171,6 +166,12 @@ export class Engine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. copy public files from inputDir (e.g. user public folder always wins)
|
||||||
|
const publicDir = path.join(this.docsDir, '..', 'public');
|
||||||
|
if (existsSync(publicDir)) {
|
||||||
|
await fse.copy(publicDir, targetDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async start(options = {}) {
|
async start(options = {}) {
|
||||||
|
|||||||
@@ -4,23 +4,42 @@ import { setupTestEngine } from './test-helpers.js';
|
|||||||
|
|
||||||
const { expect } = chai;
|
const { expect } = chai;
|
||||||
|
|
||||||
class MyPlugin {
|
|
||||||
static publicFolder = new URL(
|
|
||||||
'./fixtures/10-plugins/01-add-public-files/plugin-add-to-public/preset/__public',
|
|
||||||
import.meta.url,
|
|
||||||
).pathname;
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('Plugins', () => {
|
describe('Plugins', () => {
|
||||||
it('add plugin with custom public files', async () => {
|
it('01: add plugin with custom public files', async () => {
|
||||||
|
class TestPlugin01 {
|
||||||
|
static publicFolder = new URL(
|
||||||
|
'./fixtures/10-plugins/01-add-public-files/plugin-add-to-public/preset/__public',
|
||||||
|
import.meta.url,
|
||||||
|
).pathname;
|
||||||
|
}
|
||||||
const { build, outputExists } = await setupTestEngine(
|
const { build, outputExists } = await setupTestEngine(
|
||||||
'fixtures/10-plugins/01-add-public-files/docs',
|
'fixtures/10-plugins/01-add-public-files/docs',
|
||||||
{
|
{
|
||||||
setupPlugins: [addPlugin(MyPlugin)],
|
setupPlugins: [addPlugin(TestPlugin01)],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await build();
|
await build();
|
||||||
|
|
||||||
expect(outputExists('added-via-plugin.txt')).to.be.true;
|
expect(outputExists('added-via-plugin.txt')).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('02: add plugin with custom public files', async () => {
|
||||||
|
class TestPlugin02 {
|
||||||
|
static publicFolder = new URL(
|
||||||
|
'./fixtures/10-plugins/02-input-folder-public-always-wins/plugin-add-to-public/preset/__public',
|
||||||
|
import.meta.url,
|
||||||
|
).pathname;
|
||||||
|
}
|
||||||
|
const { build, readOutput } = await setupTestEngine(
|
||||||
|
'fixtures/10-plugins/02-input-folder-public-always-wins/docs',
|
||||||
|
{
|
||||||
|
setupPlugins: [addPlugin(TestPlugin02)],
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await build();
|
||||||
|
|
||||||
|
expect(readOutput('added-via-plugin-and-input-public.txt')).to.equal(
|
||||||
|
'from input public folder\n',
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/* START - Rocket auto generated - do not touch */
|
||||||
|
export const sourceRelativeFilePath = 'index.rocket.js';
|
||||||
|
/* END - Rocket auto generated - do not touch */
|
||||||
|
|
||||||
|
import { html } from 'lit';
|
||||||
|
|
||||||
|
export default () => html`<p>content</p>`;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"name": "index.rocket.js",
|
||||||
|
"menuLinkText": "index.rocket.js",
|
||||||
|
"url": "/",
|
||||||
|
"outputRelativeFilePath": "index.html",
|
||||||
|
"sourceRelativeFilePath": "index.rocket.js",
|
||||||
|
"level": 0
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
from plugin
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
from input public folder
|
||||||
@@ -57,12 +57,13 @@ describe('rocket-search', () => {
|
|||||||
expect(el.miniSearch).to.not.be.null;
|
expect(el.miniSearch).to.not.be.null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('initialize the search on focus', async () => {
|
// flaky on firefox 🤔
|
||||||
|
it.skip('initialize the search on focus', async () => {
|
||||||
const el = await fixture(html`<rocket-search json-url=${fixtureOneResultUrl}></rocket-search>`);
|
const el = await fixture(html`<rocket-search json-url=${fixtureOneResultUrl}></rocket-search>`);
|
||||||
expect(el.miniSearch).to.be.null;
|
expect(el.miniSearch).to.be.null;
|
||||||
|
|
||||||
el.focus();
|
el.focus();
|
||||||
await aTimeout(10);
|
await aTimeout(50);
|
||||||
expect(el.miniSearch).to.not.be.null;
|
expect(el.miniSearch).to.not.be.null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user