Skip to content

Commit

Permalink
Release 0.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
schickling committed May 11, 2022
1 parent 081e03e commit fdac478
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 20 deletions.
1 change: 0 additions & 1 deletion .vscode/settings.json
Expand Up @@ -15,7 +15,6 @@
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/dist": true,
"**/*.lock": true,
"**/vercel.json": true,
"**/.yarn": true,
"**/.direnv": true
Expand Down
2 changes: 1 addition & 1 deletion packages/@contentlayer/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@contentlayer/cli",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/@contentlayer/client/package.json
@@ -1,6 +1,6 @@
{
"name": "@contentlayer/client",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/@contentlayer/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@contentlayer/core",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/@contentlayer/core/src/ArtifactsDir.ts
Expand Up @@ -16,6 +16,7 @@ export namespace ArtifactsDir {
export const mkdir: T.Effect<OT.HasTracer & HasCwd, fs.MkdirError, PosixFilePath> = T.gen(function* ($) {
const cwd = yield* $(getCwd)
const dirPath = getDirPath({ cwd })

yield* $(fs.mkdirp(dirPath))

return dirPath
Expand Down
17 changes: 11 additions & 6 deletions packages/@contentlayer/core/src/getConfig/index.ts
@@ -1,5 +1,5 @@
import type { E } from '@contentlayer/utils/effect'
import { Chunk, OT, pipe, S, T } from '@contentlayer/utils/effect'
import { Array, Chunk, O, OT, pipe, S, T } from '@contentlayer/utils/effect'
import type { GetContentlayerVersionError } from '@contentlayer/utils/node'
import { fs } from '@contentlayer/utils/node'
import * as path from 'node:path'
Expand Down Expand Up @@ -48,14 +48,14 @@ export const getConfigWatch = ({
configPath?: string
}): S.Stream<OT.HasTracer & HasCwd, never, E.Either<GetConfigError, Config>> => {
const resolveParams = pipe(
T.structPar({ configPath: resolveConfigPath({ configPath: configPath_ }) }),
T.structPar({ configPath: resolveConfigPath({ configPath: configPath_ }), cwd: getCwd }),
T.chainMergeObject(() => makeTmpDirAndResolveEntryPoint),
T.either,
)

return pipe(
S.fromEffect(resolveParams),
S.chainMapEitherRight(({ configPath, outfilePath }) =>
S.chainMapEitherRight(({ configPath, outfilePath, cwd }) =>
pipe(
esbuild.makeAndSubscribe({
entryPoints: [configPath],
Expand All @@ -70,6 +70,7 @@ export const getConfigWatch = ({
bundle: true,
logLevel: 'silent',
metafile: true,
absWorkingDir: cwd,
plugins: [contentlayerGenPlugin(), makeAllPackagesExternalPlugin(configPath)],
}),
S.mapEffectEitherRight((result) => getConfigFromResult({ result, configPath })),
Expand Down Expand Up @@ -133,11 +134,15 @@ const getConfigFromResult = ({

const cwd = yield* $(getCwd)

const outfilePath = Object.keys(result.metafile!.outputs)
// Deriving the exact outfilePath here since it's suffixed with a hash
const outfilePath = pipe(
Object.keys(result.metafile!.outputs),
// Will look like `path.join(cacheDir, 'compiled-contentlayer-config-[SOME_HASH].mjs')
.filter((_) => _.match(/compiled-contentlayer-config-.+.mjs$/))
Array.find((_) => _.match(/compiled-contentlayer-config-.+.mjs$/) !== null),
// Needs to be absolute path for ESM import to work
.map((_) => path.join(cwd, _))[0]!
O.map((_) => path.join(cwd, _)),
O.getUnsafe,
)

const esbuildHash = outfilePath.match(/compiled-contentlayer-config-(.+).mjs$/)![1]!

Expand Down
2 changes: 1 addition & 1 deletion packages/@contentlayer/source-contentful/package.json
@@ -1,6 +1,6 @@
{
"name": "@contentlayer/source-contentful",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/@contentlayer/source-files/package.json
@@ -1,6 +1,6 @@
{
"name": "@contentlayer/source-files",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"type": "module",
"exports": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/@contentlayer/source-sanity/package.json
@@ -1,6 +1,6 @@
{
"name": "@contentlayer/source-sanity",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/@contentlayer/utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@contentlayer/utils",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"type": "module",
"exports": {
"./package.json": {
Expand Down
7 changes: 7 additions & 0 deletions packages/@contentlayer/utils/src/effect/Array.ts
@@ -0,0 +1,7 @@
import { Array, pipe } from '@effect-ts/core'

import * as O from './Option.js'

export * from '@effect-ts/core/Collections/Immutable/Array'

export const headUnsafe = <A>(array: Array.Array<A>): A => pipe(array, Array.head, O.getUnsafe)
11 changes: 11 additions & 0 deletions packages/@contentlayer/utils/src/effect/Option.ts
@@ -0,0 +1,11 @@
import { Option } from '@effect-ts/core'

export * from '@effect-ts/core/Option'

export const getUnsafe = <A>(option: Option.Option<A>): A => {
if (Option.isSome(option)) {
return option.value
}

throw new Error('Option.getUnsafe: Option is None')
}
6 changes: 3 additions & 3 deletions packages/@contentlayer/utils/src/effect/index.ts
Expand Up @@ -28,7 +28,7 @@ export * as Tp from '@effect-ts/core/Collections/Immutable/Tuple'
export * as HashMap from '@effect-ts/core/Collections/Immutable/HashMap'
export * as HashSet from '@effect-ts/core/Collections/Immutable/HashSet'

export * as Array from '@effect-ts/core/Collections/Immutable/Array'
export * as Array from './Array.js'

export * as These from './These.js'

Expand All @@ -48,8 +48,8 @@ export * as SC from '@effect-ts/core/Effect/Schedule'
export * as Either from '@effect-ts/core/Either'
export * as E from '@effect-ts/core/Either'

export * as Option from '@effect-ts/core/Option'
export * as O from '@effect-ts/core/Option'
export * as Option from './Option.js'
export * as O from './Option.js'

export * as Ex from '@effect-ts/core/Effect/Exit'

Expand Down
2 changes: 1 addition & 1 deletion packages/contentlayer-stackbit-yaml-generator/package.json
@@ -1,6 +1,6 @@
{
"name": "contentlayer-stackbit-yaml-generator",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"type": "module",
"bin": "./dist/cli/index.js",
"exports": "./dist/lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentlayer/package.json
@@ -1,6 +1,6 @@
{
"name": "contentlayer",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"bin": "./bin/cli.cjs",
"type": "module",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-contentlayer/package.json
@@ -1,6 +1,6 @@
{
"name": "next-contentlayer",
"version": "0.2.5-dev.7",
"version": "0.2.5",
"type": "module",
"main": "./dist/index-cjs.cjs",
"sideEffects": false,
Expand Down

0 comments on commit fdac478

Please sign in to comment.