Skip to content

Commit

Permalink
Merge pull request #13 from ubq-testing/feat/config-installer
Browse files Browse the repository at this point in the history
Feat/config installer
  • Loading branch information
rndquu authored Nov 21, 2024
2 parents 6ad2d0a + 5ce4b43 commit cf8e6da
Show file tree
Hide file tree
Showing 31 changed files with 3,736 additions and 4,676 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"words": ["dataurl", "devpool", "outdir", "servedir"],
"dictionaries": ["typescript", "node", "software-terms"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
"ignoreRegExpList": ["[0-9a-fA-F]{6}"],
"ignoreWords": ["ubiquibot", "Supabase", "supabase", "SUPABASE", "sonarjs", "mischeck"]
}
55 changes: 0 additions & 55 deletions .eslintrc

This file was deleted.

2 changes: 0 additions & 2 deletions .github/empty-string-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ async function main() {
);
});

// core.setFailed(`${violations.length} empty string${violations.length > 1 ? "s" : ""} detected in the code.`);

await octokit.rest.checks.create({
owner,
repo,
Expand Down
12 changes: 11 additions & 1 deletion .github/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ const config: KnipConfig = {
ignore: ["src/types/config.ts", "**/__mocks__/**", "**/__fixtures__/**"],
ignoreExportsUsedInFile: true,
// eslint can also be safely ignored as per the docs: https://knip.dev/guides/handling-issues#eslint--jest
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier", "@types/jest", "@mswjs/data"],
ignoreDependencies: [
"@mswjs/data",
"@supabase/supabase-js",
"@ubiquity-os/ubiquity-os-kernel",
"ajv",
"yaml",
"simple-git",
"@actions/core",
"esbuild",
"@ubiquity-os/plugin-sdk",
],
eslint: true,
};

Expand Down
40 changes: 37 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
<!---
Insert the issue number of the task you are completing if within this repository, or paste the url of the task.
// EXAMPLE
Resolves https://github.com/ubiquity/ts-template/issues/75
-->

Resolves #

<!--
- You must link the issue number e.g. "Resolves #1234"
- Please do not replace the keyword "Resolves" https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
<!---
We advise that you give a brief description of your changes, either that it meets
the specification exactly as described or what you had to do outwith the spec to resolve it.
This is not required but again, it is advised.
// EXAMPLE
Changes:
- Refactored the authentication mechanism because the auth token wasn't being properly stored.
- Removed unnecessary calls to render the login button.
-->

Changes:

- ...

<!---
NOTICE: This is required for all pull requests and will be requested by reviewers if not present.
- Include a screenshot/video or some other visual confirmation that your changes solve the task
- If this is not applicable, build a unit test to prove it works as intended
// EXAMPLE
QA:
- <url to your plugin fork or test issue in your own org showcasing the end result>
- <screenshot of some kind of UI fix>
- <E2E video of using the software>
-->

QA:

- ...
6 changes: 2 additions & 4 deletions .github/workflows/cypress-testing.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Run Cypress testing suite
on:
# Would be better to run this on pull request events.
workflow_dispatch:
workflow_run:
workflows: ["Build"]
types:
- completed
pull_request:

jobs:
cypress-run:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/no-empty-strings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@ jobs:
with:
node-version: "20.10.0"
- name: Get GitHub App token
if: ${{ env.APP_ID && env.APP_PRIVATE_KEY }}
uses: tibdex/github-app-token@v1.7.0
id: get_installation_token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
env:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
- name: Install Dependencies
run: |
yarn add tsx simple-git
- name: Check for Empty Strings
run: |
yarn tsx .github/empty-string-checker.ts
env:
GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token }}
GITHUB_TOKEN: ${{ steps.get_installation_token.outputs.token || secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_BASE_REF: ${{ github.base_ref }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ static/dist
coverage
junit.xml
cypress/screenshots
test-dashboard.md
45 changes: 27 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# UbiquityOS Plugin Installer

![_Users_nv_repos_0x4007_plugin-installer-gui_index html_manifest={%22name%22_%22Start%20_%20Stop%22,%22description%22_%22Assign%20or%20un-assign%20yourself%20from%20an%20issue %22,%22ubiquity_listeners%22_ %22issue_comment created%22,%22issu](https://github.com/user-attachments/assets/353b1e84-8c1b-48eb-9d6d-1f0e5ba80fb9)
![_Users_nv_repos_0x4007_plugin-installer-gui_index html_manifest={%22name%22_%22Start%20_%20Stop%22,%22description%22_%22Assign%20or%20un-assign%20yourself%20from%20an%20issue %22,%22ubiquity_listeners%22_ %22issue_comment created%22,%22issue](https://github.com/user-attachments/assets/353b1e84-8c1b-48eb-9d6d-1f0e5ba80fb9)

###### This was hand coded on an airplane ride with no internet.
###### This was hand coded on an airplane ride with no internet.

### Plan as of 16 September 2024

Expand Down Expand Up @@ -31,23 +31,32 @@ The browser automatically URI encodes it:

```json
{
"name": "Start | Stop",
"description": "Assign or un-assign yourself from an issue.",
"ubiquity:listeners": [
"issue_comment.created",
"issues.assigned",
"pull_request.opened"
],
"commands": {
"start": {
"ubiquity:example": "/start",
"description": "Assign yourself to the issue."
},
"stop": {
"ubiquity:example": "/stop",
"description": "Unassign yourself from the issue."
}
"name": "Start | Stop",
"description": "Assign or un-assign yourself from an issue.",
"ubiquity:listeners": ["issue_comment.created", "issues.assigned", "pull_request.opened"],
"commands": {
"start": {
"ubiquity:example": "/start",
"description": "Assign yourself to the issue."
},
"stop": {
"ubiquity:example": "/stop",
"description": "Unassign yourself from the issue."
}
}
}
```

###### Example from `command-start-stop/manifest.json`

## How to run

1. Clone the repository
2. Run `yarn` to install dependencies
3. OAuth: Obtain your _GitHub OAuth App_ client ID and secret from your OAuth app settings, and set the callback URL to match the one given by Supabase when enabling GitHub provider OAuth.
4. Replace the hardcoded `SUPABASE_URL` and `SUPABASE_KEY` in `build/esbuild-build.ts` with your Supabase URL and key (Optionally use `.env` and use `process.env` instead.)
5. Run `yarn start` and visit `localhost:8080` in your browser.
6. Once logged in you should see the orgs that you own.
7. Select an org > select a config (dev | prod) > select a plugin > edit/add/remove > push to GitHub.

TODO: Update readme with a better overview of the project.
14 changes: 9 additions & 5 deletions build/esbuild-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ export const esbuildOptions: BuildOptions = {
minify: false,
loader: Object.fromEntries(DATA_URL_LOADERS.map((ext) => [ext, "dataurl"])),
outdir: "static/dist",
define: createEnvDefines(["SUPABASE_URL", "SUPABASE_ANON_KEY"], {
define: createEnvDefines([], {
SUPABASE_STORAGE_KEY: generateSupabaseStorageKey(),
NODE_ENV: process.env.NODE_ENV || "development",
SUPABASE_URL: process.env.SUPABASE_URL || "https://wfzpewmlyiozupulbuur.supabase.co",
SUPABASE_ANON_KEY:
process.env.SUPABASE_ANON_KEY ||
/* cspell:disable-next-line */
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndmenBld21seWlvenVwdWxidXVyIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTU2NzQzMzksImV4cCI6MjAxMTI1MDMzOX0.SKIL3Q0NOBaMehH0ekFspwgcu3afp3Dl9EDzPqs1nKs",
}),
};

Expand All @@ -34,7 +39,6 @@ async function runBuild() {

void runBuild();


function createEnvDefines(environmentVariables: string[], generatedAtBuild: Record<string, unknown>): Record<string, string> {
const defines: Record<string, string> = {};
for (const name of environmentVariables) {
Expand All @@ -45,7 +49,7 @@ function createEnvDefines(environmentVariables: string[], generatedAtBuild: Reco
throw new Error(`Missing environment variable: ${name}`);
}
}
for (const key in generatedAtBuild) {
for (const key of Object.keys(generatedAtBuild)) {
if (Object.prototype.hasOwnProperty.call(generatedAtBuild, key)) {
defines[key] = JSON.stringify(generatedAtBuild[key]);
}
Expand All @@ -54,7 +58,7 @@ function createEnvDefines(environmentVariables: string[], generatedAtBuild: Reco
}

export function generateSupabaseStorageKey(): string | null {
const SUPABASE_URL = process.env.SUPABASE_URL;
const SUPABASE_URL = process.env.SUPABASE_URL || "https://wfzpewmlyiozupulbuur.supabase.co";
if (!SUPABASE_URL) {
console.error("SUPABASE_URL environment variable is not set");
return null;
Expand All @@ -74,4 +78,4 @@ export function generateSupabaseStorageKey(): string | null {
}

return domain.substring(lastSlashIndex + 1);
}
}
9 changes: 3 additions & 6 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { defineConfig } from "cypress";
const { defineConfig } = require("cypress");

export default defineConfig({
module.exports = defineConfig({
e2e: {
setupNodeEvents() {
// implement node event listeners here
},
experimentalStudio: true,
baseUrl: "http://localhost:8080",
baseUrl: "http://127.0.0.1:8080",
},
});
11 changes: 1 addition & 10 deletions cypress/e2e/main.cy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
describe("Homepage tests", () => {
it("Console is cleared of errors and warnings", () => {
cy.visit("/", {
onBeforeLoad(win) {
cy.stub(win.console, "error").as("consoleError");
},
});
cy.get("@consoleError").should("not.be.called");
cy.get("body").should("exist");
cy.get("h1").should("exist");
});
it("todo", () => {});
});
Loading

0 comments on commit cf8e6da

Please sign in to comment.