Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ngalaiko committed Sep 2, 2024
0 parents commit db7c9b9
Show file tree
Hide file tree
Showing 26 changed files with 8,642 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .backstage/component.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: csp-evaluator-cli
title: Content Security Policy Evaluator Command line tool
description: A command line tool to validate Content-Security-Policy rules
spec:
type: library
lifecycle: production
owner: freight-control
system: developer-tools
3 changes: 3 additions & 0 deletions .commitlintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.sage
8 changes: 8 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
extends: ["plugin:@einride/default"],
rules: {
"no-console": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"import/extensions": "off",
},
}
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @einride/freight-control
29 changes: 29 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 2

updates:
# npm == yarn in dependabot
- package-ecosystem: npm
directory: /
schedule:
interval: monthly
day: "sunday"
groups:
npm-dependencies:
patterns:
- "*" # Include all dependencies in one PR
update-types:
- "minor"
- "patch"

- package-ecosystem: gomod
directory: .sage
schedule:
interval: monthly
day: "sunday"
groups:
go-dependencies:
patterns:
- "*" # Include all dependencies in one PR
update-types:
- "minor"
- "patch"
37 changes: 37 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
push:
branches:
- master
- next

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # to create release (semantic release)
id-token: write # to publish with provenance
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Sage
uses: einride/sage/actions/setup@master

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: yarn

- name: Release
run: make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/review.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Review

on:
pull_request:
branches:
- master

jobs:
review:
name: Review
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Sage
uses: einride/sage/actions/setup@master

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: yarn

- name: Review
run: make
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# node
node_modules
# corepack
.yarn/*
!.yarn/releases
# gh auth
gha-creds-*.json
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.10.0
5 changes: 5 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import einridePrettierConfig from "@einride/prettier-config"

export default {
...einridePrettierConfig,
}
30 changes: 30 additions & 0 deletions .releaserc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
branches: [
"+([0-9])?(.{+([0-9]),x}).x",
"master",
"next",
"next-major",
{ name: "beta", prerelease: true },
{ name: "alpha", prerelease: true },
],
plugins: [
[
"@semantic-release/commit-analyzer",
{
preset: "conventionalcommits",
},
],
"@semantic-release/github",
"semantic-release-yarn",
[
"@semantic-release/release-notes-generator",
{
preset: "conventionalcommits",
},
],
],
// disable updates to github PRs and issues due to successful releases
success: false,
// disable creation of github issues due to failed releases
fail: false,
}
5 changes: 5 additions & 0 deletions .sage/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/einride/csp-evaluator-cli/.sage

go 1.17

require go.einride.tech/sage v0.294.0
2 changes: 2 additions & 0 deletions .sage/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go.einride.tech/sage v0.294.0 h1:X5v6sfvt762QwhcRptlYRKoYrNXb1nT9fxKDXsRtaWI=
go.einride.tech/sage v0.294.0/go.mod h1:EzV5uciFX7/2ho8EKB5K9JghOfXIxlzs694b+Tkl5GQ=
97 changes: 97 additions & 0 deletions .sage/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package main

import (
"context"

"go.einride.tech/sage/sg"
"go.einride.tech/sage/tools/sgbackstage"
"go.einride.tech/sage/tools/sggit"
"go.einride.tech/sage/tools/sggolangcilint"
"go.einride.tech/sage/tools/sggolines"
)

func main() {
sg.GenerateMakefiles(
sg.Makefile{
Path: sg.FromGitRoot("Makefile"),
DefaultTarget: Default,
},
)
}

func Default(ctx context.Context) error {
sg.Deps(ctx, Install)
sg.Deps(ctx, Review)
sg.SerialDeps(ctx, GitVerifyNoDiff)
return nil
}

func Install(ctx context.Context) error {
sg.Logger(ctx).Println("installing dependencies...")
return sg.Command(ctx, "yarn", "install").Run()
}

func InstallImmutable(ctx context.Context) error {
sg.Logger(ctx).Println("installing dependencies...")
return sg.Command(ctx, "yarn", "install", "--immutable").Run()
}

func Review(ctx context.Context) error {
sg.Deps(ctx,
Lint, Format,
Commitlint,
GoLint, GoFormat,
BackstageValidate,
)
return nil
}

func Commitlint(ctx context.Context) error {
sg.Logger(ctx).Println("formatting...")
cmd := sg.Command(ctx, "yarn", "commitlint", "--from", "origin/master", "--to", "HEAD")
return cmd.Run()
}

func Lint(ctx context.Context) error {
sg.Logger(ctx).Println("formatting...")
cmd := sg.Command(ctx, "yarn", "eslint", "--ext", "js", ".")
return cmd.Run()
}

func Format(ctx context.Context) error {
sg.Logger(ctx).Println("formatting...")
cmd := sg.Command(ctx, "yarn", "prettier", "--write", ".")
return cmd.Run()
}

func GoLint(ctx context.Context) error {
sg.Logger(ctx).Println("linting Go files...")
return sggolangcilint.Run(ctx)
}

func GoLintFix(ctx context.Context) error {
sg.Logger(ctx).Println("fixing Go files...")
return sggolangcilint.Fix(ctx)
}

func GoFormat(ctx context.Context) error {
sg.Logger(ctx).Println("formatting Go files...")
return sggolines.Run(ctx)
}

func BackstageValidate(ctx context.Context) error {
sg.Logger(ctx).Println("validating Backstage files...")
return sgbackstage.Validate(ctx)
}

func GitVerifyNoDiff(ctx context.Context) error {
sg.Logger(ctx).Println("verifying that git has no diff...")
return sggit.VerifyNoDiff(ctx)
}

func Release(ctx context.Context) error {
sg.Logger(ctx).Println("releasing...")
sg.Deps(ctx, InstallImmutable)
cmd := sg.Command(ctx, "yarn", "semantic-release", "--ci")
return cmd.Run()
}
873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.5.0.cjs

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
yarnPath: .yarn/releases/yarn-3.5.0.cjs
defaultSemverRangePrefix: ""
nodeLinker: node-modules

npmScopes:
saga:
npmAlwaysAuth: true
npmRegistryServer: "https://europe-west1-npm.pkg.dev/e-npm-registry-prod/npm/"
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Contributing

Thanks for showing interest in contributing to `@einride/csp-evaluator-cli`!

## Pull Request Guidelines

`@einride/csp-evaluator-cli` is using the
[Conventional Commits](https://www.conventionalcommits.org/) commit message convention.

Before opening a PR, please make sure you get no errors when running `make convco-check`.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Einride

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit db7c9b9

Please sign in to comment.