@git.zone/cli 7.2.1 → 7.2.3

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.
@@ -4,7 +4,7 @@ import { createReadStream, openAsBlob } from 'node:fs';
4
4
  import * as path from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { createHash } from 'node:crypto';
7
- import { execFile } from 'node:child_process';
7
+ import { execFile, spawn } from 'node:child_process';
8
8
  import { promisify } from 'node:util';
9
9
  import { GiteaSealedRelease } from './gitzone-release-api.mjs';
10
10
 
@@ -53,15 +53,50 @@ try {
53
53
  requireValue(process.env.GITHUB_OUTPUT, 'Expected the Actions step output file.');
54
54
  await fs.appendFile(process.env.GITHUB_OUTPUT, Object.entries(values).map(([key, value]) => `${key}=${value}\n`).join(''));
55
55
  };
56
- const runAdapter = async (args) => {
56
+ const runAdapter = (args) => {
57
57
  requireValue(Array.isArray(args) && args.length > 0 && args.every((value) => typeof value === 'string' && !value.includes('\0')), 'Expected an explicit component command argument array.');
58
58
  const environment = { ...process.env };
59
59
  delete environment.GITHUB_TOKEN;
60
60
  delete environment.ACTIONS_RUNTIME_TOKEN;
61
- let result;
62
- try { result = await exec(args[0], args.slice(1), { cwd: root, env: environment, maxBuffer: 1024 * 1024, timeout: 30 * 60 * 1000 }); }
63
- catch { throw new Error('Component preparation or verification failed. Run its committed command to inspect the build.'); }
64
- try { return JSON.parse(result.stdout); } catch { throw new Error('Component command must return one JSON packaging result.'); }
61
+ const name = `Component command ${JSON.stringify(args)}`;
62
+ // The component's stderr goes straight to the job log; stdout carries only its JSON packaging result.
63
+ return new Promise((resolve, reject) => {
64
+ const child = spawn(args[0], args.slice(1), { cwd: root, env: environment, stdio: ['ignore', 'pipe', 'inherit'] });
65
+ const chunks = [];
66
+ let size = 0;
67
+ let settled = false;
68
+ const settle = (error, value) => {
69
+ if (settled) return;
70
+ settled = true;
71
+ clearTimeout(timer);
72
+ if (error) reject(error); else resolve(value);
73
+ };
74
+ const stop = (message) => {
75
+ if (settled) return;
76
+ child.stdout.destroy();
77
+ child.kill('SIGKILL');
78
+ settle(new Error(message));
79
+ };
80
+ const timer = setTimeout(() => stop(`${name} exceeded its 30-minute limit and was stopped.`), 30 * 60 * 1000);
81
+ child.stdout.on('data', (chunk) => {
82
+ size += chunk.length;
83
+ if (size > 1024 * 1024) stop(`${name} wrote more than 1 MiB to stdout and was stopped.`);
84
+ else chunks.push(chunk);
85
+ });
86
+ child.on('error', (error) => settle(new Error(`${name} could not be started (${error.code ?? 'unknown error'}).`)));
87
+ child.on('close', (code, signal) => {
88
+ if (code !== 0) {
89
+ settle(new Error(`${name} failed with ${code === null ? `signal ${signal}` : `exit code ${code}`}; its stderr is above.`));
90
+ return;
91
+ }
92
+ let result;
93
+ try { result = JSON.parse(Buffer.concat(chunks).toString('utf8')); } catch {
94
+ settle(new Error(`${name} must return one JSON packaging result on stdout.`));
95
+ return;
96
+ }
97
+ settle(null, result);
98
+ });
99
+ });
65
100
  };
66
101
  const verify = async (result) => {
67
102
  requireValue(typeof result?.directory === 'string' && /^[a-f0-9]{64}$/.test(result.manifestSha256), 'Invalid component packaging result.');
@@ -83,7 +118,7 @@ try {
83
118
  requireValue(await fs.lstat(output).then(() => false, (error) => { if (error.code === 'ENOENT') return true; throw error; }),
84
119
  'Fresh preparation requires an absent output root; reuse retained output instead.');
85
120
  const verified = await verify(await runAdapter(config.prepareCommand));
86
- await fs.writeFile(receiptFile, `${JSON.stringify({ format: 'gitzone.sealed-release.v1', tag, commit,
121
+ await fs.writeFile(receiptFile, `${JSON.stringify({ format: 'gitzone.sealed-release', tag, commit,
87
122
  directory: path.basename(verified.directory), manifestSha256: verified.manifestSha256 }, null, 2)}\n`, { flag: 'wx' });
88
123
  await setOutputs({ manifest: verified.manifestSha256 });
89
124
  } else {
@@ -96,7 +131,7 @@ try {
96
131
  await fs.rename(incoming, output);
97
132
  }
98
133
  const receipt = await readJson(receiptFile);
99
- requireValue(receipt.format === 'gitzone.sealed-release.v1' && receipt.tag === tag && receipt.commit === commit &&
134
+ requireValue(receipt.format === 'gitzone.sealed-release' && receipt.tag === tag && receipt.commit === commit &&
100
135
  /^[a-zA-Z0-9_.-]+$/.test(receipt.directory) && /^[a-f0-9]{64}$/.test(receipt.manifestSha256) &&
101
136
  (!process.env.EXPECTED_MANIFEST || process.env.EXPECTED_MANIFEST === receipt.manifestSha256), 'Retained release receipt mismatch.');
102
137
  const verified = await verify(await runAdapter(config.verifyCommand));
@@ -115,7 +150,7 @@ try {
115
150
  } else console.log(JSON.stringify({ restored: true, manifestSha256: verified.manifestSha256 }));
116
151
  }
117
152
  } catch (error) {
118
- // Deliberately omit transport errors, subprocess output, response bodies and token-bearing URLs.
153
+ // Deliberately omit transport errors, response bodies and token-bearing URLs. Component stderr is already in the job log.
119
154
  console.error(error instanceof Error && error.message && !error.message.includes('\n') && !error.message.includes('://')
120
155
  ? error.message : 'Sealed release operation failed. Retain the original run and its artifacts.');
121
156
  process.exitCode = 1;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/cli',
6
- version: '7.2.1',
6
+ version: '7.2.3',
7
7
  description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxlQUFlO0lBQ3JCLE9BQU8sRUFBRSxPQUFPO0lBQ2hCLFdBQVcsRUFBRSwrTEFBK0w7Q0FDN00sQ0FBQSJ9
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@git.zone/cli",
3
3
  "private": false,
4
- "version": "7.2.1",
4
+ "version": "7.2.3",
5
5
  "description": "A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.",
6
6
  "main": "dist_ts/index.js",
7
7
  "typings": "dist_ts/index.d.ts",
package/readme.md CHANGED
@@ -978,6 +978,12 @@ Both commands return exactly one JSON object on stdout with `directory` and
978
978
  the configured output root and saves every input descriptor needed for reuse.
979
979
  Verification restores that same result without compiling or repacking. Commands
980
980
  are explicit executable/argument arrays; GitZone does not interpolate a shell.
981
+ A command's stderr goes straight to the job log, so write build progress and
982
+ diagnostics there and keep stdout for the JSON result. The command runs without
983
+ `GITHUB_TOKEN` and `ACTIONS_RUNTIME_TOKEN`. When it exits non-zero or is killed,
984
+ the release step fails with a line that names the command and its exit code or
985
+ signal, below the command's own stderr. A command that writes more than 1 MiB to
986
+ stdout or runs longer than 30 minutes is stopped and fails the step by name.
981
987
  Run `gitzone format --only assets --write --yes` and commit the generated files.
982
988
  The normal authorized `gitzone release -y` pushes the tag that triggers this CI flow.
983
989
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/cli',
6
- version: '7.2.1',
6
+ version: '7.2.3',
7
7
  description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
8
8
  }
@@ -1,115 +0,0 @@
1
- # gitzone ci_default
2
- image: code.foss.global/hosttoday/ht-docker-node:npmci
3
-
4
- cache:
5
- paths:
6
- - .npmci_cache/
7
- key: '$CI_BUILD_STAGE'
8
-
9
- stages:
10
- - security
11
- - test
12
- - metadata
13
-
14
- before_script:
15
- - pnpm install -g pnpm
16
- - pnpm install -g @ship.zone/npmci
17
- - npmci npm prepare
18
-
19
- # ====================
20
- # security stage
21
- # ====================
22
- # ====================
23
- # security stage
24
- # ====================
25
- auditProductionDependencies:
26
- image: code.foss.global/hosttoday/ht-docker-node:npmci
27
- stage: security
28
- script:
29
- - npmci command npm config set registry https://registry.npmjs.org
30
- - npmci command pnpm audit --audit-level=high --prod
31
- tags:
32
- - private
33
- - docker
34
- allow_failure: true
35
-
36
- auditDevDependencies:
37
- image: code.foss.global/hosttoday/ht-docker-node:npmci
38
- stage: security
39
- script:
40
- - npmci command npm config set registry https://registry.npmjs.org
41
- - npmci command pnpm audit --audit-level=high --dev
42
- tags:
43
- - private
44
- - docker
45
- allow_failure: true
46
-
47
- # ====================
48
- # test stage
49
- # ====================
50
-
51
- testStable:
52
- stage: test
53
- script:
54
- - npmci node install stable
55
- - npmci npm install
56
- - npmci npm test
57
- coverage: /\d+.?\d+?\%\s*coverage/
58
- tags:
59
- - docker
60
-
61
- testBuild:
62
- stage: test
63
- script:
64
- - npmci node install stable
65
- - npmci npm install
66
- - npmci npm build
67
- coverage: /\d+.?\d+?\%\s*coverage/
68
- tags:
69
- - docker
70
-
71
- # ====================
72
- # metadata stage
73
- # ====================
74
- codequality:
75
- stage: metadata
76
- allow_failure: true
77
- only:
78
- - tags
79
- script:
80
- - npmci command npm install -g typescript
81
- - npmci npm prepare
82
- - npmci npm install
83
- tags:
84
- - private
85
- - docker
86
- - priv
87
-
88
- trigger:
89
- stage: metadata
90
- script:
91
- - npmci trigger
92
- only:
93
- - tags
94
- tags:
95
- - private
96
- - docker
97
- - notprivileged
98
-
99
- pages:
100
- stage: metadata
101
- script:
102
- - npmci node install stable
103
- - npmci npm install
104
- - npmci command npm run buildDocs
105
- tags:
106
- - private
107
- - docker
108
- - notprivileged
109
- only:
110
- - tags
111
- artifacts:
112
- expire_in: 1 week
113
- paths:
114
- - public
115
- allow_failure: true
@@ -1,120 +0,0 @@
1
- # gitzone ci_default_private
2
- image: code.foss.global/hosttoday/ht-docker-node:npmci
3
-
4
- cache:
5
- paths:
6
- - .npmci_cache/
7
- key: '$CI_BUILD_STAGE'
8
-
9
- stages:
10
- - security
11
- - test
12
- - metadata
13
-
14
- before_script:
15
- - pnpm install -g pnpm
16
- - pnpm install -g @ship.zone/npmci
17
- - npmci npm prepare
18
-
19
- # ====================
20
- # security stage
21
- # ====================
22
- # ====================
23
- # security stage
24
- # ====================
25
- auditProductionDependencies:
26
- image: code.foss.global/hosttoday/ht-docker-node:npmci
27
- stage: security
28
- script:
29
- - npmci command npm config set registry https://registry.npmjs.org
30
- - npmci command pnpm audit --audit-level=high --prod
31
- tags:
32
- - private
33
- - docker
34
- allow_failure: true
35
-
36
- auditDevDependencies:
37
- image: code.foss.global/hosttoday/ht-docker-node:npmci
38
- stage: security
39
- script:
40
- - npmci command npm config set registry https://registry.npmjs.org
41
- - npmci command pnpm audit --audit-level=high --dev
42
- tags:
43
- - private
44
- - docker
45
- allow_failure: true
46
-
47
- # ====================
48
- # test stage
49
- # ====================
50
-
51
- testStable:
52
- stage: test
53
- script:
54
- - npmci node install stable
55
- - npmci npm install
56
- - npmci npm test
57
- coverage: /\d+.?\d+?\%\s*coverage/
58
- tags:
59
- - private
60
- - docker
61
- - notprivileged
62
-
63
- testBuild:
64
- stage: test
65
- script:
66
- - npmci node install stable
67
- - npmci npm install
68
- - npmci command npm run build
69
- coverage: /\d+.?\d+?\%\s*coverage/
70
- tags:
71
- - private
72
- - docker
73
- - notprivileged
74
-
75
- # ====================
76
- # metadata stage
77
- # ====================
78
- codequality:
79
- stage: metadata
80
- allow_failure: true
81
- only:
82
- - tags
83
- script:
84
- - npmci command npm install -g typescript
85
- - npmci npm prepare
86
- - npmci npm install
87
- tags:
88
- - private
89
- - docker
90
- - priv
91
-
92
- trigger:
93
- stage: metadata
94
- script:
95
- - npmci trigger
96
- only:
97
- - tags
98
- tags:
99
- - private
100
- - docker
101
- - notprivileged
102
-
103
- pages:
104
- stage: metadata
105
- script:
106
- - npmci node install lts
107
- - npmci command npm install -g @git.zone/tsdoc
108
- - npmci npm install
109
- - npmci command tsdoc
110
- tags:
111
- - private
112
- - docker
113
- - notprivileged
114
- only:
115
- - tags
116
- artifacts:
117
- expire_in: 1 week
118
- paths:
119
- - public
120
- allow_failure: true
@@ -1,107 +0,0 @@
1
- # gitzone ci_docker
2
- image: code.foss.global/hosttoday/ht-docker-node:npmci
3
-
4
- cache:
5
- paths:
6
- - .npmci-cache/
7
- key: '$CI_BUILD_STAGE'
8
-
9
- before_script:
10
- - pnpm install -g pnpm
11
- - pnpm install -g @ship.zone/npmci
12
- - npmci npm prepare
13
-
14
- stages:
15
- - security
16
- - test
17
- - release
18
- - metadata
19
- - pages
20
-
21
- # ====================
22
- # security stage
23
- # ====================
24
- auditProductionDependencies:
25
- image: code.foss.global/hosttoday/ht-docker-node:npmci
26
- stage: security
27
- script:
28
- - npmci command npm config set registry https://registry.npmjs.org
29
- - npmci command pnpm audit --audit-level=high --prod
30
- tags:
31
- - private
32
- - docker
33
- allow_failure: true
34
-
35
- auditDevDependencies:
36
- image: code.foss.global/hosttoday/ht-docker-node:npmci
37
- stage: security
38
- script:
39
- - npmci command npm config set registry https://registry.npmjs.org
40
- - npmci command pnpm audit --audit-level=high --dev
41
- tags:
42
- - private
43
- - docker
44
- allow_failure: true
45
-
46
- # ====================
47
- # test stage
48
- # ====================
49
- testStable:
50
- stage: test
51
- script:
52
- - npmci npm prepare
53
- - npmci node install stable
54
- - npmci npm install
55
- - npmci npm test
56
- coverage: /\d+.?\d+?\%\s*coverage/
57
- tags:
58
- - private
59
- - docker
60
-
61
- testBuild:
62
- stage: test
63
- script:
64
- - npmci npm prepare
65
- - npmci node install stable
66
- - npmci npm install
67
- - npmci command npm run build
68
- coverage: /\d+.?\d+?\%\s*coverage/
69
- tags:
70
- - private
71
- - docker
72
- - notprivileged
73
-
74
- # ====================
75
- # release stage
76
- # ====================
77
-
78
- release:
79
- image: code.foss.global/hosttoday/ht-docker-dbase:npmci
80
- services:
81
- - docker:stable-dind
82
- stage: release
83
- script:
84
- - npmci docker login
85
- - npmci docker build
86
- - npmci docker test
87
- - npmci docker push registry.gitlab.com
88
- only:
89
- - tags
90
- tags:
91
- - private
92
- - docker
93
- - priv
94
-
95
- # ====================
96
- # metadata stage
97
- # ====================
98
-
99
- trigger:
100
- stage: metadata
101
- script:
102
- - npmci trigger
103
- only:
104
- - tags
105
- tags:
106
- - private
107
- - docker