Repository navigation
feat: Load optional UI plugin layers #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
45a26f1
feat: Add billing and bank connection screens
nfebe fe1ae72
test: Use current plus prices in billing coverage
nfebe 8a196b4
fix(billing): Default checkout to yearly billing
nfebe 312126d
refactor(ui): Load optional pages from plugin layers
nfebe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Trakli UI plugins | ||
|
|
||
| Set `TRAKLI_UI_LAYERS` to a comma-separated list of installed Nuxt layer paths before development or build. Paths are relative to the web UI checkout, or absolute. | ||
|
|
||
| ```bash | ||
| TRAKLI_UI_LAYERS=/path/to/plugin/ui npm run dev | ||
| TRAKLI_UI_LAYERS=/path/to/plugin/ui npm run build | ||
| TRAKLI_UI_LAYERS=/path/to/plugin/ui npm run test:run | ||
| TRAKLI_UI_LAYERS=/path/to/plugin/ui npm run check:plugins | ||
| ``` | ||
|
|
||
| Without this setting, the app loads no optional plugin layers. A layer supplies its pages, translations and optional components. Keep the matching backend plugin enabled. Installing or removing a layer requires restarting development or rebuilding the app. | ||
|
|
||
| Backend integration descriptors insert links into the existing sidebar and settings slots. Links to local routes are hidden when the route is absent. Custom controls can still register through `useExtensionSlots().registerComponent()`. | ||
|
|
||
| Layer pages use the host's authentication middleware, layouts, components and API client. Keep provider return URLs on the same browser hostname as the UI to preserve login cookies. | ||
|
|
||
| Plugin tests live under the layer's `tests` directory. The host test runner includes tests from the configured layers and supplies its aliases and dependencies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { readdir, readFile } from 'node:fs/promises'; | ||
| import { dirname, extname, join, relative, resolve } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { ESLint } from 'eslint'; | ||
| import * as prettier from 'prettier'; | ||
|
|
||
| const host = resolve(dirname(fileURLToPath(import.meta.url)), '..'); | ||
| const layers = (process.env.TRAKLI_UI_LAYERS || '') | ||
| .split(',') | ||
| .map((layer) => layer.trim()) | ||
| .filter(Boolean) | ||
| .map((layer) => resolve(host, layer)); | ||
| const extensions = new Set(['.ts', '.js', '.mjs', '.vue', '.json', '.md']); | ||
| const excluded = new Set(['node_modules', '.nuxt', '.output', '.git']); | ||
|
|
||
| async function sources(directory) { | ||
| const files = []; | ||
| for (const entry of await readdir(directory, { withFileTypes: true })) { | ||
| if (excluded.has(entry.name)) continue; | ||
| const path = join(directory, entry.name); | ||
| if (entry.isDirectory()) files.push(...(await sources(path))); | ||
| else if (extensions.has(extname(path))) files.push(path); | ||
| } | ||
| return files; | ||
| } | ||
|
|
||
| if (layers.length) { | ||
| let common = host; | ||
| for (const layer of layers) { | ||
| while (relative(common, layer).startsWith('..')) common = dirname(common); | ||
| } | ||
| const eslint = new ESLint({ cwd: common, overrideConfigFile: join(host, 'eslint.config.mjs') }); | ||
| const results = await eslint.lintFiles(layers.map((layer) => `${layer}/**/*.{ts,js,mjs,vue}`)); | ||
| console.log(await (await eslint.loadFormatter('stylish')).format(results)); | ||
| if (results.some((result) => result.errorCount)) process.exitCode = 1; | ||
|
|
||
| const options = await prettier.resolveConfig(join(host, 'nuxt.config.ts')); | ||
| for (const layer of layers) { | ||
| for (const file of await sources(layer)) { | ||
| if (!(await prettier.check(await readFile(file, 'utf8'), { ...options, filepath: file }))) { | ||
| console.error(`Formatting failed: ${relative(host, file)}`); | ||
| process.exitCode = 1; | ||
| } | ||
| } | ||
| } | ||
| if (!process.exitCode) console.log('Plugin layer lint and formatting passed.'); | ||
| } else { | ||
| console.log('No plugin layers configured.'); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
||takes the first present href, so a contribution is gated ononboarding.hrefeven when the card's owncard.hrefroute exists (and vice versa). A working link then disappears from a slot. Check every local href and skip only when none resolve.