-
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.
- Loading branch information
1 parent
920215f
commit a6afe30
Showing
3 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { build, emptyDir } from "https://deno.land/x/dnt@0.30.0/mod.ts"; | ||
import { join } from "https://deno.land/std@0.157.0/path/mod.ts"; | ||
import { makeOptions } from "./meta.ts"; | ||
|
||
async function buildPkg(version: string): Promise<void> { | ||
await emptyDir("./npm"); | ||
const pkg = makeOptions(version); | ||
await Deno.copyFile("LICENSE", join(pkg.outDir, "LICENSE")); | ||
Deno.copyFile( | ||
join(".", "README.md"), | ||
join(pkg.outDir, "README.md"), | ||
); | ||
await build(pkg); | ||
} | ||
|
||
if (import.meta.main) { | ||
const version = Deno.args[0]; | ||
if (!version) { | ||
console.error("argument is required"); | ||
Deno.exit(1); | ||
} | ||
await buildPkg(version); | ||
} |
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,38 @@ | ||
import { BuildOptions } from "https://deno.land/x/dnt@0.30.0/mod.ts"; | ||
|
||
export const makeOptions = (version: string): BuildOptions => ({ | ||
test: false, | ||
shims: {}, | ||
typeCheck: true, | ||
entryPoints: ["./mod.ts"], | ||
outDir: "./npm", | ||
package: { | ||
name: "resultjs", | ||
version, | ||
description: "The standard API for result in JavaScript", | ||
keywords: [ | ||
"result", | ||
"ok", | ||
"error", | ||
"container", | ||
"handle", | ||
"throw", | ||
"throws", | ||
"handling", | ||
"match", | ||
"unsafe", | ||
], | ||
license: "MIT", | ||
homepage: "https://github.com/TomokiMiyauci/result-js", | ||
repository: { | ||
type: "git", | ||
url: "git+https://github.com/TomokiMiyauci/result-js.git", | ||
}, | ||
bugs: { | ||
url: "https://github.com/TomokiMiyauci/result-js/issues", | ||
}, | ||
sideEffects: false, | ||
type: "module", | ||
}, | ||
packageManager: "pnpm", | ||
}); |
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,26 @@ | ||
import { prerelease, valid } from "https://deno.land/x/semver@v1.4.0/mod.ts"; | ||
import { makeOptions } from "./meta.ts"; | ||
|
||
if (import.meta.main) { | ||
const version = Deno.args[0]; | ||
if (!version) { | ||
console.error("arg of version is required"); | ||
Deno.exit(1); | ||
} | ||
if (!valid(version)) { | ||
console.error("The argument of version is invalid"); | ||
Deno.exit(1); | ||
} | ||
|
||
const isPrerelease = prerelease(version); | ||
const tag = isPrerelease?.[0] ?? "latest"; | ||
|
||
const pkg = makeOptions(version); | ||
const result = await Deno.run({ | ||
cmd: ["npm", "publish", pkg.outDir, "--tag", String(tag)], | ||
stdout: "piped", | ||
}) | ||
.output(); | ||
|
||
console.log(new TextDecoder().decode(result)); | ||
} |