@muonic/muon 0.0.2-experimental-149-9efe5a2.0 → 0.0.2-experimental-151-6e27a7a.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-experimental-149-9efe5a2.0",
3
+ "version": "0.0.2-experimental-151-6e27a7a.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -33,7 +33,6 @@
33
33
  "chokidar": "3.5.3",
34
34
  "chroma-js": "2.4.2",
35
35
  "command-line-args": "5.2.1",
36
- "deep-equal": "2.0.5",
37
36
  "deepmerge": "4.2.2",
38
37
  "glob": "8.0.3",
39
38
  "glob-to-regexp": "0.4.1",
package/rollup.config.mjs CHANGED
@@ -3,7 +3,8 @@ import { rollupPlugins } from '@muonic/muon/scripts/rollup-plugins.mjs';
3
3
  import virtual from '@rollup/plugin-virtual';
4
4
  import { nodeResolve } from '@rollup/plugin-node-resolve';
5
5
  import { createBasicConfig } from '@open-wc/building-rollup';
6
- import { componentDefiner } from '@muonic/muon/scripts/utils/index.mjs';
6
+ import { componentDefiner, getDestination } from '@muonic/muon/scripts/utils/index.mjs';
7
+ import path from 'path';
7
8
 
8
9
  const config = createBasicConfig();
9
10
  const input = 'index.js';
@@ -22,7 +23,7 @@ export default merge(config, {
22
23
  output: {
23
24
  ...config.output,
24
25
  dir: undefined,
25
- file: 'dist/index.js',
26
+ file: path.join(getDestination(), 'index.js'),
26
27
  sourcemap: false,
27
28
  inlineDynamicImports: true
28
29
  }
@@ -7,7 +7,7 @@ import postcssPreset from 'postcss-preset-env';
7
7
  import postcssImport from 'postcss-import';
8
8
  import postcssVariables from 'postcss-simple-vars';
9
9
  import litcssPlugin from 'rollup-plugin-lit-css';
10
- import { getConfig, createTokens, sourceFilesAnalyzer, getAliasPaths } from './utils/index.mjs';
10
+ import { cleanup, getConfig, getDestination, createTokens, sourceFilesAnalyzer, getAliasPaths } from './utils/index.mjs';
11
11
 
12
12
  import path from 'path';
13
13
  import fs from 'fs';
@@ -22,13 +22,11 @@ const muonPlugin = () => {
22
22
  return {
23
23
  name: 'muon',
24
24
  async buildStart() {
25
- const destination = config?.destination || 'dist';
26
- if (!fs.existsSync(destination)) {
27
- fs.mkdirSync(destination, { recursive: true });
28
- }
29
- const cejson = await sourceFilesAnalyzer();
30
-
31
- fs.writeFileSync(path.join(destination, 'custom-elements.json'), cejson);
25
+ const destination = getDestination();
26
+ cleanup(destination, true).then(async () => {
27
+ const cejson = await sourceFilesAnalyzer();
28
+ fs.writeFileSync(path.join(destination, 'custom-elements.json'), cejson);
29
+ });
32
30
  }
33
31
  };
34
32
  };
@@ -1,11 +1,9 @@
1
1
  import ts from 'typescript';
2
2
  import { analyzeText, analyzeSourceFile, transformAnalyzerResult } from 'web-component-analyzer';
3
- import { analyzeAndTransformGlobs } from 'web-component-analyzer/lib/cjs/cli.js';
4
3
  import StyleDictionary from 'style-dictionary';
5
4
  import formatHelpers from 'style-dictionary/lib/common/formatHelpers/index.js';
6
5
  import _ from 'lodash';
7
6
  import appRoot from 'app-root-path';
8
- import deepEqual from 'deep-equal';
9
7
  import glob from 'glob';
10
8
  import globToRegExp from 'glob-to-regexp';
11
9
  import fs from 'fs';
@@ -22,14 +20,27 @@ const __dirname = path.dirname(__filename);
22
20
 
23
21
  let config = {};
24
22
 
25
- const cleanup = (destination) => {
23
+ const cleanup = (destination, cleanOnRollup = false) => {
26
24
  return new Promise((resolve) => {
27
- fs.rmSync(destination, { force: true, recursive: true });
28
- fs.rmSync(path.join(__filename, '..', '..', '..', 'build'), { force: true, recursive: true });
25
+ const cemFilePath = path.join(destination, 'custom-elements.json');
26
+ const buildPath = path.join(__filename, '..', '..', '..', 'build');
29
27
 
30
- fs.mkdirSync(destination);
31
- fs.mkdirSync(path.join(__filename, '..', '..', '..', 'build'));
28
+ if (fs.existsSync(destination)) {
29
+ if (cleanOnRollup) {
30
+ // eslint-disable-next-line no-unused-expressions
31
+ fs.existsSync(cemFilePath) && fs.rmSync(cemFilePath);
32
+ } else {
33
+ fs.rmSync(destination, { force: true, recursive: true });
34
+ fs.rmSync(buildPath, { force: true, recursive: true });
35
+ }
36
+ }
32
37
 
38
+ if (!fs.existsSync(destination)) {
39
+ fs.mkdirSync(destination);
40
+ }
41
+ if (!cleanOnRollup) {
42
+ fs.mkdirSync(buildPath);
43
+ }
33
44
  return resolve();
34
45
  });
35
46
  };
@@ -266,9 +277,13 @@ const componentDefiner = async () => {
266
277
  return componentDefinition;
267
278
  };
268
279
 
269
- const runner = async (file, overrideDestination) => {
280
+ const getDestination = () => {
270
281
  const config = getConfig();
271
- const destination = overrideDestination || config?.destination || 'dist';
282
+ return config?.destination || 'dist';
283
+ };
284
+
285
+ const runner = async (file, overrideDestination) => {
286
+ const destination = overrideDestination || getDestination();
272
287
 
273
288
  cleanup(destination).then(async () => {
274
289
  import(file);
@@ -276,7 +291,9 @@ const runner = async (file, overrideDestination) => {
276
291
  };
277
292
 
278
293
  export {
294
+ cleanup,
279
295
  getConfig,
296
+ getDestination,
280
297
  filterPathToCustomElements,
281
298
  createTokens,
282
299
  componentDefiner,
@@ -3,7 +3,7 @@ const fs = require('fs');
3
3
  const pathIsInside = require('path-is-inside');
4
4
 
5
5
  const findStories = async (dir = process.cwd()) => {
6
- const { getConfig, filterPathToCustomElements } = await import('../scripts/utils/index.mjs');
6
+ const { getConfig, getDestination, filterPathToCustomElements } = await import('../scripts/utils/index.mjs');
7
7
 
8
8
  const config = getConfig();
9
9
  const componentsList = config?.components?.included;
@@ -21,7 +21,7 @@ const findStories = async (dir = process.cwd()) => {
21
21
  ) {
22
22
  return [path.relative(dir, patterns)];
23
23
  } else {
24
- const destination = config?.destination || 'dist';
24
+ const destination = getDestination();
25
25
  const symlink = path.join(destination, 'stories');
26
26
 
27
27
  if (!fs.existsSync(symlink)) {
@@ -191,7 +191,7 @@ describe('form-element-validation', () => {
191
191
  await formElement.updateComplete;
192
192
  let validationMessage = shadowRoot.querySelector('.validation');
193
193
  expect(validationMessage).to.not.be.null; // eslint-disable-line no-unused-expressions
194
- expect(validationMessage.textContent.trim().toLowerCase()).contains('fill out this field.', 'validation message has correct value');
194
+ expect(validationMessage.textContent.trim().toLowerCase()).contains('this field is required', 'validation message has correct value');
195
195
 
196
196
  await fillIn(inputElement, 'test validation');
197
197
  expect(formElement.value).to.equal('test validation', '`value` property has value `test validation`');