authup 1.0.0-beta.41 → 1.0.0-beta.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/packages/client-web/config/parse.ts","../src/packages/client-web/config/build.ts","../src/packages/client-web/config/read/env.ts","../src/packages/client-web/config/read/fs.ts","../src/packages/client-web/config/read/module.ts","../src/utils/line-breaks.ts","../src/utils/process-output.ts","../src/utils/stringify-object-args.ts","../src/utils/shell.ts","../src/constants.ts","../src/utils/modules-path.ts","../src/packages/constants.ts","../src/packages/client-web/module.ts","../src/packages/server-core/module.ts","../src/packages/execute.ts","../src/packages/normalize.ts","../src/module.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport zod from 'zod';\nimport type { ClientWebConfigInput } from './type';\n\nexport function parseClientWebConfig(input: unknown = {}) : ClientWebConfigInput {\n const schema = zod.object({\n port: zod.number().nonnegative().optional(),\n host: zod.string().optional(),\n apiUrl: zod.string().url().optional(),\n publicUrl: zod.string().url().optional(),\n });\n\n return schema.parse(input);\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { extendObject, makeURLPublicAccessible } from '@authup/kit';\nimport { defineGetter, dycraft } from 'dycraft';\nimport { parseClientWebConfig } from './parse';\nimport type { ClientWebConfig, ClientWebConfigInput } from './type';\n\nexport function buildClientWebConfig(raw: ClientWebConfigInput): ClientWebConfig {\n const config = dycraft({\n defaults: {\n port: 3000,\n host: '0.0.0.0',\n apiUrl: 'http://127.0.0.1:3001/',\n },\n getters: {\n publicUrl: defineGetter((\n context,\n ) => `http://${makeURLPublicAccessible(context.get('host'))}:${context.get('port')}/`),\n },\n });\n\n return extendObject(config, parseClientWebConfig(raw));\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { oneOf, read, readInt } from 'envix';\nimport type { ClientWebConfigInput } from '../type';\n\nexport function readClientWebConfigFromEnv() : ClientWebConfigInput {\n const config : ClientWebConfigInput = {};\n\n const port = oneOf([\n readInt('UI_PORT'),\n readInt('NITRO_UI_PORT'),\n readInt('NUXT_UI_PORT'),\n readInt('NUXT_PUBLIC_UI_PORT'),\n readInt('PORT'),\n readInt('NITRO_PORT'),\n readInt('NUXT_PORT'),\n readInt('NUXT_PUBLIC_PORT'),\n ]);\n\n if (typeof port !== 'undefined') {\n config.port = port;\n }\n\n const host = oneOf([\n read('HOST'),\n read('NITRO_HOST'),\n read('NUXT_HOST'),\n ]);\n\n if (host) {\n config.host = host;\n }\n\n const apiUrl = oneOf([\n read('API_URL'),\n read('NUXT_API_URL'),\n read('NUXT_PUBLIC_API_URL'),\n ]);\n\n if (apiUrl) {\n config.apiUrl = apiUrl;\n }\n\n const publicURL = oneOf([\n read('PUBLIC_URL'),\n read('NUXT_PUBLIC_URL'),\n read('NUXT_PUBLIC_PUBLIC_URL'),\n ]);\n\n if (publicURL) {\n config.publicUrl = publicURL;\n }\n\n return config;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { makeURLPublicAccessible } from '@authup/kit';\nimport { Container } from 'confinity';\nimport type { ClientWebConfigInput } from '../type';\n\nexport type ClientWebConfigReadFsOptions = {\n cwd?: string,\n file?: string | string[]\n};\n\nexport async function readClientWebConfigFromFS(options: ClientWebConfigReadFsOptions = {}) : Promise<ClientWebConfigInput> {\n const container = new Container({\n prefix: 'authup',\n cwd: options.cwd,\n });\n\n if (options.file) {\n await container.loadFile(options.file);\n } else {\n await container.load();\n }\n\n const clientRaw = container.get('client.web') || {};\n const serverRaw = container.get('server.core') || {};\n if (serverRaw) {\n if (\n !clientRaw.apiUrl &&\n typeof serverRaw.publicUrl === 'string'\n ) {\n clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.publicUrl);\n }\n\n if (\n !clientRaw.publicUrl &&\n typeof serverRaw.authorizeRedirectUrl === 'string'\n ) {\n clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.authorizeRedirectUrl);\n }\n }\n\n return clientRaw;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { merge } from 'smob';\nimport type { ClientWebConfigInput } from '../type';\nimport { readClientWebConfigFromEnv } from './env';\nimport type { ClientWebConfigReadFsOptions } from './fs';\nimport { readClientWebConfigFromFS } from './fs';\n\nexport type ClientWebConfigRawReadOptions = {\n fs?: boolean | ClientWebConfigReadFsOptions,\n env?: boolean,\n};\n\nexport async function readClientWebConfigRaw(options: ClientWebConfigRawReadOptions = {}) : Promise<ClientWebConfigInput> {\n if (options.fs && options.env) {\n const fsOptions = boolableToObject(options.fs);\n const fs = await readClientWebConfigFromFS(fsOptions);\n const env = readClientWebConfigFromEnv();\n\n return merge(env, fs);\n }\n\n if (options.fs) {\n const fsOptions = boolableToObject(options.fs);\n return readClientWebConfigFromFS(fsOptions);\n }\n\n if (options.env) {\n return readClientWebConfigFromEnv();\n }\n\n return {};\n}\n\nfunction boolableToObject<T>(input: T | boolean) : T {\n if (typeof input === 'boolean') {\n return {} as T;\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function removeLineBreaks(input: string) {\n return input.replace(/(\\r\\n|\\n|\\r)/gm, '');\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty, isObject } from '@authup/kit';\nimport { removeLineBreaks } from './line-breaks';\n\nexport function parseProcessOutputData(input: unknown) : string[] {\n if (typeof input !== 'string') {\n return [];\n }\n\n const lines = input\n .split(/\\r?\\n/)\n .filter((element) => element);\n\n const items : string[] = [];\n\n for (const line_ of lines) {\n const line = removeLineBreaks(line_).trim();\n if (line.length === 0) {\n continue;\n }\n\n try {\n const parsed = JSON.parse(line);\n\n if (\n isObject(parsed) &&\n hasOwnProperty(parsed, 'message') &&\n typeof parsed.message === 'string'\n ) {\n items.push(parsed.message);\n continue;\n }\n } catch {\n // no json :/\n }\n\n items.push(line);\n }\n\n return items;\n}\n","/*\n * Copyright (c) 2022-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function stringifyObjectArgs(ob: Record<string, any>) {\n const parts : string[] = [];\n\n const keys = Object.keys(ob);\n for (const key of keys) {\n parts.push(`--${key} ${ob[key]}`);\n }\n\n return parts.join(' ');\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ChildProcess } from 'node:child_process';\nimport { exec } from 'node:child_process';\nimport process from 'node:process';\nimport { parseProcessOutputData } from './process-output';\nimport { stringifyObjectArgs } from './stringify-object-args';\n\nexport type ShellCommandExecOptions = {\n configFile?: string,\n configDirectory?: string,\n\n env?: Record<string, string | undefined>,\n envFromProcess?: boolean,\n args?: Record<string, any>,\n logErrorStream?: (content: string) => void,\n logDataStream?: (content: string) => void\n};\n\nexport async function execShellCommand(\n command: string,\n ctx: ShellCommandExecOptions = {},\n) {\n return new Promise<ChildProcess>((resolve, reject) => {\n const childProcess = exec(`${command} ${stringifyObjectArgs(ctx.args || {})}`, {\n env: {\n PATH: process.env.PATH,\n ...(ctx.envFromProcess ? process.env : {}),\n ...(ctx.env ? ctx.env : {}),\n },\n });\n\n childProcess.on('error', (data) => {\n reject(data);\n });\n\n childProcess.on('spawn', () => {\n resolve(childProcess);\n });\n\n if (childProcess.stderr) {\n childProcess.stderr.setEncoding('utf-8');\n childProcess.stderr.on('data', (data) => {\n if (typeof data !== 'string' || data.length === 0) {\n return;\n }\n\n if (ctx.logErrorStream) {\n ctx.logErrorStream(data);\n }\n });\n }\n if (childProcess.stdout) {\n childProcess.stdout.on('data', (data) => {\n if (typeof data !== 'string' || data.length === 0) {\n return;\n }\n\n if (!ctx.logDataStream) {\n return;\n }\n\n const lines = parseProcessOutputData(data);\n for (const line of lines) {\n ctx.logDataStream(line);\n }\n });\n }\n });\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\n\nexport const PACKAGE_DIRECTORY = path.join(__dirname, '..');\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport process from 'node:process';\nimport findUpPackagePath from 'resolve-package-path';\nimport { PACKAGE_DIRECTORY } from '../constants';\n\nexport function findModulePath(module: string) : string | undefined {\n let modulePath = findUpPackagePath(module, PACKAGE_DIRECTORY);\n if (PACKAGE_DIRECTORY !== process.cwd()) {\n modulePath = findUpPackagePath(module, process.cwd());\n }\n\n if (!modulePath) {\n return undefined;\n }\n\n return modulePath;\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum PackageName {\n CLIENT_WEB = '@authup/client-web',\n SERVER_CORE = '@authup/server-core',\n}\n\nexport enum PackageID {\n CLIENT_WEB = 'client.web',\n SERVER_CORE = 'server.core',\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport consola from 'consola';\nimport type { ChildProcess } from 'node:child_process';\nimport path from 'node:path';\nimport { execShellCommand, findModulePath } from '../../utils';\nimport { PackageID, PackageName } from '../constants';\nimport type { Package, PackageExecuteOptions } from '../types';\nimport { buildClientWebConfig, readClientWebConfigRaw } from './config';\n\nexport class ClientWebPackage implements Package {\n async execute(command: string, options: PackageExecuteOptions = {}) : Promise<ChildProcess> {\n const shellCommand = await this.buildShellCommand();\n const env = await this.buildEnv({\n configDirectory: options.configDirectory,\n configFile: options.configFile,\n });\n\n return execShellCommand(shellCommand, {\n env,\n logDataStream(line) {\n consola.info(`${PackageID.CLIENT_WEB}: ${line}`);\n },\n logErrorStream(line) {\n consola.warn(`${PackageID.CLIENT_WEB}: ${line}`);\n },\n });\n }\n\n protected async buildShellCommand() {\n let shellCommand : string;\n\n const modulePath = findModulePath(PackageName.CLIENT_WEB);\n if (typeof modulePath === 'string') {\n const directory = path.dirname(modulePath);\n const outputPath = path.join(directory, '.output', 'server', 'index.mjs');\n shellCommand = `node ${outputPath}`;\n } else {\n shellCommand = `npx ${PackageName.CLIENT_WEB}`;\n }\n\n return shellCommand;\n }\n\n protected async buildEnv(ctx: PackageExecuteOptions) {\n const env : Record<string, any> = {};\n\n const configRaw = await readClientWebConfigRaw({\n fs: {\n file: ctx.configFile,\n cwd: ctx.configDirectory,\n },\n });\n const config = buildClientWebConfig(configRaw);\n\n if (config.host) {\n env.HOST = config.host;\n }\n\n if (config.port) {\n env.PORT = `${config.port}`;\n }\n\n if (config.apiUrl) {\n env.API_URL = config.apiUrl;\n }\n\n if (config.publicUrl) {\n env.PUBLIC_URL = config.publicUrl;\n }\n\n return this.extendEnvKeys(env);\n }\n\n extendEnvKeys(input: Record<string, string | undefined>) {\n const env : Record<string, any> = {};\n\n const keys = Object.keys(input);\n for (const key of keys) {\n env[key] = input[key];\n\n if (!key.match(/^(?:NUXT|NITRO)_.*$/)) {\n env[`NUXT_PUBLIC_${key}`] = input[key];\n }\n }\n\n return env;\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport consola from 'consola';\nimport path from 'node:path';\nimport type { ShellCommandExecOptions } from '../../utils';\nimport { execShellCommand, findModulePath } from '../../utils';\nimport { PackageID, PackageName } from '../constants';\nimport type { Package, PackageExecuteOptions } from '../types';\n\nexport class ServerCorePackage implements Package {\n async execute(command: string, options: PackageExecuteOptions = {}) {\n const shellCommand = await this.buildShellCommand(command, {\n configDirectory: options.configDirectory,\n configFile: options.configFile,\n });\n\n return execShellCommand(shellCommand, {\n logDataStream(line) {\n consola.info(`${PackageID.SERVER_CORE}: ${line}`);\n },\n logErrorStream(line) {\n consola.warn(`${PackageID.SERVER_CORE}: ${line}`);\n },\n });\n }\n\n protected async buildShellCommand(command: string, options: ShellCommandExecOptions) {\n const parts : string[] = [];\n\n const modulePath = findModulePath(PackageName.SERVER_CORE);\n if (typeof modulePath === 'string') {\n const directory = path.dirname(modulePath);\n const outputPath = path.join(directory, 'dist', 'cli.mjs');\n parts.push(`node ${outputPath}`);\n } else {\n parts.push(`npx ${PackageName.SERVER_CORE}`);\n }\n\n parts.push(command);\n\n if (options.configFile) {\n parts.push(`--configFile=${options.configFile}`);\n }\n\n if (options.configDirectory) {\n parts.push(`--configDirectory=${options.configDirectory}`);\n }\n\n return parts.join(' ');\n }\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ChildProcess } from 'node:child_process';\nimport { ClientWebPackage } from './client-web';\nimport { PackageID } from './constants';\nimport { ServerCorePackage } from './server-core';\nimport type { PackageExecuteOptions } from './types';\n\nexport async function executePackageCommand(\n pkg: string,\n command: string,\n options: PackageExecuteOptions = {},\n) : Promise<ChildProcess> {\n switch (pkg) {\n case PackageID.CLIENT_WEB: {\n const serverCore = new ClientWebPackage();\n\n return serverCore.execute(\n command,\n options,\n );\n }\n case PackageID.SERVER_CORE: {\n const serverCore = new ServerCorePackage();\n\n return serverCore.execute(\n command,\n options,\n );\n }\n }\n\n throw new Error(`The package ${pkg} is not supported.`);\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { PackageID } from './constants';\n\nexport function normalizePackageID(input: string) : `${PackageID}` | null {\n const value = input.trim().toLowerCase();\n\n switch (value) {\n case 'client.web':\n case 'client/web':\n case 'client-web': {\n return PackageID.CLIENT_WEB;\n }\n case 'server.core':\n case 'server/core':\n case 'server-core': {\n return PackageID.SERVER_CORE;\n }\n }\n\n return null;\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { defineCommand } from 'citty';\nimport type { ChildProcess } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { PackageID, executePackageCommand, normalizePackageID } from './packages';\n\nexport async function createCLIEntryPointCommand() {\n const pkgRaw = await fs.promises.readFile(\n path.join(process.cwd(), 'package.json'),\n { encoding: 'utf8' },\n );\n const pkg = JSON.parse(pkgRaw);\n\n return defineCommand({\n meta: {\n name: pkg.name,\n version: pkg.version,\n description: pkg.description,\n },\n args: {\n command: {\n type: 'positional',\n description: 'The command which should be forwarded to the package.',\n required: true,\n },\n package: {\n type: 'positional',\n description: 'The package, which should be targeted.',\n required: false,\n },\n configDirectory: {\n type: 'string',\n description: 'Config directory path',\n alias: 'cD',\n },\n configFile: {\n type: 'string',\n description: 'Name of one or more configuration files.',\n alias: 'cF',\n },\n },\n async run(ctx) {\n let packages = ctx.args.package ?\n ctx.args.package.split(',') :\n [];\n\n if (packages.length > 0) {\n packages = packages\n .map((pkg) => normalizePackageID(pkg))\n .filter((pkg) => Boolean(pkg))\n .map((pkg) => `${pkg}`);\n }\n\n if (packages.length === 0) {\n packages = Object.values(PackageID);\n }\n\n const promises : Promise<ChildProcess>[] = [];\n for (const package_ of packages) {\n promises.push(executePackageCommand(\n package_,\n ctx.args.command,\n {\n configFile: ctx.args.configFile,\n configDirectory: ctx.args.configDirectory,\n },\n ));\n }\n\n await Promise.all(promises);\n },\n });\n}\n","#!/usr/bin/env node\n\nimport { runMain } from 'citty';\nimport { createCLIEntryPointCommand } from './module';\n\nPromise.resolve()\n .then(() => createCLIEntryPointCommand())\n .then((command) => runMain(command));\n"],"mappings":";;;;;;;;;;;;;;;AAUA,SAAgB,qBAAqB,QAAiB,EAAE,EAAyB;AAQ7E,QAPe,IAAI,OAAO;EACtB,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC,UAAU;EAC3C,MAAM,IAAI,QAAQ,CAAC,UAAU;EAC7B,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,UAAU;EACrC,WAAW,IAAI,QAAQ,CAAC,KAAK,CAAC,UAAU;EAC3C,CAEY,CAAC,MAAM,MAAM;;;;ACN9B,SAAgB,qBAAqB,KAA4C;AAc7E,QAAO,aAbQ,QAAQ;EACnB,UAAU;GACN,MAAM;GACN,MAAM;GACN,QAAQ;GACX;EACD,SAAS,EACL,WAAW,cACP,YACC,UAAU,wBAAwB,QAAQ,IAAI,OAAO,CAAC,CAAC,GAAG,QAAQ,IAAI,OAAO,CAAC,GAAG,EACzF;EACJ,CAEyB,EAAE,qBAAqB,IAAI,CAAC;;;;AChB1D,SAAgB,6BAAoD;CAChE,MAAM,SAAgC,EAAE;CAExC,MAAM,OAAO,MAAM;EACf,QAAQ,UAAU;EAClB,QAAQ,gBAAgB;EACxB,QAAQ,eAAe;EACvB,QAAQ,sBAAsB;EAC9B,QAAQ,OAAO;EACf,QAAQ,aAAa;EACrB,QAAQ,YAAY;EACpB,QAAQ,mBAAmB;EAC9B,CAAC;AAEF,KAAI,OAAO,SAAS,YAChB,QAAO,OAAO;CAGlB,MAAM,OAAO,MAAM;EACf,KAAK,OAAO;EACZ,KAAK,aA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AAQ,GAAG,MAAM;AAG/B,OAAI,SAAS,WAAW,EACpB,YAAW,OAAO,OAAO,UAAU;GAGvC,MAAM,WAAqC,EAAE;AAC7C,QAAK,MAAM,YAAY,SACnB,UAAS,KAAK,sBACV,UACA,IAAI,KAAK,SACT;IACI,YAAY,IAAI,KAAK;IACrB,iBAAiB,IAAI,KAAK;IAC7B,CACJ,CAAC;AAGN,SAAM,QAAQ,IAAI,SAAS;;EAElC,CAAC;;;;AC1EN,QAAQ,SAAS,CACZ,WAAW,4BAA4B,CAAC,CACxC,MAAM,YAAY,QAAQ,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/packages/client-web/config/parse.ts","../src/packages/client-web/config/build.ts","../src/packages/client-web/config/read/env.ts","../src/packages/client-web/config/read/fs.ts","../src/packages/client-web/config/read/module.ts","../src/utils/line-breaks.ts","../src/utils/process-output.ts","../src/utils/stringify-object-args.ts","../src/utils/shell.ts","../src/constants.ts","../src/utils/modules-path.ts","../src/packages/constants.ts","../src/packages/client-web/module.ts","../src/packages/server-core/module.ts","../src/packages/execute.ts","../src/packages/normalize.ts","../src/module.ts","../src/index.ts"],"sourcesContent":["/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport zod from 'zod';\nimport type { ClientWebConfigInput } from './type';\n\nexport function parseClientWebConfig(input: unknown = {}) : ClientWebConfigInput {\n const schema = zod.object({\n port: zod.number().nonnegative().optional(),\n host: zod.string().optional(),\n apiUrl: zod.string().url().optional(),\n publicUrl: zod.string().url().optional(),\n });\n\n return schema.parse(input);\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { extendObject, makeURLPublicAccessible } from '@authup/kit';\nimport { defineGetter, dycraft } from 'dycraft';\nimport { parseClientWebConfig } from './parse';\nimport type { ClientWebConfig, ClientWebConfigInput } from './type';\n\nexport function buildClientWebConfig(raw: ClientWebConfigInput): ClientWebConfig {\n const config = dycraft({\n defaults: {\n port: 3000,\n host: '0.0.0.0',\n apiUrl: 'http://127.0.0.1:3001/',\n },\n getters: {\n publicUrl: defineGetter((\n context,\n ) => `http://${makeURLPublicAccessible(context.get('host'))}:${context.get('port')}/`),\n },\n });\n\n return extendObject(config, parseClientWebConfig(raw));\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { oneOf, read, readInt } from 'envix';\nimport type { ClientWebConfigInput } from '../type';\n\nexport function readClientWebConfigFromEnv() : ClientWebConfigInput {\n const config : ClientWebConfigInput = {};\n\n const port = oneOf([\n readInt('UI_PORT'),\n readInt('NITRO_UI_PORT'),\n readInt('NUXT_UI_PORT'),\n readInt('NUXT_PUBLIC_UI_PORT'),\n readInt('PORT'),\n readInt('NITRO_PORT'),\n readInt('NUXT_PORT'),\n readInt('NUXT_PUBLIC_PORT'),\n ]);\n\n if (typeof port !== 'undefined') {\n config.port = port;\n }\n\n const host = oneOf([\n read('HOST'),\n read('NITRO_HOST'),\n read('NUXT_HOST'),\n ]);\n\n if (host) {\n config.host = host;\n }\n\n const apiUrl = oneOf([\n read('API_URL'),\n read('NUXT_API_URL'),\n read('NUXT_PUBLIC_API_URL'),\n ]);\n\n if (apiUrl) {\n config.apiUrl = apiUrl;\n }\n\n const publicURL = oneOf([\n read('PUBLIC_URL'),\n read('NUXT_PUBLIC_URL'),\n read('NUXT_PUBLIC_PUBLIC_URL'),\n ]);\n\n if (publicURL) {\n config.publicUrl = publicURL;\n }\n\n return config;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { makeURLPublicAccessible } from '@authup/kit';\nimport { Container } from 'confinity';\nimport type { ClientWebConfigInput } from '../type';\n\nexport type ClientWebConfigReadFsOptions = {\n cwd?: string,\n file?: string | string[]\n};\n\nexport async function readClientWebConfigFromFS(options: ClientWebConfigReadFsOptions = {}) : Promise<ClientWebConfigInput> {\n const container = new Container({\n prefix: 'authup',\n cwd: options.cwd,\n });\n\n if (options.file) {\n await container.loadFile(options.file);\n } else {\n await container.load();\n }\n\n const clientRaw = container.get('client.web') || {};\n const serverRaw = container.get('server.core') || {};\n if (serverRaw) {\n if (\n !clientRaw.apiUrl &&\n typeof serverRaw.publicUrl === 'string'\n ) {\n clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.publicUrl);\n }\n\n if (\n !clientRaw.publicUrl &&\n typeof serverRaw.authorizeRedirectUrl === 'string'\n ) {\n clientRaw.apiUrl = makeURLPublicAccessible(serverRaw.authorizeRedirectUrl);\n }\n }\n\n return clientRaw;\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { merge } from 'smob';\nimport type { ClientWebConfigInput } from '../type';\nimport { readClientWebConfigFromEnv } from './env';\nimport type { ClientWebConfigReadFsOptions } from './fs';\nimport { readClientWebConfigFromFS } from './fs';\n\nexport type ClientWebConfigRawReadOptions = {\n fs?: boolean | ClientWebConfigReadFsOptions,\n env?: boolean,\n};\n\nexport async function readClientWebConfigRaw(options: ClientWebConfigRawReadOptions = {}) : Promise<ClientWebConfigInput> {\n if (options.fs && options.env) {\n const fsOptions = boolableToObject(options.fs);\n const fs = await readClientWebConfigFromFS(fsOptions);\n const env = readClientWebConfigFromEnv();\n\n return merge(env, fs);\n }\n\n if (options.fs) {\n const fsOptions = boolableToObject(options.fs);\n return readClientWebConfigFromFS(fsOptions);\n }\n\n if (options.env) {\n return readClientWebConfigFromEnv();\n }\n\n return {};\n}\n\nfunction boolableToObject<T>(input: T | boolean) : T {\n if (typeof input === 'boolean') {\n return {} as T;\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function removeLineBreaks(input: string) {\n return input.replace(/(\\r\\n|\\n|\\r)/gm, '');\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty, isObject } from '@authup/kit';\nimport { removeLineBreaks } from './line-breaks';\n\nexport function parseProcessOutputData(input: unknown) : string[] {\n if (typeof input !== 'string') {\n return [];\n }\n\n const lines = input\n .split(/\\r?\\n/)\n .filter((element) => element);\n\n const items : string[] = [];\n\n for (const line_ of lines) {\n const line = removeLineBreaks(line_).trim();\n if (line.length === 0) {\n continue;\n }\n\n try {\n const parsed = JSON.parse(line);\n\n if (\n isObject(parsed) &&\n hasOwnProperty(parsed, 'message') &&\n typeof parsed.message === 'string'\n ) {\n items.push(parsed.message);\n continue;\n }\n } catch {\n // no json :/\n }\n\n items.push(line);\n }\n\n return items;\n}\n","/*\n * Copyright (c) 2022-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function stringifyObjectArgs(ob: Record<string, any>) {\n const parts : string[] = [];\n\n const keys = Object.keys(ob);\n for (const key of keys) {\n parts.push(`--${key} ${ob[key]}`);\n }\n\n return parts.join(' ');\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ChildProcess } from 'node:child_process';\nimport { exec } from 'node:child_process';\nimport process from 'node:process';\nimport { parseProcessOutputData } from './process-output';\nimport { stringifyObjectArgs } from './stringify-object-args';\n\nexport type ShellCommandExecOptions = {\n configFile?: string,\n configDirectory?: string,\n\n env?: Record<string, string | undefined>,\n envFromProcess?: boolean,\n args?: Record<string, any>,\n logErrorStream?: (content: string) => void,\n logDataStream?: (content: string) => void\n};\n\nexport async function execShellCommand(\n command: string,\n ctx: ShellCommandExecOptions = {},\n) {\n return new Promise<ChildProcess>((resolve, reject) => {\n const childProcess = exec(`${command} ${stringifyObjectArgs(ctx.args || {})}`, {\n env: {\n PATH: process.env.PATH,\n ...(ctx.envFromProcess ? process.env : {}),\n ...(ctx.env ? ctx.env : {}),\n },\n });\n\n childProcess.on('error', (data) => {\n reject(data);\n });\n\n childProcess.on('spawn', () => {\n resolve(childProcess);\n });\n\n if (childProcess.stderr) {\n childProcess.stderr.setEncoding('utf-8');\n childProcess.stderr.on('data', (data) => {\n if (typeof data !== 'string' || data.length === 0) {\n return;\n }\n\n if (ctx.logErrorStream) {\n ctx.logErrorStream(data);\n }\n });\n }\n if (childProcess.stdout) {\n childProcess.stdout.on('data', (data) => {\n if (typeof data !== 'string' || data.length === 0) {\n return;\n }\n\n if (!ctx.logDataStream) {\n return;\n }\n\n const lines = parseProcessOutputData(data);\n for (const line of lines) {\n ctx.logDataStream(line);\n }\n });\n }\n });\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\n\nexport const PACKAGE_DIRECTORY = path.join(__dirname, '..');\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport process from 'node:process';\nimport findUpPackagePath from 'resolve-package-path';\nimport { PACKAGE_DIRECTORY } from '../constants';\n\nexport function findModulePath(module: string) : string | undefined {\n let modulePath = findUpPackagePath(module, PACKAGE_DIRECTORY);\n if (PACKAGE_DIRECTORY !== process.cwd()) {\n modulePath = findUpPackagePath(module, process.cwd());\n }\n\n if (!modulePath) {\n return undefined;\n }\n\n return modulePath;\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum PackageName {\n CLIENT_WEB = '@authup/client-web',\n SERVER_CORE = '@authup/server-core',\n}\n\nexport enum PackageID {\n CLIENT_WEB = 'client.web',\n SERVER_CORE = 'server.core',\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport consola from 'consola';\nimport type { ChildProcess } from 'node:child_process';\nimport path from 'node:path';\nimport { execShellCommand, findModulePath } from '../../utils';\nimport { PackageID, PackageName } from '../constants';\nimport type { Package, PackageExecuteOptions } from '../types';\nimport { buildClientWebConfig, readClientWebConfigRaw } from './config';\n\nexport class ClientWebPackage implements Package {\n async execute(command: string, options: PackageExecuteOptions = {}) : Promise<ChildProcess> {\n const shellCommand = await this.buildShellCommand();\n const env = await this.buildEnv({\n configDirectory: options.configDirectory,\n configFile: options.configFile,\n });\n\n return execShellCommand(shellCommand, {\n env,\n logDataStream(line) {\n consola.info(`${PackageID.CLIENT_WEB}: ${line}`);\n },\n logErrorStream(line) {\n consola.warn(`${PackageID.CLIENT_WEB}: ${line}`);\n },\n });\n }\n\n protected async buildShellCommand() {\n let shellCommand : string;\n\n const modulePath = findModulePath(PackageName.CLIENT_WEB);\n if (typeof modulePath === 'string') {\n const directory = path.dirname(modulePath);\n const outputPath = path.join(directory, '.output', 'server', 'index.mjs');\n shellCommand = `node ${outputPath}`;\n } else {\n shellCommand = `npx ${PackageName.CLIENT_WEB}`;\n }\n\n return shellCommand;\n }\n\n protected async buildEnv(ctx: PackageExecuteOptions) {\n const env : Record<string, any> = {};\n\n const configRaw = await readClientWebConfigRaw({\n fs: {\n file: ctx.configFile,\n cwd: ctx.configDirectory,\n },\n });\n const config = buildClientWebConfig(configRaw);\n\n if (config.host) {\n env.HOST = config.host;\n }\n\n if (config.port) {\n env.PORT = `${config.port}`;\n }\n\n if (config.apiUrl) {\n env.API_URL = config.apiUrl;\n }\n\n if (config.publicUrl) {\n env.PUBLIC_URL = config.publicUrl;\n }\n\n return this.extendEnvKeys(env);\n }\n\n extendEnvKeys(input: Record<string, string | undefined>) {\n const env : Record<string, any> = {};\n\n const keys = Object.keys(input);\n for (const key of keys) {\n env[key] = input[key];\n\n if (!key.match(/^(?:NUXT|NITRO)_.*$/)) {\n env[`NUXT_PUBLIC_${key}`] = input[key];\n }\n }\n\n return env;\n }\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport consola from 'consola';\nimport path from 'node:path';\nimport type { ShellCommandExecOptions } from '../../utils';\nimport { execShellCommand, findModulePath } from '../../utils';\nimport { PackageID, PackageName } from '../constants';\nimport type { Package, PackageExecuteOptions } from '../types';\n\nexport class ServerCorePackage implements Package {\n async execute(command: string, options: PackageExecuteOptions = {}) {\n const shellCommand = await this.buildShellCommand(command, {\n configDirectory: options.configDirectory,\n configFile: options.configFile,\n });\n\n return execShellCommand(shellCommand, {\n logDataStream(line) {\n consola.info(`${PackageID.SERVER_CORE}: ${line}`);\n },\n logErrorStream(line) {\n consola.warn(`${PackageID.SERVER_CORE}: ${line}`);\n },\n });\n }\n\n protected async buildShellCommand(command: string, options: ShellCommandExecOptions) {\n const parts : string[] = [];\n\n const modulePath = findModulePath(PackageName.SERVER_CORE);\n if (typeof modulePath === 'string') {\n const directory = path.dirname(modulePath);\n const outputPath = path.join(directory, 'dist', 'cli.mjs');\n parts.push(`node ${outputPath}`);\n } else {\n parts.push(`npx ${PackageName.SERVER_CORE}`);\n }\n\n parts.push(command);\n\n if (options.configFile) {\n parts.push(`--configFile=${options.configFile}`);\n }\n\n if (options.configDirectory) {\n parts.push(`--configDirectory=${options.configDirectory}`);\n }\n\n return parts.join(' ');\n }\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ChildProcess } from 'node:child_process';\nimport { ClientWebPackage } from './client-web';\nimport { PackageID } from './constants';\nimport { ServerCorePackage } from './server-core';\nimport type { PackageExecuteOptions } from './types';\n\nexport async function executePackageCommand(\n pkg: string,\n command: string,\n options: PackageExecuteOptions = {},\n) : Promise<ChildProcess> {\n switch (pkg) {\n case PackageID.CLIENT_WEB: {\n const serverCore = new ClientWebPackage();\n\n return serverCore.execute(\n command,\n options,\n );\n }\n case PackageID.SERVER_CORE: {\n const serverCore = new ServerCorePackage();\n\n return serverCore.execute(\n command,\n options,\n );\n }\n }\n\n throw new Error(`The package ${pkg} is not supported.`);\n}\n","/*\n * Copyright (c) 2024-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { PackageID } from './constants';\n\nexport function normalizePackageID(input: string) : `${PackageID}` | null {\n const value = input.trim().toLowerCase();\n\n switch (value) {\n case 'client.web':\n case 'client/web':\n case 'client-web': {\n return PackageID.CLIENT_WEB;\n }\n case 'server.core':\n case 'server/core':\n case 'server-core': {\n return PackageID.SERVER_CORE;\n }\n }\n\n return null;\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { defineCommand } from 'citty';\nimport type { ChildProcess } from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport { PackageID, executePackageCommand, normalizePackageID } from './packages';\n\nexport async function createCLIEntryPointCommand() {\n const pkgRaw = await fs.promises.readFile(\n path.join(process.cwd(), 'package.json'),\n { encoding: 'utf8' },\n );\n const pkg = JSON.parse(pkgRaw);\n\n return defineCommand({\n meta: {\n name: pkg.name,\n version: pkg.version,\n description: pkg.description,\n },\n args: {\n command: {\n type: 'positional',\n description: 'The command which should be forwarded to the package.',\n required: true,\n },\n package: {\n type: 'positional',\n description: 'The package, which should be targeted.',\n required: false,\n },\n configDirectory: {\n type: 'string',\n description: 'Config directory path',\n alias: 'cD',\n },\n configFile: {\n type: 'string',\n description: 'Name of one or more configuration files.',\n alias: 'cF',\n },\n },\n async run(ctx) {\n let packages = ctx.args.package ?\n ctx.args.package.split(',') :\n [];\n\n if (packages.length > 0) {\n packages = packages\n .map((pkg) => normalizePackageID(pkg))\n .filter((pkg) => Boolean(pkg))\n .map((pkg) => `${pkg}`);\n }\n\n if (packages.length === 0) {\n packages = Object.values(PackageID);\n }\n\n const promises : Promise<ChildProcess>[] = [];\n for (const package_ of packages) {\n promises.push(executePackageCommand(\n package_,\n ctx.args.command,\n {\n configFile: ctx.args.configFile,\n configDirectory: ctx.args.configDirectory,\n },\n ));\n }\n\n await Promise.all(promises);\n },\n });\n}\n","#!/usr/bin/env node\n\nimport { runMain } from 'citty';\nimport { createCLIEntryPointCommand } from './module';\n\nPromise.resolve()\n .then(() => createCLIEntryPointCommand())\n .then((command) => runMain(command));\n"],"mappings":";;;;;;;;;;;;;;;AAUA,SAAgB,qBAAqB,QAAiB,CAAC,GAA0B;CAQ7E,OAPe,IAAI,OAAO;EACtB,MAAM,IAAI,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS;EAC1C,MAAM,IAAI,OAAO,CAAC,CAAC,SAAS;EAC5B,QAAQ,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;EACpC,WAAW,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CAC3C,CAEY,CAAC,CAAC,MAAM,KAAK;AAC7B;;;ACPA,SAAgB,qBAAqB,KAA4C;CAc7E,OAAO,aAbQ,QAAQ;EACnB,UAAU;GACN,MAAM;GACN,MAAM;GACN,QAAQ;EACZ;EACA,SAAS,EACL,WAAW,cACP,YACC,UAAU,wBAAwB,QAAQ,IAAI,MAAM,CAAC,EAAE,GAAG,QAAQ,IAAI,MAAM,EAAE,EAAE,EACzF;CACJ,CAEyB,GAAG,qBAAqB,GAAG,CAAC;AACzD;;;ACjBA,SAAgB,6BAAoD;CAChE,MAAM,SAAgC,C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F,MAAM,IAAI;GACV,SAAS,IAAI;GACb,aAAa,IAAI;EACrB;EACA,MAAM;GACF,SAAS;IACL,MAAM;IACN,aAAa;IACb,UAAU;GACd;GACA,SAAS;IACL,MAAM;IACN,aAAa;IACb,UAAU;GACd;GACA,iBAAiB;IACb,MAAM;IACN,aAAa;IACb,OAAO;GACX;GACA,YAAY;IACR,MAAM;IACN,aAAa;IACb,OAAO;GACX;EACJ;EACA,MAAM,IAAI,KAAK;GACX,IAAI,WAAW,IAAI,KAAK,UACpB,IAAI,KAAK,QAAQ,MAAM,GAAG,IAC1B,CAAC;GAEL,IAAI,SAAS,SAAS,GAClB,WAAW,SACN,KAAK,QAAQ,mBAAmB,GAAG,CAAC,CAAC,CACrC,QAAQ,QAAQ,QAAQ,GAAG,CAAC,CAAC,CAC7B,KAAK,QAAQ,GAAG,KAAK;GAG9B,IAAI,SAAS,WAAW,GACpB,WAAW,OAAO,OAAO,SAAS;GAGtC,MAAM,WAAqC,CAAC;GAC5C,KAAK,MAAM,YAAY,UACnB,SAAS,KAAK,sBACV,UACA,IAAI,KAAK,SACT;IACI,YAAY,IAAI,KAAK;IACrB,iBAAiB,IAAI,KAAK;GAC9B,CACJ,CAAC;GAGL,MAAM,QAAQ,IAAI,QAAQ;EAC9B;CACJ,CAAC;AACL;;;AC3EA,QAAQ,QAAQ,CAAC,CACZ,WAAW,2BAA2B,CAAC,CAAC,CACxC,MAAM,YAAY,QAAQ,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "authup",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.41",
4
+ "version": "1.0.0-beta.44",
5
5
  "description": "This is the CLI for the authup ecosystem.",
6
6
  "license": "Apache-2.0",
7
7
  "exports": {
@@ -54,10 +54,10 @@
54
54
  },
55
55
  "homepage": "https://github.com/authup/authup#readme",
56
56
  "dependencies": {
57
- "@authup/client-web": "^1.0.0-beta.41",
58
- "@authup/kit": "^1.0.0-beta.41",
59
- "@authup/core-kit": "^1.0.0-beta.41",
60
- "@authup/server-core": "^1.0.0-beta.41",
57
+ "@authup/client-web": "^1.0.0-beta.44",
58
+ "@authup/kit": "^1.0.0-beta.44",
59
+ "@authup/core-kit": "^1.0.0-beta.44",
60
+ "@authup/server-core": "^1.0.0-beta.44",
61
61
  "citty": "^0.2.2",
62
62
  "chalk": "^5.6.2",
63
63
  "confinity": "^1.0.0-beta.1",