@bobfrankston/npmglobalize 1.0.64 → 1.0.66

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.
@@ -7,7 +7,8 @@
7
7
  "Bash(npm view:*)",
8
8
  "Bash(node:*)",
9
9
  "Bash(git add:*)",
10
- "Bash(git commit:*)"
10
+ "Bash(git commit:*)",
11
+ "Bash(cmd /c \"del \\\\?\\\\Y:\\\\dev\\\\utils\\\\npmglobalize\\\\nul\")"
11
12
  ]
12
13
  }
13
14
  }
package/lib.js CHANGED
@@ -25,6 +25,39 @@ const colors = {
25
25
  italic: (text) => styleText('italic', text),
26
26
  dim: (text) => styleText('dim', text),
27
27
  };
28
+ /**
29
+ * Remove 'nul' files from a directory tree (Windows reserved name issue).
30
+ * These files break git and npm on Windows. Uses \\?\ prefix to bypass name validation.
31
+ */
32
+ function removeNulFiles(dir, visited = new Set()) {
33
+ const resolved = path.resolve(dir);
34
+ if (visited.has(resolved))
35
+ return 0;
36
+ visited.add(resolved);
37
+ let count = 0;
38
+ try {
39
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
40
+ for (const entry of entries) {
41
+ const full = path.join(dir, entry.name);
42
+ if (entry.isDirectory() && !entry.isSymbolicLink()) {
43
+ count += removeNulFiles(full, visited);
44
+ }
45
+ else if (entry.name === 'nul') {
46
+ try {
47
+ fs.unlinkSync(path.join('\\\\?\\', path.resolve(full)));
48
+ count++;
49
+ }
50
+ catch {
51
+ // Ignore deletion errors
52
+ }
53
+ }
54
+ }
55
+ }
56
+ catch {
57
+ // Ignore read errors (permissions, etc.)
58
+ }
59
+ return count;
60
+ }
28
61
  /** Get npm command for current platform (npm.cmd on Windows, npm elsewhere) */
29
62
  function getNpmCommand() {
30
63
  return process.platform === 'win32' ? 'npm.cmd' : 'npm';
@@ -1030,26 +1063,9 @@ function ensureGitignore(cwd) {
1030
1063
  // Update .gitignore if needed
1031
1064
  if (needsUpdate) {
1032
1065
  if (!content || content.trim() === '') {
1033
- // Create new .gitignore with common patterns
1034
- content = `node_modules/
1035
- .env*
1036
- *cert*/
1037
- *certs*/
1038
- *.pem
1039
- *.key
1040
- *.p12
1041
- *.pfx
1042
- configuration.json
1043
- token
1044
- tokens
1045
- *.token
1046
- cruft/
1047
- prev/
1048
- tests/
1049
- *.log
1050
- .DS_Store
1051
- Thumbs.db
1052
- `;
1066
+ // Create new .gitignore from RECOMMENDED_GITIGNORE plus extras
1067
+ const extras = ['*certs*/', 'configuration.json', 'cruft/', 'prev/', 'tests/'];
1068
+ content = [...RECOMMENDED_GITIGNORE, ...extras].join('\n') + '\n';
1053
1069
  }
1054
1070
  else {
1055
1071
  // Add node_modules to existing .gitignore
@@ -1839,6 +1855,11 @@ export async function globalize(cwd, options = {}, configOptions = {}) {
1839
1855
  const commitMsg = message || 'Pre-release commit';
1840
1856
  console.log(`Committing changes: ${commitMsg}`);
1841
1857
  if (!dryRun) {
1858
+ // Remove 'nul' files that break git on Windows
1859
+ const nulCount = removeNulFiles(cwd);
1860
+ if (nulCount > 0 && verbose) {
1861
+ console.log(` Removed ${nulCount} 'nul' file(s) (Windows reserved name)`);
1862
+ }
1842
1863
  const addResult = runCommand('git', ['add', '-A'], { cwd });
1843
1864
  if (!addResult.success) {
1844
1865
  console.error(colors.red('ERROR: Failed to add files to git:'), addResult.stderr);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/npmglobalize",
3
- "version": "1.0.64",
3
+ "version": "1.0.66",
4
4
  "description": "Transform file: dependencies to npm versions for publishing",
5
5
  "main": "index.js",
6
6
  "type": "module",