Skip to content

Commit

Permalink
chore: update repository (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreDemailly authored Jul 17, 2024
1 parent eeb3d39 commit 4b32b1d
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 50 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
"parserOptions": {
"sourceType": "module",
"requireConfigFile": false
}
},
"ignorePatterns": [
"node_modules/",
"dist/"
]
}
14 changes: 7 additions & 7 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [master]
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
branches: [main]
schedule:
- cron: '20 18 * * 6'

Expand All @@ -43,15 +43,15 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
uses: github/codeql-action/init@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -65,7 +65,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
uses: github/codeql-action/autobuild@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -78,6 +78,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
uses: github/codeql-action/analyze@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
with:
category: "/language:${{matrix.language}}"
14 changes: 9 additions & 5 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Node.js CI

on:
push:
branches: [master]
branches: [main]
pull_request:

permissions:
Expand All @@ -13,19 +13,23 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [20.x]
fail-fast: false
steps:
- name: Harden Runner
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm i
- name: Lint
run: npm run lint
- name: Build
run: npm run build
- name: Run tests
run: npm run test
10 changes: 5 additions & 5 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
schedule:
- cron: '21 19 * * 2'
push:
branches: [ "master" ]
branches: [ "main" ]

# Declare default permissions as read only.
permissions: read-all
Expand All @@ -32,12 +32,12 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -59,14 +59,14 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
uses: github/codeql-action/upload-sarif@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
with:
sarif_file: results.sarif
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ small and all contributions are valued.

This guide explains the process for contributing to the TopCli project's.

## [Code of Conduct](https://github.com/TopCli/Governance/blob/master/CODE_OF_CONDUCT.md)
## [Code of Conduct](https://github.com/TopCli/Governance/blob/main/CODE_OF_CONDUCT.md)

The TopCli project has a
[Code of Conduct](https://github.com/TopCli/Governance/blob/master/CODE_OF_CONDUCT.md)
[Code of Conduct](https://github.com/TopCli/Governance/blob/main/CODE_OF_CONDUCT.md)
that *all* contributors are expected to follow. This code describes the
*minimum* behavior expectations for all contributors.

See [details on our policy on Code of Conduct](https://github.com/TopCli/Governance/blob/master/COC_POLICY.md).
See [details on our policy on Code of Conduct](https://github.com/TopCli/Governance/blob/main/COC_POLICY.md).

<a id="developers-certificate-of-origin"></a>
## Developer's Certificate of Origin 1.1
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 TopCli
Copyright (c) 2021-2024 TopCli

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Spinner
![version](https://img.shields.io/badge/dynamic/json.svg?style=for-the-badge&url=https://raw.githubusercontent.com/TopCli/Spinner/master/package.json&query=$.version&label=Version)

![version](https://img.shields.io/badge/dynamic/json.svg?style=for-the-badge&url=https://raw.githubusercontent.com/TopCli/Spinner/main/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=for-the-badge)](https://github.com/TopCli/Spinner/commit-activity)
[![mit](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://github.com/TopCli/Spinner/blob/master/LICENSE)
[![mit](https://img.shields.io/badge/License-MIT-green.svg?style=for-the-badge)](https://github.com/TopCli/Spinner/blob/main/LICENSE)
[![scorecard](https://api.securityscorecards.dev/projects/github.com/TopCli/Spinner/badge?style=for-the-badge)](https://ossf.github.io/scorecard-visualizer/#/projects/github.com/TopCli/Spinner)
![build](https://img.shields.io/github/actions/workflow/status/TopCli/Spinner/node.js.yml?style=for-the-badge)

Asynchronous CLI Spinner. This package has been created to handle simultaneous/multiple spinner at a time. The package has been inspired by [Ora](https://github.com/sindresorhus/ora) but in Asynchronous.
Asynchronous CLI Spinner. This package has been created to handle simultaneous/multiple spinner at a time. The package has been inspired by [Ora](https://github.com/sindresorhus/ora) but asynchronous.

All available spinners are part of [cli-spinners](https://github.com/sindresorhus/cli-spinners#readme) package.

Expand All @@ -13,7 +15,8 @@ All available spinners are part of [cli-spinners](https://github.com/sindresorhu
</p>

## Requirements
- [Node.js](https://nodejs.org/en/) v18 or higher

- [Node.js](https://nodejs.org/en/) v20 or higher

## Getting Started

Expand All @@ -26,6 +29,7 @@ $ yarn add @topcli/spinner
```

## Usage example

Create and wait multiple spinner at a time.

```js
Expand Down Expand Up @@ -68,7 +72,8 @@ await timers.setTimeout(1_000);
spinner.succeed("All done !");
```

> 👀 When you are working on a CLI that can be used as an API too, the **verbose** option allow you to disable the Spinner.
> [!TIP]
> When you are working on a CLI that can be used as an API too, the **verbose** option allow you to disable the Spinner.
## API

Expand Down Expand Up @@ -100,7 +105,8 @@ export interface ISpinnerOptions {
}
```

> 👀 Check [cli-spinners](https://github.com/sindresorhus/cli-spinners#readme) for all the spinner name.
> [!TIP]
> Check [cli-spinners](https://github.com/sindresorhus/cli-spinners#readme) for all the spinner name.
```js
new Spinner({ name: "dots2" });
Expand Down
26 changes: 10 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
"prepublishOnly": "npm run build",
"test-only": "node --no-warnings --loader tsx --test test/Spinner.spec.ts",
"test-only": "npx tsx --test test/Spinner.spec.ts",
"test": "npm run lint && npm run coverage",
"coverage": "c8 -r html npm run test-only",
"lint": "eslint ."
Expand All @@ -26,17 +26,12 @@
},
"keywords": [
"CLI",
"SlimIO",
"TopCLI",
"multiple",
"simultaneous",
"async",
"asynchronous",
"spinner",
"spinners",
"ora",
"listr",
"terminal",
"term",
"console",
"progress"
],
Expand All @@ -53,22 +48,21 @@
"@topcli/wcwidth": "^1.0.1",
"ansi-regex": "^6.0.1",
"cli-cursor": "^4.0.0",
"cli-spinners": "^2.9.0",
"cli-spinners": "^3.1.0",
"kleur": "^4.1.5",
"strip-ansi": "^7.1.0"
},
"devDependencies": {
"@nodesecure/eslint-config": "^1.7.0",
"@nodesecure/eslint-config": "^1.9.0",
"@slimio/is": "^2.0.0",
"@types/node": "^20.3.3",
"c8": "^8.0.0",
"eslint": "^8.44.0",
"tsup": "^7.1.0",
"tsx": "^3.12.7",
"typescript": "^5.1.6"
"@types/node": "^20.14.11",
"c8": "^10.1.2",
"tsup": "^8.1.0",
"tsx": "^4.16.2",
"typescript": "^5.5.3"
},
"engines": {
"node": ">=16"
"node": ">=20"
},
"type": "module"
}
10 changes: 5 additions & 5 deletions src/Spinner.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import readline from "node:readline";
import * as TTY from "node:tty";

// Import Third-party Dependencies
import cliSpinners from "cli-spinners";
import cliSpinners, { type SpinnerName, type Spinner as CliSpinner } from "cli-spinners";
import stripAnsi from "strip-ansi";
import ansiRegex from "ansi-regex";
import wcwidth from "@topcli/wcwidth";
Expand All @@ -15,7 +15,7 @@ import kleur from "kleur";
let internalSpinnerCount = 0;

// CONSTANTS
const kDefaultSpinnerName = "dots" satisfies cliSpinners.SpinnerName;
const kDefaultSpinnerName = "dots" satisfies SpinnerName;
const kLogSymbols = process.platform !== "win32" || process.env.CI || process.env.TERM === "xterm-256color" ?
{ success: kleur.bold().green("✔"), error: kleur.bold().red("✖") } :
{ success: kleur.bold().green("√"), error: kleur.bold().red("×") };
Expand All @@ -26,7 +26,7 @@ export interface ISpinnerOptions {
*
* @default "dots"
*/
name?: cliSpinners.SpinnerName;
name?: SpinnerName;
/**
* Spinner frame color
*
Expand Down Expand Up @@ -54,12 +54,12 @@ export class Spinner extends EventEmitter {

#verbose = true;
#started = false;
#spinner: cliSpinners.Spinner;
#spinner: CliSpinner;
#text = "";
#prefix = "";
#color: (stdout: string) => string;

#interval: NodeJS.Timer | null = null;
#interval: NodeJS.Timeout | null = null;
#frameIndex = 0;
#spinnerPos = 0;
#startTime: number;
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"target": "ES2021",
"outDir": "dist",
"module": "NodeNext",
"moduleResolution": "node",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"resolveJsonModule": true,
"skipDefaultLibCheck": true,
Expand Down

0 comments on commit 4b32b1d

Please sign in to comment.