From c67aca7c9db44f9c71f99d0aae0910b43ae498c3 Mon Sep 17 00:00:00 2001 From: Armaldio Date: Fri, 17 Jan 2025 15:08:14 +0100 Subject: [PATCH] add unified logs view add enable extra logs in electron buiding add preliminary poki upload --- .gitattributes | 1 + assets/electron/template/app/config.cjs | 2 + .../electron/template/app/pipelab-plugin.cjs | 20 +- components.d.ts | 11 - index.html | 74 +------ package.json | 4 + pnpm-lock.yaml | 203 +++++++++++++++++- src/renderer/pages/editor.vue | 111 ++++++++-- src/renderer/store/editor.ts | 10 +- src/renderer/style/main.scss | 13 ++ .../libs/plugin-construct/export-shared.ts | 2 +- src/shared/libs/plugin-electron/configure.ts | 11 +- src/shared/libs/plugin-electron/forge.ts | 6 +- src/shared/libs/plugin-electron/model.ts | 1 + .../libs/plugin-poki/assets/poki-icon.webp | Bin 0 -> 1338 bytes src/shared/libs/plugin-poki/export.ts | 116 ++++++++++ src/shared/libs/plugin-poki/index.ts | 21 ++ 17 files changed, 491 insertions(+), 115 deletions(-) create mode 100644 .gitattributes create mode 100644 src/shared/libs/plugin-poki/assets/poki-icon.webp create mode 100644 src/shared/libs/plugin-poki/export.ts create mode 100644 src/shared/libs/plugin-poki/index.ts diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fcadb2c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=lf diff --git a/assets/electron/template/app/config.cjs b/assets/electron/template/app/config.cjs index 9278ff2..8157308 100644 --- a/assets/electron/template/app/config.cjs +++ b/assets/electron/template/app/config.cjs @@ -22,6 +22,7 @@ * @property {string} appCategoryType * @property {string} icon * @property {boolean} disableAsarPackaging + * @property {boolean} enableExtraLogging * @property {boolean} enableSteamSupport * @property {number} steamGameId */ @@ -38,6 +39,7 @@ const config = { description: 'A simple Electron application', electronVersion: '', disableAsarPackaging: false, + enableExtraLogging: false, enableDisableRendererBackgrounding: false, enableInProcessGPU: false, frame: true, diff --git a/assets/electron/template/app/pipelab-plugin.cjs b/assets/electron/template/app/pipelab-plugin.cjs index 519984c..a31fd32 100644 --- a/assets/electron/template/app/pipelab-plugin.cjs +++ b/assets/electron/template/app/pipelab-plugin.cjs @@ -17,33 +17,33 @@ module.exports = class PipelabPlugin extends PluginBase { } prePackage() { - console.log('running prePackage hook') + // console.log('running prePackage hook') } generateAssets() { - console.log('running generateAssets hook') + // console.log('running generateAssets hook') } postStart() { - console.log('running postStart hook') + // console.log('running postStart hook') } packageAfterCopy() { - console.log('running packageAfterCopy hook') + // console.log('running packageAfterCopy hook') } packageAfterPrune() { - console.log('running packageAfterPrune hook') + // console.log('running packageAfterPrune hook') } packageAfterExtract() { - console.log('running packageAfterExtract hook') + // console.log('running packageAfterExtract hook') } postPackage() { - console.log('running postPackage hook') + // console.log('running postPackage hook') } preMake() { - console.log('running preMake hook') + // console.log('running preMake hook') } postMake() { - console.log('running postMake hook') + // console.log('running postMake hook') } readPackageJson() { - console.log('running readPackageJson hook') + // console.log('running readPackageJson hook') } } diff --git a/components.d.ts b/components.d.ts index 9ca32c9..5ec358d 100644 --- a/components.d.ts +++ b/components.d.ts @@ -7,12 +7,6 @@ export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { - Accordion: typeof import('primevue/accordion')['default'] - AccordionContent: typeof import('primevue/accordioncontent')['default'] - AccordionHeader: typeof import('primevue/accordionheader')['default'] - AccordionPanel: typeof import('primevue/accordionpanel')['default'] - Avatar: typeof import('primevue/avatar')['default'] - Badge: typeof import('primevue/badge')['default'] Button: typeof import('primevue/button')['default'] Checkbox: typeof import('primevue/checkbox')['default'] Chip: typeof import('primevue/chip')['default'] @@ -35,11 +29,6 @@ declare module 'vue' { Select: typeof import('primevue/select')['default'] SelectButton: typeof import('primevue/selectbutton')['default'] Skeleton: typeof import('primevue/skeleton')['default'] - Tab: typeof import('primevue/tab')['default'] - TabList: typeof import('primevue/tablist')['default'] - TabPanel: typeof import('primevue/tabpanel')['default'] - TabPanels: typeof import('primevue/tabpanels')['default'] - Tabs: typeof import('primevue/tabs')['default'] Toast: typeof import('primevue/toast')['default'] } } diff --git a/index.html b/index.html index abfb193..620183c 100644 --- a/index.html +++ b/index.html @@ -26,6 +26,7 @@ href="https://fonts.gstatic.com" crossorigin > + diff --git a/src/renderer/store/editor.ts b/src/renderer/store/editor.ts index 1064d79..43469a4 100644 --- a/src/renderer/store/editor.ts +++ b/src/renderer/store/editor.ts @@ -84,6 +84,8 @@ export type BlockToNode = T['type'] extends 'action' ? Loop : never +export type Status = 'idle' | 'running' | 'error' | 'canceled' | 'done' + export const useEditor = defineStore('editor', () => { const appStore = useAppStore() const { presets, pluginDefinitions } = storeToRefs(appStore) @@ -117,12 +119,14 @@ export const useEditor = defineStore('editor', () => { const environnements = ref>([]) /** All log lines relative to their plugin instance */ - const logLines = ref>({}) + const logLines = ref>({}) + + const nodeStatuses = ref>({}) /** The API helper */ // const api = useAPI() - const pushLine = (nodeUid: string, data: unknown[]) => { + const pushLine = (nodeUid: string, data: string) => { if (!logLines.value[nodeUid]) { logLines.value[nodeUid] = [] } @@ -638,6 +642,8 @@ export const useEditor = defineStore('editor', () => { clearLogs, logLines, + nodeStatuses, + setActiveNode, setBlockValue, setTriggerValue, diff --git a/src/renderer/style/main.scss b/src/renderer/style/main.scss index 518d6bf..bff840f 100644 --- a/src/renderer/style/main.scss +++ b/src/renderer/style/main.scss @@ -88,3 +88,16 @@ $sizes: 12, 14, 16, 18, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 72, 80, font-size: #{nth($sizes, $i)}px; } } + +.rotate { + animation: rotate 2s linear infinite; +} + +@keyframes rotate { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} diff --git a/src/shared/libs/plugin-construct/export-shared.ts b/src/shared/libs/plugin-construct/export-shared.ts index bcf91d2..d00d9ca 100644 --- a/src/shared/libs/plugin-construct/export-shared.ts +++ b/src/shared/libs/plugin-construct/export-shared.ts @@ -182,7 +182,7 @@ export const exportc3p = async ( log('error, no result, crashed', e) throw new Error('ConstructExport failed: ' + e.message) } finally { - await context.browser().close() + // await context.browser().close() await context.close() } } diff --git a/src/shared/libs/plugin-electron/configure.ts b/src/shared/libs/plugin-electron/configure.ts index 101e5f4..0a68609 100644 --- a/src/shared/libs/plugin-electron/configure.ts +++ b/src/shared/libs/plugin-electron/configure.ts @@ -219,7 +219,16 @@ export const props = createAction({ control: { type: 'boolean' }, - description: 'Whether to to disable packaging project files in a single binary or not', + description: 'Whether to disable packaging project files in a single binary or not', + }, + enableExtraLogging: { + required: true, + label: 'Enable extra logging', + value: false, + control: { + type: 'boolean' + }, + description: 'Whether to enable extra logging of internal tools while bundling', }, // Flags diff --git a/src/shared/libs/plugin-electron/forge.ts b/src/shared/libs/plugin-electron/forge.ts index 5f8b369..e333aea 100644 --- a/src/shared/libs/plugin-electron/forge.ts +++ b/src/shared/libs/plugin-electron/forge.ts @@ -273,6 +273,7 @@ export const forge = async ( description: 'A simple Electron application', electronVersion: '', disableAsarPackaging: false, + enableExtraLogging: false, enableDisableRendererBackgrounding: false, enableInProcessGPU: false, frame: true, @@ -397,10 +398,11 @@ export const forge = async ( { cwd: destinationFolder, env: { - // DEBUG: '*', + DEBUG: completeConfiguration.enableExtraLogging ? '*' : '', ELECTRON_NO_ASAR: '1', ELECTRON_RUN_AS_NODE: '1', - PATH: `${shimsPaths}${delimiter}${process.env.PATH}` + PATH: `${shimsPaths}${delimiter}${process.env.PATH}`, + // DEBUG: "electron-packager" } }, log, diff --git a/src/shared/libs/plugin-electron/model.ts b/src/shared/libs/plugin-electron/model.ts index 8011eae..42fa741 100644 --- a/src/shared/libs/plugin-electron/model.ts +++ b/src/shared/libs/plugin-electron/model.ts @@ -5,6 +5,7 @@ export type ElectronConfiguration = { appVersion: string electronVersion: string disableAsarPackaging: boolean + enableExtraLogging: boolean customMainCode: string author: string description: string diff --git a/src/shared/libs/plugin-poki/assets/poki-icon.webp b/src/shared/libs/plugin-poki/assets/poki-icon.webp new file mode 100644 index 0000000000000000000000000000000000000000..9b57d9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1|buj6vnyoVv=Mwz9svoS( + async ({ log, inputs, cwd, paths }) => { + const { app } = await import('electron') + const { join, dirname } = await import('node:path') + const { mkdir, access, chmod, writeFile } = await import('node:fs/promises') + + const { unpack } = paths + const modulesPath = join(unpack, 'node_modules') + const poki = join(modulesPath, '@poki', 'cli', 'bin', 'index.js') + + const pokiJsonPath = join(inputs['input-folder'], 'poki.json') + + // create file at the same place the folder to upload + await writeFile( + pokiJsonPath, + JSON.stringify( + { + game_id: inputs.project, + build_dir: '.' + }, + undefined, + 2 + ), + 'utf-8' + ) + + // TODO: needs auth + + await runWithLiveLogs( + poki, + ['upload', '--name', inputs.name, '--notes', inputs.notes], + { + cwd: inputs['input-folder'] + }, + log, + { + onStderr(data, subprocess) { + log(data) + }, + onStdout(data, subprocess) { + log(data) + } + } + ) + + /* + { + "game_id": "c7bfd2ba-e23b-486f-9504-a6f196cb44df", + "build_dir": "dist" + } + npx @poki/cli upload --name "$(git rev-parse --short HEAD)" --notes "$(git log -1 --pretty=%B)" + */ + + log('Uploaded to poki') + } +) diff --git a/src/shared/libs/plugin-poki/index.ts b/src/shared/libs/plugin-poki/index.ts new file mode 100644 index 0000000..4883fdd --- /dev/null +++ b/src/shared/libs/plugin-poki/index.ts @@ -0,0 +1,21 @@ +import { uploadToPoki, uploadToPokiRunner } from './export' + +import { createNodeDefinition } from '@pipelab/plugin-core' +import icon from './assets/poki-icon.webp' + +export default createNodeDefinition({ + description: 'Poki', + name: 'Poki', + id: 'poki', + icon: { + type: 'image', + image: icon + }, + nodes: [ + // make and package + { + node: uploadToPoki, + runner: uploadToPokiRunner + } + ] +})