Skip to content

Commit

Permalink
Merge pull request ubiquity-os-marketplace#54 from ubiquity-whilefoo/…
Browse files Browse the repository at this point in the history
…command-interface

Command interface
  • Loading branch information
gentlementlegen authored Nov 25, 2024
2 parents 551544d + e12efd8 commit 5dcb30c
Show file tree
Hide file tree
Showing 42 changed files with 954 additions and 1,122 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

53 changes: 0 additions & 53 deletions .eslintrc

This file was deleted.

13 changes: 12 additions & 1 deletion .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ const config: KnipConfig = {
project: ["src/**/*.ts"],
ignore: ["src/types/config.ts", "src/adapters/supabase/types/database.ts"],
ignoreExportsUsedInFile: true,
ignoreDependencies: ["ts-node", "@types/jest", "@octokit/plugin-retry", "@octokit/plugin-throttling", "hono"],
ignoreDependencies: [
"ts-node",
"@types/jest",
"@eslint/js",
"typescript-eslint",
"eslint-plugin-sonarjs",
"eslint-plugin-prettier",
"eslint-plugin-check-file",
"eslint-config-prettier",
"@typescript-eslint/parser",
"@typescript-eslint/eslint-plugin",
],
};

export default config;
2 changes: 2 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ on:
required: true
signature:
required: true
command:
required: true

jobs:
run:
Expand Down
135 changes: 135 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import tsEslint from "typescript-eslint";
import eslint from "@eslint/js";
import sonarjs from "eslint-plugin-sonarjs";
import checkFile from "eslint-plugin-check-file";

export default tsEslint.config({
plugins: {
"@typescript-eslint": tsEslint.plugin,
"check-file": checkFile,
},
ignores: [".github/knip.ts", "src/adapters/supabase/types/database.ts", ".wrangler/**", "dist/**", "coverage/**"],
extends: [eslint.configs.recommended, ...tsEslint.configs.recommended, sonarjs.configs.recommended],
languageOptions: {
parser: tsEslint.parser,
parserOptions: {
projectService: {
defaultProject: "tsconfig.json",
allowDefaultProject: ["*.mjs"],
},
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
"check-file/filename-naming-convention": [
"error",
{
"**/*.{js,ts}": "+([-._a-z0-9])",
},
],
"prefer-arrow-callback": [
"warn",
{
allowNamedFunctions: true,
},
],
"func-style": [
"warn",
"declaration",
{
allowArrowFunctions: false,
},
],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"constructor-super": "error",
"no-invalid-this": "off",
"@typescript-eslint/no-invalid-this": ["error"],
"no-restricted-syntax": ["error", "ForInStatement"],
"use-isnan": "error",
"no-unneeded-ternary": "error",
"no-nested-ternary": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "after-used",
ignoreRestSiblings: true,
vars: "all",
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"sonarjs/no-all-duplicated-branches": "error",
"sonarjs/no-collection-size-mischeck": "error",
"sonarjs/no-duplicated-branches": "error",
"sonarjs/no-element-overwrite": "error",
"sonarjs/no-identical-conditions": "error",
"sonarjs/no-identical-expressions": "error",
"sonarjs/new-cap": "off",
"sonarjs/different-types-comparison": "off",
"sonarjs/sonar-prefer-regexp-exec": "off",
"sonarjs/function-return-type": "off",
"sonarjs/no-misleading-array-reverse": "off",
"sonarjs/slow-regex": "off",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "interface",
format: ["StrictPascalCase"],
custom: {
regex: "^I[A-Z]",
match: false,
},
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["strictCamelCase"],
leadingUnderscore: "require",
},
{
selector: "typeLike",
format: ["StrictPascalCase"],
},
{
selector: "typeParameter",
format: ["StrictPascalCase"],
prefix: ["T"],
},
{
selector: "variable",
format: ["strictCamelCase", "UPPER_CASE"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: "variable",
format: ["strictCamelCase"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{
selector: "variable",
modifiers: ["destructured"],
format: null,
},
{
selector: "variable",
types: ["boolean"],
format: ["StrictPascalCase"],
prefix: ["is", "should", "has", "can", "did", "will", "does"],
},
{
selector: "variableLike",
format: ["strictCamelCase"],
},
{
selector: ["function", "variable"],
format: ["strictCamelCase"],
},
],
},
});
19 changes: 18 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@
"commands": {
"allow": {
"ubiquity:example": "/allow @user1 label",
"description": "Allows the user to modify the given label."
"description": "Allows the user to modify the given label type.",
"parameters": {
"type": "object",
"properties": {
"username": {
"type": "string",
"description": "The user that will be allowed to change the label"
},
"labelTypes": {
"type": "array",
"description": "Array of label types that user will be allowed to change, it can be empty to remove access from all labels",
"items": {
"type": "string",
"enum": ["time", "priority"]
}
}
}
}
}
},
"configuration": {
Expand Down
38 changes: 20 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"node": ">=20.10.0"
},
"scripts": {
"worker": "wrangler dev --env dev --port 4000",
"worker": "wrangler dev --env dev --port 4001",
"start": "tsx src/index.ts",
"format": "run-s format:lint format:prettier format:cspell",
"format:lint": "eslint --fix .",
Expand All @@ -19,7 +19,7 @@
"knip": "knip --config .github/knip.ts",
"knip-ci": "knip --no-exit-code --reporter json --config .github/knip.ts",
"prepare": "husky install",
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --setupFiles dotenv/config --coverage",
"test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --setupFiles dotenv/config --coverage",
"supabase:generate:local": "supabase gen types typescript --local > src/adapters/supabase/types/database.ts",
"supabase:generate:remote": "dotenv -- cross-env-shell supabase gen types typescript --project-id $SUPABASE_PROJECT_ID --schema public > src/adapters/supabase/types/database.ts"
},
Expand All @@ -32,36 +32,37 @@
],
"dependencies": {
"@commander-js/extra-typings": "12.0.1",
"@octokit/plugin-retry": "^7.1.2",
"@octokit/plugin-throttling": "^9.3.2",
"@octokit/rest": "^20.0.2",
"@octokit/webhooks": "^13.1.0",
"@sinclair/typebox": "^0.33.17",
"@octokit/rest": "^20.1.0",
"@sinclair/typebox": "0.34.3",
"@supabase/supabase-js": "2.43.1",
"@ubiquity-os/ubiquity-os-kernel": "^2.5.1",
"@ubiquity-os/plugin-sdk": "^1.1.0",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"commander": "12.0.0",
"decimal.js": "^10.4.3",
"dotenv": "^16.4.5",
"hono": "^4.6.7"
},
"devDependencies": {
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@cspell/dict-node": "^4.0.3",
"@cspell/dict-software-terms": "^3.3.18",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@cspell/dict-node": "^5.0.5",
"@cspell/dict-software-terms": "^4.1.15",
"@cspell/dict-typescript": "^3.1.2",
"@eslint/js": "9.14.0",
"@jest/globals": "29.7.0",
"@mswjs/data": "0.16.1",
"@types/jest": "29.5.12",
"@types/node": "^20.11.19",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"cross-env": "7.0.3",
"cspell": "^8.4.0",
"dotenv-cli": "7.4.2",
"eslint": "^8.56.0",
"eslint-plugin-sonarjs": "^0.24.0",
"eslint": "9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-check-file": "^2.8.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-sonarjs": "^1.0.3",
"husky": "^9.0.11",
"jest": "29.7.0",
"jest-junit": "16.0.0",
Expand All @@ -74,8 +75,9 @@
"ts-jest": "29.1.2",
"ts-node": "10.9.2",
"tsx": "^4.7.1",
"typescript": "5.5.4",
"wrangler": "^3.83.0"
"typescript": "5.6.2",
"typescript-eslint": "^8.14.0",
"wrangler": "^3.87.0"
},
"lint-staged": {
"*.ts": [
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Context } from "@ubiquity-os/ubiquity-os-kernel";
import { Context } from "../types/context";
import { Access } from "./supabase/helpers/tables/access";
import { Label } from "./supabase/helpers/tables/label";
import { Super } from "./supabase/helpers/tables/super";
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/supabase/helpers/tables/access.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Context } from "@ubiquity-os/ubiquity-os-kernel";
import { Context } from "../../../../types/context";
import { Database } from "../../types/database";
import { Super } from "./super";

Expand Down
2 changes: 1 addition & 1 deletion src/adapters/supabase/helpers/tables/label.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Context } from "@ubiquity-os/ubiquity-os-kernel";
import { Context } from "../../../../types/context";

import { Database } from "../../types/database";
import { Super } from "./super";
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/supabase/helpers/tables/super.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Context } from "@ubiquity-os/ubiquity-os-kernel";
import { Context } from "../../../../types/context";
import { Database } from "../../types/database";

export class Super {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/supabase/helpers/tables/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Context } from "@ubiquity-os/ubiquity-os-kernel";
import { Context } from "../../../../types/context";
import { Super } from "./super";

export class User extends Super {
Expand Down
6 changes: 3 additions & 3 deletions src/handlers/check-modified-base-rate.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { CONFIG_FULL_PATH, DEV_CONFIG_FULL_PATH } from "@ubiquity-os/ubiquity-os-kernel";
import { ContextPlugin } from "../types/plugin-input";
import { CONFIG_FULL_PATH, DEV_CONFIG_FULL_PATH } from "@ubiquity-os/plugin-sdk/constants";
import { Context } from "../types/context";
import { isPushEvent } from "../types/typeguards";
import { getCommitChanges } from "./get-commit-changes";

export const ZERO_SHA = "0000000000000000000000000000000000000000";
const BASE_RATE_FILES = [DEV_CONFIG_FULL_PATH, CONFIG_FULL_PATH];

export async function isConfigModified(context: ContextPlugin): Promise<boolean> {
export async function isConfigModified(context: Context): Promise<boolean> {
if (!isPushEvent(context)) {
context.logger.debug("Not a push event");
return false;
Expand Down
Loading

0 comments on commit 5dcb30c

Please sign in to comment.