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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Contributing to @alcops/core

Thanks for your interest in contributing! This document explains how to get started.

## Getting Started

1. Fork the repository and clone your fork:

```bash
git clone https://github.com/<your-username>/npm-package.git
cd npm-package
```

2. Install dependencies:

```bash
npm install
```

3. Verify everything works:

```bash
npm test
```

## Development Workflow

1. Create a branch from `main`:

```bash
git checkout -b feature/my-change
```

2. Make your changes and ensure the checks pass:

```bash
npm run lint # ESLint
npm test # Vitest
npm run build # TypeScript compilation
npm run bundle # esbuild production bundle
```

3. Commit your changes with a clear message.

4. Push and open a pull request against `main`.

## Available Scripts

| Script | Purpose |
|--------|---------|
| `npm run lint` | Run ESLint on `src/` |
| `npm test` | Run tests with Vitest |
| `npm run test:watch` | Run tests in watch mode |
| `npm run build` | Compile TypeScript |
| `npm run bundle` | Build production bundle with esbuild |

## Code Style

- TypeScript in strict mode
- ESLint rules are enforced via `npm run lint`
- CI runs lint, tests, build, and bundle on every pull request

## Pull Request Guidelines

- Open an issue first for large or breaking changes so we can discuss the approach.
- Keep PRs focused on a single change.
- Add tests for new functionality.
- CI must pass before a PR can be merged.

## Releases

Releases are automated. When changes are merged to `main`, the maintainers trigger a release workflow that versions the package with [GitVersion](https://gitversion.net/), publishes to npm, and creates a GitHub Release.
127 changes: 127 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# @alcops/core

[![CI](https://github.com/ALCops/npm-package/actions/workflows/ci.yml/badge.svg)](https://github.com/ALCops/npm-package/actions/workflows/ci.yml)
[![npm](https://img.shields.io/npm/v/@alcops/core)](https://www.npmjs.com/package/@alcops/core)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)

Automatically detect the Target Framework Moniker (TFM) for Business Central and download the matching code analyzer files. Build AL extensions with the right analyzers, without manual version juggling. Designed for CI/CD pipelines.

## Features

- Detect the TFM from four different sources:
- **BC artifact URL** (e.g. a sandbox or OnPrem artifact)
- **VS Marketplace** (the AL Language extension)
- **NuGet DevTools** (Microsoft's AL development tools package)
- **Local compiler path** (a directory containing the AL compiler DLLs)
- JSON output on stdout, logs on stderr (pipe-friendly)
- Zero configuration required
- Usable as a CLI or as a Node.js library

## Installation

```bash
# Install globally
npm install -g @alcops/core

# Or run directly with npx
npx @alcops/core detect-tfm marketplace
```

## Requirements

- Node.js >= 20

## CLI Usage

```
alcops <command> [args]

Commands:
detect-tfm bc-artifact <url> Detect TFM from a BC artifact URL
detect-tfm marketplace [channel] Detect TFM from VS Marketplace (default: current)
detect-tfm nuget-devtools [version] Detect TFM from NuGet DevTools (default: latest)
detect-tfm compiler-path <dir> Detect TFM from a local compiler directory

Options:
--help Show this help message
```

### Examples

Detect from the VS Marketplace (most common):

```bash
alcops detect-tfm marketplace
```

Detect from a specific NuGet DevTools version:

```bash
alcops detect-tfm nuget-devtools 26.0.12345
```

Detect from a BC artifact URL:

```bash
alcops detect-tfm bc-artifact "https://bcartifacts.azureedge.net/sandbox/26.0.12345.0/us"
```

Detect from a local compiler directory:

```bash
alcops detect-tfm compiler-path ./path/to/compiler
```

### Output

All commands write JSON to stdout:

```json
{
"tfm": "net8.0",
"source": "marketplace",
"details": "AL Language extension v14.0.12345"
}
```

Logs go to stderr, so you can safely pipe the result:

```bash
TFM=$(alcops detect-tfm marketplace | jq -r '.tfm')
echo "Building with TFM: $TFM"
```

### CI/CD Example (GitHub Actions)

```yaml
- name: Detect TFM
id: tfm
run: |
result=$(npx @alcops/core detect-tfm marketplace)
echo "tfm=$(echo "$result" | jq -r '.tfm')" >> "$GITHUB_OUTPUT"

- name: Use TFM
run: echo "Target framework is ${{ steps.tfm.outputs.tfm }}"
```

## Programmatic API

The package exports all detection functions for use as a library:

```typescript
import { detectFromMarketplace, createConsoleLogger } from '@alcops/core';

const logger = createConsoleLogger();
const result = await detectFromMarketplace('current', logger);
console.log(result.tfm); // e.g. "net8.0"
```

See the [exported API surface](./src/index.ts) for the full list of available functions and types.

## Contributing

See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and contribution guidelines.

## License

[MIT](./LICENSE)