@bobfrankston/npmglobalize 1.0.117 → 1.0.119

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.
@@ -0,0 +1,23 @@
1
+ import { type NpmCommonConfig } from '@bobfrankston/userconfig';
2
+ import { type GlobalizeOptions } from './types.js';
3
+ /** Read and parse package.json from a directory */
4
+ export declare function readPackageJson(dir: string): any;
5
+ /** Global npm config from %USERPROFILE%\.userconfig\npm.json5 — via @bobfrankston/userconfig */
6
+ export type UserNpmConfig = NpmCommonConfig;
7
+ /** Get the .userconfig directory path (%USERPROFILE%\.userconfig) */
8
+ export declare function getUserConfigDir(): string;
9
+ /** Read global npm config from %USERPROFILE%\.userconfig\npm.json5 */
10
+ export declare function readUserNpmConfig(): UserNpmConfig;
11
+ /** Write global npm config to %USERPROFILE%\.userconfig\npm.json5 */
12
+ export declare function writeUserNpmConfig(config: UserNpmConfig): void;
13
+ /** Read .globalize.json5 config file */
14
+ export declare function readConfig(dir: string): Partial<GlobalizeOptions>;
15
+ /** Write .globalize.json5 config file */
16
+ export declare function writeConfig(dir: string, config: Partial<GlobalizeOptions>, explicitKeys?: Set<string>): void;
17
+ /** Write package.json to a directory */
18
+ export declare function writePackageJson(dir: string, pkg: any): void;
19
+ /** Resolve a file: path to absolute path */
20
+ export declare function resolveFilePath(fileRef: string, baseDir: string): string;
21
+ /** Check if a dependency value is a file: reference */
22
+ export declare function isFileRef(value: string): boolean;
23
+ //# sourceMappingURL=config.d.ts.map
package/lib/config.js ADDED
@@ -0,0 +1,159 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import JSON5 from 'json5';
4
+ import { readConfig as readUserConfig, writeConfig as writeUserConfig, configDir } from '@bobfrankston/userconfig';
5
+ /** Read and parse package.json from a directory */
6
+ export function readPackageJson(dir) {
7
+ const pkgPath = path.join(dir, 'package.json');
8
+ if (!fs.existsSync(pkgPath)) {
9
+ throw new Error(`package.json not found: ${pkgPath}`);
10
+ }
11
+ try {
12
+ return JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
13
+ }
14
+ catch (error) {
15
+ throw new Error(`Failed to parse ${pkgPath}: ${error.message}`);
16
+ }
17
+ }
18
+ /** Get the .userconfig directory path (%USERPROFILE%\.userconfig) */
19
+ export function getUserConfigDir() {
20
+ return configDir;
21
+ }
22
+ /** Read global npm config from %USERPROFILE%\.userconfig\npm.json5 */
23
+ export function readUserNpmConfig() {
24
+ return readUserConfig();
25
+ }
26
+ /** Write global npm config to %USERPROFILE%\.userconfig\npm.json5 */
27
+ export function writeUserNpmConfig(config) {
28
+ const existing = readUserConfig();
29
+ const merged = { ...existing, ...config };
30
+ writeUserConfig(merged);
31
+ }
32
+ /** Read .globalize.json5 config file */
33
+ export function readConfig(dir) {
34
+ const configPath = path.join(dir, '.globalize.json5');
35
+ if (!fs.existsSync(configPath)) {
36
+ return {};
37
+ }
38
+ try {
39
+ const content = fs.readFileSync(configPath, 'utf-8');
40
+ return JSON5.parse(content);
41
+ }
42
+ catch (error) {
43
+ console.warn(`Warning: Could not parse .globalize.json5 config: ${error.message}`);
44
+ return {};
45
+ }
46
+ }
47
+ /** Write .globalize.json5 config file */
48
+ export function writeConfig(dir, config, explicitKeys) {
49
+ const configPath = path.join(dir, '.globalize.json5');
50
+ // Define defaults to omit
51
+ const defaults = {
52
+ bump: 'patch',
53
+ files: true,
54
+ quiet: true,
55
+ gitVisibility: 'private',
56
+ npmVisibility: 'private',
57
+ install: false,
58
+ wsl: false,
59
+ force: false,
60
+ verbose: false,
61
+ freeze: false
62
+ };
63
+ // Read existing config to preserve values
64
+ const existing = readConfig(dir);
65
+ // Filter out temporary flags and default values (unless explicitly set)
66
+ const filtered = {};
67
+ const omitKeys = new Set(['cleanup', 'init', 'dryRun', 'message', 'conform', 'asis', 'help', 'error', 'updateDeps', 'updateMajor', 'publishDeps', 'forcePublish', 'once']);
68
+ for (const [key, value] of Object.entries(config)) {
69
+ if (omitKeys.has(key))
70
+ continue;
71
+ // Keep if: already in config, explicitly set via CLI, or differs from default
72
+ const isExplicit = explicitKeys?.has(key);
73
+ const wasInConfig = key in existing;
74
+ const differsFromDefault = defaults[key] !== value;
75
+ if (isExplicit || wasInConfig || differsFromDefault) {
76
+ filtered[key] = value;
77
+ }
78
+ }
79
+ // Build content with comments
80
+ const lines = [
81
+ '{',
82
+ ' // npmglobalize configuration (JSON5 format - trailing commas OK)',
83
+ ' // Explicitly set values are preserved here',
84
+ ''
85
+ ];
86
+ // Add configured values
87
+ const entries = Object.entries(filtered);
88
+ if (entries.length > 0) {
89
+ entries.forEach(([key, value]) => {
90
+ const jsonValue = typeof value === 'string' ? `"${value}"` : JSON.stringify(value);
91
+ const comma = ','; // JSON5 allows trailing commas
92
+ // Add inline comment for clarity
93
+ let comment = '';
94
+ if (key === 'install')
95
+ comment = ' // Auto-install globally after publish (from registry)';
96
+ else if (key === 'link')
97
+ comment = ' // Install globally via symlink (npm install -g .)';
98
+ else if (key === 'wsl')
99
+ comment = ' // Also install in WSL';
100
+ else if (key === 'files')
101
+ comment = ' // Keep file: paths after publish';
102
+ else if (key === 'force')
103
+ comment = ' // Continue despite git errors';
104
+ else if (key === 'quiet')
105
+ comment = ' // Suppress npm warnings';
106
+ else if (key === 'verbose')
107
+ comment = ' // Show detailed output';
108
+ else if (key === 'gitVisibility')
109
+ comment = ' // private (default) or public';
110
+ else if (key === 'npmVisibility')
111
+ comment = ' // private (default) or public';
112
+ else if (key === 'bump')
113
+ comment = ' // patch (default), minor, or major';
114
+ else if (key === 'fix')
115
+ comment = ' // Auto-run npm audit fix';
116
+ else if (key === 'local')
117
+ comment = ' // Local install only (skip transform/publish)';
118
+ else if (key === 'noPublish')
119
+ comment = ' // Transform but don\'t publish';
120
+ else if (key === 'freeze')
121
+ comment = ' // Freeze node_modules (replace symlinks with real copies)';
122
+ lines.push(` "${key}": ${jsonValue}${comma}${comment}`);
123
+ });
124
+ lines.push('');
125
+ }
126
+ // Add commented reference for all options
127
+ lines.push(' // Defaults (omitted above):');
128
+ lines.push(' // "bump": "patch" // Version bump: patch, minor, major');
129
+ lines.push(' // "install": false // Auto-install globally after publish (from registry)');
130
+ lines.push(' // "link": false // Install globally via symlink (npm install -g .)');
131
+ lines.push(' // "wsl": false // Also install in WSL');
132
+ lines.push(' // "files": true // Keep file: paths after publish');
133
+ lines.push(' // "force": false // Continue despite git errors');
134
+ lines.push(' // "quiet": true // Suppress npm warnings');
135
+ lines.push(' // "verbose": false // Show detailed output');
136
+ lines.push(' // "gitVisibility": "private" // Git repo: private or public');
137
+ lines.push(' // "npmVisibility": "private" // npm package: private or public');
138
+ lines.push(' // "fix": false // Auto-run npm audit fix');
139
+ lines.push(' // "local": false // Local install only (skip transform/publish)');
140
+ lines.push(' // "noPublish": false // Transform but don\'t publish');
141
+ lines.push(' // "freeze": false // Freeze node_modules (replace symlinks with real copies)');
142
+ lines.push('}');
143
+ fs.writeFileSync(configPath, lines.join('\n') + '\n');
144
+ }
145
+ /** Write package.json to a directory */
146
+ export function writePackageJson(dir, pkg) {
147
+ const pkgPath = path.join(dir, 'package.json');
148
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
149
+ }
150
+ /** Resolve a file: path to absolute path */
151
+ export function resolveFilePath(fileRef, baseDir) {
152
+ const relativePath = fileRef.replace(/^file:/, '');
153
+ return path.resolve(baseDir, relativePath);
154
+ }
155
+ /** Check if a dependency value is a file: reference */
156
+ export function isFileRef(value) {
157
+ return typeof value === 'string' && value.startsWith('file:');
158
+ }
159
+ //# sourceMappingURL=config.js.map
package/lib/deps.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * npmglobalize dependency analysis, transformation, and restoration.
3
+ * Handles file: ref discovery, workspace graphs, topological sorting,
4
+ * and transforming file: deps to npm versions for publishing.
5
+ */
6
+ /** Get all file: dependencies from package.json */
7
+ export declare function getFileRefs(pkg: any): Map<string, {
8
+ key: string;
9
+ name: string;
10
+ value: string;
11
+ }>;
12
+ /** Resolve workspace entries to package info. Skips dirs without package.json or with private:true. */
13
+ export declare function resolveWorkspacePackages(rootDir: string): Array<{
14
+ name: string;
15
+ dir: string;
16
+ pkg: any;
17
+ }>;
18
+ /** Build a dependency graph among workspace packages. Returns Map<name, Set<depName>>. */
19
+ export declare function buildDependencyGraph(packages: Array<{
20
+ name: string;
21
+ dir: string;
22
+ pkg: any;
23
+ }>): Map<string, Set<string>>;
24
+ /** Topological sort with cycle detection. Returns package names in dependency order. */
25
+ export declare function topologicalSort(graph: Map<string, Set<string>>): string[];
26
+ /** Transform file: dependencies to npm versions */
27
+ export declare function transformDeps(pkg: any, baseDir: string, verbose?: boolean, forcePublish?: boolean): {
28
+ transformed: boolean;
29
+ unpublished: Array<{
30
+ name: string;
31
+ version: string;
32
+ path: string;
33
+ }>;
34
+ };
35
+ /** Build and print a dependency tree of file: references.
36
+ * Recursively walks file: deps showing the full hierarchy with indentation. */
37
+ export declare function printDepTree(baseDir: string, indent?: number, visited?: Set<string>): void;
38
+ /** Restore file: dependencies from .dependencies */
39
+ export declare function restoreDeps(pkg: any, verbose?: boolean): boolean;
40
+ /** Check if .dependencies exist (already transformed) */
41
+ export declare function hasBackup(pkg: any): boolean;
42
+ //# sourceMappingURL=deps.d.ts.map
package/lib/deps.js ADDED
@@ -0,0 +1,298 @@
1
+ /**
2
+ * npmglobalize dependency analysis, transformation, and restoration.
3
+ * Handles file: ref discovery, workspace graphs, topological sorting,
4
+ * and transforming file: deps to npm versions for publishing.
5
+ */
6
+ import fs from 'fs';
7
+ import path from 'path';
8
+ import { spawnSafe, colors, DEP_KEYS } from './types.js';
9
+ import { readPackageJson, isFileRef, resolveFilePath } from './config.js';
10
+ import { checkVersionExists } from './npm.js';
11
+ /** Get all file: dependencies from package.json */
12
+ export function getFileRefs(pkg) {
13
+ const refs = new Map();
14
+ for (const key of DEP_KEYS) {
15
+ if (!pkg[key])
16
+ continue;
17
+ for (const [name, value] of Object.entries(pkg[key])) {
18
+ if (isFileRef(value)) {
19
+ refs.set(`${key}:${name}`, { key, name, value: value });
20
+ }
21
+ }
22
+ }
23
+ return refs;
24
+ }
25
+ // ─── Workspace helpers ───────────────────────────────────────────────
26
+ /** Resolve workspace entries to package info. Skips dirs without package.json or with private:true. */
27
+ export function resolveWorkspacePackages(rootDir) {
28
+ const rootPkg = readPackageJson(rootDir);
29
+ const workspaces = rootPkg.workspaces;
30
+ if (!Array.isArray(workspaces))
31
+ return [];
32
+ const results = [];
33
+ for (const entry of workspaces) {
34
+ const pkgDir = path.resolve(rootDir, entry);
35
+ const pkgJsonPath = path.join(pkgDir, 'package.json');
36
+ if (!fs.existsSync(pkgJsonPath))
37
+ continue;
38
+ const pkg = readPackageJson(pkgDir);
39
+ if (pkg.private)
40
+ continue; // skip private packages (they can't be published)
41
+ results.push({ name: pkg.name || entry, dir: pkgDir, pkg });
42
+ }
43
+ return results;
44
+ }
45
+ /** Build a dependency graph among workspace packages. Returns Map<name, Set<depName>>. */
46
+ export function buildDependencyGraph(packages) {
47
+ const nameSet = new Set(packages.map(p => p.name));
48
+ const dirToName = new Map();
49
+ for (const p of packages) {
50
+ dirToName.set(p.dir, p.name);
51
+ }
52
+ const graph = new Map();
53
+ for (const p of packages) {
54
+ const deps = new Set();
55
+ for (const depKey of DEP_KEYS) {
56
+ if (!p.pkg[depKey])
57
+ continue;
58
+ for (const [depName, depValue] of Object.entries(p.pkg[depKey])) {
59
+ // Check by npm name
60
+ if (nameSet.has(depName)) {
61
+ deps.add(depName);
62
+ continue;
63
+ }
64
+ // Check file: refs that resolve to a sibling workspace dir
65
+ if (isFileRef(depValue)) {
66
+ const resolved = resolveFilePath(depValue, p.dir);
67
+ const resolvedNorm = path.resolve(resolved);
68
+ const match = dirToName.get(resolvedNorm);
69
+ if (match) {
70
+ deps.add(match);
71
+ }
72
+ }
73
+ }
74
+ }
75
+ graph.set(p.name, deps);
76
+ }
77
+ return graph;
78
+ }
79
+ /** Topological sort with cycle detection. Returns package names in dependency order. */
80
+ export function topologicalSort(graph) {
81
+ const visited = new Set();
82
+ const visiting = new Set(); // cycle detection
83
+ const result = [];
84
+ function visit(node) {
85
+ if (visited.has(node))
86
+ return;
87
+ if (visiting.has(node)) {
88
+ throw new Error(`Circular dependency detected involving: ${node}`);
89
+ }
90
+ visiting.add(node);
91
+ const deps = graph.get(node);
92
+ if (deps) {
93
+ for (const dep of deps) {
94
+ if (dep === node)
95
+ continue; // skip self-references
96
+ if (graph.has(dep)) { // only visit workspace-internal deps
97
+ visit(dep);
98
+ }
99
+ }
100
+ }
101
+ visiting.delete(node);
102
+ visited.add(node);
103
+ result.push(node);
104
+ }
105
+ for (const node of graph.keys()) {
106
+ visit(node);
107
+ }
108
+ return result;
109
+ }
110
+ /** Check if a published npm package has broken deps (file: paths or unpublished transitive deps).
111
+ * Also checks local file: deps for unpublished versions. */
112
+ function hasUnpublishedTransitiveDeps(packageName, pkg, baseDir, verbose) {
113
+ // Check 1: Does the npm-published version have file: paths in its deps?
114
+ try {
115
+ const result = spawnSafe('npm', ['view', packageName, 'dependencies', '--json'], {
116
+ encoding: 'utf-8',
117
+ stdio: 'pipe',
118
+ shell: true
119
+ });
120
+ if (result.status === 0 && result.stdout.trim()) {
121
+ const npmDeps = JSON.parse(result.stdout.trim());
122
+ for (const [depName, depValue] of Object.entries(npmDeps)) {
123
+ if (isFileRef(depValue)) {
124
+ if (verbose) {
125
+ console.log(colors.yellow(` npm copy has file: dep ${depName} → ${depValue}`));
126
+ }
127
+ return true;
128
+ }
129
+ }
130
+ }
131
+ }
132
+ catch {
133
+ // Can't check npm — fall through to local check
134
+ }
135
+ // Check 2: Do local file: deps have unpublished versions?
136
+ for (const key of DEP_KEYS) {
137
+ if (!pkg[key])
138
+ continue;
139
+ for (const [depName, depValue] of Object.entries(pkg[key])) {
140
+ if (!isFileRef(depValue))
141
+ continue;
142
+ try {
143
+ const depPath = resolveFilePath(depValue, baseDir);
144
+ const depPkg = readPackageJson(depPath);
145
+ if (!checkVersionExists(depName, depPkg.version)) {
146
+ if (verbose) {
147
+ console.log(colors.yellow(` transitive dep ${depName}@${depPkg.version} not on npm`));
148
+ }
149
+ return true;
150
+ }
151
+ }
152
+ catch {
153
+ return true;
154
+ }
155
+ }
156
+ }
157
+ return false;
158
+ }
159
+ /** Transform file: dependencies to npm versions */
160
+ export function transformDeps(pkg, baseDir, verbose = false, forcePublish = false) {
161
+ let transformed = false;
162
+ const unpublished = [];
163
+ for (const key of DEP_KEYS) {
164
+ if (!pkg[key])
165
+ continue;
166
+ const dotKey = '.' + key;
167
+ // If .dependencies already exists, restore it and merge any new dependencies
168
+ if (pkg[dotKey]) {
169
+ // Save any new dependencies that aren't in .dependencies
170
+ const currentDeps = { ...pkg[key] };
171
+ // Restore .dependencies back to dependencies
172
+ pkg[key] = { ...pkg[dotKey] };
173
+ // Merge in any NEW dependencies that were added since transformation
174
+ for (const [name, value] of Object.entries(currentDeps)) {
175
+ if (!(name in pkg[dotKey])) {
176
+ // This is a new dependency, add it
177
+ pkg[key][name] = value;
178
+ // Also add to .dependencies backup
179
+ pkg[dotKey][name] = value;
180
+ if (verbose) {
181
+ console.log(` Merged new dependency: ${name}`);
182
+ }
183
+ }
184
+ }
185
+ }
186
+ const hasFileRefs = Object.values(pkg[key]).some(v => isFileRef(v));
187
+ if (!hasFileRefs)
188
+ continue;
189
+ // Backup original (or update existing backup with merged deps)
190
+ if (!pkg[dotKey]) {
191
+ pkg[dotKey] = { ...pkg[key] };
192
+ }
193
+ // Transform file: refs to npm versions
194
+ for (const [name, value] of Object.entries(pkg[key])) {
195
+ if (isFileRef(value)) {
196
+ const targetPath = resolveFilePath(value, baseDir);
197
+ console.log(colors.blue(` + ${name} → ${value}`));
198
+ try {
199
+ const targetPkg = readPackageJson(targetPath);
200
+ const targetVersion = targetPkg.version;
201
+ const npmVersion = '^' + targetVersion;
202
+ // Check if this version exists on npm (or if force publish)
203
+ const versionExists = forcePublish ? false : checkVersionExists(name, targetVersion);
204
+ if (!versionExists) {
205
+ unpublished.push({ name, version: targetVersion, path: targetPath });
206
+ if (forcePublish) {
207
+ console.log(colors.yellow(` ⟳ ${name}@${targetVersion} will be republished (--force-publish)`));
208
+ }
209
+ else {
210
+ console.log(colors.red(` ⚠ ${name}@${targetVersion} not found on npm (local: ${value})`));
211
+ }
212
+ }
213
+ else {
214
+ if (verbose) {
215
+ console.log(colors.green(` ✓ ${name}@${targetVersion} exists on npm`));
216
+ }
217
+ // Check transitive file: deps — if any are unpublished, this dep needs republishing
218
+ if (hasUnpublishedTransitiveDeps(name, targetPkg, targetPath, verbose)) {
219
+ unpublished.push({ name, version: targetVersion, path: targetPath });
220
+ console.log(colors.yellow(` ⟳ ${name}@${targetVersion} has unpublished transitive deps — will republish`));
221
+ }
222
+ }
223
+ pkg[key][name] = npmVersion;
224
+ if (verbose) {
225
+ console.log(` ${name}: ${value} -> ${npmVersion}`);
226
+ }
227
+ transformed = true;
228
+ }
229
+ catch (error) {
230
+ throw new Error(`Failed to resolve ${name} at ${targetPath}: ${error.message}`);
231
+ }
232
+ }
233
+ }
234
+ }
235
+ return { transformed, unpublished };
236
+ }
237
+ /** Build and print a dependency tree of file: references.
238
+ * Recursively walks file: deps showing the full hierarchy with indentation. */
239
+ export function printDepTree(baseDir, indent = 0, visited = new Set()) {
240
+ const realDir = fs.realpathSync(baseDir);
241
+ if (visited.has(realDir))
242
+ return;
243
+ visited.add(realDir);
244
+ let pkg;
245
+ try {
246
+ pkg = readPackageJson(baseDir);
247
+ }
248
+ catch {
249
+ return;
250
+ }
251
+ for (const key of DEP_KEYS) {
252
+ if (!pkg[key])
253
+ continue;
254
+ // Use the backup (.dependencies) if present — it has the original file: refs
255
+ const deps = pkg['.' + key] || pkg[key];
256
+ for (const [name, value] of Object.entries(deps)) {
257
+ if (!isFileRef(value))
258
+ continue;
259
+ const prefix = ' '.repeat(indent * 2);
260
+ let targetPath;
261
+ let version = '?';
262
+ try {
263
+ targetPath = resolveFilePath(value, baseDir);
264
+ const targetPkg = readPackageJson(targetPath);
265
+ version = targetPkg.version || '?';
266
+ }
267
+ catch {
268
+ console.log(`${prefix} ${name} → ${value} ${colors.red('(unresolvable)')}`);
269
+ continue;
270
+ }
271
+ const exists = checkVersionExists(name, version);
272
+ const marker = exists ? colors.green('✓') : colors.red('✗');
273
+ console.log(`${prefix} ${marker} ${name}@${version} → ${value}`);
274
+ printDepTree(targetPath, indent + 1, visited);
275
+ }
276
+ }
277
+ }
278
+ /** Restore file: dependencies from .dependencies */
279
+ export function restoreDeps(pkg, verbose = false) {
280
+ let restored = false;
281
+ for (const key of DEP_KEYS) {
282
+ const dotKey = '.' + key;
283
+ if (pkg[dotKey]) {
284
+ pkg[key] = pkg[dotKey];
285
+ delete pkg[dotKey];
286
+ restored = true;
287
+ if (verbose) {
288
+ console.log(` Restored ${key} from ${dotKey}`);
289
+ }
290
+ }
291
+ }
292
+ return restored;
293
+ }
294
+ /** Check if .dependencies exist (already transformed) */
295
+ export function hasBackup(pkg) {
296
+ return DEP_KEYS.some(key => pkg['.' + key]);
297
+ }
298
+ //# sourceMappingURL=deps.js.map
package/lib/git.d.ts ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * npmglobalize — Git operations, command execution, and push protection.
3
+ * Depends on: types (leaf), config (leaf)
4
+ */
5
+ import { type GitStatus } from './types.js';
6
+ /**
7
+ * Remove 'nul' files from a directory tree (Windows reserved name issue).
8
+ * These files break git and npm on Windows. Uses \\?\ prefix to bypass name validation.
9
+ */
10
+ export declare function removeNulFiles(dir: string, visited?: Set<string>): number;
11
+ /** Repair a corrupted git index by rebuilding it.
12
+ * Handles "invalid object" / "Error building trees" errors caused by
13
+ * stale entries in .git/index referencing missing objects. */
14
+ export declare function repairGitIndex(cwd: string): boolean;
15
+ /** Parse file paths from git add "Permission denied" / "unable to index file" errors.
16
+ * Matches lines like: error: open("data/PingDB.mdf"): Permission denied
17
+ * and: error: unable to index file 'data/PingDB.mdf' */
18
+ export declare function parseDeniedFiles(errText: string): string[];
19
+ /** Run a command and return success status */
20
+ export declare function runCommand(cmd: string, args: string[], options?: {
21
+ silent?: boolean;
22
+ verbose?: boolean;
23
+ showCommand?: boolean;
24
+ cwd?: string;
25
+ }): {
26
+ success: boolean;
27
+ output: string;
28
+ stderr: string;
29
+ };
30
+ /** Extract GitHub repo identifier from repository field */
31
+ export declare function getGitHubRepo(pkg: any): string | null;
32
+ /** Run a command and throw on failure */
33
+ export declare function runCommandOrThrow(cmd: string, args: string[], options?: {
34
+ silent?: boolean;
35
+ cwd?: string;
36
+ }): string;
37
+ export declare function getGitStatus(cwd: string): GitStatus;
38
+ /** Validate package.json for release */
39
+ export declare function validatePackageJson(pkg: any): string[];
40
+ /** Get the latest git tag (if any) */
41
+ export declare function getLatestGitTag(cwd: string): string | null;
42
+ /** Check if a git tag exists */
43
+ export declare function gitTagExists(cwd: string, tag: string): boolean;
44
+ /** Delete a git tag */
45
+ export declare function deleteGitTag(cwd: string, tag: string): boolean;
46
+ /** Get all git tags */
47
+ export declare function getAllGitTags(cwd: string): string[];
48
+ /** Parse version from tag (e.g., 'v1.2.3' -> [1, 2, 3]) */
49
+ export declare function parseVersionTag(tag: string): number[] | null;
50
+ /** Compare two version arrays (returns -1 if a < b, 0 if equal, 1 if a > b) */
51
+ export declare function compareVersions(a: number[], b: number[]): number;
52
+ /** Fix version/tag mismatches */
53
+ export declare function fixVersionTagMismatch(cwd: string, pkg: any, verbose?: boolean): boolean;
54
+ /** Wait for a package version to appear on the npm registry */
55
+ export declare function waitForNpmVersion(pkgName: string, version: string, maxWaitMs?: number): boolean;
56
+ /** Run npm install -g with retries for registry propagation delay */
57
+ export declare function installGlobalWithRetry(pkgSpec: string, cwd: string, maxRetries?: number): {
58
+ success: boolean;
59
+ output: string;
60
+ stderr: string;
61
+ };
62
+ /** Detect OAuth credentials.json type: "installed" (public app ID, safe to include) or "web" (has real secret, must ignore).
63
+ * Returns null if no credentials.json exists or it can't be parsed. */
64
+ export declare function detectCredentialsType(cwd: string): 'installed' | 'web' | null;
65
+ interface PushProtectionSecret {
66
+ type: string;
67
+ file: string;
68
+ unblockUrl: string;
69
+ }
70
+ interface PushProtectionInfo {
71
+ detected: boolean;
72
+ secrets: PushProtectionSecret[];
73
+ allInstalledOAuth: boolean;
74
+ }
75
+ /** Parse GitHub push protection (GH013) error output and extract secret details + unblock URLs. */
76
+ export declare function parsePushProtection(errorOutput: string, cwd: string): PushProtectionInfo;
77
+ /** Display push protection guidance based on the type of secrets detected. */
78
+ export declare function showPushProtectionGuidance(ppInfo: PushProtectionInfo): void;
79
+ /** Push to git with push-protection detection and auto-bypass for installed OAuth.
80
+ * Returns true if push succeeded (possibly after auto-bypass). */
81
+ export declare function pushWithProtection(cwd: string, verbose: boolean): boolean;
82
+ export {};
83
+ //# sourceMappingURL=git.d.ts.map