@d-zero/check-frontend-env 5.0.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.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # @d-zero/check-frontend-env
2
+
3
+ Check Frontend Environment for D-ZERO
4
+
5
+ フロントエンド開発環境のチェックツールです。Node.js、npm、yarn、Husky、Voltaのインストール状況とバージョンを確認できます。
6
+
7
+ ## Usage
8
+
9
+ ```bash
10
+ # 環境チェックを実行
11
+ npx @d-zero/check-frontend-env
12
+ ```
13
+
14
+ 実行すると、以下の情報が表示されます:
15
+
16
+ - **Husky設定**: v8(`.huskyrc`ファイル)とv9(`.config/husky/init.sh`ファイル)の両方のバージョンの設定ファイルを確認 <!-- cspell:disable-line -->
17
+ - **Node.js**: 現在のバージョンを表示
18
+ - **npm**: 現在のバージョンを表示
19
+ - **yarn**: インストールされている場合のバージョンを表示
20
+ - **Volta**: インストール状況、バージョン、実行ファイルの場所を確認
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env node
2
+ import { execSync } from 'node:child_process';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ /**
7
+ * Husky設定をチェックする
8
+ */
9
+ function checkHuskyConfig() {
10
+ const homeDir = os.homedir();
11
+ const v9Path = path.join(homeDir, '.config', 'husky', 'init.sh');
12
+ const v8Path = path.join(homeDir, '.huskyrc'); // cspell:disable-line
13
+ return {
14
+ v8Present: fs.existsSync(v8Path),
15
+ v9Present: fs.existsSync(v9Path),
16
+ paths: [v8Path, v9Path].filter((p) => fs.existsSync(p)),
17
+ };
18
+ }
19
+ /**
20
+ * 各ソフトウェアのバージョンを取得する
21
+ */
22
+ function getVersions() {
23
+ const versions = {
24
+ node: process.version,
25
+ npm: execSync('npm --version').toString().trim(),
26
+ };
27
+ try {
28
+ versions.yarn = execSync('yarn --version').toString().trim();
29
+ }
30
+ catch {
31
+ // yarn is not installed
32
+ }
33
+ return versions;
34
+ }
35
+ /**
36
+ * Voltaのインストール状況をチェックする
37
+ */
38
+ function checkVolta() {
39
+ const homeDir = os.homedir();
40
+ const platform = os.platform();
41
+ const isWindows = platform === 'win32';
42
+ const executableName = isWindows ? 'volta.exe' : 'volta';
43
+ // OS固有の標準的なインストール場所
44
+ const possiblePaths = isWindows
45
+ ? [
46
+ // Windows: %LOCALAPPDATA%\Volta\volta.exe
47
+ ...(process.env.LOCALAPPDATA
48
+ ? [path.join(process.env.LOCALAPPDATA, 'Volta', executableName)]
49
+ : []),
50
+ // Windows: %USERPROFILE%\.volta\bin\volta.exe
51
+ path.join(homeDir, '.volta', 'bin', executableName),
52
+ ]
53
+ : [
54
+ // Unix系: /usr/local/bin/volta (Homebrewなどでグローバルインストール)
55
+ '/usr/local/bin/volta',
56
+ // Unix系: ~/.volta/bin/volta (標準的なインストール場所)
57
+ path.join(homeDir, '.volta', 'bin', 'volta'),
58
+ ];
59
+ // PATHからvoltaを探す
60
+ try {
61
+ let commandOutput;
62
+ if (isWindows) {
63
+ // Windows: whereコマンドを使用
64
+ commandOutput = execSync('where volta', {
65
+ encoding: 'utf8',
66
+ stdio: ['ignore', 'pipe', 'ignore'],
67
+ })
68
+ .toString()
69
+ .trim();
70
+ }
71
+ else {
72
+ // Unix系: whichコマンドを使用
73
+ commandOutput = execSync('which volta', {
74
+ encoding: 'utf8',
75
+ stdio: ['ignore', 'pipe', 'ignore'],
76
+ })
77
+ .toString()
78
+ .trim();
79
+ }
80
+ // 複数行の結果がある場合(Windowsのwhereは複数のパスを返すことがある)
81
+ const paths = commandOutput
82
+ .split('\n')
83
+ .map((p) => p.trim())
84
+ .filter((p) => p.length > 0);
85
+ for (const foundPath of paths) {
86
+ if (!possiblePaths.includes(foundPath)) {
87
+ possiblePaths.push(foundPath);
88
+ }
89
+ }
90
+ }
91
+ catch {
92
+ // which/whereコマンドが失敗した場合は無視
93
+ }
94
+ // Voltaのホームディレクトリ
95
+ const voltaHome = process.env.VOLTA_HOME || path.join(homeDir, '.volta');
96
+ for (const voltaPath of possiblePaths) {
97
+ if (fs.existsSync(voltaPath)) {
98
+ try {
99
+ // Windowsでは実行ファイルパスをクォートする必要がある場合がある
100
+ const command = isWindows ? `"${voltaPath}" --version` : `${voltaPath} --version`;
101
+ const version = execSync(command, {
102
+ encoding: 'utf8',
103
+ stdio: ['ignore', 'pipe', 'ignore'],
104
+ })
105
+ .toString()
106
+ .trim();
107
+ return {
108
+ present: true,
109
+ version,
110
+ path: voltaPath,
111
+ homeDir: voltaHome,
112
+ };
113
+ }
114
+ catch {
115
+ // 実行権限がない場合など
116
+ continue;
117
+ }
118
+ }
119
+ }
120
+ return {
121
+ present: false,
122
+ homeDir: voltaHome,
123
+ };
124
+ }
125
+ /**
126
+ * メイン処理
127
+ */
128
+ function main() {
129
+ const info = {
130
+ huskyConfig: checkHuskyConfig(),
131
+ versions: getVersions(),
132
+ volta: checkVolta(),
133
+ };
134
+ const stdout = [
135
+ '環境チェック結果:',
136
+ '-------------------------',
137
+ 'Husky設定:',
138
+ ` v8 (.huskyrc): ${info.huskyConfig.v8Present ? '✅' : '❌'}`, // cspell:disable-line
139
+ ` v9 (.config/husky/init.sh): ${info.huskyConfig.v9Present ? '✅' : '❌'}`,
140
+ ...(info.huskyConfig.paths.length > 0
141
+ ? [' 発見場所:', ...info.huskyConfig.paths.map((p) => ` - ${p}`)]
142
+ : []),
143
+ '',
144
+ '各バージョン:',
145
+ ` Node.js: ${info.versions.node}`,
146
+ ` npm: ${info.versions.npm}`,
147
+ ...(info.versions.yarn ? [` yarn: ${info.versions.yarn}`] : []),
148
+ '',
149
+ 'Volta:',
150
+ ` インストール: ${info.volta.present ? '✅' : '❌'}`,
151
+ ...(info.volta.version ? [` バージョン: ${info.volta.version}`] : []),
152
+ ...(info.volta.path ? [` 実行ファイル: ${info.volta.path}`] : []),
153
+ ` ホームディレクトリ: ${info.volta.homeDir}`,
154
+ ];
155
+ process.stdout.write(stdout.join('\n'));
156
+ }
157
+ main();
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@d-zero/check-frontend-env",
3
+ "version": "5.0.0",
4
+ "description": "Check Frontend Environment for D-ZERO",
5
+ "repository": "https://github.com/d-zero-dev/frontend-env.git",
6
+ "author": "D-ZERO Co., Ltd.",
7
+ "license": "MIT",
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "type": "module",
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "bin": "./dist/index.js",
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/index.js",
18
+ "types": "./dist/index.d.ts"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "build": "tsc --project tsconfig.build.json",
23
+ "dev": "tsc --watch --project tsconfig.build.json",
24
+ "test": "vitest",
25
+ "test:run": "vitest run"
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "gitHead": "d5be73bc1f2fbfb85eea684d6b4807323a8999ff"
31
+ }