in eng/sdk/sync_sdk.py [0:0]
def update_emitter(package_json_path: str, use_dev_package: bool):
if use_dev_package:
# we cannot use "tsp-client generate-config-files" in dev mode, as this command also updates the lock file
logging.info("Update emitter-package.json")
subprocess.check_call(
[
"pwsh",
"./eng/common/scripts/typespec/New-EmitterPackageJson.ps1",
"-PackageJsonPath",
package_json_path,
"-OutputDirectory",
"eng",
],
cwd=sdk_root,
)
# replace version with path to dev package
dev_package_path = None
typespec_extension_path = os.path.dirname(package_json_path)
for file in os.listdir(typespec_extension_path):
if file.endswith(".tgz"):
dev_package_path = os.path.abspath(os.path.join(typespec_extension_path, file))
logging.info(f'Found dev package at "{dev_package_path}"')
break
if dev_package_path:
emitter_package_path = os.path.join(sdk_root, "eng", "emitter-package.json")
with open(emitter_package_path, "r") as json_file:
package_json = json.load(json_file)
package_json["dependencies"]["@azure-tools/typespec-java"] = dev_package_path
with open(emitter_package_path, "w") as json_file:
logging.info(f'Update emitter-package.json to use typespec-java from "{dev_package_path}"')
json.dump(package_json, json_file, indent=2)
else:
logging.error("Failed to locate the dev package.")
logging.info("Update emitter-package-lock.json")
subprocess.check_call(["tsp-client", "generate-lock-file"], cwd=sdk_root)
else:
logging.info("Update emitter-package.json and emitter-package-lock.json")
subprocess.check_call(
["tsp-client", "generate-config-files", "--package-json", package_json_path], cwd=sdk_root
)