git-stack-cli
Advanced tools
| import fs from "node:fs/promises"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
| export async function get_tmp_dir(): Promise<string> { | ||
| const dir = path.join(os.tmpdir(), "git-stack-cli"); | ||
| // ensure tmp directory exists | ||
| await fs.mkdir(dir, { recursive: true }); | ||
| return dir; | ||
| } |
+2
-1
| { | ||
| "name": "git-stack-cli", | ||
| "version": "2.1.0-beta", | ||
| "version": "2.1.1-beta", | ||
| "description": "", | ||
@@ -55,2 +55,3 @@ "author": "magus", | ||
| "devDependencies": { | ||
| "@oven/bun-darwin-aarch64": "1.1.42", | ||
| "@types/chalk": "^2.2.0", | ||
@@ -57,0 +58,0 @@ "@types/lodash": "^4.17.7", |
@@ -111,3 +111,3 @@ import * as React from "react"; | ||
| invariant(branch_name, "branch_name must exist"); | ||
| invariant(commit_range, "branch_name must exist"); | ||
| invariant(commit_range, "commit_range must exist"); | ||
@@ -153,3 +153,3 @@ try { | ||
| invariant(branch_name, "branch_name must exist"); | ||
| invariant(commit_range, "branch_name must exist"); | ||
| invariant(commit_range, "commit_range must exist"); | ||
@@ -156,0 +156,0 @@ for (const group of commit_range.group_list) { |
+19
-10
| import * as React from "react"; | ||
| import crypto from "node:crypto"; | ||
| import fs from "node:fs/promises"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
@@ -13,2 +13,3 @@ | ||
| import { colors } from "~/core/colors"; | ||
| import { get_tmp_dir } from "~/core/get_tmp_dir"; | ||
| import { invariant } from "~/core/invariant"; | ||
@@ -232,3 +233,6 @@ import { safe_quote } from "~/core/safe_quote"; | ||
| async function gh_json<T>(command: string): Promise<T | Error> { | ||
| const tmp_pr_json = path.join(os.tmpdir(), "git-stack-gh.json"); | ||
| // hash command for unique short string | ||
| let hash = crypto.createHash("md5").update(command).digest("hex"); | ||
| let tmp_filename = safe_filename(`gh_json-${hash}`); | ||
| const tmp_pr_json = path.join(await get_tmp_dir(), `${tmp_filename}.json`); | ||
@@ -243,5 +247,9 @@ const options = { ignoreExitCode: true }; | ||
| // read from file | ||
| const json_str = await fs.readFile(tmp_pr_json, "utf-8"); | ||
| const json = JSON.parse(json_str); | ||
| return json; | ||
| const json_str = String(await fs.readFile(tmp_pr_json)); | ||
| try { | ||
| const json = JSON.parse(json_str); | ||
| return json; | ||
| } catch (error) { | ||
| return new Error(`gh_json JSON.parse: ${error}`); | ||
| } | ||
| } | ||
@@ -264,11 +272,8 @@ | ||
| const temp_dir = os.tmpdir(); | ||
| // ensure unique filename is safe for filesystem | ||
| // base (group id) might contain slashes, e.g. dev/magus/gs-3cmrMBSUj | ||
| // the flashes would mess up the filesystem path to this file | ||
| let temp_filename = `git-stack-body-${args.base}`; | ||
| temp_filename = temp_filename.replace(RE.non_alphanumeric_dash, "-"); | ||
| let tmp_filename = safe_filename(`git-stack-body-${args.base}`); | ||
| const temp_path = path.join(temp_dir, temp_filename); | ||
| const temp_path = path.join(await get_tmp_dir(), tmp_filename); | ||
@@ -282,2 +287,6 @@ await safe_rm(temp_path); | ||
| function safe_filename(value: string): string { | ||
| return value.replace(RE.non_alphanumeric_dash, "-"); | ||
| } | ||
| type Commit = { | ||
@@ -284,0 +293,0 @@ authoredDate: string; // "2023-10-22T23:13:35Z" |
| import fs from "node:fs/promises"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
@@ -7,2 +6,3 @@ | ||
| import { cli } from "~/core/cli"; | ||
| import { get_tmp_dir } from "~/core/get_tmp_dir"; | ||
| import { invariant } from "~/core/invariant"; | ||
@@ -113,3 +113,3 @@ import { safe_rm } from "~/core/safe_rm"; | ||
| // generate temporary directory and drop sequence editor script | ||
| const tmp_git_sequence_editor_path = path.join(os.tmpdir(), "git-sequence-editor.sh"); | ||
| const tmp_git_sequence_editor_path = path.join(await get_tmp_dir(), "git-sequence-editor.sh"); | ||
@@ -116,0 +116,0 @@ // replaced at build time with literal contents of `scripts/git-sequence-editor.sh` |
+7
-0
@@ -7,2 +7,4 @@ #!/usr/bin/env node | ||
| import fs from "node:fs/promises"; | ||
| import * as Ink from "ink-cjs"; | ||
@@ -13,2 +15,3 @@ | ||
| import { command } from "~/command"; | ||
| import { get_tmp_dir } from "~/core/get_tmp_dir"; | ||
| import { pretty_json } from "~/core/pretty_json"; | ||
@@ -38,2 +41,6 @@ | ||
| // cleanup leftover temporary files from previous run | ||
| const tmp_dir = await get_tmp_dir(); | ||
| await fs.rm(tmp_dir, { recursive: true }); | ||
| const ink = Ink.render(<App />, { | ||
@@ -40,0 +47,0 @@ // If true, each update will be rendered as a separate output, without replacing the previous one. |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1880882
0.09%102
0.99%52981
0.08%17
6.25%