payload 3.0.0-beta.4 → 3.0.0-beta.5
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/dist/config/find.d.ts.map +1 -1
- package/dist/config/find.js +20 -9
- package/dist/config/find.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/config/find.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/config/find.ts"],"names":[],"mappings":"AAsDA;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,MAmE7B,CAAA"}
|
package/dist/config/find.js
CHANGED
|
@@ -9,26 +9,32 @@ import path from 'path';
|
|
|
9
9
|
const tsConfigPath = findUp.sync('tsconfig.json');
|
|
10
10
|
if (!tsConfigPath) {
|
|
11
11
|
return {
|
|
12
|
-
|
|
13
|
-
srcPath: process.cwd()
|
|
12
|
+
rootPath: process.cwd()
|
|
14
13
|
};
|
|
15
14
|
}
|
|
16
15
|
try {
|
|
17
16
|
// Read the file as a string and remove trailing commas
|
|
18
17
|
const rawTsConfig = fs.readFileSync(tsConfigPath, 'utf-8').replace(/,\s*\]/g, ']').replace(/,\s*\}/g, '}');
|
|
19
18
|
const tsConfig = JSON.parse(rawTsConfig);
|
|
20
|
-
const
|
|
21
|
-
const
|
|
19
|
+
const rootPath = process.cwd();
|
|
20
|
+
const srcPath = tsConfig.compilerOptions?.rootDir || path.resolve(process.cwd(), 'src');
|
|
21
|
+
const outPath = tsConfig.compilerOptions?.outDir || path.resolve(process.cwd(), 'dist');
|
|
22
|
+
const tsConfigDir = path.dirname(tsConfigPath);
|
|
23
|
+
let configPath = tsConfig.compilerOptions?.paths?.['@payload-config']?.[0];
|
|
24
|
+
if (configPath) {
|
|
25
|
+
configPath = path.resolve(tsConfigDir, configPath);
|
|
26
|
+
}
|
|
22
27
|
return {
|
|
28
|
+
configPath,
|
|
23
29
|
outPath,
|
|
30
|
+
rootPath,
|
|
24
31
|
srcPath
|
|
25
32
|
};
|
|
26
33
|
} catch (error) {
|
|
27
34
|
console.error(`Error parsing tsconfig.json: ${error}`) // Do not throw the error, as we can still continue with the other config path finding methods
|
|
28
35
|
;
|
|
29
36
|
return {
|
|
30
|
-
|
|
31
|
-
srcPath: process.cwd()
|
|
37
|
+
rootPath: process.cwd()
|
|
32
38
|
};
|
|
33
39
|
}
|
|
34
40
|
};
|
|
@@ -45,15 +51,20 @@ import path from 'path';
|
|
|
45
51
|
}
|
|
46
52
|
return path.resolve(process.cwd(), process.env.PAYLOAD_CONFIG_PATH);
|
|
47
53
|
}
|
|
48
|
-
const { outPath, srcPath } = getTSConfigPaths();
|
|
54
|
+
const { configPath, outPath, rootPath, srcPath } = getTSConfigPaths();
|
|
49
55
|
const searchPaths = process.env.NODE_ENV === 'production' ? [
|
|
56
|
+
configPath,
|
|
50
57
|
outPath,
|
|
51
|
-
srcPath
|
|
58
|
+
srcPath,
|
|
59
|
+
rootPath
|
|
52
60
|
] : [
|
|
53
|
-
|
|
61
|
+
configPath,
|
|
62
|
+
srcPath,
|
|
63
|
+
rootPath
|
|
54
64
|
];
|
|
55
65
|
// eslint-disable-next-line no-restricted-syntax
|
|
56
66
|
for (const searchPath of searchPaths){
|
|
67
|
+
if (!searchPath) continue;
|
|
57
68
|
const configPath = findUp.sync((dir)=>{
|
|
58
69
|
const tsPath = path.join(dir, 'payload.config.ts');
|
|
59
70
|
const hasTS = findUp.sync.exists(tsPath);
|
package/dist/config/find.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/find.ts"],"sourcesContent":["import findUp from 'find-up'\nimport fs from 'fs'\nimport path from 'path'\n\n/**\n * Returns the source and output paths from the nearest tsconfig.json file.\n * If no tsconfig.json file is found, returns the current working directory.\n * @returns An object containing the source and output paths.\n */\nconst getTSConfigPaths = (): { outPath
|
|
1
|
+
{"version":3,"sources":["../../src/config/find.ts"],"sourcesContent":["import findUp from 'find-up'\nimport fs from 'fs'\nimport path from 'path'\n\n/**\n * Returns the source and output paths from the nearest tsconfig.json file.\n * If no tsconfig.json file is found, returns the current working directory.\n * @returns An object containing the source and output paths.\n */\nconst getTSConfigPaths = (): {\n configPath?: string\n outPath?: string\n rootPath?: string\n srcPath?: string\n} => {\n const tsConfigPath = findUp.sync('tsconfig.json')\n\n if (!tsConfigPath) {\n return {\n rootPath: process.cwd(),\n }\n }\n\n try {\n // Read the file as a string and remove trailing commas\n const rawTsConfig = fs\n .readFileSync(tsConfigPath, 'utf-8')\n .replace(/,\\s*\\]/g, ']')\n .replace(/,\\s*\\}/g, '}')\n\n const tsConfig = JSON.parse(rawTsConfig)\n\n const rootPath = process.cwd()\n const srcPath = tsConfig.compilerOptions?.rootDir || path.resolve(process.cwd(), 'src')\n const outPath = tsConfig.compilerOptions?.outDir || path.resolve(process.cwd(), 'dist')\n const tsConfigDir = path.dirname(tsConfigPath)\n let configPath = tsConfig.compilerOptions?.paths?.['@payload-config']?.[0]\n if (configPath) {\n configPath = path.resolve(tsConfigDir, configPath)\n }\n return {\n configPath,\n outPath,\n rootPath,\n srcPath,\n }\n } catch (error) {\n console.error(`Error parsing tsconfig.json: ${error}`) // Do not throw the error, as we can still continue with the other config path finding methods\n return {\n rootPath: process.cwd(),\n }\n }\n}\n\n/**\n * Searches for a Payload configuration file.\n * @returns The absolute path to the Payload configuration file.\n * @throws An error if no configuration file is found.\n */\nexport const findConfig = (): string => {\n // If the developer has specified a config path,\n // format it if relative and use it directly if absolute\n if (process.env.PAYLOAD_CONFIG_PATH) {\n if (path.isAbsolute(process.env.PAYLOAD_CONFIG_PATH)) {\n return process.env.PAYLOAD_CONFIG_PATH\n }\n\n return path.resolve(process.cwd(), process.env.PAYLOAD_CONFIG_PATH)\n }\n\n const { configPath, outPath, rootPath, srcPath } = getTSConfigPaths()\n\n const searchPaths =\n process.env.NODE_ENV === 'production'\n ? [configPath, outPath, srcPath, rootPath]\n : [configPath, srcPath, rootPath]\n\n // eslint-disable-next-line no-restricted-syntax\n for (const searchPath of searchPaths) {\n if (!searchPath) continue\n\n const configPath = findUp.sync(\n (dir) => {\n const tsPath = path.join(dir, 'payload.config.ts')\n const hasTS = findUp.sync.exists(tsPath)\n\n if (hasTS) {\n return tsPath\n }\n\n const jsPath = path.join(dir, 'payload.config.js')\n const hasJS = findUp.sync.exists(jsPath)\n\n if (hasJS) {\n return jsPath\n }\n\n return undefined\n },\n { cwd: searchPath },\n )\n\n if (configPath) {\n return configPath\n }\n }\n\n // If no config file is found in the directories defined by tsconfig.json,\n // try searching in the 'src' and 'dist' directory as a last resort, as they are most commonly used\n if (process.env.NODE_ENV === 'production') {\n const distConfigPath = findUp.sync(['payload.config.js', 'payload.config.ts'], {\n cwd: path.resolve(process.cwd(), 'dist'),\n })\n\n if (distConfigPath) return distConfigPath\n } else {\n const srcConfigPath = findUp.sync(['payload.config.js', 'payload.config.ts'], {\n cwd: path.resolve(process.cwd(), 'src'),\n })\n\n if (srcConfigPath) return srcConfigPath\n }\n\n throw new Error(\n 'Error: cannot find Payload config. Please create a configuration file located at the root of your current working directory called \"payload.config.js\" or \"payload.config.ts\".',\n )\n}\n"],"names":["findUp","fs","path","getTSConfigPaths","tsConfigPath","sync","rootPath","process","cwd","rawTsConfig","readFileSync","replace","tsConfig","JSON","parse","srcPath","compilerOptions","rootDir","resolve","outPath","outDir","tsConfigDir","dirname","configPath","paths","error","console","findConfig","env","PAYLOAD_CONFIG_PATH","isAbsolute","searchPaths","NODE_ENV","searchPath","dir","tsPath","join","hasTS","exists","jsPath","hasJS","undefined","distConfigPath","srcConfigPath","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAY,UAAS;AAC5B,OAAOC,QAAQ,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+1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.5",
|
|
4
4
|
"description": "Node, React and MongoDB Headless CMS and Application Framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"sanitize-filename": "1.6.3",
|
|
50
50
|
"scheduler": "0.23.0",
|
|
51
51
|
"scmp": "2.1.0",
|
|
52
|
-
"@payloadcms/translations": "3.0.0-beta.
|
|
52
|
+
"@payloadcms/translations": "3.0.0-beta.5"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@monaco-editor/react": "4.5.1",
|