@canopy-iiif/app 1.8.1 → 1.8.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.
package/lib/build/dev.js CHANGED
@@ -23,6 +23,11 @@ const APP_COMPONENTS_DIR = path.join(process.cwd(), "app", "components");
23
23
 
24
24
  function resolveTailwindCli() {
25
25
  const root = process.cwd();
26
+ const binName = process.platform === "win32" ? "tailwindcss.cmd" : "tailwindcss";
27
+ const bin = path.join(root, "node_modules", ".bin", binName);
28
+ if (fs.existsSync(bin)) {
29
+ return { cmd: bin, args: [] };
30
+ }
26
31
  let cliEntry = null;
27
32
  try {
28
33
  cliEntry = require.resolve("@tailwindcss/cli/dist/index.mjs", { paths: [root] });
@@ -32,14 +37,7 @@ function resolveTailwindCli() {
32
37
  if (cliEntry) {
33
38
  return { cmd: process.execPath || "node", args: [cliEntry] };
34
39
  }
35
- const bin = path.join(
36
- root,
37
- "node_modules",
38
- ".bin",
39
- process.platform === "win32" ? "tailwindcss.cmd" : "tailwindcss"
40
- );
41
- if (fs.existsSync(bin)) return { cmd: bin, args: [] };
42
- return { cmd: "tailwindcss", args: [] };
40
+ return null;
43
41
  }
44
42
  const PORT = Number(process.env.PORT || 5001);
45
43
  const BUILD_MODULE_PATH = path.resolve(__dirname, "build.js");
@@ -965,7 +963,7 @@ async function dev() {
965
963
  const cli = resolveTailwindCli();
966
964
  if (!cli) {
967
965
  throw new Error(
968
- "[tailwind] Tailwind CLI not found. Install the 'tailwindcss' package in the workspace."
966
+ "[tailwind] Tailwind CLI not found. Install '@tailwindcss/cli' (and tailwindcss) in this workspace."
969
967
  );
970
968
  }
971
969
 
@@ -978,6 +976,46 @@ async function dev() {
978
976
  }
979
977
  };
980
978
 
979
+ const tailwindCmd = (args = []) => {
980
+ const parts = [cli.cmd];
981
+ if (Array.isArray(cli.args) && cli.args.length) parts.push(...cli.args);
982
+ if (Array.isArray(args) && args.length) parts.push(...args);
983
+ return parts.filter(Boolean).join(" ");
984
+ };
985
+
986
+ const formatSpawnOutput = (result) => {
987
+ if (!result) return "";
988
+ const messages = [];
989
+ if (result.stderr && result.stderr.length) {
990
+ const text = String(result.stderr).trim();
991
+ if (text) messages.push(`stderr: ${text}`);
992
+ }
993
+ if (result.stdout && result.stdout.length) {
994
+ const text = String(result.stdout).trim();
995
+ if (text) messages.push(`stdout: ${text}`);
996
+ }
997
+ return messages.join("\n");
998
+ };
999
+
1000
+ const tailwindFailureMessage = (label, result, args) => {
1001
+ const details = [
1002
+ label,
1003
+ ` input: ${prettyPath(inputCss)}`,
1004
+ ` config: ${configPath ? prettyPath(configPath) : "<unknown>"}`,
1005
+ ` cli: ${tailwindCmd(args)}`,
1006
+ ];
1007
+ const extra = formatSpawnOutput(result);
1008
+ if (extra) {
1009
+ details.push(
1010
+ extra
1011
+ .split(/\r?\n/)
1012
+ .map((line) => ` ${line}`)
1013
+ .join("\n")
1014
+ );
1015
+ }
1016
+ return details.join("\n");
1017
+ };
1018
+
981
1019
  const baseArgs = [
982
1020
  "-i",
983
1021
  inputCss,
@@ -993,10 +1031,13 @@ async function dev() {
993
1031
  env: { ...process.env, BROWSERSLIST_IGNORE_OLD_DATA: "1" },
994
1032
  });
995
1033
  if (!initial || initial.status !== 0) {
996
- if (initial && initial.stderr) {
997
- try { process.stderr.write(initial.stderr); } catch (_) {}
998
- }
999
- throw new Error("[tailwind] Initial Tailwind build failed.");
1034
+ throw new Error(
1035
+ tailwindFailureMessage(
1036
+ "[tailwind] Initial Tailwind build failed.",
1037
+ initial,
1038
+ baseArgs
1039
+ )
1040
+ );
1000
1041
  }
1001
1042
  injectThemeTokens(outputCss);
1002
1043
  stripTailwindThemeLayer(outputCss);
@@ -1047,10 +1088,13 @@ async function dev() {
1047
1088
  env: { ...process.env, BROWSERSLIST_IGNORE_OLD_DATA: "1" },
1048
1089
  });
1049
1090
  if (!res || res.status !== 0) {
1050
- if (res && res.stderr) {
1051
- try { process.stderr.write(res.stderr); } catch (_) {}
1052
- }
1053
- throw new Error("[tailwind] On-demand Tailwind compile failed.");
1091
+ throw new Error(
1092
+ tailwindFailureMessage(
1093
+ "[tailwind] On-demand Tailwind compile failed.",
1094
+ res,
1095
+ baseArgs
1096
+ )
1097
+ );
1054
1098
  }
1055
1099
  injectThemeTokens(outputCss);
1056
1100
  stripTailwindThemeLayer(outputCss);
@@ -9,6 +9,11 @@ const {
9
9
 
10
10
  function resolveTailwindCli() {
11
11
  const root = process.cwd();
12
+ const binName = process.platform === "win32" ? "tailwindcss.cmd" : "tailwindcss";
13
+ const localBin = path.join(root, "node_modules", ".bin", binName);
14
+ if (fs.existsSync(localBin)) {
15
+ return {cmd: localBin, args: []};
16
+ }
12
17
  let cliEntry = null;
13
18
  try {
14
19
  cliEntry = require.resolve("@tailwindcss/cli/dist/index.mjs", { paths: [root] });
@@ -18,14 +23,7 @@ function resolveTailwindCli() {
18
23
  if (cliEntry) {
19
24
  return {cmd: process.execPath || "node", args: [cliEntry]};
20
25
  }
21
- const localBin = path.join(
22
- root,
23
- "node_modules",
24
- ".bin",
25
- process.platform === "win32" ? "tailwindcss.cmd" : "tailwindcss"
26
- );
27
- if (fs.existsSync(localBin)) return {cmd: localBin, args: []};
28
- return {cmd: "tailwindcss", args: []};
26
+ return null;
29
27
  }
30
28
 
31
29
  function injectThemeTokens(targetPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canopy-iiif/app",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "Mat Jordan <mat@northwestern.edu>",