@skspwork/config-doc 2.0.3 → 2.0.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/package.json +3 -2
- package/packages/web/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/packages/web/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/packages/web/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/packages/web/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/packages/web/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/packages/web/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/packages/web/.next/standalone/.next/server/app/api/config/save/route.js +1 -1
- package/packages/web/.next/standalone/.next/server/app/api/config/save/route.js.nft.json +1 -1
- package/packages/web/.next/standalone/.next/server/app/api/export/route.js +3 -3
- package/packages/web/.next/standalone/.next/server/app/api/export/route.js.nft.json +1 -1
- package/packages/web/.next/standalone/.next/server/app/index.html +1 -1
- package/packages/web/.next/standalone/.next/server/app/index.rsc +3 -3
- package/packages/web/.next/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/packages/web/.next/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/packages/web/.next/standalone/.next/server/app/index.segments/_index.segment.rsc +2 -2
- package/packages/web/.next/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/packages/web/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/packages/web/.next/standalone/.next/server/chunks/[root-of-the-server]__40e87302._.js +3 -0
- package/packages/web/.next/standalone/.next/server/chunks/[root-of-the-server]__93da9fce._.js +1 -1
- package/packages/web/.next/standalone/.next/server/chunks/[root-of-the-server]__c9655ac8._.js +3 -0
- package/packages/web/.next/standalone/.next/server/chunks/[root-of-the-server]__e19366f6._.js +1 -1
- package/packages/web/.next/standalone/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_d09de205.js +368 -29
- package/packages/web/.next/standalone/.next/server/chunks/ssr/app_page_tsx_55b2e5ee._.js +1 -1
- package/packages/web/.next/standalone/.next/server/pages/404.html +1 -1
- package/packages/web/.next/standalone/.next/static/chunks/02de70e4c30afe2f.js +1 -0
- package/packages/web/.next/standalone/.next/static/chunks/862e384b52cfebf3.css +3 -0
- package/packages/web/.next/standalone/app/api/config/metadata/route.ts +5 -3
- package/packages/web/.next/standalone/package.json +2 -0
- package/packages/web/.next/standalone/playwright-report/index.html +1 -1
- package/packages/web/.next/static/chunks/02de70e4c30afe2f.js +1 -0
- package/packages/web/.next/static/chunks/862e384b52cfebf3.css +3 -0
- package/packages/web/package.json +2 -0
- package/packages/web/.next/standalone/.next/server/chunks/[root-of-the-server]__1a68b1f3._.js +0 -3
- package/packages/web/.next/standalone/.next/server/chunks/[root-of-the-server]__2c94dfea._.js +0 -3
- package/packages/web/.next/standalone/.next/static/chunks/4bbca8cd642026de.css +0 -3
- package/packages/web/.next/standalone/.next/static/chunks/54e2bd8f072e7d4e.js +0 -1
- package/packages/web/.next/standalone/app/api/config/load/route.ts +0 -57
- package/packages/web/.next/standalone/app/api/config/save/route.ts +0 -73
- package/packages/web/.next/standalone/app/api/export/route.ts +0 -75
- package/packages/web/.next/standalone/app/api/export/settings/route.ts +0 -144
- package/packages/web/.next/standalone/app/api/files/browse/route.ts +0 -46
- package/packages/web/.next/standalone/app/api/project/route.ts +0 -41
- package/packages/web/.next/standalone/app/globals.css +0 -26
- package/packages/web/.next/standalone/app/icon.svg +0 -41
- package/packages/web/.next/standalone/app/layout.tsx +0 -34
- package/packages/web/.next/standalone/app/page.tsx +0 -135
- package/packages/web/.next/standalone/components/ConfigFileTabs.tsx +0 -188
- package/packages/web/.next/standalone/components/ConfigTree.tsx +0 -176
- package/packages/web/.next/standalone/components/EditableList.tsx +0 -337
- package/packages/web/.next/standalone/components/ExportDialog.tsx +0 -234
- package/packages/web/.next/standalone/components/FieldsEditor.tsx +0 -92
- package/packages/web/.next/standalone/components/FileBrowser.tsx +0 -290
- package/packages/web/.next/standalone/components/Header.tsx +0 -37
- package/packages/web/.next/standalone/components/PropertyEditor.tsx +0 -102
- package/packages/web/.next/standalone/components/TagEditor.tsx +0 -86
- package/packages/web/.next/standalone/components/Toast.tsx +0 -91
- package/packages/web/.next/standalone/eslint.config.mjs +0 -18
- package/packages/web/.next/standalone/hooks/useConfigManager.ts +0 -633
- package/packages/web/.next/standalone/lib/configParser.ts +0 -155
- package/packages/web/.next/standalone/lib/fileSystem.ts +0 -186
- package/packages/web/.next/standalone/lib/getRootPath.ts +0 -45
- package/packages/web/.next/standalone/lib/htmlGenerator.ts +0 -839
- package/packages/web/.next/standalone/lib/jsonUtils.ts +0 -26
- package/packages/web/.next/standalone/lib/markdownGenerator.ts +0 -79
- package/packages/web/.next/standalone/lib/markdownTableGenerator.ts +0 -107
- package/packages/web/.next/standalone/lib/storage.ts +0 -104
- package/packages/web/.next/standalone/lib/utils.ts +0 -72
- package/packages/web/.next/standalone/next.config.ts +0 -10
- package/packages/web/.next/standalone/package-lock.json +0 -7977
- package/packages/web/.next/standalone/playwright.config.ts +0 -27
- package/packages/web/.next/standalone/postcss.config.mjs +0 -7
- package/packages/web/.next/standalone/test-results/.last-run.json +0 -4
- package/packages/web/.next/standalone/tsconfig.json +0 -34
- package/packages/web/.next/standalone/tsconfig.tsbuildinfo +0 -1
- package/packages/web/.next/standalone/types/index.ts +0 -74
- package/packages/web/.next/standalone/vitest.config.ts +0 -14
- package/packages/web/.next/static/chunks/4bbca8cd642026de.css +0 -3
- package/packages/web/.next/static/chunks/54e2bd8f072e7d4e.js +0 -1
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { ConfigTreeNode } from '@/types';
|
|
2
|
-
|
|
3
|
-
export class ConfigParser {
|
|
4
|
-
static flattenConfig(
|
|
5
|
-
obj: any,
|
|
6
|
-
prefix: string = ''
|
|
7
|
-
): Record<string, any> {
|
|
8
|
-
const result: Record<string, any> = {};
|
|
9
|
-
|
|
10
|
-
for (const key in obj) {
|
|
11
|
-
const fullPath = prefix ? `${prefix}:${key}` : key;
|
|
12
|
-
const value = obj[key];
|
|
13
|
-
|
|
14
|
-
if (value && typeof value === 'object') {
|
|
15
|
-
if (Array.isArray(value)) {
|
|
16
|
-
// 配列の場合:オブジェクト要素があれば展開
|
|
17
|
-
const hasObjectElements = value.some(
|
|
18
|
-
item => item && typeof item === 'object' && !Array.isArray(item)
|
|
19
|
-
);
|
|
20
|
-
if (hasObjectElements) {
|
|
21
|
-
value.forEach((item, index) => {
|
|
22
|
-
if (item && typeof item === 'object' && !Array.isArray(item)) {
|
|
23
|
-
Object.assign(result, this.flattenConfig(item, `${fullPath}[${index}]`));
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
// プリミティブ配列はそのまま
|
|
28
|
-
result[fullPath] = value;
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
// オブジェクトの場合(既存ロジック)
|
|
32
|
-
Object.assign(result, this.flattenConfig(value, fullPath));
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
result[fullPath] = value;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return result;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* オブジェクト型のプロパティも含めた全パスを取得
|
|
44
|
-
* (親オブジェクト、配列、末端の値すべて)
|
|
45
|
-
*/
|
|
46
|
-
static getAllPropertyPaths(
|
|
47
|
-
obj: any,
|
|
48
|
-
prefix: string = ''
|
|
49
|
-
): string[] {
|
|
50
|
-
const paths: string[] = [];
|
|
51
|
-
|
|
52
|
-
for (const key in obj) {
|
|
53
|
-
const fullPath = prefix ? `${prefix}:${key}` : key;
|
|
54
|
-
const value = obj[key];
|
|
55
|
-
|
|
56
|
-
// すべてのパスを追加(オブジェクトも含む)
|
|
57
|
-
paths.push(fullPath);
|
|
58
|
-
|
|
59
|
-
if (value && typeof value === 'object') {
|
|
60
|
-
if (Array.isArray(value)) {
|
|
61
|
-
// 配列の場合:オブジェクト要素があれば展開
|
|
62
|
-
const hasObjectElements = value.some(
|
|
63
|
-
item => item && typeof item === 'object' && !Array.isArray(item)
|
|
64
|
-
);
|
|
65
|
-
if (hasObjectElements) {
|
|
66
|
-
value.forEach((item, index) => {
|
|
67
|
-
if (item && typeof item === 'object' && !Array.isArray(item)) {
|
|
68
|
-
// 配列インデックスのパスを追加
|
|
69
|
-
const indexPath = `${fullPath}[${index}]`;
|
|
70
|
-
paths.push(indexPath);
|
|
71
|
-
// 再帰的に子要素のパスを追加
|
|
72
|
-
paths.push(...this.getAllPropertyPaths(item, indexPath));
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
// オブジェクトの場合:再帰的に子要素のパスを追加
|
|
78
|
-
paths.push(...this.getAllPropertyPaths(value, fullPath));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return paths;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
static buildTree(obj: any, prefix: string = ''): ConfigTreeNode[] {
|
|
87
|
-
const nodes: ConfigTreeNode[] = [];
|
|
88
|
-
|
|
89
|
-
for (const key in obj) {
|
|
90
|
-
const fullPath = prefix ? `${prefix}:${key}` : key;
|
|
91
|
-
const value = obj[key];
|
|
92
|
-
|
|
93
|
-
if (value && typeof value === 'object') {
|
|
94
|
-
if (Array.isArray(value)) {
|
|
95
|
-
// 配列の場合:オブジェクト要素があれば展開
|
|
96
|
-
const hasObjectElements = value.some(
|
|
97
|
-
item => item && typeof item === 'object' && !Array.isArray(item)
|
|
98
|
-
);
|
|
99
|
-
if (hasObjectElements) {
|
|
100
|
-
const children: ConfigTreeNode[] = [];
|
|
101
|
-
value.forEach((item, index) => {
|
|
102
|
-
if (item && typeof item === 'object' && !Array.isArray(item)) {
|
|
103
|
-
children.push({
|
|
104
|
-
key: `[${index}]`,
|
|
105
|
-
fullPath: `${fullPath}[${index}]`,
|
|
106
|
-
value: item,
|
|
107
|
-
children: this.buildTree(item, `${fullPath}[${index}]`),
|
|
108
|
-
hasDocumentation: false,
|
|
109
|
-
type: 'object'
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
nodes.push({
|
|
114
|
-
key,
|
|
115
|
-
fullPath,
|
|
116
|
-
value,
|
|
117
|
-
children: children.length > 0 ? children : undefined,
|
|
118
|
-
hasDocumentation: false,
|
|
119
|
-
type: 'array'
|
|
120
|
-
});
|
|
121
|
-
} else {
|
|
122
|
-
// プリミティブ配列は展開しない
|
|
123
|
-
nodes.push({
|
|
124
|
-
key,
|
|
125
|
-
fullPath,
|
|
126
|
-
value,
|
|
127
|
-
hasDocumentation: false,
|
|
128
|
-
type: 'array'
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
// オブジェクトの場合(既存ロジック)
|
|
133
|
-
nodes.push({
|
|
134
|
-
key,
|
|
135
|
-
fullPath,
|
|
136
|
-
value,
|
|
137
|
-
children: this.buildTree(value, fullPath),
|
|
138
|
-
hasDocumentation: false,
|
|
139
|
-
type: 'object'
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
nodes.push({
|
|
144
|
-
key,
|
|
145
|
-
fullPath,
|
|
146
|
-
value,
|
|
147
|
-
hasDocumentation: false,
|
|
148
|
-
type: typeof value as any
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return nodes;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import fs from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { ProjectConfigFiles, ConfigDocs, FileSystemItem, ProjectSettings } from '@/types';
|
|
4
|
-
import { parseJSON } from './jsonUtils';
|
|
5
|
-
|
|
6
|
-
export class FileSystemService {
|
|
7
|
-
private configDocDir = '.config_doc';
|
|
8
|
-
private rootPath: string;
|
|
9
|
-
|
|
10
|
-
constructor(rootPath: string) {
|
|
11
|
-
this.rootPath = rootPath;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async ensureConfigDocDir(): Promise<void> {
|
|
15
|
-
const dirPath = path.join(this.rootPath, this.configDocDir);
|
|
16
|
-
const metadataDir = path.join(dirPath, 'metadata');
|
|
17
|
-
const docsDir = path.join(metadataDir, 'docs');
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
await fs.access(dirPath);
|
|
21
|
-
} catch {
|
|
22
|
-
await fs.mkdir(dirPath, { recursive: true });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// metadata/docsフォルダを作成
|
|
26
|
-
await fs.mkdir(docsDir, { recursive: true });
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 新しいプロジェクト設定の読み込み
|
|
30
|
-
async loadProjectSettings(): Promise<ProjectSettings | null> {
|
|
31
|
-
const settingsPath = path.join(
|
|
32
|
-
this.rootPath,
|
|
33
|
-
this.configDocDir,
|
|
34
|
-
'project_settings.json'
|
|
35
|
-
);
|
|
36
|
-
try {
|
|
37
|
-
const content = await fs.readFile(settingsPath, 'utf-8');
|
|
38
|
-
return parseJSON(content);
|
|
39
|
-
} catch {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// 新しいプロジェクト設定の保存
|
|
45
|
-
async saveProjectSettings(settings: ProjectSettings): Promise<void> {
|
|
46
|
-
await this.ensureConfigDocDir();
|
|
47
|
-
const settingsPath = path.join(
|
|
48
|
-
this.rootPath,
|
|
49
|
-
this.configDocDir,
|
|
50
|
-
'project_settings.json'
|
|
51
|
-
);
|
|
52
|
-
await fs.writeFile(
|
|
53
|
-
settingsPath,
|
|
54
|
-
JSON.stringify(settings, null, 2),
|
|
55
|
-
'utf-8'
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 旧形式のconfig_files.jsonの読み込み(マイグレーション用)
|
|
60
|
-
async loadConfigFiles(): Promise<ProjectConfigFiles | null> {
|
|
61
|
-
const configFilesPath = path.join(
|
|
62
|
-
this.rootPath,
|
|
63
|
-
this.configDocDir,
|
|
64
|
-
'metadata',
|
|
65
|
-
'config_files.json'
|
|
66
|
-
);
|
|
67
|
-
try {
|
|
68
|
-
const content = await fs.readFile(configFilesPath, 'utf-8');
|
|
69
|
-
return parseJSON(content);
|
|
70
|
-
} catch {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async saveConfigFiles(configFiles: ProjectConfigFiles): Promise<void> {
|
|
76
|
-
// ディレクトリが存在することを確認
|
|
77
|
-
await this.ensureConfigDocDir();
|
|
78
|
-
|
|
79
|
-
const metadataPath = path.join(
|
|
80
|
-
this.rootPath,
|
|
81
|
-
this.configDocDir,
|
|
82
|
-
'metadata',
|
|
83
|
-
'config_files.json'
|
|
84
|
-
);
|
|
85
|
-
await fs.writeFile(
|
|
86
|
-
metadataPath,
|
|
87
|
-
JSON.stringify(configFiles, null, 2),
|
|
88
|
-
'utf-8'
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
async loadConfigFile(filePath: string): Promise<any> {
|
|
93
|
-
// 絶対パスか相対パスかを判定
|
|
94
|
-
const isAbsolute = path.isAbsolute(filePath);
|
|
95
|
-
const fullPath = isAbsolute ? path.normalize(filePath) : path.join(this.rootPath, filePath);
|
|
96
|
-
const content = await fs.readFile(fullPath, 'utf-8');
|
|
97
|
-
return parseJSON(content);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async loadConfigDocs(docsFileName: string): Promise<ConfigDocs | null> {
|
|
101
|
-
const docsPath = path.join(
|
|
102
|
-
this.rootPath,
|
|
103
|
-
this.configDocDir,
|
|
104
|
-
'metadata',
|
|
105
|
-
'docs',
|
|
106
|
-
docsFileName
|
|
107
|
-
);
|
|
108
|
-
try {
|
|
109
|
-
const content = await fs.readFile(docsPath, 'utf-8');
|
|
110
|
-
return parseJSON(content);
|
|
111
|
-
} catch {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async saveConfigDocs(
|
|
117
|
-
docsFileName: string,
|
|
118
|
-
docs: ConfigDocs
|
|
119
|
-
): Promise<void> {
|
|
120
|
-
// ディレクトリが存在することを確認
|
|
121
|
-
await this.ensureConfigDocDir();
|
|
122
|
-
|
|
123
|
-
const docsPath = path.join(
|
|
124
|
-
this.rootPath,
|
|
125
|
-
this.configDocDir,
|
|
126
|
-
'metadata',
|
|
127
|
-
'docs',
|
|
128
|
-
docsFileName
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
// ファイルの親ディレクトリを確保(サブディレクトリ対応)
|
|
132
|
-
const docsDir = path.dirname(docsPath);
|
|
133
|
-
await fs.mkdir(docsDir, { recursive: true });
|
|
134
|
-
|
|
135
|
-
await fs.writeFile(
|
|
136
|
-
docsPath,
|
|
137
|
-
JSON.stringify(docs, null, 2),
|
|
138
|
-
'utf-8'
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async browseDirectory(dirPath: string): Promise<FileSystemItem[]> {
|
|
143
|
-
// バックスラッシュをスラッシュに正規化(クロスプラットフォーム対応)
|
|
144
|
-
const normalizedDirPath = dirPath.replace(/\\/g, '/');
|
|
145
|
-
// 絶対パスか相対パスかを判定
|
|
146
|
-
const isAbsolute = path.isAbsolute(normalizedDirPath);
|
|
147
|
-
const fullPath = isAbsolute ? path.normalize(normalizedDirPath) : path.join(this.rootPath, normalizedDirPath);
|
|
148
|
-
|
|
149
|
-
const entries = await fs.readdir(fullPath, { withFileTypes: true });
|
|
150
|
-
|
|
151
|
-
return entries
|
|
152
|
-
.map(entry => {
|
|
153
|
-
// 絶対パスとして返す
|
|
154
|
-
const absolutePath = path.join(fullPath, entry.name);
|
|
155
|
-
return {
|
|
156
|
-
name: entry.name,
|
|
157
|
-
path: absolutePath,
|
|
158
|
-
type: entry.isDirectory() ? 'directory' as const : 'file' as const,
|
|
159
|
-
extension: entry.isFile() ? path.extname(entry.name) : undefined
|
|
160
|
-
};
|
|
161
|
-
})
|
|
162
|
-
.sort((a, b) => {
|
|
163
|
-
// ディレクトリを先に表示
|
|
164
|
-
if (a.type !== b.type) {
|
|
165
|
-
return a.type === 'directory' ? -1 : 1;
|
|
166
|
-
}
|
|
167
|
-
return a.name.localeCompare(b.name);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async deleteConfigDocs(docsFileName: string): Promise<void> {
|
|
172
|
-
const docsPath = path.join(
|
|
173
|
-
this.rootPath,
|
|
174
|
-
this.configDocDir,
|
|
175
|
-
'metadata',
|
|
176
|
-
'docs',
|
|
177
|
-
docsFileName
|
|
178
|
-
);
|
|
179
|
-
try {
|
|
180
|
-
await fs.unlink(docsPath);
|
|
181
|
-
} catch {
|
|
182
|
-
// ファイルが存在しない場合は無視
|
|
183
|
-
console.log(`Docs file not found: ${docsFileName}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import os from 'os';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* E2Eテスト用の一時ディレクトリパスを取得します。
|
|
7
|
-
* global-setup.tsで作成されたパスファイルから読み込みます。
|
|
8
|
-
*/
|
|
9
|
-
function getE2ETestDir(): string | null {
|
|
10
|
-
try {
|
|
11
|
-
const pathFile = path.join(os.tmpdir(), '.config-doc-test-dir');
|
|
12
|
-
if (fs.existsSync(pathFile)) {
|
|
13
|
-
const testDir = fs.readFileSync(pathFile, 'utf-8').trim();
|
|
14
|
-
if (testDir && fs.existsSync(testDir)) {
|
|
15
|
-
return testDir;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
} catch {
|
|
19
|
-
// ファイル読み込みエラーは無視
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* ユーザーの作業ディレクトリを取得します。
|
|
26
|
-
* E2Eテスト環境では一時ディレクトリを使用し、
|
|
27
|
-
* CLIから起動された場合は環境変数USER_WORKING_DIRを使用し、
|
|
28
|
-
* 直接Next.jsを起動した場合は親ディレクトリを使用します。
|
|
29
|
-
*/
|
|
30
|
-
export function getRootPath(): string {
|
|
31
|
-
// E2Eテスト環境の場合(一時ディレクトリを使用)
|
|
32
|
-
const e2eTestDir = getE2ETestDir();
|
|
33
|
-
if (e2eTestDir) {
|
|
34
|
-
return e2eTestDir;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// CLIから起動された場合、環境変数が設定されている
|
|
38
|
-
if (process.env.USER_WORKING_DIR) {
|
|
39
|
-
return process.env.USER_WORKING_DIR;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// 開発環境で直接Next.jsを起動した場合
|
|
43
|
-
// packages/web から 2つ上の階層に移動
|
|
44
|
-
return path.join(process.cwd(), '..', '..');
|
|
45
|
-
}
|