@specky-pm/cli v0.1.2
Specky Package Manager (spm)
The Specky Package Manager (spm) is a command-line tool for creating, installing, and managing component specifications following the Specky format. It simplifies the process of creating and maintaining standardized component specifications across your projects.
Installation
You can install the Specky Package Manager globally using npm:
npm install -g specky-pmOr using yarn:
yarn global add specky-pmUsage
Once installed, you can use the spm command to manage your Specky components.
Available Commands
spm init- Initialize a new Specky component specificationspm help- Display help informationspm version- Display the current version
Command: spm init
The spm init command helps you create a new spec.json file for your Specky component. It guides you through an interactive process to collect all the necessary information.
Usage
spm init [options]Options
-y, --yes- Skip prompts and use default values
Examples
Basic usage with interactive prompts:
spm initQuick initialization with default values:
spm init --yesInteractive Prompts
The spm init command will prompt you for the following information:
- Component name - The name of your component (must be lowercase and can only contain alphanumeric characters, hyphens, and underscores)
- Version - The version of your component (following semantic versioning)
- Description - A brief description of your component
- Author information - Your name, email, and URL
- License - The license for your component (e.g., MIT, Apache-2.0)
- Keywords - Comma-separated list of keywords
- Repository information - The URL of your component's repository
- Homepage URL - The URL of your component's homepage
- Bug reporting information - URLs and email for reporting bugs
After collecting this information, the command will show you a preview of the spec.json file and ask for confirmation before creating it.
Command: spm pack
The spm pack command creates a distributable package of your Specky component based on the spec.json file. It bundles the specified files and directories into a single archive, ready for distribution or installation.
Usage
spm pack [options]Options
-y, --yes- Skip prompts and proceed with packaging without confirmation
Examples
Basic usage with confirmation prompt:
spm packQuick packaging without confirmation:
spm pack --yesThe spec.json File
The spec.json file is the core of a Specky component. It contains metadata about the component and follows a structure similar to package.json but with specific fields for Specky components.
Example spec.json
{
"name": "my-component",
"version": "1.0.0",
"description": "A sample Specky component",
"author": {
"name": "John Doe",
"email": "john@example.com",
"url": "https://example.com"
},
"license": "MIT",
"keywords": [
"specky",
"component",
"my-component"
],
"repository": {
"type": "git",
"url": "https://github.com/username/my-component"
},
"homepage": "https://example.com/my-component",
"bugs": {
"url": "https://github.com/username/my-component/issues",
"email": "bugs@example.com"
}
}Required Fields
name- The name of the componentversion- The version of the component (following semantic versioning)description- A brief description of the component
Optional Fields
author- The author of the component (string or object with name, email, and URL)contributors- Array of contributors (strings or objects)license- The license for the component (SPDX identifier)keywords- Array of keywordsdependencies- Object mapping dependency names to version rangesrepository- The repository where the component is stored (string or object)homepage- The URL of the component's homepagebugs- Information for reporting bugs (string or object)files- Array of files to includepublishConfig- Configuration for publishing
The files Field
The files field in spec.json is an array of strings that specifies which files and directories should be included when the component is packaged using spm pack.
Each string in the files array can be a file path, a directory path, or a glob pattern.
- File Paths: Include a specific file.
- Directory Paths: Include all files within the directory and its subdirectories.
- Glob Patterns: Use glob syntax to specify multiple files or patterns. Common glob patterns include:
*: Matches any sequence of non-separator characters.**: Matches any sequence of characters, including separators (used for matching directories recursively).?: Matches any single non-separator character.[abc]: Matches any single character in the set.[!abc]: Matches any single character not in the set.
Example files field:
"files": [
"README.md",
"component.md",
"docs/",
"tests/**/*.feature",
"!tests/**/*.md"
]In this example:
README.md,component.mdincludes the README and component files.docs/includes everything in thedocsdirectory.tests/**/*.featuresincludes all Gherkin feature spec files in thetestsdirectory and its subdirectories.tests/**/*.mdexcludes markdown files from thetestsdirectory (patterns starting with!exclude matches).
Troubleshooting
Common Issues
"spec.json already exists"
If you see this message, it means there's already a spec.json file in the current directory. You can:
- Move to a different directory
- Delete or rename the existing file
- Confirm overwriting when prompted
Validation Errors
If you encounter validation errors, make sure:
- Component name is lowercase and contains only alphanumeric characters, hyphens, and underscores
- Version follows semantic versioning (X.Y.Z)
- Description is not empty
- URLs are valid
- Email addresses are valid
- License is a valid SPDX identifier
Git Configuration Not Found
If the tool can't find your git configuration:
- Make sure git is installed
- Configure your git user name and email:
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
Debug Mode
You can enable debug mode to see more detailed error information:
spm --debug initLicense
MIT