Skip to content

Commit

Permalink
fix(releaser): include LICENSE in native packages
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-olszewski committed Feb 6, 2025
1 parent 152a48a commit f390193
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
11 changes: 9 additions & 2 deletions packages/turbo-releaser/src/native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ describe("generateNativePackage", () => {
);

// Assert copyFile was called correctly
assert.equal(mockCopyFile.mock.calls.length, 1);
assert.equal(mockCopyFile.mock.calls.length, 2);
assert.ok(
mockCopyFile.mock.calls[0].arguments[0].endsWith("template/README.md")
);
assert.equal(
mockCopyFile.mock.calls[0].arguments[1],
path.join(outputDir, "README.md")
);
assert.ok(
mockCopyFile.mock.calls[1].arguments[0].endsWith("template/LICENSE")
);
assert.equal(
mockCopyFile.mock.calls[1].arguments[1],
path.join(outputDir, "LICENSE")
);

// Assert writeFile was called correctly
assert.equal(mockWriteFile.mock.calls.length, 1);
Expand Down Expand Up @@ -91,7 +98,7 @@ describe("generateNativePackage", () => {
outputDir,
});

assert.equal(mockCopyFile.mock.calls.length, 2);
assert.equal(mockCopyFile.mock.calls.length, 3);
assert.ok(
mockCopyFile.mock.calls[0].arguments[0].endsWith("template/bin/turbo")
);
Expand Down
19 changes: 10 additions & 9 deletions packages/turbo-releaser/src/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ async function generateNativePackage({
await rm(outputDir, { recursive: true, force: true });
await mkdir(path.join(outputDir, "bin"), { recursive: true });

if (os === "windows") {
console.log("Copying Windows-specific files...");
const copyFromTemplate = async (part: string, ...parts: Array<string>) => {
console.log("Copying ", path.join(part, ...parts));
await copyFile(
path.join(templateDir, "bin", "turbo"),
path.join(outputDir, "bin", "turbo")
path.join(templateDir, part, ...parts),
path.join(outputDir, part, ...parts)
);
};

if (os === "windows") {
await copyFromTemplate("bin", "turbo");
}

console.log("Copying README.md...");
await copyFile(
path.join(templateDir, "README.md"),
path.join(outputDir, "README.md")
);
await copyFromTemplate("README.md");
await copyFromTemplate("LICENSE");

console.log("Generating package.json...");
const packageJson = {
Expand Down
7 changes: 7 additions & 0 deletions packages/turbo-releaser/template/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) 2024 Vercel, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit f390193

Please sign in to comment.