@emulsify/core 2.1.0 → 2.2.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.
@@ -1,9 +1,6 @@
1
1
  import { useEffect } from '@storybook/preview-api';
2
2
  import Twig from 'twig';
3
- import { setupTwig } from './setupTwig';
4
-
5
- // Project config to import stylesheets.
6
- import('../../../../config/emulsify-core/storybook/preview');
3
+ import { setupTwig, fetchCSSFiles } from './utils.js';
7
4
 
8
5
  // If in a Drupal project, it's recommended to import a symlinked version of drupal.js.
9
6
  import './_drupal.js';
@@ -21,6 +18,7 @@ export const decorators = [
21
18
  ];
22
19
 
23
20
  setupTwig(Twig);
21
+ fetchCSSFiles();
24
22
 
25
23
  export const parameters = {
26
24
  actions: { argTypesRegex: '^on[A-Z].*' },
@@ -22,6 +22,29 @@ const fetchVariantConfig = () => {
22
22
  }
23
23
  };
24
24
 
25
+ /**
26
+ * Fetches and loads all CSS files from the specified directories based on the project's configuration.
27
+ * If the platform is 'drupal', it also includes CSS files from additional component directories.
28
+ *
29
+ * @returns {undefined} If an error occurs, the function will return undefined.
30
+ */
31
+ const fetchCSSFiles = () => {
32
+ try {
33
+ // Load all CSS files from 'dist'.
34
+ const cssFiles = require.context('../../../../dist', true, /\.css$/);
35
+ cssFiles.keys().forEach(file => cssFiles(file));
36
+
37
+ // Load all CSS files from 'components' for 'drupal' platform.
38
+ const emulsifyConfig = require('../../../../project.emulsify.json');
39
+ if (emulsifyConfig.project.platform === 'drupal') {
40
+ const drupalCSSFiles = require.context('../../../../components', true, /\.css$/);
41
+ drupalCSSFiles.keys().forEach(file => drupalCSSFiles(file));
42
+ }
43
+ } catch (e) {
44
+ return undefined;
45
+ }
46
+ };
47
+
25
48
  module.exports.namespaces = {};
26
49
  for (const { name, directory } of fetchVariantConfig()) {
27
50
  module.exports.namespaces[name] = resolve(__dirname, '../../../../', directory);
@@ -41,3 +64,6 @@ module.exports.setupTwig = function setupTwig(twig) {
41
64
  twigAddAttributes(twig);
42
65
  return twig;
43
66
  };
67
+
68
+ // Export the fetchCSSFiles function
69
+ module.exports.fetchCSSFiles = fetchCSSFiles;
@@ -115,5 +115,10 @@ module.exports = async ({ config }) => {
115
115
  }),
116
116
  ];
117
117
 
118
+ // Configure fallback for optional modules that may not be present
119
+ config.resolve.fallback = {
120
+ '../../../../components': false,
121
+ };
122
+
118
123
  return config;
119
124
  };
@@ -21,7 +21,10 @@ const BaseScssPattern = fs.existsSync(path.resolve(projectDir, 'src'))
21
21
  const ComponentScssPattern = fs.existsSync(path.resolve(projectDir, 'src'))
22
22
  ? path.resolve(srcDir, 'components/**/!(_*|cl-*|sb-*).scss')
23
23
  : path.resolve(srcDir, '**/!(_*|cl-*|sb-*).scss');
24
- const ComponentLibraryScssPattern = path.resolve(srcDir, 'util/**/!(_).scss');
24
+ const ComponentLibraryScssPattern = path.resolve(
25
+ srcDir,
26
+ '**/*{cl-*,sb-*}.scss',
27
+ );
25
28
 
26
29
  // Glob pattern for JS files.
27
30
  const jsPattern = fs.existsSync(path.resolve(projectDir, 'src'))
@@ -83,7 +86,7 @@ function getEntries(
83
86
  entries[newfilePath] = file;
84
87
  });
85
88
 
86
- // Component SCSS entries.
89
+ // Component SCSS entries.-
87
90
  glob.sync(ComponentScssMatcher).forEach((file) => {
88
91
  const filePath = file.split('components/')[1];
89
92
  const filePathDist = replaceLastSlash(filePath, '/css/');
@@ -100,7 +103,7 @@ function getEntries(
100
103
 
101
104
  // Component Library SCSS entries.
102
105
  glob.sync(ComponentLibraryScssMatcher).forEach((file) => {
103
- const filePath = file.split(/util/)[1];
106
+ const filePath = file.split(`${srcDir}/`)[1];
104
107
  const newfilePath = `dist/storybook/${filePath.replace('.scss', '')}`;
105
108
  entries[newfilePath] = file;
106
109
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emulsify/core",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Bundled tooling for Storybook development + Webpack Build",
5
5
  "keywords": [
6
6
  "component library",
@@ -49,26 +49,26 @@
49
49
  "@babel/core": "^7.25.2",
50
50
  "@babel/eslint-parser": "^7.25.1",
51
51
  "@emulsify/cli": "^1.11.0",
52
- "@storybook/addon-a11y": "^8.2.9",
53
- "@storybook/addon-actions": "^8.2.9",
54
- "@storybook/addon-essentials": "^8.2.9",
55
- "@storybook/addon-links": "^8.2.9",
52
+ "@storybook/addon-a11y": "^8.3.0",
53
+ "@storybook/addon-actions": "^8.3.0",
54
+ "@storybook/addon-essentials": "^8.3.0",
55
+ "@storybook/addon-links": "^8.3.0",
56
56
  "@storybook/addon-styling-webpack": "^1.0.0",
57
- "@storybook/addon-themes": "^8.2.9",
58
- "@storybook/html": "^8.2.9",
59
- "@storybook/html-webpack5": "^8.2.9",
60
- "@storybook/manager-api": "^8.2.9",
61
- "@storybook/preview-api": "^8.2.9",
62
- "@storybook/theming": "^8.2.9",
57
+ "@storybook/addon-themes": "^8.3.0",
58
+ "@storybook/html": "^8.3.0",
59
+ "@storybook/html-webpack5": "^8.3.0",
60
+ "@storybook/manager-api": "^8.3.0",
61
+ "@storybook/preview-api": "^8.3.0",
62
+ "@storybook/theming": "^8.3.0",
63
63
  "add-attributes-twig-extension": "^0.1.0",
64
64
  "autoprefixer": "^10.4.20",
65
- "babel-loader": "^9.1.3",
65
+ "babel-loader": "^9.2.1",
66
66
  "babel-preset-minify": "^0.5.2",
67
67
  "bem-twig-extension": "^0.1.1",
68
68
  "breakpoint-sass": "^3.0.0",
69
69
  "chalk": "^5.2.0",
70
70
  "clean-webpack-plugin": "^4.0.0",
71
- "concurrently": "^8.2.2",
71
+ "concurrently": "^9.0.1",
72
72
  "copy-webpack-plugin": "^12.0.2",
73
73
  "css-loader": "^7.1.1",
74
74
  "eslint": "^8.57.0",
@@ -98,22 +98,21 @@
98
98
  "normalize.css": "^8.0.1",
99
99
  "open-cli": "^8.0.0",
100
100
  "pa11y": "^8.0.0",
101
- "postcss": "^8.4.44",
101
+ "postcss": "^8.4.47",
102
102
  "postcss-loader": "^8.1.1",
103
103
  "postcss-scss": "^4.0.9",
104
104
  "ramda": "^0.30.1",
105
105
  "react": "^18.2.0",
106
106
  "react-dom": "^18.2.0",
107
107
  "regenerator-runtime": "^0.14.1",
108
- "sass": "^1.75.0",
108
+ "sass": "^1.78.0",
109
109
  "sass-loader": "^16.0.1",
110
- "semantic-release": "^24.1.0",
111
- "storybook": "^8.2.9",
112
- "style-dictionary": "^4.1.0",
110
+ "storybook": "^8.3.0",
111
+ "style-dictionary": "^4.1.1",
113
112
  "stylelint": "^16.9.0",
114
113
  "stylelint-config-standard-scss": "^13.1.0",
115
114
  "stylelint-prettier": "^5.0.0",
116
- "stylelint-selector-bem-pattern": "^4.0.0",
115
+ "stylelint-selector-bem-pattern": "^4.0.1",
117
116
  "stylelint-webpack-plugin": "^5.0.1",
118
117
  "svg-sprite-loader": "^6.0.11",
119
118
  "token-transformer": "^0.0.33",
@@ -126,15 +125,16 @@
126
125
  "yaml": "^2.5.0"
127
126
  },
128
127
  "devDependencies": {
129
- "@commitlint/cli": "^19.4.1",
130
- "@commitlint/config-conventional": "^19.4.1",
128
+ "@commitlint/cli": "^19.5.0",
129
+ "@commitlint/config-conventional": "^19.5.0",
131
130
  "@semantic-release/changelog": "^6.0.2",
132
131
  "@semantic-release/commit-analyzer": "^13.0.0",
133
132
  "@semantic-release/git": "^10.0.1",
134
- "@semantic-release/github": "^10.3.0",
133
+ "@semantic-release/github": "^10.3.4",
135
134
  "@semantic-release/release-notes-generator": "^14.0.0",
136
- "husky": "^9.1.5",
137
- "lint-staged": "^15.2.10"
135
+ "husky": "^9.1.6",
136
+ "lint-staged": "^15.2.10",
137
+ "semantic-release": "^24.1.1"
138
138
  },
139
139
  "overrides": {
140
140
  "graceful-fs": "^4.2.11"
@@ -1,33 +0,0 @@
1
- jest.mock('path', () => ({
2
- resolve: (...paths) => `${paths[1]}${paths[2]}`,
3
- }));
4
- jest.mock('twig-drupal-filters', () => jest.fn());
5
- jest.mock('bem-twig-extension', () => jest.fn());
6
- jest.mock('add-attributes-twig-extension', () => jest.fn());
7
-
8
- import Twig from 'twig';
9
- import twigDrupal from 'twig-drupal-filters';
10
- import twigBEM from 'bem-twig-extension';
11
- import twigAddAttributes from 'add-attributes-twig-extension';
12
-
13
- import { namespaces, setupTwig } from './setupTwig';
14
-
15
- describe('setupTwig', () => {
16
- it('sets up a twig object with drupal, bem, and attribute decorations', () => {
17
- expect.assertions(3);
18
- setupTwig(Twig);
19
- expect(twigDrupal).toHaveBeenCalledWith(Twig);
20
- expect(twigBEM).toHaveBeenCalledWith(Twig);
21
- expect(twigAddAttributes).toHaveBeenCalledWith(Twig);
22
- });
23
-
24
- it('exports emulsifys namespaces', () => {
25
- expect(namespaces).toEqual({
26
- base: '../../../../components/00-base',
27
- atoms: '../../../../components/01-atoms',
28
- molecules: '../../../../components/02-molecules',
29
- organisms: '../../../../components/03-organisms',
30
- templates: '../../../../components/04-templates',
31
- });
32
- });
33
- });