@payloadcms/figma 0.0.1-alpha.25 → 0.0.1-alpha.26

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,6 +1,6 @@
1
1
  /**
2
- * Find the Payload config file using Payload's built-in finder
3
- * Changes to project directory temporarily and restores afterward
2
+ * Find the Payload config file using Payload's built-in finder when available,
3
+ * with fallback to simple file search for npx environments where payload isn't installed.
4
4
  *
5
5
  * @param projectPath - Absolute path to project directory
6
6
  * @returns Absolute path to config file, or null if not found
@@ -1 +1 @@
1
- {"version":3,"file":"payload-config-finder.d.ts","sourceRoot":"","sources":["../../src/utils/payload-config-finder.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAmBnF"}
1
+ {"version":3,"file":"payload-config-finder.d.ts","sourceRoot":"","sources":["../../src/utils/payload-config-finder.ts"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAWnF"}
@@ -1,26 +1,65 @@
1
- import { findConfig } from 'payload/node';
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ import * as log from './log.js';
4
+ // Standard Payload config file names in priority order
5
+ const CONFIG_FILES = [
6
+ 'payload.config.ts',
7
+ 'payload.config.js',
8
+ 'src/payload.config.ts',
9
+ 'src/payload.config.js'
10
+ ];
2
11
  /**
3
- * Find the Payload config file using Payload's built-in finder
4
- * Changes to project directory temporarily and restores afterward
12
+ * Find the Payload config file using Payload's built-in finder when available,
13
+ * with fallback to simple file search for npx environments where payload isn't installed.
5
14
  *
6
15
  * @param projectPath - Absolute path to project directory
7
16
  * @returns Absolute path to config file, or null if not found
8
17
  */ export async function findPayloadConfig(projectPath) {
18
+ // First, try using Payload's official config finder (if payload is installed)
19
+ const configFromPayload = await findConfigWithPayload(projectPath);
20
+ if (configFromPayload) {
21
+ return configFromPayload;
22
+ }
23
+ // Fallback: Simple file search for standard config locations
24
+ // This works when running via npx before payload is installed
25
+ log.debug('Payload not available, using fallback config finder');
26
+ return findConfigFallback(projectPath);
27
+ }
28
+ /**
29
+ * Try to find config using Payload's findConfig function.
30
+ * Returns null if payload is not installed (dynamic import fails).
31
+ */ async function findConfigWithPayload(projectPath) {
9
32
  const originalCwd = process.cwd();
10
33
  try {
34
+ // Dynamic import - will fail gracefully if payload is not installed
35
+ const { findConfig } = await import('payload/node');
11
36
  // findConfig requires being in the project directory
12
37
  process.chdir(projectPath);
13
- // Use Payload's official config finder
14
38
  const configPath = findConfig();
15
- // Wrap in Promise.resolve to satisfy async requirement
16
- return await Promise.resolve(configPath || null);
17
- } catch {
18
- // Config not found or error occurred
39
+ return configPath || null;
40
+ } catch (error) {
41
+ // payload not installed or other error - return null to use fallback
42
+ log.debug(`Could not use Payload findConfig: ${error instanceof Error ? error.message : 'unknown'}`);
19
43
  return null;
20
44
  } finally{
21
- // Always restore original working directory
22
45
  process.chdir(originalCwd);
23
46
  }
24
47
  }
48
+ /**
49
+ * Fallback config finder that checks standard locations.
50
+ * Used when payload is not installed (e.g., running via npx).
51
+ */ async function findConfigFallback(projectPath) {
52
+ for (const configFile of CONFIG_FILES){
53
+ const fullPath = path.join(projectPath, configFile);
54
+ try {
55
+ await fs.access(fullPath);
56
+ log.debug(`Found config at: ${fullPath}`);
57
+ return fullPath;
58
+ } catch {
59
+ // File doesn't exist, try next
60
+ }
61
+ }
62
+ return null;
63
+ }
25
64
 
26
65
  //# sourceMappingURL=payload-config-finder.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/payload-config-finder.ts"],"sourcesContent":["import { findConfig } from 'payload/node'\n\n/**\n * Find the Payload config file using Payload's built-in finder\n * Changes to project directory temporarily and restores afterward\n *\n * @param projectPath - Absolute path to project directory\n * @returns Absolute path to config file, or null if not found\n */\nexport async function findPayloadConfig(projectPath: string): Promise<null | string> {\n const originalCwd = process.cwd()\n\n try {\n // findConfig requires being in the project directory\n process.chdir(projectPath)\n\n // Use Payload's official config finder\n const configPath = findConfig()\n\n // Wrap in Promise.resolve to satisfy async requirement\n return await Promise.resolve(configPath || null)\n } catch {\n // Config not found or error occurred\n return null\n } finally {\n // Always restore original working directory\n process.chdir(originalCwd)\n }\n}\n"],"names":["findConfig","findPayloadConfig","projectPath","originalCwd","process","cwd","chdir","configPath","Promise","resolve"],"mappings":"AAAA,SAASA,UAAU,QAAQ,eAAc;AAEzC;;;;;;CAMC,GACD,OAAO,eAAeC,kBAAkBC,WAAmB;IACzD,MAAMC,cAAcC,QAAQC,GAAG;IAE/B,IAAI;QACF,qDAAqD;QACrDD,QAAQE,KAAK,CAACJ;QAEd,uCAAuC;QACvC,MAAMK,aAAaP;QAEnB,uDAAuD;QACvD,OAAO,MAAMQ,QAAQC,OAAO,CAACF,cAAc;IAC7C,EAAE,OAAM;QACN,qCAAqC;QACrC,OAAO;IACT,SAAU;QACR,4CAA4C;QAC5CH,QAAQE,KAAK,CAACH;IAChB;AACF"}
1
+ {"version":3,"sources":["../../src/utils/payload-config-finder.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nimport * as log from './log.js'\n\n// Standard Payload config file names in priority order\nconst CONFIG_FILES = [\n 'payload.config.ts',\n 'payload.config.js',\n 'src/payload.config.ts',\n 'src/payload.config.js',\n]\n\n/**\n * Find the Payload config file using Payload's built-in finder when available,\n * with fallback to simple file search for npx environments where payload isn't installed.\n *\n * @param projectPath - Absolute path to project directory\n * @returns Absolute path to config file, or null if not found\n */\nexport async function findPayloadConfig(projectPath: string): Promise<null | string> {\n // First, try using Payload's official config finder (if payload is installed)\n const configFromPayload = await findConfigWithPayload(projectPath)\n if (configFromPayload) {\n return configFromPayload\n }\n\n // Fallback: Simple file search for standard config locations\n // This works when running via npx before payload is installed\n log.debug('Payload not available, using fallback config finder')\n return findConfigFallback(projectPath)\n}\n\n/**\n * Try to find config using Payload's findConfig function.\n * Returns null if payload is not installed (dynamic import fails).\n */\nasync function findConfigWithPayload(projectPath: string): Promise<null | string> {\n const originalCwd = process.cwd()\n\n try {\n // Dynamic import - will fail gracefully if payload is not installed\n const { findConfig } = await import('payload/node')\n\n // findConfig requires being in the project directory\n process.chdir(projectPath)\n const configPath = findConfig()\n return configPath || null\n } catch (error) {\n // payload not installed or other error - return null to use fallback\n log.debug(\n `Could not use Payload findConfig: ${error instanceof Error ? error.message : 'unknown'}`,\n )\n return null\n } finally {\n process.chdir(originalCwd)\n }\n}\n\n/**\n * Fallback config finder that checks standard locations.\n * Used when payload is not installed (e.g., running via npx).\n */\nasync function findConfigFallback(projectPath: string): Promise<null | string> {\n for (const configFile of CONFIG_FILES) {\n const fullPath = path.join(projectPath, configFile)\n try {\n await fs.access(fullPath)\n log.debug(`Found config at: ${fullPath}`)\n return fullPath\n } catch {\n // File doesn't exist, try next\n }\n }\n\n return null\n}\n"],"names":["fs","path","log","CONFIG_FILES","findPayloadConfig","projectPath","configFromPayload","findConfigWithPayload","debug","findConfigFallback","originalCwd","process","cwd","findConfig","chdir","configPath","error","Error","message","configFile","fullPath","join","access"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,YAAYC,SAAS,WAAU;AAE/B,uDAAuD;AACvD,MAAMC,eAAe;IACnB;IACA;IACA;IACA;CACD;AAED;;;;;;CAMC,GACD,OAAO,eAAeC,kBAAkBC,WAAmB;IACzD,8EAA8E;IAC9E,MAAMC,oBAAoB,MAAMC,sBAAsBF;IACtD,IAAIC,mBAAmB;QACrB,OAAOA;IACT;IAEA,6DAA6D;IAC7D,8DAA8D;IAC9DJ,IAAIM,KAAK,CAAC;IACV,OAAOC,mBAAmBJ;AAC5B;AAEA;;;CAGC,GACD,eAAeE,sBAAsBF,WAAmB;IACtD,MAAMK,cAAcC,QAAQC,GAAG;IAE/B,IAAI;QACF,oEAAoE;QACpE,MAAM,EAAEC,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC;QAEpC,qDAAqD;QACrDF,QAAQG,KAAK,CAACT;QACd,MAAMU,aAAaF;QACnB,OAAOE,cAAc;IACvB,EAAE,OAAOC,OAAO;QACd,qEAAqE;QACrEd,IAAIM,KAAK,CACP,CAAC,kCAAkC,EAAEQ,iBAAiBC,QAAQD,MAAME,OAAO,GAAG,WAAW;QAE3F,OAAO;IACT,SAAU;QACRP,QAAQG,KAAK,CAACJ;IAChB;AACF;AAEA;;;CAGC,GACD,eAAeD,mBAAmBJ,WAAmB;IACnD,KAAK,MAAMc,cAAchB,aAAc;QACrC,MAAMiB,WAAWnB,KAAKoB,IAAI,CAAChB,aAAac;QACxC,IAAI;YACF,MAAMnB,GAAGsB,MAAM,CAACF;YAChBlB,IAAIM,KAAK,CAAC,CAAC,iBAAiB,EAAEY,UAAU;YACxC,OAAOA;QACT,EAAE,OAAM;QACN,+BAA+B;QACjC;IACF;IAEA,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/figma",
3
- "version": "0.0.1-alpha.25",
3
+ "version": "0.0.1-alpha.26",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "type": "module",
6
6
  "exports": {