@azure-tools/typespec-python 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scripts/eng/lint.d.ts.map +1 -1
- package/dist/scripts/eng/lint.js +18 -1
- package/dist/scripts/eng/lint.js.map +1 -1
- package/dist/src/emitter.d.ts +0 -2
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +2 -102
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/generator/dev_requirements.txt +10 -3
- package/package.json +14 -11
- package/scripts/__pycache__/venvtools.cpython-310.pyc +0 -0
- package/scripts/eng/lint.ts +17 -1
- package/scripts/eng/pylintrc +2 -1
- package/scripts/install.py +0 -1
- package/dist/src/code-model.d.ts +0 -4
- package/dist/src/code-model.d.ts.map +0 -1
- package/dist/src/code-model.js +0 -190
- package/dist/src/code-model.js.map +0 -1
- package/dist/src/external-process.d.ts +0 -20
- package/dist/src/external-process.d.ts.map +0 -1
- package/dist/src/external-process.js +0 -44
- package/dist/src/external-process.js.map +0 -1
- package/dist/src/http.d.ts +0 -7
- package/dist/src/http.d.ts.map +0 -1
- package/dist/src/http.js +0 -266
- package/dist/src/http.js.map +0 -1
- package/dist/src/types.d.ts +0 -36
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -489
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils.d.ts +0 -26
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -151
- package/dist/src/utils.js.map +0 -1
- package/generator/LICENSE +0 -21
- package/generator/README.md +0 -1
- package/generator/pygen/__init__.py +0 -107
- package/generator/pygen/_version.py +0 -7
- package/generator/pygen/black.py +0 -69
- package/generator/pygen/codegen/__init__.py +0 -338
- package/generator/pygen/codegen/_utils.py +0 -16
- package/generator/pygen/codegen/models/__init__.py +0 -204
- package/generator/pygen/codegen/models/base.py +0 -186
- package/generator/pygen/codegen/models/base_builder.py +0 -119
- package/generator/pygen/codegen/models/client.py +0 -430
- package/generator/pygen/codegen/models/code_model.py +0 -237
- package/generator/pygen/codegen/models/combined_type.py +0 -149
- package/generator/pygen/codegen/models/constant_type.py +0 -129
- package/generator/pygen/codegen/models/credential_types.py +0 -214
- package/generator/pygen/codegen/models/dictionary_type.py +0 -127
- package/generator/pygen/codegen/models/enum_type.py +0 -238
- package/generator/pygen/codegen/models/imports.py +0 -291
- package/generator/pygen/codegen/models/list_type.py +0 -143
- package/generator/pygen/codegen/models/lro_operation.py +0 -142
- package/generator/pygen/codegen/models/lro_paging_operation.py +0 -32
- package/generator/pygen/codegen/models/model_type.py +0 -362
- package/generator/pygen/codegen/models/operation.py +0 -530
- package/generator/pygen/codegen/models/operation_group.py +0 -184
- package/generator/pygen/codegen/models/paging_operation.py +0 -155
- package/generator/pygen/codegen/models/parameter.py +0 -412
- package/generator/pygen/codegen/models/parameter_list.py +0 -387
- package/generator/pygen/codegen/models/primitive_types.py +0 -659
- package/generator/pygen/codegen/models/property.py +0 -171
- package/generator/pygen/codegen/models/request_builder.py +0 -189
- package/generator/pygen/codegen/models/request_builder_parameter.py +0 -115
- package/generator/pygen/codegen/models/response.py +0 -348
- package/generator/pygen/codegen/models/utils.py +0 -23
- package/generator/pygen/codegen/serializers/__init__.py +0 -574
- package/generator/pygen/codegen/serializers/base_serializer.py +0 -21
- package/generator/pygen/codegen/serializers/builder_serializer.py +0 -1513
- package/generator/pygen/codegen/serializers/client_serializer.py +0 -295
- package/generator/pygen/codegen/serializers/enum_serializer.py +0 -15
- package/generator/pygen/codegen/serializers/general_serializer.py +0 -213
- package/generator/pygen/codegen/serializers/import_serializer.py +0 -127
- package/generator/pygen/codegen/serializers/metadata_serializer.py +0 -198
- package/generator/pygen/codegen/serializers/model_init_serializer.py +0 -33
- package/generator/pygen/codegen/serializers/model_serializer.py +0 -300
- package/generator/pygen/codegen/serializers/operation_groups_serializer.py +0 -89
- package/generator/pygen/codegen/serializers/operations_init_serializer.py +0 -44
- package/generator/pygen/codegen/serializers/parameter_serializer.py +0 -221
- package/generator/pygen/codegen/serializers/patch_serializer.py +0 -19
- package/generator/pygen/codegen/serializers/request_builders_serializer.py +0 -52
- package/generator/pygen/codegen/serializers/sample_serializer.py +0 -168
- package/generator/pygen/codegen/serializers/test_serializer.py +0 -293
- package/generator/pygen/codegen/serializers/types_serializer.py +0 -31
- package/generator/pygen/codegen/serializers/utils.py +0 -68
- package/generator/pygen/codegen/templates/client.py.jinja2 +0 -37
- package/generator/pygen/codegen/templates/client_container.py.jinja2 +0 -12
- package/generator/pygen/codegen/templates/config.py.jinja2 +0 -73
- package/generator/pygen/codegen/templates/config_container.py.jinja2 +0 -16
- package/generator/pygen/codegen/templates/conftest.py.jinja2 +0 -28
- package/generator/pygen/codegen/templates/enum.py.jinja2 +0 -13
- package/generator/pygen/codegen/templates/enum_container.py.jinja2 +0 -10
- package/generator/pygen/codegen/templates/init.py.jinja2 +0 -24
- package/generator/pygen/codegen/templates/keywords.jinja2 +0 -19
- package/generator/pygen/codegen/templates/lro_operation.py.jinja2 +0 -16
- package/generator/pygen/codegen/templates/lro_paging_operation.py.jinja2 +0 -18
- package/generator/pygen/codegen/templates/macros.jinja2 +0 -12
- package/generator/pygen/codegen/templates/metadata.json.jinja2 +0 -167
- package/generator/pygen/codegen/templates/model_base.py.jinja2 +0 -1158
- package/generator/pygen/codegen/templates/model_container.py.jinja2 +0 -13
- package/generator/pygen/codegen/templates/model_dpg.py.jinja2 +0 -98
- package/generator/pygen/codegen/templates/model_init.py.jinja2 +0 -28
- package/generator/pygen/codegen/templates/model_msrest.py.jinja2 +0 -92
- package/generator/pygen/codegen/templates/operation.py.jinja2 +0 -21
- package/generator/pygen/codegen/templates/operation_group.py.jinja2 +0 -75
- package/generator/pygen/codegen/templates/operation_groups_container.py.jinja2 +0 -20
- package/generator/pygen/codegen/templates/operation_tools.jinja2 +0 -81
- package/generator/pygen/codegen/templates/operations_folder_init.py.jinja2 +0 -17
- package/generator/pygen/codegen/templates/packaging_templates/CHANGELOG.md.jinja2 +0 -6
- package/generator/pygen/codegen/templates/packaging_templates/LICENSE.jinja2 +0 -21
- package/generator/pygen/codegen/templates/packaging_templates/MANIFEST.in.jinja2 +0 -8
- package/generator/pygen/codegen/templates/packaging_templates/README.md.jinja2 +0 -107
- package/generator/pygen/codegen/templates/packaging_templates/dev_requirements.txt.jinja2 +0 -9
- package/generator/pygen/codegen/templates/packaging_templates/setup.py.jinja2 +0 -108
- package/generator/pygen/codegen/templates/paging_operation.py.jinja2 +0 -21
- package/generator/pygen/codegen/templates/patch.py.jinja2 +0 -19
- package/generator/pygen/codegen/templates/pkgutil_init.py.jinja2 +0 -1
- package/generator/pygen/codegen/templates/request_builder.py.jinja2 +0 -28
- package/generator/pygen/codegen/templates/request_builders.py.jinja2 +0 -10
- package/generator/pygen/codegen/templates/rest_init.py.jinja2 +0 -12
- package/generator/pygen/codegen/templates/sample.py.jinja2 +0 -44
- package/generator/pygen/codegen/templates/serialization.py.jinja2 +0 -2115
- package/generator/pygen/codegen/templates/test.py.jinja2 +0 -50
- package/generator/pygen/codegen/templates/testpreparer.py.jinja2 +0 -26
- package/generator/pygen/codegen/templates/types.py.jinja2 +0 -8
- package/generator/pygen/codegen/templates/validation.py.jinja2 +0 -38
- package/generator/pygen/codegen/templates/vendor.py.jinja2 +0 -96
- package/generator/pygen/codegen/templates/version.py.jinja2 +0 -4
- package/generator/pygen/m2r.py +0 -65
- package/generator/pygen/postprocess/__init__.py +0 -183
- package/generator/pygen/postprocess/get_all.py +0 -19
- package/generator/pygen/postprocess/venvtools.py +0 -75
- package/generator/pygen/preprocess/__init__.py +0 -509
- package/generator/pygen/preprocess/helpers.py +0 -27
- package/generator/pygen/preprocess/python_mappings.py +0 -224
- package/generator/pygen/utils.py +0 -160
- package/generator/pygen.egg-info/PKG-INFO +0 -25
- package/generator/pygen.egg-info/SOURCES.txt +0 -66
- package/generator/pygen.egg-info/dependency_links.txt +0 -1
- package/generator/pygen.egg-info/requires.txt +0 -4
- package/generator/pygen.egg-info/top_level.txt +0 -1
- package/generator/setup.py +0 -55
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../scripts/eng/lint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../../scripts/eng/lint.ts"],"names":[],"mappings":"AAyCA,wBAAgB,MAAM,SAErB;AAWD,wBAAgB,IAAI,SAOnB;AAED,wBAAgB,OAAO,SAEtB;AAED,wBAAgB,MAAM,SAIrB"}
|
package/dist/scripts/eng/lint.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import yargs from "yargs";
|
|
3
3
|
import { hideBin } from "yargs/helpers";
|
|
4
4
|
import { runCommand, executeCommand } from "./utils.js";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import path from "path";
|
|
5
7
|
const validCommands = ["pylint", "mypy", "pyright", "eslint"];
|
|
6
8
|
// PARSE INPUT ARGUMENTS
|
|
7
9
|
const argv = yargs(hideBin(process.argv))
|
|
@@ -30,8 +32,23 @@ const argv = yargs(hideBin(process.argv))
|
|
|
30
32
|
export function pylint() {
|
|
31
33
|
runCommand(`pylint ${argv.folderName}/ --rcfile ./scripts/eng/pylintrc`, "pylint");
|
|
32
34
|
}
|
|
35
|
+
function checkPythonFile(directory) {
|
|
36
|
+
const files = fs.readdirSync(directory);
|
|
37
|
+
for (let i = 0; i < files.length; i++) {
|
|
38
|
+
if (path.extname(files[i]) === ".py") {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
33
44
|
export function mypy() {
|
|
34
|
-
|
|
45
|
+
if (checkPythonFile(argv.folderName)) {
|
|
46
|
+
runCommand(`mypy ${argv.folderName}/ --config-file ./scripts/eng/mypy.ini`, "mypy");
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log("No python file found in the directory");
|
|
50
|
+
console.log("mypy passed");
|
|
51
|
+
}
|
|
35
52
|
}
|
|
36
53
|
export function pyright() {
|
|
37
54
|
runCommand(`pyright ${argv.folderName}/ -p ./scripts/eng/pyrightconfig.json`, "pyright");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../scripts/eng/lint.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../../scripts/eng/lint.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAE9D,wBAAwB;AACxB,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACpC,MAAM,CAAC,YAAY,EAAE;IAClB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC;IAClC,WAAW,EAAE,oBAAoB;IACjC,OAAO,EAAE,WAAW;CACvB,CAAC;KACD,MAAM,CAAC,SAAS,EAAE;IACf,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,QAAQ;IACd,OAAO,E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;IACnE,MAAM,YAAY,GAAG,EAAE,CAAC;IACxB,cAAc,CAAC,gBAAgB,YAAY,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAED,IAAI,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;IAC5B,MAAM,EAAE,CAAC;AACb,CAAC;KAAM,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM,EAAE,CAAC;IACjC,IAAI,EAAE,CAAC;AACX,CAAC;KAAM,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;IACpC,OAAO,EAAE,CAAC;AACd,CAAC;KAAM,IAAI,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;IACnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;QACnB,MAAM,EAAE,CAAC;IACb,CAAC;AACL,CAAC;KAAM,CAAC;IACJ,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;QACnB,MAAM,EAAE,CAAC;IACb,CAAC;AACL,CAAC"}
|
package/dist/src/emitter.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { EmitContext } from "@typespec/compiler";
|
|
2
|
-
import { SdkContext } from "@azure-tools/typespec-client-generator-core";
|
|
3
2
|
import { PythonEmitterOptions } from "./lib.js";
|
|
4
|
-
export declare function getModelsMode(context: SdkContext): "dpg" | "none";
|
|
5
3
|
export declare function $onEmit(context: EmitContext<PythonEmitterOptions>): Promise<void>;
|
|
6
4
|
//# sourceMappingURL=emitter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,
|
|
1
|
+
{"version":3,"file":"emitter.d.ts","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGhD,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,oBAAoB,CAAC,iBAEvE"}
|
package/dist/src/emitter.js
CHANGED
|
@@ -1,105 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { saveCodeModelAsYaml } from "./external-process.js";
|
|
3
|
-
import { dirname } from "path";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
|
-
import { execSync } from "child_process";
|
|
6
|
-
import { emitCodeModel } from "./code-model.js";
|
|
7
|
-
import { removeUnderscoresFromNamespace } from "./utils.js";
|
|
8
|
-
import path from "path";
|
|
9
|
-
import fs from "fs";
|
|
10
|
-
export function getModelsMode(context) {
|
|
11
|
-
const specifiedModelsMode = context.emitContext.options["models-mode"];
|
|
12
|
-
if (specifiedModelsMode) {
|
|
13
|
-
const modelModes = ["dpg", "none"];
|
|
14
|
-
if (modelModes.includes(specifiedModelsMode)) {
|
|
15
|
-
return specifiedModelsMode;
|
|
16
|
-
}
|
|
17
|
-
throw new Error(`Need to specify models mode with the following values: ${modelModes.join(", ")}`);
|
|
18
|
-
}
|
|
19
|
-
return "dpg";
|
|
20
|
-
}
|
|
21
|
-
function addDefaultOptions(sdkContext) {
|
|
22
|
-
const defaultOptions = {
|
|
23
|
-
"package-version": "1.0.0b1",
|
|
24
|
-
"generate-packaging-files": true,
|
|
25
|
-
"flavor": undefined,
|
|
26
|
-
};
|
|
27
|
-
sdkContext.emitContext.options = {
|
|
28
|
-
...defaultOptions,
|
|
29
|
-
...sdkContext.emitContext.options,
|
|
30
|
-
};
|
|
31
|
-
const options = sdkContext.emitContext.options;
|
|
32
|
-
options["models-mode"] = getModelsMode(sdkContext);
|
|
33
|
-
if (options["generate-packaging-files"]) {
|
|
34
|
-
options["package-mode"] = sdkContext.arm ? "azure-mgmt" : "azure-dataplane";
|
|
35
|
-
}
|
|
36
|
-
if (!options["package-name"]) {
|
|
37
|
-
options["package-name"] = removeUnderscoresFromNamespace(sdkContext.sdkPackage.rootNamespace.toLowerCase()).replace(/\./g, "-");
|
|
38
|
-
}
|
|
39
|
-
if (options.flavor !== "azure") {
|
|
40
|
-
// if they pass in a flavor other than azure, we want to ignore the value
|
|
41
|
-
options.flavor = undefined;
|
|
42
|
-
}
|
|
43
|
-
if (!options.flavor && sdkContext.emitContext.emitterOutputDir.includes("azure")) {
|
|
44
|
-
options.flavor = "azure";
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function createPythonSdkContext(context) {
|
|
48
|
-
return {
|
|
49
|
-
...(await createSdkContext(context, "@azure-tools/typespec-python", {
|
|
50
|
-
additionalDecorators: ["TypeSpec\\.@encodedName"],
|
|
51
|
-
})),
|
|
52
|
-
__endpointPathParameters: [],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
1
|
+
import { $onEmit as httpClientPythonOnEmit } from "@typespec/http-client-python";
|
|
55
2
|
export async function $onEmit(context) {
|
|
56
|
-
|
|
57
|
-
const sdkContext = await createPythonSdkContext(context);
|
|
58
|
-
const root = path.join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
59
|
-
const outputDir = context.emitterOutputDir;
|
|
60
|
-
const yamlMap = emitCodeModel(sdkContext);
|
|
61
|
-
addDefaultOptions(sdkContext);
|
|
62
|
-
const yamlPath = await saveCodeModelAsYaml("typespec-python-yaml-map", yamlMap);
|
|
63
|
-
let venvPath = path.join(root, "venv");
|
|
64
|
-
if (fs.existsSync(path.join(venvPath, "bin"))) {
|
|
65
|
-
venvPath = path.join(venvPath, "bin", "python");
|
|
66
|
-
}
|
|
67
|
-
else if (fs.existsSync(path.join(venvPath, "Scripts"))) {
|
|
68
|
-
venvPath = path.join(venvPath, "Scripts", "python.exe");
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
throw new Error("Virtual environment doesn't exist.");
|
|
72
|
-
}
|
|
73
|
-
const commandArgs = [
|
|
74
|
-
venvPath,
|
|
75
|
-
`${root}/scripts/run_tsp.py`,
|
|
76
|
-
`--output-folder=${outputDir}`,
|
|
77
|
-
`--cadl-file=${yamlPath}`,
|
|
78
|
-
];
|
|
79
|
-
const resolvedOptions = sdkContext.emitContext.options;
|
|
80
|
-
if (resolvedOptions["packaging-files-config"]) {
|
|
81
|
-
const keyValuePairs = Object.entries(resolvedOptions["packaging-files-config"]).map(([key, value]) => {
|
|
82
|
-
return `${key}:${value}`;
|
|
83
|
-
});
|
|
84
|
-
commandArgs.push(`--packaging-files-config='${keyValuePairs.join("|")}'`);
|
|
85
|
-
resolvedOptions["packaging-files-config"] = undefined;
|
|
86
|
-
}
|
|
87
|
-
if (resolvedOptions["package-pprint-name"] !== undefined &&
|
|
88
|
-
!resolvedOptions["package-pprint-name"].startsWith('"')) {
|
|
89
|
-
resolvedOptions["package-pprint-name"] = `"${resolvedOptions["package-pprint-name"]}"`;
|
|
90
|
-
}
|
|
91
|
-
for (const [key, value] of Object.entries(resolvedOptions)) {
|
|
92
|
-
commandArgs.push(`--${key}=${value}`);
|
|
93
|
-
}
|
|
94
|
-
if (sdkContext.arm === true) {
|
|
95
|
-
commandArgs.push("--azure-arm=true");
|
|
96
|
-
}
|
|
97
|
-
if (resolvedOptions.flavor === "azure") {
|
|
98
|
-
commandArgs.push("--emit-cross-language-definition-file=true");
|
|
99
|
-
}
|
|
100
|
-
commandArgs.push("--from-typespec=true");
|
|
101
|
-
if (!program.compilerOptions.noEmit && !program.hasError()) {
|
|
102
|
-
execSync(commandArgs.join(" "));
|
|
103
|
-
}
|
|
3
|
+
httpClientPythonOnEmit(context);
|
|
104
4
|
}
|
|
105
5
|
//# sourceMappingURL=emitter.js.map
|
package/dist/src/emitter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"emitter.js","sourceRoot":"","sources":["../../src/emitter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAEjF,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,OAA0C;IACpE,sBAAsB,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/src/index.js
CHANGED
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
pyright==1.1.375
|
|
2
|
+
pylint==3.2.6
|
|
3
|
+
tox==4.16.0
|
|
4
|
+
mypy==1.10.1
|
|
5
|
+
azure-pylint-guidelines-checker==0.0.8
|
|
6
|
+
colorama==0.4.6
|
|
7
|
+
debugpy==1.8.2
|
|
8
|
+
pytest==8.3.2
|
|
9
|
+
coverage==7.6.1
|
|
10
|
+
black==24.8.0
|
|
4
11
|
ptvsd==4.3.2
|
|
5
12
|
types-PyYAML==6.0.12.8
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure-tools/typespec-python",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec emitter for Python SDKs",
|
|
6
6
|
"homepage": "https://github.com/Azure/autorest.python",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist/**",
|
|
31
31
|
"!dist/test/**",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
32
|
+
"scripts/**",
|
|
33
|
+
"generator/**"
|
|
34
34
|
],
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@azure-tools/typespec-azure-core": ">=0.46.0 <1.0.0",
|
|
37
37
|
"@azure-tools/typespec-azure-resource-manager": ">=0.46.0 <1.0.0",
|
|
38
38
|
"@azure-tools/typespec-autorest": ">=0.46.0 <1.0.0",
|
|
39
|
-
"@azure-tools/typespec-client-generator-core": ">=0.46.
|
|
39
|
+
"@azure-tools/typespec-client-generator-core": ">=0.46.2 <1.0.0",
|
|
40
40
|
"@azure-tools/typespec-azure-rulesets": ">=0.46.0 <3.0.0",
|
|
41
41
|
"@typespec/compiler": ">=0.60.0 <1.0.0",
|
|
42
42
|
"@typespec/http": ">=0.60.0 <1.0.0",
|
|
@@ -48,13 +48,15 @@
|
|
|
48
48
|
"js-yaml": "~4.1.0",
|
|
49
49
|
"@typespec/openapi3": "~0.60.0",
|
|
50
50
|
"semver": "~7.6.2",
|
|
51
|
-
"tsx": "4.17.0"
|
|
51
|
+
"tsx": "4.17.0",
|
|
52
|
+
"@typespec/http-client-python": "0.2.0",
|
|
53
|
+
"fs-extra": "~11.2.0"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
54
56
|
"@azure-tools/typespec-azure-resource-manager": "~0.46.0",
|
|
55
57
|
"@azure-tools/typespec-autorest": "~0.46.0",
|
|
56
|
-
"@azure-tools/cadl-ranch-expect": "~0.15.
|
|
57
|
-
"@azure-tools/cadl-ranch-specs": "~0.37.
|
|
58
|
+
"@azure-tools/cadl-ranch-expect": "~0.15.4",
|
|
59
|
+
"@azure-tools/cadl-ranch-specs": "~0.37.2",
|
|
58
60
|
"@types/js-yaml": "~4.0.5",
|
|
59
61
|
"@types/node": "~22.5.4",
|
|
60
62
|
"@types/yargs": "~17.0.33",
|
|
@@ -66,14 +68,15 @@
|
|
|
66
68
|
"typescript": "~5.6.2",
|
|
67
69
|
"typescript-eslint": "^8.5.0",
|
|
68
70
|
"@azure-tools/typespec-azure-core": "~0.46.0",
|
|
69
|
-
"@azure-tools/typespec-client-generator-core": "0.46.
|
|
71
|
+
"@azure-tools/typespec-client-generator-core": "~0.46.2",
|
|
70
72
|
"@typespec/compiler": "~0.60.0",
|
|
71
73
|
"@typespec/http": "~0.60.0",
|
|
72
74
|
"@typespec/rest": "~0.60.0",
|
|
73
75
|
"@typespec/versioning": "~0.60.0",
|
|
74
|
-
"@azure-tools/typespec-azure-rulesets": "0.46.0",
|
|
76
|
+
"@azure-tools/typespec-azure-rulesets": "~0.46.0",
|
|
75
77
|
"yargs": "~17.7.2",
|
|
76
|
-
"chalk": "5.3.0"
|
|
78
|
+
"chalk": "5.3.0",
|
|
79
|
+
"@types/fs-extra": "11.0.4"
|
|
77
80
|
},
|
|
78
81
|
"scripts": {
|
|
79
82
|
"clean": "rimraf ./dist ./temp ./venv ./node_modules",
|
|
@@ -84,6 +87,6 @@
|
|
|
84
87
|
"format": "npx prettier **/*.ts --write && tsx ./scripts/eng/format.ts",
|
|
85
88
|
"install": "tsx ./scripts/run-python3.ts ./scripts/install.py",
|
|
86
89
|
"regenerate": "tsx ./scripts/eng/regenerate.ts",
|
|
87
|
-
"test": "
|
|
90
|
+
"test": "tsx ./scripts/eng/run-tests.ts"
|
|
88
91
|
}
|
|
89
92
|
}
|
|
Binary file
|
package/scripts/eng/lint.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import yargs from "yargs";
|
|
3
3
|
import { hideBin } from "yargs/helpers";
|
|
4
4
|
import { runCommand, executeCommand } from "./utils.js";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import path from "path";
|
|
5
7
|
|
|
6
8
|
interface Arguments {
|
|
7
9
|
folderName: string;
|
|
@@ -40,9 +42,23 @@ const argv = yargs(hideBin(process.argv))
|
|
|
40
42
|
export function pylint() {
|
|
41
43
|
runCommand(`pylint ${argv.folderName}/ --rcfile ./scripts/eng/pylintrc`, "pylint");
|
|
42
44
|
}
|
|
45
|
+
function checkPythonFile(directory: string): boolean {
|
|
46
|
+
const files = fs.readdirSync(directory);
|
|
47
|
+
for (let i = 0; i < files.length; i++) {
|
|
48
|
+
if (path.extname(files[i]) === ".py") {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
43
54
|
|
|
44
55
|
export function mypy() {
|
|
45
|
-
|
|
56
|
+
if (checkPythonFile(argv.folderName)) {
|
|
57
|
+
runCommand(`mypy ${argv.folderName}/ --config-file ./scripts/eng/mypy.ini`, "mypy");
|
|
58
|
+
} else {
|
|
59
|
+
console.log("No python file found in the directory");
|
|
60
|
+
console.log("mypy passed");
|
|
61
|
+
}
|
|
46
62
|
}
|
|
47
63
|
|
|
48
64
|
export function pyright() {
|
package/scripts/eng/pylintrc
CHANGED
|
@@ -15,8 +15,9 @@ enable=useless-suppression
|
|
|
15
15
|
# locally-disabled: Warning locally suppressed using disable-msg
|
|
16
16
|
# cyclic-import: because of https://github.com/PyCQA/pylint/issues/850
|
|
17
17
|
# too-many-arguments: Due to the nature of the CLI many commands have large arguments set which reflect in large arguments set in corresponding methods.
|
|
18
|
+
# too-many-lines: Due to code generation many files end up with too many lines.
|
|
18
19
|
# Let's black deal with bad-continuation
|
|
19
|
-
disable=useless-object-inheritance,missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods,consider-using-f-string,super-with-arguments,redefined-builtin,import-outside-toplevel,client-suffix-needed,unnecessary-dunder-call,unnecessary-ellipsis,disallowed-name,consider-using-max-builtin
|
|
20
|
+
disable=useless-object-inheritance,missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods,consider-using-f-string,super-with-arguments,redefined-builtin,import-outside-toplevel,client-suffix-needed,unnecessary-dunder-call,unnecessary-ellipsis,disallowed-name,consider-using-max-builtin,too-many-lines,parse-error,useless-suppression,unknown-option-value
|
|
20
21
|
|
|
21
22
|
[FORMAT]
|
|
22
23
|
max-line-length=120
|
package/scripts/install.py
CHANGED
|
@@ -42,7 +42,6 @@ def main():
|
|
|
42
42
|
|
|
43
43
|
python_run(venv_context, "pip", ["install", "-U", "pip"])
|
|
44
44
|
python_run(venv_context, "pip", ["install", "-r", f"{_ROOT_DIR}/generator/requirements.txt"])
|
|
45
|
-
python_run(venv_context, "pip", ["install", "-e", f"{_ROOT_DIR}/generator"])
|
|
46
45
|
|
|
47
46
|
|
|
48
47
|
if __name__ == "__main__":
|
package/dist/src/code-model.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { SdkServiceOperation } from "@azure-tools/typespec-client-generator-core";
|
|
2
|
-
import { PythonSdkContext } from "./lib.js";
|
|
3
|
-
export declare function emitCodeModel<TServiceOperation extends SdkServiceOperation>(sdkContext: PythonSdkContext<TServiceOperation>): Record<string, any>;
|
|
4
|
-
//# sourceMappingURL=code-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-model.d.ts","sourceRoot":"","sources":["../../src/code-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAWH,mBAAmB,EAGtB,MAAM,6CAA6C,CAAC;AAIrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAgM5C,wBAAgB,aAAa,CAAC,iBAAiB,SAAS,mBAAmB,EACvE,UAAU,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,uBAuClD"}
|
package/dist/src/code-model.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { UsageFlags, getCrossLanguagePackageId, } from "@azure-tools/typespec-client-generator-core";
|
|
2
|
-
import { KnownTypes, disableGenerationMap, emitEndpointType, getType, simpleTypesMap, typesMap } from "./types.js";
|
|
3
|
-
import { emitParamBase, getImplementation, removeUnderscoresFromNamespace } from "./utils.js";
|
|
4
|
-
import { emitBasicHttpMethod, emitLroHttpMethod, emitLroPagingHttpMethod, emitPagingHttpMethod } from "./http.js";
|
|
5
|
-
import { ignoreDiagnostics } from "@typespec/compiler";
|
|
6
|
-
function emitBasicMethod(context, rootClient, method, operationGroupName) {
|
|
7
|
-
if (method.operation.kind !== "http")
|
|
8
|
-
throw new Error("We only support HTTP operations right now");
|
|
9
|
-
switch (method.operation.kind) {
|
|
10
|
-
case "http":
|
|
11
|
-
return emitBasicHttpMethod(context, rootClient, method, operationGroupName);
|
|
12
|
-
default:
|
|
13
|
-
throw new Error("We only support HTTP operations right now");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function emitLroMethod(context, rootClient, method, operationGroupName) {
|
|
17
|
-
if (method.operation.kind !== "http")
|
|
18
|
-
throw new Error("We only support HTTP operations right now");
|
|
19
|
-
switch (method.operation.kind) {
|
|
20
|
-
case "http":
|
|
21
|
-
return emitLroHttpMethod(context, rootClient, method, operationGroupName);
|
|
22
|
-
default:
|
|
23
|
-
throw new Error("We only support HTTP operations right now");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function emitPagingMethod(context, rootClient, method, operationGroupName) {
|
|
27
|
-
if (method.operation.kind !== "http")
|
|
28
|
-
throw new Error("We only support HTTP operations right now");
|
|
29
|
-
switch (method.operation.kind) {
|
|
30
|
-
case "http":
|
|
31
|
-
return emitPagingHttpMethod(context, rootClient, method, operationGroupName);
|
|
32
|
-
default:
|
|
33
|
-
throw new Error("We only support HTTP operations right now");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function emitLroPagingMethod(context, rootClient, method, operationGroupName) {
|
|
37
|
-
if (method.operation.kind !== "http")
|
|
38
|
-
throw new Error("We only support HTTP operations right now");
|
|
39
|
-
switch (method.operation.kind) {
|
|
40
|
-
case "http":
|
|
41
|
-
return emitLroPagingHttpMethod(context, rootClient, method, operationGroupName);
|
|
42
|
-
default:
|
|
43
|
-
throw new Error("We only support HTTP operations right now");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function emitMethodParameter(context, parameter) {
|
|
47
|
-
if (parameter.kind === "endpoint") {
|
|
48
|
-
if (parameter.type.kind === "union") {
|
|
49
|
-
for (const endpointVal of parameter.type.variantTypes) {
|
|
50
|
-
return emitEndpointType(context, endpointVal);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return emitEndpointType(context, parameter.type);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const base = {
|
|
58
|
-
...emitParamBase(context, parameter),
|
|
59
|
-
implementation: getImplementation(context, parameter),
|
|
60
|
-
clientDefaultValue: parameter.clientDefaultValue,
|
|
61
|
-
location: parameter.kind,
|
|
62
|
-
};
|
|
63
|
-
if (parameter.isApiVersionParam) {
|
|
64
|
-
return [
|
|
65
|
-
{
|
|
66
|
-
...base,
|
|
67
|
-
location: "query",
|
|
68
|
-
wireName: "api-version",
|
|
69
|
-
in_docstring: false,
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
}
|
|
73
|
-
return [base];
|
|
74
|
-
}
|
|
75
|
-
function emitMethod(context, rootClient, method, operationGroupName) {
|
|
76
|
-
switch (method.kind) {
|
|
77
|
-
case "basic":
|
|
78
|
-
return emitBasicMethod(context, rootClient, method, operationGroupName);
|
|
79
|
-
case "lro":
|
|
80
|
-
return emitLroMethod(context, rootClient, method, operationGroupName);
|
|
81
|
-
case "paging":
|
|
82
|
-
return emitPagingMethod(context, rootClient, method, operationGroupName);
|
|
83
|
-
default:
|
|
84
|
-
return emitLroPagingMethod(context, rootClient, method, operationGroupName);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function emitOperationGroups(context, client, rootClient, prefix) {
|
|
88
|
-
const operationGroups = [];
|
|
89
|
-
for (const method of client.methods) {
|
|
90
|
-
if (method.kind === "clientaccessor") {
|
|
91
|
-
const operationGroup = method.response;
|
|
92
|
-
const name = `${prefix}${operationGroup.name}`;
|
|
93
|
-
let operations = [];
|
|
94
|
-
for (const method of operationGroup.methods) {
|
|
95
|
-
if (method.kind === "clientaccessor")
|
|
96
|
-
continue;
|
|
97
|
-
operations = operations.concat(emitMethod(context, rootClient, method, name));
|
|
98
|
-
}
|
|
99
|
-
operationGroups.push({
|
|
100
|
-
name: name,
|
|
101
|
-
className: name,
|
|
102
|
-
propertyName: operationGroup.name,
|
|
103
|
-
operations: operations,
|
|
104
|
-
operationGroups: emitOperationGroups(context, operationGroup, rootClient, name),
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// root client should deal with mixin operation group
|
|
109
|
-
if (prefix === "") {
|
|
110
|
-
let operations = [];
|
|
111
|
-
for (const method of client.methods) {
|
|
112
|
-
if (method.kind === "clientaccessor")
|
|
113
|
-
continue;
|
|
114
|
-
operations = operations.concat(emitMethod(context, rootClient, method, ""));
|
|
115
|
-
}
|
|
116
|
-
if (operations.length > 0) {
|
|
117
|
-
operationGroups.push({
|
|
118
|
-
name: "",
|
|
119
|
-
className: "",
|
|
120
|
-
propertyName: "",
|
|
121
|
-
operations: operations,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return operationGroups.length > 0 ? operationGroups : undefined;
|
|
126
|
-
}
|
|
127
|
-
function emitClient(context, client) {
|
|
128
|
-
if (client.initialization) {
|
|
129
|
-
context.__endpointPathParameters = [];
|
|
130
|
-
}
|
|
131
|
-
const parameters = client.initialization?.properties.map((x) => emitMethodParameter(context, x)).reduce((a, b) => [...a, ...b]) ??
|
|
132
|
-
[];
|
|
133
|
-
const endpointParameter = client.initialization?.properties.find((x) => x.kind === "endpoint");
|
|
134
|
-
const operationGroups = emitOperationGroups(context, client, client, "");
|
|
135
|
-
let url;
|
|
136
|
-
if (endpointParameter?.type.kind === "union") {
|
|
137
|
-
url = endpointParameter.type.variantTypes[0].serverUrl;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
url = endpointParameter?.type.serverUrl;
|
|
141
|
-
}
|
|
142
|
-
return {
|
|
143
|
-
name: client.name,
|
|
144
|
-
description: client.description ?? "",
|
|
145
|
-
parameters,
|
|
146
|
-
operationGroups,
|
|
147
|
-
url,
|
|
148
|
-
apiVersions: client.apiVersions,
|
|
149
|
-
arm: context.arm,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
export function emitCodeModel(sdkContext) {
|
|
153
|
-
// Get types
|
|
154
|
-
const sdkPackage = sdkContext.sdkPackage;
|
|
155
|
-
const codeModel = {
|
|
156
|
-
namespace: removeUnderscoresFromNamespace(sdkPackage.rootNamespace).toLowerCase(),
|
|
157
|
-
clients: [],
|
|
158
|
-
subnamespaceToClients: {},
|
|
159
|
-
};
|
|
160
|
-
for (const client of sdkPackage.clients) {
|
|
161
|
-
codeModel["clients"].push(emitClient(sdkContext, client));
|
|
162
|
-
if (client.nameSpace === sdkPackage.rootNamespace) {
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
codeModel["subnamespaceToClients"][client.nameSpace] = emitClient(sdkContext, client);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
// loop through models and enums since there may be some orphaned models needs to be generated
|
|
169
|
-
for (const model of sdkPackage.models) {
|
|
170
|
-
if (model.name === "" ||
|
|
171
|
-
((model.usage & UsageFlags.Spread) > 0 &&
|
|
172
|
-
(model.usage & UsageFlags.Input) === 0 &&
|
|
173
|
-
(model.usage & UsageFlags.Output) === 0)) {
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
if (!disableGenerationMap.has(model)) {
|
|
177
|
-
getType(sdkContext, model);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
for (const sdkEnum of sdkPackage.enums) {
|
|
181
|
-
if (sdkEnum.usage === UsageFlags.ApiVersionEnum) {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
getType(sdkContext, sdkEnum);
|
|
185
|
-
}
|
|
186
|
-
codeModel["types"] = [...typesMap.values(), ...Object.values(KnownTypes), ...simpleTypesMap.values()];
|
|
187
|
-
codeModel["crossLanguagePackageId"] = ignoreDiagnostics(getCrossLanguagePackageId(sdkContext));
|
|
188
|
-
return codeModel;
|
|
189
|
-
}
|
|
190
|
-
//# sourceMappingURL=code-model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-model.js","sourceRoot":"","sources":["../../src/code-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAYH,UAAU,EACV,yBAAyB,GAC5B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnH,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAElH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,SAAS,eAAe,CACpB,OAA4C,EAC5C,UAA4C,EAC5C,MAAgD,EAChD,kBAA0B;IAE1B,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,KAAK,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACnG,QAAQ,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAC5B,KAAK,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QAC1F,CAAC;IACL,CAAC;IACD,8FAA8F;IAC9F,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QACpC,IACI,KAAK,CAAC,IAAI,KAAK,EAAE;YACjB,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC;gBAClC,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC;gBACtC,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAC9C,CAAC;YACC,SAAS;QACb,CAAC;QACD,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,KAAK,KAAK,UAAU,CAAC,cAAc,EAAE,CAAC;YAC9C,SAAS;QACb,CAAC;QACD,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IACD,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC;IACtG,SAAS,CAAC,wBAAwB,CAAC,GAAG,iBAAiB,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/F,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ChildProcess, SpawnOptions } from "child_process";
|
|
2
|
-
export declare function createTempPath(extension: string, prefix?: string): string;
|
|
3
|
-
/**
|
|
4
|
-
* Save the given codemodel in a yaml file.
|
|
5
|
-
* @param name Name of the codemodel. To give a guide to the temp file name.
|
|
6
|
-
* @param codemodel Codemodel to save
|
|
7
|
-
* @return the absolute path to the created codemodel.
|
|
8
|
-
*/
|
|
9
|
-
export declare function saveCodeModelAsYaml(name: string, codemodel: unknown): Promise<string>;
|
|
10
|
-
/**
|
|
11
|
-
* Start external process async
|
|
12
|
-
* @param command Command to run. This is the just the executable path or name.
|
|
13
|
-
* @param args Command arguments.
|
|
14
|
-
* @param options Options
|
|
15
|
-
*/
|
|
16
|
-
export declare function execAsync(command: string, args: string[], options?: SpawnOptions): Promise<{
|
|
17
|
-
exitCode: number;
|
|
18
|
-
proc: ChildProcess;
|
|
19
|
-
}>;
|
|
20
|
-
//# sourceMappingURL=external-process.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"external-process.d.ts","sourceRoot":"","sources":["../../src/external-process.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAS,YAAY,EAAE,MAAM,eAAe,CAAC;AAQlE,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAW,UAEpE;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAM3F;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,YAAiB,GAC3B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC,CAcnD"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { joinPaths } from "@typespec/compiler";
|
|
2
|
-
import { spawn } from "child_process";
|
|
3
|
-
import { randomUUID } from "crypto";
|
|
4
|
-
import { mkdir, writeFile } from "fs/promises";
|
|
5
|
-
import jsyaml from "js-yaml";
|
|
6
|
-
import os from "os";
|
|
7
|
-
const cadlCodeGenTempDir = joinPaths(os.tmpdir(), "cadl-codegen");
|
|
8
|
-
export function createTempPath(extension, prefix = "") {
|
|
9
|
-
return joinPaths(cadlCodeGenTempDir, prefix + randomUUID() + extension);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Save the given codemodel in a yaml file.
|
|
13
|
-
* @param name Name of the codemodel. To give a guide to the temp file name.
|
|
14
|
-
* @param codemodel Codemodel to save
|
|
15
|
-
* @return the absolute path to the created codemodel.
|
|
16
|
-
*/
|
|
17
|
-
export async function saveCodeModelAsYaml(name, codemodel) {
|
|
18
|
-
await mkdir(cadlCodeGenTempDir, { recursive: true });
|
|
19
|
-
const filename = createTempPath(".yaml", name);
|
|
20
|
-
const yamlStr = jsyaml.dump(codemodel);
|
|
21
|
-
await writeFile(filename, yamlStr);
|
|
22
|
-
return filename;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Start external process async
|
|
26
|
-
* @param command Command to run. This is the just the executable path or name.
|
|
27
|
-
* @param args Command arguments.
|
|
28
|
-
* @param options Options
|
|
29
|
-
*/
|
|
30
|
-
export async function execAsync(command, args, options = {}) {
|
|
31
|
-
const child = spawn(command, args, { stdio: "inherit", ...options });
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
child.on("error", (error) => {
|
|
34
|
-
reject(error);
|
|
35
|
-
});
|
|
36
|
-
child.on("exit", (exitCode) => {
|
|
37
|
-
resolve({
|
|
38
|
-
exitCode: exitCode ?? -1,
|
|
39
|
-
proc: child,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=external-process.js.map
|