Skip to content

Commit

Permalink
add new components & add missing exports
Browse files Browse the repository at this point in the history
  • Loading branch information
blefnk committed Nov 24, 2024
1 parent 05c6c6a commit 6c5c12b
Show file tree
Hide file tree
Showing 327 changed files with 19,608 additions and 507 deletions.
18 changes: 0 additions & 18 deletions .github/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

**The current [@reliverse/relinka](https://github.com/reliverse/relinka) DOCS.md is an adaptation of README.md from [@terkelg/prompts](https://github.com/terkelg/prompts). Thanks to the original author for the detailed documentation!**

[![Separator](./public/split.png)](https://docs.reliverse.org/relinka)

**New Features by** [lu-jiejie/prompts-plus](https://github.com/lu-jiejie/prompts-plus):

- [x] add `heading` configuration option to `choices` in `select` prompts, which will be displayed as a heading or a separator in the choices list. It will not be selectable and hoverable.
Expand All @@ -24,17 +22,13 @@ typeof name // string
<sub>>_ Easy to use CLI prompts to enquire users for information▌</sub>
</p>

[![Separator](./public/split.png)](https://docs.reliverse.org/relinka)

- **Simple**: prompts has [no big dependencies](http://npm.anvaka.com/#/view/2d/prompts) nor is it broken into a [dozen](http://npm.anvaka.com/#/view/2d/inquirer) tiny modules that only work well together.
- **User friendly**: prompt uses layout and colors to create beautiful cli interfaces.
- **Promised**: uses promises and `async`/`await`. No callback hell.
- **Flexible**: all prompts are independent and can be used on their own.
- **Testable**: provides a way to submit answers programmatically.
- **Unified**: consistent experience across all [prompts](#-types).

![split](https://github.com/reliverse/relinka/raw/master/public/split.png)

## ❯ Install

```bash
Expand All @@ -43,8 +37,6 @@ npm install --save prompts

> This package supports Node 14 and above
![split](https://github.com/reliverse/relinka/raw/master/public/split.png)

## ❯ Usage

<img src="https://github.com/reliverse/relinka/raw/master/public/example.gif" alt="example prompt" width="499" height="103" />
Expand All @@ -66,8 +58,6 @@ const prompts = require('prompts');

> See [`example.js`](https://github.com/reliverse/relinka/blob/master/example.js) for more options.
![split](https://github.com/reliverse/relinka/raw/master/public/split.png)

## ❯ Examples

### Single Prompt
Expand Down Expand Up @@ -148,8 +138,6 @@ const questions = [
})();
```

![split](https://github.com/reliverse/relinka/raw/master/public/split.png)

## ❯ API

### prompts(prompts, options)
Expand Down Expand Up @@ -294,8 +282,6 @@ prompts.inject([ '@reliverse', ['#ff0000', '#0000ff'] ]);
})();
```

![split](https://github.com/reliverse/relinka/raw/master/public/split.png)

## ❯ Prompt Objects

Prompts Objects are JavaScript objects that define the "questions" and the [type of prompt](#-types).
Expand Down Expand Up @@ -424,8 +410,6 @@ Type: `Stream`
By default, prompts uses `process.stdin` for receiving input and `process.stdout` for writing output.
If you need to use different streams, for instance `process.stderr`, you can set these with the `stdin` and `stdout` properties.

![split](https://github.com/reliverse/relinka/raw/master/public/split.png)

## ❯ Types

- [text](#textmessage-initial-style)
Expand Down Expand Up @@ -895,8 +879,6 @@ Default locales:

>**Formatting**: See full list of formatting options in the [wiki](https://github.com/reliverse/relinka/wiki/Date-Time-Formatting)
![split](https://github.com/reliverse/relinka/raw/master/public/split.png)

**↑ back to:** [Prompt types](#-types)

---
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.venv/
output/
dist-jsr/
dist-npm/
.DS_Store
merged.txt
.eslintcache
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"severity": "off"
}
],
"openMultipleFiles.limit": 600,
"openMultipleFiles.limit": 700,
"markdownlint.config": {
"MD033": false
},
Expand Down
72 changes: 34 additions & 38 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"formatter": {
"enabled": true,
"ignore": [".git/", "node_modules/", "dist/", "output/"],
"ignore": [".git/", "node_modules/", "dist-jsr/", "dist-npm/"],
"indentStyle": "space",
"attributePosition": "auto",
"formatWithErrors": false,
Expand All @@ -27,8 +27,8 @@
"ignore": [
".git/",
"node_modules/",
"dist/",
"output/",
"dist-jsr/",
"dist-npm/",
"examples/deprecated/**/*.ts"
],
"rules": {
Expand Down
2 changes: 1 addition & 1 deletion build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineBuildConfig({
entries: [
{
builder: "mkdist",
outDir: "output",
outDir: "dist-npm",
format: "esm",
input: "src",
ext: "js",
Expand Down
89 changes: 82 additions & 7 deletions build.optim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@ import glob from "fast-glob";
import fs from "fs-extra";
import path from "pathe";

import { spinner } from "~/components/spinner/index.js";
import { spinner } from "~/mod.js";

const outputDir = path.resolve(__dirname, "output");
// Parse command-line arguments to check for '--jsr' flag
const args = process.argv.slice(2);
const isJSR = args.includes("--jsr");

const filesToDelete = [
// Define directories based on the presence of '--jsr' flag
const sourceDir = path.resolve(__dirname, "src");
const outputDir = path.resolve(__dirname, isJSR ? "dist-jsr" : "dist-npm");

// Separate patterns for files to delete in different modes
const npmFilesToDelete = [
"**/*.test.js",
"**/*.test.d.ts",
"unsorted/types/internal.js",
"unsorted/types/internal.d.ts",
"types/internal.js",
"types/internal.d.ts",
];

const jsrFilesToDelete = ["**/*.test.ts", "types/internal.ts"];

// Toggle debug mode
const debug = false;

/**
* Deletes files matching the provided patterns within the base directory.
* @param patterns Array of glob patterns to match files for deletion.
* @param baseDir The base directory to search for files.
*/
async function deleteFiles(patterns: string[], baseDir: string) {
try {
const files = await glob(patterns, { cwd: baseDir, absolute: true });
Expand All @@ -37,6 +52,13 @@ async function deleteFiles(patterns: string[], baseDir: string) {
}
}

/**
* Replaces import paths that use '~/' with relative paths.
* @param content The file content.
* @param fileDir The directory of the current file.
* @param rootDir The root directory to resolve relative paths.
* @returns The updated file content with modified import paths.
*/
function replaceImportPaths(
content: string,
fileDir: string,
Expand All @@ -61,6 +83,10 @@ function replaceImportPaths(
);
}

/**
* Processes all relevant files in the given directory by replacing import paths.
* @param dir The directory to process.
*/
async function processFiles(dir: string) {
const files = await fs.readdir(dir);

Expand Down Expand Up @@ -101,15 +127,64 @@ async function processFiles(dir: string) {
}
}

/**
* Removes the 'dist' directory if it exists.
*/
async function removeDistDirectory() {
try {
const exists = await fs.pathExists(outputDir);
if (exists) {
await fs.remove(outputDir);
debug && console.log(`Removed existing '${outputDir}' directory.`);
}
} catch (error) {
console.error(`Error removing '${outputDir}' directory:`, error);
throw error;
}
}

/**
* Copies the 'src' directory to 'dist' when '--jsr' flag is provided.
*/
async function copySrcToDist() {
try {
await fs.copy(sourceDir, outputDir, {
overwrite: true,
errorOnExist: false,
});
debug && console.log(`Copied 'src' to '${outputDir}'`);
} catch (error) {
console.error(`Error copying 'src' to 'dist':`, error);
throw error;
}
}

/**
* Optimizes the build for production by processing files and deleting unnecessary ones.
* @param dir The directory to optimize.
*/
async function optimizeBuildForProduction(dir: string) {
await spinner({
initialMessage: "Creating an optimized production build...",
successMessage: "Optimized production build created successfully.",
initialMessage: isJSR
? "Preparing JSR build by removing existing 'dist' directory..."
: "Creating an optimized production build...",
successMessage: isJSR
? "JSR build prepared successfully."
: "Optimized production build created successfully.",
spinnerSolution: "ora",
spinnerType: "arc",
action: async (updateMessage: (arg0: string) => void) => {
if (isJSR) {
updateMessage("Removing existing 'dist' directory...");
await removeDistDirectory(); // Remove 'dist' before copying
updateMessage("Copying 'src' to 'dist'...");
await copySrcToDist();
}
updateMessage("Processing files...");
await processFiles(dir);
updateMessage("Cleaning up unnecessary files...");
// Choose the appropriate files to delete based on the mode
const filesToDelete = isJSR ? jsrFilesToDelete : npmFilesToDelete;
await deleteFiles(filesToDelete, dir);
},
});
Expand Down
Binary file modified bun.lockb
Binary file not shown.
27 changes: 20 additions & 7 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"version": "0.2",
"language": "en",
"import": [
"@cspell/dict-npm/cspell-ext.json"
],
"ignorePaths": [
"examples/deprecated"
],
"import": ["@cspell/dict-npm/cspell-ext.json"],
"ignorePaths": ["examples/deprecated"],
"words": [
"alacritty",
"alternar",
Expand All @@ -17,6 +13,8 @@
"Arryn",
"astro",
"attw",
"ausgewählt",
"avez",
"Baratheon",
"blefnk",
"browserlist",
Expand All @@ -25,6 +23,7 @@
"bumpp",
"bunp",
"bunx",
"choisi",
"Clooney",
"cmder",
"confirmtoggle",
Expand All @@ -37,24 +36,29 @@
"defu",
"deno",
"derhuerst",
"Deutsch",
"dflt",
"Doesnt",
"Dont",
"Downey",
"emojify",
"eslintcache",
"favourite",
"figliolia",
"Fireship",
"Focusable",
"forgetme",
"Geralt",
"goroutines",
"Greyjoy",
"Gyllenhaal",
"haben",
"Haha",
"hoverable",
"iife",
"invertir",
"jetbrains",
"język",
"jiejie",
"keypresses",
"Korniienko",
Expand Down Expand Up @@ -82,6 +86,7 @@
"pagedown",
"pageup",
"picocolors",
"polski",
"printj",
"rawlist",
"redrun",
Expand All @@ -97,6 +102,7 @@
"signup",
"Silverhand",
"sisteransi",
"Sprache",
"subchoices",
"Targ",
"Targaryen",
Expand All @@ -108,14 +114,21 @@
"typecheck",
"typesafe",
"typesafety",
"typestat",
"Tyrell",
"unjs",
"unpub",
"unstub",
"valign",
"venv",
"Vous",
"vsprintf",
"Whoo",
"Wybrałeś",
"Yadxh",
"ytrewq"
"ytrewq",
"обрали",
"Українська",
"українську"
]
}
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default tseslint.config(
{
ignores: [
"**/.{git,next,astro,wxt}/",
"**/{node_modules,dist,output,public,drizzle}/",
"**/{node_modules,dist-jsr,dist-npm,public,drizzle}/",
"examples/deprecated/**/*.{js,ts}",
],
},
Expand Down
Binary file added example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6c5c12b

Please sign in to comment.