-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate from dotnetHelpers to avoid circular dependency. fixes #406 `tokenCanWritePackages` should authenticate via GPR's NuGet API and `dotnet nuget push` cli
- Loading branch information
Showing
6 changed files
with
120 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { execSync, type ExecSyncOptionsWithStringEncoding } from 'node:child_process'; | ||
import { existsSync, unlinkSync } from 'node:fs'; | ||
import { dirname, join } from 'node:path'; | ||
import { dirSync } from 'tmp'; | ||
|
||
export function createDummyNupkg(): string { | ||
const dirResult = dirSync({ unsafeCleanup: true }); | ||
const dummyPkgFullPath: string = join(dirResult.name, 'DUMMY.1.0.0.nupkg'); | ||
|
||
// delete old and possibly-poisoned nupkg | ||
if (existsSync(dummyPkgFullPath)) | ||
unlinkSync(dummyPkgFullPath); | ||
|
||
const options: ExecSyncOptionsWithStringEncoding = { | ||
cwd: dirResult.name, | ||
encoding: 'utf8' | ||
}; | ||
|
||
execSync('dotnet new console --name DUMMY', options); | ||
const packOut = execSync(`dotnet pack DUMMY --configuration Release --output ${dirname(dummyPkgFullPath)}`, options); | ||
|
||
const createdLine = packOut.replace('\r', '') | ||
.split('\n') | ||
.find(line => line.includes('Successfully created package'))?.trim(); | ||
|
||
if (!existsSync(dummyPkgFullPath)) | ||
throw new Error(`The dummy nupkg was created, but could not be found at ${dummyPkgFullPath}. See '${createdLine}'.`); | ||
|
||
return dummyPkgFullPath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createDummyNupkg } from '@halospv3/hce.shared-config/dotnet/createDummyNupkg'; | ||
import { strictEqual } from 'node:assert'; | ||
import { existsSync } from 'node:fs'; | ||
import { describe, it } from 'node:test'; | ||
|
||
await describe('createDummyNupkg', () => { | ||
const dummyNupkgPath = createDummyNupkg(); | ||
|
||
it('returns a path that exists', () => { | ||
strictEqual(existsSync(dummyNupkgPath), true); | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters