@muonic/muon 0.0.2-experimental-202-64f60d7.0 → 0.0.2-experimental-204-84bc0c7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-beta.18](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.17...v0.0.2-beta.18) (2023-06-05)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * finding all component files ([1216b2f](https://github.com/centrica-engineering/muon/commit/1216b2f45347220bd19c521c3dd5c196dba38200))
11
+
5
12
  ### [0.0.2-beta.17](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.16...v0.0.2-beta.17) (2023-05-31)
6
13
 
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-experimental-202-64f60d7.0",
3
+ "version": "0.0.2-experimental-204-84bc0c7.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -47,6 +47,11 @@ const cleanup = (destination, cleanOnRollup = false) => {
47
47
 
48
48
  const filterPathToCustomElements = async (componentsList) => {
49
49
  let pathPattern = '*';
50
+
51
+ if (!componentsList) {
52
+ return undefined;
53
+ }
54
+
50
55
  if (Array.isArray(componentsList) && componentsList?.length > 0) {
51
56
  if (componentsList.length > 1) {
52
57
  pathPattern = `{${componentsList.toString()}}`;
@@ -64,12 +69,12 @@ const findComponents = async () => {
64
69
  const componentsList = config?.components?.included;
65
70
  const pathPattern = await filterPathToCustomElements(componentsList);
66
71
  // initial Muon components
67
- let muonComponents = path.join(__filename, '..', '..', '..', 'components', '**', `${pathPattern}-component.js`);
72
+ let muonComponents = pathPattern ? path.join(__filename, '..', '..', '..', 'components', '**', `${pathPattern}-component.js`) : '';
68
73
 
69
74
  // additional components
70
75
  const additional = config?.components?.dir;
71
76
  if (additional) {
72
- muonComponents = `{${muonComponents},${additional.toString()}}`;
77
+ muonComponents = muonComponents.length > 0 ? `{${muonComponents},${additional.toString()}}` : `${additional.toString()}`;
73
78
  }
74
79
 
75
80
  return glob.sync(muonComponents).map((f) => path.resolve(f));
@@ -85,6 +90,7 @@ const getTagFromAnalyzerResult = (result) => {
85
90
  const tags = result.componentDefinitions[0]?.declaration?.jsDoc?.tags;
86
91
  const tagName = tags?.filter((jsDocTag) => jsDocTag.tag === 'element')?.[0]?.comment;
87
92
  const prefix = tags?.filter((jsDocTag) => jsDocTag.tag === 'prefix')?.[0]?.comment ?? getPrefix();
93
+
88
94
  return { tagName, prefix };
89
95
  };
90
96
 
@@ -196,7 +202,8 @@ const sourceFilesAnalyzer = async () => {
196
202
  paths
197
203
  };
198
204
  const program = ts.createProgram(files, options);
199
- const sourceFiles = program.getSourceFiles().filter((sf) => files.includes(sf.fileName));
205
+ const sourceFiles = program.getSourceFiles().
206
+ filter((sf) => files.map((f) => f.toLowerCase()).includes(sf.path.toLowerCase()));
200
207
 
201
208
  const results = sourceFiles.map((sourceFile) => analyzeSourceFile(sourceFile, {
202
209
  ts,
@@ -210,7 +217,7 @@ const sourceFilesAnalyzer = async () => {
210
217
  }));
211
218
 
212
219
  const tagNames = results?.map((result) => {
213
- const {tagName, prefix } = getTagFromAnalyzerResult(result);
220
+ const { tagName, prefix } = getTagFromAnalyzerResult(result);
214
221
 
215
222
  const elementName = `${prefix}-${tagName}`;
216
223
  result.componentDefinitions[0].tagName = elementName;
@@ -0,0 +1,12 @@
1
+ {
2
+ "components": {
3
+ "dir": "tests/scripts/utils/cta-component.js"
4
+ },
5
+ "tokens": {
6
+ "dir": ["tokens/*.json"],
7
+ "theme": "default"
8
+ },
9
+ "alias": {
10
+ "@muon/utils/validation": "./utils/validation"
11
+ }
12
+ }
@@ -33,6 +33,11 @@ testRunner('filterPathToCustomElements multiple component', async (t) => {
33
33
  t.is(componentList, '{inputter,image}');
34
34
  });
35
35
 
36
+ testRunner('filterPathToCustomElements is undefined', async (t) => {
37
+ const componentList = await utilsLibrary.filterPathToCustomElements();
38
+ t.is(componentList, undefined);
39
+ });
40
+
36
41
  testRunner('getConfig default file and root', async (t) => {
37
42
  const config = utilsLibrary.getConfig();
38
43
  t.true(config !== undefined);
@@ -229,6 +234,30 @@ testRunner('sourceFilesAnalyzer with prefix override', async (t) => {
229
234
  });
230
235
  });
231
236
 
237
+ testRunner('sourceFilesAnalyzer with no included', async (t) => {
238
+ const stub = await esmock('../../../scripts/utils/index.mjs', {
239
+ '../../../scripts/utils/config.mjs': {
240
+ getConfig: (configFile) => JSON.parse(fs.readFileSync('tests/scripts/utils/muon.config.prefix.no-included.json').toString())
241
+ }
242
+ });
243
+ const result = await stub.sourceFilesAnalyzer();
244
+ const jsonResult = JSON.parse(result);
245
+
246
+ const components = ['mnx-cta'];
247
+ const propertiesMap = {
248
+ 'mnx-cta': ['enabled', 'type']
249
+ };
250
+ t.deepEqual(jsonResult.tags?.map((tag) => tag.name).sort(), components.sort());
251
+
252
+ components.forEach((component) => {
253
+ t.deepEqual(jsonResult.tags.filter((tag) => tag.name === component)[0].properties?.map(
254
+ (property) => property.name), propertiesMap[component], component);
255
+ });
256
+ jsonResult.tags?.map((tag) => {
257
+ t.true(tag.description !== undefined, `${tag.name} description is not present`);
258
+ });
259
+ });
260
+
232
261
  testRunner('sourceFilesAnalyzer error', async (t) => {
233
262
  const stub = await esmock('../../../scripts/utils/index.mjs', {
234
263
  '../../../scripts/utils/config.mjs': {