{"size": 904, "ext": "js", "max_stars_repo_path": "scripts/test-studio/init-vars.js", "max_stars_repo_name": "sanctuarycomputer/sanity-graph-import", "max_stars_repo_stars_event_min_datetime": "2021-01-26T21:14:26.000Z", "max_stars_repo_stars_event_max_datetime": "2021-07-20T13:32:53.000Z", "max_issues_repo_path": "scripts/test-studio/init-vars.js", "max_issues_repo_name": "sanctuarycomputer/sanity-graph-import", "max_issues_repo_issues_event_min_datetime": "2021-01-26T19:23:44.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-18T16:47:42.000Z", "max_forks_repo_path": "scripts/test-studio/init-vars.js", "max_forks_repo_name": "sanctuarycomputer/sanity-graph-import", "max_forks_repo_forks_event_min_datetime": "2021-05-21T10:40:15.000Z", "max_forks_repo_forks_event_max_datetime": "2021-05-21T10:40:15.000Z"}
{"max_stars_count": 22, "max_issues_count": 15, "max_forks_count": 1, "avg_line_length": 20.5454545455, "max_line_length": 62, "alphanum_fraction": 0.7201327434}
const fs = require('fs')
const path = require('path')

const configPath = path.resolve(
  __dirname,
  '..',
  '..',
  'test-studio',
  'sanity.json'
)
const sanityConfig = require(configPath)

const dotenvPath = path.resolve(__dirname, '..', '..', '.env')

const projectId = sanityConfig.api.projectId
const sourceDataset = sanityConfig.api.dataset

const updatedSanityConfig = {
  ...sanityConfig,
  env: {
    ...sanityConfig.env,
    development: {
      dataset: 'staging',
      ...sanityConfig.env.development,
    },
  },
}

fs.writeFileSync(
  configPath,
  JSON.stringify(updatedSanityConfig, null, 2),
  'utf8'
)

const envContents = `
TEST_STUDIO_SOURCE_PROJECTID=${projectId}
TEST_STUDIO_SOURCE_DATASET=${sourceDataset}
TEST_STUDIO_TARGET_PROJECTID=${projectId}
TEST_STUDIO_TARGET_DATASET=staging
TEST_STUDIO_TARGET_TOKEN=your-token-here
`

fs.writeFileSync(dotenvPath, envContents, 'utf8')
