Skip to content

Commit

Permalink
use lib path for output
Browse files Browse the repository at this point in the history
  • Loading branch information
sepbot committed Nov 9, 2024
1 parent d839cf0 commit 9a79072
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 29 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.env
.envrc
.npmrc
dist
*.tsbuildinfo
*.tgz
node_modules
src
lib
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.2/schema.json",
"files": {
"include": ["src/**", "static/**", "tests/**"]
"include": ["lib/**", "static/**", "tests/**"]
},
"formatter": {
"enabled": true,
Expand Down
2 changes: 1 addition & 1 deletion generator/compose.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function main() {
const schema = await (await fetch(SCHEMA_URL)).json();
const ts = await compile(schema, "docker-compose");
const out = generate({ sourceText: ts, getSchemaName: (id) => id[0].toUpperCase() + id.slice(1) + "Schema" });
await writeFile("./src/compose.ts", out.getZodSchemasFile(""));
await writeFile("./lib/compose.ts", out.getZodSchemasFile(""));
}

(async () => await main())();
10 changes: 5 additions & 5 deletions generator/generator.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async function main() {
trimBlocks: true,
});

files["./src/index.ts"] = renderer.renderString(templates.root, {
files["./lib/index.ts"] = renderer.renderString(templates.root, {
tags: Object.keys(byTag),
});

Expand Down Expand Up @@ -189,12 +189,12 @@ async function main() {
ctx.endpoints.push(attribs);
}

files[`./src/tags/${tag.toLowerCase()}.ts`] = renderer.renderString(templates.tag, ctx);
files[`./lib/tags/${tag.toLowerCase()}.ts`] = renderer.renderString(templates.tag, ctx);
}

await rm("./src", { recursive: true, force: true });
await mkdir("./src/tags", { mode: 0o755, recursive: true });
await cp("./static", "./src", { recursive: true });
await rm("./lib", { recursive: true, force: true });
await mkdir("./lib/tags", { mode: 0o755, recursive: true });
await cp("./static", "./lib", { recursive: true });

for (const [filePath, content] of Object.entries(files)) {
await writeFile(filePath, content, { flush: true, mode: 0o644 });
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export default {
"^.+.ts$": ["ts-jest", { useESM: true }],
},
moduleNameMapper: {
'^~/(.*)$': '<rootDir>/src/$1',
'^~/(.*)$': '<rootDir>/lib/$1',
},
};
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,31 @@
"homepage": "https://github.com/manualpilot/docker-client-ts",
"repository": "github:manualpilot/docker-client-ts",
"keywords": [
"docker"
"docker",
"client",
"typescript"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"files": [
"dist",
"lib",
"package.json",
"tsconfig.json",
"README.md",
"LICENSE"
],
"type": "module",
"packageManager": "pnpm@9.10.0",
"packageManager": "pnpm@9.12.3",
"license": "Apache-2.0",
"engines": {
"node": ">=22",
"pnpm": ">=9"
},
"scripts": {
"prebuild": "rm -rf ./dist",
"build": "tsc --project tsconfig-build.json",
"postbuild": "tsc-alias --project tsconfig-build.json",
"format": "biome check --verbose --write --unsafe",
"pregenerate": "rm -rf ./dist ./src",
"pregenerate": "rm -rf ./lib",
"generate": "node ./generator/generator.mjs && node ./generator/compose.mjs",
"postgenerate": "pnpm run format",
"test": "jest",
Expand Down
2 changes: 1 addition & 1 deletion tests/basic.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DockerClient } from "../src";
import { DockerClient } from "../lib";
import { collect } from "./utils";

test("plain", async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/compose.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as YAML from "yaml";

import { ComposeSpecificationSchema } from "../src";
import { ComposeSpecificationSchema } from "../lib";

// TODO: is there an equivalent of python dedent in js?
test("compose", async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/error.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DockerClient } from "../src";
import { LogsError } from "../src/tags/container";
import { DockerClient } from "../lib";
import { LogsError } from "../lib/tags/container";

test("error", async () => {
const client = await DockerClient({
Expand Down
2 changes: 1 addition & 1 deletion tests/ssh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createConnection } from "node:net";

import { Server, utils } from "ssh2";

import { DockerClient } from "../src";
import { DockerClient } from "../lib";

const SSH_PORT = 34567;

Expand Down
2 changes: 1 addition & 1 deletion tests/terminal.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DockerClient } from "../src";
import { DockerClient } from "../lib";
import { collect } from "./utils";

test("terminal", async () => {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "src"
"rootDir": "lib",
"outDir": "lib"
}
}
9 changes: 4 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
"declaration": true,
"rootDir": ".",
"baseUrl": ".",
"declarationDir": "dist",
"declarationDir": "lib",
"sourceMap": true,
"outDir": "dist",
"composite": true,
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"strict": true,
"skipLibCheck": true,
"target": "ESNext",
Expand All @@ -19,11 +17,12 @@
],
"paths": {
"~/*": [
"src/*"
"lib/*"
]
}
},
"exclude": [],
"include": [
"src"
"lib"
]
}

0 comments on commit 9a79072

Please sign in to comment.