feat(extend-lion-docs): handle exports without Lion prefix
This commit is contained in:
parent
9a6ef73fd5
commit
48ffdbc4ee
5 changed files with 88 additions and 3 deletions
|
|
@ -44,14 +44,23 @@ function generateVariableChange({
|
||||||
sourceClassPrefix = 'Lion',
|
sourceClassPrefix = 'Lion',
|
||||||
sourceBareImport = '@lion/',
|
sourceBareImport = '@lion/',
|
||||||
}) {
|
}) {
|
||||||
const pureClassName = className.replace(sourceClassPrefix, '');
|
let _sourceClassPrefix = sourceClassPrefix;
|
||||||
|
let _classPrefix = classPrefix;
|
||||||
|
let pureClassName = className;
|
||||||
const purePkgName = pkgName.replace(sourceBareImport, '');
|
const purePkgName = pkgName.replace(sourceBareImport, '');
|
||||||
|
|
||||||
|
if (className.startsWith(sourceClassPrefix)) {
|
||||||
|
pureClassName = className.replace(sourceClassPrefix, '');
|
||||||
|
} else {
|
||||||
|
_sourceClassPrefix = '';
|
||||||
|
_classPrefix = '';
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: `${pkgName} - ${className}`,
|
name: `${pkgName} - ${className}`,
|
||||||
variable: {
|
variable: {
|
||||||
from: `${sourceClassPrefix}${pureClassName}`,
|
from: `${_sourceClassPrefix}${pureClassName}`,
|
||||||
to: `${classPrefix}${pureClassName}`,
|
to: `${_classPrefix}${pureClassName}`,
|
||||||
paths: [
|
paths: [
|
||||||
{
|
{
|
||||||
from: `${sourceBareImport}${purePkgName}`,
|
from: `${sourceBareImport}${purePkgName}`,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export { calculateSum } from './src/calculateSum.js';
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
"name": "@lion/core",
|
||||||
|
"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",
|
||||||
|
"./docs/": "./docs/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export function calculateSum() {}
|
||||||
|
|
@ -109,6 +109,26 @@ describe('generateExtendDocsConfig', () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can handle exports without a prefix', async () => {
|
||||||
|
const result = await execute('fixtures/core');
|
||||||
|
|
||||||
|
expect(result).to.deep.equal([
|
||||||
|
{
|
||||||
|
name: '@lion/core - calculateSum',
|
||||||
|
variable: {
|
||||||
|
from: 'calculateSum',
|
||||||
|
to: 'calculateSum',
|
||||||
|
paths: [
|
||||||
|
{
|
||||||
|
from: '@lion/core',
|
||||||
|
to: 'ing-web/core',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
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',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue