UNPKG

@storm-software/cloudflare-tools

Version:

A Nx plugin package that contains various executors, generators, and utilities that assist in managing Cloudflare services.

94 lines (87 loc) 3.14 kB
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ../package-constants/src/tags.ts var ProjectTagConstants = { Language: { TAG_ID: "language", TYPESCRIPT: "typescript", RUST: "rust" }, ProjectType: { TAG_ID: "type", LIBRARY: "library", APPLICATION: "application" }, ProjectLinking: { TAG_ID: "project-linking", REFERENCE: "reference", ALIAS: "alias" }, DistStyle: { TAG_ID: "dist-style", NORMAL: "normal", CLEAN: "clean" }, Provider: { TAG_ID: "provider" }, Platform: { TAG_ID: "platform", NODE: "node", BROWSER: "browser", NEUTRAL: "neutral", WORKER: "worker" }, Registry: { TAG_ID: "registry", CARGO: "cargo", NPM: "npm", CONTAINER: "container", CYCLONE: "cyclone" }, Plugin: { TAG_ID: "plugin" }, Builder: { TAG_ID: "builder", TSC: "tsc", TSUP: "tsup", TSDOWN: "tsdown", VITE: "vite", ROLLDOWN: "rolldown" } }; var formatProjectTag = (variant, value) => { return `${variant}:${value}`; }; var hasProjectTag = (project, variant) => { project.tags = _nullishCoalesce(project.tags, () => ( [])); const prefix = formatProjectTag(variant, ""); return project.tags.some( (tag) => tag.startsWith(prefix) && tag.length > prefix.length ); }; var getProjectTag = (project, variant) => { if (!hasProjectTag(project, variant)) { return void 0; } project.tags = _nullishCoalesce(project.tags, () => ( [])); const prefix = formatProjectTag(variant, ""); const tag = project.tags.find((tag2) => tag2.startsWith(prefix)); return _optionalChain([tag, 'optionalAccess', _ => _.replace, 'call', _2 => _2(prefix, "")]); }; var isEqualProjectTag = (project, variant, value) => { const tag = getProjectTag(project, variant); return !!(tag && _optionalChain([tag, 'optionalAccess', _3 => _3.toUpperCase, 'call', _4 => _4()]) === value.toUpperCase()); }; // ../workspace-tools/src/utils/project-tags.ts var addProjectTag = (project, variant, value, options = { overwrite: false }) => { project.tags = _nullishCoalesce(project.tags, () => ( [])); if (options.overwrite || !hasProjectTag(project, variant)) { project.tags = project.tags.filter( (tag) => !tag.startsWith(formatProjectTag(variant, "")) ); project.tags.push(formatProjectTag(variant, value)); } }; exports.ProjectTagConstants = ProjectTagConstants; exports.isEqualProjectTag = isEqualProjectTag; exports.addProjectTag = addProjectTag;