Skip to content

Commit

Permalink
add package index
Browse files Browse the repository at this point in the history
  • Loading branch information
StardustDL committed Feb 5, 2024
1 parent 045330c commit 2854300
Show file tree
Hide file tree
Showing 14 changed files with 1,217 additions and 125 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ jobs:
run: |
cd ./src/web && npm install
- name: Set Build Env
shell: bash
run: |
echo "VITE_NOSERVER=1\nVITE_COMMIT_ID=${{ github.sha }}\nVITE_BUILD_DATE=$(date -Ins)" > ./src/web/.env
- name: Build
Expand Down Expand Up @@ -204,6 +205,7 @@ jobs:
name: docs
path: ./dist
- name: Add redirects
shell: bash
run: |
echo "/* /index.html 200" > ./dist/_redirects
- name: Deploy docs to netlify
Expand All @@ -225,8 +227,9 @@ jobs:
name: web-dist
path: ./dist
- name: Add redirects
shell: bash
run: |
echo "/* /index.html 200" > ./dist/_redirects
echo "/* /index.html 200\n/data https://aexpy-docs.netlify.app 200\n/change-spec https://aexpy-docs.netlify.app 200" > ./dist/_redirects
- name: Deploy docs to netlify
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: netlify/actions/cli@master
Expand Down
31 changes: 31 additions & 0 deletions src/web/src/components/breadcrumbs/BatchBreadcrumbItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { NIcon, NBreadcrumbItem } from 'naive-ui'
import { BatchIcon, BatchIndexIcon } from '../icons'
import { RouterLink } from 'vue-router'
import { useStore } from '../../services/store'
const props = defineProps<{
isIndex?: boolean;
}>();
const store = useStore();
</script>

<template>
<n-breadcrumb-item>
<router-link to="/batch">
<n-icon>
<BatchIcon />
</n-icon>
Batch
</router-link>
</n-breadcrumb-item>
<n-breadcrumb-item v-if="isIndex">
<router-link to="/batch">
<n-icon>
<BatchIndexIcon />
</n-icon>
Index
</router-link>
</n-breadcrumb-item>
</template>
28 changes: 28 additions & 0 deletions src/web/src/components/products/PackageIndex.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script setup lang="ts">
import { ref, computed, onMounted, h, defineComponent, reactive } from 'vue'
import { NSpace, NText, NDivider, DataTableColumns, NDataTable, DataTableBaseColumn, NScrollbar, NCollapseTransition, NPopover, NIcon, NButton, NInputGroup, NInput, NCode, useMessage } from 'naive-ui'
import { useStore } from '../../services/store'
const message = useMessage();
const store = useStore();
const packages = ref<string[] | undefined>();
onMounted(async () => {
try {
packages.value = await store.state.api.packages();
}
catch (e) {
console.error(e);
message.error(`Failed to load package index.`);
}
});
</script>

<template>
<n-space v-if="packages">
<n-button v-for="item in packages" :key="item" text tag="a"
:href="`/packages/${item}`" target="_blank">{{ item }}</n-button>
</n-space>
</template>
32 changes: 20 additions & 12 deletions src/web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DistributionView from './pages/view/Distribution.vue'
import DescriptionView from './pages/view/Description.vue'
import DifferenceView from './pages/view/Difference.vue'
import ReportView from './pages/view/Report.vue'
import PackageView from './pages/view/Package.vue'
import NotFound from './pages/NotFound.vue'
import { publicModels } from './services/utils'

Expand All @@ -20,59 +21,66 @@ const routes = [
}
},
{
path: '/distribution',
path: '/distributions',
component: Home,
meta: {
title: 'Home'
}
},
{
path: '/description',
path: '/apis',
component: Home,
meta: {
title: 'Home'
}
},
{
path: '/difference',
path: '/changes',
component: Home,
meta: {
title: 'Home'
}
},
{
path: '/report',
path: '/reports',
component: Home,
meta: {
title: 'Home'
}
},
{
path: '/distribution/:id',
path: '/distributions/:id',
component: DistributionView,
meta: {
title: 'Distribution'
title: 'Distributions'
}
},
{
path: '/description/:id',
path: '/apis/:id',
component: DescriptionView,
meta: {
title: 'Description'
title: 'APIs'
}
},
{
path: '/difference/:id',
path: '/changes/:id',
component: DifferenceView,
meta: {
title: 'Difference'
title: 'Changes'
}
},
{
path: '/report/:id',
path: '/reports/:id',
component: ReportView,
meta: {
title: 'Report'
title: 'Reports'
}
},
{
path: '/packages/:id',
component: PackageView,
meta: {
title: 'Packages'
}
},
{
Expand Down
146 changes: 145 additions & 1 deletion src/web/src/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { store } from "../services/store";
import { ApiEntry, AttributeEntry, ClassEntry, FunctionEntry, ItemEntry, loadApiEntry, ModuleEntry } from "./description";
import { BreakingRank, DiffEntry, VerifyState } from "./difference";
import { parse as durationParse} from "tinyduration";
import { parse as durationParse } from "tinyduration";

export enum ProduceMode {
Access = 0,
Expand Down Expand Up @@ -360,4 +360,148 @@ export class Report extends Product {
this.new.from(data.new ?? {});
this.content = data.content ?? "";
}
}

export class PackageProductIndex {
releases: Release[] = [];
preprocessed: Release[] = [];
extracted: Release[] = [];
pairs: ReleasePair[] = [];
diffed: ReleasePair[] = [];
reported: ReleasePair[] = [];

from(data: any) {
(<any[]>data.releases ?? []).forEach((value: any) => {
let release = Release.fromString(value);
if (release) {
this.releases.push(release);
}
});
(<any[]>data.distributions ?? []).forEach((value: any) => {
let release = Release.fromString(value);
if (release) {
this.preprocessed.push(release);
}
});
(<any[]>data.apis ?? []).forEach((value: any) => {
let release = Release.fromString(value);
if (release) {
this.extracted.push(release);
}
});
(<any[]>data.pairs ?? []).forEach((value: any) => {
let pair = ReleasePair.fromString(value);
if (pair) {
this.pairs.push(pair);
}
});
(<any[]>data.changes ?? []).forEach((value: any) => {
let pair = ReleasePair.fromString(value);
if (pair) {
this.diffed.push(pair);
}
});
(<any[]>data.reports ?? []).forEach((value: any) => {
let pair = ReleasePair.fromString(value);
if (pair) {
this.reported.push(pair);
}
});
}

ispreprocessed(release: Release): boolean {
return this.preprocessed.find((item: Release) => item.equals(release)) != undefined;
}

isextracted(release: Release): boolean {
return this.extracted.find((item: Release) => item.equals(release)) != undefined;
}

isdiffed(pair: ReleasePair): boolean {
return this.diffed.find((item: ReleasePair) => item.equals(pair)) != undefined;
}

isreported(pair: ReleasePair): boolean {
return this.reported.find((item: ReleasePair) => item.equals(pair)) != undefined;
}

failpreprocessed(): Release[] {
return this.releases.filter((release: Release) => {
return !this.ispreprocessed(release);
});
}

failextracted(): Release[] {
return this.releases.filter((release: Release) => {
return !this.isextracted(release);
});
}

faildiffed(): ReleasePair[] {
return this.pairs.filter((pair: ReleasePair) => {
return !this.isdiffed(pair);
});
}

failreported(): ReleasePair[] {
return this.pairs.filter((pair: ReleasePair) => {
return !this.isreported(pair);
});
}

async loadPreprocessed() {
let preprocessed: { [key: string]: Distribution } = {};
let promised: Promise<any>[] = [];
for (let item of this.preprocessed) {
let cur = item;
let tfunc = async () => {
preprocessed[cur.toString()] = await store.state.api.distribution(cur);
}
promised.push(tfunc());
}
await Promise.all(promised);
return preprocessed;
}

async loadExtracted() {
let extracted: { [key: string]: ApiDescription } = {};
let promised: Promise<any>[] = [];
for (let item of this.extracted) {
let cur = item;
let tfunc = async () => {
extracted[cur.toString()] = await store.state.api.api(cur);
}
promised.push(tfunc());
}
await Promise.all(promised);
return extracted;
}

async loadDiffed() {
let diffed: { [key: string]: ApiDifference } = {};
let promised: Promise<any>[] = [];
for (let item of this.diffed) {
let cur = item;
let tfunc = async () => {
diffed[cur.toString()] = await store.state.api.change(cur);
}
promised.push(tfunc());
}
await Promise.all(promised);
return diffed;
}

async loadReported() {
let reported: { [key: string]: Report } = {};
let promised: Promise<any>[] = [];
for (let item of this.reported) {
let cur = item;
let tfunc = async () => {
reported[cur.toString()] = await store.state.api.report(cur);
}
promised.push(tfunc());
}
await Promise.all(promised);
return reported;
}
}
Loading

0 comments on commit 2854300

Please sign in to comment.