@fuman/build 0.0.4 → 0.0.6

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.
@@ -138,7 +138,7 @@ async function publishPackages(params) {
138
138
  if (tar.exitCode !== 0) {
139
139
  console.error(tar.stderr);
140
140
  } else {
141
- tarballs.push(tar.stdout.trim());
141
+ tarballs.push(join(fullDistDir, tar.stdout.trim()));
142
142
  }
143
143
  }
144
144
  }
@@ -1,7 +1,8 @@
1
- import { readFile } from "node:fs/promises";
1
+ import { createReadStream } from "node:fs";
2
2
  import { basename } from "node:path";
3
3
  import process from "node:process";
4
- import { asNonNull, notImplemented, parallelMap } from "@fuman/utils";
4
+ import { nodeReadableToWeb } from "@fuman/node";
5
+ import { asNonNull, notImplemented } from "@fuman/utils";
5
6
  import { sort } from "semver";
6
7
  import { createGithubRelease } from "../../git/github.js";
7
8
  import { getLatestTag, getFirstCommit, gitTagExists } from "../../git/utils.js";
@@ -212,10 +213,10 @@ ${changelog}`;
212
213
  tag: tagName,
213
214
  name: tagName,
214
215
  body: changelog,
215
- artifacts: await parallelMap(tarballs, async (file) => ({
216
+ artifacts: tarballs.map((file) => ({
216
217
  name: basename(file),
217
218
  type: "application/gzip",
218
- body: await readFile(file)
219
+ body: nodeReadableToWeb(createReadStream(file))
219
220
  }))
220
221
  });
221
222
  console.log(`\x1B[;32m✅github release created: https://github.com/${repo}/releases/tag/${tagName}\x1B[;0m`);
package/git/github.js CHANGED
@@ -30,7 +30,7 @@ async function createGithubRelease(params) {
30
30
  }));
31
31
  if (params.artifacts != null && params.artifacts.length > 0) {
32
32
  await asyncPool(params.artifacts, async (file) => {
33
- await ffetch(`/repos/${params.repo}/releases/${release.id}/assets`, {
33
+ await ffetch(`https://uploads.github.com/repos/${params.repo}/releases/${release.id}/assets`, {
34
34
  method: "POST",
35
35
  query: { name: file.name },
36
36
  headers: {
@@ -39,6 +39,12 @@ async function createGithubRelease(params) {
39
39
  body: file.body,
40
40
  validateResponse: (res) => res.status === 201
41
41
  });
42
+ }, {
43
+ onError: (item, idx, err) => {
44
+ console.error("failed to upload artifact:", item.name);
45
+ console.error(err);
46
+ return "ignore";
47
+ }
42
48
  });
43
49
  }
44
50
  return release.id;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@fuman/build",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "description": "utils for building packages and managing monorepos",
6
6
  "license": "MIT",
7
7
  "scripts": {},
8
8
  "dependencies": {
9
9
  "@drizzle-team/brocli": "^0.10.2",
10
- "@fuman/fetch": "^0.0.4",
10
+ "@fuman/fetch": "^0.0.6",
11
11
  "@fuman/io": "^0.0.4",
12
12
  "@fuman/node": "^0.0.4",
13
13
  "@fuman/utils": "^0.0.4",
@@ -1,7 +1,8 @@
1
1
  import * as fsp from "node:fs/promises";
2
2
  import { join, relative } from "node:path";
3
3
  import process from "node:process";
4
- import { asNonNull, deepMerge, assertStartsWith } from "@fuman/utils";
4
+ import { asNonNull, deepMerge, assertStartsWith, parallelMap } from "@fuman/utils";
5
+ import { glob } from "tinyglobby";
5
6
  import { loadBuildConfig } from "../misc/_config.js";
6
7
  import { tryCopy, fileExists, directoryExists } from "../misc/fs.js";
7
8
  import { normalizeFilePath } from "../misc/path.js";
@@ -148,16 +149,15 @@ async function fumanBuild(params) {
148
149
  await fsp.writeFile(dTsFile, `export * from ${JSON.stringify(entrypointFile)}`);
149
150
  }
150
151
  }
151
- if (buildCjs && await directoryExists(join(buildDir, "chunks/cjs"))) {
152
- const cjsFile = join(buildDir, "chunks/cjs/package.json");
153
- await fsp.writeFile(cjsFile, JSON.stringify({ type: "commonjs" }));
154
- for (const name of Object.keys(entrypoints)) {
155
- const dTsFile = join(buildDir, `${name}.d.ts`);
156
- if (!await fileExists(dTsFile)) {
157
- continue;
158
- }
159
- await fsp.cp(dTsFile, dTsFile.replace(/\.d\.ts$/, ".d.cts"));
152
+ if (buildCjs) {
153
+ if (await directoryExists(join(buildDir, "chunks/cjs"))) {
154
+ const cjsFile = join(buildDir, "chunks/cjs/package.json");
155
+ await fsp.writeFile(cjsFile, JSON.stringify({ type: "commonjs" }));
160
156
  }
157
+ await parallelMap(await glob("**/*.d.ts", { cwd: buildDir }), async (file) => {
158
+ const fullPath = join(buildDir, file);
159
+ await fsp.cp(fullPath, fullPath.replace(/\.d\.ts$/, ".d.cts"));
160
+ });
161
161
  }
162
162
  await params.finalize?.(hookContext);
163
163
  await packageConfig?.finalize?.(hookContext);