repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
obsidian-sets
github_2023
Canna71
typescript
escapeURI
function escapeURI(e: string) { // eslint-disable-next-line no-control-regex return e.replace(/[\\\x00\x08\x0B\x0C\x0E-\x1F ]/g, function (e) { return encodeURIComponent(e); }); }
// define a scope type that could be "type", "collection", "folder" or "all"
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Data/VaultDB.ts#L53-L58
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
VaultDB.execute
execute(query: Query): QueryResult { if (!this.dbInitialized) { throw Error("VaultDB not initialized yet"); } const startTime = Date.now(); const archetypeFolder = this.getArchetypeFolder(); const types = archetypeFolder?.children || []; //@ts-ignore /...
// }
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Data/VaultDB.ts#L142-L203
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
VaultDB.getTypeNames
getTypeNames(): string[] { return this.getTypes() .map((f) => { const cache = this.app.metadataCache.getFileCache(f); if (cache) { return cache.frontmatter?.[ this.plugin.settings.typeAttributeKey ] as st...
// frontmater of the TFiles returned by getTypes
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Data/VaultDB.ts#L516-L527
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
VaultDB.getCollectionNames
getCollectionNames(): string[] { return this.getCollections() .map((f) => { return f.file.basename; }) .filter((t) => t !== undefined) as string[]; }
// returns all the available collections
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Data/VaultDB.ts#L530-L536
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
stableCmp
const stableCmp = (a, b) => { const order = cmp!(a[0], b[0]); if (order != 0) return order; return a[1] - b[1]; }
// Create a stable comparator that uses the original index to break ties
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Utils/stableSort.ts#L11-L15
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
NameValueSuggestModal.getSuggestions
getSuggestions(query: string): { name: string, value: string }[] { return this.data.filter((item) => item.name.toLowerCase().includes(query.toLowerCase()) ); }
// Returns all available suggestions.
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/NameValueSuggestModal.tsx#L19-L23
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
NameValueSuggestModal.renderSuggestion
renderSuggestion(item: { name: string, value: string }, el: HTMLElement) { el.createEl("div", { text: item.name }); }
// Renders each suggestion item.
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/NameValueSuggestModal.tsx#L26-L28
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
NameValueSuggestModal.onChooseSuggestion
onChooseSuggestion(item: { name: string, value: string }) { this.onChoice(item); }
// Perform action on the selected suggestion.
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/NameValueSuggestModal.tsx#L31-L33
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
isValid
const isValid = () => { // if the scopeType is "type" then the scopeSpecifier should be a valid type if (scopeType() === "type") { return types().includes(scopeSpecifier()); } // if the scopeType is "collection" then the scopeSpecifier should be a valid collection ...
// the isValid function should return true if the scope is valid
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/ScopeEditor.tsx#L66-L89
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
AttributeModal.getSuggestions
getSuggestions(query: string): PropertyData[] { query = query.toLowerCase(); const pds = getPropertyData(this.app); return pds.filter(pd => pd.name && pd.name.length && pd.name.toLowerCase().includes(query)) .filter(pd => !this._filter || this._filt...
// Returns all available suggestions.
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/AttributeModal.tsx#L15-L25
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
AttributeModal.renderSuggestion
renderSuggestion(prop: PropertyData, el: HTMLElement) { el.createEl("div", { text: prop.name }); const details = el.createEl("div" , {cls: "metadata-property-key"}); const icon = details.createEl("div", {cls: "metadata-property-icon"}) setIcon(icon, prop.typeIcon || "file-question"); ...
// Renders each suggestion item.
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/AttributeModal.tsx#L28-L36
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
AttributeModal.onChooseSuggestion
onChooseSuggestion(prop: PropertyData, evt: MouseEvent | KeyboardEvent) { this._onSelect && this._onSelect(prop); }
// Perform action on the selected suggestion.
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/AttributeModal.tsx#L39-L41
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
dynamicValues
const dynamicValues = () => { if(prop()?.typeKey){ const dv = getDynamicValuesForType(prop()!.typeKey) return dv; } return []; }
// const [operators, setOperators] = createSignal(getOperators());
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/ClauseEditor.tsx#L44-L50
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
onClickProp
const onClickProp = (e: MouseEvent) => { const am = new AttributeModal(app!,(pd:PropertyData)=>{ // const type = pd.typeKey; // setOperators(_ops); // setProp(pd); // setOperator(_ops[0]); const attr = db.getAttributeDefinition(pd.key); co...
// app.metadataTypeManager.properties
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/ClauseEditor.tsx#L63-L79
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
limitedResults
const limitedResults = () => { const topResults = top(); const limitedResults = limitResults(props.queryResult, topResults, getNewFile()); return limitedResults; }
// if newFile is set, put the new file in the first row
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/CodeBlock.tsx#L30-L35
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
moreItemsAvailable
const moreItemsAvailable = () => { return limitedResults().total > limitedResults().data.length; }
// function that returns if more items were available
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/CodeBlock.tsx#L40-L42
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
Collapsible
const Collapsible: Component<CollapsibleProps> = (props) => { let collapse: HTMLDivElement; const [collapsed, setCollapsed] = createSignal(!!props.isCollapsed); onMount(() => { // setIcon(collapse, "chevron-down"); setIcon(collapse, "right-triangle"); }); const onToggle = () => ...
// implements a solidjs collapsible component
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/Collapsible.tsx#L13-L53
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
onSave
const onSave = () => { save(); props.exit(); };
// const [activeItem, setActiveItem] = createSignal<any>(null);
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/FieldSelect.tsx#L39-L42
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
available
const available = () => { const pd = getPropertyData(app); return pd.filter(pd => !(definition().fields || []).includes(pd.key)) .filter(pd => pd.name.toLowerCase().includes(keyword().toLowerCase())); };
// const update = () => {
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/FieldSelect.tsx#L48-L52
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
isEditFile
const isEditFile = () => { if (!editable()) return false; if (props.editMode) return true; const tmp = getNewFile() === props.data.file.path; // if (tmp) setNewFile(""); return tmp; }
// const isEdit = () => {
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/FileName.tsx#L34-L40
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
onEdit
const onEdit = (e: MouseEvent) => { if (!isEdit()) setEdit(true); // if(isEdit()) { // const range = document.createRange(); // editor.focus(); // range.selectNodeContents(editor); // const selection = window.getSelection(); // selection!.remov...
// focus editor when it becomes visible
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/FileName.tsx#L58-L68
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
linkText
const linkText = () => { return app.metadataCache.fileToLinktext(props.data.file, "/") }
// const onClick = async (e:MouseEvent) => {
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/FileName.tsx#L111-L113
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
folders
const folders = () => { // return folder names from querying VaultDB return getFolders(app) .filter((folder) => folder !== "/" && folder !== "") // .filter((folder) => folder.toLowerCase().contains(scopeSpecifier().toLowerCase())) .map((folder) => { return { ...
// const { app } = useApp()!;
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/FolderSelect.tsx#L14-L25
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
headerResize
function headerResize(el: Element, onResize: Accessor<(ev:ResizeEvent) => void>) { const state: { resizing?: Element, index: number, originalSize?: number, mousex?: number } = { resizing: undefined, index: -1, mousex: undefined, originalSize: undef...
// eslint-disable-next-line @typescript-eslint/no-unused-vars
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/HeaderRow.tsx#L19-L92
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
allData
const allData = () => db.execute(query());
// const [allData, setAllData] = createSignal(db.execute(query()));
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/SidebarWidget.tsx#L192-L192
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
linkText
const linkText = (file: TFile) => { return app.metadataCache.fileToLinktext(file, "/") }
// const fileNameAttribute = db.getAttributeDefinition(IntrinsicAttributeKey.FileName);
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/SidebarWidget.tsx#L240-L242
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
attributes
const attributes = () => { const { attributes, definition } = inferAttributes(widget().definition, db, data()); return attributes; }
// Infer fields
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/SidebarWidget.tsx#L245-L248
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
onIconClick
const onIconClick = (e: MouseEvent) => { removeSort(props.key); }
// const onRemove = (e:PropertyData) => {
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/SortingEditor.tsx#L39-L41
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
sortFields
const sortFields = () => { return definition().sortby || []; }
// const update = () => {
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/SortingEditor.tsx#L89-L91
1f5108589e23722ec5d890dda020ab89a61b2145
obsidian-sets
github_2023
Canna71
typescript
updateDefinition
const updateDefinition = (def: SetDefinition) => { const scrollLeft = el.querySelector(".sets-view-scroller")?.scrollLeft; // def.scroll = scrollLeft; stateMap.set(stateKey, { scroll: scrollLeft }); delete def.transientState; db.off("metadata-changed", onDataChanged); sav...
// Saves current scroll position into the state map and deletes it from the definition
https://github.com/Canna71/obsidian-sets/blob/1f5108589e23722ec5d890dda020ab89a61b2145/src/Views/components/renderCodeBlock.tsx#L82-L89
1f5108589e23722ec5d890dda020ab89a61b2145
cli
github_2023
reliverse
typescript
getRollupSourcemapOption
function getRollupSourcemapOption( sourcemap: boolean | "inline" | "none" | "linked" | "external", ): boolean | "inline" { if (sourcemap === "none") return false; if (sourcemap === "inline") return sourcemap; if (sourcemap === "linked" || sourcemap === "external" || sourcemap) return true; return false; }
/** * Helper to compute the Rollup sourcemap option based on the configuration. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.config.ts#L146-L154
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
handleDistFoldersRemoving
async function handleDistFoldersRemoving(): Promise<void> { try { await Promise.all( DIST_FOLDERS.map(async (folder) => { const folderPath = path.resolve(CURRENT_DIR, folder); if (await fs.pathExists(folderPath)) { await fs.remove(folderPath); logger.verbose(`Removed: ${f...
// ---------- Dist Folders Existence Check & Cleanup ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L87-L102
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
deleteSpecificFiles
async function deleteSpecificFiles(outdirBin: string): Promise<void> { const patterns = [ "**/*.test.js", "**/*.test.ts", "**/*.test.d.ts", "**/*-temp.js", "**/*-temp.ts", "**/*-temp.d.ts", ]; const files = await globby(patterns, { cwd: outdirBin, absolute: true, gitignore: tru...
// ---------- Delete Specific Files ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L123-L141
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
bumpVersions
async function bumpVersions( oldVersion: string, newVersion: string, ): Promise<void> { try { const codebase = await globby(["**/*.{ts,json,jsonc,json5,reliverse}"], { ignore: [ "**/node_modules/**", "**/.git/**", "**/dist/**", "**/build/**", "**/.next/**", ...
// ---------- Bump Versions in Files ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L144-L283
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
updateFile
const updateFile = async ( filePath: string, content: string, ): Promise<boolean> => { try { // Handle JSON-like files if (/\.(json|jsonc|json5|reliverse)$/.test(filePath)) { let parsed: { version?: string } | null = null; if (filePath.endsWith(".json")) { ...
/** * Update the version in a given file if it matches the oldVersion. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L171-L261
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
autoIncrementVersion
function autoIncrementVersion( oldVersion: string, mode: "autoPatch" | "autoMinor" | "autoMajor", ): string { if (!semver.valid(oldVersion)) { throw new Error(`Can't auto-increment invalid version: ${oldVersion}`); } const releaseTypeMap = { autoPatch: "patch", autoMinor: "minor", autoMajor: "...
// ---------- Auto-Increment Version Based on Config ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L286-L303
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
setBumpDisabled
async function setBumpDisabled(value: boolean): Promise<void> { // Do not toggle disableBump if pausePublish is active and we're trying to disable bumping. if (pubConfig.pausePublish && value) { logger.verbose("Skipping disableBump toggle due to pausePublish", true); return; } const tsConfigPath = path...
// ---------- Set Bump Disabled Flag in Config ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L309-L338
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
bumpHandler
async function bumpHandler(): Promise<void> { if (pubConfig.disableBump || pubConfig.pausePublish) { logger.info( "Skipping version bump because a previous run already bumped the version or config paused it.", true, ); return; } const cliVersion = scriptFlags["bump"]; const pkgPath = pa...
// ---------- Bump Handler ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L346-L394
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
defineConfig
function defineConfig(isJSR: boolean): BuildPublishConfig { return { ...pubConfig, isJSR, lastBuildFor: isJSR ? "jsr" : "npm", }; }
// ---------- Build Config Definition ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L397-L403
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createCommonPackageFields
async function createCommonPackageFields(): Promise<Partial<PackageJson>> { const originalPkg = await readPackageJSON(); const { name, author, version, license, description, keywords } = originalPkg; const pkgHomepage = "https://docs.reliverse.org/cli"; const commonFields: Partial<PackageJson> = { name, ...
// ---------- Create Common Package Fields ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L406-L438
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createPackageJSON
async function createPackageJSON( outdirRoot: string, isJSR: boolean, ): Promise<void> { logger.info("Generating distribution package.json, tsconfig.json...", true); const commonPkg = await createCommonPackageFields(); const originalPkg = await readPackageJSON(); if (isJSR) { const jsrPkg = definePack...
// ---------- Create Dist Package.json ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L459-L499
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createTSConfig
async function createTSConfig( outdirRoot: string, allowImportingTsExtensions: boolean, ): Promise<void> { const tsConfig = defineTSConfig({ compilerOptions: { allowImportingTsExtensions, target: "ES2023", module: "NodeNext", moduleResolution: "nodenext", lib: ["DOM", "DOM.Iterab...
// ---------- Create TSConfig ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L502-L542
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
findFileCaseInsensitive
async function findFileCaseInsensitive( targetFile: string, ): Promise<string | null> { const files = await fs.readdir("."); const found = files.find( (file) => file.toLowerCase() === targetFile.toLowerCase(), ); return found || null; }
// ---------- Copy README, LICENSE, etc. ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L548-L556
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
convertJsToTsImports
async function convertJsToTsImports( outdirBin: string, isJSR: boolean, ): Promise<void> { const entries = await fs.readdir(outdirBin); for (const entry of entries) { const filePath = path.join(outdirBin, entry); const stat = await fs.stat(filePath); if (stat.isDirectory()) { await convertJsTo...
// ---------- Convert JS Imports to TS ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L591-L620
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
renameTsxFiles
async function renameTsxFiles(dir: string): Promise<void> { const files = await globby(["**/*.tsx"], { cwd: dir, absolute: true, gitignore: true, }); await Promise.all( files.map(async (filePath) => { const newPath = filePath.replace(/\.tsx$/, "-tsx.txt"); await fs.rename(filePath, new...
// ---------- Rename TSX Files ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L627-L640
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
buildJsrDist
async function buildJsrDist(): Promise<void> { const cfg = { ...defineConfig(true), lastBuildFor: "jsr" as const }; const outdirRoot = cfg.jsrDistDir; const outdirBin = `${outdirRoot}/bin`; // Remove any existing JSR dist folder and ensure it exists await fs.remove(outdirRoot); await fs.ensureDir(outdirRoot...
// ---------- Build JSR Distribution ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L817-L906
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
buildNpmDist
async function buildNpmDist(): Promise<void> { const cfg = { ...defineConfig(false), lastBuildFor: "npm" as const }; const outdirRoot = cfg.npmDistDir; const outdirBin = `${outdirRoot}/bin`; // Remove any existing NPM dist folder and ensure it exists await fs.remove(outdirRoot); await fs.ensureDir(outdirRoo...
// ---------- Build NPM Distribution ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L909-L989
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
publishToJsr
async function publishToJsr(dryRun: boolean): Promise<void> { logger.info("Publishing to JSR...", true); try { if (!pubConfig.pausePublish) { const originalDir = process.cwd(); const jsrDistDir = path.resolve(CURRENT_DIR, "dist-jsr"); try { // Change to JSR dist directory for publish...
// ---------- Publish Functions ----------
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/build.publish.ts#L992-L1029
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
initializeDatabase
async function initializeDatabase() { try { await client.batch([ `CREATE TABLE IF NOT EXISTS config_keys ( key TEXT PRIMARY KEY, value TEXT NOT NULL )`, `CREATE TABLE IF NOT EXISTS user_data ( key TEXT PRIMARY KEY, value TEXT NOT NULL )`, ]); } catch (...
// Initialize database schema
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/db/client.ts#L23-L42
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getDerivedKey
function getDerivedKey(): Buffer { const machineId = `${process.platform}-${process.arch}-${process.env["USERNAME"] ?? process.env["USER"]}`; return createHash("sha256").update(machineId).digest(); }
// Encryption key based on machine-specific data
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/db/config.ts#L16-L19
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
ensureUniqueProjectName
async function ensureUniqueProjectName( initialName: string, isDev: boolean, cwd: string, skipPrompts: boolean, ): Promise<string> { let projectName = initialName; let targetPath = isDev ? path.join(cwd, "tests-runtime", projectName) : path.join(cwd, projectName); let index = 1; while (await fs...
/** * Ensures a unique project name by prompting for a new one if the target directory exists. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-impl.ts#L44-L81
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
moveProjectFromTestsRuntime
async function moveProjectFromTestsRuntime( projectName: string, sourceDir: string, ): Promise<string | null> { try { const shouldUseProject = await confirmPrompt({ title: `Project bootstrapped in dev mode. Move to a permanent location? ${experimental}`, content: "If yes, I'll move it from...
/** * Moves the project from a test runtime directory to a user-specified location. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-impl.ts#L236-L291
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getDefaultProjectPath
function getDefaultProjectPath(): string { const platform = os.platform(); return platform === "win32" ? "C:\\B\\S" : path.join(os.homedir(), "Projects"); }
/** * Chooses a default path based on OS for test -> permanent move. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-impl.ts#L296-L301
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
normalizeGitHubUrl
function normalizeGitHubUrl(url: string): string { return url .trim() .replace( /^https?:\/\/(www\.)?(github|gitlab|bitbucket|sourcehut)\.com\//i, "", ) .replace(/^(github|gitlab|bitbucket|sourcehut)\.com\//i, "") .replace(/\.git$/i, ""); }
/** * Normalizes a GitHub repository URL to the format "owner/repo" */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/cli-main-modules/cli-menu-items/showCloneProjectMenu.ts#L21-L30
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createMenuOptions
function createMenuOptions( repos: string[], config: ReliverseConfig, isUserFocused: boolean, ) { const customRepos = ( isUserFocused ? (config.customUserFocusedRepos ?? []) : (config.customDevsFocusedRepos ?? []) ).map(normalizeGitHubUrl); // Hide predefined repos if hideRepoSuggestions is...
/** * Helper function to create menu options from repository list */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/cli-main-modules/cli-menu-items/showCloneProjectMenu.ts#L83-L121
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getUserOptions
function getUserOptions(config: ReliverseConfig) { return createMenuOptions(REPOS_USERS, config, true); }
/** * Options for "End-user" category repositories. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/cli-main-modules/cli-menu-items/showCloneProjectMenu.ts#L126-L128
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getDevOptions
function getDevOptions(config: ReliverseConfig) { return createMenuOptions(REPOS_DEVS, config, false); }
/** * Options for "Developer" category repositories. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/cli-main-modules/cli-menu-items/showCloneProjectMenu.ts#L133-L135
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
promptForRepo
async function promptForRepo({ title, options, category, config, }: { title: string; options: { label: string; value: string }[]; category: "users" | "developers"; config: ReliverseConfig; }): Promise<RepoPromptResult | MultiRepoPromptResult> { const customRepos = ( category === "users" ? (c...
/** * Helper function to prompt for a repository from a list of options. * If "custom" is chosen, it prompts the user for a link. * Returns both the `repo` string and a boolean `isCustom`. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/cli-main-modules/cli-menu-items/showCloneProjectMenu.ts#L142-L205
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getCategoryChoice
async function getCategoryChoice( category: "users" | "developers", config: ReliverseConfig, ): Promise<RepoPromptResult | MultiRepoPromptResult> { if (category === "users") { return promptForRepo({ title: "What end-user related project do you want to clone?", options: getUserOptions(config), ...
/** * Unified function to prompt for either user or developer repository selection. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/cli-main-modules/cli-menu-items/showCloneProjectMenu.ts#L210-L229
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
handleFileConflicts
const handleFileConflicts = async ({ files, automaticConflictHandling, projectPath, }: ConflictHandlerOptions): Promise<void> => { for (const { customMessage, description, fileName } of files) { const filePath = path.join(projectPath, fileName); if (fs.pathExistsSync(filePath)) { const fileDescri...
// Universal conflict handler function
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/cli-main-modules/modules/askToResolveProjectConflicts.ts#L33-L84
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
parseEnvKeys
function parseEnvKeys(envContents: string): Record<string, string> { const result: Record<string, string> = {}; const lines = envContents .split("\n") .map((l) => l.trim()) .filter((l) => !!l && !l.startsWith("#")); for (const line of lines) { // Simplistic parse: KEY=VALUE // It will also ha...
/** * Helper to parse lines from a .env file * Returns an object: { KEY: "value", ... } */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/compose-env-file/cef-impl.ts#L122-L142
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
validateKeyValue
function validateKeyValue(value: string, keyType: KeyType): string | boolean { const trimmed = value.trim(); switch (keyType) { case "string": case "password": case "database": return true; case "email": { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(tri...
/** * Validate user-provided values based on key type. * Returns true if the value passes, otherwise returns an error message. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/compose-env-file/cef-impl.ts#L311-L338
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
validateProjectDir
async function validateProjectDir(effectiveDir: string): Promise<boolean> { const exists = await fs.pathExists(effectiveDir); if (!exists) { relinka("error", `Project directory does not exist: ${effectiveDir}`); } return exists; }
/* ----------------------------------------------------------------------------- * Utility Functions * -------------------------------------------------------------------------- */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/git-deploy-prompts/git.ts#L35-L41
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
removeGitDir
async function removeGitDir(effectiveDir: string): Promise<boolean> { const gitDir = path.join(effectiveDir, ".git"); try { await fs.remove(gitDir); relinka("info-verbose", "Removed existing .git directory"); return true; } catch (error) { relinka( "error", "Failed to remove existing ....
/** * Removes the .git directory from the given directory. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/git-deploy-prompts/git.ts#L46-L60
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
initializeGitRepo
async function initializeGitRepo( git: SimpleGit, alreadyGit: boolean, config: ReliverseConfig, isTemplateDownload: boolean, ): Promise<void> { // Skip initializing repo if this is a template download. if (isTemplateDownload) { relinka( "info-verbose", "Skipping git initialization for templa...
/** * Initializes Git repository in effectiveDir if not already present. * Also renames the default branch to config.repoBranch if provided. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/git-deploy-prompts/git.ts#L66-L103
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createGitCommit
async function createGitCommit( git: SimpleGit, effectiveDir: string, alreadyGit: boolean, isTemplateDownload: boolean, message?: string, ): Promise<void> { if (isTemplateDownload) { relinka("info-verbose", "Skipping commit creation for template download"); return; } const status = await git.st...
/** * Creates a Git commit with all changes. * If there are no files and the repo is empty, creates an empty commit. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/git-deploy-prompts/git.ts#L109-L144
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
isRepoOwner
async function isRepoOwner( githubUsername: string, repoName: string, githubToken: string, githubInstance: InstanceGithub, ): Promise<boolean> { if (!githubToken) { relinka("error", "GitHub token not found in Reliverse's memory"); return false; } try { const { isOwner } = await checkGithubRepo...
/* ----------------------------------------------------------------------------- * GitHub Integration * -------------------------------------------------------------------------- */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/git-deploy-prompts/git.ts#L325-L350
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
validateDomain
function validateDomain(domain: string): string | boolean { if (!domain) return "Domain is required"; if (!/^[a-zA-Z0-9][a-zA-Z0-9-_.]+\.[a-zA-Z]{2,}$/.test(domain)) { return "Invalid domain format"; } return true; }
/** * Validates and formats a domain name */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/git-deploy-prompts/helpers/promptForDomain.ts#L8-L14
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
uploadEnvVars
async function uploadEnvVars( vercelInstance: InstanceVercel, projectName: string, envVars: EnvVar[], ): Promise<void> { await withRateLimit(async () => { const res = await projectsCreateProjectEnv(vercelInstance, { idOrName: projectName, upsert: "true", requestBody: envVars.map((env) => (...
/** * Uploads environment variables to a Vercel project. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/git-deploy-prompts/vercel/vercel-env.ts#L74-L92
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
renameTsxToTxt
async function renameTsxToTxt(dir: string): Promise<void> { try { const files = await globby("**/*.tsx", { cwd: dir, absolute: true, }); for (const filePath of files) { const newPath = filePath.replace(/\.tsx$/, "-tsx.txt"); await fs.rename(filePath, newPath); } } catch (err...
/** * Renames all .tsx files to -tsx.txt in the specified directory and its subdirectories. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/helpers/createProject.ts#L35-L49
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getDefaultBranch
const getDefaultBranch = () => { const stdout = execSync("git config --global init.defaultBranch || echo main") .toString() .trim(); return stdout; };
/** @returns The git config value of "init.defaultBranch". If it is not set, returns "main". */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/helpers/git.ts#L48-L54
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
renameTxtToTsx
async function renameTxtToTsx(dir: string): Promise<void> { try { const files = await globby("**/*-tsx.txt", { cwd: dir, absolute: true, }); for (const filePath of files) { const newPath = filePath.replace(/-tsx\.txt$/, ".tsx"); await fs.rename(filePath, newPath); } } catch ...
/** * Renames all -tsx.txt files back to .tsx in the specified directory and its subdirectories. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/helpers/scaffoldProject.ts#L16-L34
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
sanitizeName
const sanitizeName = (name: string): string => { return name .replace(/[^a-zA-Z0-9_.-]/g, "_") // Replace invalid characters with underscores .toLowerCase(); // Convert to lowercase for consistency };
// Sanitizes a project name to ensure it adheres to Docker container naming conventions.
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/installers/dbContainer.ts#L9-L13
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createContext
const createContext = (req: NextRequest) => { return createTRPCContext({ headers: req.headers, }); };
/** * This wraps the `createTRPCContext` helper and provides the required context for the tRPC API when * handling a HTTP request (e.g. when you make requests from Client Components). */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/template/extras/src/app/api/trpc/[trpc]/route.ts#L16-L20
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createInnerTRPCContext
const createInnerTRPCContext = (_opts: CreateContextOptions) => { return {}; };
/** * This helper generates the "internals" for a tRPC context. If you need to use it, you can export * it from here. * * Examples of things you may need it for: * - testing, so we don't have to mock Next.js' req/res * - tRPC's `createSSGHelpers`, where we don't have req/res * * @see https://docs.reliverse.org/...
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/template/extras/src/server/api/trpc-pages/base.ts#L35-L37
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createInnerTRPCContext
const createInnerTRPCContext = (opts: CreateContextOptions) => { return { session: opts.session, db, }; };
/** * This helper generates the "internals" for a tRPC context. If you need to use it, you can export * it from here. * * Examples of things you may need it for: * - testing, so we don't have to mock Next.js' req/res * - tRPC's `createSSGHelpers`, where we don't have req/res * * @see https://docs.reliverse.org/...
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/template/extras/src/server/api/trpc-pages/with-auth-db.ts#L43-L48
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createInnerTRPCContext
const createInnerTRPCContext = ({ session }: CreateContextOptions) => { return { session, }; };
/** * This helper generates the "internals" for a tRPC context. If you need to use it, you can export * it from here. * * Examples of things you may need it for: * - testing, so we don't have to mock Next.js' req/res * - tRPC's `createSSGHelpers`, where we don't have req/res * * @see https://docs.reliverse.org/...
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/template/extras/src/server/api/trpc-pages/with-auth.ts#L40-L44
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createInnerTRPCContext
const createInnerTRPCContext = (_opts: CreateContextOptions) => { return { db, }; };
/** * This helper generates the "internals" for a tRPC context. If you need to use it, you can export * it from here. * * Examples of things you may need it for: * - testing, so we don't have to mock Next.js' req/res * - tRPC's `createSSGHelpers`, where we don't have req/res * * @see https://docs.reliverse.org/...
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/template/extras/src/server/api/trpc-pages/with-db.ts#L37-L41
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
IsTTYError.constructor
constructor(msg: string) { super(msg); }
// biome-ignore lint/complexity/noUselessConstructor: <explanation>
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/app/menu/create-project/cp-modules/use-composer-mode/utils/isTTYError.ts#L4-L6
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
ensureOpenAIKey
async function ensureOpenAIKey(memory: ReliverseMemory): Promise<string> { let envKeyInvalid = false; let memoryKeyInvalid = false; // 1) Check .env if (process.env["OPENAI_API_KEY"]) { try { await ofetch("https://api.openai.com/v1/models", { headers: { Authorization: `Bearer ${proc...
/** * Ensures we have a valid OpenAI API key in either: * 1) process.env * 2) memory.openaiKey * * If not found or invalid, prompts the user to provide one, * then stores it in memory. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/aiChatHandler.ts#L27-L98
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
initOctokitSDK
function initOctokitSDK(githubKey: string): InstanceGithub { return new OctokitWithRest({ auth: githubKey.trim(), userAgent: octokitUserAgent, throttle: { onRateLimit: ( _retryAfter: number, options: { method: string; url: string; request: { retryCount: ...
/** * Initializes and returns an Octokit instance with rate limiting and a custom user agent. * * @param githubKey - The GitHub personal access token. * @returns An instance of OctokitWithRest. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/instanceGithub.ts#L25-L61
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getReposConfigPath
async function getReposConfigPath(): Promise<string> { const reposPath = path.join(os.homedir(), ".reliverse", "repos"); await fs.ensureDir(reposPath); // Regenerate schema if required. if (await shouldRegenerateSchema()) { await generateReposJsonSchema(); } return path.join(reposPath, "repos.json"); ...
// ────────────────────────────────────────────────
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/projectRepository.ts#L141-L151
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
deepMerge
function deepMerge<T extends Record<string, unknown>>( target: T, source: Partial<T>, ): T { const result = { ...target }; for (const key in source) { if (!Object.prototype.hasOwnProperty.call(source, key)) continue; const sourceValue = source[key]; const targetValue = target[key]; if (sourceV...
/* ------------------------------------------------------------------ * Update Project Config * ------------------------------------------------------------------ */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/reliverseConfig.ts#L132-L162
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createSinglePropertySchema
function createSinglePropertySchema(key: string, subSchema: TSchema): TSchema { return Type.Object({ [key]: subSchema } as Record<string, TSchema>, { additionalProperties: false, required: [key], }); }
/* ------------------------------------------------------------------ * Fixing Config Line-by-Line * ------------------------------------------------------------------ */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/reliverseConfig.ts#L469-L474
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
fixSingleProperty
function fixSingleProperty( schema: TSchema, propName: string, userValue: unknown, defaultValue: unknown, ): unknown { const singlePropertySchema = createSinglePropertySchema(propName, schema); const testObject = { [propName]: userValue }; const isValid = Value.Check(singlePropertySchema, testObject); ...
/** * Validates a single property against its schema. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/reliverseConfig.ts#L479-L490
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
parseReliverseFile
async function parseReliverseFile(configPath: string): Promise<{ parsed: unknown; errors: Iterable<{ schema: unknown; path: string; value: unknown; message: string; }> | null; } | null> { try { const content = (await fs.readFile(configPath, "utf-8")).trim(); if (!content || content === "...
/* ------------------------------------------------------------------ * Config Read/Write (TypeBox) * ------------------------------------------------------------------ */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/reliverseConfig.ts#L663-L695
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
parseAndFixConfig
async function parseAndFixConfig( configPath: string, ): Promise<ReliverseConfig | null> { try { const raw = await fs.readFile(configPath, "utf-8"); const parsed = parseJSONC(raw); if (parsed && typeof parsed === "object") { const originalErrors = [...Value.Errors(reliverseConfigSchema, parsed)];...
/* ------------------------------------------------------------------ * parseAndFixConfig (Line-by-Line) * ------------------------------------------------------------------ */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/reliverseConfig.ts#L808-L860
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
checkProjectFiles
async function checkProjectFiles(projectPath: string): Promise<{ hasReliverse: boolean; hasPackageJson: boolean; hasNodeModules: boolean; hasGit: boolean; }> { const [hasReliverse, hasPackageJson, hasNodeModules, hasGit] = await Promise.all([ fs.pathExists(path.join(projectPath, ".reliverse")), ...
/* ------------------------------------------------------------------ * Project Detection and Additional Logic * ------------------------------------------------------------------ */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/reliverseConfig.ts#L942-L957
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
createReliverseConfig
async function createReliverseConfig( cwd: string, githubUsername: string, isDev: boolean, ): Promise<void> { const defaultRules = await generateDefaultRulesForProject(cwd); const effectiveProjectName = defaultRules?.projectName ?? path.basename(cwd); let effectiveAuthorName = defaultRules?.projectAuthor ?...
/* ------------------------------------------------------------------ * Reliverse Config Creation (wrapper around config generator and fixer) * ------------------------------------------------------------------ */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/reliverseConfig.ts#L975-L1009
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getPackageJson
async function getPackageJson( projectPath: string, ): Promise<PackageJson | null> { try { const packageJsonPath = path.join(projectPath, "package.json"); if (!(await fs.pathExists(packageJsonPath))) { return null; } return await readPackageJSON(projectPath); } catch (error) { const pack...
/* ------------------------------------------------------------------ * Project Detection & Additional Logic * ------------------------------------------------------------------ */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/reliverseConfig.ts#L1148-L1168
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
convertTypeBoxToJsonSchema
function convertTypeBoxToJsonSchema(schema: any): any { if (!schema || typeof schema !== "object") return schema; // Handle TypeBox specific conversions if (schema.type === "string" && schema.enum) { return { type: "string", enum: schema.enum, }; } // Handle unions (convert to enum if al...
/** * Converts a TypeBox schema to a JSON Schema */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/schemaConfig.ts#L264-L345
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
convertTypeBoxToJsonSchema
function convertTypeBoxToJsonSchema(schema: any): any { if (!schema || typeof schema !== "object") return schema; // Handle TypeBox specific conversions if (schema.type === "string" && schema.enum) { return { type: "string", enum: schema.enum, }; } // Handle unions (convert to enum if al...
/** * Converts a TypeBox schema to a JSON Schema */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/schemaTemplate.ts#L54-L120
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
pathExists
async function pathExists(p: string): Promise<boolean> { try { await fs.access(p); return true; } catch { return false; } }
/** * Check if a path exists */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/dependencies/getUserPkgManager.ts#L32-L39
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
checkPMVersion
async function checkPMVersion( pm: PackageManager, includeGlobalBun = true, ): Promise<string | null> { if (pm === "bun" && !includeGlobalBun) return null; const cacheKey = `has_global_${pm}`; if (cache.has(cacheKey)) { return cache.get(cacheKey) as string | null; } try { const { stdout } = awai...
/** * Check if a package manager is available globally by running its version command */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/dependencies/getUserPkgManager.ts#L44-L65
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
detectLockFile
async function detectLockFile( projectPath: string, ): Promise<PkgManagerInfo | null> { const cacheKey = `lockfile_${projectPath}`; if (cache.has(cacheKey)) { return cache.get(cacheKey) as PkgManagerInfo | null; } const lockFiles = await Promise.all([ pathExists(path.join(projectPath, "yarn.lock")), ...
/** * Check for lock files in the directory */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/dependencies/getUserPkgManager.ts#L70-L120
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
detectPackageManagers
async function detectPackageManagers( projectPath: string, options: DetectOptions = {}, ): Promise<PkgManagerInfo[]> { const cacheKey = `detect_${projectPath}_${options.includeGlobalBun}`; if (cache.has(cacheKey)) { return cache.get(cacheKey) as PkgManagerInfo[]; } const detected: PkgManagerInfo[] = []...
/** * Detects all package managers present in the directory */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/dependencies/getUserPkgManager.ts#L125-L214
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
isI18nAlreadySetup
async function isI18nAlreadySetup(projectPath: string): Promise<boolean> { const checkPaths = [ "src/app/[locale]", "src/app/[lang]", "src/i18n", "src/locales", "src/translations", "src/config/i18n.ts", "src/utils/i18n.ts", ]; for (const checkPath of checkPaths) { if (await fs.pat...
/** * Checks if i18n is already set up in the project */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/downloading/downloadI18nFiles.ts#L8-L26
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getFolderSize
async function getFolderSize( directory: string, skipDirs: string[] = [], ): Promise<number> { let totalSize = 0; const entries = await fs.readdir(directory); for (const entry of entries) { // Skip directories that match one of the names in skipDirs. if (skipDirs.includes(entry)) continue; const ...
/** * Recursively calculates the total size of a folder in bytes. * Optionally, directories with a basename found in skipDirs will be skipped. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/downloading/downloadRepo.ts#L129-L148
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
parseGitURI
function parseGitURI(input: string) { const normalizedInput = input .trim() .replace( /^https?:\/\/(www\.)?(github|gitlab|bitbucket|sourcehut)\.com\//, "", ) .replace(/^(github|gitlab|bitbucket|sourcehut)\.com\//, "") .replace(/^https?:\/\/git\.sr\.ht\/~/, "") .replace(/^git\.sr\.h...
/** * Reads a Git repository string and extracts the provider (if any), repository path, reference/branch, and subdirectory. * * Supports formats such as: * - "owner/repo" * - "owner/repo#ref" * - "provider:owner/repo" * - "provider:owner/repo#ref" * - Full URLs (e.g., "https://github.com/owner/repo")...
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/downloading/downloadRepo.ts#L160-L188
725066145859e6b29a7c419e0b22ac51e1468943
cli
github_2023
reliverse
typescript
getRepoUrl
function getRepoUrl(repo: string, provider: GitProvider): string { switch (provider) { case "gitlab": return `https://gitlab.com/${repo}.git`; case "bitbucket": return `https://bitbucket.org/${repo}.git`; case "sourcehut": return `https://git.sr.ht/~${repo}`; default: return `h...
/** * Gets the repository URL based on the provider. */
https://github.com/reliverse/cli/blob/725066145859e6b29a7c419e0b22ac51e1468943/src/utils/downloading/downloadRepo.ts#L193-L204
725066145859e6b29a7c419e0b22ac51e1468943