@git.zone/cli 7.2.2 → 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 =
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
|
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
|
|
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,
|
|
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.
|
|
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.
|
|
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
|
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@git.zone/cli',
|
|
6
|
-
version: '7.2.
|
|
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
|
}
|