Compare commits
9 Commits
web/add-ht
...
docs-scrip
Author | SHA1 | Date | |
---|---|---|---|
78bc5687ef | |||
52b1e8de13 | |||
73a9957925 | |||
90824b966f | |||
4c9f977361 | |||
9143197ef5 | |||
e20eaac56e | |||
085ab3c2dd | |||
c0063c1749 |
@ -5,9 +5,9 @@ import process from "process";
|
||||
|
||||
const localizeRules = JSON.parse(fs.readFileSync("./lit-localize.json", "utf-8"));
|
||||
|
||||
function compareXlfAndSrc(loc) {
|
||||
const xlf = path.join("./xliff", `${loc}.xlf`);
|
||||
const src = path.join("./src/locales", `${loc}.ts`);
|
||||
function generatedFileIsUpToDateWithXliffSource(loc) {
|
||||
const xliff = path.join("./xliff", `${loc}.xlf`);
|
||||
const gened = path.join("./src/locales", `${loc}.ts`);
|
||||
|
||||
// Returns false if: the expected XLF file doesn't exist, The expected
|
||||
// generated file doesn't exist, or the XLF file is newer (has a higher date)
|
||||
@ -15,29 +15,28 @@ function compareXlfAndSrc(loc) {
|
||||
// generates a unique error message and halts the build.
|
||||
|
||||
try {
|
||||
var xlfStat = fs.statSync(xlf);
|
||||
var xlfStat = fs.statSync(xliff);
|
||||
} catch (_error) {
|
||||
console.error(`lit-localize expected '${loc}.xlf', but XLF file is not present`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// If the generated file doesn't exist, of course it's not up to date.
|
||||
try {
|
||||
var srcStat = fs.statSync(src);
|
||||
var genedStat = fs.statSync(gened);
|
||||
} catch (_error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if the xlf is newer (greater) than src, it's out of date.
|
||||
if (xlfStat.mtimeMs > srcStat.mtimeMs) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
// if the generated file is the same age or older (date is greater) than the xliff file, it's
|
||||
// presumed to have been generated by that file and is up-to-date.
|
||||
return genedStat.mtimeMs >= xlfStat.mtimeMs;
|
||||
}
|
||||
|
||||
// For all the expected files, find out if any aren't up-to-date.
|
||||
|
||||
const upToDate = localizeRules.targetLocales.reduce(
|
||||
(acc, loc) => acc && compareXlfAndSrc(loc),
|
||||
(acc, loc) => acc && generatedFileIsUpToDateWithXliffSource(loc),
|
||||
true,
|
||||
);
|
||||
|
||||
@ -61,7 +60,9 @@ if (!upToDate) {
|
||||
.map((locale) => `Locale '${locale}' has ${counts.get(locale)} missing translations`)
|
||||
.join("\n");
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Translation tables rebuilt.\n${report}\n`);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log("Locale ./src is up-to-date");
|
||||
|
@ -12,4 +12,5 @@ const cmd = [
|
||||
"-S './src/locales/**' ./src -s",
|
||||
].join(" ");
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(execSync(cmd, { encoding: "utf8" }));
|
||||
|
55
web/scripts/eslint-nightmare.mjs
Normal file
55
web/scripts/eslint-nightmare.mjs
Normal file
@ -0,0 +1,55 @@
|
||||
import { execFileSync } from "child_process";
|
||||
import { ESLint } from "eslint";
|
||||
import path from "path";
|
||||
import process from "process";
|
||||
|
||||
// Code assumes this script is in the './web/scripts' folder.
|
||||
const projectRoot = execFileSync("git", ["rev-parse", "--show-toplevel"], {
|
||||
encoding: "utf8",
|
||||
}).replace("\n", "");
|
||||
process.chdir(path.join(projectRoot, "./web"));
|
||||
|
||||
const eslintConfig = {
|
||||
overrideConfig: {
|
||||
env: {
|
||||
browser: true,
|
||||
es2021: true,
|
||||
},
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:lit/recommended",
|
||||
"plugin:custom-elements/recommended",
|
||||
"plugin:storybook/recommended",
|
||||
"plugin:sonarjs/recommended",
|
||||
],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: 12,
|
||||
sourceType: "module",
|
||||
},
|
||||
plugins: ["@typescript-eslint", "lit", "custom-elements", "sonarjs"],
|
||||
rules: {
|
||||
"indent": "off",
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"quotes": ["error", "double", { avoidEscape: true }],
|
||||
"semi": ["error", "always"],
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"sonarjs/cognitive-complexity": ["error", 9],
|
||||
"sonarjs/no-duplicate-string": "off",
|
||||
"sonarjs/no-nested-template-literals": "off",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const updated = ["./src/", "./build.mjs", "./scripts/*.mjs"];
|
||||
|
||||
const eslint = new ESLint(eslintConfig);
|
||||
const results = await eslint.lintFiles(updated);
|
||||
const formatter = await eslint.loadFormatter("stylish");
|
||||
const resultText = formatter.format(results);
|
||||
const errors = results.reduce((acc, result) => acc + result.errorCount, 0);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(resultText);
|
||||
process.exit(errors > 1 ? 1 : 0);
|
@ -2,7 +2,7 @@
|
||||
|
||||
TARGET="./node_modules/@spotlightjs/overlay/dist/index-"[0-9a-f]*.js
|
||||
|
||||
if [[ $(grep -L "QX2" "$TARGET" > /dev/null 2&>1) ]]; then
|
||||
if [[ $(grep -L "QX2" "$TARGET" > /dev/null 2> /dev/null) ]]; then
|
||||
patch --forward -V none --no-backup-if-mismatch -p0 $TARGET <<EOF
|
||||
|
||||
TARGET=$(find "./node_modules/@spotlightjs/overlay/dist/" -name "index-[0-9a-f]*.js");
|
||||
|
@ -103,11 +103,7 @@ export class ApplicationWizardCommitApplication extends BasePanel {
|
||||
);
|
||||
if (!providerModel) {
|
||||
throw new Error(
|
||||
`Could not determine provider model from user request: ${JSON.stringify(
|
||||
this.wizard,
|
||||
null,
|
||||
2,
|
||||
)}`,
|
||||
`Could not determine provider model from user request: ${JSON.stringify(this.wizard, null, 2)}`,
|
||||
);
|
||||
}
|
||||
|
||||
@ -118,7 +114,6 @@ export class ApplicationWizardCommitApplication extends BasePanel {
|
||||
};
|
||||
|
||||
this.send(request);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import "@goauthentik/elements/forms/SearchSelect";
|
||||
import YAML from "yaml";
|
||||
|
||||
import { msg } from "@lit/localize";
|
||||
import { TemplateResult, html } from "lit";
|
||||
import { TemplateResult, html, nothing } from "lit";
|
||||
import { customElement, property } from "lit/decorators.js";
|
||||
import { ifDefined } from "lit/directives/if-defined.js";
|
||||
|
||||
@ -66,14 +66,11 @@ export class PolicyTestForm extends Form<PropertyMappingTestRequest> {
|
||||
</ak-form-element-horizontal>`;
|
||||
}
|
||||
|
||||
renderExampleButtons(): TemplateResult {
|
||||
const header = html`<p>${msg("Example context data")}</p>`;
|
||||
switch (this.mapping?.metaModelName) {
|
||||
case "authentik_sources_ldap.ldappropertymapping":
|
||||
return html`${header}${this.renderExampleLDAP()}`;
|
||||
default:
|
||||
return html``;
|
||||
}
|
||||
renderExampleButtons() {
|
||||
return this.mapping?.metaModelName === "authentik_sources_ldap.ldappropertymapping"
|
||||
? html`<p>${msg("Example context data")}</p>
|
||||
${this.renderExampleLDAP()}`
|
||||
: nothing;
|
||||
}
|
||||
|
||||
renderExampleLDAP(): TemplateResult {
|
||||
|
@ -42,12 +42,11 @@ export function transformCredentialCreateOptions(
|
||||
user.id = u8arr(b64enc(u8arr(stringId)));
|
||||
const challenge = u8arr(credentialCreateOptions.challenge.toString());
|
||||
|
||||
const transformedCredentialCreateOptions = Object.assign({}, credentialCreateOptions, {
|
||||
return {
|
||||
...credentialCreateOptions,
|
||||
challenge,
|
||||
user,
|
||||
});
|
||||
|
||||
return transformedCredentialCreateOptions;
|
||||
};
|
||||
}
|
||||
|
||||
export interface Assertion {
|
||||
@ -98,12 +97,11 @@ export function transformCredentialRequestOptions(
|
||||
},
|
||||
);
|
||||
|
||||
const transformedCredentialRequestOptions = Object.assign({}, credentialRequestOptions, {
|
||||
return {
|
||||
...credentialRequestOptions,
|
||||
challenge,
|
||||
allowCredentials,
|
||||
});
|
||||
|
||||
return transformedCredentialRequestOptions;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AuthAssertion {
|
||||
|
@ -92,11 +92,13 @@ export class Tabs extends AKElement {
|
||||
const pages = Array.from(this.querySelectorAll(":scope > [slot^='page-']"));
|
||||
if (window.location.hash.includes(ROUTE_SEPARATOR)) {
|
||||
const params = getURLParams();
|
||||
if (this.pageIdentifier in params && !this.currentPage) {
|
||||
if (this.querySelector(`[slot='${params[this.pageIdentifier]}']`) !== null) {
|
||||
// To update the URL to match with the current slot
|
||||
this.onClick(params[this.pageIdentifier] as string);
|
||||
}
|
||||
if (
|
||||
this.pageIdentifier in params &&
|
||||
!this.currentPage &&
|
||||
this.querySelector(`[slot='${params[this.pageIdentifier]}']`) !== null
|
||||
) {
|
||||
// To update the URL to match with the current slot
|
||||
this.onClick(params[this.pageIdentifier] as string);
|
||||
}
|
||||
}
|
||||
if (!this.currentPage) {
|
||||
|
@ -352,10 +352,13 @@ export class SearchSelect<T> extends CustomEmitterElement(AKElement) {
|
||||
const onFocus = (ev: FocusEvent) => {
|
||||
this.open = true;
|
||||
this.renderMenu();
|
||||
if (this.blankable && this.renderedValue === this.emptyOption) {
|
||||
if (ev.target && ev.target instanceof HTMLInputElement) {
|
||||
ev.target.value = "";
|
||||
}
|
||||
if (
|
||||
this.blankable &&
|
||||
this.renderedValue === this.emptyOption &&
|
||||
ev.target &&
|
||||
ev.target instanceof HTMLInputElement
|
||||
) {
|
||||
ev.target.value = "";
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -117,19 +117,11 @@ export class SidebarItem extends AKElement {
|
||||
if (!this.path) {
|
||||
return false;
|
||||
}
|
||||
if (this.path) {
|
||||
const ourPath = this.path.split(";")[0];
|
||||
if (new RegExp(`^${ourPath}$`).exec(path)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return this.activeMatchers.some((v) => {
|
||||
const match = v.exec(path);
|
||||
if (match !== null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
const ourPath = this.path.split(";")[0];
|
||||
const pathIsWholePath = new RegExp(`^${ourPath}$`).test(path);
|
||||
const pathIsAnActivePath = this.activeMatchers.some((v) => v.test(path));
|
||||
return pathIsWholePath || pathIsAnActivePath;
|
||||
}
|
||||
|
||||
expandParentRecursive(activePath: string, item: SidebarItem): void {
|
||||
|
@ -231,14 +231,11 @@ ${prompt.initialValue}</textarea
|
||||
|
||||
shouldRenderInWrapper(prompt: StagePrompt): boolean {
|
||||
// Special types that aren't rendered in a wrapper
|
||||
if (
|
||||
return !(
|
||||
prompt.type === PromptTypeEnum.Static ||
|
||||
prompt.type === PromptTypeEnum.Hidden ||
|
||||
prompt.type === PromptTypeEnum.Separator
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
);
|
||||
}
|
||||
|
||||
renderField(prompt: StagePrompt): TemplateResult {
|
||||
|
@ -166,6 +166,6 @@ export class LibraryPageApplicationSearch extends AKElement {
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"ak-library-list-search": LibraryPageApplicationList;
|
||||
"ak-library-list-search": LibraryPageApplicationSearch;
|
||||
}
|
||||
}
|
||||
|
@ -70,10 +70,7 @@ export class UserSettingsFlowExecutor
|
||||
})
|
||||
.then((data) => {
|
||||
this.challenge = data;
|
||||
if (this.challenge.responseErrors) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !this.challenge.responseErrors;
|
||||
})
|
||||
.catch((e: Error | ResponseError) => {
|
||||
this.errorMessage(e);
|
||||
|
@ -10,20 +10,16 @@ import { PromptTypeEnum, StagePrompt } from "@goauthentik/api";
|
||||
@customElement("ak-user-stage-prompt")
|
||||
export class UserSettingsPromptStage extends PromptStage {
|
||||
renderPromptInner(prompt: StagePrompt): TemplateResult {
|
||||
switch (prompt.type) {
|
||||
// Checkbox requires slightly different rendering here due to the use of horizontal form elements
|
||||
case PromptTypeEnum.Checkbox:
|
||||
return html`<input
|
||||
type="checkbox"
|
||||
class="pf-c-check__input"
|
||||
name="${prompt.fieldKey}"
|
||||
?checked=${prompt.initialValue !== ""}
|
||||
?required=${prompt.required}
|
||||
style="vertical-align: bottom"
|
||||
/>`;
|
||||
default:
|
||||
return super.renderPromptInner(prompt);
|
||||
}
|
||||
return prompt.type === PromptTypeEnum.Checkbox
|
||||
? html`<input
|
||||
type="checkbox"
|
||||
class="pf-c-check__input"
|
||||
name="${prompt.fieldKey}"
|
||||
?checked=${prompt.initialValue !== ""}
|
||||
?required=${prompt.required}
|
||||
style="vertical-align: bottom"
|
||||
/>`
|
||||
: super.renderPromptInner(prompt);
|
||||
}
|
||||
|
||||
renderField(prompt: StagePrompt): TemplateResult {
|
||||
|
77
website/scripts/migration/readme.md
Normal file
77
website/scripts/migration/readme.md
Normal file
@ -0,0 +1,77 @@
|
||||
---
|
||||
title: Docs migration script
|
||||
---
|
||||
|
||||
This repository contains the source code for the authentik Docs Migration Script.
|
||||
|
||||
## How to Run
|
||||
|
||||
- use branch
|
||||
- run the script
|
||||
- ?
|
||||
- test
|
||||
- ?
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- ?
|
||||
- git
|
||||
|
||||
## What does it do, and how does it work?
|
||||
|
||||
The script does the following:
|
||||
|
||||
- migrates all doc files and images from their old file path structure into their new structure
|
||||
- creates new directories (name read from the `migratefile.txt` TO column.)
|
||||
- files moved into new directories
|
||||
- internal links within each file are rewritten to use new location
|
||||
- tbd
|
||||
|
||||
### Setup
|
||||
|
||||
- tbd
|
||||
|
||||
### Run the Script
|
||||
|
||||
`docsmg migrate`
|
||||
|
||||
### Commands:
|
||||
|
||||
- `docsmg move`
|
||||
|
||||
Examples:
|
||||
|
||||
`docsmg move + <current path file name> <target path and file name>`
|
||||
|
||||
or for moving all files within a folder, use:
|
||||
|
||||
`docsmg move testing/testing2 newtesting/newtesting2/puthere >> migratefile`
|
||||
|
||||
- `docsmg migrate`
|
||||
|
||||
This will read the `migratefile.txt`, creates the dirs (gets the names from the `migratefile.txt` file), and then migrate the files.
|
||||
|
||||
- `docsmg unmigrate`
|
||||
|
||||
This command will undo the most recent move.
|
||||
|
||||
#### Flags
|
||||
|
||||
Flags include
|
||||
|
||||
Use `-r` if we are keeping the exact same structure in any place, we can use this flag to move that specified dir to a new place while keeping the sub-structure exactly the same.
|
||||
|
||||
Using `-m` flag that allows tab-completion of the OLD file path.
|
||||
|
||||
Use `-q` flag with `docsmg migrate` to not show the successful lines but will show any failures.
|
||||
|
||||
### Steps:
|
||||
|
||||
1. tbw
|
||||
- sub-tbw
|
||||
- sub-tbq
|
||||
2. tbw
|
||||
3. tbw
|
||||
4. tbw
|
||||
|
||||
## Verify the migration
|
11
website/scripts/readme.md
Normal file
11
website/scripts/readme.md
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
title: Docs Tools
|
||||
---
|
||||
|
||||
This repository is for tools that the Docs teams uses for various tasks:
|
||||
|
||||
## Docs migration script:
|
||||
|
||||
This [script](./migration/readme.md) will be used to auto-build the new structure for the docs, as part of the Information Architecture effort.
|
||||
|
||||
Using a script that will restucture all of our docs at once prevents the difficulty of trying to handle pull requests not being able to be merged while working on the docs restructure.
|
Reference in New Issue
Block a user