@zokugun/cli-utils 0.3.0 → 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.
@@ -14,6 +14,7 @@ exports.finishTimer = finishTimer;
14
14
  exports.info = info;
15
15
  exports.newLine = newLine;
16
16
  exports.pauseProgress = pauseProgress;
17
+ exports.print = print;
17
18
  exports.resumeProgress = resumeProgress;
18
19
  exports.showProgress = showProgress;
19
20
  exports.stopProgress = stopProgress;
@@ -23,6 +24,7 @@ const node_process_1 = __importDefault(require("node:process"));
23
24
  const log_update_plus_1 = require("@zokugun/log-update-plus");
24
25
  const ansi_colors_1 = __importDefault(require("ansi-colors"));
25
26
  const cli_spinners_1 = __importDefault(require("cli-spinners"));
27
+ const is_ci_js_1 = require("./utils/is-ci.cjs");
26
28
  const { dots } = cli_spinners_1.default;
27
29
  let $loading;
28
30
  let $progessFn;
@@ -84,21 +86,29 @@ function pauseProgress() {
84
86
  clearInterval($loading);
85
87
  log_update_plus_1.stdout.render('');
86
88
  } // }}}
89
+ function print(message) {
90
+ log_update_plus_1.stdout.persist(message);
91
+ } // }}}
87
92
  function resumeProgress() {
88
93
  if ($progessFn) {
89
94
  $loading = setInterval($progessFn, cli_spinners_1.default.dots.interval);
90
95
  }
91
96
  } // }}}
92
97
  function showProgress(label) {
93
- clearInterval($loading);
94
- let index = 0;
95
- $progessFn = () => {
96
- if (!$loading) {
97
- return;
98
- }
99
- log_update_plus_1.stdout.render(`${ansi_colors_1.default.cyan(dots.frames[index = ++index % dots.frames.length])} ${label}`);
100
- };
101
- $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
+ }
102
112
  } // }}}
103
113
  function stopProgress(message = '') {
104
114
  clearInterval($loading);
@@ -125,6 +135,7 @@ exports.default = {
125
135
  info,
126
136
  newLine,
127
137
  pauseProgress,
138
+ print,
128
139
  resumeProgress,
129
140
  showProgress,
130
141
  stopProgress,
@@ -14,6 +14,7 @@ export declare function finishTimer(duration?: number): void;
14
14
  export declare function info(message: string): void;
15
15
  export declare function newLine(): void;
16
16
  export declare function pauseProgress(): void;
17
+ export declare function print(message: string): void;
17
18
  export declare function resumeProgress(): void;
18
19
  export declare function showProgress(label: string): void;
19
20
  export declare function stopProgress(message?: string): void;
@@ -31,6 +32,7 @@ declare const _default: {
31
32
  info: typeof info;
32
33
  newLine: typeof newLine;
33
34
  pauseProgress: typeof pauseProgress;
35
+ print: typeof print;
34
36
  resumeProgress: typeof resumeProgress;
35
37
  showProgress: typeof showProgress;
36
38
  stopProgress: typeof stopProgress;
@@ -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;
@@ -14,6 +14,7 @@ export declare function finishTimer(duration?: number): void;
14
14
  export declare function info(message: string): void;
15
15
  export declare function newLine(): void;
16
16
  export declare function pauseProgress(): void;
17
+ export declare function print(message: string): void;
17
18
  export declare function resumeProgress(): void;
18
19
  export declare function showProgress(label: string): void;
19
20
  export declare function stopProgress(message?: string): void;
@@ -31,6 +32,7 @@ declare const _default: {
31
32
  info: typeof info;
32
33
  newLine: typeof newLine;
33
34
  pauseProgress: typeof pauseProgress;
35
+ print: typeof print;
34
36
  resumeProgress: typeof resumeProgress;
35
37
  showProgress: typeof showProgress;
36
38
  stopProgress: typeof stopProgress;
@@ -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;
@@ -63,21 +64,29 @@ export function pauseProgress() {
63
64
  clearInterval($loading);
64
65
  stdout.render('');
65
66
  } // }}}
67
+ export function print(message) {
68
+ stdout.persist(message);
69
+ } // }}}
66
70
  export function resumeProgress() {
67
71
  if ($progessFn) {
68
72
  $loading = setInterval($progessFn, cliSpinners.dots.interval);
69
73
  }
70
74
  } // }}}
71
75
  export function showProgress(label) {
72
- clearInterval($loading);
73
- let index = 0;
74
- $progessFn = () => {
75
- if (!$loading) {
76
- return;
77
- }
78
- stdout.render(`${c.cyan(dots.frames[index = ++index % dots.frames.length])} ${label}`);
79
- };
80
- $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
+ }
81
90
  } // }}}
82
91
  export function stopProgress(message = '') {
83
92
  clearInterval($loading);
@@ -104,6 +113,7 @@ export default {
104
113
  info,
105
114
  newLine,
106
115
  pauseProgress,
116
+ print,
107
117
  resumeProgress,
108
118
  showProgress,
109
119
  stopProgress,
@@ -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.0",
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",