create-cn-application 0.0.0
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.
- package/create-cn-component/package.json +19 -0
- package/create-cn-component/readme.md +22 -0
- package/create-cn-extenstion/bin/index.js +76 -0
- package/create-cn-extenstion/package.json +20 -0
- package/create-cn-extenstion/readme.md +22 -0
- package/create-cn-workspace/bin/index.js +55 -0
- package/create-cn-workspace/node_modules/chalk/license +9 -0
- package/create-cn-workspace/node_modules/chalk/package.json +83 -0
- package/create-cn-workspace/node_modules/chalk/readme.md +297 -0
- package/create-cn-workspace/node_modules/chalk/source/index.d.ts +325 -0
- package/create-cn-workspace/node_modules/chalk/source/index.js +225 -0
- package/create-cn-workspace/node_modules/chalk/source/utilities.js +33 -0
- package/create-cn-workspace/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/create-cn-workspace/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/create-cn-workspace/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/create-cn-workspace/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/create-cn-workspace/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/create-cn-workspace/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/create-cn-workspace/package.json +19 -0
- package/create-cn-workspace/readme.md +22 -0
- package/package.json +19 -0
- package/readme.md +22 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-cn-component",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Scaffold a new Cnos component",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-cn-component": "./bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"preferGlobal": true,
|
|
10
|
+
"author": "CNOS",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"chalk": "^4.1.2",
|
|
17
|
+
"inquirer": "^9.2.8"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# create-cn-component
|
|
2
|
+
|
|
3
|
+
**Package Status:** Reserved for Future Use
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This NPM package is currently **reserved for future development** and is not intended for public use at this time.
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
create-cn-component is planned to serve as a **Cloud Native Installation component** format for distributing components and components in the CNOS ecosystem. This package acts as a placeholder to reserve the namespace and will eventually provide tools, manifest schemas, and distribution utilities for CNOS components.
|
|
12
|
+
|
|
13
|
+
## Current Status
|
|
14
|
+
|
|
15
|
+
- No functionality is implemented yet.
|
|
16
|
+
- The package is **not production-ready**.
|
|
17
|
+
- All attempts to install or use this package will have **no effect**.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install create-cn-component
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import chalk from 'chalk';
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
console.log(chalk.green.bold('\nCnos Extension Creator\n'));
|
|
10
|
+
|
|
11
|
+
const { extName, extType } = await inquirer.prompt([
|
|
12
|
+
{
|
|
13
|
+
type: 'input',
|
|
14
|
+
name: 'extName',
|
|
15
|
+
message: 'Enter extension name (no spaces, e.g., my-extension):',
|
|
16
|
+
validate: input => /^[a-z0-9-_]+$/.test(input) ? true : 'Only lowercase letters, numbers, - or _ allowed'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'list',
|
|
20
|
+
name: 'extType',
|
|
21
|
+
message: 'Select extension type:',
|
|
22
|
+
choices: ['connector', 'extension', 'integration', 'widget', 'plugin', 'tool']
|
|
23
|
+
}
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
const extPath = path.resolve(process.cwd(), extName);
|
|
27
|
+
|
|
28
|
+
if (fs.existsSync(extPath)) {
|
|
29
|
+
console.log(chalk.red(`\nError: Folder ${extName} already exists!`));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fs.ensureDirSync(extPath);
|
|
34
|
+
|
|
35
|
+
// Create basic index.js
|
|
36
|
+
fs.writeFileSync(
|
|
37
|
+
path.join(extPath, 'index.js'),
|
|
38
|
+
`// ${extName} extension entry point\n\nmodule.exports = () => {\n console.log('Hello from ${extName}');\n};\n`
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// Create cnix.manifest.json
|
|
42
|
+
const manifest = {
|
|
43
|
+
name: extName,
|
|
44
|
+
version: "0.1.0",
|
|
45
|
+
type: extType,
|
|
46
|
+
main: "index.js",
|
|
47
|
+
description: `${extType} extension for Cnos`,
|
|
48
|
+
author: "",
|
|
49
|
+
license: "MIT"
|
|
50
|
+
};
|
|
51
|
+
fs.writeFileSync(
|
|
52
|
+
path.join(extPath, 'cnix.manifest.json'),
|
|
53
|
+
JSON.stringify(manifest, null, 2)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Optional package.json
|
|
57
|
+
const pkgJson = {
|
|
58
|
+
name: extName,
|
|
59
|
+
version: "0.1.0",
|
|
60
|
+
main: "index.js",
|
|
61
|
+
license: "MIT"
|
|
62
|
+
};
|
|
63
|
+
fs.writeFileSync(
|
|
64
|
+
path.join(extPath, 'package.json'),
|
|
65
|
+
JSON.stringify(pkgJson, null, 2)
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
console.log(chalk.blue(`\nExtension "${extName}" created successfully at:`));
|
|
69
|
+
console.log(chalk.yellow(extPath));
|
|
70
|
+
console.log(chalk.green('\nNext steps:'));
|
|
71
|
+
console.log(` cd ${extName}`);
|
|
72
|
+
console.log(' npm install (if you need dependencies)');
|
|
73
|
+
console.log(` npx cnos build or integrate into your workspace\n`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
main();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-cn-extension",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Scaffold a new Cnos extension",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-cn-extension": "./bin/index.js"
|
|
8
|
+
},
|
|
9
|
+
"preferGlobal": true,
|
|
10
|
+
"author": "Your Name",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"chalk": "^4.1.2",
|
|
17
|
+
"fs-extra": "^11.1.1",
|
|
18
|
+
"inquirer": "^9.2.8"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# create-cn-extension
|
|
2
|
+
|
|
3
|
+
**Package Status:** Reserved for Future Use
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This NPM package is currently **reserved for future development** and is not intended for public use at this time.
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
create-cn-extension is planned to serve as a **Cloud Native Installation eXtension** format for distributing components and extensions in the CNOS ecosystem. This package acts as a placeholder to reserve the namespace and will eventually provide tools, manifest schemas, and distribution utilities for CNOS components.
|
|
12
|
+
|
|
13
|
+
## Current Status
|
|
14
|
+
|
|
15
|
+
- No functionality is implemented yet.
|
|
16
|
+
- The package is **not production-ready**.
|
|
17
|
+
- All attempts to install or use this package will have **no effect**.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install create-cn-extension
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const inquirer = require('inquirer');
|
|
6
|
+
const chalk = require('chalk');
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
console.log(chalk.green.bold('\nCnos Workspace Creator\n'));
|
|
10
|
+
|
|
11
|
+
const { workspaceName } = await inquirer.prompt([
|
|
12
|
+
{
|
|
13
|
+
type: 'input',
|
|
14
|
+
name: 'workspaceName',
|
|
15
|
+
message: 'Enter your Cnos workspace name:',
|
|
16
|
+
validate: input => input ? true : 'Workspace name cannot be empty'
|
|
17
|
+
}
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
const workspacePath = path.resolve(process.cwd(), workspaceName);
|
|
21
|
+
|
|
22
|
+
if (fs.existsSync(workspacePath)) {
|
|
23
|
+
console.log(chalk.red(`\nError: Folder ${workspaceName} already exists!`));
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Create basic structure
|
|
28
|
+
const folders = ['apps', 'libs', 'packages', 'dist', 'extensions'];
|
|
29
|
+
folders.forEach(f => fs.ensureDirSync(path.join(workspacePath, f)));
|
|
30
|
+
|
|
31
|
+
// Initialize a package.json
|
|
32
|
+
const pkgJson = {
|
|
33
|
+
name: workspaceName,
|
|
34
|
+
version: "1.0.0",
|
|
35
|
+
private: true,
|
|
36
|
+
workspaces: ["apps/*", "libs/*", "packages/*"],
|
|
37
|
+
scripts: {
|
|
38
|
+
build: "echo 'Build your Cnos workspace here'",
|
|
39
|
+
start: "echo 'Start your workspace'"
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
fs.writeFileSync(
|
|
43
|
+
path.join(workspacePath, 'package.json'),
|
|
44
|
+
JSON.stringify(pkgJson, null, 2)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
console.log(chalk.blue(`\nWorkspace "${workspaceName}" created successfully at:`));
|
|
48
|
+
console.log(chalk.yellow(workspacePath));
|
|
49
|
+
console.log(chalk.green('\nNext steps:'));
|
|
50
|
+
console.log(` cd ${workspaceName}`);
|
|
51
|
+
console.log(' npm install');
|
|
52
|
+
console.log(' npm run build\n');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
main();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chalk",
|
|
3
|
+
"version": "5.6.2",
|
|
4
|
+
"description": "Terminal string styling done right",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "chalk/chalk",
|
|
7
|
+
"funding": "https://github.com/chalk/chalk?sponsor=1",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./source/index.js",
|
|
10
|
+
"exports": "./source/index.js",
|
|
11
|
+
"imports": {
|
|
12
|
+
"#ansi-styles": "./source/vendor/ansi-styles/index.js",
|
|
13
|
+
"#supports-color": {
|
|
14
|
+
"node": "./source/vendor/supports-color/index.js",
|
|
15
|
+
"default": "./source/vendor/supports-color/browser.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"types": "./source/index.d.ts",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": "^12.17.0 || ^14.13 || >=16.0.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "xo && c8 ava && tsd",
|
|
25
|
+
"bench": "matcha benchmark.js"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"source",
|
|
29
|
+
"!source/index.test-d.ts"
|
|
30
|
+
],
|
|
31
|
+
"keywords": [
|
|
32
|
+
"color",
|
|
33
|
+
"colour",
|
|
34
|
+
"colors",
|
|
35
|
+
"terminal",
|
|
36
|
+
"console",
|
|
37
|
+
"cli",
|
|
38
|
+
"string",
|
|
39
|
+
"ansi",
|
|
40
|
+
"style",
|
|
41
|
+
"styles",
|
|
42
|
+
"tty",
|
|
43
|
+
"formatting",
|
|
44
|
+
"rgb",
|
|
45
|
+
"256",
|
|
46
|
+
"shell",
|
|
47
|
+
"xterm",
|
|
48
|
+
"log",
|
|
49
|
+
"logging",
|
|
50
|
+
"command-line",
|
|
51
|
+
"text"
|
|
52
|
+
],
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^16.11.10",
|
|
55
|
+
"ava": "^3.15.0",
|
|
56
|
+
"c8": "^7.10.0",
|
|
57
|
+
"color-convert": "^2.0.1",
|
|
58
|
+
"execa": "^6.0.0",
|
|
59
|
+
"log-update": "^5.0.0",
|
|
60
|
+
"matcha": "^0.7.0",
|
|
61
|
+
"tsd": "^0.19.0",
|
|
62
|
+
"xo": "^0.57.0",
|
|
63
|
+
"yoctodelay": "^2.0.0"
|
|
64
|
+
},
|
|
65
|
+
"xo": {
|
|
66
|
+
"rules": {
|
|
67
|
+
"unicorn/prefer-string-slice": "off",
|
|
68
|
+
"@typescript-eslint/consistent-type-imports": "off",
|
|
69
|
+
"@typescript-eslint/consistent-type-exports": "off",
|
|
70
|
+
"@typescript-eslint/consistent-type-definitions": "off",
|
|
71
|
+
"unicorn/expiring-todo-comments": "off"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"c8": {
|
|
75
|
+
"reporter": [
|
|
76
|
+
"text",
|
|
77
|
+
"lcov"
|
|
78
|
+
],
|
|
79
|
+
"exclude": [
|
|
80
|
+
"source/vendor"
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<br>
|
|
3
|
+
<br>
|
|
4
|
+
<img width="320" src="media/logo.svg" alt="Chalk">
|
|
5
|
+
<br>
|
|
6
|
+
<br>
|
|
7
|
+
<br>
|
|
8
|
+
</h1>
|
|
9
|
+
|
|
10
|
+
> Terminal string styling done right
|
|
11
|
+
|
|
12
|
+
[](https://codecov.io/gh/chalk/chalk)
|
|
13
|
+
[](https://www.npmjs.com/package/chalk?activeTab=dependents)
|
|
14
|
+
[](https://www.npmjs.com/package/chalk)
|
|
15
|
+
|
|
16
|
+

|
|
17
|
+
|
|
18
|
+
## Info
|
|
19
|
+
|
|
20
|
+
- [Why not switch to a smaller coloring package?](https://github.com/chalk/chalk?tab=readme-ov-file#why-not-switch-to-a-smaller-coloring-package)
|
|
21
|
+
- See [yoctocolors](https://github.com/sindresorhus/yoctocolors) for a smaller alternative
|
|
22
|
+
|
|
23
|
+
## Highlights
|
|
24
|
+
|
|
25
|
+
- Expressive API
|
|
26
|
+
- Highly performant
|
|
27
|
+
- No dependencies
|
|
28
|
+
- Ability to nest styles
|
|
29
|
+
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
|
30
|
+
- Auto-detects color support
|
|
31
|
+
- Doesn't extend `String.prototype`
|
|
32
|
+
- Clean and focused
|
|
33
|
+
- Actively maintained
|
|
34
|
+
- [Used by ~115,000 packages](https://www.npmjs.com/browse/depended/chalk) as of July 4, 2024
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm install chalk
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**IMPORTANT:** Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now. [Read more.](https://github.com/chalk/chalk/releases/tag/v5.0.0)
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
import chalk from 'chalk';
|
|
48
|
+
|
|
49
|
+
console.log(chalk.blue('Hello world!'));
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import chalk from 'chalk';
|
|
56
|
+
|
|
57
|
+
const log = console.log;
|
|
58
|
+
|
|
59
|
+
// Combine styled and normal strings
|
|
60
|
+
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
|
61
|
+
|
|
62
|
+
// Compose multiple styles using the chainable API
|
|
63
|
+
log(chalk.blue.bgRed.bold('Hello world!'));
|
|
64
|
+
|
|
65
|
+
// Pass in multiple arguments
|
|
66
|
+
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
|
|
67
|
+
|
|
68
|
+
// Nest styles
|
|
69
|
+
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
|
|
70
|
+
|
|
71
|
+
// Nest styles of the same type even (color, underline, background)
|
|
72
|
+
log(chalk.green(
|
|
73
|
+
'I am a green line ' +
|
|
74
|
+
chalk.blue.underline.bold('with a blue substring') +
|
|
75
|
+
' that becomes green again!'
|
|
76
|
+
));
|
|
77
|
+
|
|
78
|
+
// ES2015 template literal
|
|
79
|
+
log(`
|
|
80
|
+
CPU: ${chalk.red('90%')}
|
|
81
|
+
RAM: ${chalk.green('40%')}
|
|
82
|
+
DISK: ${chalk.yellow('70%')}
|
|
83
|
+
`);
|
|
84
|
+
|
|
85
|
+
// Use RGB colors in terminal emulators that support it.
|
|
86
|
+
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
|
87
|
+
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Easily define your own themes:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import chalk from 'chalk';
|
|
94
|
+
|
|
95
|
+
const error = chalk.bold.red;
|
|
96
|
+
const warning = chalk.hex('#FFA500'); // Orange color
|
|
97
|
+
|
|
98
|
+
console.log(error('Error!'));
|
|
99
|
+
console.log(warning('Warning!'));
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
import chalk from 'chalk';
|
|
106
|
+
|
|
107
|
+
const name = 'Sindre';
|
|
108
|
+
console.log(chalk.green('Hello %s'), name);
|
|
109
|
+
//=> 'Hello Sindre'
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## API
|
|
113
|
+
|
|
114
|
+
### chalk.`<style>[.<style>...](string, [string...])`
|
|
115
|
+
|
|
116
|
+
Example: `chalk.red.bold.underline('Hello', 'world');`
|
|
117
|
+
|
|
118
|
+
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
|
119
|
+
|
|
120
|
+
Multiple arguments will be separated by space.
|
|
121
|
+
|
|
122
|
+
### chalk.level
|
|
123
|
+
|
|
124
|
+
Specifies the level of color support.
|
|
125
|
+
|
|
126
|
+
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
|
|
127
|
+
|
|
128
|
+
If you need to change this in a reusable module, create a new instance:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
import {Chalk} from 'chalk';
|
|
132
|
+
|
|
133
|
+
const customChalk = new Chalk({level: 0});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
| Level | Description |
|
|
137
|
+
| :---: | :--- |
|
|
138
|
+
| `0` | All colors disabled |
|
|
139
|
+
| `1` | Basic color support (16 colors) |
|
|
140
|
+
| `2` | 256 color support |
|
|
141
|
+
| `3` | Truecolor support (16 million colors) |
|
|
142
|
+
|
|
143
|
+
### supportsColor
|
|
144
|
+
|
|
145
|
+
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
|
146
|
+
|
|
147
|
+
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
|
148
|
+
|
|
149
|
+
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
|
150
|
+
|
|
151
|
+
### chalkStderr and supportsColorStderr
|
|
152
|
+
|
|
153
|
+
`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `supportsColorStderr` is exposed for convenience.
|
|
154
|
+
|
|
155
|
+
### modifierNames, foregroundColorNames, backgroundColorNames, and colorNames
|
|
156
|
+
|
|
157
|
+
All supported style strings are exposed as an array of strings for convenience. `colorNames` is the combination of `foregroundColorNames` and `backgroundColorNames`.
|
|
158
|
+
|
|
159
|
+
This can be useful if you wrap Chalk and need to validate input:
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
import {modifierNames, foregroundColorNames} from 'chalk';
|
|
163
|
+
|
|
164
|
+
console.log(modifierNames.includes('bold'));
|
|
165
|
+
//=> true
|
|
166
|
+
|
|
167
|
+
console.log(foregroundColorNames.includes('pink'));
|
|
168
|
+
//=> false
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Styles
|
|
172
|
+
|
|
173
|
+
### Modifiers
|
|
174
|
+
|
|
175
|
+
- `reset` - Reset the current style.
|
|
176
|
+
- `bold` - Make the text bold.
|
|
177
|
+
- `dim` - Make the text have lower opacity.
|
|
178
|
+
- `italic` - Make the text italic. *(Not widely supported)*
|
|
179
|
+
- `underline` - Put a horizontal line below the text. *(Not widely supported)*
|
|
180
|
+
- `overline` - Put a horizontal line above the text. *(Not widely supported)*
|
|
181
|
+
- `inverse`- Invert background and foreground colors.
|
|
182
|
+
- `hidden` - Print the text but make it invisible.
|
|
183
|
+
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
|
184
|
+
- `visible`- Print the text only when Chalk has a color level above zero. Can be useful for things that are purely cosmetic.
|
|
185
|
+
|
|
186
|
+
### Colors
|
|
187
|
+
|
|
188
|
+
- `black`
|
|
189
|
+
- `red`
|
|
190
|
+
- `green`
|
|
191
|
+
- `yellow`
|
|
192
|
+
- `blue`
|
|
193
|
+
- `magenta`
|
|
194
|
+
- `cyan`
|
|
195
|
+
- `white`
|
|
196
|
+
- `blackBright` (alias: `gray`, `grey`)
|
|
197
|
+
- `redBright`
|
|
198
|
+
- `greenBright`
|
|
199
|
+
- `yellowBright`
|
|
200
|
+
- `blueBright`
|
|
201
|
+
- `magentaBright`
|
|
202
|
+
- `cyanBright`
|
|
203
|
+
- `whiteBright`
|
|
204
|
+
|
|
205
|
+
### Background colors
|
|
206
|
+
|
|
207
|
+
- `bgBlack`
|
|
208
|
+
- `bgRed`
|
|
209
|
+
- `bgGreen`
|
|
210
|
+
- `bgYellow`
|
|
211
|
+
- `bgBlue`
|
|
212
|
+
- `bgMagenta`
|
|
213
|
+
- `bgCyan`
|
|
214
|
+
- `bgWhite`
|
|
215
|
+
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
|
216
|
+
- `bgRedBright`
|
|
217
|
+
- `bgGreenBright`
|
|
218
|
+
- `bgYellowBright`
|
|
219
|
+
- `bgBlueBright`
|
|
220
|
+
- `bgMagentaBright`
|
|
221
|
+
- `bgCyanBright`
|
|
222
|
+
- `bgWhiteBright`
|
|
223
|
+
|
|
224
|
+
## 256 and Truecolor color support
|
|
225
|
+
|
|
226
|
+
Chalk supports 256 colors and [Truecolor](https://github.com/termstandard/colors) (16 million colors) on supported terminal apps.
|
|
227
|
+
|
|
228
|
+
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
|
|
229
|
+
|
|
230
|
+
Examples:
|
|
231
|
+
|
|
232
|
+
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
|
233
|
+
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
|
234
|
+
|
|
235
|
+
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `hex` for foreground colors and `bgHex` for background colors).
|
|
236
|
+
|
|
237
|
+
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
|
238
|
+
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
|
239
|
+
|
|
240
|
+
The following color models can be used:
|
|
241
|
+
|
|
242
|
+
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
|
243
|
+
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
|
244
|
+
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
|
245
|
+
|
|
246
|
+
## Browser support
|
|
247
|
+
|
|
248
|
+
Since Chrome 69, ANSI escape codes are natively supported in the developer console.
|
|
249
|
+
|
|
250
|
+
## Windows
|
|
251
|
+
|
|
252
|
+
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
|
253
|
+
|
|
254
|
+
## FAQ
|
|
255
|
+
|
|
256
|
+
### Why not switch to a smaller coloring package?
|
|
257
|
+
|
|
258
|
+
Chalk may be larger, but there is a reason for that. It offers a more user-friendly API, well-documented types, supports millions of colors, and covers edge cases that smaller alternatives miss. Chalk is mature, reliable, and built to last.
|
|
259
|
+
|
|
260
|
+
But beyond the technical aspects, there's something more critical: trust and long-term maintenance. I have been active in open source for over a decade, and I'm committed to keeping Chalk maintained. Smaller packages might seem appealing now, but there's no guarantee they will be around for the long term, or that they won't become malicious over time.
|
|
261
|
+
|
|
262
|
+
Chalk is also likely already in your dependency tree (since 100K+ packages depend on it), so switching won’t save space—in fact, it might increase it. npm deduplicates dependencies, so multiple Chalk instances turn into one, but adding another package alongside it will increase your overall size.
|
|
263
|
+
|
|
264
|
+
If the goal is to clean up the ecosystem, switching away from Chalk won’t even make a dent. The real problem lies with packages that have very deep dependency trees (for example, those including a lot of polyfills). Chalk has no dependencies. It's better to focus on impactful changes rather than minor optimizations.
|
|
265
|
+
|
|
266
|
+
If absolute package size is important to you, I also maintain [yoctocolors](https://github.com/sindresorhus/yoctocolors), one of the smallest color packages out there.
|
|
267
|
+
|
|
268
|
+
*\- [Sindre](https://github.com/sindresorhus)*
|
|
269
|
+
|
|
270
|
+
### But the smaller coloring package has benchmarks showing it is faster
|
|
271
|
+
|
|
272
|
+
[Micro-benchmarks are flawed](https://sindresorhus.com/blog/micro-benchmark-fallacy) because they measure performance in unrealistic, isolated scenarios, often giving a distorted view of real-world performance. Don't believe marketing fluff. All the coloring packages are more than fast enough.
|
|
273
|
+
|
|
274
|
+
## Related
|
|
275
|
+
|
|
276
|
+
- [chalk-template](https://github.com/chalk/chalk-template) - [Tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) support for this module
|
|
277
|
+
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
|
278
|
+
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
|
279
|
+
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
|
280
|
+
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
|
|
281
|
+
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
|
|
282
|
+
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
|
283
|
+
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
|
284
|
+
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
|
285
|
+
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
|
286
|
+
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
|
|
287
|
+
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
|
288
|
+
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
|
289
|
+
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
|
290
|
+
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
|
291
|
+
|
|
292
|
+
*(Not accepting additional entries)*
|
|
293
|
+
|
|
294
|
+
## Maintainers
|
|
295
|
+
|
|
296
|
+
- [Sindre Sorhus](https://github.com/sindresorhus)
|
|
297
|
+
- [Josh Junon](https://github.com/qix-)
|