Problem: the hexagonal refactor churns the backend tree for nine more phases; the UI delivery stack (web/ SPA, cmd/desktop Wails wrapper, compose/web image) must move to its own repo first so doc/layout rewrites land once on a backend-only tree. Change: - New repo git.hubris.network/dtoro/oikos-web (v0.33.0): web/, desktop/ (updateURL repointed to oikos-web releases), compose/, own CI (web + desktop jobs), own deploy script (CI-green gate, TOCTOU guard, version-tagged images, prune-to-3), own webhook receiver on :9798 + launchd unit, own compose project publishing the same 8091:80. - Cutover executed on mac-mini in order: oikos stack's web service stopped+removed, oikos-web project brought up on 8091; outer Caddy untouched (targets the published port) — serving + Authentik flow + /wails 404 quirk verified post-cutover. - Stripped from oikos: web/, cmd/desktop/, compose/web/, desktop CI workflow, ci.yml web job, Makefile ui/desktop/desktop-package/install targets, the compose web service, oikos-web from deploy.sh's fallback prune list; wails + go-keyring dropped from go.mod, vendor synced. - README / CONTRIBUTING / AGENTS.md / .agents dev+operations docs now point at the new repo; mbse + mascot design docs carry a path note. Risk: production SPA serving depends on the new pipeline now; rollback is versioned-image re-up of the old web service from a pre-split checkout (port 8091). Desktop builds installed before the split still check dtoro/oikos releases — one manual reinstall, noted in the oikos-web release notes. Verification: go vet, make test (race), make generate-check, golangci (no new findings; baseline down 400→365); post-cutover curls — localhost:8091 200, /wails/runtime.js 404, outer Caddy 302 Authentik.
97 lines
3.0 KiB
JavaScript
97 lines
3.0 KiB
JavaScript
/**
|
|
* @fileoverview Common helpers for naming of plugins, formatters and configs
|
|
*/
|
|
|
|
const NAMESPACE_REGEX = /^@.*\//iu;
|
|
|
|
/**
|
|
* Brings package name to correct format based on prefix
|
|
* @param {string} name The name of the package.
|
|
* @param {string} prefix Can be either "eslint-plugin", "eslint-config" or "eslint-formatter"
|
|
* @returns {string} Normalized name of the package
|
|
* @private
|
|
*/
|
|
function normalizePackageName(name, prefix) {
|
|
let normalizedName = name;
|
|
|
|
/**
|
|
* On Windows, name can come in with Windows slashes instead of Unix slashes.
|
|
* Normalize to Unix first to avoid errors later on.
|
|
* https://github.com/eslint/eslint/issues/5644
|
|
*/
|
|
if (normalizedName.includes("\\")) {
|
|
normalizedName = normalizedName.replace(/\\/gu, "/");
|
|
}
|
|
|
|
if (normalizedName.charAt(0) === "@") {
|
|
|
|
/**
|
|
* it's a scoped package
|
|
* package name is the prefix, or just a username
|
|
*/
|
|
const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"),
|
|
scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u");
|
|
|
|
if (scopedPackageShortcutRegex.test(normalizedName)) {
|
|
normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
|
|
} else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) {
|
|
|
|
/**
|
|
* for scoped packages, insert the prefix after the first / unless
|
|
* the path is already @scope/eslint or @scope/eslint-xxx-yyy
|
|
*/
|
|
normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`);
|
|
}
|
|
} else if (!normalizedName.startsWith(`${prefix}-`)) {
|
|
normalizedName = `${prefix}-${normalizedName}`;
|
|
}
|
|
|
|
return normalizedName;
|
|
}
|
|
|
|
/**
|
|
* Removes the prefix from a fullname.
|
|
* @param {string} fullname The term which may have the prefix.
|
|
* @param {string} prefix The prefix to remove.
|
|
* @returns {string} The term without prefix.
|
|
*/
|
|
function getShorthandName(fullname, prefix) {
|
|
if (fullname[0] === "@") {
|
|
let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname);
|
|
|
|
if (matchResult) {
|
|
return matchResult[1];
|
|
}
|
|
|
|
matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname);
|
|
if (matchResult) {
|
|
return `${matchResult[1]}/${matchResult[2]}`;
|
|
}
|
|
} else if (fullname.startsWith(`${prefix}-`)) {
|
|
return fullname.slice(prefix.length + 1);
|
|
}
|
|
|
|
return fullname;
|
|
}
|
|
|
|
/**
|
|
* Gets the scope (namespace) of a term.
|
|
* @param {string} term The term which may have the namespace.
|
|
* @returns {string} The namespace of the term if it has one.
|
|
*/
|
|
function getNamespaceFromTerm(term) {
|
|
const match = term.match(NAMESPACE_REGEX);
|
|
|
|
return match ? match[0] : "";
|
|
}
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Public Interface
|
|
//------------------------------------------------------------------------------
|
|
|
|
export {
|
|
normalizePackageName,
|
|
getShorthandName,
|
|
getNamespaceFromTerm
|
|
};
|