Skip to content

Commit

Permalink
Move typescript package into subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
amacneil committed Feb 2, 2025
1 parent 0707891 commit a39ccf9
Show file tree
Hide file tree
Showing 32 changed files with 108 additions and 64 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
.pytest_cache/
.yarn/
*.py[cod]
/python/**/dist/
*.tsbuildinfo
/python/*/dist/
/python/foxglove-schemas-flatbuffer/foxglove_schemas_flatbuffer/*.bfbs
/python/foxglove-schemas-flatbuffer/foxglove_schemas_flatbuffer/*.py
/python/foxglove-schemas-protobuf/foxglove_schemas_protobuf/*.py
/python/foxglove-schemas-protobuf/foxglove_schemas_protobuf/*.pyi
/python/foxglove-sdk/python/foxglove/_protobuf/
/target/
/typescript/*/dist/
node_modules/
3 changes: 0 additions & 3 deletions jsonschema/index.ts

This file was deleted.

26 changes: 5 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
{
"name": "@foxglove/schemas",
"version": "1.6.6",
"description": "Foxglove-defined message schemas for ROS, Protobuf, FlatBuffers, OMG IDL, and JSON",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/foxglove/schemas.git"
},
"author": {
"name": "Foxglove Technologies Inc",
"email": "[email protected]"
},
"engines": {
"node": ">=16"
},
"name": "foxglove-sdk",
"private": true,
"packageManager": "[email protected]",
"main": "schemas/typescript/index.js",
"typings": "schemas/typescript/index.d.ts",
"workspaces": [
"typescript/*"
],
"scripts": {
"prepack": "yarn update-generated-files && tsc -p tsconfig.json",
"typecheck": "tsc -p tsconfig.json --noEmit",
Expand Down Expand Up @@ -51,9 +39,5 @@
"ts-jest": "29.2.5",
"ts-node": "^10.9.2",
"typescript": "5.7.3"
},
"dependencies": {
"@foxglove/rosmsg-msgs-common": "^3.0.0",
"tslib": "^2.8.1"
}
}
23 changes: 13 additions & 10 deletions scripts/updateGeneratedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import fs from "fs/promises";
import path from "path";
import { rimraf } from "rimraf";

import { generateRosMsg, generateRosMsgDefinition } from "../internal";
import { exportTypeScriptSchemas } from "../internal/exportTypeScriptSchemas";
import { generateRosMsg, generateRosMsgDefinition } from "../typescript/schemas/src/internal";
import { exportTypeScriptSchemas } from "../typescript/schemas/src/internal/exportTypeScriptSchemas";
import {
BYTE_VECTOR_FB,
DURATION_FB,
TIME_FB,
generateFlatbuffers,
} from "../internal/generateFlatbufferSchema";
import { generateJsonSchema } from "../internal/generateJsonSchema";
import { generateMarkdown } from "../internal/generateMarkdown";
import { DURATION_IDL, TIME_IDL, generateOmgIdl } from "../internal/generateOmgIdl";
import { generateProto } from "../internal/generateProto";
import { foxgloveEnumSchemas, foxgloveMessageSchemas } from "../internal/schemas";
} from "../typescript/schemas/src/internal/generateFlatbufferSchema";
import { generateJsonSchema } from "../typescript/schemas/src/internal/generateJsonSchema";
import { generateMarkdown } from "../typescript/schemas/src/internal/generateMarkdown";
import { DURATION_IDL, TIME_IDL, generateOmgIdl } from "../typescript/schemas/src/internal/generateOmgIdl";

Check failure on line 16 in scripts/updateGeneratedFiles.ts

View workflow job for this annotation

GitHub Actions / typescript

Replace `·DURATION_IDL,·TIME_IDL,·generateOmgIdl·` with `⏎··DURATION_IDL,⏎··TIME_IDL,⏎··generateOmgIdl,⏎`
import { generateProto } from "../typescript/schemas/src/internal/generateProto";
import { foxgloveEnumSchemas, foxgloveMessageSchemas } from "../typescript/schemas/src/internal/schemas";

Check failure on line 18 in scripts/updateGeneratedFiles.ts

View workflow job for this annotation

GitHub Actions / typescript

Replace `·foxgloveEnumSchemas,·foxgloveMessageSchemas·` with `⏎··foxgloveEnumSchemas,⏎··foxgloveMessageSchemas,⏎`

async function logProgress(message: string, body: () => Promise<void>) {
process.stderr.write(`${message}... `);
Expand Down Expand Up @@ -101,10 +101,13 @@ async function main({ outDir, rosOutDir }: { outDir: string; rosOutDir: string }
});

await logProgress("Generating TypeScript definitions", async () => {
await fs.mkdir(path.join(outDir, "typescript"), { recursive: true });
const typesDir = path.join(outDir, "typescript");
await rimraf(typesDir);
await fs.mkdir(typesDir, { recursive: true });

const schemas = exportTypeScriptSchemas();
for (const [name, source] of schemas.entries()) {
await fs.writeFile(path.join(outDir, "typescript", `${name}.ts`), source);
await fs.writeFile(path.join(typesDir, `${name}.ts`), source);
}
});

Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compilerOptions": {
"rootDir": ".",
"module": "commonjs",
"lib": ["es2020", "dom"]
"lib": ["es2020"],
"noEmit": true
}
}
1 change: 1 addition & 0 deletions typescript/schemas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# schemas
34 changes: 34 additions & 0 deletions typescript/schemas/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@foxglove/schemas",
"version": "1.6.6",
"description": "Foxglove-defined message schemas for ROS, Protobuf, FlatBuffers, OMG IDL, and JSON",
"license": "MIT",
"author": {
"name": "Foxglove",
"email": "[email protected]",
"url": "https://foxglove.dev/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/foxglove/foxglove-sdk.git",
"directory": "typescript/schemas"
},
"main": "./dist/typescript/schemas/src/index.js",
"exports": {
".": "./dist/typescript/schemas/src/index.js",
"./jsonschema": "./dist/typescript/schemas/src/jsonschema.js"
},
"packageManager": "[email protected]",
"scripts": {
"clean": "rimraf dist",
"build": "tsc -b"
},
"dependencies": {
"tslib": "^2"
},
"devDependencies": {
"@foxglove/rosmsg-msgs-common": "^3.0.0",
"rimraf": "^6.0.1",
"typescript": "5.7.3"
}
}
1 change: 1 addition & 0 deletions typescript/schemas/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "../../../schemas/typescript";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ describe("generateTypeScript", () => {
});

it("generates parseable .ts files", async () => {
await expect(import("../schemas/typescript")).resolves.not.toThrow();
await expect(import("../../../../schemas/typescript")).resolves.not.toThrow();
});

it("can include TypedArray types", () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions typescript/schemas/src/jsonschema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "../../../schemas/jsonschema";
11 changes: 11 additions & 0 deletions typescript/schemas/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"include": ["./**/*"],
"compilerOptions": {
"rootDir": "../..",
"outDir": "./dist",
"module": "commonjs",
"lib": ["es2020"],
"noEmit": false
}
}
63 changes: 36 additions & 27 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -685,36 +685,13 @@ __metadata:
languageName: node
linkType: hard

"@foxglove/schemas@workspace:.":
"@foxglove/schemas@workspace:typescript/schemas":
version: 0.0.0-use.local
resolution: "@foxglove/schemas@workspace:."
resolution: "@foxglove/schemas@workspace:typescript/schemas"
dependencies:
"@foxglove/eslint-plugin": "npm:2.0.0"
"@foxglove/omgidl-parser": "npm:^0.2.0"
"@foxglove/rosmsg": "npm:^4.0.0"
"@foxglove/rosmsg-msgs-common": "npm:^3.0.0"
"@foxglove/tsconfig": "npm:2.0.0"
"@types/jest": "npm:29.5.14"
"@types/node": "npm:22.13.0"
"@typescript-eslint/eslint-plugin": "npm:8.22.0"
"@typescript-eslint/parser": "npm:8.22.0"
ajv: "npm:^8.12.0"
commander: "npm:^10.0.0"
eslint: "npm:9.19.0"
eslint-config-prettier: "npm:10.0.1"
eslint-plugin-es: "npm:4.1.0"
eslint-plugin-filenames: "npm:1.3.2"
eslint-plugin-import: "npm:2.31.0"
eslint-plugin-jest: "npm:28.11.0"
eslint-plugin-prettier: "npm:5.2.3"
jest: "npm:29.7.0"
prettier: "npm:^3.4.2"
prettier-plugin-toml: "npm:^2.0.1"
protobufjs: "npm:^7.2.2"
rimraf: "npm:^6.0.1"
ts-jest: "npm:29.2.5"
ts-node: "npm:^10.9.2"
tslib: "npm:^2.8.1"
tslib: "npm:^2"
typescript: "npm:5.7.3"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -3423,6 +3400,38 @@ __metadata:
languageName: node
linkType: hard

"foxglove-sdk@workspace:.":
version: 0.0.0-use.local
resolution: "foxglove-sdk@workspace:."
dependencies:
"@foxglove/eslint-plugin": "npm:2.0.0"
"@foxglove/omgidl-parser": "npm:^0.2.0"
"@foxglove/rosmsg": "npm:^4.0.0"
"@foxglove/tsconfig": "npm:2.0.0"
"@types/jest": "npm:29.5.14"
"@types/node": "npm:22.13.0"
"@typescript-eslint/eslint-plugin": "npm:8.22.0"
"@typescript-eslint/parser": "npm:8.22.0"
ajv: "npm:^8.12.0"
commander: "npm:^10.0.0"
eslint: "npm:9.19.0"
eslint-config-prettier: "npm:10.0.1"
eslint-plugin-es: "npm:4.1.0"
eslint-plugin-filenames: "npm:1.3.2"
eslint-plugin-import: "npm:2.31.0"
eslint-plugin-jest: "npm:28.11.0"
eslint-plugin-prettier: "npm:5.2.3"
jest: "npm:29.7.0"
prettier: "npm:^3.4.2"
prettier-plugin-toml: "npm:^2.0.1"
protobufjs: "npm:^7.2.2"
rimraf: "npm:^6.0.1"
ts-jest: "npm:29.2.5"
ts-node: "npm:^10.9.2"
typescript: "npm:5.7.3"
languageName: unknown
linkType: soft

"fs-minipass@npm:^3.0.0":
version: 3.0.3
resolution: "fs-minipass@npm:3.0.3"
Expand Down Expand Up @@ -6977,7 +6986,7 @@ __metadata:
languageName: node
linkType: hard

"tslib@npm:^2.6.2, tslib@npm:^2.8.1":
"tslib@npm:^2.6.2":
version: 2.8.1
resolution: "tslib@npm:2.8.1"
checksum: 10c0/9c4759110a19c53f992d9aae23aac5ced636e99887b51b9e61def52611732872ff7668757d4e4c61f19691e36f4da981cd9485e869b4a7408d689f6bf1f14e62
Expand Down

0 comments on commit a39ccf9

Please sign in to comment.