@emulsify/core 2.0.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
  };
@@ -50,7 +50,13 @@
50
50
  "function-no-unknown": null,
51
51
  "import-notation": null,
52
52
  "media-feature-range-notation": null,
53
- "prettier/prettier": true,
53
+ "prettier/prettier": [
54
+ true,
55
+ {
56
+ "singleQuote": true,
57
+ "tabWidth": 2
58
+ }
59
+ ],
54
60
  "property-no-vendor-prefix": null,
55
61
  "selector-class-pattern": null,
56
62
  "selector-not-notation": null,
@@ -21,9 +21,16 @@
21
21
  "it": true,
22
22
  "describe": true
23
23
  },
24
+ "parser": "@babel/eslint-parser",
25
+ "parserOptions": {
26
+ "requireConfigFile": false,
27
+ "babelOptions": {
28
+ "babelrc": false,
29
+ "configFile": false
30
+ }
31
+ },
24
32
  "rules": {
25
33
  "strict": 0,
26
- "prettier/prettier": "error",
27
34
  "consistent-return": ["off"],
28
35
  "no-underscore-dangle": ["off"],
29
36
  "max-nested-callbacks": ["warn", 3],
@@ -36,6 +43,7 @@
36
43
  }],
37
44
  "no-param-reassign": ["off"],
38
45
  "no-prototype-builtins": ["off"],
46
+ "prettier/prettier": ["error", { "singleQuote": true }],
39
47
  "valid-jsdoc": ["warn", {
40
48
  "prefer": {
41
49
  "returns": "return",
@@ -44,7 +52,8 @@
44
52
  "requireReturn": false
45
53
  }],
46
54
  "no-unused-vars": ["warn"],
47
- "operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }]
55
+ "operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }],
56
+ "quotes": ["error", "single"]
48
57
  },
49
58
  "settings": {
50
59
  "import/ignore": [
@@ -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.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Bundled tooling for Storybook development + Webpack Build",
5
5
  "keywords": [
6
6
  "component library",
@@ -47,27 +47,28 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@babel/core": "^7.25.2",
50
+ "@babel/eslint-parser": "^7.25.1",
50
51
  "@emulsify/cli": "^1.11.0",
51
- "@storybook/addon-a11y": "^8.2.9",
52
- "@storybook/addon-actions": "^8.2.9",
53
- "@storybook/addon-essentials": "^8.2.9",
54
- "@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",
55
56
  "@storybook/addon-styling-webpack": "^1.0.0",
56
- "@storybook/addon-themes": "^8.2.9",
57
- "@storybook/html": "^8.2.9",
58
- "@storybook/html-webpack5": "^8.2.9",
59
- "@storybook/manager-api": "^8.2.9",
60
- "@storybook/preview-api": "^8.2.9",
61
- "@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",
62
63
  "add-attributes-twig-extension": "^0.1.0",
63
64
  "autoprefixer": "^10.4.20",
64
- "babel-loader": "^9.1.3",
65
+ "babel-loader": "^9.2.1",
65
66
  "babel-preset-minify": "^0.5.2",
66
67
  "bem-twig-extension": "^0.1.1",
67
68
  "breakpoint-sass": "^3.0.0",
68
69
  "chalk": "^5.2.0",
69
70
  "clean-webpack-plugin": "^4.0.0",
70
- "concurrently": "^8.2.2",
71
+ "concurrently": "^9.0.1",
71
72
  "copy-webpack-plugin": "^12.0.2",
72
73
  "css-loader": "^7.1.1",
73
74
  "eslint": "^8.57.0",
@@ -97,22 +98,21 @@
97
98
  "normalize.css": "^8.0.1",
98
99
  "open-cli": "^8.0.0",
99
100
  "pa11y": "^8.0.0",
100
- "postcss": "^8.4.44",
101
+ "postcss": "^8.4.47",
101
102
  "postcss-loader": "^8.1.1",
102
103
  "postcss-scss": "^4.0.9",
103
104
  "ramda": "^0.30.1",
104
105
  "react": "^18.2.0",
105
106
  "react-dom": "^18.2.0",
106
107
  "regenerator-runtime": "^0.14.1",
107
- "sass": "^1.75.0",
108
+ "sass": "^1.78.0",
108
109
  "sass-loader": "^16.0.1",
109
- "semantic-release": "^24.1.0",
110
- "storybook": "^8.2.9",
111
- "style-dictionary": "^4.1.0",
110
+ "storybook": "^8.3.0",
111
+ "style-dictionary": "^4.1.1",
112
112
  "stylelint": "^16.9.0",
113
113
  "stylelint-config-standard-scss": "^13.1.0",
114
114
  "stylelint-prettier": "^5.0.0",
115
- "stylelint-selector-bem-pattern": "^4.0.0",
115
+ "stylelint-selector-bem-pattern": "^4.0.1",
116
116
  "stylelint-webpack-plugin": "^5.0.1",
117
117
  "svg-sprite-loader": "^6.0.11",
118
118
  "token-transformer": "^0.0.33",
@@ -125,15 +125,16 @@
125
125
  "yaml": "^2.5.0"
126
126
  },
127
127
  "devDependencies": {
128
- "@commitlint/cli": "^19.4.1",
129
- "@commitlint/config-conventional": "^19.4.1",
128
+ "@commitlint/cli": "^19.5.0",
129
+ "@commitlint/config-conventional": "^19.5.0",
130
130
  "@semantic-release/changelog": "^6.0.2",
131
131
  "@semantic-release/commit-analyzer": "^13.0.0",
132
132
  "@semantic-release/git": "^10.0.1",
133
- "@semantic-release/github": "^10.3.0",
133
+ "@semantic-release/github": "^10.3.4",
134
134
  "@semantic-release/release-notes-generator": "^14.0.0",
135
- "husky": "^9.1.5",
136
- "lint-staged": "^15.2.10"
135
+ "husky": "^9.1.6",
136
+ "lint-staged": "^15.2.10",
137
+ "semantic-release": "^24.1.1"
137
138
  },
138
139
  "overrides": {
139
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
- });