From e40298f1d5a89396e98086b3c22cef4fedf378ec Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Tue, 17 Mar 2026 21:58:14 +0100 Subject: [PATCH 01/11] feat: support branch names other than master --- src/package-converter.js | 2 +- src/publish.js | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/package-converter.js b/src/package-converter.js index a93642f1..d6f4ee34 100644 --- a/src/package-converter.js +++ b/src/package-converter.js @@ -48,7 +48,7 @@ class PackageConverter { getDownloadUrl() { let downloadUrl = this.sourcePath; downloadUrl = downloadUrl.replace(/(\.git)?\/*$/, ''); - return downloadUrl += '/archive/master.tar.gz'; + return downloadUrl += '/archive/HEAD.tar.gz'; } async downloadBundle() { diff --git a/src/publish.js b/src/publish.js index 38d23c99..18b4a82f 100644 --- a/src/publish.js +++ b/src/publish.js @@ -1,5 +1,6 @@ const path = require('path'); +const { execSync } = require('child_process'); const yargs = require('yargs'); const Git = require('git-utils'); @@ -29,6 +30,7 @@ class Publish extends Command { Usage: ppm publish [ | major | minor | patch | build] ppm publish --tag ppm publish --rename + ppm publish --branch Publish a new version of the package in the current working directory. @@ -50,7 +52,8 @@ have published it.\ ); options.alias('h', 'help').describe('help', 'Print this usage message'); options.alias('t', 'tag').string('tag').describe('tag', 'Specify a tag to publish. Must be of the form vx.y.z'); - return options.alias('r', 'rename').string('rename').describe('rename', 'Specify a new name for the package'); + options.alias('r', 'rename').string('rename').describe('rename', 'Specify a new name for the package'); + return options.alias('b', 'branch').string('branch').describe('branch', 'Specify the default branch of the package repository'); } // Create a new version and tag use the `npm version` command. @@ -272,7 +275,25 @@ have published it.\ fs.writeFileSync(metadataPath, `${metadataJson}\n`); } - loadRepository() { + getDefaultBranch(repo) { + try { + const ref = execSync('git symbolic-ref refs/remotes/origin/HEAD', { + encoding: 'utf8', + stdio: ['pipe', 'pipe', 'ignore'] + }).trim(); + const match = ref.match(/refs\/remotes\/origin\/(.+)/); + if (match) { return match[1]; } + } catch { /* symbolic-ref may not exist; fall through to heuristic */ } + + for (const branch of ['main', 'master']) { + if (repo.getConfigValue(`branch.${branch}.remote`)) { + return branch; + } + } + return null; + } + + loadRepository(branch) { let currentBranch, remoteName, upstreamUrl; const currentDirectory = process.cwd(); @@ -281,12 +302,16 @@ have published it.\ throw new Error('Package must be in a Git repository before publishing: https://help.github.com/articles/create-a-repo'); } - currentBranch = repo.getShortHead(); if (currentBranch) { remoteName = repo.getConfigValue(`branch.${currentBranch}.remote`); } - if (remoteName == null) { remoteName = repo.getConfigValue('branch.master.remote'); } + if (remoteName == null) { + const defaultBranch = branch || this.getDefaultBranch(repo); + if (defaultBranch && defaultBranch !== currentBranch) { + remoteName = repo.getConfigValue(`branch.${defaultBranch}.remote`); + } + } if (remoteName) { upstreamUrl = repo.getConfigValue(`remote.${remoteName}.url`); } if (upstreamUrl == null) { upstreamUrl = repo.getConfigValue('remote.origin.url'); } @@ -387,7 +412,7 @@ have published it.\ async run(options) { let pack, originalName; options = this.parseOptions(options.commandArgs); - let {tag, rename} = options.argv; + let {tag, rename, branch} = options.argv; let [version] = options.argv._; // Normalize variables to ensure they are strings with zero length @@ -416,7 +441,7 @@ have published it.\ } try { - this.loadRepository(); + this.loadRepository(branch); } catch (error) { return error; } From d487c0f050fbd2826a76db7ab9a427a15cd6c5e9 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Tue, 17 Mar 2026 21:58:31 +0100 Subject: [PATCH 02/11] test: add tests for branch features --- spec/init-spec.js | 23 ++++++++++++ spec/publish-spec.js | 85 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/spec/init-spec.js b/spec/init-spec.js index 67706ce5..432c79ca 100644 --- a/spec/init-spec.js +++ b/spec/init-spec.js @@ -2,6 +2,7 @@ const path = require('path'); const temp = require('temp'); const CSON = require('season'); const fs = require('../src/fs'); +const PackageConverter = require('../src/package-converter'); describe('apm init', () => { let languagePath, packagePath, themePath; @@ -210,3 +211,25 @@ describe('apm init', () => { }); }); }); + +describe('PackageConverter.getDownloadUrl', () => { + it('uses HEAD instead of a hardcoded branch name', () => { + const converter = new PackageConverter( + 'https://github.com/textmate/r.tmbundle', + '/tmp/fake-dest' + ); + expect(converter.getDownloadUrl()).toBe( + 'https://github.com/textmate/r.tmbundle/archive/HEAD.tar.gz' + ); + }); + + it('strips trailing .git and slashes before appending archive path', () => { + const converter = new PackageConverter( + 'https://github.com/textmate/r.tmbundle.git/', + '/tmp/fake-dest' + ); + expect(converter.getDownloadUrl()).toBe( + 'https://github.com/textmate/r.tmbundle/archive/HEAD.tar.gz' + ); + }); +}); \ No newline at end of file diff --git a/spec/publish-spec.js b/spec/publish-spec.js index ed92d96d..d2b0a9c2 100644 --- a/spec/publish-spec.js +++ b/spec/publish-spec.js @@ -248,6 +248,41 @@ describe('apm publish', () => { expect(callback.calls.mostRecent().args[0]).toBeUndefined(); }); + it('publishes successfully with --branch flag', async () => { + const packageToPublish = temp.mkdirSync('apm-test-package-'); + const metadata = { + name: 'test', + version: '1.0.0', + "repository": { + "type": "git", + "url": "https://github.com/pulsar-edit/foo" + }, + engines: { + atom: '1' + }, + dependencies: { + foo: '^5' + }, + devDependencies: { + abc: 'git://github.com/user/project.git', + abcd: 'latest', + } + }; + fs.writeFileSync( + path.join(packageToPublish, 'package.json'), + JSON.stringify(metadata) + ); + process.chdir(packageToPublish); + + childProcess.execSync('git init', { cwd: packageToPublish }); + childProcess.execSync('git remote add origin https://github.com/pulsar-edit/foo', { cwd: packageToPublish }); + + const callback = jasmine.createSpy('callback'); + await apmRun(['publish', 'patch', '--branch', 'main'], callback); + expect(requests.length).toBe(1); + expect(callback.calls.mostRecent().args[0]).toBeUndefined(); + }); + it('publishes successfully when the package exists and is being renamed', async () => { spyOn(Publish.prototype, 'packageExists').and.callFake((name) => { // If we're renaming the package, we need to ask the API if the package's @@ -294,3 +329,53 @@ describe('apm publish', () => { expect(callback.calls.mostRecent().args[0]).toBeUndefined(); }); }); + + + +describe('Publish.getDefaultBranch', () => { + let publish; + + beforeEach(() => { + publish = new Publish(); + }); + + it('falls back to main when symbolic-ref is unavailable', () => { + // execSync is bound at import time, so we call getDefaultBranch + // outside a real git repo where symbolic-ref will naturally fail + const repo = { + getConfigValue: jasmine.createSpy('getConfigValue').and.callFake((key) => { + if (key === 'branch.main.remote') return 'origin'; + return null; + }) + }; + expect(publish.getDefaultBranch(repo)).toBe('main'); + }); + + it('falls back to master when main is not configured', () => { + const repo = { + getConfigValue: jasmine.createSpy('getConfigValue').and.callFake((key) => { + if (key === 'branch.master.remote') return 'origin'; + return null; + }) + }; + expect(publish.getDefaultBranch(repo)).toBe('master'); + }); + + it('returns null when no default branch can be determined', () => { + const repo = { + getConfigValue: jasmine.createSpy('getConfigValue').and.returnValue(null) + }; + expect(publish.getDefaultBranch(repo)).toBeNull(); + }); + + it('prefers main over master', () => { + const repo = { + getConfigValue: jasmine.createSpy('getConfigValue').and.callFake((key) => { + if (key === 'branch.main.remote') return 'origin'; + if (key === 'branch.master.remote') return 'origin'; + return null; + }) + }; + expect(publish.getDefaultBranch(repo)).toBe('main'); + }); +}); \ No newline at end of file From bf033cbcd7e80ad01af7c1dc38a89feda3d0992d Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Wed, 10 Jun 2026 22:49:57 +0200 Subject: [PATCH 03/11] chore: install @pulsar/git-utils --- package.json | 5 +++-- yarn.lock | 34 ++++++---------------------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 21dc2390..c32e9889 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "async": "^3.2.0", "colors": "~1.4.0", "fs-plus": "3.x", - "git-utils": "^5.7.2", + "git-utils": "npm:@pulsar-edit/git-utils^@0.1.0", "hosted-git-info": "^3.0.7", "keytar": "^7.7.0", "npm": "https://github.com/pulsar-edit/npm-cli/releases/download/v6.14.19-pulsar2/npm-6.14.19-pulsar2.tgz", @@ -57,5 +57,6 @@ "npm/**/http-cache-semantics": "^4.1.1", "npm/**/node-gyp": "^10.2.0", "npm/**/tar": "^6.1.2" - } + }, + "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72" } diff --git a/yarn.lock b/yarn.lock index 4928eecd..0dffcdd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1815,13 +1815,12 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" -git-utils@^5.7.2: - version "5.7.3" - resolved "https://registry.yarnpkg.com/git-utils/-/git-utils-5.7.3.tgz#3b53983204678313b305bbf278c07dc015ba2155" - integrity sha512-in1hjFfmzY86gKBt+YMTaVyCGtX2WTnN0uPj37bI5HsrnU2oj8OFcWOEzOI5PxQXPMxFxtvRebOHAOGB8M125w== +"git-utils@npm:@pulsar-edit/git-utils@0.1.0": + version "8.1.0" + resolved "https://registry.yarnpkg.com/@pulsar-edit/git-utils/-/git-utils-8.1.0.tgz#e8f4469296bb889719aa7a2225893256351ef534" + integrity sha512-YaM5VWIw0ciC1JYyKm0BCDJ+FfAKQ/Pc2S7U/3b2UR1/Y146hzlx4HGISIWFTVK+ROFZpdVvfc3ECZ7lzzmBBA== dependencies: fs-plus "^3.0.0" - nan "^2.14.2" github-from-package@0.0.0: version "0.0.0" @@ -3095,11 +3094,6 @@ mute-stream@~0.0.4: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== -nan@^2.14.2: - version "2.18.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.18.0.tgz#26a6faae7ffbeb293a39660e88a76b82e30b7554" - integrity sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w== - napi-build-utils@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806" @@ -4570,7 +4564,7 @@ strict-uri-encode@^2.0.0: resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ== -"string-width-cjs@npm:string-width@^4.2.0": +"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -4588,15 +4582,6 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== - dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" - string-width@^2.0.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -4665,7 +4650,7 @@ stringify-package@^1.0.0, stringify-package@^1.0.1: resolved "https://registry.yarnpkg.com/stringify-package/-/stringify-package-1.0.1.tgz#e5aa3643e7f74d0f28628b72f3dad5cecfc3ba85" integrity sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg== -"strip-ansi-cjs@npm:strip-ansi@^6.0.1": +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -4693,13 +4678,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== - dependencies: - ansi-regex "^5.0.1" - strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" From 478aa593a92137dd43b9a95842edd1f3a9cfb586 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Wed, 10 Jun 2026 22:50:27 +0200 Subject: [PATCH 04/11] refactor: use git-utils api instead of spawning git child process --- src/publish.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/publish.js b/src/publish.js index 18b4a82f..59d5e1d5 100644 --- a/src/publish.js +++ b/src/publish.js @@ -1,6 +1,5 @@ const path = require('path'); -const { execSync } = require('child_process'); const yargs = require('yargs'); const Git = require('git-utils'); @@ -277,10 +276,7 @@ have published it.\ getDefaultBranch(repo) { try { - const ref = execSync('git symbolic-ref refs/remotes/origin/HEAD', { - encoding: 'utf8', - stdio: ['pipe', 'pipe', 'ignore'] - }).trim(); + const ref = repo.getSymbolicRefTarget('refs/remotes/origin/HEAD'); const match = ref.match(/refs\/remotes\/origin\/(.+)/); if (match) { return match[1]; } } catch { /* symbolic-ref may not exist; fall through to heuristic */ } From 2da48edfd287b174ef708e7ff9b1ead8e3c80dd7 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Thu, 11 Jun 2026 22:00:26 +0200 Subject: [PATCH 05/11] Replace git-utils with @pulsar-edit/git-utils --- package.json | 5 ++--- src/install.js | 2 +- src/publish.js | 2 +- src/upgrade.js | 2 +- yarn.lock | 16 +++++++++------- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index c32e9889..3285d435 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,11 @@ "test": "npm run check-version && jasmine --config=./spec/jasmine.json" }, "dependencies": { + "@pulsar-edit/git-utils": "^8.1.0", "asar-require": "0.3.0", "async": "^3.2.0", "colors": "~1.4.0", "fs-plus": "3.x", - "git-utils": "npm:@pulsar-edit/git-utils^@0.1.0", "hosted-git-info": "^3.0.7", "keytar": "^7.7.0", "npm": "https://github.com/pulsar-edit/npm-cli/releases/download/v6.14.19-pulsar2/npm-6.14.19-pulsar2.tgz", @@ -57,6 +57,5 @@ "npm/**/http-cache-semantics": "^4.1.1", "npm/**/node-gyp": "^10.2.0", "npm/**/tar": "^6.1.2" - }, - "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72" + } } diff --git a/src/install.js b/src/install.js index 00fef790..36794e9e 100644 --- a/src/install.js +++ b/src/install.js @@ -5,7 +5,7 @@ const path = require('path'); const async = require('async'); const CSON = require('season'); const yargs = require('yargs'); -const Git = require('git-utils'); +const Git = require('@pulsar-edit/git-utils'); const semver = require('semver'); const temp = require('temp'); const hostedGitInfo = require('hosted-git-info'); diff --git a/src/publish.js b/src/publish.js index 59d5e1d5..64d4a930 100644 --- a/src/publish.js +++ b/src/publish.js @@ -2,7 +2,7 @@ const path = require('path'); const yargs = require('yargs'); -const Git = require('git-utils'); +const Git = require('@pulsar-edit/git-utils'); const semver = require('semver'); const fs = require('./fs'); diff --git a/src/upgrade.js b/src/upgrade.js index d636f83a..b635f8c3 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -5,7 +5,7 @@ const async = require('async'); const yargs = require('yargs'); const { read } = require('read'); const semver = require('semver'); -const Git = require('git-utils'); +const Git = require('@pulsar-edit/git-utils'); const Command = require('./command'); const config = require('./apm'); diff --git a/yarn.lock b/yarn.lock index 0dffcdd3..0c4d9382 100644 --- a/yarn.lock +++ b/yarn.lock @@ -45,6 +45,13 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== +"@pulsar-edit/git-utils@^8.1.0": + version "8.1.0" + resolved "https://registry.yarnpkg.com/@pulsar-edit/git-utils/-/git-utils-8.1.0.tgz#e8f4469296bb889719aa7a2225893256351ef534" + integrity sha512-YaM5VWIw0ciC1JYyKm0BCDJ+FfAKQ/Pc2S7U/3b2UR1/Y146hzlx4HGISIWFTVK+ROFZpdVvfc3ECZ7lzzmBBA== + dependencies: + fs-plus "^3.0.0" + "@sindresorhus/is@^4.0.0": version "4.6.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" @@ -1815,13 +1822,6 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" -"git-utils@npm:@pulsar-edit/git-utils@0.1.0": - version "8.1.0" - resolved "https://registry.yarnpkg.com/@pulsar-edit/git-utils/-/git-utils-8.1.0.tgz#e8f4469296bb889719aa7a2225893256351ef534" - integrity sha512-YaM5VWIw0ciC1JYyKm0BCDJ+FfAKQ/Pc2S7U/3b2UR1/Y146hzlx4HGISIWFTVK+ROFZpdVvfc3ECZ7lzzmBBA== - dependencies: - fs-plus "^3.0.0" - github-from-package@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" @@ -4565,6 +4565,7 @@ strict-uri-encode@^2.0.0: integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ== "string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0: + name string-width-cjs version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -4651,6 +4652,7 @@ stringify-package@^1.0.0, stringify-package@^1.0.1: integrity sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg== "strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: + name strip-ansi-cjs version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== From adb539484a889abbcab94fd6bb8c1fc2bb6696f4 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Fri, 12 Jun 2026 00:09:18 +0200 Subject: [PATCH 06/11] Update CI config --- .github/workflows/CI.yml | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f54dff72..422f80b1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -18,9 +18,9 @@ jobs: - macos-14 - windows-latest node_version: - - 14 - - 16 - 18 + - 20 + - 22 node_arch: - x64 steps: @@ -34,41 +34,16 @@ jobs: check-latest: true - name: Setup Python - # NodeJS v14 can use the python included by the CI - if: ${{ matrix.node_version != 14 }} uses: actions/setup-python@v4 with: python-version: '3.12' - - name: Setup Python (NodeJS v14) - # While initially tests would pass with no Python setup, additional testing - # is showing issues with CI included Python versions, so we will install our own - if: ${{ matrix.node_version == 14 }} - uses: actions/setup-python@v4 - with: - python-version: '3.10' - - name: Install Python Dependencies - # NodeJS v14 doesn't have a newer copy of python, so we don't need to install deps - if: ${{ matrix.node_version != 14 }} - # This is needed for Python 3.12+, since node-gyp requires - # 'distutils', which has been removed run: python3 -m pip install setuptools - - name: Update node-gyp (NodeJS v14, Windows) - # Need newer node-gyp to support newer Visual Studio versions - if: ${{ matrix.node_version == 14 && runner.os == 'Windows' }} - run: yarn global add node-gyp@9 - - name: Install dependencies - if: ${{ matrix.node_version != 14 }} run: yarn install - - name: Install dependencies (NodeJS v14) - # node-gyp v10+'s `engines` field dropped support for Node 14... Ignore and install anyway. - if: ${{ matrix.node_version == 14 }} - run: yarn install --ignore-engines - - name: Run tests 👩🏾‍💻 run: ./bin/npm test # Q: Why are we using some random test section when the package.json has a test script? From 5ca865a7042d52eff61ded09fe29eed423013546 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Fri, 12 Jun 2026 22:19:54 +0200 Subject: [PATCH 07/11] Revert "Replace git-utils with @pulsar-edit/git-utils" This reverts commit 2da48edfd287b174ef708e7ff9b1ead8e3c80dd7. --- package.json | 5 +++-- src/install.js | 2 +- src/publish.js | 2 +- src/upgrade.js | 2 +- yarn.lock | 16 +++++++--------- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 3285d435..c32e9889 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,11 @@ "test": "npm run check-version && jasmine --config=./spec/jasmine.json" }, "dependencies": { - "@pulsar-edit/git-utils": "^8.1.0", "asar-require": "0.3.0", "async": "^3.2.0", "colors": "~1.4.0", "fs-plus": "3.x", + "git-utils": "npm:@pulsar-edit/git-utils^@0.1.0", "hosted-git-info": "^3.0.7", "keytar": "^7.7.0", "npm": "https://github.com/pulsar-edit/npm-cli/releases/download/v6.14.19-pulsar2/npm-6.14.19-pulsar2.tgz", @@ -57,5 +57,6 @@ "npm/**/http-cache-semantics": "^4.1.1", "npm/**/node-gyp": "^10.2.0", "npm/**/tar": "^6.1.2" - } + }, + "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72" } diff --git a/src/install.js b/src/install.js index 36794e9e..00fef790 100644 --- a/src/install.js +++ b/src/install.js @@ -5,7 +5,7 @@ const path = require('path'); const async = require('async'); const CSON = require('season'); const yargs = require('yargs'); -const Git = require('@pulsar-edit/git-utils'); +const Git = require('git-utils'); const semver = require('semver'); const temp = require('temp'); const hostedGitInfo = require('hosted-git-info'); diff --git a/src/publish.js b/src/publish.js index 64d4a930..59d5e1d5 100644 --- a/src/publish.js +++ b/src/publish.js @@ -2,7 +2,7 @@ const path = require('path'); const yargs = require('yargs'); -const Git = require('@pulsar-edit/git-utils'); +const Git = require('git-utils'); const semver = require('semver'); const fs = require('./fs'); diff --git a/src/upgrade.js b/src/upgrade.js index b635f8c3..d636f83a 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -5,7 +5,7 @@ const async = require('async'); const yargs = require('yargs'); const { read } = require('read'); const semver = require('semver'); -const Git = require('@pulsar-edit/git-utils'); +const Git = require('git-utils'); const Command = require('./command'); const config = require('./apm'); diff --git a/yarn.lock b/yarn.lock index 0c4d9382..0dffcdd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -45,13 +45,6 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== -"@pulsar-edit/git-utils@^8.1.0": - version "8.1.0" - resolved "https://registry.yarnpkg.com/@pulsar-edit/git-utils/-/git-utils-8.1.0.tgz#e8f4469296bb889719aa7a2225893256351ef534" - integrity sha512-YaM5VWIw0ciC1JYyKm0BCDJ+FfAKQ/Pc2S7U/3b2UR1/Y146hzlx4HGISIWFTVK+ROFZpdVvfc3ECZ7lzzmBBA== - dependencies: - fs-plus "^3.0.0" - "@sindresorhus/is@^4.0.0": version "4.6.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" @@ -1822,6 +1815,13 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +"git-utils@npm:@pulsar-edit/git-utils@0.1.0": + version "8.1.0" + resolved "https://registry.yarnpkg.com/@pulsar-edit/git-utils/-/git-utils-8.1.0.tgz#e8f4469296bb889719aa7a2225893256351ef534" + integrity sha512-YaM5VWIw0ciC1JYyKm0BCDJ+FfAKQ/Pc2S7U/3b2UR1/Y146hzlx4HGISIWFTVK+ROFZpdVvfc3ECZ7lzzmBBA== + dependencies: + fs-plus "^3.0.0" + github-from-package@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce" @@ -4565,7 +4565,6 @@ strict-uri-encode@^2.0.0: integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ== "string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0: - name string-width-cjs version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -4652,7 +4651,6 @@ stringify-package@^1.0.0, stringify-package@^1.0.1: integrity sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg== "strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: - name strip-ansi-cjs version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== From e688f5da055f2d90689aff8a76ab38ac1b1b1711 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Fri, 12 Jun 2026 22:29:17 +0200 Subject: [PATCH 08/11] Revert "refactor: use git-utils api instead of spawning git child process" This reverts commit 478aa593a92137dd43b9a95842edd1f3a9cfb586. --- src/publish.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/publish.js b/src/publish.js index 59d5e1d5..18b4a82f 100644 --- a/src/publish.js +++ b/src/publish.js @@ -1,5 +1,6 @@ const path = require('path'); +const { execSync } = require('child_process'); const yargs = require('yargs'); const Git = require('git-utils'); @@ -276,7 +277,10 @@ have published it.\ getDefaultBranch(repo) { try { - const ref = repo.getSymbolicRefTarget('refs/remotes/origin/HEAD'); + const ref = execSync('git symbolic-ref refs/remotes/origin/HEAD', { + encoding: 'utf8', + stdio: ['pipe', 'pipe', 'ignore'] + }).trim(); const match = ref.match(/refs\/remotes\/origin\/(.+)/); if (match) { return match[1]; } } catch { /* symbolic-ref may not exist; fall through to heuristic */ } From c2f02591ff3bb5eec1b78fd14a57a7e9334d71a4 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Fri, 12 Jun 2026 22:30:59 +0200 Subject: [PATCH 09/11] Revert "chore: install @pulsar/git-utils" This reverts commit bf033cbcd7e80ad01af7c1dc38a89feda3d0992d. --- package.json | 5 ++--- yarn.lock | 34 ++++++++++++++++++++++++++++------ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index c32e9889..21dc2390 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "async": "^3.2.0", "colors": "~1.4.0", "fs-plus": "3.x", - "git-utils": "npm:@pulsar-edit/git-utils^@0.1.0", + "git-utils": "^5.7.2", "hosted-git-info": "^3.0.7", "keytar": "^7.7.0", "npm": "https://github.com/pulsar-edit/npm-cli/releases/download/v6.14.19-pulsar2/npm-6.14.19-pulsar2.tgz", @@ -57,6 +57,5 @@ "npm/**/http-cache-semantics": "^4.1.1", "npm/**/node-gyp": "^10.2.0", "npm/**/tar": "^6.1.2" - }, - "packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72" + } } diff --git a/yarn.lock b/yarn.lock index 0dffcdd3..4928eecd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1815,12 +1815,13 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" -"git-utils@npm:@pulsar-edit/git-utils@0.1.0": - version "8.1.0" - resolved "https://registry.yarnpkg.com/@pulsar-edit/git-utils/-/git-utils-8.1.0.tgz#e8f4469296bb889719aa7a2225893256351ef534" - integrity sha512-YaM5VWIw0ciC1JYyKm0BCDJ+FfAKQ/Pc2S7U/3b2UR1/Y146hzlx4HGISIWFTVK+ROFZpdVvfc3ECZ7lzzmBBA== +git-utils@^5.7.2: + version "5.7.3" + resolved "https://registry.yarnpkg.com/git-utils/-/git-utils-5.7.3.tgz#3b53983204678313b305bbf278c07dc015ba2155" + integrity sha512-in1hjFfmzY86gKBt+YMTaVyCGtX2WTnN0uPj37bI5HsrnU2oj8OFcWOEzOI5PxQXPMxFxtvRebOHAOGB8M125w== dependencies: fs-plus "^3.0.0" + nan "^2.14.2" github-from-package@0.0.0: version "0.0.0" @@ -3094,6 +3095,11 @@ mute-stream@~0.0.4: resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA== +nan@^2.14.2: + version "2.18.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.18.0.tgz#26a6faae7ffbeb293a39660e88a76b82e30b7554" + integrity sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w== + napi-build-utils@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806" @@ -4564,7 +4570,7 @@ strict-uri-encode@^2.0.0: resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ== -"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0: +"string-width-cjs@npm:string-width@^4.2.0": version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -4582,6 +4588,15 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^2.0.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -4650,7 +4665,7 @@ stringify-package@^1.0.0, stringify-package@^1.0.1: resolved "https://registry.yarnpkg.com/stringify-package/-/stringify-package-1.0.1.tgz#e5aa3643e7f74d0f28628b72f3dad5cecfc3ba85" integrity sha512-sa4DUQsYciMP1xhKWGuFM04fB0LG/9DlluZoSVywUMRNvzid6XucHK0/90xGxRoHrAaROrcHK1aPKaijCtSrhg== -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -4678,6 +4693,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" From 1714a50f709b5af48c4cbcae12f9b2f4f90fab22 Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Fri, 12 Jun 2026 22:31:12 +0200 Subject: [PATCH 10/11] Add TODO comment --- src/publish.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/publish.js b/src/publish.js index 18b4a82f..4bf8b491 100644 --- a/src/publish.js +++ b/src/publish.js @@ -277,6 +277,8 @@ have published it.\ getDefaultBranch(repo) { try { + // TODO replace with repo.getSymbolicRefTarget once the Windows issues in @pulsar-edit/git-utils have been fixed + // see https://github.com/pulsar-edit/ppm/pull/175/changes/478aa593a92137dd43b9a95842edd1f3a9cfb586 const ref = execSync('git symbolic-ref refs/remotes/origin/HEAD', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] From e1d74b5ff0dc82302358fc3fa4aa5e8906ac53ec Mon Sep 17 00:00:00 2001 From: "Jan T. Sott" Date: Sat, 13 Jun 2026 01:09:22 +0200 Subject: [PATCH 11/11] Update NodeJS matrix --- .github/workflows/CI.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 422f80b1..c09c7679 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -20,7 +20,6 @@ jobs: node_version: - 18 - 20 - - 22 node_arch: - x64 steps: