diff --git a/packages/component-list/README.md b/packages/component-list/README.md index 9a48b95a..e1ee1071 100644 --- a/packages/component-list/README.md +++ b/packages/component-list/README.md @@ -27,7 +27,7 @@ and submit a pull request. > 💡 Thinking about maintenance, it's best to find a way to build this data from > your component library. See how -> [cloud-cognitive](https://github.com/carbon-design-system/devtools/tree/base/packages/component-list/src/library/cloud-cognitive.js) +> [ibm-products](https://github.com/carbon-design-system/devtools/tree/base/packages/component-list/src/library/ibm-products.js) > set up their components to scale. 5. Add your new library file to the build file diff --git a/packages/component-list/src/libraries/cloud-cognitive.js b/packages/component-list/src/libraries/cloud-cognitive.js deleted file mode 100644 index 5ab57285..00000000 --- a/packages/component-list/src/libraries/cloud-cognitive.js +++ /dev/null @@ -1,35 +0,0 @@ -import * as _CloudCognitive from '@carbon/ibm-products'; -import { _initStats } from '../helpers.js'; - -const { _stats, success } = new _initStats(); - -let { - pkg: { - devtoolsAttribute: cloudCognitiveDevtoolsAttribute, - getDevtoolsId: getCloudCognitiveDevtoolsId, - }, - ...cloudCognitive -} = _CloudCognitive; - -cloudCognitive = Object.values(cloudCognitive).reduce( - (components, { displayName }) => { - components[ - `[${cloudCognitiveDevtoolsAttribute}="${getCloudCognitiveDevtoolsId( - displayName - )}"]` - ] = displayName; - - success(); - - return components; - }, - {} -); - -cloudCognitive = { - name: 'Carbon for IBM Products', - components: cloudCognitive, - _stats, -}; - -export { cloudCognitive }; diff --git a/packages/component-list/src/libraries/ibm-products.js b/packages/component-list/src/libraries/ibm-products.js new file mode 100644 index 00000000..aacd14be --- /dev/null +++ b/packages/component-list/src/libraries/ibm-products.js @@ -0,0 +1,31 @@ +import fs from 'fs'; +import { pkg } from '@carbon/ibm-products'; +import { _initStats } from '../helpers.js'; + +const { _stats, success } = new _initStats(); +const productsDir = '../../node_modules/@carbon/ibm-products/es/components'; +const products = { + name: 'Carbon for IBM Products', + components: {}, + _stats, +}; +const { getDevtoolsId, devtoolsAttribute } = pkg; + +try { + const components = fs.readdirSync(productsDir); + + components.forEach((file) => { + if (file === '_Canary' || file === 'index.d.ts') { + return; + } + + const identifier = `[${devtoolsAttribute}="${getDevtoolsId(file)}]`; + + products.components[identifier] = file; + success(); + }); +} catch (e) { + console.log(e); +} + +export { products }; diff --git a/packages/component-list/src/libraries/index.js b/packages/component-list/src/libraries/index.js index f286c6f5..33ce271d 100644 --- a/packages/component-list/src/libraries/index.js +++ b/packages/component-list/src/libraries/index.js @@ -1,6 +1,6 @@ export * from './carbon'; export * from './carbon-web-components'; export * from './ibmdotcom'; -// export * from './cloud-cognitive'; +export * from './ibm-products'; export * from './security'; export * from './cloud-pal';