Skip to content

Commit

Permalink
copy schema.json to dist folder (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
fubhy authored Nov 15, 2023
1 parent 6a4685f commit 4e72aee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-ways-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/docgen": patch
---

Re-added schema.json
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"engines": {
"node": ">=16.17.1"
},
"bin": {
"docgen": "./dist/bin.js"
},
"repository": {
"type": "git",
"url": "https://github.com/effect-ts/docgen.git"
Expand All @@ -24,11 +21,6 @@
"url": "https://github.com/effect-ts/docgen/issues"
},
"homepage": "https://github.com/effect-ts/docgen",
"files": [
"dist",
"src",
"schema.json"
],
"scripts": {
"prepare": "pnpm clean && pnpm build",
"update-version": "changeset version && pnpm install --no-frozen-lockfile",
Expand Down
18 changes: 9 additions & 9 deletions scripts/copy-package-json.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import * as FileSystem from "@effect/platform-node/FileSystem"
import { Effect, ReadonlyRecord } from "effect"
import * as path from "node:path"
import { FileSystem, Path } from "@effect/platform-node"
import { Effect, Layer, ReadonlyRecord } from "effect"

const excludedPrefixes = ["@effect", "effect", "chalk", "tsconfck", "ts-morph"]

const excludeEffectPackages = (deps: Record<string, string>): Record<string, string> =>
ReadonlyRecord.filter(deps, (_, k) => !excludedPrefixes.some((_) => k.startsWith(_)))

const pathTo = path.join("dist", "package.json")

const program = Effect.gen(function*(_) {
console.log(`[Build] Copying package.json to ${pathTo}...`)
const fs = yield* _(FileSystem.FileSystem)
const path = yield* _(Path.Path)
yield* _(Effect.log(`[Build] Copying schema.json ...`))
yield* _(fs.copyFile("schema.json", path.join("dist", "schema.json")))
yield* _(Effect.log(`[Build] Copying package.json ...`))
const json: any = yield* _(fs.readFileString("package.json"), Effect.map(JSON.parse))
const pkg = {
name: json.name,
Expand All @@ -31,10 +31,10 @@ const program = Effect.gen(function*(_) {
tags: json.tags,
keywords: json.keywords
}
yield* _(fs.writeFileString(pathTo, JSON.stringify(pkg, null, 2)))
console.log("[Build] Build completed.")
yield* _(fs.writeFileString(path.join("dist", "package.json"), JSON.stringify(pkg, null, 2)))
yield* _(Effect.log("[Build] Build completed."))
}).pipe(
Effect.provide(FileSystem.layer)
Effect.provide(Layer.merge(FileSystem.layer, Path.layerPosix))
)

Effect.runPromise(program).catch(console.error)

0 comments on commit 4e72aee

Please sign in to comment.