@zokugun/cli-utils 0.3.1 → 0.3.2

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.
@@ -24,6 +24,7 @@ const node_process_1 = __importDefault(require("node:process"));
24
24
  const log_update_plus_1 = require("@zokugun/log-update-plus");
25
25
  const ansi_colors_1 = __importDefault(require("ansi-colors"));
26
26
  const cli_spinners_1 = __importDefault(require("cli-spinners"));
27
+ const is_ci_js_1 = require("./utils/is-ci.cjs");
27
28
  const { dots } = cli_spinners_1.default;
28
29
  let $loading;
29
30
  let $progessFn;
@@ -94,15 +95,20 @@ function resumeProgress() {
94
95
  }
95
96
  } // }}}
96
97
  function showProgress(label) {
97
- clearInterval($loading);
98
- let index = 0;
99
- $progessFn = () => {
100
- if (!$loading) {
101
- return;
102
- }
103
- log_update_plus_1.stdout.render(`${ansi_colors_1.default.cyan(dots.frames[index = ++index % dots.frames.length])} ${label}`);
104
- };
105
- $loading = setInterval($progessFn, cli_spinners_1.default.dots.interval);
98
+ if ((0, is_ci_js_1.isCI)()) {
99
+ log_update_plus_1.stdout.render(label);
100
+ }
101
+ else {
102
+ clearInterval($loading);
103
+ let index = 0;
104
+ $progessFn = () => {
105
+ if (!$loading) {
106
+ return;
107
+ }
108
+ log_update_plus_1.stdout.render(`${ansi_colors_1.default.cyan(dots.frames[index = ++index % dots.frames.length])} ${label}`);
109
+ };
110
+ $loading = setInterval($progessFn, cli_spinners_1.default.dots.interval);
111
+ }
106
112
  } // }}}
107
113
  function stopProgress(message = '') {
108
114
  clearInterval($loading);
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isCI = isCI;
7
+ const node_process_1 = __importDefault(require("node:process"));
8
+ const PROVIDERS = [
9
+ 'CI_OVERRIDE',
10
+ 'CI_SERVER',
11
+ 'GITHUB_ACTIONS',
12
+ 'GITLAB_CI',
13
+ 'TRAVIS',
14
+ 'CIRCLECI',
15
+ 'TF_BUILD', // Azure Pipelines
16
+ 'BUILDKITE',
17
+ 'DRONE',
18
+ 'APPVEYOR',
19
+ 'CODEBUILD_BUILD_ID', // AWS CodeBuild
20
+ 'BITBUCKET_COMMIT',
21
+ 'BITBUCKET_BUILD_NUMBER',
22
+ 'TEAMCITY_VERSION',
23
+ 'JENKINS_URL',
24
+ 'CONTINUOUS_INTEGRATION',
25
+ ];
26
+ const TRUTHY = new Set(['1', 'true', 'TRUE', 'True', 'yes', 'on']);
27
+ function isCI(environment = node_process_1.default.env) {
28
+ if (environment.CI && TRUTHY.has(environment.CI)) {
29
+ return true;
30
+ }
31
+ for (const key of PROVIDERS) {
32
+ const value = environment[key];
33
+ if (value && value.length > 0) {
34
+ return true;
35
+ }
36
+ }
37
+ return false;
38
+ }
@@ -0,0 +1 @@
1
+ export declare function isCI(environment?: NodeJS.ProcessEnv): boolean;
@@ -2,6 +2,7 @@ import process from 'node:process';
2
2
  import { stdout } from '@zokugun/log-update-plus';
3
3
  import c from 'ansi-colors';
4
4
  import cliSpinners from 'cli-spinners';
5
+ import { isCI } from './utils/is-ci.mjs';
5
6
  const { dots } = cliSpinners;
6
7
  let $loading;
7
8
  let $progessFn;
@@ -72,15 +73,20 @@ export function resumeProgress() {
72
73
  }
73
74
  } // }}}
74
75
  export function showProgress(label) {
75
- clearInterval($loading);
76
- let index = 0;
77
- $progessFn = () => {
78
- if (!$loading) {
79
- return;
80
- }
81
- stdout.render(`${c.cyan(dots.frames[index = ++index % dots.frames.length])} ${label}`);
82
- };
83
- $loading = setInterval($progessFn, cliSpinners.dots.interval);
76
+ if (isCI()) {
77
+ stdout.render(label);
78
+ }
79
+ else {
80
+ clearInterval($loading);
81
+ let index = 0;
82
+ $progessFn = () => {
83
+ if (!$loading) {
84
+ return;
85
+ }
86
+ stdout.render(`${c.cyan(dots.frames[index = ++index % dots.frames.length])} ${label}`);
87
+ };
88
+ $loading = setInterval($progessFn, cliSpinners.dots.interval);
89
+ }
84
90
  } // }}}
85
91
  export function stopProgress(message = '') {
86
92
  clearInterval($loading);
@@ -0,0 +1 @@
1
+ export declare function isCI(environment?: NodeJS.ProcessEnv): boolean;
@@ -0,0 +1,32 @@
1
+ import process from 'node:process';
2
+ const PROVIDERS = [
3
+ 'CI_OVERRIDE',
4
+ 'CI_SERVER',
5
+ 'GITHUB_ACTIONS',
6
+ 'GITLAB_CI',
7
+ 'TRAVIS',
8
+ 'CIRCLECI',
9
+ 'TF_BUILD', // Azure Pipelines
10
+ 'BUILDKITE',
11
+ 'DRONE',
12
+ 'APPVEYOR',
13
+ 'CODEBUILD_BUILD_ID', // AWS CodeBuild
14
+ 'BITBUCKET_COMMIT',
15
+ 'BITBUCKET_BUILD_NUMBER',
16
+ 'TEAMCITY_VERSION',
17
+ 'JENKINS_URL',
18
+ 'CONTINUOUS_INTEGRATION',
19
+ ];
20
+ const TRUTHY = new Set(['1', 'true', 'TRUE', 'True', 'yes', 'on']);
21
+ export function isCI(environment = process.env) {
22
+ if (environment.CI && TRUTHY.has(environment.CI)) {
23
+ return true;
24
+ }
25
+ for (const key of PROVIDERS) {
26
+ const value = environment[key];
27
+ if (value && value.length > 0) {
28
+ return true;
29
+ }
30
+ }
31
+ return false;
32
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zokugun/cli-utils",
3
3
  "description": "Utils for CLI app",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "author": {
6
6
  "name": "Baptiste Augrain",
7
7
  "email": "daiyam@zokugun.org"
@@ -70,21 +70,22 @@
70
70
  "audit:fix": "npm audit fix --min-release-age=0",
71
71
  "build": "npm run clean && npm run build:lib",
72
72
  "build:lib": "tsc-leda generate",
73
- "build:package": "tsc-leda update-package",
73
+ "build:package": "tsc-leda update-package && npm run lint:package",
74
74
  "ci:lint": "zizmor .",
75
75
  "ci:lint:fix": "zizmor . --fix=all",
76
76
  "clean": "rimraf lib .src",
77
77
  "compile:src": "tsc -p src",
78
78
  "lint": "xo",
79
- "lint:all": "fixpack && npm audit && npm run ci:lint && npm run lint",
79
+ "lint:all": "npm audit && npm run lint:package && npm run ci:lint && npm run lint",
80
80
  "lint:fix": "xo --fix",
81
+ "lint:package": "fixpack || true",
81
82
  "postinstall": "patch-package",
82
83
  "prepack": "npm run build",
83
- "prepare": "husky; fixpack || true",
84
+ "prepare": "husky; npm run lint:package",
84
85
  "release": "release-it",
85
86
  "update:artifacts": "artifact update",
86
- "update:ci": "PINACT_MIN_AGE=7 pinact run",
87
- "update:deps": "taze",
87
+ "update:ci": "PINACT_MIN_AGE=7 pinact run --update",
88
+ "update:deps": "taze --all",
88
89
  "watch:build": "tsc-watch -p src --onSuccess 'npm run build'",
89
90
  "watch:src": "tsc-watch -p src"
90
91
  },
@@ -98,14 +99,15 @@
98
99
  "patch-package": "8.0.1"
99
100
  },
100
101
  "devDependencies": {
101
- "@commitlint/cli": "19.8.1",
102
- "@commitlint/config-conventional": "19.8.1",
102
+ "@commitlint/cli": "20.5.2",
103
+ "@commitlint/config-conventional": "20.5.0",
103
104
  "@types/node": "20.19.39",
104
- "@zokugun/tsc-leda": "0.3.2",
105
+ "@zokugun/tsc-leda": "0.4.0",
105
106
  "fixpack": "4.0.0",
106
107
  "husky": "9.1.7",
107
108
  "lint-staged": "16.4.0",
108
- "release-it": "20.0.0-1",
109
+ "release-it": "20.0.1",
110
+ "rimraf": "6.1.3",
109
111
  "taze": "19.11.0",
110
112
  "tsc-watch": "7.2.0",
111
113
  "typescript": "5.9.3",