@salesforce/storefront-next-dev 0.3.0-alpha.0 → 0.3.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.
@@ -2,9 +2,9 @@ import { t as logger } from "../logger.js";
2
2
  import "../logger2.js";
3
3
  import { Command, Flags } from "@oclif/core";
4
4
  import path from "path";
5
+ import Handlebars from "handlebars";
5
6
  import fs from "fs";
6
7
  import { fileURLToPath } from "url";
7
- import Handlebars from "handlebars";
8
8
 
9
9
  //#region src/extensibility/create-instructions.ts
10
10
  const SKIP_DIRS = [
@@ -5,9 +5,11 @@ import { a as trimExtensions, i as validateNoCycles, n as resolveDependenciesFor
5
5
  import { t as prepareForLocalDev } from "../local-dev-setup.js";
6
6
  import { Command, Flags } from "@oclif/core";
7
7
  import { execFileSync, execSync } from "child_process";
8
+ import { fileURLToPath } from "node:url";
8
9
  import path from "path";
9
10
  import fs from "fs-extra";
10
11
  import dotenv from "dotenv";
12
+ import Handlebars from "handlebars";
11
13
  import prompts from "prompts";
12
14
 
13
15
  //#region src/create-storefront.ts
@@ -100,6 +102,22 @@ const createStorefront = async (options = {}) => {
100
102
  recursive: true,
101
103
  force: true
102
104
  });
105
+ const gitignoreExclusions = /* @__PURE__ */ new Set();
106
+ const gitignorePath = path.join(outputPath, ".gitignore");
107
+ if (fs.existsSync(gitignorePath)) for (const line of fs.readFileSync(gitignorePath, "utf8").split("\n")) {
108
+ const entry = line.trim().replace(/\/$/, "");
109
+ if (entry && !entry.startsWith("#") && !entry.startsWith("!") && !entry.includes("/") && !entry.includes("*")) gitignoreExclusions.add(entry);
110
+ }
111
+ const subPackages = fs.readdirSync(outputPath).filter((name) => {
112
+ if (name === "node_modules" || name.startsWith(".")) return false;
113
+ if (gitignoreExclusions.has(name)) return false;
114
+ const subDir = path.join(outputPath, name);
115
+ return fs.statSync(subDir).isDirectory() && fs.existsSync(path.join(subDir, "package.json"));
116
+ });
117
+ const workspaceTemplatePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../templates/pnpm-workspace.yaml.hbs");
118
+ const workspaceTemplate = Handlebars.compile(fs.readFileSync(workspaceTemplatePath, "utf8"));
119
+ const packagesBlock = subPackages.length > 0 ? `packages:\n${subPackages.map((p) => ` - ${p}`).join("\n")}\n` : "";
120
+ fs.writeFileSync(path.join(outputPath, "pnpm-workspace.yaml"), workspaceTemplate({ packages: packagesBlock }));
103
121
  if (isLocalPath(template) || options.localPackagesDir) {
104
122
  const templatePath = template.replace("file://", "");
105
123
  await prepareForLocalDev({
package/dist/config.js CHANGED
@@ -64,7 +64,8 @@ async function loadRuntimeConfig(projectDirectory) {
64
64
  }).import(configPath);
65
65
  return (mod.default ?? mod).runtime;
66
66
  } catch (error) {
67
- throw new Error(`[storefront-next-dev] Found config.server.ts at ${configPath} but failed to import it.`, { cause: error });
67
+ const reason = error instanceof Error ? error.message : String(error);
68
+ throw new Error(`[storefront-next-dev] Found config.server.ts at ${configPath} but failed to import it.\n${reason}`, { cause: error });
68
69
  }
69
70
  }
70
71
  const buildMrtConfig = async (_buildDirectory, projectDirectory) => {