feat(extend-lion-docs): support usage without a scope folder

This commit is contained in:
Thomas Allmer 2021-06-15 16:31:57 +02:00 committed by Thomas Allmer
parent 17c471ed4b
commit 9a6ef73fd5
6 changed files with 97 additions and 2 deletions

View file

@ -123,11 +123,11 @@ export async function generateExtendDocsConfig({
await init; await init;
const options = { classPrefix, classBareImport, tagPrefix, tagBareImport }; const options = { classPrefix, classBareImport, tagPrefix, tagBareImport };
const folderToCheck = path.join(_nodeModulesDir, npmScope); const folderToCheck = npmScope ? path.join(_nodeModulesDir, npmScope) : _nodeModulesDir;
const packages = fs const packages = fs
.readdirSync(folderToCheck) .readdirSync(folderToCheck)
.filter(dir => fs.statSync(path.join(folderToCheck, dir)).isDirectory()) .filter(dir => fs.statSync(path.join(folderToCheck, dir)).isDirectory())
.map(dir => `${npmScope}/${dir}`); .map(dir => (npmScope ? `${npmScope}/${dir}` : dir));
const changes = []; const changes = [];
for (const pkgName of packages) { for (const pkgName of packages) {

View file

@ -0,0 +1 @@
export { LionAccordion } from './src/LionAccordion.js';

View file

@ -0,0 +1,3 @@
import { LionAccordion } from './src/LionAccordion.js';
customElements.define('lion-accordion', LionAccordion);

View file

@ -0,0 +1,55 @@
{
"name": "@lion/accordion",
"version": "0.5.0",
"description": "Vertically stacked list of invokers that can be clicked to reveal or hide content associated with them.",
"license": "MIT",
"author": "ing-bank",
"homepage": "https://github.com/ing-bank/lion/",
"repository": {
"type": "git",
"url": "https://github.com/ing-bank/lion.git",
"directory": "packages/accordion"
},
"main": "index.js",
"module": "index.js",
"files": [
"*.d.ts",
"*.js",
"custom-elements.json",
"docs",
"src",
"test",
"test-helpers",
"translations",
"types"
],
"scripts": {
"custom-elements-manifest": "custom-elements-manifest analyze --litelement --exclude \"docs/**/*\" \"test-helpers/**/*\"",
"debug": "cd ../../ && npm run debug -- --group accordion",
"debug:firefox": "cd ../../ && npm run debug:firefox -- --group accordion",
"debug:webkit": "cd ../../ && npm run debug:webkit -- --group accordion",
"publish-docs": "node ../../packages-node/publish-docs/src/cli.js --github-url https://github.com/ing-bank/lion/ --git-root-dir ../../",
"prepublishOnly": "npm run publish-docs && npm run custom-elements-manifest",
"test": "cd ../../ && npm run test:browser -- --group accordion"
},
"sideEffects": [
"lion-accordion.js"
],
"dependencies": {
"@lion/core": "0.17.0"
},
"keywords": [
"accordion",
"lion",
"web-components"
],
"publishConfig": {
"access": "public"
},
"customElementsManifest": "custom-elements.json",
"exports": {
".": "./index.js",
"./define": "./lion-accordion.js",
"./docs/": "./docs/"
}
}

View file

@ -0,0 +1 @@
export class LionAccordion extends HTMLElement {}

View file

@ -74,6 +74,41 @@ describe('generateExtendDocsConfig', () => {
]); ]);
}); });
it('works if there is no npm scope sub folder', async () => {
const result = await execute('fixtures/no-node-modules-scope-folder', {
npmScope: '',
});
expect(result).to.deep.equal([
{
name: 'accordion - LionAccordion',
variable: {
from: 'LionAccordion',
to: 'IngAccordion',
paths: [
{
from: '@lion/accordion',
to: 'ing-web/accordion',
},
],
},
},
{
name: 'accordion/define',
tag: {
from: 'lion-accordion',
to: 'ing-accordion',
paths: [
{
from: '@lion/accordion/define',
to: '#accordion/define',
},
],
},
},
]);
});
it('can customize the target', async () => { it('can customize the target', async () => {
const result = await execute('fixtures/accordion', { const result = await execute('fixtures/accordion', {
classPrefix: 'Wolf', classPrefix: 'Wolf',