Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM mcr.microsoft.com/devcontainers/base:2.0-ubuntu-24.04

# Build arguments
ARG CLAUDE_CODE_OAUTH_TOKEN

Check warning on line 4 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Trivy Container Scan

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "CLAUDE_CODE_OAUTH_TOKEN") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 4 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Generate SBOM

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "CLAUDE_CODE_OAUTH_TOKEN") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ARG ANTHROPIC_API_KEY

Check warning on line 5 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Trivy Container Scan

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "ANTHROPIC_API_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 5 in .devcontainer/Dockerfile

View workflow job for this annotation

GitHub Actions / Generate SBOM

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "ANTHROPIC_API_KEY") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
ARG IMAGE_VERSION="dev"

# OCI Image Labels for version tracking
Expand Down Expand Up @@ -66,7 +66,7 @@
&& rm node-${NODE_VERSION}-linux-${NODE_ARCH}.tar.xz \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs

RUN npm install -g pnpm
RUN npm install -g pnpm@10.30.3

USER vscode
ENV SHELL=/bin/bash
Expand Down
16 changes: 16 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# pnpm security settings
# Strict peer dependency resolution - fail on conflicts
strict-peer-dependencies=true

# Auto-install missing peer dependencies
auto-install-peers=true

# Run security audit on install
audit=true
audit-level=moderate

# Prevent phantom dependencies (packages hoisting to root node_modules)
shamefully-hoist=false

# Use content-addressable storage (pnpm default - integrity verification)
verify-store-integrity=true
47 changes: 47 additions & 0 deletions docs/setup/npm-library-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,53 @@ pnpm exec lint-staged
- **ベースイメージ**: `ghcr.io/keito4/config-base:latest`
- **冗長 Features の削除**: ベースイメージに含まれるもの(node, gh 等)は更新後に削除を検討

## pnpm セキュリティ設定(supply chain attack 対策)

pnpm を使用する場合は以下を必ず設定する。

**`pnpm-workspace.yaml`**:

```yaml
# 公開から 2 日未満のパッケージをインストール禁止(pnpm v10.16.0+)
minimumReleaseAge: 2880
```

**`.npmrc`**:

```ini
strict-peer-dependencies=true
auto-install-peers=true
audit=true
audit-level=moderate
shamefully-hoist=false
verify-store-integrity=true
```

## ni(パッケージマネージャーコマンド統一)

`@antfu/ni` はロックファイルを検出し、プロジェクトのパッケージマネージャーを自動判定してコマンドを実行するツール。npm / pnpm / yarn / bun どのプロジェクトでも同じコマンドが使える。

```bash
npm install -g @antfu/ni
```

| コマンド | 相当する操作 |
| ------------- | --------------------------------------- |
| `ni` | 依存関係インストール |
| `nr <script>` | スクリプト実行 |
| `nu` | パッケージ更新 |
| `nun` | パッケージ削除 |
| `nci` | クリーンインストール(lockfile frozen) |

**推奨エイリアス** (`~/.zshrc`):

```zsh
alias nrd="nr dev"
alias nrb="nr build"
alias nrs="nr start"
alias nrp="nr preview"
```

## 関連ドキュメント

| ドキュメント | 説明 |
Expand Down
47 changes: 47 additions & 0 deletions docs/setup/spa-react-vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,53 @@ module.exports = {

- **ベースイメージ**: `ghcr.io/keito4/config-base:latest`

## pnpm セキュリティ設定(supply chain attack 対策)

pnpm を使用する場合は以下を必ず設定する。

**`pnpm-workspace.yaml`**:

```yaml
# 公開から 2 日未満のパッケージをインストール禁止(pnpm v10.16.0+)
minimumReleaseAge: 2880
```

**`.npmrc`**:

```ini
strict-peer-dependencies=true
auto-install-peers=true
audit=true
audit-level=moderate
shamefully-hoist=false
verify-store-integrity=true
```

## ni(パッケージマネージャーコマンド統一)

`@antfu/ni` はロックファイルを検出し、プロジェクトのパッケージマネージャーを自動判定してコマンドを実行するツール。npm / pnpm / yarn / bun どのプロジェクトでも同じコマンドが使える。

```bash
npm install -g @antfu/ni
```

| コマンド | 相当する操作 |
| ------------- | --------------------------------------- |
| `ni` | 依存関係インストール |
| `nr <script>` | スクリプト実行 |
| `nu` | パッケージ更新 |
| `nun` | パッケージ削除 |
| `nci` | クリーンインストール(lockfile frozen) |

**推奨エイリアス** (`~/.zshrc`):

```zsh
alias nrd="nr dev"
alias nrb="nr build"
alias nrs="nr start"
alias nrp="nr preview"
```

## 関連ドキュメント

| ドキュメント | 説明 |
Expand Down
63 changes: 63 additions & 0 deletions docs/setup/web-app-nextjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,69 @@ export default function RootLayout({ children }: { children: React.ReactNode })
- 例外・エラーは Sentry に `captureException` してアラートを受け取る
- `console.log` の本番利用は禁止 → Biome の `noConsole` ルールで CI がブロック

## pnpm セキュリティ設定(supply chain attack 対策)

pnpm v10.16.0+ のネイティブ機能で、公開直後の悪意あるパッケージのインストールを防ぐ。

### pnpm-workspace.yaml

プロジェクトルートに配置する。**pnpm を使用するすべてのプロジェクトで必須設定**。

```yaml
# supply chain attack 対策: 公開から 2 日未満のパッケージをインストール禁止
# pnpm v10.16.0+ でサポート(単位: 分)
minimumReleaseAge: 2880

# 信頼できるパッケージを除外する場合(例: 公式パッケージで更新頻度が高いもの)
minimumReleaseAgeExclude: []
```

> **動作**: `pnpm add` や `pnpm update` で依存解決する際に適用。
> `pnpm-lock.yaml` が存在する `pnpm install` では環境再現性優先のためスキップされる。

### .npmrc(pnpm セキュリティ強化)

```ini
# Strict peer dependency resolution
strict-peer-dependencies=true
auto-install-peers=true

# インストール時に脆弱性チェック
audit=true
audit-level=moderate

# Phantom dependencies の排除
shamefully-hoist=false

# コンテンツハッシュで改ざん検知
verify-store-integrity=true
```

## ni(パッケージマネージャーコマンド統一)

`@antfu/ni` はロックファイルを検出し、プロジェクトのパッケージマネージャーを自動判定してコマンドを実行するツール。npm / pnpm / yarn / bun どのプロジェクトでも同じコマンドが使える。

```bash
npm install -g @antfu/ni
```

| コマンド | 相当する操作 |
| ------------- | --------------------------------------- |
| `ni` | 依存関係インストール |
| `nr <script>` | スクリプト実行 |
| `nu` | パッケージ更新 |
| `nun` | パッケージ削除 |
| `nci` | クリーンインストール(lockfile frozen) |

**推奨エイリアス** (`~/.zshrc`):

```zsh
alias nrd="nr dev"
alias nrb="nr build"
alias nrs="nr start"
alias nrp="nr preview"
```

## 関連ドキュメント

| ドキュメント | 説明 |
Expand Down
8 changes: 7 additions & 1 deletion dot/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# pnpm end# Added by Windsurf
# pnpm end

# ni - package manager command unifier (@antfu/ni)
alias nrd="nr dev"
alias nrb="nr build"
alias nrs="nr start"
alias nrp="nr preview"# Added by Windsurf

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fix malformed nrp alias line in zshrc

The nrp alias line appends # Added by Windsurf directly after the closing quote, so # is parsed as part of the argument (not a comment) and the trailing words are treated as extra alias operands when the file is sourced. This leaves nrp mapped incorrectly (e.g. ending with #) and can emit startup errors, so the new shortcut does not reliably work.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cat -n dot/.zshrc | sed -n '125,140p'

Repository: keito4/config

Length of output: 594


🏁 Script executed:

# Test shell alias parsing with and without space before inline comment
bash -c 'alias nrp="nr preview"# Added by Windsurf 2>/dev/null; alias nrp' 2>&1 || true
echo "---"
bash -c 'alias nrp2="nr preview" # Added by Windsurf 2>/dev/null; alias nrp2' 2>&1 || true

Repository: keito4/config

Length of output: 84


🏁 Script executed:

# Verify the exact patterns mentioned in the review
rg -nP '^\s*alias\s+nrp="nr preview"#' dot/.zshrc dot/.zshrc.devcontainer 2>/dev/null || echo "No matches found"
echo "---"
rg -nP '^\s*alias\s+nr[dbsp]=' dot/.zshrc dot/.zshrc.devcontainer 2>/dev/null | head -20

Repository: keito4/config

Length of output: 472


Fix inline comment spacing in alias definition.

Line 132 has alias nrp="nr preview"# where the # is included in the alias value instead of starting a comment. Add a space before # so the comment is properly parsed.

Suggested fix
-alias nrp="nr preview"# Added by Windsurf
+alias nrp="nr preview" # Added by Windsurf

This causes the alias to expand to nr preview# instead of nr preview, making it non-functional.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
alias nrp="nr preview"# Added by Windsurf
alias nrp="nr preview" # Added by Windsurf
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dot/.zshrc` at line 132, The alias definition alias nrp="nr preview"# Added
by Windsurf includes the # inside the quoted value; update the alias nrp
declaration so the comment is separated (e.g., add a space before the # or move
the comment after a space) so the alias value is exactly "nr preview" and the
trailing comment (Added by Windsurf) is parsed as a comment rather than part of
the alias.

export PATH="$HOME/.codeium/windsurf/bin:$PATH"

### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT)
Expand Down
8 changes: 7 additions & 1 deletion dot/.zshrc.devcontainer
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ setopt COMPLETE_IN_WORD
setopt NO_BEEP

# Set default editor
export EDITOR='vim'
export EDITOR='vim'

# ni - package manager command unifier (@antfu/ni)
alias nrd="nr dev"
alias nrb="nr build"
alias nrs="nr start"
alias nrp="nr preview"
Comment on lines +91 to +95

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Aliases look correct; add trailing newline for POSIX compliance.

The ni aliases are properly defined. However, the file is missing a trailing newline at the end (Line 95), which can cause issues with POSIX tools and some editors.

🔧 Add trailing newline
 # ni - package manager command unifier (`@antfu/ni`)
 alias nrd="nr dev"
 alias nrb="nr build"
 alias nrs="nr start"
 alias nrp="nr preview"
+
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# ni - package manager command unifier (@antfu/ni)
alias nrd="nr dev"
alias nrb="nr build"
alias nrs="nr start"
alias nrp="nr preview"
# ni - package manager command unifier (`@antfu/ni`)
alias nrd="nr dev"
alias nrb="nr build"
alias nrs="nr start"
alias nrp="nr preview"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dot/.zshrc.devcontainer` around lines 91 - 95, The file ends without a
trailing newline; add a single newline character at EOF so the last alias line
(e.g., the aliases nrd, nrb, nrs, nrp defined with "alias nrd=\"nr dev\"" etc.)
is terminated by a newline to satisfy POSIX compliance and editors—simply ensure
the file's last byte is a newline character.

4 changes: 4 additions & 0 deletions npm/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
"version": "0.34.6",
"overridden": false
},
"@antfu/ni": {
"version": "28.2.0",
"overridden": false
Comment on lines +56 to +58

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Install @antfu/ni where global CLIs are provisioned

Adding @antfu/ni to npm/global.json alone does not make nr available in fresh DevContainer/Codespaces setups, because provisioning still uses hardcoded package allowlists (.devcontainer/Dockerfile global install block and script/install-npm-globals.sh PACKAGES) that do not include this package. The newly added nrd/nrb/nrs/nrp aliases therefore point to a command that is missing by default.

Useful? React with 👍 / 👎.

},
"difit": {
"version": "3.1.12",
"overridden": false
Expand Down
10 changes: 10 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# pnpm workspace configuration
# https://pnpm.io/pnpm-workspace_yaml

# supply chain attack 対策: 公開から 2 日未満のパッケージをインストール禁止
# pnpm v10.16.0+ でサポート
# 単位: 分(2880 = 2 days)
minimumReleaseAge: 2880

# 除外パッケージ(公式・信頼できるリリースサイクルが速いもの)
minimumReleaseAgeExclude: []
Comment on lines +1 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

pnpm-workspace.yaml packages field required mandatory

💡 Result:

  • Conceptually (per docs): pnpm-workspace.yaml is the workspace manifest; if you do provide packages, it’s used to include/exclude workspace packages, and if you don’t specify it, pnpm considers “all packages in all subdirectories” included by default. So from a configuration standpoint, packages is not inherently mandatory. [1]

  • In practice (pnpm v10 bug/regression): some pnpm v10.x versions would throw ERROR packages field missing or empty if a pnpm-workspace.yaml existed without a packages array (even if you only wanted other settings like onlyBuiltDependencies). This is documented in pnpm issues. [2]

  • Fix: pnpm merged a change to allow packages to be optional in the workspace manifest, and downstream release notes indicate this landed by pnpm 10.8.1 (“The packages field in pnpm-workspace.yaml became optional”). [3][4]

What to do

  • If you’re seeing packages field missing or empty, upgrade pnpm (≥ 10.8.1), or add a packages: list (even a broad one), or remove pnpm-workspace.yaml if you don’t need it.

Sources
[1] https://cuyl.github.io/pnpm.github.io/pnpm-workspace_yaml/
[2] pnpm/pnpm#9361
[3] pnpm/pnpm#8969
[4] https://build.opensuse.org/projects/openSUSE%3AFactory/packages/pnpm/files/pnpm.changes?expand=1


🌐 Web query:

pnpm minimumReleaseAge configuration pnpm-workspace.yaml .npmrc

💡 Result:

minimumReleaseAge (and minimumReleaseAgeExclude) is configured in the root pnpm-workspace.yaml of a workspace (monorepo). pnpm’s docs state this setting works only when placed in a pnpm-workspace.yaml located at the workspace root—not in per-package .npmrc files. [1]

Example (pnpm-workspace.yaml at repo root):

packages:
  - "packages/*"

minimumReleaseAge: 1440 # minutes (24h)

minimumReleaseAgeExclude:
  - react
  - webpack
  - "@myorg/*"

Sources: pnpm settings documentation (workspace file) describing minimumReleaseAge, minimumReleaseAgeExclude, and the “root pnpm-workspace.yaml only” constraint. [1]

References
[1] (pnpm.cn)

Citations:


🌐 Web query:

pnpm workspace configuration yaml single package repository

💡 Result:

If your repo has only one package (the root package.json), you usually don’t need pnpm workspaces at all—just use pnpm normally (package.json + pnpm-lock.yaml). Workspaces are mainly for multi-package repos. [1]

If you still want a pnpm-workspace.yaml (e.g., to keep pnpm-only settings in one place), put it in the repo root. pnpm uses it as a configuration source, and (importantly) the root package is always included as a workspace package even when you customize package globs. [2][3]

Minimal “single-package repo” pnpm-workspace.yaml

packages: []

Typical monorepo-style example (for reference)

packages:
  - "packages/**"
  - "apps/**"
  - "!**/test/**"

[3]

Notes

  • packages: uses glob patterns to include/exclude workspace package folders. [3]
  • pnpm-workspace.yaml can also hold various pnpm settings (not just packages). [2]

Sources: [1] [2] [3]


Remove suggestion to move minimumReleaseAge to .npmrc—it must remain in pnpm-workspace.yaml.

The minimumReleaseAge setting is correctly placed and configured. However, the packages field is only mandatory for pnpm versions before 10.8.1; in pnpm ≥ 10.8.1, it is optional. For compatibility with older pnpm versions or for clarity, consider adding packages: [] to explicitly define this as a single-package workspace. Note that minimumReleaseAge cannot be configured in .npmrc—it must remain in the workspace-level pnpm-workspace.yaml.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pnpm-workspace.yaml` around lines 1 - 10, The review suggests removing or
moving minimumReleaseAge, but the minimumReleaseAge setting must remain in
pnpm-workspace.yaml (it cannot live in .npmrc); update the file to keep
minimumReleaseAge: 2880 and minimumReleaseAgeExclude: [] as-is and optionally
add packages: [] to explicitly mark a single-package workspace for compatibility
with pnpm < 10.8.1; do not move minimumReleaseAge to .npmrc and ensure the
symbols minimumReleaseAge, minimumReleaseAgeExclude, and packages appear in the
workspace file.

Loading