Compare commits
2 Commits
dev
...
201-enforc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9dd9f9d79f | ||
|
|
1746eb5570 |
@ -1,53 +0,0 @@
|
||||
---
|
||||
name: speckit-git-commit
|
||||
description: Auto-commit changes after a Spec Kit command completes
|
||||
compatibility: Requires spec-kit project structure with .specify/ directory
|
||||
metadata:
|
||||
author: github-spec-kit
|
||||
source: git:commands/speckit.git.commit.md
|
||||
---
|
||||
|
||||
# Auto-Commit Changes
|
||||
|
||||
Automatically stage and commit all changes after a Spec Kit command completes.
|
||||
|
||||
## Behavior
|
||||
|
||||
This command is invoked as a hook after (or before) core commands. It:
|
||||
|
||||
1. Determines the event name from the hook context (e.g., if invoked as an `after_specify` hook, the event is `after_specify`; if `before_plan`, the event is `before_plan`)
|
||||
2. Checks `.specify/extensions/git/git-config.yml` for the `auto_commit` section
|
||||
3. Looks up the specific event key to see if auto-commit is enabled
|
||||
4. Falls back to `auto_commit.default` if no event-specific key exists
|
||||
5. Uses the per-command `message` if configured, otherwise a default message
|
||||
6. If enabled and there are uncommitted changes, runs `git add .` + `git commit`
|
||||
|
||||
## Execution
|
||||
|
||||
Determine the event name from the hook that triggered this command, then run the script:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/auto-commit.sh <event_name>`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/auto-commit.ps1 <event_name>`
|
||||
|
||||
Replace `<event_name>` with the actual hook event (e.g., `after_specify`, `before_plan`, `after_implement`).
|
||||
|
||||
## Configuration
|
||||
|
||||
In `.specify/extensions/git/git-config.yml`:
|
||||
|
||||
```yaml
|
||||
auto_commit:
|
||||
default: false # Global toggle — set true to enable for all commands
|
||||
after_specify:
|
||||
enabled: true # Override per-command
|
||||
message: "[Spec Kit] Add specification"
|
||||
after_plan:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add implementation plan"
|
||||
```
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
- If Git is not available or the current directory is not a repository: skips with a warning
|
||||
- If no config file exists: skips (disabled by default)
|
||||
- If no changes to commit: skips with a message
|
||||
@ -1,72 +0,0 @@
|
||||
---
|
||||
name: speckit-git-feature
|
||||
description: Create a feature branch with sequential or timestamp numbering
|
||||
compatibility: Requires spec-kit project structure with .specify/ directory
|
||||
metadata:
|
||||
author: github-spec-kit
|
||||
source: git:commands/speckit.git.feature.md
|
||||
---
|
||||
|
||||
# Create Feature Branch
|
||||
|
||||
Create and switch to a new git feature branch for the given specification. This command handles **branch creation only** — the spec directory and files are created by the core `/speckit.specify` workflow.
|
||||
|
||||
## User Input
|
||||
|
||||
```text
|
||||
$ARGUMENTS
|
||||
```
|
||||
|
||||
You **MUST** consider the user input before proceeding (if not empty).
|
||||
|
||||
## Environment Variable Override
|
||||
|
||||
If the user explicitly provided `GIT_BRANCH_NAME` (e.g., via environment variable, argument, or in their request), pass it through to the script by setting the `GIT_BRANCH_NAME` environment variable before invoking the script. When `GIT_BRANCH_NAME` is set:
|
||||
- The script uses the exact value as the branch name, bypassing all prefix/suffix generation
|
||||
- `--short-name`, `--number`, and `--timestamp` flags are ignored
|
||||
- `FEATURE_NUM` is extracted from the name if it starts with a numeric prefix, otherwise set to the full branch name
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Verify Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, warn the user and skip branch creation
|
||||
|
||||
## Branch Numbering Mode
|
||||
|
||||
Determine the branch numbering strategy by checking configuration in this order:
|
||||
|
||||
1. Check `.specify/extensions/git/git-config.yml` for `branch_numbering` value
|
||||
2. Check `.specify/init-options.json` for `branch_numbering` value (backward compatibility)
|
||||
3. Default to `sequential` if neither exists
|
||||
|
||||
## Execution
|
||||
|
||||
Generate a concise short name (2-4 words) for the branch:
|
||||
- Analyze the feature description and extract the most meaningful keywords
|
||||
- Use action-noun format when possible (e.g., "add-user-auth", "fix-payment-bug")
|
||||
- Preserve technical terms and acronyms (OAuth2, API, JWT, etc.)
|
||||
|
||||
Run the appropriate script based on your platform:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --short-name "<short-name>" "<feature description>"`
|
||||
- **Bash (timestamp)**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --timestamp --short-name "<short-name>" "<feature description>"`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -ShortName "<short-name>" "<feature description>"`
|
||||
- **PowerShell (timestamp)**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -Timestamp -ShortName "<short-name>" "<feature description>"`
|
||||
|
||||
**IMPORTANT**:
|
||||
- Do NOT pass `--number` — the script determines the correct next number automatically
|
||||
- Always include the JSON flag (`--json` for Bash, `-Json` for PowerShell) so the output can be parsed reliably
|
||||
- You must only ever run this script once per feature
|
||||
- The JSON output will contain `BRANCH_NAME` and `FEATURE_NUM`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed or the current directory is not a Git repository:
|
||||
- Branch creation is skipped with a warning: `[specify] Warning: Git repository not detected; skipped branch creation`
|
||||
- The script still outputs `BRANCH_NAME` and `FEATURE_NUM` so the caller can reference them
|
||||
|
||||
## Output
|
||||
|
||||
The script outputs JSON with:
|
||||
- `BRANCH_NAME`: The branch name (e.g., `003-user-auth` or `20260319-143022-user-auth`)
|
||||
- `FEATURE_NUM`: The numeric or timestamp prefix used
|
||||
@ -1,54 +0,0 @@
|
||||
---
|
||||
name: speckit-git-initialize
|
||||
description: Initialize a Git repository with an initial commit
|
||||
compatibility: Requires spec-kit project structure with .specify/ directory
|
||||
metadata:
|
||||
author: github-spec-kit
|
||||
source: git:commands/speckit.git.initialize.md
|
||||
---
|
||||
|
||||
# Initialize Git Repository
|
||||
|
||||
Initialize a Git repository in the current project directory if one does not already exist.
|
||||
|
||||
## Execution
|
||||
|
||||
Run the appropriate script from the project root:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/initialize-repo.sh`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/initialize-repo.ps1`
|
||||
|
||||
If the extension scripts are not found, fall back to:
|
||||
- **Bash**: `git init && git add . && git commit -m "Initial commit from Specify template"`
|
||||
- **PowerShell**: `git init; git add .; git commit -m "Initial commit from Specify template"`
|
||||
|
||||
The script handles all checks internally:
|
||||
- Skips if Git is not available
|
||||
- Skips if already inside a Git repository
|
||||
- Runs `git init`, `git add .`, and `git commit` with an initial commit message
|
||||
|
||||
## Customization
|
||||
|
||||
Replace the script to add project-specific Git initialization steps:
|
||||
- Custom `.gitignore` templates
|
||||
- Default branch naming (`git config init.defaultBranch`)
|
||||
- Git LFS setup
|
||||
- Git hooks installation
|
||||
- Commit signing configuration
|
||||
- Git Flow initialization
|
||||
|
||||
## Output
|
||||
|
||||
On success:
|
||||
- `✓ Git repository initialized`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed:
|
||||
- Warn the user
|
||||
- Skip repository initialization
|
||||
- The project continues to function without Git (specs can still be created under `specs/`)
|
||||
|
||||
If Git is installed but `git init`, `git add .`, or `git commit` fails:
|
||||
- Surface the error to the user
|
||||
- Stop this command rather than continuing with a partially initialized repository
|
||||
@ -1,50 +0,0 @@
|
||||
---
|
||||
name: speckit-git-remote
|
||||
description: Detect Git remote URL for GitHub integration
|
||||
compatibility: Requires spec-kit project structure with .specify/ directory
|
||||
metadata:
|
||||
author: github-spec-kit
|
||||
source: git:commands/speckit.git.remote.md
|
||||
---
|
||||
|
||||
# Detect Git Remote URL
|
||||
|
||||
Detect the Git remote URL for integration with GitHub services (e.g., issue creation).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Check if Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, output a warning and return empty:
|
||||
```
|
||||
[specify] Warning: Git repository not detected; cannot determine remote URL
|
||||
```
|
||||
|
||||
## Execution
|
||||
|
||||
Run the following command to get the remote URL:
|
||||
|
||||
```bash
|
||||
git config --get remote.origin.url
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Parse the remote URL and determine:
|
||||
|
||||
1. **Repository owner**: Extract from the URL (e.g., `github` from `https://github.com/github/spec-kit.git`)
|
||||
2. **Repository name**: Extract from the URL (e.g., `spec-kit` from `https://github.com/github/spec-kit.git`)
|
||||
3. **Is GitHub**: Whether the remote points to a GitHub repository
|
||||
|
||||
Supported URL formats:
|
||||
- HTTPS: `https://github.com/<owner>/<repo>.git`
|
||||
- SSH: `git@github.com:<owner>/<repo>.git`
|
||||
|
||||
> [!CAUTION]
|
||||
> ONLY report a GitHub repository if the remote URL actually points to github.com.
|
||||
> Do NOT assume the remote is GitHub if the URL format doesn't match.
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed, the directory is not a Git repository, or no remote is configured:
|
||||
- Return an empty result
|
||||
- Do NOT error — other workflows should continue without Git remote information
|
||||
@ -1,54 +0,0 @@
|
||||
---
|
||||
name: speckit-git-validate
|
||||
description: Validate current branch follows feature branch naming conventions
|
||||
compatibility: Requires spec-kit project structure with .specify/ directory
|
||||
metadata:
|
||||
author: github-spec-kit
|
||||
source: git:commands/speckit.git.validate.md
|
||||
---
|
||||
|
||||
# Validate Feature Branch
|
||||
|
||||
Validate that the current Git branch follows the expected feature branch naming conventions.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Check if Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, output a warning and skip validation:
|
||||
```
|
||||
[specify] Warning: Git repository not detected; skipped branch validation
|
||||
```
|
||||
|
||||
## Validation Rules
|
||||
|
||||
Get the current branch name:
|
||||
|
||||
```bash
|
||||
git rev-parse --abbrev-ref HEAD
|
||||
```
|
||||
|
||||
The branch name must match one of these patterns:
|
||||
|
||||
1. **Sequential**: `^[0-9]{3,}-` (e.g., `001-feature-name`, `042-fix-bug`, `1000-big-feature`)
|
||||
2. **Timestamp**: `^[0-9]{8}-[0-9]{6}-` (e.g., `20260319-143022-feature-name`)
|
||||
|
||||
## Execution
|
||||
|
||||
If on a feature branch (matches either pattern):
|
||||
- Output: `✓ On feature branch: <branch-name>`
|
||||
- Check if the corresponding spec directory exists under `specs/`:
|
||||
- For sequential branches, look for `specs/<prefix>-*` where prefix matches the numeric portion
|
||||
- For timestamp branches, look for `specs/<prefix>-*` where prefix matches the `YYYYMMDD-HHMMSS` portion
|
||||
- If spec directory exists: `✓ Spec directory found: <path>`
|
||||
- If spec directory missing: `⚠ No spec directory found for prefix <prefix>`
|
||||
|
||||
If NOT on a feature branch:
|
||||
- Output: `✗ Not on a feature branch. Current branch: <branch-name>`
|
||||
- Output: `Feature branches should be named like: 001-feature-name or 20260319-143022-feature-name`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed or the directory is not a Git repository:
|
||||
- Check the `SPECIFY_FEATURE` environment variable as a fallback
|
||||
- If set, validate that value against the naming patterns
|
||||
- If not set, skip validation with a warning
|
||||
@ -1,50 +0,0 @@
|
||||
description = "Auto-commit changes after a Spec Kit command completes"
|
||||
|
||||
# Source: git
|
||||
|
||||
prompt = """
|
||||
# Auto-Commit Changes
|
||||
|
||||
Automatically stage and commit all changes after a Spec Kit command completes.
|
||||
|
||||
## Behavior
|
||||
|
||||
This command is invoked as a hook after (or before) core commands. It:
|
||||
|
||||
1. Determines the event name from the hook context (e.g., if invoked as an `after_specify` hook, the event is `after_specify`; if `before_plan`, the event is `before_plan`)
|
||||
2. Checks `.specify/extensions/git/git-config.yml` for the `auto_commit` section
|
||||
3. Looks up the specific event key to see if auto-commit is enabled
|
||||
4. Falls back to `auto_commit.default` if no event-specific key exists
|
||||
5. Uses the per-command `message` if configured, otherwise a default message
|
||||
6. If enabled and there are uncommitted changes, runs `git add .` + `git commit`
|
||||
|
||||
## Execution
|
||||
|
||||
Determine the event name from the hook that triggered this command, then run the script:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/auto-commit.sh <event_name>`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/auto-commit.ps1 <event_name>`
|
||||
|
||||
Replace `<event_name>` with the actual hook event (e.g., `after_specify`, `before_plan`, `after_implement`).
|
||||
|
||||
## Configuration
|
||||
|
||||
In `.specify/extensions/git/git-config.yml`:
|
||||
|
||||
```yaml
|
||||
auto_commit:
|
||||
default: false # Global toggle — set true to enable for all commands
|
||||
after_specify:
|
||||
enabled: true # Override per-command
|
||||
message: "[Spec Kit] Add specification"
|
||||
after_plan:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add implementation plan"
|
||||
```
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
- If Git is not available or the current directory is not a repository: skips with a warning
|
||||
- If no config file exists: skips (disabled by default)
|
||||
- If no changes to commit: skips with a message
|
||||
"""
|
||||
@ -1,69 +0,0 @@
|
||||
description = "Create a feature branch with sequential or timestamp numbering"
|
||||
|
||||
# Source: git
|
||||
|
||||
prompt = """
|
||||
# Create Feature Branch
|
||||
|
||||
Create and switch to a new git feature branch for the given specification. This command handles **branch creation only** — the spec directory and files are created by the core `/speckit.specify` workflow.
|
||||
|
||||
## User Input
|
||||
|
||||
```text
|
||||
{{args}}
|
||||
```
|
||||
|
||||
You **MUST** consider the user input before proceeding (if not empty).
|
||||
|
||||
## Environment Variable Override
|
||||
|
||||
If the user explicitly provided `GIT_BRANCH_NAME` (e.g., via environment variable, argument, or in their request), pass it through to the script by setting the `GIT_BRANCH_NAME` environment variable before invoking the script. When `GIT_BRANCH_NAME` is set:
|
||||
- The script uses the exact value as the branch name, bypassing all prefix/suffix generation
|
||||
- `--short-name`, `--number`, and `--timestamp` flags are ignored
|
||||
- `FEATURE_NUM` is extracted from the name if it starts with a numeric prefix, otherwise set to the full branch name
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Verify Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, warn the user and skip branch creation
|
||||
|
||||
## Branch Numbering Mode
|
||||
|
||||
Determine the branch numbering strategy by checking configuration in this order:
|
||||
|
||||
1. Check `.specify/extensions/git/git-config.yml` for `branch_numbering` value
|
||||
2. Check `.specify/init-options.json` for `branch_numbering` value (backward compatibility)
|
||||
3. Default to `sequential` if neither exists
|
||||
|
||||
## Execution
|
||||
|
||||
Generate a concise short name (2-4 words) for the branch:
|
||||
- Analyze the feature description and extract the most meaningful keywords
|
||||
- Use action-noun format when possible (e.g., "add-user-auth", "fix-payment-bug")
|
||||
- Preserve technical terms and acronyms (OAuth2, API, JWT, etc.)
|
||||
|
||||
Run the appropriate script based on your platform:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --short-name "<short-name>" "<feature description>"`
|
||||
- **Bash (timestamp)**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --timestamp --short-name "<short-name>" "<feature description>"`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -ShortName "<short-name>" "<feature description>"`
|
||||
- **PowerShell (timestamp)**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -Timestamp -ShortName "<short-name>" "<feature description>"`
|
||||
|
||||
**IMPORTANT**:
|
||||
- Do NOT pass `--number` — the script determines the correct next number automatically
|
||||
- Always include the JSON flag (`--json` for Bash, `-Json` for PowerShell) so the output can be parsed reliably
|
||||
- You must only ever run this script once per feature
|
||||
- The JSON output will contain `BRANCH_NAME` and `FEATURE_NUM`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed or the current directory is not a Git repository:
|
||||
- Branch creation is skipped with a warning: `[specify] Warning: Git repository not detected; skipped branch creation`
|
||||
- The script still outputs `BRANCH_NAME` and `FEATURE_NUM` so the caller can reference them
|
||||
|
||||
## Output
|
||||
|
||||
The script outputs JSON with:
|
||||
- `BRANCH_NAME`: The branch name (e.g., `003-user-auth` or `20260319-143022-user-auth`)
|
||||
- `FEATURE_NUM`: The numeric or timestamp prefix used
|
||||
"""
|
||||
@ -1,51 +0,0 @@
|
||||
description = "Initialize a Git repository with an initial commit"
|
||||
|
||||
# Source: git
|
||||
|
||||
prompt = """
|
||||
# Initialize Git Repository
|
||||
|
||||
Initialize a Git repository in the current project directory if one does not already exist.
|
||||
|
||||
## Execution
|
||||
|
||||
Run the appropriate script from the project root:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/initialize-repo.sh`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/initialize-repo.ps1`
|
||||
|
||||
If the extension scripts are not found, fall back to:
|
||||
- **Bash**: `git init && git add . && git commit -m "Initial commit from Specify template"`
|
||||
- **PowerShell**: `git init; git add .; git commit -m "Initial commit from Specify template"`
|
||||
|
||||
The script handles all checks internally:
|
||||
- Skips if Git is not available
|
||||
- Skips if already inside a Git repository
|
||||
- Runs `git init`, `git add .`, and `git commit` with an initial commit message
|
||||
|
||||
## Customization
|
||||
|
||||
Replace the script to add project-specific Git initialization steps:
|
||||
- Custom `.gitignore` templates
|
||||
- Default branch naming (`git config init.defaultBranch`)
|
||||
- Git LFS setup
|
||||
- Git hooks installation
|
||||
- Commit signing configuration
|
||||
- Git Flow initialization
|
||||
|
||||
## Output
|
||||
|
||||
On success:
|
||||
- `✓ Git repository initialized`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed:
|
||||
- Warn the user
|
||||
- Skip repository initialization
|
||||
- The project continues to function without Git (specs can still be created under `specs/`)
|
||||
|
||||
If Git is installed but `git init`, `git add .`, or `git commit` fails:
|
||||
- Surface the error to the user
|
||||
- Stop this command rather than continuing with a partially initialized repository
|
||||
"""
|
||||
@ -1,47 +0,0 @@
|
||||
description = "Detect Git remote URL for GitHub integration"
|
||||
|
||||
# Source: git
|
||||
|
||||
prompt = """
|
||||
# Detect Git Remote URL
|
||||
|
||||
Detect the Git remote URL for integration with GitHub services (e.g., issue creation).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Check if Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, output a warning and return empty:
|
||||
```
|
||||
[specify] Warning: Git repository not detected; cannot determine remote URL
|
||||
```
|
||||
|
||||
## Execution
|
||||
|
||||
Run the following command to get the remote URL:
|
||||
|
||||
```bash
|
||||
git config --get remote.origin.url
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Parse the remote URL and determine:
|
||||
|
||||
1. **Repository owner**: Extract from the URL (e.g., `github` from `https://github.com/github/spec-kit.git`)
|
||||
2. **Repository name**: Extract from the URL (e.g., `spec-kit` from `https://github.com/github/spec-kit.git`)
|
||||
3. **Is GitHub**: Whether the remote points to a GitHub repository
|
||||
|
||||
Supported URL formats:
|
||||
- HTTPS: `https://github.com/<owner>/<repo>.git`
|
||||
- SSH: `git@github.com:<owner>/<repo>.git`
|
||||
|
||||
> [!CAUTION]
|
||||
> ONLY report a GitHub repository if the remote URL actually points to github.com.
|
||||
> Do NOT assume the remote is GitHub if the URL format doesn't match.
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed, the directory is not a Git repository, or no remote is configured:
|
||||
- Return an empty result
|
||||
- Do NOT error — other workflows should continue without Git remote information
|
||||
"""
|
||||
@ -1,51 +0,0 @@
|
||||
description = "Validate current branch follows feature branch naming conventions"
|
||||
|
||||
# Source: git
|
||||
|
||||
prompt = """
|
||||
# Validate Feature Branch
|
||||
|
||||
Validate that the current Git branch follows the expected feature branch naming conventions.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Check if Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, output a warning and skip validation:
|
||||
```
|
||||
[specify] Warning: Git repository not detected; skipped branch validation
|
||||
```
|
||||
|
||||
## Validation Rules
|
||||
|
||||
Get the current branch name:
|
||||
|
||||
```bash
|
||||
git rev-parse --abbrev-ref HEAD
|
||||
```
|
||||
|
||||
The branch name must match one of these patterns:
|
||||
|
||||
1. **Sequential**: `^[0-9]{3,}-` (e.g., `001-feature-name`, `042-fix-bug`, `1000-big-feature`)
|
||||
2. **Timestamp**: `^[0-9]{8}-[0-9]{6}-` (e.g., `20260319-143022-feature-name`)
|
||||
|
||||
## Execution
|
||||
|
||||
If on a feature branch (matches either pattern):
|
||||
- Output: `✓ On feature branch: <branch-name>`
|
||||
- Check if the corresponding spec directory exists under `specs/`:
|
||||
- For sequential branches, look for `specs/<prefix>-*` where prefix matches the numeric portion
|
||||
- For timestamp branches, look for `specs/<prefix>-*` where prefix matches the `YYYYMMDD-HHMMSS` portion
|
||||
- If spec directory exists: `✓ Spec directory found: <path>`
|
||||
- If spec directory missing: `⚠ No spec directory found for prefix <prefix>`
|
||||
|
||||
If NOT on a feature branch:
|
||||
- Output: `✗ Not on a feature branch. Current branch: <branch-name>`
|
||||
- Output: `Feature branches should be named like: 001-feature-name or 20260319-143022-feature-name`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed or the directory is not a Git repository:
|
||||
- Check the `SPECIFY_FEATURE` environment variable as a fallback
|
||||
- If set, validate that value against the naming patterns
|
||||
- If not set, skip validation with a warning
|
||||
"""
|
||||
48
.github/agents/copilot-instructions.md
vendored
48
.github/agents/copilot-instructions.md
vendored
@ -208,38 +208,8 @@ ## Active Technologies
|
||||
- Markdown governance artifacts in a PHP 8.4.15 / Laravel 12 / Filament v5 / Livewire v4 repository + `.specify/memory/constitution.md`, `docs/ui/operator-ux-surface-standards.md`, adjacent Specs 196 through 199, existing UI rule IDs `UI-SURF-001`, `ACTSURF-001`, `UI-HARD-001`, `UI-EX-001`, `UI-FIL-001`, `DECIDE-001`, and `UX-001` (200-filament-surface-rules)
|
||||
- Astro 6.0.0 templates + TypeScript 5.x (explicit setup in `apps/website`) + Astro 6, Tailwind CSS v4, custom Astro component primitives (shadcn-inspired), lightweight Playwright browser smoke tests (213-website-foundation-v0)
|
||||
- Static filesystem content, styles, and assets under `apps/website/src` and `apps/website/public`; no database (213-website-foundation-v0)
|
||||
- Astro 6.0.0 templates + TypeScript 5.9 strict + Astro 6, Tailwind CSS v4 via `@tailwindcss/vite`, Astro content collections, local Astro component primitives, Playwright browser smoke tests (214-website-visual-foundation)
|
||||
- Static filesystem content, styles, assets, and content collections under `apps/website/src` and `apps/website/public`; no database (214-website-visual-foundation)
|
||||
- Markdown governance artifacts, JSON Schema plus logical OpenAPI planning contracts, and Bash-backed SpecKit scripts inside a PHP 8.4.15 / Laravel 12 / Filament v5 / Livewire v4 repository + `.specify/memory/constitution.md`, `.specify/templates/spec-template.md`, `.specify/templates/plan-template.md`, `.specify/templates/tasks-template.md`, `.specify/templates/checklist-template.md`, `.specify/README.md`, `docs/ui/operator-ux-surface-standards.md`, and Specs 196 through 200 (201-enforcement-review-guardrails)
|
||||
- Repository-owned markdown and contract artifacts under `.specify/` and `/Users/ahmeddarrazi/Documents/projects/wt-plattform/specs/201-enforcement-review-guardrails/`; no product database persistence (201-enforcement-review-guardrails)
|
||||
- PHP 8.4.15, Laravel 12, Filament v5, Livewire v4, Blade + Filament v5, Livewire v4, Pest v4, Laravel Sail, `ArtifactTruthPresenter`, `ArtifactTruthEnvelope`, `OperatorExplanationBuilder`, `BaselineSnapshotPresenter`, `BadgeCatalog`, `BadgeRenderer`, existing governance Filament resources/pages, and current Enterprise Detail builders (214-governance-outcome-compression)
|
||||
- PostgreSQL via existing `baseline_snapshots`, `evidence_snapshots`, `evidence_snapshot_items`, `tenant_reviews`, `review_packs`, and `operation_runs` tables; no schema change planned (214-governance-outcome-compression)
|
||||
- Astro 6.0.0 templates + TypeScript 5.9 strict + Astro 6, Tailwind CSS v4 via `@tailwindcss/vite`, Astro content collections, local Astro layout/primitive/content helpers, Playwright smoke tests (215-website-core-pages)
|
||||
- Static filesystem pages, content modules, and Astro content collections under `apps/website/src` and `apps/website/public`; no database (215-website-core-pages)
|
||||
- PHP 8.4.15, Laravel 12, Filament v5, Livewire v4 + Filament Resources/Pages/Actions, Livewire 4, Pest 4, `ProviderOperationStartGate`, `ProviderOperationRegistry`, `ProviderConnectionResolver`, `OperationRunService`, `ProviderNextStepsRegistry`, `ReasonPresenter`, `OperationUxPresenter`, `OperationRunLinks` (216-provider-dispatch-gate)
|
||||
- PostgreSQL via existing `operation_runs`, `provider_connections`, `managed_tenant_onboarding_sessions`, `restore_runs`, and tenant-owned runtime records; no new tables planned (216-provider-dispatch-gate)
|
||||
- Astro 6.0.0 templates + TypeScript 5.9.x + Astro 6, Tailwind CSS v4, local Astro layout/section primitives, Astro content collections, Playwright browser smoke tests (217-homepage-structure)
|
||||
- Static filesystem content, Astro content collections, and assets under `apps/website/src` and `apps/website/public`; no database (217-homepage-structure)
|
||||
- Astro 6.0.0 templates + TypeScript 5.9.x + Astro 6, Tailwind CSS v4, existing Astro content modules and section primitives, Playwright browser smoke tests (218-homepage-hero)
|
||||
- Static filesystem content and assets under `apps/website/src` and `apps/website/public`; no database (218-homepage-hero)
|
||||
- PHP 8.4.15 / Laravel 12 + Filament v5, Livewire v4.0+, Pest v4, Tailwind CSS v4 (219-finding-ownership-semantics)
|
||||
- PostgreSQL via Sail; existing `findings.owner_user_id`, `findings.assignee_user_id`, and `finding_exceptions.owner_user_id` fields; no schema changes planned (219-finding-ownership-semantics)
|
||||
- PHP 8.4.15, Laravel 12, Filament v5, Livewire v4, Blade + Filament v5, Livewire v4, Pest v4, Laravel Sail, `TenantlessOperationRunViewer`, `OperationRunResource`, `ArtifactTruthPresenter`, `OperatorExplanationBuilder`, `ReasonPresenter`, `OperationUxPresenter`, `SummaryCountsNormalizer`, and the existing enterprise-detail builders (220-governance-run-summaries)
|
||||
- PostgreSQL via existing `operation_runs` plus related `baseline_snapshots`, `evidence_snapshots`, `tenant_reviews`, and `review_packs`; no schema changes planned (220-governance-run-summaries)
|
||||
- PHP 8.4.15, Laravel 12, Filament v5, Livewire v4, Blade + Filament admin panel pages, `Finding`, `FindingResource`, `WorkspaceOverviewBuilder`, `WorkspaceContext`, `WorkspaceCapabilityResolver`, `CapabilityResolver`, `CanonicalAdminTenantFilterState`, and `CanonicalNavigationContext` (221-findings-operator-inbox)
|
||||
- PostgreSQL via existing `findings`, `tenants`, `tenant_memberships`, and workspace context session state; no schema changes planned (221-findings-operator-inbox)
|
||||
- PHP 8.4.15, Laravel 12, Filament v5, Livewire v4, Blade + Filament admin pages/tables/actions/notifications, `Finding`, `FindingResource`, `FindingWorkflowService`, `FindingPolicy`, `CapabilityResolver`, `CanonicalAdminTenantFilterState`, `CanonicalNavigationContext`, `WorkspaceContext`, and `UiEnforcement` (222-findings-intake-team-queue)
|
||||
- PostgreSQL via existing `findings`, `tenants`, `tenant_memberships`, `audit_logs`, and workspace session context; no schema changes planned (222-findings-intake-team-queue)
|
||||
- TypeScript 5.9, Astro 6, Node.js 20+ + Astro, astro-icon, Tailwind CSS v4, Playwright 1.59 (223-astrodeck-website-rebuild)
|
||||
- File-based route files, Astro content collections under `src/content`, public assets, and planning documents under `specs/223-astrodeck-website-rebuild`; no database (223-astrodeck-website-rebuild)
|
||||
- PHP 8.4.15, Laravel 12, Filament v5, Livewire v4, Blade + Laravel notifications (`database` channel), Filament database notifications, `Finding`, `FindingWorkflowService`, `FindingSlaPolicy`, `AlertRule`, `AlertDelivery`, `AlertDispatchService`, `EvaluateAlertsJob`, `CapabilityResolver`, `WorkspaceContext`, `TenantMembership`, `FindingResource` (224-findings-notifications-escalation)
|
||||
- PostgreSQL via existing `findings`, `alert_rules`, `alert_deliveries`, `notifications`, `tenant_memberships`, and `audit_logs`; no schema changes planned (224-findings-notifications-escalation)
|
||||
- PHP 8.4.15, Laravel 12, Filament v5, Livewire v4, Blade + `Finding`, `FindingResource`, `MyFindingsInbox`, `FindingsIntakeQueue`, `WorkspaceOverviewBuilder`, `EnsureFilamentTenantSelected`, `FindingWorkflowService`, `AuditLog`, `TenantMembership`, Filament page and table primitives (225-assignment-hygiene)
|
||||
- PostgreSQL via existing `findings`, `audit_logs`, `tenant_memberships`, and `users`; no schema changes planned (225-assignment-hygiene)
|
||||
- Markdown artifacts + Astro 6.0.0 + TypeScript 5.9 context for source discovery + Repository spec workflow (`.specify`), Astro website source tree under `apps/website/src`, existing component taxonomy (`primitives`, `content`, `sections`, `layout`) (226-astrodeck-inventory-planning)
|
||||
- Filesystem only (`specs/226-astrodeck-inventory-planning/*`) (226-astrodeck-inventory-planning)
|
||||
- PHP 8.4.15, Laravel 12, Filament v5, Livewire v4, Blade + `App\Models\Finding`, `App\Filament\Resources\FindingResource`, `App\Services\Findings\FindingWorkflowService`, `App\Services\Baselines\BaselineAutoCloseService`, `App\Services\EntraAdminRoles\EntraAdminRolesFindingGenerator`, `App\Services\PermissionPosture\PermissionPostureFindingGenerator`, `App\Jobs\CompareBaselineToTenantJob`, `App\Filament\Pages\Reviews\ReviewRegister`, `App\Filament\Resources\TenantReviewResource`, `BadgeCatalog`, `BadgeRenderer`, `AuditLog` metadata via `AuditLogger` (231-finding-outcome-taxonomy)
|
||||
- PostgreSQL via existing `findings`, `finding_exceptions`, `tenant_reviews`, `stored_reports`, and audit-log tables; no schema changes planned (231-finding-outcome-taxonomy)
|
||||
|
||||
- PHP 8.4.15 (feat/005-bulk-operations)
|
||||
|
||||
@ -274,20 +244,8 @@ ## Code Style
|
||||
PHP 8.4.15: Follow standard conventions
|
||||
|
||||
## Recent Changes
|
||||
- 231-finding-outcome-taxonomy: Added PHP 8.4.15, Laravel 12, Filament v5, Livewire v4, Blade + `App\Models\Finding`, `App\Filament\Resources\FindingResource`, `App\Services\Findings\FindingWorkflowService`, `App\Services\Baselines\BaselineAutoCloseService`, `App\Services\EntraAdminRoles\EntraAdminRolesFindingGenerator`, `App\Services\PermissionPosture\PermissionPostureFindingGenerator`, `App\Jobs\CompareBaselineToTenantJob`, `App\Filament\Pages\Reviews\ReviewRegister`, `App\Filament\Resources\TenantReviewResource`, `BadgeCatalog`, `BadgeRenderer`, `AuditLog` metadata via `AuditLogger`
|
||||
- 226-astrodeck-inventory-planning: Added Markdown artifacts + Astro 6.0.0 + TypeScript 5.9 context for source discovery + Repository spec workflow (`.specify`), Astro website source tree under `apps/website/src`, existing component taxonomy (`primitives`, `content`, `sections`, `layout`)
|
||||
- 225-assignment-hygiene: Added PHP 8.4.15, Laravel 12, Filament v5, Livewire v4, Blade + `Finding`, `FindingResource`, `MyFindingsInbox`, `FindingsIntakeQueue`, `WorkspaceOverviewBuilder`, `EnsureFilamentTenantSelected`, `FindingWorkflowService`, `AuditLog`, `TenantMembership`, Filament page and table primitives
|
||||
- 201-enforcement-review-guardrails: Added Markdown governance artifacts, JSON Schema plus logical OpenAPI planning contracts, and Bash-backed SpecKit scripts inside a PHP 8.4.15 / Laravel 12 / Filament v5 / Livewire v4 repository + `.specify/memory/constitution.md`, `.specify/templates/spec-template.md`, `.specify/templates/plan-template.md`, `.specify/templates/tasks-template.md`, `.specify/templates/checklist-template.md`, `.specify/README.md`, `docs/ui/operator-ux-surface-standards.md`, and Specs 196 through 200
|
||||
- 213-website-foundation-v0: Added Astro 6.0.0 templates + TypeScript 5.x (explicit setup in `apps/website`) + Astro 6, Tailwind CSS v4, custom Astro component primitives (shadcn-inspired), lightweight Playwright browser smoke tests
|
||||
- 200-filament-surface-rules: Added Markdown governance artifacts in a PHP 8.4.15 / Laravel 12 / Filament v5 / Livewire v4 repository + `.specify/memory/constitution.md`, `docs/ui/operator-ux-surface-standards.md`, adjacent Specs 196 through 199, existing UI rule IDs `UI-SURF-001`, `ACTSURF-001`, `UI-HARD-001`, `UI-EX-001`, `UI-FIL-001`, `DECIDE-001`, and `UX-001`
|
||||
<!-- MANUAL ADDITIONS START -->
|
||||
|
||||
### Pre-production compatibility check
|
||||
|
||||
Before adding aliases, fallback readers, dual-write logic, migration shims, or legacy fixtures, verify all of the following:
|
||||
|
||||
1. Do live production data exist?
|
||||
2. Is shared staging migration-relevant?
|
||||
3. Does an external contract depend on the old shape?
|
||||
4. Does the spec explicitly require compatibility behavior?
|
||||
|
||||
If all answers are no, replace the old shape and remove the compatibility path.
|
||||
|
||||
<!-- MANUAL ADDITIONS END -->
|
||||
|
||||
51
.github/agents/speckit.git.commit.agent.md
vendored
51
.github/agents/speckit.git.commit.agent.md
vendored
@ -1,51 +0,0 @@
|
||||
---
|
||||
description: Auto-commit changes after a Spec Kit command completes
|
||||
---
|
||||
|
||||
|
||||
<!-- Extension: git -->
|
||||
<!-- Config: .specify/extensions/git/ -->
|
||||
# Auto-Commit Changes
|
||||
|
||||
Automatically stage and commit all changes after a Spec Kit command completes.
|
||||
|
||||
## Behavior
|
||||
|
||||
This command is invoked as a hook after (or before) core commands. It:
|
||||
|
||||
1. Determines the event name from the hook context (e.g., if invoked as an `after_specify` hook, the event is `after_specify`; if `before_plan`, the event is `before_plan`)
|
||||
2. Checks `.specify/extensions/git/git-config.yml` for the `auto_commit` section
|
||||
3. Looks up the specific event key to see if auto-commit is enabled
|
||||
4. Falls back to `auto_commit.default` if no event-specific key exists
|
||||
5. Uses the per-command `message` if configured, otherwise a default message
|
||||
6. If enabled and there are uncommitted changes, runs `git add .` + `git commit`
|
||||
|
||||
## Execution
|
||||
|
||||
Determine the event name from the hook that triggered this command, then run the script:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/auto-commit.sh <event_name>`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/auto-commit.ps1 <event_name>`
|
||||
|
||||
Replace `<event_name>` with the actual hook event (e.g., `after_specify`, `before_plan`, `after_implement`).
|
||||
|
||||
## Configuration
|
||||
|
||||
In `.specify/extensions/git/git-config.yml`:
|
||||
|
||||
```yaml
|
||||
auto_commit:
|
||||
default: false # Global toggle — set true to enable for all commands
|
||||
after_specify:
|
||||
enabled: true # Override per-command
|
||||
message: "[Spec Kit] Add specification"
|
||||
after_plan:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add implementation plan"
|
||||
```
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
- If Git is not available or the current directory is not a repository: skips with a warning
|
||||
- If no config file exists: skips (disabled by default)
|
||||
- If no changes to commit: skips with a message
|
||||
70
.github/agents/speckit.git.feature.agent.md
vendored
70
.github/agents/speckit.git.feature.agent.md
vendored
@ -1,70 +0,0 @@
|
||||
---
|
||||
description: Create a feature branch with sequential or timestamp numbering
|
||||
---
|
||||
|
||||
|
||||
<!-- Extension: git -->
|
||||
<!-- Config: .specify/extensions/git/ -->
|
||||
# Create Feature Branch
|
||||
|
||||
Create and switch to a new git feature branch for the given specification. This command handles **branch creation only** — the spec directory and files are created by the core `/speckit.specify` workflow.
|
||||
|
||||
## User Input
|
||||
|
||||
```text
|
||||
$ARGUMENTS
|
||||
```
|
||||
|
||||
You **MUST** consider the user input before proceeding (if not empty).
|
||||
|
||||
## Environment Variable Override
|
||||
|
||||
If the user explicitly provided `GIT_BRANCH_NAME` (e.g., via environment variable, argument, or in their request), pass it through to the script by setting the `GIT_BRANCH_NAME` environment variable before invoking the script. When `GIT_BRANCH_NAME` is set:
|
||||
- The script uses the exact value as the branch name, bypassing all prefix/suffix generation
|
||||
- `--short-name`, `--number`, and `--timestamp` flags are ignored
|
||||
- `FEATURE_NUM` is extracted from the name if it starts with a numeric prefix, otherwise set to the full branch name
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Verify Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, warn the user and skip branch creation
|
||||
|
||||
## Branch Numbering Mode
|
||||
|
||||
Determine the branch numbering strategy by checking configuration in this order:
|
||||
|
||||
1. Check `.specify/extensions/git/git-config.yml` for `branch_numbering` value
|
||||
2. Check `.specify/init-options.json` for `branch_numbering` value (backward compatibility)
|
||||
3. Default to `sequential` if neither exists
|
||||
|
||||
## Execution
|
||||
|
||||
Generate a concise short name (2-4 words) for the branch:
|
||||
- Analyze the feature description and extract the most meaningful keywords
|
||||
- Use action-noun format when possible (e.g., "add-user-auth", "fix-payment-bug")
|
||||
- Preserve technical terms and acronyms (OAuth2, API, JWT, etc.)
|
||||
|
||||
Run the appropriate script based on your platform:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --short-name "<short-name>" "<feature description>"`
|
||||
- **Bash (timestamp)**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --timestamp --short-name "<short-name>" "<feature description>"`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -ShortName "<short-name>" "<feature description>"`
|
||||
- **PowerShell (timestamp)**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -Timestamp -ShortName "<short-name>" "<feature description>"`
|
||||
|
||||
**IMPORTANT**:
|
||||
- Do NOT pass `--number` — the script determines the correct next number automatically
|
||||
- Always include the JSON flag (`--json` for Bash, `-Json` for PowerShell) so the output can be parsed reliably
|
||||
- You must only ever run this script once per feature
|
||||
- The JSON output will contain `BRANCH_NAME` and `FEATURE_NUM`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed or the current directory is not a Git repository:
|
||||
- Branch creation is skipped with a warning: `[specify] Warning: Git repository not detected; skipped branch creation`
|
||||
- The script still outputs `BRANCH_NAME` and `FEATURE_NUM` so the caller can reference them
|
||||
|
||||
## Output
|
||||
|
||||
The script outputs JSON with:
|
||||
- `BRANCH_NAME`: The branch name (e.g., `003-user-auth` or `20260319-143022-user-auth`)
|
||||
- `FEATURE_NUM`: The numeric or timestamp prefix used
|
||||
52
.github/agents/speckit.git.initialize.agent.md
vendored
52
.github/agents/speckit.git.initialize.agent.md
vendored
@ -1,52 +0,0 @@
|
||||
---
|
||||
description: Initialize a Git repository with an initial commit
|
||||
---
|
||||
|
||||
|
||||
<!-- Extension: git -->
|
||||
<!-- Config: .specify/extensions/git/ -->
|
||||
# Initialize Git Repository
|
||||
|
||||
Initialize a Git repository in the current project directory if one does not already exist.
|
||||
|
||||
## Execution
|
||||
|
||||
Run the appropriate script from the project root:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/initialize-repo.sh`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/initialize-repo.ps1`
|
||||
|
||||
If the extension scripts are not found, fall back to:
|
||||
- **Bash**: `git init && git add . && git commit -m "Initial commit from Specify template"`
|
||||
- **PowerShell**: `git init; git add .; git commit -m "Initial commit from Specify template"`
|
||||
|
||||
The script handles all checks internally:
|
||||
- Skips if Git is not available
|
||||
- Skips if already inside a Git repository
|
||||
- Runs `git init`, `git add .`, and `git commit` with an initial commit message
|
||||
|
||||
## Customization
|
||||
|
||||
Replace the script to add project-specific Git initialization steps:
|
||||
- Custom `.gitignore` templates
|
||||
- Default branch naming (`git config init.defaultBranch`)
|
||||
- Git LFS setup
|
||||
- Git hooks installation
|
||||
- Commit signing configuration
|
||||
- Git Flow initialization
|
||||
|
||||
## Output
|
||||
|
||||
On success:
|
||||
- `✓ Git repository initialized`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed:
|
||||
- Warn the user
|
||||
- Skip repository initialization
|
||||
- The project continues to function without Git (specs can still be created under `specs/`)
|
||||
|
||||
If Git is installed but `git init`, `git add .`, or `git commit` fails:
|
||||
- Surface the error to the user
|
||||
- Stop this command rather than continuing with a partially initialized repository
|
||||
48
.github/agents/speckit.git.remote.agent.md
vendored
48
.github/agents/speckit.git.remote.agent.md
vendored
@ -1,48 +0,0 @@
|
||||
---
|
||||
description: Detect Git remote URL for GitHub integration
|
||||
---
|
||||
|
||||
|
||||
<!-- Extension: git -->
|
||||
<!-- Config: .specify/extensions/git/ -->
|
||||
# Detect Git Remote URL
|
||||
|
||||
Detect the Git remote URL for integration with GitHub services (e.g., issue creation).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Check if Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, output a warning and return empty:
|
||||
```
|
||||
[specify] Warning: Git repository not detected; cannot determine remote URL
|
||||
```
|
||||
|
||||
## Execution
|
||||
|
||||
Run the following command to get the remote URL:
|
||||
|
||||
```bash
|
||||
git config --get remote.origin.url
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Parse the remote URL and determine:
|
||||
|
||||
1. **Repository owner**: Extract from the URL (e.g., `github` from `https://github.com/github/spec-kit.git`)
|
||||
2. **Repository name**: Extract from the URL (e.g., `spec-kit` from `https://github.com/github/spec-kit.git`)
|
||||
3. **Is GitHub**: Whether the remote points to a GitHub repository
|
||||
|
||||
Supported URL formats:
|
||||
- HTTPS: `https://github.com/<owner>/<repo>.git`
|
||||
- SSH: `git@github.com:<owner>/<repo>.git`
|
||||
|
||||
> [!CAUTION]
|
||||
> ONLY report a GitHub repository if the remote URL actually points to github.com.
|
||||
> Do NOT assume the remote is GitHub if the URL format doesn't match.
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed, the directory is not a Git repository, or no remote is configured:
|
||||
- Return an empty result
|
||||
- Do NOT error — other workflows should continue without Git remote information
|
||||
52
.github/agents/speckit.git.validate.agent.md
vendored
52
.github/agents/speckit.git.validate.agent.md
vendored
@ -1,52 +0,0 @@
|
||||
---
|
||||
description: Validate current branch follows feature branch naming conventions
|
||||
---
|
||||
|
||||
|
||||
<!-- Extension: git -->
|
||||
<!-- Config: .specify/extensions/git/ -->
|
||||
# Validate Feature Branch
|
||||
|
||||
Validate that the current Git branch follows the expected feature branch naming conventions.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Check if Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, output a warning and skip validation:
|
||||
```
|
||||
[specify] Warning: Git repository not detected; skipped branch validation
|
||||
```
|
||||
|
||||
## Validation Rules
|
||||
|
||||
Get the current branch name:
|
||||
|
||||
```bash
|
||||
git rev-parse --abbrev-ref HEAD
|
||||
```
|
||||
|
||||
The branch name must match one of these patterns:
|
||||
|
||||
1. **Sequential**: `^[0-9]{3,}-` (e.g., `001-feature-name`, `042-fix-bug`, `1000-big-feature`)
|
||||
2. **Timestamp**: `^[0-9]{8}-[0-9]{6}-` (e.g., `20260319-143022-feature-name`)
|
||||
|
||||
## Execution
|
||||
|
||||
If on a feature branch (matches either pattern):
|
||||
- Output: `✓ On feature branch: <branch-name>`
|
||||
- Check if the corresponding spec directory exists under `specs/`:
|
||||
- For sequential branches, look for `specs/<prefix>-*` where prefix matches the numeric portion
|
||||
- For timestamp branches, look for `specs/<prefix>-*` where prefix matches the `YYYYMMDD-HHMMSS` portion
|
||||
- If spec directory exists: `✓ Spec directory found: <path>`
|
||||
- If spec directory missing: `⚠ No spec directory found for prefix <prefix>`
|
||||
|
||||
If NOT on a feature branch:
|
||||
- Output: `✗ Not on a feature branch. Current branch: <branch-name>`
|
||||
- Output: `Feature branches should be named like: 001-feature-name or 20260319-143022-feature-name`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed or the directory is not a Git repository:
|
||||
- Check the `SPECIFY_FEATURE` environment variable as a fallback
|
||||
- If set, validate that value against the naming patterns
|
||||
- If not set, skip validation with a warning
|
||||
5
.github/copilot-instructions.md
vendored
5
.github/copilot-instructions.md
vendored
@ -673,8 +673,3 @@ ### Replaced Utilities
|
||||
| decoration-slice | box-decoration-slice |
|
||||
| decoration-clone | box-decoration-clone |
|
||||
</laravel-boost-guidelines>
|
||||
|
||||
<!-- SPECKIT START -->
|
||||
For additional context about technologies to be used, project structure,
|
||||
shell commands, and other important information, read the current plan
|
||||
<!-- SPECKIT END -->
|
||||
|
||||
3
.github/prompts/speckit.git.commit.prompt.md
vendored
3
.github/prompts/speckit.git.commit.prompt.md
vendored
@ -1,3 +0,0 @@
|
||||
---
|
||||
agent: speckit.git.commit
|
||||
---
|
||||
@ -1,3 +0,0 @@
|
||||
---
|
||||
agent: speckit.git.feature
|
||||
---
|
||||
@ -1,3 +0,0 @@
|
||||
---
|
||||
agent: speckit.git.initialize
|
||||
---
|
||||
3
.github/prompts/speckit.git.remote.prompt.md
vendored
3
.github/prompts/speckit.git.remote.prompt.md
vendored
@ -1,3 +0,0 @@
|
||||
---
|
||||
agent: speckit.git.remote
|
||||
---
|
||||
@ -1,3 +0,0 @@
|
||||
---
|
||||
agent: speckit.git.validate
|
||||
---
|
||||
295
.github/skills/browsertest/SKILL.md
vendored
295
.github/skills/browsertest/SKILL.md
vendored
@ -1,295 +0,0 @@
|
||||
---
|
||||
name: browsertest
|
||||
description: Führe einen vollständigen Smoke-Browser-Test im Integrated Browser für das aktuelle Feature aus, inklusive Happy Path, zentraler Regressionen, Kontext-Prüfung und belastbarer Ergebniszusammenfassung.
|
||||
license: MIT
|
||||
metadata:
|
||||
author: GitHub Copilot
|
||||
---
|
||||
|
||||
# Browser Smoke Test
|
||||
|
||||
## What This Skill Does
|
||||
|
||||
Use this skill to validate the current feature end-to-end in the integrated browser.
|
||||
|
||||
This is a focused smoke test, not a full exploratory test session. The goal is to prove that the primary operator flow:
|
||||
|
||||
- loads in the correct auth, workspace, and tenant context
|
||||
- exposes the expected controls and decision points
|
||||
- completes the main happy path without blocking issues
|
||||
- lands in the expected end state or canonical drilldown
|
||||
- does not show obvious regressions such as broken navigation, missing data, or conflicting actions
|
||||
|
||||
The skill should produce a concrete pass or fail result with actionable evidence.
|
||||
|
||||
## When To Apply
|
||||
|
||||
Activate this skill when:
|
||||
|
||||
- the user asks to smoke test the current feature in the browser
|
||||
- a new Filament page, dashboard signal, report, wizard, or detail flow was just added
|
||||
- a UI regression fix needs confirmation in a real browser context
|
||||
- the primary question is whether the feature works from an operator perspective
|
||||
- you need a quick integration-level check without writing a full browser test suite first
|
||||
|
||||
## What Success Looks Like
|
||||
|
||||
A successful smoke test confirms all of the following:
|
||||
|
||||
- the target route opens successfully
|
||||
- the visible context is correct
|
||||
- the main flow is usable
|
||||
- the expected result appears after interaction
|
||||
- the route or drilldown destination is correct
|
||||
- the surface does not obviously violate its intended interaction model
|
||||
|
||||
If the test cannot be completed, the output must clearly state whether the blocker is:
|
||||
|
||||
- authentication
|
||||
- missing data or fixture state
|
||||
- routing
|
||||
- UI interaction failure
|
||||
- server error
|
||||
- an unclear expected behavior contract
|
||||
|
||||
Do not guess. If the route or state is blocked, report the blocker explicitly.
|
||||
|
||||
## Preconditions
|
||||
|
||||
Before running the browser smoke test, make sure you know:
|
||||
|
||||
- the canonical route or entry point for the feature
|
||||
- the primary operator action or happy path
|
||||
- the expected success state
|
||||
- whether the feature depends on a specific tenant, workspace, or seeded record
|
||||
|
||||
When available, use the feature spec, quickstart, tasks, or current browser page as the source of truth.
|
||||
|
||||
## Standard Workflow
|
||||
|
||||
### 1. Define the smoke-test scope
|
||||
|
||||
Identify:
|
||||
|
||||
- the route to open
|
||||
- the primary action to perform
|
||||
- the expected end state
|
||||
- one or two critical regressions that must not break
|
||||
|
||||
The smoke test should stay narrow. Prefer one complete happy path plus one critical boundary over broad exploratory clicking.
|
||||
|
||||
### 2. Establish the browser state
|
||||
|
||||
- Reuse the current browser page if it already matches the target feature.
|
||||
- Otherwise open the canonical route.
|
||||
- Confirm the current auth and scope context before interacting.
|
||||
|
||||
For this repo, that usually means checking whether the page is on:
|
||||
|
||||
- `/admin/...` for workspace-context surfaces
|
||||
- `/admin/t/{tenant}/...` for tenant-context surfaces
|
||||
|
||||
### 3. Inspect before acting
|
||||
|
||||
- Use `read_page` before interacting so you understand the live controls, refs, headings, and route context.
|
||||
- Prefer `read_page` over screenshots for actual interaction planning.
|
||||
- Use screenshots only for visual evidence or when the user asks for them.
|
||||
|
||||
### 4. Execute the primary happy path
|
||||
|
||||
Run the smallest meaningful flow that proves the feature works.
|
||||
|
||||
Typical steps include:
|
||||
|
||||
- open the page
|
||||
- verify heading or key summary text
|
||||
- click the primary CTA or row
|
||||
- fill the minimum required form fields
|
||||
- confirm modal or dialog text when relevant
|
||||
- submit or navigate
|
||||
- verify the expected destination or changed state
|
||||
|
||||
After each meaningful action, re-read the page so the next step is based on current DOM state.
|
||||
|
||||
### 5. Validate the outcome
|
||||
|
||||
Check the exact result that matters for the feature.
|
||||
|
||||
Examples:
|
||||
|
||||
- a new row appears
|
||||
- a status changes
|
||||
- a success message appears
|
||||
- a report filter changes the result set
|
||||
- a row click lands on the canonical detail page
|
||||
- a dashboard signal links to the correct report page
|
||||
|
||||
### 6. Check for obvious regressions
|
||||
|
||||
Even in a smoke test, verify a few core non-negotiables:
|
||||
|
||||
- the page is not blank or half-rendered
|
||||
- the main action is present and usable
|
||||
- the visible context is correct
|
||||
- the drilldown destination is canonical
|
||||
- no obviously duplicated primary actions exist
|
||||
- no stuck modal, spinner, or blocked interaction remains onscreen
|
||||
|
||||
### 7. Capture evidence and summarize clearly
|
||||
|
||||
Your result should state:
|
||||
|
||||
- route tested
|
||||
- context used
|
||||
- steps executed
|
||||
- pass or fail
|
||||
- exact blocker or discrepancy if failed
|
||||
|
||||
Include a screenshot only when it adds value.
|
||||
|
||||
## Tool Usage Guidance
|
||||
|
||||
Use the browser tools in this order by default:
|
||||
|
||||
1. `read_page`
|
||||
2. `click_element`
|
||||
3. `type_in_page`
|
||||
4. `handle_dialog` when needed
|
||||
5. `navigate_page` or `open_browser_page` only when route changes are required
|
||||
6. `run_playwright_code` only if the normal browser tools are insufficient
|
||||
7. `screenshot_page` for evidence, not for primary navigation logic
|
||||
|
||||
## Repo-Specific Guidance For TenantPilot
|
||||
|
||||
### Workspace surfaces
|
||||
|
||||
For `/admin` pages and similar workspace-context surfaces:
|
||||
|
||||
- verify the page is reachable without forcing tenant-route assumptions
|
||||
- confirm any summary signal or CTA lands on the canonical destination
|
||||
- verify calm-state versus attention-state behavior when the feature defines both
|
||||
|
||||
### Tenant surfaces
|
||||
|
||||
For `/admin/t/{tenant}/...` pages:
|
||||
|
||||
- verify the tenant context is explicit and correct
|
||||
- verify drilldowns stay in the intended tenant scope
|
||||
- treat cross-tenant leakage or silent scope changes as failures
|
||||
|
||||
### Filament list or report surfaces
|
||||
|
||||
For Filament tables, reports, or registry-style pages:
|
||||
|
||||
- verify the heading and table shell render
|
||||
- verify fixed filters or summary controls exist when the spec requires them
|
||||
- verify row click or the primary inspect affordance behaves as designed
|
||||
- verify empty-state messaging is specific rather than generic when the feature defines custom behavior
|
||||
|
||||
### Filament detail pages
|
||||
|
||||
For detail or view surfaces:
|
||||
|
||||
- verify the canonical record loads
|
||||
- verify expected sections or summary content are present
|
||||
- verify critical actions or drillbacks are usable
|
||||
|
||||
## Result Format
|
||||
|
||||
Use a compact result format like this:
|
||||
|
||||
```text
|
||||
Browser smoke result: PASS
|
||||
Route: /admin/findings/hygiene
|
||||
Context: workspace member with visible hygiene issues
|
||||
Steps: opened report -> verified filters -> clicked finding row -> landed on canonical finding detail
|
||||
Verified: report rendered, primary interaction worked, drilldown route was correct
|
||||
```
|
||||
|
||||
If the test fails:
|
||||
|
||||
```text
|
||||
Browser smoke result: FAIL
|
||||
Route: /admin/findings/hygiene
|
||||
Context: authenticated workspace member
|
||||
Failed step: clicking the summary CTA
|
||||
Expected: navigate to /admin/findings/hygiene
|
||||
Actual: remained on /admin with no route change
|
||||
Blocker: CTA appears rendered but is not interactive
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Example 1: Smoke test a new report page
|
||||
|
||||
Use this when the feature adds a new read-only report.
|
||||
|
||||
Steps:
|
||||
|
||||
- open the canonical report route
|
||||
- verify the page heading and main controls
|
||||
- confirm the table or defined empty state is visible
|
||||
- click one row or primary inspect affordance
|
||||
- verify navigation lands on the canonical detail route
|
||||
|
||||
Pass criteria:
|
||||
|
||||
- report loads
|
||||
- intended controls exist
|
||||
- primary inspect path works
|
||||
|
||||
### Example 2: Smoke test a dashboard signal
|
||||
|
||||
Use this when the feature adds a summary signal on `/admin`.
|
||||
|
||||
Steps:
|
||||
|
||||
- open `/admin`
|
||||
- find the signal
|
||||
- verify the visible count or summary text
|
||||
- click the CTA
|
||||
- confirm navigation lands on the canonical downstream surface
|
||||
|
||||
Pass criteria:
|
||||
|
||||
- signal is visible in the correct state
|
||||
- CTA text is present
|
||||
- CTA opens the correct route
|
||||
|
||||
### Example 3: Smoke test a tenant detail follow-up
|
||||
|
||||
Use this when a workspace-level surface should drill into a tenant-level detail page.
|
||||
|
||||
Steps:
|
||||
|
||||
- open the workspace-level surface
|
||||
- trigger the drilldown
|
||||
- verify the target route includes the correct tenant and record
|
||||
- confirm the target page actually loads the expected detail content
|
||||
|
||||
Pass criteria:
|
||||
|
||||
- drilldown route is canonical
|
||||
- tenant context is correct
|
||||
- destination content matches the selected record
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
- Clicking before reading the page state and refs
|
||||
- Treating a blocked auth session as a feature failure
|
||||
- Confusing workspace-context routes with tenant-context routes
|
||||
- Reporting visual impressions without validating the actual interaction result
|
||||
- Forgetting to re-read the page after a modal opens or a route changes
|
||||
- Claiming success without verifying the final destination or changed state
|
||||
|
||||
## Non-Goals
|
||||
|
||||
This skill does not replace:
|
||||
|
||||
- full exploratory QA
|
||||
- formal Pest browser coverage
|
||||
- accessibility review
|
||||
- visual regression approval
|
||||
- backend correctness tests
|
||||
|
||||
It is a fast, real-browser confidence pass for the current feature.
|
||||
@ -1,148 +0,0 @@
|
||||
installed: []
|
||||
settings:
|
||||
auto_execute_hooks: true
|
||||
hooks:
|
||||
before_constitution:
|
||||
- extension: git
|
||||
command: speckit.git.initialize
|
||||
enabled: true
|
||||
optional: false
|
||||
prompt: Execute speckit.git.initialize?
|
||||
description: Initialize Git repository before constitution setup
|
||||
condition: null
|
||||
before_specify:
|
||||
- extension: git
|
||||
command: speckit.git.feature
|
||||
enabled: true
|
||||
optional: false
|
||||
prompt: Execute speckit.git.feature?
|
||||
description: Create feature branch before specification
|
||||
condition: null
|
||||
before_clarify:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit outstanding changes before clarification?
|
||||
description: Auto-commit before spec clarification
|
||||
condition: null
|
||||
before_plan:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit outstanding changes before planning?
|
||||
description: Auto-commit before implementation planning
|
||||
condition: null
|
||||
before_tasks:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit outstanding changes before task generation?
|
||||
description: Auto-commit before task generation
|
||||
condition: null
|
||||
before_implement:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit outstanding changes before implementation?
|
||||
description: Auto-commit before implementation
|
||||
condition: null
|
||||
before_checklist:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit outstanding changes before checklist?
|
||||
description: Auto-commit before checklist generation
|
||||
condition: null
|
||||
before_analyze:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit outstanding changes before analysis?
|
||||
description: Auto-commit before analysis
|
||||
condition: null
|
||||
before_taskstoissues:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit outstanding changes before issue sync?
|
||||
description: Auto-commit before tasks-to-issues conversion
|
||||
condition: null
|
||||
after_constitution:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit constitution changes?
|
||||
description: Auto-commit after constitution update
|
||||
condition: null
|
||||
after_specify:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit specification changes?
|
||||
description: Auto-commit after specification
|
||||
condition: null
|
||||
after_clarify:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit clarification changes?
|
||||
description: Auto-commit after spec clarification
|
||||
condition: null
|
||||
after_plan:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit plan changes?
|
||||
description: Auto-commit after implementation planning
|
||||
condition: null
|
||||
after_tasks:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit task changes?
|
||||
description: Auto-commit after task generation
|
||||
condition: null
|
||||
after_implement:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit implementation changes?
|
||||
description: Auto-commit after implementation
|
||||
condition: null
|
||||
after_checklist:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit checklist changes?
|
||||
description: Auto-commit after checklist generation
|
||||
condition: null
|
||||
after_analyze:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit analysis results?
|
||||
description: Auto-commit after analysis
|
||||
condition: null
|
||||
after_taskstoissues:
|
||||
- extension: git
|
||||
command: speckit.git.commit
|
||||
enabled: true
|
||||
optional: true
|
||||
prompt: Commit after syncing issues?
|
||||
description: Auto-commit after tasks-to-issues conversion
|
||||
condition: null
|
||||
@ -1,44 +0,0 @@
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"extensions": {
|
||||
"git": {
|
||||
"version": "1.0.0",
|
||||
"source": "local",
|
||||
"manifest_hash": "sha256:9731aa8143a72fbebfdb440f155038ab42642517c2b2bdbbf67c8fdbe076ed79",
|
||||
"enabled": true,
|
||||
"priority": 10,
|
||||
"registered_commands": {
|
||||
"agy": [
|
||||
"speckit.git.feature",
|
||||
"speckit.git.validate",
|
||||
"speckit.git.remote",
|
||||
"speckit.git.initialize",
|
||||
"speckit.git.commit"
|
||||
],
|
||||
"codex": [
|
||||
"speckit.git.feature",
|
||||
"speckit.git.validate",
|
||||
"speckit.git.remote",
|
||||
"speckit.git.initialize",
|
||||
"speckit.git.commit"
|
||||
],
|
||||
"copilot": [
|
||||
"speckit.git.feature",
|
||||
"speckit.git.validate",
|
||||
"speckit.git.remote",
|
||||
"speckit.git.initialize",
|
||||
"speckit.git.commit"
|
||||
],
|
||||
"gemini": [
|
||||
"speckit.git.feature",
|
||||
"speckit.git.validate",
|
||||
"speckit.git.remote",
|
||||
"speckit.git.initialize",
|
||||
"speckit.git.commit"
|
||||
]
|
||||
},
|
||||
"registered_skills": [],
|
||||
"installed_at": "2026-04-22T21:58:03.029565+00:00"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,100 +0,0 @@
|
||||
# Git Branching Workflow Extension
|
||||
|
||||
Git repository initialization, feature branch creation, numbering (sequential/timestamp), validation, remote detection, and auto-commit for Spec Kit.
|
||||
|
||||
## Overview
|
||||
|
||||
This extension provides Git operations as an optional, self-contained module. It manages:
|
||||
|
||||
- **Repository initialization** with configurable commit messages
|
||||
- **Feature branch creation** with sequential (`001-feature-name`) or timestamp (`20260319-143022-feature-name`) numbering
|
||||
- **Branch validation** to ensure branches follow naming conventions
|
||||
- **Git remote detection** for GitHub integration (e.g., issue creation)
|
||||
- **Auto-commit** after core commands (configurable per-command with custom messages)
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `speckit.git.initialize` | Initialize a Git repository with a configurable commit message |
|
||||
| `speckit.git.feature` | Create a feature branch with sequential or timestamp numbering |
|
||||
| `speckit.git.validate` | Validate current branch follows feature branch naming conventions |
|
||||
| `speckit.git.remote` | Detect Git remote URL for GitHub integration |
|
||||
| `speckit.git.commit` | Auto-commit changes (configurable per-command enable/disable and messages) |
|
||||
|
||||
## Hooks
|
||||
|
||||
| Event | Command | Optional | Description |
|
||||
|-------|---------|----------|-------------|
|
||||
| `before_constitution` | `speckit.git.initialize` | No | Init git repo before constitution |
|
||||
| `before_specify` | `speckit.git.feature` | No | Create feature branch before specification |
|
||||
| `before_clarify` | `speckit.git.commit` | Yes | Commit outstanding changes before clarification |
|
||||
| `before_plan` | `speckit.git.commit` | Yes | Commit outstanding changes before planning |
|
||||
| `before_tasks` | `speckit.git.commit` | Yes | Commit outstanding changes before task generation |
|
||||
| `before_implement` | `speckit.git.commit` | Yes | Commit outstanding changes before implementation |
|
||||
| `before_checklist` | `speckit.git.commit` | Yes | Commit outstanding changes before checklist |
|
||||
| `before_analyze` | `speckit.git.commit` | Yes | Commit outstanding changes before analysis |
|
||||
| `before_taskstoissues` | `speckit.git.commit` | Yes | Commit outstanding changes before issue sync |
|
||||
| `after_constitution` | `speckit.git.commit` | Yes | Auto-commit after constitution update |
|
||||
| `after_specify` | `speckit.git.commit` | Yes | Auto-commit after specification |
|
||||
| `after_clarify` | `speckit.git.commit` | Yes | Auto-commit after clarification |
|
||||
| `after_plan` | `speckit.git.commit` | Yes | Auto-commit after planning |
|
||||
| `after_tasks` | `speckit.git.commit` | Yes | Auto-commit after task generation |
|
||||
| `after_implement` | `speckit.git.commit` | Yes | Auto-commit after implementation |
|
||||
| `after_checklist` | `speckit.git.commit` | Yes | Auto-commit after checklist |
|
||||
| `after_analyze` | `speckit.git.commit` | Yes | Auto-commit after analysis |
|
||||
| `after_taskstoissues` | `speckit.git.commit` | Yes | Auto-commit after issue sync |
|
||||
|
||||
## Configuration
|
||||
|
||||
Configuration is stored in `.specify/extensions/git/git-config.yml`:
|
||||
|
||||
```yaml
|
||||
# Branch numbering strategy: "sequential" or "timestamp"
|
||||
branch_numbering: sequential
|
||||
|
||||
# Custom commit message for git init
|
||||
init_commit_message: "[Spec Kit] Initial commit"
|
||||
|
||||
# Auto-commit per command (all disabled by default)
|
||||
# Example: enable auto-commit after specify
|
||||
auto_commit:
|
||||
default: false
|
||||
after_specify:
|
||||
enabled: true
|
||||
message: "[Spec Kit] Add specification"
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# Install the bundled git extension (no network required)
|
||||
specify extension add git
|
||||
```
|
||||
|
||||
## Disabling
|
||||
|
||||
```bash
|
||||
# Disable the git extension (spec creation continues without branching)
|
||||
specify extension disable git
|
||||
|
||||
# Re-enable it
|
||||
specify extension enable git
|
||||
```
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
When Git is not installed or the directory is not a Git repository:
|
||||
- Spec directories are still created under `specs/`
|
||||
- Branch creation is skipped with a warning
|
||||
- Branch validation is skipped with a warning
|
||||
- Remote detection returns empty results
|
||||
|
||||
## Scripts
|
||||
|
||||
The extension bundles cross-platform scripts:
|
||||
|
||||
- `scripts/bash/create-new-feature.sh` — Bash implementation
|
||||
- `scripts/bash/git-common.sh` — Shared Git utilities (Bash)
|
||||
- `scripts/powershell/create-new-feature.ps1` — PowerShell implementation
|
||||
- `scripts/powershell/git-common.ps1` — Shared Git utilities (PowerShell)
|
||||
@ -1,48 +0,0 @@
|
||||
---
|
||||
description: "Auto-commit changes after a Spec Kit command completes"
|
||||
---
|
||||
|
||||
# Auto-Commit Changes
|
||||
|
||||
Automatically stage and commit all changes after a Spec Kit command completes.
|
||||
|
||||
## Behavior
|
||||
|
||||
This command is invoked as a hook after (or before) core commands. It:
|
||||
|
||||
1. Determines the event name from the hook context (e.g., if invoked as an `after_specify` hook, the event is `after_specify`; if `before_plan`, the event is `before_plan`)
|
||||
2. Checks `.specify/extensions/git/git-config.yml` for the `auto_commit` section
|
||||
3. Looks up the specific event key to see if auto-commit is enabled
|
||||
4. Falls back to `auto_commit.default` if no event-specific key exists
|
||||
5. Uses the per-command `message` if configured, otherwise a default message
|
||||
6. If enabled and there are uncommitted changes, runs `git add .` + `git commit`
|
||||
|
||||
## Execution
|
||||
|
||||
Determine the event name from the hook that triggered this command, then run the script:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/auto-commit.sh <event_name>`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/auto-commit.ps1 <event_name>`
|
||||
|
||||
Replace `<event_name>` with the actual hook event (e.g., `after_specify`, `before_plan`, `after_implement`).
|
||||
|
||||
## Configuration
|
||||
|
||||
In `.specify/extensions/git/git-config.yml`:
|
||||
|
||||
```yaml
|
||||
auto_commit:
|
||||
default: false # Global toggle — set true to enable for all commands
|
||||
after_specify:
|
||||
enabled: true # Override per-command
|
||||
message: "[Spec Kit] Add specification"
|
||||
after_plan:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add implementation plan"
|
||||
```
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
- If Git is not available or the current directory is not a repository: skips with a warning
|
||||
- If no config file exists: skips (disabled by default)
|
||||
- If no changes to commit: skips with a message
|
||||
@ -1,67 +0,0 @@
|
||||
---
|
||||
description: "Create a feature branch with sequential or timestamp numbering"
|
||||
---
|
||||
|
||||
# Create Feature Branch
|
||||
|
||||
Create and switch to a new git feature branch for the given specification. This command handles **branch creation only** — the spec directory and files are created by the core `/speckit.specify` workflow.
|
||||
|
||||
## User Input
|
||||
|
||||
```text
|
||||
$ARGUMENTS
|
||||
```
|
||||
|
||||
You **MUST** consider the user input before proceeding (if not empty).
|
||||
|
||||
## Environment Variable Override
|
||||
|
||||
If the user explicitly provided `GIT_BRANCH_NAME` (e.g., via environment variable, argument, or in their request), pass it through to the script by setting the `GIT_BRANCH_NAME` environment variable before invoking the script. When `GIT_BRANCH_NAME` is set:
|
||||
- The script uses the exact value as the branch name, bypassing all prefix/suffix generation
|
||||
- `--short-name`, `--number`, and `--timestamp` flags are ignored
|
||||
- `FEATURE_NUM` is extracted from the name if it starts with a numeric prefix, otherwise set to the full branch name
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Verify Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, warn the user and skip branch creation
|
||||
|
||||
## Branch Numbering Mode
|
||||
|
||||
Determine the branch numbering strategy by checking configuration in this order:
|
||||
|
||||
1. Check `.specify/extensions/git/git-config.yml` for `branch_numbering` value
|
||||
2. Check `.specify/init-options.json` for `branch_numbering` value (backward compatibility)
|
||||
3. Default to `sequential` if neither exists
|
||||
|
||||
## Execution
|
||||
|
||||
Generate a concise short name (2-4 words) for the branch:
|
||||
- Analyze the feature description and extract the most meaningful keywords
|
||||
- Use action-noun format when possible (e.g., "add-user-auth", "fix-payment-bug")
|
||||
- Preserve technical terms and acronyms (OAuth2, API, JWT, etc.)
|
||||
|
||||
Run the appropriate script based on your platform:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --short-name "<short-name>" "<feature description>"`
|
||||
- **Bash (timestamp)**: `.specify/extensions/git/scripts/bash/create-new-feature.sh --json --timestamp --short-name "<short-name>" "<feature description>"`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -ShortName "<short-name>" "<feature description>"`
|
||||
- **PowerShell (timestamp)**: `.specify/extensions/git/scripts/powershell/create-new-feature.ps1 -Json -Timestamp -ShortName "<short-name>" "<feature description>"`
|
||||
|
||||
**IMPORTANT**:
|
||||
- Do NOT pass `--number` — the script determines the correct next number automatically
|
||||
- Always include the JSON flag (`--json` for Bash, `-Json` for PowerShell) so the output can be parsed reliably
|
||||
- You must only ever run this script once per feature
|
||||
- The JSON output will contain `BRANCH_NAME` and `FEATURE_NUM`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed or the current directory is not a Git repository:
|
||||
- Branch creation is skipped with a warning: `[specify] Warning: Git repository not detected; skipped branch creation`
|
||||
- The script still outputs `BRANCH_NAME` and `FEATURE_NUM` so the caller can reference them
|
||||
|
||||
## Output
|
||||
|
||||
The script outputs JSON with:
|
||||
- `BRANCH_NAME`: The branch name (e.g., `003-user-auth` or `20260319-143022-user-auth`)
|
||||
- `FEATURE_NUM`: The numeric or timestamp prefix used
|
||||
@ -1,49 +0,0 @@
|
||||
---
|
||||
description: "Initialize a Git repository with an initial commit"
|
||||
---
|
||||
|
||||
# Initialize Git Repository
|
||||
|
||||
Initialize a Git repository in the current project directory if one does not already exist.
|
||||
|
||||
## Execution
|
||||
|
||||
Run the appropriate script from the project root:
|
||||
|
||||
- **Bash**: `.specify/extensions/git/scripts/bash/initialize-repo.sh`
|
||||
- **PowerShell**: `.specify/extensions/git/scripts/powershell/initialize-repo.ps1`
|
||||
|
||||
If the extension scripts are not found, fall back to:
|
||||
- **Bash**: `git init && git add . && git commit -m "Initial commit from Specify template"`
|
||||
- **PowerShell**: `git init; git add .; git commit -m "Initial commit from Specify template"`
|
||||
|
||||
The script handles all checks internally:
|
||||
- Skips if Git is not available
|
||||
- Skips if already inside a Git repository
|
||||
- Runs `git init`, `git add .`, and `git commit` with an initial commit message
|
||||
|
||||
## Customization
|
||||
|
||||
Replace the script to add project-specific Git initialization steps:
|
||||
- Custom `.gitignore` templates
|
||||
- Default branch naming (`git config init.defaultBranch`)
|
||||
- Git LFS setup
|
||||
- Git hooks installation
|
||||
- Commit signing configuration
|
||||
- Git Flow initialization
|
||||
|
||||
## Output
|
||||
|
||||
On success:
|
||||
- `✓ Git repository initialized`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed:
|
||||
- Warn the user
|
||||
- Skip repository initialization
|
||||
- The project continues to function without Git (specs can still be created under `specs/`)
|
||||
|
||||
If Git is installed but `git init`, `git add .`, or `git commit` fails:
|
||||
- Surface the error to the user
|
||||
- Stop this command rather than continuing with a partially initialized repository
|
||||
@ -1,45 +0,0 @@
|
||||
---
|
||||
description: "Detect Git remote URL for GitHub integration"
|
||||
---
|
||||
|
||||
# Detect Git Remote URL
|
||||
|
||||
Detect the Git remote URL for integration with GitHub services (e.g., issue creation).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Check if Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, output a warning and return empty:
|
||||
```
|
||||
[specify] Warning: Git repository not detected; cannot determine remote URL
|
||||
```
|
||||
|
||||
## Execution
|
||||
|
||||
Run the following command to get the remote URL:
|
||||
|
||||
```bash
|
||||
git config --get remote.origin.url
|
||||
```
|
||||
|
||||
## Output
|
||||
|
||||
Parse the remote URL and determine:
|
||||
|
||||
1. **Repository owner**: Extract from the URL (e.g., `github` from `https://github.com/github/spec-kit.git`)
|
||||
2. **Repository name**: Extract from the URL (e.g., `spec-kit` from `https://github.com/github/spec-kit.git`)
|
||||
3. **Is GitHub**: Whether the remote points to a GitHub repository
|
||||
|
||||
Supported URL formats:
|
||||
- HTTPS: `https://github.com/<owner>/<repo>.git`
|
||||
- SSH: `git@github.com:<owner>/<repo>.git`
|
||||
|
||||
> [!CAUTION]
|
||||
> ONLY report a GitHub repository if the remote URL actually points to github.com.
|
||||
> Do NOT assume the remote is GitHub if the URL format doesn't match.
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed, the directory is not a Git repository, or no remote is configured:
|
||||
- Return an empty result
|
||||
- Do NOT error — other workflows should continue without Git remote information
|
||||
@ -1,49 +0,0 @@
|
||||
---
|
||||
description: "Validate current branch follows feature branch naming conventions"
|
||||
---
|
||||
|
||||
# Validate Feature Branch
|
||||
|
||||
Validate that the current Git branch follows the expected feature branch naming conventions.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Check if Git is available by running `git rev-parse --is-inside-work-tree 2>/dev/null`
|
||||
- If Git is not available, output a warning and skip validation:
|
||||
```
|
||||
[specify] Warning: Git repository not detected; skipped branch validation
|
||||
```
|
||||
|
||||
## Validation Rules
|
||||
|
||||
Get the current branch name:
|
||||
|
||||
```bash
|
||||
git rev-parse --abbrev-ref HEAD
|
||||
```
|
||||
|
||||
The branch name must match one of these patterns:
|
||||
|
||||
1. **Sequential**: `^[0-9]{3,}-` (e.g., `001-feature-name`, `042-fix-bug`, `1000-big-feature`)
|
||||
2. **Timestamp**: `^[0-9]{8}-[0-9]{6}-` (e.g., `20260319-143022-feature-name`)
|
||||
|
||||
## Execution
|
||||
|
||||
If on a feature branch (matches either pattern):
|
||||
- Output: `✓ On feature branch: <branch-name>`
|
||||
- Check if the corresponding spec directory exists under `specs/`:
|
||||
- For sequential branches, look for `specs/<prefix>-*` where prefix matches the numeric portion
|
||||
- For timestamp branches, look for `specs/<prefix>-*` where prefix matches the `YYYYMMDD-HHMMSS` portion
|
||||
- If spec directory exists: `✓ Spec directory found: <path>`
|
||||
- If spec directory missing: `⚠ No spec directory found for prefix <prefix>`
|
||||
|
||||
If NOT on a feature branch:
|
||||
- Output: `✗ Not on a feature branch. Current branch: <branch-name>`
|
||||
- Output: `Feature branches should be named like: 001-feature-name or 20260319-143022-feature-name`
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
If Git is not installed or the directory is not a Git repository:
|
||||
- Check the `SPECIFY_FEATURE` environment variable as a fallback
|
||||
- If set, validate that value against the naming patterns
|
||||
- If not set, skip validation with a warning
|
||||
@ -1,62 +0,0 @@
|
||||
# Git Branching Workflow Extension Configuration
|
||||
# Copied to .specify/extensions/git/git-config.yml on install
|
||||
|
||||
# Branch numbering strategy: "sequential" (001, 002, ...) or "timestamp" (YYYYMMDD-HHMMSS)
|
||||
branch_numbering: sequential
|
||||
|
||||
# Commit message used by `git commit` during repository initialization
|
||||
init_commit_message: "[Spec Kit] Initial commit"
|
||||
|
||||
# Auto-commit before/after core commands.
|
||||
# Set "default" to enable for all commands, then override per-command.
|
||||
# Each key can be true/false. Message is customizable per-command.
|
||||
auto_commit:
|
||||
default: false
|
||||
before_clarify:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before clarification"
|
||||
before_plan:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before planning"
|
||||
before_tasks:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before task generation"
|
||||
before_implement:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before implementation"
|
||||
before_checklist:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before checklist"
|
||||
before_analyze:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before analysis"
|
||||
before_taskstoissues:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before issue sync"
|
||||
after_constitution:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add project constitution"
|
||||
after_specify:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add specification"
|
||||
after_clarify:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Clarify specification"
|
||||
after_plan:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add implementation plan"
|
||||
after_tasks:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add tasks"
|
||||
after_implement:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Implementation progress"
|
||||
after_checklist:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add checklist"
|
||||
after_analyze:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add analysis report"
|
||||
after_taskstoissues:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Sync tasks to issues"
|
||||
@ -1,140 +0,0 @@
|
||||
schema_version: "1.0"
|
||||
|
||||
extension:
|
||||
id: git
|
||||
name: "Git Branching Workflow"
|
||||
version: "1.0.0"
|
||||
description: "Feature branch creation, numbering (sequential/timestamp), validation, and Git remote detection"
|
||||
author: spec-kit-core
|
||||
repository: https://github.com/github/spec-kit
|
||||
license: MIT
|
||||
|
||||
requires:
|
||||
speckit_version: ">=0.2.0"
|
||||
tools:
|
||||
- name: git
|
||||
required: false
|
||||
|
||||
provides:
|
||||
commands:
|
||||
- name: speckit.git.feature
|
||||
file: commands/speckit.git.feature.md
|
||||
description: "Create a feature branch with sequential or timestamp numbering"
|
||||
- name: speckit.git.validate
|
||||
file: commands/speckit.git.validate.md
|
||||
description: "Validate current branch follows feature branch naming conventions"
|
||||
- name: speckit.git.remote
|
||||
file: commands/speckit.git.remote.md
|
||||
description: "Detect Git remote URL for GitHub integration"
|
||||
- name: speckit.git.initialize
|
||||
file: commands/speckit.git.initialize.md
|
||||
description: "Initialize a Git repository with an initial commit"
|
||||
- name: speckit.git.commit
|
||||
file: commands/speckit.git.commit.md
|
||||
description: "Auto-commit changes after a Spec Kit command completes"
|
||||
|
||||
config:
|
||||
- name: "git-config.yml"
|
||||
template: "config-template.yml"
|
||||
description: "Git branching configuration"
|
||||
required: false
|
||||
|
||||
hooks:
|
||||
before_constitution:
|
||||
command: speckit.git.initialize
|
||||
optional: false
|
||||
description: "Initialize Git repository before constitution setup"
|
||||
before_specify:
|
||||
command: speckit.git.feature
|
||||
optional: false
|
||||
description: "Create feature branch before specification"
|
||||
before_clarify:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit outstanding changes before clarification?"
|
||||
description: "Auto-commit before spec clarification"
|
||||
before_plan:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit outstanding changes before planning?"
|
||||
description: "Auto-commit before implementation planning"
|
||||
before_tasks:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit outstanding changes before task generation?"
|
||||
description: "Auto-commit before task generation"
|
||||
before_implement:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit outstanding changes before implementation?"
|
||||
description: "Auto-commit before implementation"
|
||||
before_checklist:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit outstanding changes before checklist?"
|
||||
description: "Auto-commit before checklist generation"
|
||||
before_analyze:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit outstanding changes before analysis?"
|
||||
description: "Auto-commit before analysis"
|
||||
before_taskstoissues:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit outstanding changes before issue sync?"
|
||||
description: "Auto-commit before tasks-to-issues conversion"
|
||||
after_constitution:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit constitution changes?"
|
||||
description: "Auto-commit after constitution update"
|
||||
after_specify:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit specification changes?"
|
||||
description: "Auto-commit after specification"
|
||||
after_clarify:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit clarification changes?"
|
||||
description: "Auto-commit after spec clarification"
|
||||
after_plan:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit plan changes?"
|
||||
description: "Auto-commit after implementation planning"
|
||||
after_tasks:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit task changes?"
|
||||
description: "Auto-commit after task generation"
|
||||
after_implement:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit implementation changes?"
|
||||
description: "Auto-commit after implementation"
|
||||
after_checklist:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit checklist changes?"
|
||||
description: "Auto-commit after checklist generation"
|
||||
after_analyze:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit analysis results?"
|
||||
description: "Auto-commit after analysis"
|
||||
after_taskstoissues:
|
||||
command: speckit.git.commit
|
||||
optional: true
|
||||
prompt: "Commit after syncing issues?"
|
||||
description: "Auto-commit after tasks-to-issues conversion"
|
||||
|
||||
tags:
|
||||
- "git"
|
||||
- "branching"
|
||||
- "workflow"
|
||||
|
||||
config:
|
||||
defaults:
|
||||
branch_numbering: sequential
|
||||
init_commit_message: "[Spec Kit] Initial commit"
|
||||
@ -1,62 +0,0 @@
|
||||
# Git Branching Workflow Extension Configuration
|
||||
# Copied to .specify/extensions/git/git-config.yml on install
|
||||
|
||||
# Branch numbering strategy: "sequential" (001, 002, ...) or "timestamp" (YYYYMMDD-HHMMSS)
|
||||
branch_numbering: sequential
|
||||
|
||||
# Commit message used by `git commit` during repository initialization
|
||||
init_commit_message: "[Spec Kit] Initial commit"
|
||||
|
||||
# Auto-commit before/after core commands.
|
||||
# Set "default" to enable for all commands, then override per-command.
|
||||
# Each key can be true/false. Message is customizable per-command.
|
||||
auto_commit:
|
||||
default: false
|
||||
before_clarify:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before clarification"
|
||||
before_plan:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before planning"
|
||||
before_tasks:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before task generation"
|
||||
before_implement:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before implementation"
|
||||
before_checklist:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before checklist"
|
||||
before_analyze:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before analysis"
|
||||
before_taskstoissues:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Save progress before issue sync"
|
||||
after_constitution:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add project constitution"
|
||||
after_specify:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add specification"
|
||||
after_clarify:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Clarify specification"
|
||||
after_plan:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add implementation plan"
|
||||
after_tasks:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add tasks"
|
||||
after_implement:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Implementation progress"
|
||||
after_checklist:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add checklist"
|
||||
after_analyze:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Add analysis report"
|
||||
after_taskstoissues:
|
||||
enabled: false
|
||||
message: "[Spec Kit] Sync tasks to issues"
|
||||
@ -1,140 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Git extension: auto-commit.sh
|
||||
# Automatically commit changes after a Spec Kit command completes.
|
||||
# Checks per-command config keys in git-config.yml before committing.
|
||||
#
|
||||
# Usage: auto-commit.sh <event_name>
|
||||
# e.g.: auto-commit.sh after_specify
|
||||
|
||||
set -e
|
||||
|
||||
EVENT_NAME="${1:-}"
|
||||
if [ -z "$EVENT_NAME" ]; then
|
||||
echo "Usage: $0 <event_name>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
_find_project_root() {
|
||||
local dir="$1"
|
||||
while [ "$dir" != "/" ]; do
|
||||
if [ -d "$dir/.specify" ] || [ -d "$dir/.git" ]; then
|
||||
echo "$dir"
|
||||
return 0
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
REPO_ROOT=$(_find_project_root "$SCRIPT_DIR") || REPO_ROOT="$(pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
# Check if git is available
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
echo "[specify] Warning: Git not found; skipped auto-commit" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
echo "[specify] Warning: Not a Git repository; skipped auto-commit" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Read per-command config from git-config.yml
|
||||
_config_file="$REPO_ROOT/.specify/extensions/git/git-config.yml"
|
||||
_enabled=false
|
||||
_commit_msg=""
|
||||
|
||||
if [ -f "$_config_file" ]; then
|
||||
# Parse the auto_commit section for this event.
|
||||
# Look for auto_commit.<event_name>.enabled and .message
|
||||
# Also check auto_commit.default as fallback.
|
||||
_in_auto_commit=false
|
||||
_in_event=false
|
||||
_default_enabled=false
|
||||
|
||||
while IFS= read -r _line; do
|
||||
# Detect auto_commit: section
|
||||
if echo "$_line" | grep -q '^auto_commit:'; then
|
||||
_in_auto_commit=true
|
||||
_in_event=false
|
||||
continue
|
||||
fi
|
||||
|
||||
# Exit auto_commit section on next top-level key
|
||||
if $_in_auto_commit && echo "$_line" | grep -Eq '^[a-z]'; then
|
||||
break
|
||||
fi
|
||||
|
||||
if $_in_auto_commit; then
|
||||
# Check default key
|
||||
if echo "$_line" | grep -Eq "^[[:space:]]+default:[[:space:]]"; then
|
||||
_val=$(echo "$_line" | sed 's/^[^:]*:[[:space:]]*//' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
|
||||
[ "$_val" = "true" ] && _default_enabled=true
|
||||
fi
|
||||
|
||||
# Detect our event subsection
|
||||
if echo "$_line" | grep -Eq "^[[:space:]]+${EVENT_NAME}:"; then
|
||||
_in_event=true
|
||||
continue
|
||||
fi
|
||||
|
||||
# Inside our event subsection
|
||||
if $_in_event; then
|
||||
# Exit on next sibling key (same indent level as event name)
|
||||
if echo "$_line" | grep -Eq '^[[:space:]]{2}[a-z]' && ! echo "$_line" | grep -Eq '^[[:space:]]{4}'; then
|
||||
_in_event=false
|
||||
continue
|
||||
fi
|
||||
if echo "$_line" | grep -Eq '[[:space:]]+enabled:'; then
|
||||
_val=$(echo "$_line" | sed 's/^[^:]*:[[:space:]]*//' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]')
|
||||
[ "$_val" = "true" ] && _enabled=true
|
||||
[ "$_val" = "false" ] && _enabled=false
|
||||
fi
|
||||
if echo "$_line" | grep -Eq '[[:space:]]+message:'; then
|
||||
_commit_msg=$(echo "$_line" | sed 's/^[^:]*:[[:space:]]*//' | sed 's/^["'\'']//' | sed 's/["'\'']*$//')
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done < "$_config_file"
|
||||
|
||||
# If event-specific key not found, use default
|
||||
if [ "$_enabled" = "false" ] && [ "$_default_enabled" = "true" ]; then
|
||||
# Only use default if the event wasn't explicitly set to false
|
||||
# Check if event section existed at all
|
||||
if ! grep -q "^[[:space:]]*${EVENT_NAME}:" "$_config_file" 2>/dev/null; then
|
||||
_enabled=true
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# No config file — auto-commit disabled by default
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$_enabled" != "true" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if there are changes to commit
|
||||
if git diff --quiet HEAD 2>/dev/null && git diff --cached --quiet 2>/dev/null && [ -z "$(git ls-files --others --exclude-standard 2>/dev/null)" ]; then
|
||||
echo "[specify] No changes to commit after $EVENT_NAME" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Derive a human-readable command name from the event
|
||||
# e.g., after_specify -> specify, before_plan -> plan
|
||||
_command_name=$(echo "$EVENT_NAME" | sed 's/^after_//' | sed 's/^before_//')
|
||||
_phase=$(echo "$EVENT_NAME" | grep -q '^before_' && echo 'before' || echo 'after')
|
||||
|
||||
# Use custom message if configured, otherwise default
|
||||
if [ -z "$_commit_msg" ]; then
|
||||
_commit_msg="[Spec Kit] Auto-commit ${_phase} ${_command_name}"
|
||||
fi
|
||||
|
||||
# Stage and commit
|
||||
_git_out=$(git add . 2>&1) || { echo "[specify] Error: git add failed: $_git_out" >&2; exit 1; }
|
||||
_git_out=$(git commit -q -m "$_commit_msg" 2>&1) || { echo "[specify] Error: git commit failed: $_git_out" >&2; exit 1; }
|
||||
|
||||
echo "[OK] Changes committed ${_phase} ${_command_name}" >&2
|
||||
@ -1,453 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Git extension: create-new-feature.sh
|
||||
# Adapted from core scripts/bash/create-new-feature.sh for extension layout.
|
||||
# Sources common.sh from the project's installed scripts, falling back to
|
||||
# git-common.sh for minimal git helpers.
|
||||
|
||||
set -e
|
||||
|
||||
JSON_MODE=false
|
||||
DRY_RUN=false
|
||||
ALLOW_EXISTING=false
|
||||
SHORT_NAME=""
|
||||
BRANCH_NUMBER=""
|
||||
USE_TIMESTAMP=false
|
||||
ARGS=()
|
||||
i=1
|
||||
while [ $i -le $# ]; do
|
||||
arg="${!i}"
|
||||
case "$arg" in
|
||||
--json)
|
||||
JSON_MODE=true
|
||||
;;
|
||||
--dry-run)
|
||||
DRY_RUN=true
|
||||
;;
|
||||
--allow-existing-branch)
|
||||
ALLOW_EXISTING=true
|
||||
;;
|
||||
--short-name)
|
||||
if [ $((i + 1)) -gt $# ]; then
|
||||
echo 'Error: --short-name requires a value' >&2
|
||||
exit 1
|
||||
fi
|
||||
i=$((i + 1))
|
||||
next_arg="${!i}"
|
||||
if [[ "$next_arg" == --* ]]; then
|
||||
echo 'Error: --short-name requires a value' >&2
|
||||
exit 1
|
||||
fi
|
||||
SHORT_NAME="$next_arg"
|
||||
;;
|
||||
--number)
|
||||
if [ $((i + 1)) -gt $# ]; then
|
||||
echo 'Error: --number requires a value' >&2
|
||||
exit 1
|
||||
fi
|
||||
i=$((i + 1))
|
||||
next_arg="${!i}"
|
||||
if [[ "$next_arg" == --* ]]; then
|
||||
echo 'Error: --number requires a value' >&2
|
||||
exit 1
|
||||
fi
|
||||
BRANCH_NUMBER="$next_arg"
|
||||
if [[ ! "$BRANCH_NUMBER" =~ ^[0-9]+$ ]]; then
|
||||
echo 'Error: --number must be a non-negative integer' >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--timestamp)
|
||||
USE_TIMESTAMP=true
|
||||
;;
|
||||
--help|-h)
|
||||
echo "Usage: $0 [--json] [--dry-run] [--allow-existing-branch] [--short-name <name>] [--number N] [--timestamp] <feature_description>"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --json Output in JSON format"
|
||||
echo " --dry-run Compute branch name without creating the branch"
|
||||
echo " --allow-existing-branch Switch to branch if it already exists instead of failing"
|
||||
echo " --short-name <name> Provide a custom short name (2-4 words) for the branch"
|
||||
echo " --number N Specify branch number manually (overrides auto-detection)"
|
||||
echo " --timestamp Use timestamp prefix (YYYYMMDD-HHMMSS) instead of sequential numbering"
|
||||
echo " --help, -h Show this help message"
|
||||
echo ""
|
||||
echo "Environment variables:"
|
||||
echo " GIT_BRANCH_NAME Use this exact branch name, bypassing all prefix/suffix generation"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 'Add user authentication system' --short-name 'user-auth'"
|
||||
echo " $0 'Implement OAuth2 integration for API' --number 5"
|
||||
echo " $0 --timestamp --short-name 'user-auth' 'Add user authentication'"
|
||||
echo " GIT_BRANCH_NAME=my-branch $0 'feature description'"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
ARGS+=("$arg")
|
||||
;;
|
||||
esac
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
FEATURE_DESCRIPTION="${ARGS[*]}"
|
||||
if [ -z "$FEATURE_DESCRIPTION" ]; then
|
||||
echo "Usage: $0 [--json] [--dry-run] [--allow-existing-branch] [--short-name <name>] [--number N] [--timestamp] <feature_description>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Trim whitespace and validate description is not empty
|
||||
FEATURE_DESCRIPTION=$(echo "$FEATURE_DESCRIPTION" | xargs)
|
||||
if [ -z "$FEATURE_DESCRIPTION" ]; then
|
||||
echo "Error: Feature description cannot be empty or contain only whitespace" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Function to get highest number from specs directory
|
||||
get_highest_from_specs() {
|
||||
local specs_dir="$1"
|
||||
local highest=0
|
||||
|
||||
if [ -d "$specs_dir" ]; then
|
||||
for dir in "$specs_dir"/*; do
|
||||
[ -d "$dir" ] || continue
|
||||
dirname=$(basename "$dir")
|
||||
# Match sequential prefixes (>=3 digits), but skip timestamp dirs.
|
||||
if echo "$dirname" | grep -Eq '^[0-9]{3,}-' && ! echo "$dirname" | grep -Eq '^[0-9]{8}-[0-9]{6}-'; then
|
||||
number=$(echo "$dirname" | grep -Eo '^[0-9]+')
|
||||
number=$((10#$number))
|
||||
if [ "$number" -gt "$highest" ]; then
|
||||
highest=$number
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "$highest"
|
||||
}
|
||||
|
||||
# Function to get highest number from git branches
|
||||
get_highest_from_branches() {
|
||||
git branch -a 2>/dev/null | sed 's/^[* ]*//; s|^remotes/[^/]*/||' | _extract_highest_number
|
||||
}
|
||||
|
||||
# Extract the highest sequential feature number from a list of ref names (one per line).
|
||||
_extract_highest_number() {
|
||||
local highest=0
|
||||
while IFS= read -r name; do
|
||||
[ -z "$name" ] && continue
|
||||
if echo "$name" | grep -Eq '^[0-9]{3,}-' && ! echo "$name" | grep -Eq '^[0-9]{8}-[0-9]{6}-'; then
|
||||
number=$(echo "$name" | grep -Eo '^[0-9]+' || echo "0")
|
||||
number=$((10#$number))
|
||||
if [ "$number" -gt "$highest" ]; then
|
||||
highest=$number
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "$highest"
|
||||
}
|
||||
|
||||
# Function to get highest number from remote branches without fetching (side-effect-free)
|
||||
get_highest_from_remote_refs() {
|
||||
local highest=0
|
||||
|
||||
for remote in $(git remote 2>/dev/null); do
|
||||
local remote_highest
|
||||
remote_highest=$(GIT_TERMINAL_PROMPT=0 git ls-remote --heads "$remote" 2>/dev/null | sed 's|.*refs/heads/||' | _extract_highest_number)
|
||||
if [ "$remote_highest" -gt "$highest" ]; then
|
||||
highest=$remote_highest
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$highest"
|
||||
}
|
||||
|
||||
# Function to check existing branches and return next available number.
|
||||
check_existing_branches() {
|
||||
local specs_dir="$1"
|
||||
local skip_fetch="${2:-false}"
|
||||
|
||||
if [ "$skip_fetch" = true ]; then
|
||||
local highest_remote=$(get_highest_from_remote_refs)
|
||||
local highest_branch=$(get_highest_from_branches)
|
||||
if [ "$highest_remote" -gt "$highest_branch" ]; then
|
||||
highest_branch=$highest_remote
|
||||
fi
|
||||
else
|
||||
git fetch --all --prune >/dev/null 2>&1 || true
|
||||
local highest_branch=$(get_highest_from_branches)
|
||||
fi
|
||||
|
||||
local highest_spec=$(get_highest_from_specs "$specs_dir")
|
||||
|
||||
local max_num=$highest_branch
|
||||
if [ "$highest_spec" -gt "$max_num" ]; then
|
||||
max_num=$highest_spec
|
||||
fi
|
||||
|
||||
echo $((max_num + 1))
|
||||
}
|
||||
|
||||
# Function to clean and format a branch name
|
||||
clean_branch_name() {
|
||||
local name="$1"
|
||||
echo "$name" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-//' | sed 's/-$//'
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Source common.sh for resolve_template, json_escape, get_repo_root, has_git.
|
||||
#
|
||||
# Search locations in priority order:
|
||||
# 1. .specify/scripts/bash/common.sh under the project root (installed project)
|
||||
# 2. scripts/bash/common.sh under the project root (source checkout fallback)
|
||||
# 3. git-common.sh next to this script (minimal fallback — lacks resolve_template)
|
||||
# ---------------------------------------------------------------------------
|
||||
SCRIPT_DIR="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Find project root by walking up from the script location
|
||||
_find_project_root() {
|
||||
local dir="$1"
|
||||
while [ "$dir" != "/" ]; do
|
||||
if [ -d "$dir/.specify" ] || [ -d "$dir/.git" ]; then
|
||||
echo "$dir"
|
||||
return 0
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
_common_loaded=false
|
||||
_PROJECT_ROOT=$(_find_project_root "$SCRIPT_DIR") || true
|
||||
|
||||
if [ -n "$_PROJECT_ROOT" ] && [ -f "$_PROJECT_ROOT/.specify/scripts/bash/common.sh" ]; then
|
||||
source "$_PROJECT_ROOT/.specify/scripts/bash/common.sh"
|
||||
_common_loaded=true
|
||||
elif [ -n "$_PROJECT_ROOT" ] && [ -f "$_PROJECT_ROOT/scripts/bash/common.sh" ]; then
|
||||
source "$_PROJECT_ROOT/scripts/bash/common.sh"
|
||||
_common_loaded=true
|
||||
elif [ -f "$SCRIPT_DIR/git-common.sh" ]; then
|
||||
source "$SCRIPT_DIR/git-common.sh"
|
||||
_common_loaded=true
|
||||
fi
|
||||
|
||||
if [ "$_common_loaded" != "true" ]; then
|
||||
echo "Error: Could not locate common.sh or git-common.sh. Please ensure the Specify core scripts are installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Resolve repository root
|
||||
if type get_repo_root >/dev/null 2>&1; then
|
||||
REPO_ROOT=$(get_repo_root)
|
||||
elif git rev-parse --show-toplevel >/dev/null 2>&1; then
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
elif [ -n "$_PROJECT_ROOT" ]; then
|
||||
REPO_ROOT="$_PROJECT_ROOT"
|
||||
else
|
||||
echo "Error: Could not determine repository root." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if git is available at this repo root
|
||||
if type has_git >/dev/null 2>&1; then
|
||||
if has_git "$REPO_ROOT"; then
|
||||
HAS_GIT=true
|
||||
else
|
||||
HAS_GIT=false
|
||||
fi
|
||||
elif git -C "$REPO_ROOT" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
HAS_GIT=true
|
||||
else
|
||||
HAS_GIT=false
|
||||
fi
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
SPECS_DIR="$REPO_ROOT/specs"
|
||||
|
||||
# Function to generate branch name with stop word filtering
|
||||
generate_branch_name() {
|
||||
local description="$1"
|
||||
|
||||
local stop_words="^(i|a|an|the|to|for|of|in|on|at|by|with|from|is|are|was|were|be|been|being|have|has|had|do|does|did|will|would|should|could|can|may|might|must|shall|this|that|these|those|my|your|our|their|want|need|add|get|set)$"
|
||||
|
||||
local clean_name=$(echo "$description" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/ /g')
|
||||
|
||||
local meaningful_words=()
|
||||
for word in $clean_name; do
|
||||
[ -z "$word" ] && continue
|
||||
if ! echo "$word" | grep -qiE "$stop_words"; then
|
||||
if [ ${#word} -ge 3 ]; then
|
||||
meaningful_words+=("$word")
|
||||
elif echo "$description" | grep -qw -- "${word^^}"; then
|
||||
meaningful_words+=("$word")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#meaningful_words[@]} -gt 0 ]; then
|
||||
local max_words=3
|
||||
if [ ${#meaningful_words[@]} -eq 4 ]; then max_words=4; fi
|
||||
|
||||
local result=""
|
||||
local count=0
|
||||
for word in "${meaningful_words[@]}"; do
|
||||
if [ $count -ge $max_words ]; then break; fi
|
||||
if [ -n "$result" ]; then result="$result-"; fi
|
||||
result="$result$word"
|
||||
count=$((count + 1))
|
||||
done
|
||||
echo "$result"
|
||||
else
|
||||
local cleaned=$(clean_branch_name "$description")
|
||||
echo "$cleaned" | tr '-' '\n' | grep -v '^$' | head -3 | tr '\n' '-' | sed 's/-$//'
|
||||
fi
|
||||
}
|
||||
|
||||
# Check for GIT_BRANCH_NAME env var override (exact branch name, no prefix/suffix)
|
||||
if [ -n "${GIT_BRANCH_NAME:-}" ]; then
|
||||
BRANCH_NAME="$GIT_BRANCH_NAME"
|
||||
# Extract FEATURE_NUM from the branch name if it starts with a numeric prefix
|
||||
# Check timestamp pattern first (YYYYMMDD-HHMMSS-) since it also matches the simpler ^[0-9]+ pattern
|
||||
if echo "$BRANCH_NAME" | grep -Eq '^[0-9]{8}-[0-9]{6}-'; then
|
||||
FEATURE_NUM=$(echo "$BRANCH_NAME" | grep -Eo '^[0-9]{8}-[0-9]{6}')
|
||||
BRANCH_SUFFIX="${BRANCH_NAME#${FEATURE_NUM}-}"
|
||||
elif echo "$BRANCH_NAME" | grep -Eq '^[0-9]+-'; then
|
||||
FEATURE_NUM=$(echo "$BRANCH_NAME" | grep -Eo '^[0-9]+')
|
||||
BRANCH_SUFFIX="${BRANCH_NAME#${FEATURE_NUM}-}"
|
||||
else
|
||||
FEATURE_NUM="$BRANCH_NAME"
|
||||
BRANCH_SUFFIX="$BRANCH_NAME"
|
||||
fi
|
||||
else
|
||||
# Generate branch name
|
||||
if [ -n "$SHORT_NAME" ]; then
|
||||
BRANCH_SUFFIX=$(clean_branch_name "$SHORT_NAME")
|
||||
else
|
||||
BRANCH_SUFFIX=$(generate_branch_name "$FEATURE_DESCRIPTION")
|
||||
fi
|
||||
|
||||
# Warn if --number and --timestamp are both specified
|
||||
if [ "$USE_TIMESTAMP" = true ] && [ -n "$BRANCH_NUMBER" ]; then
|
||||
>&2 echo "[specify] Warning: --number is ignored when --timestamp is used"
|
||||
BRANCH_NUMBER=""
|
||||
fi
|
||||
|
||||
# Determine branch prefix
|
||||
if [ "$USE_TIMESTAMP" = true ]; then
|
||||
FEATURE_NUM=$(date +%Y%m%d-%H%M%S)
|
||||
BRANCH_NAME="${FEATURE_NUM}-${BRANCH_SUFFIX}"
|
||||
else
|
||||
if [ -z "$BRANCH_NUMBER" ]; then
|
||||
if [ "$DRY_RUN" = true ] && [ "$HAS_GIT" = true ]; then
|
||||
BRANCH_NUMBER=$(check_existing_branches "$SPECS_DIR" true)
|
||||
elif [ "$DRY_RUN" = true ]; then
|
||||
HIGHEST=$(get_highest_from_specs "$SPECS_DIR")
|
||||
BRANCH_NUMBER=$((HIGHEST + 1))
|
||||
elif [ "$HAS_GIT" = true ]; then
|
||||
BRANCH_NUMBER=$(check_existing_branches "$SPECS_DIR")
|
||||
else
|
||||
HIGHEST=$(get_highest_from_specs "$SPECS_DIR")
|
||||
BRANCH_NUMBER=$((HIGHEST + 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
FEATURE_NUM=$(printf "%03d" "$((10#$BRANCH_NUMBER))")
|
||||
BRANCH_NAME="${FEATURE_NUM}-${BRANCH_SUFFIX}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# GitHub enforces a 244-byte limit on branch names
|
||||
MAX_BRANCH_LENGTH=244
|
||||
_byte_length() { printf '%s' "$1" | LC_ALL=C wc -c | tr -d ' '; }
|
||||
BRANCH_BYTE_LEN=$(_byte_length "$BRANCH_NAME")
|
||||
if [ -n "${GIT_BRANCH_NAME:-}" ] && [ "$BRANCH_BYTE_LEN" -gt $MAX_BRANCH_LENGTH ]; then
|
||||
>&2 echo "Error: GIT_BRANCH_NAME must be 244 bytes or fewer in UTF-8. Provided value is ${BRANCH_BYTE_LEN} bytes."
|
||||
exit 1
|
||||
elif [ "$BRANCH_BYTE_LEN" -gt $MAX_BRANCH_LENGTH ]; then
|
||||
PREFIX_LENGTH=$(( ${#FEATURE_NUM} + 1 ))
|
||||
MAX_SUFFIX_LENGTH=$((MAX_BRANCH_LENGTH - PREFIX_LENGTH))
|
||||
|
||||
TRUNCATED_SUFFIX=$(echo "$BRANCH_SUFFIX" | cut -c1-$MAX_SUFFIX_LENGTH)
|
||||
TRUNCATED_SUFFIX=$(echo "$TRUNCATED_SUFFIX" | sed 's/-$//')
|
||||
|
||||
ORIGINAL_BRANCH_NAME="$BRANCH_NAME"
|
||||
BRANCH_NAME="${FEATURE_NUM}-${TRUNCATED_SUFFIX}"
|
||||
|
||||
>&2 echo "[specify] Warning: Branch name exceeded GitHub's 244-byte limit"
|
||||
>&2 echo "[specify] Original: $ORIGINAL_BRANCH_NAME (${#ORIGINAL_BRANCH_NAME} bytes)"
|
||||
>&2 echo "[specify] Truncated to: $BRANCH_NAME (${#BRANCH_NAME} bytes)"
|
||||
fi
|
||||
|
||||
if [ "$DRY_RUN" != true ]; then
|
||||
if [ "$HAS_GIT" = true ]; then
|
||||
branch_create_error=""
|
||||
if ! branch_create_error=$(git checkout -q -b "$BRANCH_NAME" 2>&1); then
|
||||
current_branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
|
||||
if git branch --list "$BRANCH_NAME" | grep -q .; then
|
||||
if [ "$ALLOW_EXISTING" = true ]; then
|
||||
if [ "$current_branch" = "$BRANCH_NAME" ]; then
|
||||
:
|
||||
elif ! switch_branch_error=$(git checkout -q "$BRANCH_NAME" 2>&1); then
|
||||
>&2 echo "Error: Failed to switch to existing branch '$BRANCH_NAME'. Please resolve any local changes or conflicts and try again."
|
||||
if [ -n "$switch_branch_error" ]; then
|
||||
>&2 printf '%s\n' "$switch_branch_error"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
elif [ "$USE_TIMESTAMP" = true ]; then
|
||||
>&2 echo "Error: Branch '$BRANCH_NAME' already exists. Rerun to get a new timestamp or use a different --short-name."
|
||||
exit 1
|
||||
else
|
||||
>&2 echo "Error: Branch '$BRANCH_NAME' already exists. Please use a different feature name or specify a different number with --number."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
>&2 echo "Error: Failed to create git branch '$BRANCH_NAME'."
|
||||
if [ -n "$branch_create_error" ]; then
|
||||
>&2 printf '%s\n' "$branch_create_error"
|
||||
else
|
||||
>&2 echo "Please check your git configuration and try again."
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
>&2 echo "[specify] Warning: Git repository not detected; skipped branch creation for $BRANCH_NAME"
|
||||
fi
|
||||
|
||||
printf '# To persist: export SPECIFY_FEATURE=%q\n' "$BRANCH_NAME" >&2
|
||||
fi
|
||||
|
||||
if $JSON_MODE; then
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
jq -cn \
|
||||
--arg branch_name "$BRANCH_NAME" \
|
||||
--arg feature_num "$FEATURE_NUM" \
|
||||
'{BRANCH_NAME:$branch_name,FEATURE_NUM:$feature_num,DRY_RUN:true}'
|
||||
else
|
||||
jq -cn \
|
||||
--arg branch_name "$BRANCH_NAME" \
|
||||
--arg feature_num "$FEATURE_NUM" \
|
||||
'{BRANCH_NAME:$branch_name,FEATURE_NUM:$feature_num}'
|
||||
fi
|
||||
else
|
||||
if type json_escape >/dev/null 2>&1; then
|
||||
_je_branch=$(json_escape "$BRANCH_NAME")
|
||||
_je_num=$(json_escape "$FEATURE_NUM")
|
||||
else
|
||||
_je_branch="$BRANCH_NAME"
|
||||
_je_num="$FEATURE_NUM"
|
||||
fi
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
printf '{"BRANCH_NAME":"%s","FEATURE_NUM":"%s","DRY_RUN":true}\n' "$_je_branch" "$_je_num"
|
||||
else
|
||||
printf '{"BRANCH_NAME":"%s","FEATURE_NUM":"%s"}\n' "$_je_branch" "$_je_num"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "BRANCH_NAME: $BRANCH_NAME"
|
||||
echo "FEATURE_NUM: $FEATURE_NUM"
|
||||
if [ "$DRY_RUN" != true ]; then
|
||||
printf '# To persist in your shell: export SPECIFY_FEATURE=%q\n' "$BRANCH_NAME"
|
||||
fi
|
||||
fi
|
||||
@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Git-specific common functions for the git extension.
|
||||
# Extracted from scripts/bash/common.sh — contains only git-specific
|
||||
# branch validation and detection logic.
|
||||
|
||||
# Check if we have git available at the repo root
|
||||
has_git() {
|
||||
local repo_root="${1:-$(pwd)}"
|
||||
{ [ -d "$repo_root/.git" ] || [ -f "$repo_root/.git" ]; } && \
|
||||
command -v git >/dev/null 2>&1 && \
|
||||
git -C "$repo_root" rev-parse --is-inside-work-tree >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Strip a single optional path segment (e.g. gitflow "feat/004-name" -> "004-name").
|
||||
# Only when the full name is exactly two slash-free segments; otherwise returns the raw name.
|
||||
spec_kit_effective_branch_name() {
|
||||
local raw="$1"
|
||||
if [[ "$raw" =~ ^([^/]+)/([^/]+)$ ]]; then
|
||||
printf '%s\n' "${BASH_REMATCH[2]}"
|
||||
else
|
||||
printf '%s\n' "$raw"
|
||||
fi
|
||||
}
|
||||
|
||||
# Validate that a branch name matches the expected feature branch pattern.
|
||||
# Accepts sequential (###-* with >=3 digits) or timestamp (YYYYMMDD-HHMMSS-*) formats.
|
||||
# Logic aligned with scripts/bash/common.sh check_feature_branch after effective-name normalization.
|
||||
check_feature_branch() {
|
||||
local raw="$1"
|
||||
local has_git_repo="$2"
|
||||
|
||||
# For non-git repos, we can't enforce branch naming but still provide output
|
||||
if [[ "$has_git_repo" != "true" ]]; then
|
||||
echo "[specify] Warning: Git repository not detected; skipped branch validation" >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
local branch
|
||||
branch=$(spec_kit_effective_branch_name "$raw")
|
||||
|
||||
# Accept sequential prefix (3+ digits) but exclude malformed timestamps
|
||||
# Malformed: 7-or-8 digit date + 6-digit time with no trailing slug (e.g. "2026031-143022" or "20260319-143022")
|
||||
local is_sequential=false
|
||||
if [[ "$branch" =~ ^[0-9]{3,}- ]] && [[ ! "$branch" =~ ^[0-9]{7}-[0-9]{6}- ]] && [[ ! "$branch" =~ ^[0-9]{7,8}-[0-9]{6}$ ]]; then
|
||||
is_sequential=true
|
||||
fi
|
||||
if [[ "$is_sequential" != "true" ]] && [[ ! "$branch" =~ ^[0-9]{8}-[0-9]{6}- ]]; then
|
||||
echo "ERROR: Not on a feature branch. Current branch: $raw" >&2
|
||||
echo "Feature branches should be named like: 001-feature-name, 1234-feature-name, or 20260319-143022-feature-name" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Git extension: initialize-repo.sh
|
||||
# Initialize a Git repository with an initial commit.
|
||||
# Customizable — replace this script to add .gitignore templates,
|
||||
# default branch config, git-flow, LFS, signing, etc.
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Find project root
|
||||
_find_project_root() {
|
||||
local dir="$1"
|
||||
while [ "$dir" != "/" ]; do
|
||||
if [ -d "$dir/.specify" ] || [ -d "$dir/.git" ]; then
|
||||
echo "$dir"
|
||||
return 0
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
REPO_ROOT=$(_find_project_root "$SCRIPT_DIR") || REPO_ROOT="$(pwd)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
# Read commit message from extension config, fall back to default
|
||||
COMMIT_MSG="[Spec Kit] Initial commit"
|
||||
_config_file="$REPO_ROOT/.specify/extensions/git/git-config.yml"
|
||||
if [ -f "$_config_file" ]; then
|
||||
_msg=$(grep '^init_commit_message:' "$_config_file" 2>/dev/null | sed 's/^init_commit_message:[[:space:]]*//' | sed 's/^["'\'']//' | sed 's/["'\'']*$//')
|
||||
if [ -n "$_msg" ]; then
|
||||
COMMIT_MSG="$_msg"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if git is available
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
echo "[specify] Warning: Git not found; skipped repository initialization" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if already a git repo
|
||||
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
echo "[specify] Git repository already initialized; skipping" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Initialize
|
||||
_git_out=$(git init -q 2>&1) || { echo "[specify] Error: git init failed: $_git_out" >&2; exit 1; }
|
||||
_git_out=$(git add . 2>&1) || { echo "[specify] Error: git add failed: $_git_out" >&2; exit 1; }
|
||||
_git_out=$(git commit --allow-empty -q -m "$COMMIT_MSG" 2>&1) || { echo "[specify] Error: git commit failed: $_git_out" >&2; exit 1; }
|
||||
|
||||
echo "✓ Git repository initialized" >&2
|
||||
@ -1,169 +0,0 @@
|
||||
#!/usr/bin/env pwsh
|
||||
# Git extension: auto-commit.ps1
|
||||
# Automatically commit changes after a Spec Kit command completes.
|
||||
# Checks per-command config keys in git-config.yml before committing.
|
||||
#
|
||||
# Usage: auto-commit.ps1 <event_name>
|
||||
# e.g.: auto-commit.ps1 after_specify
|
||||
param(
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[string]$EventName
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
function Find-ProjectRoot {
|
||||
param([string]$StartDir)
|
||||
$current = Resolve-Path $StartDir
|
||||
while ($true) {
|
||||
foreach ($marker in @('.specify', '.git')) {
|
||||
if (Test-Path (Join-Path $current $marker)) {
|
||||
return $current
|
||||
}
|
||||
}
|
||||
$parent = Split-Path $current -Parent
|
||||
if ($parent -eq $current) { return $null }
|
||||
$current = $parent
|
||||
}
|
||||
}
|
||||
|
||||
$repoRoot = Find-ProjectRoot -StartDir $PSScriptRoot
|
||||
if (-not $repoRoot) { $repoRoot = Get-Location }
|
||||
Set-Location $repoRoot
|
||||
|
||||
# Check if git is available
|
||||
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
|
||||
Write-Warning "[specify] Warning: Git not found; skipped auto-commit"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Temporarily relax ErrorActionPreference so git stderr warnings
|
||||
# (e.g. CRLF notices on Windows) do not become terminating errors.
|
||||
$savedEAP = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'Continue'
|
||||
try {
|
||||
git rev-parse --is-inside-work-tree 2>$null | Out-Null
|
||||
$isRepo = $LASTEXITCODE -eq 0
|
||||
} finally {
|
||||
$ErrorActionPreference = $savedEAP
|
||||
}
|
||||
if (-not $isRepo) {
|
||||
Write-Warning "[specify] Warning: Not a Git repository; skipped auto-commit"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Read per-command config from git-config.yml
|
||||
$configFile = Join-Path $repoRoot ".specify/extensions/git/git-config.yml"
|
||||
$enabled = $false
|
||||
$commitMsg = ""
|
||||
|
||||
if (Test-Path $configFile) {
|
||||
# Parse YAML to find auto_commit section
|
||||
$inAutoCommit = $false
|
||||
$inEvent = $false
|
||||
$defaultEnabled = $false
|
||||
|
||||
foreach ($line in Get-Content $configFile) {
|
||||
# Detect auto_commit: section
|
||||
if ($line -match '^auto_commit:') {
|
||||
$inAutoCommit = $true
|
||||
$inEvent = $false
|
||||
continue
|
||||
}
|
||||
|
||||
# Exit auto_commit section on next top-level key
|
||||
if ($inAutoCommit -and $line -match '^[a-z]') {
|
||||
break
|
||||
}
|
||||
|
||||
if ($inAutoCommit) {
|
||||
# Check default key
|
||||
if ($line -match '^\s+default:\s*(.+)$') {
|
||||
$val = $matches[1].Trim().ToLower()
|
||||
if ($val -eq 'true') { $defaultEnabled = $true }
|
||||
}
|
||||
|
||||
# Detect our event subsection
|
||||
if ($line -match "^\s+${EventName}:") {
|
||||
$inEvent = $true
|
||||
continue
|
||||
}
|
||||
|
||||
# Inside our event subsection
|
||||
if ($inEvent) {
|
||||
# Exit on next sibling key (2-space indent, not 4+)
|
||||
if ($line -match '^\s{2}[a-z]' -and $line -notmatch '^\s{4}') {
|
||||
$inEvent = $false
|
||||
continue
|
||||
}
|
||||
if ($line -match '\s+enabled:\s*(.+)$') {
|
||||
$val = $matches[1].Trim().ToLower()
|
||||
if ($val -eq 'true') { $enabled = $true }
|
||||
if ($val -eq 'false') { $enabled = $false }
|
||||
}
|
||||
if ($line -match '\s+message:\s*(.+)$') {
|
||||
$commitMsg = $matches[1].Trim() -replace '^["'']' -replace '["'']$'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# If event-specific key not found, use default
|
||||
if (-not $enabled -and $defaultEnabled) {
|
||||
$hasEventKey = Select-String -Path $configFile -Pattern "^\s*${EventName}:" -Quiet
|
||||
if (-not $hasEventKey) {
|
||||
$enabled = $true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
# No config file — auto-commit disabled by default
|
||||
exit 0
|
||||
}
|
||||
|
||||
if (-not $enabled) {
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Check if there are changes to commit
|
||||
# Relax ErrorActionPreference so CRLF warnings on stderr do not terminate.
|
||||
$savedEAP = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'Continue'
|
||||
try {
|
||||
git diff --quiet HEAD 2>$null; $d1 = $LASTEXITCODE
|
||||
git diff --cached --quiet 2>$null; $d2 = $LASTEXITCODE
|
||||
$untracked = git ls-files --others --exclude-standard 2>$null
|
||||
} finally {
|
||||
$ErrorActionPreference = $savedEAP
|
||||
}
|
||||
|
||||
if ($d1 -eq 0 -and $d2 -eq 0 -and -not $untracked) {
|
||||
Write-Host "[specify] No changes to commit after $EventName" -ForegroundColor DarkGray
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Derive a human-readable command name from the event
|
||||
$commandName = $EventName -replace '^after_', '' -replace '^before_', ''
|
||||
$phase = if ($EventName -match '^before_') { 'before' } else { 'after' }
|
||||
|
||||
# Use custom message if configured, otherwise default
|
||||
if (-not $commitMsg) {
|
||||
$commitMsg = "[Spec Kit] Auto-commit $phase $commandName"
|
||||
}
|
||||
|
||||
# Stage and commit
|
||||
# Relax ErrorActionPreference so CRLF warnings on stderr do not terminate,
|
||||
# while still allowing redirected error output to be captured for diagnostics.
|
||||
$savedEAP = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'Continue'
|
||||
try {
|
||||
$out = git add . 2>&1 | Out-String
|
||||
if ($LASTEXITCODE -ne 0) { throw "git add failed: $out" }
|
||||
$out = git commit -q -m $commitMsg 2>&1 | Out-String
|
||||
if ($LASTEXITCODE -ne 0) { throw "git commit failed: $out" }
|
||||
} catch {
|
||||
Write-Warning "[specify] Error: $_"
|
||||
exit 1
|
||||
} finally {
|
||||
$ErrorActionPreference = $savedEAP
|
||||
}
|
||||
|
||||
Write-Host "[OK] Changes committed $phase $commandName"
|
||||
@ -1,403 +0,0 @@
|
||||
#!/usr/bin/env pwsh
|
||||
# Git extension: create-new-feature.ps1
|
||||
# Adapted from core scripts/powershell/create-new-feature.ps1 for extension layout.
|
||||
# Sources common.ps1 from the project's installed scripts, falling back to
|
||||
# git-common.ps1 for minimal git helpers.
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[switch]$Json,
|
||||
[switch]$AllowExistingBranch,
|
||||
[switch]$DryRun,
|
||||
[string]$ShortName,
|
||||
[Parameter()]
|
||||
[long]$Number = 0,
|
||||
[switch]$Timestamp,
|
||||
[switch]$Help,
|
||||
[Parameter(Position = 0, ValueFromRemainingArguments = $true)]
|
||||
[string[]]$FeatureDescription
|
||||
)
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
if ($Help) {
|
||||
Write-Host "Usage: ./create-new-feature.ps1 [-Json] [-DryRun] [-AllowExistingBranch] [-ShortName <name>] [-Number N] [-Timestamp] <feature description>"
|
||||
Write-Host ""
|
||||
Write-Host "Options:"
|
||||
Write-Host " -Json Output in JSON format"
|
||||
Write-Host " -DryRun Compute branch name without creating the branch"
|
||||
Write-Host " -AllowExistingBranch Switch to branch if it already exists instead of failing"
|
||||
Write-Host " -ShortName <name> Provide a custom short name (2-4 words) for the branch"
|
||||
Write-Host " -Number N Specify branch number manually (overrides auto-detection)"
|
||||
Write-Host " -Timestamp Use timestamp prefix (YYYYMMDD-HHMMSS) instead of sequential numbering"
|
||||
Write-Host " -Help Show this help message"
|
||||
Write-Host ""
|
||||
Write-Host "Environment variables:"
|
||||
Write-Host " GIT_BRANCH_NAME Use this exact branch name, bypassing all prefix/suffix generation"
|
||||
Write-Host ""
|
||||
exit 0
|
||||
}
|
||||
|
||||
if (-not $FeatureDescription -or $FeatureDescription.Count -eq 0) {
|
||||
Write-Error "Usage: ./create-new-feature.ps1 [-Json] [-DryRun] [-AllowExistingBranch] [-ShortName <name>] [-Number N] [-Timestamp] <feature description>"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$featureDesc = ($FeatureDescription -join ' ').Trim()
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($featureDesc)) {
|
||||
Write-Error "Error: Feature description cannot be empty or contain only whitespace"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function Get-HighestNumberFromSpecs {
|
||||
param([string]$SpecsDir)
|
||||
|
||||
[long]$highest = 0
|
||||
if (Test-Path $SpecsDir) {
|
||||
Get-ChildItem -Path $SpecsDir -Directory | ForEach-Object {
|
||||
if ($_.Name -match '^(\d{3,})-' -and $_.Name -notmatch '^\d{8}-\d{6}-') {
|
||||
[long]$num = 0
|
||||
if ([long]::TryParse($matches[1], [ref]$num) -and $num -gt $highest) {
|
||||
$highest = $num
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $highest
|
||||
}
|
||||
|
||||
function Get-HighestNumberFromNames {
|
||||
param([string[]]$Names)
|
||||
|
||||
[long]$highest = 0
|
||||
foreach ($name in $Names) {
|
||||
if ($name -match '^(\d{3,})-' -and $name -notmatch '^\d{8}-\d{6}-') {
|
||||
[long]$num = 0
|
||||
if ([long]::TryParse($matches[1], [ref]$num) -and $num -gt $highest) {
|
||||
$highest = $num
|
||||
}
|
||||
}
|
||||
}
|
||||
return $highest
|
||||
}
|
||||
|
||||
function Get-HighestNumberFromBranches {
|
||||
param()
|
||||
|
||||
try {
|
||||
$branches = git branch -a 2>$null
|
||||
if ($LASTEXITCODE -eq 0 -and $branches) {
|
||||
$cleanNames = $branches | ForEach-Object {
|
||||
$_.Trim() -replace '^\*?\s+', '' -replace '^remotes/[^/]+/', ''
|
||||
}
|
||||
return Get-HighestNumberFromNames -Names $cleanNames
|
||||
}
|
||||
} catch {
|
||||
Write-Verbose "Could not check Git branches: $_"
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function Get-HighestNumberFromRemoteRefs {
|
||||
[long]$highest = 0
|
||||
try {
|
||||
$remotes = git remote 2>$null
|
||||
if ($remotes) {
|
||||
foreach ($remote in $remotes) {
|
||||
$env:GIT_TERMINAL_PROMPT = '0'
|
||||
$refs = git ls-remote --heads $remote 2>$null
|
||||
$env:GIT_TERMINAL_PROMPT = $null
|
||||
if ($LASTEXITCODE -eq 0 -and $refs) {
|
||||
$refNames = $refs | ForEach-Object {
|
||||
if ($_ -match 'refs/heads/(.+)$') { $matches[1] }
|
||||
} | Where-Object { $_ }
|
||||
$remoteHighest = Get-HighestNumberFromNames -Names $refNames
|
||||
if ($remoteHighest -gt $highest) { $highest = $remoteHighest }
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
Write-Verbose "Could not query remote refs: $_"
|
||||
}
|
||||
return $highest
|
||||
}
|
||||
|
||||
function Get-NextBranchNumber {
|
||||
param(
|
||||
[string]$SpecsDir,
|
||||
[switch]$SkipFetch
|
||||
)
|
||||
|
||||
if ($SkipFetch) {
|
||||
$highestBranch = Get-HighestNumberFromBranches
|
||||
$highestRemote = Get-HighestNumberFromRemoteRefs
|
||||
$highestBranch = [Math]::Max($highestBranch, $highestRemote)
|
||||
} else {
|
||||
try {
|
||||
git fetch --all --prune 2>$null | Out-Null
|
||||
} catch { }
|
||||
$highestBranch = Get-HighestNumberFromBranches
|
||||
}
|
||||
|
||||
$highestSpec = Get-HighestNumberFromSpecs -SpecsDir $SpecsDir
|
||||
$maxNum = [Math]::Max($highestBranch, $highestSpec)
|
||||
return $maxNum + 1
|
||||
}
|
||||
|
||||
function ConvertTo-CleanBranchName {
|
||||
param([string]$Name)
|
||||
return $Name.ToLower() -replace '[^a-z0-9]', '-' -replace '-{2,}', '-' -replace '^-', '' -replace '-$', ''
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Source common.ps1 from the project's installed scripts.
|
||||
# Search locations in priority order:
|
||||
# 1. .specify/scripts/powershell/common.ps1 under the project root
|
||||
# 2. scripts/powershell/common.ps1 under the project root (source checkout)
|
||||
# 3. git-common.ps1 next to this script (minimal fallback)
|
||||
# ---------------------------------------------------------------------------
|
||||
function Find-ProjectRoot {
|
||||
param([string]$StartDir)
|
||||
$current = Resolve-Path $StartDir
|
||||
while ($true) {
|
||||
foreach ($marker in @('.specify', '.git')) {
|
||||
if (Test-Path (Join-Path $current $marker)) {
|
||||
return $current
|
||||
}
|
||||
}
|
||||
$parent = Split-Path $current -Parent
|
||||
if ($parent -eq $current) { return $null }
|
||||
$current = $parent
|
||||
}
|
||||
}
|
||||
|
||||
$projectRoot = Find-ProjectRoot -StartDir $PSScriptRoot
|
||||
$commonLoaded = $false
|
||||
|
||||
if ($projectRoot) {
|
||||
$candidates = @(
|
||||
(Join-Path $projectRoot ".specify/scripts/powershell/common.ps1"),
|
||||
(Join-Path $projectRoot "scripts/powershell/common.ps1")
|
||||
)
|
||||
foreach ($candidate in $candidates) {
|
||||
if (Test-Path $candidate) {
|
||||
. $candidate
|
||||
$commonLoaded = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $commonLoaded -and (Test-Path "$PSScriptRoot/git-common.ps1")) {
|
||||
. "$PSScriptRoot/git-common.ps1"
|
||||
$commonLoaded = $true
|
||||
}
|
||||
|
||||
if (-not $commonLoaded) {
|
||||
throw "Unable to locate common script file. Please ensure the Specify core scripts are installed."
|
||||
}
|
||||
|
||||
# Resolve repository root
|
||||
if (Get-Command Get-RepoRoot -ErrorAction SilentlyContinue) {
|
||||
$repoRoot = Get-RepoRoot
|
||||
} elseif ($projectRoot) {
|
||||
$repoRoot = $projectRoot
|
||||
} else {
|
||||
throw "Could not determine repository root."
|
||||
}
|
||||
|
||||
# Check if git is available
|
||||
if (Get-Command Test-HasGit -ErrorAction SilentlyContinue) {
|
||||
# Call without parameters for compatibility with core common.ps1 (no -RepoRoot param)
|
||||
# and git-common.ps1 (has -RepoRoot param with default).
|
||||
$hasGit = Test-HasGit
|
||||
} else {
|
||||
try {
|
||||
git -C $repoRoot rev-parse --is-inside-work-tree 2>$null | Out-Null
|
||||
$hasGit = ($LASTEXITCODE -eq 0)
|
||||
} catch {
|
||||
$hasGit = $false
|
||||
}
|
||||
}
|
||||
|
||||
Set-Location $repoRoot
|
||||
|
||||
$specsDir = Join-Path $repoRoot 'specs'
|
||||
|
||||
function Get-BranchName {
|
||||
param([string]$Description)
|
||||
|
||||
$stopWords = @(
|
||||
'i', 'a', 'an', 'the', 'to', 'for', 'of', 'in', 'on', 'at', 'by', 'with', 'from',
|
||||
'is', 'are', 'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had',
|
||||
'do', 'does', 'did', 'will', 'would', 'should', 'could', 'can', 'may', 'might', 'must', 'shall',
|
||||
'this', 'that', 'these', 'those', 'my', 'your', 'our', 'their',
|
||||
'want', 'need', 'add', 'get', 'set'
|
||||
)
|
||||
|
||||
$cleanName = $Description.ToLower() -replace '[^a-z0-9\s]', ' '
|
||||
$words = $cleanName -split '\s+' | Where-Object { $_ }
|
||||
|
||||
$meaningfulWords = @()
|
||||
foreach ($word in $words) {
|
||||
if ($stopWords -contains $word) { continue }
|
||||
if ($word.Length -ge 3) {
|
||||
$meaningfulWords += $word
|
||||
} elseif ($Description -match "\b$($word.ToUpper())\b") {
|
||||
$meaningfulWords += $word
|
||||
}
|
||||
}
|
||||
|
||||
if ($meaningfulWords.Count -gt 0) {
|
||||
$maxWords = if ($meaningfulWords.Count -eq 4) { 4 } else { 3 }
|
||||
$result = ($meaningfulWords | Select-Object -First $maxWords) -join '-'
|
||||
return $result
|
||||
} else {
|
||||
$result = ConvertTo-CleanBranchName -Name $Description
|
||||
$fallbackWords = ($result -split '-') | Where-Object { $_ } | Select-Object -First 3
|
||||
return [string]::Join('-', $fallbackWords)
|
||||
}
|
||||
}
|
||||
|
||||
# Check for GIT_BRANCH_NAME env var override (exact branch name, no prefix/suffix)
|
||||
if ($env:GIT_BRANCH_NAME) {
|
||||
$branchName = $env:GIT_BRANCH_NAME
|
||||
# Check 244-byte limit (UTF-8) for override names
|
||||
$branchNameUtf8ByteCount = [System.Text.Encoding]::UTF8.GetByteCount($branchName)
|
||||
if ($branchNameUtf8ByteCount -gt 244) {
|
||||
throw "GIT_BRANCH_NAME must be 244 bytes or fewer in UTF-8. Provided value is $branchNameUtf8ByteCount bytes; please supply a shorter override branch name."
|
||||
}
|
||||
# Extract FEATURE_NUM from the branch name if it starts with a numeric prefix
|
||||
# Check timestamp pattern first (YYYYMMDD-HHMMSS-) since it also matches the simpler ^\d+ pattern
|
||||
if ($branchName -match '^(\d{8}-\d{6})-') {
|
||||
$featureNum = $matches[1]
|
||||
} elseif ($branchName -match '^(\d+)-') {
|
||||
$featureNum = $matches[1]
|
||||
} else {
|
||||
$featureNum = $branchName
|
||||
}
|
||||
} else {
|
||||
if ($ShortName) {
|
||||
$branchSuffix = ConvertTo-CleanBranchName -Name $ShortName
|
||||
} else {
|
||||
$branchSuffix = Get-BranchName -Description $featureDesc
|
||||
}
|
||||
|
||||
if ($Timestamp -and $Number -ne 0) {
|
||||
Write-Warning "[specify] Warning: -Number is ignored when -Timestamp is used"
|
||||
$Number = 0
|
||||
}
|
||||
|
||||
if ($Timestamp) {
|
||||
$featureNum = Get-Date -Format 'yyyyMMdd-HHmmss'
|
||||
$branchName = "$featureNum-$branchSuffix"
|
||||
} else {
|
||||
if ($Number -eq 0) {
|
||||
if ($DryRun -and $hasGit) {
|
||||
$Number = Get-NextBranchNumber -SpecsDir $specsDir -SkipFetch
|
||||
} elseif ($DryRun) {
|
||||
$Number = (Get-HighestNumberFromSpecs -SpecsDir $specsDir) + 1
|
||||
} elseif ($hasGit) {
|
||||
$Number = Get-NextBranchNumber -SpecsDir $specsDir
|
||||
} else {
|
||||
$Number = (Get-HighestNumberFromSpecs -SpecsDir $specsDir) + 1
|
||||
}
|
||||
}
|
||||
|
||||
$featureNum = ('{0:000}' -f $Number)
|
||||
$branchName = "$featureNum-$branchSuffix"
|
||||
}
|
||||
}
|
||||
|
||||
$maxBranchLength = 244
|
||||
if ($branchName.Length -gt $maxBranchLength) {
|
||||
$prefixLength = $featureNum.Length + 1
|
||||
$maxSuffixLength = $maxBranchLength - $prefixLength
|
||||
|
||||
$truncatedSuffix = $branchSuffix.Substring(0, [Math]::Min($branchSuffix.Length, $maxSuffixLength))
|
||||
$truncatedSuffix = $truncatedSuffix -replace '-$', ''
|
||||
|
||||
$originalBranchName = $branchName
|
||||
$branchName = "$featureNum-$truncatedSuffix"
|
||||
|
||||
Write-Warning "[specify] Branch name exceeded GitHub's 244-byte limit"
|
||||
Write-Warning "[specify] Original: $originalBranchName ($($originalBranchName.Length) bytes)"
|
||||
Write-Warning "[specify] Truncated to: $branchName ($($branchName.Length) bytes)"
|
||||
}
|
||||
|
||||
if (-not $DryRun) {
|
||||
if ($hasGit) {
|
||||
$branchCreated = $false
|
||||
$branchCreateError = ''
|
||||
try {
|
||||
$branchCreateError = git checkout -q -b $branchName 2>&1 | Out-String
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$branchCreated = $true
|
||||
}
|
||||
} catch {
|
||||
$branchCreateError = $_.Exception.Message
|
||||
}
|
||||
|
||||
if (-not $branchCreated) {
|
||||
$currentBranch = ''
|
||||
try { $currentBranch = (git rev-parse --abbrev-ref HEAD 2>$null).Trim() } catch {}
|
||||
$existingBranch = git branch --list $branchName 2>$null
|
||||
if ($existingBranch) {
|
||||
if ($AllowExistingBranch) {
|
||||
if ($currentBranch -eq $branchName) {
|
||||
# Already on the target branch
|
||||
} else {
|
||||
$switchBranchError = git checkout -q $branchName 2>&1 | Out-String
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
if ($switchBranchError) {
|
||||
Write-Error "Error: Branch '$branchName' exists but could not be checked out.`n$($switchBranchError.Trim())"
|
||||
} else {
|
||||
Write-Error "Error: Branch '$branchName' exists but could not be checked out. Resolve any uncommitted changes or conflicts and try again."
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
} elseif ($Timestamp) {
|
||||
Write-Error "Error: Branch '$branchName' already exists. Rerun to get a new timestamp or use a different -ShortName."
|
||||
exit 1
|
||||
} else {
|
||||
Write-Error "Error: Branch '$branchName' already exists. Please use a different feature name or specify a different number with -Number."
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
if ($branchCreateError) {
|
||||
Write-Error "Error: Failed to create git branch '$branchName'.`n$($branchCreateError.Trim())"
|
||||
} else {
|
||||
Write-Error "Error: Failed to create git branch '$branchName'. Please check your git configuration and try again."
|
||||
}
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($Json) {
|
||||
[Console]::Error.WriteLine("[specify] Warning: Git repository not detected; skipped branch creation for $branchName")
|
||||
} else {
|
||||
Write-Warning "[specify] Warning: Git repository not detected; skipped branch creation for $branchName"
|
||||
}
|
||||
}
|
||||
|
||||
$env:SPECIFY_FEATURE = $branchName
|
||||
}
|
||||
|
||||
if ($Json) {
|
||||
$obj = [PSCustomObject]@{
|
||||
BRANCH_NAME = $branchName
|
||||
FEATURE_NUM = $featureNum
|
||||
HAS_GIT = $hasGit
|
||||
}
|
||||
if ($DryRun) {
|
||||
$obj | Add-Member -NotePropertyName 'DRY_RUN' -NotePropertyValue $true
|
||||
}
|
||||
$obj | ConvertTo-Json -Compress
|
||||
} else {
|
||||
Write-Output "BRANCH_NAME: $branchName"
|
||||
Write-Output "FEATURE_NUM: $featureNum"
|
||||
Write-Output "HAS_GIT: $hasGit"
|
||||
if (-not $DryRun) {
|
||||
Write-Output "SPECIFY_FEATURE environment variable set to: $branchName"
|
||||
}
|
||||
}
|
||||
@ -1,51 +0,0 @@
|
||||
#!/usr/bin/env pwsh
|
||||
# Git-specific common functions for the git extension.
|
||||
# Extracted from scripts/powershell/common.ps1 — contains only git-specific
|
||||
# branch validation and detection logic.
|
||||
|
||||
function Test-HasGit {
|
||||
param([string]$RepoRoot = (Get-Location))
|
||||
try {
|
||||
if (-not (Test-Path (Join-Path $RepoRoot '.git'))) { return $false }
|
||||
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { return $false }
|
||||
git -C $RepoRoot rev-parse --is-inside-work-tree 2>$null | Out-Null
|
||||
return ($LASTEXITCODE -eq 0)
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
||||
function Get-SpecKitEffectiveBranchName {
|
||||
param([string]$Branch)
|
||||
if ($Branch -match '^([^/]+)/([^/]+)$') {
|
||||
return $Matches[2]
|
||||
}
|
||||
return $Branch
|
||||
}
|
||||
|
||||
function Test-FeatureBranch {
|
||||
param(
|
||||
[string]$Branch,
|
||||
[bool]$HasGit = $true
|
||||
)
|
||||
|
||||
# For non-git repos, we can't enforce branch naming but still provide output
|
||||
if (-not $HasGit) {
|
||||
Write-Warning "[specify] Warning: Git repository not detected; skipped branch validation"
|
||||
return $true
|
||||
}
|
||||
|
||||
$raw = $Branch
|
||||
$Branch = Get-SpecKitEffectiveBranchName $raw
|
||||
|
||||
# Accept sequential prefix (3+ digits) but exclude malformed timestamps
|
||||
# Malformed: 7-or-8 digit date + 6-digit time with no trailing slug (e.g. "2026031-143022" or "20260319-143022")
|
||||
$hasMalformedTimestamp = ($Branch -match '^[0-9]{7}-[0-9]{6}-') -or ($Branch -match '^(?:\d{7}|\d{8})-\d{6}$')
|
||||
$isSequential = ($Branch -match '^[0-9]{3,}-') -and (-not $hasMalformedTimestamp)
|
||||
if (-not $isSequential -and $Branch -notmatch '^\d{8}-\d{6}-') {
|
||||
[Console]::Error.WriteLine("ERROR: Not on a feature branch. Current branch: $raw")
|
||||
[Console]::Error.WriteLine("Feature branches should be named like: 001-feature-name, 1234-feature-name, or 20260319-143022-feature-name")
|
||||
return $false
|
||||
}
|
||||
return $true
|
||||
}
|
||||
@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env pwsh
|
||||
# Git extension: initialize-repo.ps1
|
||||
# Initialize a Git repository with an initial commit.
|
||||
# Customizable — replace this script to add .gitignore templates,
|
||||
# default branch config, git-flow, LFS, signing, etc.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
# Find project root
|
||||
function Find-ProjectRoot {
|
||||
param([string]$StartDir)
|
||||
$current = Resolve-Path $StartDir
|
||||
while ($true) {
|
||||
foreach ($marker in @('.specify', '.git')) {
|
||||
if (Test-Path (Join-Path $current $marker)) {
|
||||
return $current
|
||||
}
|
||||
}
|
||||
$parent = Split-Path $current -Parent
|
||||
if ($parent -eq $current) { return $null }
|
||||
$current = $parent
|
||||
}
|
||||
}
|
||||
|
||||
$repoRoot = Find-ProjectRoot -StartDir $PSScriptRoot
|
||||
if (-not $repoRoot) { $repoRoot = Get-Location }
|
||||
Set-Location $repoRoot
|
||||
|
||||
# Read commit message from extension config, fall back to default
|
||||
$commitMsg = "[Spec Kit] Initial commit"
|
||||
$configFile = Join-Path $repoRoot ".specify/extensions/git/git-config.yml"
|
||||
if (Test-Path $configFile) {
|
||||
foreach ($line in Get-Content $configFile) {
|
||||
if ($line -match '^init_commit_message:\s*(.+)$') {
|
||||
$val = $matches[1].Trim() -replace '^["'']' -replace '["'']$'
|
||||
if ($val) { $commitMsg = $val }
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Check if git is available
|
||||
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
|
||||
Write-Warning "[specify] Warning: Git not found; skipped repository initialization"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Check if already a git repo
|
||||
try {
|
||||
git rev-parse --is-inside-work-tree 2>$null | Out-Null
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Warning "[specify] Git repository already initialized; skipping"
|
||||
exit 0
|
||||
}
|
||||
} catch { }
|
||||
|
||||
# Initialize
|
||||
try {
|
||||
$out = git init -q 2>&1 | Out-String
|
||||
if ($LASTEXITCODE -ne 0) { throw "git init failed: $out" }
|
||||
$out = git add . 2>&1 | Out-String
|
||||
if ($LASTEXITCODE -ne 0) { throw "git add failed: $out" }
|
||||
$out = git commit --allow-empty -q -m $commitMsg 2>&1 | Out-String
|
||||
if ($LASTEXITCODE -ne 0) { throw "git commit failed: $out" }
|
||||
} catch {
|
||||
Write-Warning "[specify] Error: $_"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "✓ Git repository initialized"
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"ai": "copilot",
|
||||
"branch_numbering": "sequential",
|
||||
"context_file": ".github/copilot-instructions.md",
|
||||
"here": true,
|
||||
"integration": "copilot",
|
||||
"preset": null,
|
||||
"script": "sh",
|
||||
"speckit_version": "0.7.4"
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
{
|
||||
"integration": "copilot",
|
||||
"version": "0.7.4"
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
{
|
||||
"integration": "copilot",
|
||||
"version": "0.7.4",
|
||||
"installed_at": "2026-04-22T21:58:02.962169+00:00",
|
||||
"files": {
|
||||
".github/agents/speckit.analyze.agent.md": "699032fdd49afe31d23c7191f3fe7bcb1d14b081fbc94c2287e6ba3a57574fda",
|
||||
".github/agents/speckit.checklist.agent.md": "d7d691689fe45427c868dcf18ade4df500f0c742a6c91923fefba405d6466dde",
|
||||
".github/agents/speckit.clarify.agent.md": "0cc766dcc5cab233ccdf3bc4cfb5759a6d7d1e13e29f611083046f818f5812bb",
|
||||
".github/agents/speckit.constitution.agent.md": "58d35eb026f56bb7364d91b8b0382d5dd1249ded6c1449a2b69546693afb85f7",
|
||||
".github/agents/speckit.implement.agent.md": "83628415c86ba487b3a083c7a2c0f016c9073abd02c1c7f4a30cff949b6602c0",
|
||||
".github/agents/speckit.plan.agent.md": "2ad128b81ccd8f5bfa78b3b43101f377dfddd8f800fa0856f85bf53b1489b783",
|
||||
".github/agents/speckit.specify.agent.md": "5bbb5270836cc9a3286ce3ed96a500f3d383a54abb06aa11b01a2d2f76dbf39b",
|
||||
".github/agents/speckit.tasks.agent.md": "a58886f29f75e1a14840007772ddd954742aafb3e03d9d1231bee033e6c1626b",
|
||||
".github/agents/speckit.taskstoissues.agent.md": "e84794f7a839126defb364ca815352c5c2b2d20db2d6da399fa53e4ddbb7b3ee",
|
||||
".github/prompts/speckit.analyze.prompt.md": "bb93dbbafa96d07b7cd07fc7061d8adb0c6b26cb772a52d0dce263b1ca2b9b77",
|
||||
".github/prompts/speckit.checklist.prompt.md": "c3aea7526c5cbfd8665acc9508ad5a9a3f71e91a63c36be7bed13a834c3a683c",
|
||||
".github/prompts/speckit.clarify.prompt.md": "ce79b3437ca918d46ac858eb4b8b44d3b0a02c563660c60d94c922a7b5d8d4f4",
|
||||
".github/prompts/speckit.constitution.prompt.md": "38f937279de14387601422ddfda48365debdbaf47b2d513527b8f6d8a27d499d",
|
||||
".github/prompts/speckit.implement.prompt.md": "5053a17fb9238338c63b898ee9c80b2cb4ad1a90c6071fe3748de76864ac6a80",
|
||||
".github/prompts/speckit.plan.prompt.md": "2098dae6bd9277335f31cb150b78bfb1de539c0491798e5cfe382c89ab0bcd0e",
|
||||
".github/prompts/speckit.specify.prompt.md": "7b2cc4dc6462da1c96df46bac4f60e53baba3097f4b24ac3f9b684194458aa98",
|
||||
".github/prompts/speckit.tasks.prompt.md": "88fc57c289f99d5e9d35c255f3e2683f73ecb0a5155dcb4d886f82f52b11841f",
|
||||
".github/prompts/speckit.taskstoissues.prompt.md": "2f9636d4f312a1470f000747cb62677fec0655d8b4e2357fa4fbf238965fa66d"
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
{
|
||||
"integration": "speckit",
|
||||
"version": "0.7.4",
|
||||
"installed_at": "2026-04-22T21:58:02.965809+00:00",
|
||||
"files": {
|
||||
".specify/templates/constitution-template.md": "ce7549540fa45543cca797a150201d868e64495fdff39dc38246fb17bd4024b3"
|
||||
}
|
||||
}
|
||||
@ -1,34 +1,21 @@
|
||||
<!--
|
||||
Sync Impact Report
|
||||
|
||||
- Version change: 2.7.0 -> 2.8.0
|
||||
- Modified principles: None
|
||||
- Added sections:
|
||||
- Pre-Production Lean Doctrine (LEAN-001): forbids legacy aliases,
|
||||
migration shims, dual-write logic, and compatibility fixtures in a
|
||||
pre-production codebase; includes AI-agent verification checklist,
|
||||
review rule, and explicit exit condition at first production deploy
|
||||
- Shared Pattern First For Cross-Cutting Interaction Classes
|
||||
(XCUT-001): requires shared contracts/presenters/builders for
|
||||
notifications, status messaging, action links, dashboard signals,
|
||||
navigation, and similar interaction classes before any local
|
||||
domain-specific variant is allowed
|
||||
- Version change: 2.5.0 -> 2.6.0
|
||||
- Modified principles:
|
||||
- UI surface taxonomy and review expectations: expanded with native
|
||||
vs custom classification, shared-detail host ownership, named
|
||||
anti-patterns, and shell/page/detail state ownership review
|
||||
- Filament Native First / No Ad-hoc Styling (UI-FIL-001): expanded
|
||||
into explicit native-by-default, fake-native, shared-family, and
|
||||
exception-boundary language
|
||||
- Added sections: None
|
||||
- Removed sections: None
|
||||
- Templates requiring updates:
|
||||
- .specify/templates/spec-template.md: added "Compatibility posture"
|
||||
default block ✅
|
||||
- .specify/templates/spec-template.md: add cross-cutting shared-pattern
|
||||
reuse block ✅
|
||||
- .specify/templates/plan-template.md: add shared pattern and system
|
||||
fit section ✅
|
||||
- .specify/templates/tasks-template.md: add cross-cutting reuse task
|
||||
requirements ✅
|
||||
- .specify/templates/checklist-template.md: add shared-pattern reuse
|
||||
review checks ✅
|
||||
- .github/agents/copilot-instructions.md: added "Pre-production
|
||||
compatibility check" agent checklist ✅
|
||||
- None in this docs-only constitution slice; enforcement remains
|
||||
deferred to Spec 201
|
||||
- Commands checked:
|
||||
- N/A `.specify/templates/commands/*.md` directory is not present
|
||||
- N/A `.specify/templates/commands/*.md` directory is not present in this repo
|
||||
- Follow-up TODOs: None
|
||||
-->
|
||||
|
||||
@ -83,14 +70,6 @@ ### UI Semantics Must Not Become Their Own Framework (UI-SEM-001)
|
||||
- Direct mapping from canonical domain truth to UI is preferred over intermediate semantic superstructures.
|
||||
- Presentation helpers SHOULD remain optional adapters, not mandatory architecture.
|
||||
|
||||
### Shared Pattern First For Cross-Cutting Interaction Classes (XCUT-001)
|
||||
- Cross-cutting interaction classes such as notifications, status messaging, action links, header actions, dashboard signals/cards, navigation entry points, alerts, evidence/report viewers, and similar operator-facing infrastructure MUST first attach to an existing shared contract, presenter, builder, renderer, or other shared path when one already exists.
|
||||
- New local or domain-specific implementations for an existing interaction class are allowed only when the current shared path is demonstrably insufficient for current-release truth.
|
||||
- The active spec MUST name the shared path being reused or explicitly record the deviation, why the existing path is insufficient, what consistency must still be preserved, and what ownership or spread-control cost the deviation creates.
|
||||
- The same interaction class MUST NOT develop parallel operator-facing UX languages for title/body/action structure, status semantics, action-label patterns, or deep-link behavior unless the deviation is explicit and justified.
|
||||
- Reviews MUST treat undocumented bypass of an existing shared path as drift and block merge until the feature converges on the shared path or records a bounded exception.
|
||||
- If the drift is discovered only after a feature is already implemented, the remedy is NOT to rewrite historical closed specs retroactively by default; instead the active work MUST record the issue as `document-in-feature` or escalate it as `follow-up-spec`, depending on whether the drift is contained or structural.
|
||||
|
||||
### V1 Prefers Explicit Narrow Implementations (V1-EXP-001)
|
||||
- For V1 and early product maturity, direct implementation, local mapping, explicit per-domain logic, small focused helpers, derived read models, and minimal UI adapters are preferred.
|
||||
- Generic platform engines, meta-frameworks, universal resolver systems, workflow frameworks, and broad semantic taxonomies are disfavored until real variance proves them necessary.
|
||||
@ -154,37 +133,6 @@ ### Spec Candidate Gate (SPEC-GATE-001)
|
||||
### Default Bias (BIAS-001)
|
||||
- Default codebase bias is: derive before persist, map before frameworkize, localize before generalize, simplify before extend, replace before layer, explicit before generic, and present directly before interpreting recursively.
|
||||
|
||||
### Pre-Production Lean Doctrine (LEAN-001)
|
||||
|
||||
This product has no production deployment, no live customer data, no shared staging with migration-relevant state, and no external API contract consumers.
|
||||
|
||||
#### Data and schema
|
||||
- Old data shapes, column names, enum values, and operation types MAY be replaced in place.
|
||||
- Migration shims, dual-write logic, and fallback readers MUST NOT be created unless a spec explicitly requires compatibility behavior.
|
||||
|
||||
#### Terminology and types
|
||||
- Renamed or unified operation types, reason codes, and status values MUST replace the old value everywhere (code, config, tests, fixtures, seed data).
|
||||
- Legacy aliases kept "just in case" are forbidden.
|
||||
|
||||
#### Codebase hygiene
|
||||
- Dead constants, dead enum cases, orphan config keys, and test fixtures that reference replaced shapes MUST be removed in the same PR that introduces the replacement.
|
||||
- "Old runs / old rows don't matter" is the standing assumption until the product ships.
|
||||
|
||||
#### AI-agent rule
|
||||
- Before adding aliases, fallback readers, dual-write logic, migration shims, or legacy fixtures, agents MUST verify:
|
||||
1. Do live production data exist?
|
||||
2. Is shared staging migration-relevant?
|
||||
3. Does an external contract depend on the old shape?
|
||||
4. Does the spec explicitly require compatibility behavior?
|
||||
- If all answers are no, replace the old shape and remove the compatibility path.
|
||||
|
||||
#### Review rule
|
||||
- Any PR that introduces a new legacy alias, compatibility shim, or historical fixture without answering the four questions above is a merge blocker.
|
||||
|
||||
#### Exit condition
|
||||
- LEAN-001 expires when the first production deployment occurs.
|
||||
- At that point, the constitution MUST be amended to define the real migration and compatibility policy.
|
||||
|
||||
### Workspace Isolation is Non-negotiable
|
||||
- Workspace membership is an isolation boundary. If the actor is not entitled to the workspace scope, the system MUST respond as
|
||||
deny-as-not-found (404).
|
||||
@ -1625,4 +1573,4 @@ ### Versioning Policy (SemVer)
|
||||
- **MINOR**: new principle/section or materially expanded guidance.
|
||||
- **MAJOR**: removing/redefining principles in a backward-incompatible way.
|
||||
|
||||
**Version**: 2.7.0 | **Ratified**: 2026-01-03 | **Last Amended**: 2025-07-19
|
||||
**Version**: 2.6.0 | **Ratified**: 2026-01-03 | **Last Amended**: 2026-04-18
|
||||
|
||||
@ -26,24 +26,18 @@ ## Native, Shared-Family, And State Ownership
|
||||
- [ ] CHK005 Shell, page, detail, and URL/query state owners are named once and do not collapse into one another.
|
||||
- [ ] CHK006 The likely next operator action and the primary inspect/open model stay coherent with the declared surface class.
|
||||
|
||||
## Shared Pattern Reuse
|
||||
|
||||
- [ ] CHK007 Any cross-cutting interaction class is explicitly marked, and the existing shared contract/presenter/builder/renderer path is named once.
|
||||
- [ ] CHK008 The change extends the shared path where it is sufficient, or the deviation is explicitly documented with product reason, preserved consistency, ownership cost, and spread-control.
|
||||
- [ ] CHK009 The change does not create a parallel operator-facing UX language for the same interaction class unless a bounded exception is recorded.
|
||||
|
||||
## Signals, Exceptions, And Test Depth
|
||||
|
||||
- [ ] CHK010 Any triggered repository signal is classified with one handling mode: `hard-stop-candidate`, `review-mandatory`, `exception-required`, or `report-only`.
|
||||
- [ ] CHK011 Any deviation from default rules includes a bounded exception record naming the broken rule, product reason, standardized parts, spread-control rule, and the active feature PR close-out entry.
|
||||
- [ ] CHK012 The required surface test profile is explicit: `shared-detail-family`, `monitoring-state-page`, `global-context-shell`, `exception-coded-surface`, or `standard-native-filament`.
|
||||
- [ ] CHK013 The chosen test family/lane and any manual smoke are the narrowest honest proof for the declared surface class, and `standard-native-filament` relief is used when no special contract exists.
|
||||
- [ ] CHK007 Any triggered repository signal is classified with one handling mode: `hard-stop-candidate`, `review-mandatory`, `exception-required`, or `report-only`.
|
||||
- [ ] CHK008 Any deviation from default rules includes a bounded exception record naming the broken rule, product reason, standardized parts, spread-control rule, and the active feature PR close-out entry.
|
||||
- [ ] CHK009 The required surface test profile is explicit: `shared-detail-family`, `monitoring-state-page`, `global-context-shell`, `exception-coded-surface`, or `standard-native-filament`.
|
||||
- [ ] CHK010 The chosen test family/lane and any manual smoke are the narrowest honest proof for the declared surface class, and `standard-native-filament` relief is used when no special contract exists.
|
||||
|
||||
## Review Outcome
|
||||
|
||||
- [ ] CHK014 One review outcome class is chosen: `blocker`, `strong-warning`, `documentation-required-exception`, or `acceptable-special-case`.
|
||||
- [ ] CHK015 One workflow outcome is chosen: `keep`, `split`, `document-in-feature`, `follow-up-spec`, or `reject-or-split`.
|
||||
- [ ] CHK016 The final note location is explicit: the active feature PR close-out entry for guarded work, or a concise `N/A` note for low-impact changes.
|
||||
- [ ] CHK011 One review outcome class is chosen: `blocker`, `strong-warning`, `documentation-required-exception`, or `acceptable-special-case`.
|
||||
- [ ] CHK012 One workflow outcome is chosen: `keep`, `split`, `document-in-feature`, `follow-up-spec`, or `reject-or-split`.
|
||||
- [ ] CHK013 The final note location is explicit: the active feature PR close-out entry for guarded work, or a concise `N/A` note for low-impact changes.
|
||||
|
||||
## Notes
|
||||
|
||||
@ -54,7 +48,7 @@ ## Notes
|
||||
- `keep`: the current scope, guardrail handling, and proof depth are justified.
|
||||
- `split`: the intent is valid, but the scope should narrow before merge.
|
||||
- `document-in-feature`: the change is acceptable, but the active feature must record the exception, signal handling, or proof notes explicitly.
|
||||
- `follow-up-spec`: the issue is recurring or structural and needs dedicated governance follow-up. For already-implemented historical drift, prefer a follow-up spec or active feature note instead of retroactively rewriting closed specs.
|
||||
- `follow-up-spec`: the issue is recurring or structural and needs dedicated governance follow-up.
|
||||
- `reject-or-split`: hidden drift, unresolved exception spread, or wrong proof depth blocks merge as proposed.
|
||||
- Check items off as completed: `[x]`
|
||||
- Add comments or findings inline
|
||||
|
||||
@ -1,50 +0,0 @@
|
||||
# [PROJECT_NAME] Constitution
|
||||
<!-- Example: Spec Constitution, TaskFlow Constitution, etc. -->
|
||||
|
||||
## Core Principles
|
||||
|
||||
### [PRINCIPLE_1_NAME]
|
||||
<!-- Example: I. Library-First -->
|
||||
[PRINCIPLE_1_DESCRIPTION]
|
||||
<!-- Example: Every feature starts as a standalone library; Libraries must be self-contained, independently testable, documented; Clear purpose required - no organizational-only libraries -->
|
||||
|
||||
### [PRINCIPLE_2_NAME]
|
||||
<!-- Example: II. CLI Interface -->
|
||||
[PRINCIPLE_2_DESCRIPTION]
|
||||
<!-- Example: Every library exposes functionality via CLI; Text in/out protocol: stdin/args → stdout, errors → stderr; Support JSON + human-readable formats -->
|
||||
|
||||
### [PRINCIPLE_3_NAME]
|
||||
<!-- Example: III. Test-First (NON-NEGOTIABLE) -->
|
||||
[PRINCIPLE_3_DESCRIPTION]
|
||||
<!-- Example: TDD mandatory: Tests written → User approved → Tests fail → Then implement; Red-Green-Refactor cycle strictly enforced -->
|
||||
|
||||
### [PRINCIPLE_4_NAME]
|
||||
<!-- Example: IV. Integration Testing -->
|
||||
[PRINCIPLE_4_DESCRIPTION]
|
||||
<!-- Example: Focus areas requiring integration tests: New library contract tests, Contract changes, Inter-service communication, Shared schemas -->
|
||||
|
||||
### [PRINCIPLE_5_NAME]
|
||||
<!-- Example: V. Observability, VI. Versioning & Breaking Changes, VII. Simplicity -->
|
||||
[PRINCIPLE_5_DESCRIPTION]
|
||||
<!-- Example: Text I/O ensures debuggability; Structured logging required; Or: MAJOR.MINOR.BUILD format; Or: Start simple, YAGNI principles -->
|
||||
|
||||
## [SECTION_2_NAME]
|
||||
<!-- Example: Additional Constraints, Security Requirements, Performance Standards, etc. -->
|
||||
|
||||
[SECTION_2_CONTENT]
|
||||
<!-- Example: Technology stack requirements, compliance standards, deployment policies, etc. -->
|
||||
|
||||
## [SECTION_3_NAME]
|
||||
<!-- Example: Development Workflow, Review Process, Quality Gates, etc. -->
|
||||
|
||||
[SECTION_3_CONTENT]
|
||||
<!-- Example: Code review requirements, testing gates, deployment approval process, etc. -->
|
||||
|
||||
## Governance
|
||||
<!-- Example: Constitution supersedes all other practices; Amendments require documentation, approval, migration plan -->
|
||||
|
||||
[GOVERNANCE_RULES]
|
||||
<!-- Example: All PRs/reviews must verify compliance; Complexity must be justified; Use [GUIDANCE_FILE] for runtime development guidance -->
|
||||
|
||||
**Version**: [CONSTITUTION_VERSION] | **Ratified**: [RATIFICATION_DATE] | **Last Amended**: [LAST_AMENDED_DATE]
|
||||
<!-- Example: Version: 2.1.1 | Ratified: 2025-06-13 | Last Amended: 2025-07-16 -->
|
||||
@ -43,17 +43,6 @@ ## UI / Surface Guardrail Plan
|
||||
- **Exception path and spread control**: [none / describe the named exception boundary]
|
||||
- **Active feature PR close-out entry**: [Guardrail / Exception / Smoke Coverage / N/A]
|
||||
|
||||
## Shared Pattern & System Fit
|
||||
|
||||
> **Fill when the feature touches notifications, status messaging, action links, header actions, dashboard signals/cards, navigation entry points, alerts, evidence/report viewers, or any other shared interaction family. Docs-only or template-only work may use concise `N/A`. Carry the same decision forward from the spec instead of renaming it here.**
|
||||
|
||||
- **Cross-cutting feature marker**: [yes / no / N/A]
|
||||
- **Systems touched**: [List the existing shared systems or `N/A`]
|
||||
- **Shared abstractions reused**: [Named contracts / presenters / builders / renderers / helpers or `N/A`]
|
||||
- **New abstraction introduced? why?**: [none / short explanation]
|
||||
- **Why the existing abstraction was sufficient or insufficient**: [Short explanation tied to current-release truth]
|
||||
- **Bounded deviation / spread control**: [none / describe the exception boundary and containment rule]
|
||||
|
||||
## Constitution Check
|
||||
|
||||
*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
|
||||
@ -81,7 +70,6 @@ ## Constitution Check
|
||||
- Persisted truth (PERSIST-001): new tables/entities/artifacts represent independent product truth or lifecycle; convenience projections and UI helpers stay derived
|
||||
- Behavioral state (STATE-001): new states/statuses/reason codes change behavior, routing, permissions, lifecycle, audit, retention, or retry handling; presentation-only distinctions stay derived
|
||||
- UI semantics (UI-SEM-001): avoid turning badges, explanation text, trust/confidence labels, or detail summaries into mandatory interpretation frameworks; prefer direct domain-to-UI mapping
|
||||
- Shared pattern first (XCUT-001): cross-cutting interaction classes reuse existing shared contracts/presenters/builders/renderers first; any deviation is explicit, bounded, and justified against current-release truth
|
||||
- V1 explicitness / few layers (V1-EXP-001, LAYER-001): prefer direct implementation, local mappings, and small helpers; any new layer replaces an old one or proves the old one cannot serve
|
||||
- Spec discipline / bloat check (SPEC-DISC-001, BLOAT-001): related semantic changes are grouped coherently, and any new enum, DTO/presenter, persisted entity, interface/registry/resolver, or taxonomy includes a proportionality review covering operator problem, insufficiency, narrowness, ownership cost, rejected alternative, and whether it is current-release truth
|
||||
- Badge semantics (BADGE-001): status-like badges use `BadgeCatalog` / `BadgeRenderer`; no ad-hoc mappings; new values include tests
|
||||
|
||||
@ -35,18 +35,6 @@ ## Spec Scope Fields *(mandatory)*
|
||||
- **Default filter behavior when tenant-context is active**: [e.g., prefilter to current tenant]
|
||||
- **Explicit entitlement checks preventing cross-tenant leakage**: [Describe checks]
|
||||
|
||||
## Cross-Cutting / Shared Pattern Reuse *(mandatory when the feature touches notifications, status messaging, action links, header actions, dashboard signals/cards, alerts, navigation entry points, evidence/report viewers, or any other existing shared operator interaction family; otherwise write `N/A - no shared interaction family touched`)*
|
||||
|
||||
- **Cross-cutting feature?**: [yes/no]
|
||||
- **Interaction class(es)**: [notifications / status messaging / header actions / dashboard signals / navigation / reports / etc.]
|
||||
- **Systems touched**: [List shared systems, surfaces, or infrastructure paths]
|
||||
- **Existing pattern(s) to extend**: [Name the existing shared path(s) or write `none`]
|
||||
- **Shared contract / presenter / builder / renderer to reuse**: [Exact class, helper, or surface path, or `none`]
|
||||
- **Why the existing shared path is sufficient or insufficient**: [Short explanation tied to current-release truth]
|
||||
- **Allowed deviation and why**: [none / bounded exception + why]
|
||||
- **Consistency impact**: [What must stay aligned across interaction structure, copy, status semantics, actions, and deep links]
|
||||
- **Review focus**: [What reviewers must verify to prevent parallel local patterns]
|
||||
|
||||
## UI / Surface Guardrail Impact *(mandatory when operator-facing surfaces are changed; otherwise write `N/A`)*
|
||||
|
||||
Use this section to classify UI and surface risk once. If the feature does
|
||||
@ -113,14 +101,6 @@ ## Proportionality Review *(mandatory when structural complexity is introduced)*
|
||||
- **Alternative intentionally rejected**: [What simpler option was considered and why it was not sufficient]
|
||||
- **Release truth**: [Current-release truth or future-release preparation]
|
||||
|
||||
### Compatibility posture
|
||||
|
||||
This feature assumes a pre-production environment.
|
||||
|
||||
Backward compatibility, legacy aliases, migration shims, historical fixtures, and compatibility-specific tests are out of scope unless explicitly required by this spec.
|
||||
|
||||
Canonical replacement is preferred over preservation.
|
||||
|
||||
## Testing / Lane / Runtime Impact *(mandatory for runtime behavior changes)*
|
||||
|
||||
For docs-only or template-only changes, state concise `N/A` or `none`. For runtime- or test-affecting work, classification MUST follow the proving purpose of the change rather than the file path or folder name.
|
||||
@ -226,14 +206,6 @@ ## Requirements *(mandatory)*
|
||||
If the feature introduces a new enum/status family, DTO/presenter/envelope, persisted entity/table, interface/contract/registry/resolver,
|
||||
or taxonomy/classification system, the Proportionality Review section above is mandatory.
|
||||
|
||||
**Constitution alignment (XCUT-001):** If this feature touches a cross-cutting interaction class such as notifications, status messaging,
|
||||
action links, header actions, dashboard signals/cards, alerts, navigation entry points, or evidence/report viewers, the spec MUST:
|
||||
- state whether the feature is cross-cutting,
|
||||
- name the existing shared pattern(s) and shared contract/presenter/builder/renderer to extend,
|
||||
- explain why the existing shared path is sufficient or why it is insufficient for current-release truth,
|
||||
- record any allowed deviation, the consistency it must preserve, and its ownership/spread-control cost,
|
||||
- and make the reviewer focus explicit so parallel local UX paths do not appear silently.
|
||||
|
||||
**Constitution alignment (TEST-GOV-001):** If this feature changes runtime behavior or tests, the spec MUST describe:
|
||||
- the actual test-purpose classification (`Unit`, `Feature`, `Heavy-Governance`, or `Browser`) and why that classification matches the real proving purpose,
|
||||
- the affected validation lane(s) and why they are the narrowest sufficient proof,
|
||||
|
||||
@ -46,11 +46,6 @@ # Tasks: [FEATURE NAME]
|
||||
- using source/domain terms only where same-screen disambiguation is required,
|
||||
- aligning button labels, modal titles, run titles, notifications, and audit prose to the same domain vocabulary,
|
||||
- removing implementation-first wording from primary operator-facing copy.
|
||||
**Cross-Cutting Shared Pattern Reuse (XCUT-001)**: If this feature touches notifications, status messaging, action links, header actions, dashboard signals/cards, navigation entry points, alerts, evidence/report viewers, or another shared interaction family, tasks MUST include:
|
||||
- identifying the existing shared contract/presenter/builder/renderer before local implementation begins,
|
||||
- extending the shared path when it is sufficient for current-release truth,
|
||||
- or recording a bounded exception task that documents why the shared path is insufficient, what consistency must still be preserved, and how spread is controlled,
|
||||
- and ensuring reviewer proof covers whether the feature converged on the shared path or knowingly introduced a bounded exception.
|
||||
**UI / Surface Guardrails**: If this feature adds or changes operator-facing surfaces or the workflow that governs them, tasks MUST include:
|
||||
- carrying forward the spec's native/custom classification, shared-family relevance, state-layer ownership, and exception need into implementation work without renaming the same decision,
|
||||
- classifying any triggered repository signals with one handling mode (`hard-stop-candidate`, `review-mandatory`, `exception-required`, or `report-only`),
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
schema_version: "1.0"
|
||||
workflow:
|
||||
id: "speckit"
|
||||
name: "Full SDD Cycle"
|
||||
version: "1.0.0"
|
||||
author: "GitHub"
|
||||
description: "Runs specify → plan → tasks → implement with review gates"
|
||||
|
||||
requires:
|
||||
speckit_version: ">=0.7.2"
|
||||
integrations:
|
||||
any: ["copilot", "claude", "gemini"]
|
||||
|
||||
inputs:
|
||||
spec:
|
||||
type: string
|
||||
required: true
|
||||
prompt: "Describe what you want to build"
|
||||
integration:
|
||||
type: string
|
||||
default: "copilot"
|
||||
prompt: "Integration to use (e.g. claude, copilot, gemini)"
|
||||
scope:
|
||||
type: string
|
||||
default: "full"
|
||||
enum: ["full", "backend-only", "frontend-only"]
|
||||
|
||||
steps:
|
||||
- id: specify
|
||||
command: speckit.specify
|
||||
integration: "{{ inputs.integration }}"
|
||||
input:
|
||||
args: "{{ inputs.spec }}"
|
||||
|
||||
- id: review-spec
|
||||
type: gate
|
||||
message: "Review the generated spec before planning."
|
||||
options: [approve, reject]
|
||||
on_reject: abort
|
||||
|
||||
- id: plan
|
||||
command: speckit.plan
|
||||
integration: "{{ inputs.integration }}"
|
||||
input:
|
||||
args: "{{ inputs.spec }}"
|
||||
|
||||
- id: review-plan
|
||||
type: gate
|
||||
message: "Review the plan before generating tasks."
|
||||
options: [approve, reject]
|
||||
on_reject: abort
|
||||
|
||||
- id: tasks
|
||||
command: speckit.tasks
|
||||
integration: "{{ inputs.integration }}"
|
||||
input:
|
||||
args: "{{ inputs.spec }}"
|
||||
|
||||
- id: implement
|
||||
command: speckit.implement
|
||||
integration: "{{ inputs.integration }}"
|
||||
input:
|
||||
args: "{{ inputs.spec }}"
|
||||
@ -1,13 +0,0 @@
|
||||
{
|
||||
"schema_version": "1.0",
|
||||
"workflows": {
|
||||
"speckit": {
|
||||
"name": "Full SDD Cycle",
|
||||
"version": "1.0.0",
|
||||
"description": "Runs specify \u2192 plan \u2192 tasks \u2192 implement with review gates",
|
||||
"source": "bundled",
|
||||
"installed_at": "2026-04-22T21:58:03.039039+00:00",
|
||||
"updated_at": "2026-04-22T21:58:03.039046+00:00"
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../src/pg-core/columns/json.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyPgTable } from '~/pg-core/table.ts';\nimport { PgColumn, PgColumnBuilder } from './common.ts';\n\nexport type PgJsonBuilderInitial<TName extends string> = PgJsonBuilder<{\n\tname: TName;\n\tdataType: 'json';\n\tcolumnType: 'PgJson';\n\tdata: unknown;\n\tdriverParam: unknown;\n\tenumValues: undefined;\n}>;\n\nexport class PgJsonBuilder<T extends ColumnBuilderBaseConfig<'json', 'PgJson'>> extends PgColumnBuilder<\n\tT\n> {\n\tstatic override readonly [entityKind]: string = 'PgJsonBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'json', 'PgJson');\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyPgTable<{ name: TTableName }>,\n\t): PgJson<MakeColumnConfig<T, TTableName>> {\n\t\treturn new PgJson<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class PgJson<T extends ColumnBaseConfig<'json', 'PgJson'>> extends PgColumn<T> {\n\tstatic override readonly [entityKind]: string = 'PgJson';\n\n\tconstructor(table: AnyPgTable<{ name: T['tableName'] }>, config: PgJsonBuilder<T>['config']) {\n\t\tsuper(table, config);\n\t}\n\n\tgetSQLType(): string {\n\t\treturn 'json';\n\t}\n\n\toverride mapToDriverValue(value: T['data']): string {\n\t\treturn JSON.stringify(value);\n\t}\n\n\toverride mapFromDriverValue(value: T['data'] | string): T['data'] {\n\t\tif (typeof value === 'string') {\n\t\t\ttry {\n\t\t\t\treturn JSON.parse(value);\n\t\t\t} catch {\n\t\t\t\treturn value as T['data'];\n\t\t\t}\n\t\t}\n\t\treturn value;\n\t}\n}\n\nexport function json(): PgJsonBuilderInitial<''>;\nexport function json<TName extends string>(name: TName): PgJsonBuilderInitial<TName>;\nexport function json(name?: string) {\n\treturn new PgJsonBuilder(name ?? '');\n}\n"],"mappings":"AAEA,SAAS,kBAAkB;AAE3B,SAAS,UAAU,uBAAuB;AAWnC,MAAM,sBAA2E,gBAEtF;AAAA,EACD,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB;AAC5B,UAAM,MAAM,QAAQ,QAAQ;AAAA,EAC7B;AAAA;AAAA,EAGS,MACR,OAC0C;AAC1C,WAAO,IAAI,OAAwC,OAAO,KAAK,MAA8C;AAAA,EAC9G;AACD;AAEO,MAAM,eAA6D,SAAY;AAAA,EACrF,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,OAA6C,QAAoC;AAC5F,UAAM,OAAO,MAAM;AAAA,EACpB;AAAA,EAEA,aAAqB;AACpB,WAAO;AAAA,EACR;AAAA,EAES,iBAAiB,OAA0B;AACnD,WAAO,KAAK,UAAU,KAAK;AAAA,EAC5B;AAAA,EAES,mBAAmB,OAAsC;AACjE,QAAI,OAAO,UAAU,UAAU;AAC9B,UAAI;AACH,eAAO,KAAK,MAAM,KAAK;AAAA,MACxB,QAAQ;AACP,eAAO;AAAA,MACR;AAAA,IACD;AACA,WAAO;AAAA,EACR;AACD;AAIO,SAAS,KAAK,MAAe;AACnC,SAAO,IAAI,cAAc,QAAQ,EAAE;AACpC;","names":[]}
|
||||
@ -1,147 +0,0 @@
|
||||
# Prefixing
|
||||
|
||||
## Prefix Styles
|
||||
|
||||
concurrently will by default prefix each command's outputs with a zero-based index, wrapped in square brackets:
|
||||
|
||||
```bash
|
||||
$ concurrently 'echo Hello there' "echo 'General Kenobi!'"
|
||||
[0] Hello there
|
||||
[1] General Kenobi!
|
||||
[0] echo Hello there exited with code 0
|
||||
[1] echo 'General Kenobi!' exited with code 0
|
||||
```
|
||||
|
||||
If you've given the commands names, they are used instead:
|
||||
|
||||
```bash
|
||||
$ concurrently --names one,two 'echo Hello there' "echo 'General Kenobi!'"
|
||||
[one] Hello there
|
||||
[two] General Kenobi!
|
||||
[one] echo Hello there exited with code 0
|
||||
[two] echo 'General Kenobi!' exited with code 0
|
||||
```
|
||||
|
||||
There are other prefix styles available too:
|
||||
|
||||
| Style | Description |
|
||||
| --------- | --------------------------------- |
|
||||
| `index` | Zero-based command's index |
|
||||
| `name` | The command's name |
|
||||
| `command` | The command's line |
|
||||
| `time` | Time of output |
|
||||
| `pid` | ID of the command's process (PID) |
|
||||
| `none` | No prefix |
|
||||
|
||||
Any of these can be used by setting the `--prefix`/`-p` flag. For example:
|
||||
|
||||
```bash
|
||||
$ concurrently --prefix pid 'echo Hello there' 'echo General Kenobi!'
|
||||
[2222] Hello there
|
||||
[2223] General Kenobi!
|
||||
[2222] echo Hello there exited with code 0
|
||||
[2223] echo 'General Kenobi!' exited with code 0
|
||||
```
|
||||
|
||||
It's also possible to have a prefix based on a template. Any of the styles listed above can be used by wrapping it in `{}`.
|
||||
Doing so will also remove the square brackets:
|
||||
|
||||
```bash
|
||||
$ concurrently --prefix '{index}-{pid}' 'echo Hello there' 'echo General Kenobi!'
|
||||
0-2222 Hello there
|
||||
1-2223 General Kenobi!
|
||||
0-2222 echo Hello there exited with code 0
|
||||
1-2223 echo 'General Kenobi!' exited with code 0
|
||||
```
|
||||
|
||||
## Prefix Colors
|
||||
|
||||
By default, there are no colors applied to concurrently prefixes, and they just use whatever the terminal's defaults are.
|
||||
|
||||
This can be changed by using the `--prefix-colors`/`-c` flag, which takes a comma-separated list of colors to use.<br/>
|
||||
The available values are color names (e.g. `green`, `magenta`, `gray`, etc), a hex value (such as `#23de43`), or `auto`, to automatically select a color.
|
||||
|
||||
```bash
|
||||
$ concurrently -c red,blue 'echo Hello there' 'echo General Kenobi!'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>List of available color names</summary>
|
||||
|
||||
- `black`
|
||||
- `blue`
|
||||
- `cyan`
|
||||
- `green`
|
||||
- `gray`
|
||||
- `magenta`
|
||||
- `red`
|
||||
- `white`
|
||||
- `yellow`
|
||||
</details>
|
||||
|
||||
Colors can take modifiers too. Several can be applied at once by prepending `.<modifier 1>.<modifier 2>` and so on.
|
||||
|
||||
```bash
|
||||
$ concurrently -c red,bold.blue.dim 'echo Hello there' 'echo General Kenobi!'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>List of available modifiers</summary>
|
||||
|
||||
- `reset`
|
||||
- `bold`
|
||||
- `dim`
|
||||
- `hidden`
|
||||
- `inverse`
|
||||
- `italic`
|
||||
- `strikethrough`
|
||||
- `underline`
|
||||
</details>
|
||||
|
||||
A background color can be set in a similarly fashion.
|
||||
|
||||
```bash
|
||||
$ concurrently -c bgGray,red.bgBlack 'echo Hello there' 'echo General Kenobi!'
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>List of available background color names</summary>
|
||||
|
||||
- `bgBlack`
|
||||
- `bgBlue`
|
||||
- `bgCyan`
|
||||
- `bgGreen`
|
||||
- `bgGray`
|
||||
- `bgMagenta`
|
||||
- `bgRed`
|
||||
- `bgWhite`
|
||||
- `bgYellow`
|
||||
</details>
|
||||
|
||||
## Prefix Length
|
||||
|
||||
When using the `command` prefix style, it's possible that it'll be too long.<br/>
|
||||
It can be limited by setting the `--prefix-length`/`-l` flag:
|
||||
|
||||
```bash
|
||||
$ concurrently -p command -l 10 'echo Hello there' 'echo General Kenobi!'
|
||||
[echo..here] Hello there
|
||||
[echo..bi!'] General Kenobi!
|
||||
[echo..here] echo Hello there exited with code 0
|
||||
[echo..bi!'] echo 'General Kenobi!' exited with code 0
|
||||
```
|
||||
|
||||
It's also possible that some prefixes are too short, and you want all of them to have the same length.<br/>
|
||||
This can be done by setting the `--pad-prefix` flag:
|
||||
|
||||
```bash
|
||||
$ concurrently -n foo,barbaz --pad-prefix 'echo Hello there' 'echo General Kenobi!'
|
||||
[foo ] Hello there
|
||||
[foo ] echo Hello there exited with code 0
|
||||
[barbaz] General Kenobi!
|
||||
[barbaz] echo 'General Kenobi!' exited with code 0
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> If using the `pid` prefix style in combination with [`--restart-tries`](./restarting.md), the length of the PID might grow, in which case all subsequent lines will match the new length.<br/>
|
||||
> This might happen, for example, if the PID was 99 and it's now 100.
|
||||
@ -1,25 +0,0 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var neon_exports = {};
|
||||
module.exports = __toCommonJS(neon_exports);
|
||||
__reExport(neon_exports, require("./neon-auth.cjs"), module.exports);
|
||||
__reExport(neon_exports, require("./rls.cjs"), module.exports);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
...require("./neon-auth.cjs"),
|
||||
...require("./rls.cjs")
|
||||
});
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
@ -1,102 +0,0 @@
|
||||
import { AjaxRequest } from './types';
|
||||
import { getXHRResponse } from './getXHRResponse';
|
||||
import { createErrorClass } from '../util/createErrorClass';
|
||||
|
||||
/**
|
||||
* A normalized AJAX error.
|
||||
*
|
||||
* @see {@link ajax}
|
||||
*/
|
||||
export interface AjaxError extends Error {
|
||||
/**
|
||||
* The XHR instance associated with the error.
|
||||
*/
|
||||
xhr: XMLHttpRequest;
|
||||
|
||||
/**
|
||||
* The AjaxRequest associated with the error.
|
||||
*/
|
||||
request: AjaxRequest;
|
||||
|
||||
/**
|
||||
* The HTTP status code, if the request has completed. If not,
|
||||
* it is set to `0`.
|
||||
*/
|
||||
status: number;
|
||||
|
||||
/**
|
||||
* The responseType (e.g. 'json', 'arraybuffer', or 'xml').
|
||||
*/
|
||||
responseType: XMLHttpRequestResponseType;
|
||||
|
||||
/**
|
||||
* The response data.
|
||||
*/
|
||||
response: any;
|
||||
}
|
||||
|
||||
export interface AjaxErrorCtor {
|
||||
/**
|
||||
* @deprecated Internal implementation detail. Do not construct error instances.
|
||||
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
|
||||
*/
|
||||
new (message: string, xhr: XMLHttpRequest, request: AjaxRequest): AjaxError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when an error occurs during an AJAX request.
|
||||
* This is only exported because it is useful for checking to see if an error
|
||||
* is an `instanceof AjaxError`. DO NOT create new instances of `AjaxError` with
|
||||
* the constructor.
|
||||
*
|
||||
* @see {@link ajax}
|
||||
*/
|
||||
export const AjaxError: AjaxErrorCtor = createErrorClass(
|
||||
(_super) =>
|
||||
function AjaxErrorImpl(this: any, message: string, xhr: XMLHttpRequest, request: AjaxRequest) {
|
||||
this.message = message;
|
||||
this.name = 'AjaxError';
|
||||
this.xhr = xhr;
|
||||
this.request = request;
|
||||
this.status = xhr.status;
|
||||
this.responseType = xhr.responseType;
|
||||
let response: any;
|
||||
try {
|
||||
// This can throw in IE, because we have to do a JSON.parse of
|
||||
// the response in some cases to get the expected response property.
|
||||
response = getXHRResponse(xhr);
|
||||
} catch (err) {
|
||||
response = xhr.responseText;
|
||||
}
|
||||
this.response = response;
|
||||
}
|
||||
);
|
||||
|
||||
export interface AjaxTimeoutError extends AjaxError {}
|
||||
|
||||
export interface AjaxTimeoutErrorCtor {
|
||||
/**
|
||||
* @deprecated Internal implementation detail. Do not construct error instances.
|
||||
* Cannot be tagged as internal: https://github.com/ReactiveX/rxjs/issues/6269
|
||||
*/
|
||||
new (xhr: XMLHttpRequest, request: AjaxRequest): AjaxTimeoutError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when an AJAX request times out. Not to be confused with {@link TimeoutError}.
|
||||
*
|
||||
* This is exported only because it is useful for checking to see if errors are an
|
||||
* `instanceof AjaxTimeoutError`. DO NOT use the constructor to create an instance of
|
||||
* this type.
|
||||
*
|
||||
* @see {@link ajax}
|
||||
*/
|
||||
export const AjaxTimeoutError: AjaxTimeoutErrorCtor = (() => {
|
||||
function AjaxTimeoutErrorImpl(this: any, xhr: XMLHttpRequest, request: AjaxRequest) {
|
||||
AjaxError.call(this, 'ajax timeout', xhr, request);
|
||||
this.name = 'AjaxTimeoutError';
|
||||
return this;
|
||||
}
|
||||
AjaxTimeoutErrorImpl.prototype = Object.create(AjaxError.prototype);
|
||||
return AjaxTimeoutErrorImpl;
|
||||
})() as any;
|
||||
@ -1,39 +0,0 @@
|
||||
/**
|
||||
Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag.
|
||||
|
||||
@param flag - CLI flag to look for. The `--` prefix is optional.
|
||||
@param argv - CLI arguments. Default: `process.argv`.
|
||||
@returns Whether the flag exists.
|
||||
|
||||
@example
|
||||
```
|
||||
// $ ts-node foo.ts -f --unicorn --foo=bar -- --rainbow
|
||||
|
||||
// foo.ts
|
||||
import hasFlag = require('has-flag');
|
||||
|
||||
hasFlag('unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('--unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('f');
|
||||
//=> true
|
||||
|
||||
hasFlag('-f');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo=bar');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo');
|
||||
//=> false
|
||||
|
||||
hasFlag('rainbow');
|
||||
//=> false
|
||||
```
|
||||
*/
|
||||
declare function hasFlag(flag: string, argv?: string[]): boolean;
|
||||
|
||||
export = hasFlag;
|
||||
@ -1,25 +0,0 @@
|
||||
export * from "./bigint.cjs";
|
||||
export * from "./binary.cjs";
|
||||
export * from "./boolean.cjs";
|
||||
export * from "./char.cjs";
|
||||
export * from "./common.cjs";
|
||||
export * from "./custom.cjs";
|
||||
export * from "./date.cjs";
|
||||
export * from "./datetime.cjs";
|
||||
export * from "./decimal.cjs";
|
||||
export * from "./double.cjs";
|
||||
export * from "./enum.cjs";
|
||||
export * from "./float.cjs";
|
||||
export * from "./int.cjs";
|
||||
export * from "./json.cjs";
|
||||
export * from "./mediumint.cjs";
|
||||
export * from "./real.cjs";
|
||||
export * from "./serial.cjs";
|
||||
export * from "./smallint.cjs";
|
||||
export * from "./text.cjs";
|
||||
export * from "./time.cjs";
|
||||
export * from "./timestamp.cjs";
|
||||
export * from "./tinyint.cjs";
|
||||
export * from "./varbinary.cjs";
|
||||
export * from "./varchar.cjs";
|
||||
export * from "./year.cjs";
|
||||
@ -1,61 +0,0 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { MonoTypeOperatorFunction, ObservableInput } from '../types';
|
||||
/**
|
||||
* Returns an Observable that mirrors the source Observable with the exception of an `error`. If the source Observable
|
||||
* calls `error`, this method will emit the Throwable that caused the error to the `ObservableInput` returned from `notifier`.
|
||||
* If that Observable calls `complete` or `error` then this method will call `complete` or `error` on the child
|
||||
* subscription. Otherwise this method will resubscribe to the source Observable.
|
||||
*
|
||||
* 
|
||||
*
|
||||
* Retry an observable sequence on error based on custom criteria.
|
||||
*
|
||||
* ## Example
|
||||
*
|
||||
* ```ts
|
||||
* import { interval, map, retryWhen, tap, delayWhen, timer } from 'rxjs';
|
||||
*
|
||||
* const source = interval(1000);
|
||||
* const result = source.pipe(
|
||||
* map(value => {
|
||||
* if (value > 5) {
|
||||
* // error will be picked up by retryWhen
|
||||
* throw value;
|
||||
* }
|
||||
* return value;
|
||||
* }),
|
||||
* retryWhen(errors =>
|
||||
* errors.pipe(
|
||||
* // log error message
|
||||
* tap(value => console.log(`Value ${ value } was too high!`)),
|
||||
* // restart in 5 seconds
|
||||
* delayWhen(value => timer(value * 1000))
|
||||
* )
|
||||
* )
|
||||
* );
|
||||
*
|
||||
* result.subscribe(value => console.log(value));
|
||||
*
|
||||
* // results:
|
||||
* // 0
|
||||
* // 1
|
||||
* // 2
|
||||
* // 3
|
||||
* // 4
|
||||
* // 5
|
||||
* // 'Value 6 was too high!'
|
||||
* // - Wait 5 seconds then repeat
|
||||
* ```
|
||||
*
|
||||
* @see {@link retry}
|
||||
*
|
||||
* @param notifier Function that receives an Observable of notifications with which a
|
||||
* user can `complete` or `error`, aborting the retry.
|
||||
* @return A function that returns an Observable that mirrors the source
|
||||
* Observable with the exception of an `error`.
|
||||
* @deprecated Will be removed in v9 or v10, use {@link retry}'s `delay` option instead.
|
||||
* Will be removed in v9 or v10. Use {@link retry}'s {@link RetryConfig#delay delay} option instead.
|
||||
* Instead of `retryWhen(() => notify$)`, use: `retry({ delay: () => notify$ })`.
|
||||
*/
|
||||
export declare function retryWhen<T>(notifier: (errors: Observable<any>) => ObservableInput<any>): MonoTypeOperatorFunction<T>;
|
||||
//# sourceMappingURL=retryWhen.d.ts.map
|
||||
@ -1,633 +0,0 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var base_exports = {};
|
||||
__export(base_exports, {
|
||||
TerminalReporter: () => TerminalReporter,
|
||||
fitToWidth: () => fitToWidth,
|
||||
formatError: () => formatError,
|
||||
formatFailure: () => formatFailure,
|
||||
formatResultFailure: () => formatResultFailure,
|
||||
formatRetry: () => formatRetry,
|
||||
internalScreen: () => internalScreen,
|
||||
kOutputSymbol: () => kOutputSymbol,
|
||||
markErrorsAsReported: () => markErrorsAsReported,
|
||||
nonTerminalScreen: () => nonTerminalScreen,
|
||||
prepareErrorStack: () => prepareErrorStack,
|
||||
relativeFilePath: () => relativeFilePath,
|
||||
resolveOutputFile: () => resolveOutputFile,
|
||||
separator: () => separator,
|
||||
stepSuffix: () => stepSuffix,
|
||||
terminalScreen: () => terminalScreen
|
||||
});
|
||||
module.exports = __toCommonJS(base_exports);
|
||||
var import_path = __toESM(require("path"));
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var import_utils2 = require("playwright-core/lib/utils");
|
||||
var import_util = require("../util");
|
||||
var import_utilsBundle = require("../utilsBundle");
|
||||
const kOutputSymbol = Symbol("output");
|
||||
const DEFAULT_TTY_WIDTH = 100;
|
||||
const DEFAULT_TTY_HEIGHT = 40;
|
||||
const originalProcessStdout = process.stdout;
|
||||
const originalProcessStderr = process.stderr;
|
||||
const terminalScreen = (() => {
|
||||
let isTTY = !!originalProcessStdout.isTTY;
|
||||
let ttyWidth = originalProcessStdout.columns || 0;
|
||||
let ttyHeight = originalProcessStdout.rows || 0;
|
||||
if (process.env.PLAYWRIGHT_FORCE_TTY === "false" || process.env.PLAYWRIGHT_FORCE_TTY === "0") {
|
||||
isTTY = false;
|
||||
ttyWidth = 0;
|
||||
ttyHeight = 0;
|
||||
} else if (process.env.PLAYWRIGHT_FORCE_TTY === "true" || process.env.PLAYWRIGHT_FORCE_TTY === "1") {
|
||||
isTTY = true;
|
||||
ttyWidth = originalProcessStdout.columns || DEFAULT_TTY_WIDTH;
|
||||
ttyHeight = originalProcessStdout.rows || DEFAULT_TTY_HEIGHT;
|
||||
} else if (process.env.PLAYWRIGHT_FORCE_TTY) {
|
||||
isTTY = true;
|
||||
const sizeMatch = process.env.PLAYWRIGHT_FORCE_TTY.match(/^(\d+)x(\d+)$/);
|
||||
if (sizeMatch) {
|
||||
ttyWidth = +sizeMatch[1];
|
||||
ttyHeight = +sizeMatch[2];
|
||||
} else {
|
||||
ttyWidth = +process.env.PLAYWRIGHT_FORCE_TTY;
|
||||
ttyHeight = DEFAULT_TTY_HEIGHT;
|
||||
}
|
||||
if (isNaN(ttyWidth))
|
||||
ttyWidth = DEFAULT_TTY_WIDTH;
|
||||
if (isNaN(ttyHeight))
|
||||
ttyHeight = DEFAULT_TTY_HEIGHT;
|
||||
}
|
||||
let useColors = isTTY;
|
||||
if (process.env.DEBUG_COLORS === "0" || process.env.DEBUG_COLORS === "false" || process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false")
|
||||
useColors = false;
|
||||
else if (process.env.DEBUG_COLORS || process.env.FORCE_COLOR)
|
||||
useColors = true;
|
||||
const colors = useColors ? import_utils2.colors : import_utils2.noColors;
|
||||
return {
|
||||
resolveFiles: "cwd",
|
||||
isTTY,
|
||||
ttyWidth,
|
||||
ttyHeight,
|
||||
colors,
|
||||
stdout: originalProcessStdout,
|
||||
stderr: originalProcessStderr
|
||||
};
|
||||
})();
|
||||
const nonTerminalScreen = {
|
||||
colors: terminalScreen.colors,
|
||||
isTTY: false,
|
||||
ttyWidth: 0,
|
||||
ttyHeight: 0,
|
||||
resolveFiles: "rootDir"
|
||||
};
|
||||
const internalScreen = {
|
||||
colors: import_utils2.colors,
|
||||
isTTY: false,
|
||||
ttyWidth: 0,
|
||||
ttyHeight: 0,
|
||||
resolveFiles: "rootDir"
|
||||
};
|
||||
class TerminalReporter {
|
||||
constructor(options = {}) {
|
||||
this.totalTestCount = 0;
|
||||
this.fileDurations = /* @__PURE__ */ new Map();
|
||||
this._fatalErrors = [];
|
||||
this._failureCount = 0;
|
||||
this.screen = options.screen ?? terminalScreen;
|
||||
this._options = options;
|
||||
}
|
||||
version() {
|
||||
return "v2";
|
||||
}
|
||||
onConfigure(config) {
|
||||
this.config = config;
|
||||
}
|
||||
onBegin(suite) {
|
||||
this.suite = suite;
|
||||
this.totalTestCount = suite.allTests().length;
|
||||
}
|
||||
onStdOut(chunk, test, result) {
|
||||
this._appendOutput({ chunk, type: "stdout" }, result);
|
||||
}
|
||||
onStdErr(chunk, test, result) {
|
||||
this._appendOutput({ chunk, type: "stderr" }, result);
|
||||
}
|
||||
_appendOutput(output, result) {
|
||||
if (!result)
|
||||
return;
|
||||
result[kOutputSymbol] = result[kOutputSymbol] || [];
|
||||
result[kOutputSymbol].push(output);
|
||||
}
|
||||
onTestEnd(test, result) {
|
||||
if (result.status !== "skipped" && result.status !== test.expectedStatus)
|
||||
++this._failureCount;
|
||||
const projectName = test.titlePath()[1];
|
||||
const relativePath = relativeTestPath(this.screen, this.config, test);
|
||||
const fileAndProject = (projectName ? `[${projectName}] \u203A ` : "") + relativePath;
|
||||
const entry = this.fileDurations.get(fileAndProject) || { duration: 0, workers: /* @__PURE__ */ new Set() };
|
||||
entry.duration += result.duration;
|
||||
entry.workers.add(result.workerIndex);
|
||||
this.fileDurations.set(fileAndProject, entry);
|
||||
}
|
||||
onError(error) {
|
||||
this._fatalErrors.push(error);
|
||||
}
|
||||
async onEnd(result) {
|
||||
this.result = result;
|
||||
}
|
||||
fitToScreen(line, prefix) {
|
||||
if (!this.screen.ttyWidth) {
|
||||
return line;
|
||||
}
|
||||
return fitToWidth(line, this.screen.ttyWidth, prefix);
|
||||
}
|
||||
generateStartingMessage() {
|
||||
const jobs = this.config.metadata.actualWorkers ?? this.config.workers;
|
||||
const shardDetails = this.config.shard ? `, shard ${this.config.shard.current} of ${this.config.shard.total}` : "";
|
||||
if (!this.totalTestCount)
|
||||
return "";
|
||||
return "\n" + this.screen.colors.dim("Running ") + this.totalTestCount + this.screen.colors.dim(` test${this.totalTestCount !== 1 ? "s" : ""} using `) + jobs + this.screen.colors.dim(` worker${jobs !== 1 ? "s" : ""}${shardDetails}`);
|
||||
}
|
||||
getSlowTests() {
|
||||
if (!this.config.reportSlowTests)
|
||||
return [];
|
||||
const fileDurations = [...this.fileDurations.entries()].filter(([key, value]) => value.workers.size === 1).map(([key, value]) => [key, value.duration]);
|
||||
fileDurations.sort((a, b) => b[1] - a[1]);
|
||||
const count = Math.min(fileDurations.length, this.config.reportSlowTests.max || Number.POSITIVE_INFINITY);
|
||||
const threshold = this.config.reportSlowTests.threshold;
|
||||
return fileDurations.filter(([, duration]) => duration > threshold).slice(0, count);
|
||||
}
|
||||
generateSummaryMessage({ didNotRun, skipped, expected, interrupted, unexpected, flaky, fatalErrors }) {
|
||||
const tokens = [];
|
||||
if (unexpected.length) {
|
||||
tokens.push(this.screen.colors.red(` ${unexpected.length} failed`));
|
||||
for (const test of unexpected)
|
||||
tokens.push(this.screen.colors.red(this.formatTestHeader(test, { indent: " " })));
|
||||
}
|
||||
if (interrupted.length) {
|
||||
tokens.push(this.screen.colors.yellow(` ${interrupted.length} interrupted`));
|
||||
for (const test of interrupted)
|
||||
tokens.push(this.screen.colors.yellow(this.formatTestHeader(test, { indent: " " })));
|
||||
}
|
||||
if (flaky.length) {
|
||||
tokens.push(this.screen.colors.yellow(` ${flaky.length} flaky`));
|
||||
for (const test of flaky)
|
||||
tokens.push(this.screen.colors.yellow(this.formatTestHeader(test, { indent: " " })));
|
||||
}
|
||||
if (skipped)
|
||||
tokens.push(this.screen.colors.yellow(` ${skipped} skipped`));
|
||||
if (didNotRun)
|
||||
tokens.push(this.screen.colors.yellow(` ${didNotRun} did not run`));
|
||||
if (expected)
|
||||
tokens.push(this.screen.colors.green(` ${expected} passed`) + this.screen.colors.dim(` (${(0, import_utils.msToString)(this.result.duration)})`));
|
||||
if (fatalErrors.length && expected + unexpected.length + interrupted.length + flaky.length > 0)
|
||||
tokens.push(this.screen.colors.red(` ${fatalErrors.length === 1 ? "1 error was not a part of any test" : fatalErrors.length + " errors were not a part of any test"}, see above for details`));
|
||||
return tokens.join("\n");
|
||||
}
|
||||
generateSummary() {
|
||||
let didNotRun = 0;
|
||||
let skipped = 0;
|
||||
let expected = 0;
|
||||
const interrupted = [];
|
||||
const interruptedToPrint = [];
|
||||
const unexpected = [];
|
||||
const flaky = [];
|
||||
this.suite.allTests().forEach((test) => {
|
||||
switch (test.outcome()) {
|
||||
case "skipped": {
|
||||
if (test.results.some((result) => result.status === "interrupted")) {
|
||||
if (test.results.some((result) => !!result.error))
|
||||
interruptedToPrint.push(test);
|
||||
interrupted.push(test);
|
||||
} else if (!test.results.length || test.expectedStatus !== "skipped") {
|
||||
++didNotRun;
|
||||
} else {
|
||||
++skipped;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "expected":
|
||||
++expected;
|
||||
break;
|
||||
case "unexpected":
|
||||
unexpected.push(test);
|
||||
break;
|
||||
case "flaky":
|
||||
flaky.push(test);
|
||||
break;
|
||||
}
|
||||
});
|
||||
const failuresToPrint = [...unexpected, ...flaky, ...interruptedToPrint];
|
||||
return {
|
||||
didNotRun,
|
||||
skipped,
|
||||
expected,
|
||||
interrupted,
|
||||
unexpected,
|
||||
flaky,
|
||||
failuresToPrint,
|
||||
fatalErrors: this._fatalErrors
|
||||
};
|
||||
}
|
||||
epilogue(full) {
|
||||
const summary = this.generateSummary();
|
||||
const summaryMessage = this.generateSummaryMessage(summary);
|
||||
if (full && summary.failuresToPrint.length && !this._options.omitFailures)
|
||||
this._printFailures(summary.failuresToPrint);
|
||||
this._printSlowTests();
|
||||
this._printSummary(summaryMessage);
|
||||
}
|
||||
_printFailures(failures) {
|
||||
this.writeLine("");
|
||||
failures.forEach((test, index) => {
|
||||
this.writeLine(this.formatFailure(test, index + 1));
|
||||
});
|
||||
}
|
||||
_printSlowTests() {
|
||||
const slowTests = this.getSlowTests();
|
||||
slowTests.forEach(([file, duration]) => {
|
||||
this.writeLine(this.screen.colors.yellow(" Slow test file: ") + file + this.screen.colors.yellow(` (${(0, import_utils.msToString)(duration)})`));
|
||||
});
|
||||
if (slowTests.length)
|
||||
this.writeLine(this.screen.colors.yellow(" Consider running tests from slow files in parallel. See: https://playwright.dev/docs/test-parallel"));
|
||||
}
|
||||
_printSummary(summary) {
|
||||
if (summary.trim())
|
||||
this.writeLine(summary);
|
||||
}
|
||||
willRetry(test) {
|
||||
return test.outcome() === "unexpected" && test.results.length <= test.retries;
|
||||
}
|
||||
formatTestTitle(test, step) {
|
||||
return formatTestTitle(this.screen, this.config, test, step, this._options);
|
||||
}
|
||||
formatTestHeader(test, options = {}) {
|
||||
return formatTestHeader(this.screen, this.config, test, { ...options, includeTestId: this._options.includeTestId });
|
||||
}
|
||||
formatFailure(test, index) {
|
||||
return formatFailure(this.screen, this.config, test, index, this._options);
|
||||
}
|
||||
formatError(error) {
|
||||
return formatError(this.screen, error);
|
||||
}
|
||||
formatResultErrors(test, result) {
|
||||
return formatResultErrors(this.screen, test, result);
|
||||
}
|
||||
writeLine(line) {
|
||||
this.screen.stdout?.write(line ? line + "\n" : "\n");
|
||||
}
|
||||
}
|
||||
function formatResultErrors(screen, test, result) {
|
||||
const lines = [];
|
||||
if (test.outcome() === "unexpected") {
|
||||
const errorDetails = formatResultFailure(screen, test, result, " ");
|
||||
if (errorDetails.length > 0)
|
||||
lines.push("");
|
||||
for (const error of errorDetails)
|
||||
lines.push(error.message, "");
|
||||
}
|
||||
return lines.join("\n");
|
||||
}
|
||||
function formatFailure(screen, config, test, index, options) {
|
||||
const lines = [];
|
||||
let printedHeader = false;
|
||||
for (const result of test.results) {
|
||||
const resultLines = [];
|
||||
const errors = formatResultFailure(screen, test, result, " ");
|
||||
if (!errors.length)
|
||||
continue;
|
||||
if (!printedHeader) {
|
||||
const header = formatTestHeader(screen, config, test, { indent: " ", index, mode: "error", includeTestId: options?.includeTestId });
|
||||
lines.push(screen.colors.red(header));
|
||||
printedHeader = true;
|
||||
}
|
||||
if (result.retry) {
|
||||
resultLines.push("");
|
||||
resultLines.push(screen.colors.gray(separator(screen, ` Retry #${result.retry}`)));
|
||||
}
|
||||
resultLines.push(...errors.map((error) => "\n" + error.message));
|
||||
const attachmentGroups = groupAttachments(result.attachments);
|
||||
for (let i = 0; i < attachmentGroups.length; ++i) {
|
||||
const attachment = attachmentGroups[i];
|
||||
if (attachment.name === "error-context" && attachment.path) {
|
||||
resultLines.push("");
|
||||
resultLines.push(screen.colors.dim(` Error Context: ${relativeFilePath(screen, config, attachment.path)}`));
|
||||
continue;
|
||||
}
|
||||
if (attachment.name.startsWith("_"))
|
||||
continue;
|
||||
const hasPrintableContent = attachment.contentType.startsWith("text/");
|
||||
if (!attachment.path && !hasPrintableContent)
|
||||
continue;
|
||||
resultLines.push("");
|
||||
resultLines.push(screen.colors.dim(separator(screen, ` attachment #${i + 1}: ${screen.colors.bold(attachment.name)} (${attachment.contentType})`)));
|
||||
if (attachment.actual?.path) {
|
||||
if (attachment.expected?.path) {
|
||||
const expectedPath = relativeFilePath(screen, config, attachment.expected.path);
|
||||
resultLines.push(screen.colors.dim(` Expected: ${expectedPath}`));
|
||||
}
|
||||
const actualPath = relativeFilePath(screen, config, attachment.actual.path);
|
||||
resultLines.push(screen.colors.dim(` Received: ${actualPath}`));
|
||||
if (attachment.previous?.path) {
|
||||
const previousPath = relativeFilePath(screen, config, attachment.previous.path);
|
||||
resultLines.push(screen.colors.dim(` Previous: ${previousPath}`));
|
||||
}
|
||||
if (attachment.diff?.path) {
|
||||
const diffPath = relativeFilePath(screen, config, attachment.diff.path);
|
||||
resultLines.push(screen.colors.dim(` Diff: ${diffPath}`));
|
||||
}
|
||||
} else if (attachment.path) {
|
||||
const relativePath = relativeFilePath(screen, config, attachment.path);
|
||||
resultLines.push(screen.colors.dim(` ${relativePath}`));
|
||||
if (attachment.name === "trace") {
|
||||
const packageManagerCommand = (0, import_utils.getPackageManagerExecCommand)();
|
||||
resultLines.push(screen.colors.dim(` Usage:`));
|
||||
resultLines.push("");
|
||||
resultLines.push(screen.colors.dim(` ${packageManagerCommand} playwright show-trace ${quotePathIfNeeded(relativePath)}`));
|
||||
resultLines.push("");
|
||||
}
|
||||
} else {
|
||||
if (attachment.contentType.startsWith("text/") && attachment.body) {
|
||||
let text = attachment.body.toString();
|
||||
if (text.length > 300)
|
||||
text = text.slice(0, 300) + "...";
|
||||
for (const line of text.split("\n"))
|
||||
resultLines.push(screen.colors.dim(` ${line}`));
|
||||
}
|
||||
}
|
||||
resultLines.push(screen.colors.dim(separator(screen, " ")));
|
||||
}
|
||||
lines.push(...resultLines);
|
||||
}
|
||||
lines.push("");
|
||||
return lines.join("\n");
|
||||
}
|
||||
function formatRetry(screen, result) {
|
||||
const retryLines = [];
|
||||
if (result.retry) {
|
||||
retryLines.push("");
|
||||
retryLines.push(screen.colors.gray(separator(screen, ` Retry #${result.retry}`)));
|
||||
}
|
||||
return retryLines;
|
||||
}
|
||||
function quotePathIfNeeded(path2) {
|
||||
if (/\s/.test(path2))
|
||||
return `"${path2}"`;
|
||||
return path2;
|
||||
}
|
||||
const kReportedSymbol = Symbol("reported");
|
||||
function markErrorsAsReported(result) {
|
||||
result[kReportedSymbol] = result.errors.length;
|
||||
}
|
||||
function formatResultFailure(screen, test, result, initialIndent) {
|
||||
const errorDetails = [];
|
||||
if (result.status === "passed" && test.expectedStatus === "failed") {
|
||||
errorDetails.push({
|
||||
message: indent(screen.colors.red(`Expected to fail, but passed.`), initialIndent)
|
||||
});
|
||||
}
|
||||
if (result.status === "interrupted") {
|
||||
errorDetails.push({
|
||||
message: indent(screen.colors.red(`Test was interrupted.`), initialIndent)
|
||||
});
|
||||
}
|
||||
const reportedIndex = result[kReportedSymbol] || 0;
|
||||
for (const error of result.errors.slice(reportedIndex)) {
|
||||
const formattedError = formatError(screen, error);
|
||||
errorDetails.push({
|
||||
message: indent(formattedError.message, initialIndent),
|
||||
location: formattedError.location
|
||||
});
|
||||
}
|
||||
return errorDetails;
|
||||
}
|
||||
function relativeFilePath(screen, config, file) {
|
||||
if (screen.resolveFiles === "cwd")
|
||||
return import_path.default.relative(process.cwd(), file);
|
||||
return import_path.default.relative(config.rootDir, file);
|
||||
}
|
||||
function relativeTestPath(screen, config, test) {
|
||||
return relativeFilePath(screen, config, test.location.file);
|
||||
}
|
||||
function stepSuffix(step) {
|
||||
const stepTitles = step ? step.titlePath() : [];
|
||||
return stepTitles.map((t) => t.split("\n")[0]).map((t) => " \u203A " + t).join("");
|
||||
}
|
||||
function formatTestTitle(screen, config, test, step, options = {}) {
|
||||
const [, projectName, , ...titles] = test.titlePath();
|
||||
const location = `${relativeTestPath(screen, config, test)}:${test.location.line}:${test.location.column}`;
|
||||
const testId = options.includeTestId ? `[id=${test.id}] ` : "";
|
||||
const projectLabel = options.includeTestId ? `project=` : "";
|
||||
const projectTitle = projectName ? `[${projectLabel}${projectName}] \u203A ` : "";
|
||||
const testTitle = `${testId}${projectTitle}${location} \u203A ${titles.join(" \u203A ")}`;
|
||||
const extraTags = test.tags.filter((t) => !testTitle.includes(t) && !config.tags.includes(t));
|
||||
return `${testTitle}${stepSuffix(step)}${extraTags.length ? " " + extraTags.join(" ") : ""}`;
|
||||
}
|
||||
function formatTestHeader(screen, config, test, options = {}) {
|
||||
const title = formatTestTitle(screen, config, test, void 0, options);
|
||||
const header = `${options.indent || ""}${options.index ? options.index + ") " : ""}${title}`;
|
||||
let fullHeader = header;
|
||||
if (options.mode === "error") {
|
||||
const stepPaths = /* @__PURE__ */ new Set();
|
||||
for (const result of test.results.filter((r) => !!r.errors.length)) {
|
||||
const stepPath = [];
|
||||
const visit = (steps) => {
|
||||
const errors = steps.filter((s) => s.error);
|
||||
if (errors.length > 1)
|
||||
return;
|
||||
if (errors.length === 1 && errors[0].category === "test.step") {
|
||||
stepPath.push(errors[0].title);
|
||||
visit(errors[0].steps);
|
||||
}
|
||||
};
|
||||
visit(result.steps);
|
||||
stepPaths.add(["", ...stepPath].join(" \u203A "));
|
||||
}
|
||||
fullHeader = header + (stepPaths.size === 1 ? stepPaths.values().next().value : "");
|
||||
}
|
||||
return separator(screen, fullHeader);
|
||||
}
|
||||
function formatError(screen, error) {
|
||||
const message = error.message || error.value || "";
|
||||
const stack = error.stack;
|
||||
if (!stack && !error.location)
|
||||
return { message };
|
||||
const tokens = [];
|
||||
const parsedStack = stack ? prepareErrorStack(stack) : void 0;
|
||||
tokens.push(parsedStack?.message || message);
|
||||
if (error.snippet) {
|
||||
let snippet = error.snippet;
|
||||
if (!screen.colors.enabled)
|
||||
snippet = (0, import_util.stripAnsiEscapes)(snippet);
|
||||
tokens.push("");
|
||||
tokens.push(snippet);
|
||||
}
|
||||
if (parsedStack && parsedStack.stackLines.length)
|
||||
tokens.push(screen.colors.dim(parsedStack.stackLines.join("\n")));
|
||||
let location = error.location;
|
||||
if (parsedStack && !location)
|
||||
location = parsedStack.location;
|
||||
if (error.cause)
|
||||
tokens.push(screen.colors.dim("[cause]: ") + formatError(screen, error.cause).message);
|
||||
return {
|
||||
location,
|
||||
message: tokens.join("\n")
|
||||
};
|
||||
}
|
||||
function separator(screen, text = "") {
|
||||
if (text)
|
||||
text += " ";
|
||||
const columns = Math.min(100, screen.ttyWidth || 100);
|
||||
return text + screen.colors.dim("\u2500".repeat(Math.max(0, columns - (0, import_util.stripAnsiEscapes)(text).length)));
|
||||
}
|
||||
function indent(lines, tab) {
|
||||
return lines.replace(/^(?=.+$)/gm, tab);
|
||||
}
|
||||
function prepareErrorStack(stack) {
|
||||
return (0, import_utils.parseErrorStack)(stack, import_path.default.sep, !!process.env.PWDEBUGIMPL);
|
||||
}
|
||||
function characterWidth(c) {
|
||||
return import_utilsBundle.getEastAsianWidth.eastAsianWidth(c.codePointAt(0));
|
||||
}
|
||||
function stringWidth(v) {
|
||||
let width = 0;
|
||||
for (const { segment } of new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(v))
|
||||
width += characterWidth(segment);
|
||||
return width;
|
||||
}
|
||||
function suffixOfWidth(v, width) {
|
||||
const segments = [...new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(v)];
|
||||
let suffixBegin = v.length;
|
||||
for (const { segment, index } of segments.reverse()) {
|
||||
const segmentWidth = stringWidth(segment);
|
||||
if (segmentWidth > width)
|
||||
break;
|
||||
width -= segmentWidth;
|
||||
suffixBegin = index;
|
||||
}
|
||||
return v.substring(suffixBegin);
|
||||
}
|
||||
function fitToWidth(line, width, prefix) {
|
||||
const prefixLength = prefix ? (0, import_util.stripAnsiEscapes)(prefix).length : 0;
|
||||
width -= prefixLength;
|
||||
if (stringWidth(line) <= width)
|
||||
return line;
|
||||
const parts = line.split(import_util.ansiRegex);
|
||||
const taken = [];
|
||||
for (let i = parts.length - 1; i >= 0; i--) {
|
||||
if (i % 2) {
|
||||
taken.push(parts[i]);
|
||||
} else {
|
||||
let part = suffixOfWidth(parts[i], width);
|
||||
const wasTruncated = part.length < parts[i].length;
|
||||
if (wasTruncated && parts[i].length > 0) {
|
||||
part = "\u2026" + suffixOfWidth(parts[i], width - 1);
|
||||
}
|
||||
taken.push(part);
|
||||
width -= stringWidth(part);
|
||||
}
|
||||
}
|
||||
return taken.reverse().join("");
|
||||
}
|
||||
function resolveFromEnv(name) {
|
||||
const value = process.env[name];
|
||||
if (value)
|
||||
return import_path.default.resolve(process.cwd(), value);
|
||||
return void 0;
|
||||
}
|
||||
function resolveOutputFile(reporterName, options) {
|
||||
const name = reporterName.toUpperCase();
|
||||
let outputFile = resolveFromEnv(`PLAYWRIGHT_${name}_OUTPUT_FILE`);
|
||||
if (!outputFile && options.outputFile)
|
||||
outputFile = import_path.default.resolve(options.configDir, options.outputFile);
|
||||
if (outputFile)
|
||||
return { outputFile };
|
||||
let outputDir = resolveFromEnv(`PLAYWRIGHT_${name}_OUTPUT_DIR`);
|
||||
if (!outputDir && options.outputDir)
|
||||
outputDir = import_path.default.resolve(options.configDir, options.outputDir);
|
||||
if (!outputDir && options.default)
|
||||
outputDir = (0, import_util.resolveReporterOutputPath)(options.default.outputDir, options.configDir, void 0);
|
||||
if (!outputDir)
|
||||
outputDir = options.configDir;
|
||||
const reportName = process.env[`PLAYWRIGHT_${name}_OUTPUT_NAME`] ?? options.fileName ?? options.default?.fileName;
|
||||
if (!reportName)
|
||||
return void 0;
|
||||
outputFile = import_path.default.resolve(outputDir, reportName);
|
||||
return { outputFile, outputDir };
|
||||
}
|
||||
function groupAttachments(attachments) {
|
||||
const result = [];
|
||||
const attachmentsByPrefix = /* @__PURE__ */ new Map();
|
||||
for (const attachment of attachments) {
|
||||
if (!attachment.path) {
|
||||
result.push(attachment);
|
||||
continue;
|
||||
}
|
||||
const match = attachment.name.match(/^(.*)-(expected|actual|diff|previous)(\.[^.]+)?$/);
|
||||
if (!match) {
|
||||
result.push(attachment);
|
||||
continue;
|
||||
}
|
||||
const [, name, category] = match;
|
||||
let group = attachmentsByPrefix.get(name);
|
||||
if (!group) {
|
||||
group = { ...attachment, name };
|
||||
attachmentsByPrefix.set(name, group);
|
||||
result.push(group);
|
||||
}
|
||||
if (category === "expected")
|
||||
group.expected = attachment;
|
||||
else if (category === "actual")
|
||||
group.actual = attachment;
|
||||
else if (category === "diff")
|
||||
group.diff = attachment;
|
||||
else if (category === "previous")
|
||||
group.previous = attachment;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
TerminalReporter,
|
||||
fitToWidth,
|
||||
formatError,
|
||||
formatFailure,
|
||||
formatResultFailure,
|
||||
formatRetry,
|
||||
internalScreen,
|
||||
kOutputSymbol,
|
||||
markErrorsAsReported,
|
||||
nonTerminalScreen,
|
||||
prepareErrorStack,
|
||||
relativeFilePath,
|
||||
resolveOutputFile,
|
||||
separator,
|
||||
stepSuffix,
|
||||
terminalScreen
|
||||
});
|
||||
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../src/mysql-core/columns/serial.ts"],"sourcesContent":["import type {\n\tColumnBuilderBaseConfig,\n\tColumnBuilderRuntimeConfig,\n\tHasDefault,\n\tIsAutoincrement,\n\tIsPrimaryKey,\n\tMakeColumnConfig,\n\tNotNull,\n} from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyMySqlTable } from '~/mysql-core/table.ts';\nimport { MySqlColumnBuilderWithAutoIncrement, MySqlColumnWithAutoIncrement } from './common.ts';\n\nexport type MySqlSerialBuilderInitial<TName extends string> = IsAutoincrement<\n\tIsPrimaryKey<\n\t\tNotNull<\n\t\t\tHasDefault<\n\t\t\t\tMySqlSerialBuilder<{\n\t\t\t\t\tname: TName;\n\t\t\t\t\tdataType: 'number';\n\t\t\t\t\tcolumnType: 'MySqlSerial';\n\t\t\t\t\tdata: number;\n\t\t\t\t\tdriverParam: number;\n\t\t\t\t\tenumValues: undefined;\n\t\t\t\t}>\n\t\t\t>\n\t\t>\n\t>\n>;\n\nexport class MySqlSerialBuilder<T extends ColumnBuilderBaseConfig<'number', 'MySqlSerial'>>\n\textends MySqlColumnBuilderWithAutoIncrement<T>\n{\n\tstatic override readonly [entityKind]: string = 'MySqlSerialBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'number', 'MySqlSerial');\n\t\tthis.config.hasDefault = true;\n\t\tthis.config.autoIncrement = true;\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyMySqlTable<{ name: TTableName }>,\n\t): MySqlSerial<MakeColumnConfig<T, TTableName>> {\n\t\treturn new MySqlSerial<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class MySqlSerial<\n\tT extends ColumnBaseConfig<'number', 'MySqlSerial'>,\n> extends MySqlColumnWithAutoIncrement<T> {\n\tstatic override readonly [entityKind]: string = 'MySqlSerial';\n\n\tgetSQLType(): string {\n\t\treturn 'serial';\n\t}\n\n\toverride mapFromDriverValue(value: number | string): number {\n\t\tif (typeof value === 'string') {\n\t\t\treturn Number(value);\n\t\t}\n\t\treturn value;\n\t}\n}\n\nexport function serial(): MySqlSerialBuilderInitial<''>;\nexport function serial<TName extends string>(name: TName): MySqlSerialBuilderInitial<TName>;\nexport function serial(name?: string) {\n\treturn new MySqlSerialBuilder(name ?? '');\n}\n"],"mappings":"AAUA,SAAS,kBAAkB;AAE3B,SAAS,qCAAqC,oCAAoC;AAmB3E,MAAM,2BACJ,oCACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB;AAC5B,UAAM,MAAM,UAAU,aAAa;AACnC,SAAK,OAAO,aAAa;AACzB,SAAK,OAAO,gBAAgB;AAAA,EAC7B;AAAA;AAAA,EAGS,MACR,OAC+C;AAC/C,WAAO,IAAI,YAA6C,OAAO,KAAK,MAA8C;AAAA,EACnH;AACD;AAEO,MAAM,oBAEH,6BAAgC;AAAA,EACzC,QAA0B,UAAU,IAAY;AAAA,EAEhD,aAAqB;AACpB,WAAO;AAAA,EACR;AAAA,EAES,mBAAmB,OAAgC;AAC3D,QAAI,OAAO,UAAU,UAAU;AAC9B,aAAO,OAAO,KAAK;AAAA,IACpB;AACA,WAAO;AAAA,EACR;AACD;AAIO,SAAS,OAAO,MAAe;AACrC,SAAO,IAAI,mBAAmB,QAAQ,EAAE;AACzC;","names":[]}
|
||||
@ -1,796 +0,0 @@
|
||||
import type { CacheConfig, WithCacheConfig } from "../../cache/core/types.cjs";
|
||||
import { entityKind } from "../../entity.cjs";
|
||||
import type { PgColumn } from "../columns/index.cjs";
|
||||
import type { PgDialect } from "../dialect.cjs";
|
||||
import type { PgSession } from "../session.cjs";
|
||||
import type { SubqueryWithSelection } from "../subquery.cjs";
|
||||
import type { PgTable } from "../table.cjs";
|
||||
import { PgViewBase } from "../view-base.cjs";
|
||||
import { TypedQueryBuilder } from "../../query-builders/query-builder.cjs";
|
||||
import type { BuildSubquerySelection, GetSelectTableName, GetSelectTableSelection, JoinNullability, SelectMode, SelectResult } from "../../query-builders/select.types.cjs";
|
||||
import { QueryPromise } from "../../query-promise.cjs";
|
||||
import type { RunnableQuery } from "../../runnable-query.cjs";
|
||||
import { SQL } from "../../sql/sql.cjs";
|
||||
import type { ColumnsSelection, Placeholder, Query, SQLWrapper } from "../../sql/sql.cjs";
|
||||
import { Subquery } from "../../subquery.cjs";
|
||||
import { type DrizzleTypeError, type ValueOrArray } from "../../utils.cjs";
|
||||
import type { CreatePgSelectFromBuilderMode, GetPgSetOperators, LockConfig, LockStrength, PgCreateSetOperatorFn, PgSelectConfig, PgSelectCrossJoinFn, PgSelectDynamic, PgSelectHKT, PgSelectHKTBase, PgSelectJoinFn, PgSelectPrepare, PgSelectWithout, PgSetOperatorExcludedMethods, PgSetOperatorWithResult, SelectedFields, SetOperatorRightSelect, TableLikeHasEmptySelection } from "./select.types.cjs";
|
||||
export declare class PgSelectBuilder<TSelection extends SelectedFields | undefined, TBuilderMode extends 'db' | 'qb' = 'db'> {
|
||||
static readonly [entityKind]: string;
|
||||
private fields;
|
||||
private session;
|
||||
private dialect;
|
||||
private withList;
|
||||
private distinct;
|
||||
constructor(config: {
|
||||
fields: TSelection;
|
||||
session: PgSession | undefined;
|
||||
dialect: PgDialect;
|
||||
withList?: Subquery[];
|
||||
distinct?: boolean | {
|
||||
on: (PgColumn | SQLWrapper)[];
|
||||
};
|
||||
});
|
||||
private authToken?;
|
||||
/**
|
||||
* Specify the table, subquery, or other target that you're
|
||||
* building a select query against.
|
||||
*
|
||||
* {@link https://www.postgresql.org/docs/current/sql-select.html#SQL-FROM | Postgres from documentation}
|
||||
*/
|
||||
from<TFrom extends PgTable | Subquery | PgViewBase | SQL>(source: TableLikeHasEmptySelection<TFrom> extends true ? DrizzleTypeError<"Cannot reference a data-modifying statement subquery if it doesn't contain a `returning` clause"> : TFrom): CreatePgSelectFromBuilderMode<TBuilderMode, GetSelectTableName<TFrom>, TSelection extends undefined ? GetSelectTableSelection<TFrom> : TSelection, TSelection extends undefined ? 'single' : 'partial'>;
|
||||
}
|
||||
export declare abstract class PgSelectQueryBuilderBase<THKT extends PgSelectHKTBase, TTableName extends string | undefined, TSelection extends ColumnsSelection, TSelectMode extends SelectMode, TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>> extends TypedQueryBuilder<TSelectedFields, TResult> {
|
||||
static readonly [entityKind]: string;
|
||||
readonly _: {
|
||||
readonly dialect: 'pg';
|
||||
readonly hkt: THKT;
|
||||
readonly tableName: TTableName;
|
||||
readonly selection: TSelection;
|
||||
readonly selectMode: TSelectMode;
|
||||
readonly nullabilityMap: TNullabilityMap;
|
||||
readonly dynamic: TDynamic;
|
||||
readonly excludedMethods: TExcludedMethods;
|
||||
readonly result: TResult;
|
||||
readonly selectedFields: TSelectedFields;
|
||||
readonly config: PgSelectConfig;
|
||||
};
|
||||
protected config: PgSelectConfig;
|
||||
protected joinsNotNullableMap: Record<string, boolean>;
|
||||
protected tableName: string | undefined;
|
||||
private isPartialSelect;
|
||||
protected session: PgSession | undefined;
|
||||
protected dialect: PgDialect;
|
||||
protected cacheConfig?: WithCacheConfig;
|
||||
protected usedTables: Set<string>;
|
||||
constructor({ table, fields, isPartialSelect, session, dialect, withList, distinct }: {
|
||||
table: PgSelectConfig['table'];
|
||||
fields: PgSelectConfig['fields'];
|
||||
isPartialSelect: boolean;
|
||||
session: PgSession | undefined;
|
||||
dialect: PgDialect;
|
||||
withList: Subquery[];
|
||||
distinct: boolean | {
|
||||
on: (PgColumn | SQLWrapper)[];
|
||||
} | undefined;
|
||||
});
|
||||
private createJoin;
|
||||
/**
|
||||
* Executes a `left join` operation by adding another table to the current query.
|
||||
*
|
||||
* Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
* @param on the `on` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users and their pets
|
||||
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
||||
* ```
|
||||
*/
|
||||
leftJoin: PgSelectJoinFn<this, TDynamic, "left", false>;
|
||||
/**
|
||||
* Executes a `left join lateral` operation by adding subquery to the current query.
|
||||
*
|
||||
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
||||
*
|
||||
* Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}
|
||||
*
|
||||
* @param table the subquery to join.
|
||||
* @param on the `on` clause.
|
||||
*/
|
||||
leftJoinLateral: PgSelectJoinFn<this, TDynamic, "left", true>;
|
||||
/**
|
||||
* Executes a `right join` operation by adding another table to the current query.
|
||||
*
|
||||
* Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#right-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
* @param on the `on` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users and their pets
|
||||
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
||||
* ```
|
||||
*/
|
||||
rightJoin: PgSelectJoinFn<this, TDynamic, "right", false>;
|
||||
/**
|
||||
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
||||
*
|
||||
* Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
* @param on the `on` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users and their pets
|
||||
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
||||
* ```
|
||||
*/
|
||||
innerJoin: PgSelectJoinFn<this, TDynamic, "inner", false>;
|
||||
/**
|
||||
* Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.
|
||||
*
|
||||
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
||||
*
|
||||
* Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}
|
||||
*
|
||||
* @param table the subquery to join.
|
||||
* @param on the `on` clause.
|
||||
*/
|
||||
innerJoinLateral: PgSelectJoinFn<this, TDynamic, "inner", true>;
|
||||
/**
|
||||
* Executes a `full join` operation by combining rows from two tables into a new table.
|
||||
*
|
||||
* Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#full-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
* @param on the `on` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users and their pets
|
||||
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
||||
* ```
|
||||
*/
|
||||
fullJoin: PgSelectJoinFn<this, TDynamic, "full", false>;
|
||||
/**
|
||||
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
||||
*
|
||||
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users, each user with every pet
|
||||
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .crossJoin(pets)
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .crossJoin(pets)
|
||||
* ```
|
||||
*/
|
||||
crossJoin: PgSelectCrossJoinFn<this, TDynamic, false>;
|
||||
/**
|
||||
* Executes a `cross join lateral` operation by combining rows from two queries into a new table.
|
||||
*
|
||||
* A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.
|
||||
*
|
||||
* Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}
|
||||
*
|
||||
* @param table the query to join.
|
||||
*/
|
||||
crossJoinLateral: PgSelectCrossJoinFn<this, TDynamic, true>;
|
||||
private createSetOperator;
|
||||
/**
|
||||
* Adds `union` set operator to the query.
|
||||
*
|
||||
* Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all unique names from customers and users tables
|
||||
* await db.select({ name: users.name })
|
||||
* .from(users)
|
||||
* .union(
|
||||
* db.select({ name: customers.name }).from(customers)
|
||||
* );
|
||||
* // or
|
||||
* import { union } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await union(
|
||||
* db.select({ name: users.name }).from(users),
|
||||
* db.select({ name: customers.name }).from(customers)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
union: <TValue extends PgSetOperatorWithResult<TResult>>(rightSelection: ((setOperators: GetPgSetOperators) => SetOperatorRightSelect<TValue, TResult>) | SetOperatorRightSelect<TValue, TResult>) => PgSelectWithout<this, TDynamic, PgSetOperatorExcludedMethods, true>;
|
||||
/**
|
||||
* Adds `union all` set operator to the query.
|
||||
*
|
||||
* Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all transaction ids from both online and in-store sales
|
||||
* await db.select({ transaction: onlineSales.transactionId })
|
||||
* .from(onlineSales)
|
||||
* .unionAll(
|
||||
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
||||
* );
|
||||
* // or
|
||||
* import { unionAll } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await unionAll(
|
||||
* db.select({ transaction: onlineSales.transactionId }).from(onlineSales),
|
||||
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
unionAll: <TValue extends PgSetOperatorWithResult<TResult>>(rightSelection: ((setOperators: GetPgSetOperators) => SetOperatorRightSelect<TValue, TResult>) | SetOperatorRightSelect<TValue, TResult>) => PgSelectWithout<this, TDynamic, PgSetOperatorExcludedMethods, true>;
|
||||
/**
|
||||
* Adds `intersect` set operator to the query.
|
||||
*
|
||||
* Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select course names that are offered in both departments A and B
|
||||
* await db.select({ courseName: depA.courseName })
|
||||
* .from(depA)
|
||||
* .intersect(
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* // or
|
||||
* import { intersect } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await intersect(
|
||||
* db.select({ courseName: depA.courseName }).from(depA),
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
intersect: <TValue extends PgSetOperatorWithResult<TResult>>(rightSelection: ((setOperators: GetPgSetOperators) => SetOperatorRightSelect<TValue, TResult>) | SetOperatorRightSelect<TValue, TResult>) => PgSelectWithout<this, TDynamic, PgSetOperatorExcludedMethods, true>;
|
||||
/**
|
||||
* Adds `intersect all` set operator to the query.
|
||||
*
|
||||
* Calling this method will retain only the rows that are present in both result sets including all duplicates.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect-all}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all products and quantities that are ordered by both regular and VIP customers
|
||||
* await db.select({
|
||||
* productId: regularCustomerOrders.productId,
|
||||
* quantityOrdered: regularCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(regularCustomerOrders)
|
||||
* .intersectAll(
|
||||
* db.select({
|
||||
* productId: vipCustomerOrders.productId,
|
||||
* quantityOrdered: vipCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(vipCustomerOrders)
|
||||
* );
|
||||
* // or
|
||||
* import { intersectAll } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await intersectAll(
|
||||
* db.select({
|
||||
* productId: regularCustomerOrders.productId,
|
||||
* quantityOrdered: regularCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(regularCustomerOrders),
|
||||
* db.select({
|
||||
* productId: vipCustomerOrders.productId,
|
||||
* quantityOrdered: vipCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(vipCustomerOrders)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
intersectAll: <TValue extends PgSetOperatorWithResult<TResult>>(rightSelection: ((setOperators: GetPgSetOperators) => SetOperatorRightSelect<TValue, TResult>) | SetOperatorRightSelect<TValue, TResult>) => PgSelectWithout<this, TDynamic, PgSetOperatorExcludedMethods, true>;
|
||||
/**
|
||||
* Adds `except` set operator to the query.
|
||||
*
|
||||
* Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#except}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all courses offered in department A but not in department B
|
||||
* await db.select({ courseName: depA.courseName })
|
||||
* .from(depA)
|
||||
* .except(
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* // or
|
||||
* import { except } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await except(
|
||||
* db.select({ courseName: depA.courseName }).from(depA),
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
except: <TValue extends PgSetOperatorWithResult<TResult>>(rightSelection: ((setOperators: GetPgSetOperators) => SetOperatorRightSelect<TValue, TResult>) | SetOperatorRightSelect<TValue, TResult>) => PgSelectWithout<this, TDynamic, PgSetOperatorExcludedMethods, true>;
|
||||
/**
|
||||
* Adds `except all` set operator to the query.
|
||||
*
|
||||
* Calling this method will retrieve all rows from the left query, except for the rows that are present in the result set of the right query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#except-all}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all products that are ordered by regular customers but not by VIP customers
|
||||
* await db.select({
|
||||
* productId: regularCustomerOrders.productId,
|
||||
* quantityOrdered: regularCustomerOrders.quantityOrdered,
|
||||
* })
|
||||
* .from(regularCustomerOrders)
|
||||
* .exceptAll(
|
||||
* db.select({
|
||||
* productId: vipCustomerOrders.productId,
|
||||
* quantityOrdered: vipCustomerOrders.quantityOrdered,
|
||||
* })
|
||||
* .from(vipCustomerOrders)
|
||||
* );
|
||||
* // or
|
||||
* import { exceptAll } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await exceptAll(
|
||||
* db.select({
|
||||
* productId: regularCustomerOrders.productId,
|
||||
* quantityOrdered: regularCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(regularCustomerOrders),
|
||||
* db.select({
|
||||
* productId: vipCustomerOrders.productId,
|
||||
* quantityOrdered: vipCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(vipCustomerOrders)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
exceptAll: <TValue extends PgSetOperatorWithResult<TResult>>(rightSelection: ((setOperators: GetPgSetOperators) => SetOperatorRightSelect<TValue, TResult>) | SetOperatorRightSelect<TValue, TResult>) => PgSelectWithout<this, TDynamic, PgSetOperatorExcludedMethods, true>;
|
||||
/**
|
||||
* Adds a `where` clause to the query.
|
||||
*
|
||||
* Calling this method will select only those rows that fulfill a specified condition.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#filtering}
|
||||
*
|
||||
* @param where the `where` clause.
|
||||
*
|
||||
* @example
|
||||
* You can use conditional operators and `sql function` to filter the rows to be selected.
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars with green color
|
||||
* await db.select().from(cars).where(eq(cars.color, 'green'));
|
||||
* // or
|
||||
* await db.select().from(cars).where(sql`${cars.color} = 'green'`)
|
||||
* ```
|
||||
*
|
||||
* You can logically combine conditional operators with `and()` and `or()` operators:
|
||||
*
|
||||
* ```ts
|
||||
* // Select all BMW cars with a green color
|
||||
* await db.select().from(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
||||
*
|
||||
* // Select all cars with the green or blue color
|
||||
* await db.select().from(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
||||
* ```
|
||||
*/
|
||||
where(where: ((aliases: this['_']['selection']) => SQL | undefined) | SQL | undefined): PgSelectWithout<this, TDynamic, 'where'>;
|
||||
/**
|
||||
* Adds a `having` clause to the query.
|
||||
*
|
||||
* Calling this method will select only those rows that fulfill a specified condition. It is typically used with aggregate functions to filter the aggregated data based on a specified condition.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#aggregations}
|
||||
*
|
||||
* @param having the `having` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all brands with more than one car
|
||||
* await db.select({
|
||||
* brand: cars.brand,
|
||||
* count: sql<number>`cast(count(${cars.id}) as int)`,
|
||||
* })
|
||||
* .from(cars)
|
||||
* .groupBy(cars.brand)
|
||||
* .having(({ count }) => gt(count, 1));
|
||||
* ```
|
||||
*/
|
||||
having(having: ((aliases: this['_']['selection']) => SQL | undefined) | SQL | undefined): PgSelectWithout<this, TDynamic, 'having'>;
|
||||
/**
|
||||
* Adds a `group by` clause to the query.
|
||||
*
|
||||
* Calling this method will group rows that have the same values into summary rows, often used for aggregation purposes.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#aggregations}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Group and count people by their last names
|
||||
* await db.select({
|
||||
* lastName: people.lastName,
|
||||
* count: sql<number>`cast(count(*) as int)`
|
||||
* })
|
||||
* .from(people)
|
||||
* .groupBy(people.lastName);
|
||||
* ```
|
||||
*/
|
||||
groupBy(builder: (aliases: this['_']['selection']) => ValueOrArray<PgColumn | SQL | SQL.Aliased>): PgSelectWithout<this, TDynamic, 'groupBy'>;
|
||||
groupBy(...columns: (PgColumn | SQL | SQL.Aliased)[]): PgSelectWithout<this, TDynamic, 'groupBy'>;
|
||||
/**
|
||||
* Adds an `order by` clause to the query.
|
||||
*
|
||||
* Calling this method will sort the result-set in ascending or descending order. By default, the sort order is ascending.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#order-by}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```
|
||||
* // Select cars ordered by year
|
||||
* await db.select().from(cars).orderBy(cars.year);
|
||||
* ```
|
||||
*
|
||||
* You can specify whether results are in ascending or descending order with the `asc()` and `desc()` operators.
|
||||
*
|
||||
* ```ts
|
||||
* // Select cars ordered by year in descending order
|
||||
* await db.select().from(cars).orderBy(desc(cars.year));
|
||||
*
|
||||
* // Select cars ordered by year and price
|
||||
* await db.select().from(cars).orderBy(asc(cars.year), desc(cars.price));
|
||||
* ```
|
||||
*/
|
||||
orderBy(builder: (aliases: this['_']['selection']) => ValueOrArray<PgColumn | SQL | SQL.Aliased>): PgSelectWithout<this, TDynamic, 'orderBy'>;
|
||||
orderBy(...columns: (PgColumn | SQL | SQL.Aliased)[]): PgSelectWithout<this, TDynamic, 'orderBy'>;
|
||||
/**
|
||||
* Adds a `limit` clause to the query.
|
||||
*
|
||||
* Calling this method will set the maximum number of rows that will be returned by this query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
||||
*
|
||||
* @param limit the `limit` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Get the first 10 people from this query.
|
||||
* await db.select().from(people).limit(10);
|
||||
* ```
|
||||
*/
|
||||
limit(limit: number | Placeholder): PgSelectWithout<this, TDynamic, 'limit'>;
|
||||
/**
|
||||
* Adds an `offset` clause to the query.
|
||||
*
|
||||
* Calling this method will skip a number of rows when returning results from this query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
||||
*
|
||||
* @param offset the `offset` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Get the 10th-20th people from this query.
|
||||
* await db.select().from(people).offset(10).limit(10);
|
||||
* ```
|
||||
*/
|
||||
offset(offset: number | Placeholder): PgSelectWithout<this, TDynamic, 'offset'>;
|
||||
/**
|
||||
* Adds a `for` clause to the query.
|
||||
*
|
||||
* Calling this method will specify a lock strength for this query that controls how strictly it acquires exclusive access to the rows being queried.
|
||||
*
|
||||
* See docs: {@link https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE}
|
||||
*
|
||||
* @param strength the lock strength.
|
||||
* @param config the lock configuration.
|
||||
*/
|
||||
for(strength: LockStrength, config?: LockConfig): PgSelectWithout<this, TDynamic, 'for'>;
|
||||
toSQL(): Query;
|
||||
as<TAlias extends string>(alias: TAlias): SubqueryWithSelection<this['_']['selectedFields'], TAlias>;
|
||||
$dynamic(): PgSelectDynamic<this>;
|
||||
$withCache(config?: {
|
||||
config?: CacheConfig;
|
||||
tag?: string;
|
||||
autoInvalidate?: boolean;
|
||||
} | false): this;
|
||||
}
|
||||
export interface PgSelectBase<TTableName extends string | undefined, TSelection extends ColumnsSelection, TSelectMode extends SelectMode, TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>> extends PgSelectQueryBuilderBase<PgSelectHKT, TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields>, QueryPromise<TResult>, SQLWrapper {
|
||||
}
|
||||
export declare class PgSelectBase<TTableName extends string | undefined, TSelection extends ColumnsSelection, TSelectMode extends SelectMode, TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields = BuildSubquerySelection<TSelection, TNullabilityMap>> extends PgSelectQueryBuilderBase<PgSelectHKT, TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields> implements RunnableQuery<TResult, 'pg'>, SQLWrapper {
|
||||
static readonly [entityKind]: string;
|
||||
/**
|
||||
* Create a prepared statement for this query. This allows
|
||||
* the database to remember this query for the given session
|
||||
* and call it by name, rather than specifying the full query.
|
||||
*
|
||||
* {@link https://www.postgresql.org/docs/current/sql-prepare.html | Postgres prepare documentation}
|
||||
*/
|
||||
prepare(name: string): PgSelectPrepare<this>;
|
||||
private authToken?;
|
||||
execute: ReturnType<this['prepare']>['execute'];
|
||||
}
|
||||
/**
|
||||
* Adds `union` set operator to the query.
|
||||
*
|
||||
* Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all unique names from customers and users tables
|
||||
* import { union } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await union(
|
||||
* db.select({ name: users.name }).from(users),
|
||||
* db.select({ name: customers.name }).from(customers)
|
||||
* );
|
||||
* // or
|
||||
* await db.select({ name: users.name })
|
||||
* .from(users)
|
||||
* .union(
|
||||
* db.select({ name: customers.name }).from(customers)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
export declare const union: PgCreateSetOperatorFn;
|
||||
/**
|
||||
* Adds `union all` set operator to the query.
|
||||
*
|
||||
* Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all transaction ids from both online and in-store sales
|
||||
* import { unionAll } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await unionAll(
|
||||
* db.select({ transaction: onlineSales.transactionId }).from(onlineSales),
|
||||
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
||||
* );
|
||||
* // or
|
||||
* await db.select({ transaction: onlineSales.transactionId })
|
||||
* .from(onlineSales)
|
||||
* .unionAll(
|
||||
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
export declare const unionAll: PgCreateSetOperatorFn;
|
||||
/**
|
||||
* Adds `intersect` set operator to the query.
|
||||
*
|
||||
* Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select course names that are offered in both departments A and B
|
||||
* import { intersect } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await intersect(
|
||||
* db.select({ courseName: depA.courseName }).from(depA),
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* // or
|
||||
* await db.select({ courseName: depA.courseName })
|
||||
* .from(depA)
|
||||
* .intersect(
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
export declare const intersect: PgCreateSetOperatorFn;
|
||||
/**
|
||||
* Adds `intersect all` set operator to the query.
|
||||
*
|
||||
* Calling this method will retain only the rows that are present in both result sets including all duplicates.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect-all}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all products and quantities that are ordered by both regular and VIP customers
|
||||
* import { intersectAll } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await intersectAll(
|
||||
* db.select({
|
||||
* productId: regularCustomerOrders.productId,
|
||||
* quantityOrdered: regularCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(regularCustomerOrders),
|
||||
* db.select({
|
||||
* productId: vipCustomerOrders.productId,
|
||||
* quantityOrdered: vipCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(vipCustomerOrders)
|
||||
* );
|
||||
* // or
|
||||
* await db.select({
|
||||
* productId: regularCustomerOrders.productId,
|
||||
* quantityOrdered: regularCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(regularCustomerOrders)
|
||||
* .intersectAll(
|
||||
* db.select({
|
||||
* productId: vipCustomerOrders.productId,
|
||||
* quantityOrdered: vipCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(vipCustomerOrders)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
export declare const intersectAll: PgCreateSetOperatorFn;
|
||||
/**
|
||||
* Adds `except` set operator to the query.
|
||||
*
|
||||
* Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#except}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all courses offered in department A but not in department B
|
||||
* import { except } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await except(
|
||||
* db.select({ courseName: depA.courseName }).from(depA),
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* // or
|
||||
* await db.select({ courseName: depA.courseName })
|
||||
* .from(depA)
|
||||
* .except(
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
export declare const except: PgCreateSetOperatorFn;
|
||||
/**
|
||||
* Adds `except all` set operator to the query.
|
||||
*
|
||||
* Calling this method will retrieve all rows from the left query, except for the rows that are present in the result set of the right query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#except-all}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all products that are ordered by regular customers but not by VIP customers
|
||||
* import { exceptAll } from 'drizzle-orm/pg-core'
|
||||
*
|
||||
* await exceptAll(
|
||||
* db.select({
|
||||
* productId: regularCustomerOrders.productId,
|
||||
* quantityOrdered: regularCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(regularCustomerOrders),
|
||||
* db.select({
|
||||
* productId: vipCustomerOrders.productId,
|
||||
* quantityOrdered: vipCustomerOrders.quantityOrdered
|
||||
* })
|
||||
* .from(vipCustomerOrders)
|
||||
* );
|
||||
* // or
|
||||
* await db.select({
|
||||
* productId: regularCustomerOrders.productId,
|
||||
* quantityOrdered: regularCustomerOrders.quantityOrdered,
|
||||
* })
|
||||
* .from(regularCustomerOrders)
|
||||
* .exceptAll(
|
||||
* db.select({
|
||||
* productId: vipCustomerOrders.productId,
|
||||
* quantityOrdered: vipCustomerOrders.quantityOrdered,
|
||||
* })
|
||||
* .from(vipCustomerOrders)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
export declare const exceptAll: PgCreateSetOperatorFn;
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,149 +0,0 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var indexes_exports = {};
|
||||
__export(indexes_exports, {
|
||||
Index: () => Index,
|
||||
IndexBuilder: () => IndexBuilder,
|
||||
IndexBuilderOn: () => IndexBuilderOn,
|
||||
index: () => index,
|
||||
uniqueIndex: () => uniqueIndex
|
||||
});
|
||||
module.exports = __toCommonJS(indexes_exports);
|
||||
var import_sql = require("../sql/sql.cjs");
|
||||
var import_entity = require("../entity.cjs");
|
||||
var import_columns = require("./columns/index.cjs");
|
||||
class IndexBuilderOn {
|
||||
constructor(unique, name) {
|
||||
this.unique = unique;
|
||||
this.name = name;
|
||||
}
|
||||
static [import_entity.entityKind] = "GelIndexBuilderOn";
|
||||
on(...columns) {
|
||||
return new IndexBuilder(
|
||||
columns.map((it) => {
|
||||
if ((0, import_entity.is)(it, import_sql.SQL)) {
|
||||
return it;
|
||||
}
|
||||
it = it;
|
||||
const clonedIndexedColumn = new import_columns.IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
||||
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
||||
return clonedIndexedColumn;
|
||||
}),
|
||||
this.unique,
|
||||
false,
|
||||
this.name
|
||||
);
|
||||
}
|
||||
onOnly(...columns) {
|
||||
return new IndexBuilder(
|
||||
columns.map((it) => {
|
||||
if ((0, import_entity.is)(it, import_sql.SQL)) {
|
||||
return it;
|
||||
}
|
||||
it = it;
|
||||
const clonedIndexedColumn = new import_columns.IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
||||
it.indexConfig = it.defaultConfig;
|
||||
return clonedIndexedColumn;
|
||||
}),
|
||||
this.unique,
|
||||
true,
|
||||
this.name
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.
|
||||
*
|
||||
* If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.
|
||||
*
|
||||
* **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**
|
||||
*
|
||||
* @param method The name of the index method to be used
|
||||
* @param columns
|
||||
* @returns
|
||||
*/
|
||||
using(method, ...columns) {
|
||||
return new IndexBuilder(
|
||||
columns.map((it) => {
|
||||
if ((0, import_entity.is)(it, import_sql.SQL)) {
|
||||
return it;
|
||||
}
|
||||
it = it;
|
||||
const clonedIndexedColumn = new import_columns.IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
|
||||
it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
|
||||
return clonedIndexedColumn;
|
||||
}),
|
||||
this.unique,
|
||||
true,
|
||||
this.name,
|
||||
method
|
||||
);
|
||||
}
|
||||
}
|
||||
class IndexBuilder {
|
||||
static [import_entity.entityKind] = "GelIndexBuilder";
|
||||
/** @internal */
|
||||
config;
|
||||
constructor(columns, unique, only, name, method = "btree") {
|
||||
this.config = {
|
||||
name,
|
||||
columns,
|
||||
unique,
|
||||
only,
|
||||
method
|
||||
};
|
||||
}
|
||||
concurrently() {
|
||||
this.config.concurrently = true;
|
||||
return this;
|
||||
}
|
||||
with(obj) {
|
||||
this.config.with = obj;
|
||||
return this;
|
||||
}
|
||||
where(condition) {
|
||||
this.config.where = condition;
|
||||
return this;
|
||||
}
|
||||
/** @internal */
|
||||
build(table) {
|
||||
return new Index(this.config, table);
|
||||
}
|
||||
}
|
||||
class Index {
|
||||
static [import_entity.entityKind] = "GelIndex";
|
||||
config;
|
||||
constructor(config, table) {
|
||||
this.config = { ...config, table };
|
||||
}
|
||||
}
|
||||
function index(name) {
|
||||
return new IndexBuilderOn(false, name);
|
||||
}
|
||||
function uniqueIndex(name) {
|
||||
return new IndexBuilderOn(true, name);
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
Index,
|
||||
IndexBuilder,
|
||||
IndexBuilderOn,
|
||||
index,
|
||||
uniqueIndex
|
||||
});
|
||||
//# sourceMappingURL=indexes.cjs.map
|
||||
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../src/singlestore-core/columns/year.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnySingleStoreTable } from '~/singlestore-core/table.ts';\nimport { SingleStoreColumn, SingleStoreColumnBuilder } from './common.ts';\n\nexport type SingleStoreYearBuilderInitial<TName extends string> = SingleStoreYearBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'SingleStoreYear';\n\tdata: number;\n\tdriverParam: number;\n\tenumValues: undefined;\n\tgenerated: undefined;\n}>;\n\nexport class SingleStoreYearBuilder<T extends ColumnBuilderBaseConfig<'number', 'SingleStoreYear'>>\n\textends SingleStoreColumnBuilder<T>\n{\n\tstatic override readonly [entityKind]: string = 'SingleStoreYearBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'number', 'SingleStoreYear');\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnySingleStoreTable<{ name: TTableName }>,\n\t): SingleStoreYear<MakeColumnConfig<T, TTableName>> {\n\t\treturn new SingleStoreYear<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class SingleStoreYear<\n\tT extends ColumnBaseConfig<'number', 'SingleStoreYear'>,\n> extends SingleStoreColumn<T> {\n\tstatic override readonly [entityKind]: string = 'SingleStoreYear';\n\n\tgetSQLType(): string {\n\t\treturn `year`;\n\t}\n}\n\nexport function year(): SingleStoreYearBuilderInitial<''>;\nexport function year<TName extends string>(name: TName): SingleStoreYearBuilderInitial<TName>;\nexport function year(name?: string) {\n\treturn new SingleStoreYearBuilder(name ?? '');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAE3B,oBAA4D;AAYrD,MAAM,+BACJ,uCACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB;AAC5B,UAAM,MAAM,UAAU,iBAAiB;AAAA,EACxC;AAAA;AAAA,EAGS,MACR,OACmD;AACnD,WAAO,IAAI;AAAA,MACV;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,wBAEH,gCAAqB;AAAA,EAC9B,QAA0B,wBAAU,IAAY;AAAA,EAEhD,aAAqB;AACpB,WAAO;AAAA,EACR;AACD;AAIO,SAAS,KAAK,MAAe;AACnC,SAAO,IAAI,uBAAuB,QAAQ,EAAE;AAC7C;","names":[]}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
{"version":3,"file":"concatMap.js","sourceRoot":"","sources":["../../../../src/internal/operators/concatMap.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AAEtC,iDAAgD;AA2EhD,SAAgB,SAAS,CACvB,OAAuC,EACvC,cAA6G;IAE7G,OAAO,uBAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,mBAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAClG,CAAC;AALD,8BAKC"}
|
||||
@ -1,5 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
module.exports.isClean = Symbol('isClean')
|
||||
|
||||
module.exports.my = Symbol('my')
|
||||
@ -1,34 +0,0 @@
|
||||
var defer = require('./defer.js');
|
||||
|
||||
// API
|
||||
module.exports = async;
|
||||
|
||||
/**
|
||||
* Runs provided callback asynchronously
|
||||
* even if callback itself is not
|
||||
*
|
||||
* @param {function} callback - callback to invoke
|
||||
* @returns {function} - augmented callback
|
||||
*/
|
||||
function async(callback)
|
||||
{
|
||||
var isAsync = false;
|
||||
|
||||
// check if async happened
|
||||
defer(function() { isAsync = true; });
|
||||
|
||||
return function async_callback(err, result)
|
||||
{
|
||||
if (isAsync)
|
||||
{
|
||||
callback(err, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
defer(function nextTick_callback()
|
||||
{
|
||||
callback(err, result);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../src/gel-core/columns/localdate.ts"],"sourcesContent":["import type { LocalDate } from 'gel';\nimport type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnyGelTable } from '~/gel-core/table.ts';\nimport { GelColumn } from './common.ts';\nimport { GelLocalDateColumnBaseBuilder } from './date.common.ts';\n\nexport type GelLocalDateStringBuilderInitial<TName extends string> = GelLocalDateStringBuilder<{\n\tname: TName;\n\tdataType: 'localDate';\n\tcolumnType: 'GelLocalDateString';\n\tdata: LocalDate;\n\tdriverParam: LocalDate;\n\tenumValues: undefined;\n}>;\n\nexport class GelLocalDateStringBuilder<T extends ColumnBuilderBaseConfig<'localDate', 'GelLocalDateString'>>\n\textends GelLocalDateColumnBaseBuilder<T>\n{\n\tstatic override readonly [entityKind]: string = 'GelLocalDateStringBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'localDate', 'GelLocalDateString');\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnyGelTable<{ name: TTableName }>,\n\t): GelLocalDateString<MakeColumnConfig<T, TTableName>> {\n\t\treturn new GelLocalDateString<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class GelLocalDateString<T extends ColumnBaseConfig<'localDate', 'GelLocalDateString'>> extends GelColumn<T> {\n\tstatic override readonly [entityKind]: string = 'GelLocalDateString';\n\n\tgetSQLType(): string {\n\t\treturn 'cal::local_date';\n\t}\n}\n\nexport function localDate(): GelLocalDateStringBuilderInitial<''>;\nexport function localDate<TName extends string>(name: TName): GelLocalDateStringBuilderInitial<TName>;\nexport function localDate(name?: string) {\n\treturn new GelLocalDateStringBuilder(name ?? '');\n}\n"],"mappings":"AAGA,SAAS,kBAAkB;AAE3B,SAAS,iBAAiB;AAC1B,SAAS,qCAAqC;AAWvC,MAAM,kCACJ,8BACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB;AAC5B,UAAM,MAAM,aAAa,oBAAoB;AAAA,EAC9C;AAAA;AAAA,EAGS,MACR,OACsD;AACtD,WAAO,IAAI;AAAA,MACV;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,2BAA0F,UAAa;AAAA,EACnH,QAA0B,UAAU,IAAY;AAAA,EAEhD,aAAqB;AACpB,WAAO;AAAA,EACR;AACD;AAIO,SAAS,UAAU,MAAe;AACxC,SAAO,IAAI,0BAA0B,QAAQ,EAAE;AAChD;","names":[]}
|
||||
@ -1 +0,0 @@
|
||||
{"version":3,"file":"refCount.js","sourceRoot":"","sources":["../../../../src/internal/operators/refCount.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AA4DhE,MAAM,UAAU,QAAQ;IACtB,OAAO,OAAO,CAAC,UAAC,MAAM,EAAE,UAAU;QAChC,IAAI,UAAU,GAAwB,IAAI,CAAC;QAE1C,MAAc,CAAC,SAAS,EAAE,CAAC;QAE5B,IAAM,UAAU,GAAG,wBAAwB,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE;YACvF,IAAI,CAAC,MAAM,IAAK,MAAc,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,GAAG,EAAG,MAAc,CAAC,SAAS,EAAE;gBAChF,UAAU,GAAG,IAAI,CAAC;gBAClB,OAAO;aACR;YA2BD,IAAM,gBAAgB,GAAI,MAAc,CAAC,WAAW,CAAC;YACrD,IAAM,IAAI,GAAG,UAAU,CAAC;YACxB,UAAU,GAAG,IAAI,CAAC;YAElB,IAAI,gBAAgB,IAAI,CAAC,CAAC,IAAI,IAAI,gBAAgB,KAAK,IAAI,CAAC,EAAE;gBAC5D,gBAAgB,CAAC,WAAW,EAAE,CAAC;aAChC;YAED,UAAU,CAAC,WAAW,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAE7B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YACtB,UAAU,GAAI,MAAmC,CAAC,OAAO,EAAE,CAAC;SAC7D;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
@ -1,138 +0,0 @@
|
||||
# combined-stream
|
||||
|
||||
A stream that emits multiple other streams one after another.
|
||||
|
||||
**NB** Currently `combined-stream` works with streams version 1 only. There is ongoing effort to switch this library to streams version 2. Any help is welcome. :) Meanwhile you can explore other libraries that provide streams2 support with more or less compatibility with `combined-stream`.
|
||||
|
||||
- [combined-stream2](https://www.npmjs.com/package/combined-stream2): A drop-in streams2-compatible replacement for the combined-stream module.
|
||||
|
||||
- [multistream](https://www.npmjs.com/package/multistream): A stream that emits multiple other streams one after another.
|
||||
|
||||
## Installation
|
||||
|
||||
``` bash
|
||||
npm install combined-stream
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a simple example that shows how you can use combined-stream to combine
|
||||
two files into one:
|
||||
|
||||
``` javascript
|
||||
var CombinedStream = require('combined-stream');
|
||||
var fs = require('fs');
|
||||
|
||||
var combinedStream = CombinedStream.create();
|
||||
combinedStream.append(fs.createReadStream('file1.txt'));
|
||||
combinedStream.append(fs.createReadStream('file2.txt'));
|
||||
|
||||
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
||||
```
|
||||
|
||||
While the example above works great, it will pause all source streams until
|
||||
they are needed. If you don't want that to happen, you can set `pauseStreams`
|
||||
to `false`:
|
||||
|
||||
``` javascript
|
||||
var CombinedStream = require('combined-stream');
|
||||
var fs = require('fs');
|
||||
|
||||
var combinedStream = CombinedStream.create({pauseStreams: false});
|
||||
combinedStream.append(fs.createReadStream('file1.txt'));
|
||||
combinedStream.append(fs.createReadStream('file2.txt'));
|
||||
|
||||
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
||||
```
|
||||
|
||||
However, what if you don't have all the source streams yet, or you don't want
|
||||
to allocate the resources (file descriptors, memory, etc.) for them right away?
|
||||
Well, in that case you can simply provide a callback that supplies the stream
|
||||
by calling a `next()` function:
|
||||
|
||||
``` javascript
|
||||
var CombinedStream = require('combined-stream');
|
||||
var fs = require('fs');
|
||||
|
||||
var combinedStream = CombinedStream.create();
|
||||
combinedStream.append(function(next) {
|
||||
next(fs.createReadStream('file1.txt'));
|
||||
});
|
||||
combinedStream.append(function(next) {
|
||||
next(fs.createReadStream('file2.txt'));
|
||||
});
|
||||
|
||||
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### CombinedStream.create([options])
|
||||
|
||||
Returns a new combined stream object. Available options are:
|
||||
|
||||
* `maxDataSize`
|
||||
* `pauseStreams`
|
||||
|
||||
The effect of those options is described below.
|
||||
|
||||
### combinedStream.pauseStreams = `true`
|
||||
|
||||
Whether to apply back pressure to the underlaying streams. If set to `false`,
|
||||
the underlaying streams will never be paused. If set to `true`, the
|
||||
underlaying streams will be paused right after being appended, as well as when
|
||||
`delayedStream.pipe()` wants to throttle.
|
||||
|
||||
### combinedStream.maxDataSize = `2 * 1024 * 1024`
|
||||
|
||||
The maximum amount of bytes (or characters) to buffer for all source streams.
|
||||
If this value is exceeded, `combinedStream` emits an `'error'` event.
|
||||
|
||||
### combinedStream.dataSize = `0`
|
||||
|
||||
The amount of bytes (or characters) currently buffered by `combinedStream`.
|
||||
|
||||
### combinedStream.append(stream)
|
||||
|
||||
Appends the given `stream` to the combinedStream object. If `pauseStreams` is
|
||||
set to `true, this stream will also be paused right away.
|
||||
|
||||
`streams` can also be a function that takes one parameter called `next`. `next`
|
||||
is a function that must be invoked in order to provide the `next` stream, see
|
||||
example above.
|
||||
|
||||
Regardless of how the `stream` is appended, combined-stream always attaches an
|
||||
`'error'` listener to it, so you don't have to do that manually.
|
||||
|
||||
Special case: `stream` can also be a String or Buffer.
|
||||
|
||||
### combinedStream.write(data)
|
||||
|
||||
You should not call this, `combinedStream` takes care of piping the appended
|
||||
streams into itself for you.
|
||||
|
||||
### combinedStream.resume()
|
||||
|
||||
Causes `combinedStream` to start drain the streams it manages. The function is
|
||||
idempotent, and also emits a `'resume'` event each time which usually goes to
|
||||
the stream that is currently being drained.
|
||||
|
||||
### combinedStream.pause();
|
||||
|
||||
If `combinedStream.pauseStreams` is set to `false`, this does nothing.
|
||||
Otherwise a `'pause'` event is emitted, this goes to the stream that is
|
||||
currently being drained, so you can use it to apply back pressure.
|
||||
|
||||
### combinedStream.end();
|
||||
|
||||
Sets `combinedStream.writable` to false, emits an `'end'` event, and removes
|
||||
all streams from the queue.
|
||||
|
||||
### combinedStream.destroy();
|
||||
|
||||
Same as `combinedStream.end()`, except it emits a `'close'` event instead of
|
||||
`'end'`.
|
||||
|
||||
## License
|
||||
|
||||
combined-stream is licensed under the MIT license.
|
||||
@ -1,14 +0,0 @@
|
||||
import { AsyncAction } from './AsyncAction';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { QueueScheduler } from './QueueScheduler';
|
||||
import { SchedulerAction } from '../types';
|
||||
import { TimerHandle } from './timerHandle';
|
||||
export declare class QueueAction<T> extends AsyncAction<T> {
|
||||
protected scheduler: QueueScheduler;
|
||||
protected work: (this: SchedulerAction<T>, state?: T) => void;
|
||||
constructor(scheduler: QueueScheduler, work: (this: SchedulerAction<T>, state?: T) => void);
|
||||
schedule(state?: T, delay?: number): Subscription;
|
||||
execute(state: T, delay: number): any;
|
||||
protected requestAsyncId(scheduler: QueueScheduler, id?: TimerHandle, delay?: number): TimerHandle;
|
||||
}
|
||||
//# sourceMappingURL=QueueAction.d.ts.map
|
||||
@ -1,714 +0,0 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except2, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except2)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var select_exports = {};
|
||||
__export(select_exports, {
|
||||
SQLiteSelectBase: () => SQLiteSelectBase,
|
||||
SQLiteSelectBuilder: () => SQLiteSelectBuilder,
|
||||
SQLiteSelectQueryBuilderBase: () => SQLiteSelectQueryBuilderBase,
|
||||
except: () => except,
|
||||
intersect: () => intersect,
|
||||
union: () => union,
|
||||
unionAll: () => unionAll
|
||||
});
|
||||
module.exports = __toCommonJS(select_exports);
|
||||
var import_entity = require("../../entity.cjs");
|
||||
var import_query_builder = require("../../query-builders/query-builder.cjs");
|
||||
var import_query_promise = require("../../query-promise.cjs");
|
||||
var import_selection_proxy = require("../../selection-proxy.cjs");
|
||||
var import_sql = require("../../sql/sql.cjs");
|
||||
var import_subquery = require("../../subquery.cjs");
|
||||
var import_table = require("../../table.cjs");
|
||||
var import_utils = require("../../utils.cjs");
|
||||
var import_view_common = require("../../view-common.cjs");
|
||||
var import_utils2 = require("../utils.cjs");
|
||||
var import_view_base = require("../view-base.cjs");
|
||||
class SQLiteSelectBuilder {
|
||||
static [import_entity.entityKind] = "SQLiteSelectBuilder";
|
||||
fields;
|
||||
session;
|
||||
dialect;
|
||||
withList;
|
||||
distinct;
|
||||
constructor(config) {
|
||||
this.fields = config.fields;
|
||||
this.session = config.session;
|
||||
this.dialect = config.dialect;
|
||||
this.withList = config.withList;
|
||||
this.distinct = config.distinct;
|
||||
}
|
||||
from(source) {
|
||||
const isPartialSelect = !!this.fields;
|
||||
let fields;
|
||||
if (this.fields) {
|
||||
fields = this.fields;
|
||||
} else if ((0, import_entity.is)(source, import_subquery.Subquery)) {
|
||||
fields = Object.fromEntries(
|
||||
Object.keys(source._.selectedFields).map((key) => [key, source[key]])
|
||||
);
|
||||
} else if ((0, import_entity.is)(source, import_view_base.SQLiteViewBase)) {
|
||||
fields = source[import_view_common.ViewBaseConfig].selectedFields;
|
||||
} else if ((0, import_entity.is)(source, import_sql.SQL)) {
|
||||
fields = {};
|
||||
} else {
|
||||
fields = (0, import_utils.getTableColumns)(source);
|
||||
}
|
||||
return new SQLiteSelectBase({
|
||||
table: source,
|
||||
fields,
|
||||
isPartialSelect,
|
||||
session: this.session,
|
||||
dialect: this.dialect,
|
||||
withList: this.withList,
|
||||
distinct: this.distinct
|
||||
});
|
||||
}
|
||||
}
|
||||
class SQLiteSelectQueryBuilderBase extends import_query_builder.TypedQueryBuilder {
|
||||
static [import_entity.entityKind] = "SQLiteSelectQueryBuilder";
|
||||
_;
|
||||
/** @internal */
|
||||
config;
|
||||
joinsNotNullableMap;
|
||||
tableName;
|
||||
isPartialSelect;
|
||||
session;
|
||||
dialect;
|
||||
cacheConfig = void 0;
|
||||
usedTables = /* @__PURE__ */ new Set();
|
||||
constructor({ table, fields, isPartialSelect, session, dialect, withList, distinct }) {
|
||||
super();
|
||||
this.config = {
|
||||
withList,
|
||||
table,
|
||||
fields: { ...fields },
|
||||
distinct,
|
||||
setOperators: []
|
||||
};
|
||||
this.isPartialSelect = isPartialSelect;
|
||||
this.session = session;
|
||||
this.dialect = dialect;
|
||||
this._ = {
|
||||
selectedFields: fields,
|
||||
config: this.config
|
||||
};
|
||||
this.tableName = (0, import_utils.getTableLikeName)(table);
|
||||
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
||||
for (const item of (0, import_utils2.extractUsedTable)(table)) this.usedTables.add(item);
|
||||
}
|
||||
/** @internal */
|
||||
getUsedTables() {
|
||||
return [...this.usedTables];
|
||||
}
|
||||
createJoin(joinType) {
|
||||
return (table, on) => {
|
||||
const baseTableName = this.tableName;
|
||||
const tableName = (0, import_utils.getTableLikeName)(table);
|
||||
for (const item of (0, import_utils2.extractUsedTable)(table)) this.usedTables.add(item);
|
||||
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
|
||||
throw new Error(`Alias "${tableName}" is already used in this query`);
|
||||
}
|
||||
if (!this.isPartialSelect) {
|
||||
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") {
|
||||
this.config.fields = {
|
||||
[baseTableName]: this.config.fields
|
||||
};
|
||||
}
|
||||
if (typeof tableName === "string" && !(0, import_entity.is)(table, import_sql.SQL)) {
|
||||
const selection = (0, import_entity.is)(table, import_subquery.Subquery) ? table._.selectedFields : (0, import_entity.is)(table, import_sql.View) ? table[import_view_common.ViewBaseConfig].selectedFields : table[import_table.Table.Symbol.Columns];
|
||||
this.config.fields[tableName] = selection;
|
||||
}
|
||||
}
|
||||
if (typeof on === "function") {
|
||||
on = on(
|
||||
new Proxy(
|
||||
this.config.fields,
|
||||
new import_selection_proxy.SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
||||
)
|
||||
);
|
||||
}
|
||||
if (!this.config.joins) {
|
||||
this.config.joins = [];
|
||||
}
|
||||
this.config.joins.push({ on, table, joinType, alias: tableName });
|
||||
if (typeof tableName === "string") {
|
||||
switch (joinType) {
|
||||
case "left": {
|
||||
this.joinsNotNullableMap[tableName] = false;
|
||||
break;
|
||||
}
|
||||
case "right": {
|
||||
this.joinsNotNullableMap = Object.fromEntries(
|
||||
Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
|
||||
);
|
||||
this.joinsNotNullableMap[tableName] = true;
|
||||
break;
|
||||
}
|
||||
case "cross":
|
||||
case "inner": {
|
||||
this.joinsNotNullableMap[tableName] = true;
|
||||
break;
|
||||
}
|
||||
case "full": {
|
||||
this.joinsNotNullableMap = Object.fromEntries(
|
||||
Object.entries(this.joinsNotNullableMap).map(([key]) => [key, false])
|
||||
);
|
||||
this.joinsNotNullableMap[tableName] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Executes a `left join` operation by adding another table to the current query.
|
||||
*
|
||||
* Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
* @param on the `on` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users and their pets
|
||||
* const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
||||
* ```
|
||||
*/
|
||||
leftJoin = this.createJoin("left");
|
||||
/**
|
||||
* Executes a `right join` operation by adding another table to the current query.
|
||||
*
|
||||
* Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#right-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
* @param on the `on` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users and their pets
|
||||
* const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
||||
* ```
|
||||
*/
|
||||
rightJoin = this.createJoin("right");
|
||||
/**
|
||||
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
||||
*
|
||||
* Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
* @param on the `on` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users and their pets
|
||||
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
||||
* ```
|
||||
*/
|
||||
innerJoin = this.createJoin("inner");
|
||||
/**
|
||||
* Executes a `full join` operation by combining rows from two tables into a new table.
|
||||
*
|
||||
* Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#full-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
* @param on the `on` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users and their pets
|
||||
* const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
||||
* ```
|
||||
*/
|
||||
fullJoin = this.createJoin("full");
|
||||
/**
|
||||
* Executes a `cross join` operation by combining rows from two tables into a new table.
|
||||
*
|
||||
* Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}
|
||||
*
|
||||
* @param table the table to join.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all users, each user with every pet
|
||||
* const usersWithPets: { user: User; pets: Pet; }[] = await db.select()
|
||||
* .from(users)
|
||||
* .crossJoin(pets)
|
||||
*
|
||||
* // Select userId and petId
|
||||
* const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({
|
||||
* userId: users.id,
|
||||
* petId: pets.id,
|
||||
* })
|
||||
* .from(users)
|
||||
* .crossJoin(pets)
|
||||
* ```
|
||||
*/
|
||||
crossJoin = this.createJoin("cross");
|
||||
createSetOperator(type, isAll) {
|
||||
return (rightSelection) => {
|
||||
const rightSelect = typeof rightSelection === "function" ? rightSelection(getSQLiteSetOperators()) : rightSelection;
|
||||
if (!(0, import_utils.haveSameKeys)(this.getSelectedFields(), rightSelect.getSelectedFields())) {
|
||||
throw new Error(
|
||||
"Set operator error (union / intersect / except): selected fields are not the same or are in a different order"
|
||||
);
|
||||
}
|
||||
this.config.setOperators.push({ type, isAll, rightSelect });
|
||||
return this;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Adds `union` set operator to the query.
|
||||
*
|
||||
* Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all unique names from customers and users tables
|
||||
* await db.select({ name: users.name })
|
||||
* .from(users)
|
||||
* .union(
|
||||
* db.select({ name: customers.name }).from(customers)
|
||||
* );
|
||||
* // or
|
||||
* import { union } from 'drizzle-orm/sqlite-core'
|
||||
*
|
||||
* await union(
|
||||
* db.select({ name: users.name }).from(users),
|
||||
* db.select({ name: customers.name }).from(customers)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
union = this.createSetOperator("union", false);
|
||||
/**
|
||||
* Adds `union all` set operator to the query.
|
||||
*
|
||||
* Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all transaction ids from both online and in-store sales
|
||||
* await db.select({ transaction: onlineSales.transactionId })
|
||||
* .from(onlineSales)
|
||||
* .unionAll(
|
||||
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
||||
* );
|
||||
* // or
|
||||
* import { unionAll } from 'drizzle-orm/sqlite-core'
|
||||
*
|
||||
* await unionAll(
|
||||
* db.select({ transaction: onlineSales.transactionId }).from(onlineSales),
|
||||
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
unionAll = this.createSetOperator("union", true);
|
||||
/**
|
||||
* Adds `intersect` set operator to the query.
|
||||
*
|
||||
* Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select course names that are offered in both departments A and B
|
||||
* await db.select({ courseName: depA.courseName })
|
||||
* .from(depA)
|
||||
* .intersect(
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* // or
|
||||
* import { intersect } from 'drizzle-orm/sqlite-core'
|
||||
*
|
||||
* await intersect(
|
||||
* db.select({ courseName: depA.courseName }).from(depA),
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
intersect = this.createSetOperator("intersect", false);
|
||||
/**
|
||||
* Adds `except` set operator to the query.
|
||||
*
|
||||
* Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/set-operations#except}
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all courses offered in department A but not in department B
|
||||
* await db.select({ courseName: depA.courseName })
|
||||
* .from(depA)
|
||||
* .except(
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* // or
|
||||
* import { except } from 'drizzle-orm/sqlite-core'
|
||||
*
|
||||
* await except(
|
||||
* db.select({ courseName: depA.courseName }).from(depA),
|
||||
* db.select({ courseName: depB.courseName }).from(depB)
|
||||
* );
|
||||
* ```
|
||||
*/
|
||||
except = this.createSetOperator("except", false);
|
||||
/** @internal */
|
||||
addSetOperators(setOperators) {
|
||||
this.config.setOperators.push(...setOperators);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds a `where` clause to the query.
|
||||
*
|
||||
* Calling this method will select only those rows that fulfill a specified condition.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#filtering}
|
||||
*
|
||||
* @param where the `where` clause.
|
||||
*
|
||||
* @example
|
||||
* You can use conditional operators and `sql function` to filter the rows to be selected.
|
||||
*
|
||||
* ```ts
|
||||
* // Select all cars with green color
|
||||
* await db.select().from(cars).where(eq(cars.color, 'green'));
|
||||
* // or
|
||||
* await db.select().from(cars).where(sql`${cars.color} = 'green'`)
|
||||
* ```
|
||||
*
|
||||
* You can logically combine conditional operators with `and()` and `or()` operators:
|
||||
*
|
||||
* ```ts
|
||||
* // Select all BMW cars with a green color
|
||||
* await db.select().from(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
||||
*
|
||||
* // Select all cars with the green or blue color
|
||||
* await db.select().from(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
||||
* ```
|
||||
*/
|
||||
where(where) {
|
||||
if (typeof where === "function") {
|
||||
where = where(
|
||||
new Proxy(
|
||||
this.config.fields,
|
||||
new import_selection_proxy.SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
||||
)
|
||||
);
|
||||
}
|
||||
this.config.where = where;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds a `having` clause to the query.
|
||||
*
|
||||
* Calling this method will select only those rows that fulfill a specified condition. It is typically used with aggregate functions to filter the aggregated data based on a specified condition.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#aggregations}
|
||||
*
|
||||
* @param having the `having` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Select all brands with more than one car
|
||||
* await db.select({
|
||||
* brand: cars.brand,
|
||||
* count: sql<number>`cast(count(${cars.id}) as int)`,
|
||||
* })
|
||||
* .from(cars)
|
||||
* .groupBy(cars.brand)
|
||||
* .having(({ count }) => gt(count, 1));
|
||||
* ```
|
||||
*/
|
||||
having(having) {
|
||||
if (typeof having === "function") {
|
||||
having = having(
|
||||
new Proxy(
|
||||
this.config.fields,
|
||||
new import_selection_proxy.SelectionProxyHandler({ sqlAliasedBehavior: "sql", sqlBehavior: "sql" })
|
||||
)
|
||||
);
|
||||
}
|
||||
this.config.having = having;
|
||||
return this;
|
||||
}
|
||||
groupBy(...columns) {
|
||||
if (typeof columns[0] === "function") {
|
||||
const groupBy = columns[0](
|
||||
new Proxy(
|
||||
this.config.fields,
|
||||
new import_selection_proxy.SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
||||
)
|
||||
);
|
||||
this.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];
|
||||
} else {
|
||||
this.config.groupBy = columns;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
orderBy(...columns) {
|
||||
if (typeof columns[0] === "function") {
|
||||
const orderBy = columns[0](
|
||||
new Proxy(
|
||||
this.config.fields,
|
||||
new import_selection_proxy.SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
||||
)
|
||||
);
|
||||
const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
||||
if (this.config.setOperators.length > 0) {
|
||||
this.config.setOperators.at(-1).orderBy = orderByArray;
|
||||
} else {
|
||||
this.config.orderBy = orderByArray;
|
||||
}
|
||||
} else {
|
||||
const orderByArray = columns;
|
||||
if (this.config.setOperators.length > 0) {
|
||||
this.config.setOperators.at(-1).orderBy = orderByArray;
|
||||
} else {
|
||||
this.config.orderBy = orderByArray;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds a `limit` clause to the query.
|
||||
*
|
||||
* Calling this method will set the maximum number of rows that will be returned by this query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
||||
*
|
||||
* @param limit the `limit` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Get the first 10 people from this query.
|
||||
* await db.select().from(people).limit(10);
|
||||
* ```
|
||||
*/
|
||||
limit(limit) {
|
||||
if (this.config.setOperators.length > 0) {
|
||||
this.config.setOperators.at(-1).limit = limit;
|
||||
} else {
|
||||
this.config.limit = limit;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Adds an `offset` clause to the query.
|
||||
*
|
||||
* Calling this method will skip a number of rows when returning results from this query.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
||||
*
|
||||
* @param offset the `offset` clause.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* ```ts
|
||||
* // Get the 10th-20th people from this query.
|
||||
* await db.select().from(people).offset(10).limit(10);
|
||||
* ```
|
||||
*/
|
||||
offset(offset) {
|
||||
if (this.config.setOperators.length > 0) {
|
||||
this.config.setOperators.at(-1).offset = offset;
|
||||
} else {
|
||||
this.config.offset = offset;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
/** @internal */
|
||||
getSQL() {
|
||||
return this.dialect.buildSelectQuery(this.config);
|
||||
}
|
||||
toSQL() {
|
||||
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
||||
return rest;
|
||||
}
|
||||
as(alias) {
|
||||
const usedTables = [];
|
||||
usedTables.push(...(0, import_utils2.extractUsedTable)(this.config.table));
|
||||
if (this.config.joins) {
|
||||
for (const it of this.config.joins) usedTables.push(...(0, import_utils2.extractUsedTable)(it.table));
|
||||
}
|
||||
return new Proxy(
|
||||
new import_subquery.Subquery(this.getSQL(), this.config.fields, alias, false, [...new Set(usedTables)]),
|
||||
new import_selection_proxy.SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
||||
);
|
||||
}
|
||||
/** @internal */
|
||||
getSelectedFields() {
|
||||
return new Proxy(
|
||||
this.config.fields,
|
||||
new import_selection_proxy.SelectionProxyHandler({ alias: this.tableName, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
||||
);
|
||||
}
|
||||
$dynamic() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class SQLiteSelectBase extends SQLiteSelectQueryBuilderBase {
|
||||
static [import_entity.entityKind] = "SQLiteSelect";
|
||||
/** @internal */
|
||||
_prepare(isOneTimeQuery = true) {
|
||||
if (!this.session) {
|
||||
throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
|
||||
}
|
||||
const fieldsList = (0, import_utils.orderSelectedFields)(this.config.fields);
|
||||
const query = this.session[isOneTimeQuery ? "prepareOneTimeQuery" : "prepareQuery"](
|
||||
this.dialect.sqlToQuery(this.getSQL()),
|
||||
fieldsList,
|
||||
"all",
|
||||
true,
|
||||
void 0,
|
||||
{
|
||||
type: "select",
|
||||
tables: [...this.usedTables]
|
||||
},
|
||||
this.cacheConfig
|
||||
);
|
||||
query.joinsNotNullableMap = this.joinsNotNullableMap;
|
||||
return query;
|
||||
}
|
||||
$withCache(config) {
|
||||
this.cacheConfig = config === void 0 ? { config: {}, enable: true, autoInvalidate: true } : config === false ? { enable: false } : { enable: true, autoInvalidate: true, ...config };
|
||||
return this;
|
||||
}
|
||||
prepare() {
|
||||
return this._prepare(false);
|
||||
}
|
||||
run = (placeholderValues) => {
|
||||
return this._prepare().run(placeholderValues);
|
||||
};
|
||||
all = (placeholderValues) => {
|
||||
return this._prepare().all(placeholderValues);
|
||||
};
|
||||
get = (placeholderValues) => {
|
||||
return this._prepare().get(placeholderValues);
|
||||
};
|
||||
values = (placeholderValues) => {
|
||||
return this._prepare().values(placeholderValues);
|
||||
};
|
||||
async execute() {
|
||||
return this.all();
|
||||
}
|
||||
}
|
||||
(0, import_utils.applyMixins)(SQLiteSelectBase, [import_query_promise.QueryPromise]);
|
||||
function createSetOperator(type, isAll) {
|
||||
return (leftSelect, rightSelect, ...restSelects) => {
|
||||
const setOperators = [rightSelect, ...restSelects].map((select) => ({
|
||||
type,
|
||||
isAll,
|
||||
rightSelect: select
|
||||
}));
|
||||
for (const setOperator of setOperators) {
|
||||
if (!(0, import_utils.haveSameKeys)(leftSelect.getSelectedFields(), setOperator.rightSelect.getSelectedFields())) {
|
||||
throw new Error(
|
||||
"Set operator error (union / intersect / except): selected fields are not the same or are in a different order"
|
||||
);
|
||||
}
|
||||
}
|
||||
return leftSelect.addSetOperators(setOperators);
|
||||
};
|
||||
}
|
||||
const getSQLiteSetOperators = () => ({
|
||||
union,
|
||||
unionAll,
|
||||
intersect,
|
||||
except
|
||||
});
|
||||
const union = createSetOperator("union", false);
|
||||
const unionAll = createSetOperator("union", true);
|
||||
const intersect = createSetOperator("intersect", false);
|
||||
const except = createSetOperator("except", false);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
SQLiteSelectBase,
|
||||
SQLiteSelectBuilder,
|
||||
SQLiteSelectQueryBuilderBase,
|
||||
except,
|
||||
intersect,
|
||||
union,
|
||||
unionAll
|
||||
});
|
||||
//# sourceMappingURL=select.cjs.map
|
||||
@ -1 +0,0 @@
|
||||
{"version":3,"file":"innerFrom.js","sourceRoot":"","sources":["../../../../src/internal/observable/innerFrom.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAExG,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGvE,MAAM,UAAU,SAAS,CAAI,KAAyB;IACpD,IAAI,KAAK,YAAY,UAAU,EAAE;QAC/B,OAAO,KAAK,CAAC;KACd;IACD,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE;YAC9B,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC;SACrC;QACD,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;YACtB,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;YACpB,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;SAC3B;QACD,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;YAC1B,OAAO,iBAAiB,CAAC,KAAK,CAAC,CAAC;SACjC;QACD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE;YACrB,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;SAC5B;QACD,IAAI,oBAAoB,CAAC,KAAK,CAAC,EAAE;YAC/B,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;SACtC;KACF;IAED,MAAM,gCAAgC,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAMD,MAAM,UAAU,qBAAqB,CAAI,GAAQ;IAC/C,OAAO,IAAI,UAAU,CAAC,UAAC,UAAyB;QAC9C,IAAM,GAAG,GAAG,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACrC,IAAI,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC7B,OAAO,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;SAClC;QAED,MAAM,IAAI,SAAS,CAAC,gEAAgE,CAAC,CAAC;IACxF,CAAC,CAAC,CAAC;AACL,CAAC;AASD,MAAM,UAAU,aAAa,CAAI,KAAmB;IAClD,OAAO,IAAI,UAAU,CAAC,UAAC,UAAyB;QAU9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC3D,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B;QACD,UAAU,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CAAI,OAAuB;IACpD,OAAO,IAAI,UAAU,CAAC,UAAC,UAAyB;QAC9C,OAAO;aACJ,IAAI,CACH,UAAC,KAAK;YACJ,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;gBACtB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,UAAU,CAAC,QAAQ,EAAE,CAAC;aACvB;QACH,CAAC,EACD,UAAC,GAAQ,IAAK,OAAA,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAArB,CAAqB,CACpC;aACA,IAAI,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,YAAY,CAAI,QAAqB;IACnD,OAAO,IAAI,UAAU,CAAC,UAAC,UAAyB;;;YAC9C,KAAoB,IAAA,aAAA,SAAA,QAAQ,CAAA,kCAAA,wDAAE;gBAAzB,IAAM,KAAK,qBAAA;gBACd,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACvB,IAAI,UAAU,CAAC,MAAM,EAAE;oBACrB,OAAO;iBACR;aACF;;;;;;;;;QACD,UAAU,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAI,aAA+B;IAClE,OAAO,IAAI,UAAU,CAAC,UAAC,UAAyB;QAC9C,OAAO,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,UAAC,GAAG,IAAK,OAAA,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAArB,CAAqB,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAI,cAAqC;IAC7E,OAAO,iBAAiB,CAAC,kCAAkC,CAAC,cAAc,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED,SAAe,OAAO,CAAI,aAA+B,EAAE,UAAyB;;;;;;;;;oBACxD,kBAAA,cAAA,aAAa,CAAA;;;;;oBAAtB,KAAK,0BAAA,CAAA;oBACpB,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAGvB,IAAI,UAAU,CAAC,MAAM,EAAE;wBACrB,WAAO;qBACR;;;;;;;;;;;;;;;;;;;;;oBAEH,UAAU,CAAC,QAAQ,EAAE,CAAC;;;;;CACvB"}
|
||||
@ -1,83 +0,0 @@
|
||||
import { entityKind } from "../../entity.cjs";
|
||||
import { QueryPromise } from "../../query-promise.cjs";
|
||||
import type { SingleStoreDialect } from "../dialect.cjs";
|
||||
import type { AnySingleStoreQueryResultHKT, PreparedQueryHKTBase, PreparedQueryKind, SingleStorePreparedQueryConfig, SingleStoreQueryResultHKT, SingleStoreQueryResultKind, SingleStoreSession } from "../session.cjs";
|
||||
import type { SingleStoreTable } from "../table.cjs";
|
||||
import type { Placeholder, Query, SQL, SQLWrapper } from "../../sql/sql.cjs";
|
||||
import type { Subquery } from "../../subquery.cjs";
|
||||
import type { ValueOrArray } from "../../utils.cjs";
|
||||
import type { SingleStoreColumn } from "../columns/common.cjs";
|
||||
import type { SelectedFieldsOrdered } from "./select.types.cjs";
|
||||
export type SingleStoreDeleteWithout<T extends AnySingleStoreDeleteBase, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<SingleStoreDeleteBase<T['_']['table'], T['_']['queryResult'], T['_']['preparedQueryHKT'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
|
||||
export type SingleStoreDelete<TTable extends SingleStoreTable = SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT = AnySingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase> = SingleStoreDeleteBase<TTable, TQueryResult, TPreparedQueryHKT, true, never>;
|
||||
export interface SingleStoreDeleteConfig {
|
||||
where?: SQL | undefined;
|
||||
limit?: number | Placeholder;
|
||||
orderBy?: (SingleStoreColumn | SQL | SQL.Aliased)[];
|
||||
table: SingleStoreTable;
|
||||
returning?: SelectedFieldsOrdered;
|
||||
withList?: Subquery[];
|
||||
}
|
||||
export type SingleStoreDeletePrepare<T extends AnySingleStoreDeleteBase> = PreparedQueryKind<T['_']['preparedQueryHKT'], SingleStorePreparedQueryConfig & {
|
||||
execute: SingleStoreQueryResultKind<T['_']['queryResult'], never>;
|
||||
iterator: never;
|
||||
}, true>;
|
||||
type SingleStoreDeleteDynamic<T extends AnySingleStoreDeleteBase> = SingleStoreDelete<T['_']['table'], T['_']['queryResult'], T['_']['preparedQueryHKT']>;
|
||||
type AnySingleStoreDeleteBase = SingleStoreDeleteBase<any, any, any, any, any>;
|
||||
export interface SingleStoreDeleteBase<TTable extends SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<SingleStoreQueryResultKind<TQueryResult, never>> {
|
||||
readonly _: {
|
||||
readonly table: TTable;
|
||||
readonly queryResult: TQueryResult;
|
||||
readonly preparedQueryHKT: TPreparedQueryHKT;
|
||||
readonly dynamic: TDynamic;
|
||||
readonly excludedMethods: TExcludedMethods;
|
||||
};
|
||||
}
|
||||
export declare class SingleStoreDeleteBase<TTable extends SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<SingleStoreQueryResultKind<TQueryResult, never>> implements SQLWrapper {
|
||||
private table;
|
||||
private session;
|
||||
private dialect;
|
||||
static readonly [entityKind]: string;
|
||||
private config;
|
||||
constructor(table: TTable, session: SingleStoreSession, dialect: SingleStoreDialect, withList?: Subquery[]);
|
||||
/**
|
||||
* Adds a `where` clause to the query.
|
||||
*
|
||||
* Calling this method will delete only those rows that fulfill a specified condition.
|
||||
*
|
||||
* See docs: {@link https://orm.drizzle.team/docs/delete}
|
||||
*
|
||||
* @param where the `where` clause.
|
||||
*
|
||||
* @example
|
||||
* You can use conditional operators and `sql function` to filter the rows to be deleted.
|
||||
*
|
||||
* ```ts
|
||||
* // Delete all cars with green color
|
||||
* db.delete(cars).where(eq(cars.color, 'green'));
|
||||
* // or
|
||||
* db.delete(cars).where(sql`${cars.color} = 'green'`)
|
||||
* ```
|
||||
*
|
||||
* You can logically combine conditional operators with `and()` and `or()` operators:
|
||||
*
|
||||
* ```ts
|
||||
* // Delete all BMW cars with a green color
|
||||
* db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
||||
*
|
||||
* // Delete all cars with the green or blue color
|
||||
* db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
||||
* ```
|
||||
*/
|
||||
where(where: SQL | undefined): SingleStoreDeleteWithout<this, TDynamic, 'where'>;
|
||||
orderBy(builder: (deleteTable: TTable) => ValueOrArray<SingleStoreColumn | SQL | SQL.Aliased>): SingleStoreDeleteWithout<this, TDynamic, 'orderBy'>;
|
||||
orderBy(...columns: (SingleStoreColumn | SQL | SQL.Aliased)[]): SingleStoreDeleteWithout<this, TDynamic, 'orderBy'>;
|
||||
limit(limit: number | Placeholder): SingleStoreDeleteWithout<this, TDynamic, 'limit'>;
|
||||
toSQL(): Query;
|
||||
prepare(): SingleStoreDeletePrepare<this>;
|
||||
execute: ReturnType<this['prepare']>['execute'];
|
||||
private createIterator;
|
||||
iterator: ReturnType<this["prepare"]>["iterator"];
|
||||
$dynamic(): SingleStoreDeleteDynamic<this>;
|
||||
}
|
||||
export {};
|
||||
@ -1,89 +0,0 @@
|
||||
# has-flag [](https://travis-ci.org/sindresorhus/has-flag)
|
||||
|
||||
> Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
|
||||
|
||||
Correctly stops looking after an `--` argument terminator.
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-has-flag?utm_source=npm-has-flag&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install has-flag
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
hasFlag('unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('--unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('f');
|
||||
//=> true
|
||||
|
||||
hasFlag('-f');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo=bar');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo');
|
||||
//=> false
|
||||
|
||||
hasFlag('rainbow');
|
||||
//=> false
|
||||
```
|
||||
|
||||
```
|
||||
$ node foo.js -f --unicorn --foo=bar -- --rainbow
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### hasFlag(flag, [argv])
|
||||
|
||||
Returns a boolean for whether the flag exists.
|
||||
|
||||
#### flag
|
||||
|
||||
Type: `string`
|
||||
|
||||
CLI flag to look for. The `--` prefix is optional.
|
||||
|
||||
#### argv
|
||||
|
||||
Type: `string[]`<br>
|
||||
Default: `process.argv`
|
||||
|
||||
CLI arguments.
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../src/gel-core/query-builders/raw.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport type { PreparedQuery } from '~/session.ts';\nimport type { Query, SQL, SQLWrapper } from '~/sql/sql.ts';\n\nexport interface GelRaw<TResult> extends QueryPromise<TResult>, RunnableQuery<TResult, 'gel'>, SQLWrapper {}\n\nexport class GelRaw<TResult> extends QueryPromise<TResult>\n\timplements RunnableQuery<TResult, 'gel'>, SQLWrapper, PreparedQuery\n{\n\tstatic override readonly [entityKind]: string = 'GelRaw';\n\n\tdeclare readonly _: {\n\t\treadonly dialect: 'gel';\n\t\treadonly result: TResult;\n\t};\n\n\tconstructor(\n\t\tpublic execute: () => Promise<TResult>,\n\t\tprivate sql: SQL,\n\t\tprivate query: Query,\n\t\tprivate mapBatchResult: (result: unknown) => unknown,\n\t) {\n\t\tsuper();\n\t}\n\n\t/** @internal */\n\tgetSQL() {\n\t\treturn this.sql;\n\t}\n\n\tgetQuery() {\n\t\treturn this.query;\n\t}\n\n\tmapResult(result: unknown, isFromBatch?: boolean) {\n\t\treturn isFromBatch ? this.mapBatchResult(result) : result;\n\t}\n\n\t_prepare(): PreparedQuery {\n\t\treturn this;\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode() {\n\t\treturn false;\n\t}\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAOtB,MAAM,eAAwB,aAErC;AAAA,EAQC,YACQ,SACC,KACA,OACA,gBACP;AACD,UAAM;AALC;AACC;AACA;AACA;AAAA,EAGT;AAAA,EAdA,QAA0B,UAAU,IAAY;AAAA;AAAA,EAiBhD,SAAS;AACR,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,WAAW;AACV,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,UAAU,QAAiB,aAAuB;AACjD,WAAO,cAAc,KAAK,eAAe,MAAM,IAAI;AAAA,EACpD;AAAA,EAEA,WAA0B;AACzB,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,wBAAwB;AACvB,WAAO;AAAA,EACR;AACD;","names":[]}
|
||||
@ -1 +0,0 @@
|
||||
{"version":3,"file":"webSocket.js","sourceRoot":"","sources":["../../../../../src/internal/observable/dom/webSocket.ts"],"names":[],"mappings":";;;AAAA,uDAA8E;AA8J9E,SAAgB,SAAS,CAAI,iBAAqD;IAChF,OAAO,IAAI,mCAAgB,CAAI,iBAAiB,CAAC,CAAC;AACpD,CAAC;AAFD,8BAEC"}
|
||||
@ -1,53 +0,0 @@
|
||||
import { AsyncScheduler } from './AsyncScheduler';
|
||||
/**
|
||||
*
|
||||
* Async Scheduler
|
||||
*
|
||||
* <span class="informal">Schedule task as if you used setTimeout(task, duration)</span>
|
||||
*
|
||||
* `async` scheduler schedules tasks asynchronously, by putting them on the JavaScript
|
||||
* event loop queue. It is best used to delay tasks in time or to schedule tasks repeating
|
||||
* in intervals.
|
||||
*
|
||||
* If you just want to "defer" task, that is to perform it right after currently
|
||||
* executing synchronous code ends (commonly achieved by `setTimeout(deferredTask, 0)`),
|
||||
* better choice will be the {@link asapScheduler} scheduler.
|
||||
*
|
||||
* ## Examples
|
||||
* Use async scheduler to delay task
|
||||
* ```ts
|
||||
* import { asyncScheduler } from 'rxjs';
|
||||
*
|
||||
* const task = () => console.log('it works!');
|
||||
*
|
||||
* asyncScheduler.schedule(task, 2000);
|
||||
*
|
||||
* // After 2 seconds logs:
|
||||
* // "it works!"
|
||||
* ```
|
||||
*
|
||||
* Use async scheduler to repeat task in intervals
|
||||
* ```ts
|
||||
* import { asyncScheduler } from 'rxjs';
|
||||
*
|
||||
* function task(state) {
|
||||
* console.log(state);
|
||||
* this.schedule(state + 1, 1000); // `this` references currently executing Action,
|
||||
* // which we reschedule with new state and delay
|
||||
* }
|
||||
*
|
||||
* asyncScheduler.schedule(task, 3000, 0);
|
||||
*
|
||||
* // Logs:
|
||||
* // 0 after 3s
|
||||
* // 1 after 4s
|
||||
* // 2 after 5s
|
||||
* // 3 after 6s
|
||||
* ```
|
||||
*/
|
||||
export declare const asyncScheduler: AsyncScheduler;
|
||||
/**
|
||||
* @deprecated Renamed to {@link asyncScheduler}. Will be removed in v8.
|
||||
*/
|
||||
export declare const async: AsyncScheduler;
|
||||
//# sourceMappingURL=async.d.ts.map
|
||||
@ -1,12 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.subscribeOn = void 0;
|
||||
var lift_1 = require("../util/lift");
|
||||
function subscribeOn(scheduler, delay) {
|
||||
if (delay === void 0) { delay = 0; }
|
||||
return lift_1.operate(function (source, subscriber) {
|
||||
subscriber.add(scheduler.schedule(function () { return source.subscribe(subscriber); }, delay));
|
||||
});
|
||||
}
|
||||
exports.subscribeOn = subscribeOn;
|
||||
//# sourceMappingURL=subscribeOn.js.map
|
||||
@ -1,8 +0,0 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { innerFrom } from './innerFrom';
|
||||
export function defer(observableFactory) {
|
||||
return new Observable((subscriber) => {
|
||||
innerFrom(observableFactory()).subscribe(subscriber);
|
||||
});
|
||||
}
|
||||
//# sourceMappingURL=defer.js.map
|
||||
@ -1,261 +0,0 @@
|
||||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var firefoxPrefs_exports = {};
|
||||
__export(firefoxPrefs_exports, {
|
||||
createProfile: () => createProfile
|
||||
});
|
||||
module.exports = __toCommonJS(firefoxPrefs_exports);
|
||||
var import_fs = __toESM(require("fs"));
|
||||
var import_path = __toESM(require("path"));
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2023 Google Inc.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
async function createProfile(options) {
|
||||
if (!import_fs.default.existsSync(options.path)) {
|
||||
await import_fs.default.promises.mkdir(options.path, {
|
||||
recursive: true
|
||||
});
|
||||
}
|
||||
await writePreferences({
|
||||
preferences: {
|
||||
...defaultProfilePreferences(options.preferences),
|
||||
...options.preferences
|
||||
},
|
||||
path: options.path
|
||||
});
|
||||
}
|
||||
function defaultProfilePreferences(extraPrefs) {
|
||||
const server = "dummy.test";
|
||||
const defaultPrefs = {
|
||||
// Make sure Shield doesn't hit the network.
|
||||
"app.normandy.api_url": "",
|
||||
// Disable Firefox old build background check
|
||||
"app.update.checkInstallTime": false,
|
||||
// Disable automatically upgrading Firefox
|
||||
"app.update.disabledForTesting": true,
|
||||
// Increase the APZ content response timeout to 1 minute
|
||||
"apz.content_response_timeout": 6e4,
|
||||
// Prevent various error message on the console
|
||||
// jest-puppeteer asserts that no error message is emitted by the console
|
||||
"browser.contentblocking.features.standard": "-tp,tpPrivate,cookieBehavior0,-cm,-fp",
|
||||
// Enable the dump function: which sends messages to the system
|
||||
// console
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1543115
|
||||
"browser.dom.window.dump.enabled": true,
|
||||
// Make sure newtab weather doesn't hit the network to retrieve weather data.
|
||||
"browser.newtabpage.activity-stream.discoverystream.region-weather-config": "",
|
||||
// Make sure newtab wallpapers don't hit the network to retrieve wallpaper data.
|
||||
"browser.newtabpage.activity-stream.newtabWallpapers.enabled": false,
|
||||
"browser.newtabpage.activity-stream.newtabWallpapers.v2.enabled": false,
|
||||
// Make sure Topsites doesn't hit the network to retrieve sponsored tiles.
|
||||
"browser.newtabpage.activity-stream.showSponsoredTopSites": false,
|
||||
// Disable topstories
|
||||
"browser.newtabpage.activity-stream.feeds.system.topstories": false,
|
||||
// Always display a blank page
|
||||
"browser.newtabpage.enabled": false,
|
||||
// Background thumbnails in particular cause grief: and disabling
|
||||
// thumbnails in general cannot hurt
|
||||
"browser.pagethumbnails.capturing_disabled": true,
|
||||
// Disable safebrowsing components.
|
||||
"browser.safebrowsing.blockedURIs.enabled": false,
|
||||
"browser.safebrowsing.downloads.enabled": false,
|
||||
"browser.safebrowsing.malware.enabled": false,
|
||||
"browser.safebrowsing.phishing.enabled": false,
|
||||
// Disable updates to search engines.
|
||||
"browser.search.update": false,
|
||||
// Do not restore the last open set of tabs if the browser has crashed
|
||||
"browser.sessionstore.resume_from_crash": false,
|
||||
// Skip check for default browser on startup
|
||||
"browser.shell.checkDefaultBrowser": false,
|
||||
// Disable newtabpage
|
||||
"browser.startup.homepage": "about:blank",
|
||||
// Do not redirect user when a milstone upgrade of Firefox is detected
|
||||
"browser.startup.homepage_override.mstone": "ignore",
|
||||
// Start with a blank page about:blank
|
||||
"browser.startup.page": 0,
|
||||
// Do not allow background tabs to be zombified on Android: otherwise for
|
||||
// tests that open additional tabs: the test harness tab itself might get
|
||||
// unloaded
|
||||
"browser.tabs.disableBackgroundZombification": false,
|
||||
// Do not warn when closing all other open tabs
|
||||
"browser.tabs.warnOnCloseOtherTabs": false,
|
||||
// Do not warn when multiple tabs will be opened
|
||||
"browser.tabs.warnOnOpen": false,
|
||||
// Do not automatically offer translations, as tests do not expect this.
|
||||
"browser.translations.automaticallyPopup": false,
|
||||
// Disable the UI tour.
|
||||
"browser.uitour.enabled": false,
|
||||
// Turn off search suggestions in the location bar so as not to trigger
|
||||
// network connections.
|
||||
"browser.urlbar.suggest.searches": false,
|
||||
// Disable first run splash page on Windows 10
|
||||
"browser.usedOnWindows10.introURL": "",
|
||||
// Do not warn on quitting Firefox
|
||||
"browser.warnOnQuit": false,
|
||||
// Defensively disable data reporting systems
|
||||
"datareporting.healthreport.documentServerURI": `http://${server}/dummy/healthreport/`,
|
||||
"datareporting.healthreport.logging.consoleEnabled": false,
|
||||
"datareporting.healthreport.service.enabled": false,
|
||||
"datareporting.healthreport.service.firstRun": false,
|
||||
"datareporting.healthreport.uploadEnabled": false,
|
||||
// Do not show datareporting policy notifications which can interfere with tests
|
||||
"datareporting.policy.dataSubmissionEnabled": false,
|
||||
"datareporting.policy.dataSubmissionPolicyBypassNotification": true,
|
||||
// DevTools JSONViewer sometimes fails to load dependencies with its require.js.
|
||||
// This doesn't affect Puppeteer but spams console (Bug 1424372)
|
||||
"devtools.jsonview.enabled": false,
|
||||
// Disable popup-blocker
|
||||
"dom.disable_open_during_load": false,
|
||||
// Enable the support for File object creation in the content process
|
||||
// Required for |Page.setFileInputFiles| protocol method.
|
||||
"dom.file.createInChild": true,
|
||||
// Disable the ProcessHangMonitor
|
||||
"dom.ipc.reportProcessHangs": false,
|
||||
// Disable slow script dialogues
|
||||
"dom.max_chrome_script_run_time": 0,
|
||||
"dom.max_script_run_time": 0,
|
||||
// Disable background timer throttling to allow tests to run in parallel
|
||||
// without a decrease in performance.
|
||||
"dom.min_background_timeout_value": 0,
|
||||
"dom.min_background_timeout_value_without_budget_throttling": 0,
|
||||
"dom.timeout.enable_budget_timer_throttling": false,
|
||||
// Disable HTTPS-First upgrades
|
||||
"dom.security.https_first": false,
|
||||
// Only load extensions from the application and user profile
|
||||
// AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
|
||||
"extensions.autoDisableScopes": 0,
|
||||
"extensions.enabledScopes": 5,
|
||||
// Disable metadata caching for installed add-ons by default
|
||||
"extensions.getAddons.cache.enabled": false,
|
||||
// Disable installing any distribution extensions or add-ons.
|
||||
"extensions.installDistroAddons": false,
|
||||
// Disabled screenshots extension
|
||||
"extensions.screenshots.disabled": true,
|
||||
// Turn off extension updates so they do not bother tests
|
||||
"extensions.update.enabled": false,
|
||||
// Turn off extension updates so they do not bother tests
|
||||
"extensions.update.notifyUser": false,
|
||||
// Make sure opening about:addons will not hit the network
|
||||
"extensions.webservice.discoverURL": `http://${server}/dummy/discoveryURL`,
|
||||
// Allow the application to have focus even it runs in the background
|
||||
"focusmanager.testmode": true,
|
||||
// Disable useragent updates
|
||||
"general.useragent.updates.enabled": false,
|
||||
// Always use network provider for geolocation tests so we bypass the
|
||||
// macOS dialog raised by the corelocation provider
|
||||
"geo.provider.testing": true,
|
||||
// Do not scan Wifi
|
||||
"geo.wifi.scan": false,
|
||||
// No hang monitor
|
||||
"hangmonitor.timeout": 0,
|
||||
// Show chrome errors and warnings in the error console
|
||||
"javascript.options.showInConsole": true,
|
||||
// Do not throttle rendering (requestAnimationFrame) in background tabs
|
||||
"layout.testing.top-level-always-active": true,
|
||||
// Disable download and usage of OpenH264: and Widevine plugins
|
||||
"media.gmp-manager.updateEnabled": false,
|
||||
// Disable the GFX sanity window
|
||||
"media.sanity-test.disabled": true,
|
||||
// Disable connectivity service pings
|
||||
"network.connectivity-service.enabled": false,
|
||||
// Disable experimental feature that is only available in Nightly
|
||||
"network.cookie.sameSite.laxByDefault": false,
|
||||
// Do not prompt for temporary redirects
|
||||
"network.http.prompt-temp-redirect": false,
|
||||
// Disable speculative connections so they are not reported as leaking
|
||||
// when they are hanging around
|
||||
"network.http.speculative-parallel-limit": 0,
|
||||
// Do not automatically switch between offline and online
|
||||
"network.manage-offline-status": false,
|
||||
// Make sure SNTP requests do not hit the network
|
||||
"network.sntp.pools": server,
|
||||
// Disable Flash.
|
||||
"plugin.state.flash": 0,
|
||||
"privacy.trackingprotection.enabled": false,
|
||||
// Can be removed once Firefox 89 is no longer supported
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1710839
|
||||
"remote.enabled": true,
|
||||
// Don't do network connections for mitm priming
|
||||
"security.certerrors.mitm.priming.enabled": false,
|
||||
// Local documents have access to all other local documents,
|
||||
// including directory listings
|
||||
"security.fileuri.strict_origin_policy": false,
|
||||
// Do not wait for the notification button security delay
|
||||
"security.notification_enable_delay": 0,
|
||||
// Do not automatically fill sign-in forms with known usernames and
|
||||
// passwords
|
||||
"signon.autofillForms": false,
|
||||
// Disable password capture, so that tests that include forms are not
|
||||
// influenced by the presence of the persistent doorhanger notification
|
||||
"signon.rememberSignons": false,
|
||||
// Disable first-run welcome page
|
||||
"startup.homepage_welcome_url": "about:blank",
|
||||
// Disable first-run welcome page
|
||||
"startup.homepage_welcome_url.additional": "",
|
||||
// Disable browser animations (tabs, fullscreen, sliding alerts)
|
||||
"toolkit.cosmeticAnimations.enabled": false,
|
||||
// Prevent starting into safe mode after application crashes
|
||||
"toolkit.startup.max_resumed_crashes": -1,
|
||||
// Enable TestUtils
|
||||
"dom.testing.testutils.enabled": true
|
||||
};
|
||||
return Object.assign(defaultPrefs, extraPrefs);
|
||||
}
|
||||
async function writePreferences(options) {
|
||||
const prefsPath = import_path.default.join(options.path, "prefs.js");
|
||||
const lines = Object.entries(options.preferences).map(([key, value]) => {
|
||||
return `user_pref(${JSON.stringify(key)}, ${JSON.stringify(value)});`;
|
||||
});
|
||||
const result = await Promise.allSettled([
|
||||
import_fs.default.promises.writeFile(import_path.default.join(options.path, "user.js"), lines.join("\n")),
|
||||
// Create a backup of the preferences file if it already exitsts.
|
||||
import_fs.default.promises.access(prefsPath, import_fs.default.constants.F_OK).then(
|
||||
async () => {
|
||||
await import_fs.default.promises.copyFile(
|
||||
prefsPath,
|
||||
import_path.default.join(options.path, "prefs.js.playwright")
|
||||
);
|
||||
},
|
||||
// Swallow only if file does not exist
|
||||
() => {
|
||||
}
|
||||
)
|
||||
]);
|
||||
for (const command of result) {
|
||||
if (command.status === "rejected") {
|
||||
throw command.reason;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
createProfile
|
||||
});
|
||||
@ -1,5 +0,0 @@
|
||||
const MySqlViewConfig = Symbol.for("drizzle:MySqlViewConfig");
|
||||
export {
|
||||
MySqlViewConfig
|
||||
};
|
||||
//# sourceMappingURL=view-common.js.map
|
||||
@ -1,23 +0,0 @@
|
||||
import type { ColumnBuilderBaseConfig } from "../../column-builder.js";
|
||||
import type { ColumnBaseConfig } from "../../column.js";
|
||||
import { entityKind } from "../../entity.js";
|
||||
import { GelColumn } from "./common.js";
|
||||
import { GelIntColumnBaseBuilder } from "./int.common.js";
|
||||
export type GelIntegerBuilderInitial<TName extends string> = GelIntegerBuilder<{
|
||||
name: TName;
|
||||
dataType: 'number';
|
||||
columnType: 'GelInteger';
|
||||
data: number;
|
||||
driverParam: number;
|
||||
enumValues: undefined;
|
||||
}>;
|
||||
export declare class GelIntegerBuilder<T extends ColumnBuilderBaseConfig<'number', 'GelInteger'>> extends GelIntColumnBaseBuilder<T> {
|
||||
static readonly [entityKind]: string;
|
||||
constructor(name: T['name']);
|
||||
}
|
||||
export declare class GelInteger<T extends ColumnBaseConfig<'number', 'GelInteger'>> extends GelColumn<T> {
|
||||
static readonly [entityKind]: string;
|
||||
getSQLType(): string;
|
||||
}
|
||||
export declare function integer(): GelIntegerBuilderInitial<''>;
|
||||
export declare function integer<TName extends string>(name: TName): GelIntegerBuilderInitial<TName>;
|
||||
@ -1,4 +0,0 @@
|
||||
import type { ReverseSegment, SourceMapSegment } from './sourcemap-segment.mts';
|
||||
export type Source = ReverseSegment[][];
|
||||
export default function buildBySources(decoded: readonly SourceMapSegment[][], memos: unknown[]): Source[];
|
||||
//# sourceMappingURL=by-source.d.ts.map
|
||||
@ -1,749 +0,0 @@
|
||||
<h1 align="center">Picomatch</h1>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://npmjs.org/package/picomatch">
|
||||
<img src="https://img.shields.io/npm/v/picomatch.svg" alt="version">
|
||||
</a>
|
||||
<a href="https://github.com/micromatch/picomatch/actions?workflow=Tests">
|
||||
<img src="https://github.com/micromatch/picomatch/workflows/Tests/badge.svg" alt="test status">
|
||||
</a>
|
||||
<a href="https://coveralls.io/github/micromatch/picomatch">
|
||||
<img src="https://img.shields.io/coveralls/github/micromatch/picomatch/master.svg" alt="coverage status">
|
||||
</a>
|
||||
<a href="https://npmjs.org/package/picomatch">
|
||||
<img src="https://img.shields.io/npm/dm/picomatch.svg" alt="downloads">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<p align="center">
|
||||
<strong>Blazing fast and accurate glob matcher written in JavaScript.</strong></br>
|
||||
<em>No dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.</em>
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
## Why picomatch?
|
||||
|
||||
* **Lightweight** - No dependencies
|
||||
* **Minimal** - Tiny API surface. Main export is a function that takes a glob pattern and returns a matcher function.
|
||||
* **Fast** - Loads in about 2ms (that's several times faster than a [single frame of a HD movie](http://www.endmemo.com/sconvert/framespersecondframespermillisecond.php) at 60fps)
|
||||
* **Performant** - Use the returned matcher function to speed up repeat matching (like when watching files)
|
||||
* **Accurate matching** - Using wildcards (`*` and `?`), globstars (`**`) for nested directories, [advanced globbing](#advanced-globbing) with extglobs, braces, and POSIX brackets, and support for escaping special characters with `\` or quotes.
|
||||
* **Well tested** - Thousands of unit tests
|
||||
|
||||
See the [library comparison](#library-comparisons) to other libraries.
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
## Table of Contents
|
||||
|
||||
<details><summary> Click to expand </summary>
|
||||
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [API](#api)
|
||||
* [picomatch](#picomatch)
|
||||
* [.test](#test)
|
||||
* [.matchBase](#matchbase)
|
||||
* [.isMatch](#ismatch)
|
||||
* [.parse](#parse)
|
||||
* [.scan](#scan)
|
||||
* [.compileRe](#compilere)
|
||||
* [.makeRe](#makere)
|
||||
* [.toRegex](#toregex)
|
||||
- [Options](#options)
|
||||
* [Picomatch options](#picomatch-options)
|
||||
* [Scan Options](#scan-options)
|
||||
* [Options Examples](#options-examples)
|
||||
- [Globbing features](#globbing-features)
|
||||
* [Basic globbing](#basic-globbing)
|
||||
* [Advanced globbing](#advanced-globbing)
|
||||
* [Braces](#braces)
|
||||
* [Matching special characters as literals](#matching-special-characters-as-literals)
|
||||
- [Library Comparisons](#library-comparisons)
|
||||
- [Benchmarks](#benchmarks)
|
||||
- [Philosophies](#philosophies)
|
||||
- [About](#about)
|
||||
* [Author](#author)
|
||||
* [License](#license)
|
||||
|
||||
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
|
||||
|
||||
</details>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
npm install --save picomatch
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Usage
|
||||
|
||||
The main export is a function that takes a glob pattern and an options object and returns a function for matching strings.
|
||||
|
||||
```js
|
||||
const pm = require('picomatch');
|
||||
const isMatch = pm('*.js');
|
||||
|
||||
console.log(isMatch('abcd')); //=> false
|
||||
console.log(isMatch('a.js')); //=> true
|
||||
console.log(isMatch('a.md')); //=> false
|
||||
console.log(isMatch('a/b.js')); //=> false
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## API
|
||||
|
||||
### [picomatch](lib/picomatch.js#L31)
|
||||
|
||||
Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information.
|
||||
|
||||
**Params**
|
||||
|
||||
* `globs` **{String|Array}**: One or more glob patterns.
|
||||
* `options` **{Object=}**
|
||||
* `returns` **{Function=}**: Returns a matcher function.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
// picomatch(glob[, options]);
|
||||
|
||||
const isMatch = picomatch('*.!(*a)');
|
||||
console.log(isMatch('a.a')); //=> false
|
||||
console.log(isMatch('a.b')); //=> true
|
||||
```
|
||||
|
||||
**Example without node.js**
|
||||
|
||||
For environments without `node.js`, `picomatch/posix` provides you a dependency-free matcher, without automatic OS detection.
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch/posix');
|
||||
// the same API, defaulting to posix paths
|
||||
const isMatch = picomatch('a/*');
|
||||
console.log(isMatch('a\\b')); //=> false
|
||||
console.log(isMatch('a/b')); //=> true
|
||||
|
||||
// you can still configure the matcher function to accept windows paths
|
||||
const isMatch = picomatch('a/*', { options: windows });
|
||||
console.log(isMatch('a\\b')); //=> true
|
||||
console.log(isMatch('a/b')); //=> true
|
||||
```
|
||||
|
||||
### [.test](lib/picomatch.js#L116)
|
||||
|
||||
Test `input` with the given `regex`. This is used by the main `picomatch()` function to test the input string.
|
||||
|
||||
**Params**
|
||||
|
||||
* `input` **{String}**: String to test.
|
||||
* `regex` **{RegExp}**
|
||||
* `returns` **{Object}**: Returns an object with matching info.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
// picomatch.test(input, regex[, options]);
|
||||
|
||||
console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
||||
// { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
||||
```
|
||||
|
||||
### [.matchBase](lib/picomatch.js#L160)
|
||||
|
||||
Match the basename of a filepath.
|
||||
|
||||
**Params**
|
||||
|
||||
* `input` **{String}**: String to test.
|
||||
* `glob` **{RegExp|String}**: Glob pattern or regex created by [.makeRe](#makeRe).
|
||||
* `returns` **{Boolean}**
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
// picomatch.matchBase(input, glob[, options]);
|
||||
console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
||||
```
|
||||
|
||||
### [.isMatch](lib/picomatch.js#L182)
|
||||
|
||||
Returns true if **any** of the given glob `patterns` match the specified `string`.
|
||||
|
||||
**Params**
|
||||
|
||||
* **{String|Array}**: str The string to test.
|
||||
* **{String|Array}**: patterns One or more glob patterns to use for matching.
|
||||
* **{Object}**: See available [options](#options).
|
||||
* `returns` **{Boolean}**: Returns true if any patterns match `str`
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
// picomatch.isMatch(string, patterns[, options]);
|
||||
|
||||
console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
||||
console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
||||
```
|
||||
|
||||
### [.parse](lib/picomatch.js#L198)
|
||||
|
||||
Parse a glob pattern to create the source string for a regular expression.
|
||||
|
||||
**Params**
|
||||
|
||||
* `pattern` **{String}**
|
||||
* `options` **{Object}**
|
||||
* `returns` **{Object}**: Returns an object with useful properties and output to be used as a regex source string.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
const result = picomatch.parse(pattern[, options]);
|
||||
```
|
||||
|
||||
### [.scan](lib/picomatch.js#L230)
|
||||
|
||||
Scan a glob pattern to separate the pattern into segments.
|
||||
|
||||
**Params**
|
||||
|
||||
* `input` **{String}**: Glob pattern to scan.
|
||||
* `options` **{Object}**
|
||||
* `returns` **{Object}**: Returns an object with
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
// picomatch.scan(input[, options]);
|
||||
|
||||
const result = picomatch.scan('!./foo/*.js');
|
||||
console.log(result);
|
||||
{ prefix: '!./',
|
||||
input: '!./foo/*.js',
|
||||
start: 3,
|
||||
base: 'foo',
|
||||
glob: '*.js',
|
||||
isBrace: false,
|
||||
isBracket: false,
|
||||
isGlob: true,
|
||||
isExtglob: false,
|
||||
isGlobstar: false,
|
||||
negated: true }
|
||||
```
|
||||
|
||||
### [.compileRe](lib/picomatch.js#L244)
|
||||
|
||||
Compile a regular expression from the `state` object returned by the
|
||||
[parse()](#parse) method.
|
||||
|
||||
**Params**
|
||||
|
||||
* `state` **{Object}**
|
||||
* `options` **{Object}**
|
||||
* `returnOutput` **{Boolean}**: Intended for implementors, this argument allows you to return the raw output from the parser.
|
||||
* `returnState` **{Boolean}**: Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
||||
* `returns` **{RegExp}**
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
const state = picomatch.parse('*.js');
|
||||
// picomatch.compileRe(state[, options]);
|
||||
|
||||
console.log(picomatch.compileRe(state));
|
||||
//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
||||
```
|
||||
|
||||
### [.makeRe](lib/picomatch.js#L285)
|
||||
|
||||
Create a regular expression from a parsed glob pattern.
|
||||
|
||||
**Params**
|
||||
|
||||
* `state` **{String}**: The object returned from the `.parse` method.
|
||||
* `options` **{Object}**
|
||||
* `returnOutput` **{Boolean}**: Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
||||
* `returnState` **{Boolean}**: Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
||||
* `returns` **{RegExp}**: Returns a regex created from the given pattern.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
// picomatch.makeRe(state[, options]);
|
||||
|
||||
const result = picomatch.makeRe('*.js');
|
||||
console.log(result);
|
||||
//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
||||
```
|
||||
|
||||
### [.toRegex](lib/picomatch.js#L320)
|
||||
|
||||
Create a regular expression from the given regex source string.
|
||||
|
||||
**Params**
|
||||
|
||||
* `source` **{String}**: Regular expression source string.
|
||||
* `options` **{Object}**
|
||||
* `returns` **{RegExp}**
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
// picomatch.toRegex(source[, options]);
|
||||
|
||||
const { output } = picomatch.parse('*.js');
|
||||
console.log(picomatch.toRegex(output));
|
||||
//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Options
|
||||
|
||||
### Picomatch options
|
||||
|
||||
The following options may be used with the main `picomatch()` function or any of the methods on the picomatch API.
|
||||
|
||||
| **Option** | **Type** | **Default value** | **Description** |
|
||||
| --- | --- | --- | --- |
|
||||
| `basename` | `boolean` | `false` | If set, then patterns without slashes will be matched against the basename of the path if it contains slashes. For example, `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. |
|
||||
| `bash` | `boolean` | `false` | Follow bash matching rules more strictly - disallows backslashes as escape characters, and treats single stars as globstars (`**`). |
|
||||
| `capture` | `boolean` | `undefined` | Return regex matches in supporting methods. |
|
||||
| `contains` | `boolean` | `undefined` | Allows glob to match any part of the given string(s). |
|
||||
| `debug` | `boolean` | `undefined` | Debug regular expressions when an error is thrown. |
|
||||
| `dot` | `boolean` | `false` | Enable dotfile matching. By default, dotfiles are ignored unless a `.` is explicitly defined in the pattern, or `options.dot` is true |
|
||||
| `expandRange` | `function` | `undefined` | Custom function for expanding ranges in brace patterns, such as `{a..z}`. The function receives the range values as two arguments, and it must return a string to be used in the generated regex. It's recommended that returned strings be wrapped in parentheses. |
|
||||
| `fastpaths` | `boolean` | `true` | To speed up processing, full parsing is skipped for a handful common glob patterns. Disable this behavior by setting this option to `false`. |
|
||||
| `flags` | `string` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. |
|
||||
| [format](#optionsformat) | `function` | `undefined` | Custom function for formatting the returned string. This is useful for removing leading slashes, converting Windows paths to Posix paths, etc. |
|
||||
| `ignore` | `array\|string` | `undefined` | One or more glob patterns for excluding strings that should not be matched from the result. |
|
||||
| `keepQuotes` | `boolean` | `false` | Retain quotes in the generated regex, since quotes may also be used as an alternative to backslashes. |
|
||||
| `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. |
|
||||
| `matchBase` | `boolean` | `false` | Alias for `basename` |
|
||||
| `maxLength` | `number` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. |
|
||||
| `maxExtglobRecursion` | `number\|boolean` | `0` | Limit nested quantified extglobs and other risky repeated extglob forms. When the limit is exceeded, the extglob is treated as a literal string instead of being compiled to regex. Set to `false` to disable this safeguard. |
|
||||
| `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. |
|
||||
| `nobracket` | `boolean` | `undefined` | Disable matching with regex brackets. |
|
||||
| `nocase` | `boolean` | `false` | Make matching case-insensitive. Equivalent to the regex `i` flag. Note that this option is overridden by the `flags` option. |
|
||||
| `noext` | `boolean` | `false` | Alias for `noextglob` |
|
||||
| `noextglob` | `boolean` | `false` | Disable support for matching with extglobs (like `+(a\|b)`) |
|
||||
| `noglobstar` | `boolean` | `false` | Disable support for matching nested directories with globstars (`**`) |
|
||||
| `nonegate` | `boolean` | `false` | Disable support for negating with leading `!` |
|
||||
| [onIgnore](#optionsonIgnore) | `function` | `undefined` | Function to be called on ignored items. |
|
||||
| [onMatch](#optionsonMatch) | `function` | `undefined` | Function to be called on matched items. |
|
||||
| [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. |
|
||||
| `posix` | `boolean` | `false` | Support POSIX character classes ("posix brackets"). |
|
||||
| `prepend` | `boolean` | `undefined` | String to prepend to the generated regex used for matching. |
|
||||
| `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). |
|
||||
| `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. |
|
||||
| `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. |
|
||||
| `unescape` | `boolean` | `undefined` | Remove backslashes preceding escaped characters in the glob pattern. By default, backslashes are retained. |
|
||||
| `windows` | `boolean` | `false` | Also accept backslashes as the path separator. |
|
||||
|
||||
### Scan Options
|
||||
|
||||
In addition to the main [picomatch options](#picomatch-options), the following options may also be used with the [.scan](#scan) method.
|
||||
|
||||
| **Option** | **Type** | **Default value** | **Description** |
|
||||
| --- | --- | --- | --- |
|
||||
| `tokens` | `boolean` | `false` | When `true`, the returned object will include an array of tokens (objects), representing each path "segment" in the scanned glob pattern |
|
||||
| `parts` | `boolean` | `false` | When `true`, the returned object will include an array of strings representing each path "segment" in the scanned glob pattern. This is automatically enabled when `options.tokens` is true |
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const picomatch = require('picomatch');
|
||||
const result = picomatch.scan('!./foo/*.js', { tokens: true });
|
||||
console.log(result);
|
||||
// {
|
||||
// prefix: '!./',
|
||||
// input: '!./foo/*.js',
|
||||
// start: 3,
|
||||
// base: 'foo',
|
||||
// glob: '*.js',
|
||||
// isBrace: false,
|
||||
// isBracket: false,
|
||||
// isGlob: true,
|
||||
// isExtglob: false,
|
||||
// isGlobstar: false,
|
||||
// negated: true,
|
||||
// maxDepth: 2,
|
||||
// tokens: [
|
||||
// { value: '!./', depth: 0, isGlob: false, negated: true, isPrefix: true },
|
||||
// { value: 'foo', depth: 1, isGlob: false },
|
||||
// { value: '*.js', depth: 1, isGlob: true }
|
||||
// ],
|
||||
// slashes: [ 2, 6 ],
|
||||
// parts: [ 'foo', '*.js' ]
|
||||
// }
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### Options Examples
|
||||
|
||||
#### options.expandRange
|
||||
|
||||
**Type**: `function`
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
Custom function for expanding ranges in brace patterns. The [fill-range](https://github.com/jonschlinkert/fill-range) library is ideal for this purpose, or you can use custom code to do whatever you need.
|
||||
|
||||
**Example**
|
||||
|
||||
The following example shows how to create a glob that matches a folder
|
||||
|
||||
```js
|
||||
const fill = require('fill-range');
|
||||
const regex = pm.makeRe('foo/{01..25}/bar', {
|
||||
expandRange(a, b) {
|
||||
return `(${fill(a, b, { toRegex: true })})`;
|
||||
}
|
||||
});
|
||||
|
||||
console.log(regex);
|
||||
//=> /^(?:foo\/((?:0[1-9]|1[0-9]|2[0-5]))\/bar)$/
|
||||
|
||||
console.log(regex.test('foo/00/bar')) // false
|
||||
console.log(regex.test('foo/01/bar')) // true
|
||||
console.log(regex.test('foo/10/bar')) // true
|
||||
console.log(regex.test('foo/22/bar')) // true
|
||||
console.log(regex.test('foo/25/bar')) // true
|
||||
console.log(regex.test('foo/26/bar')) // false
|
||||
```
|
||||
|
||||
#### options.format
|
||||
|
||||
**Type**: `function`
|
||||
|
||||
**Default**: `undefined`
|
||||
|
||||
Custom function for formatting strings before they're matched.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
// strip leading './' from strings
|
||||
const format = str => str.replace(/^\.\//, '');
|
||||
const isMatch = picomatch('foo/*.js', { format });
|
||||
console.log(isMatch('./foo/bar.js')); //=> true
|
||||
```
|
||||
|
||||
#### options.onMatch
|
||||
|
||||
```js
|
||||
const onMatch = ({ glob, regex, input, output }) => {
|
||||
console.log({ glob, regex, input, output });
|
||||
};
|
||||
|
||||
const isMatch = picomatch('*', { onMatch });
|
||||
isMatch('foo');
|
||||
isMatch('bar');
|
||||
isMatch('baz');
|
||||
```
|
||||
|
||||
#### options.onIgnore
|
||||
|
||||
```js
|
||||
const onIgnore = ({ glob, regex, input, output }) => {
|
||||
console.log({ glob, regex, input, output });
|
||||
};
|
||||
|
||||
const isMatch = picomatch('*', { onIgnore, ignore: 'f*' });
|
||||
isMatch('foo');
|
||||
isMatch('bar');
|
||||
isMatch('baz');
|
||||
```
|
||||
|
||||
#### options.onResult
|
||||
|
||||
```js
|
||||
const onResult = ({ glob, regex, input, output }) => {
|
||||
console.log({ glob, regex, input, output });
|
||||
};
|
||||
|
||||
const isMatch = picomatch('*', { onResult, ignore: 'f*' });
|
||||
isMatch('foo');
|
||||
isMatch('bar');
|
||||
isMatch('baz');
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
## Globbing features
|
||||
|
||||
* [Basic globbing](#basic-globbing) (Wildcard matching)
|
||||
* [Advanced globbing](#advanced-globbing) (extglobs, posix brackets, brace matching)
|
||||
|
||||
### Basic globbing
|
||||
|
||||
| **Character** | **Description** |
|
||||
| --- | --- |
|
||||
| `*` | Matches any character zero or more times, excluding path separators. Does _not match_ path separators or hidden files or directories ("dotfiles"), unless explicitly enabled by setting the `dot` option to `true`. |
|
||||
| `**` | Matches any character zero or more times, including path separators. Note that `**` will only match path separators (`/`, and `\\` with the `windows` option) when they are the only characters in a path segment. Thus, `foo**/bar` is equivalent to `foo*/bar`, and `foo/a**b/bar` is equivalent to `foo/a*b/bar`, and _more than two_ consecutive stars in a glob path segment are regarded as _a single star_. Thus, `foo/***/bar` is equivalent to `foo/*/bar`. |
|
||||
| `?` | Matches any character excluding path separators one time. Does _not match_ path separators or leading dots. |
|
||||
| `[abc]` | Matches any characters inside the brackets. For example, `[abc]` would match the characters `a`, `b` or `c`, and nothing else. |
|
||||
|
||||
#### Matching behavior vs. Bash
|
||||
|
||||
Picomatch's matching features and expected results in unit tests are based on Bash's unit tests and the Bash 4.3 specification, with the following exceptions:
|
||||
|
||||
* Bash will match `foo/bar/baz` with `*`. Picomatch only matches nested directories with `**`.
|
||||
* Bash greedily matches with negated extglobs. For example, Bash 4.3 says that `!(foo)*` should match `foo` and `foobar`, since the trailing `*` bracktracks to match the preceding pattern. This is very memory-inefficient, and IMHO, also incorrect. Picomatch would return `false` for both `foo` and `foobar`.
|
||||
|
||||
<br>
|
||||
|
||||
### Advanced globbing
|
||||
|
||||
* [extglobs](#extglobs)
|
||||
* [POSIX brackets](#posix-brackets)
|
||||
* [Braces](#brace-expansion)
|
||||
|
||||
#### Extglobs
|
||||
|
||||
| **Pattern** | **Description** |
|
||||
| --- | --- |
|
||||
| `@(pattern)` | Match _only one_ consecutive occurrence of `pattern` |
|
||||
| `*(pattern)` | Match _zero or more_ consecutive occurrences of `pattern` |
|
||||
| `+(pattern)` | Match _one or more_ consecutive occurrences of `pattern` |
|
||||
| `?(pattern)` | Match _zero or **one**_ consecutive occurrences of `pattern` |
|
||||
| `!(pattern)` | Match _anything but_ `pattern` |
|
||||
|
||||
**Examples**
|
||||
|
||||
```js
|
||||
const pm = require('picomatch');
|
||||
|
||||
// *(pattern) matches ZERO or more of "pattern"
|
||||
console.log(pm.isMatch('a', 'a*(z)')); // true
|
||||
console.log(pm.isMatch('az', 'a*(z)')); // true
|
||||
console.log(pm.isMatch('azzz', 'a*(z)')); // true
|
||||
|
||||
// +(pattern) matches ONE or more of "pattern"
|
||||
console.log(pm.isMatch('a', 'a+(z)')); // false
|
||||
console.log(pm.isMatch('az', 'a+(z)')); // true
|
||||
console.log(pm.isMatch('azzz', 'a+(z)')); // true
|
||||
|
||||
// supports multiple extglobs
|
||||
console.log(pm.isMatch('foo.bar', '!(foo).!(bar)')); // false
|
||||
|
||||
// supports nested extglobs
|
||||
console.log(pm.isMatch('foo.bar', '!(!(foo)).!(!(bar))')); // true
|
||||
|
||||
// risky quantified extglobs are treated literally by default
|
||||
console.log(pm.makeRe('+(a|aa)'));
|
||||
//=> /^(?:\+\(a\|aa\))$/
|
||||
|
||||
// increase the limit to allow a small amount of nested quantified extglobs
|
||||
console.log(pm.isMatch('aaa', '+(+(a))', { maxExtglobRecursion: 1 })); // true
|
||||
```
|
||||
|
||||
#### POSIX brackets
|
||||
|
||||
POSIX classes are disabled by default. Enable this feature by setting the `posix` option to true.
|
||||
|
||||
**Enable POSIX bracket support**
|
||||
|
||||
```js
|
||||
console.log(pm.makeRe('[[:word:]]+', { posix: true }));
|
||||
//=> /^(?:(?=.)[A-Za-z0-9_]+\/?)$/
|
||||
```
|
||||
|
||||
**Supported POSIX classes**
|
||||
|
||||
The following named POSIX bracket expressions are supported:
|
||||
|
||||
* `[:alnum:]` - Alphanumeric characters, equ `[a-zA-Z0-9]`
|
||||
* `[:alpha:]` - Alphabetical characters, equivalent to `[a-zA-Z]`.
|
||||
* `[:ascii:]` - ASCII characters, equivalent to `[\\x00-\\x7F]`.
|
||||
* `[:blank:]` - Space and tab characters, equivalent to `[ \\t]`.
|
||||
* `[:cntrl:]` - Control characters, equivalent to `[\\x00-\\x1F\\x7F]`.
|
||||
* `[:digit:]` - Numerical digits, equivalent to `[0-9]`.
|
||||
* `[:graph:]` - Graph characters, equivalent to `[\\x21-\\x7E]`.
|
||||
* `[:lower:]` - Lowercase letters, equivalent to `[a-z]`.
|
||||
* `[:print:]` - Print characters, equivalent to `[\\x20-\\x7E ]`.
|
||||
* `[:punct:]` - Punctuation and symbols, equivalent to `[\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~]`.
|
||||
* `[:space:]` - Extended space characters, equivalent to `[ \\t\\r\\n\\v\\f]`.
|
||||
* `[:upper:]` - Uppercase letters, equivalent to `[A-Z]`.
|
||||
* `[:word:]` - Word characters (letters, numbers and underscores), equivalent to `[A-Za-z0-9_]`.
|
||||
* `[:xdigit:]` - Hexadecimal digits, equivalent to `[A-Fa-f0-9]`.
|
||||
|
||||
See the [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html) for more information.
|
||||
|
||||
### Braces
|
||||
|
||||
Picomatch only does [brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) of comma-delimited lists (e.g. `a/{b,c}/d`). For advanced matching with braces, use [micromatch](https://github.com/micromatch/micromatch), which supports advanced syntax such as ranges (e.g. `{01..03}`) and increments (e.g. `{2..10..2}`).
|
||||
|
||||
### Matching special characters as literals
|
||||
|
||||
If you wish to match the following special characters in a filepath, and you want to use these characters in your glob pattern, they must be escaped with backslashes or quotes:
|
||||
|
||||
**Special Characters**
|
||||
|
||||
Some characters that are used for matching in regular expressions are also regarded as valid file path characters on some platforms.
|
||||
|
||||
To match any of the following characters as literals: `$^*+?()[]
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
console.log(pm.makeRe('foo/bar \\(1\\)'));
|
||||
console.log(pm.makeRe('foo/bar \\(1\\)'));
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
## Library Comparisons
|
||||
|
||||
The following table shows which features are supported by [minimatch](https://github.com/isaacs/minimatch), [micromatch](https://github.com/micromatch/micromatch), [picomatch](https://github.com/micromatch/picomatch), [nanomatch](https://github.com/micromatch/nanomatch), [extglob](https://github.com/micromatch/extglob), [braces](https://github.com/micromatch/braces), and [expand-brackets](https://github.com/micromatch/expand-brackets).
|
||||
|
||||
| **Feature** | `minimatch` | `micromatch` | `picomatch` | `nanomatch` | `extglob` | `braces` | `expand-brackets` |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| Wildcard matching (`*?+`) | ✔ | ✔ | ✔ | ✔ | - | - | - |
|
||||
| Advancing globbing | ✔ | ✔ | ✔ | - | - | - | - |
|
||||
| Brace _matching_ | ✔ | ✔ | ✔ | - | - | ✔ | - |
|
||||
| Brace _expansion_ | ✔ | ✔ | - | - | - | ✔ | - |
|
||||
| Extglobs | partial | ✔ | ✔ | - | ✔ | - | - |
|
||||
| Posix brackets | - | ✔ | ✔ | - | - | - | ✔ |
|
||||
| Regular expression syntax | - | ✔ | ✔ | ✔ | ✔ | - | ✔ |
|
||||
| File system operations | - | - | - | - | - | - | - |
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
## Benchmarks
|
||||
|
||||
Performance comparison of picomatch and minimatch.
|
||||
|
||||
```
|
||||
# .makeRe star (*)
|
||||
picomatch x 3,251,247 ops/sec ±0.25% (95 runs sampled)
|
||||
minimatch x 497,224 ops/sec ±0.11% (100 runs sampled)
|
||||
|
||||
# .makeRe star; dot=true (*)
|
||||
picomatch x 2,624,035 ops/sec ±0.16% (98 runs sampled)
|
||||
minimatch x 446,244 ops/sec ±0.63% (99 runs sampled)
|
||||
|
||||
# .makeRe globstar (**)
|
||||
picomatch x 2,524,465 ops/sec ±0.13% (99 runs sampled)
|
||||
minimatch x 1,396,257 ops/sec ±0.58% (96 runs sampled)
|
||||
|
||||
# .makeRe globstars (**/**/**)
|
||||
picomatch x 2,545,674 ops/sec ±0.10% (99 runs sampled)
|
||||
minimatch x 1,196,835 ops/sec ±0.63% (98 runs sampled)
|
||||
|
||||
# .makeRe with leading star (*.txt)
|
||||
picomatch x 2,537,708 ops/sec ±0.11% (100 runs sampled)
|
||||
minimatch x 345,284 ops/sec ±0.64% (96 runs sampled)
|
||||
|
||||
# .makeRe - basic braces ({a,b,c}*.txt)
|
||||
picomatch x 505,430 ops/sec ±1.04% (94 runs sampled)
|
||||
minimatch x 107,991 ops/sec ±0.54% (99 runs sampled)
|
||||
|
||||
# .makeRe - short ranges ({a..z}*.txt)
|
||||
picomatch x 371,179 ops/sec ±2.91% (77 runs sampled)
|
||||
minimatch x 14,104 ops/sec ±0.61% (99 runs sampled)
|
||||
|
||||
# .makeRe - medium ranges ({1..100000}*.txt)
|
||||
picomatch x 384,958 ops/sec ±1.70% (82 runs sampled)
|
||||
minimatch x 2.55 ops/sec ±3.22% (11 runs sampled)
|
||||
|
||||
# .makeRe - long ranges ({1..10000000}*.txt)
|
||||
picomatch x 382,552 ops/sec ±1.52% (71 runs sampled)
|
||||
minimatch x 0.83 ops/sec ±5.67% (7 runs sampled))
|
||||
```
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
## Philosophies
|
||||
|
||||
The goal of this library is to be blazing fast, without compromising on accuracy.
|
||||
|
||||
**Accuracy**
|
||||
|
||||
The number one of goal of this library is accuracy. However, it's not unusual for different glob implementations to have different rules for matching behavior, even with simple wildcard matching. It gets increasingly more complicated when combinations of different features are combined, like when extglobs are combined with globstars, braces, slashes, and so on: `!(**/{a,b,*/c})`.
|
||||
|
||||
Thus, given that there is no canonical glob specification to use as a single source of truth when differences of opinion arise regarding behavior, sometimes we have to implement our best judgement and rely on feedback from users to make improvements.
|
||||
|
||||
**Performance**
|
||||
|
||||
Although this library performs well in benchmarks, and in most cases it's faster than other popular libraries we benchmarked against, we will always choose accuracy over performance. It's not helpful to anyone if our library is faster at returning the wrong answer.
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
## About
|
||||
|
||||
<details>
|
||||
<summary><strong>Contributing</strong></summary>
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Running Tests</strong></summary>
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
npm install && npm test
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Building docs</strong></summary>
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [GitHub Profile](https://github.com/jonschlinkert)
|
||||
* [Twitter Profile](https://twitter.com/jonschlinkert)
|
||||
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017-present, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
@ -1,49 +0,0 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { Unsubscribable, ObservableInput, ObservedValueOf } from '../types';
|
||||
import { innerFrom } from './innerFrom';
|
||||
import { EMPTY } from './empty';
|
||||
|
||||
/**
|
||||
* Creates an Observable that uses a resource which will be disposed at the same time as the Observable.
|
||||
*
|
||||
* <span class="informal">Use it when you catch yourself cleaning up after an Observable.</span>
|
||||
*
|
||||
* `using` is a factory operator, which accepts two functions. First function returns a disposable resource.
|
||||
* It can be an arbitrary object that implements `unsubscribe` method. Second function will be injected with
|
||||
* that object and should return an Observable. That Observable can use resource object during its execution.
|
||||
* Both functions passed to `using` will be called every time someone subscribes - neither an Observable nor
|
||||
* resource object will be shared in any way between subscriptions.
|
||||
*
|
||||
* When Observable returned by `using` is subscribed, Observable returned from the second function will be subscribed
|
||||
* as well. All its notifications (nexted values, completion and error events) will be emitted unchanged by the output
|
||||
* Observable. If however someone unsubscribes from the Observable or source Observable completes or errors by itself,
|
||||
* the `unsubscribe` method on resource object will be called. This can be used to do any necessary clean up, which
|
||||
* otherwise would have to be handled by hand. Note that complete or error notifications are not emitted when someone
|
||||
* cancels subscription to an Observable via `unsubscribe`, so `using` can be used as a hook, allowing you to make
|
||||
* sure that all resources which need to exist during an Observable execution will be disposed at appropriate time.
|
||||
*
|
||||
* @see {@link defer}
|
||||
*
|
||||
* @param resourceFactory A function which creates any resource object that implements `unsubscribe` method.
|
||||
* @param observableFactory A function which creates an Observable, that can use injected resource object.
|
||||
* @return An Observable that behaves the same as Observable returned by `observableFactory`, but
|
||||
* which - when completed, errored or unsubscribed - will also call `unsubscribe` on created resource object.
|
||||
*/
|
||||
export function using<T extends ObservableInput<any>>(
|
||||
resourceFactory: () => Unsubscribable | void,
|
||||
observableFactory: (resource: Unsubscribable | void) => T | void
|
||||
): Observable<ObservedValueOf<T>> {
|
||||
return new Observable<ObservedValueOf<T>>((subscriber) => {
|
||||
const resource = resourceFactory();
|
||||
const result = observableFactory(resource);
|
||||
const source = result ? innerFrom(result) : EMPTY;
|
||||
source.subscribe(subscriber);
|
||||
return () => {
|
||||
// NOTE: Optional chaining did not work here.
|
||||
// Related TS Issue: https://github.com/microsoft/TypeScript/issues/40818
|
||||
if (resource) {
|
||||
resource.unsubscribe();
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
@ -1,46 +0,0 @@
|
||||
import { PGlite, type PGliteOptions } from '@electric-sql/pglite';
|
||||
import type { Cache } from "../cache/core/cache.cjs";
|
||||
import { entityKind } from "../entity.cjs";
|
||||
import type { Logger } from "../logger.cjs";
|
||||
import { PgDatabase } from "../pg-core/db.cjs";
|
||||
import { PgDialect } from "../pg-core/dialect.cjs";
|
||||
import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.cjs";
|
||||
import { type DrizzleConfig } from "../utils.cjs";
|
||||
import type { PgliteClient, PgliteQueryResultHKT } from "./session.cjs";
|
||||
import { PgliteSession } from "./session.cjs";
|
||||
export interface PgDriverOptions {
|
||||
logger?: Logger;
|
||||
cache?: Cache;
|
||||
}
|
||||
export declare class PgliteDriver {
|
||||
private client;
|
||||
private dialect;
|
||||
private options;
|
||||
static readonly [entityKind]: string;
|
||||
constructor(client: PgliteClient, dialect: PgDialect, options?: PgDriverOptions);
|
||||
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): PgliteSession<Record<string, unknown>, TablesRelationalConfig>;
|
||||
}
|
||||
export declare class PgliteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<PgliteQueryResultHKT, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
}
|
||||
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends PGlite = PGlite>(...params: [] | [
|
||||
TClient | string
|
||||
] | [
|
||||
TClient | string,
|
||||
DrizzleConfig<TSchema>
|
||||
] | [
|
||||
(DrizzleConfig<TSchema> & ({
|
||||
connection?: (PGliteOptions & {
|
||||
dataDir?: string;
|
||||
}) | string;
|
||||
} | {
|
||||
client: TClient;
|
||||
}))
|
||||
]): PgliteDatabase<TSchema> & {
|
||||
$client: TClient;
|
||||
};
|
||||
export declare namespace drizzle {
|
||||
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): PgliteDatabase<TSchema> & {
|
||||
$client: '$client is not available on drizzle.mock()';
|
||||
};
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
import type { ColumnBuilderBaseConfig } from "../../../column-builder.js";
|
||||
import type { ColumnBaseConfig } from "../../../column.js";
|
||||
import { entityKind } from "../../../entity.js";
|
||||
import { type Equal } from "../../../utils.js";
|
||||
import { PgColumn, PgColumnBuilder } from "../common.js";
|
||||
export type PgGeometryBuilderInitial<TName extends string> = PgGeometryBuilder<{
|
||||
name: TName;
|
||||
dataType: 'array';
|
||||
columnType: 'PgGeometry';
|
||||
data: [number, number];
|
||||
driverParam: string;
|
||||
enumValues: undefined;
|
||||
}>;
|
||||
export declare class PgGeometryBuilder<T extends ColumnBuilderBaseConfig<'array', 'PgGeometry'>> extends PgColumnBuilder<T> {
|
||||
static readonly [entityKind]: string;
|
||||
constructor(name: T['name']);
|
||||
}
|
||||
export declare class PgGeometry<T extends ColumnBaseConfig<'array', 'PgGeometry'>> extends PgColumn<T> {
|
||||
static readonly [entityKind]: string;
|
||||
getSQLType(): string;
|
||||
mapFromDriverValue(value: string): [number, number];
|
||||
mapToDriverValue(value: [number, number]): string;
|
||||
}
|
||||
export type PgGeometryObjectBuilderInitial<TName extends string> = PgGeometryObjectBuilder<{
|
||||
name: TName;
|
||||
dataType: 'json';
|
||||
columnType: 'PgGeometryObject';
|
||||
data: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
driverParam: string;
|
||||
enumValues: undefined;
|
||||
}>;
|
||||
export declare class PgGeometryObjectBuilder<T extends ColumnBuilderBaseConfig<'json', 'PgGeometryObject'>> extends PgColumnBuilder<T> {
|
||||
static readonly [entityKind]: string;
|
||||
constructor(name: T['name']);
|
||||
}
|
||||
export declare class PgGeometryObject<T extends ColumnBaseConfig<'json', 'PgGeometryObject'>> extends PgColumn<T> {
|
||||
static readonly [entityKind]: string;
|
||||
getSQLType(): string;
|
||||
mapFromDriverValue(value: string): {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
mapToDriverValue(value: {
|
||||
x: number;
|
||||
y: number;
|
||||
}): string;
|
||||
}
|
||||
export interface PgGeometryConfig<T extends 'tuple' | 'xy' = 'tuple' | 'xy'> {
|
||||
mode?: T;
|
||||
type?: 'point' | (string & {});
|
||||
srid?: number;
|
||||
}
|
||||
export declare function geometry(): PgGeometryBuilderInitial<''>;
|
||||
export declare function geometry<TMode extends PgGeometryConfig['mode'] & {}>(config?: PgGeometryConfig<TMode>): Equal<TMode, 'xy'> extends true ? PgGeometryObjectBuilderInitial<''> : PgGeometryBuilderInitial<''>;
|
||||
export declare function geometry<TName extends string, TMode extends PgGeometryConfig['mode'] & {}>(name: TName, config?: PgGeometryConfig<TMode>): Equal<TMode, 'xy'> extends true ? PgGeometryObjectBuilderInitial<TName> : PgGeometryBuilderInitial<TName>;
|
||||
@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/tidb-serverless/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { TiDBServerlessDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: TiDBServerlessDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tawait db.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAmC;AAGnC,eAAsB,QACrB,IACA,QACC;AACD,QAAM,iBAAa,oCAAmB,MAAM;AAC5C,QAAM,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AACxD;","names":[]}
|
||||
File diff suppressed because one or more lines are too long
@ -1,9 +0,0 @@
|
||||
import { entityKind } from "../entity.cjs";
|
||||
import type { ColumnsSelection } from "../sql/sql.cjs";
|
||||
import { View } from "../sql/sql.cjs";
|
||||
export declare abstract class MySqlViewBase<TName extends string = string, TExisting extends boolean = boolean, TSelectedFields extends ColumnsSelection = ColumnsSelection> extends View<TName, TExisting, TSelectedFields> {
|
||||
static readonly [entityKind]: string;
|
||||
readonly _: View<TName, TExisting, TSelectedFields>['_'] & {
|
||||
readonly viewBrand: 'MySqlViewBase';
|
||||
};
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
import { entityKind } from "../entity.js";
|
||||
import type { SQL } from "../sql/sql.js";
|
||||
import type { SQLiteTable } from "./table.js";
|
||||
export declare class CheckBuilder {
|
||||
name: string;
|
||||
value: SQL;
|
||||
static readonly [entityKind]: string;
|
||||
protected brand: 'SQLiteConstraintBuilder';
|
||||
constructor(name: string, value: SQL);
|
||||
build(table: SQLiteTable): Check;
|
||||
}
|
||||
export declare class Check {
|
||||
table: SQLiteTable;
|
||||
static readonly [entityKind]: string;
|
||||
_: {
|
||||
brand: 'SQLiteCheck';
|
||||
};
|
||||
readonly name: string;
|
||||
readonly value: SQL;
|
||||
constructor(table: SQLiteTable, builder: CheckBuilder);
|
||||
}
|
||||
export declare function check(name: string, value: SQL): CheckBuilder;
|
||||
@ -1,33 +0,0 @@
|
||||
type Key = string | number | symbol;
|
||||
/**
|
||||
* SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the
|
||||
* index of the `key` in the backing array.
|
||||
*
|
||||
* This is designed to allow synchronizing a second array with the contents of the backing array,
|
||||
* like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`,
|
||||
* and there are never duplicates.
|
||||
*/
|
||||
export declare class SetArray<T extends Key = Key> {
|
||||
private _indexes;
|
||||
array: readonly T[];
|
||||
constructor();
|
||||
}
|
||||
/**
|
||||
* Gets the index associated with `key` in the backing array, if it is already present.
|
||||
*/
|
||||
export declare function get<T extends Key>(setarr: SetArray<T>, key: T): number | undefined;
|
||||
/**
|
||||
* Puts `key` into the backing array, if it is not already present. Returns
|
||||
* the index of the `key` in the backing array.
|
||||
*/
|
||||
export declare function put<T extends Key>(setarr: SetArray<T>, key: T): number;
|
||||
/**
|
||||
* Pops the last added item out of the SetArray.
|
||||
*/
|
||||
export declare function pop<T extends Key>(setarr: SetArray<T>): void;
|
||||
/**
|
||||
* Removes the key, if it exists in the set.
|
||||
*/
|
||||
export declare function remove<T extends Key>(setarr: SetArray<T>, key: T): void;
|
||||
export {};
|
||||
//# sourceMappingURL=set-array.d.ts.map
|
||||
@ -1 +0,0 @@
|
||||
{"version":3,"file":"bufferToggle.js","sourceRoot":"","sources":["../../../../src/internal/operators/bufferToggle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AA6C9C,MAAM,UAAU,YAAY,CAC1B,QAA4B,EAC5B,eAAmD;IAEnD,OAAO,OAAO,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;QACpC,MAAM,OAAO,GAAU,EAAE,CAAC;QAG1B,SAAS,CAAC,QAAQ,CAAC,CAAC,SAAS,CAC3B,wBAAwB,CACtB,UAAU,EACV,CAAC,SAAS,EAAE,EAAE;YACZ,MAAM,MAAM,GAAQ,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAGrB,MAAM,mBAAmB,GAAG,IAAI,YAAY,EAAE,CAAC;YAE/C,MAAM,UAAU,GAAG,GAAG,EAAE;gBACtB,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;gBAC3B,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACxB,mBAAmB,CAAC,WAAW,EAAE,CAAC;YACpC,CAAC,CAAC;YAGF,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QACnI,CAAC,EACD,IAAI,CACL,CACF,CAAC;QAEF,MAAM,CAAC,SAAS,CACd,wBAAwB,CACtB,UAAU,EACV,CAAC,KAAK,EAAE,EAAE;YAER,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;QACH,CAAC,EACD,GAAG,EAAE;YAEH,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gBACzB,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAG,CAAC,CAAC;aACnC;YACD,UAAU,CAAC,QAAQ,EAAE,CAAC;QACxB,CAAC,CACF,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user