def _init_scratch_org(self, org_config):
if not org_config.scratch:
# Only run against scratch orgs
return
# Set up the logger to output to the build.log field
init_logger(self.build)
# Create the scratch org and get its info
info = org_config.scratch_info
# Get the contents of the org's json file from Salesforce DX
json_path = os.path.join(os.path.expanduser('~'), '.sfdx', info['username'] + '.json')
if not os.path.isfile(json_path):
json_path = os.path.join(os.path.expanduser('~'), '.local', '.sfdx', info['username'] + '.json')
with open(json_path, 'r') as json_file:
dx_json = json_file.read()
org_json = json.dumps(org_config.config, cls=DjangoJSONEncoder)
# Create a ScratchOrgInstance to store the org info
instance = ScratchOrgInstance(
org=org_config.org,
build=self.build,
sf_org_id=info['org_id'],
username=info['username'],
json_dx=dx_json,
json=org_json,
)
instance.save()
org_config.org_instance = instance
return org_config
评论列表
文章目录