diff --git a/package.json b/package.json index f0fcf9c3..bcebfbd3 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "scripts": { "clean": "node scripts/clean.mjs && rimraf tsconfig.tsbuildinfo", "build": "pnpm gen && preconstruct fix && preconstruct build && pnpm gen", - "gen": "node scripts/gen.mjs", + "gen": "build-utils prepare-v1", "circular": "madge --ts-config ./tsconfig.json --circular --no-color --no-spinner packages/*", "test": "vitest", "autofix": "ultra -r autofix", @@ -28,7 +28,7 @@ "@babel/preset-typescript": "^7.23.0", "@changesets/changelog-github": "^0.4.8", "@changesets/cli": "^2.26.2", - "@effect/build-utils": "^0.1.4", + "@effect/build-utils": "^0.1.5", "@effect/docgen": "^0.1.8", "@effect/eslint-plugin": "^0.1.2", "@effect/language-service": "0.0.21", diff --git a/packages/platform-browser/.gitignore b/packages/platform-browser/.gitignore index 605d9591..878c18cd 100644 --- a/packages/platform-browser/.gitignore +++ b/packages/platform-browser/.gitignore @@ -1,7 +1,6 @@ coverage/ *.tsbuildinfo node_modules/ -yarn-error.log .ultra.cache.json .DS_Store tmp/ diff --git a/packages/platform-browser/package.json b/packages/platform-browser/package.json index 8a96441b..07a0127f 100644 --- a/packages/platform-browser/package.json +++ b/packages/platform-browser/package.json @@ -13,6 +13,9 @@ "importConditionDefaultExport": "default" } }, + "effect": { + "generateIndex": true + }, "publishConfig": { "access": "public" }, diff --git a/packages/platform-browser/src/index.ts b/packages/platform-browser/src/index.ts index 61090979..14f39e45 100644 --- a/packages/platform-browser/src/index.ts +++ b/packages/platform-browser/src/index.ts @@ -1,38 +1,38 @@ /** * @since 1.0.0 */ -export * as Clipboard from "./Clipboard" +export * as Clipboard from "@effect/platform-browser/Clipboard" /** * @since 1.0.0 */ -export * as Effectify from "./Effectify" +export * as Effectify from "@effect/platform-browser/Effectify" /** * @since 1.0.0 */ -export * as Error from "./Error" +export * as Error from "@effect/platform-browser/Error" /** * @since 1.0.0 */ -export * as HttpClient from "./HttpClient" +export * as HttpClient from "@effect/platform-browser/HttpClient" /** * @since 1.0.0 * * Also includes exports from [`@effect/platform/KeyValueStore`](https://effect-ts.github.io/platform/platform/KeyValueStore.ts.html). */ -export * as KeyValueStore from "./KeyValueStore" +export * as KeyValueStore from "@effect/platform-browser/KeyValueStore" /** * @since 1.0.0 * * Also includes exports from [`@effect/platform/Path`](https://effect-ts.github.io/platform/platform/Path.ts.html). */ -export * as Path from "./Path" +export * as Path from "@effect/platform-browser/Path" /** * @since 1.0.0 */ -export * as Runtime from "./Runtime" +export * as Runtime from "@effect/platform-browser/Runtime" diff --git a/packages/platform-bun/.gitignore b/packages/platform-bun/.gitignore index ecca9cb1..81184de7 100644 --- a/packages/platform-bun/.gitignore +++ b/packages/platform-bun/.gitignore @@ -1,7 +1,6 @@ coverage/ *.tsbuildinfo node_modules/ -yarn-error.log .ultra.cache.json .DS_Store tmp/ diff --git a/packages/platform-bun/package.json b/packages/platform-bun/package.json index c1bc0592..adf1d322 100644 --- a/packages/platform-bun/package.json +++ b/packages/platform-bun/package.json @@ -14,6 +14,9 @@ "importConditionDefaultExport": "default" } }, + "effect": { + "generateIndex": true + }, "publishConfig": { "access": "public" }, diff --git a/packages/platform-bun/src/index.ts b/packages/platform-bun/src/index.ts index 7d35edb7..5a8394f0 100644 --- a/packages/platform-bun/src/index.ts +++ b/packages/platform-bun/src/index.ts @@ -1,66 +1,66 @@ /** * @since 1.0.0 */ -export * as BunContext from "./BunContext" +export * as BunContext from "@effect/platform-bun/BunContext" /** * @since 1.0.0 */ -export * as Command from "./Command" +export * as Command from "@effect/platform-bun/Command" /** * @since 1.0.0 */ -export * as CommandExecutor from "./CommandExecutor" +export * as CommandExecutor from "@effect/platform-bun/CommandExecutor" /** * @since 1.0.0 */ -export * as Effectify from "./Effectify" +export * as Effectify from "@effect/platform-bun/Effectify" /** * @since 1.0.0 */ -export * as Error from "./Error" +export * as Error from "@effect/platform-bun/Error" /** * @since 1.0.0 */ -export * as FileSystem from "./FileSystem" +export * as FileSystem from "@effect/platform-bun/FileSystem" /** * @since 1.0.0 */ -export * as HttpClient from "./HttpClient" +export * as HttpClient from "@effect/platform-bun/HttpClient" /** * @since 1.0.0 */ -export * as HttpServer from "./HttpServer" +export * as HttpServer from "@effect/platform-bun/HttpServer" /** * @since 1.0.0 * * Also includes exports from [`@effect/platform/KeyValueStore`](https://effect-ts.github.io/platform/platform/KeyValueStore.ts.html). */ -export * as KeyValueStore from "./KeyValueStore" +export * as KeyValueStore from "@effect/platform-bun/KeyValueStore" /** * @since 1.0.0 */ -export * as Path from "./Path" +export * as Path from "@effect/platform-bun/Path" /** * @since 1.0.0 */ -export * as Runtime from "./Runtime" +export * as Runtime from "@effect/platform-bun/Runtime" /** * @since 1.0.0 */ -export * as Sink from "./Sink" +export * as Sink from "@effect/platform-bun/Sink" /** * @since 1.0.0 */ -export * as Stream from "./Stream" +export * as Stream from "@effect/platform-bun/Stream" diff --git a/packages/platform-node/.gitignore b/packages/platform-node/.gitignore index 612f627b..aad67fa6 100644 --- a/packages/platform-node/.gitignore +++ b/packages/platform-node/.gitignore @@ -1,7 +1,6 @@ coverage/ *.tsbuildinfo node_modules/ -yarn-error.log .ultra.cache.json .DS_Store tmp/ diff --git a/packages/platform-node/package.json b/packages/platform-node/package.json index 2ea29b54..052c9c4f 100644 --- a/packages/platform-node/package.json +++ b/packages/platform-node/package.json @@ -14,6 +14,9 @@ "importConditionDefaultExport": "default" } }, + "effect": { + "generateIndex": true + }, "publishConfig": { "access": "public" }, diff --git a/packages/platform-node/src/index.ts b/packages/platform-node/src/index.ts index 23bcab27..709e296b 100644 --- a/packages/platform-node/src/index.ts +++ b/packages/platform-node/src/index.ts @@ -1,66 +1,66 @@ /** * @since 1.0.0 */ -export * as Command from "./Command" +export * as Command from "@effect/platform-node/Command" /** * @since 1.0.0 */ -export * as CommandExecutor from "./CommandExecutor" +export * as CommandExecutor from "@effect/platform-node/CommandExecutor" /** * @since 1.0.0 */ -export * as Effectify from "./Effectify" +export * as Effectify from "@effect/platform-node/Effectify" /** * @since 1.0.0 */ -export * as Error from "./Error" +export * as Error from "@effect/platform-node/Error" /** * @since 1.0.0 */ -export * as FileSystem from "./FileSystem" +export * as FileSystem from "@effect/platform-node/FileSystem" /** * @since 1.0.0 */ -export * as HttpClient from "./HttpClient" +export * as HttpClient from "@effect/platform-node/HttpClient" /** * @since 1.0.0 */ -export * as HttpServer from "./HttpServer" +export * as HttpServer from "@effect/platform-node/HttpServer" /** * @since 1.0.0 * * Also includes exports from [`@effect/platform/KeyValueStore`](https://effect-ts.github.io/platform/platform/KeyValueStore.ts.html). */ -export * as KeyValueStore from "./KeyValueStore" +export * as KeyValueStore from "@effect/platform-node/KeyValueStore" /** * @since 1.0.0 */ -export * as NodeContext from "./NodeContext" +export * as NodeContext from "@effect/platform-node/NodeContext" /** * @since 1.0.0 */ -export * as Path from "./Path" +export * as Path from "@effect/platform-node/Path" /** * @since 1.0.0 */ -export * as Runtime from "./Runtime" +export * as Runtime from "@effect/platform-node/Runtime" /** * @since 1.0.0 */ -export * as Sink from "./Sink" +export * as Sink from "@effect/platform-node/Sink" /** * @since 1.0.0 */ -export * as Stream from "./Stream" +export * as Stream from "@effect/platform-node/Stream" diff --git a/packages/platform/.gitignore b/packages/platform/.gitignore index 866d7244..2564dc06 100644 --- a/packages/platform/.gitignore +++ b/packages/platform/.gitignore @@ -1,7 +1,6 @@ coverage/ *.tsbuildinfo node_modules/ -yarn-error.log .ultra.cache.json .DS_Store tmp/ diff --git a/packages/platform/package.json b/packages/platform/package.json index 2b5693ec..86c8adec 100644 --- a/packages/platform/package.json +++ b/packages/platform/package.json @@ -14,6 +14,9 @@ "importConditionDefaultExport": "default" } }, + "effect": { + "generateIndex": true + }, "publishConfig": { "access": "public" }, diff --git a/packages/platform/src/index.ts b/packages/platform/src/index.ts index 88ad8e0a..54efb08e 100644 --- a/packages/platform/src/index.ts +++ b/packages/platform/src/index.ts @@ -1,49 +1,49 @@ /** * @since 1.0.0 */ -export * as Command from "./Command" +export * as Command from "@effect/platform/Command" /** * @since 1.0.0 */ -export * as CommandExecutor from "./CommandExecutor" +export * as CommandExecutor from "@effect/platform/CommandExecutor" /** * @since 1.0.0 */ -export * as Effectify from "./Effectify" +export * as Effectify from "@effect/platform/Effectify" /** * @since 1.0.0 */ -export * as Error from "./Error" +export * as Error from "@effect/platform/Error" /** * @since 1.0.0 */ -export * as FileSystem from "./FileSystem" +export * as FileSystem from "@effect/platform/FileSystem" /** * @since 1.0.0 */ -export * as HttpClient from "./HttpClient" +export * as HttpClient from "@effect/platform/HttpClient" /** * @since 1.0.0 */ -export * as HttpServer from "./HttpServer" +export * as HttpServer from "@effect/platform/HttpServer" /** * @since 1.0.0 */ -export * as KeyValueStore from "./KeyValueStore" +export * as KeyValueStore from "@effect/platform/KeyValueStore" /** * @since 1.0.0 */ -export * as Path from "./Path" +export * as Path from "@effect/platform/Path" /** * @since 1.0.0 */ -export * as Runtime from "./Runtime" +export * as Runtime from "@effect/platform/Runtime" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b3c05a6e..1a087c73 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,8 +26,8 @@ importers: specifier: ^2.26.2 version: 2.26.2 '@effect/build-utils': - specifier: ^0.1.4 - version: 0.1.4 + specifier: ^0.1.5 + version: 0.1.5 '@effect/docgen': specifier: ^0.1.8 version: 0.1.8(@types/node@20.8.2)(typescript@5.2.2) @@ -783,8 +783,8 @@ packages: resolution: {integrity: sha512-rPwwm/RrFIolz6xHa8Kzpshuwpe+xu/XcEw9iUmRF2tnyIwxxaW7XoFKaQ+GfPju81cKpH4vJeq7/2IizKvyjg==} dev: true - /@effect/build-utils@0.1.4: - resolution: {integrity: sha512-eQs28z44SHdDR0lFyO0e+0R6+kx0yNqzXOOKgbQOssDaoqXyEutiFfde2aSWBvcQRS7yt0WW6dYNQ2y7jYFK9Q==} + /@effect/build-utils@0.1.5: + resolution: {integrity: sha512-j1ggCQnhIQ4TZaEAc2xyQXC2ChWsbIziwxDwKqBH6xL2VZDCEpxkNKPhN66QLJFVOuv/POUI9mzOKRZVde6LVQ==} engines: {node: '>=16.17.1'} hasBin: true dev: true diff --git a/scripts/gen.mjs b/scripts/gen.mjs deleted file mode 100644 index 81eb0c19..00000000 --- a/scripts/gen.mjs +++ /dev/null @@ -1,134 +0,0 @@ -import * as Glob from "glob"; -import * as Fs from "node:fs"; -import * as Path from "node:path"; - -const packages = Glob.sync("packages/*").sort(); -const topPkgJson = readJson("package.json"); -const topName = topPkgJson.name; - -packages.forEach((pkg) => { - const pkgDir = Path.basename(pkg); - const pkgJson = readJson(`${pkg}/package.json`); - - const entrypoints = pkgJson.preconstruct?.entrypoints ?? []; - const resolvedEntrypoints = entrypoints - .flatMap((_) => Glob.sync(Path.join(pkg, "src", _))) - .map((_) => Path.relative(Path.join(pkg, "src"), _)) - .filter((_) => _ !== "index.ts"); - - const modules = resolvedEntrypoints - .map((_) => _.replace(/\.tsx?$/, "")) - .sort(); - - const files = genFiles(modules); - const exports = genExports(topName, pkgDir, modules); - const indexTs = genIndex(pkg); - - writeGitignore(pkg, files); - writeJson(`${pkg}/package.json`, { - ...pkgJson, - exports, - files: ["src", ...files], - }); - Fs.writeFileSync(`${pkg}/src/index.ts`, indexTs); -}); - -updateVscodeIgnore(); - -function genExports(topName, pkgDir, modules) { - const exportPrefix = `${topName}-${pkgDir}`; - const exports = { - ".": { - types: "./dist/declarations/src/index.d.ts", - module: `./dist/${exportPrefix}.esm.js`, - import: `./dist/${exportPrefix}.cjs.mjs`, - default: `./dist/${exportPrefix}.cjs.js`, - }, - "./package.json": "./package.json", - }; - modules.forEach((module) => { - const moduleSafe = module.replace(/\//g, "-"); - exports[`./${module}`] = { - types: `./dist/declarations/src/${module}.d.ts`, - module: `./${module}/dist/${exportPrefix}-${moduleSafe}.esm.js`, - import: `./${module}/dist/${exportPrefix}-${moduleSafe}.cjs.mjs`, - default: `./${module}/dist/${exportPrefix}-${moduleSafe}.cjs.js`, - }; - }); - return exports; -} - -function genFiles(modules) { - return [ - "dist", - ...modules - .reduce((acc, file) => { - const topLevel = file.split("/")[0]; - if (!acc.includes(topLevel)) { - acc.push(topLevel); - } - return acc; - }, []) - .sort(), - ]; -} - -function genIndex(dir) { - const modules = Glob.sync(`${dir}/src/*.ts`) - .filter((_) => !_.endsWith("/index.ts")) - .sort(); - return ( - modules - .map((module) => { - const content = Fs.readFileSync(module, "utf8"); - const topComment = content.match(/\/\*\*\n.+?\*\//s)?.[0] ?? ""; - const name = Path.basename(module, ".ts"); - return `${topComment} -export * as ${name} from "./${name}"`; - }) - .join("\n\n") + "\n" - ); -} - -function updateVscodeIgnore() { - const settings = readJson(".vscode/settings.json"); - settings["files.exclude"] = Glob.sync("packages/*/package.json") - .map((file) => [Path.dirname(file), readJson(file)]) - .flatMap( - ([dir, pkg]) => - pkg.files.filter((_) => _ !== "src").map((_) => [dir, _]) ?? [] - ) - .reduce((acc, [dir, file]) => { - acc[Path.join(dir, file)] = true; - return acc; - }, {}); - writeJson(".vscode/settings.json", settings); -} - -function readJson(file) { - return JSON.parse(Fs.readFileSync(file, "utf8")); -} - -function writeJson(file, content) { - Fs.writeFileSync(file, JSON.stringify(content, null, 2) + "\n"); -} - -function writeGitignore(pkg, files) { - Fs.writeFileSync( - `${pkg}/.gitignore`, - `coverage/ -*.tsbuildinfo -node_modules/ -yarn-error.log -.ultra.cache.json -.DS_Store -tmp/ -build/ -dist/ -.direnv/ - -# files -${files.map((_) => `/${_}`).join("\n")} -` - ); -}