web/NPM Workspaces: Prep ESBuild plugin for publish. (#14552)
* web: Prep ESBuild plugin for publish. * prettier-config: Update deps. * eslint-config: Update deps. * docusaurus-config: Update deps. * docs: Update deps. * docs: Enable linter. * docs: Lint. * web/sfe: Clean up types. Prep for monorepo. * esbuild-plugin-live-reload: Update deps. * web: Tidy ESLint, script commands. * web: Fix logs. * web: Lint. * web: Split compile check from cached version.
This commit is contained in:
@ -1,23 +0,0 @@
|
||||
{
|
||||
"arrowParens": "always",
|
||||
"bracketSpacing": true,
|
||||
"embeddedLanguageFormatting": "auto",
|
||||
"htmlWhitespaceSensitivity": "css",
|
||||
"insertPragma": false,
|
||||
"jsxSingleQuote": false,
|
||||
"printWidth": 100,
|
||||
"proseWrap": "preserve",
|
||||
"quoteProps": "consistent",
|
||||
"requirePragma": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 4,
|
||||
"trailingComma": "all",
|
||||
"useTabs": false,
|
||||
"vueIndentScriptAndStyle": false,
|
||||
"plugins": ["@trivago/prettier-plugin-sort-imports"],
|
||||
"importOrder": ["^(@?)lit(.*)$", "\\.css$", "^@goauthentik/api$", "^[./]"],
|
||||
"importOrderSeparation": true,
|
||||
"importOrderSortSpecifiers": true,
|
||||
"importOrderParserPlugins": ["typescript", "classProperties", "decorators-legacy"]
|
||||
}
|
@ -1,6 +1,14 @@
|
||||
{
|
||||
"name": "@goauthentik/web-sfe",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "rollup -c rollup.config.mjs --bundleConfigAsCjs",
|
||||
"prettier": "prettier --cache --write -u .",
|
||||
"prettier-check": "prettier --cache --check -u .",
|
||||
"watch": "rollup -w -c rollup.config.mjs --bundleConfigAsCjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@goauthentik/api": "^2024.6.0-1719577139",
|
||||
"base64-js": "^1.5.1",
|
||||
@ -10,19 +18,17 @@
|
||||
"weakmap-polyfill": "^2.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@goauthentik/core": "^1.0.0",
|
||||
"@rollup/plugin-commonjs": "^28.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||
"@rollup/plugin-swc": "^0.4.0",
|
||||
"@swc/cli": "^0.4.0",
|
||||
"@swc/core": "^1.7.28",
|
||||
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
||||
"@types/jquery": "^3.5.31",
|
||||
"prettier": "^3.3.2",
|
||||
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
||||
"prettier": "^3.5.3",
|
||||
"rollup": "^4.23.0",
|
||||
"rollup-plugin-copy": "^3.5.0",
|
||||
"wireit": "^0.14.9"
|
||||
"rollup-plugin-copy": "^3.5.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"optionalDependencies": {
|
||||
"@swc/core": "^1.7.28",
|
||||
"@swc/core-darwin-arm64": "^1.6.13",
|
||||
@ -35,29 +41,5 @@
|
||||
"@swc/core-win32-arm64-msvc": "^1.6.13",
|
||||
"@swc/core-win32-ia32-msvc": "^1.6.13",
|
||||
"@swc/core-win32-x64-msvc": "^1.6.13"
|
||||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "wireit",
|
||||
"prettier": "prettier --write ./src ./tsconfig.json ./rollup.config.js ./package.json",
|
||||
"watch": "rollup -w -c rollup.config.js --bundleConfigAsCjs"
|
||||
},
|
||||
"wireit": {
|
||||
"build:sfe": {
|
||||
"command": "rollup -c rollup.config.js --bundleConfigAsCjs",
|
||||
"files": [
|
||||
"../../node_modules/bootstrap/dist/css/bootstrap.min.css",
|
||||
"src/index.ts"
|
||||
],
|
||||
"output": [
|
||||
"./dist/sfe/*"
|
||||
]
|
||||
},
|
||||
"build": {
|
||||
"command": "mkdir -p ../../dist/sfe && cp -r dist/sfe/* ../../dist/sfe",
|
||||
"dependencies": [
|
||||
"build:sfe"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +0,0 @@
|
||||
import commonjs from "@rollup/plugin-commonjs";
|
||||
import resolve from "@rollup/plugin-node-resolve";
|
||||
import swc from "@rollup/plugin-swc";
|
||||
import copy from "rollup-plugin-copy";
|
||||
|
||||
export default {
|
||||
input: "src/index.ts",
|
||||
output: {
|
||||
dir: "./dist/sfe",
|
||||
format: "cjs",
|
||||
},
|
||||
context: "window",
|
||||
plugins: [
|
||||
copy({
|
||||
targets: [
|
||||
{
|
||||
src: "../../node_modules/bootstrap/dist/css/bootstrap.min.css",
|
||||
dest: "./dist/sfe",
|
||||
},
|
||||
],
|
||||
}),
|
||||
resolve({ browser: true }),
|
||||
commonjs(),
|
||||
swc({
|
||||
swc: {
|
||||
jsc: {
|
||||
loose: false,
|
||||
externalHelpers: false,
|
||||
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
|
||||
keepClassNames: false,
|
||||
},
|
||||
minify: false,
|
||||
env: {
|
||||
targets: {
|
||||
edge: "17",
|
||||
ie: "11",
|
||||
},
|
||||
mode: "entry",
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
61
web/packages/sfe/rollup.config.mjs
Normal file
61
web/packages/sfe/rollup.config.mjs
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file Rollup configuration for the SFE package.
|
||||
*/
|
||||
import commonjs from "@rollup/plugin-commonjs";
|
||||
import resolve from "@rollup/plugin-node-resolve";
|
||||
import swc from "@rollup/plugin-swc";
|
||||
import { resolve as resolvePath } from "node:path";
|
||||
import copy from "rollup-plugin-copy";
|
||||
|
||||
export async function createConfig() {
|
||||
// TODO: Move this to a synchronous import once the repo root has NPM Workspaces.
|
||||
const { resolvePackage, MonoRepoRoot } = await import("@goauthentik/core/paths/node");
|
||||
|
||||
const distDirectory = resolvePath(MonoRepoRoot, "web", "dist", "sfe");
|
||||
const bootstrapDirectory = resolvePackage("bootstrap", import.meta);
|
||||
|
||||
const config = {
|
||||
input: "src/index.ts",
|
||||
output: {
|
||||
dir: distDirectory,
|
||||
format: "cjs",
|
||||
},
|
||||
context: "window",
|
||||
plugins: [
|
||||
copy({
|
||||
targets: [
|
||||
{
|
||||
src: resolvePath(bootstrapDirectory, "dist", "css", "bootstrap.min.css"),
|
||||
dest: distDirectory,
|
||||
},
|
||||
],
|
||||
}),
|
||||
resolve({ browser: true }),
|
||||
commonjs(),
|
||||
swc({
|
||||
swc: {
|
||||
jsc: {
|
||||
loose: false,
|
||||
externalHelpers: false,
|
||||
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
|
||||
keepClassNames: false,
|
||||
},
|
||||
minify: false,
|
||||
env: {
|
||||
targets: {
|
||||
edge: "17",
|
||||
ie: "11",
|
||||
},
|
||||
mode: "entry",
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
console.log("Preparing SFE package...");
|
||||
|
||||
export default createConfig;
|
@ -1,6 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"types": ["jquery"],
|
||||
"noEmit": true,
|
||||
"baseUrl": ".",
|
||||
"outDir": "out",
|
||||
"types": [],
|
||||
"esModuleInterop": true,
|
||||
"lib": ["DOM", "ES2015", "ES2017"]
|
||||
}
|
||||
|
42
web/packages/sfe/types/jquery.d.ts
vendored
Normal file
42
web/packages/sfe/types/jquery.d.ts
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file Minimal typings for jQuery.
|
||||
*
|
||||
* This file provides a small subset of the jQuery typings used in authentik's
|
||||
* Simplified Flow Executor.
|
||||
*
|
||||
* Unlike the `@types/jquery` package, this package does not expose `$` as a global
|
||||
* which causes issues with WebdriverIO.
|
||||
*/
|
||||
|
||||
declare module "jquery" {
|
||||
export function JQuery<TElement = HTMLElement>(selector: string): JQuery<TElement>;
|
||||
|
||||
export namespace JQuery {
|
||||
function ajax(options: JQueryAjaxSettings): void;
|
||||
}
|
||||
|
||||
export interface JQuery<TElement = HTMLElement> extends ArrayLike<TElement> {
|
||||
getElements(): TElement[];
|
||||
getElement(): TElement;
|
||||
getText(): string;
|
||||
submit(): void;
|
||||
html(html: string): JQuery<TElement>;
|
||||
addClass(className: string): JQuery<TElement>;
|
||||
removeClass(className: string): JQuery<TElement>;
|
||||
on(eventName: string, handler: (event: Event) => void): JQuery<TElement>;
|
||||
trigger(eventName: string): void;
|
||||
ajax(options: JQueryAjaxSettings): void;
|
||||
}
|
||||
|
||||
export interface JQueryAjaxSettings {
|
||||
url: string;
|
||||
type?: string;
|
||||
data?: string;
|
||||
contentType?: string;
|
||||
dataType?: string;
|
||||
success?: (data: unknown) => void;
|
||||
error?: (data: unknown) => void;
|
||||
}
|
||||
|
||||
export default JQuery;
|
||||
}
|
Reference in New Issue
Block a user