Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
*.tsbuildinfo
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"packages/*"
],
"scripts": {
"build": "tsc --build packages/format packages/pointers",
"bundle": "tsx ./bin/bundle-schema.ts",
"test": "vitest",
"start": "./bin/start",
Expand Down
11 changes: 9 additions & 2 deletions packages/format/bin/generate-schema-yamls.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const rawSchemas = Object.entries(schemaYamls)
.map(([id, yaml]) => ({ [id]: YAML.parse(yaml) }))
.reduce((a, b) => ({ ...a, ...b }), {});

console.log(`// THIS FILE GETS AUTO-GENERATED AS PART OF THIS PACKAGE'S BUILD PROCESS
const output = `// THIS FILE GETS AUTO-GENERATED AS PART OF THIS PACKAGE'S BUILD PROCESS
// Please do not modify it directly or allow it to get checked into source control.

export type SchemaYamlsById = {
Expand All @@ -50,4 +50,11 @@ const rawSchemas = ${JSON.stringify(rawSchemas, undefined, 2)} as const;

export type Schema<Id extends keyof typeof rawSchemas> =
(typeof rawSchemas)[Id];
`);
`;

const outputPath = path.resolve(__dirname, "../src/schemas/yamls.ts");
const tempPath = outputPath + ".tmp";

// Write to temp file, then rename atomically to avoid race conditions
fs.writeFileSync(tempPath, output);
fs.renameSync(tempPath, outputPath);
4 changes: 2 additions & 2 deletions packages/format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"dist"
],
"scripts": {
"prepare:yamls": "node ./bin/generate-schema-yamls.js > src/schemas/yamls.ts",
"prepare:yamls": "node ./bin/generate-schema-yamls.js",
"prepare": "yarn prepare:yamls && tsc",
"clean": "rm -rf dist && rm src/schemas/yamls.ts",
"test": "vitest",
"watch:typescript": "tsc --watch",
"watch:schemas": "nodemon --watch ../../schemas -e 'yaml' --exec 'yarn prepare:yamls'",
"watch": "concurrently --names=tsc,schemas \"yarn watch:typescript\" \"yarn watch:schemas\""
"watch": "yarn prepare && concurrently --names=tsc,schemas \"yarn watch:typescript\" \"yarn watch:schemas\""
},
"dependencies": {
"json-schema-typed": "^8.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/format/test/guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface SchemaGuard extends DescribeSchemaOptions {

export const testSchemaGuards = (
namespace: string,
schemaGuards: SchemaGuard[],
schemaGuards: readonly SchemaGuard[],
) => {
describe(`type guards for ${namespace} schemas`, () => {
for (const { guard, ...describeSchemaOptions } of schemaGuards) {
Expand Down
2 changes: 1 addition & 1 deletion packages/format/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"rootDir": "./",
"outDir": "./dist/"
},
"include": ["./src/**/*.ts", "vitest.d.ts", "yamls.ts"]
"include": ["./src/**/*.ts", "./test/**/*.ts", "./*.ts"]
}
4 changes: 2 additions & 2 deletions packages/pointers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"license": "MIT",
"scripts": {
"run-example": "node ./dist/bin/run-example.js",
"prepare": "tsc",
"watch": "yarn prepare --watch",
"prepare": "tsc --build",
"watch": "tsc --build --watch",
"test": "vitest"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/pointers/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"compilerOptions": {
"rootDir": "./",
"outDir": "./dist/"
}
},
"references": [{ "path": "../format" }]
}
4 changes: 2 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/* Visit https://aka.ms/tsconfig to read more about this file */

/* Projects */
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
"incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
"composite": true /* Enable constraints that allow a TypeScript project to be used with project references. */,
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
Expand Down
Loading