Skip to content

Commit 896668b

Browse files
authored
Bump CLI to 228.1 and regenerate schema (#1369)
## Changes CLI generates schema with additional string types added for almost complex sub types (to support complex variables). We usually work with `bundle validate` or `summary` outputs, which have expanded variables, so we don't need to account for additional string types. Had to resort to typescript magic to strip down strings from all union types. Also moved to the `quicktype-core` dependency to generate the typescript definitions, since the previous dependency wasn't handling recursive types (and CLI now generate them). ## Tests existing tests and typechecks
1 parent d090ec7 commit 896668b

File tree

7 files changed

+15621
-6679
lines changed

7 files changed

+15621
-6679
lines changed

packages/databricks-vscode/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@
897897
"useYarn": false
898898
},
899899
"cli": {
900-
"version": "0.228.0"
900+
"version": "0.228.1"
901901
},
902902
"scripts": {
903903
"vscode:prepublish": "rm -rf out && yarn run package:compile && yarn run package:wrappers:write && yarn run package:jupyter-init-script:write && yarn run package:copy-webview-toolkit && yarn run generate-telemetry",
@@ -913,7 +913,7 @@
913913
"package:cli:link": "rm -f ./bin/databricks && mkdir -p bin && ln -s ../../../../cli/cli bin/databricks",
914914
"package:wrappers:write": "ts-node ./scripts/writeIpynbWrapper.ts -s ./resources/python/notebook.workflow-wrapper.py -o ./resources/python/generated/notebook.workflow-wrapper.json",
915915
"package:jupyter-init-script:write": "ts-node ./scripts/writeJupyterInitFileWithVersion.ts",
916-
"package:bundle-schema:write": "yarn package:cli:fetch && ts-node ./scripts/writeBundleSchema.ts ./bin/databricks ./src/bundle/BundleSchema.d.ts",
916+
"package:bundle-schema:write": "yarn package:cli:fetch && ts-node ./scripts/writeBundleSchema.ts ./bin/databricks ./src/bundle/BundleSchema.ts",
917917
"package:compile": "yarn run esbuild:base",
918918
"package:copy-webview-toolkit": "cp ./node_modules/@vscode/webview-ui-toolkit/dist/toolkit.js ./out/toolkit.js",
919919
"esbuild:base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --sourcemap --target=es2019",
@@ -944,6 +944,7 @@
944944
"ansi-to-html": "^0.7.2",
945945
"bcryptjs": "^2.4.3",
946946
"lodash": "^4.17.21",
947+
"minimatch": "^10.0.1",
947948
"shell-quote": "^1.8.1",
948949
"triple-beam": "^1.4.1",
949950
"winston": "^3.11.0",
@@ -979,11 +980,11 @@
979980
"eslint-plugin-local-rules": "^2.0.1",
980981
"fs-extra": "^11.2.0",
981982
"glob": "^10.3.10",
982-
"json-schema-to-typescript": "^13.1.1",
983983
"mocha": "^10.2.0",
984984
"mock-require": "^3.0.3",
985985
"nyc": "^15.1.0",
986986
"prettier": "^3.1.1",
987+
"quicktype-core": "^23.0.0",
987988
"tmp-promise": "^3.0.3",
988989
"ts-mocha": "^10.0.0",
989990
"ts-mockito": "^2.6.1",
@@ -1012,4 +1013,4 @@
10121013
],
10131014
"report-dir": "coverage"
10141015
}
1015-
}
1016+
}
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
/**
2-
* This script generates the BundleSchema.d.ts file from the bundle schema.
2+
* This script generates the BundleSchema.ts file from the bundle schema.
33
* It MUST be run after a yarn package:cli:fetch
44
*/
55

66
import * as cp from "child_process";
77
import * as fs from "fs";
8-
import {compileFromFile} from "json-schema-to-typescript";
9-
import {tmpdir} from "os";
10-
import path from "path";
8+
import {
9+
quicktype,
10+
InputData,
11+
JSONSchemaInput,
12+
FetchingJSONSchemaStore,
13+
} from "quicktype-core";
1114
import {argv} from "process";
1215

1316
const output = cp.execFileSync(argv[2], ["bundle", "schema"]);
1417

15-
const tmpFile = path.join(tmpdir(), "BundleSchema.json");
16-
fs.writeFileSync(tmpFile, output);
18+
async function quicktypeJSONSchema(
19+
targetLanguage: string,
20+
typeName: string,
21+
jsonSchemaString: string
22+
) {
23+
const schemaInput = new JSONSchemaInput(new FetchingJSONSchemaStore());
24+
await schemaInput.addSource({name: typeName, schema: jsonSchemaString});
25+
const inputData = new InputData();
26+
inputData.addInput(schemaInput);
27+
const result = await quicktype({
28+
inputData,
29+
lang: targetLanguage,
30+
});
31+
fs.writeFileSync(
32+
argv[3],
33+
"/* eslint-disable */\n" + result.lines.join("\n")
34+
);
35+
// eslint-disable-next-line no-console
36+
console.log("BundleSchema.d.ts written to", argv[3]);
37+
}
1738

18-
// eslint-disable-next-line no-console
19-
console.log("Bundle schema written to", tmpFile);
20-
21-
// compile from file
22-
compileFromFile(tmpFile).then((ts) => fs.writeFileSync(argv[3], ts));
23-
24-
// eslint-disable-next-line no-console
25-
console.log("BundleSchema.d.ts written to", argv[3]);
39+
quicktypeJSONSchema("typescript", "BundleSchema", output.toString());

packages/databricks-vscode/src/bundle/BundleFileSet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import path from "path";
66
import {BundleSchema} from "./types";
77
import {readFile, writeFile} from "fs/promises";
88
import {CachedValue} from "../locking/CachedValue";
9-
import minimatch from "minimatch";
9+
import {minimatch} from "minimatch";
1010
import {WorkspaceFolderManager} from "../vscode-objs/WorkspaceFolderManager";
1111

1212
const rootFilePattern: string = "{bundle,databricks}.{yaml,yml}";

0 commit comments

Comments
 (0)