storybook-addon-sdc 0.18.1 → 0.19.2

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.
Files changed (2) hide show
  1. package/dist/preset.js +20 -10
  2. package/package.json +1 -2
package/dist/preset.js CHANGED
@@ -2,7 +2,6 @@
2
2
  import { readdirSync as readdirSync2, readFileSync } from "fs";
3
3
  import { parse as parseYaml } from "yaml";
4
4
  import { join as join2, basename as basename2, dirname as dirname3, extname } from "path";
5
- import { globSync } from "glob";
6
5
 
7
6
  // src/logger.ts
8
7
  import pino from "pino";
@@ -425,14 +424,25 @@ var readSDC = (filePath, defs, validate) => {
425
424
  }
426
425
  return sdcSchema;
427
426
  };
428
- var generateImports = (directory, namespaces) => readdirSync2(directory).filter(
429
- (file) => [".css", ".js", ".mjs", ".twig", ".yml"].includes(extname(file))
430
- ).map((file) => {
431
- const filePath = `./${file}`;
432
- const namespace = namespaces.pathToNamespace(directory);
433
- logger.info(`IMPORT ASSET ${directory}/${file}`);
434
- return extname(file) === ".twig" ? `import COMPONENT from '${namespace}/${file}';` : `import '${filePath}';`;
435
- }).join("\n");
427
+ var generateImports = (directory, namespaces) => {
428
+ const componentName = basename2(directory);
429
+ return readdirSync2(directory).filter(
430
+ (file) => [".css", ".js", ".mjs", ".twig", ".yml"].includes(extname(file))
431
+ ).map((file) => {
432
+ const filePath = `./${file}`;
433
+ const namespace = namespaces.pathToNamespace(directory);
434
+ logger.info(`IMPORT ASSET ${directory}/${file}`);
435
+ if (extname(file) === ".twig") {
436
+ const fileName = basename2(file, ".twig");
437
+ if (fileName === componentName) {
438
+ return `import COMPONENT from '${namespace}/${file}';`;
439
+ }
440
+ logger.info(`Skipping variant template: ${file}`);
441
+ return "";
442
+ }
443
+ return `import '${filePath}';`;
444
+ }).filter(Boolean).join("\n");
445
+ };
436
446
  var dynamicImports = (stories, namespaces) => {
437
447
  const imports = /* @__PURE__ */ new Set();
438
448
  const importComponent = (item) => {
@@ -611,7 +621,7 @@ var yamlStoriesIndexer = {
611
621
  };
612
622
  var loadStoryFilesSync = (fileName) => {
613
623
  const folderPath = dirname3(fileName);
614
- const storyFiles = globSync(join2(folderPath, "*.story.yml"));
624
+ const storyFiles = readdirSync2(folderPath).filter((file) => file.endsWith(".story.yml")).map((file) => join2(folderPath, file));
615
625
  return storyFiles.reduce(
616
626
  (acc, file) => {
617
627
  const content = readFileSync(file, "utf8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storybook-addon-sdc",
3
- "version": "0.18.1",
3
+ "version": "0.19.2",
4
4
  "description": "Drupal Single Directory Components as stories",
5
5
  "keywords": [
6
6
  "SDC",
@@ -37,7 +37,6 @@
37
37
  "format": "prettier --write ."
38
38
  },
39
39
  "dependencies": {
40
- "glob": "^13.0.0",
41
40
  "json-schema-faker": "^0.5.8",
42
41
  "jsonschema": "^1.5.0",
43
42
  "lodash-es": "^4.17.21",