feat(extend-lion-docs): setting json filename containing the export map
This commit is contained in:
parent
48ffdbc4ee
commit
269ad57fdd
6 changed files with 99 additions and 1 deletions
|
|
@ -118,6 +118,7 @@ function generateTagChange({
|
||||||
* @param {string} opts.classBareImport
|
* @param {string} opts.classBareImport
|
||||||
* @param {string} opts.tagPrefix
|
* @param {string} opts.tagPrefix
|
||||||
* @param {string} opts.tagBareImport
|
* @param {string} opts.tagBareImport
|
||||||
|
* @param {string} [opts.exportsMapJsonFileName]
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function generateExtendDocsConfig({
|
export async function generateExtendDocsConfig({
|
||||||
|
|
@ -127,6 +128,7 @@ export async function generateExtendDocsConfig({
|
||||||
classBareImport,
|
classBareImport,
|
||||||
tagPrefix,
|
tagPrefix,
|
||||||
tagBareImport,
|
tagBareImport,
|
||||||
|
exportsMapJsonFileName = 'package.json',
|
||||||
}) {
|
}) {
|
||||||
const _nodeModulesDir = nodeModulesDir || path.resolve('./node_modules');
|
const _nodeModulesDir = nodeModulesDir || path.resolve('./node_modules');
|
||||||
await init;
|
await init;
|
||||||
|
|
@ -141,7 +143,7 @@ export async function generateExtendDocsConfig({
|
||||||
const changes = [];
|
const changes = [];
|
||||||
for (const pkgName of packages) {
|
for (const pkgName of packages) {
|
||||||
const pkgPath = path.join(_nodeModulesDir, ...pkgName.split('/'));
|
const pkgPath = path.join(_nodeModulesDir, ...pkgName.split('/'));
|
||||||
const pkgJsonPath = path.join(pkgPath, 'package.json');
|
const pkgJsonPath = path.join(pkgPath, exportsMapJsonFileName);
|
||||||
const pkgJsonString = await fs.promises.readFile(pkgJsonPath, 'utf8');
|
const pkgJsonString = await fs.promises.readFile(pkgJsonPath, 'utf8');
|
||||||
const pkgJson = JSON.parse(pkgJsonString);
|
const pkgJson = JSON.parse(pkgJsonString);
|
||||||
const pkgExports = pkgJson.exports;
|
const pkgExports = pkgJson.exports;
|
||||||
|
|
|
||||||
|
|
@ -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/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export { LionAccordion } from './src/LionAccordion.js';
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import { LionAccordion } from './src/LionAccordion.js';
|
||||||
|
|
||||||
|
customElements.define('lion-accordion', LionAccordion);
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
export class LionAccordion extends HTMLElement {}
|
||||||
|
|
@ -17,6 +17,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
* @param {string} [options.classBareImport]
|
* @param {string} [options.classBareImport]
|
||||||
* @param {string} [options.tagPrefix]
|
* @param {string} [options.tagPrefix]
|
||||||
* @param {string} [options.tagBareImport]
|
* @param {string} [options.tagBareImport]
|
||||||
|
* @param {string} [options.exportsMapJsonFileName]
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async function execute(input, options = {}) {
|
async function execute(input, options = {}) {
|
||||||
|
|
@ -74,6 +75,41 @@ describe('generateExtendDocsConfig', () => {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can configure the name of the json file that contains the export map', async () => {
|
||||||
|
const result = await execute('fixtures/export-map-json', {
|
||||||
|
exportsMapJsonFileName: 'exports.json',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result).to.deep.equal([
|
||||||
|
{
|
||||||
|
name: '@lion/accordion - LionAccordion',
|
||||||
|
variable: {
|
||||||
|
from: 'LionAccordion',
|
||||||
|
to: 'IngAccordion',
|
||||||
|
paths: [
|
||||||
|
{
|
||||||
|
from: '@lion/accordion',
|
||||||
|
to: 'ing-web/accordion',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '@lion/accordion/define',
|
||||||
|
tag: {
|
||||||
|
from: 'lion-accordion',
|
||||||
|
to: 'ing-accordion',
|
||||||
|
paths: [
|
||||||
|
{
|
||||||
|
from: '@lion/accordion/define',
|
||||||
|
to: '#accordion/define',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it('works if there is no npm scope sub folder', async () => {
|
it('works if there is no npm scope sub folder', async () => {
|
||||||
const result = await execute('fixtures/no-node-modules-scope-folder', {
|
const result = await execute('fixtures/no-node-modules-scope-folder', {
|
||||||
npmScope: '',
|
npmScope: '',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue